commit 0748aaf9e29e4a4bc7bc4c5cf5e7ee7cee339b8b Author: Scott Duensing Date: Mon May 16 17:59:47 2022 -0500 Initial commit of new GUI code. diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c31db78 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +*.fnt filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.gif filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e388045 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +bin/ +obj/ +build-*/ +installed/ +thirdparty/jpeg-9e/.deps/ +thirdparty/libpng-1.6.37/.deps/ + +*~ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4414ed9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,26 @@ + +Third Party Library Licenses: + + +GRX +--- +http://grx.gnu.de/index.html +Lib: LGPL with DOS binary exception / Fonts: MIT + + +JPEG +---- +https://ijg.org/ +"As-Is" + + +PNG +--- +http://www.libpng.org/pub/png/libpng.html +PNG Reference Library License v2 ("As-Is") + + +ZLIB +---- +https://www.zlib.net/ +"As-Is" diff --git a/Makefile.djgpp b/Makefile.djgpp new file mode 100644 index 0000000..627db83 --- /dev/null +++ b/Makefile.djgpp @@ -0,0 +1,123 @@ +# +# Kangaroo Punch MultiPlayer Game Server Mark II +# Copyright (C) 2020-2021 Scott Duensing +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# General +CC = gcc +LD = gcc +RM = rm -f +RMDIR = rm -rf +INSTALL = install +DEBUG = -g + +## CHANGE THIS ## +TARGET = client +SRCDIR = . +OBJDIR = obj +BINDIR = bin +## CHANGE THIS ## + +# CFLAGS, LDFLAGS, CPPFLAGS, PREFIX can be overriden on CLI +CFLAGS := $(DEBUG) +CFLAGS += -I$(SRCDIR)/installed/dos/include -I$(SRCDIR)/client/src +CPPFLAGS := +LDFLAGS := -L$(SRCDIR)/installed/dos/lib +LDLIBS := -lgrx20 -ljpeg -lpng -lz +PREFIX := +TARGET_ARCH := + + +# Compiler Flags +ALL_CFLAGS := $(CFLAGS) +ALL_CFLAGS += -Wall -Ofast +#ALL_CFLAGS += -Wall -O0 -pg + +# Preprocessor Flags +ALL_CPPFLAGS := $(CPPFLAGS) + +# Linker Flags +ALL_LDFLAGS := $(LDFLAGS) +ALL_LDLIBS := $(LDLIBS) -lc + + +# Source, Binaries, Dependencies +SRC := $(shell find $(SRCDIR)/client -type f -name '*.c') +OBJ := $(patsubst $(SRCDIR)/%,$(OBJDIR)/%,$(SRC:.c=.o)) +DEP := $(OBJ:.o=.d) +BIN := $(BINDIR)/$(TARGET) +-include $(DEP) + +#$(info [${SRC}]) +#$(info [${OBJ}]) + + +# Verbosity Control, ala automake +V = 0 + +# Verbosity for CC +REAL_CC := $(CC) +CC_0 = @echo "CC $<"; $(REAL_CC) +CC_1 = $(REAL_CC) +CC = $(CC_$(V)) + +# Verbosity for LD +REAL_LD := $(LD) +LD_0 = @echo "LD $@"; $(REAL_LD) +LD_1 = $(REAL_LD) +LD = $(LD_$(V)) + +# Verbosity for RM +REAL_RM := $(RM) +RM_0 = @echo "Cleaning..."; $(REAL_RM) +RM_1 = $(REAL_RM) +RM = $(RM_$(V)) + +# Verbosity for RMDIR +REAL_RMDIR := $(RMDIR) +RMDIR_0 = @$(REAL_RMDIR) +RMDIR_1 = $(REAL_RMDIR) +RMDIR = $(RMDIR_$(V)) + + + +# Build Rules +.PHONY: clean +.DEFAULT_GOAL := all + +all: setup $(BIN) +setup: dir +remake: clean all + +dir: + @mkdir -p $(OBJDIR) + @mkdir -p $(BINDIR) + + +$(BIN): $(OBJ) + $(LD) $(ALL_LDFLAGS) $^ $(ALL_LDLIBS) -o $@ + +$(OBJDIR)/%.o: $(SRCDIR)/%.c + $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -c -MMD -MP -o $@ $< + + +install: $(BIN) + $(INSTALL) -d $(PREFIX)/bin + $(INSTALL) $(BIN) $(PREFIX)/bin + +clean: + $(RM) $(OBJ) $(DEP) $(BIN) + $(RMDIR) $(OBJDIR) $(BINDIR) 2> /dev/null; true diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..cd2d62e --- /dev/null +++ b/build.sh @@ -0,0 +1,32 @@ +#!/bin/bash -e + +# +# Kangaroo Punch MultiPlayer Game Server Mark II +# Copyright (C) 2020-2021 Scott Duensing +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# This requires DJGPP for Linux in /opt/cross/djgpp +# +# See: https://github.com/andrewwutw/build-djgpp + +mkdir -p \ + obj/client/src + +source /opt/cross/djgpp/setenv + +make -f Makefile.djgpp + +rm bin/client diff --git a/buildPrerequisites.sh b/buildPrerequisites.sh new file mode 100755 index 0000000..e7be748 --- /dev/null +++ b/buildPrerequisites.sh @@ -0,0 +1,123 @@ +#!/bin/bash -x + + +export BUILD_HOME=$(pwd) +export INSTALLED=${BUILD_HOME}/installed +export DJGPP=/opt/cross/djgpp + + +function buildGrx() { + + pushd grx249 + cp -f ${BUILD_HOME}/makedefs.grx . + + make -f makefile.dj2 clean + make -f makefile.dj2 libs \ + CROSS_PLATFORM="${DJGPP}/bin/i586-pc-msdosdjgpp-" \ + C_FLAGS="-I${INSTALLED}/dos/include" \ + L_FLAGS="-L${INSTALLED}/dos/lib" + cp -p -f lib/dj2/*.a ${INSTALLED}/dos/lib + cp -p -f include/*.h ${INSTALLED}/dos/include + make -f makefile.dj2 clean + rm lib/dj2/lib* + rm bin/*.exe + + make -f makefile.x11 clean + make -f makefile.x11 libs \ + C_FLAGS="-I${INSTALLED}/linux/include" \ + L_FLAGS="-L${INSTALLED}/linux/lib" + cp -p -f lib/unix/*.a ${INSTALLED}/linux/lib + cp -p -f include/*.h ${INSTALLED}/linux/include + make -f makefile.x11 clean + rm lib/unix/lib* + rm bin/{bin2c,fnt2c,xmodetest} + + popd +} + + +function buildJpeg() { + pushd jpeg-9e + + ( + source ${DJGPP}/setenv + sed -i 's/RM= del/RM= rm/g' makefile.dj + cp -f jconfig.dj jconfig.h + make -i -f makefile.dj clean + make -i -f makefile.dj libjpeg.a + cp -p -f *.a ${INSTALLED}/dos/lib + cp -p -f *.h ${INSTALLED}/dos/include + make -i -f makefile.dj clean + ) + + ./configure --prefix=${INSTALLED}/linux --disable-shared + make clean + make + make install + make clean + + popd +} + + +function buildPng() { + pushd libpng-1.6.37 + + ( + source ${DJGPP}/setenv + cp scripts/makefile.dj2 . + sed -i "s#\-I\.\./zlib#\-I${INSTALLED}/dos/include \-DPNG_NO_CONSOLE_IO#g" makefile.dj2 + sed -i "s#\-L\.\./zlib/#\-L${INSTALLED}/dos/lib#g" makefile.dj2 + make -f makefile.dj2 clean + make -f makefile.dj2 libpng.a + cp -p -f *.a ${INSTALLED}/dos/lib + cp -p -f *.h ${INSTALLED}/dos/include + make -f makefile.dj2 clean + ) + + make clean + cp scripts/makefile.linux . + make -f makefile.linux clean + make -f makefile.linux libpng.a + cp -p -f *.a ${INSTALLED}/linux/lib + cp -p -f *.h ${INSTALLED}/linux/include + make -f makefile.linux clean + + popd +} + + +function buildZlib() { + pushd zlib-1.2.12 + + ( + source ${DJGPP}/setenv + make clean + ./configure --prefix=${INSTALLED}/dos + make + make install + make clean + rm *.exe + ) + + make clean + ./configure --prefix=${INSTALLED}/linux --static + make + make install + make clean + + popd +} + + +mkdir -p ${INSTALLED}/dos/{include,lib,share} +mkdir -p ${INSTALLED}/linux/{include,lib,share} + +pushd thirdparty + +buildZlib +buildPng +buildJpeg +buildGrx + +popd diff --git a/client/client.pro b/client/client.pro new file mode 100644 index 0000000..71eeb76 --- /dev/null +++ b/client/client.pro @@ -0,0 +1,42 @@ +TEMPLATE = app +CONFIG -= app_bundle +CONFIG -= qt +CONFIG -= console +CONFIG += c99 + +LINUX = $$PWD/../installed/linux +SHARED = $$PWD/../shared + +DESTDIR = $$OUT_PWD/bin + +INCLUDEPATH += \ + $$PWD/src \ + $$LINUX/include \ + $$SHARED + +HEADERS += \ + $$SHARED/macros.h \ + ../shared/array.h \ + ../shared/memory.h \ + ../shared/stddclmr.h \ + ../shared/thirdparty/memwatch/memwatch.h \ + ../shared/thirdparty/stb_ds.h \ + src/gui/gui.h \ + src/gui/wmwindow.h \ + src/os.h + +SOURCES += \ + ../shared/array.c \ + ../shared/memory.c \ + ../shared/thirdparty/memwatch/memwatch.c \ + src/gui/gui.c \ + src/gui/wmwindow.c \ + src/main.c + +LIBS += \ + -L$$LINUX/lib \ + -lgrx20X \ + -lX11 \ + -ljpeg \ + -lpng \ + -lz diff --git a/client/client.pro.user b/client/client.pro.user new file mode 100644 index 0000000..456ecd5 --- /dev/null +++ b/client/client.pro.user @@ -0,0 +1,231 @@ + + + + + + EnvironmentId + {b66758f8-0b3c-4017-8297-d2a3cceca9ca} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + true + true + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 5.15.0 GCC 64bit + Desktop Qt 5.15.0 GCC 64bit + qt.qt5.5150.gcc_64_kit + 0 + 0 + 0 + + 0 + /home/scott/code/gui/build-client-Desktop_Qt_5_15_0_GCC_64bit-Debug + /home/scott/code/gui/build-client-Desktop_Qt_5_15_0_GCC_64bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/scott/code/gui/build-client-Desktop_Qt_5_15_0_GCC_64bit-Release + /home/scott/code/gui/build-client-Desktop_Qt_5_15_0_GCC_64bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + /home/scott/code/gui/build-client-Desktop_Qt_5_15_0_GCC_64bit-Profile + /home/scott/code/gui/build-client-Desktop_Qt_5_15_0_GCC_64bit-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/client/src/gui/gui.c b/client/src/gui/gui.c new file mode 100644 index 0000000..7e95866 --- /dev/null +++ b/client/src/gui/gui.c @@ -0,0 +1,123 @@ +#include "gui.h" +#include "wmwindow.h" +#include "array.h" + + +typedef struct VideoModeS { + int width; + int height; + int depth; +} VideoModeT; + +typedef struct WidgetCatalogS { + uint8_t key; // Magic + RegisterT *value; +} WidgetCatalogT; + + +GrColor *__guiBaseColors = NULL; + + +static uint8_t _magicCount = 0; +static WidgetCatalogT *_widgetCatalog = NULL; +static uint8_t _guiRunning = 1; + + +void guiModesShow(void) { + VideoModeT mode[256]; + int32_t modeCount = 0; + int32_t i; + GrFrameMode fm; + const GrVideoMode *mp; + + GrSetDriver(NULL); + if (GrCurrentVideoDriver() == NULL) { + printf("No graphics driver found!\n"); + return; + } + + for (fm=GR_firstGraphicsFrameMode; fm<=GR_lastGraphicsFrameMode; fm++) { + mp = GrFirstVideoMode(fm); + while (mp != NULL) { + if (mp->width >= 640 && mp->height >= 480 && mp->bpp >= 8) { + mode[modeCount].width = mp->width; + mode[modeCount].height = mp->height; + mode[modeCount].depth = mp->bpp; + modeCount++; + } + mp = GrNextVideoMode(mp); + } + } + + GrSetMode(GR_default_text); + + printf("Available graphics modes:\n\n"); + for (i=0; i 0) { + if (_widgetCatalog[0].value->unregister) _widgetCatalog[0].value->unregister(NULL); + hmdel(_widgetCatalog, _widgetCatalog[0].key); + } + hmfree(_widgetCatalog); + + DEL(__guiBaseColors); + + GrSetMode(GR_default_text); +} + + +void guiStartup(int16_t width, int16_t height, int16_t depth) { + if (!GrSetMode(GR_width_height_bpp_graphics, width, height, depth)) { + //***TODO*** Die + } + + GrSetRGBcolorMode(); + __guiBaseColors = GrAllocEgaColors(); + + wmStartup(); + + guiRegister(windowRegister); +} + + +void guiStop(void) { + _guiRunning = 0; +} + + +void guiWidgetBaseSet(WidgetT *widget, uint8_t magic, uint16_t x, uint16_t y, uint16_t w, uint16_t h) { + widget->magic = magic; + + widget->r.x = x; + widget->r.y = y; + widget->r.w = w; + widget->r.h = h; + + widget->reg = hmget(_widgetCatalog, magic); +} diff --git a/client/src/gui/gui.h b/client/src/gui/gui.h new file mode 100644 index 0000000..ae596c0 --- /dev/null +++ b/client/src/gui/gui.h @@ -0,0 +1,75 @@ +#ifndef GUI_H +#define GUI_H + + +#include "grx20.h" +#include "grxkeys.h" + +#include "os.h" + + +struct WidgetS; + +typedef void (*GuiCallbackT)(void *data, ...); +typedef void (*WidgetEventT)(struct WidgetS *widget, ...); + +typedef struct RectS { + uint16_t x; + uint16_t y; + union { + uint16_t w; + uint16_t x2; + }; + union { + uint16_t h; + uint16_t y2; + }; +} RectT; + +typedef struct RegisterS { + char *widgetName; + WidgetEventT paint; + WidgetEventT destroy; + GuiCallbackT unregister; +} RegisterT; + +typedef struct WidgetS { + uint8_t magic; + RectT r; + RegisterT *reg; +} WidgetT; + +typedef RegisterT *(*WidgetRegisterT)(uint8_t); + + +extern GrColor *__guiBaseColors; + + +#define GUI_BLACK __guiBaseColors[0] +#define GUI_BLUE __guiBaseColors[1] +#define GUI_GREEN __guiBaseColors[2] +#define GUI_CYAN __guiBaseColors[3] +#define GUI_RED __guiBaseColors[4] +#define GUI_MAGENTA __guiBaseColors[5] +#define GUI_BROWN __guiBaseColors[6] +#define GUI_LIGHTGRAY __guiBaseColors[7] +#define GUI_DARKGRAY __guiBaseColors[8] +#define GUI_LIGHTBLUE __guiBaseColors[9] +#define GUI_LIGHTGREEN __guiBaseColors[10] +#define GUI_LIGHTCYAN __guiBaseColors[11] +#define GUI_LIGHTRED __guiBaseColors[12] +#define GUI_LIGHTMAGENTA __guiBaseColors[13] +#define GUI_YELLOW __guiBaseColors[14] +#define GUI_WHITE __guiBaseColors[15] + + +void guiModesShow(void); +void guiRegister(WidgetRegisterT widgetRegister); +void guiRun(void); +void guiShutdown(void); +void guiStartup(int16_t width, int16_t height, int16_t depth); +void guiStop(void); +void guiWidgetBaseSet(WidgetT *widget, uint8_t magic, uint16_t x, uint16_t y, uint16_t w, uint16_t h); + + +#endif // GUI_H diff --git a/client/src/gui/wmwindow.c b/client/src/gui/wmwindow.c new file mode 100644 index 0000000..0202eb3 --- /dev/null +++ b/client/src/gui/wmwindow.c @@ -0,0 +1,261 @@ +#include "wmwindow.h" +#include "array.h" + + +uint8_t __MAGIC_WINDOW = 0; + +static WindowT **_windowList = NULL; +static GrTextOption _textOption; + + +WindowT *windowCreate(uint16_t x, uint16_t y, uint16_t w, uint16_t h, char *title, uint8_t flags, ...) { + WindowT *win = NULL; + + NEW(WindowT, win); + + guiWidgetBaseSet((WidgetT *)win, __MAGIC_WINDOW, x, y, w, h); + win->title = strdup(title); + win->flags = flags; + + arrput(_windowList, win); + + return win; +} + + +void windowDestroy(struct WidgetS *widget, ...) { + uint16_t i; + WindowT *window = (WindowT *)widget; + + for (i=0; ititle) DEL(_windowList[i]->title); + DEL(_windowList[i]); + arrdel(_windowList, i); + break; + } + } +} + + +void windowPaint(struct WidgetS *widget, ...) { + WindowT *w = (WindowT *)widget; + uint16_t x1 = w->base.r.x; + uint16_t y1 = w->base.r.y; + uint16_t x2 = w->base.r.x + w->base.r.w - 1; + uint16_t y2 = w->base.r.y + w->base.r.h - 1; + uint16_t tx1; + uint16_t ty1; + uint16_t tx2; + uint16_t ty2; + uint16_t minimizeOffset = 0; + GrColor titleBackgroundColor = GUI_DARKGRAY; + + // Fake Window contents. + GrFilledBox(x1, y1, x2, y2, GUI_BLACK); + + // If we need a titlebar, it's 18px. + if (w->title || w->flags & WIN_CLOSE || w->flags & WIN_MAXIMIZE || w->flags & WIN_MINIMIZE) { + + // Draw title bar background. + y1 -= 18; + GrFilledBox(x1, y1, x2, y1 + 17, titleBackgroundColor); + + // Close box? + if (w->flags & WIN_CLOSE) { + // 26px wide, 18 tall including highlight and shadow. + w->close.x = x1 + 1; + w->close.y = y1 + 1; + w->close.x2 = w->close.x + 24; + w->close.y2 = w->close.y + 15; + GrFilledBox(w->close.x + 1, w->close.y + 1, w->close.x2 - 1, w->close.y2 - 1, GUI_LIGHTGRAY); + GrHLine(w->close.x, w->close.x2, w->close.y, GUI_WHITE); + GrVLine(w->close.x, w->close.y, w->close.y2, GUI_WHITE); + // Button is 8px down, 3px tall, and 4px in on both sides. + tx1 = w->close.x + 4; + ty1 = w->close.y + 7; + tx2 = w->close.x2 - 4; + ty2 = w->close.y + 9; + GrHLine(tx1, tx2, ty1, GUI_WHITE); + GrPlot(tx1, ty1 + 1, GUI_WHITE); + GrHLine(tx1, tx2, ty2, GUI_BLACK); + GrVLine(tx2, ty1, ty2, GUI_BLACK); + // Set titlebar area. + w->titlebar.x = w->close.x2 + 2; + } else { + // No close box. + w->close.x = 0; + w->close.y = 0; + w->close.x2 = 0; + w->close.y2 = 0; + // Set titlebar area. + w->titlebar.x = x1; + } + w->titlebar.y = y1; + w->titlebar.x2 = x2; + w->titlebar.y2 = y1 + 17; + + // Maximize box? + if (w->flags & WIN_MAXIMIZE) { + // 26px wide, 18 tall including highlight and shadow. + w->maximize.y = y1 + 1; + w->maximize.x2 = x2 - 1; + w->maximize.x = w->maximize.x2 - 24; + w->maximize.y2 = w->maximize.y + 15; + GrFilledBox(w->maximize.x + 1, w->maximize.y + 1, w->maximize.x2 - 1, w->maximize.y2 - 1, GUI_LIGHTGRAY); + GrHLine(w->maximize.x, w->maximize.x2, w->maximize.y, GUI_WHITE); + GrVLine(w->maximize.x, w->maximize.y, w->maximize.y2, GUI_WHITE); + // Button is 3px down, and 4px in on both sides. + tx1 = w->maximize.x + 4; + ty1 = w->maximize.y + 4; + tx2 = w->maximize.x2 - 3; + ty2 = w->maximize.y + 12; + GrHLine(tx1, tx2, ty1, GUI_WHITE); + GrVLine(tx1, ty1, ty2, GUI_WHITE); + GrHLine(tx1, tx2, ty2, GUI_BLACK); + GrVLine(tx2, ty1, ty2, GUI_BLACK); + // Move minimize button over. + minimizeOffset = 26; + // Set titlebar area. + w->titlebar.x2 -= 26; + } else { + // No maximize box. + w->maximize.x = 0; + w->maximize.y = 0; + w->maximize.x2 = 0; + w->maximize.y2 = 0; + } + + // Minimize box? + if (w->flags & WIN_MINIMIZE) { + // 26px wide, 18 tall including highlight and shadow. + w->minimize.y = y1 + 1; + w->minimize.x2 = x2 - 1 - minimizeOffset; + w->minimize.x = w->minimize.x2 - 24; + w->minimize.y2 = w->minimize.y + 15; + GrFilledBox(w->minimize.x + 1, w->minimize.y + 1, w->minimize.x2 - 1, w->minimize.y2 - 1, GUI_LIGHTGRAY); + GrHLine(w->minimize.x, w->minimize.x2, w->minimize.y, GUI_WHITE); + GrVLine(w->minimize.x, w->minimize.y, w->minimize.y2, GUI_WHITE); + tx1 = w->minimize.x + 10; + ty1 = w->minimize.y + 6; + tx2 = w->minimize.x2 - 8; + ty2 = w->minimize.y + 9; + GrHLine(tx1, tx2, ty1, GUI_WHITE); + GrVLine(tx1, ty1, ty2, GUI_WHITE); + GrHLine(tx1, tx2, ty2, GUI_BLACK); + GrVLine(tx2, ty1, ty2, GUI_BLACK); + // Set titlebar area. + w->titlebar.x2 -= 26; + } else { + // No minimize box. + w->minimize.x = 0; + w->minimize.y = 0; + w->minimize.x2 = 0; + w->minimize.y2 = 0; + } + + // Title font area is 12px high. + GrHLine(w->titlebar.x, w->titlebar.x2 - 1, w->titlebar.y, GUI_WHITE); + GrVLine(w->titlebar.x, w->titlebar.y, w->titlebar.y2 - 1, GUI_WHITE); + if (w->title) { + //***TODO*** Look into GrTextRegion + _textOption.txo_bgcolor.v = titleBackgroundColor; + ty1 = w->titlebar.y + 2; + tx1 = w->titlebar.x + 2 + (w->titlebar.x2 - w->titlebar.x - 4) * 0.5 - (GrStringWidth(w->title, strlen(w->title), &_textOption) * 0.5); + //***TODO*** Does not handle text being clipped. + GrDrawString(w->title, strlen(w->title), tx1, ty1, &_textOption); + } + } + + // Innermost shadow frame. 1px wide. + x1--; + y1--; + x2++; + y2++; + GrHLine(x1, x2, y2, GUI_WHITE); + GrVLine(x2, y1, y2, GUI_WHITE); + GrHLine(x1, x2, y1, GUI_DARKGRAY); + GrVLine(x1, y1, y2, GUI_DARKGRAY); + + // Frame Border. 4px wide. + x1 -= 4; + y1 -= 4; + x2 += 4; + y2 += 4; + GrFilledBox(x1, y1, x1 + 3, y2, GUI_LIGHTGRAY); + GrFilledBox(x2, y1, x2 - 3, y2, GUI_LIGHTGRAY); + GrFilledBox(x1, y1, x2, y1 + 3, GUI_LIGHTGRAY); + GrFilledBox(x1, y2, x2, y2 - 3, GUI_LIGHTGRAY); + + // Resize handle. + if (w->flags & WIN_RESIZE) { + ty1 = y2 - 15 - 3; + tx1 = x2 - 15 - 3; + GrHLine(x2, x2 - 3, ty1, GUI_DARKGRAY); + GrHLine(x2, x2 - 3, ty1 + 1, GUI_WHITE); + GrVLine(tx1, y2, y2 - 3, GUI_DARKGRAY); + GrVLine(tx1 + 1, y2, y2 - 3, GUI_WHITE); + } + + // Outermost shadow frame. 1px wide. + x1--; + y1--; + x2++; + y2++; + GrHLine(x1, x2, y1, GUI_WHITE); + GrVLine(x1, y1, y2, GUI_WHITE); + GrHLine(x1, x2, y2, GUI_DARKGRAY); + GrVLine(x2, y1, y2, GUI_DARKGRAY); +} + + +RegisterT *windowRegister(uint8_t magic) { + static RegisterT reg = { + "Window", + windowPaint, + windowDestroy, + NULL + }; + + // One-time widget startup code. + __MAGIC_WINDOW = magic; + + _textOption.txo_bgcolor.v = GUI_DARKGRAY; + _textOption.txo_fgcolor.v = GUI_WHITE; + _textOption.txo_chrtype = GR_BYTE_TEXT; + _textOption.txo_direct = GR_TEXT_RIGHT; + _textOption.txo_font = &GrFont_PC8x14; + _textOption.txo_xalign = GR_ALIGN_DEFAULT; + _textOption.txo_yalign = GR_ALIGN_DEFAULT; + + return ® +} + + +void wmPaint(void) { + uint16_t i; + WidgetT *widget; + + // Paint desktop. + GrClearScreen(GUI_CYAN); + + // Paint all windows. + for (i=0; ireg->paint(widget); + } +} + + +void wmShutdown(void) { + while (arrlen(_windowList) > 0) { + windowDestroy((WidgetT *)_windowList[0]); + } + arrfree(_windowList); +} + + +void wmStartup(void) { + +} diff --git a/client/src/gui/wmwindow.h b/client/src/gui/wmwindow.h new file mode 100644 index 0000000..cedbae6 --- /dev/null +++ b/client/src/gui/wmwindow.h @@ -0,0 +1,40 @@ +#ifndef WMWINDOW_H +#define WMWINDOW_H + + +#include "gui.h" + + +#define WIN_NONE 0 +#define WIN_CLOSE 1 +#define WIN_MAXIMIZE 2 +#define WIN_MINIMIZE 4 +#define WIN_RESIZE 8 + + +typedef struct WindowS { + WidgetT base; + char *title; + uint8_t flags; + RectT close; + RectT titlebar; + RectT minimize; + RectT maximize; +} WindowT; + + +extern uint8_t __MAGIC_WINDOW; + + +WindowT *windowCreate(uint16_t x, uint16_t y, uint16_t w, uint16_t h, char *title, uint8_t flags, ...); +void windowDestroy(struct WidgetS *widget, ...); +void windowPaint(struct WidgetS *widget, ...); +RegisterT *windowRegister(uint8_t magic); + + +void wmPaint(void); +void wmShutdown(void); +void wmStartup(void); + + +#endif // WMWINDOW_H diff --git a/client/src/main.c b/client/src/main.c new file mode 100644 index 0000000..444a0ac --- /dev/null +++ b/client/src/main.c @@ -0,0 +1,18 @@ +#include "gui/gui.h" +#include "gui/wmwindow.h" + + +int main(int argc, char *argv[]) { + + (void)argc; + (void)argv; + + guiStartup(800, 600, 24); + + windowCreate(50, 50, 300, 200, "Testing", WIN_CLOSE | WIN_MAXIMIZE | WIN_MINIMIZE | WIN_RESIZE); + guiRun(); + + guiShutdown(); + + return 0; +} diff --git a/client/src/os.h b/client/src/os.h new file mode 100644 index 0000000..8d8b3ee --- /dev/null +++ b/client/src/os.h @@ -0,0 +1,17 @@ +#ifndef OS_H +#define OS_H + + +#define MEMORY_CHECK_ENABLED + + +#include +#include +#include + +#include "macros.h" +#include "memory.h" +#include "stddclmr.h" + + +#endif // OS_H diff --git a/makedefs.grx b/makedefs.grx new file mode 100644 index 0000000..c39cfe4 --- /dev/null +++ b/makedefs.grx @@ -0,0 +1,261 @@ +### CONFIGURATION ######################################################## + +# This file sets variables that direct the libary build for the +# programmer needs. The file is used for the four standard plattforms + +# Specify version of GRX +# Currently only used to generate name of shared libraries for linux +GRX_VERSION=2.4.9 + +# Specify if you have libtiff.a and corresponding .h files. +# Change setting to 'y' if you have it, or to 'n' if not. +HAVE_LIBTIFF=n + +# Specify if you have libjpeg.a and corresponding .h files. +HAVE_LIBJPEG=y + +# Specify if you have libpng.a and corresponding .h files. +HAVE_LIBPNG=y + +# Specify if one of the above libs requires the +# zlib compression library +NEED_ZLIB=y + +# Specify if you want to include printing code from addons +INCLUDE_PRINTING_CODE=n + +# Specify if you want to include bmp image code from addons +INCLUDE_BMP_CODE=y + +# Specify if you want to include GNU_Pascal (gpc) support +INCLUDE_GPC_SUPPORT=n + +# Specify if you want shared library support (Linux console and X11) +INCLUDE_SHARED_SUPPORT=n + +# Specify if you want to include BGI support +INCLUDE_BGI_SUPPORT=n + +# For cross-compiling, specify prefix for tools including the trailing dash +# (e.g. i386-mingw32- for using i386-mingw32-gcc instead of just gcc) +#CROSS_PLATFORM=i586-pc-msdosdjgpp- + +# Specify if you want to use Unix tools on DOS-like platforms +HAVE_UNIX_TOOLS=y + +# Specify in linux if you want to build the library for x86_64 +BUILD_X86_64=y + +# For SDL driver the executable prefix EP is used to discriminate +# between linux X11 and mingw32. Set +#EP=x ... For linux X11. +#EP= ... For mingw32 +EP=x + +### SYSTEM SETTINGS ###################################################### + +CC = $(CROSS_PLATFORM)gcc +PC = $(CROSS_PLATFORM)gpc +AR = $(CROSS_PLATFORM)ar +RANLIB = $(CROSS_PLATFORM)ranlib +STRIP = $(CROSS_PLATFORM)strip + +# Different systems / setups may generate .o files +# this tag files will show what version is present +SYSTEM_TAG_PREFIX = systag +LINUX_i386_CONSOLE = $(SYSTEM_TAG_PREFIX).000 +LINUX_i386_X11 = $(SYSTEM_TAG_PREFIX).002 +DOS_DJGPP_V2 = $(SYSTEM_TAG_PREFIX).004 +WIN32_GCC_i386_STATIC = $(SYSTEM_TAG_PREFIX).006 +ANY_GCC_SDL_STATIC = $(SYSTEM_TAG_PREFIX).008 + +ifdef DEBUG +CCOPT = -O2 -fno-strict-aliasing -Wall -g -DDEBUG=$(DEBUG) ${C_FLAGS} +LDOPT = -g ${L_FLAGS} +else +CCOPT = -O2 -fno-strict-aliasing -Wall ${C_FLAGS} +LDOPT = -s ${L_FLAGS} +endif + +ifdef PROFILE +CCOPT += -pg +endif + +# Additional warnings for development +WARNOPTS = -W -Wshadow -Wpointer-arith -Wbad-function-cast \ + -Wcast-align -Wconversion -Wmissing-prototypes \ + -Wnested-externs -Wstrict-prototypes +#CCOPT += $(WARNOPTS) + +# Some systems can't allocate big arrays on stack. +# If test/xcirctest fails on bigger diameters, try +#CCOPT += -DSMALL_STACK + +# You may want to enable one (or both) of the following +# switches if your get lots of warnings when compiling GRX +#CCOPT += -DNO_LEFTSIDE_LVALUE_CAST +#CCOPT += -DNO_LEFTSIDE_PTR_CAST + +########################################################################## + +ifdef GRXVSDL +ifeq ($(EP),x) +GRXVX11=y +else +GRXVW32=y +endif +endif + +ifdef GRXVLNX +GRXVUNX=y +endif + +ifdef GRXVX11 +GRXVUNX=y +endif + +### UNIX SPECIFIC ######################################################## + +ifdef GRXVUNX + +# Put libgrx20.a, libgrx20.so, libgrx20X.a, libgrx20X.so and libgrx20S.a +# in lib/unix +GRX_LIB_SUBDIR=unix + +# Set here the default destination dirs for install and uninstall targets +prefix=/usr/local + +# Set the default GRX font path +#GRX_DEFAULT_FONT_PATH=${datadir}/grx/fonts + +# check for i386 or x86_64 build +ifeq ($(BUILD_X86_64),y) +CCOPT += -m64 +LDOPT += -m64 +else +CCOPT += -m32 +LDOPT += -m32 +endif + +endif + +### LINUX CONSOLE SPECIFIC ############################################### + +ifdef GRXVLNX + +# Use direct PS/2 mouse driver instead the svgalib one +USE_DIRECT_MOUSE_DRIVER=n + +# Set the videodrivers to be included, you can set both or only one of them +# (remember to set USE_DIRECT_MOUSE_DRIVER to 'y' if you set only the +# framebuffer driver) +USE_SVGALIB_DRIVER=y +USE_FRAMEBUFFER_DRIVER=y + +# Set or not set suid root. This is required for the svgalib 1.4.x stable +# release, it can be set to 'n' if you use the framebuffer driver only or +# the svgalib 1.9.x alpha release without the 1 and 4 bpp resolutions +# (see bellow) +SET_SUIDROOT=y + +# Set to 'y' this variable if you want to add the framedrivers that use +# inport/outport instructions: 1 and 4 bpp modes and the 8 bpp mode X. But +# beware this works only with svgalib 1.4.x (not with 1.9.x) and without +# the linux framebuffer enabled +USE_INOUTP_FRAMEDRIVERS=y + +endif + +### LINUX X11 SPECIFIC ################################################### + +ifdef GRXVX11 + +# The X11 base dir on your system +X11BASE=/usr/X11R6 + +# Add directories with X11 include files here +X11INCS=-I$(X11BASE)/include + +# put X11 required libraries and directories here +# note: some systems need -lsocket added +X11LIB=$(X11BASE)/lib +X11LIBS=-L$(X11LIB) -lX11 + +# Set to try to use the XFree86 Direct Graphics Access driver (DGA2) +# (if DGA2 is not available, fall back to the windowed X11 driver) +# As of XFree-4.3.99.5 DGA/DGA2 seems stable, but use with caution. +USE_XF86DGA_DRIVER=n +# Set to 'y' this variable if you want the DGA2 driver to use direct +# framebuffer access. That should not make DGA2 more unstable and is +# faster. If this setting is 'y', the DGA2 driver (see above) must +# also be 'y', or you will get compilation/linkage errors. +USE_XF86DGA_FRAMEBUFFER=n +# Set or not set suid root for X11. This is required for the DGA2 +# framebuffer access, it can be set to 'n' if you use the standard +# X11 driver only or DGA2 without framebuffer access. +SET_XSUIDROOT=n + +endif + +### DOS DJGPPv2 SPECIFIC ################################################# + +ifdef GRXVDJ2 + +# Put libgrx20.a to lib/dj2 +GRX_LIB_SUBDIR=dj2 + +# Set here the destination dir for install and uninstall targets +prefix=/dev/env/DJDIR + +# Set the default GRX font path +#GRX_DEFAULT_FONT_PATH=/dev/env/DJDIR/share/grx/fonts + +# If you want to use 'upx.exe' compressor +# disable the echo line and enable upx line. +EXE_COMPRESS = -echo +#EXE_COMPRESS = upx --best + +# Default compiler switches. In djgpp.env. under [make], +# add the line "BUTT=-mcpu=i386", if that is your target, +# or directly add -mcpu here. +# At present gcc supports 'i386', 'i486', 'i586' ('pentium'), +# 'i686' ('pentiumpro') and 'k6'. +#CCOPT += $(BUTT) +#CCOPT += -mcpu=i586 + +# GRX uses "uclock" to gets 1 ms resolution in the input code, +# this can causes problems in Win3.1, so you may want to enable +# the following switch +#CCOPT += -DNO_REPROGRAM_TIMER + +endif + +### WIN32 MINGW SPECIFIC ################################################# + +ifdef GRXVW32 + +# Put libgrx20.a and libgrx20S.a to lib/win32 +GRX_LIB_SUBDIR=win32 + +# Set here the destination dir for install and uninstall targets +prefix=C:\MINGW + +# Set the default GRX font path +#GRX_DEFAULT_FONT_PATH=c:/grxfonts + +endif + +### COMMON ############################################################## + +exec_prefix=${prefix} + +bindir=${exec_prefix}/bin +libdir=${exec_prefix}/lib +datadir=${prefix}/share + +infodir=${prefix}/info +includedir=${prefix}/include +unitsdir=${exec_prefix}/units + +########################################################################## + diff --git a/shared/array.c b/shared/array.c new file mode 100644 index 0000000..6092b84 --- /dev/null +++ b/shared/array.c @@ -0,0 +1,4 @@ +#include "array.h" + +#define STB_DS_IMPLEMENTATION +#include "thirdparty/stb_ds.h" diff --git a/shared/array.h b/shared/array.h new file mode 100644 index 0000000..36a5aed --- /dev/null +++ b/shared/array.h @@ -0,0 +1,9 @@ +#ifndef ARRAY_H +#define ARRAY_H + + +#include "os.h" +#include "thirdparty/stb_ds.h" + + +#endif // ARRAY_H diff --git a/shared/macros.h b/shared/macros.h new file mode 100644 index 0000000..1d7d320 --- /dev/null +++ b/shared/macros.h @@ -0,0 +1,19 @@ +#ifndef MACROS_H +#define MACROS_H + + +// Should be after system headers in this file. +#define MEMORY_CHECK_ENABLED +#include "memory.h" + + +// Allocation helpers. +#define NEW(t,v) (v)=(t*)malloc(sizeof(t)) // Add check for NULL and die here. +#define DEL(v) {if(v) {free(v); v=NULL;}} + + +#define SUCCESS 0 +#define FAIL 1 + + +#endif // MACROS_H diff --git a/shared/memory.c b/shared/memory.c new file mode 100644 index 0000000..b31569d --- /dev/null +++ b/shared/memory.c @@ -0,0 +1 @@ +#include "memory.h" diff --git a/shared/memory.h b/shared/memory.h new file mode 100644 index 0000000..97f5802 --- /dev/null +++ b/shared/memory.h @@ -0,0 +1,13 @@ +#ifndef MEMORY_H +#define MEMORY_H + + +#include "os.h" + +#ifdef MEMORY_CHECK_ENABLED +#define MEMWATCH +#include "thirdparty/memwatch/memwatch.h" +#endif + + +#endif // MEMORY_H diff --git a/shared/stddclmr.h b/shared/stddclmr.h new file mode 100644 index 0000000..8e6b3d9 --- /dev/null +++ b/shared/stddclmr.h @@ -0,0 +1,95 @@ +#ifndef STDDCLMR_H +#define STDDCLMR_H + +/* +Action figures sold separately. Add toner. All models over 18 years of age. +All rights reserved. Allow four to six weeks for delivery. An equal +opportunity employer. Any resemblance to actual persons, living or dead, is +unintentional and purely coincidental. Apply only to affected area. Approved +for veterans. As seen on TV. At participating locations only. Avoid contact +with mucous membranes. Avoid contact with skin. Avoid extreme temperatures +and store in a cool dry place. Batteries not included. Be sure each item is +properly endorsed. Beware of dog. Booths for two or more. Breaking seal +constitutes acceptance of agreement. Call toll free number before digging. +Caveat emptor. Check here if tax deductible. Close cover before striking +Colors may fade. Contains a substantial amount of non-tobacco ingredients. +Contents may settle during shipment. Contestants have been briefed on some +questions before the show. Copyright 1995 Joker's Wild. Disclaimer does +not cover hurricane, lightning, tornado, tsunami, volcanic eruption, +earthquake, flood, and other Acts of God, misuse, neglect, unauthorized +repair, damage from improper installation, broken antenna or marred cabinet, +incorrect line voltage, missing or altered serial numbers, sonic boom +vibrations, electromagnetic radiation from nuclear blasts, customer +adjustments that are not covered in the joke list, and incidents owing to +airplane crash, ship sinking, motor vehicle accidents, leaky roof, broken +glass, falling rocks, mud slides, forest fire, flying projectiles, or +dropping the item. Do not bend, fold, mutilate, or spindle. Do not place +near flammable or magnetic source. Do not puncture, incinerate, or store +above 120 degrees Fahrenheit. Do not stamp. Use other side for additional +listings. Do not use while operating a motor vehicle or heavy equipment. Do +not write below this line. Documents are provided "as is" without any +warranties expressed or implied. Don't quote me on anything. Don't quote me +on that. Driver does not carry cash. Drop in any mailbox. Edited for +television. Employees and their families are not eligible. Falling rock. +First pull up, then pull down. Flames redirected to /dev/null. For a +limited time only. For external use only. For off-road use only. For office +use only. For recreational use only. Do not disturb. Freshest if eaten +before date on carton. Hand wash only, tumble dry on low heat. If a rash, +redness, irritation, or swelling develops, discontinue use. If condition +persists, consult your physician. If defects are discovered, do not attempt +to fix them yourself, but return to an authorized service center. If +ingested, do not induce vomiting, if symptoms persist, consult a doctor. +Keep away from open flames and avoid inhaling fumes. Keep away from +sunlight, pets, and small children. Keep cool; process promptly. Limit +one-per-family please. Limited time offer, call now to ensure prompt +delivery. List at least two alternate dates. List each check separately by +bank number. List was current at time of printing. Lost ticket pays maximum +rate. May be too intense for some viewers. Must be 18 to enter. No Canadian +coins. No alcohol, dogs or horses. No anchovies unless otherwise specified. +No animals were harmed in the production of these documents. No money down. +No other warranty expressed or implied. No passes accepted for this +engagement. No postage necessary if mailed in the United States. No +preservatives added. No purchase necessary. No salt, MSG, artificial color +or flavor added. No shoes, no shirt, no service, no kidding. No solicitors. +No substitutions allowed. No transfers issued until the bus comes to a +complete stop. No user-serviceable parts inside. Not affiliated with the +American Red Cross. Not liable for damages due to use or misuse. Not +recommended for children. Not responsible for direct, indirect, incidental +or consequential damages resulting from any defect, error or failure to +perform. Not the Beatles. Objects in mirror may be closer than they appear. +One size fits all. Many suitcases look alike. Other copyright laws for +specific entries apply wherever noted. Other restrictions may apply. Package +sold by weight, not volume. Parental advisory - explicit lyrics. Penalty for +private use. Place stamp here. Please remain seated until the ride has come +to a complete stop. Possible penalties for early withdrawal. Post office will +not deliver without postage. Postage will be paid by addressee. Prerecorded +for this time zone. Price does not include taxes. Processed at location +stamped in code at top of carton. Quantities are limited while supplies last. +Read at your own risk. Record additional transactions on back of previous +stub. Replace with same type. Reproduction strictly prohibited. Restaurant +package, not for resale. Return to sender, no forwarding order on file, +unable to forward. Safety goggles may be required during use. Sanitized for +your protection. Sealed for your protection, do not use if the safety seal is +broken. See label for sequence. Shading within a garment may occur. Sign here +without admitting guilt. Simulated picture. Slightly enlarged to show detail. +Slightly higher west of the Rockies. Slippery when wet. Smoking these may be +hazardous to your health. Some assembly required. Some equipment shown is +optional. Some of the trademarks mentioned in this product appear for +identification purposes only. Subject to FCC approval. Subject to change +without notice. Substantial penalty for early withdrawal. Text may contain +material some readers may find objectionable, parental guidance is advised. +Text used in these documents is made from 100% recycled electrons and magnetic +particles. These documents do not reflect the thoughts or opinions of either +myself, my company, my friends, or my rabbit. This is not an offer to sell +securities. This offer is void where prohibited, taxed, or otherwise +restricted. This product is meant for educational purposes only. Times +approximate. Unix is a registered trademark of AT&T. Use only as directed. Use +only in a well-ventilated are. User assumes full liabilities. Void where +prohibited. We have sent the forms which seem right for you. You must be +present to win. You need not be present to win. Your canceled check is your +receipt. Your mileage may vary. I didn't do it. You can't prove anything. + +This supersedes all previous notices. +*/ + +#endif // STDDCLMR_H diff --git a/shared/thirdparty/memwatch/FAQ b/shared/thirdparty/memwatch/FAQ new file mode 100644 index 0000000..efcec58 --- /dev/null +++ b/shared/thirdparty/memwatch/FAQ @@ -0,0 +1,133 @@ +Frequently Asked Questions for memwatch + +Q. I'm not getting any log file! What's wrong?? + +A. Did you define MEMWATCH when compiling all files? + Did you include memwatch.h in all the files? + If you did, then...: + + Memwatch creates the file when it initializes. If you're not + getting the log file, it's because a) memwatch is not + initializing or b) it's initializing, but can't create the + file. + + Memwatch has two functions, mwInit() and mwTerm(), that + initialize and terminate memwatch, respectively. They are + nestable. You USUALLY don't need to call mwInit() and + mwTerm(), since memwatch will auto-initialize on the first + call to a memory function, and then add mwTerm() to the + atexit() list. + + You can call mwInit() and mwTerm() manually, if it's not + initializing properly or if your system doesn't support + atexit(). Call mwInit() as soon as you can, and mwTerm() at + the logical no-error ending of your program. Call mwAbort() + if the program is stopping due to an error; this will + terminate memwatch even if more than one call to mwTerm() is + outstanding. + + If you are using C++, remember that global and static C++ + objects constructors execute before main() when considering + where to put mwInit(). Also, their destructors execute after + main(). You may want to create a global object very early + with mwInit() in the constructor and mwTerm() in the + destructor. Too bad C++ does not guarantee initialization + order for global objects. + + If this didn't help, try adding a call to mwDoFlush(1) after + mwInit(). If THAT didn't help, then memwatch is unable to + create the log file. Check write permissions. + + If you can't use a log file, you can still use memwatch by + redirecting the output to a function of your choice. See the + next question. + +Q. I'd like memwatch's output to pipe to my fave debugger! How? + +A. Call mwSetOutFunc() with the address of a "void func(int c)" + function. You should also consider doing something about + the ARI handler, see memwatch.h for more details about that. + +Q. Why isn't there any C++ support? + +A. Because C++ is for sissies! =) Just kidding. + C++ comes with overridable allocation/deallocation + built-in. You can define your own new/delete operators + for any class, and thus circumvent memwatch, or confuse + it to no end. Also, the keywords "new" and "delete" may + appear in declarations in C++, making the preprocessor + replacement approach shaky. You can do it, but it's not + very stable. + + If someone were to write a rock solid new/delete checker + for C++, there is no conflict with memwatch; use them both. + +Q. I'm getting "WILD free" errors, but the code is bug-free! + +A. If memwatch's free() recieves a pointer that wasn't allocated + by memwatch, a "WILD free" message appears. If the source of + the memory buffer is outside of memwatch (a non-standard + library function, for instance), you can use mwFree_() to + release it. mwFree_() calls free() on the pointer given if + memwatch can't recognize it, instead of blocking it. + + Another source of "WILD free" messages is that if memwatch + is terminated before all memory allocated is freed, memwatch + will have forgotten about it, and thus generate the errors. + This is commonly caused by having memwatch auto-initialize, + and then using atexit() to clean up. When auto-initializing, + memwatch registers mwTerm() with atexit(), but if mwTerm() + runs before all memory is freed, then you will get "unfreed" + and "WILD free" messages when your own atexit()-registered + cleanup code runs, and frees the memory. + +Q. I'm getting "unfreed" errors, but the code is bug-free! + +A. You can get erroneous "unfreed" messages if memwatch + terminates before all memory has been freed. Try using + mwInit() and mwTerm() instead of auto-initialization. + + If you _are_ using mwInit() and mwTerm(), it may be that + some code in your program executes before mwInit() or + after mwTerm(). Make sure that mwInit() is the first thing + executed, and mwTerm() the last. + +Q. When compiling memwatch I get these 'might get clobbered' + errors, and something about a longjmp() inside memwatch. + +A. When using gcc or egcs with the optimization to inline + functions, this warning occurs. This is because gcc and + egcs inlines memwatch's functions with setjmp/longjmp, + causing the calling functions to become unstable. + + The gcc/egcs maintainers have been informed of this + problem, but until they modify the inline optimization + so that it leaves setjmp functions alone, make sure to + compile memwatch without inline function optimizations. + + gcc 2.95.2 can be patched for this, and I have been told + it will be fixed in an upcoming version. + +Q. My program crashes with SIGSEGV or alignment errors, but + only when I compile with memwatch enabled! + +A. You are using a 64-bit (or higher) platform, and memwatch + was unable to detect and adjust for this. You'll have to + either compile with a suitable define for mwROUNDALLOC, + I suggest (number of bits / 8), or define mwROUNDALLOC + directly in memwatch.c. + + Also, please check your limits.h file for the relevant + #defines, and tell me what they are. + +Q. When I include string.h after memwatch.h, I get errors + related to strdup(), what gives? + +A. Most, but probably not all, platforms are nice about + including files multiple times, so I could probably + avoid these errors by including string.h from memwatch.h. + But since I want to be on the safe side, I don't. + + To fix this, simply include string.h before memwatch.h, + or modify memwatch.h to include string.h. + diff --git a/shared/thirdparty/memwatch/Makefile b/shared/thirdparty/memwatch/Makefile new file mode 100644 index 0000000..bc1be19 --- /dev/null +++ b/shared/thirdparty/memwatch/Makefile @@ -0,0 +1,2 @@ +test: + $(CC) -DMEMWATCH -DMW_STDIO test.c memwatch.c diff --git a/shared/thirdparty/memwatch/README b/shared/thirdparty/memwatch/README new file mode 100644 index 0000000..aeb86ce --- /dev/null +++ b/shared/thirdparty/memwatch/README @@ -0,0 +1,99 @@ +README for MEMWATCH 2.69 + + This file should be enough to get you started, and should be + enough for small projects. For more info, see the files USING + and the FAQ. If this is not enough, see memwatch.h, which is + well documented. + + Memwatch is licensed under the GPL from version 2.69 + onwards. Please read the file gpl.txt for more details. + + If you choose to use memwatch to validate your projects, I + would like to hear about it. Please drop me a line at + johan@linkdata.se about the project itself, the hardware, + operating system, compiler and any URL(s) you feel is + appropriate. + +***** To run the test program: + + Look at the source code for test.c first. It does some really + nasty things, and I want you to be aware of that. If memwatch + can't capture SIGSEGV (General Protection Fault for Windoze), + your program will dump core (crash for Windoze). + + Once you've done that, you can build the test program. + + Linux and other *nixes with gcc: + + gcc -o test -DMEMWATCH -DMEMWATCH_STDIO test.c memwatch.c + + Windows 95, Windows NT with MS Visual C++: + + cl -DMEMWATCH -DMEMWATCH_STDIO test.c memwatch.c + + Then simply run the test program. + + ./test + + +***** Quick-start instructions: + + 1. Make sure that memwatch.h is included in all of the + source code files. If you have an include file that + all of the source code uses, you might be able to include + memwatch.h from there. + + 2. Recompile the program with MEMWATCH defined. See your + compiler's documentation if you don't know how to do this. + The usual switch looks like "-DMEMWATCH". To have MEMWATCH + use stderr for some output (like, "Abort, Retry, Ignore?"), + please also define MW_STDIO (or MEMWATCH_STDIO, same thing). + + 3. Run the program and examine the output in the + log file "memwatch.log". If you didn't get a log file, + you probably didn't do step 1 and 2 correctly, or your + program crashed before memwatch flushed the file buffer. + To have memwatch _always_ flush the buffer, add a call + to "mwDoFlush(1)" at the top of your main function. + + 4. There is no fourth step... but remember that there + are limits to what memwatch can do, and that you need + to be aware of them: + +***** Limits to memwatch: + + Memwatch cannot catch all wild pointer writes. It can catch + those it could make itself due to your program trashing + memwatch's internal data structures. It can catch, sort of, + wild writes into No Mans Land buffers (see the header file for + more info). Anything else and you're going to get core dumped, + or data corruption if you're lucky. + + There are other limits of course, but that one is the most + serious one, and the one that you're likely to be suffering + from. + +***** Can use memwatch with XXXXX? + + Probably the answer is yes. It's been tested with several + different platforms and compilers. It may not work on yours + though... but there's only one way to find out. + +***** Need more assistance? + + I don't want e-mail on "how to program in C", or "I've got a + bug, help me". I _do_ want you to send email to me if you + find a bug in memwatch, or if it won't compile cleanly on your + system (assuming it's an ANSI-C compiler of course). + + If you need help with using memwatch, read the header file. + If, after reading the header file, you still can't resolve the + problem, please mail me with the details. + + I can be reached at "johan@linkdata.se". + + The latest version of memwatch should be found at + "http://www.linkdata.se/". + + Johan Lindh + diff --git a/shared/thirdparty/memwatch/USING b/shared/thirdparty/memwatch/USING new file mode 100644 index 0000000..3d78e95 --- /dev/null +++ b/shared/thirdparty/memwatch/USING @@ -0,0 +1,213 @@ +Using memwatch +============== + +What is it? + + Memwatch is primarily a memory leak detector for C. Besides + detecting leaks, it can do a bunch of other stuff, but lets + stay to the basics. If you _really_ want to know all the + gory details, you should check out the header file, + memwatch.h, and the source code. It's actually got some + comments! (Whoa, what a concept!) + +How do I get the latest version? + + http://www.linkdata.se/sourcecode.html + ftp://ftp.linkdata.se/pub/memwatch/ + +How does it work? + + Using the C preprocessor, memwatch replaces all your + programs calls to ANSI C memory allocation functions with + calls to it's own functions, which keeps a record of all + allocations. + + Memwatch is very unobtrusive; unless the define MEMWATCH is + defined, memwatch removes all traces of itself from the + code (using the preprocessor). + + Memwatch normally writes it's data to the file + memwatch.log, but this can be overridden; see the section + on I/O, later. + +Can I use it for my C++ sources? + + You can, but it's not recommended. C++ allows individual + classes to have their own memory management, and the + preprocessor approach used by memwatch can cause havoc + with such class declarations if improperly used. + + If you have no such classes, or have them but still want + to test it, you can give it a try. + + First, re-enable the C++ support code in memwatch. + If you can't find it, you probably shouldn't be using + it. Then, in your source code, after including ALL + header files: + + #define new mwNew + #define delete mwDelete + + This will cause calls to new and delete in that source file + to be directed to memwatch. Also, be sure to read all the + text in memwatch.h regarding C++ support. + +Is this stuff thread-safe? + + I doubt it. As of version 2.66, there is rudimentary support + for threads, if you happen to be using Win32 or if you have + pthreads. Define WIN32 or MW_PTHREADS to signify this fact. + + This will cause a global mutex to be created, and memwatch + will lock it when accessing the global memory chain, but it's + still far from certified threadsafe. + +Initialization and cleanup + + In order to do it's work in a timely fashion, memwatch + needs to do some startup and cleanup work. mwInit() + initializes memwatch and mwTerm() terminates it. Memwatch + can auto-initialize, and will do so if you don't call + mwInit() yourself. If this is the case, memwatch will use + atexit() to register mwTerm() to the atexit-queue. + + The auto-init technique has a caveat; if you are using + atexit() yourself to do cleanup work, memwatch may + terminate before your program is done. To be on the safe + side, use mwInit() and mwTerm(). + + mwInit() and mwTerm() is nestable, so you can call mwInit() + several times, requiring mwTerm() to be called an equal + number of times to terminate memwatch. + + In case of the program aborting in a controlled way, you + may want to call mwAbort() instead of mwTerm(). mwAbort() + will terminate memwatch even if there are outstanding calls + to mwTerm(). + +I/O operations + + During normal operations, memwatch creates a file named + memwatch.log. Sometimes, memwatch.log can't be created; + then memwatch tries to create files name memwatNN.log, + where NN is between 01 and 99. If that fails, no log will + be produced. + + If you can't use a file log, or don't want to, no worry. + Just call mwSetOutFunc() with the address of a "void + func(int c)" function, and all output will be directed + there, character by character. + + Memwatch also has an Abort/Retry/Ignore handler that is + used when an ASSERT or VERIFY fails. The default handler + does no I/O, but automatically aborts the program. You can + use any handler you want; just send the address of a "int + func(const char*)" to mwSetAriFunc(). For more details on + that, see memwatch.h. + +TRACE/ASSERT/VERIFY macros + + Memwatch defines (if not already defined) the macros TRACE, + ASSERT and VERIFY. If you are already using macros with + these names, memwatch 2.61 and later will not override + them. Memwatch 2.61 and later will also always define the + macros mwTRACE, mwASSERT and mwVERIFY, so you can use these + to make sure you're talking to memwatch. Versions prior + to 2.61 will *OVERRIDE* existing TRACE, ASSERT and VERIFY. + + To make sure that existing TRACE, ASSERT and VERIFY macros + are preserved, you can define MW_NOTRACE, MW_NOASSERT and + MW_NOVERIFY. All versions of memwatch will abide by these. + +How slow can you go? + + Memwatch slows things down. Large allocations aren't + affected so that you can measure it, but small allocations + that would utilize a compilers small-allocator function + suddenly cannot, and so gets slowed down alot. As a worst + case, expect it to be 3-5 times slower. + + Free'ing gets hit worse, I'm afraid, as memwatch checks + a lot of stuff when freeing. Expect it to be 5-7 times + slower, no matter what the size of the allocation. + +Stress-testing the application + + You can simulate low-memory conditions using mwLimit(). + mwLimit() takes the maximum number of bytes to be + allocated; when the limit is hit, allocation requests will + fail, and a "limit" message will be logged. + + If you hit a real low-memory situation, memwatch logs that + too. Memwatch itself has some reserve memory tucked away so + it should continue running even in the worst conditions. + +Hunting down wild writes and other Nasty Things + + Wild writes are usually caused by using pointers that arent + initialized, or that were initialized, but then the memory + they points to is moved or freed. The best way to avoid + these kind of problems is to ALWAYS initialize pointers to + NULL, and after freeing a memory buffer, setting all + pointers that pointed to it to NULL. + + To aid in tracking down uninitialized pointers memwatch + zaps all memory with certain values. Recently allocated + memory (unless calloc'd, of course), contains 0xFE. + Recently freed memory contains 0xFD. So if your program + crashes when using memwatch and not without memwatch, it's + most likely because you are not initializing your allocated + buffers, or using the buffers after they've been freed. + + In the event that a wild pointer should damage memwatch's + internal data structures, memwatch employs checksums, + multiple copies of some values, and can also repair it's + own data structures. + + If you are a paranoid person, and as programmer you should + be, you can use memwatch's mwIsReadAddr() and + mwIsSafeAddr() functions to check the accessibility of + memory. These are implemented for both ANSI C systems and + Win32 systems. Just put an mwASSERT() around the check and + forget about it. + +Can I help? + + Well, sure. For instance, I like memwatch to compile + without any warnings or errors. If you are using an ANSI C + compliant compiler, and are getting warnings or errors, + please mail me the details and instructions on how to fix + them, if you can. + + Another thing you can do if you decide to use memwatch is + to mail me the name of the project(s) (and URL, if any), + hardware and operating system, compiler and what user + (organization). I will then post this info on the list of + memwatch users. + (http://www.linkdata.se/memwatchusers.html) + +Top five problems using memwatch + + 5. Passed a non-memwatch allocated pointer to memwatch's + free(). Symtom: Causes an erroneous "WILD free" log + entry to appear. Cure: Either include memwatch.h for + the file that allocates, or use mwFree_() to free it. + + 4. Relied on auto-initialization when using atexit(). + Symptom: Causes incorrect "unfreed" and "WILD free" + messages. Cure: Use mwInit() and mwTerm(). + + 3. Forgot to include memwatch.h in all files. Symptom: + Tends to generate "WILD free" and "unfreed" messages. + Cure: Make sure to include memwatch.h! + + 2. No write permissions in currect directory. Symptom: + Seems like memwatch 'just aint working'. Cure: Use + mwSetOutFunc() to redirect output. + + ...and the number one problem is... + + 1. Didn't define MEMWATCH when compiling. Symptom: + Memwatch dutifully disables itself. Cure: Try adding + -DMEMWATCH to the command line. + diff --git a/shared/thirdparty/memwatch/gpl.txt b/shared/thirdparty/memwatch/gpl.txt new file mode 100644 index 0000000..5b6e7c6 --- /dev/null +++ b/shared/thirdparty/memwatch/gpl.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/shared/thirdparty/memwatch/memwatch.c b/shared/thirdparty/memwatch/memwatch.c new file mode 100644 index 0000000..ae0f6ab --- /dev/null +++ b/shared/thirdparty/memwatch/memwatch.c @@ -0,0 +1,2664 @@ +/* +** MEMWATCH.C +** Nonintrusive ANSI C memory leak / overwrite detection +** Copyright (C) 1992-2003 Johan Lindh +** All rights reserved. +** Version 2.71 + + This file is part of MEMWATCH. + + MEMWATCH is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + MEMWATCH is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with MEMWATCH; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +** +** 920810 JLI [1.00] +** 920830 JLI [1.10 double-free detection] +** 920912 JLI [1.15 mwPuts, mwGrab/Drop, mwLimit] +** 921022 JLI [1.20 ASSERT and VERIFY] +** 921105 JLI [1.30 C++ support and TRACE] +** 921116 JLI [1.40 mwSetOutFunc] +** 930215 JLI [1.50 modified ASSERT/VERIFY] +** 930327 JLI [1.51 better auto-init & PC-lint support] +** 930506 JLI [1.55 MemWatch class, improved C++ support] +** 930507 JLI [1.60 mwTest & CHECK()] +** 930809 JLI [1.65 Abort/Retry/Ignore] +** 930820 JLI [1.70 data dump when unfreed] +** 931016 JLI [1.72 modified C++ new/delete handling] +** 931108 JLI [1.77 mwSetAssertAction() & some small changes] +** 940110 JLI [1.80 no-mans-land alloc/checking] +** 940328 JLI [2.00 version 2.0 rewrite] +** Improved NML (no-mans-land) support. +** Improved performance (especially for free()ing!). +** Support for 'read-only' buffers (checksums) +** ^^ NOTE: I never did this... maybe I should? +** FBI (free'd block info) tagged before freed blocks +** Exporting of the mwCounter variable +** mwBreakOut() localizes debugger support +** Allocation statistics (global, per-module, per-line) +** Self-repair ability with relinking +** 950913 JLI [2.10 improved garbage handling] +** 951201 JLI [2.11 improved auto-free in emergencies] +** 960125 JLI [X.01 implemented auto-checking using mwAutoCheck()] +** 960514 JLI [2.12 undefining of existing macros] +** 960515 JLI [2.13 possibility to use default new() & delete()] +** 960516 JLI [2.20 suppression of file flushing on unfreed msgs] +** 960516 JLI [2.21 better support for using MEMWATCH with DLL's] +** 960710 JLI [X.02 multiple logs and mwFlushNow()] +** 960801 JLI [2.22 merged X.01 version with current] +** 960805 JLI [2.30 mwIsXXXXAddr() to avoid unneeded GP's] +** 960805 JLI [2.31 merged X.02 version with current] +** 961002 JLI [2.32 support for realloc() + fixed STDERR bug] +** 961222 JLI [2.40 added mwMark() & mwUnmark()] +** 970101 JLI [2.41 added over/underflow checking after failed ASSERT/VERIFY] +** 970113 JLI [2.42 added support for PC-Lint 7.00g] +** 970207 JLI [2.43 added support for strdup()] +** 970209 JLI [2.44 changed default filename to lowercase] +** 970405 JLI [2.45 fixed bug related with atexit() and some C++ compilers] +** 970723 JLI [2.46 added MW_ARI_NULLREAD flag] +** 970813 JLI [2.47 stabilized marker handling] +** 980317 JLI [2.48 ripped out C++ support; wasn't working good anyway] +** 980318 JLI [2.50 improved self-repair facilities & SIGSEGV support] +** 980417 JLI [2.51 more checks for invalid addresses] +** 980512 JLI [2.52 moved MW_ARI_NULLREAD to occur before aborting] +** 990112 JLI [2.53 added check for empty heap to mwIsOwned] +** 990217 JLI [2.55 improved the emergency repairs diagnostics and NML] +** 990224 JLI [2.56 changed ordering of members in structures] +** 990303 JLI [2.57 first maybe-fixit-for-hpux test] +** 990516 JLI [2.58 added 'static' to the definition of mwAutoInit] +** 990517 JLI [2.59 fixed some high-sensitivity warnings] +** 990610 JLI [2.60 fixed some more high-sensitivity warnings] +** 990715 JLI [2.61 changed TRACE/ASSERT/VERIFY macro names] +** 991001 JLI [2.62 added CHECK_BUFFER() and mwTestBuffer()] +** 991007 JLI [2.63 first shot at a 64-bit compatible version] +** 991009 JLI [2.64 undef's strdup() if defined, mwStrdup made const] +** 000704 JLI [2.65 added some more detection for 64-bits] +** 010502 JLI [2.66 incorporated some user fixes] +** [mwRelink() could print out garbage pointer (thanks mac@phobos.ca)] +** [added array destructor for C++ (thanks rdasilva@connecttel.com)] +** [added mutex support (thanks rdasilva@connecttel.com)] +** 010531 JLI [2.67 fix: mwMutexXXX() was declared even if MW_HAVE_MUTEX was not defined] +** 010619 JLI [2.68 fix: mwRealloc() could leave the mutex locked] +** 020918 JLI [2.69 changed to GPL, added C++ array allocation by Howard Cohen] +** 030212 JLI [2.70 mwMalloc() bug for very large allocations (4GB on 32bits)] +** 030520 JLI [2.71 added ULONG_LONG_MAX as a 64-bit detector (thanks Sami Salonen)] +*/ + +#define __MEMWATCH_C 1 + +#ifdef MW_NOCPP +#define MEMWATCH_NOCPP +#endif +#ifdef MW_STDIO +#define MEMWATCH_STDIO +#endif + +/*********************************************************************** +** Include files +***********************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "memwatch.h" + +#ifndef toupper +#include +#endif + +#if defined(WIN32) || defined(__WIN32__) +#define MW_HAVE_MUTEX 1 +#include +#endif + +#if defined(MW_PTHREADS) || defined(HAVE_PTHREAD_H) +#define MW_HAVE_MUTEX 1 +#include +#endif + +/*********************************************************************** +** Defines & other weird stuff +***********************************************************************/ + +/*lint -save -e767 */ +#define VERSION "2.71" /* the current version number */ +#define CHKVAL(mw) (0xFE0180L^(long)mw->count^(long)mw->size^(long)mw->line) +#define FLUSH() mwFlush() +#define TESTS(f,l) if(mwTestAlways) (void)mwTestNow(f,l,1) +#define PRECHK 0x01234567L +#define POSTCHK 0x76543210L +#define mwBUFFER_TO_MW(p) ( (mwData*) (void*) ( ((char*)p)-mwDataSize-mwOverflowZoneSize ) ) +/*lint -restore */ + +#define MW_NML 0x0001 + +#ifdef _MSC_VER +#define COMMIT "c" /* Microsoft C requires the 'c' to perform as desired */ +#else +#define COMMIT "" /* Normal ANSI */ +#endif /* _MSC_VER */ + +#ifdef __cplusplus +#define CPPTEXT "++" +#else +#define CPPTEXT "" +#endif /* __cplusplus */ + +#ifdef MEMWATCH_STDIO +#define mwSTDERR stderr +#else +#define mwSTDERR mwLog +#endif + +#ifdef MW_HAVE_MUTEX +#define MW_MUTEX_INIT() mwMutexInit() +#define MW_MUTEX_TERM() mwMutexTerm() +#define MW_MUTEX_LOCK() mwMutexLock() +#define MW_MUTEX_UNLOCK() mwMutexUnlock() +#else +#define MW_MUTEX_INIT() +#define MW_MUTEX_TERM() +#define MW_MUTEX_LOCK() +#define MW_MUTEX_UNLOCK() +#endif + +/*********************************************************************** +** If you really, really know what you're doing, +** you can predefine these things yourself. +***********************************************************************/ + +#ifndef mwBYTE_DEFINED +# if CHAR_BIT != 8 +# error need CHAR_BIT to be 8! +# else +typedef unsigned char mwBYTE; +# define mwBYTE_DEFINED 1 +# endif +#endif + +#if defined(ULONGLONG_MAX) || defined(ULLONG_MAX) || defined(_UI64_MAX) || defined(ULONG_LONG_MAX) +# define mw64BIT 1 +# define mwROUNDALLOC_DEFAULT 8 +#else +# if UINT_MAX <= 0xFFFFUL +# define mw16BIT 1 +# define mwROUNDALLOC_DEFAULT 2 +# else +# if ULONG_MAX > 0xFFFFFFFFUL +# define mw64BIT 1 +# define mwROUNDALLOC_DEFAULT 8 +# else +# define mw32BIT 1 +# define mwROUNDALLOC_DEFAULT 4 +# endif +# endif +#endif + +/* mwROUNDALLOC is the number of bytes to */ +/* round up to, to ensure that the end of */ +/* the buffer is suitable for storage of */ +/* any kind of object */ +#ifndef mwROUNDALLOC +# define mwROUNDALLOC mwROUNDALLOC_DEFAULT +#endif + +#ifndef mwDWORD_DEFINED +#if ULONG_MAX == 0xFFFFFFFFUL +typedef unsigned long mwDWORD; +#define mwDWORD_DEFINED "unsigned long" +#endif +#endif + +#ifndef mwDWORD_DEFINED +#if UINT_MAX == 0xFFFFFFFFUL +typedef unsigned int mwDWORD; +#define mwDWORD_DEFINED "unsigned int" +#endif +#endif + +#ifndef mwDWORD_DEFINED +#if USHRT_MAX == 0xFFFFFFFFUL +typedef unsigned short mwDWORD; +#define mwDWORD_DEFINED "unsigned short" +#endif +#endif + +#ifndef mwBYTE_DEFINED +#error "can't find out the correct type for a 8 bit scalar" +#endif + +#ifndef mwDWORD_DEFINED +#error "can't find out the correct type for a 32 bit scalar" +#endif + +/*********************************************************************** +** Typedefs & structures +***********************************************************************/ + +/* main data holding area, precedes actual allocation */ +typedef struct mwData_ mwData; +struct mwData_ { + mwData* prev; /* previous allocation in chain */ + mwData* next; /* next allocation in chain */ + const char* file; /* file name where allocated */ + long count; /* action count */ + long check; /* integrity check value */ +#if 0 + long crc; /* data crc value */ +#endif + size_t size; /* size of allocation */ + int line; /* line number where allocated */ + unsigned flag; /* flag word */ + }; + +/* statistics structure */ +typedef struct mwStat_ mwStat; +struct mwStat_ { + mwStat* next; /* next statistic buffer */ + const char* file; + long total; /* total bytes allocated */ + long num; /* total number of allocations */ + long max; /* max allocated at one time */ + long curr; /* current allocations */ + int line; + }; + +/* grabbing structure, 1K in size */ +typedef struct mwGrabData_ mwGrabData; +struct mwGrabData_ { + mwGrabData* next; + int type; + char blob[ 1024 - sizeof(mwGrabData*) - sizeof(int) ]; + }; + +typedef struct mwMarker_ mwMarker; +struct mwMarker_ { + void *host; + char *text; + mwMarker *next; + int level; + }; + +#if defined(WIN32) || defined(__WIN32__) +typedef HANDLE mwMutex; +#endif + +#if defined(MW_PTHREADS) || defined(HAVE_PTHREAD_H) +typedef pthread_mutex_t mwMutex; +#endif + +/*********************************************************************** +** Static variables +***********************************************************************/ + +static int mwInited = 0; +static int mwInfoWritten = 1; +static int mwUseAtexit = 0; +static FILE* mwLog = NULL; +static int mwFlushing = 0; +static int mwStatLevel = MW_STAT_DEFAULT; +static int mwNML = MW_NML_DEFAULT; +static int mwFBI = 0; +static long mwAllocLimit = 0L; +static int mwUseLimit = 0; + +static long mwNumCurAlloc = 0L; +static mwData* mwHead = NULL; +static mwData* mwTail = NULL; +static int mwDataSize = 0; +static unsigned char mwOverflowZoneTemplate[] = "mEmwAtch"; +static int mwOverflowZoneSize = mwROUNDALLOC; + +static void (*mwOutFunction)(int) = NULL; +static int (*mwAriFunction)(const char*) = NULL; +static int mwAriAction = MW_ARI_ABORT; + +static char mwPrintBuf[MW_TRACE_BUFFER+8]; + +static unsigned long mwCounter = 0L; +static long mwErrors = 0L; + +static int mwTestFlags = 0; +static int mwTestAlways = 0; + +static FILE* mwLogB1 = NULL; +static int mwFlushingB1 = 0; + +static mwStat* mwStatList = NULL; +static long mwStatTotAlloc = 0L; +static long mwStatMaxAlloc = 0L; +static long mwStatNumAlloc = 0L; +static long mwStatCurAlloc = 0L; +static long mwNmlNumAlloc = 0L; +static long mwNmlCurAlloc = 0L; + +static mwGrabData* mwGrabList = NULL; +static long mwGrabSize = 0L; + +static void * mwLastFree[MW_FREE_LIST]; +static const char *mwLFfile[MW_FREE_LIST]; +static int mwLFline[MW_FREE_LIST]; +static int mwLFcur = 0; + +static mwMarker* mwFirstMark = NULL; + +static FILE* mwLogB2 = NULL; +static int mwFlushingB2 = 0; + +#ifdef MW_HAVE_MUTEX +static mwMutex mwGlobalMutex; +#endif + +/*********************************************************************** +** Static function declarations +***********************************************************************/ + +static void mwAutoInit( void ); +static FILE* mwLogR( void ); +/* static */ void mwLogW( FILE* ); +static int mwFlushR( void ); +static void mwFlushW( int ); +static void mwFlush( void ); +static void mwIncErr( void ); +static void mwUnlink( mwData*, const char* file, int line ); +static int mwRelink( mwData*, const char* file, int line ); +static int mwIsHeapOK( mwData *mw ); +static int mwIsOwned( mwData* mw, const char* file, int line ); +static int mwTestBuf( mwData* mw, const char* file, int line ); +static void mwDefaultOutFunc( int ); +static void mwWrite( const char* format, ... ); +static void mwLogFile( const char* name ); +static size_t mwFreeUp( size_t, int ); +static const void *mwTestMem( const void *, unsigned, int ); +static int mwStrCmpI( const char *s1, const char *s2 ); +static int mwTestNow( const char *file, int line, int always_invoked ); +static void mwDropAll( void ); +static const char *mwGrabType( int type ); +static unsigned mwGrab_( unsigned kb, int type, int silent ); +static unsigned mwDrop_( unsigned kb, int type, int silent ); +static int mwARI( const char* text ); +static void mwStatReport( void ); +static mwStat* mwStatGet( const char*, int, int ); +static void mwStatAlloc( size_t, const char*, int ); +static void mwStatFree( size_t, const char*, int ); +static int mwCheckOF( const void * p ); +static void mwWriteOF( void * p ); +static char mwDummy( char c ); +#ifdef MW_HAVE_MUTEX +static void mwMutexInit( void ); +static void mwMutexTerm( void ); +static void mwMutexLock( void ); +static void mwMutexUnlock( void ); +#endif + +/*********************************************************************** +** System functions +***********************************************************************/ + +void mwInit( void ) { + time_t tid; + + if( mwInited++ > 0 ) return; + + MW_MUTEX_INIT(); + + /* start a log if none is running */ + if( mwLogR() == NULL ) mwLogFile( "memwatch.log" ); + if( mwLogR() == NULL ) { + int i; + char buf[32]; + /* oops, could not open it! */ + /* probably because it's already open */ + /* so we try some other names */ + for( i=1; i<100; i++ ) { + sprintf( buf, "memwat%02d.log", i ); + mwLogFile( buf ); + if( mwLogR() != NULL ) break; + } + } + + /* initialize the statistics */ + mwStatList = NULL; + mwStatTotAlloc = 0L; + mwStatCurAlloc = 0L; + mwStatMaxAlloc = 0L; + mwStatNumAlloc = 0L; + mwNmlCurAlloc = 0L; + mwNmlNumAlloc = 0L; + + /* calculate the buffer size to use for a mwData */ + mwDataSize = sizeof(mwData); + while( mwDataSize % mwROUNDALLOC ) mwDataSize ++; + + /* write informational header if needed */ + if( !mwInfoWritten ) { + mwInfoWritten = 1; + (void) time( &tid ); + mwWrite( + "\n=============" + " MEMWATCH " VERSION " Copyright (C) 1992-1999 Johan Lindh " + "=============\n"); + mwWrite( "\nStarted at %s\n", ctime( &tid ) ); + +/**************************************************************** Generic */ + mwWrite( "Modes: " ); +#ifdef mwNew + mwWrite( "C++ " ); +#endif /* mwNew */ +#ifdef __STDC__ + mwWrite( "__STDC__ " ); +#endif /* __STDC__ */ +#ifdef mw16BIT + mwWrite( "16-bit " ); +#endif +#ifdef mw32BIT + mwWrite( "32-bit " ); +#endif +#ifdef mw64BIT + mwWrite( "64-bit " ); +#endif + mwWrite( "mwDWORD==(" mwDWORD_DEFINED ")\n" ); + mwWrite( "mwROUNDALLOC==%d sizeof(mwData)==%d mwDataSize==%d\n", + mwROUNDALLOC, sizeof(mwData), mwDataSize ); +/**************************************************************** Generic */ + +/************************************************************ Microsoft C */ +#ifdef _MSC_VER + mwWrite( "Compiled using Microsoft C" CPPTEXT + " %d.%02d\n", _MSC_VER / 100, _MSC_VER % 100 ); +#endif /* _MSC_VER */ +/************************************************************ Microsoft C */ + +/************************************************************** Borland C */ +#ifdef __BORLANDC__ + mwWrite( "Compiled using Borland C" +#ifdef __cplusplus + "++ %d.%01d\n", __BCPLUSPLUS__/0x100, (__BCPLUSPLUS__%0x100)/0x10 ); +#else + " %d.%01d\n", __BORLANDC__/0x100, (__BORLANDC__%0x100)/0x10 ); +#endif /* __cplusplus */ +#endif /* __BORLANDC__ */ +/************************************************************** Borland C */ + +/************************************************************** Watcom C */ +#ifdef __WATCOMC__ + mwWrite( "Compiled using Watcom C %d.%02d ", + __WATCOMC__/100, __WATCOMC__%100 ); +#ifdef __FLAT__ + mwWrite( "(32-bit flat model)" ); +#endif /* __FLAT__ */ + mwWrite( "\n" ); +#endif /* __WATCOMC__ */ +/************************************************************** Watcom C */ + + mwWrite( "\n" ); + FLUSH(); + } + + if( mwUseAtexit ) (void) atexit( mwAbort ); + return; + } + +void mwAbort( void ) { + mwData *mw; + mwMarker *mrk; + char *data; + time_t tid; + int c, i, j; + int errors; + + tid = time( NULL ); + mwWrite( "\nStopped at %s\n", ctime( &tid) ); + + if( !mwInited ) + mwWrite( "internal: mwAbort(): MEMWATCH not initialized!\n" ); + + /* release the grab list */ + mwDropAll(); + + /* report mwMarked items */ + while( mwFirstMark ) { + mrk = mwFirstMark->next; + mwWrite( "mark: %p: %s\n", mwFirstMark->host, mwFirstMark->text ); + free( mwFirstMark->text ); + free( mwFirstMark ); + mwFirstMark = mrk; + mwErrors ++; + } + + /* release all still allocated memory */ + errors = 0; + while( mwHead != NULL && errors < 3 ) { + if( !mwIsOwned(mwHead, __FILE__, __LINE__ ) ) { + if( errors < 3 ) + { + errors ++; + mwWrite( "internal: NML/unfreed scan restarting\n" ); + FLUSH(); + mwHead = mwHead; + continue; + } + mwWrite( "internal: NML/unfreed scan aborted, heap too damaged\n" ); + FLUSH(); + break; + } + mwFlushW(0); + if( !(mwHead->flag & MW_NML) ) { + mwErrors++; + data = ((char*)mwHead)+mwDataSize; + mwWrite( "unfreed: <%ld> %s(%d), %ld bytes at %p ", + mwHead->count, mwHead->file, mwHead->line, (long)mwHead->size, data+mwOverflowZoneSize ); + if( mwCheckOF( data ) ) { + mwWrite( "[underflowed] "); + FLUSH(); + } + if( mwCheckOF( (data+mwOverflowZoneSize+mwHead->size) ) ) { + mwWrite( "[overflowed] "); + FLUSH(); + } + mwWrite( " \t{" ); + j = 16; if( mwHead->size < 16 ) j = (int) mwHead->size; + for( i=0;i<16;i++ ) { + if( i 126 ) c = '.'; + mwWrite( "%c", c ); + } + mwWrite( "}\n" ); + mw = mwHead; + mwUnlink( mw, __FILE__, __LINE__ ); + free( mw ); + } + else { + data = ((char*)mwHead) + mwDataSize + mwOverflowZoneSize; + if( mwTestMem( data, mwHead->size, MW_VAL_NML ) ) { + mwErrors++; + mwWrite( "wild pointer: <%ld> NoMansLand %p alloc'd at %s(%d)\n", + mwHead->count, data + mwOverflowZoneSize, mwHead->file, mwHead->line ); + FLUSH(); + } + mwNmlNumAlloc --; + mwNmlCurAlloc -= mwHead->size; + mw = mwHead; + mwUnlink( mw, __FILE__, __LINE__ ); + free( mw ); + } + } + + if( mwNmlNumAlloc ) mwWrite("internal: NoMansLand block counter %ld, not zero\n", mwNmlNumAlloc ); + if( mwNmlCurAlloc ) mwWrite("internal: NoMansLand byte counter %ld, not zero\n", mwNmlCurAlloc ); + + /* report statistics */ + mwStatReport(); + FLUSH(); + + mwInited = 0; + mwHead = mwTail = NULL; + if( mwErrors ) + fprintf(mwSTDERR,"MEMWATCH detected %ld anomalies\n",mwErrors); + mwLogFile( NULL ); + mwErrors = 0; + + MW_MUTEX_TERM(); + + } + +void mwTerm( void ) { + if( mwInited == 1 ) + { + mwAbort(); + return; + } + if( !mwInited ) + mwWrite("internal: mwTerm(): MEMWATCH has not been started!\n"); + else + mwInited --; + } + +void mwStatistics( int level ) +{ + mwAutoInit(); + if( level<0 ) level=0; + if( mwStatLevel != level ) + { + mwWrite( "statistics: now collecting on a %s basis\n", + level<1?"global":(level<2?"module":"line") ); + mwStatLevel = level; + } +} + +void mwAutoCheck( int onoff ) { + mwAutoInit(); + mwTestAlways = onoff; + if( onoff ) mwTestFlags = MW_TEST_ALL; + } + +void mwSetOutFunc( void (*func)(int) ) { + mwAutoInit(); + mwOutFunction = func; + } + +static void mwWriteOF( void *p ) +{ + int i; + unsigned char *ptr; + ptr = (unsigned char*) p; + for( i=0; inext is not always set? +*/ +void * mwMark( void *p, const char *desc, const char *file, unsigned line ) { + mwMarker *mrk; + unsigned n, isnew; + char *buf; + int tot, oflow = 0; + char wherebuf[128]; + + mwAutoInit(); + TESTS(NULL,0); + + if( desc == NULL ) desc = "unknown"; + if( file == NULL ) file = "unknown"; + + tot = sprintf( wherebuf, "%.48s called from %s(%d)", desc, file, line ); + if( tot >= (int)sizeof(wherebuf) ) { wherebuf[sizeof(wherebuf)-1] = 0; oflow = 1; } + + if( p == NULL ) { + mwWrite("mark: %s(%d), no mark for NULL:'%s' may be set\n", file, line, desc ); + return p; + } + + if( mwFirstMark != NULL && !mwIsReadAddr( mwFirstMark, sizeof( mwMarker ) ) ) + { + mwWrite("mark: %s(%d), mwFirstMark (%p) is trashed, can't mark for %s\n", + file, line, mwFirstMark, desc ); + return p; + } + + for( mrk=mwFirstMark; mrk; mrk=mrk->next ) + { + if( mrk->next != NULL && !mwIsReadAddr( mrk->next, sizeof( mwMarker ) ) ) + { + mwWrite("mark: %s(%d), mark(%p)->next(%p) is trashed, can't mark for %s\n", + file, line, mrk, mrk->next, desc ); + return p; + } + if( mrk->host == p ) break; + } + + if( mrk == NULL ) { + isnew = 1; + mrk = (mwMarker*) malloc( sizeof( mwMarker ) ); + if( mrk == NULL ) { + mwWrite("mark: %s(%d), no mark for %p:'%s', out of memory\n", file, line, p, desc ); + return p; + } + mrk->next = NULL; + n = 0; + } + else { + isnew = 0; + n = strlen( mrk->text ); + } + + n += strlen( wherebuf ); + buf = (char*) malloc( n+3 ); + if( buf == NULL ) { + if( isnew ) free( mrk ); + mwWrite("mark: %s(%d), no mark for %p:'%s', out of memory\n", file, line, p, desc ); + return p; + } + + if( isnew ) { + memcpy( buf, wherebuf, n+1 ); + mrk->next = mwFirstMark; + mrk->host = p; + mrk->text = buf; + mrk->level = 1; + mwFirstMark = mrk; + } + else { + strcpy( buf, mrk->text ); + strcat( buf, ", " ); + strcat( buf, wherebuf ); + free( mrk->text ); + mrk->text = buf; + mrk->level ++; + } + + if( oflow ) { + mwIncErr(); + mwTrace( " [WARNING: OUTPUT BUFFER OVERFLOW - SYSTEM UNSTABLE]\n" ); + } + return p; + } + +void* mwUnmark( void *p, const char *file, unsigned line ) { + mwMarker *mrk, *prv; + mrk = mwFirstMark; + prv = NULL; + while( mrk ) { + if( mrk->host == p ) { + if( mrk->level < 2 ) { + if( prv ) prv->next = mrk->next; + else mwFirstMark = mrk->next; + free( mrk->text ); + free( mrk ); + return p; + } + mrk->level --; + return p; + } + prv = mrk; + mrk = mrk->next; + } + mwWrite("mark: %s(%d), no mark found for %p\n", file, line, p ); + return p; + } + + +/*********************************************************************** +** Abort/Retry/Ignore handlers +***********************************************************************/ + +static int mwARI( const char *estr ) { + char inbuf[81]; + int c; + fprintf(mwSTDERR, "\n%s\nMEMWATCH: Abort, Retry or Ignore? ", estr); + (void) fgets(inbuf,sizeof(inbuf),stdin); + for( c=0; inbuf[c] && inbuf[c] <= ' '; c++ ) ; + c = inbuf[c]; + if( c == 'R' || c == 'r' ) { + mwBreakOut( estr ); + return MW_ARI_RETRY; + } + if( c == 'I' || c == 'i' ) return MW_ARI_IGNORE; + return MW_ARI_ABORT; + } + +/* standard ARI handler (exported) */ +int mwAriHandler( const char *estr ) { + mwAutoInit(); + return mwARI( estr ); + } + +/* used to set the ARI function */ +void mwSetAriFunc( int (*func)(const char *) ) { + mwAutoInit(); + mwAriFunction = func; + } + +/*********************************************************************** +** Allocation handlers +***********************************************************************/ + +void* mwMalloc( size_t size, const char* file, int line) { + size_t needed; + mwData *mw; + char *ptr; + void *p; + + mwAutoInit(); + + MW_MUTEX_LOCK(); + + TESTS(file,line); + + mwCounter ++; + needed = mwDataSize + mwOverflowZoneSize*2 + size; + if( needed < size ) + { + /* theoretical case: req size + mw overhead exceeded size_t limits */ + return NULL; + } + + /* if this allocation would violate the limit, fail it */ + if( mwUseLimit && ((long)size + mwStatCurAlloc > mwAllocLimit) ) { + mwWrite( "limit fail: <%ld> %s(%d), %ld wanted %ld available\n", + mwCounter, file, line, (long)size, mwAllocLimit - mwStatCurAlloc ); + mwIncErr(); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + + mw = (mwData*) malloc( needed ); + if( mw == NULL ) { + if( mwFreeUp(needed,0) >= needed ) { + mw = (mwData*) malloc(needed); + if( mw == NULL ) { + mwWrite( "internal: mwFreeUp(%u) reported success, but malloc() fails\n", needed ); + mwIncErr(); + FLUSH(); + } + } + if( mw == NULL ) { + mwWrite( "fail: <%ld> %s(%d), %ld wanted %ld allocated\n", + mwCounter, file, line, (long)size, mwStatCurAlloc ); + mwIncErr(); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + } + + mw->count = mwCounter; + mw->prev = NULL; + mw->next = mwHead; + mw->file = file; + mw->size = size; + mw->line = line; + mw->flag = 0; + mw->check = CHKVAL(mw); + + if( mwHead ) mwHead->prev = mw; + mwHead = mw; + if( mwTail == NULL ) mwTail = mw; + + ptr = ((char*)mw) + mwDataSize; + mwWriteOF( ptr ); /* '*(long*)ptr = PRECHK;' */ + ptr += mwOverflowZoneSize; + p = ptr; + memset( ptr, MW_VAL_NEW, size ); + ptr += size; + mwWriteOF( ptr ); /* '*(long*)ptr = POSTCHK;' */ + + mwNumCurAlloc ++; + mwStatCurAlloc += (long) size; + mwStatTotAlloc += (long) size; + if( mwStatCurAlloc > mwStatMaxAlloc ) + mwStatMaxAlloc = mwStatCurAlloc; + mwStatNumAlloc ++; + + if( mwStatLevel ) mwStatAlloc( size, file, line ); + + MW_MUTEX_UNLOCK(); + return p; + } + +void* mwRealloc( void *p, size_t size, const char* file, int line) { + int oldUseLimit, i; + mwData *mw; + char *ptr; + + mwAutoInit(); + + if( p == NULL ) return mwMalloc( size, file, line ); + if( size == 0 ) { mwFree( p, file, line ); return NULL; } + + MW_MUTEX_LOCK(); + + /* do the quick ownership test */ + mw = (mwData*) mwBUFFER_TO_MW( p ); + if( mwIsOwned( mw, file, line ) ) { + + /* if the buffer is an NML, treat this as a double-free */ + if( mw->flag & MW_NML ) + { + mwIncErr(); + if( *((unsigned char*)(mw)+mwDataSize+mwOverflowZoneSize) != MW_VAL_NML ) + { + mwWrite( "internal: <%ld> %s(%d), no-mans-land MW-%p is corrupted\n", + mwCounter, file, line, mw ); + } + goto check_dbl_free; + } + + /* if this allocation would violate the limit, fail it */ + if( mwUseLimit && ((long)size + mwStatCurAlloc - (long)mw->size > mwAllocLimit) ) { + TESTS(file,line); + mwCounter ++; + mwWrite( "limit fail: <%ld> %s(%d), %ld wanted %ld available\n", + mwCounter, file, line, (unsigned long)size - mw->size, mwAllocLimit - mwStatCurAlloc ); + mwIncErr(); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + + /* fake realloc operation */ + oldUseLimit = mwUseLimit; + mwUseLimit = 0; + ptr = (char*) mwMalloc( size, file, line ); + if( ptr != NULL ) { + if( size < mw->size ) + memcpy( ptr, p, size ); + else + memcpy( ptr, p, mw->size ); + mwFree( p, file, line ); + } + mwUseLimit = oldUseLimit; + MW_MUTEX_UNLOCK(); + return (void*) ptr; + } + + /* Unknown pointer! */ + + /* using free'd pointer? */ +check_dbl_free: + for(i=0;i %s(%d), %p was" + " freed from %s(%d)\n", + mwCounter, file, line, p, + mwLFfile[i], mwLFline[i] ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + } + + /* some weird pointer */ + mwIncErr(); + mwWrite( "realloc: <%ld> %s(%d), unknown pointer %p\n", + mwCounter, file, line, p ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + +char *mwStrdup( const char* str, const char* file, int line ) { + size_t len; + char *newstring; + + MW_MUTEX_LOCK(); + + if( str == NULL ) { + mwIncErr(); + mwWrite( "strdup: <%ld> %s(%d), strdup(NULL) called\n", + mwCounter, file, line ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return NULL; + } + + len = strlen( str ) + 1; + newstring = (char*) mwMalloc( len, file, line ); + if( newstring != NULL ) memcpy( newstring, str, len ); + MW_MUTEX_UNLOCK(); + return newstring; + } + +void mwFree( void* p, const char* file, int line ) { + int i; + mwData* mw; + char buffer[ sizeof(mwData) + (mwROUNDALLOC*3) + 64 ]; + + /* this code is in support of C++ delete */ + if( file == NULL ) { + mwFree_( p ); + MW_MUTEX_UNLOCK(); + return; + } + + mwAutoInit(); + + MW_MUTEX_LOCK(); + TESTS(file,line); + mwCounter ++; + + /* on NULL free, write a warning and return */ + if( p == NULL ) { + mwWrite( "NULL free: <%ld> %s(%d), NULL pointer free'd\n", + mwCounter, file, line ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return; + } + + /* do the quick ownership test */ + mw = (mwData*) mwBUFFER_TO_MW( p ); + + if( mwIsOwned( mw, file, line ) ) { + (void) mwTestBuf( mw, file, line ); + + /* if the buffer is an NML, treat this as a double-free */ + if( mw->flag & MW_NML ) + { + if( *(((unsigned char*)mw)+mwDataSize+mwOverflowZoneSize) != MW_VAL_NML ) + { + mwWrite( "internal: <%ld> %s(%d), no-mans-land MW-%p is corrupted\n", + mwCounter, file, line, mw ); + } + goto check_dbl_free; + } + + /* update the statistics */ + mwNumCurAlloc --; + mwStatCurAlloc -= (long) mw->size; + if( mwStatLevel ) mwStatFree( mw->size, mw->file, mw->line ); + + /* we should either free the allocation or keep it as NML */ + if( mwNML ) { + mw->flag |= MW_NML; + mwNmlNumAlloc ++; + mwNmlCurAlloc += (long) mw->size; + memset( ((char*)mw)+mwDataSize+mwOverflowZoneSize, MW_VAL_NML, mw->size ); + } + else { + /* unlink the allocation, and enter the post-free data */ + mwUnlink( mw, file, line ); + memset( mw, MW_VAL_DEL, + mw->size + mwDataSize+mwOverflowZoneSize+mwOverflowZoneSize ); + if( mwFBI ) { + memset( mw, '.', mwDataSize + mwOverflowZoneSize ); + sprintf( buffer, "FBI<%ld>%s(%d)", mwCounter, file, line ); + strncpy( (char*)(void*)mw, buffer, mwDataSize + mwOverflowZoneSize ); + } + free( mw ); + } + + /* add the pointer to the last-free track */ + mwLFfile[ mwLFcur ] = file; + mwLFline[ mwLFcur ] = line; + mwLastFree[ mwLFcur++ ] = p; + if( mwLFcur == MW_FREE_LIST ) mwLFcur = 0; + + MW_MUTEX_UNLOCK(); + return; + } + + /* check for double-freeing */ +check_dbl_free: + for(i=0;i %s(%d), %p was" + " freed from %s(%d)\n", + mwCounter, file, line, p, + mwLFfile[i], mwLFline[i] ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return; + } + } + + /* some weird pointer... block the free */ + mwIncErr(); + mwWrite( "WILD free: <%ld> %s(%d), unknown pointer %p\n", + mwCounter, file, line, p ); + FLUSH(); + MW_MUTEX_UNLOCK(); + return; + } + +void* mwCalloc( size_t a, size_t b, const char *file, int line ) { + void *p; + size_t size = a * b; + p = mwMalloc( size, file, line ); + if( p == NULL ) return NULL; + memset( p, 0, size ); + return p; + } + +void mwFree_( void *p ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + free(p); + } + +void* mwMalloc_( size_t size ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + return malloc( size ); + } + +void* mwRealloc_( void *p, size_t size ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + return realloc( p, size ); + } + +void* mwCalloc_( size_t a, size_t b ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + MW_MUTEX_UNLOCK(); + return calloc( a, b ); + } + +void mwFlushNow( void ) { + if( mwLogR() ) fflush( mwLogR() ); + return; + } + +void mwDoFlush( int onoff ) { + mwFlushW( onoff<1?0:onoff ); + if( onoff ) if( mwLogR() ) fflush( mwLogR() ); + return; + } + +void mwLimit( long lim ) { + TESTS(NULL,0); + mwWrite("limit: old limit = "); + if( !mwAllocLimit ) mwWrite( "none" ); + else mwWrite( "%ld bytes", mwAllocLimit ); + mwWrite( ", new limit = "); + if( !lim ) { + mwWrite( "none\n" ); + mwUseLimit = 0; + } + else { + mwWrite( "%ld bytes\n", lim ); + mwUseLimit = 1; + } + mwAllocLimit = lim; + FLUSH(); + } + +void mwSetAriAction( int action ) { + MW_MUTEX_LOCK(); + TESTS(NULL,0); + mwAriAction = action; + MW_MUTEX_UNLOCK(); + return; + } + +int mwAssert( int exp, const char *exps, const char *fn, int ln ) { + int i; + char buffer[MW_TRACE_BUFFER+8]; + if( exp ) { + return 0; + } + mwAutoInit(); + MW_MUTEX_LOCK(); + TESTS(fn,ln); + mwIncErr(); + mwCounter++; + mwWrite( "assert trap: <%ld> %s(%d), %s\n", mwCounter, fn, ln, exps ); + if( mwAriFunction != NULL ) { + sprintf( buffer, "MEMWATCH: assert trap: %s(%d), %s", fn, ln, exps ); + i = (*mwAriFunction)(buffer); + switch( i ) { + case MW_ARI_IGNORE: + mwWrite( "assert trap: <%ld> IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + case MW_ARI_RETRY: + mwWrite( "assert trap: <%ld> RETRY - executing again\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 1; + } + } + else { + if( mwAriAction & MW_ARI_IGNORE ) { + mwWrite( "assert trap: <%ld> AUTO IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + } + fprintf(mwSTDERR,"\nMEMWATCH: assert trap: %s(%d), %s\n", fn, ln, exps ); + } + + FLUSH(); + (void) mwTestNow( fn, ln, 1 ); + FLUSH(); + + if( mwAriAction & MW_ARI_NULLREAD ) { + /* This is made in an attempt to kick in */ + /* any debuggers or OS stack traces */ + FLUSH(); + /*lint -save -e413 */ + i = *((int*)NULL); + mwDummy( (char)i ); + /*lint -restore */ + } + + MW_MUTEX_UNLOCK(); + exit(255); + /* NOT REACHED - the return statement is in to keep */ + /* stupid compilers from squeaking about differing return modes. */ + /* Smart compilers instead say 'code unreachable...' */ + /*lint -save -e527 */ + return 0; + /*lint -restore */ + } + +int mwVerify( int exp, const char *exps, const char *fn, int ln ) { + int i; + char buffer[MW_TRACE_BUFFER+8]; + if( exp ) { + return 0; + } + mwAutoInit(); + MW_MUTEX_LOCK(); + TESTS(fn,ln); + mwIncErr(); + mwCounter++; + mwWrite( "verify trap: <%ld> %s(%d), %s\n", mwCounter, fn, ln, exps ); + if( mwAriFunction != NULL ) { + sprintf( buffer, "MEMWATCH: verify trap: %s(%d), %s", fn, ln, exps ); + i = (*mwAriFunction)(buffer); + if( i == 0 ) { + mwWrite( "verify trap: <%ld> IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + } + if( i == 1 ) { + mwWrite( "verify trap: <%ld> RETRY - executing again\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 1; + } + } + else { + if( mwAriAction & MW_ARI_NULLREAD ) { + /* This is made in an attempt to kick in */ + /* any debuggers or OS stack traces */ + FLUSH(); + /*lint -save -e413 */ + i = *((int*)NULL); + mwDummy( (char)i ); + /*lint -restore */ + } + if( mwAriAction & MW_ARI_IGNORE ) { + mwWrite( "verify trap: <%ld> AUTO IGNORED - execution continues\n", mwCounter ); + MW_MUTEX_UNLOCK(); + return 0; + } + fprintf(mwSTDERR,"\nMEMWATCH: verify trap: %s(%d), %s\n", fn, ln, exps ); + } + FLUSH(); + (void) mwTestNow( fn, ln, 1 ); + FLUSH(); + MW_MUTEX_UNLOCK(); + exit(255); + /* NOT REACHED - the return statement is in to keep */ + /* stupid compilers from squeaking about differing return modes. */ + /* Smart compilers instead say 'code unreachable...' */ + /*lint -save -e527 */ + return 0; + /*lint -restore */ + } + +void mwTrace( const char *format, ... ) { + int tot, oflow = 0; + va_list mark; + + mwAutoInit(); + MW_MUTEX_LOCK(); + TESTS(NULL,0); + if( mwOutFunction == NULL ) mwOutFunction = mwDefaultOutFunc; + + va_start( mark, format ); + tot = vsprintf( mwPrintBuf, format, mark ); + va_end( mark ); + if( tot >= MW_TRACE_BUFFER ) { mwPrintBuf[MW_TRACE_BUFFER] = 0; oflow = 1; } + for(tot=0;mwPrintBuf[tot];tot++) + (*mwOutFunction)( mwPrintBuf[tot] ); + if( oflow ) { + mwIncErr(); + mwTrace( " [WARNING: OUTPUT BUFFER OVERFLOW - SYSTEM UNSTABLE]\n" ); + } + + FLUSH(); + MW_MUTEX_UNLOCK(); + } + + +/*********************************************************************** +** Grab & Drop +***********************************************************************/ + +unsigned mwGrab( unsigned kb ) { + TESTS(NULL,0); + return mwGrab_( kb, MW_VAL_GRB, 0 ); + } + +unsigned mwDrop( unsigned kb ) { + TESTS(NULL,0); + return mwDrop_( kb, MW_VAL_GRB, 0 ); + } + +static void mwDropAll() { + TESTS(NULL,0); + (void) mwDrop_( 0, MW_VAL_GRB, 0 ); + (void) mwDrop_( 0, MW_VAL_NML, 0 ); + if( mwGrabList != NULL ) + mwWrite( "internal: the grab list is not empty after mwDropAll()\n"); + } + +static const char *mwGrabType( int type ) { + switch( type ) { + case MW_VAL_GRB: + return "grabbed"; + case MW_VAL_NML: + return "no-mans-land"; + default: + /* do nothing */ + ; + } + return ""; + } + +static unsigned mwGrab_( unsigned kb, int type, int silent ) { + unsigned i = kb; + mwGrabData *gd; + if( !kb ) i = kb = 65000U; + + for(;kb;kb--) { + if( mwUseLimit && + (mwStatCurAlloc + mwGrabSize + (long)sizeof(mwGrabData) > mwAllocLimit) ) { + if( !silent ) { + mwWrite("grabbed: all allowed memory to %s (%u kb)\n", + mwGrabType(type), i-kb); + FLUSH(); + } + return i-kb; + } + gd = (mwGrabData*) malloc( sizeof(mwGrabData) ); + if( gd == NULL ) { + if( !silent ) { + mwWrite("grabbed: all available memory to %s (%u kb)\n", + mwGrabType(type), i-kb); + FLUSH(); + } + return i-kb; + } + mwGrabSize += (long) sizeof(mwGrabData); + gd->next = mwGrabList; + memset( gd->blob, type, sizeof(gd->blob) ); + gd->type = type; + mwGrabList = gd; + } + if( !silent ) { + mwWrite("grabbed: %u kilobytes of %s memory\n", i, mwGrabType(type) ); + FLUSH(); + } + return i; + } + +static unsigned mwDrop_( unsigned kb, int type, int silent ) { + unsigned i = kb; + mwGrabData *gd,*tmp,*pr; + const void *p; + + if( mwGrabList == NULL && kb == 0 ) return 0; + if( !kb ) i = kb = 60000U; + + pr = NULL; + gd = mwGrabList; + for(;kb;) { + if( gd == NULL ) { + if( i-kb > 0 && !silent ) { + mwWrite("dropped: all %s memory (%u kb)\n", mwGrabType(type), i-kb); + FLUSH(); + } + return i-kb; + } + if( gd->type == type ) { + if( pr ) pr->next = gd->next; + kb --; + tmp = gd; + if( mwGrabList == gd ) mwGrabList = gd->next; + gd = gd->next; + p = mwTestMem( tmp->blob, sizeof( tmp->blob ), type ); + if( p != NULL ) { + mwWrite( "wild pointer: <%ld> %s memory hit at %p\n", + mwCounter, mwGrabType(type), p ); + FLUSH(); + } + mwGrabSize -= (long) sizeof(mwGrabData); + free( tmp ); + } + else { + pr = gd; + gd = gd->next; + } + } + if( !silent ) { + mwWrite("dropped: %u kilobytes of %s memory\n", i, mwGrabType(type) ); + FLUSH(); + } + return i; + } + +/*********************************************************************** +** No-Mans-Land +***********************************************************************/ + +void mwNoMansLand( int level ) { + mwAutoInit(); + TESTS(NULL,0); + switch( level ) { + case MW_NML_NONE: + (void) mwDrop_( 0, MW_VAL_NML, 0 ); + break; + case MW_NML_FREE: + break; + case MW_NML_ALL: + (void) mwGrab_( 0, MW_VAL_NML, 0 ); + break; + default: + return; + } + mwNML = level; + } + +/*********************************************************************** +** Static functions +***********************************************************************/ + +static void mwAutoInit( void ) +{ + if( mwInited ) return; + mwUseAtexit = 1; + mwInit(); + return; +} + +static FILE *mwLogR() { + if( (mwLog == mwLogB1) && (mwLog == mwLogB2) ) return mwLog; + if( mwLog == mwLogB1 ) mwLogB2 = mwLog; + if( mwLog == mwLogB2 ) mwLogB1 = mwLog; + if( mwLogB1 == mwLogB2 ) mwLog = mwLogB1; + if( (mwLog == mwLogB1) && (mwLog == mwLogB2) ) { + mwWrite("internal: log file handle damaged and recovered\n"); + FLUSH(); + return mwLog; + } + fprintf(mwSTDERR,"\nMEMWATCH: log file handle destroyed, using mwSTDERR\n" ); + mwLog = mwLogB1 = mwLogB2 = mwSTDERR; + return mwSTDERR; + } + +/* static */ void mwLogW( FILE *p ) { + mwLog = mwLogB1 = mwLogB2 = p; + } + +static int mwFlushR() { + if( (mwFlushing == mwFlushingB1) && (mwFlushing == mwFlushingB2) ) return mwFlushing; + if( mwFlushing == mwFlushingB1 ) mwFlushingB2 = mwFlushing; + if( mwFlushing == mwFlushingB2 ) mwFlushingB1 = mwFlushing; + if( mwFlushingB1 == mwFlushingB2 ) mwFlushing = mwFlushingB1; + if( (mwFlushing == mwFlushingB1) && (mwFlushing == mwFlushingB2) ) { + mwWrite("internal: flushing flag damaged and recovered\n"); + FLUSH(); + return mwFlushing; + } + mwWrite("internal: flushing flag destroyed, so set to true\n"); + mwFlushing = mwFlushingB1 = mwFlushingB2 = 1; + return 1; + } + +static void mwFlushW( int n ) { + mwFlushing = mwFlushingB1 = mwFlushingB2 = n; + } + +static void mwIncErr() { + mwErrors++; + mwFlushW( mwFlushR()+1 ); + FLUSH(); + } + +static void mwFlush() { + if( mwLogR() == NULL ) return; +#ifdef MW_FLUSH + fflush( mwLogR() ); +#else + if( mwFlushR() ) fflush( mwLogR() ); +#endif + return; + } + +static void mwUnlink( mwData* mw, const char* file, int line ) { + if( mw->prev == NULL ) { + if( mwHead != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link1 NULL, but not head\n", + mwCounter, file, line, mw ); + mwHead = mw->next; + } + else { + if( mw->prev->next != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link1 failure\n", + mwCounter, file, line, mw ); + else mw->prev->next = mw->next; + } + if( mw->next == NULL ) { + if( mwTail != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link2 NULL, but not tail\n", + mwCounter, file, line, mw ); + mwTail = mw->prev; + } + else { + if( mw->next->prev != mw ) + mwWrite( "internal: <%ld> %s(%d), MW-%p: link2 failure\n", + mwCounter, file, line, mw ); + else mw->next->prev = mw->prev; + } + } + +/* +** Relinking tries to repair a damaged mw block. +** Returns nonzero if it thinks it successfully +** repaired the heap chain. +*/ +static int mwRelink( mwData* mw, const char* file, int line ) { + int fails; + mwData *mw1, *mw2; + long count, size; + mwStat *ms; + + if( file == NULL ) file = "unknown"; + + if( mw == NULL ) { + mwWrite("relink: cannot repair MW at NULL\n"); + FLUSH(); + goto emergency; + } + + if( !mwIsSafeAddr(mw, mwDataSize) ) { + mwWrite("relink: MW-%p is a garbage pointer\n", mw); + FLUSH(); + goto emergency; + } + + mwWrite("relink: <%ld> %s(%d) attempting to repair MW-%p...\n", mwCounter, file, line, mw ); + FLUSH(); + fails = 0; + + /* Repair from head */ + if( mwHead != mw ) { + if( !mwIsSafeAddr( mwHead, mwDataSize ) ) { + mwWrite("relink: failed for MW-%p; head pointer destroyed\n", mw ); + FLUSH(); + goto emergency; + } + for( mw1=mwHead; mw1; mw1=mw1->next ) { + if( mw1->next == mw ) { + mw->prev = mw1; + break; + } + if( mw1->next && + ( !mwIsSafeAddr(mw1->next, mwDataSize ) || mw1->next->prev != mw1) ) { + mwWrite("relink: failed for MW-%p; forward chain fragmented at MW-%p: 'next' is %p\n", mw, mw1, mw1->next ); + FLUSH(); + goto emergency; + } + } + if( mw1 == NULL ) { + mwWrite("relink: MW-%p not found in forward chain search\n", mw ); + FLUSH(); + fails ++; + } + } + else + { + mwWrite( "relink: MW-%p is the head (first) allocation\n", mw ); + if( mw->prev != NULL ) + { + mwWrite( "relink: MW-%p prev pointer is non-NULL, you have a wild pointer\n", mw ); + mw->prev = NULL; + } + } + + /* Repair from tail */ + if( mwTail != mw ) { + if( !mwIsSafeAddr( mwTail, mwDataSize ) ) { + mwWrite("relink: failed for MW-%p; tail pointer destroyed\n", mw ); + FLUSH(); + goto emergency; + } + for( mw1=mwTail; mw1; mw1=mw1->prev ) { + if( mw1->prev == mw ) { + mw->next = mw1; + break; + } + if( mw1->prev && (!mwIsSafeAddr(mw1->prev, mwDataSize ) || mw1->prev->next != mw1) ) { + mwWrite("relink: failed for MW-%p; reverse chain fragmented at MW-%p, 'prev' is %p\n", mw, mw1, mw1->prev ); + FLUSH(); + goto emergency; + } + } + if( mw1 == NULL ) { + mwWrite("relink: MW-%p not found in reverse chain search\n", mw ); + FLUSH(); + fails ++; + } + } + else + { + mwWrite( "relink: MW-%p is the tail (last) allocation\n", mw ); + if( mw->next != NULL ) + { + mwWrite( "relink: MW-%p next pointer is non-NULL, you have a wild pointer\n", mw ); + mw->next = NULL; + } + } + + if( fails > 1 ) { + mwWrite("relink: heap appears intact, MW-%p probably garbage pointer\n", mw ); + FLUSH(); + goto verifyok; + } + + /* restore MW info where possible */ + if( mwIsReadAddr( mw->file, 1 ) ) { + ms = mwStatGet( mw->file, -1, 0 ); + if( ms == NULL ) mw->file = ""; + } + mw->check = CHKVAL(mw); + goto verifyok; + + /* Emergency repair */ + emergency: + + if( mwHead == NULL && mwTail == NULL ) + { + if( mwStatCurAlloc == 0 ) + mwWrite("relink: <%ld> %s(%d) heap is empty, nothing to repair\n", mwCounter, file, line ); + else + mwWrite("relink: <%ld> %s(%d) heap damaged beyond repair\n", mwCounter, file, line ); + FLUSH(); + return 0; + } + + mwWrite("relink: <%ld> %s(%d) attempting emergency repairs...\n", mwCounter, file, line ); + FLUSH(); + + if( mwHead == NULL || mwTail == NULL ) + { + if( mwHead == NULL ) mwWrite("relink: mwHead is NULL, but mwTail is %p\n", mwTail ); + else mwWrite("relink: mwTail is NULL, but mwHead is %p\n", mwHead ); + } + + mw1=NULL; + if( mwHead != NULL ) + { + if( !mwIsReadAddr( mwHead, mwDataSize ) || mwHead->check != CHKVAL(mwHead) ) + { + mwWrite("relink: mwHead (MW-%p) is damaged, skipping forward scan\n", mwHead ); + mwHead = NULL; + goto scan_reverse; + } + if( mwHead->prev != NULL ) + { + mwWrite("relink: the mwHead pointer's 'prev' member is %p, not NULL\n", mwHead->prev ); + } + for( mw1=mwHead; mw1; mw1=mw1->next ) + { + if( mw1->next ) + { + if( !mwIsReadAddr(mw1->next,mwDataSize) || + (!mw1->next->check) != CHKVAL(mw1) || + mw1->next->prev != mw1 ) + { + mwWrite("relink: forward chain's last intact MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw1, mw1->size, (mw->flag & MW_NML)?"NoMansLand ":"", mw1->file, mw1->line ); + if( mwIsReadAddr(mw1->next,mwDataSize ) ) + { + mwWrite("relink: forward chain's first damaged MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw1->next, mw1->size, (mw->flag & MW_NML)?"NoMansLand ":"", + mwIsReadAddr(mw1->file,16)?mw1->file:"", mw1->line ); + } + else + { + mwWrite("relink: the 'next' pointer of this MW points to %p, which is out-of-legal-access\n", + mw1->next ); + } + break; + } + } + } + } + + +scan_reverse: + mw2=NULL; + if( mwTail != NULL ) + { + if( !mwIsReadAddr(mwTail,mwDataSize) || mwTail->check != CHKVAL(mwTail) ) + { + mwWrite("relink: mwTail (%p) is damaged, skipping reverse scan\n", mwTail ); + mwTail = NULL; + goto analyze; + } + if( mwTail->next != NULL ) + { + mwWrite("relink: the mwTail pointer's 'next' member is %p, not NULL\n", mwTail->next ); + } + for( mw2=mwTail; mw2; mw2=mw2->prev ) + { + if( mw2->prev ) + { + if( !mwIsReadAddr(mw2->prev,mwDataSize) || + (!mw2->prev->check) != CHKVAL(mw2) || + mw2->prev->next != mw2 ) + { + mwWrite("relink: reverse chain's last intact MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw2, mw2->size, (mw->flag & MW_NML)?"NoMansLand ":"", mw2->file, mw2->line ); + if( mwIsReadAddr(mw2->prev,mwDataSize ) ) + { + mwWrite("relink: reverse chain's first damaged MW is MW-%p, %ld %sbytes at %s(%d)\n", + mw2->prev, mw2->size, (mw->flag & MW_NML)?"NoMansLand ":"", + mwIsReadAddr(mw2->file,16)?mw2->file:"", mw2->line ); + } + else + { + mwWrite("relink: the 'prev' pointer of this MW points to %p, which is out-of-legal-access\n", + mw2->prev ); + } + break; + } + } + } + } + +analyze: + if( mwHead == NULL && mwTail == NULL ) + { + mwWrite("relink: both head and tail pointers damaged, aborting program\n"); + mwFlushW(1); + FLUSH(); + abort(); + } + if( mwHead == NULL ) + { + mwHead = mw2; + mwWrite("relink: heap truncated, MW-%p designated as new mwHead\n", mw2 ); + mw2->prev = NULL; + mw1 = mw2 = NULL; + } + if( mwTail == NULL ) + { + mwTail = mw1; + mwWrite("relink: heap truncated, MW-%p designated as new mwTail\n", mw1 ); + mw1->next = NULL; + mw1 = mw2 = NULL; + } + if( mw1 == NULL && mw2 == NULL && + mwHead->prev == NULL && mwTail->next == NULL ) { + mwWrite("relink: verifying heap integrity...\n" ); + FLUSH(); + goto verifyok; + } + if( mw1 && mw2 && mw1 != mw2 ) { + mw1->next = mw2; + mw2->prev = mw1; + mwWrite("relink: emergency repairs successful, assessing damage...\n"); + FLUSH(); + } + else { + mwWrite("relink: heap totally destroyed, aborting program\n"); + mwFlushW(1); + FLUSH(); + abort(); + } + + /* Verify by checking that the number of active allocations */ + /* match the number of entries in the chain */ +verifyok: + if( !mwIsHeapOK( NULL ) ) { + mwWrite("relink: heap verification FAILS - aborting program\n"); + mwFlushW(1); + FLUSH(); + abort(); + } + for( size=count=0, mw1=mwHead; mw1; mw1=mw1->next ) { + count ++; + size += (long) mw1->size; + } + if( count == mwNumCurAlloc ) { + mwWrite("relink: successful, "); + if( size == mwStatCurAlloc ) { + mwWrite("no allocations lost\n"); + } + else { + if( mw != NULL ) { + mwWrite("size information lost for MW-%p\n", mw); + mw->size = 0; + } + } + } + else { + mwWrite("relink: partial, %ld MW-blocks of %ld bytes lost\n", + mwNmlNumAlloc+mwNumCurAlloc-count, mwNmlCurAlloc+mwStatCurAlloc-size ); + return 0; + } + + return 1; + } + +/* +** If mwData* is NULL: +** Returns 0 if heap chain is broken. +** Returns 1 if heap chain is intact. +** If mwData* is not NULL: +** Returns 0 if mwData* is missing or if chain is broken. +** Returns 1 if chain is intact and mwData* is found. +*/ +static int mwIsHeapOK( mwData *includes_mw ) { + int found = 0; + mwData *mw; + + for( mw = mwHead; mw; mw=mw->next ) { + if( includes_mw == mw ) found++; + if( !mwIsSafeAddr( mw, mwDataSize ) ) return 0; + if( mw->prev ) { + if( !mwIsSafeAddr( mw->prev, mwDataSize ) ) return 0; + if( mw==mwHead || mw->prev->next != mw ) return 0; + } + if( mw->next ) { + if( !mwIsSafeAddr( mw->next, mwDataSize ) ) return 0; + if( mw==mwTail || mw->next->prev != mw ) return 0; + } + else if( mw!=mwTail ) return 0; + } + + if( includes_mw != NULL && !found ) return 0; + + return 1; + } + +static int mwIsOwned( mwData* mw, const char *file, int line ) { + int retv; + mwStat *ms; + + /* see if the address is legal according to OS */ + if( !mwIsSafeAddr( mw, mwDataSize ) ) return 0; + + /* make sure we have _anything_ allocated */ + if( mwHead == NULL && mwTail == NULL && mwStatCurAlloc == 0 ) + return 0; + + /* calculate checksum */ + if( mw->check != CHKVAL(mw) ) { + /* may be damaged checksum, see if block is in heap */ + if( mwIsHeapOK( mw ) ) { + /* damaged checksum, repair it */ + mwWrite( "internal: <%ld> %s(%d), checksum for MW-%p is incorrect\n", + mwCounter, file, line, mw ); + mwIncErr(); + if( mwIsReadAddr( mw->file, 1 ) ) { + ms = mwStatGet( mw->file, -1, 0 ); + if( ms == NULL ) mw->file = ""; + } + else mw->file = ""; + mw->size = 0; + mw->check = CHKVAL(mw); + return 1; + } + /* no, it's just some garbage data */ + return 0; + } + + /* check that the non-NULL pointers are safe */ + if( mw->prev && !mwIsSafeAddr( mw->prev, mwDataSize ) ) mwRelink( mw, file, line ); + if( mw->next && !mwIsSafeAddr( mw->next, mwDataSize ) ) mwRelink( mw, file, line ); + + /* safe address, checksum OK, proceed with heap checks */ + + /* see if the block is in the heap */ + retv = 0; + if( mw->prev ) { if( mw->prev->next == mw ) retv ++; } + else { if( mwHead == mw ) retv++; } + if( mw->next ) { if( mw->next->prev == mw ) retv ++; } + else { if( mwTail == mw ) retv++; } + if( mw->check == CHKVAL(mw) ) retv ++; + if( retv > 2 ) return 1; + + /* block not in heap, check heap for corruption */ + + if( !mwIsHeapOK( mw ) ) { + if( mwRelink( mw, file, line ) ) + return 1; + } + + /* unable to repair */ + mwWrite( "internal: <%ld> %s(%d), mwIsOwned fails for MW-%p\n", + mwCounter, file, line, mw ); + mwIncErr(); + + return 0; + } + +/* +** mwTestBuf: +** Checks a buffers links and pre/postfixes. +** Writes errors found to the log. +** Returns zero if no errors found. +*/ +static int mwTestBuf( mwData* mw, const char* file, int line ) { + int retv = 0; + char *p; + + if( file == NULL ) file = "unknown"; + + if( !mwIsSafeAddr( mw, mwDataSize + mwOverflowZoneSize ) ) { + mwWrite( "internal: <%ld> %s(%d): pointer MW-%p is invalid\n", + mwCounter, file, line, mw ); + mwIncErr(); + return 2; + } + + if( mw->check != CHKVAL(mw) ) { + mwWrite( "internal: <%ld> %s(%d), info trashed; relinking\n", + mwCounter, file, line ); + mwIncErr(); + if( !mwRelink( mw, file, line ) ) return 2; + } + + if( mw->prev && mw->prev->next != mw ) { + mwWrite( "internal: <%ld> %s(%d), buffer <%ld> %s(%d) link1 broken\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + if( !mwRelink( mw, file, line ) ) retv = 2; + } + if( mw->next && mw->next->prev != mw ) { + mwWrite( "internal: <%ld> %s(%d), buffer <%ld> %s(%d) link2 broken\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + if( !mwRelink( mw, file, line ) ) retv = 2; + } + + p = ((char*)mw) + mwDataSize; + if( mwCheckOF( p ) ) { + mwWrite( "underflow: <%ld> %s(%d), %ld bytes alloc'd at <%ld> %s(%d)\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + retv = 1; + } + p += mwOverflowZoneSize + mw->size; + if( mwIsReadAddr( p, mwOverflowZoneSize ) && mwCheckOF( p ) ) { + mwWrite( "overflow: <%ld> %s(%d), %ld bytes alloc'd at <%ld> %s(%d)\n", + mwCounter,file,line, (long)mw->size, mw->count, mw->file, mw->line ); + mwIncErr(); + retv = 1; + } + + return retv; + } + +static void mwDefaultOutFunc( int c ) { + if( mwLogR() ) fputc( c, mwLogR() ); + } + +static void mwWrite( const char *format, ... ) { + int tot, oflow = 0; + va_list mark; + mwAutoInit(); + if( mwOutFunction == NULL ) mwOutFunction = mwDefaultOutFunc; + va_start( mark, format ); + tot = vsprintf( mwPrintBuf, format, mark ); + va_end( mark ); + if( tot >= MW_TRACE_BUFFER ) { mwPrintBuf[MW_TRACE_BUFFER] = 0; oflow = 1; } + for(tot=0;mwPrintBuf[tot];tot++) + (*mwOutFunction)( mwPrintBuf[tot] ); + if( oflow ) { + mwWrite( "\ninternal: mwWrite(): WARNING! OUTPUT EXCEEDED %u CHARS: SYSTEM UNSTABLE\n", MW_TRACE_BUFFER-1 ); + FLUSH(); + } + return; + } + +static void mwLogFile( const char *name ) { + time_t tid; + (void) time( &tid ); + if( mwLogR() != NULL ) { + fclose( mwLogR() ); + mwLogW( NULL ); + } + if( name == NULL ) return; + mwLogW( fopen( name, "a" COMMIT ) ); + if( mwLogR() == NULL ) + mwWrite( "logfile: failed to open/create file '%s'\n", name ); + } + +/* +** Try to free NML memory until a contiguous allocation of +** 'needed' bytes can be satisfied. If this is not enough +** and the 'urgent' parameter is nonzero, grabbed memory is +** also freed. +*/ +static size_t mwFreeUp( size_t needed, int urgent ) { + void *p; + mwData *mw, *mw2; + char *data; + + /* free grabbed NML memory */ + for(;;) { + if( mwDrop_( 1, MW_VAL_NML, 1 ) == 0 ) break; + p = malloc( needed ); + if( p == NULL ) continue; + free( p ); + return needed; + } + + /* free normal NML memory */ + mw = mwHead; + while( mw != NULL ) { + if( !(mw->flag & MW_NML) ) mw = mw->next; + else { + data = ((char*)mw)+mwDataSize+mwOverflowZoneSize; + if( mwTestMem( data, mw->size, MW_VAL_NML ) ) { + mwIncErr(); + mwWrite( "wild pointer: <%ld> NoMansLand %p alloc'd at %s(%d)\n", + mw->count, data + mwOverflowZoneSize, mw->file, mw->line ); + } + mw2 = mw->next; + mwUnlink( mw, "mwFreeUp", 0 ); + free( mw ); + mw = mw2; + p = malloc( needed ); + if( p == NULL ) continue; + free( p ); + return needed; + } + } + + /* if not urgent (for internal purposes), fail */ + if( !urgent ) return 0; + + /* free grabbed memory */ + for(;;) { + if( mwDrop_( 1, MW_VAL_GRB, 1 ) == 0 ) break; + p = malloc( needed ); + if( p == NULL ) continue; + free( p ); + return needed; + } + + return 0; + } + +static const void * mwTestMem( const void *p, unsigned len, int c ) { + const unsigned char *ptr; + ptr = (const unsigned char *) p; + while( len-- ) { + if( *ptr != (unsigned char)c ) return (const void*)ptr; + ptr ++; + } + return NULL; + } + +static int mwStrCmpI( const char *s1, const char *s2 ) { + if( s1 == NULL || s2 == NULL ) return 0; + while( *s1 ) { + if( toupper(*s2) == toupper(*s1) ) { s1++; s2++; continue; } + return 1; + } + return 0; + } + +#define AIPH() if( always_invoked ) { mwWrite("autocheck: <%ld> %s(%d) ", mwCounter, file, line ); always_invoked = 0; } + +static int mwTestNow( const char *file, int line, int always_invoked ) { + int retv = 0; + mwData *mw; + char *data; + + if( file && !always_invoked ) + mwWrite("check: <%ld> %s(%d), checking %s%s%s\n", + mwCounter, file, line, + (mwTestFlags & MW_TEST_CHAIN) ? "chain ": "", + (mwTestFlags & MW_TEST_ALLOC) ? "alloc ": "", + (mwTestFlags & MW_TEST_NML) ? "nomansland ": "" + ); + + if( mwTestFlags & MW_TEST_CHAIN ) { + for( mw = mwHead; mw; mw=mw->next ) { + if( !mwIsSafeAddr(mw, mwDataSize) ) { + AIPH(); + mwWrite("check: heap corruption detected\n"); + mwIncErr(); + return retv + 1; + } + if( mw->prev ) { + if( !mwIsSafeAddr(mw->prev, mwDataSize) ) { + AIPH(); + mwWrite("check: heap corruption detected\n"); + mwIncErr(); + return retv + 1; + } + if( mw==mwHead || mw->prev->next != mw ) { + AIPH(); + mwWrite("check: heap chain broken, prev link incorrect\n"); + mwIncErr(); + retv ++; + } + } + if( mw->next ) { + if( !mwIsSafeAddr(mw->next, mwDataSize) ) { + AIPH(); + mwWrite("check: heap corruption detected\n"); + mwIncErr(); + return retv + 1; + } + if( mw==mwTail || mw->next->prev != mw ) { + AIPH(); + mwWrite("check: heap chain broken, next link incorrect\n"); + mwIncErr(); + retv ++; + } + } + else if( mw!=mwTail ) { + AIPH(); + mwWrite("check: heap chain broken, tail incorrect\n"); + mwIncErr(); + retv ++; + } + } + } + if( mwTestFlags & MW_TEST_ALLOC ) { + for( mw = mwHead; mw; mw=mw->next ) { + if( mwTestBuf( mw, file, line ) ) retv ++; + } + } + if( mwTestFlags & MW_TEST_NML ) { + for( mw = mwHead; mw; mw=mw->next ) { + if( (mw->flag & MW_NML) ) { + data = ((char*)mw)+mwDataSize+mwOverflowZoneSize; + if( mwTestMem( data, mw->size, MW_VAL_NML ) ) { + mwIncErr(); + mwWrite( "wild pointer: <%ld> NoMansLand %p alloc'd at %s(%d)\n", + mw->count, data + mwOverflowZoneSize, mw->file, mw->line ); + } + } + } + } + + + if( file && !always_invoked && !retv ) + mwWrite("check: <%ld> %s(%d), complete; no errors\n", + mwCounter, file, line ); + return retv; + } + +/********************************************************************** +** Statistics +**********************************************************************/ + +static void mwStatReport() +{ + mwStat* ms, *ms2; + const char *modname; + int modnamelen; + + /* global statistics report */ + mwWrite( "\nMemory usage statistics (global):\n" ); + mwWrite( " N)umber of allocations made: %ld\n", mwStatNumAlloc ); + mwWrite( " L)argest memory usage : %ld\n", mwStatMaxAlloc ); + mwWrite( " T)otal of all alloc() calls: %ld\n", mwStatTotAlloc ); + mwWrite( " U)nfreed bytes totals : %ld\n", mwStatCurAlloc ); + FLUSH(); + + if( mwStatLevel < 1 ) return; + + /* on a per-module basis */ + mwWrite( "\nMemory usage statistics (detailed):\n"); + mwWrite( " Module/Line Number Largest Total Unfreed \n"); + for( ms=mwStatList; ms; ms=ms->next ) + { + if( ms->line == -1 ) + { + if( ms->file == NULL || !mwIsReadAddr(ms->file,22) ) modname = ""; + else modname = ms->file; + modnamelen = strlen(modname); + if( modnamelen > 42 ) + { + modname = modname + modnamelen - 42; + } + + mwWrite(" %-42s %-8ld %-8ld %-8ld %-8ld\n", + modname, ms->num, ms->max, ms->total, ms->curr ); + if( ms->file && mwStatLevel > 1 ) + { + for( ms2=mwStatList; ms2; ms2=ms2->next ) + { + if( ms2->line!=-1 && ms2->file!=NULL && !mwStrCmpI( ms2->file, ms->file ) ) + { + mwWrite( " %-8d %-8ld %-8ld %-8ld %-8ld\n", + ms2->line, ms2->num, ms2->max, ms2->total, ms2->curr ); + } + } + } + } + } +} + +static mwStat* mwStatGet( const char *file, int line, int makenew ) { + mwStat* ms; + + if( mwStatLevel < 2 ) line = -1; + + for( ms=mwStatList; ms!=NULL; ms=ms->next ) { + if( line != ms->line ) continue; + if( file==NULL ) { + if( ms->file == NULL ) break; + continue; + } + if( ms->file == NULL ) continue; + if( !strcmp( ms->file, file ) ) break; + } + + if( ms != NULL ) return ms; + + if( !makenew ) return NULL; + + ms = (mwStat*) malloc( sizeof(mwStat) ); + if( ms == NULL ) { + if( mwFreeUp( sizeof(mwStat), 0 ) < sizeof(mwStat) || + (ms=(mwStat*)malloc(sizeof(mwStat))) == NULL ) { + mwWrite("internal: memory low, statistics incomplete for '%s'\n", file ); + return NULL; + } + } + ms->file = file; + ms->line = line; + ms->total = 0L; + ms->max = 0L; + ms->num = 0L; + ms->curr = 0L; + ms->next = mwStatList; + mwStatList = ms; + return ms; + } + +static void mwStatAlloc( size_t size, const char* file, int line ) { + mwStat* ms; + + /* update the module statistics */ + ms = mwStatGet( file, -1, 1 ); + if( ms != NULL ) { + ms->total += (long) size; + ms->curr += (long) size; + ms->num ++; + if( ms->curr > ms->max ) ms->max = ms->curr; + } + + /* update the line statistics */ + if( mwStatLevel > 1 && line != -1 && file ) { + ms = mwStatGet( file, line, 1 ); + if( ms != NULL ) { + ms->total += (long) size; + ms->curr += (long) size; + ms->num ++; + if( ms->curr > ms->max ) ms->max = ms->curr; + } + } + + } + +static void mwStatFree( size_t size, const char* file, int line ) { + mwStat* ms; + + /* update the module statistics */ + ms = mwStatGet( file, -1, 1 ); + if( ms != NULL ) ms->curr -= (long) size; + + /* update the line statistics */ + if( mwStatLevel > 1 && line != -1 && file ) { + ms = mwStatGet( file, line, 1 ); + if( ms != NULL ) ms->curr -= (long) size; + } + } + +/*********************************************************************** +** Safe memory checkers +** +** Using ifdefs, implement the operating-system specific mechanism +** of identifying a piece of memory as legal to access with read +** and write priviliges. Default: return nonzero for non-NULL pointers. +***********************************************************************/ + +static char mwDummy( char c ) +{ + return c; +} + +#ifndef MW_SAFEADDR +#ifdef WIN32 +#define MW_SAFEADDR +#define WIN32_LEAN_AND_MEAN +#include +int mwIsReadAddr( const void *p, unsigned len ) +{ + if( p == NULL ) return 0; + if( IsBadReadPtr(p,len) ) return 0; + return 1; +} +int mwIsSafeAddr( void *p, unsigned len ) +{ + /* NOTE: For some reason, under Win95 the IsBad... */ + /* can return false for invalid pointers. */ + if( p == NULL ) return 0; + if( IsBadReadPtr(p,len) || IsBadWritePtr(p,len) ) return 0; + return 1; +} +#endif /* WIN32 */ +#endif /* MW_SAFEADDR */ + +#ifndef MW_SAFEADDR +#ifdef SIGSEGV +#define MW_SAFEADDR + +typedef void (*mwSignalHandlerPtr)( int ); +mwSignalHandlerPtr mwOldSIGSEGV = (mwSignalHandlerPtr) 0; +jmp_buf mwSIGSEGVjump; +static void mwSIGSEGV( int n ); + +static void mwSIGSEGV( int n ) +{ + n = n; + longjmp( mwSIGSEGVjump, 1 ); +} + +int mwIsReadAddr( const void *p, unsigned len ) +{ + const char *ptr; + + if( p == NULL ) return 0; + if( !len ) return 1; + + /* set up to catch the SIGSEGV signal */ + mwOldSIGSEGV = signal( SIGSEGV, mwSIGSEGV ); + + if( setjmp( mwSIGSEGVjump ) ) + { + signal( SIGSEGV, mwOldSIGSEGV ); + return 0; + } + + /* read all the bytes in the range */ + ptr = (const char *)p; + ptr += len; + + /* the reason for this rather strange construct is that */ + /* we want to keep the number of used parameters and locals */ + /* to a minimum. if we use len for a counter gcc will complain */ + /* it may get clobbered by longjmp() at high warning levels. */ + /* it's a harmless warning, but this way we don't have to see it. */ + do + { + ptr --; + if( *ptr == 0x7C ) (void) mwDummy( (char)0 ); + } while( (const void*) ptr != p ); + + /* remove the handler */ + signal( SIGSEGV, mwOldSIGSEGV ); + + return 1; +} +int mwIsSafeAddr( void *p, unsigned len ) +{ + char *ptr; + + if( p == NULL ) return 0; + if( !len ) return 1; + + /* set up to catch the SIGSEGV signal */ + mwOldSIGSEGV = signal( SIGSEGV, mwSIGSEGV ); + + if( setjmp( mwSIGSEGVjump ) ) + { + signal( SIGSEGV, mwOldSIGSEGV ); + return 0; + } + + /* read and write-back all the bytes in the range */ + ptr = (char *)p; + ptr += len; + + /* the reason for this rather strange construct is that */ + /* we want to keep the number of used parameters and locals */ + /* to a minimum. if we use len for a counter gcc will complain */ + /* it may get clobbered by longjmp() at high warning levels. */ + /* it's a harmless warning, but this way we don't have to see it. */ + do + { + ptr --; + *ptr = mwDummy( *ptr ); + } while( (void*) ptr != p ); + + /* remove the handler */ + signal( SIGSEGV, mwOldSIGSEGV ); + + return 1; +} +#endif /* SIGSEGV */ +#endif /* MW_SAFEADDR */ + +#ifndef MW_SAFEADDR +int mwIsReadAddr( const void *p, unsigned len ) +{ + if( p == NULL ) return 0; + if( len == 0 ) return 1; + return 1; +} +int mwIsSafeAddr( void *p, unsigned len ) +{ + if( p == NULL ) return 0; + if( len == 0 ) return 1; + return 1; +} +#endif + +/********************************************************************** +** Mutex handling +**********************************************************************/ + +#if defined(WIN32) || defined(__WIN32__) + +static void mwMutexInit( void ) +{ + mwGlobalMutex = CreateMutex( NULL, FALSE, NULL); + return; +} + +static void mwMutexTerm( void ) +{ + CloseHandle( mwGlobalMutex ); + return; +} + +static void mwMutexLock( void ) +{ + if( WaitForSingleObject(mwGlobalMutex, 1000 ) == WAIT_TIMEOUT ) + { + mwWrite( "mwMutexLock: timed out, possible deadlock\n" ); + } + return; +} + +static void mwMutexUnlock( void ) +{ + ReleaseMutex( mwGlobalMutex ); + return; +} + +#endif + +#if defined(MW_PTHREADS) || defined(HAVE_PTHREAD_H) + +static void mwMutexInit( void ) +{ + pthread_mutex_init( &mwGlobalMutex, NULL ); + return; +} + +static void mwMutexTerm( void ) +{ + pthread_mutex_destroy( &mwGlobalMutex ); + return; +} + +static void mwMutexLock( void ) +{ + pthread_mutex_lock(&mwGlobalMutex); + return; +} + +static void mwMutexUnlock( void ) +{ + pthread_mutex_unlock(&mwGlobalMutex); + return; +} + +#endif + +/********************************************************************** +** C++ new & delete +**********************************************************************/ + +#if 0 /* 980317: disabled C++ */ + +#ifdef __cplusplus +#ifndef MEMWATCH_NOCPP + +int mwNCur = 0; +const char *mwNFile = NULL; +int mwNLine = 0; + +class MemWatch { +public: + MemWatch(); + ~MemWatch(); + }; + +MemWatch::MemWatch() { + if( mwInited ) return; + mwUseAtexit = 0; + mwInit(); + } + +MemWatch::~MemWatch() { + if( mwUseAtexit ) return; + mwTerm(); + } + +/* +** This global new will catch all 'new' calls where MEMWATCH is +** not active. +*/ +void* operator new( unsigned size ) { + mwNCur = 0; + return mwMalloc( size, "", 0 ); + } + +/* +** This is the new operator that's called when a module uses mwNew. +*/ +void* operator new( unsigned size, const char *file, int line ) { + mwNCur = 0; + return mwMalloc( size, file, line ); + } + +/* +** This is the new operator that's called when a module uses mwNew[]. +** -- hjc 07/16/02 +*/ +void* operator new[] ( unsigned size, const char *file, int line ) { + mwNCur = 0; + return mwMalloc( size, file, line ); + } + +/* +** Since this delete operator will recieve ALL delete's +** even those from within libraries, we must accept +** delete's before we've been initialized. Nor can we +** reliably check for wild free's if the mwNCur variable +** is not set. +*/ +void operator delete( void *p ) { + if( p == NULL ) return; + if( !mwInited ) { + free( p ); + return; + } + if( mwNCur ) { + mwFree( p, mwNFile, mwNLine ); + mwNCur = 0; + return; + } + mwFree_( p ); + } + +void operator delete[]( void *p ) { + if( p == NULL ) return; + if( !mwInited ) { + free( p ); + return; + } + if( mwNCur ) { + mwFree( p, mwNFile, mwNLine ); + mwNCur = 0; + return; + } + mwFree_( p ); + } + +#endif /* MEMWATCH_NOCPP */ +#endif /* __cplusplus */ + +#endif /* 980317: disabled C++ */ + +/* MEMWATCH.C */ diff --git a/shared/thirdparty/memwatch/memwatch.h b/shared/thirdparty/memwatch/memwatch.h new file mode 100644 index 0000000..4a42cb9 --- /dev/null +++ b/shared/thirdparty/memwatch/memwatch.h @@ -0,0 +1,710 @@ +/* +** MEMWATCH.H +** Nonintrusive ANSI C memory leak / overwrite detection +** Copyright (C) 1992-2002 Johan Lindh +** All rights reserved. +** Version 2.71 +** +************************************************************************ +** +** PURPOSE: +** +** MEMWATCH has been written to allow guys and gals that like to +** program in C a public-domain memory error control product. +** I hope you'll find it's as advanced as most commercial packages. +** The idea is that you use it during the development phase and +** then remove the MEMWATCH define to produce your final product. +** MEMWATCH is distributed in source code form in order to allow +** you to compile it for your platform with your own compiler. +** It's aim is to be 100% ANSI C, but some compilers are more stingy +** than others. If it doesn't compile without warnings, please mail +** me the configuration of operating system and compiler you are using +** along with a description of how to modify the source, and the version +** number of MEMWATCH that you are using. +** +************************************************************************ + + This file is part of MEMWATCH. + + MEMWATCH is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + MEMWATCH is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with MEMWATCH; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +************************************************************************ +** +** REVISION HISTORY: +** +** 920810 JLI [1.00] +** 920830 JLI [1.10 double-free detection] +** 920912 JLI [1.15 mwPuts, mwGrab/Drop, mwLimit] +** 921022 JLI [1.20 ASSERT and VERIFY] +** 921105 JLI [1.30 C++ support and TRACE] +** 921116 JLI [1.40 mwSetOutFunc] +** 930215 JLI [1.50 modified ASSERT/VERIFY] +** 930327 JLI [1.51 better auto-init & PC-lint support] +** 930506 JLI [1.55 MemWatch class, improved C++ support] +** 930507 JLI [1.60 mwTest & CHECK()] +** 930809 JLI [1.65 Abort/Retry/Ignore] +** 930820 JLI [1.70 data dump when unfreed] +** 931016 JLI [1.72 modified C++ new/delete handling] +** 931108 JLI [1.77 mwSetAssertAction() & some small changes] +** 940110 JLI [1.80 no-mans-land alloc/checking] +** 940328 JLI [2.00 version 2.0 rewrite] +** Improved NML (no-mans-land) support. +** Improved performance (especially for free()ing!). +** Support for 'read-only' buffers (checksums) +** ^^ NOTE: I never did this... maybe I should? +** FBI (free'd block info) tagged before freed blocks +** Exporting of the mwCounter variable +** mwBreakOut() localizes debugger support +** Allocation statistics (global, per-module, per-line) +** Self-repair ability with relinking +** 950913 JLI [2.10 improved garbage handling] +** 951201 JLI [2.11 improved auto-free in emergencies] +** 960125 JLI [X.01 implemented auto-checking using mwAutoCheck()] +** 960514 JLI [2.12 undefining of existing macros] +** 960515 JLI [2.13 possibility to use default new() & delete()] +** 960516 JLI [2.20 suppression of file flushing on unfreed msgs] +** 960516 JLI [2.21 better support for using MEMWATCH with DLL's] +** 960710 JLI [X.02 multiple logs and mwFlushNow()] +** 960801 JLI [2.22 merged X.01 version with current] +** 960805 JLI [2.30 mwIsXXXXAddr() to avoid unneeded GP's] +** 960805 JLI [2.31 merged X.02 version with current] +** 961002 JLI [2.32 support for realloc() + fixed STDERR bug] +** 961222 JLI [2.40 added mwMark() & mwUnmark()] +** 970101 JLI [2.41 added over/underflow checking after failed ASSERT/VERIFY] +** 970113 JLI [2.42 added support for PC-Lint 7.00g] +** 970207 JLI [2.43 added support for strdup()] +** 970209 JLI [2.44 changed default filename to lowercase] +** 970405 JLI [2.45 fixed bug related with atexit() and some C++ compilers] +** 970723 JLI [2.46 added MW_ARI_NULLREAD flag] +** 970813 JLI [2.47 stabilized marker handling] +** 980317 JLI [2.48 ripped out C++ support; wasn't working good anyway] +** 980318 JLI [2.50 improved self-repair facilities & SIGSEGV support] +** 980417 JLI [2.51 more checks for invalid addresses] +** 980512 JLI [2.52 moved MW_ARI_NULLREAD to occur before aborting] +** 990112 JLI [2.53 added check for empty heap to mwIsOwned] +** 990217 JLI [2.55 improved the emergency repairs diagnostics and NML] +** 990224 JLI [2.56 changed ordering of members in structures] +** 990303 JLI [2.57 first maybe-fixit-for-hpux test] +** 990516 JLI [2.58 added 'static' to the definition of mwAutoInit] +** 990517 JLI [2.59 fixed some high-sensitivity warnings] +** 990610 JLI [2.60 fixed some more high-sensitivity warnings] +** 990715 JLI [2.61 changed TRACE/ASSERT/VERIFY macro names] +** 991001 JLI [2.62 added CHECK_BUFFER() and mwTestBuffer()] +** 991007 JLI [2.63 first shot at a 64-bit compatible version] +** 991009 JLI [2.64 undef's strdup() if defined, mwStrdup made const] +** 000704 JLI [2.65 added some more detection for 64-bits] +** 010502 JLI [2.66 incorporated some user fixes] +** [mwRelink() could print out garbage pointer (thanks mac@phobos.ca)] +** [added array destructor for C++ (thanks rdasilva@connecttel.com)] +** [added mutex support (thanks rdasilva@connecttel.com)] +** 010531 JLI [2.67 fix: mwMutexXXX() was declared even if MW_HAVE_MUTEX was not defined] +** 010619 JLI [2.68 fix: mwRealloc() could leave the mutex locked] +** 020918 JLI [2.69 changed to GPL, added C++ array allocation by Howard Cohen] +** 030212 JLI [2.70 mwMalloc() bug for very large allocations (4GB on 32bits)] +** 030520 JLI [2.71 added ULONG_LONG_MAX as a 64-bit detector (thanks Sami Salonen)] +** +** To use, simply include 'MEMWATCH.H' as a header file, +** and add MEMWATCH.C to your list of files, and define the macro +** 'MEMWATCH'. If this is not defined, MEMWATCH will disable itself. +** +** To call the standard C malloc / realloc / calloc / free; use mwMalloc_(), +** mwCalloc_() and mwFree_(). Note that mwFree_() will correctly +** free both malloc()'d memory as well as mwMalloc()'d. +** +** 980317: C++ support has been disabled. +** The code remains, but is not compiled. +** +** For use with C++, which allows use of inlining in header files +** and class specific new/delete, you must also define 'new' as +** 'mwNew' and 'delete' as 'mwDelete'. Do this *after* you include +** C++ header files from libraries, otherwise you can mess up their +** class definitions. If you don't define these, the C++ allocations +** will not have source file and line number information. Also note, +** most C++ class libraries implement their own C++ memory management, +** and don't allow anyone to override them. MFC belongs to this crew. +** In these cases, the only thing to do is to use MEMWATCH_NOCPP. +** +** You can capture output from MEMWATCH using mwSetOutFunc(). +** Just give it the adress of a "void myOutFunc(int c)" function, +** and all characters to be output will be redirected there. +** +** A failing ASSERT() or VERIFY() will normally always abort your +** program. This can be changed using mwSetAriFunc(). Give it a +** pointer to a "int myAriFunc(const char *)" function. Your function +** must ask the user whether to Abort, Retry or Ignore the trap. +** Return 2 to Abort, 1 to Retry or 0 to Ignore. Beware retry; it +** causes the expression to be evaluated again! MEMWATCH has a +** default ARI handler. It's disabled by default, but you can enable +** it by calling 'mwDefaultAri()'. Note that this will STILL abort +** your program unless you define MEMWATCH_STDIO to allow MEMWATCH +** to use the standard C I/O streams. Also, setting the ARI function +** will cause MEMWATCH *NOT* to write the ARI error to stderr. The +** error string is passed to the ARI function instead, as the +** 'const char *' parameter. +** +** You can disable MEMWATCH's ASSERT/VERIFY and/or TRACE implementations. +** This can be useful if you're using a debug terminal or smart debugger. +** Disable them by defining MW_NOASSERT, MW_NOVERIFY or MW_NOTRACE. +** +** MEMWATCH fills all allocated memory with the byte 0xFE, so if +** you're looking at erroneous data which are all 0xFE:s, the +** data probably was not initialized by you. The exception is +** calloc(), which will fill with zero's. All freed buffers are +** zapped with 0xFD. If this is what you look at, you're using +** data that has been freed. If this is the case, be aware that +** MEMWATCH places a 'free'd block info' structure immediately +** before the freed data. This block contains info about where +** the block was freed. The information is in readable text, +** in the format "FBIfilename(line)", for example: +** "FBI<267>test.c(12)". Using FBI's slows down free(), so it's +** disabled by default. Use mwFreeBufferInfo(1) to enable it. +** +** To aid in tracking down wild pointer writes, MEMWATCH can perform +** no-mans-land allocations. No-mans-land will contain the byte 0xFC. +** MEMWATCH will, when this is enabled, convert recently free'd memory +** into NML allocations. +** +** MEMWATCH protects it's own data buffers with checksums. If you +** get an internal error, it means you're overwriting wildly, +** or using an uninitialized pointer. +** +************************************************************************ +** +** Note when compiling with Microsoft C: +** - MSC ignores fflush() by default. This is overridden, so that +** the disk log will always be current. +** +** This utility has been tested with: +** PC-lint 7.0k, passed as 100% ANSI C compatible +** Microsoft Visual C++ on Win16 and Win32 +** Microsoft C on DOS +** SAS C on an Amiga 500 +** Gnu C on a PC running Red Hat Linux +** ...and using an (to me) unknown compiler on an Atari machine. +** +************************************************************************ +** +** Format of error messages in MEMWATCH.LOG: +** message: filename(linenumber), information +** +** Errors caught by MemWatch, when they are detected, and any +** actions taken besides writing to the log file MEMWATCH.LOG: +** +** Double-freeing: +** A pointer that was recently freed and has not since been +** reused was freed again. The place where the previous free() +** was executed is displayed. +** Detect: delete or free() using the offending pointer. +** Action: The delete or free() is cancelled, execution continues. +** Underflow: +** You have written just ahead of the allocated memory. +** The size and place of the allocation is displayed. +** Detect: delete or free() of the damaged buffer. +** Action: The buffer is freed, but there may be secondary damage. +** Overflow: +** Like underflow, but you've written after the end of the buffer. +** Detect: see Underflow. +** Action: see Underflow. +** WILD free: +** An unrecognized pointer was passed to delete or free(). +** The pointer may have been returned from a library function; +** in that case, use mwFree_() to force free() of it. +** Also, this may be a double-free, but the previous free was +** too long ago, causing MEMWATCH to 'forget' it. +** Detect: delete or free() of the offending pointer. +** Action: The delete or free() is cancelled, execution continues. +** NULL free: +** It's unclear to me whether or not freeing of NULL pointers +** is legal in ANSI C, therefore a warning is written to the log file, +** but the error counter remains the same. This is legal using C++, +** so the warning does not appear with delete. +** Detect: When you free(NULL). +** Action: The free() is cancelled. +** Failed: +** A request to allocate memory failed. If the allocation is +** small, this may be due to memory depletion, but is more likely +** to be memory fragmentation problems. The amount of memory +** allocated so far is displayed also. +** Detect: When you new, malloc(), realloc() or calloc() memory. +** Action: NULL is returned. +** Realloc: +** A request to re-allocate a memory buffer failed for reasons +** other than out-of-memory. The specific reason is shown. +** Detect: When you realloc() +** Action: realloc() is cancelled, NULL is returned +** Limit fail: +** A request to allocate memory failed since it would violate +** the limit set using mwLimit(). mwLimit() is used to stress-test +** your code under simulated low memory conditions. +** Detect: At new, malloc(), realloc() or calloc(). +** Action: NULL is returned. +** Assert trap: +** An ASSERT() failed. The ASSERT() macro works like C's assert() +** macro/function, except that it's interactive. See your C manual. +** Detect: On the ASSERT(). +** Action: Program ends with an advisory message to stderr, OR +** Program writes the ASSERT to the log and continues, OR +** Program asks Abort/Retry/Ignore? and takes that action. +** Verify trap: +** A VERIFY() failed. The VERIFY() macro works like ASSERT(), +** but if MEMWATCH is not defined, it still evaluates the +** expression, but it does not act upon the result. +** Detect: On the VERIFY(). +** Action: Program ends with an advisory message to stderr, OR +** Program writes the VERIFY to the log and continues, OR +** Program asks Abort/Retry/Ignore? and takes that action. +** Wild pointer: +** A no-mans-land buffer has been written into. MEMWATCH can +** allocate and distribute chunks of memory solely for the +** purpose of trying to catch random writes into memory. +** Detect: Always on CHECK(), but can be detected in several places. +** Action: The error is logged, and if an ARI handler is installed, +** it is executed, otherwise, execution continues. +** Unfreed: +** A memory buffer you allocated has not been freed. +** You are informed where it was allocated, and whether any +** over or underflow has occured. MemWatch also displays up to +** 16 bytes of the data, as much as it can, in hex and text. +** Detect: When MemWatch terminates. +** Action: The buffer is freed. +** Check: +** An error was detected during a CHECK() operation. +** The associated pointer is displayed along with +** the file and line where the CHECK() was executed. +** Followed immediately by a normal error message. +** Detect: When you CHECK() +** Action: Depends on the error +** Relink: +** After a MEMWATCH internal control block has been trashed, +** MEMWATCH tries to repair the damage. If successful, program +** execution will continue instead of aborting. Some information +** about the block may be gone permanently, though. +** Detect: N/A +** Action: Relink successful: program continues. +** Relink fails: program aborts. +** Internal: +** An internal error is flagged by MEMWATCH when it's control +** structures have been damaged. You are likely using an uninitialized +** pointer somewhere in your program, or are zapping memory all over. +** The message may give you additional diagnostic information. +** If possible, MEMWATCH will recover and continue execution. +** Detect: Various actions. +** Action: Whatever is needed +** Mark: +** The program terminated without umarking all marked pointers. Marking +** can be used to track resources other than memory. mwMark(pointer,text,...) +** when the resource is allocated, and mwUnmark(pointer) when it's freed. +** The 'text' is displayed for still marked pointers when the program +** ends. +** Detect: When MemWatch terminates. +** Action: The error is logged. +** +** +************************************************************************ +** +** The author may be reached by e-mail at the address below. If you +** mail me about source code changes in MEMWATCH, remember to include +** MW's version number. +** +** Johan Lindh +** johan@linkdata.se +** +** The latest version of MEMWATCH may be downloaded from +** http://www.linkdata.se/ +*/ + +#ifndef __MEMWATCH_H +#define __MEMWATCH_H + +/* Make sure that malloc(), realloc(), calloc() and free() are declared. */ +/*lint -save -e537 */ +#include +/*lint -restore */ + +/* strdup() */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* +** Constants used +** All MEMWATCH constants start with the prefix MW_, followed by +** a short mnemonic which indicates where the constant is used, +** followed by a descriptive text about it. +*/ + +#define MW_ARI_NULLREAD 0x10 /* Null read (to start debugger) */ +#define MW_ARI_ABORT 0x04 /* ARI handler says: abort program! */ +#define MW_ARI_RETRY 0x02 /* ARI handler says: retry action! */ +#define MW_ARI_IGNORE 0x01 /* ARI handler says: ignore error! */ + +#define MW_VAL_NEW 0xFE /* value in newly allocated memory */ +#define MW_VAL_DEL 0xFD /* value in newly deleted memory */ +#define MW_VAL_NML 0xFC /* value in no-mans-land */ +#define MW_VAL_GRB 0xFB /* value in grabbed memory */ + +#define MW_TEST_ALL 0xFFFF /* perform all tests */ +#define MW_TEST_CHAIN 0x0001 /* walk the heap chain */ +#define MW_TEST_ALLOC 0x0002 /* test allocations & NML guards */ +#define MW_TEST_NML 0x0004 /* test all-NML areas for modifications */ + +#define MW_NML_NONE 0 /* no NML */ +#define MW_NML_FREE 1 /* turn FREE'd memory into NML */ +#define MW_NML_ALL 2 /* all unused memory is NML */ +#define MW_NML_DEFAULT 0 /* the default NML setting */ + +#define MW_STAT_GLOBAL 0 /* only global statistics collected */ +#define MW_STAT_MODULE 1 /* collect statistics on a module basis */ +#define MW_STAT_LINE 2 /* collect statistics on a line basis */ +#define MW_STAT_DEFAULT 0 /* the default statistics setting */ + +/* +** MemWatch internal constants +** You may change these and recompile MemWatch to change the limits +** of some parameters. Respect the recommended minimums! +*/ +#define MW_TRACE_BUFFER 2048 /* (min 160) size of TRACE()'s output buffer */ +#define MW_FREE_LIST 64 /* (min 4) number of free()'s to track */ + +/* +** Exported variables +** In case you have to remove the 'const' keyword because your compiler +** doesn't support it, be aware that changing the values may cause +** unpredictable behaviour. +** - mwCounter contains the current action count. You can use this to +** place breakpoints using a debugger, if you want. +*/ +#ifndef __MEMWATCH_C +extern const unsigned long mwCounter; +#endif + +/* +** System functions +** Normally, it is not nessecary to call any of these. MEMWATCH will +** automatically initialize itself on the first MEMWATCH function call, +** and set up a call to mwAbort() using atexit(). Some C++ implementations +** run the atexit() chain before the program has terminated, so you +** may have to use mwInit() or the MemWatch C++ class to get good +** behaviour. +** - mwInit() can be called to disable the atexit() usage. If mwInit() +** is called directly, you must call mwTerm() to end MemWatch, or +** mwAbort(). +** - mwTerm() is usually not nessecary to call; but if called, it will +** call mwAbort() if it finds that it is cancelling the 'topmost' +** mwInit() call. +** - mwAbort() cleans up after MEMWATCH, reports unfreed buffers, etc. +*/ +void mwInit( void ); +void mwTerm( void ); +void mwAbort( void ); + +/* +** Setup functions +** These functions control the operation of MEMWATCH's protective features. +** - mwFlushNow() causes MEMWATCH to flush it's buffers. +** - mwDoFlush() controls whether MEMWATCH flushes the disk buffers after +** writes. The default is smart flushing: MEMWATCH will not flush buffers +** explicitly until memory errors are detected. Then, all writes are +** flushed until program end or mwDoFlush(0) is called. +** - mwLimit() sets the allocation limit, an arbitrary limit on how much +** memory your program may allocate in bytes. Used to stress-test app. +** Also, in virtual-memory or multitasking environs, puts a limit on +** how much MW_NML_ALL can eat up. +** - mwGrab() grabs up X kilobytes of memory. Allocates actual memory, +** can be used to stress test app & OS both. +** - mwDrop() drops X kilobytes of grabbed memory. +** - mwNoMansLand() sets the behaviour of the NML logic. See the +** MW_NML_xxx for more information. The default is MW_NML_DEFAULT. +** - mwStatistics() sets the behaviour of the statistics collector. See +** the MW_STAT_xxx defines for more information. Default MW_STAT_DEFAULT. +** - mwFreeBufferInfo() enables or disables the tagging of free'd buffers +** with freeing information. This information is written in text form, +** using sprintf(), so it's pretty slow. Disabled by default. +** - mwAutoCheck() performs a CHECK() operation whenever a MemWatch function +** is used. Slows down performance, of course. +** - mwCalcCheck() calculates checksums for all data buffers. Slow! +** - mwDumpCheck() logs buffers where stored & calc'd checksums differ. Slow!! +** - mwMark() sets a generic marker. Returns the pointer given. +** - mwUnmark() removes a generic marker. If, at the end of execution, some +** markers are still in existence, these will be reported as leakage. +** returns the pointer given. +*/ +void mwFlushNow( void ); +void mwDoFlush( int onoff ); +void mwLimit( long bytes ); +unsigned mwGrab( unsigned kilobytes ); +unsigned mwDrop( unsigned kilobytes ); +void mwNoMansLand( int mw_nml_level ); +void mwStatistics( int level ); +void mwFreeBufferInfo( int onoff ); +void mwAutoCheck( int onoff ); +void mwCalcCheck( void ); +void mwDumpCheck( void ); +void * mwMark( void *p, const char *description, const char *file, unsigned line ); +void * mwUnmark( void *p, const char *file, unsigned line ); + +/* +** Testing/verification/tracing +** All of these macros except VERIFY() evaluates to a null statement +** if MEMWATCH is not defined during compilation. +** - mwIsReadAddr() checks a memory area for read privilige. +** - mwIsSafeAddr() checks a memory area for both read & write privilige. +** This function and mwIsReadAddr() is highly system-specific and +** may not be implemented. If this is the case, they will default +** to returning nonzero for any non-NULL pointer. +** - CHECK() does a complete memory integrity test. Slow! +** - CHECK_THIS() checks only selected components. +** - CHECK_BUFFER() checks the indicated buffer for errors. +** - mwASSERT() or ASSERT() If the expression evaluates to nonzero, execution continues. +** Otherwise, the ARI handler is called, if present. If not present, +** the default ARI action is taken (set with mwSetAriAction()). +** ASSERT() can be disabled by defining MW_NOASSERT. +** - mwVERIFY() or VERIFY() works just like ASSERT(), but when compiling without +** MEMWATCH the macro evaluates to the expression. +** VERIFY() can be disabled by defining MW_NOVERIFY. +** - mwTRACE() or TRACE() writes some text and data to the log. Use like printf(). +** TRACE() can be disabled by defining MW_NOTRACE. +*/ +int mwIsReadAddr( const void *p, unsigned len ); +int mwIsSafeAddr( void *p, unsigned len ); +int mwTest( const char *file, int line, int mw_test_flags ); +int mwTestBuffer( const char *file, int line, void *p ); +int mwAssert( int, const char*, const char*, int ); +int mwVerify( int, const char*, const char*, int ); + +/* +** User I/O functions +** - mwTrace() works like printf(), but dumps output either to the +** function specified with mwSetOutFunc(), or the log file. +** - mwPuts() works like puts(), dumps output like mwTrace(). +** - mwSetOutFunc() allows you to give the adress of a function +** where all user output will go. (exeption: see mwSetAriFunc) +** Specifying NULL will direct output to the log file. +** - mwSetAriFunc() gives MEMWATCH the adress of a function to call +** when an 'Abort, Retry, Ignore' question is called for. The +** actual error message is NOT printed when you've set this adress, +** but instead it is passed as an argument. If you call with NULL +** for an argument, the ARI handler is disabled again. When the +** handler is disabled, MEMWATCH will automatically take the +** action specified by mwSetAriAction(). +** - mwSetAriAction() sets the default ARI return value MEMWATCH should +** use if no ARI handler is specified. Defaults to MW_ARI_ABORT. +** - mwAriHandler() is an ANSI ARI handler you can use if you like. It +** dumps output to stderr, and expects input from stdin. +** - mwBreakOut() is called in certain cases when MEMWATCH feels it would +** be nice to break into a debugger. If you feel like MEMWATCH, place +** an execution breakpoint on this function. +*/ +void mwTrace( const char* format_string, ... ); +void mwPuts( const char* text ); +void mwSetOutFunc( void (*func)(int) ); +void mwSetAriFunc( int (*func)(const char*) ); +void mwSetAriAction( int mw_ari_value ); +int mwAriHandler( const char* cause ); +void mwBreakOut( const char* cause ); + +/* +** Allocation/deallocation functions +** These functions are the ones actually to perform allocations +** when running MEMWATCH, for both C and C++ calls. +** - mwMalloc() debugging allocator +** - mwMalloc_() always resolves to a clean call of malloc() +** - mwRealloc() debugging re-allocator +** - mwRealloc_() always resolves to a clean call of realloc() +** - mwCalloc() debugging allocator, fills with zeros +** - mwCalloc_() always resolves to a clean call of calloc() +** - mwFree() debugging free. Can only free memory which has +** been allocated by MEMWATCH. +** - mwFree_() resolves to a) normal free() or b) debugging free. +** Can free memory allocated by MEMWATCH and malloc() both. +** Does not generate any runtime errors. +*/ +void* mwMalloc( size_t, const char*, int ); +void* mwMalloc_( size_t ); +void* mwRealloc( void *, size_t, const char*, int ); +void* mwRealloc_( void *, size_t ); +void* mwCalloc( size_t, size_t, const char*, int ); +void* mwCalloc_( size_t, size_t ); +void mwFree( void*, const char*, int ); +void mwFree_( void* ); +char* mwStrdup( const char *, const char*, int ); + +/* +** Enable/disable precompiler block +** This block of defines and if(n)defs make sure that references +** to MEMWATCH is completely removed from the code if the MEMWATCH +** manifest constant is not defined. +*/ +#ifndef __MEMWATCH_C +#ifdef MEMWATCH + +#define mwASSERT(exp) while(mwAssert((int)(exp),#exp,__FILE__,__LINE__)) +#ifndef MW_NOASSERT +#ifndef ASSERT +#define ASSERT mwASSERT +#endif /* !ASSERT */ +#endif /* !MW_NOASSERT */ +#define mwVERIFY(exp) while(mwVerify((int)(exp),#exp,__FILE__,__LINE__)) +#ifndef MW_NOVERIFY +#ifndef VERIFY +#define VERIFY mwVERIFY +#endif /* !VERIFY */ +#endif /* !MW_NOVERIFY */ +#define mwTRACE mwTrace +#ifndef MW_NOTRACE +#ifndef TRACE +#define TRACE mwTRACE +#endif /* !TRACE */ +#endif /* !MW_NOTRACE */ + +/* some compilers use a define and not a function */ +/* for strdup(). */ +#ifdef strdup +#undef strdup +#endif + +#define malloc(n) mwMalloc(n,__FILE__,__LINE__) +#define strdup(p) mwStrdup(p,__FILE__,__LINE__) +#define realloc(p,n) mwRealloc(p,n,__FILE__,__LINE__) +#define calloc(n,m) mwCalloc(n,m,__FILE__,__LINE__) +#define free(p) mwFree(p,__FILE__,__LINE__) +#define CHECK() mwTest(__FILE__,__LINE__,MW_TEST_ALL) +#define CHECK_THIS(n) mwTest(__FILE__,__LINE__,n) +#define CHECK_BUFFER(b) mwTestBuffer(__FILE__,__LINE__,b) +#define MARK(p) mwMark(p,#p,__FILE__,__LINE__) +#define UNMARK(p) mwUnmark(p,__FILE__,__LINE__) + +#else /* MEMWATCH */ + +#define mwASSERT(exp) +#ifndef MW_NOASSERT +#ifndef ASSERT +#define ASSERT mwASSERT +#endif /* !ASSERT */ +#endif /* !MW_NOASSERT */ + +#define mwVERIFY(exp) exp +#ifndef MW_NOVERIFY +#ifndef VERIFY +#define VERIFY mwVERIFY +#endif /* !VERIFY */ +#endif /* !MW_NOVERIFY */ + +/*lint -esym(773,mwTRACE) */ +#define mwTRACE /*lint -save -e506 */ 1?(void)0:mwDummyTraceFunction /*lint -restore */ +#ifndef MW_NOTRACE +#ifndef TRACE +/*lint -esym(773,TRACE) */ +#define TRACE mwTRACE +#endif /* !TRACE */ +#endif /* !MW_NOTRACE */ + +extern void mwDummyTraceFunction(const char *,...); +/*lint -save -e652 */ +#define mwDoFlush(n) +#define mwPuts(s) +#define mwInit() +#define mwGrab(n) +#define mwDrop(n) +#define mwLimit(n) +#define mwTest(f,l) +#define mwSetOutFunc(f) +#define mwSetAriFunc(f) +#define mwDefaultAri() +#define mwNomansland() +#define mwStatistics(f) +#define mwMark(p,t,f,n) (p) +#define mwUnmark(p,f,n) (p) +#define mwMalloc(n,f,l) malloc(n) +#define mwStrdup(p,f,l) strdup(p) +#define mwRealloc(p,n,f,l) realloc(p,n) +#define mwCalloc(n,m,f,l) calloc(n,m) +#define mwFree(p) free(p) +#define mwMalloc_(n) malloc(n) +#define mwRealloc_(p,n) realloc(p,n) +#define mwCalloc_(n,m) calloc(n,m) +#define mwFree_(p) free(p) +#define mwAssert(e,es,f,l) +#define mwVerify(e,es,f,l) (e) +#define mwTrace mwDummyTrace +#define mwTestBuffer(f,l,b) (0) +#define CHECK() +#define CHECK_THIS(n) +#define CHECK_BUFFER(b) +#define MARK(p) (p) +#define UNMARK(p) (p) +/*lint -restore */ + +#endif /* MEMWATCH */ +#endif /* !__MEMWATCH_C */ + +#ifdef __cplusplus + } +#endif + +#if 0 /* 980317: disabled C++ */ + +/* +** C++ support section +** Implements the C++ support. Please note that in order to avoid +** messing up library classes, C++ support is disabled by default. +** You must NOT enable it until AFTER the inclusion of all header +** files belonging to code that are not compiled with MEMWATCH, and +** possibly for some that are! The reason for this is that a C++ +** class may implement it's own new() function, and the preprocessor +** would substitute this crucial declaration for MEMWATCH new(). +** You can forcibly deny C++ support by defining MEMWATCH_NOCPP. +** To enble C++ support, you must be compiling C++, MEMWATCH must +** be defined, MEMWATCH_NOCPP must not be defined, and finally, +** you must define 'new' to be 'mwNew', and 'delete' to be 'mwDelete'. +** Unlike C, C++ code can begin executing *way* before main(), for +** example if a global variable is created. For this reason, you can +** declare a global variable of the class 'MemWatch'. If this is +** is the first variable created, it will then check ALL C++ allocations +** and deallocations. Unfortunately, this evaluation order is not +** guaranteed by C++, though the compilers I've tried evaluates them +** in the order encountered. +*/ +#ifdef __cplusplus +#ifndef __MEMWATCH_C +#ifdef MEMWATCH +#ifndef MEMWATCH_NOCPP +extern int mwNCur; +extern const char *mwNFile; +extern int mwNLine; +class MemWatch { +public: + MemWatch(); + ~MemWatch(); + }; +void * operator new(size_t); +void * operator new(size_t,const char *,int); +void * operator new[] (size_t,const char *,int); // hjc 07/16/02 +void operator delete(void *); +#define mwNew new(__FILE__,__LINE__) +#define mwDelete (mwNCur=1,mwNFile=__FILE__,mwNLine=__LINE__),delete +#endif /* MEMWATCH_NOCPP */ +#endif /* MEMWATCH */ +#endif /* !__MEMWATCH_C */ +#endif /* __cplusplus */ + +#endif /* 980317: disabled C++ */ + +#endif /* __MEMWATCH_H */ + +/* EOF MEMWATCH.H */ diff --git a/shared/thirdparty/memwatch/memwatch.lsm b/shared/thirdparty/memwatch/memwatch.lsm new file mode 100644 index 0000000..a7742a3 --- /dev/null +++ b/shared/thirdparty/memwatch/memwatch.lsm @@ -0,0 +1,15 @@ +Begin3 +Title: memwatch +Version: 2.71 +Entered-date: 2002-09-18 +Description: fault tolerant ANSI-C source code memory leak and corruption detection +Keywords: memwatch debugging library memory leak source code ansi c +Author: johan@linkdata.se +Maintained-by: johan@linkdata.se +Primary-site: ftp.linkdata.se /pub/memwatch + 42K memwatch-2.71.tar.gz +Alternate-site: +Original-site: ftp.linkdata.se /pub/memwatch +Platforms: all +Copying-policy: GPL +End diff --git a/shared/thirdparty/memwatch/test.C b/shared/thirdparty/memwatch/test.C new file mode 100644 index 0000000..b4d847c --- /dev/null +++ b/shared/thirdparty/memwatch/test.C @@ -0,0 +1,116 @@ + +/* +** NOTE: Running this program in a Win32 or Unix environment +** will probably result in a segmentation fault or protection +** error. These errors may be caused by MEMWATCH when it is +** looking at memory to see if it owns it, or may be caused by +** the test program writing to memory it does not own. +** +** MEMWATCH has two functions called 'mwIsReadAddr()' and +** 'mwIsSafeAddr()', which are system-specific. +** If they are implemented for your system, and works +** correctly, MEMWATCH will identify garbage pointers and +** avoid causing segmentation faults, GP's etc. +** +** If they are NOT implemented, count on getting the core +** dumped when running this test program! As of this writing, +** the safe-address checking has been implemented for Win32 +** and ANSI-C compliant systems. The ANSI-C checking traps +** SIGSEGV and uses setjmp/longjmp to resume processing. +** +** Note for Win95 users: The Win32 IsBadReadPtr() and its +** similar functions can return incorrect values. This has +** not happened under WinNT, though, just Win95. +** +** 991009 Johan Lindh +** +*/ + +#include +#include +#include "memwatch.h" + +#ifndef SIGSEGV +#error "SIGNAL.H does not define SIGSEGV; running this program WILL cause a core dump/crash!" +#endif + +#ifndef MEMWATCH +#error "You really, really don't want to run this without memwatch. Trust me." +#endif + +#if !defined(MW_STDIO) && !defined(MEMWATCH_STDIO) +#error "Define MW_STDIO and try again, please." +#endif + +int main() +{ + char *p; + + /* Collect stats on a line number basis */ + mwStatistics( 2 ); + + /* Slows things down, but OK for this test prg */ + /* mwAutoCheck( 1 ); */ + + TRACE("Hello world!\n"); + + p = malloc(210); + free(p); + p = malloc(20); + p = malloc(200); /* causes unfreed error */ + p[-1] = 0; /* causes underflow error */ + free(p); + + p = malloc(100); + p[ -(int)(sizeof(long)*8) ] = -1; /* try to damage MW's heap chain */ + free( p ); /* should cause relink */ + + mwSetAriFunc( mwAriHandler ); + ASSERT(1==2); + + mwLimit(1000000); + mwNoMansLand( MW_NML_ALL ); + + /* These may cause a general protection fault (segmentation fault) */ + /* They're here to help test the no-mans-land protection */ + if( mwIsSafeAddr(p+50000,1) ) { + TRACE("Killing byte at %p\n", p+50000); + *(p+50000) = 0; + } + if( mwIsSafeAddr(p+30000,1) ) { + TRACE("Killing byte at %p\n", p+30000); + *(p+30000) = 0; + } + if( mwIsSafeAddr(p+1000,1) ) { + TRACE("Killing byte at %p\n", p+1000); + *(p+1000) = 0; + } + if( mwIsSafeAddr(p-100,1) ) { + TRACE("Killing byte at %p\n", p-100); + *(p-100) = 0; + } + + /* This may cause a GP fault as well, since MW data buffers */ + /* have been damaged in the above killing spree */ + CHECK(); + + p = malloc(12000); + p[-5] = 1; + p[-10] = 2; + p[-15] = 3; + p[-20] = 4; + + /* This may cause a GP fault since MW's buffer list may have */ + /* been damaged by above killing, and it will try to repair it. */ + free(p); + + p = realloc(p,10); /* causes realloc: free'd from error */ + + /* May cause GP since MW will inspect the memory to see if it owns it. */ + free( (void*)main ); + + return 0; +} + +/* Comment out the following line to compile. */ +#error "Hey! Don't just compile this program, read the comments first!" diff --git a/shared/thirdparty/stb_ds.h b/shared/thirdparty/stb_ds.h new file mode 100644 index 0000000..e84c82d --- /dev/null +++ b/shared/thirdparty/stb_ds.h @@ -0,0 +1,1895 @@ +/* stb_ds.h - v0.67 - public domain data structures - Sean Barrett 2019 + + This is a single-header-file library that provides easy-to-use + dynamic arrays and hash tables for C (also works in C++). + + For a gentle introduction: + http://nothings.org/stb_ds + + To use this library, do this in *one* C or C++ file: + #define STB_DS_IMPLEMENTATION + #include "stb_ds.h" + +TABLE OF CONTENTS + + Table of Contents + Compile-time options + License + Documentation + Notes + Notes - Dynamic arrays + Notes - Hash maps + Credits + +COMPILE-TIME OPTIONS + + #define STBDS_NO_SHORT_NAMES + + This flag needs to be set globally. + + By default stb_ds exposes shorter function names that are not qualified + with the "stbds_" prefix. If these names conflict with the names in your + code, define this flag. + + #define STBDS_SIPHASH_2_4 + + This flag only needs to be set in the file containing #define STB_DS_IMPLEMENTATION. + + By default stb_ds.h hashes using a weaker variant of SipHash and a custom hash for + 4- and 8-byte keys. On 64-bit platforms, you can define the above flag to force + stb_ds.h to use specification-compliant SipHash-2-4 for all keys. Doing so makes + hash table insertion about 20% slower on 4- and 8-byte keys, 5% slower on + 64-byte keys, and 10% slower on 256-byte keys on my test computer. + + #define STBDS_REALLOC(context,ptr,size) better_realloc + #define STBDS_FREE(context,ptr) better_free + + These defines only need to be set in the file containing #define STB_DS_IMPLEMENTATION. + + By default stb_ds uses stdlib realloc() and free() for memory management. You can + substitute your own functions instead by defining these symbols. You must either + define both, or neither. Note that at the moment, 'context' will always be NULL. + @TODO add an array/hash initialization function that takes a memory context pointer. + + #define STBDS_UNIT_TESTS + + Defines a function stbds_unit_tests() that checks the functioning of the data structures. + + Note that on older versions of gcc (e.g. 5.x.x) you may need to build with '-std=c++0x' + (or equivalentally '-std=c++11') when using anonymous structures as seen on the web + page or in STBDS_UNIT_TESTS. + +LICENSE + + Placed in the public domain and also MIT licensed. + See end of file for detailed license information. + +DOCUMENTATION + + Dynamic Arrays + + Non-function interface: + + Declare an empty dynamic array of type T + T* foo = NULL; + + Access the i'th item of a dynamic array 'foo' of type T, T* foo: + foo[i] + + Functions (actually macros) + + arrfree: + void arrfree(T*); + Frees the array. + + arrlen: + ptrdiff_t arrlen(T*); + Returns the number of elements in the array. + + arrlenu: + size_t arrlenu(T*); + Returns the number of elements in the array as an unsigned type. + + arrpop: + T arrpop(T* a) + Removes the final element of the array and returns it. + + arrput: + T arrput(T* a, T b); + Appends the item b to the end of array a. Returns b. + + arrins: + T arrins(T* a, int p, T b); + Inserts the item b into the middle of array a, into a[p], + moving the rest of the array over. Returns b. + + arrinsn: + void arrinsn(T* a, int p, int n); + Inserts n uninitialized items into array a starting at a[p], + moving the rest of the array over. + + arraddnptr: + T* arraddnptr(T* a, int n) + Appends n uninitialized items onto array at the end. + Returns a pointer to the first uninitialized item added. + + arraddnindex: + size_t arraddnindex(T* a, int n) + Appends n uninitialized items onto array at the end. + Returns the index of the first uninitialized item added. + + arrdel: + void arrdel(T* a, int p); + Deletes the element at a[p], moving the rest of the array over. + + arrdeln: + void arrdeln(T* a, int p, int n); + Deletes n elements starting at a[p], moving the rest of the array over. + + arrdelswap: + void arrdelswap(T* a, int p); + Deletes the element at a[p], replacing it with the element from + the end of the array. O(1) performance. + + arrsetlen: + void arrsetlen(T* a, int n); + Changes the length of the array to n. Allocates uninitialized + slots at the end if necessary. + + arrsetcap: + size_t arrsetcap(T* a, int n); + Sets the length of allocated storage to at least n. It will not + change the length of the array. + + arrcap: + size_t arrcap(T* a); + Returns the number of total elements the array can contain without + needing to be reallocated. + + Hash maps & String hash maps + + Given T is a structure type: struct { TK key; TV value; }. Note that some + functions do not require TV value and can have other fields. For string + hash maps, TK must be 'char *'. + + Special interface: + + stbds_rand_seed: + void stbds_rand_seed(size_t seed); + For security against adversarially chosen data, you should seed the + library with a strong random number. Or at least seed it with time(). + + stbds_hash_string: + size_t stbds_hash_string(char *str, size_t seed); + Returns a hash value for a string. + + stbds_hash_bytes: + size_t stbds_hash_bytes(void *p, size_t len, size_t seed); + These functions hash an arbitrary number of bytes. The function + uses a custom hash for 4- and 8-byte data, and a weakened version + of SipHash for everything else. On 64-bit platforms you can get + specification-compliant SipHash-2-4 on all data by defining + STBDS_SIPHASH_2_4, at a significant cost in speed. + + Non-function interface: + + Declare an empty hash map of type T + T* foo = NULL; + + Access the i'th entry in a hash table T* foo: + foo[i] + + Function interface (actually macros): + + hmfree + shfree + void hmfree(T*); + void shfree(T*); + Frees the hashmap and sets the pointer to NULL. + + hmlen + shlen + ptrdiff_t hmlen(T*) + ptrdiff_t shlen(T*) + Returns the number of elements in the hashmap. + + hmlenu + shlenu + size_t hmlenu(T*) + size_t shlenu(T*) + Returns the number of elements in the hashmap. + + hmgeti + shgeti + hmgeti_ts + ptrdiff_t hmgeti(T*, TK key) + ptrdiff_t shgeti(T*, char* key) + ptrdiff_t hmgeti_ts(T*, TK key, ptrdiff_t tempvar) + Returns the index in the hashmap which has the key 'key', or -1 + if the key is not present. + + hmget + hmget_ts + shget + TV hmget(T*, TK key) + TV shget(T*, char* key) + TV hmget_ts(T*, TK key, ptrdiff_t tempvar) + Returns the value corresponding to 'key' in the hashmap. + The structure must have a 'value' field + + hmgets + shgets + T hmgets(T*, TK key) + T shgets(T*, char* key) + Returns the structure corresponding to 'key' in the hashmap. + + hmgetp + shgetp + hmgetp_ts + hmgetp_null + shgetp_null + T* hmgetp(T*, TK key) + T* shgetp(T*, char* key) + T* hmgetp_ts(T*, TK key, ptrdiff_t tempvar) + T* hmgetp_null(T*, TK key) + T* shgetp_null(T*, char *key) + Returns a pointer to the structure corresponding to 'key' in + the hashmap. Functions ending in "_null" return NULL if the key + is not present in the hashmap; the others return a pointer to a + structure holding the default value (but not the searched-for key). + + hmdefault + shdefault + TV hmdefault(T*, TV value) + TV shdefault(T*, TV value) + Sets the default value for the hashmap, the value which will be + returned by hmget/shget if the key is not present. + + hmdefaults + shdefaults + TV hmdefaults(T*, T item) + TV shdefaults(T*, T item) + Sets the default struct for the hashmap, the contents which will be + returned by hmgets/shgets if the key is not present. + + hmput + shput + TV hmput(T*, TK key, TV value) + TV shput(T*, char* key, TV value) + Inserts a pair into the hashmap. If the key is already + present in the hashmap, updates its value. + + hmputs + shputs + T hmputs(T*, T item) + T shputs(T*, T item) + Inserts a struct with T.key into the hashmap. If the struct is already + present in the hashmap, updates it. + + hmdel + shdel + int hmdel(T*, TK key) + int shdel(T*, char* key) + If 'key' is in the hashmap, deletes its entry and returns 1. + Otherwise returns 0. + + Function interface (actually macros) for strings only: + + sh_new_strdup + void sh_new_strdup(T*); + Overwrites the existing pointer with a newly allocated + string hashmap which will automatically allocate and free + each string key using realloc/free + + sh_new_arena + void sh_new_arena(T*); + Overwrites the existing pointer with a newly allocated + string hashmap which will automatically allocate each string + key to a string arena. Every string key ever used by this + hash table remains in the arena until the arena is freed. + Additionally, any key which is deleted and reinserted will + be allocated multiple times in the string arena. + +NOTES + + * These data structures are realloc'd when they grow, and the macro + "functions" write to the provided pointer. This means: (a) the pointer + must be an lvalue, and (b) the pointer to the data structure is not + stable, and you must maintain it the same as you would a realloc'd + pointer. For example, if you pass a pointer to a dynamic array to a + function which updates it, the function must return back the new + pointer to the caller. This is the price of trying to do this in C. + + * The following are the only functions that are thread-safe on a single data + structure, i.e. can be run in multiple threads simultaneously on the same + data structure + hmlen shlen + hmlenu shlenu + hmget_ts shget_ts + hmgeti_ts shgeti_ts + hmgets_ts shgets_ts + + * You iterate over the contents of a dynamic array and a hashmap in exactly + the same way, using arrlen/hmlen/shlen: + + for (i=0; i < arrlen(foo); ++i) + ... foo[i] ... + + * All operations except arrins/arrdel are O(1) amortized, but individual + operations can be slow, so these data structures may not be suitable + for real time use. Dynamic arrays double in capacity as needed, so + elements are copied an average of once. Hash tables double/halve + their size as needed, with appropriate hysteresis to maintain O(1) + performance. + +NOTES - DYNAMIC ARRAY + + * If you know how long a dynamic array is going to be in advance, you can avoid + extra memory allocations by using arrsetlen to allocate it to that length in + advance and use foo[n] while filling it out, or arrsetcap to allocate the memory + for that length and use arrput/arrpush as normal. + + * Unlike some other versions of the dynamic array, this version should + be safe to use with strict-aliasing optimizations. + +NOTES - HASH MAP + + * For compilers other than GCC and clang (e.g. Visual Studio), for hmput/hmget/hmdel + and variants, the key must be an lvalue (so the macro can take the address of it). + Extensions are used that eliminate this requirement if you're using C99 and later + in GCC or clang, or if you're using C++ in GCC. But note that this can make your + code less portable. + + * To test for presence of a key in a hashmap, just do 'hmgeti(foo,key) >= 0'. + + * The iteration order of your data in the hashmap is determined solely by the + order of insertions and deletions. In particular, if you never delete, new + keys are always added at the end of the array. This will be consistent + across all platforms and versions of the library. However, you should not + attempt to serialize the internal hash table, as the hash is not consistent + between different platforms, and may change with future versions of the library. + + * Use sh_new_arena() for string hashmaps that you never delete from. Initialize + with NULL if you're managing the memory for your strings, or your strings are + never freed (at least until the hashmap is freed). Otherwise, use sh_new_strdup(). + @TODO: make an arena variant that garbage collects the strings with a trivial + copy collector into a new arena whenever the table shrinks / rebuilds. Since + current arena recommendation is to only use arena if it never deletes, then + this can just replace current arena implementation. + + * If adversarial input is a serious concern and you're on a 64-bit platform, + enable STBDS_SIPHASH_2_4 (see the 'Compile-time options' section), and pass + a strong random number to stbds_rand_seed. + + * The default value for the hash table is stored in foo[-1], so if you + use code like 'hmget(T,k)->value = 5' you can accidentally overwrite + the value stored by hmdefault if 'k' is not present. + +CREDITS + + Sean Barrett -- library, idea for dynamic array API/implementation + Per Vognsen -- idea for hash table API/implementation + Rafael Sachetto -- arrpop() + github:HeroicKatora -- arraddn() reworking + + Bugfixes: + Andy Durdin + Shane Liesegang + Vinh Truong + Andreas Molzer + github:hashitaku + github:srdjanstipic + Macoy Madson + Andreas Vennstrom + Tobias Mansfield-Williams +*/ + +#ifdef STBDS_UNIT_TESTS +#define _CRT_SECURE_NO_WARNINGS +#endif + +#ifndef INCLUDE_STB_DS_H +#define INCLUDE_STB_DS_H + +#include +#include + +#ifndef STBDS_NO_SHORT_NAMES +#define arrlen stbds_arrlen +#define arrlenu stbds_arrlenu +#define arrput stbds_arrput +#define arrpush stbds_arrput +#define arrpop stbds_arrpop +#define arrfree stbds_arrfree +#define arraddn stbds_arraddn // deprecated, use one of the following instead: +#define arraddnptr stbds_arraddnptr +#define arraddnindex stbds_arraddnindex +#define arrsetlen stbds_arrsetlen +#define arrlast stbds_arrlast +#define arrins stbds_arrins +#define arrinsn stbds_arrinsn +#define arrdel stbds_arrdel +#define arrdeln stbds_arrdeln +#define arrdelswap stbds_arrdelswap +#define arrcap stbds_arrcap +#define arrsetcap stbds_arrsetcap + +#define hmput stbds_hmput +#define hmputs stbds_hmputs +#define hmget stbds_hmget +#define hmget_ts stbds_hmget_ts +#define hmgets stbds_hmgets +#define hmgetp stbds_hmgetp +#define hmgetp_ts stbds_hmgetp_ts +#define hmgetp_null stbds_hmgetp_null +#define hmgeti stbds_hmgeti +#define hmgeti_ts stbds_hmgeti_ts +#define hmdel stbds_hmdel +#define hmlen stbds_hmlen +#define hmlenu stbds_hmlenu +#define hmfree stbds_hmfree +#define hmdefault stbds_hmdefault +#define hmdefaults stbds_hmdefaults + +#define shput stbds_shput +#define shputi stbds_shputi +#define shputs stbds_shputs +#define shget stbds_shget +#define shgeti stbds_shgeti +#define shgets stbds_shgets +#define shgetp stbds_shgetp +#define shgetp_null stbds_shgetp_null +#define shdel stbds_shdel +#define shlen stbds_shlen +#define shlenu stbds_shlenu +#define shfree stbds_shfree +#define shdefault stbds_shdefault +#define shdefaults stbds_shdefaults +#define sh_new_arena stbds_sh_new_arena +#define sh_new_strdup stbds_sh_new_strdup + +#define stralloc stbds_stralloc +#define strreset stbds_strreset +#endif + +#if defined(STBDS_REALLOC) && !defined(STBDS_FREE) || !defined(STBDS_REALLOC) && defined(STBDS_FREE) +#error "You must define both STBDS_REALLOC and STBDS_FREE, or neither." +#endif +#if !defined(STBDS_REALLOC) && !defined(STBDS_FREE) +#include +#define STBDS_REALLOC(c,p,s) realloc(p,s) +#define STBDS_FREE(c,p) free(p) +#endif + +#ifdef _MSC_VER +#define STBDS_NOTUSED(v) (void)(v) +#else +#define STBDS_NOTUSED(v) (void)sizeof(v) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// for security against attackers, seed the library with a random number, at least time() but stronger is better +extern void stbds_rand_seed(size_t seed); + +// these are the hash functions used internally if you want to test them or use them for other purposes +extern size_t stbds_hash_bytes(void *p, size_t len, size_t seed); +extern size_t stbds_hash_string(char *str, size_t seed); + +// this is a simple string arena allocator, initialize with e.g. 'stbds_string_arena my_arena={0}'. +typedef struct stbds_string_arena stbds_string_arena; +extern char * stbds_stralloc(stbds_string_arena *a, char *str); +extern void stbds_strreset(stbds_string_arena *a); + +// have to #define STBDS_UNIT_TESTS to call this +extern void stbds_unit_tests(void); + +/////////////// +// +// Everything below here is implementation details +// + +extern void * stbds_arrgrowf(void *a, size_t elemsize, size_t addlen, size_t min_cap); +extern void stbds_arrfreef(void *a); +extern void stbds_hmfree_func(void *p, size_t elemsize); +extern void * stbds_hmget_key(void *a, size_t elemsize, void *key, size_t keysize, int mode); +extern void * stbds_hmget_key_ts(void *a, size_t elemsize, void *key, size_t keysize, ptrdiff_t *temp, int mode); +extern void * stbds_hmput_default(void *a, size_t elemsize); +extern void * stbds_hmput_key(void *a, size_t elemsize, void *key, size_t keysize, int mode); +extern void * stbds_hmdel_key(void *a, size_t elemsize, void *key, size_t keysize, size_t keyoffset, int mode); +extern void * stbds_shmode_func(size_t elemsize, int mode); + +#ifdef __cplusplus +} +#endif + +#if defined(__GNUC__) || defined(__clang__) +#define STBDS_HAS_TYPEOF +#ifdef __cplusplus +//#define STBDS_HAS_LITERAL_ARRAY // this is currently broken for clang +#endif +#endif + +#if !defined(__cplusplus) +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define STBDS_HAS_LITERAL_ARRAY +#endif +#endif + +// this macro takes the address of the argument, but on gcc/clang can accept rvalues +#if defined(STBDS_HAS_LITERAL_ARRAY) && defined(STBDS_HAS_TYPEOF) + #if __clang__ + #define STBDS_ADDRESSOF(typevar, value) ((__typeof__(typevar)[1]){value}) // literal array decays to pointer to value + #else + #define STBDS_ADDRESSOF(typevar, value) ((typeof(typevar)[1]){value}) // literal array decays to pointer to value + #endif +#else +#define STBDS_ADDRESSOF(typevar, value) &(value) +#endif + +#define STBDS_OFFSETOF(var,field) ((char *) &(var)->field - (char *) (var)) + +#define stbds_header(t) ((stbds_array_header *) (t) - 1) +#define stbds_temp(t) stbds_header(t)->temp +#define stbds_temp_key(t) (*(char **) stbds_header(t)->hash_table) + +#define stbds_arrsetcap(a,n) (stbds_arrgrow(a,0,n)) +#define stbds_arrsetlen(a,n) ((stbds_arrcap(a) < (size_t) (n) ? stbds_arrsetcap((a),(size_t)(n)),0 : 0), (a) ? stbds_header(a)->length = (size_t) (n) : 0) +#define stbds_arrcap(a) ((a) ? stbds_header(a)->capacity : 0) +#define stbds_arrlen(a) ((a) ? (ptrdiff_t) stbds_header(a)->length : 0) +#define stbds_arrlenu(a) ((a) ? stbds_header(a)->length : 0) +#define stbds_arrput(a,v) (stbds_arrmaybegrow(a,1), (a)[stbds_header(a)->length++] = (v)) +#define stbds_arrpush stbds_arrput // synonym +#define stbds_arrpop(a) (stbds_header(a)->length--, (a)[stbds_header(a)->length]) +#define stbds_arraddn(a,n) ((void)(stbds_arraddnindex(a, n))) // deprecated, use one of the following instead: +#define stbds_arraddnptr(a,n) (stbds_arrmaybegrow(a,n), (n) ? (stbds_header(a)->length += (n), &(a)[stbds_header(a)->length-(n)]) : (a)) +#define stbds_arraddnindex(a,n)(stbds_arrmaybegrow(a,n), (n) ? (stbds_header(a)->length += (n), stbds_header(a)->length-(n)) : stbds_arrlen(a)) +#define stbds_arraddnoff stbds_arraddnindex +#define stbds_arrlast(a) ((a)[stbds_header(a)->length-1]) +#define stbds_arrfree(a) ((void) ((a) ? STBDS_FREE(NULL,stbds_header(a)) : (void)0), (a)=NULL) +#define stbds_arrdel(a,i) stbds_arrdeln(a,i,1) +#define stbds_arrdeln(a,i,n) (memmove(&(a)[i], &(a)[(i)+(n)], sizeof *(a) * (stbds_header(a)->length-(n)-(i))), stbds_header(a)->length -= (n)) +#define stbds_arrdelswap(a,i) ((a)[i] = stbds_arrlast(a), stbds_header(a)->length -= 1) +#define stbds_arrinsn(a,i,n) (stbds_arraddn((a),(n)), memmove(&(a)[(i)+(n)], &(a)[i], sizeof *(a) * (stbds_header(a)->length-(n)-(i)))) +#define stbds_arrins(a,i,v) (stbds_arrinsn((a),(i),1), (a)[i]=(v)) + +#define stbds_arrmaybegrow(a,n) ((!(a) || stbds_header(a)->length + (n) > stbds_header(a)->capacity) \ + ? (stbds_arrgrow(a,n,0),0) : 0) + +#define stbds_arrgrow(a,b,c) ((a) = stbds_arrgrowf_wrapper((a), sizeof *(a), (b), (c))) + +#define stbds_hmput(t, k, v) \ + ((t) = stbds_hmput_key_wrapper((t), sizeof *(t), (void*) STBDS_ADDRESSOF((t)->key, (k)), sizeof (t)->key, 0), \ + (t)[stbds_temp((t)-1)].key = (k), \ + (t)[stbds_temp((t)-1)].value = (v)) + +#define stbds_hmputs(t, s) \ + ((t) = stbds_hmput_key_wrapper((t), sizeof *(t), &(s).key, sizeof (s).key, STBDS_HM_BINARY), \ + (t)[stbds_temp((t)-1)] = (s)) + +#define stbds_hmgeti(t,k) \ + ((t) = stbds_hmget_key_wrapper((t), sizeof *(t), (void*) STBDS_ADDRESSOF((t)->key, (k)), sizeof (t)->key, STBDS_HM_BINARY), \ + stbds_temp((t)-1)) + +#define stbds_hmgeti_ts(t,k,temp) \ + ((t) = stbds_hmget_key_ts_wrapper((t), sizeof *(t), (void*) STBDS_ADDRESSOF((t)->key, (k)), sizeof (t)->key, &(temp), STBDS_HM_BINARY), \ + (temp)) + +#define stbds_hmgetp(t, k) \ + ((void) stbds_hmgeti(t,k), &(t)[stbds_temp((t)-1)]) + +#define stbds_hmgetp_ts(t, k, temp) \ + ((void) stbds_hmgeti_ts(t,k,temp), &(t)[temp]) + +#define stbds_hmdel(t,k) \ + (((t) = stbds_hmdel_key_wrapper((t),sizeof *(t), (void*) STBDS_ADDRESSOF((t)->key, (k)), sizeof (t)->key, STBDS_OFFSETOF((t),key), STBDS_HM_BINARY)),(t)?stbds_temp((t)-1):0) + +#define stbds_hmdefault(t, v) \ + ((t) = stbds_hmput_default_wrapper((t), sizeof *(t)), (t)[-1].value = (v)) + +#define stbds_hmdefaults(t, s) \ + ((t) = stbds_hmput_default_wrapper((t), sizeof *(t)), (t)[-1] = (s)) + +#define stbds_hmfree(p) \ + ((void) ((p) != NULL ? stbds_hmfree_func((p)-1,sizeof*(p)),0 : 0),(p)=NULL) + +#define stbds_hmgets(t, k) (*stbds_hmgetp(t,k)) +#define stbds_hmget(t, k) (stbds_hmgetp(t,k)->value) +#define stbds_hmget_ts(t, k, temp) (stbds_hmgetp_ts(t,k,temp)->value) +#define stbds_hmlen(t) ((t) ? (ptrdiff_t) stbds_header((t)-1)->length-1 : 0) +#define stbds_hmlenu(t) ((t) ? stbds_header((t)-1)->length-1 : 0) +#define stbds_hmgetp_null(t,k) (stbds_hmgeti(t,k) == -1 ? NULL : &(t)[stbds_temp((t)-1)]) + +#define stbds_shput(t, k, v) \ + ((t) = stbds_hmput_key_wrapper((t), sizeof *(t), (void*) (k), sizeof (t)->key, STBDS_HM_STRING), \ + (t)[stbds_temp((t)-1)].value = (v)) + +#define stbds_shputi(t, k, v) \ + ((t) = stbds_hmput_key_wrapper((t), sizeof *(t), (void*) (k), sizeof (t)->key, STBDS_HM_STRING), \ + (t)[stbds_temp((t)-1)].value = (v), stbds_temp((t)-1)) + +#define stbds_shputs(t, s) \ + ((t) = stbds_hmput_key_wrapper((t), sizeof *(t), (void*) (s).key, sizeof (s).key, STBDS_HM_STRING), \ + (t)[stbds_temp((t)-1)] = (s), \ + (t)[stbds_temp((t)-1)].key = stbds_temp_key((t)-1)) // above line overwrites whole structure, so must rewrite key here if it was allocated internally + +#define stbds_pshput(t, p) \ + ((t) = stbds_hmput_key_wrapper((t), sizeof *(t), (void*) (p)->key, sizeof (p)->key, STBDS_HM_PTR_TO_STRING), \ + (t)[stbds_temp((t)-1)] = (p)) + +#define stbds_shgeti(t,k) \ + ((t) = stbds_hmget_key_wrapper((t), sizeof *(t), (void*) (k), sizeof (t)->key, STBDS_HM_STRING), \ + stbds_temp((t)-1)) + +#define stbds_pshgeti(t,k) \ + ((t) = stbds_hmget_key_wrapper((t), sizeof *(t), (void*) (k), sizeof (*(t))->key, STBDS_HM_PTR_TO_STRING), \ + stbds_temp((t)-1)) + +#define stbds_shgetp(t, k) \ + ((void) stbds_shgeti(t,k), &(t)[stbds_temp((t)-1)]) + +#define stbds_pshget(t, k) \ + ((void) stbds_pshgeti(t,k), (t)[stbds_temp((t)-1)]) + +#define stbds_shdel(t,k) \ + (((t) = stbds_hmdel_key_wrapper((t),sizeof *(t), (void*) (k), sizeof (t)->key, STBDS_OFFSETOF((t),key), STBDS_HM_STRING)),(t)?stbds_temp((t)-1):0) +#define stbds_pshdel(t,k) \ + (((t) = stbds_hmdel_key_wrapper((t),sizeof *(t), (void*) (k), sizeof (*(t))->key, STBDS_OFFSETOF(*(t),key), STBDS_HM_PTR_TO_STRING)),(t)?stbds_temp((t)-1):0) + +#define stbds_sh_new_arena(t) \ + ((t) = stbds_shmode_func_wrapper(t, sizeof *(t), STBDS_SH_ARENA)) +#define stbds_sh_new_strdup(t) \ + ((t) = stbds_shmode_func_wrapper(t, sizeof *(t), STBDS_SH_STRDUP)) + +#define stbds_shdefault(t, v) stbds_hmdefault(t,v) +#define stbds_shdefaults(t, s) stbds_hmdefaults(t,s) + +#define stbds_shfree stbds_hmfree +#define stbds_shlenu stbds_hmlenu + +#define stbds_shgets(t, k) (*stbds_shgetp(t,k)) +#define stbds_shget(t, k) (stbds_shgetp(t,k)->value) +#define stbds_shgetp_null(t,k) (stbds_shgeti(t,k) == -1 ? NULL : &(t)[stbds_temp((t)-1)]) +#define stbds_shlen stbds_hmlen + +typedef struct +{ + size_t length; + size_t capacity; + void * hash_table; + ptrdiff_t temp; +} stbds_array_header; + +typedef struct stbds_string_block +{ + struct stbds_string_block *next; + char storage[8]; +} stbds_string_block; + +struct stbds_string_arena +{ + stbds_string_block *storage; + size_t remaining; + unsigned char block; + unsigned char mode; // this isn't used by the string arena itself +}; + +#define STBDS_HM_BINARY 0 +#define STBDS_HM_STRING 1 + +enum +{ + STBDS_SH_NONE, + STBDS_SH_DEFAULT, + STBDS_SH_STRDUP, + STBDS_SH_ARENA +}; + +#ifdef __cplusplus +// in C we use implicit assignment from these void*-returning functions to T*. +// in C++ these templates make the same code work +template static T * stbds_arrgrowf_wrapper(T *a, size_t elemsize, size_t addlen, size_t min_cap) { + return (T*)stbds_arrgrowf((void *)a, elemsize, addlen, min_cap); +} +template static T * stbds_hmget_key_wrapper(T *a, size_t elemsize, void *key, size_t keysize, int mode) { + return (T*)stbds_hmget_key((void*)a, elemsize, key, keysize, mode); +} +template static T * stbds_hmget_key_ts_wrapper(T *a, size_t elemsize, void *key, size_t keysize, ptrdiff_t *temp, int mode) { + return (T*)stbds_hmget_key_ts((void*)a, elemsize, key, keysize, temp, mode); +} +template static T * stbds_hmput_default_wrapper(T *a, size_t elemsize) { + return (T*)stbds_hmput_default((void *)a, elemsize); +} +template static T * stbds_hmput_key_wrapper(T *a, size_t elemsize, void *key, size_t keysize, int mode) { + return (T*)stbds_hmput_key((void*)a, elemsize, key, keysize, mode); +} +template static T * stbds_hmdel_key_wrapper(T *a, size_t elemsize, void *key, size_t keysize, size_t keyoffset, int mode){ + return (T*)stbds_hmdel_key((void*)a, elemsize, key, keysize, keyoffset, mode); +} +template static T * stbds_shmode_func_wrapper(T *, size_t elemsize, int mode) { + return (T*)stbds_shmode_func(elemsize, mode); +} +#else +#define stbds_arrgrowf_wrapper stbds_arrgrowf +#define stbds_hmget_key_wrapper stbds_hmget_key +#define stbds_hmget_key_ts_wrapper stbds_hmget_key_ts +#define stbds_hmput_default_wrapper stbds_hmput_default +#define stbds_hmput_key_wrapper stbds_hmput_key +#define stbds_hmdel_key_wrapper stbds_hmdel_key +#define stbds_shmode_func_wrapper(t,e,m) stbds_shmode_func(e,m) +#endif + +#endif // INCLUDE_STB_DS_H + + +////////////////////////////////////////////////////////////////////////////// +// +// IMPLEMENTATION +// + +#ifdef STB_DS_IMPLEMENTATION +#include +#include + +#ifndef STBDS_ASSERT +#define STBDS_ASSERT_WAS_UNDEFINED +#define STBDS_ASSERT(x) ((void) 0) +#endif + +#ifdef STBDS_STATISTICS +#define STBDS_STATS(x) x +size_t stbds_array_grow; +size_t stbds_hash_grow; +size_t stbds_hash_shrink; +size_t stbds_hash_rebuild; +size_t stbds_hash_probes; +size_t stbds_hash_alloc; +size_t stbds_rehash_probes; +size_t stbds_rehash_items; +#else +#define STBDS_STATS(x) +#endif + +// +// stbds_arr implementation +// + +//int *prev_allocs[65536]; +//int num_prev; + +void *stbds_arrgrowf(void *a, size_t elemsize, size_t addlen, size_t min_cap) +{ + stbds_array_header temp={0}; // force debugging + void *b; + size_t min_len = stbds_arrlen(a) + addlen; + (void) sizeof(temp); + + // compute the minimum capacity needed + if (min_len > min_cap) + min_cap = min_len; + + if (min_cap <= stbds_arrcap(a)) + return a; + + // increase needed capacity to guarantee O(1) amortized + if (min_cap < 2 * stbds_arrcap(a)) + min_cap = 2 * stbds_arrcap(a); + else if (min_cap < 4) + min_cap = 4; + + //if (num_prev < 65536) if (a) prev_allocs[num_prev++] = (int *) ((char *) a+1); + //if (num_prev == 2201) + // num_prev = num_prev; + b = STBDS_REALLOC(NULL, (a) ? stbds_header(a) : 0, elemsize * min_cap + sizeof(stbds_array_header)); + //if (num_prev < 65536) prev_allocs[num_prev++] = (int *) (char *) b; + b = (char *) b + sizeof(stbds_array_header); + if (a == NULL) { + stbds_header(b)->length = 0; + stbds_header(b)->hash_table = 0; + stbds_header(b)->temp = 0; + } else { + STBDS_STATS(++stbds_array_grow); + } + stbds_header(b)->capacity = min_cap; + + return b; +} + +void stbds_arrfreef(void *a) +{ + STBDS_FREE(NULL, stbds_header(a)); +} + +// +// stbds_hm hash table implementation +// + +#ifdef STBDS_INTERNAL_SMALL_BUCKET +#define STBDS_BUCKET_LENGTH 4 +#else +#define STBDS_BUCKET_LENGTH 8 +#endif + +#define STBDS_BUCKET_SHIFT (STBDS_BUCKET_LENGTH == 8 ? 3 : 2) +#define STBDS_BUCKET_MASK (STBDS_BUCKET_LENGTH-1) +#define STBDS_CACHE_LINE_SIZE 64 + +#define STBDS_ALIGN_FWD(n,a) (((n) + (a) - 1) & ~((a)-1)) + +typedef struct +{ + size_t hash [STBDS_BUCKET_LENGTH]; + ptrdiff_t index[STBDS_BUCKET_LENGTH]; +} stbds_hash_bucket; // in 32-bit, this is one 64-byte cache line; in 64-bit, each array is one 64-byte cache line + +typedef struct +{ + char * temp_key; // this MUST be the first field of the hash table + size_t slot_count; + size_t used_count; + size_t used_count_threshold; + size_t used_count_shrink_threshold; + size_t tombstone_count; + size_t tombstone_count_threshold; + size_t seed; + size_t slot_count_log2; + stbds_string_arena string; + stbds_hash_bucket *storage; // not a separate allocation, just 64-byte aligned storage after this struct +} stbds_hash_index; + +#define STBDS_INDEX_EMPTY -1 +#define STBDS_INDEX_DELETED -2 +#define STBDS_INDEX_IN_USE(x) ((x) >= 0) + +#define STBDS_HASH_EMPTY 0 +#define STBDS_HASH_DELETED 1 + +static size_t stbds_hash_seed=0x31415926; + +void stbds_rand_seed(size_t seed) +{ + stbds_hash_seed = seed; +} + +#define stbds_load_32_or_64(var, temp, v32, v64_hi, v64_lo) \ + temp = v64_lo ^ v32, temp <<= 16, temp <<= 16, temp >>= 16, temp >>= 16, /* discard if 32-bit */ \ + var = v64_hi, var <<= 16, var <<= 16, /* discard if 32-bit */ \ + var ^= temp ^ v32 + +#define STBDS_SIZE_T_BITS ((sizeof (size_t)) * 8) + +static size_t stbds_probe_position(size_t hash, size_t slot_count, size_t slot_log2) +{ + size_t pos; + STBDS_NOTUSED(slot_log2); + pos = hash & (slot_count-1); + #ifdef STBDS_INTERNAL_BUCKET_START + pos &= ~STBDS_BUCKET_MASK; + #endif + return pos; +} + +static size_t stbds_log2(size_t slot_count) +{ + size_t n=0; + while (slot_count > 1) { + slot_count >>= 1; + ++n; + } + return n; +} + +static stbds_hash_index *stbds_make_hash_index(size_t slot_count, stbds_hash_index *ot) +{ + stbds_hash_index *t; + t = (stbds_hash_index *) STBDS_REALLOC(NULL,0,(slot_count >> STBDS_BUCKET_SHIFT) * sizeof(stbds_hash_bucket) + sizeof(stbds_hash_index) + STBDS_CACHE_LINE_SIZE-1); + t->storage = (stbds_hash_bucket *) STBDS_ALIGN_FWD((size_t) (t+1), STBDS_CACHE_LINE_SIZE); + t->slot_count = slot_count; + t->slot_count_log2 = stbds_log2(slot_count); + t->tombstone_count = 0; + t->used_count = 0; + + #if 0 // A1 + t->used_count_threshold = slot_count*12/16; // if 12/16th of table is occupied, grow + t->tombstone_count_threshold = slot_count* 2/16; // if tombstones are 2/16th of table, rebuild + t->used_count_shrink_threshold = slot_count* 4/16; // if table is only 4/16th full, shrink + #elif 1 // A2 + //t->used_count_threshold = slot_count*12/16; // if 12/16th of table is occupied, grow + //t->tombstone_count_threshold = slot_count* 3/16; // if tombstones are 3/16th of table, rebuild + //t->used_count_shrink_threshold = slot_count* 4/16; // if table is only 4/16th full, shrink + + // compute without overflowing + t->used_count_threshold = slot_count - (slot_count>>2); + t->tombstone_count_threshold = (slot_count>>3) + (slot_count>>4); + t->used_count_shrink_threshold = slot_count >> 2; + + #elif 0 // B1 + t->used_count_threshold = slot_count*13/16; // if 13/16th of table is occupied, grow + t->tombstone_count_threshold = slot_count* 2/16; // if tombstones are 2/16th of table, rebuild + t->used_count_shrink_threshold = slot_count* 5/16; // if table is only 5/16th full, shrink + #else // C1 + t->used_count_threshold = slot_count*14/16; // if 14/16th of table is occupied, grow + t->tombstone_count_threshold = slot_count* 2/16; // if tombstones are 2/16th of table, rebuild + t->used_count_shrink_threshold = slot_count* 6/16; // if table is only 6/16th full, shrink + #endif + // Following statistics were measured on a Core i7-6700 @ 4.00Ghz, compiled with clang 7.0.1 -O2 + // Note that the larger tables have high variance as they were run fewer times + // A1 A2 B1 C1 + // 0.10ms : 0.10ms : 0.10ms : 0.11ms : 2,000 inserts creating 2K table + // 0.96ms : 0.95ms : 0.97ms : 1.04ms : 20,000 inserts creating 20K table + // 14.48ms : 14.46ms : 10.63ms : 11.00ms : 200,000 inserts creating 200K table + // 195.74ms : 196.35ms : 203.69ms : 214.92ms : 2,000,000 inserts creating 2M table + // 2193.88ms : 2209.22ms : 2285.54ms : 2437.17ms : 20,000,000 inserts creating 20M table + // 65.27ms : 53.77ms : 65.33ms : 65.47ms : 500,000 inserts & deletes in 2K table + // 72.78ms : 62.45ms : 71.95ms : 72.85ms : 500,000 inserts & deletes in 20K table + // 89.47ms : 77.72ms : 96.49ms : 96.75ms : 500,000 inserts & deletes in 200K table + // 97.58ms : 98.14ms : 97.18ms : 97.53ms : 500,000 inserts & deletes in 2M table + // 118.61ms : 119.62ms : 120.16ms : 118.86ms : 500,000 inserts & deletes in 20M table + // 192.11ms : 194.39ms : 196.38ms : 195.73ms : 500,000 inserts & deletes in 200M table + + if (slot_count <= STBDS_BUCKET_LENGTH) + t->used_count_shrink_threshold = 0; + // to avoid infinite loop, we need to guarantee that at least one slot is empty and will terminate probes + STBDS_ASSERT(t->used_count_threshold + t->tombstone_count_threshold < t->slot_count); + STBDS_STATS(++stbds_hash_alloc); + if (ot) { + t->string = ot->string; + // reuse old seed so we can reuse old hashes so below "copy out old data" doesn't do any hashing + t->seed = ot->seed; + } else { + size_t a,b,temp; + memset(&t->string, 0, sizeof(t->string)); + t->seed = stbds_hash_seed; + // LCG + // in 32-bit, a = 2147001325 b = 715136305 + // in 64-bit, a = 2862933555777941757 b = 3037000493 + stbds_load_32_or_64(a,temp, 2147001325, 0x27bb2ee6, 0x87b0b0fd); + stbds_load_32_or_64(b,temp, 715136305, 0, 0xb504f32d); + stbds_hash_seed = stbds_hash_seed * a + b; + } + + { + size_t i,j; + for (i=0; i < slot_count >> STBDS_BUCKET_SHIFT; ++i) { + stbds_hash_bucket *b = &t->storage[i]; + for (j=0; j < STBDS_BUCKET_LENGTH; ++j) + b->hash[j] = STBDS_HASH_EMPTY; + for (j=0; j < STBDS_BUCKET_LENGTH; ++j) + b->index[j] = STBDS_INDEX_EMPTY; + } + } + + // copy out the old data, if any + if (ot) { + size_t i,j; + t->used_count = ot->used_count; + for (i=0; i < ot->slot_count >> STBDS_BUCKET_SHIFT; ++i) { + stbds_hash_bucket *ob = &ot->storage[i]; + for (j=0; j < STBDS_BUCKET_LENGTH; ++j) { + if (STBDS_INDEX_IN_USE(ob->index[j])) { + size_t hash = ob->hash[j]; + size_t pos = stbds_probe_position(hash, t->slot_count, t->slot_count_log2); + size_t step = STBDS_BUCKET_LENGTH; + STBDS_STATS(++stbds_rehash_items); + for (;;) { + size_t limit,z; + stbds_hash_bucket *bucket; + bucket = &t->storage[pos >> STBDS_BUCKET_SHIFT]; + STBDS_STATS(++stbds_rehash_probes); + + for (z=pos & STBDS_BUCKET_MASK; z < STBDS_BUCKET_LENGTH; ++z) { + if (bucket->hash[z] == 0) { + bucket->hash[z] = hash; + bucket->index[z] = ob->index[j]; + goto done; + } + } + + limit = pos & STBDS_BUCKET_MASK; + for (z = 0; z < limit; ++z) { + if (bucket->hash[z] == 0) { + bucket->hash[z] = hash; + bucket->index[z] = ob->index[j]; + goto done; + } + } + + pos += step; // quadratic probing + step += STBDS_BUCKET_LENGTH; + pos &= (t->slot_count-1); + } + } + done: + ; + } + } + } + + return t; +} + +#define STBDS_ROTATE_LEFT(val, n) (((val) << (n)) | ((val) >> (STBDS_SIZE_T_BITS - (n)))) +#define STBDS_ROTATE_RIGHT(val, n) (((val) >> (n)) | ((val) << (STBDS_SIZE_T_BITS - (n)))) + +size_t stbds_hash_string(char *str, size_t seed) +{ + size_t hash = seed; + while (*str) + hash = STBDS_ROTATE_LEFT(hash, 9) + (unsigned char) *str++; + + // Thomas Wang 64-to-32 bit mix function, hopefully also works in 32 bits + hash ^= seed; + hash = (~hash) + (hash << 18); + hash ^= hash ^ STBDS_ROTATE_RIGHT(hash,31); + hash = hash * 21; + hash ^= hash ^ STBDS_ROTATE_RIGHT(hash,11); + hash += (hash << 6); + hash ^= STBDS_ROTATE_RIGHT(hash,22); + return hash+seed; +} + +#ifdef STBDS_SIPHASH_2_4 +#define STBDS_SIPHASH_C_ROUNDS 2 +#define STBDS_SIPHASH_D_ROUNDS 4 +typedef int STBDS_SIPHASH_2_4_can_only_be_used_in_64_bit_builds[sizeof(size_t) == 8 ? 1 : -1]; +#endif + +#ifndef STBDS_SIPHASH_C_ROUNDS +#define STBDS_SIPHASH_C_ROUNDS 1 +#endif +#ifndef STBDS_SIPHASH_D_ROUNDS +#define STBDS_SIPHASH_D_ROUNDS 1 +#endif + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4127) // conditional expression is constant, for do..while(0) and sizeof()== +#endif + +static size_t stbds_siphash_bytes(void *p, size_t len, size_t seed) +{ + unsigned char *d = (unsigned char *) p; + size_t i,j; + size_t v0,v1,v2,v3, data; + + // hash that works on 32- or 64-bit registers without knowing which we have + // (computes different results on 32-bit and 64-bit platform) + // derived from siphash, but on 32-bit platforms very different as it uses 4 32-bit state not 4 64-bit + v0 = ((((size_t) 0x736f6d65 << 16) << 16) + 0x70736575) ^ seed; + v1 = ((((size_t) 0x646f7261 << 16) << 16) + 0x6e646f6d) ^ ~seed; + v2 = ((((size_t) 0x6c796765 << 16) << 16) + 0x6e657261) ^ seed; + v3 = ((((size_t) 0x74656462 << 16) << 16) + 0x79746573) ^ ~seed; + + #ifdef STBDS_TEST_SIPHASH_2_4 + // hardcoded with key material in the siphash test vectors + v0 ^= 0x0706050403020100ull ^ seed; + v1 ^= 0x0f0e0d0c0b0a0908ull ^ ~seed; + v2 ^= 0x0706050403020100ull ^ seed; + v3 ^= 0x0f0e0d0c0b0a0908ull ^ ~seed; + #endif + + #define STBDS_SIPROUND() \ + do { \ + v0 += v1; v1 = STBDS_ROTATE_LEFT(v1, 13); v1 ^= v0; v0 = STBDS_ROTATE_LEFT(v0,STBDS_SIZE_T_BITS/2); \ + v2 += v3; v3 = STBDS_ROTATE_LEFT(v3, 16); v3 ^= v2; \ + v2 += v1; v1 = STBDS_ROTATE_LEFT(v1, 17); v1 ^= v2; v2 = STBDS_ROTATE_LEFT(v2,STBDS_SIZE_T_BITS/2); \ + v0 += v3; v3 = STBDS_ROTATE_LEFT(v3, 21); v3 ^= v0; \ + } while (0) + + for (i=0; i+sizeof(size_t) <= len; i += sizeof(size_t), d += sizeof(size_t)) { + data = d[0] | (d[1] << 8) | (d[2] << 16) | (d[3] << 24); + data |= (size_t) (d[4] | (d[5] << 8) | (d[6] << 16) | (d[7] << 24)) << 16 << 16; // discarded if size_t == 4 + + v3 ^= data; + for (j=0; j < STBDS_SIPHASH_C_ROUNDS; ++j) + STBDS_SIPROUND(); + v0 ^= data; + } + data = len << (STBDS_SIZE_T_BITS-8); + switch (len - i) { + case 7: data |= ((size_t) d[6] << 24) << 24; // fall through + case 6: data |= ((size_t) d[5] << 20) << 20; // fall through + case 5: data |= ((size_t) d[4] << 16) << 16; // fall through + case 4: data |= (d[3] << 24); // fall through + case 3: data |= (d[2] << 16); // fall through + case 2: data |= (d[1] << 8); // fall through + case 1: data |= d[0]; // fall through + case 0: break; + } + v3 ^= data; + for (j=0; j < STBDS_SIPHASH_C_ROUNDS; ++j) + STBDS_SIPROUND(); + v0 ^= data; + v2 ^= 0xff; + for (j=0; j < STBDS_SIPHASH_D_ROUNDS; ++j) + STBDS_SIPROUND(); + +#ifdef STBDS_SIPHASH_2_4 + return v0^v1^v2^v3; +#else + return v1^v2^v3; // slightly stronger since v0^v3 in above cancels out final round operation? I tweeted at the authors of SipHash about this but they didn't reply +#endif +} + +size_t stbds_hash_bytes(void *p, size_t len, size_t seed) +{ +#ifdef STBDS_SIPHASH_2_4 + return stbds_siphash_bytes(p,len,seed); +#else + unsigned char *d = (unsigned char *) p; + + if (len == 4) { + unsigned int hash = d[0] | (d[1] << 8) | (d[2] << 16) | (d[3] << 24); + #if 0 + // HASH32-A Bob Jenkin's hash function w/o large constants + hash ^= seed; + hash -= (hash<<6); + hash ^= (hash>>17); + hash -= (hash<<9); + hash ^= seed; + hash ^= (hash<<4); + hash -= (hash<<3); + hash ^= (hash<<10); + hash ^= (hash>>15); + #elif 1 + // HASH32-BB Bob Jenkin's presumably-accidental version of Thomas Wang hash with rotates turned into shifts. + // Note that converting these back to rotates makes it run a lot slower, presumably due to collisions, so I'm + // not really sure what's going on. + hash ^= seed; + hash = (hash ^ 61) ^ (hash >> 16); + hash = hash + (hash << 3); + hash = hash ^ (hash >> 4); + hash = hash * 0x27d4eb2d; + hash ^= seed; + hash = hash ^ (hash >> 15); + #else // HASH32-C - Murmur3 + hash ^= seed; + hash *= 0xcc9e2d51; + hash = (hash << 17) | (hash >> 15); + hash *= 0x1b873593; + hash ^= seed; + hash = (hash << 19) | (hash >> 13); + hash = hash*5 + 0xe6546b64; + hash ^= hash >> 16; + hash *= 0x85ebca6b; + hash ^= seed; + hash ^= hash >> 13; + hash *= 0xc2b2ae35; + hash ^= hash >> 16; + #endif + // Following statistics were measured on a Core i7-6700 @ 4.00Ghz, compiled with clang 7.0.1 -O2 + // Note that the larger tables have high variance as they were run fewer times + // HASH32-A // HASH32-BB // HASH32-C + // 0.10ms // 0.10ms // 0.10ms : 2,000 inserts creating 2K table + // 0.96ms // 0.95ms // 0.99ms : 20,000 inserts creating 20K table + // 14.69ms // 14.43ms // 14.97ms : 200,000 inserts creating 200K table + // 199.99ms // 195.36ms // 202.05ms : 2,000,000 inserts creating 2M table + // 2234.84ms // 2187.74ms // 2240.38ms : 20,000,000 inserts creating 20M table + // 55.68ms // 53.72ms // 57.31ms : 500,000 inserts & deletes in 2K table + // 63.43ms // 61.99ms // 65.73ms : 500,000 inserts & deletes in 20K table + // 80.04ms // 77.96ms // 81.83ms : 500,000 inserts & deletes in 200K table + // 100.42ms // 97.40ms // 102.39ms : 500,000 inserts & deletes in 2M table + // 119.71ms // 120.59ms // 121.63ms : 500,000 inserts & deletes in 20M table + // 185.28ms // 195.15ms // 187.74ms : 500,000 inserts & deletes in 200M table + // 15.58ms // 14.79ms // 15.52ms : 200,000 inserts creating 200K table with varying key spacing + + return (((size_t) hash << 16 << 16) | hash) ^ seed; + } else if (len == 8 && sizeof(size_t) == 8) { + size_t hash = d[0] | (d[1] << 8) | (d[2] << 16) | (d[3] << 24); + hash |= (size_t) (d[4] | (d[5] << 8) | (d[6] << 16) | (d[7] << 24)) << 16 << 16; // avoid warning if size_t == 4 + hash ^= seed; + hash = (~hash) + (hash << 21); + hash ^= STBDS_ROTATE_RIGHT(hash,24); + hash *= 265; + hash ^= STBDS_ROTATE_RIGHT(hash,14); + hash ^= seed; + hash *= 21; + hash ^= STBDS_ROTATE_RIGHT(hash,28); + hash += (hash << 31); + hash = (~hash) + (hash << 18); + return hash; + } else { + return stbds_siphash_bytes(p,len,seed); + } +#endif +} +#ifdef _MSC_VER +#pragma warning(pop) +#endif + + +static int stbds_is_key_equal(void *a, size_t elemsize, void *key, size_t keysize, size_t keyoffset, int mode, size_t i) +{ + if (mode >= STBDS_HM_STRING) + return 0==strcmp((char *) key, * (char **) ((char *) a + elemsize*i + keyoffset)); + else + return 0==memcmp(key, (char *) a + elemsize*i + keyoffset, keysize); +} + +#define STBDS_HASH_TO_ARR(x,elemsize) ((char*) (x) - (elemsize)) +#define STBDS_ARR_TO_HASH(x,elemsize) ((char*) (x) + (elemsize)) + +#define stbds_hash_table(a) ((stbds_hash_index *) stbds_header(a)->hash_table) + +void stbds_hmfree_func(void *a, size_t elemsize) +{ + if (a == NULL) return; + if (stbds_hash_table(a) != NULL) { + if (stbds_hash_table(a)->string.mode == STBDS_SH_STRDUP) { + size_t i; + // skip 0th element, which is default + for (i=1; i < stbds_header(a)->length; ++i) + STBDS_FREE(NULL, *(char**) ((char *) a + elemsize*i)); + } + stbds_strreset(&stbds_hash_table(a)->string); + } + STBDS_FREE(NULL, stbds_header(a)->hash_table); + STBDS_FREE(NULL, stbds_header(a)); +} + +static ptrdiff_t stbds_hm_find_slot(void *a, size_t elemsize, void *key, size_t keysize, size_t keyoffset, int mode) +{ + void *raw_a = STBDS_HASH_TO_ARR(a,elemsize); + stbds_hash_index *table = stbds_hash_table(raw_a); + size_t hash = mode >= STBDS_HM_STRING ? stbds_hash_string((char*)key,table->seed) : stbds_hash_bytes(key, keysize,table->seed); + size_t step = STBDS_BUCKET_LENGTH; + size_t limit,i; + size_t pos; + stbds_hash_bucket *bucket; + + if (hash < 2) hash += 2; // stored hash values are forbidden from being 0, so we can detect empty slots + + pos = stbds_probe_position(hash, table->slot_count, table->slot_count_log2); + + for (;;) { + STBDS_STATS(++stbds_hash_probes); + bucket = &table->storage[pos >> STBDS_BUCKET_SHIFT]; + + // start searching from pos to end of bucket, this should help performance on small hash tables that fit in cache + for (i=pos & STBDS_BUCKET_MASK; i < STBDS_BUCKET_LENGTH; ++i) { + if (bucket->hash[i] == hash) { + if (stbds_is_key_equal(a, elemsize, key, keysize, keyoffset, mode, bucket->index[i])) { + return (pos & ~STBDS_BUCKET_MASK)+i; + } + } else if (bucket->hash[i] == STBDS_HASH_EMPTY) { + return -1; + } + } + + // search from beginning of bucket to pos + limit = pos & STBDS_BUCKET_MASK; + for (i = 0; i < limit; ++i) { + if (bucket->hash[i] == hash) { + if (stbds_is_key_equal(a, elemsize, key, keysize, keyoffset, mode, bucket->index[i])) { + return (pos & ~STBDS_BUCKET_MASK)+i; + } + } else if (bucket->hash[i] == STBDS_HASH_EMPTY) { + return -1; + } + } + + // quadratic probing + pos += step; + step += STBDS_BUCKET_LENGTH; + pos &= (table->slot_count-1); + } + /* NOTREACHED */ +} + +void * stbds_hmget_key_ts(void *a, size_t elemsize, void *key, size_t keysize, ptrdiff_t *temp, int mode) +{ + size_t keyoffset = 0; + if (a == NULL) { + // make it non-empty so we can return a temp + a = stbds_arrgrowf(0, elemsize, 0, 1); + stbds_header(a)->length += 1; + memset(a, 0, elemsize); + *temp = STBDS_INDEX_EMPTY; + // adjust a to point after the default element + return STBDS_ARR_TO_HASH(a,elemsize); + } else { + stbds_hash_index *table; + void *raw_a = STBDS_HASH_TO_ARR(a,elemsize); + // adjust a to point to the default element + table = (stbds_hash_index *) stbds_header(raw_a)->hash_table; + if (table == 0) { + *temp = -1; + } else { + ptrdiff_t slot = stbds_hm_find_slot(a, elemsize, key, keysize, keyoffset, mode); + if (slot < 0) { + *temp = STBDS_INDEX_EMPTY; + } else { + stbds_hash_bucket *b = &table->storage[slot >> STBDS_BUCKET_SHIFT]; + *temp = b->index[slot & STBDS_BUCKET_MASK]; + } + } + return a; + } +} + +void * stbds_hmget_key(void *a, size_t elemsize, void *key, size_t keysize, int mode) +{ + ptrdiff_t temp; + void *p = stbds_hmget_key_ts(a, elemsize, key, keysize, &temp, mode); + stbds_temp(STBDS_HASH_TO_ARR(p,elemsize)) = temp; + return p; +} + +void * stbds_hmput_default(void *a, size_t elemsize) +{ + // three cases: + // a is NULL <- allocate + // a has a hash table but no entries, because of shmode <- grow + // a has entries <- do nothing + if (a == NULL || stbds_header(STBDS_HASH_TO_ARR(a,elemsize))->length == 0) { + a = stbds_arrgrowf(a ? STBDS_HASH_TO_ARR(a,elemsize) : NULL, elemsize, 0, 1); + stbds_header(a)->length += 1; + memset(a, 0, elemsize); + a=STBDS_ARR_TO_HASH(a,elemsize); + } + return a; +} + +static char *stbds_strdup(char *str); + +void *stbds_hmput_key(void *a, size_t elemsize, void *key, size_t keysize, int mode) +{ + size_t keyoffset=0; + void *raw_a; + stbds_hash_index *table; + + if (a == NULL) { + a = stbds_arrgrowf(0, elemsize, 0, 1); + memset(a, 0, elemsize); + stbds_header(a)->length += 1; + // adjust a to point AFTER the default element + a = STBDS_ARR_TO_HASH(a,elemsize); + } + + // adjust a to point to the default element + raw_a = a; + a = STBDS_HASH_TO_ARR(a,elemsize); + + table = (stbds_hash_index *) stbds_header(a)->hash_table; + + if (table == NULL || table->used_count >= table->used_count_threshold) { + stbds_hash_index *nt; + size_t slot_count; + + slot_count = (table == NULL) ? STBDS_BUCKET_LENGTH : table->slot_count*2; + nt = stbds_make_hash_index(slot_count, table); + if (table) + STBDS_FREE(NULL, table); + else + nt->string.mode = mode >= STBDS_HM_STRING ? STBDS_SH_DEFAULT : 0; + stbds_header(a)->hash_table = table = nt; + STBDS_STATS(++stbds_hash_grow); + } + + // we iterate hash table explicitly because we want to track if we saw a tombstone + { + size_t hash = mode >= STBDS_HM_STRING ? stbds_hash_string((char*)key,table->seed) : stbds_hash_bytes(key, keysize,table->seed); + size_t step = STBDS_BUCKET_LENGTH; + size_t pos; + ptrdiff_t tombstone = -1; + stbds_hash_bucket *bucket; + + // stored hash values are forbidden from being 0, so we can detect empty slots to early out quickly + if (hash < 2) hash += 2; + + pos = stbds_probe_position(hash, table->slot_count, table->slot_count_log2); + + for (;;) { + size_t limit, i; + STBDS_STATS(++stbds_hash_probes); + bucket = &table->storage[pos >> STBDS_BUCKET_SHIFT]; + + // start searching from pos to end of bucket + for (i=pos & STBDS_BUCKET_MASK; i < STBDS_BUCKET_LENGTH; ++i) { + if (bucket->hash[i] == hash) { + if (stbds_is_key_equal(raw_a, elemsize, key, keysize, keyoffset, mode, bucket->index[i])) { + stbds_temp(a) = bucket->index[i]; + if (mode >= STBDS_HM_STRING) + stbds_temp_key(a) = * (char **) ((char *) raw_a + elemsize*bucket->index[i] + keyoffset); + return STBDS_ARR_TO_HASH(a,elemsize); + } + } else if (bucket->hash[i] == 0) { + pos = (pos & ~STBDS_BUCKET_MASK) + i; + goto found_empty_slot; + } else if (tombstone < 0) { + if (bucket->index[i] == STBDS_INDEX_DELETED) + tombstone = (ptrdiff_t) ((pos & ~STBDS_BUCKET_MASK) + i); + } + } + + // search from beginning of bucket to pos + limit = pos & STBDS_BUCKET_MASK; + for (i = 0; i < limit; ++i) { + if (bucket->hash[i] == hash) { + if (stbds_is_key_equal(raw_a, elemsize, key, keysize, keyoffset, mode, bucket->index[i])) { + stbds_temp(a) = bucket->index[i]; + return STBDS_ARR_TO_HASH(a,elemsize); + } + } else if (bucket->hash[i] == 0) { + pos = (pos & ~STBDS_BUCKET_MASK) + i; + goto found_empty_slot; + } else if (tombstone < 0) { + if (bucket->index[i] == STBDS_INDEX_DELETED) + tombstone = (ptrdiff_t) ((pos & ~STBDS_BUCKET_MASK) + i); + } + } + + // quadratic probing + pos += step; + step += STBDS_BUCKET_LENGTH; + pos &= (table->slot_count-1); + } + found_empty_slot: + if (tombstone >= 0) { + pos = tombstone; + --table->tombstone_count; + } + ++table->used_count; + + { + ptrdiff_t i = (ptrdiff_t) stbds_arrlen(a); + // we want to do stbds_arraddn(1), but we can't use the macros since we don't have something of the right type + if ((size_t) i+1 > stbds_arrcap(a)) + *(void **) &a = stbds_arrgrowf(a, elemsize, 1, 0); + raw_a = STBDS_ARR_TO_HASH(a,elemsize); + + STBDS_ASSERT((size_t) i+1 <= stbds_arrcap(a)); + stbds_header(a)->length = i+1; + bucket = &table->storage[pos >> STBDS_BUCKET_SHIFT]; + bucket->hash[pos & STBDS_BUCKET_MASK] = hash; + bucket->index[pos & STBDS_BUCKET_MASK] = i-1; + stbds_temp(a) = i-1; + + switch (table->string.mode) { + case STBDS_SH_STRDUP: stbds_temp_key(a) = *(char **) ((char *) a + elemsize*i) = stbds_strdup((char*) key); break; + case STBDS_SH_ARENA: stbds_temp_key(a) = *(char **) ((char *) a + elemsize*i) = stbds_stralloc(&table->string, (char*)key); break; + case STBDS_SH_DEFAULT: stbds_temp_key(a) = *(char **) ((char *) a + elemsize*i) = (char *) key; break; + default: memcpy((char *) a + elemsize*i, key, keysize); break; + } + } + return STBDS_ARR_TO_HASH(a,elemsize); + } +} + +void * stbds_shmode_func(size_t elemsize, int mode) +{ + void *a = stbds_arrgrowf(0, elemsize, 0, 1); + stbds_hash_index *h; + memset(a, 0, elemsize); + stbds_header(a)->length = 1; + stbds_header(a)->hash_table = h = (stbds_hash_index *) stbds_make_hash_index(STBDS_BUCKET_LENGTH, NULL); + h->string.mode = (unsigned char) mode; + return STBDS_ARR_TO_HASH(a,elemsize); +} + +void * stbds_hmdel_key(void *a, size_t elemsize, void *key, size_t keysize, size_t keyoffset, int mode) +{ + if (a == NULL) { + return 0; + } else { + stbds_hash_index *table; + void *raw_a = STBDS_HASH_TO_ARR(a,elemsize); + table = (stbds_hash_index *) stbds_header(raw_a)->hash_table; + stbds_temp(raw_a) = 0; + if (table == 0) { + return a; + } else { + ptrdiff_t slot; + slot = stbds_hm_find_slot(a, elemsize, key, keysize, keyoffset, mode); + if (slot < 0) + return a; + else { + stbds_hash_bucket *b = &table->storage[slot >> STBDS_BUCKET_SHIFT]; + int i = slot & STBDS_BUCKET_MASK; + ptrdiff_t old_index = b->index[i]; + ptrdiff_t final_index = (ptrdiff_t) stbds_arrlen(raw_a)-1-1; // minus one for the raw_a vs a, and minus one for 'last' + STBDS_ASSERT(slot < (ptrdiff_t) table->slot_count); + --table->used_count; + ++table->tombstone_count; + stbds_temp(raw_a) = 1; + STBDS_ASSERT(table->used_count >= 0); + //STBDS_ASSERT(table->tombstone_count < table->slot_count/4); + b->hash[i] = STBDS_HASH_DELETED; + b->index[i] = STBDS_INDEX_DELETED; + + if (mode == STBDS_HM_STRING && table->string.mode == STBDS_SH_STRDUP) + STBDS_FREE(NULL, *(char**) ((char *) a+elemsize*old_index)); + + // if indices are the same, memcpy is a no-op, but back-pointer-fixup will fail, so skip + if (old_index != final_index) { + // swap delete + memmove((char*) a + elemsize*old_index, (char*) a + elemsize*final_index, elemsize); + + // now find the slot for the last element + if (mode == STBDS_HM_STRING) + slot = stbds_hm_find_slot(a, elemsize, *(char**) ((char *) a+elemsize*old_index + keyoffset), keysize, keyoffset, mode); + else + slot = stbds_hm_find_slot(a, elemsize, (char* ) a+elemsize*old_index + keyoffset, keysize, keyoffset, mode); + STBDS_ASSERT(slot >= 0); + b = &table->storage[slot >> STBDS_BUCKET_SHIFT]; + i = slot & STBDS_BUCKET_MASK; + STBDS_ASSERT(b->index[i] == final_index); + b->index[i] = old_index; + } + stbds_header(raw_a)->length -= 1; + + if (table->used_count < table->used_count_shrink_threshold && table->slot_count > STBDS_BUCKET_LENGTH) { + stbds_header(raw_a)->hash_table = stbds_make_hash_index(table->slot_count>>1, table); + STBDS_FREE(NULL, table); + STBDS_STATS(++stbds_hash_shrink); + } else if (table->tombstone_count > table->tombstone_count_threshold) { + stbds_header(raw_a)->hash_table = stbds_make_hash_index(table->slot_count , table); + STBDS_FREE(NULL, table); + STBDS_STATS(++stbds_hash_rebuild); + } + + return a; + } + } + } + /* NOTREACHED */ +} + +static char *stbds_strdup(char *str) +{ + // to keep replaceable allocator simple, we don't want to use strdup. + // rolling our own also avoids problem of strdup vs _strdup + size_t len = strlen(str)+1; + char *p = (char*) STBDS_REALLOC(NULL, 0, len); + memmove(p, str, len); + return p; +} + +#ifndef STBDS_STRING_ARENA_BLOCKSIZE_MIN +#define STBDS_STRING_ARENA_BLOCKSIZE_MIN 512u +#endif +#ifndef STBDS_STRING_ARENA_BLOCKSIZE_MAX +#define STBDS_STRING_ARENA_BLOCKSIZE_MAX (1u<<20) +#endif + +char *stbds_stralloc(stbds_string_arena *a, char *str) +{ + char *p; + size_t len = strlen(str)+1; + if (len > a->remaining) { + // compute the next blocksize + size_t blocksize = a->block; + + // size is 512, 512, 1024, 1024, 2048, 2048, 4096, 4096, etc., so that + // there are log(SIZE) allocations to free when we destroy the table + blocksize = (size_t) (STBDS_STRING_ARENA_BLOCKSIZE_MIN) << (blocksize>>1); + + // if size is under 1M, advance to next blocktype + if (blocksize < (size_t)(STBDS_STRING_ARENA_BLOCKSIZE_MAX)) + ++a->block; + + if (len > blocksize) { + // if string is larger than blocksize, then just allocate the full size. + // note that we still advance string_block so block size will continue + // increasing, so e.g. if somebody only calls this with 1000-long strings, + // eventually the arena will start doubling and handling those as well + stbds_string_block *sb = (stbds_string_block *) STBDS_REALLOC(NULL, 0, sizeof(*sb)-8 + len); + memmove(sb->storage, str, len); + if (a->storage) { + // insert it after the first element, so that we don't waste the space there + sb->next = a->storage->next; + a->storage->next = sb; + } else { + sb->next = 0; + a->storage = sb; + a->remaining = 0; // this is redundant, but good for clarity + } + return sb->storage; + } else { + stbds_string_block *sb = (stbds_string_block *) STBDS_REALLOC(NULL, 0, sizeof(*sb)-8 + blocksize); + sb->next = a->storage; + a->storage = sb; + a->remaining = blocksize; + } + } + + STBDS_ASSERT(len <= a->remaining); + p = a->storage->storage + a->remaining - len; + a->remaining -= len; + memmove(p, str, len); + return p; +} + +void stbds_strreset(stbds_string_arena *a) +{ + stbds_string_block *x,*y; + x = a->storage; + while (x) { + y = x->next; + STBDS_FREE(NULL, x); + x = y; + } + memset(a, 0, sizeof(*a)); +} + +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// UNIT TESTS +// + +#ifdef STBDS_UNIT_TESTS +#include +#ifdef STBDS_ASSERT_WAS_UNDEFINED +#undef STBDS_ASSERT +#endif +#ifndef STBDS_ASSERT +#define STBDS_ASSERT assert +#include +#endif + +typedef struct { int key,b,c,d; } stbds_struct; +typedef struct { int key[2],b,c,d; } stbds_struct2; + +static char buffer[256]; +char *strkey(int n) +{ +#if defined(_WIN32) && defined(__STDC_WANT_SECURE_LIB__) + sprintf_s(buffer, sizeof(buffer), "test_%d", n); +#else + sprintf(buffer, "test_%d", n); +#endif + return buffer; +} + +void stbds_unit_tests(void) +{ +#if defined(_MSC_VER) && _MSC_VER <= 1200 && defined(__cplusplus) + // VC6 C++ doesn't like the template<> trick on unnamed structures, so do nothing! + STBDS_ASSERT(0); +#else + const int testsize = 100000; + const int testsize2 = testsize/20; + int *arr=NULL; + struct { int key; int value; } *intmap = NULL; + struct { char *key; int value; } *strmap = NULL, s; + struct { stbds_struct key; int value; } *map = NULL; + stbds_struct *map2 = NULL; + stbds_struct2 *map3 = NULL; + stbds_string_arena sa = { 0 }; + int key3[2] = { 1,2 }; + ptrdiff_t temp; + + int i,j; + + STBDS_ASSERT(arrlen(arr)==0); + for (i=0; i < 20000; i += 50) { + for (j=0; j < i; ++j) + arrpush(arr,j); + arrfree(arr); + } + + for (i=0; i < 4; ++i) { + arrpush(arr,1); arrpush(arr,2); arrpush(arr,3); arrpush(arr,4); + arrdel(arr,i); + arrfree(arr); + arrpush(arr,1); arrpush(arr,2); arrpush(arr,3); arrpush(arr,4); + arrdelswap(arr,i); + arrfree(arr); + } + + for (i=0; i < 5; ++i) { + arrpush(arr,1); arrpush(arr,2); arrpush(arr,3); arrpush(arr,4); + stbds_arrins(arr,i,5); + STBDS_ASSERT(arr[i] == 5); + if (i < 4) + STBDS_ASSERT(arr[4] == 4); + arrfree(arr); + } + + i = 1; + STBDS_ASSERT(hmgeti(intmap,i) == -1); + hmdefault(intmap, -2); + STBDS_ASSERT(hmgeti(intmap, i) == -1); + STBDS_ASSERT(hmget (intmap, i) == -2); + for (i=0; i < testsize; i+=2) + hmput(intmap, i, i*5); + for (i=0; i < testsize; i+=1) { + if (i & 1) STBDS_ASSERT(hmget(intmap, i) == -2 ); + else STBDS_ASSERT(hmget(intmap, i) == i*5); + if (i & 1) STBDS_ASSERT(hmget_ts(intmap, i, temp) == -2 ); + else STBDS_ASSERT(hmget_ts(intmap, i, temp) == i*5); + } + for (i=0; i < testsize; i+=2) + hmput(intmap, i, i*3); + for (i=0; i < testsize; i+=1) + if (i & 1) STBDS_ASSERT(hmget(intmap, i) == -2 ); + else STBDS_ASSERT(hmget(intmap, i) == i*3); + for (i=2; i < testsize; i+=4) + hmdel(intmap, i); // delete half the entries + for (i=0; i < testsize; i+=1) + if (i & 3) STBDS_ASSERT(hmget(intmap, i) == -2 ); + else STBDS_ASSERT(hmget(intmap, i) == i*3); + for (i=0; i < testsize; i+=1) + hmdel(intmap, i); // delete the rest of the entries + for (i=0; i < testsize; i+=1) + STBDS_ASSERT(hmget(intmap, i) == -2 ); + hmfree(intmap); + for (i=0; i < testsize; i+=2) + hmput(intmap, i, i*3); + hmfree(intmap); + + #if defined(__clang__) || defined(__GNUC__) + #ifndef __cplusplus + intmap = NULL; + hmput(intmap, 15, 7); + hmput(intmap, 11, 3); + hmput(intmap, 9, 5); + STBDS_ASSERT(hmget(intmap, 9) == 5); + STBDS_ASSERT(hmget(intmap, 11) == 3); + STBDS_ASSERT(hmget(intmap, 15) == 7); + #endif + #endif + + for (i=0; i < testsize; ++i) + stralloc(&sa, strkey(i)); + strreset(&sa); + + { + s.key = "a", s.value = 1; + shputs(strmap, s); + STBDS_ASSERT(*strmap[0].key == 'a'); + STBDS_ASSERT(strmap[0].key == s.key); + STBDS_ASSERT(strmap[0].value == s.value); + shfree(strmap); + } + + { + s.key = "a", s.value = 1; + sh_new_strdup(strmap); + shputs(strmap, s); + STBDS_ASSERT(*strmap[0].key == 'a'); + STBDS_ASSERT(strmap[0].key != s.key); + STBDS_ASSERT(strmap[0].value == s.value); + shfree(strmap); + } + + { + s.key = "a", s.value = 1; + sh_new_arena(strmap); + shputs(strmap, s); + STBDS_ASSERT(*strmap[0].key == 'a'); + STBDS_ASSERT(strmap[0].key != s.key); + STBDS_ASSERT(strmap[0].value == s.value); + shfree(strmap); + } + + for (j=0; j < 2; ++j) { + STBDS_ASSERT(shgeti(strmap,"foo") == -1); + if (j == 0) + sh_new_strdup(strmap); + else + sh_new_arena(strmap); + STBDS_ASSERT(shgeti(strmap,"foo") == -1); + shdefault(strmap, -2); + STBDS_ASSERT(shgeti(strmap,"foo") == -1); + for (i=0; i < testsize; i+=2) + shput(strmap, strkey(i), i*3); + for (i=0; i < testsize; i+=1) + if (i & 1) STBDS_ASSERT(shget(strmap, strkey(i)) == -2 ); + else STBDS_ASSERT(shget(strmap, strkey(i)) == i*3); + for (i=2; i < testsize; i+=4) + shdel(strmap, strkey(i)); // delete half the entries + for (i=0; i < testsize; i+=1) + if (i & 3) STBDS_ASSERT(shget(strmap, strkey(i)) == -2 ); + else STBDS_ASSERT(shget(strmap, strkey(i)) == i*3); + for (i=0; i < testsize; i+=1) + shdel(strmap, strkey(i)); // delete the rest of the entries + for (i=0; i < testsize; i+=1) + STBDS_ASSERT(shget(strmap, strkey(i)) == -2 ); + shfree(strmap); + } + + { + struct { char *key; char value; } *hash = NULL; + char name[4] = "jen"; + shput(hash, "bob" , 'h'); + shput(hash, "sally" , 'e'); + shput(hash, "fred" , 'l'); + shput(hash, "jen" , 'x'); + shput(hash, "doug" , 'o'); + + shput(hash, name , 'l'); + shfree(hash); + } + + for (i=0; i < testsize; i += 2) { + stbds_struct s = { i,i*2,i*3,i*4 }; + hmput(map, s, i*5); + } + + for (i=0; i < testsize; i += 1) { + stbds_struct s = { i,i*2,i*3 ,i*4 }; + stbds_struct t = { i,i*2,i*3+1,i*4 }; + if (i & 1) STBDS_ASSERT(hmget(map, s) == 0); + else STBDS_ASSERT(hmget(map, s) == i*5); + if (i & 1) STBDS_ASSERT(hmget_ts(map, s, temp) == 0); + else STBDS_ASSERT(hmget_ts(map, s, temp) == i*5); + //STBDS_ASSERT(hmget(map, t.key) == 0); + } + + for (i=0; i < testsize; i += 2) { + stbds_struct s = { i,i*2,i*3,i*4 }; + hmputs(map2, s); + } + hmfree(map); + + for (i=0; i < testsize; i += 1) { + stbds_struct s = { i,i*2,i*3,i*4 }; + stbds_struct t = { i,i*2,i*3+1,i*4 }; + if (i & 1) STBDS_ASSERT(hmgets(map2, s.key).d == 0); + else STBDS_ASSERT(hmgets(map2, s.key).d == i*4); + //STBDS_ASSERT(hmgetp(map2, t.key) == 0); + } + hmfree(map2); + + for (i=0; i < testsize; i += 2) { + stbds_struct2 s = { { i,i*2 }, i*3,i*4, i*5 }; + hmputs(map3, s); + } + for (i=0; i < testsize; i += 1) { + stbds_struct2 s = { { i,i*2}, i*3, i*4, i*5 }; + stbds_struct2 t = { { i,i*2}, i*3+1, i*4, i*5 }; + if (i & 1) STBDS_ASSERT(hmgets(map3, s.key).d == 0); + else STBDS_ASSERT(hmgets(map3, s.key).d == i*5); + //STBDS_ASSERT(hmgetp(map3, t.key) == 0); + } +#endif +} +#endif + + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2019 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ diff --git a/test.conf b/test.conf new file mode 100644 index 0000000..ae44225 --- /dev/null +++ b/test.conf @@ -0,0 +1,475 @@ +# This is the configuration file for dosbox-staging (0.78.0). +# Lines starting with a '#' character are comments. + +[sdl] +# fullscreen: Start directly in fullscreen. +# Run INTRO and see Special Keys for window control hotkeys. +# display: Number of display to use; values depend on OS and user settings. +# fullresolution: What resolution to use for fullscreen: 'original', 'desktop' +# or a fixed size (e.g. 1024x768). +# windowresolution: Set window size when running in windowed mode: +# default: Select the best option based on your +# environment and other settings. +# small, medium, or large (or s, m, l): +# Size the window relative to the desktop. +# : Scale the window to the given dimensions in +# WxH format. For example: 1024x768. +# Scaling is not performed for output=surface. +# window_position: Set initial window position when running in windowed mode: +# auto: Let the window manager decide the position. +# : Set window position in X,Y format. For example: 250,100 +# 0,0 is the top-left corner of the screen. +# window_decorations: Controls whether to display window decorations in windowed mode. +# vsync: Synchronize with display refresh rate if supported. This can +# reduce flickering and tearing, but may also impact performance. +# vsync_skip: Number of microseconds to allow rendering to block before skipping the next frame. 0 disables this and will always render. +# max_resolution: Optionally restricts the viewport resolution within the window/screen: +# auto: The viewport fills the window/screen (default). +# : Set max viewport resolution in WxH format. +# For example: 960x720 +# output: What video system to use for output. +# Possible values: surface, texture, texturenb, texturepp, opengl, openglnb, openglpp. +# texture_renderer: Choose a renderer driver when using a texture output mode. +# Use texture_renderer=auto for an automatic choice. +# Possible values: auto, opengl, opengles2, software. +# capture_mouse: Choose a mouse control method: +# onclick: Capture the mouse when clicking any button in the window. +# onstart: Capture the mouse immediately on start. +# seamless: Let the mouse move seamlessly; captures only with middle-click or hotkey. +# nomouse: Hide the mouse and don't send input to the game. +# Choose how middle-clicks are handled (second parameter): +# middlegame: Middle-clicks are sent to the game. +# middlerelease: Middle-click will release the captured mouse, and also capture when seamless. +# Defaults (if not present or incorrect): seamless middlerelease +# Possible values: seamless, onclick, onstart, nomouse. +# sensitivity: Mouse sensitivity. The optional second parameter specifies vertical sensitivity (e.g. 100,-50). +# raw_mouse_input: Enable this setting to bypass your operating system's mouse +# acceleration and sensitivity settings. This works in +# fullscreen or when the mouse is captured in window mode. +# waitonerror: Wait before closing the console if dosbox has an error. +# priority: Priority levels for dosbox. Second entry behind the comma is for when dosbox is not focused/minimized. +# pause is only valid for the second entry. auto disables priority levels and uses OS defaults +# Possible values: auto, lowest, lower, normal, higher, highest, pause. +# mapperfile: File used to load/save the key/event mappings from. +# Resetmapper only works with the default value. +# screensaver: Use 'allow' or 'block' to override the SDL_VIDEO_ALLOW_SCREENSAVER +# environment variable (which usually blocks the OS screensaver +# while the emulator is running). +# Possible values: auto, allow, block. + +fullscreen = false +display = 0 +fullresolution = desktop +windowresolution = default +window_position = auto +window_decorations = true +vsync = false +vsync_skip = 7000 +max_resolution = auto +output = opengl +texture_renderer = auto +capture_mouse = seamless middlerelease +sensitivity = 100 +raw_mouse_input = false +waitonerror = true +priority = auto,auto +mapperfile = mapper-sdl2-0.78.0.map +screensaver = auto + +[dosbox] +# language: Select another language file. +# machine: The type of machine DOSBox tries to emulate. +# Possible values: hercules, cga, cga_mono, tandy, pcjr, ega, vgaonly, svga_s3, svga_et3000, svga_et4000, svga_paradise, vesa_nolfb, vesa_oldvbe. +# captures: Directory where things like wave, midi, screenshot get captured. +# memsize: Amount of memory DOSBox has in megabytes. +# This value is best left at its default to avoid problems with some games, +# though few games might require a higher value. +# There is generally no speed advantage when raising this value. +# vmemsize: Video memory in MiB (1-8) or KiB (256 to 8192). 'auto' uses the default per video adapter. +# Possible values: auto, 1, 2, 4, 8, 256, 512, 1024, 2048, 4096, 8192. +# vesa_modes: Controls the selection of VESA 1.2 and 2.0 modes offered: +# compatible A tailored selection that maximizes game compatibility. +# This is recommended along with 4 or 8 MB of video memory. +# all Offers all modes for a given video memory size, however +# some games may not use them properly (flickering) or may need +# more system memory (mem = ) to use them. +# Possible values: compatible, all. +# autoexec_section: How autoexec sections are handled from multiple config files. +# join : combines them into one big section (legacy behavior). +# overwrite : use the last one encountered, like other conf settings. +# Possible values: join, overwrite. +# startup_verbosity: Controls verbosity prior to displaying the program: +# Verbosity | Splash | Welcome | Early stdout +# high | yes | yes | yes +# medium | no | yes | yes +# low | no | no | yes +# quiet | no | no | no +# splash_only | yes | no | no +# auto | 'low' if exec or dir is passed, otherwise 'high' +# Possible values: auto, high, medium, low, splash_only, quiet. + +language = +machine = svga_s3 +captures = capture +memsize = 16 +vmemsize = auto +vesa_modes = compatible +autoexec_section = join +startup_verbosity = auto + +[render] +# frameskip: How many frames DOSBox skips before drawing one. +# aspect: Scales the vertical resolution to produce a 4:3 display aspect +# ratio, matching that of the original standard-definition monitors +# for which the majority of DOS games were designed. This setting +# only affects video modes that use non-square pixels, such as +# 320x200 or 640x400; where as square-pixel modes, such as 640x480 +# and 800x600, will be displayed as-is. +# monochrome_palette: Select default palette for monochrome display. +# Works only when emulating hercules or cga_mono. +# You can also cycle through available colours using F11. +# Possible values: white, paperwhite, green, amber. +# scaler: Scaler used to enlarge/enhance low resolution modes. +# If 'forced' is appended, then the scaler will be used even if +# the result might not be desired. +# Note that some scalers may use black borders to fit the image +# within your configured display resolution. If this is +# undesirable, try either a different scaler or enabling +# fullresolution output. +# Possible values: none, normal2x, normal3x, advmame2x, advmame3x, advinterp2x, advinterp3x, hq2x, hq3x, 2xsai, super2xsai, supereagle, tv2x, tv3x, rgb2x, rgb3x, scan2x, scan3x. +# glshader: Either 'none' or a GLSL shader name. Works only with +# OpenGL output. Can be either an absolute path, a file +# in the 'glshaders' subdirectory of the DOSBox +# configuration directory, or one of the built-in shaders: +# advinterp2x, advinterp3x, advmame2x, advmame3x, +# crt-easymode-flat, crt-fakelottes-flat, rgb2x, rgb3x, +# scan2x, scan3x, tv2x, tv3x, sharp (default). + +frameskip = 0 +aspect = true +monochrome_palette = white +scaler = none +glshader = default + +[composite] +# composite: Enable composite mode on start. 'auto' lets the program decide. +# Note: Fine-tune the settings below (ie: hue) using the composite hotkeys. +# Then read the new settings from your console and enter them here. +# Possible values: auto, on, off. +# era: Era of composite technology. When 'auto', PCjr uses new and CGA/Tandy use old. +# Possible values: auto, old, new. +# hue: Appearance of RGB palette. For example, adjust until sky is blue. +# saturation: Intensity of colors, from washed out to vivid. +# contrast: Ratio between the dark and light area. +# brightness: Luminosity of the image, from dark to light. +# convergence: Convergence of subpixel elements, from blurry to sharp (CGA and Tandy-only). + +composite = auto +era = auto +hue = 0 +saturation = 100 +contrast = 100 +brightness = 0 +convergence = 0 + +[cpu] +# core: CPU Core used in emulation. auto will switch to dynamic if available and +# appropriate. +# Possible values: auto, dynamic, normal, simple. +# cputype: CPU Type used in emulation. auto is the fastest choice. +# Possible values: auto, 386, 386_slow, 486_slow, pentium_slow, 386_prefetch. +# cycles: Number of instructions DOSBox tries to emulate each millisecond. +# Setting this value too high results in sound dropouts and lags. +# Cycles can be set in 3 ways: +# 'auto' tries to guess what a game needs. +# It usually works, but can fail for certain games. +# 'fixed #number' will set a fixed number of cycles. This is what you usually +# need if 'auto' fails (Example: fixed 4000). +# 'max' will allocate as much cycles as your computer is able to +# handle. +# Possible values: auto, fixed, max. +# cycleup: Number of cycles added or subtracted with speed control hotkeys. +# Run INTRO and see Special Keys for list of hotkeys. +# cycledown: Setting it lower than 100 will be a percentage. + +core = auto +cputype = pentium_slow +cycles = 12000 +#cycles = auto +cycleup = 10 +cycledown = 20 + +[mixer] +# nosound: Enable silent mode, sound is still emulated though. +# rate: Mixer sample rate, setting any device's rate higher than this will probably lower their sound quality. +# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. +# blocksize: Mixer block size, larger blocks might help sound stuttering but sound will also be more lagged. +# Possible values: 1024, 2048, 4096, 8192, 512, 256, 128. +# prebuffer: How many milliseconds of data to keep on top of the blocksize. +# negotiate: Allow system audio driver to negotiate optimal rate and blocksize +# as close to the specified values as possible. + +nosound = false +rate = 48000 +blocksize = 512 +prebuffer = 20 +negotiate = true + +[midi] +# mididevice: Device that will receive the MIDI data (from the emulated MIDI +# interface - MPU-401). Choose one of the following: +# 'fluidsynth', to use the built-in MIDI synthesizer. See the +# [fluidsynth] section for detailed configuration. +# 'mt32', to use the built-in Roland MT-32 synthesizer. +# See the [mt32] section for detailed configuration. +# 'auto', to use the first working external MIDI player. This +# might be a software synthesizer or physical device. +# Possible values: auto, oss, alsa, fluidsynth, mt32, none. +# midiconfig: Configuration options for the selected MIDI interface. +# This is usually the id or name of the MIDI synthesizer you want +# to use (find the id/name with DOS command 'mixer /listmidi'). +# - This option has no effect when using the built-in synthesizers +# (mididevice = fluidsynth or mt32). +# - When using ALSA, use Linux command 'aconnect -l' to list open +# MIDI ports, and select one (for example 'midiconfig=14:0' +# for sequencer client 14, port 0). +# - If you're using a physical Roland MT-32 with revision 0 PCB, +# the hardware may require a delay in order to prevent its +# buffer from overflowing. In that case, add 'delaysysex', +# for example: 'midiconfig=2 delaysysex'. +# See the README/Manual for more details. +# mpu401: Type of MPU-401 to emulate. +# Possible values: intelligent, uart, none. + +mididevice = auto +midiconfig = +mpu401 = intelligent + +[fluidsynth] +# soundfont: Path to a SoundFont file in .sf2 format. You can use an +# absolute or relative path, or the name of an .sf2 inside +# the 'soundfonts' directory within your DOSBox configuration +# directory. +# An optional percentage will scale the SoundFont's volume. +# For example: 'soundfont.sf2 50' will attenuate it by 50 percent. +# The scaling percentage can range from 1 to 500. +# chorus: Chorus effect: 'auto', 'on', 'off', or custom values. +# When using custom values: +# All five must be provided in-order and space-separated. +# They are: voice-count level speed depth modulation-wave, where: +# - voice-count is an integer from 0 to 99. +# - level is a decimal from 0.0 to 10.0 +# - speed is a decimal, measured in Hz, from 0.1 to 5.0 +# - depth is a decimal from 0.0 to 21.0 +# - modulation-wave is either 'sine' or 'triangle' +# For example: chorus = 3 1.2 0.3 8.0 sine +# reverb: Reverb effect: 'auto', 'on', 'off', or custom values. +# When using custom values: +# All four must be provided in-order and space-separated. +# They are: room-size damping width level, where: +# - room-size is a decimal from 0.0 to 1.0 +# - damping is a decimal from 0.0 to 1.0 +# - width is a decimal from 0.0 to 100.0 +# - level is a decimal from 0.0 to 1.0 +# For example: reverb = 0.61 0.23 0.76 0.56 + +soundfont = default.sf2 +chorus = auto +reverb = auto + +[mt32] +# model: Model of synthesizer to use. +# 'auto' picks the first model with available ROMs, in order as listed. +# 'cm32l' and 'mt32' pick the first model of their type, in the order listed. +# 'mt32_old' and 'mt32_new' are aliases for 1.07 and 2.04, respectively. +# Possible values: auto, cm32l, cm32l_102, cm32l_100, mt32, mt32_old, mt32_107, mt32_106, mt32_105, mt32_104, mt32_bluer, mt32_new, mt32_204. +# romdir: The directory containing ROMs for one or more models. +# The directory can be absolute or relative, or leave it blank to +# use the 'mt32-roms' directory in your DOSBox configuration +# directory. Other common system locations will be checked as well. +# ROM files inside this directory may include any of the following: +# - MT32_CONTROL.ROM and MT32_PCM.ROM, for the 'mt32' model. +# - CM32L_CONTROL.ROM and CM32L_PCM.ROM, for the 'cm32l' model. +# - Unzipped MAME MT-32 and CM-32L ROMs, for the versioned models. + +model = auto +romdir = + +[sblaster] +# sbtype: Type of Sound Blaster to emulate. 'gb' is Game Blaster. +# Possible values: sb1, sb2, sbpro1, sbpro2, sb16, gb, none. +# sbbase: The IO address of the Sound Blaster. +# Possible values: 220, 240, 260, 280, 2a0, 2c0, 2e0, 300. +# irq: The IRQ number of the Sound Blaster. +# Possible values: 7, 5, 3, 9, 10, 11, 12. +# dma: The DMA number of the Sound Blaster. +# Possible values: 1, 5, 0, 3, 6, 7. +# hdma: The High DMA number of the Sound Blaster. +# Possible values: 1, 5, 0, 3, 6, 7. +# sbmixer: Allow the Sound Blaster mixer to modify the DOSBox mixer. +# oplmode: Type of OPL emulation. On 'auto' the mode is determined by 'sbtype'. +# All OPL modes are AdLib-compatible, except for 'cms'. +# Possible values: auto, cms, opl2, dualopl2, opl3, opl3gold, none. +# oplemu: Provider for the OPL emulation. 'compat' provides better quality, +# 'nuked' is the default and most accurate (but the most CPU-intensive). +# Possible values: default, compat, fast, mame, nuked. + +sbtype = sb16 +sbbase = 220 +irq = 7 +dma = 1 +hdma = 5 +sbmixer = true +oplmode = auto +oplemu = default + +[gus] +# gus: Enable Gravis UltraSound emulation. +# gusbase: The IO base address of the Gravis UltraSound. +# Possible values: 240, 220, 260, 280, 2a0, 2c0, 2e0, 300. +# gusirq: The IRQ number of the Gravis UltraSound. +# Possible values: 5, 3, 7, 9, 10, 11, 12. +# gusdma: The DMA channel of the Gravis UltraSound. +# Possible values: 3, 0, 1, 5, 6, 7. +# ultradir: Path to UltraSound directory. In this directory +# there should be a MIDI directory that contains +# the patch files for GUS playback. Patch sets used +# with Timidity should work fine. + +gus = false +gusbase = 240 +gusirq = 5 +gusdma = 3 +ultradir = C:\ULTRASND + +[innovation] +# sidmodel: Model of chip to emulate in the Innovation SSI-2001 card: +# - auto: Selects the 6581 chip. +# - 6581: The original chip, known for its bassy and rich character. +# - 8580: A later revision that more closely matched the SID specification. +# It fixed the 6581's DC bias and is less prone to distortion. +# The 8580 is an option on reproduction cards, like the DuoSID. +# - none: Disables the card. +# Possible values: auto, 6581, 8580, none. +# sidclock: The SID chip's clock frequency, which is jumperable on reproduction cards. +# - default: uses 0.895 MHz, per the original SSI-2001 card. +# - c64ntsc: uses 1.023 MHz, per NTSC Commodore PCs and the DuoSID. +# - c64pal: uses 0.985 MHz, per PAL Commodore PCs and the DuoSID. +# - hardsid: uses 1.000 MHz, available on the DuoSID. +# Possible values: default, c64ntsc, c64pal, hardsid. +# sidport: The IO port address of the Innovation SSI-2001. +# Possible values: 240, 260, 280, 2a0, 2c0. +# 6581filter: The SID's analog filtering meant that each chip was physically unique. +# Adjusts the 6581's filtering strength as a percent from 0 to 100. +# 8580filter: Adjusts the 8580's filtering strength as a percent from 0 to 100. + +sidmodel = none +sidclock = default +sidport = 280 +6581filter = 50 +8580filter = 50 + +[speaker] +# pcspeaker: Enable PC-Speaker emulation. +# pcrate: Sample rate of the PC-Speaker sound generation. +# zero_offset: Neutralizes and prevents the PC speaker's DC-offset from harming other sources. +# 'auto' enables this for non-Windows systems and disables it on Windows. +# If your OS performs its own DC-offset correction, then set this to 'false'. +# Possible values: auto, true, false. +# tandy: Enable Tandy Sound System emulation. For 'auto', emulation is present only if machine is set to 'tandy'. +# Possible values: auto, on, off. +# tandyrate: Sample rate of the Tandy 3-Voice generation. +# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. +# disney: Enable Disney Sound Source emulation. (Covox Voice Master and Speech Thing compatible). +# ps1audio: Enable IBM PS/1 Audio emulation. + +pcspeaker = true +pcrate = 18939 +zero_offset = auto +tandy = auto +tandyrate = 44100 +disney = true +ps1audio = false + +[joystick] +# joysticktype: Type of joystick to emulate: auto (default), +# auto : Detect and use any joystick(s), if possible., +# 2axis : Support up to two joysticks. +# 4axis : Support the first joystick only. +# 4axis_2 : Support the second joystick only. +# fcs : Support a Thrustmaster-type joystick. +# ch : Support a CH Flightstick-type joystick. +# hidden : Prevent DOS from seeing the joystick(s), but enable them for mapping. +# disabled : Fully disable joysticks: won't be polled, mapped, or visible in DOS. +# (Remember to reset DOSBox's mapperfile if you saved it earlier) +# Possible values: auto, 2axis, 4axis, 4axis_2, fcs, ch, hidden, disabled. +# timed: enable timed intervals for axis. Experiment with this option, if your joystick drifts (away). +# autofire: continuously fires as long as you keep the button pressed. +# swap34: swap the 3rd and the 4th axis. Can be useful for certain joysticks. +# buttonwrap: enable button wrapping at the number of emulated buttons. +# circularinput: enable translation of circular input to square output. +# Try enabling this if your left analog stick can only move in a circle. +# deadzone: the percentage of motion to ignore. 100 turns the stick into a digital one. + +joysticktype = auto +timed = true +autofire = false +swap34 = false +buttonwrap = false +circularinput = false +deadzone = 10 + +[serial] +# serial1: set type of device connected to com port. +# Can be disabled, dummy, modem, nullmodem, directserial. +# Additional parameters must be in the same line in the form of +# parameter:value. Parameter for all types is irq (optional). +# for directserial: realport (required), rxdelay (optional). +# (realport:COM1 realport:ttyS0). +# for modem: listenport (optional). +# for nullmodem: server, rxdelay, txdelay, telnet, usedtr, +# transparent, port, inhsocket (all optional). +# Example: serial1=modem listenport:5000 +# Possible values: dummy, disabled, modem, nullmodem, directserial. +# serial2: see serial1 +# Possible values: dummy, disabled, modem, nullmodem, directserial. +# serial3: see serial1 +# Possible values: dummy, disabled, modem, nullmodem, directserial. +# serial4: see serial1 +# Possible values: dummy, disabled, modem, nullmodem, directserial. +# phonebookfile: File used to map fake phone numbers to addresses. + +serial1 = modem listenport:8192 sock:1 +serial2 = dummy +serial3 = disabled +serial4 = disabled +phonebookfile = phonebook.txt + +[dos] +# xms: Enable XMS support. +# ems: Enable EMS support. The default (=true) provides the best +# compatibility but certain applications may run better with +# other choices, or require EMS support to be disabled (=false) +# to work at all. +# Possible values: true, emsboard, emm386, false. +# umb: Enable UMB support. +# ver: Set DOS version (5.0 by default). Specify as major.minor format. +# A single number is treated as the major version. +# Common settings are 3.3, 5.0, 6.22, and 7.1. +# keyboardlayout: Language code of the keyboard layout (or none). + +xms = false +ems = false +umb = false +ver = 5.0 +keyboardlayout = auto + +[ipx] +# ipx: Enable ipx over UDP/IP emulation. + +ipx = false + +[autoexec] +mount c ~/dos +c: +autoexec.bat diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..1fb1ed5 --- /dev/null +++ b/test.sh @@ -0,0 +1,4 @@ +#!/bin/bash +#${HOME}/code/dosbox-custom/dosbox-staging/build/dosbox -noprimaryconf -nolocalconf -conf test.conf & +#dosbox -noprimaryconf -nolocalconf -conf test.conf & +${HOME}/bin/dosbox-staging-linux-v0.78.1/dosbox -noprimaryconf -nolocalconf -conf test.conf & diff --git a/thirdparty/grx249/Makefile b/thirdparty/grx249/Makefile new file mode 120000 index 0000000..6e6bedf --- /dev/null +++ b/thirdparty/grx249/Makefile @@ -0,0 +1 @@ +makefile.x11 \ No newline at end of file diff --git a/thirdparty/grx249/addons/bmp/bmp.c b/thirdparty/grx249/addons/bmp/bmp.c new file mode 100644 index 0000000..f25115c --- /dev/null +++ b/thirdparty/grx249/addons/bmp/bmp.c @@ -0,0 +1,669 @@ +/* +** - BMP read/write file +** by Michal Stencl Copyright (c) 1998 +** - read BMP 2, 4, 8 bpp +** - write BMP 8, 24 bpp +** - [stenclpmd@ba.telecom.sk] +** +*/ + +#include +#include +#include +#if defined(_MSC_VER) && defined(_WIN32) +#include +#else +#include +#endif +#include +#include +#include +#ifdef __MSDOS__ +# include +#endif + +#include "libgrx.h" +#include "clipping.h" + +#if defined(__MSDOS__) || defined(MSDOS) +#define BIN_WR (O_WRONLY | O_BINARY) +#define BIN_RD (O_RDONLY | O_BINARY) +#else +#define BIN_WR O_WRONLY +#define BIN_RD O_RDONLY +#endif + +#define BIN_CREAT (BIN_WR|O_CREAT) + +#ifndef S_IREAD +#define S_IREAD S_IRUSR +#endif +#ifndef S_IWRITE +#define S_IWRITE S_IWUSR +#endif + +#define CREAT_PERM S_IREAD|S_IWRITE + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#define BMPFILEHEADERSIZE 14 +#define BMPINFOHEADERSIZE 40 + +#define BI_RGB 0L +#define BI_RLE8 1L +#define BI_RLE4 2L + +#define _GrBitmapPointerTypes_DEFINED_ +typedef struct _GR_bitmapfileheader GrBitmapFileHeader; +typedef struct _GR_bitmapinfoheader GrBitmapInfoHeader; +typedef struct _GR_bmpimagecolors GrBmpImageColors; +typedef struct _GR_bmpimage GrBmpImage; + +/* ************************************************************************ */ +/* _GR_bitmapfileheader */ +/* ************************************************************************ */ +struct _GR_bitmapfileheader { + GR_int16u bf_type; + GR_int32u bf_size; + GR_int16u bf_reserved1; + GR_int16u bf_reserved2; + GR_int32u bf_offbits; +}; + +/* ************************************************************************ */ +/* _GR_bitmapinfoheader */ +/* ************************************************************************ */ +struct _GR_bitmapinfoheader { + GR_int32u bn_size; + GR_int32u bn_width; + GR_int32u bn_height; + GR_int16u bn_planes; + GR_int16u bn_bitcount; + GR_int32u bn_compression; + GR_int32u bn_sizeimage; + GR_int32u bn_xpelspermeter; + GR_int32u bn_ypelspermeter; + GR_int32u bn_clrused; + GR_int32u bn_clrimportant; +}; + +/* ************************************************************************ */ +/* _GR_bmpimagecolors */ +/* ************************************************************************ */ +struct _GR_bmpimagecolors { + GR_int8u *bp_palette; /* (R, G, B, Reserved) * | 2 | 16 | 256 */ + GrColor *bp_colormap; + int bp_numcolors; +}; + +/* ************************************************************************ */ +/* _GR_bmpimage */ +/* ************************************************************************ */ +struct _GR_bmpimage { + GrBitmapFileHeader *bi_bmpfileheader; + GrBitmapInfoHeader *bi_bmpinfoheader; + GrBmpImageColors *bi_bmpimagecolors; + GR_int16s bi_erasepalette; + char *bi_map; +}; + +#define bi_width bi_bmpinfoheader->bn_width +#define bi_height bi_bmpinfoheader->bn_height +#define bi_palette bi_bmpimagecolors->bp_palette +#define bi_colormap bi_bmpimagecolors->bp_colormap +#define bi_numcolors bi_bmpimagecolors->bp_numcolors + +int GrLoadBmpFileHeader ( int _handle, GrBitmapFileHeader* _fileheader ); +int GrLoadBmpInfoHeader ( int _handle, GrBitmapInfoHeader* _infoheader ); +static unsigned char *__GrLoadPaletteBmp ( int _handle, unsigned long _paloffset, int _colors ); +static unsigned char *GrLoadPaletteBmp ( int _handle, int *_col, GrBitmapInfoHeader *_iheader ); +static char *GrLoadImageFromBmpBiRgb ( int _handle, unsigned long _offset, long _maxbufsize, int _colors, GrBitmapInfoHeader *_infoheader ); +static char *GrLoadImageFromBmpBiRle8 ( int _handle, unsigned long _offset, unsigned long _maxbufsize, int _colors, GrBitmapInfoHeader *_infoheader ); +static char *GrLoadImageFromBmpBiRle4 ( int _handle, unsigned long _offset, unsigned long _maxbufsize, int _colors, GrBitmapInfoHeader *_infoheader ); +static char *GrLoadImageFromBmp ( int _handle, unsigned long _offset, int _colors, GrBitmapInfoHeader *_infoheader ); + +/* exported functions */ +int GrFreeBmpImageColors ( GrBmpImageColors *_pal ); +int GrAllocBmpImageColors ( GrBmpImage *_bmp, GrBmpImageColors *_pal ); +GrBmpImage *GrLoadBmpImage ( char *_filename ); +GrPattern *GrConvertBmpImageToPattern ( GrBmpImage *_bmp ); +GrPattern *GrConvertBmpImageToStaticPattern ( GrBmpImage *_bmp ); +void GrUnloadBmpImage ( GrBmpImage *_bmp ); +int GrSaveBmpImage ( char *_filename, GrContext *_c, int _x1, int _y1, int _x2, int _y2 ); +unsigned long GrBmpImageWidth ( GrBmpImage* _bmp ); +unsigned long GrBmpImageHeight ( GrBmpImage* _bmp ); +char *GrBmpImagePalette ( GrBmpImage* _bmp ); +GrColor *GrBmpImageColorMap ( GrBmpImage* _bmp ); +GrColor GrBmpImageNumColors ( GrBmpImage* _bmp ); +/* end of exported functions */ + +/* ************************************************************************ */ +int GrLoadBmpFileHeader ( int _handle, GrBitmapFileHeader *_fileheader ) +/* ************************************************************************ */ +{ + if (( !_fileheader ) || ( _handle == -1 )) return FALSE; + memset(_fileheader, 0, BMPFILEHEADERSIZE); + lseek(_handle, SEEK_SET, 0); + read(_handle, &_fileheader->bf_type, 2); + read(_handle, &_fileheader->bf_size, 4); + read(_handle, &_fileheader->bf_reserved1, 2); + read(_handle, &_fileheader->bf_reserved2, 2); + read(_handle, &_fileheader->bf_offbits, 4); + return TRUE; +} + +/* ************************************************************************ */ +int GrLoadBmpInfoHeader ( int _handle, GrBitmapInfoHeader *_infoheader ) +/* ************************************************************************ */ +{ + if (( !_infoheader ) || ( _handle == -1 )) return FALSE; + lseek(_handle, SEEK_SET, BMPFILEHEADERSIZE); + _infoheader->bn_size = 0; + read(_handle, &_infoheader->bn_size, 4); + memset(_infoheader, 0, _infoheader->bn_size); + read(_handle, &_infoheader->bn_width, 4); + if ( _infoheader->bn_width % 4 ) + _infoheader->bn_width += 4 - (_infoheader->bn_width % 4); + read(_handle, &_infoheader->bn_height, 4); + read(_handle, &_infoheader->bn_planes, 2); + read(_handle, &_infoheader->bn_bitcount, 2); + read(_handle, &_infoheader->bn_compression, 4); + read(_handle, &_infoheader->bn_sizeimage, 4); + read(_handle, &_infoheader->bn_xpelspermeter, 4); + read(_handle, &_infoheader->bn_ypelspermeter, 4); + read(_handle, &_infoheader->bn_clrused, 4); + read(_handle, &_infoheader->bn_clrimportant, 4); + return TRUE; +} + +/* ************************************************************************ */ +static unsigned char *__GrLoadPaletteBmp ( int _handle, unsigned long _paloffset, int _colors ) +/* ************************************************************************ */ +{ + unsigned char *palette; + if ( _handle == -1 ) return NULL; + palette = (unsigned char*)malloc(_colors * 4); + if ( !palette ) return NULL; + lseek(_handle, SEEK_SET, _paloffset); + read(_handle, palette, _colors * 4); + return palette; +} + +/* ************************************************************************ */ +static unsigned char *GrLoadPaletteBmp ( int _handle, int *_col, GrBitmapInfoHeader* _iheader ) +/* ************************************************************************ */ +{ + unsigned char *palette; + unsigned long paloffset; + *_col = -1; + if (( _handle == -1 ) || ( !_iheader )) return NULL; + palette = NULL; + paloffset = BMPFILEHEADERSIZE + _iheader->bn_size; + switch ( _iheader->bn_bitcount ) + { + case 1 : { *_col = 2; palette = __GrLoadPaletteBmp(_handle, paloffset, 2); } break; + case 4 : { *_col = 16; palette = __GrLoadPaletteBmp(_handle, paloffset, 16); } break; + case 8 : { *_col = 256; palette = __GrLoadPaletteBmp(_handle, paloffset, 256); } break; + case 24 : { *_col = 0; palette = NULL; } break; + default : *_col = -1; + } + if (( !palette ) && ( *_col != 0 )) *_col = -1; + return palette; +} + +/* ************************************************************************ */ +static char *GrLoadImageFromBmpBiRgb ( int _handle, unsigned long _offset, long _maxbufsize, int _colors, + GrBitmapInfoHeader *_infoheader ) +/* ************************************************************************ */ +{ + char *map = NULL; + char *buffer = NULL; + unsigned long width; + unsigned long size; + unsigned long i; + if (( _handle == -1 ) || ( !_infoheader ) || ( _infoheader->bn_bitcount < 1 )) + return NULL; + width = _infoheader->bn_width; + size = width; + i = size; + lseek(_handle, SEEK_SET, _offset); + if ( _infoheader->bn_bitcount == 1 ) + { + unsigned char bits[8], n; + unsigned long w, bufsize; + int j, k; + char *runmap; + _maxbufsize = _maxbufsize * 8; + map = (char *)malloc(_maxbufsize); + bufsize = (unsigned long)ceil((float)width / 8); + buffer = (char *)malloc(bufsize); + runmap = NULL; + if ( !map || !buffer ) + { + if (map) free(map); + if (buffer) free(buffer); + return NULL; + } + while ( i <= _maxbufsize ) + { + read(_handle, buffer, bufsize); + runmap = &map[_maxbufsize - i]; + for ( w = 0; w < width; w++) + { + j = w % 8; + if ( !j ) + { + n = buffer[w / 8]; + for ( k = 0; k < 8; k++ ) + { + bits[7 - k] = n & 1; + n = n >> 1; + } + } + runmap[w] = bits[j]; + } + i += size; + } + } + if ( _infoheader->bn_bitcount == 4 ) + { + unsigned long bufsize; + char *runmap; + unsigned char bits[2], n; + unsigned long w; + int j, q; + _maxbufsize = _maxbufsize * 2; + map = (char *)malloc(_maxbufsize); + bufsize = (unsigned long)ceil((float)width / 2); + buffer = (char*)malloc(bufsize); + runmap = NULL; + if ( !map || !buffer ) + { + if (map) free(map); + if (buffer) free(buffer); + return NULL; + } + while ( i <= _maxbufsize ) + { + read(_handle, buffer, bufsize); + runmap = &map[_maxbufsize - i]; + for ( w = 0; w < width; w++) + { + j = w % 2; + if ( !j ) + { + n = buffer[w / 2]; + q = n & 255; + bits[1] = q & 15; + q = q >> 4; + bits[0] = q & 15; + n = n >> 8; + } + runmap[w] = bits[j]; + } + i += size; + } + } + if ( _infoheader->bn_bitcount == 8 ) + { + unsigned long bufsize; + map = (char*)malloc(_maxbufsize); + bufsize = size; + if ( !map ) return NULL; + while ( i <= _maxbufsize ) + { + read(_handle, &map[_maxbufsize - i], bufsize); + i += bufsize; + } + } + if ( _infoheader->bn_bitcount == 24 ) + { + } + if (buffer) free(buffer); + return map; +} + +/* ************************************************************************ */ +static char *GrLoadImageFromBmpBiRle8 ( int _handle, unsigned long _offset, unsigned long _maxbufsize, int _colors, + GrBitmapInfoHeader *_infoheader ) +/* ************************************************************************ */ +{ + return NULL; /* this version not contains Rle8 yet */ +} + +/* ************************************************************************ */ +static char *GrLoadImageFromBmpBiRle4 ( int _handle, unsigned long _offset, unsigned long _maxbufsize, int _colors, + GrBitmapInfoHeader *_infoheader ) +/* ************************************************************************ */ +{ + return NULL; /* this version not contains Rle4 yet */ +} + +/* ************************************************************************ */ +static char *GrLoadImageFromBmp ( int _handle, unsigned long _offset, int _colors, GrBitmapInfoHeader *_infoheader ) +/* ************************************************************************ */ +{ + char* map; + int maxbufsize; + if (( _handle == -1 ) || ( !_infoheader )) return NULL; + map = NULL; + maxbufsize = _infoheader->bn_sizeimage; + switch ( _infoheader->bn_compression ) { + case BI_RGB : + { + if ( !maxbufsize ) + maxbufsize = _infoheader->bn_width * _infoheader->bn_height; + map = GrLoadImageFromBmpBiRgb(_handle, _offset, maxbufsize, _colors, _infoheader); break; + } + case BI_RLE8 : + map = GrLoadImageFromBmpBiRle8(_handle, _offset, maxbufsize, _colors, _infoheader); break; + case BI_RLE4 : + map = GrLoadImageFromBmpBiRle4(_handle, _offset, maxbufsize, _colors, _infoheader); break; + } + return map; +} + +/*====++====================================================================*/ +/* EXPORTED FUNCTIONS */ +/*==++======================================================================*/ + +/* ************************************************************************ */ +int GrFreeBmpImageColors ( GrBmpImageColors *_pal ) +/* ************************************************************************ */ +{ + if (( !_pal ) || ( !_pal->bp_colormap )) return FALSE; + if ( _pal->bp_palette ) + { + int i; + GrColor *colors = _pal->bp_colormap; + colors[0] = _pal->bp_numcolors; + for ( i = 0; i < _pal->bp_numcolors; i++ ) + GrFreeColor(colors[i+1]); + free(_pal->bp_palette); + _pal->bp_palette = NULL; + _pal->bp_numcolors = 0; + return TRUE; + } + return FALSE; +} + +/* ************************************************************************ */ +int GrAllocBmpImageColors ( GrBmpImage *_bmp, GrBmpImageColors *_pal ) +/* ************************************************************************ */ +{ + if (( !_bmp ) || ( _bmp->bi_colormap != NULL ) || (_bmp->bi_numcolors < 2 )) + return FALSE; + _bmp->bi_erasepalette = TRUE; + if ( _bmp->bi_palette ) + { + int i; + GrColor *colors = malloc(sizeof(GrColor)*(_bmp->bi_numcolors+1)); + if ( !colors ) return FALSE; + colors[0] = _bmp->bi_numcolors; + for ( i = 0; i < _bmp->bi_numcolors; i++ ) + colors[i+1] = GrAllocColor(_bmp->bi_palette[i*4+2], _bmp->bi_palette[i*4+1], _bmp->bi_palette[i*4+0]); + _bmp->bi_colormap = colors; + if ( _pal ) + { + _bmp->bi_erasepalette = FALSE; + memcpy(_pal,_bmp->bi_bmpimagecolors,sizeof(GrBmpImageColors)); + _bmp->bi_palette = NULL; + _bmp->bi_numcolors = 0; + } + return TRUE; + } + return FALSE; +} + +/* ************************************************************************ */ +GrBmpImage *GrLoadBmpImage ( char *_filename ) +/* ************************************************************************ */ +{ + #define defClose { \ + close(handle); \ + if (bmpimage) free(bmpimage); \ + return NULL; \ + } + #define ADD2PTR(p,o) ((void *) ((char *)(p)+(o)) ) + int handle; + GrBmpImage *bmpimage = NULL; + if ( (handle = open(_filename, BIN_RD)) != -1 ) { + bmpimage = malloc( sizeof(GrBmpImage) + +sizeof(GrBitmapFileHeader) + +sizeof(GrBitmapInfoHeader) + +sizeof(GrBmpImageColors)); + if ( !bmpimage ) defClose; + memset(bmpimage, 0, sizeof(GrBmpImage) + +sizeof(GrBitmapFileHeader) + +sizeof(GrBitmapInfoHeader) + +sizeof(GrBmpImageColors)); + bmpimage->bi_bmpfileheader = ADD2PTR(bmpimage, sizeof(GrBmpImage)); + bmpimage->bi_bmpinfoheader = ADD2PTR(bmpimage, sizeof(GrBmpImage) + +sizeof(GrBitmapFileHeader)); + bmpimage->bi_bmpimagecolors = ADD2PTR(bmpimage, sizeof(GrBmpImage) + +sizeof(GrBitmapFileHeader) + +sizeof(GrBitmapInfoHeader)); + bmpimage->bi_erasepalette = TRUE; + if ( !GrLoadBmpFileHeader(handle, bmpimage->bi_bmpfileheader) ) + defClose; + if ( bmpimage->bi_bmpfileheader->bf_type != 19778 ) /* MAGIC NUMBER */ + defClose; + if ( !GrLoadBmpInfoHeader(handle, bmpimage->bi_bmpinfoheader) ) + defClose; + bmpimage->bi_palette = GrLoadPaletteBmp(handle, &(bmpimage->bi_numcolors), bmpimage->bi_bmpinfoheader); + if ( bmpimage->bi_numcolors == -1 ) + defClose; + bmpimage->bi_map = GrLoadImageFromBmp(handle, bmpimage->bi_bmpfileheader->bf_offbits - BMPFILEHEADERSIZE, bmpimage->bi_numcolors, bmpimage->bi_bmpinfoheader); + if ( !bmpimage->bi_map ) + defClose; + } + #undef defClose + return bmpimage; +} + +/* ************************************************************************ */ +GrPattern *GrConvertBmpImageToPattern ( GrBmpImage *_bmp ) +/* ************************************************************************ */ +{ + if (( !_bmp ) || ( !_bmp->bi_map )) return NULL; + return GrBuildPixmap(_bmp->bi_map, _bmp->bi_width, _bmp->bi_height, _bmp->bi_colormap); +} + +/* ************************************************************************ */ +GrPattern *GrConvertBmpImageToStaticPattern ( GrBmpImage *_bmp ) +/* ************************************************************************ */ +{ + GrPattern *p = NULL; + if ( _bmp && _bmp->bi_map ) + { + p = GrBuildPixmap(_bmp->bi_map, _bmp->bi_width, _bmp->bi_height, _bmp->bi_colormap); + if ( p ) GrUnloadBmpImage(_bmp); + } + return p; +} + +/* ************************************************************************ */ +void GrUnloadBmpImage ( GrBmpImage *_bmp ) +/* ************************************************************************ */ +{ + if ( !_bmp ) return; + if ( _bmp->bi_erasepalette ) + GrFreeBmpImageColors(_bmp->bi_bmpimagecolors); + _bmp->bi_palette = NULL; + _bmp->bi_numcolors = 0; + if ( _bmp->bi_map ) free(_bmp->bi_map); + free(_bmp); + _bmp = NULL; +} + +/* ************************************************************************ */ +int GrSaveBmpImage ( char *_filename, GrContext *_c, int _x1, int _y1, int _x2, int _y2 ) +/* ************************************************************************ */ +{ + int handle; + unsigned long width, height; + unsigned char palette[256*4]; + int r, g, b; + char* line; + unsigned long yy, xx; + GrColor pixcol; + GrBitmapFileHeader fileheader; + GrBitmapInfoHeader infoheader; + GrColor colors, i; + GrContext safe; + + if ( !_c ) _c = (GrContext *)GrCurrentContext(); + +/* + handle = creat(_filename, S_IWRITE); + if ( handle < 0 ) + { + close(handle); + return FALSE; + } +*/ + handle = open(_filename, BIN_CREAT, CREAT_PERM); + if ( handle < 0 ) return FALSE; + + clip_box_(_c, _x1, _y1, _x2, _y2, CLIP_EMPTY_MACRO_ARG, CLIP_EMPTY_MACRO_ARG); + + width = _x2 - _x1; + height = _y2 - _y1; + + safe = *GrCurrentContext(); + GrSetContext(_c); + colors = GrNumColors(); + GrSetContext(&safe); + + if ( width % 4 ) width += 4 - (width % 4); + + /*========= FILEHEADER =========*/ + fileheader.bf_type = 19778; + if ( colors == 256 ) + fileheader.bf_size = BMPINFOHEADERSIZE + BMPFILEHEADERSIZE + 256*4 + width*height; + else + fileheader.bf_size = BMPINFOHEADERSIZE + BMPFILEHEADERSIZE + (width*height*3); + fileheader.bf_reserved1 = 0; + fileheader.bf_reserved2 = 0; + if ( colors == 256 ) + fileheader.bf_offbits = BMPINFOHEADERSIZE + BMPFILEHEADERSIZE + 256*4; + else + fileheader.bf_offbits = BMPINFOHEADERSIZE + BMPFILEHEADERSIZE; + + /*========= INFOHEADER =========*/ + infoheader.bn_size = BMPINFOHEADERSIZE; + infoheader.bn_width = width; + infoheader.bn_height = height; + infoheader.bn_planes = 1; + infoheader.bn_bitcount = ( colors == 256 ) ? 8 : 24; + infoheader.bn_compression = BI_RGB; + infoheader.bn_sizeimage = width*height*(infoheader.bn_bitcount / 8); + infoheader.bn_xpelspermeter = 0L; + infoheader.bn_ypelspermeter = 0L; + infoheader.bn_clrused = 0L; + infoheader.bn_clrimportant = 0L; + + /*========= PALETTE =========*/ + if ( colors == 256 ) + { + for ( i = 0; i < colors; i++ ) + { + GrQueryColor(i, &r, &g, &b); + palette[(i*4)] = (unsigned char)b; + palette[(i*4)+1] = (unsigned char)g; + palette[(i*4)+2] = (unsigned char)r; + palette[(i*4)+3] = 0; + } + } + + line = (char *)malloc(width*(infoheader.bn_bitcount / 8)); + if ( !line ) + { + close(handle); + return FALSE; + } + /*========= WRITE FILEHEADER =========*/ + write(handle, &fileheader.bf_type, 2); + write(handle, &fileheader.bf_size, 4); + write(handle, &fileheader.bf_reserved1, 2); + write(handle, &fileheader.bf_reserved2, 2); + write(handle, &fileheader.bf_offbits, 4); + + /*========= WRITE INFOHEADER =========*/ + write(handle, &infoheader.bn_size, 4); + write(handle, &infoheader.bn_width, 4); + write(handle, &infoheader.bn_height, 4); + write(handle, &infoheader.bn_planes, 2); + write(handle, &infoheader.bn_bitcount, 2); + write(handle, &infoheader.bn_compression, 4); + write(handle, &infoheader.bn_sizeimage, 4); + write(handle, &infoheader.bn_xpelspermeter, 4); + write(handle, &infoheader.bn_ypelspermeter, 4); + write(handle, &infoheader.bn_clrused, 4); + write(handle, &infoheader.bn_clrimportant, 4); + + /*========= WRITE PALETTE =========*/ + if ( colors == 256 ) write(handle, palette, 256*4); + + /*========= WRITE MAP =========*/ + yy = height; + do { + xx = 0; + do { + pixcol = GrPixelC(_c,_x1+xx,_y1+yy); + if ( colors == 256 ) line[xx] = pixcol; + else + { + line[(xx*3)+0] = GrRGBcolorBlue(pixcol); + line[(xx*3)+1] = GrRGBcolorGreen(pixcol);; + line[(xx*3)+2] = GrRGBcolorRed(pixcol);; + } + } while(++xx < width); + write(handle, line, width*(infoheader.bn_bitcount / 8)); + } while(--yy > 0); + free((void *)line); + close(handle); + return TRUE; +} + +/* ************************************************************************ */ +unsigned long GrBmpImageWidth ( GrBmpImage* _bmp ) +/* ************************************************************************ */ +{ + return ( _bmp && _bmp->bi_bmpinfoheader ) ? _bmp->bi_width : 0L; +} + +/* ************************************************************************ */ +unsigned long GrBmpImageHeight ( GrBmpImage* _bmp ) +/* ************************************************************************ */ +{ + return ( _bmp && _bmp->bi_bmpinfoheader ) ? _bmp->bi_height : 0L; +} + +/* ************************************************************************ */ +char *GrBmpImagePalette ( GrBmpImage* _bmp ) +/* ************************************************************************ */ +{ + return (char *)(( _bmp && _bmp->bi_bmpimagecolors ) ? _bmp->bi_palette : NULL); +} + +/* ************************************************************************ */ +GrColor *GrBmpImageColorMap ( GrBmpImage* _bmp ) +/* ************************************************************************ */ +{ + return ( _bmp && _bmp->bi_bmpimagecolors ) ? _bmp->bi_colormap : NULL; +} + +/* ************************************************************************ */ +GrColor GrGetBmpImageNumColors ( GrBmpImage* _bmp ) +/* ************************************************************************ */ +{ + return ( _bmp && _bmp->bi_bmpimagecolors ) ? _bmp->bi_numcolors : 0; +} + diff --git a/thirdparty/grx249/addons/bmp/bmp.hlp b/thirdparty/grx249/addons/bmp/bmp.hlp new file mode 100644 index 0000000..028f066 --- /dev/null +++ b/thirdparty/grx249/addons/bmp/bmp.hlp @@ -0,0 +1,190 @@ +============================== +o LOAD MS-WINDOWS BITMAP FILE +============================== + Syntax + ------ + GrBmpImage *GrLoadBmpImage ( char *_filename ); + + Description + ----------- + This function load BMP file format ( 1, 4, 8 Bytes Per Pixel ) from + the file _filename into structure GrBmpImage*. + + Return Value + ------------ + On succes pointer to new GrBmpImage structure, otherwise NULL + + Example + ------- + GrBmpImage* bmp = GrLoadBmpImage("logogrx.bmp"); + +============================== +o SETTING GrBmpImage COLORS +============================== + Syntax + ------ + int GrAllocBmpImageColors ( GrBmpImage *_bmp, GrBmpImageColors *_col ); + + Description + ----------- + This function setting GrBmpImage colors. (_bmp) is pointer to GrBmpImage + structure and (_pal) is pointer to structrure, where we want to store + information about BMP palette and colors. If (_col) is NULL, it set colors and into + (_bmp) structure write 1 for own destroing palette by GrUnloadBmpImage. + Otherwise palette will be destroy only by function GrEraseBmpImageColors. + + Return Value + ------------ + On succes 1, otherwise 0 + + Example 1 ( _col is NULL ) + ------- + GrBmpImage* bmp = GrLoadBmpImage("logogrx.bmp"); + GrAllocBmpImageColors(bmp, NULL); + GrUnloadBmpImage(bmp); + + Example 2 ( _col is pointer to structure ) + ------- + GrBmpImage* bmp = GrLoadBmpImage("logogrx.bmp"); + GrBmpImageColors col; + GrAllocBmpImageColors(bmp, &col); + GrUnloadBmpImage(bmp); + GrFreeBmpImageColors(&pal); + +============================== +o FREE GrBmpImage COLORS +============================== + Syntax + ------ + int GrFreeBmpImageColors ( GrBmpImageColors *_col ); + + Description + ----------- + It destroy _col structure, free GrBmpImage Colors and set to NULL + + Return Value + ------------ + On succes 1, otherwise 0 + + Example + ------- + GrBmpImage* bmp = GrLoadBmpImage("logogrx.bmp"); + GrBmpImageColors bmpcolors; + GrAllocBmpImageColors(bmp, &bmpcolors); + GrUnloadBmpImage(bmp); + GrFreeBmpImageColors(&bmpcolors); + +=============================== +o CONVERT GrBmpImage STRUCTURE +=============================== + Syntax + ------ + GrPattern *GrConvertBmpImageToPattern ( GrBmpImage *_bmp ); + + Description + ----------- + Make GrPattern structure from GrBmpImage pointer. + + Return Value + ------------ + On succes pointer to new GrPattern structure, else NULL + + Example + ------- + GrPattern *bmppat; + GrBmpImage *bmp = GrLoadBmpImage("logogrx.bmp"); + GrAllocBmpImageColors(bmp, NULL); + bmppat = GrConvertBmpImageToPattern(bmp); + if ( bmppat ) GrPatternFilledBox(0, 0, GrMaxX(), GrMaxY(), bmppat); + GrUnloadBmpImage(bmp); + if ( bmppat ) GrDestroyPattern(bmppat); + + IN THE OTHER WAY + + Syntax + ------ + GrPattern *GrConvertBmpImageToStaticPattern ( GrBmpImage *_bmp ); + + Description + ----------- + Make GrPattern structure from GrBmpImage pointer, AND GrBmpImage (_bmp) + structure unload. + + Return Value + ------------ + On succes pointer to new GrPattern structure, else NULL + + Example + ------- + GrPattern *bmppat; + GrBmpImage *bmp = GrLoadBmpImage("logogrx.bmp"); + GrAllocBmpImageColors(bmp, NULL); + bmppat = GrConvertBmpImageToStaticPattern(bmp); + if ( bmppat ) GrPatternFilledBox(0, 0, GrMaxX(), GrMaxY(), bmppat); + if ( bmppat ) GrDestroyPattern(bmppat); + +============================== +o UNLOAD GrBmpImage STRUCTURE +============================== + + Syntax + ------ + int GrUnloadBmpImage ( GrBmpImage *_bmp ); + + Description + ----------- + Free _bmp and BmpImage colors/palette (only if GrAllocBmpImagePalette + contains NULL in 2nd variable ). + + Return Value + ------------ + On succes 1, else 0 + + Example + ------- + GrBmpImage* bmp = GrLoadBmpImage("logogrx.bmp"); + GrUnloadBmpImage(bmp); + +========================================= +o SAVE CONTEXT TO MS-WINDOWS BITMAP FILE +========================================= + Syntax + ------ + int GrSaveBmpImage ( char *_filename, GrContext *_c, int _x1, int _y1, + int _x2, int _y2 ); + + Description + ----------- + Save context from the position ( where _x1,_y1 is left uppon origin && + _x2,_y2 right bottom origin) + to BMP ( 8 or 24 bpp file ). The BMP file will be set to 8 Bits Per Line, + when GrNumColors() in GRXxx.H is set to 256, otherwise it'll be set to + 24 Bits Per Line. + If _context is set to NULL, _c will be pointer to current context + structure. + + Return Value + ------------ + On succes 1, owtherwise 0 + + Example + ------- + GrSaveBmpImage("logogrx.bmp", NULL, 100, 100, 400, 400); + + + +========================================= +======= THE END ========================= +========================================= + + Michal Stencl + + - [stenclpmd@ba.telecom.sk] + + + + + + + + diff --git a/thirdparty/grx249/addons/bmp/bmptest.c b/thirdparty/grx249/addons/bmp/bmptest.c new file mode 100644 index 0000000..22533d1 --- /dev/null +++ b/thirdparty/grx249/addons/bmp/bmptest.c @@ -0,0 +1,30 @@ +#include "grx20.h" +#include "bmp.c" + +int main ( void ) +{ + GrBmpImage *bmp256, *bmp; + GrPattern *p256, *p; + GrSetMode(GR_width_height_color_graphics, 800, 600, 256); + bmp256 = GrLoadBmpImage("mysha256.bmp"); + bmp = GrLoadBmpImage("some1.bmp"); + GrAllocBmpImageColors(bmp, NULL); + GrAllocBmpImageColors(bmp256, NULL); + p256 = GrConvertBmpImageToPattern(bmp256); + p = GrConvertBmpImageToPattern(bmp); + if ( p ) { + GrImageDisplay(0, 0, GrImageFromPattern(p)); + getkey(); + } + if ( p256 ) { + GrImageDisplay(300, 300, GrImageFromPattern(p256)); + getkey(); + } + if ( p ) GrDestroyPattern(p); + if ( p256 ) GrDestroyPattern(p256); + GrSaveBmpImage("save.bmp", NULL, 0, 0, 400, 400); + GrUnloadBmpImage(bmp); + GrUnloadBmpImage(bmp256); + return 0; +}; + diff --git a/thirdparty/grx249/addons/bmp/grxbmp.h b/thirdparty/grx249/addons/bmp/grxbmp.h new file mode 100644 index 0000000..ad4d7aa --- /dev/null +++ b/thirdparty/grx249/addons/bmp/grxbmp.h @@ -0,0 +1,78 @@ +/* +** - BMP read/write file +** by Michal Stencl Copyright (c) 1998 +** - read BMP 2, 4, 8 bpp +** - write BMP 8, 24 bpp +** - [stenclpmd@ba.telecom.sk] +** +*/ + +#include "libgrx.h" + +#define _GrBitmapPointerTypes_DEFINED_ +typedef struct _GR_bitmapfileheader GrBitmapFileHeader; +typedef struct _GR_bitmapinfoheader GrBitmapInfoHeader; +typedef struct _GR_bmpimagecolors GrBmpImageColors; +typedef struct _GR_bmpimage GrBmpImage; + +/* ************************************************************************ */ +/* _GR_bitmapfileheader */ +/* ************************************************************************ */ +struct _GR_bitmapfileheader { + GR_int16u bf_type; + GR_int32u bf_size; + GR_int16u bf_reserved1; + GR_int16u bf_reserved2; + GR_int32u bf_offbits; +}; + +/* ************************************************************************ */ +/* _GR_bitmapinfoheader */ +/* ************************************************************************ */ +struct _GR_bitmapinfoheader { + GR_int32u bn_size; + GR_int32u bn_width; + GR_int32u bn_height; + GR_int16u bn_planes; + GR_int16u bn_bitcount; + GR_int32u bn_compression; + GR_int32u bn_sizeimage; + GR_int32u bn_xpelspermeter; + GR_int32u bn_ypelspermeter; + GR_int32u bn_clrused; + GR_int32u bn_clrimportant; +}; + +/* ************************************************************************ */ +/* _GR_bmpimagecolors IMPORTANT */ +/* ************************************************************************ */ +struct _GR_bmpimagecolors { + GR_int8u *bp_palette; /* (R, G, B, Reserved) * | 2 | 16 | 256 */ + GrColor *bp_colormap; + int bp_numcolors; +}; + +/* ************************************************************************ */ +/* _GR_bmpimage IMPORTANT */ +/* ************************************************************************ */ +struct _GR_bmpimage { + GrBitmapFileHeader *bi_bmpfileheader; + GrBitmapInfoHeader *bi_bmpinfoheader; + GrBmpImageColors *bi_bmpimagecolors; + GR_int16s bi_erasepalette; + char *bi_map; +}; + +GrBmpImage *GrLoadBmpImage ( char *_filename ); +int GrSaveBmpImage ( char *_filename, GrContext *_c, int _x1, int _y1, int _x2, int _y2 ); +void GrUnloadBmpImage ( GrBmpImage *_bmp ); +int GrAllocBmpImageColors ( GrBmpImage *_bmp, GrBmpImageColors *_pal ); +int GrFreeBmpImageColors ( GrBmpImageColors *_pal ); +GrPattern *GrConvertBmpImageToPattern ( GrBmpImage *_bmp ); +GrPattern *GrConvertBmpImageToStaticPattern ( GrBmpImage *_bmp ); +unsigned long GrBmpImageWidth ( GrBmpImage* _bmp ); +unsigned long GrBmpImageHeight ( GrBmpImage* _bmp ); +char *GrBmpImagePalette ( GrBmpImage* _bmp ); +GrColor *GrBmpImageColorMap ( GrBmpImage* _bmp ); +GrColor GrBmpImageNumColors ( GrBmpImage* _bmp ); + diff --git a/thirdparty/grx249/addons/ctx2tiff.c b/thirdparty/grx249/addons/ctx2tiff.c new file mode 100644 index 0000000..c93ca8c --- /dev/null +++ b/thirdparty/grx249/addons/ctx2tiff.c @@ -0,0 +1,210 @@ +/** + ** CTX2TIFF.C ---- saves a context in a TIFF file + ** + ** Copyright (c) 1997 Hartmut Schirmer + ** + ** requires tifflib by Sam Leffler (sam@engr.sgi.com) + ** available at ftp://ftp.sgi.com/graphics/tiff + ** + ** should work with every compiler supporting both, + ** tifflib and GRX libraries + **/ + +#include +#include +#include +#include + +#define SCALE(x) ((x)<<8) + +#define puttobuf(r,x,depth,col) do { \ + switch (depth) { \ + case 1 : if (col) { \ + int offset = (x) >> 3; \ + int mask = 0x80 >> ((x) & 7); \ + r[offset] |= mask; \ + } \ + break; \ + case 8 : r[x] = (unsigned char)(col); break; \ + case 24: r[3*(x)+0] = GrRGBcolorRed(col); \ + r[3*(x)+1] = GrRGBcolorGreen(col); \ + r[3*(x)+2] = GrRGBcolorBlue(col); \ + break; \ + } \ +} while(0) + + +/* +** SaveContextToTiff - Dump a context in a TIFF file +** +** Arguments: +** ctx: Context to be saved (NULL -> use current context) +** tiffn: Name of tiff file +** compr: Compression method (see tiff.h), 0: automatic selection +** docn: string saved in the tiff file (DOCUMENTNAME tag) +** +** Returns 0 on success +** -1 on error +*/ +int +SaveContextToTiff(GrContext *ctx, char *tiffn, unsigned compr, char *docn) { + int depth, i, res; + long row; + TIFF *tif; + long width, height, colors; + short photometric; + short samplesperpixel; + short bitspersample; + unsigned char *r; + unsigned short red[256], green[256], blue[256]; + + if (!ctx) ctx = (GrContext *)GrCurrentContext(); + if (!ctx) return -1; + width = ctx->gc_xmax+1; + height = ctx->gc_ymax+1; + colors = GrNumColors(); + if (colors < 2) return -1; + if (colors == 2) depth = 1; else + if (colors <= 256) depth = 8; else + if (colors <= 1L<<24) depth = 24; else return -1; + + if (!compr) { /* compr == 0 -> auto select compression */ + if (depth==1) compr = COMPRESSION_CCITTFAX4; + else compr = COMPRESSION_LZW; + } + + switch (depth) { + case 1: + samplesperpixel = 1; + bitspersample = 1; + photometric = PHOTOMETRIC_MINISBLACK; + break; + case 8: + samplesperpixel = 1; + bitspersample = 8; + photometric = PHOTOMETRIC_PALETTE; + break; + case 24: + samplesperpixel = 3; + bitspersample = 8; + photometric = PHOTOMETRIC_RGB; + break; + default: + return -1; /* shouldn't happen */ + } + + r = (unsigned char *) malloc( depth>1 ? + samplesperpixel*width*sizeof(unsigned char) : + (width+7)/8); + if (!r) return -1; + + tif = TIFFOpen(tiffn, "w"); + if (tif == NULL) { + free(r); + return -1; + } + + TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width); + TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height); + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bitspersample); + TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField(tif, TIFFTAG_COMPRESSION, compr); + TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric); + if (docn) + TIFFSetField(tif, TIFFTAG_DOCUMENTNAME, docn); + TIFFSetField(tif, TIFFTAG_IMAGEDESCRIPTION, "GRX saved context"); + TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, height); + TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + + memset(red, 0, sizeof(red)); + memset(green, 0, sizeof(green)); + memset(blue, 0, sizeof(blue)); + if (depth == 8) { + for (i = 0; i < colors; i++) { + int r, g, b; + GrQueryColor(i, &r, &g, &b); + red[i] = SCALE(r); + green[i] = SCALE(g); + blue[i] = SCALE(b); + } + TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue); + } + res = 0; + for (row = 0; row < height; row++) { + int x; + GrColor c; +#if GRX_VERSION_API-0 >= 0x229 + const GrColor *rcb = GrGetScanlineC(ctx,0,width-1,row); + if (rcb) { + for (x=0; x < width; ++x) { + c = rcb[x]; + puttobuf(r,x,depth,c); + } + } else +#endif + { + if (depth==1) memset (r,0,(width+7)/8); + for (x=0; x < width; ++x) { + c = GrPixelC(ctx,x,row); + puttobuf(r,x,depth,c); + } + } + if (TIFFWriteScanline(tif, r, row, 0) < 0) { + res = -1; + break; + } + } + TIFFFlushData(tif); + TIFFClose(tif); + free(r); + return res; +} + +#ifdef TEST_CTX2TIFF +#include "../test/test.h" + +TESTFUNC(wintest) +{ + int x = GrSizeX(); + int y = GrSizeY(); + int ww = (x / 2) - 10; + int wh = (y / 2) - 10; + long c; + GrContext *w1 = GrCreateSubContext(5,5,ww+4,wh+4,NULL,NULL); + GrContext *w2 = GrCreateSubContext(15+ww,5,ww+ww+14,wh+4,NULL,NULL); + GrContext *w3 = GrCreateSubContext(5,15+wh,ww+4,wh+wh+14,NULL,NULL); + GrContext *w4 = GrCreateSubContext(15+ww,15+wh,ww+ww+14,wh+wh+14,NULL,NULL); + + GrSetContext(w1); + c = GrAllocColor(200,100,100); + drawing(0,0,ww,wh,c,GrBlack()); + c = GrAllocColor(100,50,50); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w2); + c = GrAllocColor(100,200,200); + drawing(0,0,ww,wh,c,GrBlack()); + c = GrAllocColor(50,100,100); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w3); + c = GrAllocColor(200,200,0); + drawing(0,0,ww,wh,c,GrBlack()); + c = GrAllocColor(100,100,0); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w4); + c = GrAllocColor(0,100,200); + drawing(0,0,ww,wh,c,GrBlack()); + c = GrAllocColor(255,0,100); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(NULL); + + SaveContextToTiff(NULL, "test.tif", 0, "Context2TIFF test file"); + getch(); +} +#endif + + diff --git a/thirdparty/grx249/addons/print/copying.uz b/thirdparty/grx249/addons/print/copying.uz new file mode 100644 index 0000000..680f5b6 --- /dev/null +++ b/thirdparty/grx249/addons/print/copying.uz @@ -0,0 +1,64 @@ +[See below for an english version] + + PRINTER.BGI + + (C) Copyright 1990-1995 Ullrich von Bassewitz + + Bedingungen fuer Nutzung und Weitergabe + + +Die Software (sowohl die Quellcodes, als auch die Binaries) werden +ohne jegliche Zusagen/Garantien bezglich Funktionalit„t oder +Funktionsf„higkeit abgegeben. Weder die Autoren noch die Distributoren +bernehmen eine Verantwortung fr Sch„den, die durch die Benutzung der +Software verursacht werden. + +Die Software darf frei verwendet und weitergegeben werden, wobei +"frei" ausdrcklich auch eine kommerzielle Nutzung/Weitergabe +einschlieát, *vorausgesetzt* die folgenden Bedingungen werden +eingehalten: + + 1. Die Herkunft der Software muá - wenn berhaupt - dann korrekt + angegeben werden. Es ist nicht erlaubt, die Software als Werk + eines anderen auszugeben. Wird die Software in Teilen oder als + Ganzes in einem Produkt benutzt, dann wrde ich mich ber einen + Hinweis auf die Herkunft in der Dokumentation freuen. Ein solcher + Hinweis ist aber nicht zwingend notwendig. + + 2. Ge„nderte Quellcodes mssen deutlich als solche gekennzeichnet + werden und drfen nicht ohne einen expliziten Hinweis auf die + durchgefhrten Žnderungen weiterverteilt werden. + + 3. Die Bedingungen ber die Nutzung/Weitergabe drfen nicht entfernt + oder ge„ndert werden. + + +------------------------------------------------------------------------------- +[Dasselbe auf englisch:] + + + PRINTER.BGI + + (C) Copyright 1990-1995 Ullrich von Bassewitz + + COPYING CONDITIONS + + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source + distribution + + diff --git a/thirdparty/grx249/addons/print/grxprint.c b/thirdparty/grx249/addons/print/grxprint.c new file mode 100644 index 0000000..1471477 --- /dev/null +++ b/thirdparty/grx249/addons/print/grxprint.c @@ -0,0 +1,1272 @@ +/*****************************************************************************/ +/* */ +/* grxprint.cc : Output of graphics on printer from GRX graphic library */ +/* Version 0.5 (beta) 98/01/26 Andris Pavenis (pavenis@acad.latnet.lv) */ +/* - Initial version */ +/* */ +/* Version 0.51 98/02/18 A.Pavenis */ +/* - Fixes to allow to work under Linux (still printing to file only) */ +/* */ +/* Version 0.52 98/02/24 A.Pavenis */ +/* - Changed name of function from GrDoPrinting to GrPrintToFile */ +/* - Added function GrDoPrinting(void) that prints to prn in MS-DOS */ +/* and pipes output to lpr in Linux */ +/* - Some other small changes, such as saving current video driver in */ +/* GrSetPrintMode and restoring it from GrDoPrinting */ +/* or GrPrintToFile */ +/* */ +/* Version 0.6 98/02/28 A.Pavenis */ +/* - Many changes and fixed bugs, e.g. the mirror image was */ +/* printed */ +/* */ +/* Version 0.61 98/03/03 A.Pavenis */ +/* - Fixed problem when printing directly to printer (DJGPP version). */ +/* The opened file was opened in text mode (old bug in libc). */ +/* A workaround for this problem is used */ +/* - Get rid of most of warnings that appears with -Wall */ +/* */ +/* Version 0.65 98/03/09 A.Pavenis */ +/* - Changed GrPrintToFile() under Linux. Now GrPrintToFile("|lpr") */ +/* is equivalent to GrDoPrinting(); */ +/* */ +/* Version 0.66 98/05/07 H.Schirmer */ +/* - minor changes for Watcom support */ +/* made cpp # start on first column */ +/* */ +/* Version 0.67 98/05/10 H.Schirmer */ +/* - eleminated C++ style comments for better portability */ +/* */ +/* Version 0.68 98/05/13 H.Schirmer */ +/* - clean source for better portability / ANSI-C conformance */ +/* */ +/* Version 0.7 98/05/14 A.Pavenis */ +/* - internal procedures that are used only from this file are */ +/* defined static and the definitions are removed from prn000.h */ +/* - changed restoring previous state after printing to avoid */ +/* unnecessary autodetection of video driver */ +/* */ +/* This code is port of part of printer BGI driver */ +/* (C) 1990-1995 Ullrich von Bassewitz (see copying.uz). */ +/* Only the code of printing itself is ported. */ +/* */ +/* Full version of printer BGI driver version 4.0 can be found */ +/* at URL ftp://ftp.musoftware.com/pub/uz/printerbgi+src.zip */ +/* An alternate URL is http://www.lanet.lv/~pavenis/printerbgi+src.zip */ +/* */ +/*****************************************************************************/ + +/* +>>>>> We need to configure this code on Unix like systems <<<<< +>>>>> for popen(), ... <<<<< +*/ + +#if defined(__MSDOS__) +# include +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if !defined(__WATCOMC__) && !defined(__DJGPP__) && !defined(__WIN32__) +#include +#endif + +static short InitDone=0; +static short Mode=-1; /* Print mode to be used */ +static GrColor numGrxColors; /* Number of colors for GRX to use */ +static int MaxX=0, MaxY=0; +static long AspectRatio=10000L; + +static jmp_buf PrintAborted; + + +/****************************************************************************/ +/* Extern deklarierte Variable */ +/****************************************************************************/ + +/* Die Farbtabelle wird (da nicht verwendet) als Moeglichkeit zur Einstellung */ +/* von diversen Daten von aussen benutzt. Sie heisst daher nicht ColorTable */ +/* (wie im SVGA-Treiber), sondern Settings (fuer die aktuelle Tabelle) und */ +/* DefaultSettings (fuer die Default-Einstellungen). */ + +static struct GrPrintOptionsType DefaultSettings = { + 0, /* Output quality, 0 --> keypad setting */ + /* 1 --> draft */ + /* 2 --> high */ + 0, /* Shingling, 0 --> normal */ + /* 1 --> 25% (2 pass) */ + /* 2 --> 50% (4 pass) */ + 1, /* Depletion 0 --> none */ + /* 1 --> 25% */ + /* 2 --> 50% */ + 0 /* Media type, 0 --> Plain paper */ + /* 1 --> Bond paper */ + /* 2 --> Special paper */ + /* 3 --> Glossy film */ + /* 4 --> Transparency film */ +}; + + + +/* Die folgenden Farbtabelle wird als Einstellungstabelle "missbraucht" */ +static struct GrPrintOptionsType Settings = { + 0, /* Output quality, 0 --> keypad setting */ + /* 1 --> draft */ + /* 2 --> high */ + 0, /* Shingling, 0 --> normal */ + /* 1 --> 25% (2 pass) */ + /* 2 --> 50% (4 pass) */ + 1, /* Depletion 0 --> none */ + /* 1 --> 25% */ + /* 2 --> 50% */ + 0 /* Media type, 0 --> Plain paper */ + /* 1 --> Bond paper */ + /* 2 --> Special paper */ + /* 3 --> Glossy film */ + /* 4 --> Transparency film */ +}; + + + + +/* RGB-Palette */ +static struct RGBEntry RGBPal [256]; + +/* Der Zeiger auf die aktuelle DST */ +static struct _DST * DSTPtr = NULL; + +/*****************************************************************************/ +/* Prototypes of internal procedures */ +/*****************************************************************************/ + + static BOOLEAN InitPrinter (BYTE *Buf, int BufSize, int Handle); + /* Stellt das Ausgabegeraet auf "binary" um und prueft gleichzeitig, ob */ + /* das Handle 4 ok (offen) ist. Der aktuelle Zustand wird gemerkt und bei */ + /* Post wiederhergestellt. Buf wird als Puffer fuer die Ausgabe verwendet */ + /* und muss PrintBufSize Bytes gross sein, Handle ist das Handle auf das */ + /* ausgegeben wird. */ + + static void ResetPrinter (void); + /* Stellt den orginalen Zustand des Ausgabegeraets wieder her. */ + + static void Flush (void); + /* Schreibt den Ausgabepuffer leer. Muss am Ende eines Ausdrucks */ + /* aufgerufen werden. Springt PrintAbortLabel an bei Fehlern. */ + + static void PrintByte (BYTE B); + /* Gibt ein Byte auf den Drucker (bzw. in den Ausgabepuffer) aus. */ + /* Springt PrintAbortLabel an bei Fehlern. */ + + static void PrintData (BYTE * Data, unsigned Size); + /* Gibt Daten auf den Drucker (bzw. in den Ausgabepuffer) aus. */ + /* Springt PrintAbortLabel an bei Fehlern. */ + + static void PrintString (char * S); + /* Gibt einen Pascal-String auf den Drucker (bzw. in den Ausgabepuffer) aus.*/ + /* Springt PrintAbortLabel an bei Fehlern. */ + + static void PrintZString (char * S); + /* Gibt einen nullterminierten String auf den Drucker (bzw. in den */ + /* Ausgabepuffer) aus. Springt PrintAbortLabel an bei Fehlern. */ + + +/****************************************************************************/ +/* */ +/* Interne Variablen */ +/* */ +/****************************************************************************/ + + +/* Default-Palette fuer die ersten Eintraege */ +static struct RGBEntry RGBDefPal [8] = { + { 0, 0, 0 }, /* Black */ + { 255, 0, 0 }, /* Red */ + { 0, 255, 0 }, /* Green */ + { 255, 255, 0 }, /* Yellow */ + { 0, 0, 255 }, /* Blue */ + { 255, 0, 255 }, /* Magenta */ + { 255, 255, 0 }, /* Cyan */ + { 255, 255, 255 } /* White */ +}; + + +static GrVideoDriver * PrevDrv = NULL; + + +int GrPrintSetMode ( int _mode_ ) + { + int rc; + unsigned I; + struct RGBEntry * P; + PrevDrv = GrDriverInfo->vdriver; + + Mode = _mode_; + if (Mode<0 || Mode>MaxModes) return -1; /* Check mode range */ + if (DSTTable[Mode]==0) return -1; + + DSTPtr = DSTTable[Mode]; + + MaxX = (int) ((((long) (DSTPtr->XDPI))*((long) (DSTPtr->XInch)))/1000L); + MaxY = (int) ((((long) (DSTPtr->YDPI))*((long) (DSTPtr->YInch)))/1000L); + AspectRatio = (long) ((10000L*DSTPtr->YDPI)/DSTPtr->XDPI); + + if (DSTPtr->ColorBits==1) numGrxColors=2; + else if (DSTPtr->ColorBits<=4) numGrxColors=16; + else if (DSTPtr->ColorBits<=8) numGrxColors=256; + else numGrxColors=256; + + /* Palette initialisieren, erste 8 Eintraege wie beim DeskJet */ + memcpy (RGBPal, RGBDefPal, sizeof (RGBDefPal)); + + /* Rest der Palette mit Grautoenen vorbesetzen */ + I = sizeof (RGBDefPal) / sizeof (struct RGBEntry); + P = &RGBPal [I]; + while (I < sizeof (RGBPal) / sizeof (struct RGBEntry)) { + P->R = P->G = P->B = I; + P++; + I++; + } + + rc = GrSetDriver ("memory"); + if (rc==TRUE) + { + rc = GrSetMode (GR_width_height_color_graphics, MaxX, MaxY, numGrxColors); + InitDone = 1; + } + return rc; + } + + + + +int GrPrintToFile (const char * DestFile) + { + int handle; +# ifdef __MSDOS__ + handle = creat (DestFile,S_IREAD+S_IWRITE); + if (!handle) return -1; + if (DSTPtr) (DSTPtr->Print) (DSTPtr,handle); + close (handle); + GrSetMode (GR_default_text); +# else + FILE * output; + if (*DestFile=='|') output = popen (DestFile+1,"w"); + else output = fopen (DestFile ,"w"); + if (!output) return -1; + handle = fileno (output); + if (DSTPtr) (DSTPtr->Print) (DSTPtr,handle); + if (*DestFile=='|') pclose (output); + else fclose (output); +# endif + if (PrevDrv) GrSetDriver (PrevDrv->name); + else DRVINFO->vdriver = NULL; + return 0; + } + + + +int GrDoPrinting (void) + { + int handle; +# ifdef __MSDOS__ + handle = creat ("prn",S_IREAD+S_IWRITE); + if (!handle) return -1; +# else + FILE * output = popen ("lpr","w"); + if (!output) return -1; + handle = fileno (output); +# endif + if (DSTPtr) (DSTPtr->Print) (DSTPtr,handle); +# ifdef __MSDOS__ + close (handle); +# else + pclose (output); +# endif + GrSetMode (GR_default_text); + if (PrevDrv) GrSetDriver (PrevDrv->name); + else DRVINFO->vdriver = NULL; + return 0; + } + + +void GrPrintGetAspectRatio ( unsigned * x , unsigned * y ) + { + *x = AspectRatio; + *y = 10000U; + } + + +/*****************************************************************************/ +/* NP.CPP */ +/* */ +/* */ +/* (C) 1994 by Ullrich von Bassewitz */ +/* Zwehrenbuehlstrasse 33 */ +/* 72070 Tuebingen */ +/* */ +/* E-Mail: uz@ibb.schwaben.de */ +/* */ +/* Port of printing code to DJGPP */ +/* Revision 0.5 98/01/26 Andris Pavenis (pavenis@acad.latnet.lv) */ +/* */ +/*****************************************************************************/ + + +/*****************************************************************************/ +/* */ +/* Printing on dot matrix printers */ +/* */ +/*****************************************************************************/ +/* */ +/* */ +/* Anmerkung zur Speicheraufteilung: Die urspruengliche Speicheraufteilung */ +/* wurde so geaendert, dass sich alle Bytes einer Druckerspalte (also bis */ +/* zu 3 bei einem 24-Nadler) linear hintereinander im Speicher befinden. */ +/* Dadurch ergibt sich ein wesentlich schnellerer Ausdruck, da eine */ +/* komplette Zeile mit Druckdaten am Stueck im Speicher steht. */ +/* */ +/* Die Berechnung fuer Adresse und Pixel erfolgt nach folgenden Formeln: */ +/* */ +/* Pixelmaske im Byte: */ +/* */ +/* PixelMask = 0x01 << (7 - (X % 8)); */ +/* */ +/* bzw. (bei Reverse) */ +/* */ +/* PixelMask = 0x01 << (X % 8); */ +/* */ +/* Lineare Adresse des Bytes in dem das Pixel steht (Achtung: die Formel */ +/* kann _nicht_ vereinfacht werden, d.h. es darf nichts weggekuerzt werden, */ +/* da es sich um Ganzzahlarithmetik handelt). */ +/* */ +/* X */ +/* Abs = -------------- * MaxY * ColBytes */ +/* 8 * ColBytes */ +/* */ +/* */ +/* + (MaxY - Y - 1) * ColBytes */ +/* */ +/* */ +/* X % (8 * ColBytes) */ +/* + -------------------- */ +/* 8 */ +/* */ + +/****************************************************************************/ +/* Drucker-Ausgaberoutinen */ +/****************************************************************************/ + +void EpsonPrint ( struct _DST * DSTPtr , int PRNHandle ) +/* Universelle Drucker-Routine fuer Nadeldrucker */ + +{ + /* + ** Steuerstrings fuer EPSON/NEC P6 Farbe. Diese sind bisher fest + ** eincodiert, da die Drucker alle dieselben Steuerstrings haben. + ** ACHTUNG: Zwei der Bit-Ebenen sind vertauscht um eine dem DeskJet + ** aehnliche Farb-Verteilung zu erhalten. + ** Alle Steuerstrings enthalten zusaetzlich zuerst einen Wagenruecklauf. + */ + + static char *ColorSel [4] = { + "\x04\r\x1Br\x02", /* Bit 0 = Cyan */ + "\x04\r\x1Br\x01", /* Bit 1 = Magenta */ + "\x04\r\x1Br\x04", /* Bit 2 = Gelb */ + "\x04\r\x1Br\x00" /* Bit 3 = Schwarz */ + }; + + WORD X, Y, EndX; + BYTE Bytes, Pass, PassCount, ColBytes, ColorBits, Bits; + DWORD Abs; + /*DWORD A;*/ + /*BYTE Buf [6]; */ /* Maximale Groesse: ColBytes(max) * PassCount(max) */ + /*BYTE PrintBuf [3];*/ /* Maximale Groesse: ColBytes(max) */ + /*int I,J,K;*/ + char Reverse; + int MaxX = GrSizeX(); + int MaxY = GrSizeY(); + unsigned char *Buffer[4]; /* Where to create buffer for printing */ + unsigned char *Curr[4] , Mask; + char OrVal[4]; + int i, j, k, l, c, X1; + int PlaneSize, BufSize; + + struct EpsonDST * dst = (struct EpsonDST *) DSTPtr; + + /* Handle auf "raw data" umstellen. Direkt Ende wenn Handle nicht Ok */ + BYTE * OutputBuf = (BYTE *) malloc (PrintBufSize); + assert (OutputBuf!=0); + if (InitPrinter (OutputBuf, PrintBufSize, PRNHandle) == FALSE) return; + + /* Vor Beginn der Druck-Ausgabe jetzt das Sprunglabel fuer Druckerfehler */ + /* setzen. */ + + if (setjmp(PrintAborted)!=0) { /* Fehler! */ return; } + + PrintString (dst->GraphicsOn); /* Variablen-Init */ + + Abs = 0L; + PassCount = dst->PassCount; + ColBytes = dst->ColBytes; + ColorBits = DSTPtr->ColorBits; + Bytes = ColBytes * PassCount; + EndX = MaxX / (ColBytes * 8); + Reverse = DSTPtr->Flags & pfReverse; + + X = 0; + + PlaneSize = ((int) ColBytes)*MaxY; + BufSize = PlaneSize*ColorBits; + Buffer[0] = (unsigned char *) malloc (BufSize); + if (Buffer[0]==0) { fprintf(stderr,"Not enough memory\n"); + longjmp(PrintAborted,-1); } + for (i=1; i=0 ? (GrPixelNC (xPos,Y)) : 0; + /* Insert color conversion here if needed */ + X1 += PassCount; + for (l=0; l>= 1; + } + for (l=0; l 1) PrintString (ColorSel [Bits]); + PrintString (dst->PreBytes); + PrintData (Buffer[Bits], PlaneSize); + PrintString (dst->PostBytes); + } + } + + + if (Pass == (PassCount - 1)) + PrintString (dst->LineFeed1); + else + PrintString (dst->LineFeed2); + } + + X += PassCount*ColBytes*8; + Flush (); + } + /* Grafik beenden, Puffer leeren */ + Flush (); + ResetPrinter (); + free (Buffer[0]); + free (OutputBuf); +} + + +/****************************************************************************/ +/* */ +/* LaserJet/DeskJet-Ausgaberoutinen fuer BGI-Druckertreiber */ +/* */ +/****************************************************************************/ +/* */ +/* (C) 1990-1993 Ullrich von Bassewitz */ +/* */ +/* Port to printing code to DJGPP */ +/* Revision 0.5 1998/01/26 Andris Pavenis (pavenis@acad.latnet.lv) */ +/* This code is not yet optimized and is rather slow espacially for */ +/* color printing. Tested on HP LaserJet 4L (Modes HPLJ_300x300, */ +/* HPLJ_300x300_NC) and on HP DeskJet 690C (Mode HPDJ500C_300x300x8_B). */ +/* Other modes are not tested. */ +/* */ +/* $Id: lj.cpp 2.10 1995/04/28 16:20:46 Uz Exp $ */ +/* */ +/* $Log: lj.cpp $ */ +/* Revision 2.10 1995/04/28 16:20:46 Uz */ +/* Umstellung auf PCX-Treiber. */ +/* */ +/* Revision 2.9 95/04/22 17:32:48 Uz */ +/* Diverse Aenderungen, Funktionen LaserPrint und LJPrint zusammengefasst, */ +/* Anpassungen an geaenderte Struktur von _DST und Support fuer DeskJet */ +/* 1200C mit einstellbarer Palette. */ +/* */ +/* Revision 2.8 94/09/08 14:14:38 Uz */ +/* Kleinere Aenderungen zur Einsprung von ein paar Bytes. */ +/* */ +/* Revision 2.7 94/09/08 09:32:52 Uz */ +/* Anpassung an extra modedata Modul. */ +/* */ +/* Revision 2.6 94/03/29 20:44:54 Uz */ +/* str.h anstelle von string.h verwendet */ +/* */ +/* Revision 2.5 94/03/19 16:16:51 Uz */ +/* Cleanup und Kosmetik. */ +/* */ +/* Revision 2.4 94/01/13 11:32:50 Uz */ +/* Ausdruck erweitert um schaltbare Schwarzabtrennung */ +/* fuer DeskJet 550C. */ +/* */ +/* Revision 2.3 93/08/01 20:53:05 Uz */ +/* Neues Format mit DPMI-Support */ +/* */ + +/****************************************************************************/ +/* Controlstrings zur Ansteuerung des LJ */ +/****************************************************************************/ + +/* defining LJ_LANDSCAPE_MODE changes order of data data output to */ +/* printer to more effectively use memory organization of GRX frame drivers */ +/* Unfortunatelly I was not able to remove some shift of image so part */ +/* of it was not printed (top was shifted down by about 6 mm) */ +/* (A.Pavenis) */ +/*#define LJ_LANDSCAPE_MODE*/ + +/* Drucker-Kontrollstrings */ +#ifndef LJ_LANDSCAPE_MODE +static char InitString [] = + "\x1B""E" /* Reset Printer */ + "\x1B*rbC" /* End Raster Graphics */ + "\x1B&l26A" /* Format: DIN A4 */ + "\x1B&l0o" /* Portrait orientation */ + "0L"; /* perf.-skip off */ +#else +static char InitString [] = + "\x1B""E" /* Reset Printer */ + "\x1B*rbC" /* End Raster Graphics */ + "\x1B&l26A" /* Format: DIN A4 */ + "\x1B&l1o" /* Landscape orientation */ + "\x1B*r0F" /* Follows orientation */ + "\x1B&l6D" /* Vertical line spacing */ + "\x1B&l0E" /* Top margin 0 */ + "\x1B*p0Y" /* Y position is 0 */ + "\x1B*p0Y\x1B*p0X" /* Cursor position 0,0 */ + "0L"; /* perf.-skip off */ +#endif + +static char ColorString1 [] = + "\x1B*r-3U"; /* 3 planes, CMY palette */ + +static char ColorString2 [] = + "\x1B*r-4U"; /* 4 planes, KCMY palette */ + +static char ColorString3 [13] = + "\x0B" /* Stringlaenge */ + "\x1B*v6W" /* CID Command */ + "\x00" /* Device RGB */ + "\x00" /* Indexed by plane */ + "\x00" /* Bits/Index (wird spaeter gesetzt) */ + "\x08\x08\x08"; /* 8 Bits per Primary */ + +static char Quality [3][6] = { + "\x1B*r0Q", /* Use keypad setting */ + "\x1B*r1Q", /* draft */ + "\x1B*r2Q" /* high */ +}; + +static char Shingling [3][6] = { + "\x1B*o0Q", /* None */ + "\x1B*o1Q", /* 25% (2 pass) */ + "\x1B*o2Q" /* 50% (4 pass) */ +}; + +static char Depletion [3][6] = { + "\x1B*o1D", /* None */ + "\x1B*o2D", /* 25% (default) */ + "\x1B*o3D" /* 50% */ +}; + +static char MediaType [5][6] = { + "\x1B&l0M", /* Plain paper */ + "\x1B&l1M", /* Bond paper */ + "\x1B&l2M", /* Special paper */ + "\x1B&l3M", /* Glossy film */ + "\x1B&l4M" /* Transparency film */ +}; + +#ifdef LJ_LANDSCAPE_MODE +static char StartGraphics [] = + "\x1B*r1A"; /* Start graphics */ +/* "\x1B&a1N"; */ /* No negative motion (DeskJet 1200C) */ +#else +static char StartGraphics [] = + "\x1B*r0A"; /* Start graphics*/ +/* "\x1B&a1N"; */ /* No negative motion (DeskJet 1200C) */ +#endif + + +/* Steuerstring zur Einstellung der Palette.*/ +static char RGBCompStr [] = + "\x03" /* Stringlaenge */ + "\x1B*v"; + +/* String der nach der Grafik geschickt wird. */ +static char EndGraphics [] = + "\x1B*rbC" /* Grafik-Ende */ + "\x0C"; /* Papier-Auswurf */ + +/* Steuerstring fuer TIFF-Pacbits Kompression */ +static char Compression [] = + "\x1B*b2M"; + +/* Steuerstring fuer keine Kompression */ +static char NoCompression [] = + "\x1B*b0M"; + +/* Hier werden die Steuercodes fuer eine Zeile zusammengebaut. */ +static char PreBytes [25] = + "\x1B*b"; + + +/****************************************************************************/ +/* */ +/* Kompressionspuffer und dessen Verwaltung */ +/* */ +/****************************************************************************/ + +/*#define CompBufSize 600 */ /* 600 Bytes Puffer */ +#define CompBufSize 6000 /* 6000 Bytes Puffer */ +static BYTE * CompBuf = 0; /* Zeiger auf Kompressionspuffer */ +static WORD CompBufFill = 0; /* Anzahl Zeichen im Puffer */ + + + +static void ToBuf (BYTE B) +/* Speichert das uebergebene Byte im Puffer wenn noch Platz ist. Der Zaehler */ +/* wird auf jeden Fall hochgezaehlt, so dass sich spaeter die theoretische */ +/* Anzahl an Bytes im Puffer auf jeden Fall feststellen laesst. */ +{ + if (CompBufFill < (CompBufSize-1)) + { /* Platz ist da, speichern */ + CompBuf [CompBufFill++] = B; + } +} + + + +static void RepeatByte (WORD bCount, BYTE B) +/* Speichert ein wiederholtes Byte im Kompressionspuffer, wobei Count die */ +/* echte Anzahl ist und B das Byte. Der Zaehler wird auf Maximum */ +/* ueberprueft und eventuell auf zwei oder drei verteilt. */ +{ + int RepeatCount; + + while (bCount) { + /* Maximal koennen 128 Bytes am Stueck geschrieben werden, wobei */ + /* der Wert 0 einem Byte entspricht usw. 127 entsprechen 128 Byte */ + RepeatCount = (bCount > 128) ? 128 : bCount; + bCount -= RepeatCount; + + /* Byte schreiben */ + ToBuf (-(RepeatCount-1)); + ToBuf (B); + } +} + + + + +static void MultiByte (WORD bCount, char *S) +/* Speichert eine Folge von ungleichen Bytes im Kompressionspuffer, wobei */ +/* Count die echte Anzahl ist und S ein Zeiger auf das erste Byte. Der */ +/* Zaehler wird auf Maximum ueberprueft und die komplette Anzahl wird */ +/* evtl. auf mehrere Male rausgeschrieben. */ +{ + WORD ByteCount; + + while (bCount) { + /* Maximal koennen 128 Bytes am Stueck geschrieben werden, wobei der */ + /* Wert 0 einem Byte entspricht usw. 127 entsprechen 128 Byte */ + ByteCount = (bCount > 128) ? 128 : bCount; + bCount -= ByteCount; + + /* Bytefolge schreiben */ + ToBuf (ByteCount-1); + while (ByteCount--) { + ToBuf (*S++); + } + } +} + + + +static void PrintNum (WORD W) +/* Gibt das Wort W vorzeichenlos in ASCII auf den Drucker aus. Zur Wandlung */ +/* wird der Kompressionspuffer verwendet! */ +{ + /*Num (W, CompBuf);*/ + char numBuf[16]; + /*itoa (W,numBuf,10);*/ + sprintf (numBuf,"%u",(unsigned) W); + PrintZString (numBuf); +} + + +/****************************************************************************/ +/* Some setup functions for LaserJet and DeskJet printers */ +/****************************************************************************/ + +static void ljSetRasterSize (int width, int height) +{ + char cmd[32]; + sprintf (cmd,"\x1B*r%dT\x1B*r%dS",height,width); + PrintZString (cmd); +} + +/*****************************************************************************/ +/* */ +/* Universelle Ausgaberoutine fuer den LaserJet/DeskJet/Color-DeskJet. Die */ +/* Routine fuehrt die Drucker-Initialisierung ueber den uebergebenen String */ +/* in Buf aus (der das passende Format haben muss, also mit fuehrendem */ +/* Laengenbyte) und druckt dann den Inhalt des Speichers. Es ist Farbe */ +/* moeglich (im DeskJet-Format), die passende Initialisierung muss aber in */ +/* Buf stehen. Die Routine behandelt nur (falls vorhanden) die Planes */ +/* korrekt. */ +/* Da Buf spaeter als Komprimierungs-Puffer verwendet wird, muss er im Daten-*/ +/* segment liegen (sowieso weil Zeiger) und mindestens 600 Bytes gross sein. */ +/* */ +/* Die Routine wurde spaeter noch erweitert um eine Moeglichkeit, die Daten */ +/* auch gezwungenermassen ohne Kompression rauszuschicken. Dabei wird der */ +/* Einfachheit halber die Zeile auch komprimiert, dann aber bei der */ +/* Abfrage, welcher Puffer kuerzer ist, gleichzeitig das Flag ausgewertet. */ +/* Die zusaetzliche Laufzeit wird hier in Kauf genommen, da diese Modi ja */ +/* wohl nur eine Notloesung fuer Uralt-Drucker sein koennen. */ +/* */ +/* */ +/* Parameter: */ +/* Buf wie oben beschrieben */ +/* */ +/* Ergebnisse: */ +/* (keine) bzw. hoffentlich ein Ausdruck... */ +/* */ +/*****************************************************************************/ + + + + +void LaserPrint ( struct _DST * DSTPtr , int PRNHandle ) +{ + + int i,rc; + int X, Count, FullCount, Len, Plane, A, PlaneCount; + int RowBytes; + unsigned I; + BYTE B, *S; + BOOLEAN SeparateBlack; + BYTE *OutputBuf=0 , *Buf=0; + int *PX=0; + /*int *PXCurr;*/ + struct RGBEntry *P; + + int MaxX = GrSizeX(); + int MaxY = GrSizeY(); + + /* Variablen-Init */ + volatile enum {Unknown, Compressed, NotCompressed} CompStatus = Unknown; + + OutputBuf = (BYTE *) malloc (PrintBufSize); + +# ifdef LJ_LANDSCAPE_MODE + PX = (int *) calloc (MaxX,sizeof(int)); +# else + PX = (int *) calloc (MaxY,sizeof(int)); +# endif + + /* Bytes pro (Plane-) Zeile berechnen */ +# ifdef LJ_LANDSCAPE_MODE + RowBytes = MaxX / 8; +# else + RowBytes = MaxY / 8; +# endif + + /* Dynamischen Speicher fuer die Puffer belegen */ + Buf = (BYTE *) malloc (RowBytes); + CompBuf = (BYTE *) malloc (CompBufSize); + + /* Vor Beginn der Druck-Ausgabe jetzt das Sprunglabel fuer Druckerfehler */ + /* setzen. */ + if ((rc=setjmp (PrintAborted))==0) + { + /* Handle auf "raw data" umstellen. Direkt Ende wenn Handle nicht Ok*/ + /* ACHTUNG: Ab hier Ausstieg mit return nicht mehr zulaessig, es */ + /* muss goto Exit verwendet werden. */ + if (OutputBuf==0 || PX==0) longjmp (PrintAborted,-1); + + if (InitPrinter (OutputBuf, PrintBufSize, PRNHandle) == FALSE) { + longjmp (PrintAborted,-2); + } + + if (Buf==0 || CompBuf==0) longjmp (PrintAborted,-1); + + /* Variable aus DST zwischenspeichern */ + SeparateBlack = hasSeparateBlack (DSTPtr); + + /* Anzahl der Farb-Ebenen rechnen. Diese entspricht der Anzahl der */ + /* Farb-Bits mit Ausnahme der Modi mit Schwarz-Abtrennung, hier */ + /* kommt eine Plane dazu. */ + PlaneCount = DSTPtr->ColorBits; + if (SeparateBlack) PlaneCount++; + + /* Ausgabe der Initialisierungs-Sequenzen */ + PrintZString (InitString); + +# ifdef LJ_LANDSCAPE_MODE + ljSetRasterSize (MaxX, MaxY); +# else + ljSetRasterSize (MaxY, MaxX); +# endif + + if (DSTPtr->ColorCount == 8) { + /* DeskJet Farbe, Schwarz-Abtrennung hat 4 Ebenen, sonst 3 */ + PrintZString (hasSeparateBlack (DSTPtr) ? ColorString2 + : ColorString1); + } else if (DSTPtr->ColorCount > 8) { + /* Deskjet 1200C, Farbmodell und Palette setzen */ + ColorString3 [8] = DSTPtr->ColorBits; + PrintString (ColorString3); + + /* Zeiger auf die Palette */ + P = RGBPal; + + /* Alle Eintraege setzen */ + for (I = 0; I < DSTPtr->ColorCount; I++) { + + /* Steuerstring zum Setzen des Eintrags */ + PrintString (RGBCompStr); + PrintNum (P->R); + PrintByte ('a'); + PrintNum (P->G); + PrintByte ('b'); + PrintNum (P->B); + PrintByte ('c'); + PrintNum (I); + PrintByte ('I'); + + /* Naechster Eintrag */ + P++; + } + } + + PrintZString (((struct LJDST *) DSTPtr)->GraphicsOn); + PrintZString (Quality [djQuality]); + if (DSTPtr->ColorCount >= 8) { + /* Farb-Deskjets */ + PrintZString (Shingling [djShingling]); + PrintZString (Depletion [djDepletion]); + } + if (DSTPtr->ColorCount > 8) { + /* Nur Deskjet 1200C */ + PrintZString (MediaType [djMediaType]); + } + PrintZString (StartGraphics); + + /* Ausgabe beginnt */ + /*for (X = 0; X < MaxX; X++) {*/ +# ifdef LJ_LANDSCAPE_MODE + for (X = 0; X < MaxY; X++) { + for (Count = 0; Count= 0; X--) { + for (Count = 0; Count=MaxX) break; +# else + if (Y>=MaxY) break; +# endif + px = PX[Y]; /* GrPixelNC (X,Y); */ + if ((px & 7)==7) + { + Buf[Count] |= Mask; + PX[Y] = 0; /* GrPlotNC (X,Y,0); */ + } + Mask >>= 1; + } + } + } + else + { + /* Es handelt sich um eine ganz normale Farb-Ebene...*/ + int cmask = 1 << ((SeparateBlack ? Plane-1 : Plane)-1); + for (Count = 0; Count < RowBytes; Count++) + { + unsigned char Mask = 0x80; + int Y = Count<<3; + Buf[Count] = 0; + for (i=0; i<8; i++) + { + int px; +# ifdef LJ_LANDSCAPE_MODE + if (Y>=MaxX) break; +# else + if (Y>=MaxY) break; +# endif + px = PX[Y]; /* GrPixelNC (X,Y); */ + if (px & cmask) Buf[Count] |= Mask; + Mask >>= 1; + Y++; + } + } + + } + + /* Pruefen, wieviele Bytes am Ende des Puffers Null-Bytes sind */ + + S = Buf + RowBytes; + FullCount = RowBytes; + while (FullCount>0 && *(--S)==0) FullCount--; + + /* Versuchen die Zeile nach Algorithmus 2 (TIFF Pacbits) zu */ + /* komprimieren. Abgeschickt wird dann der kuerzere der beiden */ + /* Puffer. */ + + S = Buf; + Count = FullCount; /* Anzahl zu pruefender Bytes */ + CompBufFill = 0; /* Puffer ist leer */ + while (Count) { + /* Erstes Byte holen */ + B = *S++; + Count--; + A = 1; + + if (Count) { + /* Es kommen noch Bytes */ + if (*S == B) { + /* Das naechste ist gleich, zaehlen wieviele + ** gleiche kommen */ + while ((Count) && (*S == B)) { + A++; + Count--; + S++; + } + /* Abschicken */ + RepeatByte (A, B); + } else { + /* Das naechste ist ungleich, zaehlen wieviele + ** ungleiche kommen */ + while ((Count) && (*S != B)) { + A++; + Count--; + B = *(S++); + } + /* Wenn Count nicht 0 ist, dann sind die Bytes an + ** Position S und S-1 gleich, koennen also beim + ** naechsten Durchgang mit einer RepeatByte-Sequenz + ** dargestellt werden. In diesem Fall wird der letzte + ** Durchgang wieder rueckgaengig gemacht. */ + if (Count) { + S--; + A--; + Count++; + } + + /* Abschicken */ + MultiByte (A, (char *) (S-A)); + } + + } else { + /* Es kommen keine Bytes mehr, das letzte Byte als + ** Einzelbyte schicken */ + MultiByte (1, (char *) (S-1)); + } + + } + + /* Sodele, den kuerzeren der beiden Puffer abschicken. Hier auch + ** pruefen ob eine Kompression ueberhaupt gewuenscht ist... */ + if (CompBufFill < FullCount && DoCompression (DSTPtr)) { + /* Der komprimierte Puffer ist kuerzer, Kontrollstring zur */ + /* Festlegung der Kompression senden, falls diese nicht */ + /* schon eingestellt ist. */ + if (CompStatus != Compressed) { + CompStatus = Compressed; + PrintZString (Compression); + } + + FullCount = CompBufFill; + S = CompBuf; + } else { + /* Der unkomprimierte Puffer ist kuerzer, Kontrollstring zur*/ + /* Festlegung der Kompression schicken, falls diese nicht */ + /* schon eingestellt ist. */ + if (CompStatus != NotCompressed) { + CompStatus = NotCompressed; + PrintZString (NoCompression); + } + + S = Buf; + } + + /* Die Steuersequenz fuer die nicht leeren Zeichen zusammenbauen. + ** Beachten, dass sich die letzte Plane in Code von den vorigen + ** unterscheidet. */ + sprintf (&PreBytes[3],"%u",(unsigned) FullCount); /*Num (FullCount, &PreBytes [3]); */ + Len = strlen (PreBytes); + PreBytes [Len] = (Plane == PlaneCount) ? 'W' : 'V'; + PreBytes [Len+1] = '\0'; + + /* Steuersequenz und dann die Zeichen senden */ + PrintZString (PreBytes); + + /* Puffer folgt */ + PrintData (S, FullCount); + + } + } + + /* Das war's, Grafik beenden und Puffer leeren */ + PrintZString (EndGraphics); + Flush (); + } + else switch (rc) + { + case -1: fprintf (stderr,"LaserPrint(): Memory allocation failed\n"); break; + case -2: fprintf (stderr,"LaserPrint(): Error writing output file\n"); break; + } + + /* Bei Fehlern geht's hier raus */ + /* Handle wieder in den Orginalzustand versetzen */ + if (OutputBuf) free(OutputBuf); + if (Buf) free(Buf); + if (PX) free(PX); + if (CompBuf) { free(CompBuf); CompBuf=0; } + + ResetPrinter (); +} + + +void GrPrintGetDefaultOptions ( struct GrPrintOptionsType * opt ) + { + *opt=DefaultSettings; + } + + +void GrPrintGetCurrentOptions ( struct GrPrintOptionsType * opt ) + { + *opt=Settings; + } + + +void GrPrintSetOptions ( struct GrPrintOptionsType * opt ) + { + Settings.Quality = opt->Quality<0 || opt->Quality>2 + ? 0 : opt->Quality; + Settings.Shingling = opt->Shingling<0 || opt->Shingling>2 + ? 0 : opt->Shingling; + Settings.Depletion = opt->Depletion<0 || opt->Depletion>2 + ? 1 : opt->Depletion; + Settings.MediaType = opt->MediaType<0 || opt->MediaType>4 + ? 0 : opt->MediaType; + } + + + + +/****************************************************************************/ +/* */ +/* Modul fuer BGI-Treiber zum Ansprechen des Druckers */ +/* */ +/****************************************************************************/ +/* */ +/* (C) 1990-1993 Ullrich von Bassewitz */ +/* */ +/* Port to DJGPP */ +/* Revision 0.5 98/01/26 Andris Pavenis (pavenis@acad.latnet.lv) */ + +/* */ +/* $Id: print.cpp 2.6 1995/04/28 16:21:14 Uz Exp $ */ +/* */ +/* $Log: print.cpp $ */ +/* Revision 2.6 1995/04/28 16:21:14 Uz */ +/* Umstellung auf PCX-Treiber. */ +/* */ +/* Revision 2.5 95/04/22 17:34:02 Uz */ +/* Neue Funktionen fuer den Ausdruck, PrintZString, PrintData, kleinere */ +/* Aenderungen bei existierenden Funktionen. */ +/* */ +/* Revision 2.4 94/09/08 14:14:51 Uz */ +/* Kleinere Aenderungen zur Einsparung von ein paar Bytes. */ +/* */ +/* Revision 2.3 93/08/01 20:53:10 Uz */ +/* Neues Format mit DPMI-Support */ +/* */ + +/****************************************************************************/ +/* */ +/* Variable */ +/* */ +/****************************************************************************/ + + +/* Ausgabepuffer und Deklarationen dazu */ +static BYTE *OutputBuf; /* Der Puffer */ +static WORD OutputBufFill = 0; /* Anzahl Zeichen im Puffer */ + +/* Handle auf das geschrieben wird */ +static WORD OutputHandle = 4; + +/* Merker fuer die Flags des Printer-Devices */ +WORD PrinterFlags; + + +/****************************************************************************/ +/* Code */ +/****************************************************************************/ + + + +static BOOLEAN InitPrinter (BYTE * Buf, int BufSize, int Handle) +/* Stellt das Ausgabegeraet auf "binary" um und prueft gleichzeitig, ob das */ +/* Handle 4 ok (offen) ist. Der aktuelle Zustand wird gemerkt und bei Post */ +/* wiederhergestellt. Buf wird als Puffer fuer die Ausgabe verwendet und */ +/* muss PrintBufSize Bytes gross sein. ACHTUNG: Buf muss bis zum Aufruf von */ +/* ResetPrinter gueltig sein! */ +{ + /* Puffer und Handle uebernehmen */ + OutputBuf = Buf; + OutputBufFill = 0; +# ifdef __MSDOS__ + PrinterFlags = setmode (Handle,O_BINARY); +# endif + OutputHandle = Handle; + return TRUE; +} + + +static void ResetPrinter (void) +/* Stellt den orginalen Zustand des Ausgabegeraets wieder her. */ +{ +# ifdef __MSDOS__ + setmode (OutputHandle,PrinterFlags); +# endif +} + + + +static void Flush (void) +/* Schreibt den Ausgabepuffer leer. Muss am Ende eines Ausdrucks aufgerufen */ +/* werden. Springt PrintAbortLabel an bei Fehlern. */ +{ + if (OutputBufFill > 0) { + if (write (OutputHandle, OutputBuf, OutputBufFill) != OutputBufFill) { + /* Fehler beim Schreiben, Fehleraussprung */ + longjmp (PrintAborted, -2); + } + /* Puffer ist wieder leer */ + OutputBufFill = 0; + + memset (OutputBuf,0,PrintBufSize); + } +} + + + +static void PrintByte (BYTE B) +/* Gibt ein Byte auf den Drucker (bzw. in den Ausgabepuffer) aus. */ +/* Springt PrintAbortLabel an bei Fehlern. */ +{ + /* Pruefen ob noch Platz im Puffer ist, wenn Nein Puffer leeren */ + if (OutputBufFill == PrintBufSize) { + /* Puffer ist voll, leeren */ + Flush (); + } + /* Neues Byte in den Puffer schreiben */ + OutputBuf [OutputBufFill++] = B; +} + + + +static void PrintData (BYTE * Data, unsigned Size) +/* Gibt Daten auf den Drucker (bzw. in den Ausgabepuffer) aus. */ +/* Springt PrintAbortLabel an bei Fehlern. */ +{ + int i; + for (i=0; i + +#ifndef __GRX20_H_INCLUDED__ +#include +#endif + +/* */ +/* Datentyp BOOLEAN */ +/* */ +typedef unsigned char BOOLEAN; +#define TRUE 1 +#define OK TRUE +#define FALSE 0 + +/* */ +/* Diverse andere Datentypen mit festen Bit-Groessen */ +/* */ +/* +>>>>> These types should be mapped to the GRX internal types GR_int..u <<<<< +*/ +typedef unsigned int WORD; +typedef unsigned char BYTE; +typedef unsigned long DWORD; + + +/****************************************************************************/ +/* */ +/* Macros */ +/* */ +/****************************************************************************/ + +/* NULL Macro */ +#ifndef NULL +#define NULL 0 +#endif + +/* Die Farbtabelle wird (da nicht verwendet) als Moeglichkeit zur Einstellung*/ +/* von diversen Daten von aussen benutzt. Sie heisst daher nicht ColorTable */ +/* (wie im SVGA-Treiber), sondern Settings (fuer die aktuelle Tabelle) und */ +/* DefaultSettings (fuer die Default-Einstellungen). */ + +/* Defines zum Zugriff auf die Elemente von Settings und DefaultSettings */ +#define djDefQuality (DefaultSettings.Quality) +#define djDefShingling (DefaultSettings.Shingling) +#define djDefDepletion (DefaultSettings.Depletion) +#define djDefMediaType (DefaultSettings.MediaType) +#define djQuality (Settings.Quality) +#define djShingling (Settings.Shingling) +#define djDepletion (Settings.Depletion) +#define djMediaType (Settings.MediaType) + + +/* RGB Palette. */ +struct RGBEntry { + BYTE R, G, B; +}; + +/****************************************************************************/ +/* Konstante fuer das Flags Byte von _DST */ +/****************************************************************************/ + +#define pfIsEpson 0x01 /* Epson-Modus */ + +/* Nadeldrucker-Flags */ +#define pfReverse 0x02 /* Nadelnummerierung umdrehen (EPSON) */ + +/* Deskjet-Flags */ +#define pfSeparateBlack 0x02 /* Separate Schwarz-Plane (Deskjet) */ +#define pfDoCompression 0x04 /* TIFF Pacbits Kompression durchfuehren */ +#define pfHasPalette 0x08 /* RGB Palette ja/nein */ + + +/* Anzahl Druckermodi */ +#define MaxModes 43 + + +/****************************************************************************/ +/* Grund-Deskriptor fuer einen Druckermodus */ +/****************************************************************************/ + +/* Die folgende struct enthaelt die Grund-Werte bzw. Funktionen, die sich */ +/* nie aendern. Jeder Treiber kann spezielle Funktionen am Ende hinzufuegen.*/ + +struct _DST { + + WORD XDPI; /* Aufloesung in X-Richtung*/ + WORD YDPI; /* Aufloesung in Y-Richtung*/ + WORD XInch; /* Groesse X in Inch * 1000*/ + WORD YInch; /* Groesse Y in Inch * 1000*/ + + WORD ColorCount; /* Anzahl Farben des Modus*/ + BYTE ColorBits; /* Anzahl Bit in denen ein Pixel codiert ist */ + BYTE Flags; /* Diverse bitmapped Flags */ + + char *Name; /* Name des Modes */ + + void (*Print) ( struct _DST * , int ); + /*void (*Print) (); *//* Druck-Routine */ + + /* Member functions, die obige Flags auswerten, alle inline! */ + /*BOOLEAN IsEpson () const { return Flags & pfIsEpson; } */ + /*BOOLEAN Reverse () const { return Flags & pfReverse; } */ + /*BOOLEAN SeparateBlack () const { return Flags & pfSeparateBlack; } */ + /*BOOLEAN DoCompression () const { return Flags & pfDoCompression; } */ + /*BOOLEAN HasPalette () const { return Flags & pfHasPalette; } */ + + }; + +#define IsEpson(x) (x->Flags & pfIsEpson) +#define Reverse(x) (x->Flags & pfReverse) +#define hasSeparateBlack(x) (x->Flags & pfSeparateBlack) +#define DoCompression(x) (x->Flags & pfDoCompression) +#define HasPalette(x) (x->Flags & pfHasPalette) + +/* Der Zeiger auf die aktuelle DST*/ +/* extern struct _DST *DSTPtr; */ +/* Die Tabelle mit den Zeigern auf die Modi*/ +extern struct _DST *DSTTable [MaxModes]; + + +/* Groesse des Ausgabepuffers*/ +#define PrintBufSize 1024 + + +/*****************************************************************************/ +/* Dot matrix printers related procedures */ +/*****************************************************************************/ +/* */ +/* Die folgende Struktur enthaelt einen Device-Status-Block. Die ersten */ +/* Werte muessen immer dieselben sein, da sie vom Grafik-Modul so erwartet */ +/* werden. Im Anschluss kommen eigene Variablen, die von Drucker zu Drucker */ +/* bzw. besser von Treiber zu Treiber verschieden sein koennen. */ +/* */ +/*****************************************************************************/ + + +struct EpsonDST { + + struct _DST DST; /* Orginal-DST */ + + BYTE ColBytes; /* Anzahl Bytes / Druckerspalte */ + BYTE PassCount; /* Wie oft ueberdrucken */ + + char *LineFeed1; /* Normaler Linefeed */ + char *LineFeed2; /* Linefeed zwischen Ueberdrucken */ + + char *GraphicsOn; /* Grafik einschalten (mit Init) */ + char *GraphicsOff; /* Grafik ausschalten */ + + char *PreBytes; /* String vor Grafik-Daten */ + char *PostBytes; /* String nach Grafik-Daten */ + +}; + +/****************************************************************************/ +/* */ +/* Universelle Ausgaberoutine fuer Nadeldrucker. */ +/* */ +/* Parameter: */ +/* (keine) */ +/* */ +/* Ergebnisse: */ +/* (keine) bzw. hoffentlich ein Ausdruck... */ +/* */ +/****************************************************************************/ + +void EpsonPrint ( struct _DST * DSTPtr , int PRNHandle ); +/* Universelle Drucker-Routine fuer Nadeldrucker */ + + +/****************************************************************************/ +/* Laser and DeskJet printers related procedures */ +/****************************************************************************/ +/* */ +/* Die folgende Struktur enthaelt fuer den LaserJet angepassten Device- */ +/* Status Block. */ +/* */ +/****************************************************************************/ + + +struct LJDST { + + struct _DST DST; /* Orginal-DST */ + char *GraphicsOn; /* Grafik einschalten (mit Init) */ + +}; + + + + +void LaserPrint ( struct _DST * DSTPtr , int PRNHandle ); + + +#endif diff --git a/thirdparty/grx249/addons/print/printer.doc b/thirdparty/grx249/addons/print/printer.doc new file mode 100644 index 0000000..406be49 --- /dev/null +++ b/thirdparty/grx249/addons/print/printer.doc @@ -0,0 +1,1047 @@ + + + PRINTER.BGI - BGI Treiber fr Drucker + + Version 4.00 vom Oktober 1995 + + (C) 1990-1995 by Ullrich von Bassewitz + Zwehrenbhlstraáe 33 + D-72070 Tbingen + + E-Mail: uz@ibb.schwaben.com + + + + + + +0. Vorwort + +Alle Rechte an der hier beschriebenen Software sowie der Dokumentaton liegen +beim Autor. Die Verwendung von PRINTER.BGI in eigenen Programmen ist frei, +sowohl fr private als auch fr kommerzielle Zwecke. Beachten Sie aber bitte +folgendes: + + Da die Verwendung von PRINTER.BGI kostenlos ist, erfolgt der Einsatz auf + auschlieáliche Gefahr des Anwenders. Jede Haftung fr direkte, indirekte, + verursachte oder gefolgte Sch„den, die durch die Verwendung von + PRINTER.BGI entstehen k”nnen, ist ausgeschlossen. + +PRINTER.BGI darf unter folgenden Bedingungen beliebig weitergegeben werden: + + * Die Weitergabe geschieht im kompletten Paket mit Dokumentation und + Beispielprogrammen. + * Die Weitergabe geschieht kostenlos. Dies bedeutet insbesondere, daá der + Treiber nicht ohne meine vorherige schriftliche Genehmigung auf CD-ROMS + vertrieben werden darf, genauso sind Mailboxen/FTP-Server ausgeschlossen, + bei denen der Zugang zum Treiber nicht frei fr jedermann ist. + + + +1. Einleitung + +Das Borland Graphics Interface (kurz BGI genannt) ist eine ger„teunabh„ngige +Schnittstelle zur Ausgabe von Grafiken auf (fast) beliebigen Ausgabeger„ten. Zu +den Borland-Compilern werden aber ausschlieálich Treiber fr Grafik-Karten +mitgeliefert. + +PRINTER.BGI ist ein zus„tzlicher Treiber, mit dem Grafik auf einer Vielzahl von +Druckern ausgegeben werden kann. Dabei wird (im Gegensatz zu Hardcopys) die +volle Aufl”sung des Druckers ausgenutzt. + +Untersttzt werden beide Borland-Compiler (also Turbo-Pascal und Borland-C++), +sowie die folgenden Drucker: + + * Zum HP-LaserJet II kompatible Drucker. + * Zum HP-LaserJet IV kompatible Drucker. Der Treiber untersttzt bei diesem + Drucker die zus„tzlich verfgbare Aufl”sung von 600 DPI. + * Der HP DeskJet 500 und Abk”mmlinge. + * Der HP DeskJet 500C und Nachfolger (z.B. HP DJ 550C). Hier werden 8 Farben + untersttzt. + * HP PaintJet XL (nur 8 Farben). + * Nadeldrucker der Serien FX und LQ von EPSON sowie dazu kompatible. Dazu + geh”ren z.T. auch Laser- und Tintenstrahldrucker, z.B. der BJ-300 und BJ330 + von Canon. + * NEC P6/P6+/P60. Diese Drucker sind prinzipiell EPSON kompatibel, + unterscheiden sich jedoch im Modus 360 * 360 DPI und verfgen zus„tzlich + noch ber die M”glichkeit zum Ausdruck in Farbe. + * IBM Proprinter X24 und kompatible. + * Benutzerdefinierte Nadeldrucker (ber separat zu erstellende + Definitionsdateien). + +PRINTER.BGI untersttzt alle im "Device Drivers Toolkit" angegebenen Funktionen +einschliesslich FloodFill. Da keiner der untersttzten Farbdrucker ber eine +einstellbare Palette verfgt, sind jedoch die Paletten-Funktionen nicht +verfgbar. + +Der Treiber ist gleichzeitig auch im neuen Format verfgbar, das ben”tigt wird, +wenn das Programm im Protected-Mode arbeitet. N„heres dazu weiter unten. + + + +2. Anforderungen + +2.1 Drucker + +Hardware-Voraussetzung ist ein Drucker der zu einer der oben erw„hnten Familien +geh”rt oder dazu kompatibel ist. Sollten Sie einen Nadeldrucker besitzen bei dem +das nicht der Fall ist, lesen Sie bitte das Kapitel ber benutzerdefinierte Modi +weiter unten. Bitte beachten Sie, daá nicht alle Drucker alle Modi untersttzen. +Speziell die Modi mit Aufl”sungen von 360 * 360 DPI sind nicht auf allen +Nadeldruckern verfgbar. + + + +2.2 Rechner + +Prinzipiell reicht ein XT-kompatibler Rechner zur Benutzung von PRINTER.BGI +aus. Da jedoch relativ groáe Datenmengen bewegt werden wird die Verwendung erst +ab einem AT-kompatiblen Rechner wirklich sinnvoll. Sind weder EMS noch XMS +in ausreichendem Umfang vorhanden (siehe Abschnitt 2.4: Speicher), so ist +die Verwendung einer schnellen Platte anzuraten. + + + +2.3 Compiler + +Der Treiber arbeitet problemlos mit allen Compilern ab Version 6.0 (Turbo +Pascal) bzw. Version 2.0 (Borland-C++) zusammen. + + + +2.4 Speicher + +Da das Grafik-Paket eine beliebige Positionierung des Grafik-Cursors zul„át, und +zudem Funktionen zum Rcklesen von Daten existieren (GetPixel, GetImage etc.), +muá der Treiber das komplette Bild bis zur Ausgabe zwischenspeichern. Dies +geschieht + + - im Real-Mode: Entweder im EMS-Speicher, im XMS-Speicher oder auf Platte. + + - im Protected-Mode: Im DPMI-Speicher oder auf Platte. N„heres siehe + Abschnitt 7. + +PRINTER.BGI entscheidet sich je nach vorhandener Hard- und Software +selbstst„ndig fr eine dieser M”glichkeiten, wobei er (in dieser Reihenfolge) +die Verwendungsm”glichkeit von EMS, XMS (bzw. DPMI-Speicher) und Platte prft. +Die Daten k”nnen dabei nicht aufgeteilt werden k”nnen (also z.B. Verwendung von +200 KB EMS, 89.5 KB XMS und der Rest auf Platte). Kann keines der oben genannten +Speichermedien genug Speicher zur Verfgung stellen, so liefert PRINTER.BGI +einen Fehlercode von -12 (grIOError) zurck. + +Wieviel Speicher fr eine bestimmte Aufl”sung ben”tigt wird, kann nach folgender +Formel berechnet werden, wobei je nach Speichermedium evtl. auf volle 16 oder 64 +KB aufgerundet werden muá: + + Breite * X-Aufl”sung (DPI) * H”he * Y-Aufl”sung (DPI) * Farbbits + ------------------------------------------------------------------ Byte + 8 + +Der Wert von Farbbits betr„gt 1 fr die Schwarz-Weiá Modi, 3 beim DeskJet +500C/550C mit 8 Farben und 4 bei den Farbmodi der Nadeldrucker. + +Die Gr”áe des bedruckbaren Bereichs ist je nach Modus unterschiedlich: In den +Nadeldrucker-Modi betr„gt die Breite immer 8, die L„nge immer 11 Zoll. In den +LaserJet-Modi betr„gt die Breite 7.8 Zoll (neuere Laserdrucker haben des ”fteren +Probleme mit der vollen Breite von 8 Zoll), die L„nge 10.5 Zoll. Beim DeskJekt +500C/550C betr„gt die Breite 8 Zoll und die L„nge 10.33 Zoll. + + + +3. Die Einbindung des Treibers + +Die Einbindung des Treibers erfolgt ber die Prozedur InstallUserDriver. Der +erste Parameter von InstallUserDriver ist der Name des Treibers (ohne die +Endung), der zweite Parameter ist ein Zeiger auf eine Detect-Routine, die prfen +kann, ob der Rechner mit einer fr den Treiber passenden Hardware ausgestattet +ist (was im Falle von Druckern natrlich schlecht geht, weswegen ein NIL-Zeiger +bergeben wird). + +Ist der von InstallUserDriver zurckgegebene Integer-Wert < 0, so ist ein Fehler +aufgetreten, ist er gr”áer, so stellt er die Nummer des Treibers dar. + +Der folgende Ausschnitt zeigt, wie eine Einbindung in Turbo-Pascal aussehen +kann. + + VAR + GraphMode, GraphDriver : INTEGER; + + BEGIN + { Grafiktreiber installieren } + GraphDriver := InstallUserDriver ('PRINTER', NIL); + IF (GraphDriver < 0) THEN BEGIN + { Fehlerbehandlung } + ... + END; + + { Gewnschten Modus festlegen und Grafik einschalten } + GraphMode := 2; { Modus 2, 180*180 DPI } + InitGraph (GraphDriver, GraphMode, PathToDriver); + ... + END; + +Soll der Treiber als OBJ-Datei in das ausfhrbare Programm eingebunden werden, +so mssen folgende Schritte in genau dieser Reihenfolge durchgefhrt werden: + + * "Installierung" des Treibers mit InstallUserDriver. Diese Prozedur teilt + dem Grafik-Kernel mit, daá es einen Treiber mit dem Namen "PRINTER" gibt. + + * "Registrierung" des Treibers mit RegisterBGIDriver. Diese Prozedur teilt + dem Grafik-Kernel mit, daá der Treiber (falls er verwendet werden sollte) + nicht von Platte zu laden ist, sondern daá er sich bereits im Speicher + befindet. + + * Einschalten des Grafikmodus mit InitGraph. + +Der folgende Code-Ausschnitt zeigt beispielhaft, wie die Einbindung erfolgen +kann. Es wird vorausgesetzt, daá der Treiber zuvor mittels + + BINOBJ PRINTER.BGI PRINTER.OBJ PRINTERDRIVER + +in eine OBJ-Datei umgewandelt worden ist (C-Programmierer: Das entsprechende +Programm heiát BGIOBJ und ist etwas komplizierter zu bedienen. Es mssen beim +Aufruf alle Parameter angegeben werden! Dazu einfach BGIOBJ ohne Parameter +aufrufen und nach Hilfestellung vorgehen.) + + + { Der Treiber als Prozedur deklariert } + PROCEDURE PRINTERDriver; FAR; EXTERNAL; + + { Einbinden des Treibers } + {$L PRINTER.OBJ} + + VAR + GraphDriver : INTEGER; { Nummer des Treibers } + + + PROCEDURE Install; + { Fhrt die Installation des Treibers durch } + BEGIN + GraphDriver := InstallUserDriver ('PRINTER', NIL); + IF (GraphDriver < 0) THEN Error; + IF (RegisterBGIDriver (@PRINTERDriver) < 0) THEN Error; + END; + + + BEGIN { Hauptprogramm } + .... + Install; + GraphMode := 1; { Autodetect } + InitGraph (GraphDriver, GraphMode, ''); + { Fehlerauswertung muss folgen } + .... + END. + + +Weitere Details finden Sie im Handbuch zur jeweiligen Programmiersprache. + + + +4. Grafik-Modi + +Folgende Grafik-Modi sind verfgbar: + + Wert Bedeutung Anmerkungen + -------------------------------------------------------------------------- + 0 EPSON FX (8-Nadel), 240 * 72 DPI + 1 EPSON FX (8-Nadel), 240 * 216 DPI + 2 EPSON LQ (24-Nadel), 180 * 180 DPI + 3 EPSON LQ (24-Nadel), 360 * 180 DPI + 4 EPSON LQ (24-Nadel), 360 * 360 DPI + 5 NEC P6, P6+, P60 (24-Nadel), 360 * 360 DPI (1) + 6 IBM Proprinter X24 (24-Nadel), 180 * 180 DPI + 7 IBM Proprinter X24 (24-Nadel), 360 * 180 DPI + 8 EPSON LQ / NEC P6, P6+, 180 * 180 DPI, 9 Farben (6) + 9 EPSON LQ / NEC P6, P6+, 360 * 180 DPI, 9 Farben (6) + 10 EPSON LQ, 360 * 360 DPI, 9 Farben (6) + 11 NEC P6, P6+, 360 * 360 DPI, 9 Farben (6) + 12 Reserviert + 13 Benutzerdefinierter Modus 1 (2) + 14 Benutzerdefinierter Modus 2 (2) + 15 Benutzerdefinierter Modus 3 (2) + 16 HP LJ, 75 * 75 DPI (3) + 17 HP LJ, 100 * 100 DPI (3) + 18 HP LJ, 150 * 150 DPI (3) + 19 HP LJ, 300 * 300 DPI (3) + 20 HP LJ, 75 * 75 DPI, keine Kompression (4) + 21 HP LJ, 100 * 100 DPI, keine Kompression (4) + 22 HP LJ, 150 * 150 DPI, keine Kompression (4) + 23 HP LJ, 300 * 300 DPI, keine Kompression (4) + 24 HP DJ 500C, 75 * 75 DPI, 8 Farben, A4 + 25 HP DJ 500C, 100 * 100 DPI, 8 Farben, A4 + 26 HP DJ 500C, 150 * 150 DPI, 8 Farben, A4 + 27 HP DJ 500C, 300 * 300 DPI, 8 Farben, A4 + 28 HP DJ 550C, 75 * 75 DPI, 8 Farben, echtes Schwarz (7) + 29 HP DJ 550C, 100 * 100 DPI, 8 Farben, echtes Schwarz (7) + 30 HP DJ 550C, 150 * 150 DPI, 8 Farben, echtes Schwarz (7) + 31 HP DJ 550C, 300 * 300 DPI, 8 Farben, echtes Schwarz (7) + 32 HP LJ IV, 600 * 600 DPI (5) + 33 EPSON LQ (24-Nadel), 180 * 180 DPI, DIN A3 + 34 EPSON LQ (24-Nadel), 360 * 180 DPI, DIN A3 + 35 EPSON LQ (24-Nadel), 360 * 360 DPI, DIN A3 + 36 NEC P7 (24-Nadel), 360 * 360 DPI, DIN A3 (1) + 37 EPSON LQ (24-Nadel), 180 * 180 DPI, DIN A3, 9 Farben (6) + 38 EPSON LQ (24-Nadel), 360 * 180 DPI, DIN A3, 9 Farben (6) + 39 EPSON LQ (24-Nadel), 360 * 360 DPI, DIN A3, 9 Farben (6) + 40 NEC P7 (24-Nadel), 360 * 360 DPI, DIN A3, 9 Farben (1) (6) + 41 HP PaintJet 300 XL, 75 * 75 DPI, 8 Farben, A3 (8) + 42 HP PaintJet 300 XL, 100 * 100 DPI, 8 Farben, A3 (8) + 42 HP PaintJet 300 XL, 150 * 150 DPI, 8 Farben, A3 (8) + 42 HP PaintJet 300 XL, 300 * 300 DPI, 8 Farben, A3 (8) + + + +Alle anderen Modi erzeugen den Fehler -10 (grInvalidMode). + +Anmerkungen zur Tabelle: + +(1) +In den niedrigeren Aufl”sungen ist der Drucker EPSON kompatibel, d.h. es k”nnen +die Modi 2 und 3 zus„tzlich verwendet werden. + +(2) +Siehe Abschnitt 8 (Benutzerdefinierte Modi). + +(3) +Žltere Modelle des LaserJet II (und Nachbauten) beherrschen z.T. die vom Treiber +verwendete Kompressionsmethode nicht. Bei Problemen ist auf die (ansonsten +„quivalenten) Modi 20-23 auszuweichen, die keine Kompression verwenden. + +(4) +Die Modi entsprechen den Modi 16-19, es wird jedoch keine Kompression der an den +Drucker gesandten Daten durchgefhrt. Aus diesem Grund ist der Ausdruck +normalerweise langsamer. + +(5) +Der Drucker LaserJet IV kann auch mit geringeren Aufl”sungen in den Modi 16-19 +betrieben werden. + +(6) +Der Drucker muá dazu mit einer Farboption ausgestattet sein. + +(7) +Der Drucker verfgt ber eine separate Schwarz-Patrone und wird vom Treiber so +angesteuert, daá fr schwarze Fl„chen diese Patrone verwendet wird. Beachten Sie +dazu bitte die Hinweise im Abschnitt 6.4. + +(8) +Diese Modi entsprechen bis auf die Blattgr”áe den Modi 24-27. Der PaintJet +300 XL l„át sich auch in diesen Modi betreiben, wenn nur eine Ausgabe im +DIN A4 Format gewnscht ist. + + + +5. Ausgabe der Grafik + +Die Ausgabe der Grafik erfolgt beim abschlieáenden CloseGraph. Sollen mehrere +Seiten ausgegeben werden, so ist eine Ausgabe auch mittels Aufruf von +ClearDevice m”glich. Nach Aufruf dieser Funktion ist die Zeichenfl„che wieder +leer. + +Der Treiber schreibt die Daten auf das MS-DOS Datei-Handle Nr. 4, das +normalerweise (von COMMAND.COM) vor Start des Programms mit dem Ger„t PRN +(also dem ersten Drucker) verbunden wird. Das Device wird vor der Ausgabe auf +"raw data" um- und danach wieder in den Orginalzustand geschaltet. + +Die Verwendung eines Standard-Handles hat den Vorteil, daá die Ausgabe leicht in +eine Datei oder auf einen anderen Ausgabeport umgeleitet werden kann (letzteres +z.B. mit Hilfe des MODE-Kommandos). Beispiele zur Umleitung finden Sie in den +Beispielprogrammen. + + + +6. Besonderheiten der verschiedenen Drucker + +6.1 LaserJet II + +Bei „lteren Modellen dieses Druckers ist die vom Treiber verwendete Methode zur +Kompression der Druckdaten nicht implementiert. Nachbauten verhalten sich hier +unterschiedlich. Bei Problemen sind anstelle der Modi 16-19 die Modi 20-23 zu +verwenden. + + + +6.2 DeskJet 500 + +Beim DeskJet 500 und Nachfolgern (auch DeskJet 500C im Schwarz-Weiá Modus) +k”nnen Ausdruckparameter eingestellt werden. N„heres dazu steht in Abschnitt +9 (Optionen). + + + +6.3 DeskJet 500C + +Der Drucker DeskJet 500C und seine Nachfolger untersttzten 8 Farben, die aus +den drei Grundfarben Cyan, Gelb und Magenta zusammengesetzt werden. Da es sich +hier um eine subtraktive Palette handelt, unterscheiden sich die Farben von +denen des Bildschirmadapters (der eine additive Palette besitzt). Aus diesem +Grund k”nnen die vordefinierten Farb-Konstanten nicht verwendet werden. (Rein +syntaktisch k”nnen diese Konstanten natrlich verwendet werden, d.h. der +Compiler meldet keinen Fehler, das Ergebnis sieht dann jedoch etwas anders aus +als erwartet.) Die Zuordnung der Farben entnehmen Sie bitte der folgenden +Tabelle: + + Wert Farbe + ------------------- + 0 Weiá + 1 Cyan + 2 Magenta + 3 Blau + 4 Gelb + 5 Grn + 6 Rot + 7 Schwarz + +Zus„tzlich k”nnen beim DeskJet 500C Ausdruckparameter ver„ndert werden, n„heres +dazu steht in Abschnitt 9 (Optionen). + + + +6.4 DeskJet 550C + +Der DeskJet 550C verfgt im Gegensatz zu seinem Vorl„ufer ber eine separate +Schwarzpatrone, die gleichzeitig verwendet werden kann. In den Modi 28-31 ist +es m”glich, diese separate Patrone zum Druck schwarzer Fl„chen zu benutzen. +Beachten Sie dazu bitte den folgenden Hinweis aus dem Handbuch des Herstellers +(im Orginal Englisch, von mir frei bersetzt): + + Vorsicht ist geboten, wenn schwarze und farbige Tinte gleichzeitig auf + einer Seite verwendet wird. Die Tinten aus der Farb-Patrone haben eine + andere chemische Zusammensetzung als die Tinte aus der Schwarz-Patrone. + Wenn beide in direkten Kontakt miteinander kommen, kann es passieren, daá + sich die schwarze merklich mit der farbigen Tinte mischt. Das Problem + f„llt am meisten auf, wenn viel Tinte aufgetragen wird. Die Verwendung + von Shingling beim Ausdruck kann dieses Ph„nomen verringern oder ganz + eliminieren. 25% Shingling kann die Qualit„t des Ausdrucks verbessern, + 50% Shingling kann das Problem evtl. ganz zum Verschwinden bringen. + Alternativ kann mit geringerem Tintenauftrag gearbeitet werden (dnnere + Linien oder Fllmuster), oder es kann durch geeigneten Ausdruck dafr + gesorgt werden, daá sich die Fl„chen mit unterschiedlichen Tinten nicht + berhren. + +Weiterhin sind alle Hinweise aus Abschnitt 6.3 gltig. + + + +6.5 PaintJet 300 XL + +Beim PaintJet 300 XL handelt es sich um einen A3 Farbdrucker, der auch mehr +als 8 Farben untersttzt. Dieser Drucker l„sst sich in den Modi 24-27 (A4) +und 41-44 (A3) betreiben. Modi mit mehr als 8 Farben stehen derzeit nicht +zur Verfgung. Fr die Farbzuordnung, siehe Abschnitt 6.3. + + + +6.6 HP DeskJet 1200 + +Der Drucker msste die Modi 24-27 "verstehen". Aufgund fehlender Hardware ist +das bisher aber ungetestet. Fr Rckmeldungen w„re ich dankbar. + + + +6.7 Canon BJ-300 und BJ-330 + +Dieser Tintenstrahldrucker emuliert entweder die EPSON Drucker LQ850 bzw. LQ1050 +oder den IBM Proprinter X24. Je nach Einstellung am Drucker lassen sich deshalb +die Modi 2-4 oder 8-9 des Treibers verwenden. Die Einstellung des +Emulationsmodus ist im Druckerhandbuch beschrieben. + + + +6.8 Canon BJC-800 + +Als Emulationsmodus sollte "EPSON LQ-2550" gew„hlt werden. Der Drucker +untersttzt Farbe, die Farbmodi der EPSON-Drucker k”nnen verwendet werden. + + + +6.9 NEC P6, P6+, P7, P7+, EPSON LQ Serie + +In den entsprechend gekennzeichneten Modi kann der Drucker als Farbdrucker +verwendet werden. Dazu ist jedoch eine Hardware-Aufrstung des Druckers +notwendig. + +Die Farbzuordnung entnehmen Sie bitte folgender Tabelle: + + Wert Farbe + ------------------- + 0 Weiá + 1 Cyan + 2 Magenta + 3 Blau + 4 Gelb + 5 Grn + 6 Rot + 7 Braun + 8 Schwarz + + + + +7. Der Treiber im Protected-Mode + +Aufgrund der Eigenheiten des Protected-Mode muáte Borland das Format der Treiber +beim šbergang auf die Version 7.0 von Turbo-Pascal „ndern. Die neuen Versionen +des Grafik-Kernels erkennen jedoch die alten Treiber und behandeln diese +korrekt, vorausgesetzt, das Programm l„uft im Real-Mode. Die folgende Auflistung +zeigt, welcher Treiber mit welchem Compiler kompatibel ist: + + * Turbo-Pascal bis Version 6.0 und Borland-C++ bis Version 3.1 laufen nur im + Real-Mode und kennen nur das alte Format der Treiber. + + * Borland-Pascal 7.0 l„uft sowohl im Real- als auch im Protected-Mode und + erkennt beide Treiberformate. Der Betrieb im Protected-Mode ist jedoch nur + mit dem neuen Format m”glich. + + * Turbo-Pascal 7.0 ist eine abgespeckte Version von Borland-Pascal 7.0 und + l„uft nur im Real-Mode, erkennt aber beide Treiberformate. + +Im Paket befinden sich der Treiber in beiden Formaten. Der Treiber fr das neue +(DPMI-) Format tr„gt jedoch einen anderen Namen (PRINTER.BP7) und muá vor +Gebrauch umbenannt werden. + +Im Real-Mode unterscheiden sich beide Versionen des Treibers nicht. Im +Protected-Mode ergeben sich jedoch folgende Einschr„nkungen: + + * Der Treiber untersttzt kein EMS und kein XMS. Es kann nur in den + DPMI-Speicher und auf Platte ausgelagert werden. Bei Verwendung von + DPMI-Speicher ist der Treiber dafr wesentlich schneller, da ein direkter + Zugriff erfolgen kann. + + * Der Runtime-Manager von Borland belegt beim Start s„mtlichen verfgbaren + DPMI-Speicher, der dann dem Treiber nicht mehr zur Verfgung steht. Aus + diesem Grund muá dem Runtime-Manager durch Setzen einer Environment-Variable + mitgeteilt werden, welchen Anteil des DPMI-Speichers er freizuhalten hat - + ansonsten wird prinzipiell auf Platte ausgelagert. Dieser Speicher steht + dann aber dem Programm nicht mehr zur Verfgung. (Zumindest nicht ber die + Routinen des Borland-Pakets. šber DPMI-Funktionen kann der Speicher + selbstverst„ndlich belegt werden.) Soll DPMI-Speicher benutzt werden, so ist + vor Start des Programms auf DOS-Ebene + + SET RTM=EXTLEAVE nnnn + + einzugeben, wobei nnnn die Gr”áe (in KB) des vom Runtime-Managers nicht zu + belegenden Speichers ist. Um z.B. 1MB Speicher fr den Treiber freizuhalten, + wird + + SET RTM=EXTLEAVE 1024 + + verwendet. N„heres dazu lesen Sie bitte in Ihrem Compiler-Handbuch nach. + +ACHTUNG: Borland hat mehrere Monate lang eine Version 7.00 des Borland-Pascal +Compilers vertrieben die extrem fehlerhaft war (die sp„tere, fehlerbereinigte +Version tr„gt die Versionsnummer 7.01). Falls Sie im Besitz dieser „lteren +Version sind, sollten Sie auf jeden Fall ein Upgrade bei Borland erstehen (auch +wenn dieses nicht kostenlos ist). Die korrekte Version erkennen Sie an der +Uhrzeit der letzten Žnderung der Datei: Die richtige Version des Compilers zeigt +hier 07:01, die falsche 07:00. + + + +8. Benutzerdefinierte Modi + +PRINTER.BGI l„sst sich ber Drucker-Definitionsdateien an fast alle Nadeldrucker +anpassen. Dazu dient ein kleines šbersetzungsprogramm zusammen mit einigen dafr +reservierten Modi im Treiber. Bei der Initialisierung sucht der Treiber nach den +Dateien PRINTER1.PDF, PRINTER2.PDF und PRINTER3.PDF (fr die Modi 13-15). (Das +".PDF" steht fr "Printer Definition File".) Der Treiber sucht in mehreren +Verzeichnissen nach diesen Dateien, und zwar: + + * Im aktuellen Verzeichnis. + * Im Verzeichnis, in dem sich die EXE-Datei befindet. Dieser Mechanismus + funktioniert erst ab DOS 3.0. + * Im Verzeichnis, das die Environment-Variable BGIPATH angibt. Sie k”nnen + diese Variable auf DOS-Ebene mit + + set BGIPATH=X:\YYY\ZZZ + + setzen. + +Findet PRINTER.BGI eine oder mehrere dieser Dateien so wird/werden sie geladen +und Modus wird entsprechend der in der Datei enthaltenen Angaben untersttzt. + +Zur Erstellung dieser Dateien gehen Sie wie folgt vor: + + * Erstellen Sie mit Ihrem Text-Editor eine ASCII-Datei mit den erforderlichen + Steuersequenzen. Lesen Sie dazu die Anleitung (PDFCOMP.DOC) und orientieren + Sie sich an den beigelegten Beispieldateien. + * šbersetzen Sie die ASCII-Datei mit Hilfe des Programms PDFCOMP in eine + Bin„rdatei. + * Benennen Sie die Datei um in PRINTERx.PDF, je nachdem welchen Modus Sie + verwenden wollen. + * Kopieren Sie die Datei in eines der oben genannten Verzeichnisse. Der + Treiber l„dt diese Datei bei der Initialisierung und untersttzt den Modus + dann wie einen eingebauten. + * Falls Sie mir und anderen Benutzern einen Gefallen tun wollen: Senden Sie + mir die Definitionsdatei (ASCII-Datei) zu, damit ich sie anderen Benutzern + zur Verfgung stellen kann. Vermerken Sie dazu in der Datei bitte Ihren + Namen (fr Rckfragen) und die genaue Bezeichnung des Druckers, fr den die + Datei erstellt wurde. + +Findet der Treiber eine oder beide Dateien nicht in den oben genannten +Verzeichnissen, so gibt der Treiber den Fehlercode grInvalidMode (-10) zurck. +Je nachdem welche Dateien vorhanden sind k”nnen die Modi 13-15 ganz normal +angesprochen werden. + + + +9. Einstellen von Druck-Optionen + +Der Drucker untersttzt bei Ausgabe auf Drucker vom Typ DeskJet (in den Modi +16-31) Optionen zur Beeinflussung der Ausgabequalit„t. Bei Nadel- oder +Laserdruckern haben die hier besprochenen Einstellungen keine Auswirkung, die +entsprechenden Befehle werden ignoriert. Die Optionen werden ber den Treiber +durch einen "Miábrauch" der Funktion SetAllPalette verfgbar gemacht. Diese +Funktion ist speziell auf EGA-Karten bzw. VGA-Karten im 16-Farb Modus +zugeschnitten und hat bereits bei Super-VGA's im Modus mit 256 Farben keine +Bedeutung mehr, so daá die Verwendung zur šbergabe eines Kontrollblocks an den +Treiber nahe lag. + +šblicherweise wird eine Variable vom Typ PaletteType bergeben, deren +Deklaration wie folgt lautet: + + CONST + MaxColor = 15; + + TYPE + PaletteType = RECORD + Size : BYTE; + Colors : ARRAY [0..MaxColor] OF SHORTINT; + END; + +Size entspricht der Anzahl der Farben des Druckers, muá also in den Schwarzweiá- +Modi auf 2, in den Farbmodi des DeskJet dagegen auf 8 gesetzt werden. Im Array +Colors sind die ersten Size Bytes gltig und werden bei einem Aufruf vom +Grafik-Kernel an den Treiber weitergereicht. + +Die Bedeutung der Werte im Array Colors ergeben sich aus den folgenden Tabellen: + +M”gliche Ausdruck-Optionen beim DeskJet 500: + + Index Defaultwert Bedeutung + ----------------------------------------------------------------- + 0 Reserviert + 1 0 Ausgabequalit„t: + 0: Qualit„t wie am Drucker eingestellt + 1: Draft + 2: High + + +M”gliche Ausdruck-Optionen beim DeskJet 500C/550C: + + Index Defaultwert Bedeutung + ----------------------------------------------------------------- + 0 Reserviert + 1 0 Ausgabequalit„t: + 0: Qualit„t wie am Drucker eingestellt + 1: Draft + 2: High + 2 0 Shingling: + 0: Keines + 1: 50% Shingling (2 Druck-Durchg„nge) + 2: 25% Shingling (4 Druck-Durchg„nge) + 3 1 Depletion: + 0: Keine + 1: 25% + 2: 50% + 4-7 Reserviert + +Beim "Shingling" wird die Ausgabe einer Zeile in mehrere Durchg„nge aufgeteilt, +um der Farbe zwischenzeitlich eine M”glichkeit zum Antrocknen zu geben und so +eine saubere Schichtung der Farben zu gew„hrleisten. Der Defaultwert ist 0 (kein +Shingling), die Werte 1 bzw. 2 verlangsamen die Ausgabe, da mehr Durchg„nge +erforderlich sind. + +Beim "Depletion"-Verfahren wird nach einem (mir unbekannten - ich zitiere nur +das Handbuch) gleichnamigen Algorithmus ein Teil der Farb-Pixel entfernt um +Farbe zu sparen und die Qualit„t der Druckausgabe zu verbessern. Default ist +hier 1 (25% Depletion). Hinweis: Es werden keinesfalls die angegebene +Prozentzahl an Pixeln entfernt, es handelt sich um die Vorbesetzung einer +Variable im o.g. Algorithmus. + +Die Einstellung der Druck-Optionen erfolgt durch Deklaration einer Variablen +(oder typisierten Konstanten) vom Typ PaletteType, Zuweisung der Werte Aufruf +von SetAllPalette mit der deklarierten Variablen als Parameter. Werte die sich +nicht „ndern sollen (dazu geh”ren auch die mit "Reserviert" gekennzeichneten +Eintr„ge) sollten mit -1 belegt werden (siehe Compiler-Handbuch). + +ACHTUNG: Sie mssen diese Werte nicht neu einstellen - der Treiber verwendet +dann die unter "Defaultwert" stehenden Vorgaben. Diese Werte sind die +Standard-Werte des Druckers und haben normalerweise eine saubere Druck-Ausgabe +zur Folge. Fr spezielle Anwendungen oder kommerzielle Programme kann es jedoch +u.U. sinnvoll sein, die Ausgabe zu beeinflussen. + + + +10. Fehler im UNIT Graph + +10.1 Fehlercodes + +Durch einen Fehler im UNIT Graph werden die negativen Fehlercodes, die der +Treiber zurckgibt positiv an die Anwendung durchgereicht: Das Status-Feld des +Treibers, ber das die Fehlercodes rckgemeldet werden ist 1 Byte groá. Da die +Fehlercodes negative Werte sind, h„tte dieses Feld als SHORTINT deklariert +werden mssen. Die Entwickler haben dies aber bersehen und das Feld als BYTE +deklariert, was dazu fhrt, daá die Fehlercodes nicht vorzeichenrichtig +erweitert werden. Abhilfe schafft eine Abfrage wie in der folgenden Abbildung. +Unter Umst„nden kann GraphResult entsprechend berdefiniert werden. + + VAR + Result : INTEGER; + + BEGIN + { Grafik einschalten } + InitGraph (GraphDriver, GraphMode, ''); + + { Fehlercode auswerten. Durch den Typecast werden die + obersten 8 Bits abgeschnitten, durch die Zuweisung + an einen INTEGER wird vorzeichenrichtig erweitert. + } + Result := SHORTINT (GraphResult); + IF (Result <> 0) THEN BEGIN + Writeln (GraphErrorMsg (Result)); + Halt; + END; + .... + END; + + + +10.2 SetGraphMode + +Die Funktion SetGraphMode arbeitet fehlerhaft wenn Modusnummern gr”áer 10 +angegeben werden. Von der Verwendung dieser Funktion wird abgeraten. Verwenden +Sie stattdessen Aufrufe von CloseGraph und InitGraph. Siehe auch den folgenden +Abschnitt. + + + +10.3 RestoreCRTMode und SetGraphMode + +Die Funktionen arbeiten unter Borland-Pascal 7.0 im Protected-Mode nicht +korrekt, u.U. ist ein GP Fault die Folge. + + + +10.4 RegisterBGIDriver + +Manuell geladene (d.h. als .OBJ-File eingebundene oder aus einem Resource-File +geladene) Treiber mssen unter Borland-Pascal 7.0 im Protected-Mode auf eine +Adresse zu liegen kommen, die einen Offset von 0 hat. Ansonsten bricht das +Grafik-Kernel beim zweiten Aufruf von InitGraph u.U. das Programm mit einer +Fehlermeldung ab. + +Um sicherzustellen, daá der Treiber auf einer Adresse mit Offset 0 zu liegen +kommt, wenn er als .OBJ-Datei eingebunden wird, erstellen Sie bitte ein +separates Modul, in dem sich ausschlieálich der Treiber befindet. Exportieren +Sie die Adresse des Treibers und fhren Sie die Initialisierung der Grafik in +einem anderen Modul durch. + + + +11. Zusammenfassung + +Nachdem in den vorigen Abschnitten nach und nach immer mehr Details dargestellt +wurden, sollen diese Informationen hier nochmals kurz zusammengefaát und anhand +eines (diesmal vollst„ndigen) Beispiels in Turbo-Pascal demonstriert werden. +Weitere Beispiele (auch in C) sind im Paket enthalten. + + * Die Einbindung des Treibers geschieht mittels der Prozedur + InstallUserDriver, die die Nummer des Treibers zurckliefert. Diese Prozedur + muá vor InitGraph aufgerufen werden. + + * Die Abfrage von Fehlern muá ber den in Abschnitt 10 beschriebenen Umweg + erfolgen, falls die Nummer des Fehlers ausgewertet werden soll (z.B. bei + Aufruf von GraphErrorMsg zur Ausgabe einer Meldung). + + * Die Ausgabe der Grafik erfolgt beim Aufruf von ClearDevice sowie beim + abschliessenden CloseGraph. + + * Die Einstellung von Ausdruck-Optionen oder die Erkl„rungen zum Datei-Handle + k”nnen Sie fr den Anfang getrost vergessen. Der Ausdruck funktioniert + normalerweise auch ohne daá Sie diese Optionen neu einstellen. (Falls Sie + nicht ein sehr speziell konfiguriertes System haben. Aber dann wissen Sie ja + sowieso, was mit diesen Dingen gemeint ist.) + + +Komplettes Beispiel in Turbo-Pascal: + + VAR + GraphDriver, GraphMode : INTEGER; + Result : INTEGER; + + BEGIN + { Einbinden des Treibers } + GraphDriver := InstallUserDriver ('PRINTER', NIL); + IF (GraphDriver < 0) THEN BEGIN + { Fehlerbehandlung } + .... + END; + + { Modus setzen und Einschalten der Grafik } + GraphMode := 11; { Modus 11, LaserJet 300 DPI } + InitGraph (GraphDriver, GraphMode, ''); + { Fehler auswerten } + Result := SHORTINT (GraphResult); + IF (Result <> 0) THEN BEGIN + { Fehlerbehandlung } + Writeln (GraphErrorMsg (Result)); + Halt; + END; + + { Grafik-Operationen } + Line (0, 0, GetMaxX, GetMaxY); + .... + + { Grafik ausgeben } + ClearDevice; + + { Neue Grafik } + Line (0, 0, GetMaxX, GetMaxY); + .... + + { Grafik ausgeben und beenden } + CloseGraph; + END; + + + +12. Zus„tzliche Informationen + +Dieser Abschnitt enth„lt zus„tzliche Informationen, die u.U. von Nutzen sein +k”nnen. Weitere Hinweise entnehmen Sie bitte der Datei README.TXT. + + * Die Auswahl der Speicherm”glichkeit erfolgt in der Reihenfolge der damit + erzielbaren Geschwindigkeit: + + - Der schnellste Zugriff wird durch die Verwendung von DPMI-Speicher im + Protected-Mode erreicht. + + - Direkt danach folgt EMS-Speicher, wobei der Unterschied zu DPMI fast + vollst„ndig auf die zur Seitenumschaltung ben”tigte Zeit zurckzufhren + ist und sich je nach verwendetem EM-Manager unterscheiden kann. + + - Bei Verwendung von XMS wird kein Speicher eingeblendet, sondern die + Daten werden zwischen normalem und erweiterten Speicher hin- und + herkopiert, was zus„tzlich Zeit ben”tigt. + + - Die Verwendung einer tempor„ren Datei auf Platte ist umso langsamer, je + h”her die Aufl”sung ist (weil der interne Puffer des Treibers einen + immer kleineren Bereich der Zeichenfl„che umfaát). Vor allem bei den + hohen Aufl”sungen (ab 180 * 360 DPI) sollte die Verwendung von Platte + wenn m”glich vermieden werden. (Wobei sich dies nicht verallgemeinern + l„sst: Wird ein gutes Plattenpufferprogramm verwendet, ist u.U. auch in + den h”heren Aufl”sungen die Ausdruckzeit akzeptabel. Versuche in den + DOS-Boxen von OS/2 haben gezeigt, daá auch im Modus 19 mit 300 DPI noch + Ausdrucke m”glch sind, die ben”tigte Zeit betr„gt ca. 3-4 Minuten.) + + * Die tempor„re Datei bei Auslagerung auf Platte wird beim Aufruf von + InitGraph im aktuellen Verzeichnis angelegt. Soll diese Datei in einem + bestimmten Verzeichnis liegen, so ist vor Aufruf von InitGraph dieses + Verzeichnis zum aktuellen Verzeichnis zu machen. Sp„tere Wechsel des + Verzeichnisses haben keinen Einfluss mehr auf die Lage der tempor„ren Datei. + Die Auswertung einer Environment-Variable (wie z.B. TMP oder TEMP) erschien + mir problematisch, da diese Variable oft auf eine RAM-Disk mit beschr„nkter + Kapazit„t zeigt. Durch o.g. Verfahren ist es jedoch m”glich, das Verzeichnis + festzulegen, in das die tempor„re Datei gelegt wird. + + * Da Rckmeldungen des Treibers nach durchgefhrten Operationen durch das + Borland Grafik-Modul gr”átenteils nicht ausgewertet werden, ist die Rckgabe + eines Fehlercodes bei nicht eingeschaltetem Drucker nicht m”glich. Sie + sollten daher vor Beginn der Grafik-Ausgabe den Drucker-Status prfen. + PRINTER.BGI bricht bei Druckerfehlern (also auch bei ausgeschaltetem + Drucker) den Ausdruck sofort ab. + + * CloseGraph ruft automatisch immer RestoreCRTMode auf, was zur Folge hat, daá + der Text-Bildschirm gel”scht wird. Sie mssen daher eventuelle Inhalte + retten und nach CloseGraph wiederherstellen (oder kurzfristig die + Modus-Umschaltung verhindern, indem Sie einen eigenen Handler fr den + Interrupt 10h installieren). + + * Fr die Verwendung von EMS wird eine Untersttzung der EMS 3.2 kompatiblen + Funktionen vorausgesetzt (dies wird von allen mir bekannten EMS-Treibern + erfllt). Fr den XMM (Etended emory anager) erwartet PRINTER.BGI + zumindest eine Versionnummer von 2.0, das DPMI-Interface muá Version 0.9 + oder neuer entsprechen. + + * Bei Auslagerung auf Platte berprft der Treiber bei der Initialisierung den + zur Verfgung stehenden Platz auf dem aktuellen Laufwerk. Falls eine + Auslagerung in EMS oder XMS nicht m”glich ist, muá also zum Zeitpunkt des + Aufrufs von InitGraph gengend Platz auf der Platte vorhanden sein. + + * Wird das Programm vor dem Aufruf von CloseGraph unterbrochen, erh„lt der + Treiber keine Gelegenheit mehr, das von ihm verwendete Speichermedium + "aufzur„umen". Dies kann zum Beispiel beim Debuggen eines Programms + passieren, wenn das Programm nicht bis zu Ende ausgefhrt wird. Die Folge + davon sind belegte EMS-Seiten, belegter XMS-Speicher oder nicht gel”schte + tempor„re Dateien auf der Festplatte. Vor allem letztere sind „rgerlich, + weil sie beim Neustart des Systems nicht gel”scht werden und ob ihrer Gr”áe + recht schnell die Platte fllen. Diese Dateien werden vom Treiber als + versteckte (Attribut Hidden) Dateien im aktuellen Verzeichnis angelegt. Sie + sollten also nach einem Programm-Abbruch prfen, ob solche Dateien vorhanden + sind (erkennbar an Namen wie AACGHFKL) und diese - falls vorhanden - + l”schen. + + * Die Aufl”sungen mit 240 * 72 DPI und 240 * 216 DPI funktionieren nicht auf + 24-Nadeldruckern! Auf den ersten Blick scheinen auch die 24-Nadler ber + diese Modi zu verfgen. Ein Test zeigt jedoch, daá ber den unteren + Seitenrand hinausgedruckt wird. Dies liegt daran, daá 24-Nadel Drucker diese + Modi simulieren, indem nur jede dritte Nadel verwendet wird. Da der + Nadel-Abstand bei 1/180 Zoll liegt ergibt sich bei Verwendung jeder dritten + Nadel eine vertikale Aufl”sung von 60 DPI (im Gegensatz zu 72 DPI bei den + 8-Nadlern). Aufgrund dieser niedrigeren Aufl”sung beansprucht das Bild in + vertikaler Richtung mehr Platz, was zum šberschreiten des unteren Bildrandes + fhrt. + + * Der Modus 360 * 360 DPI wird nicht von allen Nadeldruckern untersttzt. + Zus„tzlich ist dieser Modus von unterschiedlichen Herstellern auch + unterschiedlich implementiert worden. Falls Ihr Drucker die Demo-Programme + in diesem Modus fehlerhaft ausdruckt, prfen Sie bitte erst anhand Ihres + Druckerhandbuchs, ob Ihr Drucker einen Befehl zum Einstellen des + Zeilenvorschubs in Einheiten von 1/360 Zoll kennt. Wenn dies nicht der Fall + ist, beherrscht Ihr Drucker diesen Modus nicht. Ist es der Fall, vergleichen + Sie den Befehl bitte mit den folgenden beiden: + + Hersteller Steuersequenz + ----------------------------- + EPSON ESC '+' + NEC FS '3' + + Verwenden Sie dann den entsprechenden Modus des Treibers (NEC 360 * 360 oder + EPSON 360 * 360). + + Sollte Ihr Drucker einen v”llig anderen Befehl zur Einstellung verwenden, + mssen Sie eine Drucker-Definitionsdatei fr diesen Modus erzeugen. Lesen + Sie dazu bitte den entsprechenden Abschnitt. + + * In der C-Version existiert eine undokumentierte Variable namens _BGI_auto, + die dazu verwendet werden kann, das L”schen des Bildschirms bei initgraph() + und closegraph() zu verhindern. Diese Variable war im ursprnglichen + BGI-Konzept dafr vorgesehen war, das L”schen des Bildschirms zu + unterdrcken, indem sie vom Treiber (PRINTER.BGI) auf einen "magischen" Wert + gesetzt wird. Aufgrund eines der vielen Fehler im Grafik-Kernel funktioniert + dies jedoch nicht, da das L”schen des Bildschirms vor dem Aufruf des + Treibers geschieht, so daá ein sp„teres Setzen dieser Variable wirkungslos + ist. In der "C"-Version des Grafik-Kernels ist diese Variable jedoch + ”ffentlich zug„nglich und kann so vor dem Einschalten des Grafik-Modus vom + Programm gesetzt werden. Es gibt keine Garantie dafr, daá dieses Vorgehen + mit sp„teren Versionen des Grafik-Kernels kompatibel ist (es ist jedoch + anzunehmen, daá sich an der GRAPHICS Library nicht mehr viel „ndern wird). + Die Variable wird deklariert als + + extern char _BGI_auto; + + Nach der Zuweisung + + _BGI_auto = 0xA5; + + l”scht das Grafik-Kernel den Bildschirm nicht mehr. Diese Variable existiert + auch in der Pascal-Version ist allerdings dort nicht zug„nglich, da der Name + nur innerhalb von Graph bekannt ist. + + * Wenn sowohl der Treiber als auch das Programm EMS verwenden kann es unter + Umst„nden zu Problemen kommen. Das ist vor allem dann der Fall, wenn das + Programm Overlays ins EMS auslagert. Die einfachste M”glichkeit, diese + Schwierigkeiten zu umgehen ist es, einem der beiden die Benutzung des EMS zu + untersagen. Das kann im Fall der Overlays durch Streichen des Aufrufs von + OvrInitEMS geschehen. Soll der Treiber kein EMS verwenden, so ist vor Aufruf + von InitGraph s„mtlicher EMS-Speicher zu belegen. + + * Beim Fllen von komplexen Mustern mit FloodFill kann es u.U. notwendig sein, + den Puffer, den Graph dafr bereitstellt, mit der Prozedur SetGraphBufSize + *vor* dem Aufruf von InitGraph etwas zu vergroessern (Default sind 4KB). + + + +13. Bei Problemen und Fehlern + +Da sich leider in der Vergangenheit gezeigt hat, daá die wenigsten +Schwierigkeiten tats„chlich am Treiber selber liegen, m”chte ich Sie bitten die +folgenden Punkte zu beherzigen: + + * Lesen Sie die komplette Anleitung sowie alle README-Dateien auf der Diskette + nochmals durch. Einige g„ngigere Fehlerquellen sind dort beschrieben. + + * Falls der Treiber bei Ihnen berhaupt nicht funktionieren sollte berprfen + Sie bitte anhand der beigelegten Beispielprogramme ob das Nicht- + Funktionieren an Ihrem Programm oder am Treiber liegt. + + * Versuchen Sie herauszufinden, ob der Fehler evtl. an Ihrer Hardware liegt, + indem Sie Ihr Programm auf einem anderen Rechner testen. + + * Versuchen Sie, herauszufinden, ob eine spezielle Rechnerkonfiguration fr + den Fehler verantwortlich ist. Entfernen Sie dazu Ger„tetreiber aus den + Konfigurationsdateien CONFIG.SYS und AUTOEXEC.BAT. + + * Falls Sie tats„chlich vermuten, einen Fehler im Treiber gefunden zu haben, + versuchen Sie bitte, den Fehler einzukreisen und ein m”glichst kleines + Programm herzustellen, bei dem der Fehler auftritt. Entfernen Sie dazu allen + Code, der nicht unbedingt notwendig fr die Reproduktion des Fehlers ist. + Bitte senden Sie mir dieses Programm zusammen mit einer detailierten + Fehlerbeschreibung zu. + + + +14. Sonstiges + +Bei mir sind weitere BGI-Treiber fr Plotter, fr Super-VGA's und zur Ausgabe +von PCX-Dateien zu denselben Bedingungen erh„ltlich. Die aktuellen Versionen +erhalten Sie per Modem unter der Nummer 07071/440588, 8N1, V32bis. + +Falls Sie Interesse an weiteren Treibern, weiteren untersttzten Druckern usw. +haben, setzen Sie sich bitte mit mir in Verbindung. Speziell Untersttzung von +weiteren Druckern fr den Druckertreiber werden von mir blicherweise zu einem +sehr gnstigen Festpreis durchgefhrt. + + + +15. Dateien im Paket + +Das vorliegende Archiv muá folgende Dateien enthalten: + + +Im Verzeichnis PRINTER + PRINTER.BGI Der BGI-Treiber. + PRINTER.BP7 BGI-Treiber fr Borland-Pascal 7.0. + + +Im Verzeichnis PDFCOMP + PDFCOMP.EXE Der Definitions-Compiler. + PDFCOMP.DOC Die Dokumentation dazu. + *.DEF Diverse Definitionsdateien. + + +Im Verzeichnis PIXFONT + PIXFONT.PAS Modul zur Ausgabe von Pixelfonts beliebiger + Gr”áe. + PIXFONT.DOC Die Dokumentation dazu. + GETFONT.EXE Programm zur Abspeicherung der VGA-Fonts + (in den Gr”áen 8x14 und 8x16) als Datei. + GETFONT.PAS Quelltext dazu. + *.FNT Einige Pixelfonts zur Verwendung mit dem + Modul PixFont. + FONTDEMO.EXE Beispielprogramm zu Anwendung von PIXFONT. + FONTDEMO.PAS Quellcode zu PIXFONT.EXE. + FONTDEMO.DOC Dokumentation zu FONTDEMO. + + +Im Verzeichnis C + DEMO.EXE Kurzes Demo-Programm zur Verwendung des + Treibers. + DEMO.C Der Quellcode dazu. + + +Im Verzeichnis PASCAL + DEMO.EXE Kurzes Demo-Programm zur Verwendung des + Treibers. + DEMO.PAS Der Quellcode dazu. + DEMO2.EXE Ausfhrliches Demo-Programm. + DEMO2.PAS Quelltext zu DEMO.PAS. + + +Im Verzeichnis BGILIB + MAKELIB.BAT Batch-Datei von Herrn Jung-Merkelbach zur + Erzeugung zweier Libraries fr den C-Compiler, + die die kompletten Fonts und Treiber als OBJ- + Dateien enthalten. + diff --git a/thirdparty/grx249/addons/print/printest.c b/thirdparty/grx249/addons/print/printest.c new file mode 100644 index 0000000..fd76f3a --- /dev/null +++ b/thirdparty/grx249/addons/print/printest.c @@ -0,0 +1,78 @@ +#include +#include +#include +#include "grxprint.h" + + +static void displaytext (GrFont *font,char *text,int len); + + +int GRXMain (int argc , char * argv []) + { + int i, j, rc, mc, MaxX, MaxY; + unsigned AspX, AspY; + double Asp, r; + char * text = "Printing example from GRX"; + GrFont * Fnt = GrBuildConvertedFont( + &GrDefaultFont, + (GR_FONTCVT_SKIPCHARS | GR_FONTCVT_RESIZE), + 36, + 72, + ' ', + 'z' + ); + +/* rc = GrPrintSetMode (LQ_180x180); mc = 2; */ +/* rc = GrPrintSetMode (HPLJ_300x300); mc = 2; */ +/* rc = GrPrintSetMode (HPLJ_1200x1200); mc = 2; */ +/* rc = GrPrintSetMode (HPLJ_IV_600x600); mc = 2; */ +/* rc = GrPrintSetMode (HPLJ_300x300_NC); mc = 2; */ + rc = GrPrintSetMode (HPDJ500C_300x300x8_B); mc = 8; + printf ("GrPrintSetMode : rc=%d\n",rc); + + MaxX = GrMaxX (); + MaxY = GrMaxY (); + GrPrintGetAspectRatio (&AspX,&AspY); + Asp = ((double) AspX)/AspY; + printf ("Size : (%d %d)\n",MaxX,MaxY); + + GrBox (0,0,MaxX,MaxY,mc-1); /* Draw box around page */ + GrLine (0,MaxY,MaxX,MaxY-30,mc-1); + r = (int) (MaxY/20); + GrEllipse ((int) (r*Asp), (int) r, (int) (r*Asp), (int) r, mc-1); + displaytext (Fnt,text,strlen(text)); + + if (mc>2) for (i=0; i<8; i++) + { + int x0 = 50*i; + GrFilledBox (x0,1,x0+30,31,i); + } + + for (i=1; i<14; i++) + { + r = (double) (MaxY*(0.45-0.03*i)); + for (j=0; j<(mc>2 ? 3 : 1); j++) + { + GrEllipse (MaxX/2-100,MaxY/2, + (int) (r*Asp), (int) r, i>=mc ? mc-1 : i); + r--; + } + } + GrPrintToFile ("test.pcl"); +/* GrDoPrinting (); */ + return 0; + } + + +void displaytext (GrFont *font,char *text,int len) +{ + GrTextOption opt; + memset(&opt,0,sizeof(opt)); + opt.txo_font = font; + opt.txo_xalign = GR_ALIGN_LEFT; + opt.txo_yalign = GR_ALIGN_TOP; + opt.txo_direct = GR_TEXT_RIGHT; + opt.txo_fgcolor.v = 1; + opt.txo_bgcolor.v = 0; + GrDrawString(text,len,100,100,&opt); +} diff --git a/thirdparty/grx249/addons/print/prndata.c b/thirdparty/grx249/addons/print/prndata.c new file mode 100644 index 0000000..32c8425 --- /dev/null +++ b/thirdparty/grx249/addons/print/prndata.c @@ -0,0 +1,1655 @@ +/*****************************************************************************/ +/* */ +/* PRNDATA.CPP */ +/* */ +/* (C) 1994 by Ullrich von Bassewitz */ +/* Zwehrenbuehlstrasse 33 */ +/* 72070 Tuebingen */ +/* */ +/* E-Mail: uz@ibb.schwaben.de */ +/* */ +/*****************************************************************************/ + +/* Revision 1.4 1998/02/05 Andris Pavenis */ +/* Modified for use under DJGPP */ +/* */ +/* (C) 1994 Ullrich von Bassewitz */ +/* */ +/* $Id: prndata.cpp 1.3 1995/04/28 16:20:53 Uz Exp $ */ +/* */ +/* $Log: prndata.cpp $ */ +/* Revision 1.3 1995/04/28 16:20:53 Uz */ +/* Umstellung auf PCX-Treiber. */ +/* */ +/* Revision 1.2 95/04/22 17:31:52 Uz */ +/* Neuer Modus 41 fuer DeskJet 1200 C. */ +/* */ +/* Revision 1.1 94/09/08 09:33:42 Uz */ +/* Initial revision */ +/* */ + + +#include "grxprn00.h" + +/*************** Original values from printer BGI driver */ +/*#define NP_A4_SIZEX 11000*/ +/*#define NP_A4_SIZEY 8000*/ +/*#define LJ_A4_SIZEX 10334*/ +/*#define LJ_A4_SIZEY 7800*/ +/*#define NP_A3_SIZEX 15600*/ +/*#define NP_A3_SIZEY 11400*/ +/*********************************************************/ +#define NP_A4_SIZEX 11000 +#define NP_A4_SIZEY 8000 +#define LJ_A4_SIZEX 10334 +#define LJ_A4_SIZEY 7760 +#define NP_A3_SIZEX 15600 +#define NP_A3_SIZEY 11400 +/*********************************************************/ + +/****************************************************************************/ +/* 8-Nadel Modus 240 * 72 DPI */ +/****************************************************************************/ + +static struct EpsonDST EPSON240x72 = { + + /* DPI in X-und Y-Richtung*/ + { 72, 240, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x10""EPSON 240x72 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 1, 1, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x04\x1B\x4A\x18\r", /* ESC 'J' 24 cr*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + NULL, /* Nicht vorhanden*/ + + /* Einschalten der Grafik*/ + "\x05\x1B\x40\x1B\x4F\r", /* ESC '@' ESC 'O' \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x03\x80\x07", /* ESC '*' 03 1920*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ + +}; + + + +/****************************************************************************/ +/* 8-Nadel Modus 240 * 216 DPI */ +/****************************************************************************/ + +static struct EpsonDST EPSON240x216 = { + + /* DPI in X-und Y-Richtung*/ + { 216, 240, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x11""EPSON 240x216 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 1, 3, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x04\x1B\x4A\x16\r", /* ESC 'J' 22 cr*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + "\x04\x1B\x4A\x01\r", /* ESC 'J' 1 cr*/ + + /* Einschalten der Grafik*/ + "\x05\x1B\x40\x1B\x4F\r", /* ESC '@' ESC 'O' \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x03\x80\x07", /* ESC '*' 03 1920*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ + +}; + + + +/****************************************************************************/ +/* 24-Nadel Modus 180 * 180 DPI */ +/****************************************************************************/ + +static struct EpsonDST EPSON180x180 = { + + /* DPI in X-und Y-Richtung*/ + { 180, 180, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x11""EPSON 180x180 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 1, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x04\x1B\x4A\x18\r", /* ESC 'J' 24 cr*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + NULL, /* Nicht vorhanden*/ + + /* Einschalten der Grafik*/ + "\x05\x1B\x40\x1B\x4F\r", /* ESC '@' ESC 'O' \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x27\xA0\x05", /* ESC '*' 39 1440*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ + +}; + + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 180 DPI */ +/****************************************************************************/ + +static struct EpsonDST EPSON360x180 = { + + /* DPI in X-und Y-Richtung*/ + { 180, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x11""EPSON 360x180 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 1, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x04\x1B\x4A\x18\r", /* ESC 'J' 24 cr*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + NULL, /* Nicht vorhanden*/ + + /* Einschalten der Grafik*/ + "\x05\x1B\x40\x1B\x4F\r", /* ESC '@' ESC 'O' \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x40\x0B", /* ESC '*' 40 2880*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 360 DPI, EPSON */ +/****************************************************************************/ + +static struct EpsonDST EPSON360x360 = { + + /* DPI in X-und Y-Richtung*/ + { 360, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x11""EPSON 360x360 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 2, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x05\x1B\x2B\x2F\x0D\x0A", /* ESC '+' 47 cr lf*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + "\x05\x1B\x2B\x01\x0D\x0A", /* ESC '+' 01 cr lf*/ + + /* Einschalten der Grafik*/ + "\x05\x1B\x40\x1B\x4F\r", /* ESC '@' ESC 'O' \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x40\x0B", /* ESC '*' 40 2880*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 360 DPI, NEC P6 */ +/****************************************************************************/ + +static struct EpsonDST NEC360x360 = { + + /* DPI in X-und Y-Richtung*/ + { 360, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x12""NEC P6 360x360 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 2, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x05\x1C\x33\x2F\x0D\x0A", /* FS '3' 47 cr lf*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + "\x05\x1C\x33\x01\x0D\x0A", /* FS '3' 01 cr lf*/ + + /* Einschalten der Grafik*/ + "\x05\x1B\x40\x1B\x4F\r", /* ESC '@' ESC 'O' \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x40\x0B", /* ESC '*' 40 2880*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + + +/****************************************************************************/ +/* IBM Proprinter X24, 180 * 180 DPI */ +/****************************************************************************/ + +static struct EpsonDST IBMPro180x180 = { + + /* DPI in X-und Y-Richtung*/ + { 180, 180, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x1A""IBM Proprinter 180x180 DPI", + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 1, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x05\x1B\x33\x18\r\n", /* ESC '3' 24 cr lf*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + NULL, /* Nicht vorhanden*/ + + /* Einschalten der Grafik*/ + "\x0C\x1B\x4F\x1B\x5B\x5C\x04\x00\x00\x00\x00\xB4\r", + + /* Ausschalten der Grafik*/ + "\x0C\x1B\x32\x1B\x5B\x5C\x04\x00\x00\x00\x00\xD8\f", + + /* Code vor den Grafik-Bytes*/ + "\x06\x1B\x5B\x67\xE1\x10\x0B", /* ESC '[' 'g' 4321 11*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ + +}; + + + +/****************************************************************************/ +/* IBM Proprinter X24, 360 * 180 DPI */ +/****************************************************************************/ + +static struct EpsonDST IBMPro360x180 = { + + /* DPI in X-und Y-Richtung*/ + { 180, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x1A""IBM Proprinter 360x180 DPI", + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 1, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x05\x1B\x33\x18\r\n", /* ESC '3' 24 cr lf*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + NULL, /* Nicht vorhanden*/ + + /* Einschalten der Grafik*/ + "\x0C\x1B\x4F\x1B\x5B\x5C\x04\x00\x00\x00\x00\xB4\r", + + /* Ausschalten der Grafik*/ + "\x0C\x1B\x32\x1B\x5B\x5C\x04\x00\x00\x00\x00\xD8\f", + + /* Code vor den Grafik-Bytes*/ + "\x06\x1B\x5B\x67\xC1\x21\x0C", /* ESC '[' 'g' 8641 12*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ + +}; + + + +/****************************************************************************/ +/* 24-Nadel Modus 180 * 180 DPI EPSON Farbe */ +/****************************************************************************/ + +static struct EpsonDST EPSON180x180C = { + + /* DPI in X-und Y-Richtung*/ + { 180, 180, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 9, 4, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x18""EPSON 180x180 DPI Color", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 1, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x04\x1B\x4A\x18\r", /* ESC 'J' 24 cr*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + NULL, /* Nicht vorhanden*/ + + /* Einschalten der Grafik*/ + "\x05\x1B\x40\x1B\x4F\r", /* ESC '@' ESC 'O' \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x27\xA0\x05", /* ESC '*' 39 1440*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ + +}; + + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 180 DPI EPSON Farbe */ +/****************************************************************************/ + +static struct EpsonDST EPSON360x180C = { + + /* DPI in X-und Y-Richtung*/ + { 180, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 9, 4, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x17""EPSON 360x180 DPI Color", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 1, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x04\x1B\x4A\x18\r", /* ESC 'J' 24 cr*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + NULL, /* Nicht vorhanden*/ + + /* Einschalten der Grafik*/ + "\x05\x1B\x40\x1B\x4F\r", /* ESC '@' ESC 'O' \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x40\x0B", /* ESC '*' 40 2880*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 360 DPI, EPSON Farbe */ +/****************************************************************************/ + +static struct EpsonDST EPSON360x360C = { + + /* DPI in X-und Y-Richtung*/ + { 360, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 9, 4, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x17""EPSON 360x360 DPI Color", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 2, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x05\x1B\x2B\x2F\x0D\x0A", /* ESC '+' 47 cr lf*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + "\x05\x1B\x2B\x01\x0D\x0A", /* ESC '+' 01 cr lf*/ + + /* Einschalten der Grafik*/ + "\x05\x1B\x40\x1B\x4F\r", /* ESC '@' ESC 'O' \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x40\x0B", /* ESC '*' 40 2880*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 360 DPI, NEC P6 Farbe */ +/****************************************************************************/ + +static struct EpsonDST NEC360x360C = { + + /* DPI in X-und Y-Richtung*/ + { 360, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 9, 4, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x18""NEC P6 360x360 DPI Color", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 2, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x05\x1C\x33\x2F\x0D\x0A", /* FS '3' 47 cr lf*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + "\x05\x1C\x33\x01\x0D\x0A", /* FS '3' 01 cr lf*/ + + /* Einschalten der Grafik*/ + "\x05\x1B\x40\x1B\x4F\r", /* ESC '@' ESC 'O' \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x40\x0B", /* ESC '*' 40 2880*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + + +/****************************************************************************/ +/* HP-Laserdrucker 75*75 DPI */ +/****************************************************************************/ + +static struct LJDST HPLJ75 = { + + /* DPI in X-und Y-Richtung*/ + { 75, 75, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfDoCompression, + + /* Name des Modus*/ + "\x0E""HPLJ 75x75 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Festlegen der Grafik*/ + "\x1B*t75R" /* ESC * t 75 R*/ + +}; + + + +/****************************************************************************/ +/* HP-Laserdrucker 100*100 DPI */ +/****************************************************************************/ + +static struct LJDST HPLJ100 = { + + /* DPI in X-und Y-Richtung*/ + { 100, 100, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfDoCompression, + + /* Name des Modus*/ + "\x10""HPLJ 100x100 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Festlegen der Grafik*/ + "\x1B*t100R" /* ESC * t 100 R*/ + +}; + + + +/****************************************************************************/ +/* HP-Laserdrucker 150*150 DPI */ +/****************************************************************************/ + +static struct LJDST HPLJ150 = { + + /* DPI in X-und Y-Richtung*/ + { 150, 150, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfDoCompression, + + /* Name des Modus*/ + "\x10""HPLJ 150x150 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Festlegen der Grafik*/ + "\x1B*t150R" /* ESC * t 150 R*/ + +}; + + + +/****************************************************************************/ +/* HP-Laserdrucker 300*300 DPI */ +/****************************************************************************/ + +static struct LJDST HPLJ300 = { + + /* DPI in X-und Y-Richtung*/ + { 300, 300, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfDoCompression, + + /* Name des Modus*/ + "\x10""HPLJ 300x300 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Festlegen der Grafik*/ + "\x1B*t300R" /* ESC * t 300 R*/ + +}; + + + +/****************************************************************************/ +/* HP-Laserdrucker 75*75 DPI ohne Kompression */ +/****************************************************************************/ + +static struct LJDST HPLJ75O = { + + /* DPI in X-und Y-Richtung*/ + { 75, 75, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + 0, + + /* Name des Modus*/ + "\x0E""HPLJ 75x75 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Festlegen der Grafik*/ + "\x1B*t75R" /* ESC * t 75 R*/ + +}; + + + +/****************************************************************************/ +/* HP-Laserdrucker 100*100 DPI ohne Kompression */ +/****************************************************************************/ + +static struct LJDST HPLJ100O = { + + /* DPI in X-und Y-Richtung*/ + { 100, 100, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + 0, + + /* Name des Modus*/ + "\x10""HPLJ 100x100 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Festlegen der Grafik*/ + "\x1B*t100R" /* ESC * t 100 R*/ + +}; + + + +/****************************************************************************/ +/* HP-Laserdrucker 150*150 DPI ohne Kompression */ +/****************************************************************************/ + +static struct LJDST HPLJ150O = { + + /* DPI in X-und Y-Richtung*/ + { 150, 150, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + 0, + + /* Name des Modus*/ + "\x10""HPLJ 150x150 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Festlegen der Grafik*/ + "\x1B*t150R" /* ESC * t 150 R*/ + +}; + + + +/****************************************************************************/ +/* HP-Laserdrucker 300*300 DPI ohne Kompression */ +/****************************************************************************/ + +static struct LJDST HPLJ300O = { + + /* DPI in X-und Y-Richtung*/ + { 300, 300, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + 0, + + /* Name des Modus*/ + "\x10""HPLJ 300x300 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Festlegen der Grafik*/ + "\x1B*t300R" /* ESC * t 300 R*/ + +}; + + + +/****************************************************************************/ +/* HP-Laserdrucker 600*600 DPI */ +/****************************************************************************/ + +static struct LJDST HPLJ600 = { + + /* DPI in X-und Y-Richtung*/ + { 600, 600, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfDoCompression, + + /* Name des Modus*/ + "\x10""HPLJ 600x600 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Festlegen der Grafik*/ + "\x1B*t600R" /* ESC * t 300 R*/ + +}; + + + +/****************************************************************************/ +/* 75*75 DPI HP-DJ, Farbe */ +/****************************************************************************/ + +static struct LJDST HPDJ75 = { + + /* DPI in X-und Y-Richtung*/ + { 75, 75, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 8, 3, + + /* Flags*/ + pfDoCompression, + + /* Name des Modus*/ + "\x0F""HPDJ500C 75 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Einschalten der Grafik*/ + "\x1B*t75R" /* ESC * t 75 R*/ + +}; + + +/****************************************************************************/ +/* 100*100 DPI HP-DJ, Farbe */ +/****************************************************************************/ + +static struct LJDST HPDJ100 = { + + /* DPI in X-und Y-Richtung*/ + { 100, 100, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 8, 3, + + /* Flags*/ + pfDoCompression, + + /* Name des Modus*/ + "\x10""HPDJ500C 100 DPI", /* Name des Modus*/ + + /* Druckeroutine */ + LaserPrint }, + + /* Einschalten der Grafik*/ + "\x1B*t100R" /* ESC * t 100 R*/ + +}; + + +/****************************************************************************/ +/* 150*150 DPI HP-DJ, Farbe */ +/****************************************************************************/ + +static struct LJDST HPDJ150 = { + + /* DPI in X-und Y-Richtung*/ + { 150, 150, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 8, 3, + + /* Flags*/ + pfDoCompression, + + /* Name des Modus*/ + "\x10""HPDJ500C 150 DPI", /* Name des Modus*/ + + /* Druckeroutine */ + LaserPrint }, + + /* Einschalten der Grafik*/ + "\x1B*t150R" /* ESC * t 150 R*/ + +}; + + +/****************************************************************************/ +/* 300*300 DPI HP-DJ, Farbe */ +/****************************************************************************/ + +static struct LJDST HPDJ300 = { + + /* DPI in X-und Y-Richtung*/ + { 300, 300, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 8, 3, + + /* Flags*/ + pfDoCompression, + + /* Name des Modus*/ + "\x10""HPDJ500C 300 DPI", /* Name des Modus*/ + + /* Druckeroutine */ + LaserPrint }, + + /* Einschalten der Grafik*/ + "\x1B*t300R" /* ESC * t 300 R*/ + +}; + + +/****************************************************************************/ +/* 75*75 DPI HP-DJ, Farbe, Schwarzabtrennung */ +/****************************************************************************/ + +static struct LJDST HPDJ75S = { + + /* DPI in X-und Y-Richtung*/ + { 75, 75, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 8, 3, + + /* Flags*/ + pfDoCompression | pfSeparateBlack, + + /* Name des Modus*/ + "\x0F""HPDJ500C 75 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Einschalten der Grafik*/ + "\x1B*t75R" /* ESC * t 75 R*/ + +}; + + +/****************************************************************************/ +/* 100*100 DPI HP-DJ, Farbe, Schwarzabtrennung */ +/****************************************************************************/ + +static struct LJDST HPDJ100S = { + + /* DPI in X-und Y-Richtung*/ + { 100, 100, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 8, 3, + + /* Flags*/ + pfDoCompression | pfSeparateBlack, + + /* Name des Modus*/ + "\x10""HPDJ500C 100 DPI", /* Name des Modus*/ + + /* Druckeroutine */ + LaserPrint }, + + /* Einschalten der Grafik*/ + "\x1B*t100R" /* ESC * t 100 R*/ + +}; + + +/****************************************************************************/ +/* 150*150 DPI HP-DJ, Farbe, Schwarabtrennung */ +/****************************************************************************/ + +static struct LJDST HPDJ150S = { + + /* DPI in X-und Y-Richtung*/ + { 150, 150, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 8, 3, + + /* Flags*/ + pfDoCompression | pfSeparateBlack, + + /* Name des Modus*/ + "\x10""HPDJ500C 150 DPI", /* Name des Modus*/ + + /* Druckeroutine */ + LaserPrint }, + + /* Einschalten der Grafik*/ + "\x1B*t150R" /* ESC * t 150 R*/ + +}; + + +/****************************************************************************/ +/* 300*300 DPI HP-DJ, Farbe, Schwarzabtrennung */ +/****************************************************************************/ + +static struct LJDST HPDJ300S = { + + /* DPI in X-und Y-Richtung*/ + { 300, 300, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 8, 3, + + /* Flags*/ + pfDoCompression | pfSeparateBlack, + + /* Name des Modus*/ + "\x10""HPDJ500C 300 DPI", /* Name des Modus*/ + + /* Druckeroutine */ + LaserPrint }, + + /* Einschalten der Grafik*/ + "\x1B*t300R" /* ESC * t 300 R*/ + +}; + + +/****************************************************************************/ +/* 24-Nadel Modus 180 * 180 DPI, DIN A3 */ +/****************************************************************************/ + +/* Achtung: Die Anzahl der Pixel in X- sowie Y-Richtung muss durch 8 teilbar*/ +/* sein. Aus diesem Grund sind beim Druckerstring vor den Grafikbytes 2048*/ +/* Bytes anstelle (der sich aus Aufloesung/Blattgroesse ergebenden) 2052*/ +/* eingetragen.*/ + +static struct EpsonDST EPSON180x180_A3 = { + + /* DPI in X-und Y-Richtung*/ + { 180, 180, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x14""EPSON 180x180 DPI A3", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 1, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x04\x1B\x4A\x18\r", /* ESC 'J' 24 cr*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + NULL, /* Nicht vorhanden*/ + + /* Einschalten der Grafik*/ + "\x09\x1B\x40\x1B\x4F\x1B\x43\x00\x10\r", /* ESC '@' ESC 'O' ESC 'C' 0 16 \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x27\x00\x08", /* ESC '*' 39 2048*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ + +}; + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 180 DPI, DIN A3 */ +/****************************************************************************/ + +static struct EpsonDST EPSON360x180_A3 = { + + /* DPI in X-und Y-Richtung*/ + { 180, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x14""EPSON 360x180 DPI A3", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 1, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x04\x1B\x4A\x18\r", /* ESC 'J' 24 cr*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + NULL, /* Nicht vorhanden*/ + + /* Einschalten der Grafik*/ + "\x09\x1B\x40\x1B\x4F\x1B\x43\x00\x10\r", /* ESC '@' ESC 'O' ESC 'C' 0 16 \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x08\x10", /* ESC '*' 40 4104*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 360 DPI, EPSON, DIN A3 */ +/****************************************************************************/ + +static struct EpsonDST EPSON360x360_A3 = { + + /* DPI in X-und Y-Richtung*/ + { 360, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x14""EPSON 360x360 DPI A3", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 2, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x05\x1B\x2B\x2F\x0D\x0A", /* ESC '+' 47 cr lf*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + "\x05\x1B\x2B\x01\x0D\x0A", /* ESC '+' 01 cr lf*/ + + /* Einschalten der Grafik*/ + "\x09\x1B\x40\x1B\x4F\x1B\x43\x00\x10\r", /* ESC '@' ESC 'O' ESC 'C' 0 16 \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x08\x10", /* ESC '*' 40 4104*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 360 DPI, NEC P7, DIN A3 */ +/****************************************************************************/ + +static struct EpsonDST NEC360x360_A3 = { + + /* DPI in X-und Y-Richtung*/ + { 360, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x15""NEC P7 360x360 DPI A3", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 2, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x05\x1C\x33\x2F\x0D\x0A", /* FS '3' 47 cr lf*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + "\x05\x1C\x33\x01\x0D\x0A", /* FS '3' 01 cr lf*/ + + /* Einschalten der Grafik*/ + "\x09\x1B\x40\x1B\x4F\x1B\x43\x00\x10\r", /* ESC '@' ESC 'O' ESC 'C' 0 16 \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x08\x10", /* ESC '*' 40 4104*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + + +/****************************************************************************/ +/* 24-Nadel Modus 180 * 180 DPI, DIN A3, Farbe */ +/****************************************************************************/ + +/* Achtung: Die Anzahl der Pixel in X- sowie Y-Richtung muss durch 8 teilbar */ +/* sein. Aus diesem Grund sind beim Druckerstring vor den Grafikbytes 2048 */ +/* Bytes anstelle (der sich aus Aufloesung/Blattgroesse ergebenden) 2052 */ +/* eingetragen. */ + +static struct EpsonDST EPSON180x180C_A3 = { + + /* DPI in X-und Y-Richtung*/ + { 180, 180, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 9, 4, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x1A""EPSON 180x180 DPI A3 Color", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 1, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x04\x1B\x4A\x18\r", /* ESC 'J' 24 cr*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + NULL, /* Nicht vorhanden*/ + + /* Einschalten der Grafik*/ + "\x09\x1B\x40\x1B\x4F\x1B\x43\x00\x10\r", /* ESC '@' ESC 'O' ESC 'C' 0 16 \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x27\x00\x08", /* ESC '*' 39 2048*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ + +}; + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 180 DPI, DIN A3, Farbe */ +/****************************************************************************/ + +static struct EpsonDST EPSON360x180C_A3 = { + + /* DPI in X-und Y-Richtung*/ + { 180, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 9, 4, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x1A""EPSON 360x180 DPI A3 Color", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 1, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x04\x1B\x4A\x18\r", /* ESC 'J' 24 cr*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + NULL, /* Nicht vorhanden*/ + + /* Einschalten der Grafik*/ + "\x09\x1B\x40\x1B\x4F\x1B\x43\x00\x10\r", /* ESC '@' ESC 'O' ESC 'C' 0 16 \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x08\x10", /* ESC '*' 40 4104*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 360 DPI, EPSON, DIN A3, Farbe */ +/****************************************************************************/ + +static struct EpsonDST EPSON360x360C_A3 = { + + /* DPI in X-und Y-Richtung*/ + { 360, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 9, 4, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x1A""EPSON 360x360 DPI A3 Color", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 2, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x05\x1B\x2B\x2F\x0D\x0A", /* ESC '+' 47 cr lf*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + "\x05\x1B\x2B\x01\x0D\x0A", /* ESC '+' 01 cr lf*/ + + /* Einschalten der Grafik*/ + "\x09\x1B\x40\x1B\x4F\x1B\x43\x00\x10\r", /* ESC '@' ESC 'O' ESC 'C' 0 16 \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x08\x10", /* ESC '*' 40 4104*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + + +/****************************************************************************/ +/* 24-Nadel Modus 360 * 360 DPI, NEC P7, DIN A3, Farbe */ +/****************************************************************************/ + +static struct EpsonDST NEC360x360C_A3 = { + + /* DPI in X-und Y-Richtung*/ + { 360, 360, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + NP_A4_SIZEX, NP_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 9, 4, + + /* Flags*/ + pfIsEpson, + + /* Name des Modus*/ + "\x1B""NEC P7 360x360 DPI A3 Color", /* Name des Modus*/ + + /* Druckeroutine*/ + EpsonPrint }, + + /* Bytes pro Druckerspalte und Durchgaenge*/ + 3, 2, + + /* Linefeed1, d.h. normaler Linefeed*/ + "\x05\x1C\x33\x2F\x0D\x0A", /* FS '3' 47 cr lf*/ + + /* LineFeed2, d.h. kleinster Linefeed*/ + "\x05\x1C\x33\x01\x0D\x0A", /* FS '3' 01 cr lf*/ + + /* Einschalten der Grafik*/ + "\x09\x1B\x40\x1B\x4F\x1B\x43\x00\x10\r", /* ESC '@' ESC 'O' ESC 'C' 0 16 \r*/ + + /* Ausschalten der Grafik*/ + "\x03\f\x1B\x40", /* \f ESC '@'*/ + + /* Code vor den Grafik-Bytes*/ + "\x05\x1B\x2A\x28\x08\x10", /* ESC '*' 40 4104*/ + + /* Code nach den Grafik-Bytes*/ + NULL /* Nicht vorhanden*/ +}; + + + +/****************************************************************************/ +/* 150*150 DPI HP-DJ 1200C, 256 Farben, A4 */ +/****************************************************************************/ + +static struct LJDST HPDJ1200C150 = { + + /* DPI in X-und Y-Richtung*/ + { 150, 150, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 256, 8, + + /* Flags*/ + pfDoCompression | pfHasPalette, + + /* Name des Modus*/ + "\x11""HPDJ1200C 150 DPI", /* Name des Modus*/ + + /* Druckeroutine */ + LaserPrint }, + + /* Einschalten der Grafik*/ + "\x1B*t150R" /* ESC * t 150 R*/ + +}; + +/****************************************************************************/ +/* HP-Laserdrucker 1200*1200 DPI */ +/****************************************************************************/ + +static struct LJDST HPLJ1200 = { + + /* DPI in X-und Y-Richtung*/ + { 1200, 1200, + + /* Blattgroesse in X- und Y-Richtung in 1/1000 Inch*/ + LJ_A4_SIZEX, LJ_A4_SIZEY, + + /* Anzahl Farben und Bits pro Pixel*/ + 2, 1, + + /* Flags*/ + pfDoCompression, + + /* Name des Modus*/ + "\x12""HPLJ 1200x1200 DPI", /* Name des Modus*/ + + /* Druckeroutine*/ + LaserPrint }, + + /* Festlegen der Grafik*/ + "\x1B*t1200R" /* ESC * t 300 R*/ + +}; + + +/****************************************************************************/ +/* Das Array Zeigern auf die DST's */ +/****************************************************************************/ + +struct _DST * DSTTable [MaxModes] = { + + (struct _DST*) &EPSON240x72, /* 0*/ + (struct _DST*) &EPSON240x216, /* 1*/ + (struct _DST*) &EPSON180x180, /* 2*/ + (struct _DST*) &EPSON360x180, /* 3*/ + (struct _DST*) &EPSON360x360, /* 4*/ + (struct _DST*) &NEC360x360, /* 5*/ + (struct _DST*) &IBMPro180x180, /* 6*/ + (struct _DST*) &IBMPro360x180, /* 7*/ + (struct _DST*) &EPSON180x180C, /* 8*/ + (struct _DST*) &EPSON360x180C, /* 9*/ + (struct _DST*) &EPSON360x360C, /* 11*/ + (struct _DST*) &NEC360x360C, /* 10*/ + (struct _DST*) NULL, /* 12*/ + (struct _DST*) NULL, /* 13 Benutzerdefinierter Modus 1*/ + (struct _DST*) NULL, /* 14 Benutzerdefinierter Modus 2*/ + (struct _DST*) NULL, /* 15 Benutzerdefinierter Modus 3*/ + (struct _DST*) &HPLJ75, /* 16 LaserJet-Modi*/ + (struct _DST*) &HPLJ100, /* 17*/ + (struct _DST*) &HPLJ150, /* 18*/ + (struct _DST*) &HPLJ300, /* 19*/ + (struct _DST*) &HPLJ75O, /* 20 Nochmals LJ, ohne Kompression*/ + (struct _DST*) &HPLJ100O, /* 21*/ + (struct _DST*) &HPLJ150O, /* 22*/ + (struct _DST*) &HPLJ300O, /* 23*/ + (struct _DST*) &HPDJ75, /* 24 Farbmodi des DeskJet*/ + (struct _DST*) &HPDJ100, /* 25*/ + (struct _DST*) &HPDJ150, /* 26*/ + (struct _DST*) &HPDJ300, /* 27*/ + (struct _DST*) &HPDJ75S, /* 28 Farbmodi, Deskjet mit Schwarzabtrennung*/ + (struct _DST*) &HPDJ100S, /* 29*/ + (struct _DST*) &HPDJ150S, /* 30*/ + (struct _DST*) &HPDJ300S, /* 31*/ + (struct _DST*) &HPLJ600, /* 32*/ + (struct _DST*) &EPSON180x180_A3, /* 33 A3 Modi*/ + (struct _DST*) &EPSON360x180_A3, /* 34*/ + (struct _DST*) &EPSON360x360_A3, /* 35*/ + (struct _DST*) &NEC360x360_A3, /* 36*/ + (struct _DST*) &EPSON180x180C_A3, /* 37 A3 Modi, Farbe*/ + (struct _DST*) &EPSON360x180C_A3, /* 38*/ + (struct _DST*) &EPSON360x360C_A3, /* 39*/ + (struct _DST*) &NEC360x360C_A3, /* 40*/ + (struct _DST*) &HPDJ1200C150, /* 41 Deskjet 1200C, 256 Farben*/ + (struct _DST*) &HPLJ1200, /* 42 HP LJ4000, 1200 * 1200 DPI*/ + +}; + + + diff --git a/thirdparty/grx249/addons/print/prndata.lo b/thirdparty/grx249/addons/print/prndata.lo new file mode 100644 index 0000000..5010038 Binary files /dev/null and b/thirdparty/grx249/addons/print/prndata.lo differ diff --git a/thirdparty/grx249/addons/print/readme.txt b/thirdparty/grx249/addons/print/readme.txt new file mode 100644 index 0000000..5035aa1 --- /dev/null +++ b/thirdparty/grx249/addons/print/readme.txt @@ -0,0 +1,45 @@ + Printing from GRX + +This is source of beta version of printing procedures for GRX. +These procedures are based on sources of printer BGI drivers +for Borland C++ and Pascal compilers. This BGI driver was +developed by Ullrich von Bassevitz (see copying.uz). + +Only part of sources of printer BGI driver are used. I didn't port +drawing functions from BGI driver as they are already implemented in GRX. +I took only printing part which is now rather heavily modified to get +rid of Borland C++ specific features (e.g. inline assembler). + +Current version is tested with DJGPP and Linux versions of GRX only. +I didn't even try to compile it with Borland C++ for real mode as +I think it is useless due to lack of memory needed for buffer where +to create image. To print from GRX under Linux one should install +printer filter that allows to send PCL output to printer. + +Only some modes are tested: + Epson LQ printer : 180x180 dpi + LaserJet 4L : 300x300 dpi (with and without compression) + +I also tried DeskJet 500C mode (300x300 dpi with separate black) +on DeskJet 690C and it worked. + +Printing code is linked into executable only when it is really required. + +Currently it's included as addon to GRX. + +-------------------- Files ------------------------------------------- +grxprint.c - main sources of printing code +grxprint.h - interface definitions for user +prndata.c - printer definitions +grxprn00.h - definitions used internally by grxprint only +printest.c - test example +copying.uz - original copyright notice from Ullrich von Bassevitz +printer.doc - original docs on printer BGI driver +------------------------------------------------------------------------ + +NOTE: Ullrich von Bassevitz is no more maintaining printer BGI driver. + Addresses mentioned in printer.doc are NO MORE USABLE + + +Andris Pavenis +e-mail: pavenis@latnet.lv diff --git a/thirdparty/grx249/addons/print/readme.uz b/thirdparty/grx249/addons/print/readme.uz new file mode 100644 index 0000000..d8cbc3c --- /dev/null +++ b/thirdparty/grx249/addons/print/readme.uz @@ -0,0 +1,47 @@ + +Das Paket enthaelt die komplette Distribution meines PRINTER BGI-Treibers mit +allen Quellen. + + + +Bitte beachten: + + * Fuer die Uebersetzung der Quellen wird Borland C++ in der Version + 3.1 benoetigt. + + * Die Adressen und Telefonnumern, die in README.TXT genannt sind, sind + nicht mehr gueltig. + + * Ich will keine Anrufe, Briefe oder Mails bezueglich des Treibers + bekommen. Ich mache nichts mehr mit dem Treiber, und o.g. Dinge + stehlen mir nur meine Zeit. Eine Ausnahme mache ich nur, wenn mir + die anfallende Zeit bezahlt wird. + + * Fuer die Quellen gilt folgendes Copyright: + +Die Software (sowohl die Quellcodes, als auch die Binaries) werden +ohne jegliche Zusagen/Garantien bezglich Funktionalit„t oder +Funktionsf„higkeit abgegeben. Weder die Autoren noch die Distributoren +bernehmen eine Verantwortung fr Sch„den, die durch die Benutzung der +Software verursacht werden. + +Die Software darf frei verwendet und weitergegeben werden, wobei +"frei" ausdrcklich auch eine kommerzielle Nutzung/Weitergabe +einschlieát, *vorausgesetzt* die folgenden Bedingungen werden +eingehalten: + + 1. Die Herkunft der Software muá - wenn berhaupt - dann korrekt + angegeben werden. Es ist nicht erlaubt, die Software als Werk + eines anderen auszugeben. Wird die Software in Teilen oder als + Ganzes in einem Produkt benutzt, dann wrde ich mich ber einen + Hinweis auf die Herkunft in der Dokumentation freuen. Ein solcher + Hinweis ist aber nicht zwingend notwendig. + + 2. Ge„nderte Quellcodes mssen deutlich als solche gekennzeichnet + werden und drfen nicht ohne einen expliziten Hinweis auf die + durchgefhrten Žnderungen weiterverteilt werden. + + 3. Die Bedingungen ber die Nutzung/Weitergabe drfen nicht entfernt + oder ge„ndert werden. + + diff --git a/thirdparty/grx249/chr/addfonts.bat b/thirdparty/grx249/chr/addfonts.bat new file mode 100755 index 0000000..01d18aa --- /dev/null +++ b/thirdparty/grx249/chr/addfonts.bat @@ -0,0 +1,32 @@ +rem We are not distributing Borland BGI fonts with GRX. +rem To add them to the library put .CHR files in this +rem directory (where this script is located) and run it +rem after building GRX +rem This file is for Borland C. + +if "%1"=="" addfonts bold euro goth lcom litt sans scri simp trip tscr + +del *.obj +del addfonts.rsp +bcc -O -ml -ebin2c.exe ..\src\utilprog\bin2c.c + +:proc +if not exist %1.chr goto next + +echo Processing %1.chr +bin2c %1.chr _%1_font %1.c +bcc -c -O -ml %1.c +echo +%1.obj & >> addfonts.rsp +del %1.c + +:next +shift +if not "%1"=="" goto proc + +:done +echo , >> addfonts.rsp +tlib ..\lib\bcc\grx20l.lib @addfonts.rsp + +del *.obj +del addfonts.rsp +del ..\lib\bcc\grx20l.bak diff --git a/thirdparty/grx249/chr/addfonts.sh b/thirdparty/grx249/chr/addfonts.sh new file mode 100755 index 0000000..afcae89 --- /dev/null +++ b/thirdparty/grx249/chr/addfonts.sh @@ -0,0 +1,21 @@ +#! /bin/sh +# +# We are not distributing Borland BGI fonts with GRX. +# To add them to the library put .CHR files in this +# directory (where this script is located) and run it +# after building GRX +# + +rm -f *.o +gcc -O2 ../src/utilprog/bin2c.c -o bin2c.exe +for x in *.chr; do + echo "Processing $x ..."; + name=`basename $x | sed -e 's,\.chr,,g'` + ./bin2c $x _${name}_font $name.c + gcc -c -O2 $name.c + rm $name.c +done + +ar rc ../lib/dj2/libgrx20.a *.o +ranlib ../lib/dj2/libgrx20.a +rm -f *.o diff --git a/thirdparty/grx249/chr/addfonts.x11 b/thirdparty/grx249/chr/addfonts.x11 new file mode 100755 index 0000000..abdf21a --- /dev/null +++ b/thirdparty/grx249/chr/addfonts.x11 @@ -0,0 +1,21 @@ +#! /bin/sh +# +# We are not distributing Borland BGI fonts with GRX. +# To add them to the library put .CHR files in this +# directory (where this script is located) and run it +# after building GRX +# + +rm -f *.o +gcc -O2 ../src/utilprog/bin2c.c -o bin2c +for x in *.chr; do + echo "Processing $x ..."; + name=`basename $x | sed -e 's,\.chr,,g'` + ./bin2c $x _${name}_font $name.c + gcc -c -O2 $name.c + rm $name.c +done + +ar rc ../lib/unix/libgrx20X.a *.o +ranlib ../lib/unix/libgrx20X.a +rm -f *.o diff --git a/thirdparty/grx249/compat/grx.h b/thirdparty/grx249/compat/grx.h new file mode 100644 index 0000000..5a1240c --- /dev/null +++ b/thirdparty/grx249/compat/grx.h @@ -0,0 +1,64 @@ +/** + ** grx.h ---- GRX 2.0 -> 1.0x backward compatibility declarations + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __GRX_H_INCLUDED__ +#define __GRX_H_INCLUDED__ + +#ifndef __GRX20_H_INCLUDED__ +#include "grx20.h" +#endif + +/* + * old style context creation + */ +static char far *_context_memory_[4] = { 0 }; +#ifdef GrCreateContext +#undef GrCreateContext +#endif +#define GrCreateContext(w,h,mem,where) ( \ + _context_memory_[0] = (char far *)(mem), \ + GrCreateFrameContext( \ + GrCoreFrameMode(), \ + (w),(h), \ + (((GrCurrentFrameDriver()->num_planes == 1) && _context_memory_[0]) ? \ + _context_memory_ : \ + (char far **)0 \ + ), \ + (where) \ + ) \ +) + +/* + * drawing stuff + */ +#define GR_MAX_POLY_VERTICES GR_MAX_POLYGON_POINTS +#define GrCircleArc(x,y,r,s,e,c) (GrCircleArc)((x),(y),(r),(s),(e),GR_ARC_STYLE_OPEN,(c)) +#define GrEllipseArc(x,y,w,h,s,e,c) (GrEllipseArc)((x),(y),(w),(h),(s),(e),GR_ARC_STYLE_OPEN,(c)) +#define GrFilledCircleArc(x,y,r,s,e,c) (GrFilledCircleArc)((x),(y),(r),(s),(e),GR_ARC_STYLE_CLOSE2,(c)) +#define GrFilledEllipseArc(x,y,w,h,s,e,c) (GrFilledEllipseArc)((x),(y),(w),(h),(s),(e),GR_ARC_STYLE_CLOSE2,(c)) +#define GrGetLastArcCoords GrLastArcCoords + +/* + * text stuff + */ +#define GrLoadBIOSFont GrLoadFont /* I don't know whether this is a good idea */ +#define GrFontWidth(opt) ((opt)->txo_font->h.width) +#define GrFontHeight(opt) ((opt)->txo_font->h.height) + +#endif /* whole file */ + diff --git a/thirdparty/grx249/compat/mousex.h b/thirdparty/grx249/compat/mousex.h new file mode 100644 index 0000000..b4f0e01 --- /dev/null +++ b/thirdparty/grx249/compat/mousex.h @@ -0,0 +1,88 @@ +/** + ** mousex.h ---- GRX 2.0 -> 1.0x mouse backward compatibility declarations + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __MOUSEX_H_INCLUDED__ +#define __MOUSEX_H_INCLUDED__ + +#ifndef __GRX20_H_INCLUDED__ +#include "grx20.h" +#endif + +#ifndef M_MOTION /* "eventque.h" also defines these */ +#define M_MOTION GR_M_MOTION +#define M_LEFT_DOWN GR_M_LEFT_DOWN +#define M_LEFT_UP GR_M_LEFT_UP +#define M_RIGHT_DOWN GR_M_RIGHT_DOWN +#define M_RIGHT_UP GR_M_RIGHT_UP +#define M_MIDDLE_DOWN GR_M_MIDDLE_DOWN +#define M_MIDDLE_UP GR_M_MIDDLE_UP +#define M_BUTTON_DOWN GR_M_BUTTON_DOWN +#define M_BUTTON_UP GR_M_BUTTON_UP +#define M_BUTTON_CHANGE GR_M_BUTTON_CHANGE +#define M_LEFT GR_M_LEFT +#define M_RIGHT GR_M_RIGHT +#define M_MIDDLE GR_M_MIDDLE +#endif /* M_MOTION */ + +#define M_KEYPRESS GR_M_KEYPRESS +#define M_POLL GR_M_POLL +#define M_NOPAINT GR_M_NOPAINT +#define M_EVENT GR_M_EVENT + +#ifndef KB_SHIFT /* "eventque.h" also defines these */ +#define KB_RIGHTSHIFT GR_KB_RIGHTSHIFT +#define KB_LEFTSHIFT GR_KB_LEFTSHIFT +#define KB_CTRL GR_KB_CTRL +#define KB_ALT GR_KB_ALT +#define KB_SCROLLOCK GR_KB_SCROLLOCK +#define KB_NUMLOCK GR_KB_NUMLOCK +#define KB_CAPSLOCK GR_KB_CAPSLOCK +#define KB_INSERT GR_KB_INSERT +#define KB_SHIFT GR_KB_SHIFT +#endif /* KB_SHIFT */ + +#define M_CUR_NORMAL GR_M_CUR_NORMAL +#define M_CUR_RUBBER GR_M_CUR_RUBBER +#define M_CUR_LINE GR_M_CUR_LINE +#define M_CUR_BOX GR_M_CUR_BOX + +#define MouseEvent GrMouseEvent +#define MouseDetect GrMouseDetect +#define MouseEventMode GrMouseEventMode +#define MouseInit GrMouseInit +#define MouseUnInit GrMouseUnInit +#define MouseSetSpeed(s) GrMouseSetSpeed(1,s) +#define MouseSetAccel GrMouseSetAccel +#define MouseSetLimits GrMouseSetLimits +#define MouseGetLimits GrMouseGetLimits +#define MouseWarp GrMouseWarp +#define MouseEventEnable GrMouseEventEnable +#define MouseGetEvent GrMouseGetEvent +#define MousePendingEvent GrMousePendingEvent +#define MouseGetCursor GrMouseGetCursor +#define MouseSetCursor GrMouseSetCursor +#define MouseSetColors GrMouseSetColors +#define MouseSetCursorMode GrMouseSetCursorMode +#define MouseDisplayCursor GrMouseDisplayCursor +#define MouseEraseCursor GrMouseEraseCursor +#define MouseBlock GrMouseBlock +#define MouseUnBlock GrMouseUnBlock +#define MouseCursorIsDisplayed GrMouseCursorIsDisplayed + +#endif /* whole file */ + diff --git a/thirdparty/grx249/configure b/thirdparty/grx249/configure new file mode 100755 index 0000000..73478b3 --- /dev/null +++ b/thirdparty/grx249/configure @@ -0,0 +1,403 @@ +#!/bin/sh + +# Configure script for GRX +# +# NOTE: This script is completely OPTIONAL. If you don't know what +# to do with it, just ignore it and follow the normal install +# instructions. +# +# Copyright (C) 2001-2002,2004 Frank Heckenbach +# Peter Gerwinski +# +# Parts copied from some version of GCC's configure script, +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, version 2. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +silent=n + +default_prefix=/usr/local +prefix=$default_prefix +exec_prefix='${prefix}' +bindir='${exec_prefix}/bin' +datadir='${prefix}/share' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +infodir='${prefix}/info' + +# "Detect" default target (wrong for cross-compiling) +if [ x"$COMSPEC" != x ]; then + default_target=DJGPP +else + default_target=x11 +fi +target=$default_target + +default_fontpath='${datadir}/grx/fonts' +fontpath="" + +default_x11base=/usr/X11R6 +x11base="$default_x11base" + +default_x11lib='$(X11BASE)/lib' +x11lib="$default_x11lib" + +default_unitspath='${exec_prefix}/units' +unitspath="$default_unitspath" + +HAVE_LIBJPEG=n +HAVE_LIBPNG=n +NEED_ZLIB=n +HAVE_LIBTIFF=n +# if you are able to run this script you have (ba)sh +# we suppose you have other needed unix tools as well +HAVE_UNIX_TOOLS=y +INCLUDE_BMP_CODE=y +INCLUDE_PRINTING_CODE=y +INCLUDE_GPC_SUPPORT=n +INCLUDE_SHARED_SUPPORT=y +INCLUDE_BGI_SUPPORT=y +USE_DIRECT_MOUSE_DRIVER=n +USE_SVGALIB_DRIVER=y +USE_FRAMEBUFFER_DRIVER=y +SET_SUIDROOT=y +USE_INOUTP_FRAMEDRIVERS=y +BUILD_X86_64=n +lsocket="" +subst_EP="" + +ac_prev= +for ac_option do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'`;; + *) ac_optarg=;; + esac + + case "$ac_option" in + + -s | --silent | --silen | --sile | --sil | --si | --s) + silent=y;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg";; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg";; + + # Don't complain about unknown enable, disable, with and without options + -enable-* | --enable-* | -en-* | --en-*) + case "`echo "$ac_option" | sed -e 's/^-*enable-//;s/^-*en-//'`" in + x86_64) BUILD_X86_64=y;; + jpeg) HAVE_LIBJPEG=y;; + png) HAVE_LIBPNG=y;; + z | zlib) NEED_ZLIB=y;; + png-z) HAVE_LIBPNG=y; NEED_ZLIB=y;; + tiff) HAVE_LIBTIFF=y;; + bmp) INCLUDE_BMP_CODE=y;; + print) INCLUDE_PRINTING_CODE=y;; + pascal | gpc) INCLUDE_GPC_SUPPORT=y;; + shared) INCLUDE_SHARED_SUPPORT=y;; + bgi) INCLUDE_BGI_SUPPORT=y;; + direct-mouse) USE_DIRECT_MOUSE_DRIVER=y;; + svgalib) USE_SVGALIB_DRIVER=y;; + framebuffer) USE_FRAMEBUFFER_DRIVER=y;; + suidroot) SET_SUIDROOT=y;; + io-framedrivers) USE_INOUTP_FRAMEDRIVERS=y;; + lsocket) lsocket=" -lsocket";; + esac;; + -disable-* | --disable-* | -di-* | --di-*) + case "`echo "$ac_option" | sed -e 's/^-*disable-//;s/^-*di-//'`" in + x86_64) BUILD_X86_64=n;; + jpeg) HAVE_LIBJPEG=n;; + png) HAVE_LIBPNG=n;; + z | zlib) NEED_ZLIB=n;; + png-z) HAVE_LIBPNG=n; NEED_ZLIB=n;; + tiff) HAVE_LIBTIFF=n;; + bmp) INCLUDE_BMP_CODE=n;; + print) INCLUDE_PRINTING_CODE=n;; + pascal | gpc) INCLUDE_GPC_SUPPORT=n;; + shared) INCLUDE_SHARED_SUPPORT=n;; + bgi) INCLUDE_BGI_SUPPORT=n;; + direct-mouse) USE_DIRECT_MOUSE_DRIVER=n;; + svgalib) USE_SVGALIB_DRIVER=n;; + framebuffer) USE_FRAMEBUFFER_DRIVER=n;; + suidroot) SET_SUIDROOT=n;; + io-framedrivers) USE_INOUTP_FRAMEDRIVERS=n;; + lsocket) lsocket="";; + esac;; + -with-* | --with-*) + case "`echo "$ac_option" | sed -e 's/^-*with-//'`" in + fontpath=*) fontpath="$ac_optarg";; + fontpath) fontpath="$default_fontpath";; + x11-base=*) x11base="$ac_optarg";; + x11-base) echo "$0: \`--with-x11-base' requires an argument" >&2; exit 1;; + x11-lib=*) x11lib="$ac_optarg";; + x11-base) echo "$0: \`--with-x11-lib' requires an argument" >&2; exit 1;; + unitspath=*) unitspath="$ac_optarg";; + unitspath) echo "$0: \`--with-unitspath' requires an argument" >&2; exit 1;; + esac;; + -without-* | --without-*) + case "`echo "$ac_option" | sed -e 's/^-*without-//'`" in + fontpath) fontpath="";; + esac;; + -h | -help | --help | --hel | --he) + cat << EOF +Usage: $0 [options] +Options: [defaults in brackets after descriptions] + --help print this message and exit + --version print version information and exit + --silent silent operation + --prefix=PREFIX install architecture-independent files in PREFIX + [$default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + --bindir=DIR user executables [EPREFIX/bin] + --datadir=DIR read-only architecture-independent data + [PREFIX/share] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --infodir=DIR info documentation [PREFIX/info] + --target=TARGET configure for TARGET [$default_target] + possible values: djgpp,x11,console,w32,sdlx,sdlw + or GCC-style ("i386-mingw32") for cross-compiling + --enable-x86_64 build for x86_64 architecture [no] + --enable-jpeg include JPEG support [no] + --enable-png include PNG support [no] + --enable-zlib use zlib [no] + --enable-png-z include PNG support and use zlib [no] + --enable-tiff include TIFF support [no] + --enable-bmp include BMP support [yes] + --enable-print include printing code [yes] + --enable-pascal or include Pascal support [no] + --enable-gpc + --enable-shared build shared libraries [yes] + --enable-bgi include BGI support [yes] + --enable-lsocket link lsocket [no] + --disable-FOO opposite of --enable-FOO + --with-fontpath=PATH set GRX font path to PATH + --with-fontpath set GRX font path to $default_fontpath + --without-fontpath use no GRX font path [default] + --with-x11-base=DIR use DIR as X11 base directory [$default_x11base] + --with-x11-lib=DIR use DIR as X11 lib directory [$default_x11lib] + --with-unitspath=PATH set GPC units path to PATH [$default_unitspath] +The following options apply to the Linux console (not X11) target only: + --enable-direct-mouse use PS/2 instead of svgalib mouse driver [no] + --enable-svgalib use svgalib driver [yes] + --enable-framebuffer use framebuffer driver [yes] + --enable-suidroot create suid root executables (required with svgalib + 1.4.x) [yes] + --enable-io-framedrivers use frame drivers that require suid root + executables under newer versions of svgalib [yes] +Some options can be abbreviated, e.g. \`--p' for \`--prefix', +\`--en-FOO' for \`--enable-FOO' and \`--di-FOO' for \`--disable-FOO'. +NOTE: This script is completely OPTIONAL. If you don't know what to do with it, + just ignore it and follow the normal install instructions. +EOF + exit 0;; + -v | -version | --version | --versio | --versi | --vers) + echo "Optional GRX configure script" + exit 0;; + *) { echo "$0: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + esac +done + +case "`echo "$target" | tr A-Z a-z`" in + *djgpp*) cfgsection=GRXVDJ2; target_makefile=makefile.dj2;; + x | x11) cfgsection=GRXVX11; target_makefile=makefile.x11;; + console) cfgsection=GRXVLNX; target_makefile=makefile.lnx;; + *w32 | *mingw*) cfgsection=GRXVW32; target_makefile=makefile.w32;; + sdlx) cfgsection=GRXVX11; target_makefile=makefile.sdl; subst_EP="/^EP=/s/=.*/=x/";; + sdlw) cfgsection=GRXVW32; target_makefile=makefile.sdl; subst_EP="/^EP=/s/=.*/=/";; + *) echo "$0: invalid target" >&2; exit 1;; +esac + +case "$target" in + *[A-Za-z0-9]-[A-Za-z0-9]*|mingw32) + CROSS_PLATFORM="`echo "$target" | tr A-Z a-z`-" + exec_prefix="$prefix/$target";; + *) + CROSS_PLATFORM="" + exec_prefix='${prefix}';; +esac + +if [ $USE_SVGALIB_DRIVER != y ] && [ $USE_FRAMEBUFFER_DRIVER != y ]; then + echo "$0: either \`--enable-svgalib' or \`--enable-framebuffer' must be set" >&2 + exit 1 +fi + +if [ $USE_SVGALIB_DRIVER != y ] && [ $USE_DIRECT_MOUSE_DRIVER != y ]; then + echo "$0: if \`--disable-svgalib' is unset then \`--enable-direct-mouse' must be set" >&2 + exit 1 +fi + +if [ -r Makefile ]; then + if cmp Makefile makefile.lnx > /dev/null 2>&1 || + cmp Makefile makefile.dj2 > /dev/null 2>&1 || + cmp Makefile makefile.w32 > /dev/null 2>&1 || + cmp Makefile makefile.x11 > /dev/null 2>&1 || + cmp Makefile makefile.sdl > /dev/null 2>&1; then + rm -f Makefile + else + echo "$0: Makefile exists already. Not overwriting!" >&2 + exit 1 + fi +fi + +if [ ! -r "$target_makefile" ]; then + echo "$0: $target_makefile not found (please run in source directory)" >&2 + exit 1 +fi + +# On DJGPP, `ln -s' creates `makefile.exe', so copy in this case +{ ln -s "$target_makefile" Makefile && [ -r Makefile ]; } || + { rm -f makefile.exe; cp "$target_makefile" Makefile; } +[ $silent = y ] || echo "Created Makefile" + +cfgfile="makedefs.grx" +cfgorigfile="makedefs.orig" +if [ ! -r "$cfgfile" ]; then + echo "$0: $cfgfile not found" >&2 + exit 1 +fi + +if [ ! -r "$cfgorigfile" ]; then + cp "$cfgfile" "$cfgorigfile" +fi + +if [ x"$fontpath" = x ]; then + subst_fontpath="/^#*GRX_DEFAULT_FONT_PATH=/s/^#*/#/" +else + subst_fontpath="/^#*GRX_DEFAULT_FONT_PATH=/{s/^#*//;s|=.*|=$fontpath|;}" +fi + +if [ "$cfgsection" = GRXVLNX ] || [ "$cfgsection" = GRXVX11 ]; then + extra_unix="/^ifdef GRXVUNX\$/,/^endif\$/{/^prefix=/s|=.*|=$prefix|;$subst_fontpath;}" +else + extra_unix= +fi + +if sed -e "/^BUILD_X86_64=/s/=.*/=$BUILD_X86_64/; + $subst_EP; + /^HAVE_LIBTIFF=/s/=.*/=$HAVE_LIBTIFF/; + /^HAVE_LIBJPEG=/s/=.*/=$HAVE_LIBJPEG/; + /^HAVE_LIBPNG=/s/=.*/=$HAVE_LIBPNG/; + /^HAVE_UNIX_TOOLS=/s/=.*/=$HAVE_UNIX_TOOLS/; + /^NEED_ZLIB=/s/=.*/=$NEED_ZLIB/; + /^INCLUDE_PRINTING_CODE=/s/=.*/=$INCLUDE_PRINTING_CODE/; + /^INCLUDE_BMP_CODE=/s/=.*/=$INCLUDE_BMP_CODE/; + /^INCLUDE_GPC_SUPPORT=/s/=.*/=$INCLUDE_GPC_SUPPORT/; + /^INCLUDE_SHARED_SUPPORT=/s/=.*/=$INCLUDE_SHARED_SUPPORT/; + /^INCLUDE_BGI_SUPPORT=/s/=.*/=$INCLUDE_BGI_SUPPORT/; + /^CROSS_PLATFORM=/s/=.*/=$CROSS_PLATFORM/; + /^USE_DIRECT_MOUSE_DRIVER=/s/=.*/=$USE_DIRECT_MOUSE_DRIVER/; + /^USE_SVGALIB_DRIVER=/s/=.*/=$USE_SVGALIB_DRIVER/; + /^USE_FRAMEBUFFER_DRIVER=/s/=.*/=$USE_FRAMEBUFFER_DRIVER/; + /^SET_SUIDROOT=/s/=.*/=$SET_SUIDROOT/; + /^USE_INOUTP_FRAMEDRIVERS=/s/=.*/=$USE_INOUTP_FRAMEDRIVERS/; + /^exec_prefix=/s|=.*|=$exec_prefix|; + /^bindir=/s|=.*|=$bindir|; + /^libdir=/s|=.*|=$libdir|; + /^datadir=/s|=.*|=$datadir|; + /^includedir=/s|=.*|=$includedir|; + /^unitsdir=/s|=.*|=$unitspath|; + /^infodir=/s|=.*|=$infodir|; + $extra_unix; + /^ifdef $cfgsection\$/,/^endif\$/{ + /^prefix=/s|=.*|=$prefix|; + $subst_fontpath; + /^X11BASE=/s|=.*|=$x11base|; + /^X11LIB=/s|=.*|=$x11lib|; + /^X11LIBS=/s/\$/$lsocket/; + }" "$cfgorigfile" > "$cfgfile"; then + [ $silent = y ] || echo "Modified $cfgfile" +else + cp -f "$cfgorigfile" "$cfgfile" + exit 1 +fi + +if [ x"$INCLUDE_GPC_SUPPORT" = x"y" ]; then + for file in pascal/grx.pas pascal/bgi/graph.pas; do + if [ ! -r "$file" ]; then + echo "$0: $file not found" >&2 + exit 1 + fi + if sed -e "s/{.*\\\$define LINUX_CONSOLE}/{`if [ x"$target" != x"console" ]; then echo .; fi`\$define LINUX_CONSOLE}/; + s/{.*\\\$define SVGALIB}/{`if [ x"$target" != x"console" -o $USE_SVGALIB_DRIVER != y ]; then echo .; fi`\$define SVGALIB}/; + s/{.*\\\$define __SDL__}/{`if [ x"$target" != x"sdlx" -a x"$target" != x"sdlw" ]; then echo .; fi`\$define __SDL__}/; + s/{.*\\\$L socket}/{`if [ x"$lsocket" = x ]; then echo .; fi`\$L socket}/ + " "$file" > "$file.new" && + sed -e "s/{.*\\\$L tiff}/{`if [ $HAVE_LIBTIFF != y ]; then echo .; fi`\$L tiff}/; + s/{.*\\\$L jpeg}/{`if [ $HAVE_LIBJPEG != y ]; then echo .; fi`\$L jpeg}/; + s/{.*\\\$L png}/{`if [ $HAVE_LIBPNG != y ]; then echo .; fi`\$L png}/; + s/{.*\\\$L z}/{`if [ $NEED_ZLIB != y ]; then echo .; fi`\$L z}/; + " "$file.new" > "$file" && + rm -f "$file.new" ; then + [ $silent = y ] || echo "Modified $file" + else + rm -f "$file.new" + exit 1 + fi + done +fi diff --git a/thirdparty/grx249/copying b/thirdparty/grx249/copying new file mode 100644 index 0000000..a43ea21 --- /dev/null +++ b/thirdparty/grx249/copying @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/thirdparty/grx249/copying.grx b/thirdparty/grx249/copying.grx new file mode 100644 index 0000000..ed54935 --- /dev/null +++ b/thirdparty/grx249/copying.grx @@ -0,0 +1,53 @@ +This is file "copying.grx". + +This document describes the terms for distributing the source code of and any +derived work based on the GRX graphics library. Such source code is marked +with the next text: + + ** Copyright (c) [year] [author], [author information] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + +Source code with the above copyright is distributed under the following terms: + + (1) The test programs for the graphics library (code in the 'test' + sub-directory) is distributed without restrictions. This code + is free for use in commercial, shareware or freeware applications. + + (2) The GRX graphics library is distributed under the terms of the + GNU LGPL (Library General Public License) with the following amendments + and/or exceptions: + + - Using the DOS versions (DOS only! this exception DOES NOT apply to + the Linux version) you are permitted to distribute an application + linked with GRX in binary only, provided that the documentation + of the program: + + a) informs the user that GRX is used in the program, AND + + b) provides the user with the necessary information about + how to obtain GRX. (i.e. ftp site, etc..) + + (3) Fonts (in the 'fonts' sub-directory). Most of the fonts included with + the GRX library were derived from fonts in the MIT X11R4 distribution. + They are distributed according to the terms in the file "COPYING.MIT" + (X license). Exceptions are: + - The fonts "ter-114b.res", "ter-114n.fna" and "ter-114v.psf" are + Copyright (C) 2002 Dimitar Zhekov, but are distributed under the + X license too. + - The "pc" BIOS font family, which is distributed without restrictions. + +A copy of the GNU GPL (in the file "COPYING") and the GNU LGPL (in +the file "COPYING.LIB") is included with this document. If you did +not receive a copy of "COPYING" or "COPYING.LIB", you may obtain one +from where this document was obtained, or by writing to: + + Free Software Foundation + 675 Mass Ave + Cambridge, MA 02139 + USA + diff --git a/thirdparty/grx249/copying.lib b/thirdparty/grx249/copying.lib new file mode 100644 index 0000000..d750c7e --- /dev/null +++ b/thirdparty/grx249/copying.lib @@ -0,0 +1,481 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/thirdparty/grx249/copying.mit b/thirdparty/grx249/copying.mit new file mode 100644 index 0000000..fdc3a01 --- /dev/null +++ b/thirdparty/grx249/copying.mit @@ -0,0 +1,96 @@ +Software in this distribution of the X Window System is covered by copyrights; +see the file LABELS in this directory for a list. + +The MIT distribution of the X Window System is publicly available, but is NOT +in the public domain. The difference is that copyrights granting rights for +unrestricted use and redistribution have been placed on all of the software to +identify its authors. You are allowed and encouraged to take this software and +build commerical products. + +Individuals or organizations wishing to contribute software to the public +releases should use a copyright notice that is no more restrictive than +the sample given below. In particular, + + o Do not place any restictions on what can be done with this software + (this includes using the GNU "copyleft"). + + o Do not include the words "All rights reserved" unless you have had a + lawyer verify that you have also explicitly given away all of the + necessary rights shown in the samples. + + o Spell out the word "Copyright"; the phrase "(c)" is NOT a legal + alternative to the c-in-circle symbol. + + o Put at least a one-line copyright at the top of EVERY source file, if + not the full copyright. Also, the copyright line or full notice MUST + physically appear in each file. Using the preprocessor to #include the + copyright from some other file has no legal meaning (it can be used to + incorporate common strings into the binary, but has no effect on the + status of the source code). + + o Things that are copyrighted are, by definition, not in the public + domain. + +A copyright notice similar to the following is strongly recommended (replacing +MIT with your organization's name and putting your name and address at the +bottom). + +/* + * Copyright 1989 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of M.I.T. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. M.I.T. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Your Name, Name of your organization + */ + + + X Window System, Version 11 + Release 4 + + contents copyrighted by + + + Massachusetts Institute of Technology + Adobe Systems, Inc. + Apollo Computer Inc. + Apple Computer, Inc. + AT&T, Inc. + Don Bennett + Bigelow & Holmes + Bitstream, Inc. + Adam de Boor + Cognition Corp. + Digital Equipment Corporation + Evans & Sutherland Computer Corporation + Franz Inc + Hewlett-Packard Company + IBM Corporation + Network Computing Devices, Inc. + O'Reilly and Associates, Inc. + Dale Schumacher + Marvin Solomon + Sony Corp. + SRI + Sun Microsystems, Inc. + Tektronix, Inc. + Texas Instruments Incorporated + UniSoft Systems + The Regents of the University of California + University of Wisconsin + Larry Wall + Wyse Technology, Inc. diff --git a/thirdparty/grx249/doc/changes.bgi b/thirdparty/grx249/doc/changes.bgi new file mode 100644 index 0000000..23adb99 --- /dev/null +++ b/thirdparty/grx249/doc/changes.bgi @@ -0,0 +1,116 @@ +******* 2.3 --> 2.3.4 +- BCC2GRX is now part of the GRX graphics library. +******* 2.0 --> 2.3 +- will use the floodfill() from GRX 2.25 or newer +- Linux: can be compiled as shared library (make SHARED=1 in src/) +- made all functions direct linkable (mostly for GPC support) +- Pascal (GPC) support by Sven Hilscher included +- updated for grx21 (patterns & custom lines) +- No more warnings using LIBBCC.H in C++ programs +******* 1.3 --> 2.0 +- new copyright terms, see readme +- compiles with both grx v2.0 and v1.03 +- text.c splitted +- added setactivepage(), setvisualpage() and helper func's + set_BGI_mode_pages(int p), get_BGI_mode_pages(), + getactivepage() and getvisualpage() (functional only with + grx v2.0 or newer) +- __gr_Y_page_offs disabled if compiled for grx 1.0x +- restrict RGB values in setrgbpalette() to 0..63 +- added extended graphics modes from BC++ 4.5 +- few experimental custom line hacks for grx 2.0 (lnestyle.c) +- more work on Makefiles, make in src or test subdir works +- Due to limited stack space with DJGPP v2, complete rewrite + of floodfill() to avoid deep recursions. +- DJGPP: libbcc2.a will work on v1 and v2 systems with grx10, no need + to keep libbccx.a any longer. +- Link test: create dummy executable using all library objects. Nice to + check grx20fix.h settings. +- Optimized makefiles and configuration +- getdrivername() will report GRX driver name with GRX2 +- LINUX: saved some getpixel() calls for floodfill() under X11. Remains slow :-( +- LINUX: No need to keep a seperate X11 directory any longer, binaries + are just linked with -lgrx20X -X11 instead of -lgrx20 -lvga +- LINUX: Enhanced Linux support (svgalib && X11) +- rewrote bgi font loading +- libbcc.h won't include GRX stuff any more +- rewrote floodfill(): Will use it's own dumb monochrome + context to keep track of drawn points. Uses less memory but + seems to be a little slower in few cases. +- moved _ega_color, setrgbdefaults() and setrgbgray256() from libbcc?.a + to src/addons.a +- added four new functions getmodemaxcolor(), getmodemaxx(), getmodemaxy() + and setrgbcolor(). +- added version check __BCC2GRX__ (equals to 0x21a for v2.1 alpha, + 0x20b -> v2.0 beta, 0x230 -> v2.3 offical release, ...) + +******* 1.2 --> 1.3 (1.3 didn't made it to public) + +- Vector fonts may be plotted using the actual line style. + calling textlinestyle(1) enables and textlinestyle(0) disables + this feature. +- corrected getmodename() TrueColor definition, name of actual + graphics mode valid now, will display 32K/64K/16M instead of + huge numbers +- CGA/MCGA/ATT400 will be emulated by 16 color modes +- EGA64HI sets 16 color mode on non EGA cards +- named source files in a more functional way +- circle() will use GrCircle() in "round" cases +- graphdefaults(), setgraphmode() and initgraph() set up the + correct aspect ratio +- added __gr_ prefix to several library functions called + by other bcc2grx functions. Protects against interference + with other libraries (problem reported by Axel Rohde) +- updated for libgrx 1.03 +- should work with .vdr drivers now +- uses GrGetLastArcCoords() instead of global variables +- BLACK changed into constant +- Pascal support improved. KeyPressed and ReadKey will + flush stdout first, updated Readme +- bccbgi now uses random() instead of RANDOM_TP() for correct + support of >32768 colors modes. (Bad news: random() is much slower) +- set_BGI_mode_whc translates 64K and 16M color values into + GRX internals 0xC010 and 0xC018 (grx1.0x only) +- added _ega_color for EGA color emulation in HiColor/TrueColor modes +- Corrected range check in setfillstyle() (bug found by Axel Rohde) +- Corrected bugs/problems reported by Antonio Carlos Moreirao de Queiroz: + - initgraph won't crash if pathtodriver == NULL + - When loading a font failed, DEFAULT_FONT size 1 will be used + - font switching should be faster now + - if a font can't be found, grFontNotFound error will be set. +- Correct name expansion in installuserfont() + +******* 1.1 --> 1.2 + +- installuserfont() accepts GRX font names (name.fnt). +- getmodename() supports modes >32768 colors +- initgraph() has NATIVE_GRX driver entry. NATIVE_GRX supports + the default, biggest (noninterlaced), BGI_mode graphics and all valid + modes from .grn drivers +- set_BGI_mode()/set_BGI_mode_whc() routines to emulate BGI driver resolutions +- floodfill() doesn't uses second context in simple cases (much faster), + leaves viewport if no clipping required +- getmoderange(), getmaxmode() and getpalettesize() will call + __gr_set_up_modes() first -->> returned values are initialized +- closegraph() resets __gr_INIT flag +- cleardevice(), clearviewport(), imagesize(), graphresult(), getmaxcolor(), getgraphmode(), getpixel() and + putpixel() are checking __gr_INIT flag now +- setrgbpalette() check's initgraph(), moved from bccgrx.h -> bccgrx20.c +- drawpoly() always closed the polygon -- fixed. +- registerfarbgifont() now same as registerbgifont() +- setgraphbufsize() returns a defined value +- setwritemode() protects against setting color bits +- detectgraph() returns the correct graphdriver info +- graphdefaults() doesn't call setlinestyle() & setviewport() any more +- bccgrx.c/__gr_set_up_modes() executed once only (fixes memory waste) + +******* 1.0 --> 1.1 + +- initgraph() will set the requested graphmode if graphdriver != DETECT. +- using GrHLineNC and GrPixelNC in bccgrx09.c / _floodfill() +- BCC2GRX should run correct with old style drivers (.grd) + (bccgrx.c/__gr_set_up_modes changed) +- Corrected detectgraph()/initgraph() problem calling Gr... funcs + before GrSetMode() +- Used normal filled / solid line commands where ever possible +- Text direction and justify setting compatible with Borland definition diff --git a/thirdparty/grx249/doc/changes.txt b/thirdparty/grx249/doc/changes.txt new file mode 100644 index 0000000..bdab75c --- /dev/null +++ b/thirdparty/grx249/doc/changes.txt @@ -0,0 +1,728 @@ +This file lists the history of changes to the grx source files from +the 2.2 version. +------------------------------------------------------------------- + +Date Changes + +12/07/10 ----------- GRX v2.4.9 released (Maurice Lombardi) +12/07/04 Change configure script and makedefs.grx to conform to recent + GNU practice. Honours DESTDIR to ease building binary distributions. + INSTALLDIR is no more present in makedefs.grx, but prefix is there + to replace it. (Extension of a patch by Guillem Jover to all targets + by M. Lombardi) +11/11/23 All drivers generate button4 and button5 mouse events (the scroll + wheel scrolled up or down). Extended from MGRX by M. Lombardi. +11/11/18 Add GrFlush(). Useful only on X11 when when switching between + graphics and console windows open simultaneously. (M. Lombardi) +10/08/17 Add GrMsecTime(). Adapted from MGRX. +09/04/02 Synchronisation of windows and grx mouse cursors by Richard Sanders + +08/12/12 Fix a race condition with the loadcolor SetDIBColorTable function + call, which happens sometimes on fast multiprocessor machines + This affects only 8 bpp modes (Peter Schauer ) +08/11/05 Added GrClearContextC function, by Richard Sanders. +08/08/01 fdrivers/fd_xwin.c: Sanitized pixel cache code. + New faster and specific for X11 putscanline function, this change + accelerates a lot displaying pnm, png and jpeg images. + Backports from MGRX of M.Alvarez +08/05/15 Fix a conflict between underline and XOR char writing reported by + Al-Junaid H. Walker (M. Lombardi) +07/12/27 Added GrFloodSpill functions, by Richard Sanders +07/12/01 vd_xwin: go to fullscreen if w,h == X resolution, GR_biggest_graphics + is honored. Modes higher than X resolution are made no-present. + Added videomodes for wide monitors in x11 and w32 drivers. + Backports from MGRX of M.Alvarez +07/08/11 Fix a keyboard bug reported by A. Moreira. It was a bug produced by + the optimiser for gcc >= 4 when using asm: memory clobber. + If not corrected it could pop up at other places. (M. Lombardi) + +07/08/29 ----------- GRX v2.4.8 released (Maurice Lombardi) +07/08/29 Sanitized win32, eliminating WM_SIZE events +07/08/27 Add Sleep(5) to setrgbpalette for win32 which sends WM_PAINT to + redraw whole screen. Compare PlayRGBpalette() in test/bgi/bccbgi.c + Add Sleep(1) when no more W32events queued to yield control + when looking for grx events by M. Lombardi. +07/08/21 Correction to WM_PAINT in vdrivers/vd_win32.c: GetUpdateRect() gave + wrong UpdateRect -> few missing chars in text drawing, by M. Lombardi +07/08/17 Change to text/fontpath.c and text/loadfont.c to allow the syntax + /dev/env/DJDIR in djgpp when loading fonts by M. Lombardi +07/08/07 Correction to test/test.h to enable test/scroltst to run as expected. +07/08/05 Eliminate WM_PAINT in mouse/w32inp.c to enqueue GR_OS_DRAW_REQUEST. + Too frequents, they produced saturation of the GRX event queue and + gobbling of keybord/mouse events. Compare responsivity of + test/mousetst.c, test/bgi/bccbgi.c, pascal/bgi/demo.pas by M. Lombardi +07/08/01 The X11 driver now responds to Expose events by using a pixmap + for backing store. But this slows it down. You can recover + previous behaviour (faster but no response to Expose) by editing + src/include/libxwin.h and setting USE_PIXMAP_FOR_BS to 0. + Backported from Mariano's MGRX by M. Lombardi. +07/07/30 various improvements in makefiles, demo.pas, test/speedtst.c + by M. Lombardi. + +07/04/06 ----------- GRX v2.4.7 released (Maurice Lombardi) +07/04/06 updates in test/speedtst.c +07/04/05 change to bgi/bccgrx.c, so that all 32 bpp modes are considered + by BGI as 16M modes (the extra byte is only for padding): this was + the case for older drivers up to VESA which gave GrVideoMode->bpp=24 + in these cases (see lines 246-258 in vdrivers/vesa.c). +07/03/25 SDL driver (sdl-rc4-support.zip) by Dimitar Zhekov 28 May 2004 + with changes to makefiles/makedefs/configure + and pascal support by Maurice Lombardi +07/03/16 inclusion of various corrections submitted to the list + grx.diff-byteorder by Frank Heckenbach 31 May 2006 + grx-exitprocess.diff GRX app termination bug (winXP) + by Mario Zagar 15 Feb 2005 + grxfixes.zip by Dimitar Zhekov 24 Sep 2004 + fontdemo-res-fix.diff + fontdemo-Y-fix.diff + test-changes.diff + win32-8bpp-cls-fix.diff (win32 setmode() clear screen problem) + xfdga-detect-once.diff (xfdga avoid double detection) + grx-w32events.diff (more W32 event handling) + by Peter Gerwinski 19 Jun 2004 + graphresult.diff by Andris Pavenis 8 Jan 2004 +07/01/05 introduction of GR_PtrInt (integer of same length as a pointer) + to suppress warnings (in fact errors) when compiling with + x86_64 platforms, + renaming sincos() to GrSinCos() in genellip.c to avoid + name conflict with builtin, by M. Lombardi. +06/09/19 correction to bgi/text4.c to correct update of graphics + pointer in vertical writing with outtext (was going in + the wrong direction. BP does not update it at all, + but this is stupid), by M. Lombardi. +06/09/11 correction to grx.pas (bar3d) +06/02/10 Better understanding of x86_64. Now by default an i386 + library is built even on x86_64 platforms. If you set + BUILD_X86_64 to 'y' in makdefs.grx a x86_64 library is + built, and the install target go to the lib64 subdir + (backport from MGRX by M. Lombardi) +04/09/24 Added x86_64 support (backport from MGRX by M. Lombardi) +xx/09/05 Florian Xaver updated GRX to make it compatible with latest + DJGPP/GCC. +05/03/08 correction to polytest.pas +04/09/27 more changes to graph.pas, jpgtest.pas, imgview.pas, + by Frank Heckenbach. +04/09/17 more changes to grx.pas and graph.pas, by Frank Heckenbach. +04/06/06 more changes for same purpose by Peter Gerwinski. +04/04/25 changes to introduce: + HAVE_UNIX_TOOLS, CROSS_PLATFORM in makefefs.grx and configure + w32 (mingw32) target in configure + corresponding changes in makefiles, + by Frank Heckenbach and Peter Gerwinski. +04/03/28 changes in grx.pas to make it compile with recent versions of + gpc, by Frank Heckenbach. +03/12/27 Close the framebuffer if DGA is compiled with framebuffer + support, not without it, by Dimitar Zhekov. +03/12/27 Version 2 of the raw driver. Support for psf2. Better + support for RAW: up to 16x32, assuming width:height 1:2 + (the previous code was always assuming width = 8), + by Dimitar Zhekov. +03/12/27 Small bug in grxprint.c, by Andris Pavenis. +03/12/27 Version 2 of the libGRX DGA2 driver. Features set mode + via DGA2 and rendering via Xlib or linear framebuffer, + by Dimitar Zhekov. +03/12/27 Up to 200 the possible modes in the DGA2 driver, by Dimitar + Zhekov. +03/12/27 A batch mode for speedtst. Usage: run speedtst to see the + mode numbers, then "time speedtst MODE" or [4dos] "timer ^ + speedtst ^timer". Maybe "first" should be named "prompt", + by Dimitar Zhekov. + +03/07/17 ----------- GRX v2.4.6 released (Mariano Alvarez Fernandez) +03/07/15 fdv_win.c: the resource header fields must be swapped, + not the data they "point" to, by Dimitar Zhekov. +03/07/15 Changed the default to 'n' for the USE_INOUTP_FRAMEDRIVERS + switch in makedefs.grx +03/06/25 In the svgalib driver don't re-setting the initial mode if + it's already set, by Dimitar Zhekov. +03/06/23 define alloca to __builtin_alloca in src/include/allocate.h + to avoid warnings in Mingw with gcc 3.x. src/makefile.lnx, + src/makefile.x11: don't link ADDON_LIBS for UTILP. + src/stdobjs.mak: remove any duplicate definitions and + trailing \-s. src/text/buildfnt.c: produce a more readable + bdump() DEBUG output, by Dimitar Zhekov. +03/06/23 The GRX raw keyboard I/O can't be safely used in text mode. + Fixed it in test/bgi/, by Dimitar Zhekov. +03/06/10 Small fixes, replaced some printf with DBGPRINTF, removed + GrKeyPressed test in debug mode, it can't be used in all + plattforms, by Dimitar Zhekov. +03/06/10 Small chamges to fdv_win.c, better name/family supportm, avoid + possible overflow, by Dimitar Zhekov. +03/06/10 More Pascal updates, by Frank Heckenbach. +03/05/31 Small fixes to fdv_fna.c and fdv_xwin.c, by Dimitar Zhekov. +03/05/31 Pascal demos updates, by Eike Lange. +03/05/03 Added a InvalidateRect in the loadcolor function in the Win32 + videodriver, now the play-palette bgi demo works properly. + I think the Win32 driver is now very usable, not more in alpha. +03/05/03 Faster w32_drawpixel function in the Win32 framedrivers. +03/05/02 Small patch for the next GPC version, by Frank Heckenbach. +03/05/02 Small test fixes, by Dimitar Zhekov. +03/05/02 Added a cleanall target to the borland makefile, + by Dimitar Zhekov. +03/04/02 Added new video driver for Xfree86 DGA2 (Direct Graphics Access), + experimental, not compiled by default, you must activate it in + makedefs.grx, by Dimitar Zhekov. +03/03/31 New 8bpp frame driver (by Josu) and 24 bpp frame driver (by me) + for Win32. They use the standard GRX framedirvers plus the + necesary InvalidateRects. Now the Win32 version is faster and + reliable. +03/03/31 With the Thomas idea of using a DIB in the win32 video driver, + we can now use the DIB like a linear frame buffer, so the new + win32 framedrivers can take advantage of the standard GRX frame + drivers, by Josu Onandia. +03/03/31 Use a DIB for the hDCMem in the win32 video driver, + by Thomas Demmer +03/03/11 The alternate linux console input driver now calls + _LnxfbSwitchConsoleAndWait if _lnxfb_waiting_to_switch_console + is set. +03/03/11 Changes to the linuxfb driver. Added code to catch a signal + when user wants to change virtual terminals. The driver sets + _lnxfb_waiting_to_switch_console and the input driver must + calls _LnxfbSwitchConsoleAndWait then. + Previous function _SwitchConsoleLnxfbDriver renamed to + _LnxfbSwitchConsoleVt, not used,is here only for possible + future use. +03/03/10 Some more adjustments to GPC changes. This time, however, + there will be backward-incompatible changes (WRT …smname' + etc.). Therefore, I'm using a compiler version check, so it + should work with old and new GPC versions. At this occasion, + I'm also removing the old-style external variable syntax + (of GPC versions prior to 2000-04-12) from graph.pas, by + Frank Heckenbach. +03/03/10 Changes the x11 font driver to use it's own X11 display + and window. It allows X11 fonts to be loaded before GrSetMode() + and makes the font driver independent from the X11 video and + frame drivers, by Dimitar Zhekov. +03/03/10 Syncs ulheight/ulpos calculation in the X11 font driver with + all other drivers for which ulheight isn't known, by + Dimitar Zhekov. +03/02/27 Changes to the .fna font driver: undpos is not supported and + fix driver inability to read fonts with 2+ nonempty "note", + by Dimitar Zhekov. +03/02/26 Get rid of GRXMain in test programs, we use main now. +03/02/12 Sanitize the Thomas changes. +03/02/12 Changes to the win32 videodriver. Instead of begin with WinMain + and start a thread with the main GRX program, do it backward: + begin in main and start a thread to handle the Windows window. + With this change we get rid of the awful GRXMain special entry + point and GRX compiles now with CygWin, added the new platform + to grx20.h, by Thomas Demmer +03/02/11 Some small bugfixes for the Pascal units, by Frank Heckenbach. +03/01/14 Pascal units rewritten, this is to make the formatting more in + line with the GPC conventions, by Frank Heckenbach. +02/12/29 The alternate linux console input driver now works with PS2 and + IMPS2 mice (but the whell is not used). +02/12/21 Added function to change virtual terminals in the linuxfb + driver, _SwitchConsoleLnxfbDriver to be called from the input + driver (it doesn't work yet). +02/12/21 Some cleanups to the linuxfb driver, now the text screen restart + ok on exit. +02/12/13 Added 8bpp paletted mode to the linuxfb driver, + by Josu Onandia. +02/11/24 In fdrivers/lfb8.c, lfbbltrv.c, lfbbltvr.c and lfbbltvv.c + there was a erroneous test on LBF_BY_NEAR_POINTER instead + LFB_BY_NEAR_POINTER, reported by . +02/11/24 Changes avoid some warnings given by `-W' in graph.pas, by + Frank Heckenbach. +02/11/24 The test program launcher, demogrx, has now two pages. Added + some fontdemos. +02/10/27 Modetest shows the actual resolution when in graphics mode. +02/10/26 Corrected bug in fdrives/ram4.c, if the GR_UNDERLINE_TEXT + flag was set colors were wrong, reported by Alex. +02/10/26 Corrected bug in draw/bitblt1b.c, bad source origin if the + destination origin was negative, by Alex + Changed bb1test.c test program to see the efect. + +02/10/20 ----------- GRX v2.4.5 released (Mariano Alvarez Fernandez) +02/10/18 Changed __MINGW32__ to _WIN32 in Pascal units, by + Frank Heckenbach. +02/10/16 Updated the configure script, by Frank Heckenbach. +02/10/02 Corrected bugs in GrFloodFill, before it didn't paint the + righter point (causing ocasionall aborts too) and didn't + work on subcontexts. +02/08/27 Updates to the fdv_raw font driver, the loadfont source + now does a cleanup to close the font file, fontdemo test + program updated, by Dimitar Zhekov. +02/08/10 Make the test/bgi programs depend of a unique file header + for input and delay functions. +02/08/10 New api functions with a unique color parameter in 0xRRGGBB + format: + GrColor GrAllocColor2(long hcolor); + GrColor GrAllocColor2ID(long hcolor); + void GrQueryColor2(GrColor c,long *hcolor); + void GrQueryColor2ID(GrColor c,long *hcolor); +02/08/06 Added 'setsuid' target to test/makefile.lnx and + test/bgi/makefile.lnx. Now you can run 'make -f makefile.lnx' + in the grx base directory an them become root and run + 'make -f makefile.lnx setsuid'. +02/08/06 Use the SET_SUIDROOT variable in test/bgi/makefile.lnx, + by Dimitar Zhekov. +02/08/06 Fontdemo update, by Dimitar Zhekov. +02/08/02 Modifications to acomodate new options in makedefs.grx, + for the four standard platforms: + INCLUDE_BGI_SUPPORT, 'y' by default + for the linux console platform: + USE_SVGALIB_DRIVER, 'y' by default + USE_FRAMEBUFFER_DRIVER, 'y' by default + SET_SUIDROOT, 'y' by default + USE_INOUTP_FRAMEDRIVERS, 'y' by default + Added a note about "Suidroot in the Linux console platform" + in the readme file. +02/07/29 Revert some changes in the bgi test demos to compile again + with DJGPP. +02/07/29 Corrected an off-by-one error in the raw font driver, by + Dimitar Zhekov. +02/07/29 16-bit fix for BGI and GRX. __gr_WR must match GrColor, by + Dimitar Zhekov. +02/07/29 Changes to the BGI interface, by Dimitar Zhekov. + Inline functions defined as macro and non-inline versions. + BGI number of colors for DOS / BCC limited to < 15bpp. + BGI aspect ratio fixed for 16-bit systems (DOS / BCC). + _BGI_INLINE_ moved to fldfill.c, the only module that uses it now. + Inline functions in text4.c replaced with macros. + Test\bgi\colortst.c fixed to use getch() not getchar(). +02/07/21 Make bccbgi works with Borland C, by Dimitar Zhekov. +02/06/17 Added fontdemo test program, by Dimitar Zhekov. +02/06/17 Added the GrDumpFnaFont fucntion, to save a fon in a ascii + fna file, by Dimitar Zhekov. +02/06/12 Three new font drivers by Dimitar Zhekov: + * RAW driver - for RAW data and Linux PSF (not PCF) files. RAW + data files must be 8 points wide. 512 character PSF files are + supported. For the PSF files contained in Linux systems to be + readable with GRX, you'll have to unzip them. + * FNA driver - for the ascii font format used by grx 1 font + read/write tool. A doc about this format was added to the doc + subdirectory. + * WIN driver - for MS Windows FNT and RES files. FNT versions 2 + and 3 are supported, 32-bit RES and FON files are not. The first + resource from RES is used. As far as I know, all MS Windows-es + from 2.0 to NT 4.0 use FNT version 2 and 16-bit resources packed + into FON for raster fonts. To use the MS Windows .FON files, + split them into .FNT or .RES files using a resource editor. + Note. Big endian support is untested. +02/06/12 Fixes for src/makefile.bcc and test/makefile.bcc, + by Dimitar Zhekov +02/04/29 GrResizeSubContext uses now the parent context coordinates. +02/04/29 Reverted some 'const' that didn't make sense. +02/03/31 The win32 driver accepts arbitrary (user defined) resolution. +02/03/14 A new global switch _GR_textattrintensevideo (false by default) + permits the use (when true) of 16 background colors in + GR_ATTR_TEXT strings. +02/03/13 When the close icon is pressed in the w32 version a dialog + is issued warning it aborts the program. +02/03/12 Fixed some bugs introduced with the new win32 input queue. +02/02/11 The makefile install target installs the grxprint.h file + if printer support is activate +02/02/11 Inprovements to the win32 driver: + Now the GRX window is properly closed, so the previous app + gets the focus. +02/02/02 Inprovements to the win32 driver: + The w32 imput queue implemented as a circular queue. + All the input related code moved to w32inp.c from vd_win32.c + The main window is created in WinMain, so the grx program + can use other videodrivers like the memory one. + Now the printer stuff compiles and run, checked with the + DeskJet driver, printing to a file and them "copy file lpt1", + but the printout is not totally correct (?). + +02/01/11 ----------- GRX v2.4.4 released (Mariano Alvarez Fernandez) +02/01/09 Modified the demogrx test program to center the image when + a mode bigger than 640x480 is selected +02/01/09 Added an alternate linux console input driver, it handles + the mouse directly openning /dev/psaux, but note only PS/2 + mouses work by now. It must be activate explicitly by + uncomenting the switch "USE_DIRECT_MOUSE_DRIVER=y" in + "makedefs.grx" +02/01/09 The linux framebuffer video driver now set the console in + graphics or text mode when necesary. Now the text cursor is + not show, and the svgalib mouse input driver doesn't collide + with GPM, so, surprise!, it works! +02/01/09 Small changes to improve the linux console input driver +02/01/07 More patches to the Pascal interface, by Frank Heckenbach and + Maurice Lombardi +02/01/02 Go to full screen in the Win32 driver if the requested framemode + dimensions are equal to the screen dimensions (setting the + client start area at 0,0). +01/12/22 More patches to the Pascal interface, by Frank Heckenbach and + Maurice Lombardi +01/12/22 Added an optional configure script, by Frank Heckenbach +01/12/21 The linuxfb driver now open /dev/fb0 by default. An alternative + frame buffer device can be specified setting the environment + variable $FRAMEBUFFER +01/12/21 pascal ega colors are now functions, by Frank Heckenbach +01/12/21 fixed some borland bgi incompatibilities, by Frank Heckenbach +01/12/21 added 'const' (C) and 'protected' (Pascal) to some + function parameters, to make them a little "safer", + by Frank Heckenbach +01/12/16 Added imgview.pas and colortst.pas demo programs, by + Frank Heckenbach +01/12/16 Change in the pascal interface: GrAllocEgaColors, GrGetScanline, + etc. return a pointer to an array of GrColor, rather than to a + single GrColor, by Frank Heckenbach +01/12/16 Make installation of shared libraries optional on Linux/X11 + by Frank Heckenbach +01/12/16 GrSaveContextToGrayJpeg added to the pascal interface, by + Maurice Lombardi +01/11/29 better w32 keyboard handling. Now most special keys with + shift, alt and control combinations works +01/11/29 added jpeg functions to grx.pas and jpgtest.pas demo, by + Maurice Lombardi +01/11/29 patch to define gpc-main in grx.pas and graph.pas, by + Frank Heckenbach +01/11/29 patch to remove warnings on unix in test/bgi programs, by + Frank Heckenbach +01/11/16 Added new function: GrSaveContextToGrayJpeg. Now + GrLoadContextFromJpeg can load grayscale jpeg files +01/11/08 jpgtest test program added. It works too without jpeg support + and shows a message +01/11/08 New jpeg functions (GrSaveContextToJpeg, GrLoadContextFromJpeg, + GrQueryJpeg, GrJpegSupport). Added dummy functions if there + isn't jpeg support +01/11/07 Added new targets to makefiles: install-info, unisntall-info. + Now install doesn't install info (readme file updated) +01/09/08 Applied additional patches to update Pascal interface, new + polytest.pas demo, by Maurice Lombardi +01/09/07 Applied patches to update the Pascal interface, by + Frank Heckenbach. Note, the "bgi2grx" unit was renamed to + "Graph", so it will be BP compatible and more natural to + Pascal programmers + +01/06/28 ----------- GRX v2.4.3 released (Mariano Alvarez Fernandez) +01/06/27 Added new targets to makefiles: install-bin, uninstall-bin, + install-fonts and uninstall-fonts (readme file updated) +01/06/26 Moved bin2c, fnt2c, vesainfo, lfbinfo and modetest to + src/utilprog. They are build in the source makefile. +01/06/22 Except for the w32 version the install target installs the + info manual. As suggested by Maurice Lombardi and Waldemar + Schultz +01/06/21 pngtest test program added. It works too without png support + and shows a message +01/06/20 Changed BCCGRX cleardevice function to clear the screen to + the current BACKGROUND color instead of black. Suggested by + Waldemar Schultz +01/06/19 ctx2png functions (GrSaveContextToPng, GrLoadContextFromPng, + GrQueryPng, GrPngSupport) integrated in GRX. src/pnm subdir + renamed to src/gformats. Added dummy functions if there isn't + png support +01/06/18 New API functions: GrLoadContextFromPnmBuffer and + GrQueryPnmBuffer + +01/06/15 ----------- GRX v2.4.2 released (Mariano Alvarez Fernandez) +01/06/12 Modified win32 input code for GrMouseGetEvent and GrKeyRead + work at the same time, when GrMouseEventEnable(1,0) is set +01/06/07 Merged makedefs.gnu, makedefs.x11, makedefs.dj2 and + makedefs.w32 in makedefs.grx (readme file updated) +01/06/06 Now we can use "GRXMain" for all GRX versions, grx20.h defines + it like "main" except for the win32 version. Deleted the ugly + "#ifdef __WIN32__ ..." in test programs (except for BGI tests) +01/06/05 Added the Linux framebuffer videodriver (vdrivers/vd_lnxfb.c) + alpha stage, only in 16 or 24 bpp. To use it set GRX20DRV to + "linuxfb" in the GRX Linux version. The mouse doesn't work +01/06/05 Some minimal changes to compile ok with gcc 2.96 and + Linux 2.4.x +01/05/30 Applied patch to sanity bgi code for gcc 3.0, by Andris + Pavenis +01/05/28 Modified makefiles for linux and x11. Now they build + shared and static libs at the same time. Added install and + uninstall targets. +01/05/16 Applied patch to add standard pascal makefiles for dj2, w32, + x11 and lnx. pascal/bgi/test and pascal/bgi/demo merged in + pascal/bgi. Pascal readme updated. By Maurice Lombardi +01/05/09 Applied patch to produce makefiles for mingw32 pascal tests + by Maurice Lombardi + +01/04/26 ----------- GRX v2.4.1 released (Mariano Alvarez Fernandez) +01/04/25 User's guide (info) updated, by Vicente Fuentes Gea +01/04/20 User's guide (html) updated +01/04/19 Applied partially patches to make GRX compile with MS-VC + by Hartmut Schirmer +01/04/18 Added install and uninstall targets to src/makefile.dj2 and + src/makefile.w32 +01/04/18 Patched src/bgi/text7.c to compile Ok with GCC 3.0 + by Andris Pavenis +01/04/14 New API routine: GrBitBlt1bpp, contributed by Josu Onandia + Added bb1test.c test program +01/04/01 Changed compiler options from "-O6 -fomit-frame-pointer" to + "-O2" only. Suggested by Andris Pavenis. +01/03/27 drawpattern and bltr2v_24 added to fdrivers/fd_win32.c +01/03/26 Fixed a bug in pnm/ctx2pnm.c, when grx == NULL the actual context + must be used. Reported by Vicente Fuentes Gea +01/03/25 The dj2 version uses now "uclock" in mouse/input.h to get 1ms + resolution in input code. Because "uclock" can be unsafe in W3.1 + when NO_REPROGRAM_TIMER is defined the old code is used. A + comment has been added to makedefs.dj2 +01/03/25 Changed CLOCKS_PER_SECOND by CLK_TCK for linux in mouse/input.h + to get real ticks per second +01/03/24 New API routines: GrSetWindowTitle and GrSleep +01/03/22 Changed DJGPP test macro from __GO32__ to __DJGPP__ + by Andris Pavenis + +01/03/18 ----------- GRX v2.4 released (Mariano Alvarez Fernandez) +01/03/16 Win32 drivers improved again by Josu Onandia +01/03/15 Make bccbgi to use ../rand.h to work with the Win32 drivers +01/03/14 Added ifdef to demo programs to use GRXMain with the Win32 drivers +01/03/12 Fixed a bug in mouse/xwinkeys.c, preventing getkey & kbhit work + together (Now bccbgi demo works properly in X, except restoring + from text mode) +01/03/10 Support for DJGPP v1 removed (really only removed makefiles by now) +01/03/10 Optimized pnm/ctx2pnm.c, contributed by Josu Onandia +01/03/10 Improved frame and video drivers for win32, by Josu Onandia + +01/03/06 Integrated the win32 version written by Gernot Graeff + +01/03/05 Fixed bug in modetest.c preventing 32 bpp modes to work. +01/03/04 Applied patch to solve 32bpp problems, by Hartmut Schirmer +01/03/03 Applied patch to make GRX compile with gcc 3.0, by Andris Pavenis +01/03/03 Fixed bug in pattern/fillpatt.c +01/02/26 Modified setmode.c and svgalib.c to set frame pointer dinamicaly + and fix the svgalib video driver. +01/02/22 Applied some patches by Maurice Lombardi + +01/02/20 Fixed bug in pattern/patfbox.c +01/02/14 Fixed bug preventing GrLoadFont work with BGI fonts + +01/02/12 ----------- GRX v2.3.4 released (Mariano Alvarez Fernandez) +01/02/06 user's manual in info format contributed by Vicente Fuentes Gea + +01/02/01 new WIN32 Mingw32 target (memory driver only) +01/01/28 ctx2pnm functions added. +01/01/28 user's manual updated again. +01/01/28 new test programs added: pnmtest and demogrx. +01/01/28 some test programs bug fixes. +01/01/28 pascal subdirectory update contributed by Eike Lange + + +01/01/24 ----------- GRX v2.3.3 released (Mariano Alvarez Fernandez) +01/01/21 BGI test programs moved to test/bgi +01/01/21 Added the updated GRX user's guide. +01/01/20 BCC2GRX license comments changed to point to the GRX license. +01/01/20 Sources changed to point to the copying.grx file +01/01/10 Applied some patches by Andris Pavenis. + +00/09/14 ----------- GRX v2.3.2 released (Peter Gerwinski) + +00/06/21 ----------- GRX v2.3.1 released (Peter Gerwinski) +00/06/21 Some bug fixes (solved problems induced by the update). + +00/05/20 ----------- GRX update released (Hartmut Schirmer) +00/05/20 Added AIX support in grx20.h, xwininp.c, allocate.h as + suggested by Andris Pavenis . + Added BGI-Support from BCC2GRX. +00/05/19 Don't use GCC/i386 asm in highlow.h on gcc after v2.8.x +00/05/17 Added test/sbctest.c contributed by + Mariano Alvarez Fernandez + Fixed additional subcontext bugs in GrPatternFilledLine + and GrPatternFilledPlot (reported by Mariano Alvarez + Fernández ) + Applied the 32bit X11 patch by Ulrich Leodolter +00/04/23 Applied some changes suggested by Josu Onandia + + - pattern/patfbox.c: Context offset wasn't added + to drawing coordinates + - text/buildfnt.c: Fixed a typo, pointer to passed + free() not same as returned by malloc() + - mouse/drawcurs.c: Incorrect calculation of mouse + cursor work area + Applied asm bugfixes by Ian Miller + required for EGCS/GCC compilers after v2.8.x + and for binutils after v2.9.1 + Changed GRX internal version to 0x0231 + Changed return type of main in test/textpatt.c to int +00/04/06 Fixed an uninitialized variable reported by Josu Onandia + n wideline/drwcpoly.c +98/06/28 Updated addons/print test files + Added a note to DJGPP & BCC src/makefiles that command.com + is required as shell +98/06/08 GCC asm enhancements (arith.h,ioport.h,highlow.h) +98/06/07 fine tuning mach64 banking functions +98/06/06 Fixed a typo in addons/ctx2jpeg.c + DJGPP&BCC didn't cleanup the addons subdir's + DJGPP v1 failed on grxprint.c compilation + Added optimized GCC/i386 asm repfill_b code + +98/06/03 ----------- GRX v2.3 released (Hartmut Schirmer) +98/05/26 Fixed a bug in gcc/highlow.h +98/05/24 Printing code synced with Andris + Some additional files needed memcopy.h + X11R6 driver was broken (XInitImage) -- fixed +98/05/20 DOS _GrUpdateInputs() still used getxkey -- fixed + ram3x8, ega4, herc1 & dosinput didn't include memcopy.h + System endian can now be defined by -D_BIG_ENDIAN or + -D_LITTLE_ENDIAN at compile time +98/05/19 GrSetFontPath() still used alloca -- fixed + Again fixed minor problems in printing code: + - some functions where declared extern but + implemented static + - signed / unsigned problem in RepeatByte() +98/05/18 Update printing support. + There were no RAM drivers for 1 & 4bpp in X11 + build. + Fixed a bug on short hlines in ram1 & ram4 + GRX uses it's own memcopy now +98/05/17 Watcom makefiles changed for DEBUG support and + .dat copy from test/ to bin/ +98/05/14 Some code fixes to avoid warnings fron SUN cc +98/05/13 Minor changes to avoid warnings on several platforms + (eg, eliminated C++ style comments, non ASCII chars, ...) +98/05/11 Fixed LFB frame buffer address handling when + LFB_BY_NEAR_POINTER active + JPEG & TIFF save now use GrGetScanlineC() and + malloc() instead of alloca() +98/05/10 Fixed a typo in watcom/memfill.h + GCC v2.8.1 broke dependency file creation under + DJGPP v2, no subdir information was included for + the target. The gcc -MM output is now passed through + a new sed script and the created dep-file should be + ok on any version GCC. Same change for Linux and X11 + makefile. This change makes Watcom makefile creation + by utils/watmake work again. + Again fixed Watcom makefiles + Added -DGRX_DEFAULT_FONT_PATH="...." configuration for + default font path when no GRXFONT environment entry + specified. This is mostly useful on Unix platforms. + Getting scanline changed for GrPixel / GrPixelC + like naming: GrGetScanline && GrGetScanlineC +98/05/07 Watcom updates (bmp/printing/makefiles) + Minor BMP & printing updates for better Unix support +98/05/06 Fixed a bug in _GrFrDrvGenericStretchBlt() + Fixed potential bug in GrImageFilledBoxAlign() +98/05/05 GrGetScanline && GrPutScanline functions added +98/05/04 GCC/i386 peek_24 was broken + Image streching fixes and imgtest prog +98/05/03 Added getindexscanline() and putscanline() to frame + drivers and implemented generic versions. + Added _GrFrDrvGenericStretchBlt() using integer + arithmetic and the new scanline functions. + Fixed dynamic memory allocation bugs im image code. + GrImageStretch() now uses _GrFrDrvGenericStretchBlt() +98/04/30 Pascal definition for GrGetLibrarySystem + Changed VBE2 memory mapped IO support so a buggy BIOS + won't break the code that easily +98/04/28 Pattern filling uses predefined _GrPatternFiller instead + of local initialized var + S3 drivers banking functions enhanced + Unified DJGPP & Watcom VBE2 code +98/04/27 Fixed problems in font loading code on big endian systems + Updated Watcom support + Again eliminated some empty macro args + Added GrGetLibrarySystem() returning GRX_VERSION for + portable runtime system check +98/04/26 Fixed a bug introduced when changing pattern filled text + code +98/04/22 (Pattern-) fill code unified & simplified. + Fixed a filling bug on big endian systems. + Makefiles updated (printing, zlib) + Configuration switches for 'noisy' compilers + Code cleanups and splitted some files +98/04/21 Better cooperation between X11 and GRX in Pseudocolor mode + Added GrAllocEgaColors() for allocation standard EGA colors + Borland-C++ 4bpp blit was broken. + Relaxed some macro argument handlings for older BCC versions +98/04/20 GRX should work on X11R5 systems now. + Added some new key definitions (shift left/right/up/down). + Changed inline -> INLINE for portability. + Removed empty arguments in clipping.h + Again fixed minor problems. +98/04/15 Added X11 driver changes by Ulrich. Fixes the XGetImage problem. + Fixed several portability problems, mainly removed cast + to (unsigned) int of assigned variables. + Fixed some bugs Thomas found in the ALPHA code + Changed temp. memory allocation. New function ALLOC() + will use malloc if SMALL_STACK defined of alloca otherwise. + Watcom assembler code didn't work. Changed the #pragma + definitions so they don't use macros. + Fixed several minor bugs +98/04/13 Fixed minor bugs in X11 driver. +98/04/06 Checked GNU-Pascal support (basic functions only) +98/04/05 Minor bugfixes and some GCC/386 speedups (copy & fill + loops aligned on 16byte boundary for optimal performance) + Changed the mouse timing information to real world time + instead of user process time (X11 & Linux) + GrMouseGetEventT will only return a valid ev.dtime if + any event occured +98/04/02 Faster VGA8X line drawing + The far (eg. to video ram) peek and poke operations + won't get optimized away any more (solves 4bpp blit bug) +98/03/31 Added 64 bit support (_h) + Fixed a bug in egavga1.c/drawvline +98/03/30 Integrated Gary's Watcom changes. + Watcom port now defined LFB_BY_NEAR_POINTER + Added _n as near/normal opposite of _f in macro names to + avoid empty arguments in macro calls +98/03/27 Borland port now uses RAM3x8 in 24bpp and 32bpp modes + Fast and robust colfill_... functions for Borland + Updated image support +98/03/19 24bpp mode changed: + - Added repfill_24 and optimized peek_24/poke_24 + - dropped access24.h (only color component access left) + - LFB24 and RAM24 now use the same code. + - Optimization for black/grey/white filling: done by repfill_b + Fixed some Linux/386 shared lib problems (can't use EBX with -fPIC) +98/03/17 Major code rearrangement: (Watcom port may be broken :(( + - A lot of frame driver now share code and use much + more optimized (!= generic) drawing functions + - Generic and asm fwdcopy/revcopy functions for blitting + - splitted header files to individual system files + (filling, copying, ...) for better maintaince and + easier optimization + - much work on BCC speed & stability + - Expect the Watcom port to be broken :(( + Added Andris latest changes to the printing system +98/02/25 Fixed X11 keyboard handling + minor changes for BSD compilation + updates to printing system +98/02/24 Fixed a bug in GrDestroyPattern() when freeing the + bitmap planes (found&patched by Michal). + access24.h needed another fix for linux shared lib :( +98/02/20 Added BMP file read && image display contributed + by Michal Stencl + Added JPEG context save by Vincenzo Morello +98/02/19 Watcom makefiles, fixes to print system + Changed access24.h for shared library compilation + on Linux-i386 systems +98/02/17 Watcom fixes and addons by Gary + Fixed svga4, lfb8 and vga8x blit functions + Added color selection by bpp to GrSetMode + Added patterned text output by Stencl Peter + Added printing support (thanks again Andris!) +98/01/13 fast RAM to video blit to 16 color driver + fast hline for 16 color RAM driver +98/01/08 Watcom support integrated. Code cleanup (eg. gcc + multi line strings cleaned for other compilers) + Added platform dependent lib-subdirs + Fixed some Linux/svgalib keyboard bugs +98/01/01 Revised keyboard support as suggested by Andris and + Vincenzo. See new grxkeys.h file in include dir! +97/12/21 Updated DJGPP (v1&v2) makefiles again. + Fixed some GCC warnings with additional -W... switches + (WARNOPTS in makedefs.gnu) + Fixed a BCC problem with the new 16 color blit function + Some local functions didn't have a static :( + Fixed some Linux && X11 keyboard problems (input got + desynced on heavy load / high keyrates) +97/12/18 updated Pascal support + BCC allocates from heap instead of stack for big blocks + eliminated some unchecked malloc's + Splitted several code files for smarter linking + BCC arithmetic moved from assembler macro to optimized + function for more reliable results +97/12/16 ported the flood fill function from BCC2GRX. See grx20.h + for ...FloodFill +97/12/15 changed ulong, ushort, etc to GR_int32u, GR_int16u, etc + for better portability and to avoid warnings on Linux +97/12/08 Integrated code (variable X11 window size & memory driver) + and patches (genellip & SaveContextToTiff & other) by Andris +97/11/16 Updated Linux and X11 makefiles +97/11/02 Makefiles for DJGPP v1 compilation + New (much faster) 16 color video to video blit routine +97/11/01 Fixed some far pointers to RAM area in the video drivers +97/10/29 Added ALPHA processor support +97/10/01 Fixed DJGPP systag generation in SRC makefile +97/09/30 Updated makefiles and makedefs + Added the addons directory and the SaveContextToTiff + function + Fixed some BCC specific warnings + S3 driver banking doesn't work for 16 color modes, at + least for my card. Uses VESA banking for < 256 colors + Fixed BCC __emit__() code in arith.h (thanks, Andris) +------- grx v2.2 release diff --git a/thirdparty/grx249/doc/copying.cb b/thirdparty/grx249/doc/copying.cb new file mode 100644 index 0000000..e6f7c19 --- /dev/null +++ b/thirdparty/grx249/doc/copying.cb @@ -0,0 +1,50 @@ +This is the original Csaba Biegl copying file, it will be here until +all source files will be updated to point to ../copying.grx +The license terms have not changed. + +-------------------------------------------------------------------- + +This is file "copying.cb". + +This document describes the terms for distributing the source code of and any +derived work based on the GRX graphics library. Such source code is marked +with the copyright notice: + + "Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221" + +Source code with the above copyright is distributed under the following terms: + + (1) The test programs for the graphics library (code in the 'test' + sub-directory) is distributed without restrictions. This code + is free for use in commercial, shareware or freeware applications. + + (2) The GRX graphics library is distributed under the terms of the + GNU LGPL (Library General Public License) with the following amendments + and/or exceptions: + + - Using the DOS versions (DOS only! this exception DOES NOT apply to + the Linux version) you are permitted to distribute an application + linked with GRX in binary only, provided that the documentation + of the program: + + a) informs the user that GRX is used in the program, AND + + b) provides the user with the necessary information about + how to obtain GRX. (i.e. ftp site, etc..) + + (3) Fonts (in the 'fonts' directory) are distributed according to the + terms in the file "COPYING.MIT". Most of the fonts included with the + GRX library were derived from fonts in the MIT X11R4 distribution. + The exception is the "pc" BIOS font family, which is distributed + without restrictions. + +A copy of the GNU GPL (in the file "COPYING") and the GNU LGPL (in +the file "COPYING.LIB") is included with this document. If you did +not receive a copy of "COPYING" or "COPYING.LIB", you may obtain one +from where this document was obtained, or by writing to: + + Free Software Foundation + 675 Mass Ave + Cambridge, MA 02139 + USA + diff --git a/thirdparty/grx249/doc/credits.doc b/thirdparty/grx249/doc/credits.doc new file mode 100644 index 0000000..7d32ed3 --- /dev/null +++ b/thirdparty/grx249/doc/credits.doc @@ -0,0 +1,123 @@ +CONTRIB.DOC +=========== + +GRX was original written by Csaba Biegl +for DJ Delorie's DOS port of the GCC compiler. + +Michael Goffioul released GRX 2.1a +(first full API implementation). + +Starting from version v2.2 GRX was maintained by Hartmut Schirmer +. + +Peter Gerwinski released GRX 2.3.1 and 2.3.2. + +Mariano Alvarez Fernandez (malfer@telefonica.net) released GRX 2.3.3, +2.3.4 and the 2.4.0-6 series. + +Maurice Lombardi packed together +various contributions to release GRX 2.4.7-9 + +Credits for GRX > v2.0 in alphabetical order +============================================ + +Csaba Biegl for the post v2.0 developers +source code (and of course: MANY THANKS FOR THE GREAT GRX LIB !). + +N. D. Culver for suggesting the bpp based color +spec with GrSetMode(). + +Thomas Demmer for inprovements and good ideas +with the win32 driver. + +Frank Donahoe for bug reports and patches. + +Vicente Fuentes Gea for the info version of the +user's manual. + +Michael Goffioul for his GREAT work: + - Pattern Filled functions + - Patterned Line functions + - Custom Line functions + - User Coordinates functions + +Gernot Graeff for the Win32 driver. + +Thomas Hahn for the ALPHA +processor patches (64bit support). + +Frank Heckenbach for Pascal interface updates, +configure script and many others inprovements. + +Sven Hilscher for GNU-Pascal interface and +bug reports. + +Eike Lange for Pascal updates. + +Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] for linear framebuffer +support. + +Maurice Lombardi for many patches +and bug reports. + +Peter C. Mehlitz for his suggestions on +Linux and X11 event time handling + +Vincenzo Morello continous using GRX as base +graphics API for his MGUI lib. He submitted many suggestions, +found lots of bugs and contributed the SaveContextToJpeg() code. + +Josu Onandia for patches, bug reports +and lot of inprovements to the Win32 driver. + +Andris Pavenis for many suggestions, the +memory driver, printing support, variable X11 resolution, patches +and bug reports. + +Gary Sands did the Watcom C++ port. + +Daniel Skarda <0rfelyus@atrey.karlin.mff.cuni.cz> for Linux shared +libraries and bug reports. + +Anton Norup Soerensen for patches and bug reports. + +Michal Stencl for the pattern text +output, BMP handling and image display functions. + +Waldemar Schultz for bug reports. + +Michael for bug reports. + +Dimitar Zhekov for three new font drivers, makefile +fixes for the bcc version, bgi updates, X11 fixes and the Xfree86 DGA2 +video driver. + +########################################################################### +This is the original contrib.doc by Csaba Biegl (csaba@vuse.vanderbilt.edu) +########################################################################### + +This is a (far from complete) list of people who sent me ideas, bug reports +or useful code pieces during the development of GRX 2.0. + +This file is under construction (I need to go back in my e-mail records to +see who sent me bug reports, ideas, etc...). Currently it has only the most +recent contributions. If you think you sent me something for which you should +be mentioned here, but you don't see your name in the list, drop me an e-mail. +I may have lost same of the older correspondence. + +Hartmut Schirmer (hsc@techfak.uni-kiel.de) for many good ideas, bug reports, +the BGI font loader sources and the protected mode VESA paging code. + +Christian Domp (alma.student.uni-kl.de) for bug reports, the 90x30, 94x30 +90x34 and 94x34 text modes in the stdvga driver and for fixing the HiColor +and TrueColor modes in the et4000 driver. + +Ulrich Leodolter (ulrich@lab1.psy.univie.ac.at) for the wonderful X11 +video, frame and font drivers, bug reports and the DOS Hercules video +driver. + +Daniel Skarda (DSKA4435@novell.karlin.mff.cuni.cz) for bug reports. + +Mauro Condarelli (mc5686@mclink.it) for the Linux SVGA version keyboard +enhancements. + diff --git a/thirdparty/grx249/doc/fna.txt b/thirdparty/grx249/doc/fna.txt new file mode 100644 index 0000000..1af5a2f --- /dev/null +++ b/thirdparty/grx249/doc/fna.txt @@ -0,0 +1,140 @@ +ASCII FONT FORMAT + +This document describes the ascii font format, FNA, as found in GRX 1 font +read/write-tool and GRX 2 FNA driver. + +FILE FORMAT + +An ascii font file consists of lines. Each line consists of zero or more +8-bit characters and is terminated by a line feed, a carriage return or a +carriage return followed by a line feed, depending on the operating system. +Line length must not exceed 129 characters with the line terminators and 127 +characters without them. Trailing blanks are allowed (and ignored), while +leading blanks are not allowed. Lines starting with semicolon are comments. +They are ignored, and so are the blank lines. + +HEADER + +An ascii font file starts with a header. The header must specify at least 8 +font properties. Each property is on a separate line, can only be specified +once and has the general form: + + + +where separator consists of one or more blanks. + +Required properties: + +name + +Font name. + +family + +Font family. + +isfixed <0|1> + +0 for proportional or 1 for monospaced fonts. Any non-zero value is treated +as 1. + +width + +Font width for monospaced fonts. + +avgwidth + +Average font width for proportional fonts. + +Note: monospaced fonts should only specify width, and proportional fonts +should only specify avgwidth. The GRX FNA driver does not check for that. It +expects one width or avgwidth property for each font, no matter the spacing. + +height + +Font height. + +minchar + +The character with which the font starts. Usually 32 (ascii space). + +maxchar + +The character with which the font ends. Must be > minchar. The number of +characters in an ascii font file equals to maxchar - minchar + 1. + +baseline + +Font baseline. 1-based. + +minwidth + +The narrowest character width (proportional fonts only). Must be non-zero. +Ignored by the driver. + +maxwidth + +The widest character width (proportional fonts only). Must be <= 127. Ignored +by the driver. + +Note: the driver does not require minwidth and maxwidth, but any proper ascii +font header should include them when describing a proportional font. + +Optional properties: + +undwidth + +Underline height in lines. The default is height / 15 rounded down, or 1 if +the font height is < 15. + +note + +Comment. May be empty. Any number of comments may be specified. The usual +comments are the font XFDL name and copyright. Ignored by the driver. + +Note: the comments starting with semicolon are always ignored, while the note +comments may be taken into account by a non-GRX driver or program. + +DATA + +The file header is followed by data lines. +Each data lines describe one character scan line by scan line. These +lines must all be characters long, where is the width of the +character being described. Each line describes one character scan line bit by +bit from left to right: period for 0-bit, number sign for 1-bit. A blank line +and a comment are usually placed before each lines to make the file +more readable. Hope my english was good enought, and here is an example: + +; character 36 ($) width = 8 +........ +...#.... +...#.... +.#####.. +#..#..#. +#..#.... +#..#.... +.#####.. +...#..#. +...#..#. +#..#..#. +.#####.. +...#.... +...#.... + +If the character being described is less than 33 (exclamation) or greater +than 96 (asciitilde), the comment is shorter: + +; character 255 width = 8 + +Note: both the blank line and the comment are ignored and DO NOT act as +character data separators. Do not let them fool you and check if there are +exactly data lines for each character. The driver will not read a +file without enough data in it, but will silently ignore any extra data. + +THE END + +No non-blank lines should follow the data, except for semicolon comments. The +driver does not check for that. Placing one blank line after the data is not +a practice. + +For a full ascii font example, see ter-114n.fna in the GRX fonts directory. diff --git a/thirdparty/grx249/doc/grx249um.html b/thirdparty/grx249/doc/grx249um.html new file mode 100644 index 0000000..9b696c3 --- /dev/null +++ b/thirdparty/grx249/doc/grx249um.html @@ -0,0 +1,2470 @@ + + +GRX 2.4.9 User's Manual + + + + + + + + + + +
+

GRX +2.4.9

+

a 2D graphics library for DOS, Linux, X11 and Win32

+

User's Manual

+

Based on the original doc written by: Csaba Biegl on August 10, 1992 +

Updated by: Mariano Alvarez Fernández on August 17, 2000 +

Last update: July 10, 2012 +

+ +
+ +


+Next:  +
+ + + +

Abstract

+ +

GRX is a 2D graphics library originaly written by +Csaba Biegl for DJ Delorie's DOS port of the GCC compiler. Now it support +a big range of platforms, the main four are: DOS (DJGPPv2), Linux console, +X11 and Win32 (Mingw). On DOS it supports VGA, EGA and VESA compliant cards. +On Linux console it uses svgalib or the framebuffer. On X11 it must work on +any X11R5 (or later). From the 2.4 version, GRX comes with a Win32 driver. +The framebuffer Linux console driver was new in 2.4.2. From 2.4.7 there is a +support for x86_64 bits Linux machines and a support for an SDL driver +on MingW and X11. On MingW and X11 it runs on a window with the original +driver, and either full screen or on a window with the SDL driver. + +

+ + +
+ +


+Next: , +Previous: Top, +Up: Top + +
+ +

GRX2 User's Manual

+ + + + + + +

Hello world

+ +

The next program draws a double frame around the screen and writes "Hello, GRX +world" centered. Then it waits after a key is pressed. + +

     #include <string.h>
+     #include <grx20.h>
+     #include <grxkeys.h>
+     
+     int main()
+     {
+       char *message = "Hello, GRX world";
+       int x, y;
+       GrTextOption grt;
+     
+       GrSetMode( GR_default_graphics );
+     
+       grt.txo_font = &GrDefaultFont;
+       grt.txo_fgcolor.v = GrWhite();
+       grt.txo_bgcolor.v = GrBlack();
+       grt.txo_direct = GR_TEXT_RIGHT;
+       grt.txo_xalign = GR_ALIGN_CENTER;
+       grt.txo_yalign = GR_ALIGN_CENTER;
+       grt.txo_chrtype = GR_BYTE_TEXT;
+     
+       GrBox( 0,0,GrMaxX(),GrMaxY(),GrWhite() );
+       GrBox( 4,4,GrMaxX()-4,GrMaxY()-4,GrWhite() );
+     
+       x = GrMaxX()/2;
+       y = GrMaxY()/2;
+       GrDrawString( message,strlen( message ),x,y,&grt );
+     
+       GrKeyRead();
+     
+       return 0;
+     }
+     
+
+

How to compile the hello world (assuming the GRX library was +previously installed) +

       DJGPP: gcc -o hellogrx.exe hellogrx.c -lgrx20
+       Mingw: gcc -o hellogrx.exe hellogrx.c -lgrx20 -mwindows
+       X11  : gcc -o hellogrx hellogrx.c -D__XWIN__ -I/usr/X11R6/include
+              -lgrx20X -L/usr/X11R6/lib -lX11
+       Linux: gcc -o hellogrx hellogrx.c -lgrx20 -lvga
+     
+       For the SDL driver:
+       Mingw: gcc -o hellogrx.exe hellogrx.c -lgrx20S -lSDL
+       X11  : gcc -o hellogrx hellogrx.c -D__XWIN__ -I/usr/X11R6/include
+              -lgrx20S -lSDL -lpthread -L/usr/X11R6/lib -lX11
+     
+       For x86_64 systems add -m32 or -m64 for 32/64 bits executables
+       and replace /lib by /lib64 or /lib32 as needed
+     
+
+ + + +

Data types and function declarations

+ +

All public data structures and graphics primitives meant for usage by the +application program are declared/prototyped in the header files (in the +'include' sub-directory): + +

        * grdriver.h   graphics driver format specifications
+        * grfontdv.h   format of a font when loaded into memory
+        * grx20.h      drawing-related structures and functions
+        * grxkeys.h    platform independent key definitions
+     
+     User programs normally only include include/grx20.h and include/grxkeys.h
+
+ + + +

Setting the graphics driver

+ +

The graphics driver is normally set by the final user by the environment +variable GRX20DRV, but a program can set it using: + +

     int GrSetDriver(char *drvspec);
+
+

The drvspec string has the same format as the environment variable: + +

     <driver> gw <width> gh <height> nc <colors>
+
+

Available drivers are for: + +

     * DOS => herc, stdvga, stdega, et4000, cl5426, mach64, ati28800, s3, VESA, memory
+     * Linux => svgalib, linuxfb, memory
+     * X11 => xwin, memory
+     * Win32 => win32, memory
+     * SDL (Win32 and X11) => sdl::fs, sdl::ww, memory
+
+

The xwin and win32 drivers are windowed. +The SDL driver on the same systems can be either fullscreen (::fs) or windowed (::ww). + +

The optionals gw, gh and nc parameters set the desired default graphics mode. +Normal values for 'nc' are 2, 16, 256, 64K and 16M. The current driver name can +be obtained from: + +

     GrCurrentVideoDriver()->name
+
+ + + +

Setting video modes

+ +

Before a program can do any graphics drawing it has to configure the graphics +driver for the desired graphics mode. It is done with the GrSetMode function as +follows: + +

     int GrSetMode(int which,...);
+
+

On succes it returns non-zero (TRUE). The which parameter can be one of the +following constants, declared in grx20.h: + +

     typedef enum _GR_graphicsModes {
+       GR_80_25_text,
+       GR_default_text,
+       GR_width_height_text,
+       GR_biggest_text,
+       GR_320_200_graphics,
+       GR_default_graphics,
+       GR_width_height_graphics,
+       GR_biggest_noninterlaced_graphics,
+       GR_biggest_graphics,
+       GR_width_height_color_graphics,
+       GR_width_height_color_text,
+       GR_custom_graphics,
+       GR_width_height_bpp_graphics,
+       GR_width_height_bpp_text,
+       GR_custom_bpp_graphics,
+       GR_NC_80_25_text,
+       GR_NC_default_text,
+       GR_NC_width_height_text,
+       GR_NC_biggest_text,
+       GR_NC_320_200_graphics,
+       GR_NC_default_graphics,
+       GR_NC_width_height_graphics,
+       GR_NC_biggest_noninterlaced_graphics,
+       GR_NC_biggest_graphics,
+       GR_NC_width_height_color_graphics,
+       GR_NC_width_height_color_text,
+       GR_NC_custom_graphics,
+       GR_NC_width_height_bpp_graphics,
+       GR_NC_width_height_bpp_text,
+       GR_NC_custom_bpp_graphics,
+     } GrGraphicsMode;
+
+

The GR_width_height_text and GR_width_height_graphics modes require the two +size arguments: int width and int height. + +

The GR_width_height_color_graphics and GR_width_height_color_text modes +require three arguments: int width, int height and GrColor colors. + +

The GR_width_height_bpp_graphics and GR_width_height_bpp_text modes require +three arguments: int width, int height and int bpp (bits per plane instead +number of colors). + +

The GR_custom_graphics and GR_custom_bpp_graphics modes require five +arguments: int width, int height, GrColor colors or int bpp, int vx and int vy. +Using this modes you can set a virtual screen of vx by vy size. + +

A call with any other mode does not require any arguments. + +

The GR_NC_... modes are equivalent to the GR_.. ones, but they don't clear the +video memory. + +

Graphics drivers can provide info of the supported graphics modes, use the +next code skeleton to colect the data: + +

     {
+       GrFrameMode fm;
+       const GrVideoMode *mp;
+       for(fm =GR_firstGraphicsFrameMode; fm <= GR_lastGraphicsFrameMode; fm++) {
+         mp = GrFirstVideoMode(fm);
+         while( mp != NULL ) {
+           ..
+           .. use the mp info
+           ..
+           mp = GrNextVideoMode(mp))
+         }
+       }
+     }
+
+

Don't worry if you don't understand it, normal user programs don't need to +know about FrameModes. The GrVideoMode structure has the following fields: + +

     typedef struct _GR_videoMode GrVideoMode;
+     
+     struct _GR_videoMode {
+       char    present;                    /* is it really available? */
+       char    bpp;                        /* log2 of # of colors */
+       short   width,height;               /* video mode geometry */
+       short   mode;                       /* BIOS mode number (if any) */
+       int     lineoffset;                 /* scan line length */
+       int     privdata;                   /* driver can use it for anything */
+       struct _GR_videoModeExt *extinfo;   /* extra info (maybe shared) */
+     };
+
+

The width, height and bpp members are the useful information if you are +interested in set modes other than the GR_default_graphics. + +

A user-defined function can be invoked every time the video mode is changed +(i.e. GrSetMode is called). This function should not take any parameters and +don't return any value. It can be installed (for all subsequent GrSetMode calls) +with the: + +

     void GrSetModeHook(void (*hookfunc)(void));
+
+

function. The current graphics mode (one of the valid mode argument values for +GrSetMode) can be obtained with the: + +

     GrGraphicsMode GrCurrentMode(void);
+
+

function, while the type of the installed graphics adapter can be determined +with the: + +

     GrVideoAdapter GrAdapterType(void);
+
+

function. GrAdapterType returns the type of the adapter as one of the following +symbolic constants (defined in grx20.h): + +

     typedef enum _GR_videoAdapters {
+       GR_UNKNOWN = (-1),     /* not known (before driver set) */
+       GR_VGA,                /* VGA adapter */
+       GR_EGA,                /* EGA adapter */
+       GR_HERC,               /* Hercules mono adapter */
+       GR_8514A,              /* 8514A or compatible */
+       GR_S3,                 /* S3 graphics accelerator */
+       GR_XWIN,               /* X11 driver */
+       GR_WIN32,              /* WIN32 driver */
+       GR_LNXFB,              /* Linux framebuffer */
+       GR_SDL,                /* SDL driver */
+       GR_MEM                 /* memory only driver */
+     } GrVideoAdapter;
+
+

Note that the VESA driver return GR_VGA here. + + +

+ +


+Next: , +Previous: Setting video modes, +Up: A User Manual For GRX2 + +
+ +

Graphics contexts

+ +

The library supports a set of drawing regions called contexts (the GrContext +structure). These can be in video memory or in system memory. Contexts in system +memory always have the same memory organization as the video memory. When +GrSetMode is called, a default context is created which maps to the whole +graphics screen. Contexts are described by the GrContext data structure: + +

     typedef struct _GR_context GrContext;
+     
+     struct _GR_context {
+       struct _GR_frame    gc_frame;       /* frame buffer info */
+       struct _GR_context *gc_root;        /* context which owns frame */
+       int    gc_xmax;                     /* max X coord (width  - 1) */
+       int    gc_ymax;                     /* max Y coord (height - 1) */
+       int    gc_xoffset;                  /* X offset from root's base */
+       int    gc_yoffset;                  /* Y offset from root's base */
+       int    gc_xcliplo;                  /* low X clipping limit */
+       int    gc_ycliplo;                  /* low Y clipping limit */
+       int    gc_xcliphi;                  /* high X clipping limit */
+       int    gc_ycliphi;                  /* high Y clipping limit */
+       int    gc_usrxbase;                 /* user window min X coordinate */
+       int    gc_usrybase;                 /* user window min Y coordinate */
+       int    gc_usrwidth;                 /* user window width  */
+       int    gc_usrheight;                /* user window height */
+     # define gc_baseaddr                  gc_frame.gf_baseaddr
+     # define gc_selector                  gc_frame.gf_selector
+     # define gc_onscreen                  gc_frame.gf_onscreen
+     # define gc_memflags                  gc_frame.gf_memflags
+     # define gc_lineoffset                gc_frame.gf_lineoffset
+     # define gc_driver                    gc_frame.gf_driver
+     };
+
+

The following four functions return information about the layout of and memory +occupied by a graphics context of size width by height in the current graphics +mode (as set up by GrSetMode): + +

     int GrLineOffset(int width);
+     int GrNumPlanes(void);
+     long GrPlaneSize(int w,int h);
+     long GrContextSize(int w,int h);
+
+

GrLineOffset always returns the offset between successive pixel rows of the +context in bytes. GrNumPlanes returns the number of bitmap planes in the current +graphics mode. GrContextSize calculates the total amount of memory needed by a +context, while GrPlaneSize calculates the size of a bitplane in the context. The +function: + +

     GrContext *GrCreateContext(int w,int h,char far *memory[4],GrContext *where);
+
+

can be used to create a new context in system memory. The NULL pointer is also +accepted as the value of the memory and where arguments, in this case the +library allocates the necessary amount of memory internally. It is a general +convention in the library that functions returning pointers to any GRX +specific data structure have a last argument (most of the time named where in +the prototypes) which can be used to pass the address of the data structure +which should be filled with the result. If this where pointer has the value of +NULL, then the library allocates space for the data structure internally. + +

The memory argument is really a 4 pointer array, each pointer must point to +space to handle GrPlaneSize(w,h) bytes, really only GrNumPlanes() pointers must +be malloced, the rest can be NULL. Nevertheless the normal use (see below) is + +

     gc = GrCreateContext(w,h,NULL,NULL);
+
+

so yo don't need to care about. + +

The function: +

     
+     GrContext *GrCreateSubContext(int x1,int y1,int x2,int y2,
+                                   const GrContext *parent,GrContext *where);
+
+

creates a new sub-context which maps to a part of an existing context. The +coordinate arguments (x1 through y2) are interpreted relative to the parent +context's limits. Pixel addressing is zero-based even in sub-contexts, i.e. the +address of the top left pixel is (0,0) even in a sub-context which has been +mapped onto the interior of its parent context. + +

Sub-contexts can be resized, but not their parents (i.e. anything returned by +GrCreateContext or set up by GrSetMode cannot be resized – because this could +lead to irrecoverable "loss" of drawing memory. The following function can be +used for this purpose: + +

     void GrResizeSubContext(GrContext *context,int x1,int y1,int x2,int y2);
+
+

The current context structure is stored in a static location in the library. +(For efficiency reasons – it is used quite frequently, and this way no pointer +dereferencing is necessary.) The context stores all relevant information about +the video organization, coordinate limits, etc... The current context can be set +with the: + +

     void GrSetContext(const GrContext *context);
+
+

function. This function will reset the current context to the full graphics +screen if it is passed the NULL pointer as argument. The value of the current +context can be saved into a GrContext structure pointed to by where using: + +

     GrContext *GrSaveContext(GrContext *where);
+
+

(Again, if where is NULL, the library allocates the space.) The next two +functions: + +

     const GrContext *GrCurrentContext(void);
+     const GrContext *GrScreenContext(void);
+
+

return the current context and the screen context respectively. Contexts can be +destroyed with: + +

     void GrDestroyContext(GrContext *context);
+
+

This function will free the memory occupied by the context only if it was +allocated originally by the library. The next three functions set up and query +the clipping limits associated with the current context: + +

     void GrSetClipBox(int x1,int y1,int x2,int y2);
+     void GrGetClipBox(int *x1p,int *y1p,int *x2p,int *y2p);
+     void GrResetClipBox(void);
+
+

GrResetClipBox sets the clipping limits to the limits of context. These are +the limits set up initially when a context is created. There are three similar +functions to sets/gets the clipping limits of any context: + +

     void  GrSetClipBoxC(GrContext *c,int x1,int y1,int x2,int y2);
+     void  GrGetClipBoxC(const GrContext *c,int *x1p,int *y1p,int *x2p,int *y2p);
+     void  GrResetClipBoxC(GrContext *c);
+
+

The limits of the current context can be obtained using the following +functions: + +

     int GrMaxX(void);
+     int GrMaxY(void);
+     int GrSizeX(void);
+     int GrSizeY(void);
+
+

The Max functions return the biggest valid coordinate, while the Size +functions return a value one higher. The limits of the graphics screen +(regardless of the current context) can be obtained with: + +

     int GrScreenX(void);
+     int GrScreenY(void);
+
+

If you had set a virtual screen (using a custom graphics mode), the limits of +the virtual screen can be fetched with: + +

     int GrVirtualX(void);
+     int GrVirtualY(void);
+
+

The routine: + +

     int GrScreenIsVirtual(void);
+
+

returns non zero if a virtual screen is set. The rectangle showed in the real +screen can be set with: + +

     int GrSetViewport(int xpos,int ypos);
+
+

and the current viewport position can be obtained by: + +

     int GrViewportX(void);
+     int GrViewportY(void);
+
+ +
+ +


+Next: , +Previous: Graphics contexts, +Up: A User Manual For GRX2 + +
+ +

Context use

+ +

Here is a example of normal context use: + +

     GrContext *grc;
+     
+     if( (grc = GrCreateContext( w,h,NULL,NULL )) == NULL ){
+       ...process the error
+       }
+     else {
+       GrSetContext( grc );
+       ...do some drawing
+       ...and probably bitblt to the screen context
+       GrSetContext( NULL ); /* the screen context! */
+       GrDestroyContext( grc );
+       }
+     
+
+

But if you have a GrContext variable (not a pointer) you want to use (probably +because is static to some routines) you can do: + +

     static GrContext grc; /* not a pointer!! */
+     
+     if( GrCreateContext( w,h,NULL,&grc )) == NULL ) {
+       ...process the error
+      }
+     else {
+       GrSetContext( &grc );
+       ...do some drawing
+       ...and probably bitblt to the screen context
+       GrSetContext( NULL ); /* the screen context! */
+       GrDestroyContext( &grc );
+       }
+     
+
+

Note that GrDestoryContext knows if grc was automatically malloced or not!! + +

Only if you don't want GrCreateContext use malloc at all, you must allocate +the memory buffers and pass it to GrCreateContext. + +

Using GrCreateSubContext is the same, except it doesn't need the buffer, +because it uses the parent buffer. + +

See the test/winclip.c and test/wintest.c examples. + + +

+ +

Color management

+ +

GRX defines the type GrColor for color variables. GrColor it's a 32 bits +integer. The 8 left bits are reserved for the write mode (see below). The 24 +bits right are the color value. + +

The library supports two models for color management. In the 'indirect' (or +color table) model, color values are indices to a color table. The color table +slots will be allocated with the highest resolution supported by the hardware +(EGA: 2 bits, VGA: 6 bits) with respect to the component color intensities. In +the 'direct' (or RGB) model, color values map directly into component color +intensities with non-overlapping bitfields of the color index representing the +component colors. + +

Color table model is supported until 256 color modes. The RGB model is +supported in 256 color and up color modes. + +

In RGB model the color index map to component color intensities depend on the +video mode set, so it can't be assumed the component color bitfields (but if you +are curious check the GrColorInfo global structure in grx20.h). + +

After the first GrSetMode call two colors are always defined: black and white. +The color values of these two colors are returned by the functions: + +

     GrColor GrBlack(void);
+     GrColor GrWhite(void);
+
+

GrBlack() is guaranteed to be 0. + +

The library supports five write modes (a write mode descibes the operation +between the actual bit color and the one to be set): write, XOR, logical OR, +logical AND and IMAGE. These can be selected with OR-ing the color value with +one of the following constants declared in grx20.h : + +

     #define GrWRITE       0UL            /* write color */
+     #define GrXOR         0x01000000UL   /* to "XOR" any color to the screen */
+     #define GrOR          0x02000000UL   /* to "OR" to the screen */
+     #define GrAND         0x03000000UL   /* to "AND" to the screen */
+     #define GrIMAGE       0x04000000UL   /* blit: write, except given color */
+
+

The GrIMAGE write mode only works with the bitblt function. +By convention, the no-op color is obtained by combining color value 0 (black) +with the XOR operation. This no-op color has been defined in grx20.h as: + +

     #define GrNOCOLOR     (GrXOR | 0)    /* GrNOCOLOR is used for "no" color */
+
+

The write mode part and the color value part of a GrColor variable can be +obtained OR-ing it with one of the following constants declared in grx20.h: + +

     #define GrCVALUEMASK  0x00ffffffUL   /* color value mask */
+     #define GrCMODEMASK   0xff000000UL   /* color operation mask */
+
+

The number of colors in the current graphics mode is returned by the: + +

     GrColor GrNumColors(void);
+
+

function, while the number of unused, available color can be obtained by +calling: + +

     GrColor GrNumFreeColors(void);
+
+

Colors can be allocated with the: + +

     GrColor GrAllocColor(int r,int g,int b);
+     GrColor GrAllocColor2(long hcolor);
+
+

functions (component intensities can range from 0 to 255, +hcolor must be in 0xRRGGBB format), or with the: + +

     GrColor GrAllocCell(void);
+
+

function. In the second case the component intensities of the returned color can +be set with: + +

     void GrSetColor(GrColor color,int r,int g,int b);
+
+

In the color table model both Alloc functions return GrNOCOLOR if there are no +more free colors available. In the RGB model GrNumFreeColors returns 0 and +GrAllocCell always returns GrNOCOLOR, as colors returned by GrAllocCell are +meant to be changed – what is not supposed to be done in RGB mode. Also note +that GrAllocColor operates much more efficiently in RGB mode, and that it never +returns GrNOCOLOR in this case. + +

Color table entries can be freed (when not in RGB mode) by calling: + +

     void GrFreeColor(GrColor color);
+
+

The component intensities of any color can be queried using one of this function: + +

     void GrQueryColor(GrColor c,int *r,int *g,int *b);
+     void GrQueryColor2(GrColor c,long *hcolor);
+
+

Initially the color system is in color table (indirect) model if there are 256 +or less colors. 256 color modes can be put into the RGB model by calling: + +

     void GrSetRGBcolorMode(void);
+
+

The color system can be reset (i.e. put back into color table model if +possible, all colors freed except for black and white) by calling: + +

     void GrResetColors(void);
+
+

The function: + +

     void GrRefreshColors(void);
+
+

reloads the currently allocated color values into the video hardware. This +function is not needed in typical applications, unless the display adapter is +programmed directly by the application. + +

This functions: + +

     GrColor GrAllocColorID(int r,int g,int b);
+     GrColor GrAllocColor2ID(long hcolor);
+     void GrQueryColorID(GrColor c,int *r,int *g,int *b);
+     void GrQueryColor2ID(GrColor c,long *hcolor);
+
+

are inlined versions (except if you compile GRX with GRX_SKIP_INLINES defined) +to be used in the RGB model (in the color table model they call the normal +routines). + +

See the test/rgbtest.c and test/colorops.c examples. + + +

+ +


+Next: , +Previous: Color management, +Up: A User Manual For GRX2 + +
+ +

Portable use of a few colors

+ +

People that only want to use a few colors find the GRX color handling a bit +confusing, but it gives the power to manage a lot of color deeps and two color +models. Here are some guidelines to easily use the famous 16 ega colors in GRX +programs. We need this GRX function: + +

     GrColor *GrAllocEgaColors(void);
+
+

it returns a 16 GrColor array with the 16 ega colors alloced (really it's a +trivial function, read the source src/setup/colorega.c). We can use a +construction like that: + +

First, in your C code make a global pointer, and init it after set the +graphics mode: + +

     GrColor *egacolors;
+     ....
+     int your_setup_function( ... )
+     {
+       ...
+       GrSetMode( ... )
+       ...
+       egacolors = GrAllocEgaColors();
+       ...
+     }
+     
+
+

Next, add this to your main include file: + +

     extern GrColor *egacolors;
+     #define BLACK        egacolors[0]
+     #define BLUE         egacolors[1]
+     #define GREEN        egacolors[2]
+     #define CYAN         egacolors[3]
+     #define RED          egacolors[4]
+     #define MAGENTA      egacolors[5]
+     #define BROWN        egacolors[6]
+     #define LIGHTGRAY    egacolors[7]
+     #define DARKGRAY     egacolors[8]
+     #define LIGHTBLUE    egacolors[9]
+     #define LIGHTGREEN   egacolors[10]
+     #define LIGHTCYAN    egacolors[11]
+     #define LIGHTRED     egacolors[12]
+     #define LIGHTMAGENTA egacolors[13]
+     #define YELLOW       egacolors[14]
+     #define WHITE        egacolors[15]
+
+

Now you can use the defined colors in your code. Note that if you are in color +table model in a 16 color mode, you have exhausted the color table. Note too +that this don't work to initialize static variables with a color, because +egacolors is not initialized. + + +

+ +

Graphics primitives

+ +

The screen, the current context or the current clip box can be cleared (i.e. +set to a desired background color) by using one of the following three +functions: + +

     void GrClearScreen(GrColor bg);
+     void GrClearContext(GrColor bg);
+     void GrClearClipBox(GrColor bg);
+
+

Any context can be cleared using this function: +

     void GrClearContextC(GrContext *ctx, GrColor bg);
+
+

Thanks to the special GrColor definition, you can do more than simple clear +with this functions, by example with: + +

     GrClearScreen( GrWhite()|GrXOR );
+
+

the graphics screen is negativized, do it again and the screen is restored. + +

The following line drawing graphics primitives are supported by the library: + +

     void GrPlot(int x,int y,GrColor c);
+     void GrLine(int x1,int y1,int x2,int y2,GrColor c);
+     void GrHLine(int x1,int x2,int y,GrColor c);
+     void GrVLine(int x,int y1,int y2,GrColor c);
+     void GrBox(int x1,int y1,int x2,int y2,GrColor c);
+     void GrCircle(int xc,int yc,int r,GrColor c);
+     void GrEllipse(int xc,int yc,int xa,int ya,GrColor c);
+     void GrCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c);
+     void GrEllipseArc(int xc,int yc,int xa,int ya,
+                       int start,int end,int style,GrColor c);
+     void GrPolyLine(int numpts,int points[][2],GrColor c);
+     void GrPolygon(int numpts,int points[][2],GrColor c);
+
+

All primitives operate on the current graphics context. The last argument of +these functions is always the color to use for the drawing. The HLine and VLine +primitives are for drawing horizontal and vertical lines. They have been +included in the library because they are more efficient than the general line +drawing provided by GrLine. The ellipse primitives can only draw ellipses with +their major axis parallel with either the X or Y coordinate axis. They take the +half X and Y axis length in the xa and ya arguments. The arc (circle and +ellipse) drawing functions take the start and end angles in tenths of degrees +(i.e. meaningful range: 0 ... 3600). The angles are interpreted +counter-clockwise starting from the positive X axis. The style argument can be +one of this defines from grx20.h: + +

     #define GR_ARC_STYLE_OPEN       0
+     #define GR_ARC_STYLE_CLOSE1     1
+     #define GR_ARC_STYLE_CLOSE2     2
+
+

GR_ARC_STYLE_OPEN draws only the arc, GR_ARC_STYLE_CLOSE1 closes the arc with +a line between his start and end point, GR_ARC_STYLE_CLOSE1 draws the typical +cake slice. This routine: + +

     void GrLastArcCoords(int *xs,int *ys,int *xe,int *ye,int *xc,int *yc);
+
+

can be used to retrieve the start, end, and center points used by the last arc +drawing functions. + +

See the test/circtest.c and test/arctest.c examples. + +

The polyline and polygon primitives take the address of an n by 2 coordinate +array. The X values should be stored in the elements with 0 second index, and +the Y values in the elements with a second index value of 1. Coordinate arrays +passed to the polygon primitive can either contain or omit the closing edge of +the polygon – the primitive will append it to the list if it is missing. + +

See the test/polytest.c example. + +

Because calculating the arc points it's a very time consuming operation, there +are two functions to pre-calculate the points, that can be used next with +polyline and polygon primitives: + +

     int  GrGenerateEllipse(int xc,int yc,int xa,int ya,
+                            int points[GR_MAX_ELLIPSE_POINTS][2]);
+     int  GrGenerateEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
+                               int points[GR_MAX_ELLIPSE_POINTS][2]);
+
+

The following filled primitives are available: + +

     void GrFilledBox(int x1,int y1,int x2,int y2,GrColor c);
+     void GrFramedBox(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c);
+     void GrFilledCircle(int xc,int yc,int r,GrColor c);
+     void GrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c);
+     void GrFilledCircleArc(int xc,int yc,int r,
+                            int start,int end,int style,GrColor c);
+     void GrFilledEllipseArc(int xc,int yc,int xa,int ya,
+                             int start,int end,int style,GrColor c);
+     void GrFilledPolygon(int numpts,int points[][2],GrColor c);
+     void GrFilledConvexPolygon(int numpts,int points[][2],GrColor c);
+
+

Similarly to the line drawing, all of the above primitives operate on the +current graphics context. The GrFramedBox primitive can be used to draw +motif-like shaded boxes and "ordinary" framed boxes as well. The x1 through y2 +coordinates specify the interior of the box, the border is outside this area, +wdt pixels wide. The primitive uses five different colors for the interior and +four borders of the box which are specified in the GrFBoxColors structure: + +

     typedef struct {
+       GrColor fbx_intcolor;
+       GrColor fbx_topcolor;
+       GrColor fbx_rightcolor;
+       GrColor fbx_bottomcolor;
+       GrColor fbx_leftcolor;
+     } GrFBoxColors;
+
+

The GrFilledConvexPolygon primitive can be used to fill convex polygons. It +can also be used to fill some concave polygons whose boundaries do not intersect +any horizontal scan line more than twice. All other concave polygons have to be +filled with the (somewhat less efficient) GrFilledPolygon primitive. This +primitive can also be used to fill several disjoint non­overlapping polygons in +a single operation. + +

The function: + +

     void GrFloodFill(int x, int y, GrColor border, GrColor c);
+
+

flood-fills the area bounded by the color border using x, y like the starting +point. + +

Floodspill is a color replacer, replacing color A with color B. +This is quite useful for highlighting a selected item in a list, or changing +a selected color(s) in a multi colored area. + +

     void GrFloodSpill(int x1, int y1, int x2, int y2,
+                      GrColor old_c, GrColor new_c)
+
+

replaces old color with new color in the rectangle bounded by x1, y1, x2, y2. + +

     void GrFloodSpillC(GrContext *ctx, int x1, int y1, int x2, int y2,
+                       GrColor old_c, GrColor new_c)
+
+

as above but in the specified context. + +

     void GrFloodSpill2(int x1, int y1, int x2, int y2,
+                       GrColor old_c1, GrColor new_c1,
+                       GrColor old_c2, GrColor new_c2)
+
+

replaces 2 colors, a one stop shop for highlighting a selection in a list. + +

     void GrFloodSpillC2(GrContext *ctx, int x1, int y1, int x2, int y2,
+                       GrColor old_c1, GrColor new_c1,
+                       GrColor old_c2, GrColor new_c2)
+
+

as above but in the specified context. + +

The current color value of any pixel in the current context can be obtained +with: + +

     GrColor GrPixel(int x,int y);
+
+

and: + +

     GrColor GrPixelC(GrContext *c,int x,int y);
+
+

do the same for any context. + +

Rectangular areas can be transferred within a context or between contexts by +calling: + +

     void GrBitBlt(GrContext *dest,int x,int y,GrContext *source,
+                   int x1,int y1,int x2,int y2,GrColor op);
+
+

x, y is the position in the destination context, and x1, y1, x2, y2 the area +from the source context to be transfered. The op argument should be one of +supported color write modes (GrWRITE, GrXOR, GrOR, GrAND, GrIMAGE), it will +control how the pixels from the source context are combined with the pixels in +the destination context (the GrIMAGE op must be ored with the color value to be +handled as transparent). If either the source or the destination context +argument is the NULL pointer then the current context is used for that argument. + +

See the test/blittest.c example. + +

A efficient form to get/put pixels from/to a context can be achieved using the +next functions: + +

     const GrColor *GrGetScanline(int x1,int x2,int yy);
+     const GrColor *GrGetScanlineC(GrContext *ctx,int x1,int x2,int yy);
+     void GrPutScanline(int x1,int x2,int yy,const GrColor *c, GrColor op);
+
+

The Get functions return a pointer to a static GrColor pixel array (or NULL if +they fail) with the color values of a row (yy) segment (x1 to x2). GrGetScanline +uses the current context. GrGestScanlineC uses the context ctx (that can be NULL +to refer to the current context). Note that the output is only valid until the +next GRX call. + +

GrPutScanline puts the GrColor pixel array c on the yy row segmet defined by +x1 to x2 in the current context using the op operation. op can be any of +GrWRITE, GrXOR, GrOR, GrAND or GrIMAGE. Data in c must fit GrCVALUEMASK +otherwise the results are implementation dependend. So you can't supply +operation code with the pixel data!. + + +

+ +

Non-clipping graphics primitives

+ +

There is a non-clipping version of some of the elementary primitives. These +are somewhat more efficient than the regular versions. These are to be used only +in situations when it is absolutely certain that no drawing will be performed +beyond the boundaries of the current context. Otherwise the program will almost +certainly crash! The reason for including these functions is that they are +somewhat more efficient than the regular, clipping versions. ALSO NOTE: These +function do not check for conflicts with the mouse cursor. (See the explanation +about the mouse cursor handling later in this document.) The list of the +supported non-clipping primitives: + +

     void GrPlotNC(int x,int y,GrColor c);
+     void GrLineNC(int x1,int y1,int x2,int y2,GrColor c);
+     void GrHLineNC(int x1,int x2,int y,GrColor c);
+     void GrVLineNC(int x,int y1,int y2,GrColor c);
+     void GrBoxNC(int x1,int y1,int x2,int y2,GrColor c);
+     void GrFilledBoxNC(int x1,int y1,int x2,int y2,GrColor c);
+     void GrFramedBoxNC(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c);
+     void grbitbltNC(GrContext *dst,int x,int y,GrContext *src,
+                     int x1,int y1,int x2,int y2,GrColor op);
+     GrColor GrPixelNC(int x,int y);
+     GrColor GrPixelCNC(GrContext *c,int x,int y);
+
+ + + +

Customized line drawing

+ +

The basic line drawing graphics primitives described previously always draw +continuous lines which are one pixel wide. There is another group of line +drawing functions which can be used to draw wide and/or patterned lines. These +functions have similar parameter passing conventions as the basic ones with one +difference: instead of the color value a pointer to a structure of type +GrLineOption has to be passed to them. The definition of the GrLineOption +structure: + +

     typedef struct {
+       GrColor lno_color;             /* color used to draw line */
+       int     lno_width;             /* width of the line */
+       int     lno_pattlen;           /* length of the dash pattern */
+       unsigned char *lno_dashpat;    /* draw/nodraw pattern */
+     } GrLineOption;
+
+

The lno_pattlen structure element should be equal to the number of alternating +draw – no draw section length values in the array pointed to by the lno_dashpat +element. The dash pattern array is assumed to begin with a drawn section. If the +pattern length is equal to zero a continuous line is drawn. + +

Example, a white line 3 bits wide (thick) and pattern 6 bits draw, 4 bits nodraw: + +

     GrLineOption mylineop;
+     ...
+     mylineop.lno_color = GrWhite();
+     mylineop.lno_width = 3;
+     mylineop.lno_pattlen = 2;
+     mylineop.lno_dashpat = "\x06\x04";
+
+

The available custom line drawing primitives: + +

     void GrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o);
+     void GrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o);
+     void GrCustomCircle(int xc,int yc,int r,const GrLineOption *o);
+     void GrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o);
+     void GrCustomCircleArc(int xc,int yc,int r,
+                            int start,int end,int style,const GrLineOption *o);
+     void GrCustomEllipseArc(int xc,int yc,int xa,int ya,
+                             int start,int end,int style,const GrLineOption *o);
+     void GrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o);
+     void GrCustomPolygon(int numpts,int points[][2],const GrLineOption *o);
+
+

See the test/linetest.c example. + + +

+ +

Pattern filled graphics primitives

+ +

The library also supports a pattern filled version of the basic filled +primitives described above. These functions have similar parameter passing +conventions as the basic ones with one difference: instead of the color value a +pointer to an union of type 'GrPattern' has to be passed to them. The GrPattern +union can contain either a bitmap or a pixmap fill pattern. The first integer +slot in the union determines which type it is. Bitmap fill patterns are +rectangular arrays of bits, each set bit representing the foreground color of +the fill operation, and each zero bit representing the background. Both the +foreground and background colors can be combined with any of the supported +logical operations. Bitmap fill patterns have one restriction: their width must +be eight pixels. Pixmap fill patterns are very similar to contexts. The relevant +structure declarations (from grx20.h): + +

     /*
+      * BITMAP: a mode independent way to specify a fill pattern of two
+      *   colors. It is always 8 pixels wide (1 byte per scan line), its
+      *   height is user-defined. SET THE TYPE FLAG TO ZERO!!!
+      */
+     typedef struct _GR_bitmap {
+       int     bmp_ispixmap;          /* type flag for pattern union */
+       int     bmp_height;            /* bitmap height */
+       char   *bmp_data;              /* pointer to the bit pattern */
+       GrColor bmp_fgcolor;           /* foreground color for fill */
+       GrColor bmp_bgcolor;           /* background color for fill */
+       int     bmp_memflags;          /* set if dynamically allocated */
+     } GrBitmap;
+     
+     /*
+      * PIXMAP: a fill pattern stored in a layout identical to the video RAM
+      *   for filling using 'bitblt'-s. It is mode dependent, typically one
+      *   of the library functions is used to build it. KEEP THE TYPE FLAG
+      *   NONZERO!!!
+      */
+     typedef struct _GR_pixmap {
+       int     pxp_ispixmap;          /* type flag for pattern union */
+       int     pxp_width;             /* pixmap width (in pixels)  */
+       int     pxp_height;            /* pixmap height (in pixels) */
+       GrColor pxp_oper;              /* bitblt mode (SET, OR, XOR, AND, IMAGE) */
+       struct _GR_frame pxp_source;   /* source context for fill */
+     } GrPixmap;
+     
+     /*
+      * Fill pattern union -- can either be a bitmap or a pixmap
+      */
+     typedef union _GR_pattern {
+       int      gp_ispixmap;          /* nonzero for pixmaps */
+       GrBitmap gp_bitmap;            /* fill bitmap */
+       GrPixmap gp_pixmap;            /* fill pixmap */
+     } GrPattern;
+     
+
+

This define group (from grx20.h) help to acces the GrPattern menbers: + +

     #define gp_bmp_data                     gp_bitmap.bmp_data
+     #define gp_bmp_height                   gp_bitmap.bmp_height
+     #define gp_bmp_fgcolor                  gp_bitmap.bmp_fgcolor
+     #define gp_bmp_bgcolor                  gp_bitmap.bmp_bgcolor
+     
+     #define gp_pxp_width                    gp_pixmap.pxp_width
+     #define gp_pxp_height                   gp_pixmap.pxp_height
+     #define gp_pxp_oper                     gp_pixmap.pxp_oper
+     #define gp_pxp_source                   gp_pixmap.pxp_source
+
+

Bitmap patterns can be easily built from initialized character arrays and +static structures by the C compiler, thus no special support is included in the +library for creating them. The only action required from the application program +might be changing the foreground and background colors as needed. Pixmap +patterns are more difficult to build as they replicate the layout of the video +memory which changes for different video modes. For this reason the library +provides three functions to create pixmap patterns in a mode-independent way: + +

     GrPattern *GrBuildPixmap(const char *pixels,int w,int h,const GrColorTableP colors);
+     GrPattern *GrBuildPixmapFromBits(const char *bits,int w,int h,
+                                      GrColor fgc,GrColor bgc);
+     GrPattern *GrConvertToPixmap(GrContext *src);
+
+

GrBuildPixmap build a pixmap from a two dimensional (w by h) array of +characters. The elements in this array are used as indices into the color table +specified with the argument colors. (This means that pixmaps created this way +can use at most 256 colors.) The color table pointer: + +

     typedef GrColor *GrColorTableP;
+
+

should point to an array of integers with the first element being the number of +colors in the table and the color values themselves starting with the second +element. NOTE: any color modifiers (GrXOR, GrOR, GrAND) OR-ed to the elements of +the color table are ignored. + +

The GrBuildPixmapFromBits function builds a pixmap fill pattern from bitmap +data. It is useful if the width of the bitmap pattern is not eight as such +bitmap patterns can not be used to build a GrBitmap structure. + +

The GrConvertToPixmap function converts a graphics context to a pixmap fill +pattern. It is useful when the pattern can be created with graphics drawing +operations. NOTE: the pixmap pattern and the original context share the drawing +RAM, thus if the context is redrawn the fill pattern changes as well. Fill +patterns which were built by library routines can be destroyed when no longer +needed (i.e. the space occupied by them can be freed) by calling: + +

     void GrDestroyPattern(GrPattern *p);
+
+

NOTE: when pixmap fill patterns converted from contexts are destroyed, the +drawing RAM is not freed. It is freed when the original context is destroyed. +Fill patterns built by the application have to be destroyed by the application +as well (if this is needed). + +

The list of supported pattern filled graphics primitives is shown below. These +functions are very similar to their solid filled counterparts, only their last +argument is different: + +

     void GrPatternFilledPlot(int x,int y,GrPattern *p);
+     void GrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p);
+     void GrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p);
+     void GrPatternFilledCircle(int xc,int yc,int r,GrPattern *p);
+     void GrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p);
+     void GrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,
+                                   int style,GrPattern *p);
+     void GrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
+                                    int style,GrPattern *p);
+     void GrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p);
+     void GrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p);
+     void GrPatternFloodFill(int x, int y, GrColor border, GrPattern *p);
+
+

Strictly speaking the plot and line functions in the above group are not +filled, but they have been included here for convenience. + + +

+ +

Patterned line drawing

+ +

The custom line drawing functions introduced above also have a version when +the drawn sections can be filled with a (pixmap or bitmap) fill pattern. To +achieve this these functions must be passed both a custom line drawing option +(GrLineOption structure) and a fill pattern (GrPattern union). These two have +been combined into the GrLinePattern structure: + +

     typedef struct {
+       GrPattern     *lnp_pattern;    /* fill pattern */
+       GrLineOption  *lnp_option;     /* width + dash pattern */
+     } GrLinePattern;
+     
+
+

All patterned line drawing functions take a pointer to this structure as their +last argument. The list of available functions: + +

     void GrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp);
+     void GrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp);
+     void GrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp);
+     void GrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp);
+     void GrPatternedCircleArc(int xc,int yc,int r,int start,int end,
+                               int style,GrLinePattern *lp);
+     void GrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
+                                int style,GrLinePattern *lp);
+     void GrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp);
+     void GrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp);
+     
+
+ +
+ +


+Next: , +Previous: Patterned line drawing, +Up: A User Manual For GRX2 + +
+ +

Image manipulation

+ +

GRX defines the GrImage type like a GrPixmap synonym: + +

     #define GrImage GrPixmap
+
+

nevertheless the GrImage type enforces the image character of this object, so +for compatibility with future GRX versions use the next functions if you need to +convert between GrImage and GrPixmap objects: + +

     GrImage *GrImageFromPattern(GrPattern *p);
+     GrPattern *GrPatternFromImage(GrImage *p);
+
+

the GrImageFromPattern function returns NULL if the GrPattern given is not a +GrPixmap. + +

Like pixmaps patterns images are dependent of the actual video mode set. So +the library provides functions to create images in a mode-independent way: + +

     GrImage *GrImageBuild(const char *pixels,int w,int h,const GrColorTableP colors);
+     GrImage *GrImageFromContext(GrContext *c);
+
+

these functions work like the GrBuildPixmap and GrConvertToPixmap ones. +Remember: the image and the original context share the drawing RAM. + +

There are a number of functions to display all or part of an image in the +current context: + +

     void GrImageDisplay(int x,int y, GrImage *i);
+     void GrImageDisplayExt(int x1,int y1,int x2,int y2, GrImage *i);
+     void GrImageFilledBoxAlign(int xo,int yo,int x1,int y1,int x2,int y2,
+                                GrImage *p);
+     void GrImageHLineAlign(int xo,int yo,int x,int y,int width,GrImage *p);
+     void GrImagePlotAlign(int xo,int yo,int x,int y,GrImage *p);
+
+

GrImageDisplay display the whole image using x, y like the upper left corner +in the current context. GrImageDisplayExt display as much as it can (repiting +the image if necesary) in the rectangle defined by x1, y1 and x2, y2. + +

GrImageFilledBoxAlign is a most general funtion (really the later two call it) +display as much as it can in the defined rectangle using xo, yo like the align +point, it is the virtual point in the destination context (it doesn't need to be +into the rectangle) with that the upper left image corner is aligned. + +

GrImageHLineAlign and GrImagePlotAlign display a row segment or a point of the +image at x y position using the xo, yo allign point. + +

The most usefull image funtions are these: + +

     GrImage *GrImageInverse(GrImage *p,int flag);
+     GrImage *GrImageStretch(GrImage *p,int nwidth,int nheight);
+
+

GrImageInverse creates a new image object, flipping p left-right or top-down +as indicated by flag that can be: + +

     #define GR_IMAGE_INVERSE_LR  0x01  /* inverse left right */
+     #define GR_IMAGE_INVERSE_TD  0x02  /* inverse top down */
+
+

GrImageStretch creates a new image stretching p to nwidth by nheight. + +

To destroy a image objet when you don't need it any more use: + +

     void GrImageDestroy(GrImage *i);
+
+

See the test/imgtest.c example. + + +

+ +

Text drawing

+ +

The library supports loadable fonts. When in memory they are bit-mapped (i.e. +not scalable!) fonts. A driver design allow GRX to load different font formats, +the last GRX release come with drivers to load the GRX own font format and the +BGI Borland format for all platforms supported, the X11 version can load X11 +fonts too. + +

The GRX distribution come with a font collection in the GRX own format. Some +of these fonts were converted from VGA fonts. These fonts have all 256 +characters from the PC-437 codepage. Some additional fonts were converted from +fonts in the MIT X11 distribution. Most of these are ISO-8859-1 coded. Fonts +also have family names. The following font families are included: + +

     Font file name       Family  Description
+     pc<W>x<H>[t].fnt     pc      VGA font, fixed
+     xm<W>x<H>[b][i].fnt  X_misc  X11, fixed, miscellaneous group
+     char<H>[b][i].fnt    char    X11, proportional, charter family
+     cour<H>[b][i].fnt    cour    X11, fixed, courier
+     helve<H>[b][i].fnt   helve   X11, proportional, helvetica
+     lucb<H>[b][i].fnt    lucb    X11, proportional, lucida bright
+     lucs<H>[b][i].fnt    lucs    X11, proportional, lucida sans serif
+     luct<H>[b][i].fnt    luct    X11, fixed, lucida typewriter
+     ncen<H>[b][i].fnt    ncen    X11, proportional, new century schoolbook
+     symb<H>.fnt          symbol  X11, proportional, greek letters, symbols
+     tms<H>[b][i].fnt     times   X11, proportional, times
+
+

In the font names <W> means the font width, <H> the font height. Many font +families have bold and/or italic variants. The files containing these fonts +contain a 'b' and/or 'i' character in their name just before the extension. +Additionally, the strings "_bold" and/or "_ital" are appended to the font family +names. Some of the pc VGA fonts come in thin formats also, these are denoted by +a 't' in their file names and the string "_thin" in their family names. + +

The GrFont structure hold a font in memory. A number of 'pc' fonts are +built-in to the library and don't need to be loaded: + +

     extern  GrFont          GrFont_PC6x8;
+     extern  GrFont          GrFont_PC8x8;
+     extern  GrFont          GrFont_PC8x14;
+     extern  GrFont          GrFont_PC8x16;
+
+

Other fonts must be loaded with the GrLoadFont function. If the font file name +starts with any path separator character or character sequence (':', '/' or '\') +then it is loaded from the specified directory, otherwise the library try load +the font first from the current directory and next from the default font path. +The font path can be set up with the GrSetFontPath function. If the font path is +not set then the value of the 'GRXFONT' environment variable is used as the font +path. If GrLoadFont is called again with the name of an already loaded font then +it will return a pointer to the result of the first loading. Font loading +routines return NULL if the font was not found. When not needed any more, fonts +can be unloaded (i.e. the storage occupied by them freed) by calling +GrUnloadFont. + +

The prototype declarations for these functions: + +

     GrFont *GrLoadFont(char *name);
+     void GrUnloadFont(GrFont *font);
+     void GrSetFontPath(char *path_list);
+
+

Using these functions: + +

     GrFont *GrLoadConvertedFont(char *name,int cvt,int w,int h,
+                                 int minch,int maxch);
+     GrFont *GrBuildConvertedFont(const GrFont *from,int cvt,int w,int h,
+                                  int minch,int maxch);
+
+

a new font can be generated from a file font or a font in memory, the 'cvt' +argument direct the conversion or-ing the desired operations from these defines: + +

     /*
+      * Font conversion flags for 'GrLoadConvertedFont'. OR them as desired.
+      */
+     #define GR_FONTCVT_NONE         0     /* no conversion */
+     #define GR_FONTCVT_SKIPCHARS    1     /* load only selected characters */
+     #define GR_FONTCVT_RESIZE       2     /* resize the font */
+     #define GR_FONTCVT_ITALICIZE    4     /* tilt font for "italic" look */
+     #define GR_FONTCVT_BOLDIFY      8     /* make a "bold"(er) font  */
+     #define GR_FONTCVT_FIXIFY       16    /* convert prop. font to fixed wdt */
+     #define GR_FONTCVT_PROPORTION   32    /* convert fixed font to prop. wdt */
+
+

GR_FONTCVT_SKIPCHARS needs 'minch' and 'maxch' arguments. + +

GR_FONTCVT_RESIZE needs 'w' and 'h' arguments. + +

The function: + +

     void GrDumpFnaFont(const GrFont *f, char *fileName);
+
+

writes a font to an ascii font file, so it can be quickly edited with a text +editor. For a description of the ascii font format, see the fna.txt file. + +

The function: + +

     void GrDumpFont(const GrFont *f,char *CsymbolName,char *fileName);
+
+

writes a font to a C source code file, so it can be compiled and linked with a +user program. GrDumpFont would not normally be used in a release program because +its purpose is to produce source code. When the source code is compiled and +linked into a program distributing the font file with the program in not +necessary, avoiding the possibility of the font file being deleted or corrupted. + +

You can use the premade fnt2c.c program (see the source, it's so simple) to +dump a selected font to source code, by example: + +

     fnt2c helv15 myhelv15 myhelv15.c
+
+

Next, if this line is included in your main include file: + +

     extern GrFont myhelv15
+
+

and "myhelv15.c" compiled and linked with your project, you can use 'myhelv15' +in every place a GrFont is required. + +

This simple function: + +

     void GrTextXY(int x,int y,char *text,GrColor fg,GrColor bg);
+
+

draw text in the current context in the standard direction, using the +GrDefaultFont (mapped in the grx20.h file to the GrFont_PC8x14 font) with x, y +like the upper left corner and the foreground and background colors given (note +that bg equal to GrNOCOLOR make the background transparent). + +

For other functions the GrTextOption structure specifies how to draw a +character string: + +

     typedef struct _GR_textOption {      /* text drawing option structure */
+       struct _GR_font     *txo_font;      /* font to be used */
+       union  _GR_textColor txo_fgcolor;   /* foreground color */
+       union  _GR_textColor txo_bgcolor;   /* background color */
+       char    txo_chrtype;                /* character type (see above) */
+       char    txo_direct;                 /* direction (see above) */
+       char    txo_xalign;                 /* X alignment (see above) */
+       char    txo_yalign;                 /* Y alignment (see above) */
+     } GrTextOption;
+     
+     typedef union _GR_textColor {        /* text color union */
+       GrColor       v;                    /* color value for "direct" text */
+       GrColorTableP p;                    /* color table for attribute text */
+     } GrTextColor;
+     
+
+

The text can be rotated in increments of 90 degrees (txo_direct), alignments +can be set in both directions (txo_xalign and txo_yalign), and separate fore and +background colors can be specified. The accepted text direction values: + +

     #define GR_TEXT_RIGHT           0       /* normal */
+     #define GR_TEXT_DOWN            1       /* downward */
+     #define GR_TEXT_LEFT            2       /* upside down, right to left */
+     #define GR_TEXT_UP              3       /* upward */
+     #define GR_TEXT_DEFAULT         GR_TEXT_RIGHT
+
+

The accepted horizontal and vertical alignment option values: + +

     #define GR_ALIGN_LEFT           0       /* X only */
+     #define GR_ALIGN_TOP            0       /* Y only */
+     #define GR_ALIGN_CENTER         1       /* X, Y   */
+     #define GR_ALIGN_RIGHT          2       /* X only */
+     #define GR_ALIGN_BOTTOM         2       /* Y only */
+     #define GR_ALIGN_BASELINE       3       /* Y only */
+     #define GR_ALIGN_DEFAULT        GR_ALIGN_LEFT
+
+

Text strings can be of three different types: one character per byte (i.e. the +usual C character string, this is the default), one character per 16-bit word +(suitable for fonts with a large number of characters), and a PC-style +character-attribute pair. In the last case the GrTextOption structure must +contain a pointer to a color table of size 16 (fg color bits in attrib) or 8 (bg +color bits). (The color table format is explained in more detail in the previous +section explaining the methods to build fill patterns.) The supported text +types: + +

     #define GR_BYTE_TEXT            0       /* one byte per character */
+     #define GR_WORD_TEXT            1       /* two bytes per character */
+     #define GR_ATTR_TEXT            2       /* chr w/ PC style attribute byte */
+
+

The PC-style attribute text uses the same layout (first byte: character, +second: attributes) and bitfields as the text mode screen on the PC. The only +difference is that the 'blink' bit is not supported (it would be very time +consuming – the PC text mode does it with hardware support). This bit is used +instead to control the underlined display of characters. For convenience the +following attribute manipulation macros have been declared in grx20.h: + +

     #define GR_BUILD_ATTR(fg,bg,ul) \
+             (((fg) & 15) | (((bg) & 7) << 4) | ((ul) ? 128 : 0))
+     #define GR_ATTR_FGCOLOR(attr)   (((attr)     ) &  15)
+     #define GR_ATTR_BGCOLOR(attr)   (((attr) >> 4) &   7)
+     #define GR_ATTR_UNDERLINE(attr) (((attr)     ) & 128)
+
+

Text strings of the types GR_BYTE_TEXT and GR_WORD_TEXT can also be drawn +underlined. This is controlled by OR-ing the constant GR_UNDERLINE_TEXT to the +foreground color value: + +

     #define GR_UNDERLINE_TEXT       (GrXOR << 4)
+
+

After the application initializes a text option structure with the desired +values it can call one of the following two text drawing functions: + +

     void GrDrawChar(int chr,int x,int y,const GrTextOption *opt);
+     void GrDrawString(void *text,int length,int x,int y,const GrTextOption *opt);
+
+

NOTE: text drawing is fastest when it is drawn in the 'normal' direction, and +the character does not have to be clipped. It this case the library can use the +appropriate low-level video RAM access routine, while in any other case the text +is drawn pixel-by-pixel by the higher-level code. + +

There are pattern filed versions too: + +

     void GrPatternDrawChar(int chr,int x,int y,const GrTextOption *opt,GrPattern *p);
+     void GrPatternDrawString(void *text,int length,int x,int y,const GrTextOption *opt,
+                              GrPattern *p);
+     void GrPatternDrawStringExt(void *text,int length,int x,int y,
+                                 const GrTextOption *opt,GrPattern *p);
+
+

The size of a font, a character or a text string can be obtained by calling +one of the following functions. These functions also take into consideration the +text direction specified in the text option structure passed to them. + +

     int  GrFontCharPresent(const GrFont *font,int chr);
+     int  GrFontCharWidth(const GrFont *font,int chr);
+     int  GrFontCharHeight(const GrFont *font,int chr);
+     int  GrFontCharBmpRowSize(const GrFont *font,int chr);
+     int  GrFontCharBitmapSize(const GrFont *font,int chr);
+     int  GrFontStringWidth(const GrFont *font,void *text,int len,int type);
+     int  GrFontStringHeight(const GrFont *font,void *text,int len,int type);
+     int  GrProportionalTextWidth(const GrFont *font,void *text,int len,int type);
+     int  GrCharWidth(int chr,const GrTextOption *opt);
+     int  GrCharHeight(int chr,const GrTextOption *opt);
+     void GrCharSize(int chr,const GrTextOption *opt,int *w,int *h);
+     int  GrStringWidth(void *text,int length,const GrTextOption *opt);
+     int  GrStringHeight(void *text,int length,const GrTextOption *opt);
+     void GrStringSize(void *text,int length,const GrTextOption *opt,int *w,int *h);
+
+

The GrTextRegion structure and its associated functions can be used to +implement a fast (as much as possible in graphics modes) rectangular text window +using a fixed font. Clipping for such windows is done in character size +increments instead of pixels (i.e. no partial characters are drawn). Only fixed +fonts can be used in their natural size. GrDumpText will cache the code of the +drawn characters in the buffer pointed to by the 'backup' slot (if it is +non-NULL) and will draw a character only if the previously drawn character in +that grid element is different. + +

This can speed up text scrolling significantly in graphics modes. The +supported text types are the same as above. + +

     typedef struct {                     /* fixed font text window desc. */
+       struct _GR_font     *txr_font;      /* font to be used */
+       union  _GR_textColor txr_fgcolor;   /* foreground color */
+       union  _GR_textColor txr_bgcolor;   /* background color */
+       void   *txr_buffer;                 /* pointer to text buffer */
+       void   *txr_backup;                 /* optional backup buffer */
+       int     txr_width;                  /* width of area in chars */
+       int     txr_height;                 /* height of area in chars */
+       int     txr_lineoffset;             /* offset in buffer(s) between rows */
+       int     txr_xpos;                   /* upper left corner X coordinate */
+       int     txr_ypos;                   /* upper left corner Y coordinate */
+       char    txr_chrtype;                /* character type (see above) */
+     } GrTextRegion;
+     
+     void GrDumpChar(int chr,int col,int row,const GrTextRegion *r);
+     void GrDumpText(int col,int row,int wdt,int hgt,const GrTextRegion *r);
+     void GrDumpTextRegion(const GrTextRegion *r);
+     
+
+

The GrDumpTextRegion function outputs the whole text region, while GrDumpText +draws only a user-specified part of it. GrDumpChar updates the character in the +buffer at the specified location with the new character passed to it as argument +and then draws the new character on the screen as well. With these functions you +can simulate a text mode window, write chars directly to the txr_buffer and call +GrDumpTextRegion when you want to update the window (or GrDumpText if you know +the area to update is small). + +

See the test/fonttest.c example. + + +

+ +


+Next: , +Previous: Text drawing, +Up: A User Manual For GRX2 + +
+ +

Drawing in user coordinates

+ +

There is a second set of the graphics primitives which operates in user +coordinates. Every context has a user to screen coordinate mapping associated +with it. An application specifies the user window by calling the GrSetUserWindow +function. + +

     void GrSetUserWindow(int x1,int y1,int x2,int y2);
+
+

A call to this function it in fact specifies the virtual coordinate limits +which will be mapped onto the current context regardless of the size of the +context. For example, the call: + +

     GrSetUserWindow(0,0,11999,8999);
+
+

tells the library that the program will perform its drawing operations in a +coordinate system X:0...11999 (width = 12000) and Y:0...8999 (height = 9000). +This coordinate range will be mapped onto the total area of the current context. +The virtual coordinate system can also be shifted. For example: + +

     GrSetUserWindow(5000,2000,16999,10999);
+
+

The user coordinates can even be used to turn the usual left-handed coordinate +system (0:0 corresponds to the upper left corner) to a right handed one (0:0 +corresponds to the bottom left corner) by calling: + +

     GrSetUserWindow(0,8999,11999,0);
+
+

The library also provides three utility functions for the query of the current +user coordinate limits and for converting user coordinates to screen coordinates +and vice versa. + +

     void GrGetUserWindow(int *x1,int *y1,int *x2,int *y2);
+     void GrGetScreenCoord(int *x,int *y);
+     void GrGetUserCoord(int *x,int *y);
+
+

If an application wants to take advantage of the user to screen coordinate +mapping it has to use the user coordinate version of the graphics primitives. +These have exactly the same parameter passing conventions as their screen +coordinate counterparts. NOTE: the user coordinate system is not initialized by +the library! The application has to set up its coordinate mapping before calling +any of the use coordinate drawing functions – otherwise the program will almost +certainly exit (in a quite ungraceful fashion) with a 'division by zero' error. +The list of supported user coordinate drawing functions: + +

     void GrUsrPlot(int x,int y,GrColor c);
+     void GrUsrLine(int x1,int y1,int x2,int y2,GrColor c);
+     void GrUsrHLine(int x1,int x2,int y,GrColor c);
+     void GrUsrVLine(int x,int y1,int y2,GrColor c);
+     void GrUsrBox(int x1,int y1,int x2,int y2,GrColor c);
+     void GrUsrFilledBox(int x1,int y1,int x2,int y2,GrColor c);
+     void GrUsrFramedBox(int x1,int y1,int x2,int y2,int wdt,GrFBoxColors *c);
+     void GrUsrCircle(int xc,int yc,int r,GrColor c);
+     void GrUsrEllipse(int xc,int yc,int xa,int ya,GrColor c);
+     void GrUsrCircleArc(int xc,int yc,int r,int start,int end,
+                         int style,GrColor c);
+     void GrUsrEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
+                          int style,GrColor c);
+     void GrUsrFilledCircle(int xc,int yc,int r,GrColor c);
+     void GrUsrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c);
+     void GrUsrFilledCircleArc(int xc,int yc,int r,int start,int end,
+                               int style,GrColor c);
+     void GrUsrFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
+                                int style,GrColor c);
+     void GrUsrPolyLine(int numpts,int points[][2],GrColor c);
+     void GrUsrPolygon(int numpts,int points[][2],GrColor c);
+     void GrUsrFilledConvexPolygon(int numpts,int points[][2],GrColor c);
+     void GrUsrFilledPolygon(int numpts,int points[][2],GrColor c);
+     void GrUsrFloodFill(int x, int y, GrColor border, GrColor c);
+     GrColor GrUsrPixel(int x,int y);
+     GrColor GrUsrPixelC(GrContext *c,int x,int y);
+     void GrUsrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o);
+     void GrUsrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o);
+     void GrUsrCustomCircle(int xc,int yc,int r,const GrLineOption *o);
+     void GrUsrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o);
+     void GrUsrCustomCircleArc(int xc,int yc,int r,int start,int end,
+                               int style,const GrLineOption *o);
+     void GrUsrCustomEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
+                                int style,const GrLineOption *o);
+     void GrUsrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o);
+     void GrUsrCustomPolygon(int numpts,int points[][2],const GrLineOption *o);
+     void GrUsrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp);
+     void GrUsrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp);
+     void GrUsrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp);
+     void GrUsrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp);
+     void GrUsrPatternedCircleArc(int xc,int yc,int r,int start,int end,
+                                  int style,GrLinePattern *lp);
+     void GrUsrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
+                                   int style,GrLinePattern *lp);
+     void GrUsrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp);
+     void GrUsrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp);
+     void GrUsrPatternFilledPlot(int x,int y,GrPattern *p);
+     void GrUsrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p);
+     void GrUsrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p);
+     void GrUsrPatternFilledCircle(int xc,int yc,int r,GrPattern *p);
+     void GrUsrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p);
+     void GrUsrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrPattern *p);
+     void GrUsrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrPattern *p);
+     void GrUsrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p);
+     void GrUsrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p);
+     void GrUsrPatternFloodFill(int x, int y, GrColor border, GrPattern *p);
+     void GrUsrDrawChar(int chr,int x,int y,const GrTextOption *opt);
+     void GrUsrDrawString(char *text,int length,int x,int y,const GrTextOption *opt);
+     void GrUsrTextXY(int x,int y,char *text,GrColor fg,GrColor bg);
+
+ + + +

Graphics cursors

+ +

The library provides support for the creation and usage of an unlimited number +of graphics cursors. An application can use these cursors for any purpose. +Cursors always save the area they occupy before they are drawn. When moved or +erased they restore this area. As a general rule of thumb, an application should +erase a cursor before making changes to an area it occupies and redraw the +cursor after finishing the drawing. Cursors are created with the GrBuildCursor +function: + +

     GrCursor *GrBuildCursor(char far *pixels,int pitch,int w,int h,
+                             int xo,int yo,const GrColorTableP c);
+
+

The pixels, w (=width), h (=height) and c (= color table) arguments are +similar to the arguments of the pixmap building library function GrBuildPixmap +(see that paragraph for a more detailed explanation.), but with two differences. +First, is not assumed that the pixels data is w x h sized, the pitch argument +set the offset between rows. Second, the pixmap data is interpreted slightly +differently, any pixel with value zero is taken as a "transparent" pixel, i.e. +the background will show through the cursor pattern at that pixel. A pixmap data +byte with value = 1 will refer to the first color in the table, and so on. + +

The xo (= X offset) and yo (= Y offset) arguments specify the position (from +the top left corner of the cursor pattern) of the cursor's "hot point". + +

The GrCursor data structure: + +

     typedef struct _GR_cursor {
+       struct _GR_context work;            /* work areas (4) */
+       int     xcord,ycord;                /* cursor position on screen */
+       int     xsize,ysize;                /* cursor size */
+       int     xoffs,yoffs;                /* LU corner to hot point offset */
+       int     xwork,ywork;                /* save/work area sizes */
+       int     xwpos,ywpos;                /* save/work area position on screen */
+       int     displayed;                  /* set if displayed */
+     } GrCursor;
+
+

is typically not used (i.e. read or changed) by the application program, it +should just pass pointers to these structures to the appropriate library +functions. Other cursor manipulation functions: + +

     void GrDisplayCursor(GrCursor *cursor);
+     void GrEraseCursor(GrCursor *cursor);
+     void GrMoveCursor(GrCursor *cursor,int x,int y);
+     void GrDestroyCursor(GrCursor *cursor);
+
+

See the test/curstest.c example. + + +

+ +


+Next: , +Previous: Graphics cursors, +Up: A User Manual For GRX2 + +
+ +

Keyboard input

+ +

GRX can handle platform independant key input. The file grxkeys.h defines the +keys to be used in the user's program. This is an extract: + +

     #define GrKey_Control_A            0x0001
+     #define GrKey_Control_B            0x0002
+     #define GrKey_Control_C            0x0003
+     ...
+     #define GrKey_A                    0x0041
+     #define GrKey_B                    0x0042
+     #define GrKey_C                    0x0043
+     ...
+     #define GrKey_F1                   0x013b
+     #define GrKey_F2                   0x013c
+     #define GrKey_F3                   0x013d
+     ...
+     #define GrKey_Alt_F1               0x0168
+     #define GrKey_Alt_F2               0x0169
+     #define GrKey_Alt_F3               0x016a
+
+

But you can be confident that the standard ASCII is right maped. +The GrKeyType type is defined to store keycodes: + +

     typedef unsigned short GrKeyType;
+
+

This function: + +

     int GrKeyPressed(void);
+
+

returns non zero if there are any keycode waiting, that can be read with: + +

     GrKeyType GrKeyRead(void);
+
+

The function: + +

     int GrKeyStat(void);
+
+

returns a keyboard status word, or-ing it with the next defines it can be known +the status of some special keys: + +

     #define GR_KB_RIGHTSHIFT    0x01      /* right shift key depressed */
+     #define GR_KB_LEFTSHIFT     0x02      /* left shift key depressed */
+     #define GR_KB_CTRL          0x04      /* CTRL depressed */
+     #define GR_KB_ALT           0x08      /* ALT depressed */
+     #define GR_KB_SCROLLOCK     0x10      /* SCROLL LOCK active */
+     #define GR_KB_NUMLOCK       0x20      /* NUM LOCK active */
+     #define GR_KB_CAPSLOCK      0x40      /* CAPS LOCK active */
+     #define GR_KB_INSERT        0x80      /* INSERT state active */
+     #define GR_KB_SHIFT         (GR_KB_LEFTSHIFT | GR_KB_RIGHTSHIFT)
+
+

See the test/keys.c example. + + +

+ +

Mouse event handling

+ +

All mouse services need the presence of a mouse. An application can test +whether a mouse is available by calling the function: + +

     int  GrMouseDetect(void);
+
+

which will return zero if no mouse (or mouse driver) is present, non-zero +otherwise. The mouse must be initialized by calling one (and only one) of these +functions: + +

     void GrMouseInit(void);
+     void GrMouseInitN(int queue_size);
+
+

GrMouseInit sets a event queue (see below) size to GR_M_QUEU_SIZE (128). A +user supply event queue size can be set calling GrMouseInitN instead. + +

It is a good practice to call GrMouseUnInit before exiting the program. This +will restore any interrupt vectors hooked by the program to their original +values. + +

     void GrMouseUnInit(void);
+
+

The mouse can be controlled with the following functions: + +

     void GrMouseSetSpeed(int spmult,int spdiv);
+     void GrMouseSetAccel(int thresh,int accel);
+     void GrMouseSetLimits(int x1,int y1,int x2,int y2);
+     void GrMouseGetLimits(int *x1,int *y1,int *x2,int *y2);
+     void GrMouseWarp(int x,int y);
+
+

The library calculates the mouse position only from the mouse mickey counters. +(To avoid the limit and 'rounding to the next multiple of eight' problem with +some mouse driver when it finds itself in a graphics mode unknown to it.) The +parameters to the GrMouseSetSpeed function specify how coordinate changes are +obtained from mickey counter changes, multipling by spmult and dividing by +spdiv. In high resolution graphics modes the value of one just works fine, in +low resolution modes (320x200 or similar) it is best set the spdiv to two or +three. (Of course, it also depends on the sensitivity the mouse.) The +GrMouseSetAccel function is used to control the ballistic effect: if a mouse +coordinate changes between two samplings by more than the thresh parameter, the +change is multiplied by the accel parameter. NOTE: some mouse drivers perform +similar calculations before reporting the coordinates in mickeys. In this case +the acceleration done by the library will be additional to the one already +performed by the mouse driver. The limits of the mouse movement can be set +(passed limits will be clipped to the screen) with GrMouseSetLimits (default is +the whole screen) and the current limits can be obtained with GrMouseGetLimits. +GrMouseWarp sets the mouse cursor to the specified position. + +

As typical mouse drivers do not know how to draw mouse cursors in high +resolution graphics modes, the mouse cursor is drawn by the library. The mouse +cursor can be set with: + +

     void GrMouseSetCursor(GrCursor *cursor);
+     void GrMouseSetColors(GrColor fg,GrColor bg);
+
+

GrMouseSetColors uses an internal arrow pattern, the color fg will be used as +the interior of it and bg will be the border. The current mouse cursor can be +obtained with: + +

     GrCursor *GrMouseGetCursor(void);
+
+

The mouse cursor can be displayed/erased with: + +

     void GrMouseDisplayCursor(void);
+     void GrMouseEraseCursor(void);
+
+

The mouse cursor can be left permanently displayed. All graphics primitives +except for the few non-clipping functions check for conflicts with the mouse +cursor and erase it before the drawing if necessary. Of course, it may be more +efficient to erase the cursor manually before a long drawing sequence and redraw +it after completion. The library provides an alternative pair of calls for this +purpose which will erase the cursor only if it interferes with the drawing: + +

     int  GrMouseBlock(GrContext *c,int x1,int y1,int x2,int y2);
+     void GrMouseUnBlock(int return_value_from_GrMouseBlock);
+
+

GrMouseBlock should be passed the context in which the drawing will take place +(the usual convention of NULL meaning the current context is supported) and the +limits of the affected area. It will erase the cursor only if it interferes with +the drawing. When the drawing is finished GrMouseUnBlock must be called with the +argument returned by GrMouseBlock. + +

The status of the mouse cursor can be obtained with calling +GrMouseCursorIsDisplayed. This function will return non-zero if the cursor is +displayed, zero if it is erased. + +

     int  GrMouseCursorIsDisplayed(void);
+
+

The library supports (beside the simple cursor drawing) three types of +"rubberband" attached to the mouse cursor. The GrMouseSetCursorMode function is +used to select the cursor drawing mode. + +

     void GrMouseSetCursorMode(int mode,...);
+
+

The parameter mode can have the following values: + +

     #define GR_M_CUR_NORMAL   0    /* MOUSE CURSOR modes: just the cursor */
+     #define GR_M_CUR_RUBBER   1    /* rect. rubber band (XOR-d to the screen) */
+     #define GR_M_CUR_LINE     2    /* line attached to the cursor */
+     #define GR_M_CUR_BOX      3    /* rectangular box dragged by the cursor */
+
+

GrMouseSetCursorMode takes different parameters depending on the cursor +drawing mode selected. The accepted call formats are: + +

     GrMouseSetCursorMode(M_CUR_NORMAL);
+     GrMouseSetCursorMode(M_CUR_RUBBER,xanchor,yanchor,GrColor);
+     GrMouseSetCursorMode(M_CUR_LINE,xanchor,yanchor,GrColor);
+     GrMouseSetCursorMode(M_CUR_BOX,dx1,dy1,dx2,dy2,GrColor);
+
+

The anchor parameters for the rubberband and rubberline modes specify a fixed +screen location to which the other corner of the primitive is bound. The dx1 +through dy2 parameters define the offsets of the corners of the dragged box from +the hotpoint of the mouse cursor. The color value passed is always XOR-ed to the +screen, i.e. if an application wants the rubberband to appear in a given color +on a given background then it has to pass the XOR of these two colors to +GrMouseSetCursorMode. + +

The GrMouseGetEvent function is used to obtain the next mouse or keyboard +event. It takes a flag with various bits encoding the type of event needed. It +returns the event in a GrMouseEvent structure. The relevant declarations from +grx20.h: + +

     void GrMouseGetEvent(int flags,GrMouseEvent *event);
+     
+     typedef struct _GR_mouseEvent {    /* mouse event buffer structure */
+       int  flags;                       /* event type flags (see above) */
+       int  x,y;                         /* mouse coordinates */
+       int  buttons;                     /* mouse button state */
+       int  key;                         /* key code from keyboard */
+       int  kbstat;                      /* keybd status (ALT, CTRL, etc..) */
+       long dtime;                       /* time since last event (msec) */
+     } GrMouseEvent;
+
+

The event structure has been extended with a keyboard status word (thus a +program can check for combinations like ALT-<left mousebutton press>) and a time +stamp which can be used to check for double clicks, etc... The following macros +have been defined in grx20.h to help in creating the control flag for +GrMouseGetEvent and decoding the various bits in the event structure: + +

     #define GR_M_MOTION         0x001       /* mouse event flag bits */
+     #define GR_M_LEFT_DOWN      0x002
+     #define GR_M_LEFT_UP        0x004
+     #define GR_M_RIGHT_DOWN     0x008
+     #define GR_M_RIGHT_UP       0x010
+     #define GR_M_MIDDLE_DOWN    0x020
+     #define GR_M_MIDDLE_UP      0x040
+     #define GR_M_BUTTON_DOWN    (GR_M_LEFT_DOWN  | GR_M_MIDDLE_DOWN | \
+                                  GR_M_RIGHT_DOWN | GR_M_P4_DOWN | GR_M_P5_DOWN)
+     #define GR_M_BUTTON_UP      (GR_M_LEFT_UP    | GR_M_MIDDLE_UP   | \
+                                  GR_M_RIGHT_UP   | GR_M_P4_UP  | GR_M_P5_UP)
+     #define GR_M_BUTTON_CHANGE  (GR_M_BUTTON_UP  | GR_M_BUTTON_DOWN )
+     
+     #define GR_M_LEFT           0x01        /* mouse button index bits */
+     #define GR_M_RIGHT          0x02
+     #define GR_M_MIDDLE         0x04
+     #define GR_M_P4             0x08        /* wheel rolls up */
+     #define GR_M_P5             0x10        /* wheel rolls down */
+     
+     #define GR_M_KEYPRESS       0x080        /* other event flag bits */
+     #define GR_M_POLL           0x100
+     #define GR_M_NOPAINT        0x200
+     #define GR_COMMAND          0x1000
+     #define GR_M_EVENT          (GR_M_MOTION | GR_M_KEYPRESS | \
+                                  GR_M_BUTTON_CHANGE | GR_COMMAND)
+
+

GrMouseGetEvent will display the mouse cursor if it was previously erased and +the GR_M_NOPAINT bit is not set in the flag passed to it. In this case it will +also erase the cursor after an event has been obtained. + +

GrMouseGetEvent block until a event is produced, except if the GR_M_POLL bit +is set in the flag passed to it. + +

Another version of GetEvent: + +

     void GrMouseGetEventT(int flags,GrMouseEvent *event,long timout_msecs);
+
+

can be istructed to wait timout_msec for the presence of an event. Note that +event->dtime is only valid if any event occured (event->flags != 0) otherwise +it's set as -1. Additionally event timing is real world time even in X11 && +Linux. + +

If there are one or more events waiting the function: + +

     int  GrMousePendingEvent(void);
+
+

returns non-zero value. + +

The generation of mouse and keyboard events can be individually enabled or +disabled (by passing a non-zero or zero, respectively, value in the +corresponding enable_XX parameter) by calling: + +

     void GrMouseEventEnable(int enable_kb,int enable_ms);
+
+

Note that GrMouseInit set both by default. If you want to use +GrMouseGetEvent and GrKeyRead at the same time, a call to +GrMouseEventEnable( 0,1 ) is needed before input process. + +

See the test/mousetst.c example. + +

+ +

Writing/reading PNM graphics files

+ +

GRX includes functions to load/save a context from/to a PNM file. + +

PNM is a group of simple graphics formats from the +NetPbm +distribution. NetPbm can convert from/to PNM lots of graphics formats, +and apply some transformations to PNM files. +(Note. You don't need the NetPbm distribution to use this functions). + +

There are six PNM formats: + +

       P1 text PBM (bitmap)
+       P2 text PGM (gray scale)
+       P3 text PPM (real color)
+       P4 binary PBM (bitmap)
+       P5 binary PGM (gray scale)
+       P6 binary PPM (real color)
+
+

GRX can handle the binary formats only (get the NetPbm distribution if you +need convert text to binary formats). + +

To save a context in a PNM file you have three functions: + +

     int GrSaveContextToPbm( GrContext *grc, char *pbmfn, char *docn );
+     int GrSaveContextToPgm( GrContext *grc, char *pgmfn, char *docn );
+     int GrSaveContextToPpm( GrContext *grc, char *ppmfn, char *docn );
+
+

they work both in RGB and palette modes, grc must be a pointer to the context to +be saved, if it is NULL the current context is saved; p-mfn is the file name to +be created and docn is an optional text comment to be written in the file, it +can be NULL. Three functions return 0 on succes and -1 on error. + +

GrSaveContextToPbm dumps a context in a PBM file (bitmap). If the pixel color +isn't Black it asumes White. + +

GrSaveContextToPgm dumps a context in a PGM file (gray scale). The colors are +quantized to gray scale using .299r + .587g + .114b. + +

GrSaveContextToPpm dumps a context in a PPM file (real color). +To load a PNM file in a context you must use: + +

     int GrLoadContextFromPnm( GrContext *grc, char *pnmfn );
+
+

it support reading PBM, PGM and PPM binary files. grc must be a pointer to the +context to be written, if it is NULL the current context is used; p-mfn is the +file name to be read. If context dimensions are lesser than pnm dimensions, the +function loads as much as it can. If color mode is not in RGB mode, the routine +allocates as much colors as it can. The function returns 0 on succes and -1 on +error. + +

To query the file format, width and height of a PNM file you can use: + +

     int GrQueryPnm( char *ppmfn, int *width, int *height, int *maxval );
+
+

pnmfn is the name of pnm file; width returns the pnm width; height returns the +pnm height; maxval returns the max color component value. The function returns 1 +to 6 on success (the PNM format) or -1 on error. + +

The two next functions: + +

     int GrLoadContextFromPnmBuffer( GrContext *grc, const char *pnmbuf );
+     int GrQueryPnmBuffer( const char *pnmbuf, int *width, int *height, int *maxval );
+
+

work like GrLoadContextFromPnm and +GrQueryPnmBuffer, but they get his input from a buffer instead +of a file. This way, pnm files can be embeded in a program (using the +bin2c program by example). + +

+ +

Writing/reading PNG graphics files

+ +

GRX includes functions to load/save a context +from/to a png file. But note, for this purpose it needs the +libpng library, +and to enable the png support before make the GRX lib. + +

Use next function to save a context in a PNG file: + +

     int GrSaveContextToPng( GrContext *grc, char *pngfn );
+
+

it works both in RGB and palette modes, grc must be +a pointer to the context to be saved, if it is NULL the current context is +saved; pngfn is the file name to be created. +The function returns 0 on succes and -1 on error. + +

To load a PNG file in a context you must use: + +

     int GrLoadContextFromPng( GrContext *grc, char *pngfn, int use_alpha );
+
+

grc must be a pointer to the context to be written, if it +is NULL the current context is used; pngfn is the file name +to be read; set use_alpha to 1 if you want to use the image +alpha channel (if available). If context dimensions are lesser than png +dimensions, the function loads as much as it can. If color mode is not +in RGB mode, the routine allocates as much colors as it can. The function +returns 0 on succes and -1 on error. + +

To query the width and height of a PNG file you can use: + +

     int GrQueryPng( char *pngfn, int *width, int *height );
+
+

pngfn is the name of png file; width returns the +png width; height returns the png height. +The function returns 0 on success or -1 on error. + +

The function: + +

     int GrPngSupport( void );
+
+

returns 1 if there is png support in the library, 0 otherwise. If there is +not support for png, dummy functions are added to the library, returning +error (-1) ever. + +

+ +

Writing/reading PNG graphics files

+ +

GRX includes functions to load/save a context +from/to a jpeg file. But note, for this purpose it needs the +libjpeg library, +and to enable the jpeg support before make the GRX lib. + +

Use next function to save a context in a JPEG file: + +

     int GrSaveContextToJpeg( GrContext *grc, char *jpegfn, int quality );
+
+

it works both in RGB and palette modes, grc must be +a pointer to the context to be saved, if it is NULL the current context is +saved; jpegfn is the file name to be created; +quality is a number between 1 and 100 to drive the compression +quality, use higher values for better quality (and bigger files), you can +use 75 as a standard value, normally a value between 50 and 95 is good. +The function returns 0 on succes and -1 on error. + +

This function saves a context in a grayscale JPEG file: + +

     int GrSaveContextToGrayJpeg( GrContext *grc, char *jpegfn, int quality );
+
+

parameters and return codes are like in GrSaveContextToJpeg. +The colors are quantized to gray scale using .299r + .587g + .114b. + +

To load a JPEG file in a context you must use: + +

     int GrLoadContextFromJpeg( GrContext *grc, char *jpegfn, int scale );
+
+

grc must be a pointer to the context to be written, if it +is NULL the current context is used; jpegfn is the file name +to be read; set scale to 1, 2, 4 or 8 to reduce the loaded +image to 1/1, 1/2, 1/4 or 1/8. If context dimensions are lesser than jpeg +dimensions, the function loads as much as it can. If color mode is not +in RGB mode, the routine allocates as much colors as it can. The function +returns 0 on succes and -1 on error. + +

To query the width and height of a JPEG file you can use: + +

     int GrQueryJpeg( char *jpegfn, int *width, int *height );
+
+

jpegfn is the name of jpeg file; width returns the +jpeg width; height returns the jpeg height. +The function returns 0 on success or -1 on error. + +

The function: + +

     int GrJpegSupport( void );
+
+

returns 1 if there is jpeg support in the library, 0 otherwise. If there is +not support for jpeg, dummy functions are added to the library, returning +error (-1) ever. + +

+ +

Miscellaneous functions

+ +

Here we will describe some miscellaneous functions. + +

     unsigned GrGetLibraryVersion(void);
+
+

GrGetLibraryVersion returns the GRX version API, like a hexadecimal coded +number. By example 0x0241 means 2.4.1 Because grx20.h defines the +GRX_VERSION_API macro, you can check if both, the library and the +include file, are in the same version using +if(GrGetLibraryVersion() == GRX_VERSION_API ) + +

     unsigned GrGetLibrarySystem(void);
+
+

This functions returns a unsigned integer identifing the system you are +working in. grx20.h defines some macros you can use: + +

     /* these are the supported configurations: */
+     #define GRX_VERSION_TCC_8086_DOS        1   /* also works with BCC */
+     #define GRX_VERSION_GCC_386_DJGPP       2   /* DJGPP v2 */
+     #define GRX_VERSION_GCC_386_LINUX       3   /* the real stuff */
+     #define GRX_VERSION_GENERIC_X11         4   /* generic X11 version */
+     #define GRX_VERSION_WATCOM_DOS4GW       5   /* GS - Watcom C++ 11.0 32 Bit
+     #define GRX_VERSION_GCC_386_WIN32       7   /* WIN32 using Mingw32 */
+     #define GRX_VERSION_MSC_386_WIN32       8   /* WIN32 using MS-VC */
+     #define GRX_VERSION_GCC_386_CYG32       9   /* WIN32 using CYGWIN */
+     #define GRX_VERSION_GCC_386_X11        10   /* X11 version */
+     #define GRX_VERSION_GCC_X86_64_LINUX   11   /* console framebuffer 64 */
+     #define GRX_VERSION_GCC_X86_64_X11     12   /* X11 version 64 */
+
+

Note. On Linux, GrGetLibrarySystem returns GRX_VERSION_GCC_386_LINUX even in the +X11 version. + +

     void GrSetWindowTitle(char *title);
+
+

GrSetWindowTitle sets the main window title in the X11 an Win32 versions. It +doesn't do nothing in the DOS and Linux-SvgaLib versions. + +

     void GrSleep(int msec);
+
+

This function stops the program execution for msec miliseconds. + +

     long GrMsecTime( void );
+
+

This function gives the current time with millisecond resolution + +

     void GrFlush( void );
+
+

This funnction flushes the graphics window. Not dummy because useful only on +X11 when switching between graphics and console windows open simultaneously. + +

      GrContext *GrCreateFrameContext(GrFrameMode md,int w,int h,
+                 char far *memory[4],GrContext *where);
+     
+
+

This function is like GrCreateContext, except that you can specify any valid +memory frame mode, not only the Screen associated frame mode. It can be used for +special purposes (see GrBitBlt1bpp for an example). + +

      void GrBitBlt1bpp(GrContext *dst,int dx,int dy,GrContext *src,
+           int x1,int y1,int x2,int y2,GrColor fg,GrColor bg);
+     
+
+

This special function does a bitblt from a 1bpp context (a bitmap really), +using fg and bg like the color+opcode when bit=1 and bit=0 respectively. Here is +an example: + +

        pContext = GrCreateFrameContext(GR_frameRAM1, sizex, sizey, NULL, NULL);
+        /* draw something (black and white) into the bitmap */
+        GrSetContext(pContext);
+        GrClearContext( GrBlack() );
+        GrLine(0, 0, sizex-1, sizey-1, GrWhite());
+        GrLine(0, sizey-1, sizex-1, 0, GrWhite());
+     
+        /* Put the bitmap into the screen */
+        GrSetContext(NULL);
+        fcolor = GrAllocColor( 255,0,0 );
+        bcolor = GrAllocColor( 0,0,255 );
+        GrBitBlt1bpp(NULL,x,y,pContext,0,0,sizex-1,sizey-1,fcolor,bcolor);
+
+ + + +

BGI interface

+ +

From the 2.3.1 version, GRX includes the BCC2GRX library created by Hartmut +Schirmer. The BCC2GRX was created to allow users of GRX to compile graphics +programs written for Borland-C++ and Turbo-C graphics interface. BCC2GRX is not +a convenient platform to develop new BGI programs. Of course you should use +native GRX interface in such cases! + +

Read the readme.bgi file for more info. + + +

+ +


+Next: , +Previous: BGI interface, +Up: A User Manual For GRX2 + +
+ +

Pascal interface

+ +

The Pascal (gpc) support is produced by two unit files pascal/grx.pas +and pascal/bgi/graph.pas which are the Pascal translations of the C +header files include/grx20.h + include/grxkeys.h +and include/libbcc.h. + +

Compilation of the examples and installation of the header files is allowed +by setting INCLUDE_GPC_SUPPORT=y in makedef.grx. + +

The unit files contain at the beginning instructions to load the required +libraries (libgrx20..., depending on the system) and addon libraries +(e.g. libpng). +You can uncomment manually the addons you want. +You can also use the configure script which does that automatically, +together with editing the makedefs.grx file. + +

By default they are installed in a units directory below the +INSTALLDIR directory. But you can put them where you like. + + +

+ +


+Previous: Pascal interface, +Up: A User Manual For GRX2 + +
+ +

References

+ +

Official GRX site +http://grx.gnu.de +
GRX mailing list archive +http://grx.gnu.de/archive/grx/en/ +
MGRX site (fork from GRX) +http://mgrx.fgrim.com +
NetPbm distribution +http://netpbm.sourceforge.net +
PNG library +http://www.libpng.org/pub/png/libpng.html +
JPEG library +http://www.ijg.org +
TIFF library +http://www.remotesensing.org/libtiff/ +
+ + +

+ + + diff --git a/thirdparty/grx249/doc/grx249um.inf b/thirdparty/grx249/doc/grx249um.inf new file mode 100644 index 0000000..c09bf06 --- /dev/null +++ b/thirdparty/grx249/doc/grx249um.inf @@ -0,0 +1,2317 @@ +This is grx249um.inf, produced by makeinfo version 4.13 from grx2.tex. + +INFO-DIR-SECTION Libraries +START-INFO-DIR-ENTRY +* GRX: (grx). The GRX Graphics Library. +END-INFO-DIR-ENTRY + + +File: grx249um.inf, Node: Top, Next: A User Manual For GRX2 + + GRX 2.4.9 User's Manual +*********************** + +A 2D graphics library for DOS, Linux, X11 and Win32 +*************************************************** + Based on the original doc written by: Csaba Biegl on August 10, 1992 + Updated by: Mariano Alvarez Fernandez on August 17, 2000 + Last update: July 10, 2012 + +Abstract +******** + +*GRX* is a 2D graphics library originaly written by Csaba Biegl for DJ +Delorie's DOS port of the GCC compiler. Now it support a big range of +platforms, the main four are: DOS (DJGPPv2), Linux console, X11 and +Win32 (Mingw). On DOS it supports VGA, EGA and VESA compliant cards. +On Linux console it uses svgalib or the framebuffer. On X11 it must +work on any X11R5 (or later). From the 2.4 version, GRX comes with a +Win32 driver. The framebuffer Linux console driver was new in 2.4.2. +From 2.4.7 there is a support for x86_64 bits Linux machines and a +support for an SDL driver on MingW and X11. On MingW and X11 it runs on +a window with the original driver, and either full screen or on a +window with the SDL driver. + +* Menu: + +* A User Manual For GRX2:: + + +File: grx249um.inf, Node: A User Manual For GRX2, Next: Hello world, Prev: Top, Up: Top + +GRX2 User's Manual +****************** + +* Menu: + +* Top:: +* Hello world:: +* Data types and function declarations:: +* Setting the graphics driver:: +* Setting video modes:: +* Graphics contexts:: +* Context use:: +* Color management:: +* Portable use of a few colors:: +* Graphics primitives:: +* Non-clipping graphics primitives:: +* Customized line drawing:: +* Pattern filled graphics primitives:: +* Patterned line drawing:: +* Image manipulation:: +* Text drawing:: +* Drawing in user coordinates:: +* Graphics cursors:: +* Keyboard input:: +* Mouse event handling:: +* Writing/reading PNM graphics files:: +* Writing/reading PNG graphics files:: +* Writing/reading JPEG graphics files:: +* Miscellaneous functions:: +* BGI interface:: +* Pascal interface:: +* References:: + + +File: grx249um.inf, Node: Hello world, Next: Data types and function declarations, Prev: A User Manual For GRX2, Up: A User Manual For GRX2 + +Hello world +=========== + +The next program draws a double frame around the screen and writes +"Hello, GRX world" centered. Then it waits after a key is pressed. + + #include + #include + #include + + int main() + { + char *message = "Hello, GRX world"; + int x, y; + GrTextOption grt; + + GrSetMode( GR_default_graphics ); + + grt.txo_font = &GrDefaultFont; + grt.txo_fgcolor.v = GrWhite(); + grt.txo_bgcolor.v = GrBlack(); + grt.txo_direct = GR_TEXT_RIGHT; + grt.txo_xalign = GR_ALIGN_CENTER; + grt.txo_yalign = GR_ALIGN_CENTER; + grt.txo_chrtype = GR_BYTE_TEXT; + + GrBox( 0,0,GrMaxX(),GrMaxY(),GrWhite() ); + GrBox( 4,4,GrMaxX()-4,GrMaxY()-4,GrWhite() ); + + x = GrMaxX()/2; + y = GrMaxY()/2; + GrDrawString( message,strlen( message ),x,y,&grt ); + + GrKeyRead(); + + return 0; + } +How to compile the hello world (assuming the GRX library was previously +installed) + DJGPP: gcc -o hellogrx.exe hellogrx.c -lgrx20 + Mingw: gcc -o hellogrx.exe hellogrx.c -lgrx20 -mwindows + X11 : gcc -o hellogrx hellogrx.c -D__XWIN__ -I/usr/X11R6/include + -lgrx20X -L/usr/X11R6/lib -lX11 + Linux: gcc -o hellogrx hellogrx.c -lgrx20 -lvga + + For the SDL driver: + Mingw: gcc -o hellogrx.exe hellogrx.c -lgrx20S -lSDL + X11 : gcc -o hellogrx hellogrx.c -D__XWIN__ -I/usr/X11R6/include + -lgrx20S -lSDL -lpthread -L/usr/X11R6/lib -lX11 + + For x86_64 systems add -m32 or -m64 for 32/64 bits executables + and replace /lib by /lib64 or /lib32 as needed + + +File: grx249um.inf, Node: Data types and function declarations, Next: Setting the graphics driver, Prev: Hello world, Up: A User Manual For GRX2 + +Data types and function declarations +==================================== + +All public data structures and graphics primitives meant for usage by +the application program are declared/prototyped in the header files (in +the 'include' sub-directory): + + * grdriver.h graphics driver format specifications + * grfontdv.h format of a font when loaded into memory + * grx20.h drawing-related structures and functions + * grxkeys.h platform independent key definitions + + User programs normally only include *include/grx20.h* and *include/grxkeys.h* + + +File: grx249um.inf, Node: Setting the graphics driver, Next: Setting video modes, Prev: Data types and function declarations, Up: A User Manual For GRX2 + +Setting the graphics driver +=========================== + +The graphics driver is normally set by the final user by the environment +variable GRX20DRV, but a program can set it using: + + int GrSetDriver(char *drvspec); + +The drvspec string has the same format as the environment variable: + + gw gh nc + +Available drivers are for: + + * DOS => herc, stdvga, stdega, et4000, cl5426, mach64, ati28800, s3, VESA, memory + * Linux => svgalib, linuxfb, memory + * X11 => xwin, memory + * Win32 => win32, memory + * SDL (Win32 and X11) => sdl::fs, sdl::ww, memory + +The xwin and win32 drivers are windowed. The SDL driver on the same +systems can be either fullscreen (::fs) or windowed (::ww). + +The optionals gw, gh and nc parameters set the desired default graphics +mode. Normal values for 'nc' are 2, 16, 256, 64K and 16M. The current +driver name can be obtained from: + + GrCurrentVideoDriver()->name + + +File: grx249um.inf, Node: Setting video modes, Next: Graphics contexts, Prev: Setting the graphics driver, Up: A User Manual For GRX2 + +Setting video modes +=================== + +Before a program can do any graphics drawing it has to configure the +graphics driver for the desired graphics mode. It is done with the +GrSetMode function as follows: + + int GrSetMode(int which,...); + +On succes it returns non-zero (TRUE). The which parameter can be one of +the following constants, declared in grx20.h: + + typedef enum _GR_graphicsModes { + GR_80_25_text, + GR_default_text, + GR_width_height_text, + GR_biggest_text, + GR_320_200_graphics, + GR_default_graphics, + GR_width_height_graphics, + GR_biggest_noninterlaced_graphics, + GR_biggest_graphics, + GR_width_height_color_graphics, + GR_width_height_color_text, + GR_custom_graphics, + GR_width_height_bpp_graphics, + GR_width_height_bpp_text, + GR_custom_bpp_graphics, + GR_NC_80_25_text, + GR_NC_default_text, + GR_NC_width_height_text, + GR_NC_biggest_text, + GR_NC_320_200_graphics, + GR_NC_default_graphics, + GR_NC_width_height_graphics, + GR_NC_biggest_noninterlaced_graphics, + GR_NC_biggest_graphics, + GR_NC_width_height_color_graphics, + GR_NC_width_height_color_text, + GR_NC_custom_graphics, + GR_NC_width_height_bpp_graphics, + GR_NC_width_height_bpp_text, + GR_NC_custom_bpp_graphics, + } GrGraphicsMode; + +The GR_width_height_text and GR_width_height_graphics modes require the +two size arguments: int width and int height. + +The GR_width_height_color_graphics and GR_width_height_color_text modes +require three arguments: int width, int height and GrColor colors. + +The GR_width_height_bpp_graphics and GR_width_height_bpp_text modes +require three arguments: int width, int height and int bpp (bits per +plane instead number of colors). + +The GR_custom_graphics and GR_custom_bpp_graphics modes require five +arguments: int width, int height, GrColor colors or int bpp, int vx and +int vy. Using this modes you can set a virtual screen of vx by vy size. + +A call with any other mode does not require any arguments. + +The GR_NC_... modes are equivalent to the GR_.. ones, but they don't +clear the video memory. + +Graphics drivers can provide info of the supported graphics modes, use +the next code skeleton to colect the data: + + { + GrFrameMode fm; + const GrVideoMode *mp; + for(fm =GR_firstGraphicsFrameMode; fm <= GR_lastGraphicsFrameMode; fm++) { + mp = GrFirstVideoMode(fm); + while( mp != NULL ) { + .. + .. use the mp info + .. + mp = GrNextVideoMode(mp)) + } + } + } + +Don't worry if you don't understand it, normal user programs don't need +to know about FrameModes. The GrVideoMode structure has the following +fields: + + typedef struct _GR_videoMode GrVideoMode; + + struct _GR_videoMode { + char present; /* is it really available? */ + char bpp; /* log2 of # of colors */ + short width,height; /* video mode geometry */ + short mode; /* BIOS mode number (if any) */ + int lineoffset; /* scan line length */ + int privdata; /* driver can use it for anything */ + struct _GR_videoModeExt *extinfo; /* extra info (maybe shared) */ + }; + +The width, height and bpp members are the useful information if you are +interested in set modes other than the GR_default_graphics. + +A user-defined function can be invoked every time the video mode is +changed (i.e. GrSetMode is called). This function should not take any +parameters and don't return any value. It can be installed (for all +subsequent GrSetMode calls) with the: + + void GrSetModeHook(void (*hookfunc)(void)); + +function. The current graphics mode (one of the valid mode argument +values for GrSetMode) can be obtained with the: + + GrGraphicsMode GrCurrentMode(void); + +function, while the type of the installed graphics adapter can be +determined with the: + + GrVideoAdapter GrAdapterType(void); + +function. GrAdapterType returns the type of the adapter as one of the +following symbolic constants (defined in grx20.h): + + typedef enum _GR_videoAdapters { + GR_UNKNOWN = (-1), /* not known (before driver set) */ + GR_VGA, /* VGA adapter */ + GR_EGA, /* EGA adapter */ + GR_HERC, /* Hercules mono adapter */ + GR_8514A, /* 8514A or compatible */ + GR_S3, /* S3 graphics accelerator */ + GR_XWIN, /* X11 driver */ + GR_WIN32, /* WIN32 driver */ + GR_LNXFB, /* Linux framebuffer */ + GR_SDL, /* SDL driver */ + GR_MEM /* memory only driver */ + } GrVideoAdapter; + +Note that the VESA driver return GR_VGA here. + + +File: grx249um.inf, Node: Graphics contexts, Next: Context use, Prev: Setting video modes, Up: A User Manual For GRX2 + +Graphics contexts +================= + +The library supports a set of drawing regions called contexts (the +GrContext structure). These can be in video memory or in system memory. +Contexts in system memory always have the same memory organization as +the video memory. When GrSetMode is called, a default context is +created which maps to the whole graphics screen. Contexts are described +by the GrContext data structure: + + typedef struct _GR_context GrContext; + + struct _GR_context { + struct _GR_frame gc_frame; /* frame buffer info */ + struct _GR_context *gc_root; /* context which owns frame */ + int gc_xmax; /* max X coord (width - 1) */ + int gc_ymax; /* max Y coord (height - 1) */ + int gc_xoffset; /* X offset from root's base */ + int gc_yoffset; /* Y offset from root's base */ + int gc_xcliplo; /* low X clipping limit */ + int gc_ycliplo; /* low Y clipping limit */ + int gc_xcliphi; /* high X clipping limit */ + int gc_ycliphi; /* high Y clipping limit */ + int gc_usrxbase; /* user window min X coordinate */ + int gc_usrybase; /* user window min Y coordinate */ + int gc_usrwidth; /* user window width */ + int gc_usrheight; /* user window height */ + # define gc_baseaddr gc_frame.gf_baseaddr + # define gc_selector gc_frame.gf_selector + # define gc_onscreen gc_frame.gf_onscreen + # define gc_memflags gc_frame.gf_memflags + # define gc_lineoffset gc_frame.gf_lineoffset + # define gc_driver gc_frame.gf_driver + }; + +The following four functions return information about the layout of and +memory occupied by a graphics context of size width by height in the +current graphics mode (as set up by GrSetMode): + + int GrLineOffset(int width); + int GrNumPlanes(void); + long GrPlaneSize(int w,int h); + long GrContextSize(int w,int h); + +GrLineOffset always returns the offset between successive pixel rows of +the context in bytes. GrNumPlanes returns the number of bitmap planes +in the current graphics mode. GrContextSize calculates the total amount +of memory needed by a context, while GrPlaneSize calculates the size of +a bitplane in the context. The function: + + GrContext *GrCreateContext(int w,int h,char far *memory[4],GrContext *where); + +can be used to create a new context in system memory. The NULL pointer +is also accepted as the value of the memory and where arguments, in +this case the library allocates the necessary amount of memory +internally. It is a general convention in the library that functions +returning pointers to any GRX specific data structure have a last +argument (most of the time named where in the prototypes) which can be +used to pass the address of the data structure which should be filled +with the result. If this where pointer has the value of NULL, then the +library allocates space for the data structure internally. + +The memory argument is really a 4 pointer array, each pointer must +point to space to handle GrPlaneSize(w,h) bytes, really only +GrNumPlanes() pointers must be malloced, the rest can be NULL. +Nevertheless the normal use (see below) is + + gc = GrCreateContext(w,h,NULL,NULL); + +so yo don't need to care about. + +The function: + + GrContext *GrCreateSubContext(int x1,int y1,int x2,int y2, + const GrContext *parent,GrContext *where); + +creates a new sub-context which maps to a part of an existing context. +The coordinate arguments (x1 through y2) are interpreted relative to +the parent context's limits. Pixel addressing is zero-based even in +sub-contexts, i.e. the address of the top left pixel is (0,0) even in a +sub-context which has been mapped onto the interior of its parent +context. + +Sub-contexts can be resized, but not their parents (i.e. anything +returned by GrCreateContext or set up by GrSetMode cannot be resized - +because this could lead to irrecoverable "loss" of drawing memory. The +following function can be used for this purpose: + + void GrResizeSubContext(GrContext *context,int x1,int y1,int x2,int y2); + +The current context structure is stored in a static location in the +library. (For efficiency reasons - it is used quite frequently, and +this way no pointer dereferencing is necessary.) The context stores all +relevant information about the video organization, coordinate limits, +etc... The current context can be set with the: + + void GrSetContext(const GrContext *context); + +function. This function will reset the current context to the full +graphics screen if it is passed the NULL pointer as argument. The value +of the current context can be saved into a GrContext structure pointed +to by where using: + + GrContext *GrSaveContext(GrContext *where); + +(Again, if where is NULL, the library allocates the space.) The next two +functions: + + const GrContext *GrCurrentContext(void); + const GrContext *GrScreenContext(void); + +return the current context and the screen context respectively. +Contexts can be destroyed with: + + void GrDestroyContext(GrContext *context); + +This function will free the memory occupied by the context only if it +was allocated originally by the library. The next three functions set +up and query the clipping limits associated with the current context: + + void GrSetClipBox(int x1,int y1,int x2,int y2); + void GrGetClipBox(int *x1p,int *y1p,int *x2p,int *y2p); + void GrResetClipBox(void); + +GrResetClipBox sets the clipping limits to the limits of context. These +are the limits set up initially when a context is created. There are +three similar functions to sets/gets the clipping limits of any context: + + void GrSetClipBoxC(GrContext *c,int x1,int y1,int x2,int y2); + void GrGetClipBoxC(const GrContext *c,int *x1p,int *y1p,int *x2p,int *y2p); + void GrResetClipBoxC(GrContext *c); + +The limits of the current context can be obtained using the following +functions: + + int GrMaxX(void); + int GrMaxY(void); + int GrSizeX(void); + int GrSizeY(void); + +The Max functions return the biggest valid coordinate, while the Size +functions return a value one higher. The limits of the graphics screen +(regardless of the current context) can be obtained with: + + int GrScreenX(void); + int GrScreenY(void); + +If you had set a virtual screen (using a custom graphics mode), the +limits of the virtual screen can be fetched with: + + int GrVirtualX(void); + int GrVirtualY(void); + +The routine: + + int GrScreenIsVirtual(void); + +returns non zero if a virtual screen is set. The rectangle showed in +the real screen can be set with: + + int GrSetViewport(int xpos,int ypos); + +and the current viewport position can be obtained by: + + int GrViewportX(void); + int GrViewportY(void); + + +File: grx249um.inf, Node: Context use, Next: Color management, Prev: Graphics contexts, Up: A User Manual For GRX2 + +Context use +=========== + +Here is a example of normal context use: + + GrContext *grc; + + if( (grc = GrCreateContext( w,h,NULL,NULL )) == NULL ){ + ...process the error + } + else { + GrSetContext( grc ); + ...do some drawing + ...and probably bitblt to the screen context + GrSetContext( NULL ); /* the screen context! */ + GrDestroyContext( grc ); + } + +But if you have a GrContext variable (not a pointer) you want to use +(probably because is static to some routines) you can do: + + static GrContext grc; /* not a pointer!! */ + + if( GrCreateContext( w,h,NULL,&grc )) == NULL ) { + ...process the error + } + else { + GrSetContext( &grc ); + ...do some drawing + ...and probably bitblt to the screen context + GrSetContext( NULL ); /* the screen context! */ + GrDestroyContext( &grc ); + } + +Note that GrDestoryContext knows if grc was automatically malloced or +not!! + +Only if you don't want GrCreateContext use malloc at all, you must +allocate the memory buffers and pass it to GrCreateContext. + +Using GrCreateSubContext is the same, except it doesn't need the buffer, +because it uses the parent buffer. + +See the *test/winclip.c* and *test/wintest.c* examples. + + +File: grx249um.inf, Node: Color management, Next: Portable use of a few colors, Prev: Context use, Up: A User Manual For GRX2 + +Color management +================ + +GRX defines the type GrColor for color variables. GrColor it's a 32 bits +integer. The 8 left bits are reserved for the write mode (see below). +The 24 bits right are the color value. + +The library supports two models for color management. In the 'indirect' +(or color table) model, color values are indices to a color table. The +color table slots will be allocated with the highest resolution +supported by the hardware (EGA: 2 bits, VGA: 6 bits) with respect to +the component color intensities. In the 'direct' (or RGB) model, color +values map directly into component color intensities with +non-overlapping bitfields of the color index representing the component +colors. + +Color table model is supported until 256 color modes. The RGB model is +supported in 256 color and up color modes. + +In RGB model the color index map to component color intensities depend +on the video mode set, so it can't be assumed the component color +bitfields (but if you are curious check the GrColorInfo global +structure in grx20.h). + +After the first GrSetMode call two colors are always defined: black and +white. The color values of these two colors are returned by the +functions: + + GrColor GrBlack(void); + GrColor GrWhite(void); + +GrBlack() is guaranteed to be 0. + +The library supports five write modes (a write mode descibes the +operation between the actual bit color and the one to be set): write, +XOR, logical OR, logical AND and IMAGE. These can be selected with +OR-ing the color value with one of the following constants declared in +grx20.h : + + #define GrWRITE 0UL /* write color */ + #define GrXOR 0x01000000UL /* to "XOR" any color to the screen */ + #define GrOR 0x02000000UL /* to "OR" to the screen */ + #define GrAND 0x03000000UL /* to "AND" to the screen */ + #define GrIMAGE 0x04000000UL /* blit: write, except given color */ + +The GrIMAGE write mode only works with the bitblt function. By +convention, the no-op color is obtained by combining color value 0 +(black) with the XOR operation. This no-op color has been defined in +grx20.h as: + + #define GrNOCOLOR (GrXOR | 0) /* GrNOCOLOR is used for "no" color */ + +The write mode part and the color value part of a GrColor variable can +be obtained OR-ing it with one of the following constants declared in +grx20.h: + + #define GrCVALUEMASK 0x00ffffffUL /* color value mask */ + #define GrCMODEMASK 0xff000000UL /* color operation mask */ + +The number of colors in the current graphics mode is returned by the: + + GrColor GrNumColors(void); + +function, while the number of unused, available color can be obtained by +calling: + + GrColor GrNumFreeColors(void); + +Colors can be allocated with the: + + GrColor GrAllocColor(int r,int g,int b); + GrColor GrAllocColor2(long hcolor); + +functions (component intensities can range from 0 to 255, hcolor must +be in 0xRRGGBB format), or with the: + + GrColor GrAllocCell(void); + +function. In the second case the component intensities of the returned +color can be set with: + + void GrSetColor(GrColor color,int r,int g,int b); + +In the color table model both Alloc functions return GrNOCOLOR if there +are no more free colors available. In the RGB model GrNumFreeColors +returns 0 and GrAllocCell always returns GrNOCOLOR, as colors returned +by GrAllocCell are meant to be changed - what is not supposed to be +done in RGB mode. Also note that GrAllocColor operates much more +efficiently in RGB mode, and that it never returns GrNOCOLOR in this +case. + +Color table entries can be freed (when not in RGB mode) by calling: + + void GrFreeColor(GrColor color); + +The component intensities of any color can be queried using one of this +function: + + void GrQueryColor(GrColor c,int *r,int *g,int *b); + void GrQueryColor2(GrColor c,long *hcolor); + +Initially the color system is in color table (indirect) model if there +are 256 or less colors. 256 color modes can be put into the RGB model +by calling: + + void GrSetRGBcolorMode(void); + +The color system can be reset (i.e. put back into color table model if +possible, all colors freed except for black and white) by calling: + + void GrResetColors(void); + +The function: + + void GrRefreshColors(void); + +reloads the currently allocated color values into the video hardware. +This function is not needed in typical applications, unless the display +adapter is programmed directly by the application. + +This functions: + + GrColor GrAllocColorID(int r,int g,int b); + GrColor GrAllocColor2ID(long hcolor); + void GrQueryColorID(GrColor c,int *r,int *g,int *b); + void GrQueryColor2ID(GrColor c,long *hcolor); + +are inlined versions (except if you compile GRX with GRX_SKIP_INLINES +defined) to be used in the RGB model (in the color table model they +call the normal routines). + +See the *test/rgbtest.c* and *test/colorops.c* examples. + + +File: grx249um.inf, Node: Portable use of a few colors, Next: Graphics primitives, Prev: Color management, Up: A User Manual For GRX2 + +Portable use of a few colors +============================ + +People that only want to use a few colors find the GRX color handling a +bit confusing, but it gives the power to manage a lot of color deeps +and two color models. Here are some guidelines to easily use the famous +16 ega colors in GRX programs. We need this GRX function: + + GrColor *GrAllocEgaColors(void); + +it returns a 16 GrColor array with the 16 ega colors alloced (really +it's a trivial function, read the source src/setup/colorega.c). We can +use a construction like that: + +First, in your C code make a global pointer, and init it after set the +graphics mode: + + GrColor *egacolors; + .... + int your_setup_function( ... ) + { + ... + GrSetMode( ... ) + ... + egacolors = GrAllocEgaColors(); + ... + } + +Next, add this to your main include file: + + extern GrColor *egacolors; + #define BLACK egacolors[0] + #define BLUE egacolors[1] + #define GREEN egacolors[2] + #define CYAN egacolors[3] + #define RED egacolors[4] + #define MAGENTA egacolors[5] + #define BROWN egacolors[6] + #define LIGHTGRAY egacolors[7] + #define DARKGRAY egacolors[8] + #define LIGHTBLUE egacolors[9] + #define LIGHTGREEN egacolors[10] + #define LIGHTCYAN egacolors[11] + #define LIGHTRED egacolors[12] + #define LIGHTMAGENTA egacolors[13] + #define YELLOW egacolors[14] + #define WHITE egacolors[15] + +Now you can use the defined colors in your code. Note that if you are +in color table model in a 16 color mode, you have exhausted the color +table. Note too that this don't work to initialize static variables +with a color, because egacolors is not initialized. + + +File: grx249um.inf, Node: Graphics primitives, Next: Non-clipping graphics primitives, Prev: Portable use of a few colors, Up: A User Manual For GRX2 + +Graphics primitives +=================== + +The screen, the current context or the current clip box can be cleared +(i.e. set to a desired background color) by using one of the following +three functions: + + void GrClearScreen(GrColor bg); + void GrClearContext(GrColor bg); + void GrClearClipBox(GrColor bg); + +Any context can be cleared using this function: + void GrClearContextC(GrContext *ctx, GrColor bg); + +Thanks to the special GrColor definition, you can do more than simple +clear with this functions, by example with: + + GrClearScreen( GrWhite()|GrXOR ); + +the graphics screen is negativized, do it again and the screen is +restored. + +The following line drawing graphics primitives are supported by the +library: + + void GrPlot(int x,int y,GrColor c); + void GrLine(int x1,int y1,int x2,int y2,GrColor c); + void GrHLine(int x1,int x2,int y,GrColor c); + void GrVLine(int x,int y1,int y2,GrColor c); + void GrBox(int x1,int y1,int x2,int y2,GrColor c); + void GrCircle(int xc,int yc,int r,GrColor c); + void GrEllipse(int xc,int yc,int xa,int ya,GrColor c); + void GrCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c); + void GrEllipseArc(int xc,int yc,int xa,int ya, + int start,int end,int style,GrColor c); + void GrPolyLine(int numpts,int points[][2],GrColor c); + void GrPolygon(int numpts,int points[][2],GrColor c); + +All primitives operate on the current graphics context. The last +argument of these functions is always the color to use for the drawing. +The HLine and VLine primitives are for drawing horizontal and vertical +lines. They have been included in the library because they are more +efficient than the general line drawing provided by GrLine. The ellipse +primitives can only draw ellipses with their major axis parallel with +either the X or Y coordinate axis. They take the half X and Y axis +length in the xa and ya arguments. The arc (circle and ellipse) drawing +functions take the start and end angles in tenths of degrees (i.e. +meaningful range: 0 ... 3600). The angles are interpreted +counter-clockwise starting from the positive X axis. The style argument +can be one of this defines from grx20.h: + + #define GR_ARC_STYLE_OPEN 0 + #define GR_ARC_STYLE_CLOSE1 1 + #define GR_ARC_STYLE_CLOSE2 2 + +GR_ARC_STYLE_OPEN draws only the arc, GR_ARC_STYLE_CLOSE1 closes the +arc with a line between his start and end point, GR_ARC_STYLE_CLOSE1 +draws the typical cake slice. This routine: + + void GrLastArcCoords(int *xs,int *ys,int *xe,int *ye,int *xc,int *yc); + +can be used to retrieve the start, end, and center points used by the +last arc drawing functions. + +See the *test/circtest.c* and *test/arctest.c* examples. + +The polyline and polygon primitives take the address of an n by 2 +coordinate array. The X values should be stored in the elements with 0 +second index, and the Y values in the elements with a second index +value of 1. Coordinate arrays passed to the polygon primitive can +either contain or omit the closing edge of the polygon - the primitive +will append it to the list if it is missing. + +See the *test/polytest.c* example. + +Because calculating the arc points it's a very time consuming +operation, there are two functions to pre-calculate the points, that +can be used next with polyline and polygon primitives: + + int GrGenerateEllipse(int xc,int yc,int xa,int ya, + int points[GR_MAX_ELLIPSE_POINTS][2]); + int GrGenerateEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int points[GR_MAX_ELLIPSE_POINTS][2]); + +The following filled primitives are available: + + void GrFilledBox(int x1,int y1,int x2,int y2,GrColor c); + void GrFramedBox(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c); + void GrFilledCircle(int xc,int yc,int r,GrColor c); + void GrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c); + void GrFilledCircleArc(int xc,int yc,int r, + int start,int end,int style,GrColor c); + void GrFilledEllipseArc(int xc,int yc,int xa,int ya, + int start,int end,int style,GrColor c); + void GrFilledPolygon(int numpts,int points[][2],GrColor c); + void GrFilledConvexPolygon(int numpts,int points[][2],GrColor c); + +Similarly to the line drawing, all of the above primitives operate on +the current graphics context. The GrFramedBox primitive can be used to +draw motif-like shaded boxes and "ordinary" framed boxes as well. The +x1 through y2 coordinates specify the interior of the box, the border +is outside this area, wdt pixels wide. The primitive uses five +different colors for the interior and four borders of the box which are +specified in the GrFBoxColors structure: + + typedef struct { + GrColor fbx_intcolor; + GrColor fbx_topcolor; + GrColor fbx_rightcolor; + GrColor fbx_bottomcolor; + GrColor fbx_leftcolor; + } GrFBoxColors; + +The GrFilledConvexPolygon primitive can be used to fill convex +polygons. It can also be used to fill some concave polygons whose +boundaries do not intersect any horizontal scan line more than twice. +All other concave polygons have to be filled with the (somewhat less +efficient) GrFilledPolygon primitive. This primitive can also be used +to fill several disjoint non­overlapping polygons in a single operation. + +The function: + + void GrFloodFill(int x, int y, GrColor border, GrColor c); + +flood-fills the area bounded by the color border using x, y like the +starting point. + +Floodspill is a color replacer, replacing color A with color B. This +is quite useful for highlighting a selected item in a list, or changing +a selected color(s) in a multi colored area. + + void GrFloodSpill(int x1, int y1, int x2, int y2, + GrColor old_c, GrColor new_c) + +replaces old color with new color in the rectangle bounded by x1, y1, +x2, y2. + + void GrFloodSpillC(GrContext *ctx, int x1, int y1, int x2, int y2, + GrColor old_c, GrColor new_c) + +as above but in the specified context. + + void GrFloodSpill2(int x1, int y1, int x2, int y2, + GrColor old_c1, GrColor new_c1, + GrColor old_c2, GrColor new_c2) + +replaces 2 colors, a one stop shop for highlighting a selection in a +list. + + void GrFloodSpillC2(GrContext *ctx, int x1, int y1, int x2, int y2, + GrColor old_c1, GrColor new_c1, + GrColor old_c2, GrColor new_c2) + +as above but in the specified context. + +The current color value of any pixel in the current context can be +obtained with: + + GrColor GrPixel(int x,int y); + +and: + + GrColor GrPixelC(GrContext *c,int x,int y); + +do the same for any context. + +Rectangular areas can be transferred within a context or between +contexts by calling: + + void GrBitBlt(GrContext *dest,int x,int y,GrContext *source, + int x1,int y1,int x2,int y2,GrColor op); + +x, y is the position in the destination context, and x1, y1, x2, y2 the +area from the source context to be transfered. The op argument should +be one of supported color write modes (GrWRITE, GrXOR, GrOR, GrAND, +GrIMAGE), it will control how the pixels from the source context are +combined with the pixels in the destination context (the GrIMAGE op +must be ored with the color value to be handled as transparent). If +either the source or the destination context argument is the NULL +pointer then the current context is used for that argument. + +See the *test/blittest.c* example. + +A efficient form to get/put pixels from/to a context can be achieved +using the next functions: + + const GrColor *GrGetScanline(int x1,int x2,int yy); + const GrColor *GrGetScanlineC(GrContext *ctx,int x1,int x2,int yy); + void GrPutScanline(int x1,int x2,int yy,const GrColor *c, GrColor op); + +The Get functions return a pointer to a static GrColor pixel array (or +NULL if they fail) with the color values of a row (yy) segment (x1 to +x2). GrGetScanline uses the current context. GrGestScanlineC uses the +context ctx (that can be NULL to refer to the current context). Note +that the output is only valid until the next GRX call. + +GrPutScanline puts the GrColor pixel array c on the yy row segmet +defined by x1 to x2 in the current context using the op operation. op +can be any of GrWRITE, GrXOR, GrOR, GrAND or GrIMAGE. Data in c must +fit GrCVALUEMASK otherwise the results are implementation dependend. So +you can't supply operation code with the pixel data!. + + +File: grx249um.inf, Node: Non-clipping graphics primitives, Next: Customized line drawing, Prev: Graphics primitives, Up: A User Manual For GRX2 + +Non-clipping graphics primitives +================================ + +There is a non-clipping version of some of the elementary primitives. +These are somewhat more efficient than the regular versions. These are +to be used only in situations when it is absolutely certain that no +drawing will be performed beyond the boundaries of the current context. +Otherwise the program will almost certainly crash! The reason for +including these functions is that they are somewhat more efficient than +the regular, clipping versions. ALSO NOTE: These function do not check +for conflicts with the mouse cursor. (See the explanation about the +mouse cursor handling later in this document.) The list of the +supported non-clipping primitives: + + void GrPlotNC(int x,int y,GrColor c); + void GrLineNC(int x1,int y1,int x2,int y2,GrColor c); + void GrHLineNC(int x1,int x2,int y,GrColor c); + void GrVLineNC(int x,int y1,int y2,GrColor c); + void GrBoxNC(int x1,int y1,int x2,int y2,GrColor c); + void GrFilledBoxNC(int x1,int y1,int x2,int y2,GrColor c); + void GrFramedBoxNC(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c); + void grbitbltNC(GrContext *dst,int x,int y,GrContext *src, + int x1,int y1,int x2,int y2,GrColor op); + GrColor GrPixelNC(int x,int y); + GrColor GrPixelCNC(GrContext *c,int x,int y); + + +File: grx249um.inf, Node: Customized line drawing, Next: Pattern filled graphics primitives, Prev: Non-clipping graphics primitives, Up: A User Manual For GRX2 + +Customized line drawing +======================= + +The basic line drawing graphics primitives described previously always +draw continuous lines which are one pixel wide. There is another group +of line drawing functions which can be used to draw wide and/or +patterned lines. These functions have similar parameter passing +conventions as the basic ones with one difference: instead of the color +value a pointer to a structure of type GrLineOption has to be passed to +them. The definition of the GrLineOption structure: + + typedef struct { + GrColor lno_color; /* color used to draw line */ + int lno_width; /* width of the line */ + int lno_pattlen; /* length of the dash pattern */ + unsigned char *lno_dashpat; /* draw/nodraw pattern */ + } GrLineOption; + +The lno_pattlen structure element should be equal to the number of +alternating draw - no draw section length values in the array pointed +to by the lno_dashpat element. The dash pattern array is assumed to +begin with a drawn section. If the pattern length is equal to zero a +continuous line is drawn. + +Example, a white line 3 bits wide (thick) and pattern 6 bits draw, 4 +bits nodraw: + + GrLineOption mylineop; + ... + mylineop.lno_color = GrWhite(); + mylineop.lno_width = 3; + mylineop.lno_pattlen = 2; + mylineop.lno_dashpat = "\x06\x04"; + +The available custom line drawing primitives: + + void GrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o); + void GrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o); + void GrCustomCircle(int xc,int yc,int r,const GrLineOption *o); + void GrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o); + void GrCustomCircleArc(int xc,int yc,int r, + int start,int end,int style,const GrLineOption *o); + void GrCustomEllipseArc(int xc,int yc,int xa,int ya, + int start,int end,int style,const GrLineOption *o); + void GrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o); + void GrCustomPolygon(int numpts,int points[][2],const GrLineOption *o); + +See the *test/linetest.c* example. + + +File: grx249um.inf, Node: Pattern filled graphics primitives, Next: Patterned line drawing, Prev: Customized line drawing, Up: A User Manual For GRX2 + +Pattern filled graphics primitives +================================== + +The library also supports a pattern filled version of the basic filled +primitives described above. These functions have similar parameter +passing conventions as the basic ones with one difference: instead of +the color value a pointer to an union of type 'GrPattern' has to be +passed to them. The GrPattern union can contain either a bitmap or a +pixmap fill pattern. The first integer slot in the union determines +which type it is. Bitmap fill patterns are rectangular arrays of bits, +each set bit representing the foreground color of the fill operation, +and each zero bit representing the background. Both the foreground and +background colors can be combined with any of the supported logical +operations. Bitmap fill patterns have one restriction: their width must +be eight pixels. Pixmap fill patterns are very similar to contexts. The +relevant structure declarations (from grx20.h): + + /* + * BITMAP: a mode independent way to specify a fill pattern of two + * colors. It is always 8 pixels wide (1 byte per scan line), its + * height is user-defined. SET THE TYPE FLAG TO ZERO!!! + */ + typedef struct _GR_bitmap { + int bmp_ispixmap; /* type flag for pattern union */ + int bmp_height; /* bitmap height */ + char *bmp_data; /* pointer to the bit pattern */ + GrColor bmp_fgcolor; /* foreground color for fill */ + GrColor bmp_bgcolor; /* background color for fill */ + int bmp_memflags; /* set if dynamically allocated */ + } GrBitmap; + + /* + * PIXMAP: a fill pattern stored in a layout identical to the video RAM + * for filling using 'bitblt'-s. It is mode dependent, typically one + * of the library functions is used to build it. KEEP THE TYPE FLAG + * NONZERO!!! + */ + typedef struct _GR_pixmap { + int pxp_ispixmap; /* type flag for pattern union */ + int pxp_width; /* pixmap width (in pixels) */ + int pxp_height; /* pixmap height (in pixels) */ + GrColor pxp_oper; /* bitblt mode (SET, OR, XOR, AND, IMAGE) */ + struct _GR_frame pxp_source; /* source context for fill */ + } GrPixmap; + + /* + * Fill pattern union -- can either be a bitmap or a pixmap + */ + typedef union _GR_pattern { + int gp_ispixmap; /* nonzero for pixmaps */ + GrBitmap gp_bitmap; /* fill bitmap */ + GrPixmap gp_pixmap; /* fill pixmap */ + } GrPattern; + +This define group (from grx20.h) help to acces the GrPattern menbers: + + #define gp_bmp_data gp_bitmap.bmp_data + #define gp_bmp_height gp_bitmap.bmp_height + #define gp_bmp_fgcolor gp_bitmap.bmp_fgcolor + #define gp_bmp_bgcolor gp_bitmap.bmp_bgcolor + + #define gp_pxp_width gp_pixmap.pxp_width + #define gp_pxp_height gp_pixmap.pxp_height + #define gp_pxp_oper gp_pixmap.pxp_oper + #define gp_pxp_source gp_pixmap.pxp_source + +Bitmap patterns can be easily built from initialized character arrays +and static structures by the C compiler, thus no special support is +included in the library for creating them. The only action required +from the application program might be changing the foreground and +background colors as needed. Pixmap patterns are more difficult to +build as they replicate the layout of the video memory which changes +for different video modes. For this reason the library provides three +functions to create pixmap patterns in a mode-independent way: + + GrPattern *GrBuildPixmap(const char *pixels,int w,int h,const GrColorTableP colors); + GrPattern *GrBuildPixmapFromBits(const char *bits,int w,int h, + GrColor fgc,GrColor bgc); + GrPattern *GrConvertToPixmap(GrContext *src); + +GrBuildPixmap build a pixmap from a two dimensional (w by h) array of +characters. The elements in this array are used as indices into the +color table specified with the argument colors. (This means that +pixmaps created this way can use at most 256 colors.) The color table +pointer: + + typedef GrColor *GrColorTableP; + +should point to an array of integers with the first element being the +number of colors in the table and the color values themselves starting +with the second element. NOTE: any color modifiers (GrXOR, GrOR, GrAND) +OR-ed to the elements of the color table are ignored. + +The GrBuildPixmapFromBits function builds a pixmap fill pattern from +bitmap data. It is useful if the width of the bitmap pattern is not +eight as such bitmap patterns can not be used to build a GrBitmap +structure. + +The GrConvertToPixmap function converts a graphics context to a pixmap +fill pattern. It is useful when the pattern can be created with +graphics drawing operations. NOTE: the pixmap pattern and the original +context share the drawing RAM, thus if the context is redrawn the fill +pattern changes as well. Fill patterns which were built by library +routines can be destroyed when no longer needed (i.e. the space +occupied by them can be freed) by calling: + + void GrDestroyPattern(GrPattern *p); + +NOTE: when pixmap fill patterns converted from contexts are destroyed, +the drawing RAM is not freed. It is freed when the original context is +destroyed. Fill patterns built by the application have to be destroyed +by the application as well (if this is needed). + +The list of supported pattern filled graphics primitives is shown +below. These functions are very similar to their solid filled +counterparts, only their last argument is different: + + void GrPatternFilledPlot(int x,int y,GrPattern *p); + void GrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p); + void GrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p); + void GrPatternFilledCircle(int xc,int yc,int r,GrPattern *p); + void GrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p); + void GrPatternFilledCircleArc(int xc,int yc,int r,int start,int end, + int style,GrPattern *p); + void GrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,GrPattern *p); + void GrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p); + void GrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p); + void GrPatternFloodFill(int x, int y, GrColor border, GrPattern *p); + +Strictly speaking the plot and line functions in the above group are not +filled, but they have been included here for convenience. + + +File: grx249um.inf, Node: Patterned line drawing, Next: Image manipulation, Prev: Pattern filled graphics primitives, Up: A User Manual For GRX2 + +Patterned line drawing +====================== + +The custom line drawing functions introduced above also have a version +when the drawn sections can be filled with a (pixmap or bitmap) fill +pattern. To achieve this these functions must be passed both a custom +line drawing option (GrLineOption structure) and a fill pattern +(GrPattern union). These two have been combined into the GrLinePattern +structure: + + typedef struct { + GrPattern *lnp_pattern; /* fill pattern */ + GrLineOption *lnp_option; /* width + dash pattern */ + } GrLinePattern; + +All patterned line drawing functions take a pointer to this structure +as their last argument. The list of available functions: + + void GrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp); + void GrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp); + void GrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp); + void GrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp); + void GrPatternedCircleArc(int xc,int yc,int r,int start,int end, + int style,GrLinePattern *lp); + void GrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,GrLinePattern *lp); + void GrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp); + void GrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp); + + +File: grx249um.inf, Node: Image manipulation, Next: Text drawing, Prev: Patterned line drawing, Up: A User Manual For GRX2 + +Image manipulation +================== + +GRX defines the GrImage type like a GrPixmap synonym: + + #define GrImage GrPixmap + +nevertheless the GrImage type enforces the image character of this +object, so for compatibility with future GRX versions use the next +functions if you need to convert between GrImage and GrPixmap objects: + + GrImage *GrImageFromPattern(GrPattern *p); + GrPattern *GrPatternFromImage(GrImage *p); + +the GrImageFromPattern function returns NULL if the GrPattern given is +not a GrPixmap. + +Like pixmaps patterns images are dependent of the actual video mode +set. So the library provides functions to create images in a +mode-independent way: + + GrImage *GrImageBuild(const char *pixels,int w,int h,const GrColorTableP colors); + GrImage *GrImageFromContext(GrContext *c); + +these functions work like the GrBuildPixmap and GrConvertToPixmap ones. +Remember: the image and the original context share the drawing RAM. + +There are a number of functions to display all or part of an image in +the current context: + + void GrImageDisplay(int x,int y, GrImage *i); + void GrImageDisplayExt(int x1,int y1,int x2,int y2, GrImage *i); + void GrImageFilledBoxAlign(int xo,int yo,int x1,int y1,int x2,int y2, + GrImage *p); + void GrImageHLineAlign(int xo,int yo,int x,int y,int width,GrImage *p); + void GrImagePlotAlign(int xo,int yo,int x,int y,GrImage *p); + +GrImageDisplay display the whole image using x, y like the upper left +corner in the current context. GrImageDisplayExt display as much as it +can (repiting the image if necesary) in the rectangle defined by x1, y1 +and x2, y2. + +GrImageFilledBoxAlign is a most general funtion (really the later two +call it) display as much as it can in the defined rectangle using xo, +yo like the align point, it is the virtual point in the destination +context (it doesn't need to be into the rectangle) with that the upper +left image corner is aligned. + +GrImageHLineAlign and GrImagePlotAlign display a row segment or a point +of the image at x y position using the xo, yo allign point. + +The most usefull image funtions are these: + + GrImage *GrImageInverse(GrImage *p,int flag); + GrImage *GrImageStretch(GrImage *p,int nwidth,int nheight); + +GrImageInverse creates a new image object, flipping p left-right or +top-down as indicated by flag that can be: + + #define GR_IMAGE_INVERSE_LR 0x01 /* inverse left right */ + #define GR_IMAGE_INVERSE_TD 0x02 /* inverse top down */ + +GrImageStretch creates a new image stretching p to nwidth by nheight. + +To destroy a image objet when you don't need it any more use: + + void GrImageDestroy(GrImage *i); + +See the *test/imgtest.c* example. + + +File: grx249um.inf, Node: Text drawing, Next: Drawing in user coordinates, Prev: Image manipulation, Up: A User Manual For GRX2 + +Text drawing +============ + +The library supports loadable fonts. When in memory they are bit-mapped +(i.e. not scalable!) fonts. A driver design allow GRX to load +different font formats, the last GRX release come with drivers to load +the GRX own font format and the BGI Borland format for all platforms +supported, the X11 version can load X11 fonts too. + +The GRX distribution come with a font collection in the GRX own format. +Some of these fonts were converted from VGA fonts. These fonts have all +256 characters from the PC-437 codepage. Some additional fonts were +converted from fonts in the MIT X11 distribution. Most of these are +ISO-8859-1 coded. Fonts also have family names. The following font +families are included: + + Font file name Family Description + pcx[t].fnt pc VGA font, fixed + xmx[b][i].fnt X_misc X11, fixed, miscellaneous group + char[b][i].fnt char X11, proportional, charter family + cour[b][i].fnt cour X11, fixed, courier + helve[b][i].fnt helve X11, proportional, helvetica + lucb[b][i].fnt lucb X11, proportional, lucida bright + lucs[b][i].fnt lucs X11, proportional, lucida sans serif + luct[b][i].fnt luct X11, fixed, lucida typewriter + ncen[b][i].fnt ncen X11, proportional, new century schoolbook + symb.fnt symbol X11, proportional, greek letters, symbols + tms[b][i].fnt times X11, proportional, times + +In the font names means the font width, the font height. Many +font families have bold and/or italic variants. The files containing +these fonts contain a 'b' and/or 'i' character in their name just +before the extension. Additionally, the strings "_bold" and/or "_ital" +are appended to the font family names. Some of the pc VGA fonts come in +thin formats also, these are denoted by a 't' in their file names and +the string "_thin" in their family names. + +The GrFont structure hold a font in memory. A number of 'pc' fonts are +built-in to the library and don't need to be loaded: + + extern GrFont GrFont_PC6x8; + extern GrFont GrFont_PC8x8; + extern GrFont GrFont_PC8x14; + extern GrFont GrFont_PC8x16; + +Other fonts must be loaded with the GrLoadFont function. If the font +file name starts with any path separator character or character +sequence (':', '/' or '\') then it is loaded from the specified +directory, otherwise the library try load the font first from the +current directory and next from the default font path. The font path +can be set up with the GrSetFontPath function. If the font path is not +set then the value of the 'GRXFONT' environment variable is used as the +font path. If GrLoadFont is called again with the name of an already +loaded font then it will return a pointer to the result of the first +loading. Font loading routines return NULL if the font was not found. +When not needed any more, fonts can be unloaded (i.e. the storage +occupied by them freed) by calling GrUnloadFont. + +The prototype declarations for these functions: + + GrFont *GrLoadFont(char *name); + void GrUnloadFont(GrFont *font); + void GrSetFontPath(char *path_list); + +Using these functions: + + GrFont *GrLoadConvertedFont(char *name,int cvt,int w,int h, + int minch,int maxch); + GrFont *GrBuildConvertedFont(const GrFont *from,int cvt,int w,int h, + int minch,int maxch); + +a new font can be generated from a file font or a font in memory, the +'cvt' argument direct the conversion or-ing the desired operations from +these defines: + + /* + * Font conversion flags for 'GrLoadConvertedFont'. OR them as desired. + */ + #define GR_FONTCVT_NONE 0 /* no conversion */ + #define GR_FONTCVT_SKIPCHARS 1 /* load only selected characters */ + #define GR_FONTCVT_RESIZE 2 /* resize the font */ + #define GR_FONTCVT_ITALICIZE 4 /* tilt font for "italic" look */ + #define GR_FONTCVT_BOLDIFY 8 /* make a "bold"(er) font */ + #define GR_FONTCVT_FIXIFY 16 /* convert prop. font to fixed wdt */ + #define GR_FONTCVT_PROPORTION 32 /* convert fixed font to prop. wdt */ + +GR_FONTCVT_SKIPCHARS needs 'minch' and 'maxch' arguments. + +GR_FONTCVT_RESIZE needs 'w' and 'h' arguments. + +The function: + + void GrDumpFnaFont(const GrFont *f, char *fileName); + +writes a font to an ascii font file, so it can be quickly edited with a +text editor. For a description of the ascii font format, see the +fna.txt file. + +The function: + + void GrDumpFont(const GrFont *f,char *CsymbolName,char *fileName); + +writes a font to a C source code file, so it can be compiled and linked +with a user program. GrDumpFont would not normally be used in a release +program because its purpose is to produce source code. When the source +code is compiled and linked into a program distributing the font file +with the program in not necessary, avoiding the possibility of the font +file being deleted or corrupted. + +You can use the premade fnt2c.c program (see the source, it's so +simple) to dump a selected font to source code, by example: + + fnt2c helv15 myhelv15 myhelv15.c + +Next, if this line is included in your main include file: + + extern GrFont myhelv15 + +and "myhelv15.c" compiled and linked with your project, you can use +'myhelv15' in every place a GrFont is required. + +This simple function: + + void GrTextXY(int x,int y,char *text,GrColor fg,GrColor bg); + +draw text in the current context in the standard direction, using the +GrDefaultFont (mapped in the grx20.h file to the GrFont_PC8x14 font) +with x, y like the upper left corner and the foreground and background +colors given (note that bg equal to GrNOCOLOR make the background +transparent). + +For other functions the GrTextOption structure specifies how to draw a +character string: + + typedef struct _GR_textOption { /* text drawing option structure */ + struct _GR_font *txo_font; /* font to be used */ + union _GR_textColor txo_fgcolor; /* foreground color */ + union _GR_textColor txo_bgcolor; /* background color */ + char txo_chrtype; /* character type (see above) */ + char txo_direct; /* direction (see above) */ + char txo_xalign; /* X alignment (see above) */ + char txo_yalign; /* Y alignment (see above) */ + } GrTextOption; + + typedef union _GR_textColor { /* text color union */ + GrColor v; /* color value for "direct" text */ + GrColorTableP p; /* color table for attribute text */ + } GrTextColor; + +The text can be rotated in increments of 90 degrees (txo_direct), +alignments can be set in both directions (txo_xalign and txo_yalign), +and separate fore and background colors can be specified. The accepted +text direction values: + + #define GR_TEXT_RIGHT 0 /* normal */ + #define GR_TEXT_DOWN 1 /* downward */ + #define GR_TEXT_LEFT 2 /* upside down, right to left */ + #define GR_TEXT_UP 3 /* upward */ + #define GR_TEXT_DEFAULT GR_TEXT_RIGHT + +The accepted horizontal and vertical alignment option values: + + #define GR_ALIGN_LEFT 0 /* X only */ + #define GR_ALIGN_TOP 0 /* Y only */ + #define GR_ALIGN_CENTER 1 /* X, Y */ + #define GR_ALIGN_RIGHT 2 /* X only */ + #define GR_ALIGN_BOTTOM 2 /* Y only */ + #define GR_ALIGN_BASELINE 3 /* Y only */ + #define GR_ALIGN_DEFAULT GR_ALIGN_LEFT + +Text strings can be of three different types: one character per byte +(i.e. the usual C character string, this is the default), one character +per 16-bit word (suitable for fonts with a large number of characters), +and a PC-style character-attribute pair. In the last case the +GrTextOption structure must contain a pointer to a color table of size +16 (fg color bits in attrib) or 8 (bg color bits). (The color table +format is explained in more detail in the previous section explaining +the methods to build fill patterns.) The supported text types: + + #define GR_BYTE_TEXT 0 /* one byte per character */ + #define GR_WORD_TEXT 1 /* two bytes per character */ + #define GR_ATTR_TEXT 2 /* chr w/ PC style attribute byte */ + +The PC-style attribute text uses the same layout (first byte: character, +second: attributes) and bitfields as the text mode screen on the PC. +The only difference is that the 'blink' bit is not supported (it would +be very time consuming - the PC text mode does it with hardware +support). This bit is used instead to control the underlined display of +characters. For convenience the following attribute manipulation macros +have been declared in grx20.h: + + #define GR_BUILD_ATTR(fg,bg,ul) \ + (((fg) & 15) | (((bg) & 7) << 4) | ((ul) ? 128 : 0)) + #define GR_ATTR_FGCOLOR(attr) (((attr) ) & 15) + #define GR_ATTR_BGCOLOR(attr) (((attr) >> 4) & 7) + #define GR_ATTR_UNDERLINE(attr) (((attr) ) & 128) + +Text strings of the types GR_BYTE_TEXT and GR_WORD_TEXT can also be +drawn underlined. This is controlled by OR-ing the constant +GR_UNDERLINE_TEXT to the foreground color value: + + #define GR_UNDERLINE_TEXT (GrXOR << 4) + +After the application initializes a text option structure with the +desired values it can call one of the following two text drawing +functions: + + void GrDrawChar(int chr,int x,int y,const GrTextOption *opt); + void GrDrawString(void *text,int length,int x,int y,const GrTextOption *opt); + +NOTE: text drawing is fastest when it is drawn in the 'normal' +direction, and the character does not have to be clipped. It this case +the library can use the appropriate low-level video RAM access routine, +while in any other case the text is drawn pixel-by-pixel by the +higher-level code. + +There are pattern filed versions too: + + void GrPatternDrawChar(int chr,int x,int y,const GrTextOption *opt,GrPattern *p); + void GrPatternDrawString(void *text,int length,int x,int y,const GrTextOption *opt, + GrPattern *p); + void GrPatternDrawStringExt(void *text,int length,int x,int y, + const GrTextOption *opt,GrPattern *p); + +The size of a font, a character or a text string can be obtained by +calling one of the following functions. These functions also take into +consideration the text direction specified in the text option structure +passed to them. + + int GrFontCharPresent(const GrFont *font,int chr); + int GrFontCharWidth(const GrFont *font,int chr); + int GrFontCharHeight(const GrFont *font,int chr); + int GrFontCharBmpRowSize(const GrFont *font,int chr); + int GrFontCharBitmapSize(const GrFont *font,int chr); + int GrFontStringWidth(const GrFont *font,void *text,int len,int type); + int GrFontStringHeight(const GrFont *font,void *text,int len,int type); + int GrProportionalTextWidth(const GrFont *font,void *text,int len,int type); + int GrCharWidth(int chr,const GrTextOption *opt); + int GrCharHeight(int chr,const GrTextOption *opt); + void GrCharSize(int chr,const GrTextOption *opt,int *w,int *h); + int GrStringWidth(void *text,int length,const GrTextOption *opt); + int GrStringHeight(void *text,int length,const GrTextOption *opt); + void GrStringSize(void *text,int length,const GrTextOption *opt,int *w,int *h); + +The GrTextRegion structure and its associated functions can be used to +implement a fast (as much as possible in graphics modes) rectangular +text window using a fixed font. Clipping for such windows is done in +character size increments instead of pixels (i.e. no partial characters +are drawn). Only fixed fonts can be used in their natural size. +GrDumpText will cache the code of the drawn characters in the buffer +pointed to by the 'backup' slot (if it is non-NULL) and will draw a +character only if the previously drawn character in that grid element +is different. + +This can speed up text scrolling significantly in graphics modes. The +supported text types are the same as above. + + typedef struct { /* fixed font text window desc. */ + struct _GR_font *txr_font; /* font to be used */ + union _GR_textColor txr_fgcolor; /* foreground color */ + union _GR_textColor txr_bgcolor; /* background color */ + void *txr_buffer; /* pointer to text buffer */ + void *txr_backup; /* optional backup buffer */ + int txr_width; /* width of area in chars */ + int txr_height; /* height of area in chars */ + int txr_lineoffset; /* offset in buffer(s) between rows */ + int txr_xpos; /* upper left corner X coordinate */ + int txr_ypos; /* upper left corner Y coordinate */ + char txr_chrtype; /* character type (see above) */ + } GrTextRegion; + + void GrDumpChar(int chr,int col,int row,const GrTextRegion *r); + void GrDumpText(int col,int row,int wdt,int hgt,const GrTextRegion *r); + void GrDumpTextRegion(const GrTextRegion *r); + +The GrDumpTextRegion function outputs the whole text region, while +GrDumpText draws only a user-specified part of it. GrDumpChar updates +the character in the buffer at the specified location with the new +character passed to it as argument and then draws the new character on +the screen as well. With these functions you can simulate a text mode +window, write chars directly to the txr_buffer and call +GrDumpTextRegion when you want to update the window (or GrDumpText if +you know the area to update is small). + +See the *test/fonttest.c* example. + + +File: grx249um.inf, Node: Drawing in user coordinates, Next: Graphics cursors, Prev: Text drawing, Up: A User Manual For GRX2 + +Drawing in user coordinates +=========================== + +There is a second set of the graphics primitives which operates in user +coordinates. Every context has a user to screen coordinate mapping +associated with it. An application specifies the user window by calling +the GrSetUserWindow function. + + void GrSetUserWindow(int x1,int y1,int x2,int y2); + +A call to this function it in fact specifies the virtual coordinate +limits which will be mapped onto the current context regardless of the +size of the context. For example, the call: + + GrSetUserWindow(0,0,11999,8999); + +tells the library that the program will perform its drawing operations +in a coordinate system X:0...11999 (width = 12000) and Y:0...8999 +(height = 9000). This coordinate range will be mapped onto the total +area of the current context. The virtual coordinate system can also be +shifted. For example: + + GrSetUserWindow(5000,2000,16999,10999); + +The user coordinates can even be used to turn the usual left-handed +coordinate system (0:0 corresponds to the upper left corner) to a right +handed one (0:0 corresponds to the bottom left corner) by calling: + + GrSetUserWindow(0,8999,11999,0); + +The library also provides three utility functions for the query of the +current user coordinate limits and for converting user coordinates to +screen coordinates and vice versa. + + void GrGetUserWindow(int *x1,int *y1,int *x2,int *y2); + void GrGetScreenCoord(int *x,int *y); + void GrGetUserCoord(int *x,int *y); + +If an application wants to take advantage of the user to screen +coordinate mapping it has to use the user coordinate version of the +graphics primitives. These have exactly the same parameter passing +conventions as their screen coordinate counterparts. NOTE: the user +coordinate system is not initialized by the library! The application +has to set up its coordinate mapping before calling any of the use +coordinate drawing functions - otherwise the program will almost +certainly exit (in a quite ungraceful fashion) with a 'division by +zero' error. The list of supported user coordinate drawing functions: + + void GrUsrPlot(int x,int y,GrColor c); + void GrUsrLine(int x1,int y1,int x2,int y2,GrColor c); + void GrUsrHLine(int x1,int x2,int y,GrColor c); + void GrUsrVLine(int x,int y1,int y2,GrColor c); + void GrUsrBox(int x1,int y1,int x2,int y2,GrColor c); + void GrUsrFilledBox(int x1,int y1,int x2,int y2,GrColor c); + void GrUsrFramedBox(int x1,int y1,int x2,int y2,int wdt,GrFBoxColors *c); + void GrUsrCircle(int xc,int yc,int r,GrColor c); + void GrUsrEllipse(int xc,int yc,int xa,int ya,GrColor c); + void GrUsrCircleArc(int xc,int yc,int r,int start,int end, + int style,GrColor c); + void GrUsrEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,GrColor c); + void GrUsrFilledCircle(int xc,int yc,int r,GrColor c); + void GrUsrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c); + void GrUsrFilledCircleArc(int xc,int yc,int r,int start,int end, + int style,GrColor c); + void GrUsrFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,GrColor c); + void GrUsrPolyLine(int numpts,int points[][2],GrColor c); + void GrUsrPolygon(int numpts,int points[][2],GrColor c); + void GrUsrFilledConvexPolygon(int numpts,int points[][2],GrColor c); + void GrUsrFilledPolygon(int numpts,int points[][2],GrColor c); + void GrUsrFloodFill(int x, int y, GrColor border, GrColor c); + GrColor GrUsrPixel(int x,int y); + GrColor GrUsrPixelC(GrContext *c,int x,int y); + void GrUsrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o); + void GrUsrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o); + void GrUsrCustomCircle(int xc,int yc,int r,const GrLineOption *o); + void GrUsrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o); + void GrUsrCustomCircleArc(int xc,int yc,int r,int start,int end, + int style,const GrLineOption *o); + void GrUsrCustomEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,const GrLineOption *o); + void GrUsrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o); + void GrUsrCustomPolygon(int numpts,int points[][2],const GrLineOption *o); + void GrUsrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp); + void GrUsrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp); + void GrUsrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp); + void GrUsrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp); + void GrUsrPatternedCircleArc(int xc,int yc,int r,int start,int end, + int style,GrLinePattern *lp); + void GrUsrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,GrLinePattern *lp); + void GrUsrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp); + void GrUsrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp); + void GrUsrPatternFilledPlot(int x,int y,GrPattern *p); + void GrUsrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p); + void GrUsrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p); + void GrUsrPatternFilledCircle(int xc,int yc,int r,GrPattern *p); + void GrUsrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p); + void GrUsrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrPattern *p); + void GrUsrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrPattern *p); + void GrUsrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p); + void GrUsrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p); + void GrUsrPatternFloodFill(int x, int y, GrColor border, GrPattern *p); + void GrUsrDrawChar(int chr,int x,int y,const GrTextOption *opt); + void GrUsrDrawString(char *text,int length,int x,int y,const GrTextOption *opt); + void GrUsrTextXY(int x,int y,char *text,GrColor fg,GrColor bg); + + +File: grx249um.inf, Node: Graphics cursors, Next: Keyboard input, Prev: Drawing in user coordinates, Up: A User Manual For GRX2 + +Graphics cursors +================ + +The library provides support for the creation and usage of an unlimited +number of graphics cursors. An application can use these cursors for +any purpose. Cursors always save the area they occupy before they are +drawn. When moved or erased they restore this area. As a general rule +of thumb, an application should erase a cursor before making changes to +an area it occupies and redraw the cursor after finishing the drawing. +Cursors are created with the GrBuildCursor function: + + GrCursor *GrBuildCursor(char far *pixels,int pitch,int w,int h, + int xo,int yo,const GrColorTableP c); + +The pixels, w (=width), h (=height) and c (= color table) arguments are +similar to the arguments of the pixmap building library function +GrBuildPixmap (see that paragraph for a more detailed explanation.), +but with two differences. First, is not assumed that the pixels data +is w x h sized, the pitch argument set the offset between rows. Second, +the pixmap data is interpreted slightly differently, any pixel with +value zero is taken as a "transparent" pixel, i.e. the background will +show through the cursor pattern at that pixel. A pixmap data byte with +value = 1 will refer to the first color in the table, and so on. + +The xo (= X offset) and yo (= Y offset) arguments specify the position +(from the top left corner of the cursor pattern) of the cursor's "hot +point". + +The GrCursor data structure: + + typedef struct _GR_cursor { + struct _GR_context work; /* work areas (4) */ + int xcord,ycord; /* cursor position on screen */ + int xsize,ysize; /* cursor size */ + int xoffs,yoffs; /* LU corner to hot point offset */ + int xwork,ywork; /* save/work area sizes */ + int xwpos,ywpos; /* save/work area position on screen */ + int displayed; /* set if displayed */ + } GrCursor; + +is typically not used (i.e. read or changed) by the application +program, it should just pass pointers to these structures to the +appropriate library functions. Other cursor manipulation functions: + + void GrDisplayCursor(GrCursor *cursor); + void GrEraseCursor(GrCursor *cursor); + void GrMoveCursor(GrCursor *cursor,int x,int y); + void GrDestroyCursor(GrCursor *cursor); + +See the *test/curstest.c* example. + + +File: grx249um.inf, Node: Keyboard input, Next: Mouse event handling, Prev: Graphics cursors, Up: A User Manual For GRX2 + +Keyboard input +============== + +GRX can handle platform independant key input. The file grxkeys.h +defines the keys to be used in the user's program. This is an extract: + + #define GrKey_Control_A 0x0001 + #define GrKey_Control_B 0x0002 + #define GrKey_Control_C 0x0003 + ... + #define GrKey_A 0x0041 + #define GrKey_B 0x0042 + #define GrKey_C 0x0043 + ... + #define GrKey_F1 0x013b + #define GrKey_F2 0x013c + #define GrKey_F3 0x013d + ... + #define GrKey_Alt_F1 0x0168 + #define GrKey_Alt_F2 0x0169 + #define GrKey_Alt_F3 0x016a + +But you can be confident that the standard ASCII is right maped. The +GrKeyType type is defined to store keycodes: + + typedef unsigned short GrKeyType; + +This function: + + int GrKeyPressed(void); + +returns non zero if there are any keycode waiting, that can be read +with: + + GrKeyType GrKeyRead(void); + +The function: + + int GrKeyStat(void); + +returns a keyboard status word, or-ing it with the next defines it can +be known the status of some special keys: + + #define GR_KB_RIGHTSHIFT 0x01 /* right shift key depressed */ + #define GR_KB_LEFTSHIFT 0x02 /* left shift key depressed */ + #define GR_KB_CTRL 0x04 /* CTRL depressed */ + #define GR_KB_ALT 0x08 /* ALT depressed */ + #define GR_KB_SCROLLOCK 0x10 /* SCROLL LOCK active */ + #define GR_KB_NUMLOCK 0x20 /* NUM LOCK active */ + #define GR_KB_CAPSLOCK 0x40 /* CAPS LOCK active */ + #define GR_KB_INSERT 0x80 /* INSERT state active */ + #define GR_KB_SHIFT (GR_KB_LEFTSHIFT | GR_KB_RIGHTSHIFT) + +See the *test/keys.c* example. + + +File: grx249um.inf, Node: Mouse event handling, Next: Writing/reading PNM graphics files, Prev: Keyboard input, Up: A User Manual For GRX2 + +Mouse event handling +==================== + +All mouse services need the presence of a mouse. An application can test +whether a mouse is available by calling the function: + + int GrMouseDetect(void); + +which will return zero if no mouse (or mouse driver) is present, +non-zero otherwise. The mouse must be initialized by calling one (and +only one) of these functions: + + void GrMouseInit(void); + void GrMouseInitN(int queue_size); + +GrMouseInit sets a event queue (see below) size to GR_M_QUEU_SIZE +(128). A user supply event queue size can be set calling GrMouseInitN +instead. + +It is a good practice to call GrMouseUnInit before exiting the program. +This will restore any interrupt vectors hooked by the program to their +original values. + + void GrMouseUnInit(void); + +The mouse can be controlled with the following functions: + + void GrMouseSetSpeed(int spmult,int spdiv); + void GrMouseSetAccel(int thresh,int accel); + void GrMouseSetLimits(int x1,int y1,int x2,int y2); + void GrMouseGetLimits(int *x1,int *y1,int *x2,int *y2); + void GrMouseWarp(int x,int y); + +The library calculates the mouse position only from the mouse mickey +counters. (To avoid the limit and 'rounding to the next multiple of +eight' problem with some mouse driver when it finds itself in a +graphics mode unknown to it.) The parameters to the GrMouseSetSpeed +function specify how coordinate changes are obtained from mickey +counter changes, multipling by spmult and dividing by spdiv. In high +resolution graphics modes the value of one just works fine, in low +resolution modes (320x200 or similar) it is best set the spdiv to two or +three. (Of course, it also depends on the sensitivity the mouse.) The +GrMouseSetAccel function is used to control the ballistic effect: if a +mouse coordinate changes between two samplings by more than the thresh +parameter, the change is multiplied by the accel parameter. NOTE: some +mouse drivers perform similar calculations before reporting the +coordinates in mickeys. In this case the acceleration done by the +library will be additional to the one already performed by the mouse +driver. The limits of the mouse movement can be set (passed limits will +be clipped to the screen) with GrMouseSetLimits (default is the whole +screen) and the current limits can be obtained with GrMouseGetLimits. +GrMouseWarp sets the mouse cursor to the specified position. + +As typical mouse drivers do not know how to draw mouse cursors in high +resolution graphics modes, the mouse cursor is drawn by the library. +The mouse cursor can be set with: + + void GrMouseSetCursor(GrCursor *cursor); + void GrMouseSetColors(GrColor fg,GrColor bg); + +GrMouseSetColors uses an internal arrow pattern, the color fg will be +used as the interior of it and bg will be the border. The current mouse +cursor can be obtained with: + + GrCursor *GrMouseGetCursor(void); + +The mouse cursor can be displayed/erased with: + + void GrMouseDisplayCursor(void); + void GrMouseEraseCursor(void); + +The mouse cursor can be left permanently displayed. All graphics +primitives except for the few non-clipping functions check for +conflicts with the mouse cursor and erase it before the drawing if +necessary. Of course, it may be more efficient to erase the cursor +manually before a long drawing sequence and redraw it after completion. +The library provides an alternative pair of calls for this purpose +which will erase the cursor only if it interferes with the drawing: + + int GrMouseBlock(GrContext *c,int x1,int y1,int x2,int y2); + void GrMouseUnBlock(int return_value_from_GrMouseBlock); + +GrMouseBlock should be passed the context in which the drawing will +take place (the usual convention of NULL meaning the current context is +supported) and the limits of the affected area. It will erase the +cursor only if it interferes with the drawing. When the drawing is +finished GrMouseUnBlock must be called with the argument returned by +GrMouseBlock. + +The status of the mouse cursor can be obtained with calling +GrMouseCursorIsDisplayed. This function will return non-zero if the +cursor is displayed, zero if it is erased. + + int GrMouseCursorIsDisplayed(void); + +The library supports (beside the simple cursor drawing) three types of +"rubberband" attached to the mouse cursor. The GrMouseSetCursorMode +function is used to select the cursor drawing mode. + + void GrMouseSetCursorMode(int mode,...); + +The parameter mode can have the following values: + + #define GR_M_CUR_NORMAL 0 /* MOUSE CURSOR modes: just the cursor */ + #define GR_M_CUR_RUBBER 1 /* rect. rubber band (XOR-d to the screen) */ + #define GR_M_CUR_LINE 2 /* line attached to the cursor */ + #define GR_M_CUR_BOX 3 /* rectangular box dragged by the cursor */ + +GrMouseSetCursorMode takes different parameters depending on the cursor +drawing mode selected. The accepted call formats are: + + GrMouseSetCursorMode(M_CUR_NORMAL); + GrMouseSetCursorMode(M_CUR_RUBBER,xanchor,yanchor,GrColor); + GrMouseSetCursorMode(M_CUR_LINE,xanchor,yanchor,GrColor); + GrMouseSetCursorMode(M_CUR_BOX,dx1,dy1,dx2,dy2,GrColor); + +The anchor parameters for the rubberband and rubberline modes specify a +fixed screen location to which the other corner of the primitive is +bound. The dx1 through dy2 parameters define the offsets of the corners +of the dragged box from the hotpoint of the mouse cursor. The color +value passed is always XOR-ed to the screen, i.e. if an application +wants the rubberband to appear in a given color on a given background +then it has to pass the XOR of these two colors to GrMouseSetCursorMode. + +The GrMouseGetEvent function is used to obtain the next mouse or +keyboard event. It takes a flag with various bits encoding the type of +event needed. It returns the event in a GrMouseEvent structure. The +relevant declarations from grx20.h: + + void GrMouseGetEvent(int flags,GrMouseEvent *event); + + typedef struct _GR_mouseEvent { /* mouse event buffer structure */ + int flags; /* event type flags (see above) */ + int x,y; /* mouse coordinates */ + int buttons; /* mouse button state */ + int key; /* key code from keyboard */ + int kbstat; /* keybd status (ALT, CTRL, etc..) */ + long dtime; /* time since last event (msec) */ + } GrMouseEvent; + +The event structure has been extended with a keyboard status word (thus +a program can check for combinations like ALT-) +and a time stamp which can be used to check for double clicks, etc... +The following macros have been defined in grx20.h to help in creating +the control flag for GrMouseGetEvent and decoding the various bits in +the event structure: + + #define GR_M_MOTION 0x001 /* mouse event flag bits */ + #define GR_M_LEFT_DOWN 0x002 + #define GR_M_LEFT_UP 0x004 + #define GR_M_RIGHT_DOWN 0x008 + #define GR_M_RIGHT_UP 0x010 + #define GR_M_MIDDLE_DOWN 0x020 + #define GR_M_MIDDLE_UP 0x040 + #define GR_M_BUTTON_DOWN (GR_M_LEFT_DOWN | GR_M_MIDDLE_DOWN | \ + GR_M_RIGHT_DOWN | GR_M_P4_DOWN | GR_M_P5_DOWN) + #define GR_M_BUTTON_UP (GR_M_LEFT_UP | GR_M_MIDDLE_UP | \ + GR_M_RIGHT_UP | GR_M_P4_UP | GR_M_P5_UP) + #define GR_M_BUTTON_CHANGE (GR_M_BUTTON_UP | GR_M_BUTTON_DOWN ) + + #define GR_M_LEFT 0x01 /* mouse button index bits */ + #define GR_M_RIGHT 0x02 + #define GR_M_MIDDLE 0x04 + #define GR_M_P4 0x08 /* wheel rolls up */ + #define GR_M_P5 0x10 /* wheel rolls down */ + + #define GR_M_KEYPRESS 0x080 /* other event flag bits */ + #define GR_M_POLL 0x100 + #define GR_M_NOPAINT 0x200 + #define GR_COMMAND 0x1000 + #define GR_M_EVENT (GR_M_MOTION | GR_M_KEYPRESS | \ + GR_M_BUTTON_CHANGE | GR_COMMAND) + +GrMouseGetEvent will display the mouse cursor if it was previously +erased and the GR_M_NOPAINT bit is not set in the flag passed to it. In +this case it will also erase the cursor after an event has been +obtained. + +GrMouseGetEvent block until a event is produced, except if the +GR_M_POLL bit is set in the flag passed to it. + +Another version of GetEvent: + + void GrMouseGetEventT(int flags,GrMouseEvent *event,long timout_msecs); + +can be istructed to wait timout_msec for the presence of an event. Note +that event->dtime is only valid if any event occured (event->flags != +0) otherwise it's set as -1. Additionally event timing is real world +time even in X11 && Linux. + +If there are one or more events waiting the function: + + int GrMousePendingEvent(void); + +returns non-zero value. + +The generation of mouse and keyboard events can be individually enabled +or disabled (by passing a non-zero or zero, respectively, value in the +corresponding enable_XX parameter) by calling: + + void GrMouseEventEnable(int enable_kb,int enable_ms); + +Note that GrMouseInit set both by default. If you want to use +GrMouseGetEvent and GrKeyRead at the same time, a call to +GrMouseEventEnable( 0,1 ) is needed before input process. + +See the *test/mousetst.c* example. + + +File: grx249um.inf, Node: Writing/reading PNM graphics files, Next: Writing/reading PNG graphics files, Prev: Mouse event handling, Up: A User Manual For GRX2 + +Writing/reading PNM graphics files +================================== + +GRX includes functions to load/save a context from/to a PNM file. + +PNM is a group of simple graphics formats from the NetPbm +(http://netpbm.sourceforge.net) distribution. NetPbm can convert +from/to PNM lots of graphics formats, and apply some transformations to +PNM files. (Note. You don't need the NetPbm distribution to use this +functions). + +There are six PNM formats: + + P1 text PBM (bitmap) + P2 text PGM (gray scale) + P3 text PPM (real color) + P4 binary PBM (bitmap) + P5 binary PGM (gray scale) + P6 binary PPM (real color) + +GRX can handle the binary formats only (get the NetPbm distribution if +you need convert text to binary formats). + +To save a context in a PNM file you have three functions: + + int GrSaveContextToPbm( GrContext *grc, char *pbmfn, char *docn ); + int GrSaveContextToPgm( GrContext *grc, char *pgmfn, char *docn ); + int GrSaveContextToPpm( GrContext *grc, char *ppmfn, char *docn ); + +they work both in RGB and palette modes, grc must be a pointer to the +context to be saved, if it is NULL the current context is saved; p-mfn +is the file name to be created and docn is an optional text comment to +be written in the file, it can be NULL. Three functions return 0 on +succes and -1 on error. + +GrSaveContextToPbm dumps a context in a PBM file (bitmap). If the pixel +color isn't Black it asumes White. + +GrSaveContextToPgm dumps a context in a PGM file (gray scale). The +colors are quantized to gray scale using .299r + .587g + .114b. + +GrSaveContextToPpm dumps a context in a PPM file (real color). To load +a PNM file in a context you must use: + + int GrLoadContextFromPnm( GrContext *grc, char *pnmfn ); + +it support reading PBM, PGM and PPM binary files. grc must be a pointer +to the context to be written, if it is NULL the current context is +used; p-mfn is the file name to be read. If context dimensions are +lesser than pnm dimensions, the function loads as much as it can. If +color mode is not in RGB mode, the routine allocates as much colors as +it can. The function returns 0 on succes and -1 on error. + +To query the file format, width and height of a PNM file you can use: + + int GrQueryPnm( char *ppmfn, int *width, int *height, int *maxval ); + +pnmfn is the name of pnm file; width returns the pnm width; height +returns the pnm height; maxval returns the max color component value. +The function returns 1 to 6 on success (the PNM format) or -1 on error. + +The two next functions: + + int GrLoadContextFromPnmBuffer( GrContext *grc, const char *pnmbuf ); + int GrQueryPnmBuffer( const char *pnmbuf, int *width, int *height, int *maxval ); + +work like GrLoadContextFromPnm and GrQueryPnmBuffer, but they get his +input from a buffer instead of a file. This way, pnm files can be +embeded in a program (using the bin2c program by example). + + +File: grx249um.inf, Node: Writing/reading PNG graphics files, Next: Writing/reading JPEG graphics files, Prev: Writing/reading PNM graphics files, Up: A User Manual For GRX2 + +Writing/reading PNG graphics files +================================== + +GRX includes functions to load/save a context from/to a png file. But +note, for this purpose it needs the libpng +(http://www.libpng.org/pub/png/libpng.html) library, and to enable the +png support before make the GRX lib. + +Use next function to save a context in a PNG file: + + int GrSaveContextToPng( GrContext *grc, char *pngfn ); + +it works both in RGB and palette modes, grc must be a pointer to the +context to be saved, if it is NULL the current context is saved; pngfn +is the file name to be created. The function returns 0 on succes and +-1 on error. + +To load a PNG file in a context you must use: + + int GrLoadContextFromPng( GrContext *grc, char *pngfn, int use_alpha ); + +grc must be a pointer to the context to be written, if it is NULL the +current context is used; pngfn is the file name to be read; set +use_alpha to 1 if you want to use the image alpha channel (if +available). If context dimensions are lesser than png dimensions, the +function loads as much as it can. If color mode is not in RGB mode, the +routine allocates as much colors as it can. The function returns 0 on +succes and -1 on error. + +To query the width and height of a PNG file you can use: + + int GrQueryPng( char *pngfn, int *width, int *height ); + +pngfn is the name of png file; width returns the png width; height +returns the png height. The function returns 0 on success or -1 on +error. + +The function: + + int GrPngSupport( void ); + +returns 1 if there is png support in the library, 0 otherwise. If there +is not support for png, dummy functions are added to the library, +returning error (-1) ever. + + +File: grx249um.inf, Node: Writing/reading JPEG graphics files, Next: Miscellaneous functions, Prev: Writing/reading PNG graphics files, Up: A User Manual For GRX2 + +Writing/reading PNG graphics files +================================== + +GRX includes functions to load/save a context from/to a jpeg file. But +note, for this purpose it needs the libjpeg (http://www.ijg.org) +library, and to enable the jpeg support before make the GRX lib. + +Use next function to save a context in a JPEG file: + + int GrSaveContextToJpeg( GrContext *grc, char *jpegfn, int quality ); + +it works both in RGB and palette modes, grc must be a pointer to the +context to be saved, if it is NULL the current context is saved; jpegfn +is the file name to be created; quality is a number between 1 and 100 +to drive the compression quality, use higher values for better quality +(and bigger files), you can use 75 as a standard value, normally a +value between 50 and 95 is good. The function returns 0 on succes and +-1 on error. + +This function saves a context in a grayscale JPEG file: + + int GrSaveContextToGrayJpeg( GrContext *grc, char *jpegfn, int quality ); + +parameters and return codes are like in GrSaveContextToJpeg. The +colors are quantized to gray scale using .299r + .587g + .114b. + +To load a JPEG file in a context you must use: + + int GrLoadContextFromJpeg( GrContext *grc, char *jpegfn, int scale ); + +grc must be a pointer to the context to be written, if it is NULL the +current context is used; jpegfn is the file name to be read; set scale +to 1, 2, 4 or 8 to reduce the loaded image to 1/1, 1/2, 1/4 or 1/8. If +context dimensions are lesser than jpeg dimensions, the function loads +as much as it can. If color mode is not in RGB mode, the routine +allocates as much colors as it can. The function returns 0 on succes +and -1 on error. + +To query the width and height of a JPEG file you can use: + + int GrQueryJpeg( char *jpegfn, int *width, int *height ); + +jpegfn is the name of jpeg file; width returns the jpeg width; height +returns the jpeg height. The function returns 0 on success or -1 on +error. + +The function: + + int GrJpegSupport( void ); + +returns 1 if there is jpeg support in the library, 0 otherwise. If +there is not support for jpeg, dummy functions are added to the +library, returning error (-1) ever. + + +File: grx249um.inf, Node: Miscellaneous functions, Next: BGI interface, Prev: Writing/reading JPEG graphics files, Up: A User Manual For GRX2 + +Miscellaneous functions +======================= + +Here we will describe some miscellaneous functions. + + unsigned GrGetLibraryVersion(void); + +GrGetLibraryVersion returns the GRX version API, like a hexadecimal +coded number. By example 0x0241 means 2.4.1 Because grx20.h defines the +GRX_VERSION_API macro, you can check if both, the library and the +include file, are in the same version using if(GrGetLibraryVersion() == +GRX_VERSION_API ) + + unsigned GrGetLibrarySystem(void); + +This functions returns a unsigned integer identifing the system you are +working in. grx20.h defines some macros you can use: + + /* these are the supported configurations: */ + #define GRX_VERSION_TCC_8086_DOS 1 /* also works with BCC */ + #define GRX_VERSION_GCC_386_DJGPP 2 /* DJGPP v2 */ + #define GRX_VERSION_GCC_386_LINUX 3 /* the real stuff */ + #define GRX_VERSION_GENERIC_X11 4 /* generic X11 version */ + #define GRX_VERSION_WATCOM_DOS4GW 5 /* GS - Watcom C++ 11.0 32 Bit + #define GRX_VERSION_GCC_386_WIN32 7 /* WIN32 using Mingw32 */ + #define GRX_VERSION_MSC_386_WIN32 8 /* WIN32 using MS-VC */ + #define GRX_VERSION_GCC_386_CYG32 9 /* WIN32 using CYGWIN */ + #define GRX_VERSION_GCC_386_X11 10 /* X11 version */ + #define GRX_VERSION_GCC_X86_64_LINUX 11 /* console framebuffer 64 */ + #define GRX_VERSION_GCC_X86_64_X11 12 /* X11 version 64 */ + +Note. On Linux, GrGetLibrarySystem returns GRX_VERSION_GCC_386_LINUX +even in the X11 version. + + void GrSetWindowTitle(char *title); +GrSetWindowTitle sets the main window title in the X11 an Win32 +versions. It doesn't do nothing in the DOS and Linux-SvgaLib versions. + + void GrSleep(int msec); +This function stops the program execution for msec miliseconds. + + long GrMsecTime( void ); +This function gives the current time with millisecond resolution + + void GrFlush( void ); +This funnction flushes the graphics window. Not dummy because useful +only on X11 when switching between graphics and console windows open +simultaneously. + + GrContext *GrCreateFrameContext(GrFrameMode md,int w,int h, + char far *memory[4],GrContext *where); +This function is like GrCreateContext, except that you can specify any +valid memory frame mode, not only the Screen associated frame mode. It +can be used for special purposes (see GrBitBlt1bpp for an example). + + void GrBitBlt1bpp(GrContext *dst,int dx,int dy,GrContext *src, + int x1,int y1,int x2,int y2,GrColor fg,GrColor bg); +This special function does a bitblt from a 1bpp context (a bitmap +really), using fg and bg like the color+opcode when bit=1 and bit=0 +respectively. Here is an example: + + pContext = GrCreateFrameContext(GR_frameRAM1, sizex, sizey, NULL, NULL); + /* draw something (black and white) into the bitmap */ + GrSetContext(pContext); + GrClearContext( GrBlack() ); + GrLine(0, 0, sizex-1, sizey-1, GrWhite()); + GrLine(0, sizey-1, sizex-1, 0, GrWhite()); + + /* Put the bitmap into the screen */ + GrSetContext(NULL); + fcolor = GrAllocColor( 255,0,0 ); + bcolor = GrAllocColor( 0,0,255 ); + GrBitBlt1bpp(NULL,x,y,pContext,0,0,sizex-1,sizey-1,fcolor,bcolor); + + +File: grx249um.inf, Node: BGI interface, Next: Pascal interface, Prev: Miscellaneous functions, Up: A User Manual For GRX2 + +BGI interface +============= + +From the 2.3.1 version, GRX includes the BCC2GRX library created by +Hartmut Schirmer. The BCC2GRX was created to allow users of GRX to +compile graphics programs written for Borland-C++ and Turbo-C graphics +interface. BCC2GRX is not a convenient platform to develop new BGI +programs. Of course you should use native GRX interface in such cases! + +Read the readme.bgi file for more info. + + +File: grx249um.inf, Node: Pascal interface, Next: References, Prev: BGI interface, Up: A User Manual For GRX2 + +Pascal interface +================ + +The Pascal (gpc) support is produced by two unit files *pascal/grx.pas* +and *pascal/bgi/graph.pas* which are the Pascal translations of the C +header files *include/grx20.h + include/grxkeys.h* and +*include/libbcc.h*. + +Compilation of the examples and installation of the header files is +allowed by setting INCLUDE_GPC_SUPPORT=y in makedef.grx. + +The unit files contain at the beginning instructions to load the +required libraries (libgrx20..., depending on the system) and addon +libraries (e.g. libpng). You can uncomment manually the addons you +want. You can also use the configure script which does that +automatically, together with editing the makedefs.grx file. + +By default they are installed in a *units* directory below the +INSTALLDIR directory. But you can put them where you like. + + +File: grx249um.inf, Node: References, Prev: Pascal interface, Up: A User Manual For GRX2 + +References +========== + +Official GRX site `http://grx.gnu.de' +GRX mailing list archive `http://grx.gnu.de/archive/grx/en/' +MGRX site (fork from GRX) `http://mgrx.fgrim.com' +NetPbm distribution `http://netpbm.sourceforge.net' +PNG library `http://www.libpng.org/pub/png/libpng.html' +JPEG library `http://www.ijg.org' +TIFF library `http://www.remotesensing.org/libtiff/' + + + +Tag Table: +Node: Top198 +Node: A User Manual For GRX21387 +Node: Hello world2236 +Node: Data types and function declarations4021 +Node: Setting the graphics driver4755 +Node: Setting video modes5866 +Node: Graphics contexts10923 +Node: Context use18111 +Node: Color management19492 +Node: Portable use of a few colors24538 +Node: Graphics primitives26456 +Node: Non-clipping graphics primitives35143 +Node: Customized line drawing36646 +Node: Pattern filled graphics primitives39000 +Node: Patterned line drawing45938 +Node: Image manipulation47507 +Node: Text drawing50338 +Node: Drawing in user coordinates64451 +Node: Graphics cursors70791 +Node: Keyboard input73353 +Node: Mouse event handling75355 +Node: Writing/reading PNM graphics files84879 +Node: Writing/reading PNG graphics files87934 +Node: Writing/reading JPEG graphics files89779 +Node: Miscellaneous functions92098 +Node: BGI interface95535 +Node: Pascal interface96080 +Node: References97023 + +End Tag Table diff --git a/thirdparty/grx249/doc/old/api.doc b/thirdparty/grx249/doc/old/api.doc new file mode 100644 index 0000000..64651c0 --- /dev/null +++ b/thirdparty/grx249/doc/old/api.doc @@ -0,0 +1,1610 @@ +GRX graphics library user's manual, version 2.0 +=============================================== + + +THIS FILE IS UNDER CONSTRUCTION!!!!!!! +Use the 1.03 user's manual for description of the library functions and +consult "grx20.h" + +The most important differences: +1) COLORS ARE LONG!!!! +2) NO WIDE LINES AND PATTERNED FILLS YET! +3) NO GrFindBestFont(), NO INTEGER FONT MAGNIFICATION, + BUT FONTS CAN BE SCALED +4) ARCS HAVE AN EXTRA PARAMETER, WHICH IS THE STYLE FOR CLOSING THEM + + +==================== Don't read after this ============================= + + +Abstract + +LIBGRX is a graphics library for DJGPP or Turbo C programs. (The Turbo +C version was tested using TC++ 1.01) Currently it supports VGA (32768, +256 or 16 colors), EGA (16 colors), 8514/A (256 colors) and S3-based (256 +colors) cards. Planned future improvements include support for Hercules +cards as well. It is upward compatible with the graphics library in DJGPP +(the C part, no C++ classes). It can use the same drivers as the graphics +library in DJGPP or it can work with a new driver format supporting +programmable number of colors as well. + + +Data types, function declarations + +All public data structures and graphics primitives meant for usage by +the application program are declared/prototyped in the header files (in the +'include' sub-directory): + +GRDRIVER.H graphics driver format specifications +MOUSEX.H cursor, mouse and keyboard handling +GRX.H drawing-related structures and functions +GRXFILE.H file formats and file access routines +GRXFONT.H format of a font when loaded into memory + + +Setting video modes + +Before a program can do any graphics drawing it has to configure the +display adapter of the PC for the desired graphics mode. It is done with the +'GrSetMode' function as follows: + +#ifdef __cplusplus +void GrSetMode(int which,int width=0,int height=0,int colors=0); +#else +void GrSetMode(int which,...); +#endif + +The 'mode' parameter can be one of the following constants, declared in +"grx.h": + +typedef enum { +GR_80_25_text, +GR_default_text, +GR_width_height_text, +GR_biggest_text, +GR_320_200_graphics, +GR_default_graphics, +GR_width_height_graphics, +GR_biggest_noninterlaced_graphics, +GR_biggest_graphics, +GR_width_height_color_graphics + + + + + +LIBGRX graphics library user's manual 3 + + +} GR_graphics_modes; + +The 'GR_width_height_text' and 'GR_width_height_graphics' modes require +the two optional size arguments, and the 'GR_width_height_color_graphics' mode +requires all three optional arguments. A call with any other mode does not +require any of the optional arguments. + +NOTE: the 'GR_width_height_color_graphics' mode is a new mode supported only +if: (1) you have a new format graphics driver (see the accompanying +documentation in the file "DRIVERS.DOC"), and (2) you have a recent (version +1.06, dated after the middle of April 1992) copy of GO32 which knows how to +deal with the new driver format. + +New format graphics drivers operating in the proper environment (see above) +can provide a table of the supported text and graphics modes using: + +void GrGetDriverModes(GR_DRIVER_MODE_ENTRY **ttable,GR_DRIVER_MODE_ENTRY **gtable) + +The arguments 'ttable' and 'gtable' should be addresses of pointers to the +'GR_DRIVER_MODE_ENTRY' structure defined in the include file "grdriver.h". +Upon return the pointer variables will point to two arrays of these +structures, one for the text modes, the other for graphics. The +'GR_DRIVER_MODE_ENTRY' structure has the following fields: + +typedef struct { +unsigned short width; +unsigned short height; +unsigned short number_of_colors; +unsigned char BIOS_mode; +unsigned char special; +} GR_DRIVER_MODE_ENTRY; + +The first four structure members should be obvious, but the 'special' +field may deserve some explanation. It is non-zero if the driver does some +special "tricks" to put the card into the desired mode. An example might be +the 43 row EGA text mode: for this first the "standard" 80x25 text mode is +set up and then the character generator is re-loaded with a smaller font. +If the 'special' field is zero then the driver simply invokes the INT 10 +function 0 BIOS routine with the mode in the 'BIOS_mode' slot. + +A user-defined function can be invoked every time the video mode is +changed (i.e. 'GrSetMode' is called). This function should not take any +parameters and its return value (if any) is ignored. It can be installed +(for all subsequent 'GrSetMode' calls) with the: + +void GrSetModeHook(void (*callback)(void)); + +function. The current graphics mode (one of the valid 'mode' argument values +for 'GrSetMode') can be obtained with the: + +int GrCurrentMode(void); + + + + + +LIBGRX graphics library user's manual 4 + + +function, while the type of the installed graphics adapter can be determined +with the + +int GrAdapterType(void); + +function. 'GrAdapterType' returns the type of the adapter as one of the +following three symbolic constants (defined in "grx.h"): + +#define GR_VGA 0 /* VGA adapter */ +#define GR_EGA 1 /* EGA adapter */ +#define GR_HERC 2 /* Hercules mono adapter */ +#define GR_8514A 3 /* 8514/A or compatible */ +#define GR_S3 4 /* S3 graphics accelerator */ + + + + + +LIBGRX graphics library user's manual 5 + + +Graphics contexts + +The library supports a set of drawing regions called 'contexts' (the +'GrContext' structure). These can be in video memory or in system memory. +Contexts in system memory always have the same memory organization as the +video memory. When 'GrSetMode' is called, a default context is created which +maps to the whole graphics screen. Contexts are described by the 'GrContext' +data structure: + +typedef struct _GR_context_ { +char far *gc_baseaddr; /* base address of display memory */ +long gc_frameaddr; /* upper left corner coordinate */ +long gc_planeoffset; /* offset to next color plane */ +int gc_lineoffset; /* offset to next scan line in bytes */ +char gc_onscreen; /* is it in video memory ? */ +char gc_memflags; /* memory allocation flags */ +int gc_xmax; /* max X coord (width - 1) */ +int gc_ymax; /* max Y coord (height - 1) */ +int gc_xcliplo; /* low X clipping limit */ +int gc_ycliplo; /* low Y clipping limit */ +int gc_xcliphi; /* high X clipping limit */ +int gc_ycliphi; /* high Y clipping limit */ +int gc_usrxbase; /* user window min X coordinate */ +int gc_usrybase; /* user window min Y coordinate */ +int gc_usrwidth; /* user window width */ +int gc_usrheight; /* user window height */ +int gc_xoffset; /* X offset from root's base */ +int gc_yoffset; /* Y offset from root's base */ +struct _GR_context_ *gc_root; /* context which owns frame buf */ +} GrContext; + +There is a subtype of the 'GrContext' structure. The structure +'GrVidRAM' contains only the first slots of a context describing the memory +layout of a context. This structure is used as a component of other more +complex data structures in the library. + +typedef struct { +char far *gc_baseaddr; /* base address of display memory */ +long gc_frameaddr; /* upper left corner coordinate */ +long gc_planeoffset; /* offset to next color plane */ +int gc_lineoffset; /* offset to next scan line in bytes */ +char gc_onscreen; /* is it in video memory ? */ +char gc_memflags; /* memory allocation flags */ +} GrVidRAM; + +The following four functions return information about the layout of and +memory occupied by a graphics context of size 'width' by 'height' in the +current graphics mode (as set up by 'GrSetMode'): + +int GrLineOffset(int width); +int GrNumPlanes(void); + + + + + +LIBGRX graphics library user's manual 6 + + +long GrPlaneSize(int w,int h); +long GrContextSize(int w,int h); + +'GrLineOffset' always returns the offset between successive pixel rows of the +context in bytes. 'GrNumPlanes' returns the number of bitmap planes in the +current graphics mode. 'GrContextSize' calculates the total amount of memory +needed by a context, while 'GrPlaneSize' calculates the size of a bitplane in +the context. The function: + +GrContext *GrCreateContext(int w,int h,char far *memory,GrContext *where); + +can be used to create a new context in system memory. The NULL pointer is also +accepted as the value of the 'memory' and 'where' arguments, in this case the +library allocates the necessary amount of memory internally. + +It is a general convention in the library that functions returning +pointers to any LIBGRX specific data structure have a last argument (most of +the time named 'where' in the prototypes) which can be used to pass the +address of the data structure which should be filled with the result. If this +'where' pointer has the value of NULL, then the library allocates space for +the data structure internally. + +The function: + +GrContext *GrCreateSubContext(int x1,int y1,int x2,int y2,GrContext *parent,GrContext *where); + +creates a new sub-context which maps to a part of an existing context. The +coordinate arguments ('x1' through 'y2') are interpreted relative to the +parent context's limits. Pixel addressing is zero-based even in sub-contexts, +i.e. the address of the top left pixel is (0,0) even in a sub-context which +has been mapped onto the interior of its parent context. + +Sub-contexts can be resized, but not their parents (i.e. anything +returned by 'GrCreateContext' or set up by 'GrSetMode' cannot be resized -- +because this could lead to irrecoverable "loss" of drawing memory. The +following function can be used for this purpose: + +void GrResizeSubContext(GrContext *context,int x1,int y1,int x2,int y2); + +The current context structure is stored in a static location in the +library. (For efficiency reasons -- it is used quite frequently, and this way +no pointer dereferencing is necessary.) The context stores all relevant +information about the video organization, coordinate limits, etc... The +current context can be set with the: + +void GrSetContext(GrContext *context); + +function. This function will reset the current context to the full graphics +screen if it is passed the NULL pointer as argument. The value of the current +context can be saved into a 'GrContext' structure pointed to by 'where' using: + + + + + +LIBGRX graphics library user's manual 7 + + +GrContext *GrSaveContext(GrContext *where); + +(Again, if 'where' is NULL, the library allocates the space.) Contexts can be +destroyed with: + +void GrDestroyContext(GrContext *context); + +This function will free the memory occupied by the context only if it was +allocated originally by the library. The next three functions set up and query +the clipping limits associated with the context: + +void GrSetClipBox(int x1,int y1,int x2,int y2); +void GrGetClipBox(int *x1p,int *y1p,int *x2p,int *y2p); +void GrResetClipBox(void); + +'GrResetClipBox' sets the clipping limits to the limits of context. These are +the limits set up initially when a context is created. The limits of the +current context can be obtained using the following functions: + +int GrMaxX(void); +int GrMaxY(void); +int GrSizeX(void); +int GrSizeY(void); + +The 'Max' functions return the biggest valid coordinate, while the 'Size' +functions return a value one higher. The limits of the graphics screen +(regardless of the current context) can be obtained with: + +int GrScreenX(void); +int GrScreenY(void); + + +Color management + +The library supports two models for color management. In the 'indirect' +(or color table) mode colors can be allocated with the highest resolution +supported by the hardware (EGA: 2 bits, VGA: 6 bits) with respect to the +component color intensities. In the 'direct' or RGB mode color indices map +directly into component color intensities with non-overlapping bitfields of +the color index representing the component colors. The RGB mode is supported +in 256 color and 32768 color VGA modes only (for 32768 colors this is the only +mode because of the limitations of the VGA hardware with HiColor DAC). In RGB +mode the color index maps to component color intensities as follows: + +256: rrrgggbb (3 bits for red and green, 2 for blue) +32768: xrrrrrgggggbbbbb (5 bits for each component color) + +The RGB mode is not supported in 16 color EGA and VGA modes as there are +too few available colors to provide adequate coverage. The advantage of the +RGB mode is faster color allocation (no table lookup, DAC register + + + + + +LIBGRX graphics library user's manual 8 + + +programming, etc...) its disadvantage is the relatively crude approximation of +the component color intensities. + +After the first 'GrSetMode' call two colors are always defined: black +and white. The indices of these two colors are returned by the functions: + +int GrBlack(void); +int GrWhite(void); + +NOTE: unlike the original DJGPP library, LIBGRX does not guarantee that the +white color +has the color index value of one. (GrBlack still returns 0). + +The library supports four write modes: write, XOR, logical OR and +logical AND. These can be selected with OR-ing the color index with one of the +following constants declared in "grx.h": + +#ifdef __TURBOC__ +# define GrXOR 0x100 /* to "XOR" any color to the screen */ +# define GrOR 0x200 /* to "OR" to the screen */ +# define GrAND 0x300 /* to "AND" to the screen */ +#endif +#ifdef __GNUC__ /* changed for 16 bit colors */ +# define GrXOR 0x10000 /* to "XOR" any color to the screen */ +# define GrOR 0x20000 /* to "OR" to the screen */ +# define GrAND 0x30000 /* to "AND" to the screen */ +#endif +#define GrWRITE 0 /* write color */ +#define GrNOCOLOR (GrXOR | 0) /* GrNOCOLOR is used for "no" color */ + +NOTE: 'GrXOR' was declared to be "0x100" in the original DJGPP library, but +its value had to be changed in LIBGRX in anticipation of the 32768 color VGA +support. + +By convention, the no-op color is obtained by combining color index 0 (black) +with the XOR operation. This no-op color has been defined in "grx.h" as +'GrNOCOLOR'. + +The number of colors in the current graphics mode is returned by the: + +int GrNumColors(void); + +function, while the number of unused, available color can be obtained by +calling: + +int GrNumFreeColors(void); + +Colors can be allocated with the: + +int GrAllocColor(int r,int g,int b); + + + + + +LIBGRX graphics library user's manual 9 + + +function (component intensities can range from 0 to 255), or with the: + +int GrAllocCell(void); + +function. In the second case the component intensities of the returned color +can be set with: + +void GrSetColor(int color,int r,int g,int b); + +Both 'Alloc' functions return 'GrNOCOLOR' if there are no more free colors +available. Additionally 'GrAllocCell' always returns 'GrNOCOLOR' when the +color system is in RGB mode, as colors returned by 'GrAllocCell' are meant to +be changed -- what is not supposed to be done in RGB mode. Also note that +'GrAllocColor' operates much more efficiently in RGB mode, and that it never +returns 'GrNOCOLOR' in this case. + +Color table entries can be freed (when not in RGB mode) by calling: + +void GrFreeColor(int color); + +The component intensities of any color can be queried using the function: + +void GrQueryColor(int c,int *r,int *g,int *b); + +Initially the color system is in color table (indirect) mode. (Except +for the 32768 color VGA modes which are always in RGB mode.) 256 color VGA +modes can be put into the RGB mode by calling: + +void GrSetRGBcolorMode(void); + +The color system can be reset (i.e. put back into color table mode if +possible, all colors freed except for black and white) by calling: + +void GrResetColors(void); + +The function: + +void GrRefreshColors(void); + +reloads the currently allocated color values into the video hardware. This +function is not needed in typical applications, unless the display adapter is +programmed directly by the application. + +Graphics primitives + +The screen, the current context or the current clip box can be cleared +(i.e.set toadesired backgroundcolor)by usingoneof thefollowingthree functions: + +void GrClearScreen(int bg); +void GrClearContext(int bg); +void GrClearClipBox(int bg); + + + + + +LIBGRX graphics library user's manual 10 + + +The following line drawing graphics primitives are supported by the library: + +void GrPlot(int x,int y,int c); +void GrLine(int x1,int y1,int x2,int y2,int c); +void GrHLine(int x1,int x2,int y,int c); +void GrVLine(int x,int y1,int y2,int c); +void GrBox(int x1,int y1,int x2,int y2,int c); +void GrCircle(int xc,int yc,int r,int c); +void GrEllipse(int xc,int yc,int xa,int ya,int c); +void GrCircleArc(int xc,int yc,int r,int start,int end,int c); +void GrEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int c); +void GrPolyLine(int numpts,int points[][2],int c); +void GrPolygon(int numpts,int points[][2],int c); + +All primitives operate on the current graphics context. The last argument of +these functions is always the color index to use for the drawing. The +'HLine' and 'VLine' primitives are for drawing horizontal and vertical +lines. They have been included in the library because they are more +efficient than the general line drawing provided by 'GrLine'. The ellipse +primitives can only draw ellipses with their major axis parallel with either +the X or Y coordinate axis. They take the half X and Y axis length in the +'xa' and 'ya' arguments. The arc (circle and ellipse) drawing functions take +the start and end angles in tenths of degrees (i.e. meaningful range: 0 ... +3600). The angles are interpreted counter-clockwise starting from the +positive X axis. The polyline and polygon primitives take the address of an +n by 2 coordinate array. The X values should be stored in the elements with +0 second index, and the Y values in the elements with a second index value +of 1. Coordinate arrays passed to the polygon primitives can either contain +or omit the closing edge of the polygon -- the primitive will append it to +the list if it is missing. + +The following filled primitives are available: + +void GrFilledBox(int x1,int y1,int x2,int y2,int c); +void GrFramedBox(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c); +void GrFilledCircle(int xc,int yc,int r,int c); +void GrFilledEllipse(int xc,int yc,int xa,int ya,int c); +void GrFilledCircleArc(int xc,int yc,int r,int start,int end,int c); +void GrFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int c); +void GrFilledPolygon(int numpts,int points[][2],int c); +void GrFilledConvexPolygon(int numpts,int points[][2],int c); + +Similarly to the line drawing, all of the above primitives operate on +the current graphics context. The 'GrFramedBox' primitive can be used to draw +motif-like shaded boxes and "ordinary" framed boxes as well. The 'x1' through +'y2' coordinates specify the interior of the box, the border is outside this +area. The primitive uses five different colors for the interior and four +borders of the box which are specified in the 'GrFBoxColors' structure: + +typedef struct { +int fbx_intcolor; +int fbx_topcolor; + + + + + +LIBGRX graphics library user's manual 11 + + +int fbx_rightcolor; +int fbx_bottomcolor; +int fbx_leftcolor; +} GrFBoxColors; + +The 'GrFilledConvexPolygon' primitive can be used to fill convex polygons. It +can also be used to fill some concave polygons whose boundaries do not +intersect any horizontal scan line more than twice. All other concave polygons +have to be filled with the (somewhat less efficient) 'GrFilledPolygon' +primitive. This primitive can also be used to fill several disjoint non- +overlapping polygons in a single operation. + +The current color value of any pixel in the current context can be obtained +with: + +int GrPixel(int x,int y); + +Rectangular areas can be transferred within a context or between contexts by +calling: + +void GrBitBlt(GrContext *dest,int x,int y,GrContext *source,int x1,int y1,int x2,int y2,int oper); + +The 'oper' argument should be one of supported color modes (write, XOR, OR, +AND), it will control how the pixels from the source context are combined with +the pixels in the destination context. If either the source or the destination +context argument is the NULL pointer then the current context is used for that +argument. + + +Non-clipping graphics primitives + +There is a non-clipping version of some of the elementary primitives. +These are somewhat more efficient than the regular versions. These are to be +used only in situations when it is absolutely certain that no drawing will be +performed beyond the boundaries of the current context. Otherwise the program +will almost certainly crash! The reason for including these functions is that +they are somewhat more efficient than the regular, clipping versions. ALSO +NOTE: These function do not check for conflicts with the mouse cursor. (See +the explanation about the mouse cursor handling later in this document.) The +list of the supported non-clipping primitives: + +void GrPlotNC(int x,int y,int c); +void GrLineNC(int x1,int y1,int x2,int y2,int c); +void GrHLineNC(int x1,int x2,int y,int c); +void GrVLineNC(int x,int y1,int y2,int c); +void GrBoxNC(int x1,int y1,int x2,int y2,int c); +void GrFilledBoxNC(int x1,int y1,int x2,int y2,int c); +void GrFramedBoxNC(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c); +void GrBitBltNC(GrContext *dst,int x,int y,GrContext *src,int x1,int y1,int x2,int y2,int oper); +int GrPixelNC(int x,int y); + + + + + +LIBGRX graphics library user's manual 12 + + +Customized line drawing + +The basic line drawing graphics primitives described previously always +draw continuous lines which are one pixel wide. There is another group of line +drawing functions which can be used to draw wide and/or patterned lines. These +functions have similar parameter passing conventions as the basic ones with +one difference: instead of the color value a pointer to a structure of type +'GrLineOption' has to be passed to them. The definition of the 'GrLineOption' +structure: + +typedef struct { +int lno_color; /* color used to draw line */ +int lno_width; /* width of the line */ +int lno_pattlen; /* length of the dash pattern */ +unsigned char *lno_dashpat; /* draw/nodraw pattern */ +} GrLineOption; + +The 'lno_pattlen' structure element should be equal to the number of +alternating draw -- no draw section length values in the array pointed to by +the 'lno_dashpat' element. The dash pattern array is assumed to begin with a +drawn section. If the pattern length is equal to zero a continuous line is +drawn. The available custom line drawing primitives: + +void GrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrCustomCircle(int xc,int yc,int r,const GrLineOption *o); +void GrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o); +void GrCustomCircleArc(int xc,int yc,int r,int start,int end,const GrLineOption *o); +void GrCustomEllipseArc(int xc,int yc,int xa,int ya,int start,int end,const GrLineOption *o); +void GrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o); +void GrCustomPolygon(int numpts,int points[][2],const GrLineOption *o); + + +Pattern filled graphics primitives + +The library also supports a pattern filled version of the basic filled +primitives described above. These functions have similar parameter passing +conventions as the basic ones with one difference: instead of the color value +a pointer to an union of type 'GrPattern' has to be passed to them. The +'GrPattern' union can contain either a bitmap or a pixmap fill pattern. The +first integer slot in the union determines which type it is. Bitmap fill +patterns are rectangular arrays of bits, each set bit representing the +foreground color of the fill operation, and each zero bit representing the +background. Both the foreground and background colors can be combined with any +of the supported logical operations. Bitmap fill patterns have one +restriction: their width must be eight pixels. Pixmap fill patterns are very +similar to contexts, the data is transferred to the filled primitive using +'BitBlt' operations. The relevant structure declarations (from "grx.h"): + +/* +* BITMAP: a mode independent way to specify a fill pattern of two + + + + + +LIBGRX graphics library user's manual 13 + + +* colors. It is always 8 pixels wide (1 byte per scan line), its +* height is user-defined. SET THE TYPE FLAG TO ZERO!!! +*/ +typedef struct { +int bmp_ispixmap; /* type flag for pattern union */ +int bmp_height; /* bitmap height */ +unsigned char *bmp_data; /* pointer to the bit pattern */ +int bmp_fgcolor; /* foreground color for fill */ +int bmp_bgcolor; /* background color for fill */ +int bmp_memflags; /* set if dynamically allocated */ +} GrBitmap; + +/* +* PIXMAP: a fill pattern stored in a layout identical to the video RAM +* for filling using 'bitblt'-s. It is mode dependent, typically one +* of the library functions is used to build it. KEEP THE TYPE FLAG +* NONZERO!!! +*/ +typedef struct { +int pxp_ispixmap; /* type flag for pattern union */ +int pxp_width; /* pixmap width (in pixels) */ +int pxp_height; /* pixmap height (in pixels) */ +int pxp_oper; /* bitblt mode (SET, OR, XOR, AND) */ +GrVidRAM pxp_source; /* source context for fill */ +} GrPixmap; + +/* +* Fill pattern union -- can either be a bitmap or a pixmap +*/ +typedef union { +int gp_ispixmap; /* nonzero for pixmaps */ +GrBitmap gp_bitmap; /* fill bitmap */ +GrPixmap gp_pixmap; /* fill pixmap */ +} GrPattern; + +#define gp_bmp_data gp_bitmap.bmp_data +#define gp_bmp_height gp_bitmap.bmp_height +#define gp_bmp_fgcolor gp_bitmap.bmp_fgcolor +#define gp_bmp_bgcolor gp_bitmap.bmp_bgcolor + +#define gp_pxp_width gp_pixmap.pxp_width +#define gp_pxp_height gp_pixmap.pxp_height +#define gp_pxp_oper gp_pixmap.pxp_oper +#define gp_pxp_source gp_pixmap.pxp_source + +Bitmap patterns can be easily built from initialized character arrays and +static structures by the C compiler, thus no special support is included in +the library for creating them. The only action required from the application +program might be changing the foreground and background colors as needed. +Pixmap patterns are more difficult to build as they replicate the layout of +the video memory which changes for different video modes. For this reason the + + + + + +LIBGRX graphics library user's manual 14 + + +library provides three functions to create pixmap patterns in a mode- +independent way: + +GrPattern *GrBuildPixmap(const char *pixels,int w,int h,const GrColorTableP colors); +GrPattern *GrBuildPixmapFromBits(const char *bits,int w,int h,int fgc,int bgc); +GrPattern *GrConvertToPixmap(GrContext *src); + +'GrBuildPixmap' build a pixmap from a two dimensional ('w' by 'h') array of +characters. The elements in this array are used as indices into the color +table specified with the argument 'colors'. (This means that pixmaps created +this way can use at most 256 colors.) The color table pointer: + +typedef int *GrColorTableP; + +should point to an array of integers with the first element being the number +of colors in the table and the color indices themselves starting with the +second element. NOTE: any color modifiers (GrXOR, GrOR, GrAND) OR-ed to the +elements of the color table are ignored. + +The 'GrBuildPixmapFromBits' function builds a pixmap fill pattern from bitmap +data. It is useful if the width of the bitmap pattern is not eight as such +bitmap patterns can not be used to build a 'GrBitmap' structure. + +The 'GrConvertToPixmap' function converts a graphics context to a pixmap fill +pattern. It is useful when the pattern can be created with graphics drawing +operations. NOTE: the pixmap pattern and the original context share the +drawing RAM, thus if the context is redrawn the fill pattern changes as well. + +Fill patterns which were built by library routines can be destroyed when +no longer needed (i.e. the space occupied by them can be freed) by calling: + +void GrDestroyPattern(GrPattern *p); + +NOTE: when pixmap fill patterns converted from contexts are destroyed, the +drawing RAM is not freed. It is freed when the original context is destroyed. +Fill patterns built by the application have to be destroyed by the application +as well (if this is needed). + +The list of supported pattern filled graphics primitives is shown below. +These functions are very similar to their solid filled counterparts, only +their last argument is different: + +void GrPatternFilledPlot(int x,int y,GrPattern *p); +void GrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p); +void GrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p); +void GrPatternFilledCircle(int xc,int yc,int r,GrPattern *p); +void GrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p); +void GrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,GrPattern *p); +void GrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,GrPattern *p); +void GrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p); +void GrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p); + + + + + +LIBGRX graphics library user's manual 15 + + +Strictly speaking the plot and line functions in the above group are not +filled, but they have been included here for convenience. + + +Patterned line drawing + +The custom line drawing functions introduced above also have a version +when the drawn sections can be filled with a (pixmap or bitmap) fill pattern. +To achieve this these functions must be passed both a custom line drawing +option ('GrLineOption' structure) and a fill pattern ('GrPattern' union). +These two have been combined into the 'GrLinePattern' structure: + +typedef struct { +GrPattern *lnp_pattern; /* fill pattern */ +GrLineOption *lnp_option; /* width + dash pattern */ +} GrLinePattern; + +All patterned line drawing functions take a pointer to this structure as their +last argument. The list of available functions: + +void GrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp); +void GrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp); +void GrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp); +void GrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp); +void GrPatternedCircleArc(int xc,int yc,int r,int start,int end,GrLinePattern *lp); +void GrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end,GrLinePattern *lp); +void GrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp); +void GrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp); + + +Text drawing + +The library supports loadable bit-mapped (i.e. not scalable!) fonts. +Some of these fonts were converted from VGA BIOS fonts and fonts on utility +diskettes coming with VGA cards. These fonts have all 256 characters. Some +additional fonts were converted from fonts in the MIT X11 distribution. These +have a variable number of characters, some support all 256 character codes, +some only the printable ASCII codes. Fonts also have family names, which are +used in a font lookup procedure supported by the library (see later). The +following font families are included in the distribution: + + + + + +LIBGRX graphics library user's manual 16 + + +Font file name: Family: Description: + +pcx[t].fnt pc BIOS font, fixed +xmx[b][i].fnt X_misc X11, fixed, miscellaneous group +char[b][i].fnt char X11, proportional, charter family +cour[b][i].fnt cour X11, fixed, courier +helve[b][i].fnt helve X11, proportional, helvetica +lucb[b][i].fnt lucb X11, proportional, lucida bright +lucs[b][i].fnt lucs X11, proportional, lucida sans serif +luct[b][i].fnt luct X11, fixed, lucida typewriter +ncen[b][i].fnt ncen X11, proportional, new century schoolbook +symb.fnt symbol X11, proportional, greek letters, +symbols +tms[b][i].fnt times X11, proportional, times + +In the font names means the font width, the font height. Many font +families have bold and/or italic variants. The files containing these fonts +contain a 'b' and/or 'i' character in their name just before the extension. +Additionally, the strings "_bold" and/or "_ital" are appended to the font +family names. Some of the pc BIOS fonts come in thin formats also, these are +denoted by a 't' in their file names and the string "_thin" in their family +names. + +NOTE: the basic libgrx distribution ("cbgrx101.zip") contains only the full +"pc", "courier", "helve", "symbol" and "times" font families and selected +sizes from the "X_misc" family. (Because of archive size considerations!) The +full compliment of fonts can be found in the archive file named +"cbgrxfnt.zip", which should be available from the same site where the basic +library was obtained from. + +Fonts are loaded with the 'GrLoadFont' function. If the font file name +starts with any path separator character or character sequence (':', '/' or '\') then it is loaded from the specified directory, +otherwise the font is loaded from the default font path. The font path can be +set up with the 'GrSetFontPath' function. If the font path is not set then the +value of the 'GRXFONT' environment variable is used as the font path. If +'GrLoadFont' is called again with the name of an already loaded font then it +will return a pointer to the result of the first loading. The special font +names "@:pc8x8.fnt", "@:pc8x14.fnt" and "@:pc8x16.fnt" will cause 'GrLoadFont' +to load the font from the BIOS of the graphics card of the PC (provided that +it has the desired font). Alternatively, 'GrLoadBIOSFont' can also be called +to load a font which resides in the BIOS of the display adapter. (The +difference is that 'GrLoadFont' will look at the disk as well if the BIOS does +not have the font. For example: EGA-s don't have a 16 row font in their BIOS.) +Both font loading routines return NULL if the font was not found. When not +needed any more, fonts can be unloaded (i.e. the storage occupied by them +freed) by calling 'GrUnloadFont'. The prototype declarations for these +functions: + +GrFont *GrLoadFont(char *name); +GrFont *GrLoadBIOSFont(char *name); + + + + + +LIBGRX graphics library user's manual 17 + + +void GrUnloadFont(GrFont *font); +void GrSetFontPath(char *path); + +The 'GrFont' structure is actually a font header, the real font data is +right next to this header in memory, but it is typically hidden from the +application program. If needed, the include file "grxfont.h" can provide more +details. The 'GrFont' structure: + +typedef struct { +short fnt_width; /* width (average for proportional) */ +short fnt_height; /* font height */ +short fnt_minchar; /* lowest character code in font */ +short fnt_maxchar; /* highest character code in font */ +short fnt_isfixed; /* nonzero if fixed font */ +short fnt_internal; /* nonzero if BIOS font */ +short fnt_baseline; /* baseline from top of font */ +short fnt_undwidth; /* underline width (at bottom) */ +char fnt_name[GR_NAMEWIDTH]; /* font file name (w/o path) */ +char fnt_family[GR_NAMEWIDTH]; /* font family name */ +} GrFont; + +There is a function: 'GrFindBestFont' which returns the font which +matches best a desired size. (Best match: not bigger, but as close as +possible). The application can specify whether it wants 'GrFindBestFont' to +find the best match using fonts in their original sizes only, or possibly +enlarged (with the value of the 'magnify' argument -- 0: no, nonzero: yes). +'GrFindBestFont' also takes a string argument which specifies the font family +from which to select the font. The string can specify several family patterns +separated by the ':' character. Each pattern can contain the '?' and '*' +wildcard characters which work the usual way (in UNIX sense -- i.e. "X*ital" +will match "X_misc_ital", but not "X_misc_bold"..). + +GrTextOption *GrFindBestFont(int width,int height,int magnify,char *family,GrTextOption *where); + +The 'GrTextOption' structure specifies how to draw a character string: + +typedef struct { +GrFont *txo_font; /* font to be used */ +int txo_xmag; /* X magnification */ +int txo_ymag; /* Y magnification */ +union { +int v; /* color when no attributes */ +GrColorTableP p; /* ptr to color table otherwise */ +} txo_fgcolor,txo_bgcolor; /* foreground, background */ +char txo_direct; /* direction */ +char txo_xalign; /* X alignment */ +char txo_yalign; /* Y alignment */ +char txo_chrtype; /* character type */ +} GrTextOption; + + + + + +LIBGRX graphics library user's manual 18 + + +The font can be enlarged independently in the X and Y directions, ('txo_xmag' +and 'txo_ymag' slots -- values: 1 and up) the text can be rotated in +increments of 90 degrees ('txo_direct'), alignments can be set in both +directions ('txo_xalign' and 'txo_yalign'), and separate fore and background +colors can be specified. The accepted text direction values: + +#define GR_TEXT_RIGHT 0 /* normal */ +#define GR_TEXT_DOWN 1 /* downward */ +#define GR_TEXT_LEFT 2 /* upside down, right to left */ +#define GR_TEXT_UP 3 /* upward */ +#define GR_TEXT_DEFAULT GR_TEXT_RIGHT + +The accepted horizontal and vertical alignment option values: + +#define GR_ALIGN_LEFT 0 /* X only */ +#define GR_ALIGN_TOP 0 /* Y only */ +#define GR_ALIGN_CENTER 1 /* X, Y */ +#define GR_ALIGN_RIGHT 2 /* X only */ +#define GR_ALIGN_BOTTOM 2 /* Y only */ +#define GR_ALIGN_BASELINE 3 /* Y only */ +#define GR_ALIGN_DEFAULT GR_ALIGN_LEFT + +Text strings can be of three different types: one character per byte (i.e. the +usual C character string, this is the default), one character per 16-bit word +(suitable for fonts with a large number of characters), and a PC-style +character-attribute pair. In the last case the 'GrTextOption' structure must +contain a pointer to a color table of size 16 (fg color bits in attrib) or 8 +(bg color bits). (The color table format is explained in more detail in the +previous section explaining the methods to build fill patterns.) The supported +text types: + +#define GR_BYTE_TEXT 0 /* one byte per character */ +#define GR_WORD_TEXT 1 /* two bytes per character */ +#define GR_ATTR_TEXT 2 /* char w/ PC style attribute byte */ + +The PC-style attribute text uses the same layout (first byte: character, +second: attributes) and bitfields as the text mode screen on the PC. The only +difference is that the 'blink' bit is not supported (it would be very time +consuming -- the PC text mode does it with hardware support). This bit is used +instead to control the underlined display of characters. For convenience the +following attribute manipulation macros have been declared in "grx.h": + +#define GR_BUILD_ATTR(fgcolor,bgcolor,underline) \ +((fgcolor) & 15) | (((bgcolor) & 7) << 4) | (((underline) & 1) << 7)) +#define GR_ATTR_FGCOLOR(attr) ((attr) & 15) +#define GR_ATTR_BGCOLOR(attr) (((attr) >> 4) & 7) +#define GR_ATTR_UNDERLINE(attr) (((attr) >> 7) & 1) + +Text strings of the types 'GR_BYTE_TEXT' and 'GR_WORD_TEXT" can also be drawn +underlined. This is controlled by OR-ing the constant 'GR_UNDERLINE_TEXT' to +the foreground color value: + + + + + +LIBGRX graphics library user's manual 19 + + +#define GR_UNDERLINE_TEXT (GrXOR << 6) + +After the application initializes a text option structure with the +desired values it can call one of the following two text drawing functions: + +void GrDrawChar(int chr,int x,int y,const GrTextOption *opt); +void GrDrawString(char *text,int length,int x,int y,const GrTextOption *opt); + +NOTE: text drawing is fastest when the font is not magnified, it is drawn in +the 'normal' direction, and the character does not have to be clipped. It this +case the library can use the appropriate low-level video RAM access routine +(see "INTERNAL.DOC" for more details), while in any other case the text is +drawn pixel-by-pixel (or rectangle-by-rectangle if enlarged) by the +higher-level code. + +The function 'GrTextXY' is provided for compatibility with the original +256 color DJGPP graphics library. It draws the text in the standard direction, +unmagnified, and using the 16 row BIOS font on VGA-s or the 14 row font on +EGA-s. + +void GrTextXY(int x,int y,char *text,int fg,int bg); + +The size of a font, a character or a text string can be obtained by +calling one of the following functions. These functions also take into +consideration the magnification and text direction specified in the text +option structure passed to them. + +int GrFontHeight(GrTextOption *opt); +int GrFontWidth(GrTextOption *opt); +int GrCharWidth(int chr,const GrTextOption *opt); +int GrCharHeight(int chr,const GrTextOption *opt); +int GrStringWidth(char *text,int length,const GrTextOption *opt); +int GrStringHeight(char *text,int length,const GrTextOption *opt); + +The 'GrTextRegion' structure and its associated functions can be used to +implement a fast (as much as possible in graphics modes) rectangular text +window using a fixed font. Clipping for such windows is done in character size +increments instead of pixels (i.e. no partial characters are drawn). Only +fixed fonts can be used in their natural size. 'GrDumpText' will cache the +code of the drawn characters in the buffer pointed to by the 'backup' slot (if +it is non-NULL) and will draw a character only if the previously drawn +character in that grid element is different. This can speed up text scrolling +significantly in graphics modes. The supported text types are the same as +above. + +typedef struct { +GrFont *txr_font; /* font to be used */ +char *txr_buffer; /* pointer to text buffer */ +char *txr_backup; /* optional backup buffer */ +int txr_xpos; /* upper left corner X coordinate */ +int txr_ypos; /* upper left corner Y coordinate */ + + + + + +LIBGRX graphics library user's manual 20 + + +int txr_width; /* width of area in chars */ +int txr_height; /* height of area in chars */ +int txr_lineoffset; /* offset in buffer(s) between lines */ +union { +int v; /* color when no attributes */ +GrColorTableP p; /* ptr to color table otherwise */ +} txr_fgcolor,txr_bgcolor; /* foreground, background */ +char txr_chrtype; /* character type (see above) */ +} GrTextRegion; + +void GrDumpChar(int chr,int col,int row,const GrTextRegion *r); +void GrDumpText(int col,int row,int wdt,int hgt,const GrTextRegion *r); +void GrDumpTextRegion(const GrTextRegion *r); + +The 'GrDumpTextRegion' function outputs the whole text region, while +'GrDumpText' draws only a user-specified part of it. 'GrDumpChar' updates the +character in the buffer at the specified location with the new character +passed to it as argument and then draws the new character on the screen as +well. + + +Drawing in user coordinates + +There is a second set of the graphics primitives which operates in user +coordinates. Every context has a user to screen coordinate mapping associated +with it. An application specifies the user window by calling the +'GrSetUserWindow' function. + +void GrSetUserWindow(int x1,int y1,int x2,int y2); + +A call to this function it in fact specifies the virtual coordinate limits +which will be mapped onto the current context regardless of the size of the +context. For example, the call: + +GrSetUserWindow(0,0,11999,8999); + +tells the library that the program will perform its drawing operations in a +coordinate system X:0...11999 (width = 12000) and Y:0...8999 (height = 9000). +This coordinate range will be mapped onto the total area of the current +context. The virtual coordinate system can also be shifted. For example: + +GrSetUserWindow(5000,2000,16999,10999); + +The user coordinates can even be used to turn the usual left-handed coordinate +system (0:0 corresponds to the upper left corner) to a right handed one (0:0 +corresponds to the bottom left corner) by calling: + +GrSetUserWindow(0,8999,11999,0); + + + + + +LIBGRX graphics library user's manual 21 + + +The library also provides three utility functions for the query of the +current user coordinate limits and for converting user coordinates to screen +coordinates and vice versa. + +void GrGetUserWindow(int *x1,int *y1,int *x2,int *y2); +void GrGetScreenCoord(int *x,int *y); +void GrGetUserCoord(int *x,int *y); + +If an application wants to take advantage of the user to screen +coordinate mapping it has to use the user coordinate version of +the graphics primitives. These have exactly the same parameter +passing conventions as their screen coordinate counterparts. +NOTE: the user coordinate system is not initialized by the +library! The application has to set up its coordinate mapping +before calling any of the use coordinate drawing functions -- +otherwise the program will almost certainly exit (in a quite +ungraceful fashion) with a 'division by zero' error. The list of +supported user coordinate drawing functions: + +void GrUsrPlot(int x,int y,int c); +void GrUsrLine(int x1,int y1,int x2,int y2,int c); +void GrUsrHLine(int x1,int x2,int y,int c); +void GrUsrVLine(int x,int y1,int y2,int c); +void GrUsrBox(int x1,int y1,int x2,int y2,int c); +void GrUsrFilledBox(int x1,int y1,int x2,int y2,int c); +void GrUsrFramedBox(int x1,int y1,int x2,int y2,int wdt,GrFBoxColors *c); +void GrUsrCircle(int xc,int yc,int r,int c); +void GrUsrEllipse(int xc,int yc,int xa,int ya,int c); +void GrUsrCircleArc(int xc,int yc,int r,int start,int end,int c); +void GrUsrEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int c); +void GrUsrFilledCircle(int xc,int yc,int r,int c); +void GrUsrFilledEllipse(int xc,int yc,int xa,int ya,int c); +void GrUsrFilledCircleArc(int xc,int yc,int r,int start,int end,int c); +void GrUsrFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int c); +void GrUsrPolyLine(int numpts,int points[][2],int c); +void GrUsrPolygon(int numpts,int points[][2],int c); +void GrUsrFilledConvexPolygon(int numpts,int points[][2],int c); +void GrUsrFilledPolygon(int numpts,int points[][2],int c); +int GrUsrPixel(int x,int y); + +void GrUsrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrUsrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrUsrCustomCircle(int xc,int yc,int r,const GrLineOption *o); +void GrUsrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o); +void GrUsrCustomCircleArc(int xc,int yc,int r,int start,int end,const GrLineOption *o); +void GrUsrCustomEllipseArc(int xc,int yc,int xa,int ya,int start,int end,const GrLineOption *o); +void GrUsrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o); +void GrUsrCustomPolygon(int numpts,int points[][2],const GrLineOption *o); + +void GrUsrPatternedPlot(int x,int y,GrPattern *p); +void GrUsrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp); + + + + + +LIBGRX graphics library user's manual 22 + + +void GrUsrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp); +void GrUsrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp); +void GrUsrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp); +void GrUsrPatternedCircleArc(int xc,int yc,int r,int start,int end,GrLinePattern *lp); +void GrUsrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end,GrLinePattern *lp); +void GrUsrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp); +void GrUsrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp); + +void GrUsrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p); +void GrUsrPatternFilledCircle(int xc,int yc,int r,GrPattern *p); +void GrUsrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p); +void GrUsrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,GrPattern *p); +void GrUsrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,GrPattern *p); +void GrUsrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p); +void GrUsrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p); + +GrTextOption *GrUsrFindBestFont(int width,int height,int magnify,char *family,GrTextOption *where); +void GrUsrDrawChar(int chr,int x,int y,const GrTextOption *opt); +void GrUsrDrawString(char *text,int length,int x,int y,const GrTextOption *opt); +void GrUsrTextXY(int x,int y,char *text,int fg,int bg); + + +Graphics cursors + +The library provides support for the creation and usage of an unlimited +number of graphics cursors. An application can use these cursors for any +purpose. Cursors always save the area they occupy before they are drawn. When +moved or erased they restore this area. As a general rule of thumb, an +application should erase a cursor before making changes to an area it occupies +and redraw the cursor after finishing the drawing. All cursor and mouse +related declaration are in the include file "mousex.h". Cursors are created +with the 'GrBuildCursor' function: + +GrCursor *GrBuildCursor(char *data,int w,int h,int xo,int yo,const GrColorTableP c); + +The 'data', 'w' (=width), 'h' (=height) and 'c' (= color table) arguments are +similar to the arguments of the pixmap building library function: +'GrBuildPixmap'. (See that paragraph for a more detailed explanation.) The +only difference is that the pixmap data is interpreted slightly differently: +any pixel with value zero is taken as a "transparent" pixel, i.e. the +background will show through the cursor pattern at that pixel. A pixmap data +byte with value = 1 will refer to the first color in the table, and so on. The +'xo' (= X offset) and 'yo' (= Y offset) arguments specify the position (from +the top left corner of the cursor pattern) of the cursor's "hot point". The +'GrCursor' data structure: + + + + + +LIBGRX graphics library user's manual 23 + + +typedef struct { +GrVidRAM cr_andmask; /* cursor bitmap to AND */ +GrVidRAM cr_ormask; /* cursor bitmap to OR */ +GrVidRAM cr_work; /* work area */ +GrVidRAM cr_save; /* screen save area */ +int cr_xcord,cr_ycord; /* cursor position on screen */ +int cr_xsize,cr_ysize; /* cursor size */ +int cr_xoffs,cr_yoffs; /* LU corner to hot point offset */ +int cr_xwork,cr_ywork; /* save/work area sizes */ +int cr_xwpos,cr_ywpos; /* save/work area position on screen */ +int cr_displayed; /* set if displayed */ +} GrCursor; + +is typically not used (i.e. read or changed) by the application program, it +should just pass pointers to these structures to the appropriate library +functions. Other cursor manipulation functions: + +void GrDestroyCursor(GrCursor *cursor); +void GrDisplayCursor(GrCursor *cursor); +void GrEraseCursor(GrCursor *cursor); +void GrMoveCursor(GrCursor *cursor,int x,int y); + + +Mouse event handling + +All mouse services need the presence of a mouse and an installed +Microsoft compatible mouse driver. An application can test whether a mouse is +available by calling the function: + +int MouseDetect(void); + +which will return zero if no mouse (or mouse driver) is present, non-zero +otherwise. If the mouse is present the application may decide if it wants to +use the mouse in interrupt-driven or polled mode. The polled mode is +compatible with previous releases of DJGPP and the 256 color graphics library, +it uses the mouse driver interrupts (INT 33h) to query the mouse about its +position and buttons. This method is adequate if the program can do the +polling in a tight enough loop. If the program does lengthy computations in +the background during which a "frozen" mouse and the loss of mouse button +presses would be disturbing it has to use the interrupt driven method. For +this a patched version of GO32 is needed -- a GO32 version dated after the +middle of April 1992 should work. The interrupt driven mouse event mechanism +uses an event queue library (described in the document "EVENTS.DOC") which +stores all user interaction events (mouse presses and keyboard hits) in a +queue, timestamped, in the order of occurrence. The disadvantage of the +interrupt-driven mouse event mechanism is that it may be harder to debug. To +select between the two modes the following function needs to be called: + +void MouseEventMode(int use_interrupts); + + + + + +LIBGRX graphics library user's manual 24 + + +If the 'use_interrupts' parameter is zero the mouse is put into polled mode +(this is the default), otherwise it will work interrupt-driven. After +selecting the mode, the mouse can be initialized by calling: + +void MouseInit(void); + +It is not necessary to call this function as the first call the +'MouseGetEvent' (see later) function will also perform the initialization. +However, if the mouse event mode is changed after using 'MouseGetEvent', a +call to 'MouseInit' is the only way to enforce the change. + +If the mouse is used in interrupt-driven mode, it is a good practice to +call 'MouseUnInit' before exiting the program. This will restore any interrupt +vectors hooked by the program to their original values. + +void MouseUnInit(void); + +The mouse can be controlled with the following functions: + +void MouseSetSpeed(int speed); +void MouseSetAccel(int thresh,int accel); +void MouseSetLimits(int x1,int y1,int x2,int y2); +void MouseGetLimits(int *x1,int *y1,int *x2,int *y2); +void MouseWarp(int x,int y); + +The library calculates the mouse position only from the mouse mickey counters. +(To avoid the limit and 'rounding to the next multiple of eight' problem with +the Microsoft mouse driver when it finds itself in a graphics mode unknown to +it.) The 'speed' parameter to the 'MouseSetSpeed' function is used as a +divisor, i.e. coordinate changes are obtained by dividing the mickey counter +changes by this value. In high resolution graphics modes the value of one just +works fine, in low resolution modes (320x200 or similar) it is best set the +speed to two or three. (Of course, it also depends on the sensitivity the +mouse.) The 'MouseSetAccel' function is used to control the ballistic effect: +if a mouse coordinate changes between two samplings by more than the 'thresh' +parameter, the change is multiplied by the 'accel' parameter. NOTE: some mouse +drivers perform similar calculations before reporting the coordinates in +mickeys. In this case the acceleration done by the library will be additional +to the one already performed by the mouse driver. The limits of the mouse +movement can be set (passed limits will be clipped to the screen) with +'MouseSetLimits' (default is the whole screen) and the current limits can be +obtained with 'MouseGetLimits'. 'MouseWarp' sets the mouse cursor to the +specified position. + +As typical mouse drivers do not know how to draw mouse cursors in high +resolution graphics modes, the mouse cursor is drawn by the library. The mouse +cursor can be set with: + +void MouseSetCursor(GrCursor *cursor); +void MouseSetColors(int fg,int bg); + + + + + +LIBGRX graphics library user's manual 25 + + +'MouseSetColors' uses an internal arrow pattern, the color 'fg' will be used +as the interior of it and 'bg' will be the border. The current mouse cursor +can be obtained with: + +GrCursor *MouseGetCursor(void); + +The mouse cursor can be displayed/erased with: + +void MouseDisplayCursor(void); +void MouseEraseCursor(void); + +The mouse cursor can be left permanently displayed. All graphics primitives +except for the few non-clipping functions check for conflicts with the mouse +cursor and erase it before the drawing if necessary. Of course, it may be more +efficient to erase the cursor manually before a long drawing sequence and +redraw it after completion. The library provides an alternative pair of calls +for this purpose which will erase the cursor only if it interferes with the +drawing: + +int MouseBlock(GrContext *c,int x1,int y1,int x2,int y2); +void MouseUnBlock(void); + +'MouseBlock' should be passed the context in which the drawing will take place +(the usual convention of NULL meaning the current context is supported) and +the limits of the affected area. It will erase the cursor only if it +interferes with the drawing. If it returns a non-zero value then +'MouseUnBlock' has to be called at the end of the drawing, otherwise it should +not be called. + +The library supports (beside the simple cursor drawing) three types of +"rubberband" attached to the mouse cursor. The 'MouseSetCursorMode' function +is used to select the cursor drawing mode. + +void MouseSetCursorMode(int mode,...); + +The parameter 'mode' can have the following values: + +/* +* MOUSE CURSOR modes: +* M_CUR_NORMAL -- just the cursor +* M_CUR_RUBBER -- rectangular rubber band (XOR-d to the screen) +* M_CUR_LINE -- line attached to the cursor +* M_CUR_BOX -- rectangular box dragged by the cursor +*/ +#define M_CUR_NORMAL 0 +#define M_CUR_RUBBER 1 +#define M_CUR_LINE 2 +#define M_CUR_BOX 3 + +'MouseSetCursorMode' takes different parameters depending on the cursor +drawing mode selected. The accepted call formats are: + + + + + +LIBGRX graphics library user's manual 26 + + +MouseSetCursorMode(M_CUR_NORMAL); +MouseSetCursorMode(M_CUR_RUBBER,xanchor,yanchor,color); +MouseSetCursorMode(M_CUR_LINE,xanchor,yanchor,color); +MouseSetCursorMode(M_CUR_BOX,dx1,dy1,dx2,dy2,color); + +The anchor parameters for the rubberband and rubberline modes specify a fixed +screen location to which the other corner of the primitive is bound. The 'dx1' +through 'dy2' parameters define the offsets of the corners of the dragged box +from the hotpoint of the mouse cursor. The color value passed is always XOR-ed +to the screen, i.e. if an application wants the rubberband to appear in a +given color on a given background then it has to pass the XOR of these two +colors to 'MouseSetCursorMode'. + +The status of the mouse cursor can be obtained with calling +'MouseCursorIsDisplayed'. This function will return non-zero if the cursor is +displayed, zero if it is erased. + +int MouseCursorIsDisplayed(void); + +The 'MouseGetEvent' function is used to obtain the next mouse or +keyboard event. It takes a flag with various bits encoding the type of event +needed. It returns the event in a 'MouseEvent' structure. The relevant +declarations from "mousex.h": + +void MouseGetEvent(int flags,MouseEvent *event); + +typedef struct { +int flags; /* flags (see above) */ +int x,y; /* coordinates */ +int buttons; /* button state */ +int key; /* key code from keyboard */ +int kbstat; /* keybd status (ALT, CTRL, etc..) */ +long time; /* time stamp of the event */ +} MouseEvent; + +The event structure has been extended with a keyboard status word (thus a +program can check for combinations like ALT-) and a +time stamp (in DOS clock ticks since the start of the program) which can be +used to check for double clicks, etc... The following macros have been defined +in "mousex.h" to help in creating the control flag for 'MouseGetEvent' and +decoding the various bits in the event structure: + +/* +* MOUSE event flag bits +*/ +#define M_MOTION 0x001 +#define M_LEFT_DOWN 0x002 +#define M_LEFT_UP 0x004 +#define M_RIGHT_DOWN 0x008 +#define M_RIGHT_UP 0x010 +#define M_MIDDLE_DOWN 0x020 + + + + + +LIBGRX graphics library user's manual 27 + + +#define M_MIDDLE_UP 0x040 +#define M_BUTTON_DOWN (M_LEFT_DOWN | M_MIDDLE_DOWN | M_RIGHT_DOWN) +#define M_BUTTON_UP (M_LEFT_UP | M_MIDDLE_UP | M_RIGHT_UP) +#define M_BUTTON_CHANGE (M_BUTTON_UP | M_BUTTON_DOWN ) + +/* +* MOUSE button status bits +*/ +#define M_LEFT 1 +#define M_RIGHT 2 +#define M_MIDDLE 4 + +/* +* Other bits and combinations +*/ +#define M_KEYPRESS 0x080 /* keypress */ +#define M_POLL 0x100 /* do not wait for the event */ +#define M_NOPAINT 0x200 +#define M_EVENT (M_MOTION | M_KEYPRESS | M_BUTTON_DOWN | M_BUTTON_UP) + +/* +* KEYBOARD status word bits +*/ +#define KB_RIGHTSHIFT 0x01 /* right shift key depressed */ +#define KB_LEFTSHIFT 0x02 /* left shift key depressed */ +#define KB_CTRL 0x04 /* CTRL depressed */ +#define KB_ALT 0x08 /* ALT depressed */ +#define KB_SCROLLOCK 0x10 /* SCROLL LOCK active */ +#define KB_NUMLOCK 0x20 /* NUM LOCK active */ +#define KB_CAPSLOCK 0x40 /* CAPS LOCK active */ +#define KB_INSERT 0x80 /* INSERT state active */ + +#define KB_SHIFT (KB_LEFTSHIFT | KB_RIGHTSHIFT) + +'MouseGetEvent' will display the mouse cursor if it was previously erased and +the 'M_NOPAINT' bit is not set in the flag passed to it. In this case it will +also erase the cursor after an event has been obtained. + +NOTE: some of the mouse event constants have different values than in the +original DJGPP graphics library. This change was necessary to better follow +the mouse driver conventions for assigning bits with similar functions. + +The generation of mouse and keyboard events can be individually enabled or +disabled (by passing a non-zero or zero, respectively, value in the +corresponding 'enable_XX' parameter) by calling: + +void MouseEventEnable(int enable_kb,int enable_ms); + + +README for GRX 1.03 beta release +================================ + +This is file README.GRX. It can be found at the beta7 distribution site +and also in the DOCS sub-directory of the GRX archive. This file contains +additional information about the new graphics-related features of GO32, +the new graphics drivers and GRX 1.03. + +What is in this release? +------------------------ + +This is an intermediate release based on my working sources. This version +does not yet work with DPMI. On the other hand, it has been modified to work +with the new (.VDR) drivers. These drivers together with the modifications +in GO32 1.11 allow the use of more than 1MB of video RAM. Virtual screens +larger than the displayed screen are also supported, together with a GO32 +function to change the start of the displayed region (pan). The beta GO32 +1.11 already has a new format built-in VESA driver. + +This version only supports display modes which were present in GRX 1.02. +(I.e. 16, 256, 32K colors and accelerated S3/8514A 256 color modes.) I don't +intend to finish the missing display modes in the current page-fault based +video RAM access mode. Currently I am working on a new set of low-level GRX +video RAM access routines which will use explicit paging. These will support +DPMI graphics with >64K frame buffers. As soon as these are finished and +tested there will be another GRX release. + +The other new feature of this release is that all thick and patterned +line primitives (which were missing from GRX 1.02) are present in this +version. + +New driver interface +-------------------- + +The format of the VDR drivers can be found in the "grdriver.h" file in +the GO32 source directory or in the NDRIVERS directory of the GRX archive. +The built-in driver in GO32 should work with any VESA compatible SVGA card. +Older (.GRD or .GRN) drivers still work with the new GO32 and graphics +library. There is a small change in the driver specification part of the +GO32 environment variable: + +SET GO32=driver :: tw ... + ^^^^^^^^^^^^^^^^^^ + new fields + +If the name of the driver is followed by two colons and a string then this +string is taken as an option string for the driver. GO32 configures the driver +according to the characters in this string when the driver is loaded. (Which +now happens only when the driver is first used.) The option string is +ignored for .GRD and .GRD drivers. + +The option string can contain the following characters (in any order, case +does not matter): + +p: Enables protected mode paging. For .VDR drivers the default is to use + the driver's paging function in real mode. This is necessary because + the VESA BIOS paging function was written for real mode. However, many + VESA BIOS-es are well written, and their paging function can be used + in protected mode. Give it a try, if it fails then you have to use + real mode paging which is MUCH slower. (paging with .GRD and .GRN + drivers is always in protected mode) + +f: Enables fast 256 color mode. On some SVGA cards the planar, mode X-like + 256 color memory organization can be used even in SVGA modes. There are + a few operations (especially horizontal scan line fills) which can + be much faster in this mode. Give it a try -- and if you see garbage + on the screen then it does not work with your card. + +5: This field is necessary only if your VESA BIOS is version 1.1 or older + and the 64K (16 bit) color mode reported by it is really only a 32K + (15 bit) mode. You can find out your VESA version number and a lot of + other VESA related stuff by running the VESAINFO program in the + NDRIVERS directory of the GRX archive. + +If you want to use the built-in GO32 driver with options use the following +syntax: + + SET GO32 = driver ::pf5 tw ... + +When using a new .VDR driver with GO32 1.11 the video memory is mapped as +follows: + + 0xd0000000 .. 0xd0100000 old 1MB RW area + 0xd0100000 .. 0xd0200000 old 1MB R0 area + 0xd0200000 .. 0xd0300000 old 1MB W0 area + + 0xd1000000 .. 0xd2000000 new 16MB RW area + 0xd2000000 .. 0xd3000000 new 16MB R0 area + 0xd3000000 .. 0xd4000000 new 16MB W0 area + +GRX 1.03 uses the 1MB areas whenever the frame buffer is less then 1MB, +otherwise it uses the 16MB areas. + +GO32 1.11 supports the following new int 0x10 calls: + +Mode set with virtual screen sizes: +Input: +ax = 10 // = GR_custom_graphics +bx = colors +cx = desired screen width +dx = desired screen height +VDR_driver_header.virtual_x = desired virtual width +VDR_driver_header.virtual_y = desired virtual heigth +Output: +bx = mode descriptor bits +cx = actual screen width +dx = actual screen height +VDR_driver_header.virtual_x = actual virtual width +VDR_driver_header.virtual_y = actual virtual heigth + +Inquire driver header linear address: +Input: +ax = 0xfffe +Output: +eax = linear address of driver header in real memory. (Add 0xe0000000 + when used in non-DPMI modes of the extender). Use this buffer + for passing the virtual screen parameters to the driver. + +Call driver paging function in real mode: +Input: +ax = 0xfffd +bl = read page +bh = write page +Output: none + +Set displayed screen start when virtual screen > displayed screen +Input: +ax = 0xfffc +cx = X position +dx = Y position +Output: none + + diff --git a/thirdparty/grx249/doc/old/install.doc b/thirdparty/grx249/doc/old/install.doc new file mode 100644 index 0000000..f28c2cd --- /dev/null +++ b/thirdparty/grx249/doc/old/install.doc @@ -0,0 +1,511 @@ +THIS FILE IS UNDER CONSTRUCTION!!!! + +After you un-zip the GRX archive you need to do the following things to +use it: + +Set two environment variables: + +1) SET GRX20DRV= gw gh nc +2) SET GRXFONT= + +Available drivers are: + + stdvga + stdega + et4000 + cl5426 + mach64 + ati28800 + VESA + +After setting these you may run "bin/modetest" to see what modes you have. + +To compile and link a program you need to make sure that the compiler +"sees" the "include" and "lib" directories of the GRX20 package. Either +use the -I and -L compiler switches with these directories or copy +the files from these dirs to a standard place. + + +====================== don't read after this ======================== + + + +Abstract +======== + +This document contains information necessary for rebuilding +the LIBGRX graphics library. Additionally, it describes some internal +details of the library associated with way it accesses the video RAM. This +info might be useful for adding support for new graphics adapter types. + + +How to rebuild the library +========================== + +The LIBGRX library is built using the Turbo C MAKE. (TC++ 1.01 +professional was used.) If an other MAKE has to be used it has to provide +some method for generating response files from long command lines. The +makefiles may have to be changed from the Turbo C MAKE response file +syntax to the syntax of the new MAKE. Additionally, the Turbo C MAKE +provides a C preprocessor-like conditional syntax. If the new MAKE utility +does not support this, the desired option has to be hard-coded. + +The makefile in the base directory of the package (typically it is +....djgpp\contrib\libgrx) can be invoked as follows: + + 1) make build DJGPP libraries, and the drivers + 2) make turboc build Turbo C libraries + 3) make test (1+) build DJGPP test programs + 4) make turbotst (2+) build Turbo C test programs + 5) make install copy .h and .a files into DJGPP dirs + 6) make clean clean up after recompiling + +All graphics library sources are in the 'src' directory. The makefile +in that directory can also be used to build a customized version of the +library. Customized libraries (and the executable built using them) can be +smaller, because they don't include support for all video RAM access +methods. (see later) The makefile in the src directory can be used as +follows: + + make -DPLANES= + -- or -- + make -DPLANES= [-DMODEL=] turboc + +The value of the PLANES macro determines the included video RAM access +methods. This is a number obtained by OR-ing together the following +values: + + 1 monochrome (Hercules) + 4 16 color EGA/VGA/SVGA + 8 256 color VGA/SVGA + 16 32768 color SVGA + 32 256 color plane mode (mode X) + +For example: + + make -DPLANES=12 + +will build a DJGPP library which only includes support for 16 and 256 +color video modes. + +To rebuild the Turbo C version of the library a copy of TASM is also +needed, as the library contains a significant amount of in-line assembly +code. + + +Compiling the test programs +=========================== + +The makefile in the test directory accepts the following arguments: + + 1) make build all DJGPP test programs + 2) make turboc build all Turbo C test programs + 3) make . build a single DJGPP test program + 4) make .exe build a single Turbo C test program + +See the accompanying document "tests.doc" on how to run the test programs. + + +Low-level video RAM access support +================================== + +When 'GrSetMode' is called it finally ends up making a call to the mode +set routine of the graphics driver which knows about the capabilities of +the card, and how to put the card into the desired mode. (This is card +dependent -- that's why there are so many drivers.) + +Having done this, the driver returns a status word to the library +which specifies the MEMORY ORGANIZATION of the selected graphics mode. +There are MUCH FEWER possible memory organizations than video drivers. The +currently supported memory organizations in LIBGRX are the following: + + 256 color VGA + 16 color EGA/VGA/SVGA + 32768 color SVGA + 8514/A and S3 hardware accelerated video RAM access + +The following two memory organizations are not supported yet, but stubs +have been included for them in the library: + + monochrome (Hercules, CGA 640x200 mode, EGA, VGA) + VGA 256 color plane-oriented (Mode X, Y...) + +The driver status word is used to set up some global variables +describing the layout of the video memory, the number of colors, etc.. The +library contains different low-level video RAM access routines for the +different video RAM organizations. These low-level video RAM access +routines are called indirectly via function pointers. These function +pointers are set up when a graphics primitive first attempts to use them. +This means that an attempt to draw anything before the first call to +'GrSetMode' will fail miserably as the library will has no idea about the +video access method to be used. + +The library source files containing the memory mode specific functions +are named as follows: + + p1*.c - monochrome (currently dummies only) + p4*.c - EGA/VGA 16 color modes + p8*.c - VGA 256 color modes + ph*.c - VGA 32768 color mode + px*.c - VGA 256 color mode X (currently dummies only) + pi*.c - 8514/A and S3 256 color mode + ps*.c - a few additional S3 routines where its programming + differs from the 8514/A + +Each memory mode access group contains ten files (one function in each) +which do the following: + + p?init.c - global data and possibly an init function + p?pixset.c - set a single pixel + p?pixrd.c - read a single pixel + p?pixrow.c - set a pixel row + p?pixcol.c - set a pixel column + p?pixblk.c - set a rectangular pixel block + p?bitblt.c - copy a rectangular pixel block + p?line.c - draw a line + p?char.c - draw a character + p?fillp.c - fill a pixel row with a pattern + +The library does all mode-specific video RAM access through these nine +functions. There is a small amount of mode specific code related to +setup and color management in the files "setmode.c", "layout.c", +"context.c" and "colors.c", other than these the rest of the library +(drawing functions, etc..) is video RAM organization independent. + +If the library was built to support only a single memory organization +then the calls to the appropriate low-level functions are hard-coded into +the code (via preprocessor macros in "libgrx.h"). Additionally, in 256 and +32768 color modes some trivial pixel manipulations (read and set a single +pixel) are expanded in-line. + +If the library supports more than one video RAM model then this +in-line expansion is not done, and all low-level access functions are +called via pointers. There is a dispatch routine for every low-level +service (in the files "sw*.c"). The pointers initially point to these +dispatch routines. When a dispatch routine is first called it puts the +address of the appropriate (i.e. corresponding to the current video mode) +low-level access function into the pointer and then calls it. This way the +dispatch routine gets called only the first time a video RAM access +function is used. A call to 'GrSetMode' resets the pointers to point to +the dispatch routines. + +NOTE: The Turbo C low-level video RAM access routines do not support +paging. (Actually, the 32 bit routines do not support it either because it +is handled transparently by the 386's page fault mechanism and the DOS +extender.) For this reason the Turbo C version has a resolution +limitation: 320x200 in 256 color mode and 800x600 in 16 color mode. For +the same reason there is no support for the 32768 color modes in the +Turbo C version of the library. HOWEVER: the 8514/A and S3 accelerators +do not need direct video RAM access and paging. For this reason the +full resolution of these boards (1024x768x256) can be supported even in the +Turbo C version of the library. + + + + + + + + Abstract + + This document describes the graphics driver format used for DJGPP and the + LIBGRX graphics library. It also gives hints for creating a driver for an + unsupported display adapter. + + Introduction + + The DJGPP graphics drivers do two things: + + (1) Invoke the BIOS INT 10 routine for setting up the desired graphics mode. + Different boards support different resolutions and use different mode + numbers -- that's why different drivers are needed for different boards. + + (2) Implement page mapping for video modes which use more than 64K of video + memory. This is again board dependent. + + Old driver format + + The following C declarations describe the header of an old format DJGPP + graphics driver. Of course, real drivers are coded in assembly. + + typedef unsigned short u_short; + typedef unsigned char u_char; + + struct old_driver_header { + u_short mode_set_routine_offset; + u_short paging_routine_offset; + u_short paging_mode_flag; /* 0 if no separate R/W, 1 if yes */ + u_short default_text_width; + u_short default_text_height; + u_short default_graphics_width; + u_short default_graphics_height; + }; + + The mode set routine does the following: + + ;-------------------------------------------------------------------------- + ; Entry: AX=mode selection + ; 0=80x25 text + ; 1=default text + ; 2=text CX cols by DX rows + ; 3=biggest text + ; 4=320x200 graphics + ; 5=default graphics + ; 6=graphics CX width by DX height + ; 7=biggest non-interlaced graphics + ; 8=biggest graphics + ; CX=width (in pixels or characters) (not always used -- depends on AX) + ; DX=height + ; + ; NOTE: This runs in real mode, but don't mess with the segment registers. + ; + ; Exit: CX=width (in pixels or characters) + + + + + + ; DX=height + ;-------------------------------------------------------------------------- + + The paging routine does the following: + + ;-------------------------------------------------------------------------- + ; Entry: AH=read page + ; AL=write page + ; + ; NOTE: This runs in protected mode! Don't mess with the segment registers! + ; This code must be relocatable and may not reference any data! + ; + ; Exit: VGA configured. + ; AX,BX,CX,DX,SI,DI may be trashed + ;-------------------------------------------------------------------------- + + The old style graphics driver structure remained unchanged for the first 16 + color drivers developed for LIBGRX. The only difference is that the additional + 15 bits in the third word of the header were given new meanings. (The 256 + color DJGPP library only used one bit to encode the capability to map + different pages for reading and writing.) The values of these new bitfields + were assigned as to stay compatible with the existing 256 color drivers. (I.e. + the 0 value in every bitfield selects the 256 color VGA option.) The + definition of these bits (from "grdriver.h"): + + #define GRD_NEW_DRIVER 0x0008 /* NEW FORMAT DRIVER IF THIS IS SET */ + + #define GRD_PAGING_MASK 0x0007 /* mask for paging modes */ + #define GRD_NO_RW 0x0000 /* standard paging, no separate R/W */ + #define GRD_RW_64K 0x0001 /* two separate 64K R/W pages */ + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + /* THE FOLLOWING THREE OPTIONS ARE NOT SUPPORTED AT THIS TIME */ + #define GRD_RW_32K 0x0002 /* two separate 32Kb pages */ + #define GRD_MAP_128K 0x0003 /* 128Kb memory map -- some Tridents + can do it (1024x768x16 without + paging!!!) + #define GRD_MAP_EXTMEM 0x0004 /* Can be mapped extended, above 1M. + Some Tseng 4000-s can do it, NO + PAGING AT ALL!!!! */ + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + + #define GRD_TYPE_MASK 0xf000 /* adapter type mask */ + #define GRD_VGA 0x0000 /* vga */ + #define GRD_EGA 0x1000 /* ega */ + #define GRD_HERC 0x2000 /* hercules */ + #define GRD_8514A 0x3000 /* 8514/A or compatible */ + #define GRD_S3 0x4000 /* S3 graphics accelerator */ + + #define GRD_PLANE_MASK 0x0f00 /* bitplane number mask */ + #define GRD_8_PLANES 0x0000 /* 8 planes = 256 colors */ + #define GRD_4_PLANES 0x0100 /* 4 planes = 16 colors */ + #define GRD_1_PLANE 0x0200 /* 1 plane = 2 colors */ + #define GRD_16_PLANES 0x0300 /* VGA with 32K colors */ + #define GRD_8_X_PLANES 0x0400 /* VGA in mode X w/ 256 colors */ + + + + + + #define GRD_MEM_MASK 0x00f0 /* memory size mask */ + #define GRD_64K 0x0010 /* 64K display memory */ + #define GRD_128K 0x0020 /* 128K display memory */ + #define GRD_256K 0x0030 /* 256K display memory */ + #define GRD_512K 0x0040 /* 512K display memory */ + #define GRD_1024K 0x0050 /* 1MB display memory */ + #define GRD_192K 0x0060 /* 192K -- some 640x480 EGA-s */ + #define GRD_M_NOTSPEC 0x0000 /* memory amount not specified */ + + An old style driver has the 'GRD_NEW_DRIVER' bit cleared. It can work with + previous versions of GO32. Of course for 16 color support the application has + to be linked with the LIBGRX library instead of the original 256 color + library. + + The following additional old format graphics drivers are supplied with the + LIBGRX graphics library: + + EGA16.GRD 16 color EGA driver (640x350x16 max. resolution) + VGA16.GRD 16 color standard VGA driver (640x480x16 max. + resolution) + TSENG4KN.GRD same as DJGPP's Tseng ET 4000 256 color driver, but + with added support for the 100x40 text mode. (max: + 1024x768x256) + TSENG416.GRD Tseng ET 4000 16 color driver. (max: 1024x768x16) + TRID89N.GRD Trident 8900 256 color driver. This driver has an + updated paging routine which seems to fix some + previous problems on boards with recent enough + chipsets. (max: 1024x768x256) + TRID8916.GRD: Trident 8900 16 color driver (max: 1024x768x16) + + + New driver format + + The disadvantage of the old driver format is that the number of colors is not + programmable. The new driver format solves this problem and it also gives the + application program a way to query the driver for a list of the supported text + and graphics modes. For this the driver header was extended as follows: + + struct new_driver_header { + u_short mode_set_routine_offset; + u_short paging_routine_offset; + u_short driver_mode_flag; /* flag word, see bits below */ + u_short default_text_width; + u_short default_text_height; + u_short default_graphics_width; + u_short default_graphics_height; + u_short default_color_number; /* NEW, may be set from environment */ + u_short init_routine_offset; /* NEW, call once after drvr loaded */ + u_short text_mode_table_offset; /* NEW, table of supported text modes */ + u_short graphics_mode_table_offset; /* NEW, table of supported graphics modes */ + }; + + 'text_mode_table_offset' points to a table with entries as follows: + + + + + + struct text_mode_entry { + u_short columns; + u_short rows; + u_short number_of_colors; /* in text mode it is mainly here to make + GCC happy with the alignments */ + u_char BIOS_mode; /* BIOS mode number. Mode not available on + the current card if this field is 0xff. */ + u_char special; /* if non zero then the driver does some + special hacks to set it up (like + the 50 row mode on a standard VGA) */ + }; + + The end of the table is marked by an all 0 entry. The table entries are sorted + by increasing size. The field 'graphics_mode_table_offset' points to a table + with entries as follows: + + struct graphics_mode_entry { + u_short width; + u_short height; + u_short number_of_colors; + u_char BIOS_mode; /* BIOS mode number. Mode not available on + the current card if this field is 0xff. + (This may happen for example if the card + is not fully populated with RAM) */ + u_char special; /* if non zero then the driver does some + special hacks to set it up (like + setting up the 32768 color mode on + some ET4000 cards) */ + }; + + The end of the table is marked by an all 0 entry. The table is sorted by + increasing color number and within the same color modes by increasing size. + + If the driver is of the new type then it also supports an initialization + routine. This is called once after the driver is loaded. The initialization + routine can do one or more of the following: + + (1) Check whether the video card is of the expected type + + (2) Determine the amount of video memory on board. + + (3) Determine which of the modes in the text and graphics mode tables are + actually available (due to video RAM and possibly DAC [32768 colors!!] + limitations) and mark the unavailable entries in the tables. + + To use the new format drivers a recent version of GO32 (1.06, after the middle + of April 1992) has to be used. Such versions should recognize the "nc + " option field in the GO32 environment variable which specifies the + default number of colors for the driver. + + The following new format drivers have been included with the LIBGRX library + (new drivers have the ".GRN" extension): + + STDEGA.GRN standard EGA 16 color driver + + + + + + STDVGA.GRN standard VGA 16 and 256 color driver + ET4000.GRN Tseng ET 4000 16 256 and 32768 color driver + TR8900.GRN Trident 8900 16 and 256 color driver + ATIULTRA.GRN Driver for the ATI ULTRA board. This board actually + contains two graphics adapters: a 512 KByte SVGA board + and a 8514/A compatible accelerator. The driver was + programmed to use the VGA part for text, 16 color + graphics, and low resolution 256 color graphics modes + and the 8514/A part for high resolution 256 color + modes. This driver should work with any VGA+8514/A + (the 8514/A MUST have 1MB memory for 1024x768 + resolution) combination as long as the ATI-specific + modes of the VGA part are not used. + STEALTH.GRN Driver for the Diamond Stealth S3 graphics accelerator + board. The driver was programmed to use VGA-style video RAM + access for text, 16 color graphics, and low resolution 256 + color graphics modes and the S3 accelarator functions for + high resolution 256 color modes. Currently no 32768 color + modes are supported on S3 boards. This driver should work + with other S3-based boards which have a VESA BIOS. + + + Creating a driver for an unsupported board + + You can only use EGA or VGA boards in 16 256 or 32768 color modes with the + graphics library. In the near future there will be support for Hercules boards + as well. SUPPORT IS NOT PLANNED FOR: BOARDS WITH ON-BOARD GRAPHICS PROCESSORS + (TIGA, 8514A, etc...) To create a driver for an unsupported EGA or VGA board + you will need the followings: + + (1) An assembler (TASM or MASM), a linker (TLINK or LINK) and a utility to + convert .EXE files to the .COM format (EXE2BIN). See also the 'makefile' + in the 'drivers' sub-directory. + (2) A documentation of the board containing the supported BIOS mode numbers + and resolutions. + (3) If the driver needs to support modes which use a memory map bigger than + 64K then you also need a piece of code which does page switching on your + board. (Any mode above 800x600 in 16 colors or 320x200 in 256 colors + DOES USE paging.) Possible sources: + - a working, tested 256 color original DJGPP driver (if you just + want to convert it to the new format). + - VGAKIT.ZIP (available from various archive sites, like wuarchive, + simtel, etc...) + - various books on the subject. + + It is best to start with the source of a driver supporting similar resolutions + as your board. Use the proper format driver, i.e. if you want a new format + driver start with a new original, etc... Typically the driver sources are + relatively well commented. What you need to do is: + + (1) possibly change the option word at the head of the driver to indicate + the number of colors (old format only), the amount of memory on board, + the memory mapping capabilities of the board. + (2) change the mode setting code to use the proper BIOS mode numbers. In the + + + + + + old format drivers these are somewhat scattered throughout the code, in + the new format drivers you need to edit a few tables only. + (3) Replace the paging routine with the one suitable for your board. If your + driver supports 16 color resolutions beyond 800x600 then you have to + make sure that upon exit from the paging routine the graphics controller + port's (0x3ce) index register is reset to 8. (See the paging routine in + "TR8900.ASM".) If the paging mechanism does not use any register + accessed through the graphics controller port, then you don't need to + worry about this. \ No newline at end of file diff --git a/thirdparty/grx249/doc/old/internal.doc b/thirdparty/grx249/doc/old/internal.doc new file mode 100644 index 0000000..48d6d83 --- /dev/null +++ b/thirdparty/grx249/doc/old/internal.doc @@ -0,0 +1,487 @@ +THIS FILE IS UNDER CONSTRUCTION!!!!! +DON'T READ IT. IF YOU WANT TO SEE THE INTERNALS OF GRX 2.0 CONSULT THE +SOURCE! + + + + + +Abstract +======== + +This document describes contains information necessary for rebuilding +the LIBGRX graphics library. Additionally, it describes some internal +details of the library associated with way it accesses the video RAM. This +info might be useful for adding support for new graphics adapter types. + + +How to rebuild the library +========================== + +The LIBGRX library is built using the Turbo C MAKE. (TC++ 1.01 +professional was used.) If an other MAKE has to be used it has to provide +some method for generating response files from long command lines. The +makefiles may have to be changed from the Turbo C MAKE response file +syntax to the syntax of the new MAKE. Additionally, the Turbo C MAKE +provides a C preprocessor-like conditional syntax. If the new MAKE utility +does not support this, the desired option has to be hard-coded. + +The makefile in the base directory of the package (typically it is +....djgpp\contrib\libgrx) can be invoked as follows: + + 1) make build DJGPP libraries, and the drivers + 2) make turboc build Turbo C libraries + 3) make test (1+) build DJGPP test programs + 4) make turbotst (2+) build Turbo C test programs + 5) make install copy .h and .a files into DJGPP dirs + 6) make clean clean up after recompiling + +All graphics library sources are in the 'src' directory. The makefile +in that directory can also be used to build a customized version of the +library. Customized libraries (and the executable built using them) can be +smaller, because they don't include support for all video RAM access +methods. (see later) The makefile in the src directory can be used as +follows: + + make -DPLANES= + -- or -- + make -DPLANES= [-DMODEL=] turboc + +The value of the PLANES macro determines the included video RAM access +methods. This is a number obtained by OR-ing together the following +values: + + 1 monochrome (Hercules) + 4 16 color EGA/VGA/SVGA + 8 256 color VGA/SVGA + 16 32768 color SVGA + 32 256 color plane mode (mode X) + +For example: + + make -DPLANES=12 + +will build a DJGPP library which only includes support for 16 and 256 +color video modes. + +To rebuild the Turbo C version of the library a copy of TASM is also +needed, as the library contains a significant amount of in-line assembly +code. + + +Compiling the test programs +=========================== + +The makefile in the test directory accepts the following arguments: + + 1) make build all DJGPP test programs + 2) make turboc build all Turbo C test programs + 3) make . build a single DJGPP test program + 4) make .exe build a single Turbo C test program + +See the accompanying document "tests.doc" on how to run the test programs. + + +Low-level video RAM access support +================================== + +When 'GrSetMode' is called it finally ends up making a call to the mode +set routine of the graphics driver which knows about the capabilities of +the card, and how to put the card into the desired mode. (This is card +dependent -- that's why there are so many drivers.) + +Having done this, the driver returns a status word to the library +which specifies the MEMORY ORGANIZATION of the selected graphics mode. +There are MUCH FEWER possible memory organizations than video drivers. The +currently supported memory organizations in LIBGRX are the following: + + 256 color VGA + 16 color EGA/VGA/SVGA + 32768 color SVGA + 8514/A and S3 hardware accelerated video RAM access + +The following two memory organizations are not supported yet, but stubs +have been included for them in the library: + + monochrome (Hercules, CGA 640x200 mode, EGA, VGA) + VGA 256 color plane-oriented (Mode X, Y...) + +The driver status word is used to set up some global variables +describing the layout of the video memory, the number of colors, etc.. The +library contains different low-level video RAM access routines for the +different video RAM organizations. These low-level video RAM access +routines are called indirectly via function pointers. These function +pointers are set up when a graphics primitive first attempts to use them. +This means that an attempt to draw anything before the first call to +'GrSetMode' will fail miserably as the library will has no idea about the +video access method to be used. + +The library source files containing the memory mode specific functions +are named as follows: + + p1*.c - monochrome (currently dummies only) + p4*.c - EGA/VGA 16 color modes + p8*.c - VGA 256 color modes + ph*.c - VGA 32768 color mode + px*.c - VGA 256 color mode X (currently dummies only) + pi*.c - 8514/A and S3 256 color mode + ps*.c - a few additional S3 routines where its programming + differs from the 8514/A + +Each memory mode access group contains ten files (one function in each) +which do the following: + + p?init.c - global data and possibly an init function + p?pixset.c - set a single pixel + p?pixrd.c - read a single pixel + p?pixrow.c - set a pixel row + p?pixcol.c - set a pixel column + p?pixblk.c - set a rectangular pixel block + p?bitblt.c - copy a rectangular pixel block + p?line.c - draw a line + p?char.c - draw a character + p?fillp.c - fill a pixel row with a pattern + +The library does all mode-specific video RAM access through these nine +functions. There is a small amount of mode specific code related to +setup and color management in the files "setmode.c", "layout.c", +"context.c" and "colors.c", other than these the rest of the library +(drawing functions, etc..) is video RAM organization independent. + +If the library was built to support only a single memory organization +then the calls to the appropriate low-level functions are hard-coded into +the code (via preprocessor macros in "libgrx.h"). Additionally, in 256 and +32768 color modes some trivial pixel manipulations (read and set a single +pixel) are expanded in-line. + +If the library supports more than one video RAM model then this +in-line expansion is not done, and all low-level access functions are +called via pointers. There is a dispatch routine for every low-level +service (in the files "sw*.c"). The pointers initially point to these +dispatch routines. When a dispatch routine is first called it puts the +address of the appropriate (i.e. corresponding to the current video mode) +low-level access function into the pointer and then calls it. This way the +dispatch routine gets called only the first time a video RAM access +function is used. A call to 'GrSetMode' resets the pointers to point to +the dispatch routines. + +NOTE: The Turbo C low-level video RAM access routines do not support +paging. (Actually, the 32 bit routines do not support it either because it +is handled transparently by the 386's page fault mechanism and the DOS +extender.) For this reason the Turbo C version has a resolution +limitation: 320x200 in 256 color mode and 800x600 in 16 color mode. For +the same reason there is no support for the 32768 color modes in the +Turbo C version of the library. HOWEVER: the 8514/A and S3 accelerators +do not need direct video RAM access and paging. For this reason the +full resolution of these boards (1024x768x256) can be supported even in the +Turbo C version of the library. + + + + + + + + Abstract + + This document describes the graphics driver format used for DJGPP and the + LIBGRX graphics library. It also gives hints for creating a driver for an + unsupported display adapter. + + Introduction + + The DJGPP graphics drivers do two things: + + (1) Invoke the BIOS INT 10 routine for setting up the desired graphics mode. + Different boards support different resolutions and use different mode + numbers -- that's why different drivers are needed for different boards. + + (2) Implement page mapping for video modes which use more than 64K of video + memory. This is again board dependent. + + Old driver format + + The following C declarations describe the header of an old format DJGPP + graphics driver. Of course, real drivers are coded in assembly. + + typedef unsigned short u_short; + typedef unsigned char u_char; + + struct old_driver_header { + u_short mode_set_routine_offset; + u_short paging_routine_offset; + u_short paging_mode_flag; /* 0 if no separate R/W, 1 if yes */ + u_short default_text_width; + u_short default_text_height; + u_short default_graphics_width; + u_short default_graphics_height; + }; + + The mode set routine does the following: + + ;-------------------------------------------------------------------------- + ; Entry: AX=mode selection + ; 0=80x25 text + ; 1=default text + ; 2=text CX cols by DX rows + ; 3=biggest text + ; 4=320x200 graphics + ; 5=default graphics + ; 6=graphics CX width by DX height + ; 7=biggest non-interlaced graphics + ; 8=biggest graphics + ; CX=width (in pixels or characters) (not always used -- depends on AX) + ; DX=height + ; + ; NOTE: This runs in real mode, but don't mess with the segment registers. + ; + ; Exit: CX=width (in pixels or characters) + + + + + + ; DX=height + ;-------------------------------------------------------------------------- + + The paging routine does the following: + + ;-------------------------------------------------------------------------- + ; Entry: AH=read page + ; AL=write page + ; + ; NOTE: This runs in protected mode! Don't mess with the segment registers! + ; This code must be relocatable and may not reference any data! + ; + ; Exit: VGA configured. + ; AX,BX,CX,DX,SI,DI may be trashed + ;-------------------------------------------------------------------------- + + The old style graphics driver structure remained unchanged for the first 16 + color drivers developed for LIBGRX. The only difference is that the additional + 15 bits in the third word of the header were given new meanings. (The 256 + color DJGPP library only used one bit to encode the capability to map + different pages for reading and writing.) The values of these new bitfields + were assigned as to stay compatible with the existing 256 color drivers. (I.e. + the 0 value in every bitfield selects the 256 color VGA option.) The + definition of these bits (from "grdriver.h"): + + #define GRD_NEW_DRIVER 0x0008 /* NEW FORMAT DRIVER IF THIS IS SET */ + + #define GRD_PAGING_MASK 0x0007 /* mask for paging modes */ + #define GRD_NO_RW 0x0000 /* standard paging, no separate R/W */ + #define GRD_RW_64K 0x0001 /* two separate 64K R/W pages */ + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + /* THE FOLLOWING THREE OPTIONS ARE NOT SUPPORTED AT THIS TIME */ + #define GRD_RW_32K 0x0002 /* two separate 32Kb pages */ + #define GRD_MAP_128K 0x0003 /* 128Kb memory map -- some Tridents + can do it (1024x768x16 without + paging!!!) + #define GRD_MAP_EXTMEM 0x0004 /* Can be mapped extended, above 1M. + Some Tseng 4000-s can do it, NO + PAGING AT ALL!!!! */ + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + + #define GRD_TYPE_MASK 0xf000 /* adapter type mask */ + #define GRD_VGA 0x0000 /* vga */ + #define GRD_EGA 0x1000 /* ega */ + #define GRD_HERC 0x2000 /* hercules */ + #define GRD_8514A 0x3000 /* 8514/A or compatible */ + #define GRD_S3 0x4000 /* S3 graphics accelerator */ + + #define GRD_PLANE_MASK 0x0f00 /* bitplane number mask */ + #define GRD_8_PLANES 0x0000 /* 8 planes = 256 colors */ + #define GRD_4_PLANES 0x0100 /* 4 planes = 16 colors */ + #define GRD_1_PLANE 0x0200 /* 1 plane = 2 colors */ + #define GRD_16_PLANES 0x0300 /* VGA with 32K colors */ + #define GRD_8_X_PLANES 0x0400 /* VGA in mode X w/ 256 colors */ + + + + + + #define GRD_MEM_MASK 0x00f0 /* memory size mask */ + #define GRD_64K 0x0010 /* 64K display memory */ + #define GRD_128K 0x0020 /* 128K display memory */ + #define GRD_256K 0x0030 /* 256K display memory */ + #define GRD_512K 0x0040 /* 512K display memory */ + #define GRD_1024K 0x0050 /* 1MB display memory */ + #define GRD_192K 0x0060 /* 192K -- some 640x480 EGA-s */ + #define GRD_M_NOTSPEC 0x0000 /* memory amount not specified */ + + An old style driver has the 'GRD_NEW_DRIVER' bit cleared. It can work with + previous versions of GO32. Of course for 16 color support the application has + to be linked with the LIBGRX library instead of the original 256 color + library. + + The following additional old format graphics drivers are supplied with the + LIBGRX graphics library: + + EGA16.GRD 16 color EGA driver (640x350x16 max. resolution) + VGA16.GRD 16 color standard VGA driver (640x480x16 max. + resolution) + TSENG4KN.GRD same as DJGPP's Tseng ET 4000 256 color driver, but + with added support for the 100x40 text mode. (max: + 1024x768x256) + TSENG416.GRD Tseng ET 4000 16 color driver. (max: 1024x768x16) + TRID89N.GRD Trident 8900 256 color driver. This driver has an + updated paging routine which seems to fix some + previous problems on boards with recent enough + chipsets. (max: 1024x768x256) + TRID8916.GRD: Trident 8900 16 color driver (max: 1024x768x16) + + + New driver format + + The disadvantage of the old driver format is that the number of colors is not + programmable. The new driver format solves this problem and it also gives the + application program a way to query the driver for a list of the supported text + and graphics modes. For this the driver header was extended as follows: + + struct new_driver_header { + u_short mode_set_routine_offset; + u_short paging_routine_offset; + u_short driver_mode_flag; /* flag word, see bits below */ + u_short default_text_width; + u_short default_text_height; + u_short default_graphics_width; + u_short default_graphics_height; + u_short default_color_number; /* NEW, may be set from environment */ + u_short init_routine_offset; /* NEW, call once after drvr loaded */ + u_short text_mode_table_offset; /* NEW, table of supported text modes */ + u_short graphics_mode_table_offset; /* NEW, table of supported graphics modes */ + }; + + 'text_mode_table_offset' points to a table with entries as follows: + + + + + + struct text_mode_entry { + u_short columns; + u_short rows; + u_short number_of_colors; /* in text mode it is mainly here to make + GCC happy with the alignments */ + u_char BIOS_mode; /* BIOS mode number. Mode not available on + the current card if this field is 0xff. */ + u_char special; /* if non zero then the driver does some + special hacks to set it up (like + the 50 row mode on a standard VGA) */ + }; + + The end of the table is marked by an all 0 entry. The table entries are sorted + by increasing size. The field 'graphics_mode_table_offset' points to a table + with entries as follows: + + struct graphics_mode_entry { + u_short width; + u_short height; + u_short number_of_colors; + u_char BIOS_mode; /* BIOS mode number. Mode not available on + the current card if this field is 0xff. + (This may happen for example if the card + is not fully populated with RAM) */ + u_char special; /* if non zero then the driver does some + special hacks to set it up (like + setting up the 32768 color mode on + some ET4000 cards) */ + }; + + The end of the table is marked by an all 0 entry. The table is sorted by + increasing color number and within the same color modes by increasing size. + + If the driver is of the new type then it also supports an initialization + routine. This is called once after the driver is loaded. The initialization + routine can do one or more of the following: + + (1) Check whether the video card is of the expected type + + (2) Determine the amount of video memory on board. + + (3) Determine which of the modes in the text and graphics mode tables are + actually available (due to video RAM and possibly DAC [32768 colors!!] + limitations) and mark the unavailable entries in the tables. + + To use the new format drivers a recent version of GO32 (1.06, after the middle + of April 1992) has to be used. Such versions should recognize the "nc + " option field in the GO32 environment variable which specifies the + default number of colors for the driver. + + The following new format drivers have been included with the LIBGRX library + (new drivers have the ".GRN" extension): + + STDEGA.GRN standard EGA 16 color driver + + + + + + STDVGA.GRN standard VGA 16 and 256 color driver + ET4000.GRN Tseng ET 4000 16 256 and 32768 color driver + TR8900.GRN Trident 8900 16 and 256 color driver + ATIULTRA.GRN Driver for the ATI ULTRA board. This board actually + contains two graphics adapters: a 512 KByte SVGA board + and a 8514/A compatible accelerator. The driver was + programmed to use the VGA part for text, 16 color + graphics, and low resolution 256 color graphics modes + and the 8514/A part for high resolution 256 color + modes. This driver should work with any VGA+8514/A + (the 8514/A MUST have 1MB memory for 1024x768 + resolution) combination as long as the ATI-specific + modes of the VGA part are not used. + STEALTH.GRN Driver for the Diamond Stealth S3 graphics accelerator + board. The driver was programmed to use VGA-style video RAM + access for text, 16 color graphics, and low resolution 256 + color graphics modes and the S3 accelarator functions for + high resolution 256 color modes. Currently no 32768 color + modes are supported on S3 boards. This driver should work + with other S3-based boards which have a VESA BIOS. + + + Creating a driver for an unsupported board + + You can only use EGA or VGA boards in 16 256 or 32768 color modes with the + graphics library. In the near future there will be support for Hercules boards + as well. SUPPORT IS NOT PLANNED FOR: BOARDS WITH ON-BOARD GRAPHICS PROCESSORS + (TIGA, 8514A, etc...) To create a driver for an unsupported EGA or VGA board + you will need the followings: + + (1) An assembler (TASM or MASM), a linker (TLINK or LINK) and a utility to + convert .EXE files to the .COM format (EXE2BIN). See also the 'makefile' + in the 'drivers' sub-directory. + (2) A documentation of the board containing the supported BIOS mode numbers + and resolutions. + (3) If the driver needs to support modes which use a memory map bigger than + 64K then you also need a piece of code which does page switching on your + board. (Any mode above 800x600 in 16 colors or 320x200 in 256 colors + DOES USE paging.) Possible sources: + - a working, tested 256 color original DJGPP driver (if you just + want to convert it to the new format). + - VGAKIT.ZIP (available from various archive sites, like wuarchive, + simtel, etc...) + - various books on the subject. + + It is best to start with the source of a driver supporting similar resolutions + as your board. Use the proper format driver, i.e. if you want a new format + driver start with a new original, etc... Typically the driver sources are + relatively well commented. What you need to do is: + + (1) possibly change the option word at the head of the driver to indicate + the number of colors (old format only), the amount of memory on board, + the memory mapping capabilities of the board. + (2) change the mode setting code to use the proper BIOS mode numbers. In the + + + + + + old format drivers these are somewhat scattered throughout the code, in + the new format drivers you need to edit a few tables only. + (3) Replace the paging routine with the one suitable for your board. If your + driver supports 16 color resolutions beyond 800x600 then you have to + make sure that upon exit from the paging routine the graphics controller + port's (0x3ce) index register is reset to 8. (See the paging routine in + "TR8900.ASM".) If the paging mechanism does not use any register + accessed through the graphics controller port, then you don't need to + worry about this. \ No newline at end of file diff --git a/thirdparty/grx249/doc/old/readme.20 b/thirdparty/grx249/doc/old/readme.20 new file mode 100644 index 0000000..dd1c063 --- /dev/null +++ b/thirdparty/grx249/doc/old/readme.20 @@ -0,0 +1,104 @@ +**************** +** README.NEW ** +**************** + +Introduction +------------ + +This is an updated (beta) version of the GRX v2.0 graphics library. + +New features are : + + - Pattern Filled functions + + ex.: GrPatternFilledCircle(xc,yc,r,p); + + - Patterned Line functions + + ex.: GrPatternedCircle(xc,yc,r,lp); + + - Custom Line functions + + ex.: GrCustomLine(x1,y1,x2,y2,lo); + + - User Coordinates functions + + ex.: GrUsrFilledEllipse(xc,yc,xa,ya,c); + +These features have been ported to GRX v2.0 from previous versions +in the GRX v1.03. However some functions had to be entirely rewritten +for compatibility with the new version of the library. + +For more informations on these functions, see the documentation located +in the 'doc/' subdirectory, or edit the 'grx20.h' file to see how to use +the functions. + + +Library +------- + +A compiled version of the library (with Djgpp v2.01) is supplied with +this upgrade and is located in the lib/ subdirectory as the 'libgrx20.a' +file. The file 'libgrx20.bk2' also present is a backup of the library +of the previous version of GRX20 (without the new features). + +The library can be recompiled by 'make' in the root directory : + + make libs + +If you don't want these new features, you can compile the previous +version of the library with the command line + + make previous + +In case of bugs, this can be useful. + +After compiling the library, you can clean the directory (by deleting +all the objects files in the 'src/' subdirectory with the command line + + make clean + +so you keep only the archive file on your disk. It can save a little +amount of memory. + + +Installing +---------- + +With the line command + + make install + +in the root directory of GRX20 'make' will copy the include files in the +'include/' directory of DJGPP and the library file in the 'lib/' directory. + + +Testing +------- + +For compiling the tests programs, just type the line command + + make test + +This will compile the library and the tests programs supplied in the +'test/' subdirectory of GRX20. These tests are those supplied with the +previous version. No tests are already available for the new features +of the library. But testing these shouldn't be very difficult ... + +Check your bookmarks, maybe I can release some tests soon ! + + +Conclusion +---------- + +I have not completely tested the library, but it passed all the tests +I made on it (and there were a lot of tests). However, if you encounter +some problems in using these new functions, you may contact me at this +address : + goffioul@emic.ucl.ac.be + +Please send the most reduced code which shows the bug with your message, +so I can test it for myself. + +I hope you'll enjoy these new features which I missed sometimes (and +I think I was not the only one ...). diff --git a/thirdparty/grx249/doc/old/readme.22 b/thirdparty/grx249/doc/old/readme.22 new file mode 100644 index 0000000..6ba1e27 --- /dev/null +++ b/thirdparty/grx249/doc/old/readme.22 @@ -0,0 +1,157 @@ +Hi, + +the official public release GRX v2.2 is available from + + http://www.techfak.uni-kiel.de/~hsc/GRX/grx22.zip + +and soon from any SimTel mirror in the DJGPP/v2tk +directory. + +Thanks to a lot of work by + + Csaba Biegl (csaba@vuse.vanderbilt.edu) + +of course and + + Mauro Condarelli (mc5686@mclink.it) + Christian Domp (alma.student.uni-kl.de) + Michael Goffioul (goffioul@emic.ucl.ac.be) + Sven Hilscher (Sven@rufus.central.de) + Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + Ulrich Leodolter (ulrich@lab1.psy.univie.ac.at) + Hartmut Schirmer (hsc@techfak.uni-kiel.de) + Daniel Skarda (0rfelyus@atrey.karlin.mff.cuni.cz) + +and others (see doc/credits.doc) the GRX library is now +greatly enhanced. + + +Compared with the grx20.zip from DJ-dirs this release provides: +--------------------------------------------------------------- + - user coordinates (by Michael) + - pattern filling (by Michael) + - custom lines (by Michael) + - Linux support [svgalib && X11 (Ulrich) support and other + things Csaba mentions in credits.doc ] + - reorganized font support (Csaba) + - linkable bitmap fonts (Csaba) + - Borland vector fonts (Csaba) + - VESA 2.0 and svgalib linear frame buffer support + - VESA 2.0 8bit DAC support + - various driver speed ups + - slightly changed color interface (by Michael for better + MGUI support) + - GNU-Pascal support (by Sven) + + +What's currently untested: +-------------------------- + - LFB32H frame driver + - svgalib linear frame buffer support + - X11 driver is supposed to work but couldn't test this + - svgalib/X11 on non i386 platforms + + +What's missing: +--------------- + - documentation + - VESA 2.0 protected mode virtual screen support + + +Installation for DJGPP: +----------------------- + Unpack the grx22.zip archive in your DJGPP v2 root directory + by 'pkunzip -d grx22.zip' or 'unzip grx22.zip' + + Edit your DJGPP.ENV file. + a. delete all references to GRX v2.0 or v2.1 + b. In the [cpp] section append + ;%DJDIR%/contrib/grx22/include + to C_INCLUDE_PATH and CPLUS_INCLUDE_PATH variables + c. In the [gcc] section append + ;%DJDIR%/contrib/grx22/lib + to the LIBRARY_PATH entry + d. GNU-Pascal users need to change [gpc-cpp] and + [gpc] sections too. + e. Make sure the GRXFONT environment variable is set, + otherwise add + +GRXFONT=%DJDIR%/contrib/grx22/fonts + at top of DJGPP.ENV + + Check GRX v2.2 + a. go to DJDIR/contrib/grx22 and check makedefs.gnu and + makedefs.dj2 for your system requirements (default + should work well on average system ) + b. go to the test subdir and build the test files: + make -f makefile.dj2 + c. run the tests + + Recompile your own programs with GRX v2.2! + + +Installation for Linux: +----------------------- + Unpack the grx22.zip archive in a temporary directory + using 'unzip -L -a grx22.zip'. Make sure all .fnt + files where extracted in binary mode! Go to contrib + subdir and move the grx22 tree to /usr/src + + Delete the DJGPP .a file in the grx22/lib subdir. + + Many GRX based programs need to access the font file. + Either make the /usr/src/grx22/fonts subdir readable + to anyone running GRX programs or copy the fonts subdir + to a place where anyone can access it (I placed the + fonts in /usr/local/grx-fonts on my system) + Make sure the GRXFONT environment variable points to + the fonts directory. + + In /usr/src/grx22 check the default settings in + makedefs.gnu and makedefs.x11 + + To build the SVGALIB based GRX v2.2 run + make -f makefile.lnx + + To build the X11 based GRX v2.2 run + make -f makefile.x11 + + Check the by running the (static linked) test programs. + + If everything works well, copy the .a and .so library + files to a system lib dir, eg. /usr/local/lib and + generate symbolic links for the shared libraries: + libgrx20.so -> libgrx20.so.2.2.0 + libgrx20X.so -> libgrx20X.so.2.2.0 + + Copy the files from grx22/include and grx22/compat to + an include dir (eg. /usr/local/include) + + Make sure all installed files are readable everyone + compiling/running GRX based programs. + + Now GRX v2.2 should be ready for your programs ! + + +Important: +---------- + + Due to slight changes in grx20.h you'll have to recompile + your programs. Just relinking it won't work in most cases. + + +Help: +----- +If you find a bug in GRX v2.2, if GRX doesn't work on +your system or if you have any other question concerning +GRX, please contact me by e-mail: + + hsc@techfak.uni-kiel.de + +For DJGPP based systems you might also check the DJGPP +news group: + + comp.os.msdos.djgpp + + + +Hartmut Schirmer diff --git a/thirdparty/grx249/doc/old/readme.23 b/thirdparty/grx249/doc/old/readme.23 new file mode 100644 index 0000000..d8909a9 --- /dev/null +++ b/thirdparty/grx249/doc/old/readme.23 @@ -0,0 +1,120 @@ +GRX installation instructions +============================= + +Requirements: +------------- + + The source files: grx23.zip + The fonts : grx23fnt.zip + This document : grx23rme.1st + + Currently GRX directly supports the following platforms: + + DOS / DJGPP v1.12 (GCC 2.6.3) + DOS / DJGPP v2.01 (GCC 2.6.3, 2.7.2 and 2.8.1) + DOS / Borland C++ (v2.0, v3.1 and v4.52 checked) + DOS / Turbo C (v1.0) + DOS / Watcom C++ (v11.0 checked, 32bit only) + Linux / svgalib (GCC 2.7.2, 2.8.1) + Linux / X11R6 (GCC 2.7.2, 2.8.1) + Solaris / X11R5 (GCC 2.7.2, SUN cc v4.1) + + GRX should work on any X11R5 (or later) system after a few + changes in makedefs.gnu and makedefs.x11 + + Most makefiles (DJGPP and Unix systems) require GNU make + + +A. Unzip the GRX archives +------------------------- + + 1) create a directory for the GRX file tree. Examples: + DJGPP: eg. DJGPP/contrib/grx23 + Linux: /usr/src/grx-2.3 + 2) unzip the GRX source archive in the GRX dir: + DOS : pkunzip -d grx23.zip + Unix : unzip grx23.zip + 3) unzip the GRX font archive in the same base dir: + DOS : pkunzip -d grx2fnt.zip + Unix : unzip grx2fnt.zip + + +B. Set the environment variables +-------------------------------- + + 1) set the default driver and graphics mode info: + SET GRX20DRV= gw gh nc + (very useful but not required) + Available drivers are for + DOS : stdvga, stdega, et4000, cl5426, mach64, ati28800, VESA, + memory + Linux: svgalib, memory + X11 : xwin, memory + + 2) set the GRX font dir. + SET GRXFONT= + This is required for GRX graphics text output. Path: /fonts + NOTE: You can define a default font directory when compiling GRX. + E.g, if you installed the fonts in /usr/local/lib/grx/fonts add + CCOPT += -DGRX_DEFAULT_FONT_PATH=\"/usr/local/lib/grx/fonts\" + to makedefs.gnu (Linux / GNU-make example) + + +C. Compiling GRX +---------------- + + This is only required if there's no pre-compiled GRX for your system + or you want to change GRX or the library configuration. + + 1) Go to GRX base dir and check the makefile and makedefs file + for your system setup + 2) Switch to src sub dir and check the makefile + 3) run make -f + (some system may need additional arguments here !) + 4) if every thing worked fine go to /test, check the makefile + and build all test files / examples: + make -f + + +D. Testing GRX +-------------- + + 1) go to /bin and run the modetest program. If you don't have + a modetest (or modtst16) binary, do step C4 first. + 2) Build and run the other examples (see C4) + + +E. Installing GRX for your compiler +----------------------------------- + + You'll either need to 1: copy some GRX files to places where your compiler + will find them or 2: change your compiler setup so it will find the GRX + files in there default place. + + 1) Copy the library from /lib/ to the compiler + library directory. + Copy the header files from /include to your compiler include + directory + 2) See compiler documentation. Either change the default compiler behaviour + (eg., change djgpp.env) or use command line switches to tell the + compiler where to find the GRX files. + + +F. Problems +----------- + + If you have problems installing or running GRX check + + http://www.techfak.uni-kiel.de/~hsc/GRX/ + + for updates, pre-compiled libs, ... + + If this doesn't help, check your system/compiler FAQ (eg., the + DJGPP v2 FAQ is at http://www.delorie.com/djgpp/v2faq) + + Check out the DJGPP newsgroup comp.os.msdos.djgpp (archive at + http://www.delorie.com/djgpp/mail-archives) + + Send a problem report to comp.os.msdos.djgpp or me + (hsc@techfak.uni-kiel.de) + diff --git a/thirdparty/grx249/doc/old/tests.doc b/thirdparty/grx249/doc/old/tests.doc new file mode 100644 index 0000000..dd84e36 --- /dev/null +++ b/thirdparty/grx249/doc/old/tests.doc @@ -0,0 +1,76 @@ +Introduction +============ + +This document gives a brief description of the test programs in the +'tests' sub-directory. + +The test programs were not intended as a flashy demo of the capabilities +of LIBGRX. Their purpose is to test the various services of the library. +The general syntax of their usage is: + + go32 [ []] + -- or for the Turbo C tests -- + [ []] + +The test programs typically display several screens, hitting any key +will advance to the next screen. In a few cases the keyboard is used +differently, these programs will be described below. + + +Description of the test programs: +================================= + + MODETEST: + perform video adapter speed test and test the basic primitives + of the library. + + WINTEST, WINCLIP, CLIPTEST: + test graphics contexts sub-contexts and clipping + + FRAMTEST: + demo of the framed box primitive + + BLITTEST: + test the bit block transfer function. First it tests the bitblt + primitive for 64 possible alignment cases in planar modes (8 + possible alignments for the source and destination each). It does + this test both for forward and backward copy (it depends on + whether the source address is bigger than the destination) and + for a system RAM graphics context source. A wide and a narrow + test pattern is used. After finishing the basic tests the program + gives a demo of tiling the screen with a pattern similar to the + one in FRAMTEST. + + RGBTEST: + tests the 256 color RGB mode. + + COLOROPS: + tests the four write modes: SET, XOR, OR, AND + + CURSTEST: + tests the graphics cursor drawing routines, Keyboard usage: + u U (up) \ + d D (down) move the cursor + l L (left) capitals faster + r R (right) / + q exit program + + MOUSETST: + test the mouse cursor and the rubberband cursor options. + + POLYTEST: + test the polygon filling algorithm. It takes the coordinates + of the polygons from the data file "polytest.dat" + + CIRCTEST: + test the circle drawing algorithm with a circle, horizontal and + vertical main axis ellipse. It draws the exact points (calculated + using FP arithmetics) in red. The 'q' key aborts the test. + + TESTPATT: + tests the pattern filled graphics primitives. + + +NOTE: these programs can also be used as examples for the usage of the +library. As always: CONSULT THE SOURCE!!!! + diff --git a/thirdparty/grx249/doc/problems.htm b/thirdparty/grx249/doc/problems.htm new file mode 100644 index 0000000..4927a7c --- /dev/null +++ b/thirdparty/grx249/doc/problems.htm @@ -0,0 +1,80 @@ + + + + + +

Known GRX problems and things that must be improved

+

General:

+
    +
  • The memory driver allocates all planes in one chunk instead +of using real planes. +

    +
  • +
  • Printing in 1200dpi on Laserjet supporting PCL6 doesn't work. +
  • +
+

Win32 driver:

+
    +
  • Drawline can be faster. Now when we paint a long diagonal line, +the +invalidate rect is very big. +

    +
  • +
  • Add a 16 bpp framedriver. +

    +
  • +
  • The printing code doesn't work correctly. +
  • +
+

X11 driver:

+
    +
  • Try to make GrPixel faster. +

    +
  • +
  • The driver can't respond to PAINT events, so it has problems with +XFree86 v4 because the backing-store is not enabled by default. The +best solution is to have a context to save the actual window (and the +GrPixel problem can be solved too). The workaround is to add next lines +to the /etc/X11/XF86Config-4 file, in the Device section: +

    Option "BackingStore" +

    +

    Option "SaveUnders" +

    +
  • +
+

Linux console framebuffer driver:

+
    +
  • Try to change modes if the underlaying framebuffer driver allow +it. +

    +
  • +
  • Complete the alternate direct mouse driver (now it only handles +PS/2 and IMPS2 mice). +

    +
  • +
  • Use the alternate input driver even when the Svgalib driver is +included, +so virtual consoles can be switched. +
  • +
+

Linux console SVGALIB driver:

+
    +
  • Nedded alternate framedrivers for 1 and 4 bpp modes. The actual +ones are +using inport/outport instructions and doesn't work with svgalib 1.9.x +and +even with 1.4.x if the linux framebuffer is enabled. +

    +
  • +
+

VGA DOS driver:

+
    +
  • It can be improved a lot, replacing the generic funtions it uses. +

    +
  • +
  • BitBlt to screen doens't work in 4bpp modes if the screen is not +set as the default context. +
  • +
+ + diff --git a/thirdparty/grx249/doc/readme.bgi b/thirdparty/grx249/doc/readme.bgi new file mode 100644 index 0000000..dafa361 --- /dev/null +++ b/thirdparty/grx249/doc/readme.bgi @@ -0,0 +1,326 @@ + + BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + Copyright (C) 1993-97 by Hartmut Schirmer + Copyright (C) 2002 by Dimitar Zhekov + + This library is now part of the GRX graphics library. + + Contact : grx@gnu.de + +1. Introduction and overview +----------------------------------------------------------------------------- + + The BCC2GRX was created to allow users of LIBGRX to compile graphics + programs written for Borland-C++ and Turbo-C graphics interface. C code + can be directly compiled and linked with BCC2GRX. + + Using LIBGRX based graphics gives you some advantages : + + - 32 bit linear memory model (except for Turbo-C and BCC / DOS) + - high resolution and high color graphics modes supported + - easy way to support new graphics adapters + - LIBGRX and BCC2GRX are free software + - most ported applications run faster + + The current BCC2GRX (v2.3) does only a few error checks since it is + assumed the program was extensively tested before porting it to GRX. + BCC2GRX is not a convenient platform to develop new BGI programs. Of + course you should use native LIBGRX in such cases! + + +2. Differences between BGI and BCC2GRX +----------------------------------------------------------------------------- + + BCC2GRX is based on LIBGRX instead of using an .bgi driver. This + introduces some differences compared with the Borland GI. The (known) + differences are listed below. + + - Most LIBGRX platforms are 32 bit. An int will take 4 bytes instead of + 2 with Turbo-C and BCC for DOS. If you need a 16 bit integer, change + the definition from int to short which is 16 bit on all systems. + - WHITE is a function not constant with BCC2GRX. This may cause + problems in switch () statements. + (You may use + #define WHITE 15 + #include + to improve compatibility.) + - BCC2GRX can not use .bgi drivers. Installing an user driver and the + register(far)bgidriver will always cause an error. + - registerfarbgifont() and registerbgifont() are the same. Both take a + void* to the character font (whole file with header !) + - initgraph()/detectgraph() work slightly different. See below for + details. + - getmodenames() and other functions may be called before initgraph() + - character files won't be flushed at closegraph() + - NOT_PUT isn't supported. + - some constants may differ in value + - BCC2GRX's outtext() and outtextxy() do correct clipping + - some graphics primitives slightly differ in behaviour between BGI and + LIBGRX. Eg. the "saucer" in bccbgi.c putimage()/getimage() demo + looks a little different. + - the BCC2GRX header file is . You must change the #include + statements since BCC2GRX is incompatible with . For + programs compatible with both Borland GI and BCC2GRX, conditional + compilation may be used: + #if defined(__MSDOS__) && defined(__TURBOC__) + # include + #else + # include + #endif + and such programs should be linked with the respective library, + either Borland or GRX (but not both). + - the color constants like REG, GREEN, etc. won't work in graphics + modes with more than 256 colors. Use _ega_color(RED), + _ega_color(GREEN), etc to get the right colors + + +3. Some useful internals of BCC2GRX +----------------------------------------------------------------------------- + + Since LIBGRX provides a flexible and powerful set of graphics primitives, + some of the basic routines are defined within bccgrx.h using "__inline__ + static" functions when using a GNU-C compiler. It compiles these functions + like macros, but you can refer to their addresses. There is one exeption to + this rule: When compiling code based on a pascal program, a macro is used + for getaspectratio since the pascal and C graphics interfaces use different + calling types. + + BGI has something called a 'viewport'. There are two very different + behaviors depending on the clipping flag: + + If clipping is on, one introduces something like a subscreen where + (nearly) all drawing operations are done. + Otherwise the origin of the drawing coordinate system is shifted from + the top left corner to some other point on screen. + + BCC2GRX always adds the origin shift to all operations. If clipping is + requested, GrSetClipBox() is called and LIBGRX restricts drawing to the + selected subscreen. + + One may wonder why BCC2GRX has it's own drawpoly() function instead of + using the LIBGRX function. In BGI a polygon isn't really a polygon but may + be a union of several unconnected closed polygons. In more detail: + + If the start point of a polygon is reached again, the next point + is the start point of a new polygon. No connection line is drawn. + + So one may draw several closed polygons at once. I don't know whether this + behavior of the BGI is a bug or a feature, but BCC2GRX is at least + compatible ... + + +4. initgraph()/detectgraph()/closegraph() +----------------------------------------------------------------------------- + + It's recommended to use something like the following code to + initialize the graphics interface : + + int gd, gm, err; + gd = DETECT; /* or detectgraph(&gd,&gm); */ + initgraph(&gd,&gm,PATH_TO_CHR_FILES); + err = graphresult(); + if (err != grOk) ... + + This code sets up the default graphics mode defined in the GO32 or GRX20DRV + environment variable. This code will work with Borland and GRX based BGI + code without change. BCC2GRX will treat all gd values as 'DETECT' and set + up the GRX default graphics mode. + + BCC2GRX provides two new functions to select the graphics mode: + + void set_BGI_mode(int *graphdriver, int *graphmode); + and + void set_BGI_mode_whc(int *graphdriver, int *graphmode, + int width, int height, int colors); + + If your code requires one of the standard BGI modes, use set_BGI_mode() + with BCC2GRX: + + gd = VGA; gm = VGAHI; + #ifdef __GNUC__ + set_BGI_mode( &gd, &gm); + #endif + initgraph( &gd, &gm, ""); + + All resolutions including the SVGA modes may be set up by calling the + set_BGI_mode_whc() function: + + #ifdef __GNUC__ + set_BGI_mode_whc( &gd, &gm, 640, 480, 1<<24); + #else + /* BCC stuff invoking a SVGA mode, needs nonstd BGI driver */ + #endif + initgraph( &gd, &gm, ""); + + The BCC2GRX requests the desired resolution from LIBGRX by calling + + GrSetMode( GR_width_height_color_graphics, ...) + + If there is no such mode in the current driver, a related one may be set up + by LIBGRX. If you program needs a special resolution (say eg. Hercules + 720x348) you should check getmaxx() and getmaxy() after initgraph(). + + Please note that + - set_BGI_mode(HERCMONO, HERCMONOHI) uses 720x350x16 on VGA cards, + - all drivers != NATIVE_GRX behave like DETECT with BCC2GRX, + - set_BGI_mode[_whc]() sets up local variables used by initgraph() and + setgraphmode(). You may change the resolution after initgraph() done + by + gd = DETECT; + initgraph(&gd, &gm, ""); + /* Default graphics mode */ + .... + #if defined(__TURBOC__) && defined(__MSDOS__) + /* Borland GI stuff to set up 1024x768x256 mode */ + gm = ... ; + #else + set_BGI_mode_whc(&gd, &gm, 1024, 768, 256); + #endif + setgraphmode( gm); + /* Now in 1024x768x256 mode */ + + Starting with BCC2GRX v2.0 there are new functions: + + getmodemaxcolor(int mode), getmodemaxx(int mode), getmodemaxy(int mode) + + which may be called at any time, even before initgraph(). A program may + require true rgb support (32k colors or more) and at least 800x600 pixels. + The new getmodemax*() functions may be used for flexible setup: + + int gd=DETECT, gm; + #if defined(__BCC2GRX__) && (__BCC2GRX__>=0x200) + #define XR 800 + #define YR 600 + #define CR (1<<15) + int lo,hi,x=0,y=0,c=0,i; + detectgraph(&gd,&gm); + getmoderange(gd, &lo, &hi); gm=-1; + for (i=hi;i>=lo;--i) + if (getmodemaxcolor(i)>=CR) { + if (getmodemaxx(i)==XR && getmodemaxy(i)==YR) { + gm = i; /* enough colors and exact geometry */ + break; /* ==> done */ + } + if (getmodemaxx(i)>=XR && getmodemaxy(i)>=YR) + gm = i; + } else break; /* no success */ + if (gm<0) { + puts("Sorry, no sufficient video mode available\n"); + exit(1); + } + #undef XR + #undef YR + #undef CR + #endif + initgraph(&gd,&gm,""); + + The above example exploits the BCC2GRX ordering of modes: + less colors first, less total pixel count earlier, or + decide by horizontal width + Eg.: + 640x480x16 // 16 < 256 available colors + 320x200x256 // 64000 < 128000 total pixel + 640x200x256 // 128000 < 172800 total pixel + 360x480x256 // 360 < 480 horizontal pixel + 480x360x256 // 172800 < 480000 total pixel + 800x600x256 // 256 < 16M available colors + 640x480x16M + + closegraph() doesn't free any allocated memory (eg. vector fonts). + + The paging routines setactivepage() and setvisualpage() are functional for + GRX v2 base BCC2GRX. Just call set_BGI_mode_pages() before calling + initgraph(): + + set_BGI_mode_pages(2); /* 1 or 2 valid ! */ + initgraph(...); + if (graphresult() == grOk && get_BGI_mode_pages() > 1) { + /* Do cool paging stuff */ + } + + You can't check paging without switching into graphics mode! + Translating BCC modes by set_BGI_mode() will disable paging! + + +5. Using fonts +------------------------------------------------------------------------------ + + The BCC2GRX v1.2 or newer can link vector fonts into the .exe file. + The standard fonts are in the libbcc*.a: + + _bold_font, _euro_font, _goth_font, _lcom_font + _litt_font, _sans_font, _scri_font, _simp_font + _trip_font, _tscr_font + + Call registerbgifont() to enable font usage: + + registerbgifont( &_bold_font); + registerbgifont( &_euro_font); + registerbgifont( &_goth_font); + registerbgifont( &_lcom_font); + registerbgifont( &_litt_font); + registerbgifont( &_sans_font); + registerbgifont( &_scri_font); + registerbgifont( &_simp_font); + registerbgifont( &_trip_font); + registerbgifont( &_tscr_font); + + Of course you can also link non standard fonts: + + - copy the .chr file(s) to bcc2grx/src + - goto bcc2grx and type 'make' + - add + extern int __font; + registerbgifont( &__font); + to your source + + The actual BCC2GRX handels the 11 standard and up to 10 user fonts. If you + need more user fonts, you should change the definition of LastUserFont in + text.c! + + Starting with BCC2GRX v1.2 you can also use the LIBGRX bitmapped fonts. + Just get a font handle and set the new text style. Eg. you may want to use + the 8x16 VGA font in high resolution graphics: + + font_handle = installuserfont( "pc8x16.fnt"); + settextstyle( font_handle, HORIZ_DIR, 1); + + See test/ttext.c for more examples. + + Please note that GRX 2.x can't scale bitmap fonts at drawing level any + longer. Before drawing a magnified DEFAULT_FONT, BCC2GRX will first set up + the required new font and keeps a pointer for later use. Due to this, you + might notice a slight delay the first time you request a magnified font. + + The new GRX 2.x may use Borland vector fonts as native fonts. Managing the + resulting bitmap fonts would use much more memory than linking the font + rendering code twice, so I decided not to use the GRX font API. + + Every font will be loaded only once and stay in (virtual) memory until the + program terminates. If this behaviour doesn't work with your program (eg. + something like a font editor) or you get short of memory loading hundreds + of fonts, please tell me about. + + +8. What's new in this release? +----------------------------------------------------------------------------- + + New copyright terms: same license as the rest of GRX. + Updated for GRX 1.03 / .vdr drivers / 64K && 16M color modes + More robust library internal function naming + BLACK now is a constant + Several (minor) bug fixes + Updated for GRX v2 + libbcc.h won't include GRX stuff any more + added version control __BCC2GRX__ + Linux support + setactivepage()/setvisualpage() with GRX v2 + + For a more complete list of changes and new features check src/changes. + + +9. LIBGRX 2.4.5 and later +----------------------------------------------------------------------------- + + Starting with LIBGRX 2.4.5, BCC2GRX supports Turbo-C and BCC. The + documentation has been updated accordingly. diff --git a/thirdparty/grx249/doc/tex/grx2.tex b/thirdparty/grx249/doc/tex/grx2.tex new file mode 100644 index 0000000..b956fb0 --- /dev/null +++ b/thirdparty/grx249/doc/tex/grx2.tex @@ -0,0 +1,31 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header +@setfilename grx249um.inf +@settitle GRX 2.4.9 User's Manual +@c %**end of header + +@dircategory Libraries +@direntry +* GRX: (grx). The GRX Graphics Library. +@end direntry + +@setchapternewpage odd +@paragraphindent 0 + +@titlepage +@sp 10 +@comment The title is printed in a large font. +@title GRX 2.4.9 User's Manual +@subtitle A 2D graphics library for DOS, Linux, X11 and Win32 + +@c The following two commands start the copyright page. +@page +@vskip 0pt plus 1filll + +@end titlepage + +@include grx2_0.tex + +@contents +@bye + diff --git a/thirdparty/grx249/doc/tex/grx2_0.tex b/thirdparty/grx249/doc/tex/grx2_0.tex new file mode 100644 index 0000000..cead19a --- /dev/null +++ b/thirdparty/grx249/doc/tex/grx2_0.tex @@ -0,0 +1,2516 @@ +@ifnottex +@node Top, A User Manual For GRX2, , +@comment node-name, next,previous, up + +@center @majorheading GRX 2.4.9 User's Manual + +@center @chapheading A 2D graphics library for DOS, Linux, X11 and Win32 +@end ifnottex + +@center Based on the original doc written by: Csaba Biegl on August 10, 1992 +@center Updated by: Mariano Alvarez Fernandez on August 17, 2000 +@center Last update: July 10, 2012 + +@unnumbered Abstract + + @strong{GRX} is a 2D graphics library originaly written by +Csaba Biegl for DJ Delorie's DOS port of the GCC compiler. Now it support +a big range of platforms, the main four are: DOS (DJGPPv2), Linux console, +X11 and Win32 (Mingw). On DOS it supports VGA, EGA and VESA compliant cards. +On Linux console it uses svgalib or the framebuffer. On X11 it must work on +any X11R5 (or later). From the 2.4 version, GRX comes with a Win32 driver. +The framebuffer Linux console driver was new in 2.4.2. From 2.4.7 there is a +support for x86_64 bits Linux machines and a support for an SDL driver +on MingW and X11. On MingW and X11 it runs on a window with the original +driver, and either full screen or on a window with the SDL driver. + +@menu +* A User Manual For GRX2:: +@end menu + +@c ----------------------------------------------------------------------------- +@node A User Manual For GRX2, Hello world, Top, Top +@unnumbered GRX2 User's Manual + +@menu +* Top:: +* Hello world:: +* Data types and function declarations:: +* Setting the graphics driver:: +* Setting video modes:: +* Graphics contexts:: +* Context use:: +* Color management:: +* Portable use of a few colors:: +* Graphics primitives:: +* Non-clipping graphics primitives:: +* Customized line drawing:: +* Pattern filled graphics primitives:: +* Patterned line drawing:: +* Image manipulation:: +* Text drawing:: +* Drawing in user coordinates:: +* Graphics cursors:: +* Keyboard input:: +* Mouse event handling:: +* Writing/reading PNM graphics files:: +* Writing/reading PNG graphics files:: +* Writing/reading JPEG graphics files:: +* Miscellaneous functions:: +* BGI interface:: +* Pascal interface:: +* References:: +@end menu + +@c ----------------------------------------------------------------------------- + +@node Hello world, Data types and function declarations, A User Manual For GRX2, A User Manual For GRX2 +@unnumberedsec Hello world +The next program draws a double frame around the screen and writes "Hello, GRX +world" centered. Then it waits after a key is pressed. + +@example +#include +#include +#include + +int main() +@{ + char *message = "Hello, GRX world"; + int x, y; + GrTextOption grt; + + GrSetMode( GR_default_graphics ); + + grt.txo_font = &GrDefaultFont; + grt.txo_fgcolor.v = GrWhite(); + grt.txo_bgcolor.v = GrBlack(); + grt.txo_direct = GR_TEXT_RIGHT; + grt.txo_xalign = GR_ALIGN_CENTER; + grt.txo_yalign = GR_ALIGN_CENTER; + grt.txo_chrtype = GR_BYTE_TEXT; + + GrBox( 0,0,GrMaxX(),GrMaxY(),GrWhite() ); + GrBox( 4,4,GrMaxX()-4,GrMaxY()-4,GrWhite() ); + + x = GrMaxX()/2; + y = GrMaxY()/2; + GrDrawString( message,strlen( message ),x,y,&grt ); + + GrKeyRead(); + + return 0; +@} + +@end example +How to compile the hello world (assuming the GRX library was +previously installed) +@example + DJGPP: gcc -o hellogrx.exe hellogrx.c -lgrx20 + Mingw: gcc -o hellogrx.exe hellogrx.c -lgrx20 -mwindows + X11 : gcc -o hellogrx hellogrx.c -D__XWIN__ -I/usr/X11R6/include + -lgrx20X -L/usr/X11R6/lib -lX11 + Linux: gcc -o hellogrx hellogrx.c -lgrx20 -lvga + + For the SDL driver: + Mingw: gcc -o hellogrx.exe hellogrx.c -lgrx20S -lSDL + X11 : gcc -o hellogrx hellogrx.c -D__XWIN__ -I/usr/X11R6/include + -lgrx20S -lSDL -lpthread -L/usr/X11R6/lib -lX11 + + For x86_64 systems add -m32 or -m64 for 32/64 bits executables + and replace /lib by /lib64 or /lib32 as needed + +@end example + +@c ----------------------------------------------------------------------------- +@node Data types and function declarations, Setting the graphics driver, Hello world, A User Manual For GRX2 +@unnumberedsec Data types and function declarations +All public data structures and graphics primitives meant for usage by the +application program are declared/prototyped in the header files (in the +'include' sub-directory): + +@example + * grdriver.h graphics driver format specifications + * grfontdv.h format of a font when loaded into memory + * grx20.h drawing-related structures and functions + * grxkeys.h platform independent key definitions + +User programs normally only include @strong{include/grx20.h} and @strong{include/grxkeys.h} +@end example + +@c ----------------------------------------------------------------------------- +@node Setting the graphics driver, Setting video modes, Data types and function declarations, A User Manual For GRX2 +@unnumberedsec Setting the graphics driver +The graphics driver is normally set by the final user by the environment +variable GRX20DRV, but a program can set it using: + +@example +int GrSetDriver(char *drvspec); +@end example + +The drvspec string has the same format as the environment variable: + +@example + gw gh nc +@end example + +Available drivers are for: + +@example +* DOS => herc, stdvga, stdega, et4000, cl5426, mach64, ati28800, s3, VESA, memory +* Linux => svgalib, linuxfb, memory +* X11 => xwin, memory +* Win32 => win32, memory +* SDL (Win32 and X11) => sdl::fs, sdl::ww, memory +@end example + +The xwin and win32 drivers are windowed. +The SDL driver on the same systems can be either fullscreen (::fs) or windowed (::ww). + +The optionals gw, gh and nc parameters set the desired default graphics mode. +Normal values for 'nc' are 2, 16, 256, 64K and 16M. The current driver name can +be obtained from: + +@example +GrCurrentVideoDriver()->name +@end example + +@c ----------------------------------------------------------------------------- +@node Setting video modes, Graphics contexts, Setting the graphics driver, A User Manual For GRX2 +@unnumberedsec Setting video modes + +Before a program can do any graphics drawing it has to configure the graphics +driver for the desired graphics mode. It is done with the GrSetMode function as +follows: + +@example +int GrSetMode(int which,...); +@end example + +On succes it returns non-zero (TRUE). The which parameter can be one of the +following constants, declared in grx20.h: + +@example +typedef enum _GR_graphicsModes @{ + GR_80_25_text, + GR_default_text, + GR_width_height_text, + GR_biggest_text, + GR_320_200_graphics, + GR_default_graphics, + GR_width_height_graphics, + GR_biggest_noninterlaced_graphics, + GR_biggest_graphics, + GR_width_height_color_graphics, + GR_width_height_color_text, + GR_custom_graphics, + GR_width_height_bpp_graphics, + GR_width_height_bpp_text, + GR_custom_bpp_graphics, + GR_NC_80_25_text, + GR_NC_default_text, + GR_NC_width_height_text, + GR_NC_biggest_text, + GR_NC_320_200_graphics, + GR_NC_default_graphics, + GR_NC_width_height_graphics, + GR_NC_biggest_noninterlaced_graphics, + GR_NC_biggest_graphics, + GR_NC_width_height_color_graphics, + GR_NC_width_height_color_text, + GR_NC_custom_graphics, + GR_NC_width_height_bpp_graphics, + GR_NC_width_height_bpp_text, + GR_NC_custom_bpp_graphics, +@} GrGraphicsMode; +@end example + +The GR_width_height_text and GR_width_height_graphics modes require the two +size arguments: int width and int height. + +The GR_width_height_color_graphics and GR_width_height_color_text modes +require three arguments: int width, int height and GrColor colors. + +The GR_width_height_bpp_graphics and GR_width_height_bpp_text modes require +three arguments: int width, int height and int bpp (bits per plane instead +number of colors). + +The GR_custom_graphics and GR_custom_bpp_graphics modes require five +arguments: int width, int height, GrColor colors or int bpp, int vx and int vy. +Using this modes you can set a virtual screen of vx by vy size. + +A call with any other mode does not require any arguments. + +The GR_NC_... modes are equivalent to the GR_.. ones, but they don't clear the +video memory. + +Graphics drivers can provide info of the supported graphics modes, use the +next code skeleton to colect the data: + +@example +@{ + GrFrameMode fm; + const GrVideoMode *mp; + for(fm =GR_firstGraphicsFrameMode; fm <= GR_lastGraphicsFrameMode; fm++) @{ + mp = GrFirstVideoMode(fm); + while( mp != NULL ) @{ + .. + .. use the mp info + .. + mp = GrNextVideoMode(mp)) + @} + @} +@} +@end example + +Don't worry if you don't understand it, normal user programs don't need to +know about FrameModes. The GrVideoMode structure has the following fields: + +@example +typedef struct _GR_videoMode GrVideoMode; + +struct _GR_videoMode @{ + char present; /* is it really available? */ + char bpp; /* log2 of # of colors */ + short width,height; /* video mode geometry */ + short mode; /* BIOS mode number (if any) */ + int lineoffset; /* scan line length */ + int privdata; /* driver can use it for anything */ + struct _GR_videoModeExt *extinfo; /* extra info (maybe shared) */ +@}; +@end example + +The width, height and bpp members are the useful information if you are +interested in set modes other than the GR_default_graphics. + +A user-defined function can be invoked every time the video mode is changed +(i.e. GrSetMode is called). This function should not take any parameters and +don't return any value. It can be installed (for all subsequent GrSetMode calls) +with the: + +@example +void GrSetModeHook(void (*hookfunc)(void)); +@end example + +function. The current graphics mode (one of the valid mode argument values for +GrSetMode) can be obtained with the: + +@example +GrGraphicsMode GrCurrentMode(void); +@end example + +function, while the type of the installed graphics adapter can be determined +with the: + +@example +GrVideoAdapter GrAdapterType(void); +@end example + +function. GrAdapterType returns the type of the adapter as one of the following +symbolic constants (defined in grx20.h): + +@example +typedef enum _GR_videoAdapters @{ + GR_UNKNOWN = (-1), /* not known (before driver set) */ + GR_VGA, /* VGA adapter */ + GR_EGA, /* EGA adapter */ + GR_HERC, /* Hercules mono adapter */ + GR_8514A, /* 8514A or compatible */ + GR_S3, /* S3 graphics accelerator */ + GR_XWIN, /* X11 driver */ + GR_WIN32, /* WIN32 driver */ + GR_LNXFB, /* Linux framebuffer */ + GR_SDL, /* SDL driver */ + GR_MEM /* memory only driver */ +@} GrVideoAdapter; +@end example + +Note that the VESA driver return GR_VGA here. + +@c ----------------------------------------------------------------------------- +@node Graphics contexts, Context use, Setting video modes, A User Manual For GRX2 +@unnumberedsec Graphics contexts + + +The library supports a set of drawing regions called contexts (the GrContext +structure). These can be in video memory or in system memory. Contexts in system +memory always have the same memory organization as the video memory. When +GrSetMode is called, a default context is created which maps to the whole +graphics screen. Contexts are described by the GrContext data structure: + +@example +typedef struct _GR_context GrContext; + +struct _GR_context @{ + struct _GR_frame gc_frame; /* frame buffer info */ + struct _GR_context *gc_root; /* context which owns frame */ + int gc_xmax; /* max X coord (width - 1) */ + int gc_ymax; /* max Y coord (height - 1) */ + int gc_xoffset; /* X offset from root's base */ + int gc_yoffset; /* Y offset from root's base */ + int gc_xcliplo; /* low X clipping limit */ + int gc_ycliplo; /* low Y clipping limit */ + int gc_xcliphi; /* high X clipping limit */ + int gc_ycliphi; /* high Y clipping limit */ + int gc_usrxbase; /* user window min X coordinate */ + int gc_usrybase; /* user window min Y coordinate */ + int gc_usrwidth; /* user window width */ + int gc_usrheight; /* user window height */ +# define gc_baseaddr gc_frame.gf_baseaddr +# define gc_selector gc_frame.gf_selector +# define gc_onscreen gc_frame.gf_onscreen +# define gc_memflags gc_frame.gf_memflags +# define gc_lineoffset gc_frame.gf_lineoffset +# define gc_driver gc_frame.gf_driver +@}; +@end example + +The following four functions return information about the layout of and memory +occupied by a graphics context of size width by height in the current graphics +mode (as set up by GrSetMode): + +@example +int GrLineOffset(int width); +int GrNumPlanes(void); +long GrPlaneSize(int w,int h); +long GrContextSize(int w,int h); +@end example + +GrLineOffset always returns the offset between successive pixel rows of the +context in bytes. GrNumPlanes returns the number of bitmap planes in the current +graphics mode. GrContextSize calculates the total amount of memory needed by a +context, while GrPlaneSize calculates the size of a bitplane in the context. The +function: + +@example +GrContext *GrCreateContext(int w,int h,char far *memory[4],GrContext *where); +@end example + +can be used to create a new context in system memory. The NULL pointer is also +accepted as the value of the memory and where arguments, in this case the +library allocates the necessary amount of memory internally. It is a general +convention in the library that functions returning pointers to any GRX +specific data structure have a last argument (most of the time named where in +the prototypes) which can be used to pass the address of the data structure +which should be filled with the result. If this where pointer has the value of +NULL, then the library allocates space for the data structure internally. + +The memory argument is really a 4 pointer array, each pointer must point to +space to handle GrPlaneSize(w,h) bytes, really only GrNumPlanes() pointers must +be malloced, the rest can be NULL. Nevertheless the normal use (see below) is + +@example +gc = GrCreateContext(w,h,NULL,NULL); +@end example + +so yo don't need to care about. + +The function: +@example + +GrContext *GrCreateSubContext(int x1,int y1,int x2,int y2, + const GrContext *parent,GrContext *where); +@end example + +creates a new sub-context which maps to a part of an existing context. The +coordinate arguments (x1 through y2) are interpreted relative to the parent +context's limits. Pixel addressing is zero-based even in sub-contexts, i.e. the +address of the top left pixel is (0,0) even in a sub-context which has been +mapped onto the interior of its parent context. + +Sub-contexts can be resized, but not their parents (i.e. anything returned by +GrCreateContext or set up by GrSetMode cannot be resized -- because this could +lead to irrecoverable "loss" of drawing memory. The following function can be +used for this purpose: + +@example +void GrResizeSubContext(GrContext *context,int x1,int y1,int x2,int y2); +@end example + +The current context structure is stored in a static location in the library. +(For efficiency reasons -- it is used quite frequently, and this way no pointer +dereferencing is necessary.) The context stores all relevant information about +the video organization, coordinate limits, etc... The current context can be set +with the: + +@example +void GrSetContext(const GrContext *context); +@end example + +function. This function will reset the current context to the full graphics +screen if it is passed the NULL pointer as argument. The value of the current +context can be saved into a GrContext structure pointed to by where using: + +@example +GrContext *GrSaveContext(GrContext *where); +@end example + +(Again, if where is NULL, the library allocates the space.) The next two +functions: + +@example +const GrContext *GrCurrentContext(void); +const GrContext *GrScreenContext(void); +@end example + +return the current context and the screen context respectively. Contexts can be +destroyed with: + +@example +void GrDestroyContext(GrContext *context); +@end example + +This function will free the memory occupied by the context only if it was +allocated originally by the library. The next three functions set up and query +the clipping limits associated with the current context: + +@example +void GrSetClipBox(int x1,int y1,int x2,int y2); +void GrGetClipBox(int *x1p,int *y1p,int *x2p,int *y2p); +void GrResetClipBox(void); +@end example + +GrResetClipBox sets the clipping limits to the limits of context. These are +the limits set up initially when a context is created. There are three similar +functions to sets/gets the clipping limits of any context: + +@example +void GrSetClipBoxC(GrContext *c,int x1,int y1,int x2,int y2); +void GrGetClipBoxC(const GrContext *c,int *x1p,int *y1p,int *x2p,int *y2p); +void GrResetClipBoxC(GrContext *c); +@end example + +The limits of the current context can be obtained using the following +functions: + +@example +int GrMaxX(void); +int GrMaxY(void); +int GrSizeX(void); +int GrSizeY(void); +@end example + +The Max functions return the biggest valid coordinate, while the Size +functions return a value one higher. The limits of the graphics screen +(regardless of the current context) can be obtained with: + +@example +int GrScreenX(void); +int GrScreenY(void); +@end example + +If you had set a virtual screen (using a custom graphics mode), the limits of +the virtual screen can be fetched with: + +@example +int GrVirtualX(void); +int GrVirtualY(void); +@end example + +The routine: + +@example +int GrScreenIsVirtual(void); +@end example + +returns non zero if a virtual screen is set. The rectangle showed in the real +screen can be set with: + +@example +int GrSetViewport(int xpos,int ypos); +@end example + +and the current viewport position can be obtained by: + +@example +int GrViewportX(void); +int GrViewportY(void); +@end example + +@c ----------------------------------------------------------------------------- +@node Context use, Color management, Graphics contexts, A User Manual For GRX2 +@unnumberedsec Context use + + +Here is a example of normal context use: + +@example +GrContext *grc; + +if( (grc = GrCreateContext( w,h,NULL,NULL )) == NULL )@{ + ...process the error + @} +else @{ + GrSetContext( grc ); + ...do some drawing + ...and probably bitblt to the screen context + GrSetContext( NULL ); /* the screen context! */ + GrDestroyContext( grc ); + @} + +@end example + +But if you have a GrContext variable (not a pointer) you want to use (probably +because is static to some routines) you can do: + +@example +static GrContext grc; /* not a pointer!! */ + +if( GrCreateContext( w,h,NULL,&grc )) == NULL ) @{ + ...process the error + @} +else @{ + GrSetContext( &grc ); + ...do some drawing + ...and probably bitblt to the screen context + GrSetContext( NULL ); /* the screen context! */ + GrDestroyContext( &grc ); + @} + +@end example + +Note that GrDestoryContext knows if grc was automatically malloced or not!! + +Only if you don't want GrCreateContext use malloc at all, you must allocate +the memory buffers and pass it to GrCreateContext. + +Using GrCreateSubContext is the same, except it doesn't need the buffer, +because it uses the parent buffer. + +See the @strong{test/winclip.c} and @strong{test/wintest.c} examples. + +@c ----------------------------------------------------------------------------- +@node Color management, Portable use of a few colors, Context use, A User Manual For GRX2 +@unnumberedsec Color management + +GRX defines the type GrColor for color variables. GrColor it's a 32 bits +integer. The 8 left bits are reserved for the write mode (see below). The 24 +bits right are the color value. + +The library supports two models for color management. In the 'indirect' (or +color table) model, color values are indices to a color table. The color table +slots will be allocated with the highest resolution supported by the hardware +(EGA: 2 bits, VGA: 6 bits) with respect to the component color intensities. In +the 'direct' (or RGB) model, color values map directly into component color +intensities with non-overlapping bitfields of the color index representing the +component colors. + +Color table model is supported until 256 color modes. The RGB model is +supported in 256 color and up color modes. + +In RGB model the color index map to component color intensities depend on the +video mode set, so it can't be assumed the component color bitfields (but if you +are curious check the GrColorInfo global structure in grx20.h). + +After the first GrSetMode call two colors are always defined: black and white. +The color values of these two colors are returned by the functions: + +@example +GrColor GrBlack(void); +GrColor GrWhite(void); +@end example + +GrBlack() is guaranteed to be 0. + +The library supports five write modes (a write mode descibes the operation +between the actual bit color and the one to be set): write, XOR, logical OR, +logical AND and IMAGE. These can be selected with OR-ing the color value with +one of the following constants declared in grx20.h : + +@example +#define GrWRITE 0UL /* write color */ +#define GrXOR 0x01000000UL /* to "XOR" any color to the screen */ +#define GrOR 0x02000000UL /* to "OR" to the screen */ +#define GrAND 0x03000000UL /* to "AND" to the screen */ +#define GrIMAGE 0x04000000UL /* blit: write, except given color */ +@end example + +The GrIMAGE write mode only works with the bitblt function. +By convention, the no-op color is obtained by combining color value 0 (black) +with the XOR operation. This no-op color has been defined in grx20.h as: + +@example +#define GrNOCOLOR (GrXOR | 0) /* GrNOCOLOR is used for "no" color */ +@end example + +The write mode part and the color value part of a GrColor variable can be +obtained OR-ing it with one of the following constants declared in grx20.h: + +@example +#define GrCVALUEMASK 0x00ffffffUL /* color value mask */ +#define GrCMODEMASK 0xff000000UL /* color operation mask */ +@end example + +The number of colors in the current graphics mode is returned by the: + +@example +GrColor GrNumColors(void); +@end example + +function, while the number of unused, available color can be obtained by +calling: + +@example +GrColor GrNumFreeColors(void); +@end example + +Colors can be allocated with the: + +@example +GrColor GrAllocColor(int r,int g,int b); +GrColor GrAllocColor2(long hcolor); +@end example + +functions (component intensities can range from 0 to 255, +hcolor must be in 0xRRGGBB format), or with the: + +@example +GrColor GrAllocCell(void); +@end example + +function. In the second case the component intensities of the returned color can +be set with: + +@example +void GrSetColor(GrColor color,int r,int g,int b); +@end example + +In the color table model both Alloc functions return GrNOCOLOR if there are no +more free colors available. In the RGB model GrNumFreeColors returns 0 and +GrAllocCell always returns GrNOCOLOR, as colors returned by GrAllocCell are +meant to be changed -- what is not supposed to be done in RGB mode. Also note +that GrAllocColor operates much more efficiently in RGB mode, and that it never +returns GrNOCOLOR in this case. + +Color table entries can be freed (when not in RGB mode) by calling: + +@example +void GrFreeColor(GrColor color); +@end example + +The component intensities of any color can be queried using one of this function: + +@example +void GrQueryColor(GrColor c,int *r,int *g,int *b); +void GrQueryColor2(GrColor c,long *hcolor); +@end example + +Initially the color system is in color table (indirect) model if there are 256 +or less colors. 256 color modes can be put into the RGB model by calling: + +@example +void GrSetRGBcolorMode(void); +@end example + +The color system can be reset (i.e. put back into color table model if +possible, all colors freed except for black and white) by calling: + +@example +void GrResetColors(void); +@end example + +The function: + +@example +void GrRefreshColors(void); +@end example + +reloads the currently allocated color values into the video hardware. This +function is not needed in typical applications, unless the display adapter is +programmed directly by the application. + +This functions: + +@example +GrColor GrAllocColorID(int r,int g,int b); +GrColor GrAllocColor2ID(long hcolor); +void GrQueryColorID(GrColor c,int *r,int *g,int *b); +void GrQueryColor2ID(GrColor c,long *hcolor); +@end example + +are inlined versions (except if you compile GRX with GRX_SKIP_INLINES defined) +to be used in the RGB model (in the color table model they call the normal +routines). + +See the @strong{test/rgbtest.c} and @strong{test/colorops.c} examples. + + +@c ----------------------------------------------------------------------------- +@node Portable use of a few colors, Graphics primitives, Color management, A User Manual For GRX2 +@unnumberedsec Portable use of a few colors + +People that only want to use a few colors find the GRX color handling a bit +confusing, but it gives the power to manage a lot of color deeps and two color +models. Here are some guidelines to easily use the famous 16 ega colors in GRX +programs. We need this GRX function: + +@example +GrColor *GrAllocEgaColors(void); +@end example + +it returns a 16 GrColor array with the 16 ega colors alloced (really it's a +trivial function, read the source src/setup/colorega.c). We can use a +construction like that: + +First, in your C code make a global pointer, and init it after set the +graphics mode: + +@example +GrColor *egacolors; +.... +int your_setup_function( ... ) +@{ + ... + GrSetMode( ... ) + ... + egacolors = GrAllocEgaColors(); + ... +@} + +@end example + +Next, add this to your main include file: + +@example +extern GrColor *egacolors; +#define BLACK egacolors[0] +#define BLUE egacolors[1] +#define GREEN egacolors[2] +#define CYAN egacolors[3] +#define RED egacolors[4] +#define MAGENTA egacolors[5] +#define BROWN egacolors[6] +#define LIGHTGRAY egacolors[7] +#define DARKGRAY egacolors[8] +#define LIGHTBLUE egacolors[9] +#define LIGHTGREEN egacolors[10] +#define LIGHTCYAN egacolors[11] +#define LIGHTRED egacolors[12] +#define LIGHTMAGENTA egacolors[13] +#define YELLOW egacolors[14] +#define WHITE egacolors[15] +@end example + +Now you can use the defined colors in your code. Note that if you are in color +table model in a 16 color mode, you have exhausted the color table. Note too +that this don't work to initialize static variables with a color, because +egacolors is not initialized. + + +@c ----------------------------------------------------------------------------- +@node Graphics primitives, Non-clipping graphics primitives, Portable use of a few colors, A User Manual For GRX2 +@unnumberedsec Graphics primitives + +The screen, the current context or the current clip box can be cleared (i.e. +set to a desired background color) by using one of the following three +functions: + +@example +void GrClearScreen(GrColor bg); +void GrClearContext(GrColor bg); +void GrClearClipBox(GrColor bg); +@end example + +Any context can be cleared using this function: +@example +void GrClearContextC(GrContext *ctx, GrColor bg); +@end example + +Thanks to the special GrColor definition, you can do more than simple clear +with this functions, by example with: + +@example +GrClearScreen( GrWhite()|GrXOR ); +@end example + +the graphics screen is negativized, do it again and the screen is restored. + +The following line drawing graphics primitives are supported by the library: + +@example +void GrPlot(int x,int y,GrColor c); +void GrLine(int x1,int y1,int x2,int y2,GrColor c); +void GrHLine(int x1,int x2,int y,GrColor c); +void GrVLine(int x,int y1,int y2,GrColor c); +void GrBox(int x1,int y1,int x2,int y2,GrColor c); +void GrCircle(int xc,int yc,int r,GrColor c); +void GrEllipse(int xc,int yc,int xa,int ya,GrColor c); +void GrCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c); +void GrEllipseArc(int xc,int yc,int xa,int ya, + int start,int end,int style,GrColor c); +void GrPolyLine(int numpts,int points[][2],GrColor c); +void GrPolygon(int numpts,int points[][2],GrColor c); +@end example + +All primitives operate on the current graphics context. The last argument of +these functions is always the color to use for the drawing. The HLine and VLine +primitives are for drawing horizontal and vertical lines. They have been +included in the library because they are more efficient than the general line +drawing provided by GrLine. The ellipse primitives can only draw ellipses with +their major axis parallel with either the X or Y coordinate axis. They take the +half X and Y axis length in the xa and ya arguments. The arc (circle and +ellipse) drawing functions take the start and end angles in tenths of degrees +(i.e. meaningful range: 0 ... 3600). The angles are interpreted +counter-clockwise starting from the positive X axis. The style argument can be +one of this defines from grx20.h: + +@example +#define GR_ARC_STYLE_OPEN 0 +#define GR_ARC_STYLE_CLOSE1 1 +#define GR_ARC_STYLE_CLOSE2 2 +@end example + +GR_ARC_STYLE_OPEN draws only the arc, GR_ARC_STYLE_CLOSE1 closes the arc with +a line between his start and end point, GR_ARC_STYLE_CLOSE1 draws the typical +cake slice. This routine: + +@example +void GrLastArcCoords(int *xs,int *ys,int *xe,int *ye,int *xc,int *yc); +@end example + +can be used to retrieve the start, end, and center points used by the last arc +drawing functions. + +See the @strong{test/circtest.c} and @strong{test/arctest.c} examples. + +The polyline and polygon primitives take the address of an n by 2 coordinate +array. The X values should be stored in the elements with 0 second index, and +the Y values in the elements with a second index value of 1. Coordinate arrays +passed to the polygon primitive can either contain or omit the closing edge of +the polygon -- the primitive will append it to the list if it is missing. + +See the @strong{test/polytest.c} example. + +Because calculating the arc points it's a very time consuming operation, there +are two functions to pre-calculate the points, that can be used next with +polyline and polygon primitives: + +@example +int GrGenerateEllipse(int xc,int yc,int xa,int ya, + int points[GR_MAX_ELLIPSE_POINTS][2]); +int GrGenerateEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int points[GR_MAX_ELLIPSE_POINTS][2]); +@end example + +The following filled primitives are available: + +@example +void GrFilledBox(int x1,int y1,int x2,int y2,GrColor c); +void GrFramedBox(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c); +void GrFilledCircle(int xc,int yc,int r,GrColor c); +void GrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c); +void GrFilledCircleArc(int xc,int yc,int r, + int start,int end,int style,GrColor c); +void GrFilledEllipseArc(int xc,int yc,int xa,int ya, + int start,int end,int style,GrColor c); +void GrFilledPolygon(int numpts,int points[][2],GrColor c); +void GrFilledConvexPolygon(int numpts,int points[][2],GrColor c); +@end example + +Similarly to the line drawing, all of the above primitives operate on the +current graphics context. The GrFramedBox primitive can be used to draw +motif-like shaded boxes and "ordinary" framed boxes as well. The x1 through y2 +coordinates specify the interior of the box, the border is outside this area, +wdt pixels wide. The primitive uses five different colors for the interior and +four borders of the box which are specified in the GrFBoxColors structure: + +@example +typedef struct @{ + GrColor fbx_intcolor; + GrColor fbx_topcolor; + GrColor fbx_rightcolor; + GrColor fbx_bottomcolor; + GrColor fbx_leftcolor; +@} GrFBoxColors; +@end example + +The GrFilledConvexPolygon primitive can be used to fill convex polygons. It +can also be used to fill some concave polygons whose boundaries do not intersect +any horizontal scan line more than twice. All other concave polygons have to be +filled with the (somewhat less efficient) GrFilledPolygon primitive. This +primitive can also be used to fill several disjoint non­overlapping polygons in +a single operation. + +The function: + +@example +void GrFloodFill(int x, int y, GrColor border, GrColor c); +@end example + +flood-fills the area bounded by the color border using x, y like the starting +point. + +Floodspill is a color replacer, replacing color A with color B. +This is quite useful for highlighting a selected item in a list, or changing +a selected color(s) in a multi colored area. + +@example +void GrFloodSpill(int x1, int y1, int x2, int y2, + GrColor old_c, GrColor new_c) +@end example + +replaces old color with new color in the rectangle bounded by x1, y1, x2, y2. + +@example +void GrFloodSpillC(GrContext *ctx, int x1, int y1, int x2, int y2, + GrColor old_c, GrColor new_c) +@end example + +as above but in the specified context. + +@example +void GrFloodSpill2(int x1, int y1, int x2, int y2, + GrColor old_c1, GrColor new_c1, + GrColor old_c2, GrColor new_c2) +@end example + +replaces 2 colors, a one stop shop for highlighting a selection in a list. + +@example +void GrFloodSpillC2(GrContext *ctx, int x1, int y1, int x2, int y2, + GrColor old_c1, GrColor new_c1, + GrColor old_c2, GrColor new_c2) +@end example + +as above but in the specified context. + +The current color value of any pixel in the current context can be obtained +with: + +@example +GrColor GrPixel(int x,int y); +@end example + +and: + +@example +GrColor GrPixelC(GrContext *c,int x,int y); +@end example + +do the same for any context. + +Rectangular areas can be transferred within a context or between contexts by +calling: + +@example +void GrBitBlt(GrContext *dest,int x,int y,GrContext *source, + int x1,int y1,int x2,int y2,GrColor op); +@end example + +x, y is the position in the destination context, and x1, y1, x2, y2 the area +from the source context to be transfered. The op argument should be one of +supported color write modes (GrWRITE, GrXOR, GrOR, GrAND, GrIMAGE), it will +control how the pixels from the source context are combined with the pixels in +the destination context (the GrIMAGE op must be ored with the color value to be +handled as transparent). If either the source or the destination context +argument is the NULL pointer then the current context is used for that argument. + +See the @strong{test/blittest.c} example. + +A efficient form to get/put pixels from/to a context can be achieved using the +next functions: + +@example +const GrColor *GrGetScanline(int x1,int x2,int yy); +const GrColor *GrGetScanlineC(GrContext *ctx,int x1,int x2,int yy); +void GrPutScanline(int x1,int x2,int yy,const GrColor *c, GrColor op); +@end example + +The Get functions return a pointer to a static GrColor pixel array (or NULL if +they fail) with the color values of a row (yy) segment (x1 to x2). GrGetScanline +uses the current context. GrGestScanlineC uses the context ctx (that can be NULL +to refer to the current context). Note that the output is only valid until the +next GRX call. + +GrPutScanline puts the GrColor pixel array c on the yy row segmet defined by +x1 to x2 in the current context using the op operation. op can be any of +GrWRITE, GrXOR, GrOR, GrAND or GrIMAGE. Data in c must fit GrCVALUEMASK +otherwise the results are implementation dependend. So you can't supply +operation code with the pixel data!. + +@c ----------------------------------------------------------------------------- +@node Non-clipping graphics primitives, Customized line drawing, Graphics primitives, A User Manual For GRX2 +@unnumberedsec Non-clipping graphics primitives + +There is a non-clipping version of some of the elementary primitives. These +are somewhat more efficient than the regular versions. These are to be used only +in situations when it is absolutely certain that no drawing will be performed +beyond the boundaries of the current context. Otherwise the program will almost +certainly crash! The reason for including these functions is that they are +somewhat more efficient than the regular, clipping versions. ALSO NOTE: These +function do not check for conflicts with the mouse cursor. (See the explanation +about the mouse cursor handling later in this document.) The list of the +supported non-clipping primitives: + +@example +void GrPlotNC(int x,int y,GrColor c); +void GrLineNC(int x1,int y1,int x2,int y2,GrColor c); +void GrHLineNC(int x1,int x2,int y,GrColor c); +void GrVLineNC(int x,int y1,int y2,GrColor c); +void GrBoxNC(int x1,int y1,int x2,int y2,GrColor c); +void GrFilledBoxNC(int x1,int y1,int x2,int y2,GrColor c); +void GrFramedBoxNC(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c); +void grbitbltNC(GrContext *dst,int x,int y,GrContext *src, + int x1,int y1,int x2,int y2,GrColor op); +GrColor GrPixelNC(int x,int y); +GrColor GrPixelCNC(GrContext *c,int x,int y); +@end example + +@c ----------------------------------------------------------------------------- +@node Customized line drawing, Pattern filled graphics primitives, Non-clipping graphics primitives, A User Manual For GRX2 +@unnumberedsec Customized line drawing + +The basic line drawing graphics primitives described previously always draw +continuous lines which are one pixel wide. There is another group of line +drawing functions which can be used to draw wide and/or patterned lines. These +functions have similar parameter passing conventions as the basic ones with one +difference: instead of the color value a pointer to a structure of type +GrLineOption has to be passed to them. The definition of the GrLineOption +structure: + +@example +typedef struct @{ + GrColor lno_color; /* color used to draw line */ + int lno_width; /* width of the line */ + int lno_pattlen; /* length of the dash pattern */ + unsigned char *lno_dashpat; /* draw/nodraw pattern */ +@} GrLineOption; +@end example + +The lno_pattlen structure element should be equal to the number of alternating +draw -- no draw section length values in the array pointed to by the lno_dashpat +element. The dash pattern array is assumed to begin with a drawn section. If the +pattern length is equal to zero a continuous line is drawn. + +Example, a white line 3 bits wide (thick) and pattern 6 bits draw, 4 bits nodraw: + +@example +GrLineOption mylineop; +... +mylineop.lno_color = GrWhite(); +mylineop.lno_width = 3; +mylineop.lno_pattlen = 2; +mylineop.lno_dashpat = "\x06\x04"; +@end example + +The available custom line drawing primitives: + +@example +void GrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrCustomCircle(int xc,int yc,int r,const GrLineOption *o); +void GrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o); +void GrCustomCircleArc(int xc,int yc,int r, + int start,int end,int style,const GrLineOption *o); +void GrCustomEllipseArc(int xc,int yc,int xa,int ya, + int start,int end,int style,const GrLineOption *o); +void GrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o); +void GrCustomPolygon(int numpts,int points[][2],const GrLineOption *o); +@end example + +See the @strong{test/linetest.c} example. + +@c ----------------------------------------------------------------------------- +@node Pattern filled graphics primitives, Patterned line drawing, Customized line drawing, A User Manual For GRX2 +@unnumberedsec Pattern filled graphics primitives + +The library also supports a pattern filled version of the basic filled +primitives described above. These functions have similar parameter passing +conventions as the basic ones with one difference: instead of the color value a +pointer to an union of type 'GrPattern' has to be passed to them. The GrPattern +union can contain either a bitmap or a pixmap fill pattern. The first integer +slot in the union determines which type it is. Bitmap fill patterns are +rectangular arrays of bits, each set bit representing the foreground color of +the fill operation, and each zero bit representing the background. Both the +foreground and background colors can be combined with any of the supported +logical operations. Bitmap fill patterns have one restriction: their width must +be eight pixels. Pixmap fill patterns are very similar to contexts. The relevant +structure declarations (from grx20.h): + +@example +/* + * BITMAP: a mode independent way to specify a fill pattern of two + * colors. It is always 8 pixels wide (1 byte per scan line), its + * height is user-defined. SET THE TYPE FLAG TO ZERO!!! + */ +typedef struct _GR_bitmap @{ + int bmp_ispixmap; /* type flag for pattern union */ + int bmp_height; /* bitmap height */ + char *bmp_data; /* pointer to the bit pattern */ + GrColor bmp_fgcolor; /* foreground color for fill */ + GrColor bmp_bgcolor; /* background color for fill */ + int bmp_memflags; /* set if dynamically allocated */ +@} GrBitmap; + +/* + * PIXMAP: a fill pattern stored in a layout identical to the video RAM + * for filling using 'bitblt'-s. It is mode dependent, typically one + * of the library functions is used to build it. KEEP THE TYPE FLAG + * NONZERO!!! + */ +typedef struct _GR_pixmap @{ + int pxp_ispixmap; /* type flag for pattern union */ + int pxp_width; /* pixmap width (in pixels) */ + int pxp_height; /* pixmap height (in pixels) */ + GrColor pxp_oper; /* bitblt mode (SET, OR, XOR, AND, IMAGE) */ + struct _GR_frame pxp_source; /* source context for fill */ +@} GrPixmap; + +/* + * Fill pattern union -- can either be a bitmap or a pixmap + */ +typedef union _GR_pattern @{ + int gp_ispixmap; /* nonzero for pixmaps */ + GrBitmap gp_bitmap; /* fill bitmap */ + GrPixmap gp_pixmap; /* fill pixmap */ +@} GrPattern; + +@end example + +This define group (from grx20.h) help to acces the GrPattern menbers: + +@example +#define gp_bmp_data gp_bitmap.bmp_data +#define gp_bmp_height gp_bitmap.bmp_height +#define gp_bmp_fgcolor gp_bitmap.bmp_fgcolor +#define gp_bmp_bgcolor gp_bitmap.bmp_bgcolor + +#define gp_pxp_width gp_pixmap.pxp_width +#define gp_pxp_height gp_pixmap.pxp_height +#define gp_pxp_oper gp_pixmap.pxp_oper +#define gp_pxp_source gp_pixmap.pxp_source +@end example + +Bitmap patterns can be easily built from initialized character arrays and +static structures by the C compiler, thus no special support is included in the +library for creating them. The only action required from the application program +might be changing the foreground and background colors as needed. Pixmap +patterns are more difficult to build as they replicate the layout of the video +memory which changes for different video modes. For this reason the library +provides three functions to create pixmap patterns in a mode-independent way: + +@example +GrPattern *GrBuildPixmap(const char *pixels,int w,int h,const GrColorTableP colors); +GrPattern *GrBuildPixmapFromBits(const char *bits,int w,int h, + GrColor fgc,GrColor bgc); +GrPattern *GrConvertToPixmap(GrContext *src); +@end example + +GrBuildPixmap build a pixmap from a two dimensional (w by h) array of +characters. The elements in this array are used as indices into the color table +specified with the argument colors. (This means that pixmaps created this way +can use at most 256 colors.) The color table pointer: + +@example +typedef GrColor *GrColorTableP; +@end example + +should point to an array of integers with the first element being the number of +colors in the table and the color values themselves starting with the second +element. NOTE: any color modifiers (GrXOR, GrOR, GrAND) OR-ed to the elements of +the color table are ignored. + +The GrBuildPixmapFromBits function builds a pixmap fill pattern from bitmap +data. It is useful if the width of the bitmap pattern is not eight as such +bitmap patterns can not be used to build a GrBitmap structure. + +The GrConvertToPixmap function converts a graphics context to a pixmap fill +pattern. It is useful when the pattern can be created with graphics drawing +operations. NOTE: the pixmap pattern and the original context share the drawing +RAM, thus if the context is redrawn the fill pattern changes as well. Fill +patterns which were built by library routines can be destroyed when no longer +needed (i.e. the space occupied by them can be freed) by calling: + +@example +void GrDestroyPattern(GrPattern *p); +@end example + +NOTE: when pixmap fill patterns converted from contexts are destroyed, the +drawing RAM is not freed. It is freed when the original context is destroyed. +Fill patterns built by the application have to be destroyed by the application +as well (if this is needed). + +The list of supported pattern filled graphics primitives is shown below. These +functions are very similar to their solid filled counterparts, only their last +argument is different: + +@example +void GrPatternFilledPlot(int x,int y,GrPattern *p); +void GrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p); +void GrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p); +void GrPatternFilledCircle(int xc,int yc,int r,GrPattern *p); +void GrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p); +void GrPatternFilledCircleArc(int xc,int yc,int r,int start,int end, + int style,GrPattern *p); +void GrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,GrPattern *p); +void GrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p); +void GrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p); +void GrPatternFloodFill(int x, int y, GrColor border, GrPattern *p); +@end example + +Strictly speaking the plot and line functions in the above group are not +filled, but they have been included here for convenience. + +@c ----------------------------------------------------------------------------- +@node Patterned line drawing, Image manipulation, Pattern filled graphics primitives, A User Manual For GRX2 +@unnumberedsec Patterned line drawing + +The custom line drawing functions introduced above also have a version when +the drawn sections can be filled with a (pixmap or bitmap) fill pattern. To +achieve this these functions must be passed both a custom line drawing option +(GrLineOption structure) and a fill pattern (GrPattern union). These two have +been combined into the GrLinePattern structure: + +@example +typedef struct @{ + GrPattern *lnp_pattern; /* fill pattern */ + GrLineOption *lnp_option; /* width + dash pattern */ +@} GrLinePattern; + +@end example + +All patterned line drawing functions take a pointer to this structure as their +last argument. The list of available functions: + +@example +void GrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp); +void GrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp); +void GrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp); +void GrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp); +void GrPatternedCircleArc(int xc,int yc,int r,int start,int end, + int style,GrLinePattern *lp); +void GrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,GrLinePattern *lp); +void GrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp); +void GrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp); + +@end example + +@c ----------------------------------------------------------------------------- +@node Image manipulation, Text drawing, Patterned line drawing, A User Manual For GRX2 +@unnumberedsec Image manipulation + +GRX defines the GrImage type like a GrPixmap synonym: + +@example +#define GrImage GrPixmap +@end example + +nevertheless the GrImage type enforces the image character of this object, so +for compatibility with future GRX versions use the next functions if you need to +convert between GrImage and GrPixmap objects: + +@example +GrImage *GrImageFromPattern(GrPattern *p); +GrPattern *GrPatternFromImage(GrImage *p); +@end example + +the GrImageFromPattern function returns NULL if the GrPattern given is not a +GrPixmap. + +Like pixmaps patterns images are dependent of the actual video mode set. So +the library provides functions to create images in a mode-independent way: + +@example +GrImage *GrImageBuild(const char *pixels,int w,int h,const GrColorTableP colors); +GrImage *GrImageFromContext(GrContext *c); +@end example + +these functions work like the GrBuildPixmap and GrConvertToPixmap ones. +Remember: the image and the original context share the drawing RAM. + +There are a number of functions to display all or part of an image in the +current context: + +@example +void GrImageDisplay(int x,int y, GrImage *i); +void GrImageDisplayExt(int x1,int y1,int x2,int y2, GrImage *i); +void GrImageFilledBoxAlign(int xo,int yo,int x1,int y1,int x2,int y2, + GrImage *p); +void GrImageHLineAlign(int xo,int yo,int x,int y,int width,GrImage *p); +void GrImagePlotAlign(int xo,int yo,int x,int y,GrImage *p); +@end example + +GrImageDisplay display the whole image using x, y like the upper left corner +in the current context. GrImageDisplayExt display as much as it can (repiting +the image if necesary) in the rectangle defined by x1, y1 and x2, y2. + +GrImageFilledBoxAlign is a most general funtion (really the later two call it) +display as much as it can in the defined rectangle using xo, yo like the align +point, it is the virtual point in the destination context (it doesn't need to be +into the rectangle) with that the upper left image corner is aligned. + +GrImageHLineAlign and GrImagePlotAlign display a row segment or a point of the +image at x y position using the xo, yo allign point. + +The most usefull image funtions are these: + +@example +GrImage *GrImageInverse(GrImage *p,int flag); +GrImage *GrImageStretch(GrImage *p,int nwidth,int nheight); +@end example + +GrImageInverse creates a new image object, flipping p left-right or top-down +as indicated by flag that can be: + +@example +#define GR_IMAGE_INVERSE_LR 0x01 /* inverse left right */ +#define GR_IMAGE_INVERSE_TD 0x02 /* inverse top down */ +@end example + +GrImageStretch creates a new image stretching p to nwidth by nheight. + +To destroy a image objet when you don't need it any more use: + +@example +void GrImageDestroy(GrImage *i); +@end example + +See the @strong{test/imgtest.c} example. + +@c ----------------------------------------------------------------------------- +@node Text drawing, Drawing in user coordinates, Image manipulation, A User Manual For GRX2 +@unnumberedsec Text drawing + +The library supports loadable fonts. When in memory they are bit-mapped (i.e. +not scalable!) fonts. A driver design allow GRX to load different font formats, +the last GRX release come with drivers to load the GRX own font format and the +BGI Borland format for all platforms supported, the X11 version can load X11 +fonts too. + +The GRX distribution come with a font collection in the GRX own format. Some +of these fonts were converted from VGA fonts. These fonts have all 256 +characters from the PC-437 codepage. Some additional fonts were converted from +fonts in the MIT X11 distribution. Most of these are ISO-8859-1 coded. Fonts +also have family names. The following font families are included: + +@example +Font file name Family Description +pcx[t].fnt pc VGA font, fixed +xmx[b][i].fnt X_misc X11, fixed, miscellaneous group +char[b][i].fnt char X11, proportional, charter family +cour[b][i].fnt cour X11, fixed, courier +helve[b][i].fnt helve X11, proportional, helvetica +lucb[b][i].fnt lucb X11, proportional, lucida bright +lucs[b][i].fnt lucs X11, proportional, lucida sans serif +luct[b][i].fnt luct X11, fixed, lucida typewriter +ncen[b][i].fnt ncen X11, proportional, new century schoolbook +symb.fnt symbol X11, proportional, greek letters, symbols +tms[b][i].fnt times X11, proportional, times +@end example + +In the font names means the font width, the font height. Many font +families have bold and/or italic variants. The files containing these fonts +contain a 'b' and/or 'i' character in their name just before the extension. +Additionally, the strings "_bold" and/or "_ital" are appended to the font family +names. Some of the pc VGA fonts come in thin formats also, these are denoted by +a 't' in their file names and the string "_thin" in their family names. + +The GrFont structure hold a font in memory. A number of 'pc' fonts are +built-in to the library and don't need to be loaded: + +@example +extern GrFont GrFont_PC6x8; +extern GrFont GrFont_PC8x8; +extern GrFont GrFont_PC8x14; +extern GrFont GrFont_PC8x16; +@end example + +Other fonts must be loaded with the GrLoadFont function. If the font file name +starts with any path separator character or character sequence (':', '/' or '\') +then it is loaded from the specified directory, otherwise the library try load +the font first from the current directory and next from the default font path. +The font path can be set up with the GrSetFontPath function. If the font path is +not set then the value of the 'GRXFONT' environment variable is used as the font +path. If GrLoadFont is called again with the name of an already loaded font then +it will return a pointer to the result of the first loading. Font loading +routines return NULL if the font was not found. When not needed any more, fonts +can be unloaded (i.e. the storage occupied by them freed) by calling +GrUnloadFont. + +The prototype declarations for these functions: + +@example +GrFont *GrLoadFont(char *name); +void GrUnloadFont(GrFont *font); +void GrSetFontPath(char *path_list); +@end example + +Using these functions: + +@example +GrFont *GrLoadConvertedFont(char *name,int cvt,int w,int h, + int minch,int maxch); +GrFont *GrBuildConvertedFont(const GrFont *from,int cvt,int w,int h, + int minch,int maxch); +@end example + +a new font can be generated from a file font or a font in memory, the 'cvt' +argument direct the conversion or-ing the desired operations from these defines: + +@example +/* + * Font conversion flags for 'GrLoadConvertedFont'. OR them as desired. + */ +#define GR_FONTCVT_NONE 0 /* no conversion */ +#define GR_FONTCVT_SKIPCHARS 1 /* load only selected characters */ +#define GR_FONTCVT_RESIZE 2 /* resize the font */ +#define GR_FONTCVT_ITALICIZE 4 /* tilt font for "italic" look */ +#define GR_FONTCVT_BOLDIFY 8 /* make a "bold"(er) font */ +#define GR_FONTCVT_FIXIFY 16 /* convert prop. font to fixed wdt */ +#define GR_FONTCVT_PROPORTION 32 /* convert fixed font to prop. wdt */ +@end example + +GR_FONTCVT_SKIPCHARS needs 'minch' and 'maxch' arguments. + +GR_FONTCVT_RESIZE needs 'w' and 'h' arguments. + +The function: + +@example +void GrDumpFnaFont(const GrFont *f, char *fileName); +@end example + +writes a font to an ascii font file, so it can be quickly edited with a text +editor. For a description of the ascii font format, see the fna.txt file. + +The function: + +@example +void GrDumpFont(const GrFont *f,char *CsymbolName,char *fileName); +@end example + +writes a font to a C source code file, so it can be compiled and linked with a +user program. GrDumpFont would not normally be used in a release program because +its purpose is to produce source code. When the source code is compiled and +linked into a program distributing the font file with the program in not +necessary, avoiding the possibility of the font file being deleted or corrupted. + +You can use the premade fnt2c.c program (see the source, it's so simple) to +dump a selected font to source code, by example: + +@example +fnt2c helv15 myhelv15 myhelv15.c +@end example + +Next, if this line is included in your main include file: + +@example +extern GrFont myhelv15 +@end example + +and "myhelv15.c" compiled and linked with your project, you can use 'myhelv15' +in every place a GrFont is required. + +This simple function: + +@example +void GrTextXY(int x,int y,char *text,GrColor fg,GrColor bg); +@end example + +draw text in the current context in the standard direction, using the +GrDefaultFont (mapped in the grx20.h file to the GrFont_PC8x14 font) with x, y +like the upper left corner and the foreground and background colors given (note +that bg equal to GrNOCOLOR make the background transparent). + +For other functions the GrTextOption structure specifies how to draw a +character string: + +@example +typedef struct _GR_textOption @{ /* text drawing option structure */ + struct _GR_font *txo_font; /* font to be used */ + union _GR_textColor txo_fgcolor; /* foreground color */ + union _GR_textColor txo_bgcolor; /* background color */ + char txo_chrtype; /* character type (see above) */ + char txo_direct; /* direction (see above) */ + char txo_xalign; /* X alignment (see above) */ + char txo_yalign; /* Y alignment (see above) */ +@} GrTextOption; + +typedef union _GR_textColor @{ /* text color union */ + GrColor v; /* color value for "direct" text */ + GrColorTableP p; /* color table for attribute text */ +@} GrTextColor; + +@end example + +The text can be rotated in increments of 90 degrees (txo_direct), alignments +can be set in both directions (txo_xalign and txo_yalign), and separate fore and +background colors can be specified. The accepted text direction values: + +@example +#define GR_TEXT_RIGHT 0 /* normal */ +#define GR_TEXT_DOWN 1 /* downward */ +#define GR_TEXT_LEFT 2 /* upside down, right to left */ +#define GR_TEXT_UP 3 /* upward */ +#define GR_TEXT_DEFAULT GR_TEXT_RIGHT +@end example + +The accepted horizontal and vertical alignment option values: + +@example +#define GR_ALIGN_LEFT 0 /* X only */ +#define GR_ALIGN_TOP 0 /* Y only */ +#define GR_ALIGN_CENTER 1 /* X, Y */ +#define GR_ALIGN_RIGHT 2 /* X only */ +#define GR_ALIGN_BOTTOM 2 /* Y only */ +#define GR_ALIGN_BASELINE 3 /* Y only */ +#define GR_ALIGN_DEFAULT GR_ALIGN_LEFT +@end example + +Text strings can be of three different types: one character per byte (i.e. the +usual C character string, this is the default), one character per 16-bit word +(suitable for fonts with a large number of characters), and a PC-style +character-attribute pair. In the last case the GrTextOption structure must +contain a pointer to a color table of size 16 (fg color bits in attrib) or 8 (bg +color bits). (The color table format is explained in more detail in the previous +section explaining the methods to build fill patterns.) The supported text +types: + +@example +#define GR_BYTE_TEXT 0 /* one byte per character */ +#define GR_WORD_TEXT 1 /* two bytes per character */ +#define GR_ATTR_TEXT 2 /* chr w/ PC style attribute byte */ +@end example + +The PC-style attribute text uses the same layout (first byte: character, +second: attributes) and bitfields as the text mode screen on the PC. The only +difference is that the 'blink' bit is not supported (it would be very time +consuming -- the PC text mode does it with hardware support). This bit is used +instead to control the underlined display of characters. For convenience the +following attribute manipulation macros have been declared in grx20.h: + +@example +#define GR_BUILD_ATTR(fg,bg,ul) \ + (((fg) & 15) | (((bg) & 7) << 4) | ((ul) ? 128 : 0)) +#define GR_ATTR_FGCOLOR(attr) (((attr) ) & 15) +#define GR_ATTR_BGCOLOR(attr) (((attr) >> 4) & 7) +#define GR_ATTR_UNDERLINE(attr) (((attr) ) & 128) +@end example + +Text strings of the types GR_BYTE_TEXT and GR_WORD_TEXT can also be drawn +underlined. This is controlled by OR-ing the constant GR_UNDERLINE_TEXT to the +foreground color value: + +@example +#define GR_UNDERLINE_TEXT (GrXOR << 4) +@end example + +After the application initializes a text option structure with the desired +values it can call one of the following two text drawing functions: + +@example +void GrDrawChar(int chr,int x,int y,const GrTextOption *opt); +void GrDrawString(void *text,int length,int x,int y,const GrTextOption *opt); +@end example + +NOTE: text drawing is fastest when it is drawn in the 'normal' direction, and +the character does not have to be clipped. It this case the library can use the +appropriate low-level video RAM access routine, while in any other case the text +is drawn pixel-by-pixel by the higher-level code. + +There are pattern filed versions too: + +@example +void GrPatternDrawChar(int chr,int x,int y,const GrTextOption *opt,GrPattern *p); +void GrPatternDrawString(void *text,int length,int x,int y,const GrTextOption *opt, + GrPattern *p); +void GrPatternDrawStringExt(void *text,int length,int x,int y, + const GrTextOption *opt,GrPattern *p); +@end example + +The size of a font, a character or a text string can be obtained by calling +one of the following functions. These functions also take into consideration the +text direction specified in the text option structure passed to them. + +@example +int GrFontCharPresent(const GrFont *font,int chr); +int GrFontCharWidth(const GrFont *font,int chr); +int GrFontCharHeight(const GrFont *font,int chr); +int GrFontCharBmpRowSize(const GrFont *font,int chr); +int GrFontCharBitmapSize(const GrFont *font,int chr); +int GrFontStringWidth(const GrFont *font,void *text,int len,int type); +int GrFontStringHeight(const GrFont *font,void *text,int len,int type); +int GrProportionalTextWidth(const GrFont *font,void *text,int len,int type); +int GrCharWidth(int chr,const GrTextOption *opt); +int GrCharHeight(int chr,const GrTextOption *opt); +void GrCharSize(int chr,const GrTextOption *opt,int *w,int *h); +int GrStringWidth(void *text,int length,const GrTextOption *opt); +int GrStringHeight(void *text,int length,const GrTextOption *opt); +void GrStringSize(void *text,int length,const GrTextOption *opt,int *w,int *h); +@end example + + The GrTextRegion structure and its associated functions can be used to +implement a fast (as much as possible in graphics modes) rectangular text window +using a fixed font. Clipping for such windows is done in character size +increments instead of pixels (i.e. no partial characters are drawn). Only fixed +fonts can be used in their natural size. GrDumpText will cache the code of the +drawn characters in the buffer pointed to by the 'backup' slot (if it is +non-NULL) and will draw a character only if the previously drawn character in +that grid element is different. + +This can speed up text scrolling significantly in graphics modes. The +supported text types are the same as above. + +@example +typedef struct @{ /* fixed font text window desc. */ + struct _GR_font *txr_font; /* font to be used */ + union _GR_textColor txr_fgcolor; /* foreground color */ + union _GR_textColor txr_bgcolor; /* background color */ + void *txr_buffer; /* pointer to text buffer */ + void *txr_backup; /* optional backup buffer */ + int txr_width; /* width of area in chars */ + int txr_height; /* height of area in chars */ + int txr_lineoffset; /* offset in buffer(s) between rows */ + int txr_xpos; /* upper left corner X coordinate */ + int txr_ypos; /* upper left corner Y coordinate */ + char txr_chrtype; /* character type (see above) */ +@} GrTextRegion; + +void GrDumpChar(int chr,int col,int row,const GrTextRegion *r); +void GrDumpText(int col,int row,int wdt,int hgt,const GrTextRegion *r); +void GrDumpTextRegion(const GrTextRegion *r); + +@end example + +The GrDumpTextRegion function outputs the whole text region, while GrDumpText +draws only a user-specified part of it. GrDumpChar updates the character in the +buffer at the specified location with the new character passed to it as argument +and then draws the new character on the screen as well. With these functions you +can simulate a text mode window, write chars directly to the txr_buffer and call +GrDumpTextRegion when you want to update the window (or GrDumpText if you know +the area to update is small). + +See the @strong{test/fonttest.c} example. + +@c ----------------------------------------------------------------------------- +@node Drawing in user coordinates, Graphics cursors, Text drawing, A User Manual For GRX2 +@unnumberedsec Drawing in user coordinates + + +There is a second set of the graphics primitives which operates in user +coordinates. Every context has a user to screen coordinate mapping associated +with it. An application specifies the user window by calling the GrSetUserWindow +function. + +@example +void GrSetUserWindow(int x1,int y1,int x2,int y2); +@end example + +A call to this function it in fact specifies the virtual coordinate limits +which will be mapped onto the current context regardless of the size of the +context. For example, the call: + +@example +GrSetUserWindow(0,0,11999,8999); +@end example + +tells the library that the program will perform its drawing operations in a +coordinate system X:0...11999 (width = 12000) and Y:0...8999 (height = 9000). +This coordinate range will be mapped onto the total area of the current context. +The virtual coordinate system can also be shifted. For example: + +@example +GrSetUserWindow(5000,2000,16999,10999); +@end example + +The user coordinates can even be used to turn the usual left-handed coordinate +system (0:0 corresponds to the upper left corner) to a right handed one (0:0 +corresponds to the bottom left corner) by calling: + +@example +GrSetUserWindow(0,8999,11999,0); +@end example + +The library also provides three utility functions for the query of the current +user coordinate limits and for converting user coordinates to screen coordinates +and vice versa. + +@example +void GrGetUserWindow(int *x1,int *y1,int *x2,int *y2); +void GrGetScreenCoord(int *x,int *y); +void GrGetUserCoord(int *x,int *y); +@end example + +If an application wants to take advantage of the user to screen coordinate +mapping it has to use the user coordinate version of the graphics primitives. +These have exactly the same parameter passing conventions as their screen +coordinate counterparts. NOTE: the user coordinate system is not initialized by +the library! The application has to set up its coordinate mapping before calling +any of the use coordinate drawing functions -- otherwise the program will almost +certainly exit (in a quite ungraceful fashion) with a 'division by zero' error. +The list of supported user coordinate drawing functions: + +@example +void GrUsrPlot(int x,int y,GrColor c); +void GrUsrLine(int x1,int y1,int x2,int y2,GrColor c); +void GrUsrHLine(int x1,int x2,int y,GrColor c); +void GrUsrVLine(int x,int y1,int y2,GrColor c); +void GrUsrBox(int x1,int y1,int x2,int y2,GrColor c); +void GrUsrFilledBox(int x1,int y1,int x2,int y2,GrColor c); +void GrUsrFramedBox(int x1,int y1,int x2,int y2,int wdt,GrFBoxColors *c); +void GrUsrCircle(int xc,int yc,int r,GrColor c); +void GrUsrEllipse(int xc,int yc,int xa,int ya,GrColor c); +void GrUsrCircleArc(int xc,int yc,int r,int start,int end, + int style,GrColor c); +void GrUsrEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,GrColor c); +void GrUsrFilledCircle(int xc,int yc,int r,GrColor c); +void GrUsrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c); +void GrUsrFilledCircleArc(int xc,int yc,int r,int start,int end, + int style,GrColor c); +void GrUsrFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,GrColor c); +void GrUsrPolyLine(int numpts,int points[][2],GrColor c); +void GrUsrPolygon(int numpts,int points[][2],GrColor c); +void GrUsrFilledConvexPolygon(int numpts,int points[][2],GrColor c); +void GrUsrFilledPolygon(int numpts,int points[][2],GrColor c); +void GrUsrFloodFill(int x, int y, GrColor border, GrColor c); +GrColor GrUsrPixel(int x,int y); +GrColor GrUsrPixelC(GrContext *c,int x,int y); +void GrUsrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrUsrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrUsrCustomCircle(int xc,int yc,int r,const GrLineOption *o); +void GrUsrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o); +void GrUsrCustomCircleArc(int xc,int yc,int r,int start,int end, + int style,const GrLineOption *o); +void GrUsrCustomEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,const GrLineOption *o); +void GrUsrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o); +void GrUsrCustomPolygon(int numpts,int points[][2],const GrLineOption *o); +void GrUsrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp); +void GrUsrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp); +void GrUsrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp); +void GrUsrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp); +void GrUsrPatternedCircleArc(int xc,int yc,int r,int start,int end, + int style,GrLinePattern *lp); +void GrUsrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end, + int style,GrLinePattern *lp); +void GrUsrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp); +void GrUsrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp); +void GrUsrPatternFilledPlot(int x,int y,GrPattern *p); +void GrUsrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p); +void GrUsrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p); +void GrUsrPatternFilledCircle(int xc,int yc,int r,GrPattern *p); +void GrUsrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p); +void GrUsrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrPattern *p); +void GrUsrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrPattern *p); +void GrUsrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p); +void GrUsrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p); +void GrUsrPatternFloodFill(int x, int y, GrColor border, GrPattern *p); +void GrUsrDrawChar(int chr,int x,int y,const GrTextOption *opt); +void GrUsrDrawString(char *text,int length,int x,int y,const GrTextOption *opt); +void GrUsrTextXY(int x,int y,char *text,GrColor fg,GrColor bg); +@end example + +@c ----------------------------------------------------------------------------- +@node Graphics cursors, Keyboard input, Drawing in user coordinates, A User Manual For GRX2 +@unnumberedsec Graphics cursors + +The library provides support for the creation and usage of an unlimited number +of graphics cursors. An application can use these cursors for any purpose. +Cursors always save the area they occupy before they are drawn. When moved or +erased they restore this area. As a general rule of thumb, an application should +erase a cursor before making changes to an area it occupies and redraw the +cursor after finishing the drawing. Cursors are created with the GrBuildCursor +function: + +@example +GrCursor *GrBuildCursor(char far *pixels,int pitch,int w,int h, + int xo,int yo,const GrColorTableP c); +@end example + +The pixels, w (=width), h (=height) and c (= color table) arguments are +similar to the arguments of the pixmap building library function GrBuildPixmap +(see that paragraph for a more detailed explanation.), but with two differences. +First, is not assumed that the pixels data is w x h sized, the pitch argument +set the offset between rows. Second, the pixmap data is interpreted slightly +differently, any pixel with value zero is taken as a "transparent" pixel, i.e. +the background will show through the cursor pattern at that pixel. A pixmap data +byte with value = 1 will refer to the first color in the table, and so on. + +The xo (= X offset) and yo (= Y offset) arguments specify the position (from +the top left corner of the cursor pattern) of the cursor's "hot point". + +The GrCursor data structure: + +@example +typedef struct _GR_cursor @{ + struct _GR_context work; /* work areas (4) */ + int xcord,ycord; /* cursor position on screen */ + int xsize,ysize; /* cursor size */ + int xoffs,yoffs; /* LU corner to hot point offset */ + int xwork,ywork; /* save/work area sizes */ + int xwpos,ywpos; /* save/work area position on screen */ + int displayed; /* set if displayed */ +@} GrCursor; +@end example + +is typically not used (i.e. read or changed) by the application program, it +should just pass pointers to these structures to the appropriate library +functions. Other cursor manipulation functions: + +@example +void GrDisplayCursor(GrCursor *cursor); +void GrEraseCursor(GrCursor *cursor); +void GrMoveCursor(GrCursor *cursor,int x,int y); +void GrDestroyCursor(GrCursor *cursor); +@end example + +See the @strong{test/curstest.c} example. + +@c ----------------------------------------------------------------------------- +@node Keyboard input, Mouse event handling, Graphics cursors, A User Manual For GRX2 +@unnumberedsec Keyboard input + +GRX can handle platform independant key input. The file grxkeys.h defines the +keys to be used in the user's program. This is an extract: + +@example +#define GrKey_Control_A 0x0001 +#define GrKey_Control_B 0x0002 +#define GrKey_Control_C 0x0003 +... +#define GrKey_A 0x0041 +#define GrKey_B 0x0042 +#define GrKey_C 0x0043 +... +#define GrKey_F1 0x013b +#define GrKey_F2 0x013c +#define GrKey_F3 0x013d +... +#define GrKey_Alt_F1 0x0168 +#define GrKey_Alt_F2 0x0169 +#define GrKey_Alt_F3 0x016a +@end example + +But you can be confident that the standard ASCII is right maped. +The GrKeyType type is defined to store keycodes: + +@example +typedef unsigned short GrKeyType; +@end example + +This function: + +@example +int GrKeyPressed(void); +@end example + +returns non zero if there are any keycode waiting, that can be read with: + +@example +GrKeyType GrKeyRead(void); +@end example + +The function: + +@example +int GrKeyStat(void); +@end example + +returns a keyboard status word, or-ing it with the next defines it can be known +the status of some special keys: + +@example +#define GR_KB_RIGHTSHIFT 0x01 /* right shift key depressed */ +#define GR_KB_LEFTSHIFT 0x02 /* left shift key depressed */ +#define GR_KB_CTRL 0x04 /* CTRL depressed */ +#define GR_KB_ALT 0x08 /* ALT depressed */ +#define GR_KB_SCROLLOCK 0x10 /* SCROLL LOCK active */ +#define GR_KB_NUMLOCK 0x20 /* NUM LOCK active */ +#define GR_KB_CAPSLOCK 0x40 /* CAPS LOCK active */ +#define GR_KB_INSERT 0x80 /* INSERT state active */ +#define GR_KB_SHIFT (GR_KB_LEFTSHIFT | GR_KB_RIGHTSHIFT) +@end example + +See the @strong{test/keys.c} example. + +@c ----------------------------------------------------------------------------- +@node Mouse event handling, Writing/reading PNM graphics files, Keyboard input, A User Manual For GRX2 +@unnumberedsec Mouse event handling + +All mouse services need the presence of a mouse. An application can test +whether a mouse is available by calling the function: + +@example +int GrMouseDetect(void); +@end example + +which will return zero if no mouse (or mouse driver) is present, non-zero +otherwise. The mouse must be initialized by calling one (and only one) of these +functions: + +@example +void GrMouseInit(void); +void GrMouseInitN(int queue_size); +@end example + +GrMouseInit sets a event queue (see below) size to GR_M_QUEU_SIZE (128). A +user supply event queue size can be set calling GrMouseInitN instead. + +It is a good practice to call GrMouseUnInit before exiting the program. This +will restore any interrupt vectors hooked by the program to their original +values. + +@example +void GrMouseUnInit(void); +@end example + +The mouse can be controlled with the following functions: + +@example +void GrMouseSetSpeed(int spmult,int spdiv); +void GrMouseSetAccel(int thresh,int accel); +void GrMouseSetLimits(int x1,int y1,int x2,int y2); +void GrMouseGetLimits(int *x1,int *y1,int *x2,int *y2); +void GrMouseWarp(int x,int y); +@end example + +The library calculates the mouse position only from the mouse mickey counters. +(To avoid the limit and 'rounding to the next multiple of eight' problem with +some mouse driver when it finds itself in a graphics mode unknown to it.) The +parameters to the GrMouseSetSpeed function specify how coordinate changes are +obtained from mickey counter changes, multipling by spmult and dividing by +spdiv. In high resolution graphics modes the value of one just works fine, in +low resolution modes (320x200 or similar) it is best set the spdiv to two or +three. (Of course, it also depends on the sensitivity the mouse.) The +GrMouseSetAccel function is used to control the ballistic effect: if a mouse +coordinate changes between two samplings by more than the thresh parameter, the +change is multiplied by the accel parameter. NOTE: some mouse drivers perform +similar calculations before reporting the coordinates in mickeys. In this case +the acceleration done by the library will be additional to the one already +performed by the mouse driver. The limits of the mouse movement can be set +(passed limits will be clipped to the screen) with GrMouseSetLimits (default is +the whole screen) and the current limits can be obtained with GrMouseGetLimits. +GrMouseWarp sets the mouse cursor to the specified position. + +As typical mouse drivers do not know how to draw mouse cursors in high +resolution graphics modes, the mouse cursor is drawn by the library. The mouse +cursor can be set with: + +@example +void GrMouseSetCursor(GrCursor *cursor); +void GrMouseSetColors(GrColor fg,GrColor bg); +@end example + +GrMouseSetColors uses an internal arrow pattern, the color fg will be used as +the interior of it and bg will be the border. The current mouse cursor can be +obtained with: + +@example +GrCursor *GrMouseGetCursor(void); +@end example + +The mouse cursor can be displayed/erased with: + +@example +void GrMouseDisplayCursor(void); +void GrMouseEraseCursor(void); +@end example + +The mouse cursor can be left permanently displayed. All graphics primitives +except for the few non-clipping functions check for conflicts with the mouse +cursor and erase it before the drawing if necessary. Of course, it may be more +efficient to erase the cursor manually before a long drawing sequence and redraw +it after completion. The library provides an alternative pair of calls for this +purpose which will erase the cursor only if it interferes with the drawing: + +@example +int GrMouseBlock(GrContext *c,int x1,int y1,int x2,int y2); +void GrMouseUnBlock(int return_value_from_GrMouseBlock); +@end example + +GrMouseBlock should be passed the context in which the drawing will take place +(the usual convention of NULL meaning the current context is supported) and the +limits of the affected area. It will erase the cursor only if it interferes with +the drawing. When the drawing is finished GrMouseUnBlock must be called with the +argument returned by GrMouseBlock. + +The status of the mouse cursor can be obtained with calling +GrMouseCursorIsDisplayed. This function will return non-zero if the cursor is +displayed, zero if it is erased. + +@example +int GrMouseCursorIsDisplayed(void); +@end example + +The library supports (beside the simple cursor drawing) three types of +"rubberband" attached to the mouse cursor. The GrMouseSetCursorMode function is +used to select the cursor drawing mode. + +@example +void GrMouseSetCursorMode(int mode,...); +@end example + +The parameter mode can have the following values: + +@example +#define GR_M_CUR_NORMAL 0 /* MOUSE CURSOR modes: just the cursor */ +#define GR_M_CUR_RUBBER 1 /* rect. rubber band (XOR-d to the screen) */ +#define GR_M_CUR_LINE 2 /* line attached to the cursor */ +#define GR_M_CUR_BOX 3 /* rectangular box dragged by the cursor */ +@end example + +GrMouseSetCursorMode takes different parameters depending on the cursor +drawing mode selected. The accepted call formats are: + +@example +GrMouseSetCursorMode(M_CUR_NORMAL); +GrMouseSetCursorMode(M_CUR_RUBBER,xanchor,yanchor,GrColor); +GrMouseSetCursorMode(M_CUR_LINE,xanchor,yanchor,GrColor); +GrMouseSetCursorMode(M_CUR_BOX,dx1,dy1,dx2,dy2,GrColor); +@end example + +The anchor parameters for the rubberband and rubberline modes specify a fixed +screen location to which the other corner of the primitive is bound. The dx1 +through dy2 parameters define the offsets of the corners of the dragged box from +the hotpoint of the mouse cursor. The color value passed is always XOR-ed to the +screen, i.e. if an application wants the rubberband to appear in a given color +on a given background then it has to pass the XOR of these two colors to +GrMouseSetCursorMode. + +The GrMouseGetEvent function is used to obtain the next mouse or keyboard +event. It takes a flag with various bits encoding the type of event needed. It +returns the event in a GrMouseEvent structure. The relevant declarations from +grx20.h: + +@example +void GrMouseGetEvent(int flags,GrMouseEvent *event); + +typedef struct _GR_mouseEvent @{ /* mouse event buffer structure */ + int flags; /* event type flags (see above) */ + int x,y; /* mouse coordinates */ + int buttons; /* mouse button state */ + int key; /* key code from keyboard */ + int kbstat; /* keybd status (ALT, CTRL, etc..) */ + long dtime; /* time since last event (msec) */ +@} GrMouseEvent; +@end example + +The event structure has been extended with a keyboard status word (thus a +program can check for combinations like ALT-) and a time +stamp which can be used to check for double clicks, etc... The following macros +have been defined in grx20.h to help in creating the control flag for +GrMouseGetEvent and decoding the various bits in the event structure: + +@example +#define GR_M_MOTION 0x001 /* mouse event flag bits */ +#define GR_M_LEFT_DOWN 0x002 +#define GR_M_LEFT_UP 0x004 +#define GR_M_RIGHT_DOWN 0x008 +#define GR_M_RIGHT_UP 0x010 +#define GR_M_MIDDLE_DOWN 0x020 +#define GR_M_MIDDLE_UP 0x040 +#define GR_M_BUTTON_DOWN (GR_M_LEFT_DOWN | GR_M_MIDDLE_DOWN | \ + GR_M_RIGHT_DOWN | GR_M_P4_DOWN | GR_M_P5_DOWN) +#define GR_M_BUTTON_UP (GR_M_LEFT_UP | GR_M_MIDDLE_UP | \ + GR_M_RIGHT_UP | GR_M_P4_UP | GR_M_P5_UP) +#define GR_M_BUTTON_CHANGE (GR_M_BUTTON_UP | GR_M_BUTTON_DOWN ) + +#define GR_M_LEFT 0x01 /* mouse button index bits */ +#define GR_M_RIGHT 0x02 +#define GR_M_MIDDLE 0x04 +#define GR_M_P4 0x08 /* wheel rolls up */ +#define GR_M_P5 0x10 /* wheel rolls down */ + +#define GR_M_KEYPRESS 0x080 /* other event flag bits */ +#define GR_M_POLL 0x100 +#define GR_M_NOPAINT 0x200 +#define GR_COMMAND 0x1000 +#define GR_M_EVENT (GR_M_MOTION | GR_M_KEYPRESS | \ + GR_M_BUTTON_CHANGE | GR_COMMAND) +@end example + +GrMouseGetEvent will display the mouse cursor if it was previously erased and +the GR_M_NOPAINT bit is not set in the flag passed to it. In this case it will +also erase the cursor after an event has been obtained. + +GrMouseGetEvent block until a event is produced, except if the GR_M_POLL bit +is set in the flag passed to it. + +Another version of GetEvent: + +@example +void GrMouseGetEventT(int flags,GrMouseEvent *event,long timout_msecs); +@end example + +can be istructed to wait timout_msec for the presence of an event. Note that +event->dtime is only valid if any event occured (event->flags != 0) otherwise +it's set as -1. Additionally event timing is real world time even in X11 && +Linux. + +If there are one or more events waiting the function: + +@example +int GrMousePendingEvent(void); +@end example + +returns non-zero value. + +The generation of mouse and keyboard events can be individually enabled or +disabled (by passing a non-zero or zero, respectively, value in the +corresponding enable_XX parameter) by calling: + +@example +void GrMouseEventEnable(int enable_kb,int enable_ms); +@end example + +Note that GrMouseInit set both by default. If you want to use +GrMouseGetEvent and GrKeyRead at the same time, a call to +GrMouseEventEnable( 0,1 ) is needed before input process. + +See the @strong{test/mousetst.c} example. + +@node Writing/reading PNM graphics files, Writing/reading PNG graphics files,Mouse event handling , A User Manual For GRX2 +@unnumberedsec Writing/reading PNM graphics files + +GRX includes functions to load/save a context from/to a PNM file. + +PNM is a group of simple graphics formats from the +@uref{http://netpbm.sourceforge.net, NetPbm} +distribution. NetPbm can convert from/to PNM lots of graphics formats, +and apply some transformations to PNM files. +(Note. You don't need the NetPbm distribution to use this functions). + +There are six PNM formats: + +@example + P1 text PBM (bitmap) + P2 text PGM (gray scale) + P3 text PPM (real color) + P4 binary PBM (bitmap) + P5 binary PGM (gray scale) + P6 binary PPM (real color) +@end example + +GRX can handle the binary formats only (get the NetPbm distribution if you +need convert text to binary formats). + +To save a context in a PNM file you have three functions: + +@example +int GrSaveContextToPbm( GrContext *grc, char *pbmfn, char *docn ); +int GrSaveContextToPgm( GrContext *grc, char *pgmfn, char *docn ); +int GrSaveContextToPpm( GrContext *grc, char *ppmfn, char *docn ); +@end example + +they work both in RGB and palette modes, grc must be a pointer to the context to +be saved, if it is NULL the current context is saved; p-mfn is the file name to +be created and docn is an optional text comment to be written in the file, it +can be NULL. Three functions return 0 on succes and -1 on error. + +GrSaveContextToPbm dumps a context in a PBM file (bitmap). If the pixel color +isn't Black it asumes White. + +GrSaveContextToPgm dumps a context in a PGM file (gray scale). The colors are +quantized to gray scale using .299r + .587g + .114b. + +GrSaveContextToPpm dumps a context in a PPM file (real color). +To load a PNM file in a context you must use: + +@example +int GrLoadContextFromPnm( GrContext *grc, char *pnmfn ); +@end example + +it support reading PBM, PGM and PPM binary files. grc must be a pointer to the +context to be written, if it is NULL the current context is used; p-mfn is the +file name to be read. If context dimensions are lesser than pnm dimensions, the +function loads as much as it can. If color mode is not in RGB mode, the routine +allocates as much colors as it can. The function returns 0 on succes and -1 on +error. + +To query the file format, width and height of a PNM file you can use: + +@example +int GrQueryPnm( char *ppmfn, int *width, int *height, int *maxval ); +@end example + +pnmfn is the name of pnm file; width returns the pnm width; height returns the +pnm height; maxval returns the max color component value. The function returns 1 +to 6 on success (the PNM format) or -1 on error. + +The two next functions: + +@example +int GrLoadContextFromPnmBuffer( GrContext *grc, const char *pnmbuf ); +int GrQueryPnmBuffer( const char *pnmbuf, int *width, int *height, int *maxval ); +@end example + +work like GrLoadContextFromPnm and +GrQueryPnmBuffer, but they get his input from a buffer instead +of a file. This way, pnm files can be embeded in a program (using the +bin2c program by example). + +@node Writing/reading PNG graphics files, Writing/reading JPEG graphics files, Writing/reading PNM graphics files, A User Manual For GRX2 +@unnumberedsec Writing/reading PNG graphics files + +GRX includes functions to load/save a context +from/to a png file. But note, for this purpose it needs the +@uref{http://www.libpng.org/pub/png/libpng.html, libpng} library, +and to enable the png support before make the GRX lib. + +Use next function to save a context in a PNG file: + +@example +int GrSaveContextToPng( GrContext *grc, char *pngfn ); +@end example + +it works both in RGB and palette modes, grc must be +a pointer to the context to be saved, if it is NULL the current context is +saved; pngfn is the file name to be created. +The function returns 0 on succes and -1 on error. + +To load a PNG file in a context you must use: + +@example +int GrLoadContextFromPng( GrContext *grc, char *pngfn, int use_alpha ); +@end example + +grc must be a pointer to the context to be written, if it +is NULL the current context is used; pngfn is the file name +to be read; set use_alpha to 1 if you want to use the image +alpha channel (if available). If context dimensions are lesser than png +dimensions, the function loads as much as it can. If color mode is not +in RGB mode, the routine allocates as much colors as it can. The function +returns 0 on succes and -1 on error. + +To query the width and height of a PNG file you can use: + +@example +int GrQueryPng( char *pngfn, int *width, int *height ); +@end example + +pngfn is the name of png file; width returns the +png width; height returns the png height. +The function returns 0 on success or -1 on error. + +The function: + +@example +int GrPngSupport( void ); +@end example + +returns 1 if there is png support in the library, 0 otherwise. If there is +not support for png, dummy functions are added to the library, returning +error (-1) ever. + +@node Writing/reading JPEG graphics files, Miscellaneous functions, Writing/reading PNG graphics files, A User Manual For GRX2 +@unnumberedsec Writing/reading PNG graphics files + +GRX includes functions to load/save a context +from/to a jpeg file. But note, for this purpose it needs the +@uref{http://www.ijg.org, libjpeg} library, +and to enable the jpeg support before make the GRX lib. + +Use next function to save a context in a JPEG file: + +@example +int GrSaveContextToJpeg( GrContext *grc, char *jpegfn, int quality ); +@end example + +it works both in RGB and palette modes, grc must be +a pointer to the context to be saved, if it is NULL the current context is +saved; jpegfn is the file name to be created; +quality is a number between 1 and 100 to drive the compression +quality, use higher values for better quality (and bigger files), you can +use 75 as a standard value, normally a value between 50 and 95 is good. +The function returns 0 on succes and -1 on error. + +This function saves a context in a grayscale JPEG file: + +@example +int GrSaveContextToGrayJpeg( GrContext *grc, char *jpegfn, int quality ); +@end example + +parameters and return codes are like in GrSaveContextToJpeg. +The colors are quantized to gray scale using .299r + .587g + .114b. + +To load a JPEG file in a context you must use: + +@example +int GrLoadContextFromJpeg( GrContext *grc, char *jpegfn, int scale ); +@end example + +grc must be a pointer to the context to be written, if it +is NULL the current context is used; jpegfn is the file name +to be read; set scale to 1, 2, 4 or 8 to reduce the loaded +image to 1/1, 1/2, 1/4 or 1/8. If context dimensions are lesser than jpeg +dimensions, the function loads as much as it can. If color mode is not +in RGB mode, the routine allocates as much colors as it can. The function +returns 0 on succes and -1 on error. + +To query the width and height of a JPEG file you can use: + +@example +int GrQueryJpeg( char *jpegfn, int *width, int *height ); +@end example + +jpegfn is the name of jpeg file; width returns the +jpeg width; height returns the jpeg height. +The function returns 0 on success or -1 on error. + +The function: + +@example +int GrJpegSupport( void ); +@end example + +returns 1 if there is jpeg support in the library, 0 otherwise. If there is +not support for jpeg, dummy functions are added to the library, returning +error (-1) ever. + +@node Miscellaneous functions, BGI interface, Writing/reading JPEG graphics files, A User Manual For GRX2 +@unnumberedsec Miscellaneous functions + +Here we will describe some miscellaneous functions. + +@example +unsigned GrGetLibraryVersion(void); +@end example + +GrGetLibraryVersion returns the GRX version API, like a hexadecimal coded +number. By example 0x0241 means 2.4.1 Because grx20.h defines the +GRX_VERSION_API macro, you can check if both, the library and the +include file, are in the same version using +if(GrGetLibraryVersion() == GRX_VERSION_API ) + +@example +unsigned GrGetLibrarySystem(void); +@end example + +This functions returns a unsigned integer identifing the system you are +working in. grx20.h defines some macros you can use: + +@example +/* these are the supported configurations: */ +#define GRX_VERSION_TCC_8086_DOS 1 /* also works with BCC */ +#define GRX_VERSION_GCC_386_DJGPP 2 /* DJGPP v2 */ +#define GRX_VERSION_GCC_386_LINUX 3 /* the real stuff */ +#define GRX_VERSION_GENERIC_X11 4 /* generic X11 version */ +#define GRX_VERSION_WATCOM_DOS4GW 5 /* GS - Watcom C++ 11.0 32 Bit +#define GRX_VERSION_GCC_386_WIN32 7 /* WIN32 using Mingw32 */ +#define GRX_VERSION_MSC_386_WIN32 8 /* WIN32 using MS-VC */ +#define GRX_VERSION_GCC_386_CYG32 9 /* WIN32 using CYGWIN */ +#define GRX_VERSION_GCC_386_X11 10 /* X11 version */ +#define GRX_VERSION_GCC_X86_64_LINUX 11 /* console framebuffer 64 */ +#define GRX_VERSION_GCC_X86_64_X11 12 /* X11 version 64 */ +@end example + +Note. On Linux, GrGetLibrarySystem returns GRX_VERSION_GCC_386_LINUX even in the +X11 version. + +@example +void GrSetWindowTitle(char *title); +@end example +GrSetWindowTitle sets the main window title in the X11 an Win32 versions. It +doesn't do nothing in the DOS and Linux-SvgaLib versions. + +@example +void GrSleep(int msec); +@end example +This function stops the program execution for msec miliseconds. + +@example +long GrMsecTime( void ); +@end example +This function gives the current time with millisecond resolution + + +@example +void GrFlush( void ); +@end example +This funnction flushes the graphics window. Not dummy because useful only on +X11 when switching between graphics and console windows open simultaneously. + +@example + GrContext *GrCreateFrameContext(GrFrameMode md,int w,int h, + char far *memory[4],GrContext *where); + +@end example +This function is like GrCreateContext, except that you can specify any valid +memory frame mode, not only the Screen associated frame mode. It can be used for +special purposes (see GrBitBlt1bpp for an example). + +@example + void GrBitBlt1bpp(GrContext *dst,int dx,int dy,GrContext *src, + int x1,int y1,int x2,int y2,GrColor fg,GrColor bg); + +@end example +This special function does a bitblt from a 1bpp context (a bitmap really), +using fg and bg like the color+opcode when bit=1 and bit=0 respectively. Here is +an example: + +@example + pContext = GrCreateFrameContext(GR_frameRAM1, sizex, sizey, NULL, NULL); + /* draw something (black and white) into the bitmap */ + GrSetContext(pContext); + GrClearContext( GrBlack() ); + GrLine(0, 0, sizex-1, sizey-1, GrWhite()); + GrLine(0, sizey-1, sizex-1, 0, GrWhite()); + + /* Put the bitmap into the screen */ + GrSetContext(NULL); + fcolor = GrAllocColor( 255,0,0 ); + bcolor = GrAllocColor( 0,0,255 ); + GrBitBlt1bpp(NULL,x,y,pContext,0,0,sizex-1,sizey-1,fcolor,bcolor); +@end example + +@c ----------------------------------------------------------------------------- +@node BGI interface, Pascal interface, Miscellaneous functions, A User Manual For GRX2 +@unnumberedsec BGI interface + +From the 2.3.1 version, GRX includes the BCC2GRX library created by Hartmut +Schirmer. The BCC2GRX was created to allow users of GRX to compile graphics +programs written for Borland-C++ and Turbo-C graphics interface. BCC2GRX is not +a convenient platform to develop new BGI programs. Of course you should use +native GRX interface in such cases! + +Read the readme.bgi file for more info. + +@c ----------------------------------------------------------------------------- +@node Pascal interface, References, BGI interface, A User Manual For GRX2 +@unnumberedsec Pascal interface + +The Pascal (gpc) support is produced by two unit files @strong{pascal/grx.pas} +and @strong{pascal/bgi/graph.pas} which are the Pascal translations of the C +header files @strong{include/grx20.h + include/grxkeys.h} +and @strong{include/libbcc.h}. + +Compilation of the examples and installation of the header files is allowed +by setting INCLUDE_GPC_SUPPORT=y in makedef.grx. + +The unit files contain at the beginning instructions to load the required +libraries (libgrx20..., depending on the system) and addon libraries +(e.g. libpng). +You can uncomment manually the addons you want. +You can also use the configure script which does that automatically, +together with editing the makedefs.grx file. + +By default they are installed in a @strong{units} directory below the +INSTALLDIR directory. But you can put them where you like. + +@c ----------------------------------------------------------------------------- +@node References, , Pascal interface, A User Manual For GRX2 +@unnumberedsec References + +@multitable {MGRX site (fork from GRX)----}{----http://www.libpng.org/pub/png/libpng.html} +@item Official GRX site +@tab @uref{http://grx.gnu.de} +@item GRX mailing list archive +@tab @uref{http://grx.gnu.de/archive/grx/en/} +@item MGRX site (fork from GRX) +@tab @uref{http://mgrx.fgrim.com} +@item NetPbm distribution +@tab @uref{http://netpbm.sourceforge.net} +@item PNG library +@tab @uref{http://www.libpng.org/pub/png/libpng.html} +@item JPEG library +@tab @uref{http://www.ijg.org} +@item TIFF library +@tab @uref{http://www.remotesensing.org/libtiff/} +@end multitable + +@c ----------------------------------------------------------------------------- + diff --git a/thirdparty/grx249/doc/tex/makinf.bat b/thirdparty/grx249/doc/tex/makinf.bat new file mode 100755 index 0000000..c63f32d --- /dev/null +++ b/thirdparty/grx249/doc/tex/makinf.bat @@ -0,0 +1,7 @@ +makeinfo --no-split grx2.tex +makeinfo --html --no-split grx2.tex +d2u grx* +texi2dvi grx2.tex +dvips grx2 +d2u grx2.ps +texi2dvi --pdf grx2.tex diff --git a/thirdparty/grx249/doc/tex/readme b/thirdparty/grx249/doc/tex/readme new file mode 100644 index 0000000..ceebdbb --- /dev/null +++ b/thirdparty/grx249/doc/tex/readme @@ -0,0 +1,2 @@ +Here are files I use to generate the grxvvvum.[inf/html/dvi/pdf] file before every release. +It is no necesary to do nothing with them. diff --git a/thirdparty/grx249/doc/watcom.txt b/thirdparty/grx249/doc/watcom.txt new file mode 100644 index 0000000..2bf472a --- /dev/null +++ b/thirdparty/grx249/doc/watcom.txt @@ -0,0 +1,53 @@ +WATCOM C++ 11.0 Port of GRX2.2x +Contact - Gary Sands (gsands@stbni.co.uk) +The port has been caried out for a 32-bit library for DOS4GW binaries. + +Compilation +-------------------------------------------- +NOW HAVE REAL MAKE FILES. +The project and target files were a real pain to maintain! +Run "WMAKE -F MAKEFILE.WAT" in the GRX base directory to +build the library and test executables. The library builds +to "LIB/WATCOM32" and the tests build to "BIN". Run +"WMAKE -F MAKEFILE.WAT CLEAN" to delete the object and +link files. You may see a few warnings from the test +programs - DON'T PANIC. The WATCOM compiler is just very +pedantic. + +Running "WMAKE DEBUG=1 -F MAKEFILE.WAT" should make a +debug build of the library. + +If you want to make your own .PRJ and .TGT files for the IDE +remember to compile everything with __MSDOS__ and +SMALL_STACK defined (-d option in source options). There +may be a few more definitions necessary. Check the top level +makefile to see what the compiler options are if you have +problems or see a large amount of warning messages. + +What works +-------------------------------------------- +All the test programs shipped with GRX2.29 should work. +VBE2 Protected Mode Interface and Linear Frame Buffer Support now +compile and work. Don't forget to copy any .DAT files the test +programs need to the "BIN" directory. + +What does not work +-------------------------------------------- +16-bit Real Mode Library - I have not looked at it yet. +// Added a few fixes for 16-bit mode but not finished. HSC + +What needs to be done +-------------------------------------------- +Speed enhancements - need Watcom versions of the DJGPP/GNU inline +assembly routines. In particular the line drawing and fill algorithms. +Some of the fills have been written by Hartmut. He has put a lot of +effort turning my hacks for Watcom into a structured part of GRX and +deserves most of the credit for this port. + +** REMEMBER THAT THE DEFAULT STACK SIZE IS 3K SO YOU MAY HAVE TO +ADJUST THAT IN THE LINKER OPTIONS OF YOUR EXECUTABLE - This is less +of a problem now if you define SMALL_STACK ** + +And of course best of luck using GRX with Watcom! + + diff --git a/thirdparty/grx249/fonts/char11.fnt b/thirdparty/grx249/fonts/char11.fnt new file mode 100644 index 0000000..9b04d63 --- /dev/null +++ b/thirdparty/grx249/fonts/char11.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04c36ce034058fb68aa347ff8ce117c7f8e890b1c6079b0151cb76da3701cb8c +size 4626 diff --git a/thirdparty/grx249/fonts/char11b.fnt b/thirdparty/grx249/fonts/char11b.fnt new file mode 100644 index 0000000..dd66e38 --- /dev/null +++ b/thirdparty/grx249/fonts/char11b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0ea7c938e2d74cee4889412a81efc22f27983b50bed44ee33ba6efa523372ba +size 4658 diff --git a/thirdparty/grx249/fonts/char11bi.fnt b/thirdparty/grx249/fonts/char11bi.fnt new file mode 100644 index 0000000..e481aea --- /dev/null +++ b/thirdparty/grx249/fonts/char11bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c47603b4da61e5f9842e8019de2205f083a908d9ab76aff956b89b5c0c09415 +size 4657 diff --git a/thirdparty/grx249/fonts/char11i.fnt b/thirdparty/grx249/fonts/char11i.fnt new file mode 100644 index 0000000..82e7e21 --- /dev/null +++ b/thirdparty/grx249/fonts/char11i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3644b2c4a3ab7926abd70ad8b81770deba0e8afc628530f68a4ad109dd39ccd3 +size 4626 diff --git a/thirdparty/grx249/fonts/char14.fnt b/thirdparty/grx249/fonts/char14.fnt new file mode 100644 index 0000000..40a002f --- /dev/null +++ b/thirdparty/grx249/fonts/char14.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab72f2a6094db8188fc85557a2c5f87409feb4d8c4d61bca7ea5ef6cf1d55065 +size 5594 diff --git a/thirdparty/grx249/fonts/char14b.fnt b/thirdparty/grx249/fonts/char14b.fnt new file mode 100644 index 0000000..8b80da5 --- /dev/null +++ b/thirdparty/grx249/fonts/char14b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2378e0d12a7e1e91375921688d464a70c41458f4b76c9809ae5c18e98dc36210 +size 5718 diff --git a/thirdparty/grx249/fonts/char14bi.fnt b/thirdparty/grx249/fonts/char14bi.fnt new file mode 100644 index 0000000..632abb0 --- /dev/null +++ b/thirdparty/grx249/fonts/char14bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0b90d45b662fc9f83b24f8e3eccaa943f4c2ef3ffc80914e72457c320b24898 +size 5662 diff --git a/thirdparty/grx249/fonts/char14i.fnt b/thirdparty/grx249/fonts/char14i.fnt new file mode 100644 index 0000000..a772df9 --- /dev/null +++ b/thirdparty/grx249/fonts/char14i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6146f52bb5479b02d23fc41e3218f8d7dba2f4440162b405c0bbf7e031879ab2 +size 5580 diff --git a/thirdparty/grx249/fonts/char16.fnt b/thirdparty/grx249/fonts/char16.fnt new file mode 100644 index 0000000..e4e5278 --- /dev/null +++ b/thirdparty/grx249/fonts/char16.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b3bb92547f7440438f3f5ca343416cb8b57abe468ee09fd41a5cfbf55613794f +size 6468 diff --git a/thirdparty/grx249/fonts/char16b.fnt b/thirdparty/grx249/fonts/char16b.fnt new file mode 100644 index 0000000..290b094 --- /dev/null +++ b/thirdparty/grx249/fonts/char16b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ba0af27ec3f5b16f8a1f5e10ffc8650f6e471e8ad6fcfe06411a57fdf747b33e +size 6722 diff --git a/thirdparty/grx249/fonts/char16bi.fnt b/thirdparty/grx249/fonts/char16bi.fnt new file mode 100644 index 0000000..b5f5bb1 --- /dev/null +++ b/thirdparty/grx249/fonts/char16bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ad88118fd0a4e971fd842adfaf6ee876db6163acae61582f30a6a98f4e55313 +size 6754 diff --git a/thirdparty/grx249/fonts/char16i.fnt b/thirdparty/grx249/fonts/char16i.fnt new file mode 100644 index 0000000..db11b90 --- /dev/null +++ b/thirdparty/grx249/fonts/char16i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:918457c08b498e025e9cd52968595298b47718a8e22f144af3dca945d69b5570 +size 6580 diff --git a/thirdparty/grx249/fonts/char18.fnt b/thirdparty/grx249/fonts/char18.fnt new file mode 100644 index 0000000..df1cfcd --- /dev/null +++ b/thirdparty/grx249/fonts/char18.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92d792c840477ed38a3915412d285b8b5ce88580ed8cfb1d49f286cc26138c3a +size 7366 diff --git a/thirdparty/grx249/fonts/char18b.fnt b/thirdparty/grx249/fonts/char18b.fnt new file mode 100644 index 0000000..3cc8651 --- /dev/null +++ b/thirdparty/grx249/fonts/char18b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0f6c9fd9f94537a0dc0c089fc3901e8be39a3a8549a6f22651e5aba2610298c +size 8516 diff --git a/thirdparty/grx249/fonts/char18bi.fnt b/thirdparty/grx249/fonts/char18bi.fnt new file mode 100644 index 0000000..221f502 --- /dev/null +++ b/thirdparty/grx249/fonts/char18bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84bd5c3c423e786c9693f42cd1856ca7597608c79468f4bfa8fc46b074357e4d +size 8462 diff --git a/thirdparty/grx249/fonts/char18i.fnt b/thirdparty/grx249/fonts/char18i.fnt new file mode 100644 index 0000000..b9c262b --- /dev/null +++ b/thirdparty/grx249/fonts/char18i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be5a2ee6a8a2902c9715cf433cfdd5d7b5f429f0df59683d58ee9e34202d9e63 +size 7522 diff --git a/thirdparty/grx249/fonts/char23.fnt b/thirdparty/grx249/fonts/char23.fnt new file mode 100644 index 0000000..e7a9be3 --- /dev/null +++ b/thirdparty/grx249/fonts/char23.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:af8b0a6b6c2440cc69f82f2d0080c1f7ffce51ecb2b15f210725c19f375fe393 +size 10905 diff --git a/thirdparty/grx249/fonts/char23b.fnt b/thirdparty/grx249/fonts/char23b.fnt new file mode 100644 index 0000000..7379d37 --- /dev/null +++ b/thirdparty/grx249/fonts/char23b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a0a0c91f472bc49b073f14ca7ca773674d724254c97dda1a4f512340cd05139e +size 11271 diff --git a/thirdparty/grx249/fonts/char23bi.fnt b/thirdparty/grx249/fonts/char23bi.fnt new file mode 100644 index 0000000..cc7d2b4 --- /dev/null +++ b/thirdparty/grx249/fonts/char23bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:80988a1f0090bac72502335a62fd7ba6b5adad0f738338980ca1f5c8be3f075c +size 11363 diff --git a/thirdparty/grx249/fonts/char23i.fnt b/thirdparty/grx249/fonts/char23i.fnt new file mode 100644 index 0000000..9b7c470 --- /dev/null +++ b/thirdparty/grx249/fonts/char23i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:07851b3dde94f1b75dea2fb65c935488ab07f33e8171357bf1ccbce4ebf35941 +size 10963 diff --git a/thirdparty/grx249/fonts/char30.fnt b/thirdparty/grx249/fonts/char30.fnt new file mode 100644 index 0000000..97b134f --- /dev/null +++ b/thirdparty/grx249/fonts/char30.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ebcf6faa4440cd730b8ea7e9f249667bca7432a3d0d447302b82690b2044ddbd +size 15197 diff --git a/thirdparty/grx249/fonts/char30b.fnt b/thirdparty/grx249/fonts/char30b.fnt new file mode 100644 index 0000000..90ab77a --- /dev/null +++ b/thirdparty/grx249/fonts/char30b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b93c602c3a74bc8878461e7f1e3b40830f1c63d41474ad488a8eba9efb006a09 +size 16725 diff --git a/thirdparty/grx249/fonts/char30bi.fnt b/thirdparty/grx249/fonts/char30bi.fnt new file mode 100644 index 0000000..c2ed61e --- /dev/null +++ b/thirdparty/grx249/fonts/char30bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6202bb3ea976396a6cd2d75282fc7ad59b46fb40478bdcc7f664e3739496a8f7 +size 16815 diff --git a/thirdparty/grx249/fonts/char30i.fnt b/thirdparty/grx249/fonts/char30i.fnt new file mode 100644 index 0000000..7fd8b0c --- /dev/null +++ b/thirdparty/grx249/fonts/char30i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b2acf7c9624a7e15f86924036e163a5ce19de04ffeb84ac5e2ec9cdfb10e25d +size 15737 diff --git a/thirdparty/grx249/fonts/char40.fnt b/thirdparty/grx249/fonts/char40.fnt new file mode 100644 index 0000000..d664749 --- /dev/null +++ b/thirdparty/grx249/fonts/char40.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ebc6cfbe9602fabb8fdfd3fdf7244f746901c95cdf3c0ee55a06e4580131945f +size 26459 diff --git a/thirdparty/grx249/fonts/char40b.fnt b/thirdparty/grx249/fonts/char40b.fnt new file mode 100644 index 0000000..b670d74 --- /dev/null +++ b/thirdparty/grx249/fonts/char40b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f4f44987c0c124446e762c4ae7ed05571d370238319ed789ee4ac5c3b0ba1e4 +size 28137 diff --git a/thirdparty/grx249/fonts/char40bi.fnt b/thirdparty/grx249/fonts/char40bi.fnt new file mode 100644 index 0000000..d04ec24 --- /dev/null +++ b/thirdparty/grx249/fonts/char40bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f53d22a2f86c7646c9466b313465cd976cbf748a49d57020a9d7ac3e532ab7bd +size 28817 diff --git a/thirdparty/grx249/fonts/char40i.fnt b/thirdparty/grx249/fonts/char40i.fnt new file mode 100644 index 0000000..e0592c8 --- /dev/null +++ b/thirdparty/grx249/fonts/char40i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd0b51357b76118a1496e2cad0cd512646d9b106924cdf9e07a86246a30af441 +size 26539 diff --git a/thirdparty/grx249/fonts/cour11.fnt b/thirdparty/grx249/fonts/cour11.fnt new file mode 100644 index 0000000..ccfcf3b --- /dev/null +++ b/thirdparty/grx249/fonts/cour11.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d55d623c1482adee621627c60ab623c69a8d6a4ad3ed0a39dec75067dc1d682 +size 2858 diff --git a/thirdparty/grx249/fonts/cour11b.fnt b/thirdparty/grx249/fonts/cour11b.fnt new file mode 100644 index 0000000..5f21459 --- /dev/null +++ b/thirdparty/grx249/fonts/cour11b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:37acd5bec3a5178c13b9d20146286182419cf84abdb9a903efbd06468312db85 +size 2856 diff --git a/thirdparty/grx249/fonts/cour11bi.fnt b/thirdparty/grx249/fonts/cour11bi.fnt new file mode 100644 index 0000000..95ece74 --- /dev/null +++ b/thirdparty/grx249/fonts/cour11bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3011be65ddba335b87b1080ea4c6230336a2ea027edaf0dfd450ac214c11722c +size 2856 diff --git a/thirdparty/grx249/fonts/cour11i.fnt b/thirdparty/grx249/fonts/cour11i.fnt new file mode 100644 index 0000000..4f33e11 --- /dev/null +++ b/thirdparty/grx249/fonts/cour11i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a65747e873bc1bc6abeb24936bd53e4cb2d50a578c96440af7d172053a2ecd79 +size 2858 diff --git a/thirdparty/grx249/fonts/cour12.fnt b/thirdparty/grx249/fonts/cour12.fnt new file mode 100644 index 0000000..b719256 --- /dev/null +++ b/thirdparty/grx249/fonts/cour12.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:00e93171c37110b1c5498dd9a2be7e351f68c24b048afede46c12deccf4f0ffd +size 2948 diff --git a/thirdparty/grx249/fonts/cour12b.fnt b/thirdparty/grx249/fonts/cour12b.fnt new file mode 100644 index 0000000..b438e01 --- /dev/null +++ b/thirdparty/grx249/fonts/cour12b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d701411d0cb7b70a15aa0638c55ac9cf6c8e0a3366c9f249af09927ab6eab49b +size 2946 diff --git a/thirdparty/grx249/fonts/cour12bi.fnt b/thirdparty/grx249/fonts/cour12bi.fnt new file mode 100644 index 0000000..951c3f1 --- /dev/null +++ b/thirdparty/grx249/fonts/cour12bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9bbb8a2fcdabf5ddd169d766c27ea47d413cfacd9006fe0845b72866f906a4a +size 4086 diff --git a/thirdparty/grx249/fonts/cour12i.fnt b/thirdparty/grx249/fonts/cour12i.fnt new file mode 100644 index 0000000..e1f8581 --- /dev/null +++ b/thirdparty/grx249/fonts/cour12i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c8488e72a678280afeca3a2846bab4d3374c573b27ac3b118a28c9a368e7933 +size 2948 diff --git a/thirdparty/grx249/fonts/cour14.fnt b/thirdparty/grx249/fonts/cour14.fnt new file mode 100644 index 0000000..5d2c8a7 --- /dev/null +++ b/thirdparty/grx249/fonts/cour14.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6f314045bbc473be7d1196c17c9aa905a277c0510b8415948565caea55761da +size 3145 diff --git a/thirdparty/grx249/fonts/cour14b.fnt b/thirdparty/grx249/fonts/cour14b.fnt new file mode 100644 index 0000000..64fb25a --- /dev/null +++ b/thirdparty/grx249/fonts/cour14b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da17b47345fd17e7505b774c7f68b95c7d0cde4db9d7b50b70ead42e1e86b543 +size 3144 diff --git a/thirdparty/grx249/fonts/cour14bi.fnt b/thirdparty/grx249/fonts/cour14bi.fnt new file mode 100644 index 0000000..86b9f40 --- /dev/null +++ b/thirdparty/grx249/fonts/cour14bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c9658fe82f56bbed39d764c4ed52cfdc4b9aac9089c7958feefed8c0d034c3c +size 4473 diff --git a/thirdparty/grx249/fonts/cour14i.fnt b/thirdparty/grx249/fonts/cour14i.fnt new file mode 100644 index 0000000..db22ade --- /dev/null +++ b/thirdparty/grx249/fonts/cour14i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c9771dd0b49f8ab7a965eaa7c4cfd296160b39ea0fd779b682a100bf070f109 +size 4475 diff --git a/thirdparty/grx249/fonts/cour16.fnt b/thirdparty/grx249/fonts/cour16.fnt new file mode 100644 index 0000000..1e5365f --- /dev/null +++ b/thirdparty/grx249/fonts/cour16.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c83cb3f7e5bc52b77664c175b712891cbdbd4fff821340ab03e8c85d47bccce5 +size 4855 diff --git a/thirdparty/grx249/fonts/cour16b.fnt b/thirdparty/grx249/fonts/cour16b.fnt new file mode 100644 index 0000000..9f2ba25 --- /dev/null +++ b/thirdparty/grx249/fonts/cour16b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:694c22dc7f8be068ce4b7a37ebccafdcc57dc4a20ce1e21bbbcb1e50c0cac772 +size 4853 diff --git a/thirdparty/grx249/fonts/cour16bi.fnt b/thirdparty/grx249/fonts/cour16bi.fnt new file mode 100644 index 0000000..200252b --- /dev/null +++ b/thirdparty/grx249/fonts/cour16bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dda32267d811bba7683de8ae56385ca4c39ff83c883989f7c095a4c8a9f22bd9 +size 4853 diff --git a/thirdparty/grx249/fonts/cour16i.fnt b/thirdparty/grx249/fonts/cour16i.fnt new file mode 100644 index 0000000..e29d333 --- /dev/null +++ b/thirdparty/grx249/fonts/cour16i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:32528fdc5e57612ccc80d8722cdf8e2937c5b15c331113a8e0af85e73e76587d +size 4855 diff --git a/thirdparty/grx249/fonts/cour20.fnt b/thirdparty/grx249/fonts/cour20.fnt new file mode 100644 index 0000000..2e5219f --- /dev/null +++ b/thirdparty/grx249/fonts/cour20.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b838cb20f160582227225c5c5aba925b8209cd1c1fb77723ffc671a98402a96e +size 5609 diff --git a/thirdparty/grx249/fonts/cour20b.fnt b/thirdparty/grx249/fonts/cour20b.fnt new file mode 100644 index 0000000..e744c8e --- /dev/null +++ b/thirdparty/grx249/fonts/cour20b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea3a7235d0bff5ea45189e6d48bf8bdeefac1e0c4f9ba1195cfff90b7ad89be8 +size 5614 diff --git a/thirdparty/grx249/fonts/cour20bi.fnt b/thirdparty/grx249/fonts/cour20bi.fnt new file mode 100644 index 0000000..f50f808 --- /dev/null +++ b/thirdparty/grx249/fonts/cour20bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a4ec6fdbc22daba4f84bec69859086257b29093637c7b98436bb97679802c34 +size 5614 diff --git a/thirdparty/grx249/fonts/cour20i.fnt b/thirdparty/grx249/fonts/cour20i.fnt new file mode 100644 index 0000000..a5acb1f --- /dev/null +++ b/thirdparty/grx249/fonts/cour20i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec0fa3e41684278d6b2dda66a93fa076c194aa6093bbc8fd81f39b27b4d66821 +size 5609 diff --git a/thirdparty/grx249/fonts/cour25.fnt b/thirdparty/grx249/fonts/cour25.fnt new file mode 100644 index 0000000..3d17fe2 --- /dev/null +++ b/thirdparty/grx249/fonts/cour25.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3def672d047421077a3f2d586c1b73d5502dd0256919a9d7b770c9e642158e2c +size 6559 diff --git a/thirdparty/grx249/fonts/cour25b.fnt b/thirdparty/grx249/fonts/cour25b.fnt new file mode 100644 index 0000000..33f0101 --- /dev/null +++ b/thirdparty/grx249/fonts/cour25b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c29ef4d3e8f42fc8066adb1dab42dafdf13c19c507e1271fa14b58a8f2805a37 +size 6564 diff --git a/thirdparty/grx249/fonts/cour25bi.fnt b/thirdparty/grx249/fonts/cour25bi.fnt new file mode 100644 index 0000000..5f2b559 --- /dev/null +++ b/thirdparty/grx249/fonts/cour25bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6000c593437a611760703d51d3033764f222efd9f7e691047a3e4644e4fe0ff4 +size 8939 diff --git a/thirdparty/grx249/fonts/cour25i.fnt b/thirdparty/grx249/fonts/cour25i.fnt new file mode 100644 index 0000000..808994a --- /dev/null +++ b/thirdparty/grx249/fonts/cour25i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e370ca188133ca3bbb3ca458b8d6a0de389fee6b740c290f45dd0061fd571cfc +size 8934 diff --git a/thirdparty/grx249/fonts/cour34.fnt b/thirdparty/grx249/fonts/cour34.fnt new file mode 100644 index 0000000..3cbb8e4 --- /dev/null +++ b/thirdparty/grx249/fonts/cour34.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d95725374a316cc780e2335c1ef32eefdcd346e9c87f32a2d32167f099c90e7c +size 11533 diff --git a/thirdparty/grx249/fonts/cour34b.fnt b/thirdparty/grx249/fonts/cour34b.fnt new file mode 100644 index 0000000..287cdf9 --- /dev/null +++ b/thirdparty/grx249/fonts/cour34b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04990b3e7bce36bec2e03abd9f0a0cd45570f343b330acbba31ec13ecb9bd770 +size 11531 diff --git a/thirdparty/grx249/fonts/cour34bi.fnt b/thirdparty/grx249/fonts/cour34bi.fnt new file mode 100644 index 0000000..3076dc0 --- /dev/null +++ b/thirdparty/grx249/fonts/cour34bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a94ace3fca044a9cdf1da6511ef4bf9b2448920731f38fb74d5305517b683ff1 +size 14761 diff --git a/thirdparty/grx249/fonts/cour34i.fnt b/thirdparty/grx249/fonts/cour34i.fnt new file mode 100644 index 0000000..ee3873f --- /dev/null +++ b/thirdparty/grx249/fonts/cour34i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a38b4b4878bb93ba1e752ee7c0f81510a624ee5bbd33a74368e3af1ffea73240 +size 11533 diff --git a/thirdparty/grx249/fonts/helv11.fnt b/thirdparty/grx249/fonts/helv11.fnt new file mode 100644 index 0000000..85553a0 --- /dev/null +++ b/thirdparty/grx249/fonts/helv11.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c934d8f90e7792ffd9acd2c666f8cbd9be92b464da6370a2b82b787586a2c764 +size 3112 diff --git a/thirdparty/grx249/fonts/helv11b.fnt b/thirdparty/grx249/fonts/helv11b.fnt new file mode 100644 index 0000000..2f7e7e5 --- /dev/null +++ b/thirdparty/grx249/fonts/helv11b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:60ed5e029f311b44319423a355ef44840cb36d52dc2ebdb42c2be5b00db51b9d +size 3122 diff --git a/thirdparty/grx249/fonts/helv11bi.fnt b/thirdparty/grx249/fonts/helv11bi.fnt new file mode 100644 index 0000000..f939bc1 --- /dev/null +++ b/thirdparty/grx249/fonts/helv11bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28a9fbc76b772fac800ad094f0599acc73fb1e5fa8549734b1c012bb628c1f24 +size 3122 diff --git a/thirdparty/grx249/fonts/helv11i.fnt b/thirdparty/grx249/fonts/helv11i.fnt new file mode 100644 index 0000000..7c44cf8 --- /dev/null +++ b/thirdparty/grx249/fonts/helv11i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d4285d6a82770d8cdc8783518275411a3195637e7f1ccd04b4b74c53cc48df7 +size 3113 diff --git a/thirdparty/grx249/fonts/helv13.fnt b/thirdparty/grx249/fonts/helv13.fnt new file mode 100644 index 0000000..b33a3af --- /dev/null +++ b/thirdparty/grx249/fonts/helv13.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:61882c5ef0a9abeb9deb7d158cb0646191805a35f884542d3d10c26e12664cc3 +size 3345 diff --git a/thirdparty/grx249/fonts/helv13b.fnt b/thirdparty/grx249/fonts/helv13b.fnt new file mode 100644 index 0000000..75489ac --- /dev/null +++ b/thirdparty/grx249/fonts/helv13b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed3f004dddfd87aad45f209ec19e71a4e53aae1d8103ef8e5b8c59680d16c8c3 +size 3357 diff --git a/thirdparty/grx249/fonts/helv13bi.fnt b/thirdparty/grx249/fonts/helv13bi.fnt new file mode 100644 index 0000000..9641c81 --- /dev/null +++ b/thirdparty/grx249/fonts/helv13bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20015f391349b6d8adf8795b9bf9259ec6c0efb67f5d3a14c42942e7912f225c +size 3396 diff --git a/thirdparty/grx249/fonts/helv13i.fnt b/thirdparty/grx249/fonts/helv13i.fnt new file mode 100644 index 0000000..54746a8 --- /dev/null +++ b/thirdparty/grx249/fonts/helv13i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e41a4088d5acabf7078749bbd08c554de654a06f8d34967d5a68ca0bb7e3dd0 +size 3346 diff --git a/thirdparty/grx249/fonts/helv15.fnt b/thirdparty/grx249/fonts/helv15.fnt new file mode 100644 index 0000000..fa2339f --- /dev/null +++ b/thirdparty/grx249/fonts/helv15.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0952c4870ec6cee65d63f5d6e3aaf7b6c3942de93ea4d3d6ecc1bdb0b98ff2a +size 3768 diff --git a/thirdparty/grx249/fonts/helv15b.fnt b/thirdparty/grx249/fonts/helv15b.fnt new file mode 100644 index 0000000..3862333 --- /dev/null +++ b/thirdparty/grx249/fonts/helv15b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:89464ee7788c6ccf1126430cff74f4d65a3c76f6625b464311b842207a5a2531 +size 3752 diff --git a/thirdparty/grx249/fonts/helv15bi.fnt b/thirdparty/grx249/fonts/helv15bi.fnt new file mode 100644 index 0000000..ad78b2c --- /dev/null +++ b/thirdparty/grx249/fonts/helv15bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3c883addd9fdec2931c77293a2272b49441ae471f3c84a256518b550a1a07bae +size 3977 diff --git a/thirdparty/grx249/fonts/helv15i.fnt b/thirdparty/grx249/fonts/helv15i.fnt new file mode 100644 index 0000000..d8276a6 --- /dev/null +++ b/thirdparty/grx249/fonts/helv15i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8876e639a7d1aabfa1c5731beac01337db72b9dcf53e680edae711edaf1c35b5 +size 3919 diff --git a/thirdparty/grx249/fonts/helv17.fnt b/thirdparty/grx249/fonts/helv17.fnt new file mode 100644 index 0000000..8526ce1 --- /dev/null +++ b/thirdparty/grx249/fonts/helv17.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ffaf2922a515ea33ea92173aca62160f695a4f16f77fd9bc7eebc73baf44e285 +size 4200 diff --git a/thirdparty/grx249/fonts/helv17b.fnt b/thirdparty/grx249/fonts/helv17b.fnt new file mode 100644 index 0000000..3e315cc --- /dev/null +++ b/thirdparty/grx249/fonts/helv17b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ff51b756754097b856d0377f371163c7a7b76c091d283b83c478f17df1670e7 +size 4386 diff --git a/thirdparty/grx249/fonts/helv17bi.fnt b/thirdparty/grx249/fonts/helv17bi.fnt new file mode 100644 index 0000000..eb2db17 --- /dev/null +++ b/thirdparty/grx249/fonts/helv17bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1211c73640d54275e9f79e9158eb182ecba16da0d7d019c1d626843422481f9c +size 4811 diff --git a/thirdparty/grx249/fonts/helv17i.fnt b/thirdparty/grx249/fonts/helv17i.fnt new file mode 100644 index 0000000..c58d76d --- /dev/null +++ b/thirdparty/grx249/fonts/helv17i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4347b0927fa3facf9eae939a991909e6f1c859cd629beee5f09ac2f9f8d0cea3 +size 4388 diff --git a/thirdparty/grx249/fonts/helv22.fnt b/thirdparty/grx249/fonts/helv22.fnt new file mode 100644 index 0000000..6a9dd89 --- /dev/null +++ b/thirdparty/grx249/fonts/helv22.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4e6d0a3d0b73711f3d57d736d2662c061e7710f62d66e588f918f0e33e457e6 +size 5710 diff --git a/thirdparty/grx249/fonts/helv22b.fnt b/thirdparty/grx249/fonts/helv22b.fnt new file mode 100644 index 0000000..93541e7 --- /dev/null +++ b/thirdparty/grx249/fonts/helv22b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfc7b6117aa898dfa3b126c4dec0637c7663d78fc4359bb4843482c2940f8302 +size 5732 diff --git a/thirdparty/grx249/fonts/helv22bi.fnt b/thirdparty/grx249/fonts/helv22bi.fnt new file mode 100644 index 0000000..7aad81c --- /dev/null +++ b/thirdparty/grx249/fonts/helv22bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c7703c7b2bd7f7cec47340a1f088aef795fae7dfa6926d2a1080602f4e2c457 +size 5930 diff --git a/thirdparty/grx249/fonts/helv22i.fnt b/thirdparty/grx249/fonts/helv22i.fnt new file mode 100644 index 0000000..909ffc0 --- /dev/null +++ b/thirdparty/grx249/fonts/helv22i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1b5cdc09bf383dcc58416e140bd0f2428bd4bf13f075b06d685a59202d68f9c +size 5799 diff --git a/thirdparty/grx249/fonts/helv29.fnt b/thirdparty/grx249/fonts/helv29.fnt new file mode 100644 index 0000000..94a473d --- /dev/null +++ b/thirdparty/grx249/fonts/helv29.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:11f69058526ab3742d24af3aec7494f2bb25624e2d6605bfa1fc968f80245604 +size 7511 diff --git a/thirdparty/grx249/fonts/helv29b.fnt b/thirdparty/grx249/fonts/helv29b.fnt new file mode 100644 index 0000000..aaee29d --- /dev/null +++ b/thirdparty/grx249/fonts/helv29b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b5a2303339128d311801feda19204fb778d85f4838dbb9b022a79dbc5527265 +size 7713 diff --git a/thirdparty/grx249/fonts/helv29bi.fnt b/thirdparty/grx249/fonts/helv29bi.fnt new file mode 100644 index 0000000..2b0a23d --- /dev/null +++ b/thirdparty/grx249/fonts/helv29bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:503d63640fa933923b2a163577a8ba06a675bc3592a2bbc0fdea21ce748e4afc +size 8438 diff --git a/thirdparty/grx249/fonts/helv29i.fnt b/thirdparty/grx249/fonts/helv29i.fnt new file mode 100644 index 0000000..65708a8 --- /dev/null +++ b/thirdparty/grx249/fonts/helv29i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db5e57f92fcce2363e233fc15656f8ece7725d110fa2d01fe83726c4373051eb +size 8063 diff --git a/thirdparty/grx249/fonts/helv38.fnt b/thirdparty/grx249/fonts/helv38.fnt new file mode 100644 index 0000000..2befa6a --- /dev/null +++ b/thirdparty/grx249/fonts/helv38.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67f3aff9f3e3337e457ff3846a7ea4165192d09cb1b1b5201c526e55cd3afb41 +size 11708 diff --git a/thirdparty/grx249/fonts/helv38b.fnt b/thirdparty/grx249/fonts/helv38b.fnt new file mode 100644 index 0000000..af505ee --- /dev/null +++ b/thirdparty/grx249/fonts/helv38b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:767bcffcb0cbb0b1eb02a2185dc953ebd5061ae34111a8a68d91da805e4c6a7a +size 12276 diff --git a/thirdparty/grx249/fonts/helv38bi.fnt b/thirdparty/grx249/fonts/helv38bi.fnt new file mode 100644 index 0000000..cd7a586 --- /dev/null +++ b/thirdparty/grx249/fonts/helv38bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b58b3a685ecfcebefd74e9e9724862f59d28f197293a317ce292e1b274d19cd7 +size 12884 diff --git a/thirdparty/grx249/fonts/helv38i.fnt b/thirdparty/grx249/fonts/helv38i.fnt new file mode 100644 index 0000000..82bfd9e --- /dev/null +++ b/thirdparty/grx249/fonts/helv38i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc8fd5c48f3b810880f99a43de0f6cc24e0dba02b4ab960cf6ea5da2f69f25eb +size 12734 diff --git a/thirdparty/grx249/fonts/lucb11.fnt b/thirdparty/grx249/fonts/lucb11.fnt new file mode 100644 index 0000000..d0a1a53 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb11.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7cdde45be108c9957aa459cb02734d595aefbc7c2cb4848be1b4f60d7a33a01d +size 3302 diff --git a/thirdparty/grx249/fonts/lucb11b.fnt b/thirdparty/grx249/fonts/lucb11b.fnt new file mode 100644 index 0000000..1f821ba --- /dev/null +++ b/thirdparty/grx249/fonts/lucb11b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01f945d7d94f0435bafcfc6b08fe50042ec2c0b2276fc64873dff829ea57bc30 +size 3302 diff --git a/thirdparty/grx249/fonts/lucb11bi.fnt b/thirdparty/grx249/fonts/lucb11bi.fnt new file mode 100644 index 0000000..499a05a --- /dev/null +++ b/thirdparty/grx249/fonts/lucb11bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:72ee960ba3f8d960b277a1b9be6f470fb9d6fa3ec661c5b0f8af89659026fe8a +size 3346 diff --git a/thirdparty/grx249/fonts/lucb11i.fnt b/thirdparty/grx249/fonts/lucb11i.fnt new file mode 100644 index 0000000..c5b2da3 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb11i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f2c5f9067ba9215d8365fa21571a6086e633a833c9757f8bc615aaa1abf63281 +size 3291 diff --git a/thirdparty/grx249/fonts/lucb12.fnt b/thirdparty/grx249/fonts/lucb12.fnt new file mode 100644 index 0000000..2bb1ea4 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb12.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:97641b4de61078791cd70df3d177b66b104ec06a51d6fe1c180d5f4958f3c0b5 +size 3673 diff --git a/thirdparty/grx249/fonts/lucb12b.fnt b/thirdparty/grx249/fonts/lucb12b.fnt new file mode 100644 index 0000000..1d84d47 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb12b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:98f47a8bfb678ce1c2ce9db437f3eb899096e25bcd3692746c80d0dc5e56d65b +size 3697 diff --git a/thirdparty/grx249/fonts/lucb12bi.fnt b/thirdparty/grx249/fonts/lucb12bi.fnt new file mode 100644 index 0000000..6f243b9 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb12bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5727de12923ad08aa2962406d0d8051f070adad167cfa157df57f206523dd0f5 +size 3829 diff --git a/thirdparty/grx249/fonts/lucb12i.fnt b/thirdparty/grx249/fonts/lucb12i.fnt new file mode 100644 index 0000000..c8c3bf9 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb12i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d4eb265756b34d55d19e8d2a3e3268384b68756e55591cfd336de88532f80f1 +size 3757 diff --git a/thirdparty/grx249/fonts/lucb15.fnt b/thirdparty/grx249/fonts/lucb15.fnt new file mode 100644 index 0000000..ffc21d7 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb15.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0791e65951092058a95c10c91026a7e988ca8dcbdc46de27024d93cda5096774 +size 4789 diff --git a/thirdparty/grx249/fonts/lucb15b.fnt b/thirdparty/grx249/fonts/lucb15b.fnt new file mode 100644 index 0000000..7a9c6a9 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb15b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb0d45db30e7ed3ab8711a6002bdde7b64c10df72d9c4177ea219a25e25ceaf5 +size 4939 diff --git a/thirdparty/grx249/fonts/lucb15bi.fnt b/thirdparty/grx249/fonts/lucb15bi.fnt new file mode 100644 index 0000000..ff68a3b --- /dev/null +++ b/thirdparty/grx249/fonts/lucb15bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12c288e34eb5ac244f5f50cad7814e278103448961e7256655c31ca5b8661696 +size 5059 diff --git a/thirdparty/grx249/fonts/lucb15i.fnt b/thirdparty/grx249/fonts/lucb15i.fnt new file mode 100644 index 0000000..52cb6b2 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb15i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15368685bcd6b56cdaec26a1f0af1018af458592137edb707e8627fca98c722e +size 4999 diff --git a/thirdparty/grx249/fonts/lucb17.fnt b/thirdparty/grx249/fonts/lucb17.fnt new file mode 100644 index 0000000..b975454 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb17.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:45ff77f487cd9ae9d27c16a63c9a9cb04eda26e24d256d44dd99e8688b089183 +size 6318 diff --git a/thirdparty/grx249/fonts/lucb17b.fnt b/thirdparty/grx249/fonts/lucb17b.fnt new file mode 100644 index 0000000..224ecfb --- /dev/null +++ b/thirdparty/grx249/fonts/lucb17b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d9ec0efd679cdf5609efc08d7df4905439554a26b312d8aa09880103c489513 +size 6660 diff --git a/thirdparty/grx249/fonts/lucb17bi.fnt b/thirdparty/grx249/fonts/lucb17bi.fnt new file mode 100644 index 0000000..c2342e7 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb17bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d1aec367d4e9dbd25de1088f733b69e2822f0bd8735df6d2dd1f4554afd913ca +size 6949 diff --git a/thirdparty/grx249/fonts/lucb17i.fnt b/thirdparty/grx249/fonts/lucb17i.fnt new file mode 100644 index 0000000..63e3675 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb17i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:77e9708bb75cb622b6092ed3776c44c6d2c63627791a890c5bb8aa0e9569178a +size 6726 diff --git a/thirdparty/grx249/fonts/lucb21.fnt b/thirdparty/grx249/fonts/lucb21.fnt new file mode 100644 index 0000000..6ace297 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb21.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1b59199c62efe743828731f7610f586551ad22b6ff9e71f451f0e28251fd10ef +size 8852 diff --git a/thirdparty/grx249/fonts/lucb21b.fnt b/thirdparty/grx249/fonts/lucb21b.fnt new file mode 100644 index 0000000..22fe3d8 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb21b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db2618fb6d35c81577624334dd7d80eabc05fb7a8bf9b52acbdc7a8f376004b5 +size 8873 diff --git a/thirdparty/grx249/fonts/lucb21bi.fnt b/thirdparty/grx249/fonts/lucb21bi.fnt new file mode 100644 index 0000000..482c0b0 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb21bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc5be089790fd9cc7f66d0b1d393e8492ae9aa9d5abe2cf71c998a803e605fff +size 9272 diff --git a/thirdparty/grx249/fonts/lucb21i.fnt b/thirdparty/grx249/fonts/lucb21i.fnt new file mode 100644 index 0000000..178b417 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb21i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d50c1755b484a90e0626aad6284ba64d1c0897090b857e6515b25b8bfdebf53 +size 9041 diff --git a/thirdparty/grx249/fonts/lucb27.fnt b/thirdparty/grx249/fonts/lucb27.fnt new file mode 100644 index 0000000..e248e04 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb27.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5c0ae42f59b7cf2b32a8601765fa75a73fc027f228bb84e5c9741aee7b424a0c +size 12492 diff --git a/thirdparty/grx249/fonts/lucb27b.fnt b/thirdparty/grx249/fonts/lucb27b.fnt new file mode 100644 index 0000000..e7bace0 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb27b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3fc19f35a5998769ec98c9d9ada36483eef52dbfcbdb1c9bde728dc0b889fbc4 +size 12683 diff --git a/thirdparty/grx249/fonts/lucb27bi.fnt b/thirdparty/grx249/fonts/lucb27bi.fnt new file mode 100644 index 0000000..1f572c9 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb27bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bef6f7dc81d831f3508c07ee5e8bfe354e681878e99c15da0ae016fb4d19294a +size 13817 diff --git a/thirdparty/grx249/fonts/lucb27i.fnt b/thirdparty/grx249/fonts/lucb27i.fnt new file mode 100644 index 0000000..e8dc146 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb27i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4d8bc4039905730071859ffda8a053b1bc3bbebfc4bb1b62f52a425827ab345 +size 13142 diff --git a/thirdparty/grx249/fonts/lucb40.fnt b/thirdparty/grx249/fonts/lucb40.fnt new file mode 100644 index 0000000..a40a2e1 --- /dev/null +++ b/thirdparty/grx249/fonts/lucb40.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7fec44807673f8e6fc73941f083e6efe660e819ebde1f26997a0dfa89628c63b +size 26230 diff --git a/thirdparty/grx249/fonts/lucb40b.fnt b/thirdparty/grx249/fonts/lucb40b.fnt new file mode 100644 index 0000000..f1013cc --- /dev/null +++ b/thirdparty/grx249/fonts/lucb40b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d1884744d7a03326afd8b5d0f9e178fa3d495a1aa27765b3167fd6122fc2ee4 +size 27272 diff --git a/thirdparty/grx249/fonts/lucb40bi.fnt b/thirdparty/grx249/fonts/lucb40bi.fnt new file mode 100644 index 0000000..406fa7b --- /dev/null +++ b/thirdparty/grx249/fonts/lucb40bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ad92e9db309f25be75514c0575a7746628a33adfe2cde2464fd683bf3443fbd +size 28552 diff --git a/thirdparty/grx249/fonts/lucb40i.fnt b/thirdparty/grx249/fonts/lucb40i.fnt new file mode 100644 index 0000000..b5942ac --- /dev/null +++ b/thirdparty/grx249/fonts/lucb40i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e4da5119654a8a05e05e19637b34e8afc06496a359a0cb2f13ed2dc0c386915 +size 27510 diff --git a/thirdparty/grx249/fonts/lucs11.fnt b/thirdparty/grx249/fonts/lucs11.fnt new file mode 100644 index 0000000..878aed9 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs11.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ead851a96aa09d02a245d549727bf70b8c90342dd5edd8a2b3f8b2047c9f1c89 +size 3289 diff --git a/thirdparty/grx249/fonts/lucs11b.fnt b/thirdparty/grx249/fonts/lucs11b.fnt new file mode 100644 index 0000000..8fbe742 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs11b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed30fdc3b11ddf365b25f1745ac3bc9c929b99bd0bd39ed702e931df82ad2331 +size 3329 diff --git a/thirdparty/grx249/fonts/lucs11bi.fnt b/thirdparty/grx249/fonts/lucs11bi.fnt new file mode 100644 index 0000000..2706fd4 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs11bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a05579e3573daef77ff8ba83f0ea2e5eb4437499b7b03d8a73cb77e7b99c5e8 +size 3362 diff --git a/thirdparty/grx249/fonts/lucs11i.fnt b/thirdparty/grx249/fonts/lucs11i.fnt new file mode 100644 index 0000000..61fc9e9 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs11i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:651df59f76696c28bd98fe1bea000338b556a37fe3560099dc27a2c8fa0e966f +size 3322 diff --git a/thirdparty/grx249/fonts/lucs12.fnt b/thirdparty/grx249/fonts/lucs12.fnt new file mode 100644 index 0000000..f4f7821 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs12.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:278a755fffdf1fd72b86e12bdb55cfb3783fdfa59e524e7d55858e07c64be1d2 +size 3670 diff --git a/thirdparty/grx249/fonts/lucs12b.fnt b/thirdparty/grx249/fonts/lucs12b.fnt new file mode 100644 index 0000000..6d0e61f --- /dev/null +++ b/thirdparty/grx249/fonts/lucs12b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:59a3e2c0c2d1349f6617d27aac4a091c4f1f25ca9a81fecbbfece9cd450d3c67 +size 3776 diff --git a/thirdparty/grx249/fonts/lucs12bi.fnt b/thirdparty/grx249/fonts/lucs12bi.fnt new file mode 100644 index 0000000..885e77f --- /dev/null +++ b/thirdparty/grx249/fonts/lucs12bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29490c9f75210a483565404f060a9a4d514df5dcaae66b471a15ac99593f3aef +size 3788 diff --git a/thirdparty/grx249/fonts/lucs12i.fnt b/thirdparty/grx249/fonts/lucs12i.fnt new file mode 100644 index 0000000..783f028 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs12i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:87be1de140cd7f3d1903e0fac1aef6142ffeb523139d532a56471f197200e05d +size 3670 diff --git a/thirdparty/grx249/fonts/lucs15.fnt b/thirdparty/grx249/fonts/lucs15.fnt new file mode 100644 index 0000000..881b0ed --- /dev/null +++ b/thirdparty/grx249/fonts/lucs15.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:73c3ec55e528e2c41c3aaee943e6e8feb1a7da9756732486c0a34012970853c0 +size 4720 diff --git a/thirdparty/grx249/fonts/lucs15b.fnt b/thirdparty/grx249/fonts/lucs15b.fnt new file mode 100644 index 0000000..5884990 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs15b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:73356076b922a0d367477b4b3b5c27a6e0f911e84f6c1fa846c6c2a146185a31 +size 5153 diff --git a/thirdparty/grx249/fonts/lucs15bi.fnt b/thirdparty/grx249/fonts/lucs15bi.fnt new file mode 100644 index 0000000..9c6b488 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs15bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c39ab521e1889e3b252210899c9500bb5dcb07047764dcca7b14fd21570a084 +size 5273 diff --git a/thirdparty/grx249/fonts/lucs15i.fnt b/thirdparty/grx249/fonts/lucs15i.fnt new file mode 100644 index 0000000..33149d6 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs15i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7c118cfac7365a8635933f5dd161c12ab588caba20371ab7b02f165ea5c331e +size 4690 diff --git a/thirdparty/grx249/fonts/lucs17.fnt b/thirdparty/grx249/fonts/lucs17.fnt new file mode 100644 index 0000000..5f4b352 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs17.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:975ea5e3010c8c67a002049ec04675a3a454620aa345f91a1af9f19554afcd21 +size 6392 diff --git a/thirdparty/grx249/fonts/lucs17b.fnt b/thirdparty/grx249/fonts/lucs17b.fnt new file mode 100644 index 0000000..7afa039 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs17b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a42fcae2da6c7a970951e5d8f8cd6c0d40c3d3cbed403a8eb1a51d6810992133 +size 7087 diff --git a/thirdparty/grx249/fonts/lucs17bi.fnt b/thirdparty/grx249/fonts/lucs17bi.fnt new file mode 100644 index 0000000..e4437e1 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs17bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d80743c7b08a3edac52eeec9ca1203b9ee415926645730f72aa1e467c42c12c +size 7019 diff --git a/thirdparty/grx249/fonts/lucs17i.fnt b/thirdparty/grx249/fonts/lucs17i.fnt new file mode 100644 index 0000000..21b9565 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs17i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6428b1a2066447b361aaa277440c0249d3a971f9600c562d6af860a6fe8949f6 +size 6630 diff --git a/thirdparty/grx249/fonts/lucs21.fnt b/thirdparty/grx249/fonts/lucs21.fnt new file mode 100644 index 0000000..fadbf0c --- /dev/null +++ b/thirdparty/grx249/fonts/lucs21.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b8c39501ded06cb6d68d54d29c89a7a8730a70f4fc34e7a1360ef5d8a976dc73 +size 8684 diff --git a/thirdparty/grx249/fonts/lucs21b.fnt b/thirdparty/grx249/fonts/lucs21b.fnt new file mode 100644 index 0000000..9d6109f --- /dev/null +++ b/thirdparty/grx249/fonts/lucs21b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e4e368f4e8ef06b6ccc5f1c0e899b2ca256666f3a4e598e96ce4aaef2fc07d0 +size 9039 diff --git a/thirdparty/grx249/fonts/lucs21bi.fnt b/thirdparty/grx249/fonts/lucs21bi.fnt new file mode 100644 index 0000000..ceaf7e9 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs21bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92121a15bc2f36eeff4fa1c0ec8b1fceb2cb23c0cba76c6600c8092e03c85781 +size 9228 diff --git a/thirdparty/grx249/fonts/lucs21i.fnt b/thirdparty/grx249/fonts/lucs21i.fnt new file mode 100644 index 0000000..a37bd94 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs21i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e1c2f39fef961e1ec4f09ce0fd6d7edae2ac8560af639c41e6fcb9571d453b98 +size 8852 diff --git a/thirdparty/grx249/fonts/lucs27.fnt b/thirdparty/grx249/fonts/lucs27.fnt new file mode 100644 index 0000000..b841d40 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs27.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:000700a88cd99b982eade740af1600112b9c6c15bc5ecf47eee89c798ade474a +size 12492 diff --git a/thirdparty/grx249/fonts/lucs27b.fnt b/thirdparty/grx249/fonts/lucs27b.fnt new file mode 100644 index 0000000..17329f3 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs27b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4e700f9abe68c71f83a7412b6f66042ac142541a3bbf9aa8069ac20678d2ddd +size 13624 diff --git a/thirdparty/grx249/fonts/lucs27bi.fnt b/thirdparty/grx249/fonts/lucs27bi.fnt new file mode 100644 index 0000000..031b719 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs27bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b29e6c5efd47b14a6c9e8810b4c705aec2185cf3dbbb5fbdf442f8b6e67ecce +size 15325 diff --git a/thirdparty/grx249/fonts/lucs27i.fnt b/thirdparty/grx249/fonts/lucs27i.fnt new file mode 100644 index 0000000..a3966a6 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs27i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a847ad26b4a5717de11e956ab9dbc559f73742e051ed61ef0c99a251d1f887ac +size 13059 diff --git a/thirdparty/grx249/fonts/lucs40.fnt b/thirdparty/grx249/fonts/lucs40.fnt new file mode 100644 index 0000000..ed80356 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs40.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:41df25a6a23e01a24909108abcf8b3e82eaac237a55023ec94cf28555e9ca5cd +size 26108 diff --git a/thirdparty/grx249/fonts/lucs40b.fnt b/thirdparty/grx249/fonts/lucs40b.fnt new file mode 100644 index 0000000..dd43f76 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs40b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:baf263e2adbb565ea575238639c14f2d7f48757f5cfc71a560c2c9883abf23d3 +size 27388 diff --git a/thirdparty/grx249/fonts/lucs40bi.fnt b/thirdparty/grx249/fonts/lucs40bi.fnt new file mode 100644 index 0000000..00c1e6f --- /dev/null +++ b/thirdparty/grx249/fonts/lucs40bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c72ff86775f8988a1bac2ee4bf12d00cac3ff60dd5053ad34671fbfb5472e07e +size 29226 diff --git a/thirdparty/grx249/fonts/lucs40i.fnt b/thirdparty/grx249/fonts/lucs40i.fnt new file mode 100644 index 0000000..5f45781 --- /dev/null +++ b/thirdparty/grx249/fonts/lucs40i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ff224817d1b5b6e4d4706d2536913cd43ba3eeedba2866943ea087078560676 +size 26988 diff --git a/thirdparty/grx249/fonts/luct10.fnt b/thirdparty/grx249/fonts/luct10.fnt new file mode 100644 index 0000000..c51cd1c --- /dev/null +++ b/thirdparty/grx249/fonts/luct10.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ec9b744cd8e586860333d498bac64ca5082a0e84ec2a56c26ab15814700d46f +size 2627 diff --git a/thirdparty/grx249/fonts/luct10b.fnt b/thirdparty/grx249/fonts/luct10b.fnt new file mode 100644 index 0000000..7c5cd27 --- /dev/null +++ b/thirdparty/grx249/fonts/luct10b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a48d616bc26a4fbd569583b48f79d3779f114af3597a6fc9ca9063831d73cd1e +size 2623 diff --git a/thirdparty/grx249/fonts/luct11.fnt b/thirdparty/grx249/fonts/luct11.fnt new file mode 100644 index 0000000..9b96e70 --- /dev/null +++ b/thirdparty/grx249/fonts/luct11.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bfc0bcc52883c560553572016fa6d6972aed6026fa189cda67f2361a8db333cb +size 2878 diff --git a/thirdparty/grx249/fonts/luct11b.fnt b/thirdparty/grx249/fonts/luct11b.fnt new file mode 100644 index 0000000..247e741 --- /dev/null +++ b/thirdparty/grx249/fonts/luct11b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f6cdb506af26cc8cfa314f2977f28a99c65a6cb3627ce14af219810763588adb +size 2874 diff --git a/thirdparty/grx249/fonts/luct13.fnt b/thirdparty/grx249/fonts/luct13.fnt new file mode 100644 index 0000000..c6239e6 --- /dev/null +++ b/thirdparty/grx249/fonts/luct13.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7e0da297c0de92338524998da93ee4b591c217e9115d16aeb68fb82c22902af +size 3326 diff --git a/thirdparty/grx249/fonts/luct13b.fnt b/thirdparty/grx249/fonts/luct13b.fnt new file mode 100644 index 0000000..40c6dc8 --- /dev/null +++ b/thirdparty/grx249/fonts/luct13b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a62746e3d97ed6894fd34c250cc9070dc440a2f78bf1670a9a0d50a7878d28f7 +size 3322 diff --git a/thirdparty/grx249/fonts/luct15.fnt b/thirdparty/grx249/fonts/luct15.fnt new file mode 100644 index 0000000..2995d41 --- /dev/null +++ b/thirdparty/grx249/fonts/luct15.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2cff2870723ee85731135d8ea8409cb834e6d08adb325a80dfbb51261a37b6a9 +size 7134 diff --git a/thirdparty/grx249/fonts/luct15b.fnt b/thirdparty/grx249/fonts/luct15b.fnt new file mode 100644 index 0000000..be2d849 --- /dev/null +++ b/thirdparty/grx249/fonts/luct15b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f9388ac5902602d612eae536031056a8f17bf0fc5aa291b358f75fff29458c6 +size 7130 diff --git a/thirdparty/grx249/fonts/luct19.fnt b/thirdparty/grx249/fonts/luct19.fnt new file mode 100644 index 0000000..436a29f --- /dev/null +++ b/thirdparty/grx249/fonts/luct19.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7a507dcbd55c195cfbbd281c3bff2fe7c37a944c8f42e7869a35af1a2a154ae +size 8927 diff --git a/thirdparty/grx249/fonts/luct19b.fnt b/thirdparty/grx249/fonts/luct19b.fnt new file mode 100644 index 0000000..833de5e --- /dev/null +++ b/thirdparty/grx249/fonts/luct19b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0287edebb89b8653de538d123b9a3230ddce9c30015c32cfa14d2f34db94b51 +size 8923 diff --git a/thirdparty/grx249/fonts/luct27.fnt b/thirdparty/grx249/fonts/luct27.fnt new file mode 100644 index 0000000..a79e45e --- /dev/null +++ b/thirdparty/grx249/fonts/luct27.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71bbc42234ea73accc0637b89273c0b54a5024b76160f2e9226140903d197148 +size 12486 diff --git a/thirdparty/grx249/fonts/luct27b.fnt b/thirdparty/grx249/fonts/luct27b.fnt new file mode 100644 index 0000000..3749db9 --- /dev/null +++ b/thirdparty/grx249/fonts/luct27b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7e10ea363f9a15e12f9bf0d0ec4e96c8b8406b2b83577d37996e72205079c85 +size 18530 diff --git a/thirdparty/grx249/fonts/luct38.fnt b/thirdparty/grx249/fonts/luct38.fnt new file mode 100644 index 0000000..4c2d861 --- /dev/null +++ b/thirdparty/grx249/fonts/luct38.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:14090db531ca1d86e8228acea9dc4d59d57b3b595f9414eee2996bb3074251c7 +size 25928 diff --git a/thirdparty/grx249/fonts/luct38b.fnt b/thirdparty/grx249/fonts/luct38b.fnt new file mode 100644 index 0000000..a5a2545 --- /dev/null +++ b/thirdparty/grx249/fonts/luct38b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:304af9934d7360f879d7cd46bf59f567177d44238de6107c42b7d0762e794402 +size 34436 diff --git a/thirdparty/grx249/fonts/ncen11.fnt b/thirdparty/grx249/fonts/ncen11.fnt new file mode 100644 index 0000000..2c19e8c --- /dev/null +++ b/thirdparty/grx249/fonts/ncen11.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31504af8aa49224997e5424fd4b1a7664d47550cd2d70b16c5feab5422575b97 +size 4819 diff --git a/thirdparty/grx249/fonts/ncen11b.fnt b/thirdparty/grx249/fonts/ncen11b.fnt new file mode 100644 index 0000000..746549f --- /dev/null +++ b/thirdparty/grx249/fonts/ncen11b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a11370e8ecac2fffb71dc4c05d33f17394d95dc8bf8b26f70a6bb733f38fbbbd +size 4856 diff --git a/thirdparty/grx249/fonts/ncen11bi.fnt b/thirdparty/grx249/fonts/ncen11bi.fnt new file mode 100644 index 0000000..296211a --- /dev/null +++ b/thirdparty/grx249/fonts/ncen11bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0bd5d9df97ec3bbb8c101071077aa19735f4b52aacd431be06e196a996d1217 +size 4856 diff --git a/thirdparty/grx249/fonts/ncen11i.fnt b/thirdparty/grx249/fonts/ncen11i.fnt new file mode 100644 index 0000000..f7e7766 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen11i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd72e4aee13640fa033805023dfc54eb285057d80efd57d1936ba707fe17af0b +size 4836 diff --git a/thirdparty/grx249/fonts/ncen13.fnt b/thirdparty/grx249/fonts/ncen13.fnt new file mode 100644 index 0000000..849222f --- /dev/null +++ b/thirdparty/grx249/fonts/ncen13.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:774d96d22e4de07a976fc8b4337fb591ac6efb921f44d9c2afa7653045e7c832 +size 5435 diff --git a/thirdparty/grx249/fonts/ncen13b.fnt b/thirdparty/grx249/fonts/ncen13b.fnt new file mode 100644 index 0000000..210e73d --- /dev/null +++ b/thirdparty/grx249/fonts/ncen13b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9aa7b2eb8862898ebe25273b043b7063a56e3696455e3fe82872269f93fe093 +size 5745 diff --git a/thirdparty/grx249/fonts/ncen13bi.fnt b/thirdparty/grx249/fonts/ncen13bi.fnt new file mode 100644 index 0000000..8e76a49 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen13bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6949b57cb6b5bffd7d70749a62d8a51e5c15f18c3264e3e2f5a742bfb06546b +size 5641 diff --git a/thirdparty/grx249/fonts/ncen13i.fnt b/thirdparty/grx249/fonts/ncen13i.fnt new file mode 100644 index 0000000..721617a --- /dev/null +++ b/thirdparty/grx249/fonts/ncen13i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d51b1eb5e87dcb2a1287ee13c99791dd1b0f1c1bd427a60bd3e036991afbde7f +size 5513 diff --git a/thirdparty/grx249/fonts/ncen15.fnt b/thirdparty/grx249/fonts/ncen15.fnt new file mode 100644 index 0000000..bb2e325 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen15.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd8603b4a1e11d347320240015367b056a2397040854e67adad2ba8f08a4294a +size 6421 diff --git a/thirdparty/grx249/fonts/ncen15b.fnt b/thirdparty/grx249/fonts/ncen15b.fnt new file mode 100644 index 0000000..c51c670 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen15b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15e79f2792ab16c92860ea36bd6bacf3adb8a587bda14c7f2ec6a4fb5dcfe5d6 +size 6824 diff --git a/thirdparty/grx249/fonts/ncen15bi.fnt b/thirdparty/grx249/fonts/ncen15bi.fnt new file mode 100644 index 0000000..0b57f3b --- /dev/null +++ b/thirdparty/grx249/fonts/ncen15bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d3f9b0815aa55658785278d3fe90342d418b65a5adc83bd00fd12e52542fae14 +size 6734 diff --git a/thirdparty/grx249/fonts/ncen15i.fnt b/thirdparty/grx249/fonts/ncen15i.fnt new file mode 100644 index 0000000..671217b --- /dev/null +++ b/thirdparty/grx249/fonts/ncen15i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:076219aa4119a7ac4be9df2cfbfbf94b98d1eaa2f4260bdb71da03be724a4b74 +size 6526 diff --git a/thirdparty/grx249/fonts/ncen18.fnt b/thirdparty/grx249/fonts/ncen18.fnt new file mode 100644 index 0000000..48ccc0b --- /dev/null +++ b/thirdparty/grx249/fonts/ncen18.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0874139a510667a132618334a9f371a9b5c83fbd2958c3949f60bde2fd24e5bb +size 7970 diff --git a/thirdparty/grx249/fonts/ncen18b.fnt b/thirdparty/grx249/fonts/ncen18b.fnt new file mode 100644 index 0000000..32461d6 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen18b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a292950196bf4c989e12878f25087ed2dd2a40df80105ee5c62febbca158ef0 +size 8243 diff --git a/thirdparty/grx249/fonts/ncen18bi.fnt b/thirdparty/grx249/fonts/ncen18bi.fnt new file mode 100644 index 0000000..31bd348 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen18bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1478b8d281ff8fe2cbee0a83c13eae0616c39a1bee5d9624b79c3a571ef542b1 +size 8237 diff --git a/thirdparty/grx249/fonts/ncen18i.fnt b/thirdparty/grx249/fonts/ncen18i.fnt new file mode 100644 index 0000000..7925356 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen18i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a387222fe764a7d66ac08fe24edcc8601a851d4f24fea8d219235ac70c0ebbaf +size 8005 diff --git a/thirdparty/grx249/fonts/ncen22.fnt b/thirdparty/grx249/fonts/ncen22.fnt new file mode 100644 index 0000000..96a2ef9 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen22.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a6aaaeff0215402b05494189a02a9abf9faea72d056007092c6d7197c316978 +size 10482 diff --git a/thirdparty/grx249/fonts/ncen22b.fnt b/thirdparty/grx249/fonts/ncen22b.fnt new file mode 100644 index 0000000..cc9de89 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen22b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7b85e30d372a1d94b060b8e4b009a36b0273a37c17477e7132bc36a97f7ed6b +size 10744 diff --git a/thirdparty/grx249/fonts/ncen22bi.fnt b/thirdparty/grx249/fonts/ncen22bi.fnt new file mode 100644 index 0000000..c04ed5a --- /dev/null +++ b/thirdparty/grx249/fonts/ncen22bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4bae63eeddce0fa2d621a2896bf2d806a5b0715483de7c3bc8b825144387921c +size 10788 diff --git a/thirdparty/grx249/fonts/ncen22i.fnt b/thirdparty/grx249/fonts/ncen22i.fnt new file mode 100644 index 0000000..ae277c8 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen22i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84c2404120fcb043d01525fe1ffc1260a61b4efadc29b2ea234c0476554cb535 +size 10614 diff --git a/thirdparty/grx249/fonts/ncen29.fnt b/thirdparty/grx249/fonts/ncen29.fnt new file mode 100644 index 0000000..7e02d80 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen29.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:11db4cc51de37ad6b36e1652cfa6b2d5293a6cac8ec6decf8ed40af4378b487a +size 15038 diff --git a/thirdparty/grx249/fonts/ncen29b.fnt b/thirdparty/grx249/fonts/ncen29b.fnt new file mode 100644 index 0000000..1888202 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen29b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef8a3e6992b92a0abfc53473fc9ae75a517eec9961d6eef444d7899fd18a474a +size 15999 diff --git a/thirdparty/grx249/fonts/ncen29bi.fnt b/thirdparty/grx249/fonts/ncen29bi.fnt new file mode 100644 index 0000000..0100929 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen29bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d3872148bb1b11cffe94b62c0a9403a60cdabd0a7edfd049b1247ab9529b4a2 +size 15709 diff --git a/thirdparty/grx249/fonts/ncen29i.fnt b/thirdparty/grx249/fonts/ncen29i.fnt new file mode 100644 index 0000000..24e54c1 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen29i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:236dd397396c13ef8f9806405ee102cfa465f667613b133b02e3402a1d7f3cb3 +size 15038 diff --git a/thirdparty/grx249/fonts/ncen40.fnt b/thirdparty/grx249/fonts/ncen40.fnt new file mode 100644 index 0000000..70b51d1 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen40.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06e6afb17ca49eb953d1bbc4ea394d8030d7527cdf39bb7804918bfab37949a6 +size 26133 diff --git a/thirdparty/grx249/fonts/ncen40b.fnt b/thirdparty/grx249/fonts/ncen40b.fnt new file mode 100644 index 0000000..baa59c7 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen40b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:47c775f55f5b35a7d9419c056d67117912c7b5bf97ebfaef76355b3e70ef1f65 +size 27497 diff --git a/thirdparty/grx249/fonts/ncen40bi.fnt b/thirdparty/grx249/fonts/ncen40bi.fnt new file mode 100644 index 0000000..89f6ac3 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen40bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:739593021e66536b9763f12f0d4cadcf1b06f42b20b69e2ebdbb351bc64b2907 +size 28691 diff --git a/thirdparty/grx249/fonts/ncen40i.fnt b/thirdparty/grx249/fonts/ncen40i.fnt new file mode 100644 index 0000000..7c72204 --- /dev/null +++ b/thirdparty/grx249/fonts/ncen40i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a8888f4ee564a8b7c6aeaf73501f2e8ec746839b486485cea6c40844a7190967 +size 27053 diff --git a/thirdparty/grx249/fonts/pc6x14.fnt b/thirdparty/grx249/fonts/pc6x14.fnt new file mode 100644 index 0000000..2c9da12 --- /dev/null +++ b/thirdparty/grx249/fonts/pc6x14.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a507d8245fc603525c4c533f900f2d292fa2dc195099c9e1cd35bba813e713bf +size 3640 diff --git a/thirdparty/grx249/fonts/pc6x8.fnt b/thirdparty/grx249/fonts/pc6x8.fnt new file mode 100644 index 0000000..6c34059 --- /dev/null +++ b/thirdparty/grx249/fonts/pc6x8.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:51d53fec9a21eee5a2973e034c4cecbd028cc301de3b1b07d188d4007c498c6b +size 2104 diff --git a/thirdparty/grx249/fonts/pc8x14.fnt b/thirdparty/grx249/fonts/pc8x14.fnt new file mode 100644 index 0000000..42ec654 --- /dev/null +++ b/thirdparty/grx249/fonts/pc8x14.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:faaa4318b813785fa799945a571e4f7613def80ef8b8754ff0f06b67b655ce73 +size 3640 diff --git a/thirdparty/grx249/fonts/pc8x14t.fnt b/thirdparty/grx249/fonts/pc8x14t.fnt new file mode 100644 index 0000000..cd8f0a0 --- /dev/null +++ b/thirdparty/grx249/fonts/pc8x14t.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a222373e021dc6eee16e162f6588f641a593b2c02d34c47f818b01fb4c3f8df +size 3640 diff --git a/thirdparty/grx249/fonts/pc8x16.fnt b/thirdparty/grx249/fonts/pc8x16.fnt new file mode 100644 index 0000000..4064097 --- /dev/null +++ b/thirdparty/grx249/fonts/pc8x16.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6aede38f7065d1ae51581bf1c239a69f09905c6428b513bd4cb6009a97552a78 +size 4152 diff --git a/thirdparty/grx249/fonts/pc8x8.fnt b/thirdparty/grx249/fonts/pc8x8.fnt new file mode 100644 index 0000000..f6a1c09 --- /dev/null +++ b/thirdparty/grx249/fonts/pc8x8.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:09c7e8777bc585008259022f03119ad5664794c6073f5af4a5521c1d5a270240 +size 2104 diff --git a/thirdparty/grx249/fonts/pc8x8t.fnt b/thirdparty/grx249/fonts/pc8x8t.fnt new file mode 100644 index 0000000..1548e40 --- /dev/null +++ b/thirdparty/grx249/fonts/pc8x8t.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2416e05afd3309b04df2fba556a4a3c9d9b6274ad901a3aa29a005e8ae7e5892 +size 2104 diff --git a/thirdparty/grx249/fonts/symb11.fnt b/thirdparty/grx249/fonts/symb11.fnt new file mode 100644 index 0000000..56e78b6 --- /dev/null +++ b/thirdparty/grx249/fonts/symb11.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9bf3d1aba11e47c504c175049b2ada2fbaaa569d172622a3c80b341606331a95 +size 2984 diff --git a/thirdparty/grx249/fonts/symb14.fnt b/thirdparty/grx249/fonts/symb14.fnt new file mode 100644 index 0000000..d7cff1b --- /dev/null +++ b/thirdparty/grx249/fonts/symb14.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:93bdbec9ac843be6a7cc47d6ee6d35cb86ca07e65f56676f94bf12ccf678f7bb +size 3379 diff --git a/thirdparty/grx249/fonts/symb16.fnt b/thirdparty/grx249/fonts/symb16.fnt new file mode 100644 index 0000000..1255ab2 --- /dev/null +++ b/thirdparty/grx249/fonts/symb16.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a5a29ead462f471c5c84b0fbe9fcf3209f253d2f30cee3c851595b1cf4414d10 +size 3864 diff --git a/thirdparty/grx249/fonts/symb20.fnt b/thirdparty/grx249/fonts/symb20.fnt new file mode 100644 index 0000000..d0ddb4a --- /dev/null +++ b/thirdparty/grx249/fonts/symb20.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3942654e8b1731a11cfa2dfd6132361c2571608aa46957633d1d8c972c1cae07 +size 4608 diff --git a/thirdparty/grx249/fonts/symb25.fnt b/thirdparty/grx249/fonts/symb25.fnt new file mode 100644 index 0000000..0e12764 --- /dev/null +++ b/thirdparty/grx249/fonts/symb25.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4394ed622593457e9a0e49cb635a34e18115134d8d5e3e92815d0f1321ba210 +size 6259 diff --git a/thirdparty/grx249/fonts/symb32.fnt b/thirdparty/grx249/fonts/symb32.fnt new file mode 100644 index 0000000..c4125fd --- /dev/null +++ b/thirdparty/grx249/fonts/symb32.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ef7dfb1003ad7e7e81e7c44832eac6ee06a36eed332737cea412a802a28cde8 +size 8249 diff --git a/thirdparty/grx249/fonts/symb34.fnt b/thirdparty/grx249/fonts/symb34.fnt new file mode 100644 index 0000000..43ef2e7 --- /dev/null +++ b/thirdparty/grx249/fonts/symb34.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae2a62905c171a22787ab154872fea0a4dc70fc392617acc86b8e2b4dff4edb6 +size 10613 diff --git a/thirdparty/grx249/fonts/ter-114b.res b/thirdparty/grx249/fonts/ter-114b.res new file mode 100644 index 0000000..a8c90c2 Binary files /dev/null and b/thirdparty/grx249/fonts/ter-114b.res differ diff --git a/thirdparty/grx249/fonts/ter-114n.fna b/thirdparty/grx249/fonts/ter-114n.fna new file mode 100644 index 0000000..0d15d72 --- /dev/null +++ b/thirdparty/grx249/fonts/ter-114n.fna @@ -0,0 +1,4104 @@ +name ter-u14n +family Terminus +isfixed 1 +width 8 +height 14 +minchar 0 +maxchar 255 +baseline 12 + +; character 0 width = 8 +........ +........ +.######. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.######. +........ +........ + +; character 1 width = 8 +........ +........ +.#####.. +#.....#. +#.#.#.#. +#.....#. +#.....#. +#.###.#. +#..#..#. +#.....#. +#.....#. +.#####.. +........ +........ + +; character 2 width = 8 +........ +........ +.#####.. +#######. +##.#.##. +#######. +#######. +##...##. +###.###. +#######. +#######. +.#####.. +........ +........ + +; character 3 width = 8 +........ +........ +........ +.##.##.. +#######. +#######. +#######. +#######. +.#####.. +..###... +...#.... +........ +........ +........ + +; character 4 width = 8 +........ +........ +........ +........ +...#.... +..###... +.#####.. +#######. +.#####.. +..###... +...#.... +........ +........ +........ + +; character 5 width = 8 +........ +........ +...#.... +..###... +..###... +...#.... +.#.#.#.. +#######. +#######. +.#.#.#.. +...#.... +..###... +........ +........ + +; character 6 width = 8 +........ +........ +...#.... +...#.... +..###... +.#####.. +#######. +#######. +.#####.. +...#.... +...#.... +..###... +........ +........ + +; character 7 width = 8 +........ +........ +........ +........ +........ +...##... +..####.. +..####.. +...##... +........ +........ +........ +........ +........ + +; character 8 width = 8 +######## +######## +######## +######## +######## +###..### +##....## +##....## +###..### +######## +######## +######## +######## +######## + +; character 9 width = 8 +........ +........ +........ +........ +........ +...##... +..#..#.. +..#..#.. +...##... +........ +........ +........ +........ +........ + +; character 10 width = 8 +######## +######## +######## +######## +######## +###..### +##.##.## +##.##.## +###..### +######## +######## +######## +######## +######## + +; character 11 width = 8 +........ +........ +...####. +.....##. +....#.#. +...#..#. +..###... +.#...#.. +.#...#.. +.#...#.. +.#...#.. +..###... +........ +........ + +; character 12 width = 8 +........ +........ +..###... +.#...#.. +.#...#.. +.#...#.. +.#...#.. +..###... +...#.... +.#####.. +...#.... +...#.... +........ +........ + +; character 13 width = 8 +........ +........ +..#####. +..#...#. +..#####. +..#..... +..#..... +..#..... +..#..... +..#..... +..#..... +##...... +........ +........ + +; character 14 width = 8 +........ +........ +.######. +.#....#. +.######. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#...#.. +#....... +........ + +; character 15 width = 8 +........ +........ +........ +...#.... +...#.... +##.#.##. +..###... +###.###. +..###... +##.#.##. +...#.... +...#.... +........ +........ + +; character 16 width = 8 +........ +.#...... +.##..... +.###.... +.####... +.#####.. +.######. +.#####.. +.####... +.###.... +.##..... +.#...... +........ +........ + +; character 17 width = 8 +........ +......#. +.....##. +....###. +...####. +..#####. +.######. +..#####. +...####. +....###. +.....##. +......#. +........ +........ + +; character 18 width = 8 +........ +........ +...#.... +..###... +.#####.. +...#.... +...#.... +...#.... +...#.... +.#####.. +..###... +...#.... +........ +........ + +; character 19 width = 8 +........ +........ +..#..#.. +..#..#.. +..#..#.. +..#..#.. +..#..#.. +..#..#.. +..#..#.. +........ +..#..#.. +..#..#.. +........ +........ + +; character 20 width = 8 +........ +........ +.######. +#..#..#. +#..#..#. +#..#..#. +#..#..#. +.###..#. +...#..#. +...#..#. +...#..#. +...#..#. +........ +........ + +; character 21 width = 8 +........ +..###... +.#...#.. +.#...... +..##.... +.#..#... +.#...#.. +.#...#.. +..#..#.. +...##... +.....#.. +.#...#.. +..###... +........ + +; character 22 width = 8 +........ +........ +........ +........ +........ +........ +........ +........ +.######. +.######. +.######. +.######. +........ +........ + +; character 23 width = 8 +........ +........ +...#.... +..###... +.#####.. +...#.... +...#.... +...#.... +...#.... +.#####.. +..###... +...#.... +.#####.. +........ + +; character 24 width = 8 +........ +........ +...#.... +..###... +.#####.. +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +........ +........ + +; character 25 width = 8 +........ +........ +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +.#####.. +..###... +...#.... +........ +........ + +; character 26 width = 8 +........ +........ +........ +........ +....#... +....##.. +#######. +....##.. +....#... +........ +........ +........ +........ +........ + +; character 27 width = 8 +........ +........ +........ +........ +..#..... +.##..... +#######. +.##..... +..#..... +........ +........ +........ +........ +........ + +; character 28 width = 8 +........ +........ +........ +........ +........ +........ +.#...... +.#...... +.######. +........ +........ +........ +........ +........ + +; character 29 width = 8 +........ +........ +........ +........ +..#..#.. +.##..##. +######## +.##..##. +..#..#.. +........ +........ +........ +........ +........ + +; character 30 width = 8 +........ +........ +........ +...#.... +...#.... +..###... +..###... +.#####.. +.#####.. +#######. +#######. +........ +........ +........ + +; character 31 width = 8 +........ +........ +........ +#######. +#######. +.#####.. +.#####.. +..###... +..###... +...#.... +...#.... +........ +........ +........ + +; character 32 width = 8 +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 33 (!) width = 8 +........ +........ +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +........ +...#.... +...#.... +........ +........ + +; character 34 (") width = 8 +........ +..#..#.. +..#..#.. +..#..#.. +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 35 (#) width = 8 +........ +........ +..#..#.. +..#..#.. +..#..#.. +.######. +..#..#.. +..#..#.. +.######. +..#..#.. +..#..#.. +..#..#.. +........ +........ + +; character 36 ($) width = 8 +........ +...#.... +...#.... +.#####.. +#..#..#. +#..#.... +#..#.... +.#####.. +...#..#. +...#..#. +#..#..#. +.#####.. +...#.... +...#.... + +; character 37 (%) width = 8 +........ +........ +.##..#.. +#..#.#.. +.##.#... +....#... +...#.... +...#.... +..#..... +..#.##.. +.#.#..#. +.#..##.. +........ +........ + +; character 38 (&) width = 8 +........ +........ +...##... +..#..#.. +..#..#.. +...##... +..##..#. +.#..##.. +.#...#.. +.#...#.. +.#..##.. +..##.##. +........ +........ + +; character 39 (') width = 8 +........ +...#.... +...#.... +..#..... +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 40 (() width = 8 +........ +........ +....#... +...#.... +..#..... +..#..... +..#..... +..#..... +..#..... +..#..... +...#.... +....#... +........ +........ + +; character 41 ()) width = 8 +........ +........ +..#..... +...#.... +....#... +....#... +....#... +....#... +....#... +....#... +...#.... +..#..... +........ +........ + +; character 42 (*) width = 8 +........ +........ +........ +........ +........ +..#..#.. +...##... +.######. +...##... +..#..#.. +........ +........ +........ +........ + +; character 43 (+) width = 8 +........ +........ +........ +........ +........ +...#.... +...#.... +.#####.. +...#.... +...#.... +........ +........ +........ +........ + +; character 44 (,) width = 8 +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +...#.... +...#.... +..#..... +........ + +; character 45 (-) width = 8 +........ +........ +........ +........ +........ +........ +........ +.######. +........ +........ +........ +........ +........ +........ + +; character 46 (.) width = 8 +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +...#.... +...#.... +........ +........ + +; character 47 (/) width = 8 +........ +........ +.....#.. +.....#.. +....#... +....#... +...#.... +...#.... +..#..... +..#..... +.#...... +.#...... +........ +........ + +; character 48 (0) width = 8 +........ +........ +..####.. +.#....#. +.#....#. +.#...##. +.#..#.#. +.#.#..#. +.##...#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 49 (1) width = 8 +........ +........ +...#.... +..##.... +.#.#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +.#####.. +........ +........ + +; character 50 (2) width = 8 +........ +........ +..####.. +.#....#. +.#....#. +......#. +.....#.. +....#... +...#.... +..#..... +.#...... +.######. +........ +........ + +; character 51 (3) width = 8 +........ +........ +..####.. +.#....#. +.#....#. +......#. +...###.. +......#. +......#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 52 (4) width = 8 +........ +........ +......#. +.....##. +....#.#. +...#..#. +..#...#. +.#....#. +.######. +......#. +......#. +......#. +........ +........ + +; character 53 (5) width = 8 +........ +........ +.######. +.#...... +.#...... +.#...... +.#####.. +......#. +......#. +......#. +.#....#. +..####.. +........ +........ + +; character 54 (6) width = 8 +........ +........ +...###.. +..#..... +.#...... +.#...... +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 55 (7) width = 8 +........ +........ +.######. +......#. +......#. +.....#.. +.....#.. +....#... +....#... +...#.... +...#.... +...#.... +........ +........ + +; character 56 (8) width = 8 +........ +........ +..####.. +.#....#. +.#....#. +.#....#. +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 57 (9) width = 8 +........ +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +......#. +......#. +.....#.. +..###... +........ +........ + +; character 58 (:) width = 8 +........ +........ +........ +........ +........ +...#.... +...#.... +........ +........ +........ +...#.... +...#.... +........ +........ + +; character 59 (;) width = 8 +........ +........ +........ +........ +........ +...#.... +...#.... +........ +........ +........ +...#.... +...#.... +..#..... +........ + +; character 60 (<) width = 8 +........ +........ +........ +.....#.. +....#... +...#.... +..#..... +.#...... +..#..... +...#.... +....#... +.....#.. +........ +........ + +; character 61 (=) width = 8 +........ +........ +........ +........ +........ +.######. +........ +........ +.######. +........ +........ +........ +........ +........ + +; character 62 (>) width = 8 +........ +........ +........ +.#...... +..#..... +...#.... +....#... +.....#.. +....#... +...#.... +..#..... +.#...... +........ +........ + +; character 63 (?) width = 8 +........ +........ +..####.. +.#....#. +.#....#. +.#....#. +.....#.. +....#... +....#... +........ +....#... +....#... +........ +........ + +; character 64 (@) width = 8 +........ +........ +.#####.. +#.....#. +#..####. +#.#...#. +#.#...#. +#.#...#. +#.#..##. +#..##.#. +#....... +.######. +........ +........ + +; character 65 (A) width = 8 +........ +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.######. +.#....#. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 66 (B) width = 8 +........ +........ +.#####.. +.#....#. +.#....#. +.#....#. +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#####.. +........ +........ + +; character 67 (C) width = 8 +........ +........ +..####.. +.#....#. +.#....#. +.#...... +.#...... +.#...... +.#...... +.#....#. +.#....#. +..####.. +........ +........ + +; character 68 (D) width = 8 +........ +........ +.####... +.#...#.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#...#.. +.####... +........ +........ + +; character 69 (E) width = 8 +........ +........ +.######. +.#...... +.#...... +.#...... +.####... +.#...... +.#...... +.#...... +.#...... +.######. +........ +........ + +; character 70 (F) width = 8 +........ +........ +.######. +.#...... +.#...... +.#...... +.####... +.#...... +.#...... +.#...... +.#...... +.#...... +........ +........ + +; character 71 (G) width = 8 +........ +........ +..####.. +.#....#. +.#....#. +.#...... +.#...... +.#..###. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 72 (H) width = 8 +........ +........ +.#....#. +.#....#. +.#....#. +.#....#. +.######. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 73 (I) width = 8 +........ +........ +..###... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +..###... +........ +........ + +; character 74 (J) width = 8 +........ +........ +....###. +.....#.. +.....#.. +.....#.. +.....#.. +.....#.. +.....#.. +.#...#.. +.#...#.. +..###... +........ +........ + +; character 75 (K) width = 8 +........ +........ +.#....#. +.#...#.. +.#..#... +.#.#.... +.##..... +.##..... +.#.#.... +.#..#... +.#...#.. +.#....#. +........ +........ + +; character 76 (L) width = 8 +........ +........ +.#...... +.#...... +.#...... +.#...... +.#...... +.#...... +.#...... +.#...... +.#...... +.######. +........ +........ + +; character 77 (M) width = 8 +........ +........ +#.....#. +##...##. +#.#.#.#. +#..#..#. +#.....#. +#.....#. +#.....#. +#.....#. +#.....#. +#.....#. +........ +........ + +; character 78 (N) width = 8 +........ +........ +.#....#. +.#....#. +.#....#. +.##...#. +.#.#..#. +.#..#.#. +.#...##. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 79 (O) width = 8 +........ +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 80 (P) width = 8 +........ +........ +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#####.. +.#...... +.#...... +.#...... +.#...... +........ +........ + +; character 81 (Q) width = 8 +........ +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#..#.#. +..####.. +......#. +........ + +; character 82 (R) width = 8 +........ +........ +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#####.. +.#.#.... +.#..#... +.#...#.. +.#....#. +........ +........ + +; character 83 (S) width = 8 +........ +........ +..####.. +.#....#. +.#...... +.#...... +..####.. +......#. +......#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 84 (T) width = 8 +........ +........ +#######. +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +........ +........ + +; character 85 (U) width = 8 +........ +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 86 (V) width = 8 +........ +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#..#.. +..#..#.. +..#..#.. +...##... +...##... +........ +........ + +; character 87 (W) width = 8 +........ +........ +#.....#. +#.....#. +#.....#. +#.....#. +#.....#. +#.....#. +#..#..#. +#.#.#.#. +##...##. +#.....#. +........ +........ + +; character 88 (X) width = 8 +........ +........ +.#....#. +.#....#. +..#..#.. +..#..#.. +...##... +...##... +..#..#.. +..#..#.. +.#....#. +.#....#. +........ +........ + +; character 89 (Y) width = 8 +........ +........ +#.....#. +#.....#. +.#...#.. +.#...#.. +..#.#... +...#.... +...#.... +...#.... +...#.... +...#.... +........ +........ + +; character 90 (Z) width = 8 +........ +........ +.######. +......#. +......#. +.....#.. +....#... +...#.... +..#..... +.#...... +.#...... +.######. +........ +........ + +; character 91 ([) width = 8 +........ +........ +..###... +..#..... +..#..... +..#..... +..#..... +..#..... +..#..... +..#..... +..#..... +..###... +........ +........ + +; character 92 (\) width = 8 +........ +........ +.#...... +.#...... +..#..... +..#..... +...#.... +...#.... +....#... +....#... +.....#.. +.....#.. +........ +........ + +; character 93 (]) width = 8 +........ +........ +..###... +....#... +....#... +....#... +....#... +....#... +....#... +....#... +....#... +..###... +........ +........ + +; character 94 (^) width = 8 +........ +...#.... +..#.#... +.#...#.. +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 95 (_) width = 8 +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +.######. + +; character 96 (`) width = 8 +........ +...#.... +...#.... +....#... +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 97 (a) width = 8 +........ +........ +........ +........ +........ +..#####. +.#....#. +.#....#. +.#....#. +.#....#. +.#...##. +..###.#. +........ +........ + +; character 98 (b) width = 8 +........ +........ +.#...... +.#...... +.#...... +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#####.. +........ +........ + +; character 99 (c) width = 8 +........ +........ +........ +........ +........ +..####.. +.#....#. +.#...... +.#...... +.#...... +.#....#. +..####.. +........ +........ + +; character 100 (d) width = 8 +........ +........ +......#. +......#. +......#. +..#####. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +........ +........ + +; character 101 (e) width = 8 +........ +........ +........ +........ +........ +..####.. +.#....#. +.#....#. +.######. +.#...... +.#...... +..####.. +........ +........ + +; character 102 (f) width = 8 +........ +........ +....###. +...#.... +...#.... +.#####.. +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +........ +........ + +; character 103 (g) width = 8 +........ +........ +........ +........ +........ +..#####. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +......#. +..####.. + +; character 104 (h) width = 8 +........ +........ +.#...... +.#...... +.#...... +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 105 (i) width = 8 +........ +........ +...#.... +...#.... +........ +..##.... +...#.... +...#.... +...#.... +...#.... +...#.... +..###... +........ +........ + +; character 106 (j) width = 8 +........ +........ +.....#.. +.....#.. +........ +....##.. +.....#.. +.....#.. +.....#.. +.....#.. +.....#.. +.#...#.. +.#...#.. +..###... + +; character 107 (k) width = 8 +........ +........ +.#...... +.#...... +.#...... +.#....#. +.#...#.. +.#..#... +.###.... +.#..#... +.#...#.. +.#....#. +........ +........ + +; character 108 (l) width = 8 +........ +........ +..##.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +..###... +........ +........ + +; character 109 (m) width = 8 +........ +........ +........ +........ +........ +######.. +#..#..#. +#..#..#. +#..#..#. +#..#..#. +#..#..#. +#..#..#. +........ +........ + +; character 110 (n) width = 8 +........ +........ +........ +........ +........ +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 111 (o) width = 8 +........ +........ +........ +........ +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 112 (p) width = 8 +........ +........ +........ +........ +........ +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#####.. +.#...... +.#...... + +; character 113 (q) width = 8 +........ +........ +........ +........ +........ +..#####. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +......#. +......#. + +; character 114 (r) width = 8 +........ +........ +........ +........ +........ +.#.####. +.##..... +.#...... +.#...... +.#...... +.#...... +.#...... +........ +........ + +; character 115 (s) width = 8 +........ +........ +........ +........ +........ +..#####. +.#...... +.#...... +..####.. +......#. +......#. +.#####.. +........ +........ + +; character 116 (t) width = 8 +........ +........ +...#.... +...#.... +...#.... +.#####.. +...#.... +...#.... +...#.... +...#.... +...#.... +....###. +........ +........ + +; character 117 (u) width = 8 +........ +........ +........ +........ +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +........ +........ + +; character 118 (v) width = 8 +........ +........ +........ +........ +........ +.#....#. +.#....#. +.#....#. +..#..#.. +..#..#.. +...##... +...##... +........ +........ + +; character 119 (w) width = 8 +........ +........ +........ +........ +........ +#.....#. +#.....#. +#..#..#. +#..#..#. +#..#..#. +#..#..#. +.#####.. +........ +........ + +; character 120 (x) width = 8 +........ +........ +........ +........ +........ +.#....#. +.#....#. +..#..#.. +...##... +..#..#.. +.#....#. +.#....#. +........ +........ + +; character 121 (y) width = 8 +........ +........ +........ +........ +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +......#. +..####.. + +; character 122 (z) width = 8 +........ +........ +........ +........ +........ +.######. +.....#.. +....#... +...#.... +..#..... +.#...... +.######. +........ +........ + +; character 123 ({) width = 8 +........ +........ +....##.. +...#.... +...#.... +...#.... +..#..... +...#.... +...#.... +...#.... +...#.... +....##.. +........ +........ + +; character 124 (|) width = 8 +........ +........ +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +........ +........ + +; character 125 (}) width = 8 +........ +........ +..##.... +....#... +....#... +....#... +.....#.. +....#... +....#... +....#... +....#... +..##.... +........ +........ + +; character 126 (~) width = 8 +........ +.##...#. +#..#..#. +#...##.. +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 127 width = 8 +........ +........ +........ +........ +...#.... +..#.#... +.#...#.. +#.....#. +#.....#. +#.....#. +#######. +........ +........ +........ + +; character 128 width = 8 +........ +........ +...###.. +..#...#. +.#...... +####.... +.#...... +####.... +.#...... +.#...... +..#...#. +...###.. +........ +........ + +; character 129 width = 8 +........ +........ +.######. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.######. +........ +........ + +; character 130 width = 8 +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +...#.... +...#.... +..#..... +........ + +; character 131 width = 8 +........ +........ +....##.. +...#..#. +...#.... +...#.... +.#####.. +...#.... +...#.... +...#.... +...#.... +...#.... +#..#.... +.##..... + +; character 132 width = 8 +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +..#..#.. +..#..#.. +.#..#... +........ + +; character 133 width = 8 +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +#..#..#. +#..#..#. +........ +........ + +; character 134 width = 8 +........ +........ +...#.... +...#.... +.#####.. +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +........ +........ + +; character 135 width = 8 +........ +........ +...#.... +...#.... +.#####.. +...#.... +...#.... +...#.... +...#.... +.#####.. +...#.... +...#.... +........ +........ + +; character 136 width = 8 +...##... +..#..#.. +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 137 width = 8 +........ +........ +.#..#... +#.#.#... +.#.#.... +...#.... +..#..... +..#..... +.#...... +.#.#.#.. +#.#.#.#. +#..#.#.. +........ +........ + +; character 138 width = 8 +..#..#.. +...##... +........ +..####.. +.#....#. +.#...... +.#...... +..####.. +......#. +......#. +.#....#. +..####.. +........ +........ + +; character 139 width = 8 +........ +........ +........ +........ +........ +.....#.. +....#... +...#.... +..#..... +...#.... +....#... +.....#.. +........ +........ + +; character 140 width = 8 +........ +........ +.######. +#..#.... +#..#.... +#..#.... +#..###.. +#..#.... +#..#.... +#..#.... +#..#.... +.######. +........ +........ + +; character 141 width = 8 +........ +........ +.######. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.######. +........ +........ + +; character 142 width = 8 +..#..#.. +...##... +........ +.######. +......#. +.....#.. +....#... +...#.... +..#..... +.#...... +.#...... +.######. +........ +........ + +; character 143 width = 8 +........ +........ +.######. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.######. +........ +........ + +; character 144 width = 8 +........ +........ +.######. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.######. +........ +........ + +; character 145 width = 8 +........ +....#... +...#.... +...#.... +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 146 width = 8 +........ +...#.... +...#.... +..#..... +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 147 width = 8 +........ +...#..#. +..#..#.. +..#..#.. +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 148 width = 8 +........ +..#..#.. +..#..#.. +.#..#... +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 149 width = 8 +........ +........ +........ +........ +........ +...##... +..####.. +..####.. +...##... +........ +........ +........ +........ +........ + +; character 150 width = 8 +........ +........ +........ +........ +........ +........ +........ +.######. +........ +........ +........ +........ +........ +........ + +; character 151 width = 8 +........ +........ +........ +........ +........ +........ +........ +#######. +........ +........ +........ +........ +........ +........ + +; character 152 width = 8 +..##..#. +.#..##.. +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 153 width = 8 +........ +........ +#####.## +.#.#.#.# +.#.#.#.# +.#.#...# +........ +........ +........ +........ +........ +........ +........ +........ + +; character 154 width = 8 +........ +........ +..#..#.. +...##... +........ +..#####. +.#...... +.#...... +..####.. +......#. +......#. +.#####.. +........ +........ + +; character 155 width = 8 +........ +........ +........ +........ +........ +..#..... +...#.... +....#... +.....#.. +....#... +...#.... +..#..... +........ +........ + +; character 156 width = 8 +........ +........ +........ +........ +........ +.#####.. +#..#..#. +#..#..#. +#..####. +#..#.... +#..#.... +.#####.. +........ +........ + +; character 157 width = 8 +........ +........ +.######. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.######. +........ +........ + +; character 158 width = 8 +........ +........ +..#..#.. +...##... +........ +.######. +.....#.. +....#... +...#.... +..#..... +.#...... +.######. +........ +........ + +; character 159 width = 8 +.#...#.. +.#...#.. +........ +#.....#. +#.....#. +.#...#.. +.#...#.. +..#.#... +...#.... +...#.... +...#.... +...#.... +........ +........ + +; character 160 width = 8 +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 161 width = 8 +........ +........ +...#.... +...#.... +........ +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +........ +........ + +; character 162 width = 8 +........ +........ +........ +...#.... +...#.... +.#####.. +#..#..#. +#..#.... +#..#.... +#..#.... +#..#..#. +.#####.. +...#.... +...#.... + +; character 163 width = 8 +........ +........ +...##... +..#..#.. +..#..... +..#..... +.####... +..#..... +..#..... +..#..... +..#...#. +.######. +........ +........ + +; character 164 width = 8 +........ +........ +........ +........ +.#...#.. +..###... +.#...#.. +.#...#.. +.#...#.. +..###... +.#...#.. +........ +........ +........ + +; character 165 width = 8 +........ +........ +#.....#. +#.....#. +.#...#.. +..#.#... +...#.... +.#####.. +...#.... +.#####.. +...#.... +...#.... +........ +........ + +; character 166 width = 8 +........ +........ +...#.... +...#.... +...#.... +...#.... +........ +........ +...#.... +...#.... +...#.... +...#.... +........ +........ + +; character 167 width = 8 +........ +..###... +.#...#.. +.#...... +..##.... +.#..#... +.#...#.. +.#...#.. +..#..#.. +...##... +.....#.. +.#...#.. +..###... +........ + +; character 168 width = 8 +..#..#.. +..#..#.. +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 169 width = 8 +........ +........ +........ +.######. +#......# +#..##..# +#.#..#.# +#.#....# +#.#..#.# +#..##..# +#......# +.######. +........ +........ + +; character 170 width = 8 +........ +..####.. +.#...#.. +.#...#.. +.#..##.. +..##.#.. +........ +.#####.. +........ +........ +........ +........ +........ +........ + +; character 171 width = 8 +........ +........ +........ +........ +........ +...#..#. +..#..#.. +.#..#... +#..#.... +.#..#... +..#..#.. +...#..#. +........ +........ + +; character 172 width = 8 +........ +........ +........ +........ +........ +........ +.######. +......#. +......#. +........ +........ +........ +........ +........ + +; character 173 width = 8 +........ +........ +........ +........ +........ +........ +........ +..####.. +........ +........ +........ +........ +........ +........ + +; character 174 width = 8 +........ +........ +........ +.######. +#......# +#.###..# +#.#..#.# +#.###..# +#.#.#..# +#.#..#.# +#......# +.######. +........ +........ + +; character 175 width = 8 +.######. +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 176 width = 8 +........ +...##... +..#..#.. +..#..#.. +...##... +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 177 width = 8 +........ +........ +........ +........ +...#.... +...#.... +.#####.. +...#.... +...#.... +........ +........ +.#####.. +........ +........ + +; character 178 width = 8 +........ +...##... +..#..#.. +....#... +...#.... +..####.. +........ +........ +........ +........ +........ +........ +........ +........ + +; character 179 width = 8 +........ +..###... +.....#.. +...##... +.....#.. +..###... +........ +........ +........ +........ +........ +........ +........ +........ + +; character 180 width = 8 +.....#.. +....#... +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ + +; character 181 width = 8 +........ +........ +........ +........ +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#...##. +.####.#. +.#...... +.#...... + +; character 182 width = 8 +........ +........ +.######. +#..#..#. +#..#..#. +#..#..#. +#..#..#. +.###..#. +...#..#. +...#..#. +...#..#. +...#..#. +........ +........ + +; character 183 width = 8 +........ +........ +........ +........ +........ +........ +...#.... +...#.... +........ +........ +........ +........ +........ +........ + +; character 184 width = 8 +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +........ +...#.... +...#.... +..#..... + +; character 185 width = 8 +........ +...#.... +..##.... +...#.... +...#.... +...#.... +........ +........ +........ +........ +........ +........ +........ +........ + +; character 186 width = 8 +........ +..###... +.#...#.. +.#...#.. +.#...#.. +..###... +........ +.#####.. +........ +........ +........ +........ +........ +........ + +; character 187 width = 8 +........ +........ +........ +........ +........ +#..#.... +.#..#... +..#..#.. +...#..#. +..#..#.. +.#..#... +#..#.... +........ +........ + +; character 188 width = 8 +..#..... +.##..... +..#..... +..#...#. +..#..#.. +....#... +...#.... +..#...#. +.#...##. +#...#.#. +...####. +......#. +......#. +........ + +; character 189 width = 8 +..#..... +.##..... +..#..... +..#...#. +..#..#.. +....#... +...#.... +..#..... +.#..##.. +#..#..#. +.....#.. +....#... +...####. +........ + +; character 190 width = 8 +###..... +...#.... +.##..... +...#..#. +###..#.. +....#... +...#.... +..#...#. +.#...##. +#...#.#. +...####. +......#. +......#. +........ + +; character 191 width = 8 +........ +........ +...#.... +...#.... +........ +...#.... +...#.... +..#..... +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 192 width = 8 +..#..... +...#.... +........ +..####.. +.#....#. +.#....#. +.#....#. +.######. +.#....#. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 193 width = 8 +.....#.. +....#... +........ +..####.. +.#....#. +.#....#. +.#....#. +.######. +.#....#. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 194 width = 8 +...##... +..#..#.. +........ +..####.. +.#....#. +.#....#. +.#....#. +.######. +.#....#. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 195 width = 8 +..##..#. +.#..##.. +........ +..####.. +.#....#. +.#....#. +.#....#. +.######. +.#....#. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 196 width = 8 +..#..#.. +..#..#.. +........ +..####.. +.#....#. +.#....#. +.#....#. +.######. +.#....#. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 197 width = 8 +...##... +..#..#.. +...##... +..####.. +.#....#. +.#....#. +.#....#. +.######. +.#....#. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 198 width = 8 +........ +........ +.######. +#..#.... +#..#.... +#..#.... +######.. +#..#.... +#..#.... +#..#.... +#..#.... +#..####. +........ +........ + +; character 199 width = 8 +........ +........ +..####.. +.#....#. +.#....#. +.#...... +.#...... +.#...... +.#...... +.#....#. +.#....#. +..####.. +...#.... +..#..... + +; character 200 width = 8 +..#..... +...#.... +........ +.######. +.#...... +.#...... +.#...... +.####... +.#...... +.#...... +.#...... +.######. +........ +........ + +; character 201 width = 8 +.....#.. +....#... +........ +.######. +.#...... +.#...... +.#...... +.####... +.#...... +.#...... +.#...... +.######. +........ +........ + +; character 202 width = 8 +...##... +..#..#.. +........ +.######. +.#...... +.#...... +.#...... +.####... +.#...... +.#...... +.#...... +.######. +........ +........ + +; character 203 width = 8 +..#..#.. +..#..#.. +........ +.######. +.#...... +.#...... +.#...... +.####... +.#...... +.#...... +.#...... +.######. +........ +........ + +; character 204 width = 8 +..#..... +...#.... +........ +..###... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +..###... +........ +........ + +; character 205 width = 8 +....#... +...#.... +........ +..###... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +..###... +........ +........ + +; character 206 width = 8 +..##.... +.#..#... +........ +..###... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +..###... +........ +........ + +; character 207 width = 8 +.#...#.. +.#...#.. +........ +..###... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +...#.... +..###... +........ +........ + +; character 208 width = 8 +........ +........ +.####... +.#...#.. +.#....#. +.#....#. +####..#. +.#....#. +.#....#. +.#....#. +.#...#.. +.####... +........ +........ + +; character 209 width = 8 +..##..#. +.#..##.. +........ +.#....#. +.#....#. +.##...#. +.#.#..#. +.#..#.#. +.#...##. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 210 width = 8 +..#..... +...#.... +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 211 width = 8 +.....#.. +....#... +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 212 width = 8 +...##... +..#..#.. +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 213 width = 8 +..##..#. +.#..##.. +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 214 width = 8 +..#..#.. +..#..#.. +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 215 width = 8 +........ +........ +........ +........ +........ +.#....#. +..#..#.. +...##... +..#..#.. +.#....#. +........ +........ +........ +........ + +; character 216 width = 8 +........ +......#. +..#####. +.#...##. +.#...##. +.#..#.#. +.#..#.#. +.#.#..#. +.#.#..#. +.##...#. +.##...#. +.#####.. +.#...... +........ + +; character 217 width = 8 +..#..... +...#.... +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 218 width = 8 +.....#.. +....#... +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 219 width = 8 +...##... +..#..#.. +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 220 width = 8 +..#..#.. +..#..#.. +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 221 width = 8 +....#... +...#.... +#.....#. +#.....#. +.#...#.. +.#...#.. +..#.#... +...#.... +...#.... +...#.... +...#.... +...#.... +........ +........ + +; character 222 width = 8 +........ +........ +.#...... +.#...... +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#####.. +.#...... +.#...... +........ +........ + +; character 223 width = 8 +........ +........ +..###... +.#...#.. +.#...#.. +.#..#... +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#####.. +.#...... +.#...... + +; character 224 width = 8 +........ +........ +..#..... +...#.... +........ +..#####. +.#....#. +.#....#. +.#....#. +.#....#. +.#...##. +..###.#. +........ +........ + +; character 225 width = 8 +........ +........ +.....#.. +....#... +........ +..#####. +.#....#. +.#....#. +.#....#. +.#....#. +.#...##. +..###.#. +........ +........ + +; character 226 width = 8 +........ +........ +...##... +..#..#.. +........ +..#####. +.#....#. +.#....#. +.#....#. +.#....#. +.#...##. +..###.#. +........ +........ + +; character 227 width = 8 +........ +........ +..##..#. +.#..##.. +........ +..#####. +.#....#. +.#....#. +.#....#. +.#....#. +.#...##. +..###.#. +........ +........ + +; character 228 width = 8 +........ +........ +..#..#.. +..#..#.. +........ +..#####. +.#....#. +.#....#. +.#....#. +.#....#. +.#...##. +..###.#. +........ +........ + +; character 229 width = 8 +........ +........ +...##... +..#..#.. +...##... +..#####. +.#....#. +.#....#. +.#....#. +.#....#. +.#...##. +..###.#. +........ +........ + +; character 230 width = 8 +........ +........ +........ +........ +........ +.#####.. +#..#..#. +#..#..#. +#..####. +#..#.... +#..#.... +.##.##.. +........ +........ + +; character 231 width = 8 +........ +........ +........ +........ +........ +..####.. +.#....#. +.#...... +.#...... +.#...... +.#....#. +..####.. +...#.... +..#..... + +; character 232 width = 8 +........ +........ +..#..... +...#.... +........ +..####.. +.#....#. +.#....#. +.######. +.#...... +.#...... +..####.. +........ +........ + +; character 233 width = 8 +........ +........ +.....#.. +....#... +........ +..####.. +.#....#. +.#....#. +.######. +.#...... +.#...... +..####.. +........ +........ + +; character 234 width = 8 +........ +........ +...##... +..#..#.. +........ +..####.. +.#....#. +.#....#. +.######. +.#...... +.#...... +..####.. +........ +........ + +; character 235 width = 8 +........ +........ +..#..#.. +..#..#.. +........ +..####.. +.#....#. +.#....#. +.######. +.#...... +.#...... +..####.. +........ +........ + +; character 236 width = 8 +........ +........ +..#..... +...#.... +........ +..##.... +...#.... +...#.... +...#.... +...#.... +...#.... +..###... +........ +........ + +; character 237 width = 8 +........ +........ +....#... +...#.... +........ +..##.... +...#.... +...#.... +...#.... +...#.... +...#.... +..###... +........ +........ + +; character 238 width = 8 +........ +........ +..##.... +.#..#... +........ +..##.... +...#.... +...#.... +...#.... +...#.... +...#.... +..###... +........ +........ + +; character 239 width = 8 +........ +........ +.#..#... +.#..#... +........ +..##.... +...#.... +...#.... +...#.... +...#.... +...#.... +..###... +........ +........ + +; character 240 width = 8 +........ +........ +..#.#... +...#.... +..#.#... +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 241 width = 8 +........ +........ +..##..#. +.#..##.. +........ +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +........ +........ + +; character 242 width = 8 +........ +........ +..#..... +...#.... +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 243 width = 8 +........ +........ +.....#.. +....#... +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 244 width = 8 +........ +........ +...##... +..#..#.. +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 245 width = 8 +........ +........ +..##..#. +.#..##.. +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 246 width = 8 +........ +........ +..#..#.. +..#..#.. +........ +..####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..####.. +........ +........ + +; character 247 width = 8 +........ +........ +........ +........ +...#.... +...#.... +........ +.#####.. +........ +...#.... +...#.... +........ +........ +........ + +; character 248 width = 8 +........ +........ +........ +........ +......#. +..####.. +.#...##. +.#..#.#. +.#.#..#. +.##...#. +.#....#. +#.####.. +........ +........ + +; character 249 width = 8 +........ +........ +..#..... +...#.... +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +........ +........ + +; character 250 width = 8 +........ +........ +.....#.. +....#... +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +........ +........ + +; character 251 width = 8 +........ +........ +...##... +..#..#.. +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +........ +........ + +; character 252 width = 8 +........ +........ +..#..#.. +..#..#.. +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +........ +........ + +; character 253 width = 8 +........ +........ +.....#.. +....#... +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +......#. +..####.. + +; character 254 width = 8 +........ +........ +.#...... +.#...... +.#...... +.#####.. +.#....#. +.#....#. +.#....#. +.#....#. +.#####.. +.#...... +.#...... +.#...... + +; character 255 width = 8 +........ +........ +..#..#.. +..#..#.. +........ +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +.#....#. +..#####. +......#. +..####.. diff --git a/thirdparty/grx249/fonts/ter-114v.psf b/thirdparty/grx249/fonts/ter-114v.psf new file mode 100644 index 0000000..a84b253 Binary files /dev/null and b/thirdparty/grx249/fonts/ter-114v.psf differ diff --git a/thirdparty/grx249/fonts/tms11.fnt b/thirdparty/grx249/fonts/tms11.fnt new file mode 100644 index 0000000..e6fd4c5 --- /dev/null +++ b/thirdparty/grx249/fonts/tms11.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3bf3edd92f2921d745daa042c3f326d36d4c6e7bfce446d319bec89f3c227fef +size 3087 diff --git a/thirdparty/grx249/fonts/tms11b.fnt b/thirdparty/grx249/fonts/tms11b.fnt new file mode 100644 index 0000000..00fdf25 --- /dev/null +++ b/thirdparty/grx249/fonts/tms11b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eef3306fadda667cd5a3bcd584a312c8a24083182c97aa13c9243cff41664f31 +size 3125 diff --git a/thirdparty/grx249/fonts/tms11bi.fnt b/thirdparty/grx249/fonts/tms11bi.fnt new file mode 100644 index 0000000..3413c58 --- /dev/null +++ b/thirdparty/grx249/fonts/tms11bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe5a6366de6c25a2e39b64d520a9da7f38321ff6b16c4414a0e064a916f4ab6a +size 3114 diff --git a/thirdparty/grx249/fonts/tms11i.fnt b/thirdparty/grx249/fonts/tms11i.fnt new file mode 100644 index 0000000..a8a2469 --- /dev/null +++ b/thirdparty/grx249/fonts/tms11i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2806b6246114acf96530ef87c2468161b74cf6ab6bd8d1f553fa3b2be4b0c99f +size 3087 diff --git a/thirdparty/grx249/fonts/tms13.fnt b/thirdparty/grx249/fonts/tms13.fnt new file mode 100644 index 0000000..78d607e --- /dev/null +++ b/thirdparty/grx249/fonts/tms13.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49f09dab27a2edb509b303bd6cc4db2be9e8e9803040b95f93015843ebf2a57e +size 3325 diff --git a/thirdparty/grx249/fonts/tms13b.fnt b/thirdparty/grx249/fonts/tms13b.fnt new file mode 100644 index 0000000..7f90b8c --- /dev/null +++ b/thirdparty/grx249/fonts/tms13b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b65feaedd648bbd009f5f702b43d72092f671a1343da44471194e395e8a21d81 +size 3362 diff --git a/thirdparty/grx249/fonts/tms13bi.fnt b/thirdparty/grx249/fonts/tms13bi.fnt new file mode 100644 index 0000000..2bc0755 --- /dev/null +++ b/thirdparty/grx249/fonts/tms13bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9aaa8b49478d2936ef1fa8ecc8dc0ef450d9e0c595ba9f6bc2cb38452eb6dc95 +size 3388 diff --git a/thirdparty/grx249/fonts/tms13i.fnt b/thirdparty/grx249/fonts/tms13i.fnt new file mode 100644 index 0000000..fd3c2ec --- /dev/null +++ b/thirdparty/grx249/fonts/tms13i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea6a270cb64380af42c2e08f009f2be7d8bcd674214048eaf1d0c657a4afcb84 +size 3364 diff --git a/thirdparty/grx249/fonts/tms15.fnt b/thirdparty/grx249/fonts/tms15.fnt new file mode 100644 index 0000000..0fb4a66 --- /dev/null +++ b/thirdparty/grx249/fonts/tms15.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e49c8c2e9b130540dcf3c457db954e1bb5c5010942c6676c8e693d058460d5b +size 3716 diff --git a/thirdparty/grx249/fonts/tms15b.fnt b/thirdparty/grx249/fonts/tms15b.fnt new file mode 100644 index 0000000..3b916a3 --- /dev/null +++ b/thirdparty/grx249/fonts/tms15b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:016b117a7cd11ca2d62de4263f1d0991ac618fd1acdb3a392cb70ad1bee3ca00 +size 3804 diff --git a/thirdparty/grx249/fonts/tms15bi.fnt b/thirdparty/grx249/fonts/tms15bi.fnt new file mode 100644 index 0000000..17a2a49 --- /dev/null +++ b/thirdparty/grx249/fonts/tms15bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:425d0ec41f88ff501f82074a705677c8fd5e58f309283e938c4889f37427a527 +size 3879 diff --git a/thirdparty/grx249/fonts/tms15i.fnt b/thirdparty/grx249/fonts/tms15i.fnt new file mode 100644 index 0000000..68ac7ad --- /dev/null +++ b/thirdparty/grx249/fonts/tms15i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ea8676def23dcd7b7f5f55dd347a101c8e86b74f52bce7538b6a65dfe45d0a2 +size 3716 diff --git a/thirdparty/grx249/fonts/tms18.fnt b/thirdparty/grx249/fonts/tms18.fnt new file mode 100644 index 0000000..8ae34d1 --- /dev/null +++ b/thirdparty/grx249/fonts/tms18.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:765d574659030d1a3f1cb6b86202deda2d63035fefe59037cec57a847251ca19 +size 4229 diff --git a/thirdparty/grx249/fonts/tms18b.fnt b/thirdparty/grx249/fonts/tms18b.fnt new file mode 100644 index 0000000..5743e67 --- /dev/null +++ b/thirdparty/grx249/fonts/tms18b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa2ee4732fd02e176ff526544f421ac5ac126500855bfebef17052b918e825ea +size 4299 diff --git a/thirdparty/grx249/fonts/tms18bi.fnt b/thirdparty/grx249/fonts/tms18bi.fnt new file mode 100644 index 0000000..8735052 --- /dev/null +++ b/thirdparty/grx249/fonts/tms18bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f32990d3bd569040de85ee198bc4c7f713173bb0b941b32413122cea9de333b5 +size 4400 diff --git a/thirdparty/grx249/fonts/tms18i.fnt b/thirdparty/grx249/fonts/tms18i.fnt new file mode 100644 index 0000000..7ae1f55 --- /dev/null +++ b/thirdparty/grx249/fonts/tms18i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3788fa8ed0ec46c5710b548b81856f13391e939110cc1215597a795a4c7a46e7 +size 4337 diff --git a/thirdparty/grx249/fonts/tms22.fnt b/thirdparty/grx249/fonts/tms22.fnt new file mode 100644 index 0000000..ddf1604 --- /dev/null +++ b/thirdparty/grx249/fonts/tms22.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f540a1b97d60ebc59a58e9aca5cb073469c4b13eb165fa923e5da164c90feea4 +size 5603 diff --git a/thirdparty/grx249/fonts/tms22b.fnt b/thirdparty/grx249/fonts/tms22b.fnt new file mode 100644 index 0000000..ee6f1ac --- /dev/null +++ b/thirdparty/grx249/fonts/tms22b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b960b168af149871a408eb4da4971777102df87659c4fdd6e9efed89cdf967e +size 5694 diff --git a/thirdparty/grx249/fonts/tms22bi.fnt b/thirdparty/grx249/fonts/tms22bi.fnt new file mode 100644 index 0000000..63d0b00 --- /dev/null +++ b/thirdparty/grx249/fonts/tms22bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:64d46f3496a49981b7e364b5fdead20e8c3f8e23d884296412ae19744a92f66a +size 5717 diff --git a/thirdparty/grx249/fonts/tms22i.fnt b/thirdparty/grx249/fonts/tms22i.fnt new file mode 100644 index 0000000..860c358 --- /dev/null +++ b/thirdparty/grx249/fonts/tms22i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:82b722749a092e6a8e835fc760789fb193c2604d5a15761505cb53b1ee85cd82 +size 5637 diff --git a/thirdparty/grx249/fonts/tms29.fnt b/thirdparty/grx249/fonts/tms29.fnt new file mode 100644 index 0000000..70a30a3 --- /dev/null +++ b/thirdparty/grx249/fonts/tms29.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:45d31023942da4a8bfabc3a87be9177551e57f95f9b33a9efb000bd5ffd1f85b +size 7439 diff --git a/thirdparty/grx249/fonts/tms29b.fnt b/thirdparty/grx249/fonts/tms29b.fnt new file mode 100644 index 0000000..ec9c558 --- /dev/null +++ b/thirdparty/grx249/fonts/tms29b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6fd2e624d01218098fdea5b028d2ff3237362008829675e42cdfa5d86a2ed4b +size 7727 diff --git a/thirdparty/grx249/fonts/tms29bi.fnt b/thirdparty/grx249/fonts/tms29bi.fnt new file mode 100644 index 0000000..0104157 --- /dev/null +++ b/thirdparty/grx249/fonts/tms29bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01fc2e80ee3b545d6c3f927c45a32562c3da97b8f954a9b80991572e81176c52 +size 7872 diff --git a/thirdparty/grx249/fonts/tms29i.fnt b/thirdparty/grx249/fonts/tms29i.fnt new file mode 100644 index 0000000..7bd6aaa --- /dev/null +++ b/thirdparty/grx249/fonts/tms29i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0b4e9b8993d524caaf437a21b66154f377ee6cb4e4c04c6809105dff7d0c67e +size 7794 diff --git a/thirdparty/grx249/fonts/tms38.fnt b/thirdparty/grx249/fonts/tms38.fnt new file mode 100644 index 0000000..97e6686 --- /dev/null +++ b/thirdparty/grx249/fonts/tms38.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56c4f48e88de400252951a5b9869dac8a2b89ac64aa3882588e5d99f2c8374ea +size 11009 diff --git a/thirdparty/grx249/fonts/tms38b.fnt b/thirdparty/grx249/fonts/tms38b.fnt new file mode 100644 index 0000000..f309044 --- /dev/null +++ b/thirdparty/grx249/fonts/tms38b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a38564989c8a2f57932eeb6dcde014492dbf8b659dda75e0fd4561b1c1259a4f +size 11539 diff --git a/thirdparty/grx249/fonts/tms38bi.fnt b/thirdparty/grx249/fonts/tms38bi.fnt new file mode 100644 index 0000000..0334016 --- /dev/null +++ b/thirdparty/grx249/fonts/tms38bi.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2396ff62a6e610eb8735eb035fccd56f6993d3ca166c320b5441bb758f381a1a +size 11615 diff --git a/thirdparty/grx249/fonts/tms38i.fnt b/thirdparty/grx249/fonts/tms38i.fnt new file mode 100644 index 0000000..173941f --- /dev/null +++ b/thirdparty/grx249/fonts/tms38i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4effb1e97528c8c8eae560ffa3a7cb8e32659334ffe0d4478d2e78c53a8c2ed +size 11313 diff --git a/thirdparty/grx249/fonts/xfonts.dir b/thirdparty/grx249/fonts/xfonts.dir new file mode 100644 index 0000000..9c548e5 --- /dev/null +++ b/thirdparty/grx249/fonts/xfonts.dir @@ -0,0 +1,255 @@ +char11.fnt:FONT -Bitstream-Charter-Medium-R-Normal--8-80-75-75-P-45-ISO8859-1 +char11b.fnt:FONT -Bitstream-Charter-Bold-R-Normal--8-80-75-75-P-50-ISO8859-1 +char11bi.fnt:FONT -Bitstream-Charter-Bold-I-Normal--8-80-75-75-P-50-ISO8859-1 +char11i.fnt:FONT -Bitstream-Charter-Medium-I-Normal--8-80-75-75-P-44-ISO8859-1 +char14.fnt:FONT -Bitstream-Charter-Medium-R-Normal--10-100-75-75-P-56-ISO8859-1 +char14b.fnt:FONT -Bitstream-Charter-Bold-R-Normal--10-100-75-75-P-63-ISO8859-1 +char14bi.fnt:FONT -Bitstream-Charter-Bold-I-Normal--10-100-75-75-P-62-ISO8859-1 +char14i.fnt:FONT -Bitstream-Charter-Medium-I-Normal--10-100-75-75-P-55-ISO8859-1 +char16.fnt:FONT -Bitstream-Charter-Medium-R-Normal--12-120-75-75-P-67-ISO8859-1 +char16b.fnt:FONT -Bitstream-Charter-Bold-R-Normal--12-120-75-75-P-75-ISO8859-1 +char16bi.fnt:FONT -Bitstream-Charter-Bold-I-Normal--12-120-75-75-P-74-ISO8859-1 +char16i.fnt:FONT -Bitstream-Charter-Medium-I-Normal--12-120-75-75-P-65-ISO8859-1 +char18.fnt:FONT -Bitstream-Charter-Medium-R-Normal--15-140-75-75-P-84-ISO8859-1 +char18b.fnt:FONT -Bitstream-Charter-Bold-R-Normal--15-140-75-75-P-94-ISO8859-1 +char18bi.fnt:FONT -Bitstream-Charter-Bold-I-Normal--15-140-75-75-P-93-ISO8859-1 +char18i.fnt:FONT -Bitstream-Charter-Medium-I-Normal--15-140-75-75-P-82-ISO8859-1 +char23.fnt:FONT -Bitstream-Charter-Medium-R-Normal--19-180-75-75-P-106-ISO8859-1 +char23b.fnt:FONT -Bitstream-Charter-Bold-R-Normal--19-180-75-75-P-119-ISO8859-1 +char23bi.fnt:FONT -Bitstream-Charter-Bold-I-Normal--19-180-75-75-P-117-ISO8859-1 +char23i.fnt:FONT -Bitstream-Charter-Medium-I-Normal--19-180-75-75-P-103-ISO8859-1 +char30.fnt:FONT -Bitstream-Charter-Medium-R-Normal--25-240-75-75-P-139-ISO8859-1 +char30b.fnt:FONT -Bitstream-Charter-Bold-R-Normal--25-240-75-75-P-157-ISO8859-1 +char30bi.fnt:FONT -Bitstream-Charter-Bold-I-Normal--25-240-75-75-P-154-ISO8859-1 +char30i.fnt:FONT -Bitstream-Charter-Medium-I-Normal--25-240-75-75-P-136-ISO8859-1 +char40.fnt:FONT -Bitstream-Charter-Medium-R-Normal--33-240-100-100-P-183-ISO8859-1 +char40b.fnt:FONT -Bitstream-Charter-Bold-R-Normal--33-240-100-100-P-206-ISO8859-1 +char40bi.fnt:FONT -Bitstream-Charter-Bold-I-Normal--33-240-100-100-P-203-ISO8859-1 +char40i.fnt:FONT -Bitstream-Charter-Medium-I-Normal--33-240-100-100-P-179-ISO8859-1 +cour11.fnt:FONT -Adobe-Courier-Medium-R-Normal--8-80-75-75-M-50-ISO8859-1 +cour11b.fnt:FONT -Adobe-Courier-Bold-R-Normal--8-80-75-75-M-50-ISO8859-1 +cour11bi.fnt:FONT -Adobe-Courier-Bold-O-Normal--8-80-75-75-M-50-ISO8859-1 +cour11i.fnt:FONT -Adobe-Courier-Medium-O-Normal--8-80-75-75-M-50-ISO8859-1 +cour12.fnt:FONT -Adobe-Courier-Medium-R-Normal--10-100-75-75-M-60-ISO8859-1 +cour12b.fnt:FONT -Adobe-Courier-Bold-R-Normal--10-100-75-75-M-60-ISO8859-1 +cour12bi.fnt:FONT -Adobe-Courier-Bold-O-Normal--10-100-75-75-M-60-ISO8859-1 +cour12i.fnt:FONT -Adobe-Courier-Medium-O-Normal--10-100-75-75-M-60-ISO8859-1 +cour14.fnt:FONT -Adobe-Courier-Medium-R-Normal--12-120-75-75-M-70-ISO8859-1 +cour14b.fnt:FONT -Adobe-Courier-Bold-R-Normal--12-120-75-75-M-70-ISO8859-1 +cour14bi.fnt:FONT -Adobe-Courier-Bold-O-Normal--12-120-75-75-M-70-ISO8859-1 +cour14i.fnt:FONT -Adobe-Courier-Medium-O-Normal--12-120-75-75-M-70-ISO8859-1 +cour16.fnt:FONT -Adobe-Courier-Medium-R-Normal--14-140-75-75-M-90-ISO8859-1 +cour16b.fnt:FONT -Adobe-Courier-Bold-R-Normal--14-140-75-75-M-90-ISO8859-1 +cour16bi.fnt:FONT -Adobe-Courier-Bold-O-Normal--14-140-75-75-M-90-ISO8859-1 +cour16i.fnt:FONT -Adobe-Courier-Medium-O-Normal--14-140-75-75-M-90-ISO8859-1 +cour20.fnt:FONT -Adobe-Courier-Medium-R-Normal--18-180-75-75-M-110-ISO8859-1 +cour20b.fnt:FONT -Adobe-Courier-Bold-R-Normal--18-180-75-75-M-110-ISO8859-1 +cour20bi.fnt:FONT -Adobe-Courier-Bold-O-Normal--18-180-75-75-M-110-ISO8859-1 +cour20i.fnt:FONT -Adobe-Courier-Medium-O-Normal--18-180-75-75-M-110-ISO8859-1 +cour25.fnt:FONT -Adobe-Courier-Medium-R-Normal--24-240-75-75-M-150-ISO8859-1 +cour25b.fnt:FONT -Adobe-Courier-Bold-R-Normal--24-240-75-75-M-150-ISO8859-1 +cour25bi.fnt:FONT -Adobe-Courier-Bold-O-Normal--24-240-75-75-M-150-ISO8859-1 +cour25i.fnt:FONT -Adobe-Courier-Medium-O-Normal--24-240-75-75-M-150-ISO8859-1 +cour34.fnt:FONT -Adobe-Courier-Medium-R-Normal--34-240-100-100-M-200-ISO8859-1 +cour34b.fnt:FONT -Adobe-Courier-Bold-R-Normal--34-240-100-100-M-200-ISO8859-1 +cour34bi.fnt:FONT -Adobe-Courier-Bold-O-Normal--34-240-100-100-M-200-ISO8859-1 +cour34i.fnt:FONT -Adobe-Courier-Medium-O-Normal--34-240-100-100-M-200-ISO8859-1 +helv11.fnt:FONT -Adobe-Helvetica-Medium-R-Normal--8-80-75-75-P-46-ISO8859-1 +helv11b.fnt:FONT -Adobe-Helvetica-Bold-R-Normal--8-80-75-75-P-50-ISO8859-1 +helv11bi.fnt:FONT -Adobe-Helvetica-Bold-O-Normal--8-80-75-75-P-50-ISO8859-1 +helv11i.fnt:FONT -Adobe-Helvetica-Medium-O-Normal--8-80-75-75-P-47-ISO8859-1 +helv13.fnt:FONT -Adobe-Helvetica-Medium-R-Normal--10-100-75-75-P-56-ISO8859-1 +helv13b.fnt:FONT -Adobe-Helvetica-Bold-R-Normal--10-100-75-75-P-60-ISO8859-1 +helv13bi.fnt:FONT -Adobe-Helvetica-Bold-O-Normal--10-100-75-75-P-60-ISO8859-1 +helv13i.fnt:FONT -Adobe-Helvetica-Medium-O-Normal--10-100-75-75-P-57-ISO8859-1 +helv15.fnt:FONT -Adobe-Helvetica-Medium-R-Normal--12-120-75-75-P-67-ISO8859-1 +helv15b.fnt:FONT -Adobe-Helvetica-Bold-R-Normal--12-120-75-75-P-70-ISO8859-1 +helv15bi.fnt:FONT -Adobe-Helvetica-Bold-O-Normal--12-120-75-75-P-69-ISO8859-1 +helv15i.fnt:FONT -Adobe-Helvetica-Medium-O-Normal--12-120-75-75-P-67-ISO8859-1 +helv17.fnt:FONT -Adobe-Helvetica-Medium-R-Normal--14-140-75-75-P-77-ISO8859-1 +helv17b.fnt:FONT -Adobe-Helvetica-Bold-R-Normal--14-140-75-75-P-82-ISO8859-1 +helv17bi.fnt:FONT -Adobe-Helvetica-Bold-O-Normal--14-140-75-75-P-82-ISO8859-1 +helv17i.fnt:FONT -Adobe-Helvetica-Medium-O-Normal--14-140-75-75-P-78-ISO8859-1 +helv22.fnt:FONT -Adobe-Helvetica-Medium-R-Normal--18-180-75-75-P-98-ISO8859-1 +helv22b.fnt:FONT -Adobe-Helvetica-Bold-R-Normal--18-180-75-75-P-103-ISO8859-1 +helv22bi.fnt:FONT -Adobe-Helvetica-Bold-O-Normal--18-180-75-75-P-104-ISO8859-1 +helv22i.fnt:FONT -Adobe-Helvetica-Medium-O-Normal--18-180-75-75-P-98-ISO8859-1 +helv29.fnt:FONT -Adobe-Helvetica-Medium-R-Normal--24-240-75-75-P-130-ISO8859-1 +helv29b.fnt:FONT -Adobe-Helvetica-Bold-R-Normal--24-240-75-75-P-138-ISO8859-1 +helv29bi.fnt:FONT -Adobe-Helvetica-Bold-O-Normal--24-240-75-75-P-138-ISO8859-1 +helv29i.fnt:FONT -Adobe-Helvetica-Medium-O-Normal--24-240-75-75-P-130-ISO8859-1 +helv38.fnt:FONT -Adobe-Helvetica-Medium-R-Normal--34-240-100-100-P-176-ISO8859-1 +helv38b.fnt:FONT -Adobe-Helvetica-Bold-R-Normal--34-240-100-100-P-182-ISO8859-1 +helv38bi.fnt:FONT -Adobe-Helvetica-Bold-O-Normal--34-240-100-100-P-182-ISO8859-1 +helv38i.fnt:FONT -Adobe-Helvetica-Medium-O-Normal--34-240-100-100-P-176-ISO8859-1 +lucb11.fnt:FONT -B&H-LucidaBright-Medium-R-Normal--8-80-75-75-P-45-ISO8859-1 +lucb11b.fnt:FONT -B&H-LucidaBright-DemiBold-R-Normal--8-80-75-75-P-47-ISO8859-1 +lucb11bi.fnt:FONT -B&H-LucidaBright-DemiBold-I-Normal--8-80-75-75-P-48-ISO8859-1 +lucb11i.fnt:FONT -B&H-LucidaBright-Medium-I-Normal--8-80-75-75-P-45-ISO8859-1 +lucb12.fnt:FONT -B&H-LucidaBright-Medium-R-Normal--10-100-75-75-P-56-ISO8859-1 +lucb12b.fnt:FONT -B&H-LucidaBright-DemiBold-R-Normal--10-100-75-75-P-59-ISO8859-1 +lucb12bi.fnt:FONT -B&H-LucidaBright-DemiBold-I-Normal--10-100-75-75-P-59-ISO8859-1 +lucb12i.fnt:FONT -B&H-LucidaBright-Medium-I-Normal--10-100-75-75-P-57-ISO8859-1 +lucb15.fnt:FONT -B&H-LucidaBright-Medium-R-Normal--12-120-75-75-P-68-ISO8859-1 +lucb15b.fnt:FONT -B&H-LucidaBright-DemiBold-R-Normal--12-120-75-75-P-71-ISO8859-1 +lucb15bi.fnt:FONT -B&H-LucidaBright-DemiBold-I-Normal--12-120-75-75-P-72-ISO8859-1 +lucb15i.fnt:FONT -B&H-LucidaBright-Medium-I-Normal--12-120-75-75-P-67-ISO8859-1 +lucb17.fnt:FONT -B&H-LucidaBright-Medium-R-Normal--14-140-75-75-P-80-ISO8859-1 +lucb17b.fnt:FONT -B&H-LucidaBright-DemiBold-R-Normal--14-140-75-75-P-84-ISO8859-1 +lucb17bi.fnt:FONT -B&H-LucidaBright-DemiBold-I-Normal--14-140-75-75-P-84-ISO8859-1 +lucb17i.fnt:FONT -B&H-LucidaBright-Medium-I-Normal--14-140-75-75-P-80-ISO8859-1 +lucb21.fnt:FONT -B&H-LucidaBright-Medium-R-Normal--18-180-75-75-P-103-ISO8859-1 +lucb21b.fnt:FONT -B&H-LucidaBright-DemiBold-R-Normal--18-180-75-75-P-107-ISO8859-1 +lucb21bi.fnt:FONT -B&H-LucidaBright-DemiBold-I-Normal--18-180-75-75-P-107-ISO8859-1 +lucb21i.fnt:FONT -B&H-LucidaBright-Medium-I-Normal--18-180-75-75-P-102-ISO8859-1 +lucb27.fnt:FONT -B&H-LucidaBright-Medium-R-Normal--24-240-75-75-P-137-ISO8859-1 +lucb27b.fnt:FONT -B&H-LucidaBright-DemiBold-R-Normal--24-240-75-75-P-143-ISO8859-1 +lucb27bi.fnt:FONT -B&H-LucidaBright-DemiBold-I-Normal--24-240-75-75-P-143-ISO8859-1 +lucb27i.fnt:FONT -B&H-LucidaBright-Medium-I-Normal--24-240-75-75-P-136-ISO8859-1 +lucb40.fnt:FONT -B&H-LucidaBright-Medium-R-Normal--34-240-100-100-P-193-ISO8859-1 +lucb40b.fnt:FONT -B&H-LucidaBright-DemiBold-R-Normal--34-240-100-100-P-202-ISO8859-1 +lucb40bi.fnt:FONT -B&H-LucidaBright-DemiBold-I-Normal--34-240-100-100-P-203-ISO8859-1 +lucb40i.fnt:FONT -B&H-LucidaBright-Medium-I-Normal--34-240-100-100-P-194-ISO8859-1 +lucs11.fnt:FONT -B&H-Lucida-Medium-R-Normal-Sans-8-80-75-75-P-45-ISO8859-1 +lucs11b.fnt:FONT -B&H-Lucida-Bold-R-Normal-Sans-8-80-75-75-P-50-ISO8859-1 +lucs11bi.fnt:FONT -B&H-Lucida-Bold-I-Normal-Sans-8-80-75-75-P-49-ISO8859-1 +lucs11i.fnt:FONT -B&H-Lucida-Medium-I-Normal-Sans-8-80-75-75-P-45-ISO8859-1 +lucs12.fnt:FONT -B&H-Lucida-Medium-R-Normal-Sans-10-100-75-75-P-58-ISO8859-1 +lucs12b.fnt:FONT -B&H-Lucida-Bold-R-Normal-Sans-10-100-75-75-P-66-ISO8859-1 +lucs12bi.fnt:FONT -B&H-Lucida-Bold-I-Normal-Sans-10-100-75-75-P-67-ISO8859-1 +lucs12i.fnt:FONT -B&H-Lucida-Medium-I-Normal-Sans-10-100-75-75-P-59-ISO8859-1 +lucs15.fnt:FONT -B&H-Lucida-Medium-R-Normal-Sans-12-120-75-75-P-71-ISO8859-1 +lucs15b.fnt:FONT -B&H-Lucida-Bold-R-Normal-Sans-12-120-75-75-P-79-ISO8859-1 +lucs15bi.fnt:FONT -B&H-Lucida-Bold-I-Normal-Sans-12-120-75-75-P-79-ISO8859-1 +lucs15i.fnt:FONT -B&H-Lucida-Medium-I-Normal-Sans-12-120-75-75-P-71-ISO8859-1 +lucs17.fnt:FONT -B&H-Lucida-Medium-R-Normal-Sans-14-140-75-75-P-81-ISO8859-1 +lucs17b.fnt:FONT -B&H-Lucida-Bold-R-Normal-Sans-14-140-75-75-P-92-ISO8859-1 +lucs17bi.fnt:FONT -B&H-Lucida-Bold-I-Normal-Sans-14-140-75-75-P-92-ISO8859-1 +lucs17i.fnt:FONT -B&H-Lucida-Medium-I-Normal-Sans-14-140-75-75-P-82-ISO8859-1 +lucs21.fnt:FONT -B&H-Lucida-Medium-R-Normal-Sans-18-180-75-75-P-106-ISO8859-1 +lucs21b.fnt:FONT -B&H-Lucida-Bold-R-Normal-Sans-18-180-75-75-P-120-ISO8859-1 +lucs21bi.fnt:FONT -B&H-Lucida-Bold-I-Normal-Sans-18-180-75-75-P-119-ISO8859-1 +lucs21i.fnt:FONT -B&H-Lucida-Medium-I-Normal-Sans-18-180-75-75-P-105-ISO8859-1 +lucs27.fnt:FONT -B&H-Lucida-Medium-R-Normal-Sans-24-240-75-75-P-136-ISO8859-1 +lucs27b.fnt:FONT -B&H-Lucida-Bold-R-Normal-Sans-24-240-75-75-P-152-ISO8859-1 +lucs27bi.fnt:FONT -B&H-Lucida-Bold-I-Normal-Sans-24-240-75-75-P-151-ISO8859-1 +lucs27i.fnt:FONT -B&H-Lucida-Medium-I-Normal-Sans-24-240-75-75-P-136-ISO8859-1 +lucs40.fnt:FONT -B&H-Lucida-Medium-R-Normal-Sans-34-240-100-100-P-191-ISO8859-1 +lucs40b.fnt:FONT -B&H-Lucida-Bold-R-Normal-Sans-34-240-100-100-P-216-ISO8859-1 +lucs40bi.fnt:FONT -B&H-Lucida-Bold-I-Normal-Sans-34-240-100-100-P-215-ISO8859-1 +lucs40i.fnt:FONT -B&H-Lucida-Medium-I-Normal-Sans-34-240-100-100-P-192-ISO8859-1 +luct10.fnt:FONT -B&H-LucidaTypewriter-Medium-R-Normal-Sans-8-80-75-75-M-50-ISO8859-1 +luct10b.fnt:FONT -B&H-LucidaTypewriter-Bold-R-Normal-Sans-8-80-75-75-M-50-ISO8859-1 +luct11.fnt:FONT -B&H-LucidaTypewriter-Medium-R-Normal-Sans-10-100-75-75-M-60-ISO8859-1 +luct11b.fnt:FONT -B&H-LucidaTypewriter-Bold-R-Normal-Sans-10-100-75-75-M-60-ISO8859-1 +luct13.fnt:FONT -B&H-LucidaTypewriter-Medium-R-Normal-Sans-12-120-75-75-M-70-ISO8859-1 +luct13b.fnt:FONT -B&H-LucidaTypewriter-Bold-R-Normal-Sans-12-120-75-75-M-70-ISO8859-1 +luct15.fnt:FONT -B&H-LucidaTypewriter-Medium-R-Normal-Sans-14-140-75-75-M-90-ISO8859-1 +luct15b.fnt:FONT -B&H-LucidaTypewriter-Bold-R-Normal-Sans-14-140-75-75-M-90-ISO8859-1 +luct19.fnt:FONT -B&H-LucidaTypewriter-Medium-R-Normal-Sans-18-180-75-75-M-110-ISO8859-1 +luct19b.fnt:FONT -B&H-LucidaTypewriter-Bold-R-Normal-Sans-18-180-75-75-M-110-ISO8859-1 +luct27.fnt:FONT -B&H-LucidaTypewriter-Medium-R-Normal-Sans-24-240-75-75-M-140-ISO8859-1 +luct27b.fnt:FONT -B&H-LucidaTypewriter-Bold-R-Normal-Sans-24-240-75-75-M-140-ISO8859-1 +luct38.fnt:FONT -B&H-LucidaTypewriter-Medium-R-Normal-Sans-34-240-100-100-M-200-ISO8859-1 +luct38b.fnt:FONT -B&H-LucidaTypewriter-Bold-R-Normal-Sans-34-240-100-100-M-200-ISO8859-1 +ncen11.fnt:FONT -Adobe-New Century Schoolbook-Medium-R-Normal--8-80-75-75-P-50-ISO8859-1 +ncen11b.fnt:FONT -Adobe-New Century Schoolbook-Bold-R-Normal--8-80-75-75-P-56-ISO8859-1 +ncen11bi.fnt:FONT -Adobe-New Century Schoolbook-Bold-I-Normal--8-80-75-75-P-56-ISO8859-1 +ncen11i.fnt:FONT -Adobe-New Century Schoolbook-Medium-I-Normal--8-80-75-75-P-50-ISO8859-1 +ncen13.fnt:FONT -Adobe-New Century Schoolbook-Medium-R-Normal--10-100-75-75-P-60-ISO8859-1 +ncen13b.fnt:FONT -Adobe-New Century Schoolbook-Bold-R-Normal--10-100-75-75-P-66-ISO8859-1 +ncen13bi.fnt:FONT -Adobe-New Century Schoolbook-Bold-I-Normal--10-100-75-75-P-66-ISO8859-1 +ncen13i.fnt:FONT -Adobe-New Century Schoolbook-Medium-I-Normal--10-100-75-75-P-60-ISO8859-1 +ncen15.fnt:FONT -Adobe-New Century Schoolbook-Medium-R-Normal--12-120-75-75-P-70-ISO8859-1 +ncen15b.fnt:FONT -Adobe-New Century Schoolbook-Bold-R-Normal--12-120-75-75-P-77-ISO8859-1 +ncen15bi.fnt:FONT -Adobe-New Century Schoolbook-Bold-I-Normal--12-120-75-75-P-76-ISO8859-1 +ncen15i.fnt:FONT -Adobe-New Century Schoolbook-Medium-I-Normal--12-120-75-75-P-70-ISO8859-1 +ncen18.fnt:FONT -Adobe-New Century Schoolbook-Medium-R-Normal--14-140-75-75-P-82-ISO8859-1 +ncen18b.fnt:FONT -Adobe-New Century Schoolbook-Bold-R-Normal--14-140-75-75-P-87-ISO8859-1 +ncen18bi.fnt:FONT -Adobe-New Century Schoolbook-Bold-I-Normal--14-140-75-75-P-88-ISO8859-1 +ncen18i.fnt:FONT -Adobe-New Century Schoolbook-Medium-I-Normal--14-140-75-75-P-81-ISO8859-1 +ncen22.fnt:FONT -Adobe-New Century Schoolbook-Medium-R-Normal--18-180-75-75-P-103-ISO8859-1 +ncen22b.fnt:FONT -Adobe-New Century Schoolbook-Bold-R-Normal--18-180-75-75-P-113-ISO8859-1 +ncen22bi.fnt:FONT -Adobe-New Century Schoolbook-Bold-I-Normal--18-180-75-75-P-111-ISO8859-1 +ncen22i.fnt:FONT -Adobe-New Century Schoolbook-Medium-I-Normal--18-180-75-75-P-104-ISO8859-1 +ncen29.fnt:FONT -Adobe-New Century Schoolbook-Medium-R-Normal--24-240-75-75-P-137-ISO8859-1 +ncen29b.fnt:FONT -Adobe-New Century Schoolbook-Bold-R-Normal--24-240-75-75-P-149-ISO8859-1 +ncen29bi.fnt:FONT -Adobe-New Century Schoolbook-Bold-I-Normal--24-240-75-75-P-148-ISO8859-1 +ncen29i.fnt:FONT -Adobe-New Century Schoolbook-Medium-I-Normal--24-240-75-75-P-136-ISO8859-1 +ncen40.fnt:FONT -Adobe-New Century Schoolbook-Medium-R-Normal--34-240-100-100-P-181-ISO8859-1 +ncen40b.fnt:FONT -Adobe-New Century Schoolbook-Bold-R-Normal--34-240-100-100-P-193-ISO8859-1 +ncen40bi.fnt:FONT -Adobe-New Century Schoolbook-Bold-I-Normal--34-240-100-100-P-193-ISO8859-1 +ncen40i.fnt:FONT -Adobe-New Century Schoolbook-Medium-I-Normal--34-240-100-100-P-182-ISO8859-1 +symb11.fnt:FONT -Adobe-Symbol-Medium-R-Normal--8-80-75-75-P-51-ADOBE-FONTSPECIFIC +symb14.fnt:FONT -Adobe-Symbol-Medium-R-Normal--10-100-75-75-P-61-ADOBE-FONTSPECIFIC +symb16.fnt:FONT -Adobe-Symbol-Medium-R-Normal--12-120-75-75-P-74-ADOBE-FONTSPECIFIC +symb20.fnt:FONT -ADOBE-Symbol-Medium-R-Normal--14-140-75-75-P-85-ADOBE-FONTSPECIFIC +symb25.fnt:FONT -Adobe-Symbol-Medium-R-Normal--18-180-75-75-P-107-ADOBE-FONTSPECIFIC +symb32.fnt:FONT -Adobe-Symbol-Medium-R-Normal--24-240-75-75-P-142-ADOBE-FONTSPECIFIC +symb34.fnt:FONT -Adobe-Symbol-Medium-R-Normal--34-240-100-100-P-191-ADOBE-FONTSPECIFIC +tms11.fnt:FONT -Adobe-Times-Medium-R-Normal--8-80-75-75-P-44-ISO8859-1 +tms11b.fnt:FONT -Adobe-Times-Bold-R-Normal--8-80-75-75-P-47-ISO8859-1 +tms11bi.fnt:FONT -Adobe-Times-Bold-I-Normal--8-80-75-75-P-47-ISO8859-1 +tms11i.fnt:FONT -Adobe-Times-Medium-I-Normal--8-80-75-75-P-42-ISO8859-1 +tms13.fnt:FONT -Adobe-Times-Medium-R-Normal--10-100-75-75-P-54-ISO8859-1 +tms13b.fnt:FONT -Adobe-Times-Bold-R-Normal--10-100-75-75-P-57-ISO8859-1 +tms13bi.fnt:FONT -Adobe-Times-Bold-I-Normal--10-100-75-75-P-57-ISO8859-1 +tms13i.fnt:FONT -Adobe-Times-Medium-I-Normal--10-100-75-75-P-52-ISO8859-1 +tms15.fnt:FONT -Adobe-Times-Medium-R-Normal--12-120-75-75-P-64-ISO8859-1 +tms15b.fnt:FONT -Adobe-Times-Bold-R-Normal--12-120-75-75-P-67-ISO8859-1 +tms15bi.fnt:FONT -Adobe-Times-Bold-I-Normal--12-120-75-75-P-68-ISO8859-1 +tms15i.fnt:FONT -Adobe-Times-Medium-I-Normal--12-120-75-75-P-63-ISO8859-1 +tms18.fnt:FONT -Adobe-Times-Medium-R-Normal--14-140-75-75-P-74-ISO8859-1 +tms18b.fnt:FONT -Adobe-Times-Bold-R-Normal--14-140-75-75-P-77-ISO8859-1 +tms18bi.fnt:FONT -Adobe-Times-Bold-I-Normal--14-140-75-75-P-77-ISO8859-1 +tms18i.fnt:FONT -Adobe-Times-Medium-I-Normal--14-140-75-75-P-73-ISO8859-1 +tms22.fnt:FONT -Adobe-Times-Medium-R-Normal--18-180-75-75-P-94-ISO8859-1 +tms22b.fnt:FONT -Adobe-Times-Bold-R-Normal--18-180-75-75-P-99-ISO8859-1 +tms22bi.fnt:FONT -Adobe-Times-Bold-I-Normal--18-180-75-75-P-98-ISO8859-1 +tms22i.fnt:FONT -Adobe-Times-Medium-I-Normal--18-180-75-75-P-94-ISO8859-1 +tms29.fnt:FONT -Adobe-Times-Medium-R-Normal--24-240-75-75-P-124-ISO8859-1 +tms29b.fnt:FONT -Adobe-Times-Bold-R-Normal--24-240-75-75-P-132-ISO8859-1 +tms29bi.fnt:FONT -Adobe-Times-Bold-I-Normal--24-240-75-75-P-128-ISO8859-1 +tms29i.fnt:FONT -Adobe-Times-Medium-I-Normal--24-240-75-75-P-125-ISO8859-1 +tms38.fnt:FONT -Adobe-Times-Medium-R-Normal--34-240-100-100-P-170-ISO8859-1 +tms38b.fnt:FONT -Adobe-Times-Bold-R-Normal--34-240-100-100-P-177-ISO8859-1 +tms38bi.fnt:FONT -Adobe-Times-Bold-I-Normal--34-240-100-100-P-170-ISO8859-1 +tms38i.fnt:FONT -Adobe-Times-Medium-I-Normal--34-240-100-100-P-168-ISO8859-1 +xm12x24.fnt:FONT -Sony-Fixed-Medium-R-Normal--24-170-100-100-C-120-ISO8859-1 +xm4x6.fnt:FONT -Schumacher-Clean-Medium-R-Normal--6-60-75-75-C-40-ISO8859-1 +xm5x10.fnt:FONT -Schumacher-Clean-Medium-R-Normal--10-100-75-75-C-50-ISO8859-1 +xm5x6.fnt:FONT -Schumacher-Clean-Medium-R-Normal--6-60-75-75-C-50-ISO8859-1 +xm5x8.fnt:FONT -Schumacher-Clean-Medium-R-Normal--8-80-75-75-C-50-ISO8859-1 +xm6x10.fnt:FONT -Schumacher-Clean-Medium-R-Normal--10-100-75-75-C-60-ISO8859-1 +xm6x10b.fnt:FONT -Schumacher-Clean-Bold-R-Normal--10-100-75-75-C-60-ISO8859-1 +xm6x12.fnt:FONT -Schumacher-Clean-Medium-R-Normal--12-120-75-75-C-60-ISO8859-1 +xm6x12b.fnt:FONT -Schumacher-Clean-Bold-R-Normal--12-120-75-75-C-60-ISO8859-1 +xm6x12i.fnt:FONT -Schumacher-Clean-Medium-I-Normal--12-120-75-75-C-60-ISO8859-1 +xm6x13.fnt:FONT -Schumacher-Clean-Medium-R-Normal--13-130-75-75-C-60-ISO8859-1 +xm6x13b.fnt:FONT -Misc-Fixed-Bold-R-SemiCondensed--13-120-75-75-C-60-ISO8859-1 +xm6x6.fnt:FONT -Schumacher-Clean-Medium-R-Normal--6-60-75-75-C-60-ISO8859-1 +xm6x8.fnt:FONT -Schumacher-Clean-Medium-R-Normal--8-80-75-75-C-60-ISO8859-1 +xm6x9.fnt:FONT -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO8859-1 +xm7x10.fnt:FONT -Schumacher-Clean-Medium-R-Normal--10-100-75-75-C-70-ISO8859-1 +xm7x12.fnt:FONT -Schumacher-Clean-Medium-R-Normal--12-120-75-75-C-70-ISO8859-1 +xm7x13.fnt:FONT -Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1 +xm7x13b.fnt:FONT -Misc-Fixed-Bold-R-Normal--13-120-75-75-C-70-ISO8859-1 +xm7x14.fnt:FONT -Schumacher-Clean-Medium-R-Normal--14-140-75-75-C-70-ISO8859-1 +xm7x8.fnt:FONT -Schumacher-Clean-Medium-R-Normal--8-80-75-75-C-70-ISO8859-1 +xm8x10.fnt:FONT -Schumacher-Clean-Medium-R-Normal--10-100-75-75-C-80-ISO8859-1 +xm8x10b.fnt:FONT -Schumacher-Clean-Bold-R-Normal--10-100-75-75-C-80-ISO8859-1 +xm8x12.fnt:FONT -Schumacher-Clean-Medium-R-Normal--12-120-75-75-C-80-ISO8859-1 +xm8x12b.fnt:FONT -Schumacher-Clean-Bold-R-Normal--12-120-75-75-C-80-ISO8859-1 +xm8x13.fnt:FONT -Schumacher-Clean-Medium-R-Normal--13-130-75-75-C-80-ISO8859-1 +xm8x13b.fnt:FONT -Schumacher-Clean-Bold-R-Normal--13-130-75-75-C-80-ISO8859-1 +xm8x14.fnt:FONT -Schumacher-Clean-Medium-R-Normal--14-140-75-75-C-80-ISO8859-1 +xm8x14b.fnt:FONT -Schumacher-Clean-Bold-R-Normal--14-140-75-75-C-80-ISO8859-1 +xm8x15.fnt:FONT -DEC-Terminal-Medium-R-Normal--14-140-75-75-C-80-ISO8859-1 +xm8x15b.fnt:FONT -DEC-Terminal-Bold-R-Normal--14-140-75-75-C-80-ISO8859-1 +xm8x16.fnt:FONT -Schumacher-Clean-Medium-R-Normal--16-160-75-75-C-80-ISO8859-1 +xm8x16b.fnt:FONT -Schumacher-Clean-Bold-R-Normal--16-160-75-75-C-80-ISO8859-1 +xm8x8.fnt:FONT -Schumacher-Clean-Medium-R-Normal--8-80-75-75-C-80-ISO8859-1 +xm8x8b.fnt:FONT -Schumacher-Clean-Bold-R-Normal--8-80-75-75-C-80-ISO8859-1 +xm8x8i.fnt:FONT -Schumacher-Clean-Medium-I-Normal--8-80-75-75-C-80-ISO8859-1 +xm9x15.fnt:FONT -Schumacher-Clean-Medium-R-Normal--15-150-75-75-C-90-ISO8859-1 +xm9x15b.fnt:FONT -Schumacher-Clean-Bold-R-Normal--15-150-75-75-C-90-ISO8859-1 diff --git a/thirdparty/grx249/fonts/xm10x17.fnt b/thirdparty/grx249/fonts/xm10x17.fnt new file mode 100644 index 0000000..6bd8191 --- /dev/null +++ b/thirdparty/grx249/fonts/xm10x17.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65e2d0548c30130d69c2417dcf6aa7dcbcc3b8a2bc4a9eb2db9aa4801dcf0073 +size 3286 diff --git a/thirdparty/grx249/fonts/xm10x17b.fnt b/thirdparty/grx249/fonts/xm10x17b.fnt new file mode 100644 index 0000000..0481dfa --- /dev/null +++ b/thirdparty/grx249/fonts/xm10x17b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff50ff810c6d514fcf0e8ecf2faf19df2ca03c415092faef043ecaa32e7a01b5 +size 3286 diff --git a/thirdparty/grx249/fonts/xm10x20.fnt b/thirdparty/grx249/fonts/xm10x20.fnt new file mode 100644 index 0000000..599b6b5 --- /dev/null +++ b/thirdparty/grx249/fonts/xm10x20.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b355a3bdcc4ee18e5cb656ed9b874c8fa760d0140d0e568bf5d0b16771a1e49 +size 3856 diff --git a/thirdparty/grx249/fonts/xm10x20b.fnt b/thirdparty/grx249/fonts/xm10x20b.fnt new file mode 100644 index 0000000..ccf590c --- /dev/null +++ b/thirdparty/grx249/fonts/xm10x20b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8485af0673bcf250b8ed212767b9786a0f1bede9b4aa180bd5f7c9d141ab1278 +size 3856 diff --git a/thirdparty/grx249/fonts/xm11x19b.fnt b/thirdparty/grx249/fonts/xm11x19b.fnt new file mode 100644 index 0000000..a187917 --- /dev/null +++ b/thirdparty/grx249/fonts/xm11x19b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:99e29285ca6d3b261960a73ddfe4da7d4027b0462e7cd2348c5191fdaced98e7 +size 3666 diff --git a/thirdparty/grx249/fonts/xm12x15.fnt b/thirdparty/grx249/fonts/xm12x15.fnt new file mode 100644 index 0000000..204c72b --- /dev/null +++ b/thirdparty/grx249/fonts/xm12x15.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d1ddd4c13828f864f955ec0e6c23bfd105fb98f29a52aaf836b39c77611fe81c +size 2906 diff --git a/thirdparty/grx249/fonts/xm12x20.fnt b/thirdparty/grx249/fonts/xm12x20.fnt new file mode 100644 index 0000000..7a6856f --- /dev/null +++ b/thirdparty/grx249/fonts/xm12x20.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:436e503d0c1e2d00da25c5f6994f79e1f10518e90c2044b23eb1f34bdb7c4ddd +size 3856 diff --git a/thirdparty/grx249/fonts/xm12x20b.fnt b/thirdparty/grx249/fonts/xm12x20b.fnt new file mode 100644 index 0000000..3103a90 --- /dev/null +++ b/thirdparty/grx249/fonts/xm12x20b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20432c7ca70d74dd05f56429704ee8c8c8cdb60e392e2be4e1910c8f826c5953 +size 3856 diff --git a/thirdparty/grx249/fonts/xm12x23.fnt b/thirdparty/grx249/fonts/xm12x23.fnt new file mode 100644 index 0000000..89ac49b --- /dev/null +++ b/thirdparty/grx249/fonts/xm12x23.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:40cbca5e4a4476b0f252e3f6b089b1317108c57583027a6fd755d0dd00b465fe +size 4426 diff --git a/thirdparty/grx249/fonts/xm12x24.fnt b/thirdparty/grx249/fonts/xm12x24.fnt new file mode 100644 index 0000000..2bc8450 --- /dev/null +++ b/thirdparty/grx249/fonts/xm12x24.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:843b6f88605bb026b78fb459690f0847a54dc15798a2a496614ea29568d87684 +size 5817 diff --git a/thirdparty/grx249/fonts/xm14x26.fnt b/thirdparty/grx249/fonts/xm14x26.fnt new file mode 100644 index 0000000..9c59729 --- /dev/null +++ b/thirdparty/grx249/fonts/xm14x26.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:607c1b41f099f56cadf94d10139c25e6e1d2cd961e0ece7b40c0ec456c0ee787 +size 4996 diff --git a/thirdparty/grx249/fonts/xm16x25.fnt b/thirdparty/grx249/fonts/xm16x25.fnt new file mode 100644 index 0000000..c82db64 --- /dev/null +++ b/thirdparty/grx249/fonts/xm16x25.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4fdfc8e22609ffd6e268f30c3752e8f0d2e4365454546366ce2d32870ad2759 +size 4806 diff --git a/thirdparty/grx249/fonts/xm16x25b.fnt b/thirdparty/grx249/fonts/xm16x25b.fnt new file mode 100644 index 0000000..e31e7cf --- /dev/null +++ b/thirdparty/grx249/fonts/xm16x25b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58da135da4b49d9e7c07e250b1ce64438ac8ad7f14af12b58bdf117f166888ed +size 4806 diff --git a/thirdparty/grx249/fonts/xm16x25i.fnt b/thirdparty/grx249/fonts/xm16x25i.fnt new file mode 100644 index 0000000..7e693ca --- /dev/null +++ b/thirdparty/grx249/fonts/xm16x25i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a66a321e9f678876a017f01ff18f4db38cda38d7a5140a7737f1ee6b1912222c +size 4806 diff --git a/thirdparty/grx249/fonts/xm4x5.fnt b/thirdparty/grx249/fonts/xm4x5.fnt new file mode 100644 index 0000000..01573e4 --- /dev/null +++ b/thirdparty/grx249/fonts/xm4x5.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bcf962df7331ecc5c134ebae8f00076c460370d0ff9e38e9a26e8148603641ec +size 531 diff --git a/thirdparty/grx249/fonts/xm4x6.fnt b/thirdparty/grx249/fonts/xm4x6.fnt new file mode 100644 index 0000000..5022733 --- /dev/null +++ b/thirdparty/grx249/fonts/xm4x6.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79a7e0aa307bd2763f6cef15fc96ca69d6101e72a94faaf1e3f1aa82b324ab4b +size 1489 diff --git a/thirdparty/grx249/fonts/xm5x10.fnt b/thirdparty/grx249/fonts/xm5x10.fnt new file mode 100644 index 0000000..881f9f8 --- /dev/null +++ b/thirdparty/grx249/fonts/xm5x10.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bcc784334211ee3936164fb589ce29039c8ce84aeb4e317b3a0f83aef9d16884 +size 1871 diff --git a/thirdparty/grx249/fonts/xm5x6.fnt b/thirdparty/grx249/fonts/xm5x6.fnt new file mode 100644 index 0000000..f3ec6e1 --- /dev/null +++ b/thirdparty/grx249/fonts/xm5x6.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:509f5c3f9445cb5bfb8b7741b111bcc2a75e80362f3bfc776f414be584177bc0 +size 1489 diff --git a/thirdparty/grx249/fonts/xm5x8.fnt b/thirdparty/grx249/fonts/xm5x8.fnt new file mode 100644 index 0000000..a9c2298 --- /dev/null +++ b/thirdparty/grx249/fonts/xm5x8.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:531b4063713af81aeb00e1db8db76d0e1266afb3517a7a63d071ce411bffd507 +size 1679 diff --git a/thirdparty/grx249/fonts/xm6x10.fnt b/thirdparty/grx249/fonts/xm6x10.fnt new file mode 100644 index 0000000..2591fb7 --- /dev/null +++ b/thirdparty/grx249/fonts/xm6x10.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b9baf2ca8ad91b19e8a9e2caa8cb6bc29ad9c344ba1e6cce662f24c709d795e +size 1871 diff --git a/thirdparty/grx249/fonts/xm6x10b.fnt b/thirdparty/grx249/fonts/xm6x10b.fnt new file mode 100644 index 0000000..4554aa2 --- /dev/null +++ b/thirdparty/grx249/fonts/xm6x10b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a336f6fa24549068d50f56ff16d80e8d3212294124b455b769313bbca74cb995 +size 1869 diff --git a/thirdparty/grx249/fonts/xm6x12.fnt b/thirdparty/grx249/fonts/xm6x12.fnt new file mode 100644 index 0000000..ec24b1d --- /dev/null +++ b/thirdparty/grx249/fonts/xm6x12.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da74a053566ca3d7df610436dc60ac7b5eaff2fdaa06e3128dd3a5f4b023395d +size 2061 diff --git a/thirdparty/grx249/fonts/xm6x12b.fnt b/thirdparty/grx249/fonts/xm6x12b.fnt new file mode 100644 index 0000000..0394bb2 --- /dev/null +++ b/thirdparty/grx249/fonts/xm6x12b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3dada7eeafafa43abf3f5d51627b6f00dc02a81c7b1c7eaa1283de864f7d9151 +size 2059 diff --git a/thirdparty/grx249/fonts/xm6x12i.fnt b/thirdparty/grx249/fonts/xm6x12i.fnt new file mode 100644 index 0000000..556ece9 --- /dev/null +++ b/thirdparty/grx249/fonts/xm6x12i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d31603cde6eb573bb4bdda2c07c174f935824e27f8d76111ba038fc565f62df0 +size 2061 diff --git a/thirdparty/grx249/fonts/xm6x13.fnt b/thirdparty/grx249/fonts/xm6x13.fnt new file mode 100644 index 0000000..0db3584 --- /dev/null +++ b/thirdparty/grx249/fonts/xm6x13.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f40223a6ef30d7988106f5e19b570b98bfc38ba740ed40a4262ad954044ef642 +size 2156 diff --git a/thirdparty/grx249/fonts/xm6x13b.fnt b/thirdparty/grx249/fonts/xm6x13b.fnt new file mode 100644 index 0000000..0334770 --- /dev/null +++ b/thirdparty/grx249/fonts/xm6x13b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43859ca7ebd77ae444624ed273460039a723a89c6338e9b096b10589754d8f41 +size 1464 diff --git a/thirdparty/grx249/fonts/xm6x16.fnt b/thirdparty/grx249/fonts/xm6x16.fnt new file mode 100644 index 0000000..2c6ed90 --- /dev/null +++ b/thirdparty/grx249/fonts/xm6x16.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:16827097f39badc194692e3a16616d4da82813ef20269c93e4b6dfe09624d242 +size 1576 diff --git a/thirdparty/grx249/fonts/xm6x6.fnt b/thirdparty/grx249/fonts/xm6x6.fnt new file mode 100644 index 0000000..60b6921 --- /dev/null +++ b/thirdparty/grx249/fonts/xm6x6.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e343b556ef8ca915cacaf96c2776b9f1ec4c321a25992796cff19c48fd76ba3 +size 1489 diff --git a/thirdparty/grx249/fonts/xm6x8.fnt b/thirdparty/grx249/fonts/xm6x8.fnt new file mode 100644 index 0000000..1b5a15e --- /dev/null +++ b/thirdparty/grx249/fonts/xm6x8.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:30b2e3a5fef0211df800ff106e2ed91b2d7b9038ee62e9d66155c1a3ecb940b0 +size 1679 diff --git a/thirdparty/grx249/fonts/xm6x9.fnt b/thirdparty/grx249/fonts/xm6x9.fnt new file mode 100644 index 0000000..1214fab --- /dev/null +++ b/thirdparty/grx249/fonts/xm6x9.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d01fd5e1e0a1db54e5752d4590d239159bd454b98c2c621731f41bfcf2a7ab2e +size 2183 diff --git a/thirdparty/grx249/fonts/xm7x10.fnt b/thirdparty/grx249/fonts/xm7x10.fnt new file mode 100644 index 0000000..d94e963 --- /dev/null +++ b/thirdparty/grx249/fonts/xm7x10.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f258c8c94dab2de177d779fc942a9774d79b2a9f9a213a43abace5305f9fde10 +size 1871 diff --git a/thirdparty/grx249/fonts/xm7x12.fnt b/thirdparty/grx249/fonts/xm7x12.fnt new file mode 100644 index 0000000..f816fe4 --- /dev/null +++ b/thirdparty/grx249/fonts/xm7x12.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06eb5ca88b2c351a1b5d7eb8f5e3e81b02e39669159058fd9d484c1800da8301 +size 2061 diff --git a/thirdparty/grx249/fonts/xm7x13.fnt b/thirdparty/grx249/fonts/xm7x13.fnt new file mode 100644 index 0000000..8b82eca --- /dev/null +++ b/thirdparty/grx249/fonts/xm7x13.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ef1b81d70882c4f8945d59417a6ab33cd0d5295a60f191d1ea841446cdef723 +size 1591 diff --git a/thirdparty/grx249/fonts/xm7x13b.fnt b/thirdparty/grx249/fonts/xm7x13b.fnt new file mode 100644 index 0000000..752736c --- /dev/null +++ b/thirdparty/grx249/fonts/xm7x13b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88d7ecd034d468dbfc35cbce121cf9702ac400ded3bc2311a6bb7d0e52a4efb0 +size 1589 diff --git a/thirdparty/grx249/fonts/xm7x14.fnt b/thirdparty/grx249/fonts/xm7x14.fnt new file mode 100644 index 0000000..a3df7b3 --- /dev/null +++ b/thirdparty/grx249/fonts/xm7x14.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1a1b6f73dae5d6822c26deacecae72ee4bda566ad3d2095ff1822d430b69456d +size 2251 diff --git a/thirdparty/grx249/fonts/xm7x17.fnt b/thirdparty/grx249/fonts/xm7x17.fnt new file mode 100644 index 0000000..545353f --- /dev/null +++ b/thirdparty/grx249/fonts/xm7x17.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a044fc243b4155aa53fbf2d50364a8a130ea0c469f38b875790bffb40c166649 +size 1671 diff --git a/thirdparty/grx249/fonts/xm7x8.fnt b/thirdparty/grx249/fonts/xm7x8.fnt new file mode 100644 index 0000000..447fb03 --- /dev/null +++ b/thirdparty/grx249/fonts/xm7x8.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:437e34d5f5751de4d4698e50038e15a5c093629fe0e3440e8215f034c045c0e1 +size 1679 diff --git a/thirdparty/grx249/fonts/xm8x10.fnt b/thirdparty/grx249/fonts/xm8x10.fnt new file mode 100644 index 0000000..7408371 --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x10.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3c21907f4559d96592446ef9b24b16d1936dd7a749058e8ff6bb7bf3b6a52e08 +size 1871 diff --git a/thirdparty/grx249/fonts/xm8x10b.fnt b/thirdparty/grx249/fonts/xm8x10b.fnt new file mode 100644 index 0000000..0729b4e --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x10b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d779e897e9bc29726fd66bbcea0d81d7efa02313601a9f96c3e3f681a82d9913 +size 1869 diff --git a/thirdparty/grx249/fonts/xm8x12.fnt b/thirdparty/grx249/fonts/xm8x12.fnt new file mode 100644 index 0000000..c78a1ce --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x12.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a299d688f37cd2cde67b4d5a1a3d8311feb1d38e1c2372d984f06e28989a1db3 +size 2061 diff --git a/thirdparty/grx249/fonts/xm8x12b.fnt b/thirdparty/grx249/fonts/xm8x12b.fnt new file mode 100644 index 0000000..045b6f4 --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x12b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b086adb3e0fa2ec6973417f749ed36445dd3a79f5356774e76508330bcb26a0 +size 2059 diff --git a/thirdparty/grx249/fonts/xm8x13.fnt b/thirdparty/grx249/fonts/xm8x13.fnt new file mode 100644 index 0000000..8911dcd --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x13.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f1fef12ca7bd0676ad89b731b992c71f585ee07184be62dd89477df9c2f776b +size 2156 diff --git a/thirdparty/grx249/fonts/xm8x13b.fnt b/thirdparty/grx249/fonts/xm8x13b.fnt new file mode 100644 index 0000000..695ee78 --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x13b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f6bd4022aedbe5da252e510c9117615f7e53b48affd0e8bc2577f7396bd08aa +size 2154 diff --git a/thirdparty/grx249/fonts/xm8x14.fnt b/thirdparty/grx249/fonts/xm8x14.fnt new file mode 100644 index 0000000..5b91928 --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x14.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:548d795c4fc906a7c11189e7d87b0cf890b26c6540ba6d8a6983c8efefd8ac4b +size 2251 diff --git a/thirdparty/grx249/fonts/xm8x14b.fnt b/thirdparty/grx249/fonts/xm8x14b.fnt new file mode 100644 index 0000000..97d3417 --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x14b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c7966eee8882d536fc5eb3013b5c6362780d34f5e85046ee9df54529e3fe6d4 +size 2249 diff --git a/thirdparty/grx249/fonts/xm8x15.fnt b/thirdparty/grx249/fonts/xm8x15.fnt new file mode 100644 index 0000000..59d62b2 --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x15.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e4262c17f92ec4f7d7fe97de3567de700a4c66d4576fefbec3bcbc0ca56ad369 +size 5011 diff --git a/thirdparty/grx249/fonts/xm8x15b.fnt b/thirdparty/grx249/fonts/xm8x15b.fnt new file mode 100644 index 0000000..3c9d946 --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x15b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e06ce56b4cfb3149dfb1af1c1c6a72ee36a4528c44c8d54f479a7b3f13682858 +size 5009 diff --git a/thirdparty/grx249/fonts/xm8x16.fnt b/thirdparty/grx249/fonts/xm8x16.fnt new file mode 100644 index 0000000..3602f76 --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x16.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ffe335644bd16cea8580a6c406a68bdf64c59c75be99351a421949dd66d17246 +size 2441 diff --git a/thirdparty/grx249/fonts/xm8x16b.fnt b/thirdparty/grx249/fonts/xm8x16b.fnt new file mode 100644 index 0000000..7f23bad --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x16b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed143ee0dbbc209075a1de72e36c1aef78d3413b213ab17e2825893101a92e63 +size 2439 diff --git a/thirdparty/grx249/fonts/xm8x16i.fnt b/thirdparty/grx249/fonts/xm8x16i.fnt new file mode 100644 index 0000000..294b71f --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x16i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe19a2baf547e4a5917538a55444372c5f5751e148508e83bb4f72b64a3ca096 +size 1576 diff --git a/thirdparty/grx249/fonts/xm8x19.fnt b/thirdparty/grx249/fonts/xm8x19.fnt new file mode 100644 index 0000000..13df461 --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x19.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff10e076321f4e18ff2c1a5e50a26fc5e802e4089f1e1b1864f34d446de34f3e +size 1861 diff --git a/thirdparty/grx249/fonts/xm8x8.fnt b/thirdparty/grx249/fonts/xm8x8.fnt new file mode 100644 index 0000000..6901f4f --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x8.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:795c0c7728ac4cf7673852129e705e8720fe49c82c9c4157b6c62ef6e605cebf +size 1679 diff --git a/thirdparty/grx249/fonts/xm8x8b.fnt b/thirdparty/grx249/fonts/xm8x8b.fnt new file mode 100644 index 0000000..d36eba9 --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x8b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2bdaf0051d2401b5441eb6ad44f45a3b1931276e3a4e3a4dfdb4daf69a64df74 +size 1677 diff --git a/thirdparty/grx249/fonts/xm8x8i.fnt b/thirdparty/grx249/fonts/xm8x8i.fnt new file mode 100644 index 0000000..6ddee6c --- /dev/null +++ b/thirdparty/grx249/fonts/xm8x8i.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ebc503bdc5def5d7aa058d4484ff1daeec11c65e455ea2d19c9a79f36acbbfa +size 1679 diff --git a/thirdparty/grx249/fonts/xm9x15.fnt b/thirdparty/grx249/fonts/xm9x15.fnt new file mode 100644 index 0000000..64d90d6 --- /dev/null +++ b/thirdparty/grx249/fonts/xm9x15.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b06bdd63427d3394c9eb24ee69f10d21a13a08ae6afd811449f9c74fded0c4a +size 3771 diff --git a/thirdparty/grx249/fonts/xm9x15b.fnt b/thirdparty/grx249/fonts/xm9x15b.fnt new file mode 100644 index 0000000..b220f4e --- /dev/null +++ b/thirdparty/grx249/fonts/xm9x15b.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f55d693af281aa09e03bbd6cd4412e82ff775d88980948b2dccf910703c7f29 +size 3769 diff --git a/thirdparty/grx249/fonts/xm9x17.fnt b/thirdparty/grx249/fonts/xm9x17.fnt new file mode 100644 index 0000000..c8cf2f3 --- /dev/null +++ b/thirdparty/grx249/fonts/xm9x17.fnt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17f3ac4538a656423c119bb52bf4d7afc4cb84bf7105787d12d6aaf4f43623f1 +size 3286 diff --git a/thirdparty/grx249/include/bgiext.h b/thirdparty/grx249/include/bgiext.h new file mode 100644 index 0000000..383a2dd --- /dev/null +++ b/thirdparty/grx249/include/bgiext.h @@ -0,0 +1,43 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __BGIEXT_H +#define __BGIEXT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern unsigned char _dac_g256[][3]; /* 256 shading dac values */ +extern unsigned char _dac_normal[][3]; /* 256 standard colors */ + +extern void setrgbdefaults(void); +extern void setrgbgray256(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/grx249/include/grdriver.h b/thirdparty/grx249/include/grdriver.h new file mode 100644 index 0000000..b7fb885 --- /dev/null +++ b/thirdparty/grx249/include/grdriver.h @@ -0,0 +1,202 @@ +/** + ** grdriver.h ---- utilities for frame buffer and video card drivers + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __GRDRIVER_H_INCLUDED__ +#define __GRDRIVER_H_INCLUDED__ + +#ifndef __GRX20_H_INCLUDED__ +#include "grx20.h" +#endif + +/* +** The following definitions shouldn't be used in portable +** or binary distributed programs for compatibility with +** future versions of GRX +*/ +#ifdef USE_GRX_INTERNAL_DEFINITIONS + +/* + * Video mode flag bits (in the 'GrVideoModeExt' structure) + */ +#define GR_VMODEF_LINEAR 1 /* uses linear memory mapping */ +#define GR_VMODEF_ACCEL 2 /* it is an accelerated mode */ +#define GR_VMODEF_FAST_SVGA8 4 /* use faster mixed linear-planar access */ +#define GR_VMODEF_MEMORY 8 /* virtual screen, memory only mode */ + +extern GrFrameDriver +/* + * Standard frame drivers in GRX + */ +_GrFrameDriverHERC1, /* Hercules mono */ +_GrFrameDriverEGAVGA1, /* EGA VGA mono */ +_GrFrameDriverEGA4, /* EGA 16 color */ +_GrFrameDriverSVGA4, /* (Super) VGA 16 color */ +_GrFrameDriverSVGA8, /* (Super) VGA 256 color */ +_GrFrameDriverVGA8X, /* VGA 256 color mode X */ +_GrFrameDriverSVGA16, /* Super VGA 32768/65536 color */ +_GrFrameDriverSVGA24, /* Super VGA 16M color */ +_GrFrameDriverSVGA32L, /* Super VGA 16M color padded #1 */ +_GrFrameDriverSVGA32H, /* Super VGA 16M color padded #2 */ + /* Linear Framebuffer Modes : */ +_GrFrameDriverSVGA8_LFB, /* (Super) VGA 256 color */ +_GrFrameDriverSVGA16_LFB, /* Super VGA 32768/65536 color */ +_GrFrameDriverSVGA24_LFB, /* Super VGA 16M color */ +_GrFrameDriverSVGA32L_LFB, /* Super VGA 16M color padded #1 */ +_GrFrameDriverSVGA32H_LFB, /* Super VGA 16M color padded #2 */ + +_GrFrameDriverXWIN8, /* X 8 bpp */ +_GrFrameDriverXWIN16, /* X 16 bpp */ +_GrFrameDriverXWIN24, /* X 24 bpp */ +_GrFrameDriverXWIN32L, /* X 32 bpp padded #1 */ +_GrFrameDriverXWIN32H, /* X 32 bpp padded #2 */ + +_GrFrameDriverWIN32_4, /* WIN32 4 bpp */ +_GrFrameDriverWIN32_8, /* WIN32 8 bpp */ +_GrFrameDriverWIN32_24, /* WIN32 24 bpp */ + +_GrFrameDriverSDL8, /* SDL 8 bpp */ +_GrFrameDriverSDL16, /* SDL 16 bpp */ +_GrFrameDriverSDL24, /* SDL 24 bpp */ +_GrFrameDriverSDL32L, /* SDL 32 bpp padded #2 */ +_GrFrameDriverSDL32H, /* SDL 32 bpp padded #2 */ + +_GrFrameDriverRAM1, /* mono */ +_GrFrameDriverRAM4, /* 16 color planar */ +_GrFrameDriverRAM8, /* 256 color */ +_GrFrameDriverRAM16, /* 32768/65536 color */ +_GrFrameDriverRAM24, /* 16M color */ +_GrFrameDriverRAM32L, /* 16M color padded #1 */ +_GrFrameDriverRAM32H, /* 16M color padded #2 */ +_GrFrameDriverRAM3x8, /* 16M color planar (image mode) */ +/* + * This is a NULL-terminated table of frame driver descriptor pointers. Users + * can provide their own table with only the desired (or additional) drivers. + * Otherwise the table from the GRX library is linked, which includes ALL + * currently available drivers (i.e. the ones above). + */ +*_GrFrameDriverTable[]; + + +extern GrVideoDriver +/* + * Standard video drivers in GRX + */ +_GrVideoDriverHERC, /* Hercules driver */ +_GrVideoDriverSTDEGA, /* standard EGA driver */ +_GrVideoDriverSTDVGA, /* standard VGA driver */ +_GrVideoDriverVESA, /* generic VESA Super VGA driver */ +_GrVideoDriverATI28800, /* ATI 28800 chipset driver */ +_GrVideoDriverET4000, /* Tseng ET4000 driver */ +_GrVideoDriverCL5426, /* Cirrus 5426 driver */ +_GrVideoDriverMACH64, /* ATI MACH64 driver */ +_GrVideoDriverS3, /* S3 driver */ + +_GrVideoDriverXWIN, /* X11 interface */ +_GrVideoDriverXF86DGA, /* XFree86 DGA interface */ + +_GrVideoDriverSVGALIB, /* Linux SVGALIB interface */ +_GrVideoDriverLINUXFB, /* Linux framebuffer */ + +_GrVideoDriverWIN32, /* WIN32 interface */ + +_GrVideoDriverSDL, /* SDL intrercace */ + +_GrDriverMEM, /* memory screen driver */ + +/* + * This is a NULL-terminated table of video driver descriptor pointers. Users + * can provide their own table with only the desired (or additional) drivers. + * Otherwise the table from the GRX library is linked, which includes ALL + * currently available drivers (i.e. the ones above). + */ +*_GrVideoDriverTable[]; + +/* + * frame driver function types used inside GRX + */ +typedef GrColor (*_GR_readPix)(GrFrame *,int,int); +typedef void (*_GR_drawPix)(int,int,GrColor); +typedef void (*_GR_blitFunc)(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y, + int w,int h,GrColor op); +typedef GrColor far *(*_GR_getIndexedScanline)(GrFrame *c,int x,int y, + int w, int *indx); +typedef void (*_GR_putScanline)(int x,int y,int w, + const GrColor far *scl,GrColor op); + +/* + * Frame driver utility functions + */ +void _GrFrDrvGenericBitBlt(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op); +void _GrFrDrvPackedBitBltR2R(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op); +void _GrFrDrvPackedBitBltR2V(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op); +void _GrFrDrvPackedBitBltV2R(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op); +void _GrFrDrvPackedBitBltV2V(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op); +void _GrFrDrvPackedBitBltR2V_LFB(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op); +void _GrFrDrvPackedBitBltV2R_LFB(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op); +void _GrFrDrvPackedBitBltV2V_LFB(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op); + +void _GrFrDrvGenericPutScanline(int x,int y,int w,const GrColor far *scl, GrColor op ); +GrColor *_GrFrDrvGenericGetIndexedScanline(GrFrame *c, + int x,int y,int w, + int *indx ); + +void _GrFrDrvGenericStretchBlt(GrFrame *dst,int dx,int dy,int dw,int dh, + GrFrame *src,int sx,int sy,int sw,int sh, + GrColor op); + +/* + * Video driver utility functions + */ +int _GrViDrvDetectEGAVGA(void); +int _GrViDrvDetectVGA(void); +int _GrViDrvDetectEGA(void); +int _GrViDrvInitEGAVGA(char *options); +void _GrViDrvResetEGAVGA(void); +int _GrViDrvGetCurrentEGAVGAmode(void); +int _GrViDrvSetEGAVGAmode(GrVideoMode *mp,int noclear); +int _GrViDrvSetEGAVGAcustomTextMode(GrVideoMode *mp,int noclear); +void _GrViDrvLoadColorEGA4(int c,int r,int g,int b); +void _GrViDrvLoadColorVGA4(int c,int r,int g,int b); +void _GrViDrvLoadColorVGA8(int c,int r,int g,int b); +int _GrViDrvVESAsetVirtualSize(GrVideoMode *md,int w,int h,GrVideoMode *result); +int _GrViDrvVESAvirtualScroll(GrVideoMode *md,int x,int y,int result[2]); + +/* for 8 bit color modes: +** normal DAC has 6bit for each rgb color component, VESA 2.0 allows +** 6bit or 8bit DAC color values. +** _GrViDrvLoadColorVGA8() requires 8bit values that will be shifted right: +** +** DAC width 6bit 8bit +** shift 2 0 +*/ +void _GrViDrvSetDACshift(int shift); + +/* + * Commonly used video driver data structures + */ +extern GrVideoModeExt _GrViDrvEGAVGAtextModeExt; +extern GrVideoModeExt _GrViDrvEGAVGAcustomTextModeExt; + +GrVideoMode * _gr_selectmode(GrVideoDriver *drv,int w,int h,int bpp, + int txt,unsigned int *ep); + +#endif /* USE_GRX_INTERNAL_DEFINITIONS */ + +#endif /* whole file */ + diff --git a/thirdparty/grx249/include/grfontdv.h b/thirdparty/grx249/include/grfontdv.h new file mode 100644 index 0000000..cfeb80a --- /dev/null +++ b/thirdparty/grx249/include/grfontdv.h @@ -0,0 +1,94 @@ +/** + ** grfontdv.h ---- font driver declarations + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __GRFONTDV_H_INCLUDED__ +#define __GRFONTDV_H_INCLUDED__ + +#ifndef __GRX20_H_INCLUDED__ +#include "grx20.h" +#endif + +/* +** The following definitions shouldn't be used in portable +** or binary distributed programs for compatibility with +** future versions of GRX +*/ +#ifdef USE_GRX_INTERNAL_DEFINITIONS + +/* + * Font driver header. Font drivers are used to load various font file + * formats into the internal bitmap ('GrFont') representation. + */ +typedef struct _GR_fontDriver { + char *name; /* font format name (doc only) */ + char *ext; /* font file name extension */ + int scalable; /* scalable font file format */ + int (*openfile)(char *fname); + int (*header)(GrFontHeader *hdr); + int (*charwdt)(int chr); + int (*bitmap)(int chr,int w,int h,char *buffer); + void (*cleanup)(void); +} GrFontDriver; + +extern GrFontDriver +/* + * Available font drivers in GRX + */ +_GrFontDriverGRX, /* native GRX bitmap fonts */ +_GrFontDriverBGI, /* Borland BGI font driver */ +#ifdef __XWIN__ +_GrFontDriverXWIN, /* X font driver */ +#endif +_GrFontDriverRAW, /* RAW data/linux PSF font driver */ +_GrFontDriverFNA, /* ASCII font driver */ +_GrFontDriverWIN, /* MS Windows font resource driver */ +/* + * This is a NULL-terminated table of font driver descriptor pointers. Users + * can provide their own table with only the desired (or additional) drivers. + * Otherwise the table from the GRX library is linked, which includes ALL + * currently available drivers (i.e. the ones above). + */ +*_GrFontDriverTable[]; + +/* + * Various bits of font related global data + */ +extern struct _GR_fontFileInfo { + int npath; /* number of dirs to search */ + char **path; /* the search directories */ +} _GrFontFileInfo; + +/* + * utilities + */ +GrFont *_GrBuildFont( + const GrFontHeader *hdr, + int cvt, + int width, + int height, + int minch, + int maxch, + int (*charwdt)(int chr), + int (*bitmap)(int chr,int w,int h,char far *buffer), + int canscale +); + +#endif /* USE_GRX_INTERNAL_DEFINITIONS */ + +#endif /* whole file */ + diff --git a/thirdparty/grx249/include/grx20.h b/thirdparty/grx249/include/grx20.h new file mode 100644 index 0000000..a0d9f62 --- /dev/null +++ b/thirdparty/grx249/include/grx20.h @@ -0,0 +1,1678 @@ +/** + ** grx20.h ---- GRX 2.x API functions and data structure declarations + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __GRX20_H_INCLUDED__ +#define __GRX20_H_INCLUDED__ + +/* ================================================================== */ +/* COMPILER -- CPU -- SYSTEM SPECIFIC VERSION STUFF */ +/* ================================================================== */ + +/* Version of GRX API +** +** usage: +** #include +** #ifndef GRX_VERSION_API +** #ifdef GRX_VERSION +** #define GRX_VERSION_API 0x0200 +** #else +** #define GRX_VERSION_API 0x0103 +** #endif +** #endif +*/ +#define GRX_VERSION_API 0x0249 + +/* these are the supported configurations: */ +#define GRX_VERSION_TCC_8086_DOS 1 /* also works with BCC */ +#define GRX_VERSION_GCC_386_GO32 2 /* deprecated, don't use it */ +#define GRX_VERSION_GCC_386_DJGPP 2 /* DJGPP v2 */ +#define GRX_VERSION_GCC_386_LINUX 3 /* the real stuff */ +#define GRX_VERSION_GENERIC_X11 4 /* generic X11 version */ +#define GRX_VERSION_WATCOM_DOS4GW 5 /* GS - Watcom C++ 11.0 32 Bit */ +/*#define GRX_VERSION_WATCOM_REAL_MODE 6*/ /* GS - Watcom C++ 11.0 16 Bit - TODO! */ +#define GRX_VERSION_GCC_386_WIN32 7 /* WIN32 using Mingw32 */ +#define GRX_VERSION_MSC_386_WIN32 8 /* WIN32 using MS-VC */ +#define GRX_VERSION_GCC_386_CYG32 9 /* WIN32 using CYGWIN */ +#define GRX_VERSION_GCC_386_X11 10 /* X11 version */ +#define GRX_VERSION_GCC_X86_64_LINUX 11 /* console framebuffer 64 */ +#define GRX_VERSION_GCC_X86_64_X11 12 /* X11 version 64 */ + +#define GRXMain main /* From the 2.4.6 version We don't need this */ + /* anymore, but it is here for previous apps */ + +#ifdef __TURBOC__ +#define GRX_VERSION GRX_VERSION_TCC_8086_DOS +#endif + +#ifdef __GNUC__ +#ifdef __DJGPP__ +#define GRX_VERSION GRX_VERSION_GCC_386_DJGPP +#endif +#if defined(__XWIN__) +#if defined(__linux__) && defined(__i386__) +#define GRX_VERSION GRX_VERSION_GCC_386_X11 +#endif +#if defined(__linux__) && defined(__x86_64__) +#define GRX_VERSION GRX_VERSION_GCC_X86_64_X11 +#endif +#else +#if defined(__linux__) && defined(__i386__) +#define GRX_VERSION GRX_VERSION_GCC_386_LINUX +#endif +#if defined(__linux__) && defined(__x86_64__) +#define GRX_VERSION GRX_VERSION_GCC_X86_64_LINUX +#endif +#endif +#ifdef __WIN32__ +#define GRX_VERSION GRX_VERSION_GCC_386_WIN32 +#endif +#ifdef __CYGWIN32__ +#define GRX_VERSION GRX_VERSION_GCC_386_CYG32 +#define __WIN32__ +#endif +#endif /* __GNUC__ */ + +#ifdef __WATCOMC__ /* GS - Watcom C++ 11.0 */ +#ifdef __DOS__ +#ifdef __386__ +#define GRX_VERSION GRX_VERSION_WATCOM_DOS4GW +#else +/* #define GRX_VERSION GRX_VERSION_WATCOM_REAL_MODE - I haven't tested GRX in 16 bit*/ +#endif /* __386__ */ +#endif /* __DOS__ */ +#endif /* __WATCOMC__ */ + +#ifdef _MSC_VER +#ifdef _WIN32 +#ifdef _M_IX86 +#define GRX_VERSION GRX_VERSION_MSC_386_WIN32 +#if !defined(__WIN32__) +#define __WIN32__ _WIN32 +#endif +#endif /* _M_IX86 */ +#endif /* _WIN32 */ +#endif /* _MSC_VER */ + +#ifndef GRX_VERSION +#if defined(unix) || defined(__unix) || defined(__unix__) || defined(_AIX) +#define GRX_VERSION GRX_VERSION_GENERIC_X11 +#endif +#endif + +#ifndef GRX_VERSION +#error GRX is not supported on your COMPILER/CPU/OPERATING SYSTEM! +#endif + +#if (GRX_VERSION==GRX_VERSION_WATCOM_DOS4GW) +#define near +#define far +#define huge +#endif + +#if !defined(__TURBOC__) && (GRX_VERSION!=GRX_VERSION_WATCOM_REAL_MODE) +#ifndef near /* get rid of these stupid keywords */ +#define near +#endif +#ifndef far +#define far +#endif +#ifndef huge +#define huge +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* a couple of forward declarations ... */ +typedef struct _GR_frameDriver GrFrameDriver; +typedef struct _GR_videoDriver GrVideoDriver; +typedef struct _GR_videoMode GrVideoMode; +typedef struct _GR_videoModeExt GrVideoModeExt; +typedef struct _GR_frame GrFrame; +typedef struct _GR_context GrContext; + +/* ================================================================== */ +/* SYSTEM TYPE DEF's */ +/* ================================================================== */ + +/* need unsigned 32 bit integer for color stuff */ +#if defined(__TURBOC__) && defined(__MSDOS__) +/* TCC && BCC are 16 bit compilers */ +typedef unsigned long int GrColor; +#else +/* all other platforms (GCC on i386 or x86_64 and ALPHA) have 32 bit ints */ +typedef unsigned int GrColor; +#endif + +/* ================================================================== */ +/* MODE SETTING */ +/* ================================================================== */ + +/* + * available video modes (for 'GrSetMode') + */ +typedef enum _GR_graphicsModes { + GR_unknown_mode = (-1), /* initial state */ + /* ============= modes which clear the video memory ============= */ + GR_80_25_text = 0, /* Extra parameters for GrSetMode: */ + GR_default_text, + GR_width_height_text, /* int w,int h */ + GR_biggest_text, + GR_320_200_graphics, + GR_default_graphics, + GR_width_height_graphics, /* int w,int h */ + GR_biggest_noninterlaced_graphics, + GR_biggest_graphics, + GR_width_height_color_graphics, /* int w,int h,GrColor nc */ + GR_width_height_color_text, /* int w,int h,GrColor nc */ + GR_custom_graphics, /* int w,int h,GrColor nc,int vx,int vy */ + /* ==== equivalent modes which do not clear the video memory ==== */ + GR_NC_80_25_text, + GR_NC_default_text, + GR_NC_width_height_text, /* int w,int h */ + GR_NC_biggest_text, + GR_NC_320_200_graphics, + GR_NC_default_graphics, + GR_NC_width_height_graphics, /* int w,int h */ + GR_NC_biggest_noninterlaced_graphics, + GR_NC_biggest_graphics, + GR_NC_width_height_color_graphics, /* int w,int h,GrColor nc */ + GR_NC_width_height_color_text, /* int w,int h,GrColor nc */ + GR_NC_custom_graphics, /* int w,int h,GrColor nc,int vx,int vy */ + /* ==== plane instead of color based modes ==== */ + /* colors = 1 << bpp >>> resort enum for GRX3 <<< */ + GR_width_height_bpp_graphics, /* int w,int h,int bpp */ + GR_width_height_bpp_text, /* int w,int h,int bpp */ + GR_custom_bpp_graphics, /* int w,int h,int bpp,int vx,int vy */ + GR_NC_width_height_bpp_graphics, /* int w,int h,int bpp */ + GR_NC_width_height_bpp_text, /* int w,int h,int bpp */ + GR_NC_custom_bpp_graphics /* int w,int h,int bpp,int vx,int vy */ +} GrGraphicsMode; + +/* + * Available frame modes (video memory layouts) + */ +typedef enum _GR_frameModes { + /* ====== video frame buffer modes ====== */ + GR_frameUndef, /* undefined */ + GR_frameText, /* text modes */ + GR_frameHERC1, /* Hercules mono */ + GR_frameEGAVGA1, /* EGA VGA mono */ + GR_frameEGA4, /* EGA 16 color */ + GR_frameSVGA4, /* (Super) VGA 16 color */ + GR_frameSVGA8, /* (Super) VGA 256 color */ + GR_frameVGA8X, /* VGA 256 color mode X */ + GR_frameSVGA16, /* Super VGA 32768/65536 color */ + GR_frameSVGA24, /* Super VGA 16M color */ + GR_frameSVGA32L, /* Super VGA 16M color padded #1 */ + GR_frameSVGA32H, /* Super VGA 16M color padded #2 */ + /* ==== modes provided by the X11 driver ===== */ + GR_frameXWIN1 = GR_frameEGAVGA1, + GR_frameXWIN4 = GR_frameSVGA4, + GR_frameXWIN8 = GR_frameSVGA8, + GR_frameXWIN16 = GR_frameSVGA16, + GR_frameXWIN24 = GR_frameSVGA24, + GR_frameXWIN32L = GR_frameSVGA32L, + GR_frameXWIN32H = GR_frameSVGA32H, + /* ==== modes provided by the WIN32 driver ===== */ + GR_frameWIN32_1 = GR_frameEGAVGA1, + GR_frameWIN32_4 = GR_frameSVGA4, + GR_frameWIN32_8 = GR_frameSVGA8, + GR_frameWIN32_16 = GR_frameSVGA16, + GR_frameWIN32_24 = GR_frameSVGA24, + GR_frameWIN32_32L = GR_frameSVGA32L, + GR_frameWIN32_32H = GR_frameSVGA32H, + /* ==== modes provided by the SDL driver ===== */ + GR_frameSDL8 = GR_frameSVGA8, + GR_frameSDL16 = GR_frameSVGA16, + GR_frameSDL24 = GR_frameSVGA24, + GR_frameSDL32L = GR_frameSVGA32L, + GR_frameSDL32H = GR_frameSVGA32H, + /* ==== linear frame buffer modes ====== */ + GR_frameSVGA8_LFB, /* (Super) VGA 256 color */ + GR_frameSVGA16_LFB, /* Super VGA 32768/65536 color */ + GR_frameSVGA24_LFB, /* Super VGA 16M color */ + GR_frameSVGA32L_LFB, /* Super VGA 16M color padded #1 */ + GR_frameSVGA32H_LFB, /* Super VGA 16M color padded #2 */ + /* ====== system RAM frame buffer modes ====== */ + GR_frameRAM1, /* mono */ + GR_frameRAM4, /* 16 color planar */ + GR_frameRAM8, /* 256 color */ + GR_frameRAM16, /* 32768/65536 color */ + GR_frameRAM24, /* 16M color */ + GR_frameRAM32L, /* 16M color padded #1 */ + GR_frameRAM32H, /* 16M color padded #2 */ + GR_frameRAM3x8, /* 16M color planar (image mode) */ + /* ====== markers for scanning modes ====== */ + GR_firstTextFrameMode = GR_frameText, + GR_lastTextFrameMode = GR_frameText, + GR_firstGraphicsFrameMode = GR_frameHERC1, + GR_lastGraphicsFrameMode = GR_frameSVGA32H_LFB, + GR_firstRAMframeMode = GR_frameRAM1, + GR_lastRAMframeMode = GR_frameRAM3x8 +} GrFrameMode; + +/* + * supported video adapter types + */ +typedef enum _GR_videoAdapters { + GR_UNKNOWN = (-1), /* not known (before driver set) */ + GR_VGA, /* VGA adapter */ + GR_EGA, /* EGA adapter */ + GR_HERC, /* Hercules mono adapter */ + GR_8514A, /* 8514A or compatible */ + GR_S3, /* S3 graphics accelerator */ + GR_XWIN, /* X11 driver */ + GR_WIN32, /* WIN32 driver */ + GR_LNXFB, /* Linux framebuffer */ + GR_SDL, /* SDL driver */ + GR_MEM /* memory only driver */ +} GrVideoAdapter; + +/* + * The video driver descriptor structure + */ +struct _GR_videoDriver { + char *name; /* driver name */ + enum _GR_videoAdapters adapter; /* adapter type */ + struct _GR_videoDriver *inherit; /* inherit video modes from this */ + struct _GR_videoMode *modes; /* table of supported modes */ + int nmodes; /* number of modes */ + int (*detect)(void); + int (*init)(char *options); + void (*reset)(void); + GrVideoMode * (*selectmode)(GrVideoDriver *drv,int w,int h,int bpp, + int txt,unsigned int *ep); + unsigned drvflags; +}; +/* bits in the drvflags field: */ +#define GR_DRIVERF_USER_RESOLUTION 1 + /* set if driver supports user setable arbitrary resolution */ + + +/* + * Video driver mode descriptor structure + */ +struct _GR_videoMode { + char present; /* is it really available? */ + char bpp; /* log2 of # of colors */ + short width,height; /* video mode geometry */ + short mode; /* BIOS mode number (if any) */ + int lineoffset; /* scan line length */ + int privdata; /* driver can use it for anything */ + struct _GR_videoModeExt *extinfo; /* extra info (maybe shared) */ +}; + +/* + * Video driver mode descriptor extension structure. This is a separate + * structure accessed via a pointer from the main mode descriptor. The + * reason for this is that frequently several modes can share the same + * extended info. + */ +struct _GR_videoModeExt { + enum _GR_frameModes mode; /* frame driver for this video mode */ + struct _GR_frameDriver *drv; /* optional frame driver override */ + char far *frame; /* frame buffer address */ + char cprec[3]; /* color component precisions */ + char cpos[3]; /* color component bit positions */ + int flags; /* mode flag bits; see "grdriver.h" */ + int (*setup)(GrVideoMode *md,int noclear); + int (*setvsize)(GrVideoMode *md,int w,int h,GrVideoMode *result); + int (*scroll)(GrVideoMode *md,int x,int y,int result[2]); + void (*setbank)(int bk); + void (*setrwbanks)(int rb,int wb); + void (*loadcolor)(int c,int r,int g,int b); + int LFB_Selector; +}; + +/* + * The frame driver descriptor structure. + */ +struct _GR_frameDriver { + enum _GR_frameModes mode; /* supported frame access mode */ + enum _GR_frameModes rmode; /* matching RAM frame (if video) */ + int is_video; /* video RAM frame driver ? */ + int row_align; /* scan line size alignment */ + int num_planes; /* number of planes */ + int bits_per_pixel; /* bits per pixel */ + long max_plane_size; /* maximum plane size in bytes */ + int (*init)(GrVideoMode *md); + GrColor (*readpixel)(GrFrame *c,int x,int y); + void (*drawpixel)(int x,int y,GrColor c); + void (*drawline)(int x,int y,int dx,int dy,GrColor c); + void (*drawhline)(int x,int y,int w,GrColor c); + void (*drawvline)(int x,int y,int h,GrColor c); + void (*drawblock)(int x,int y,int w,int h,GrColor c); + void (*drawbitmap)(int x,int y,int w,int h,char far *bmp,int pitch,int start,GrColor fg,GrColor bg); + void (*drawpattern)(int x,int y,int w,char patt,GrColor fg,GrColor bg); + void (*bitblt)(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op); + void (*bltv2r)(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op); + void (*bltr2v)(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op); + /* new functions in v2.3 */ + GrColor far *(*getindexedscanline)(GrFrame *c,int x, int y, int w, int *indx); + /* will return an array of pixel values pv[] read from frame */ + /* if indx == NULL: pv[i=0..w-1] = readpixel(x+i,y) */ + /* else pv[i=0..w-1] = readpixel(x+indx[i],y) */ + void (*putscanline)(int x, int y, int w,const GrColor far *scl, GrColor op); + /** will draw scl[i=0..w-1] to frame: */ + /* if (scl[i] != skipcolor) drawpixel(x+i,y,(scl[i] | op)) */ +}; + +/* + * driver and mode info structure + */ +extern const struct _GR_driverInfo { + struct _GR_videoDriver *vdriver; /* the current video driver */ + struct _GR_videoMode *curmode; /* current video mode pointer */ + struct _GR_videoMode actmode; /* copy of above, resized if virtual */ + struct _GR_frameDriver fdriver; /* frame driver for the current context */ + struct _GR_frameDriver sdriver; /* frame driver for the screen */ + struct _GR_frameDriver tdriver; /* a dummy driver for text modes */ + enum _GR_graphicsModes mcode; /* code for the current mode */ + int deftw,defth; /* default text mode size */ + int defgw,defgh; /* default graphics mode size */ + GrColor deftc,defgc; /* default text and graphics colors */ + int vposx,vposy; /* current virtual viewport position */ + int errsfatal; /* if set, exit upon errors */ + int moderestore; /* restore startup video mode if set */ + int splitbanks; /* indicates separate R/W banks */ + int curbank; /* currently mapped bank */ + void (*mdsethook)(void); /* callback for mode set */ + void (*setbank)(int bk); /* banking routine */ + void (*setrwbanks)(int rb,int wb); /* split banking routine */ +} * const GrDriverInfo; + +/* + * setup stuff + */ +int GrSetDriver(char *drvspec); +int GrSetMode(GrGraphicsMode which,...); +int GrSetViewport(int xpos,int ypos); +void GrSetModeHook(void (*hookfunc)(void)); +void GrSetModeRestore(int restoreFlag); +void GrSetErrorHandling(int exitIfError); +void GrSetEGAVGAmonoDrawnPlane(int plane); +void GrSetEGAVGAmonoShownPlane(int plane); + +unsigned GrGetLibraryVersion(void); +unsigned GrGetLibrarySystem(void); + +/* + * inquiry stuff ---- many of these are actually macros (see below) + */ +GrGraphicsMode GrCurrentMode(void); +GrVideoAdapter GrAdapterType(void); +GrFrameMode GrCurrentFrameMode(void); +GrFrameMode GrScreenFrameMode(void); +GrFrameMode GrCoreFrameMode(void); + +const GrVideoDriver *GrCurrentVideoDriver(void); +const GrVideoMode *GrCurrentVideoMode(void); +const GrVideoMode *GrVirtualVideoMode(void); +const GrFrameDriver *GrCurrentFrameDriver(void); +const GrFrameDriver *GrScreenFrameDriver(void); +const GrVideoMode *GrFirstVideoMode(GrFrameMode fmode); +const GrVideoMode *GrNextVideoMode(const GrVideoMode *prev); + +int GrScreenX(void); +int GrScreenY(void); +int GrVirtualX(void); +int GrVirtualY(void); +int GrViewportX(void); +int GrViewportY(void); + +int GrScreenIsVirtual(void); + +/* + * RAM context geometry and memory allocation inquiry stuff + */ +int GrFrameNumPlanes(GrFrameMode md); +int GrFrameLineOffset(GrFrameMode md,int width); +long GrFramePlaneSize(GrFrameMode md,int w,int h); +long GrFrameContextSize(GrFrameMode md,int w,int h); + +int GrNumPlanes(void); +int GrLineOffset(int width); +long GrPlaneSize(int w,int h); +long GrContextSize(int w,int h); + +/* + * inline implementation for some of the above + */ +#ifndef GRX_SKIP_INLINES +#define GrAdapterType() (GrDriverInfo->vdriver ? GrDriverInfo->vdriver->adapter : GR_UNKNOWN) +#define GrCurrentMode() (GrDriverInfo->mcode) +#define GrCurrentFrameMode() (GrDriverInfo->fdriver.mode) +#define GrScreenFrameMode() (GrDriverInfo->sdriver.mode) +#define GrCoreFrameMode() (GrDriverInfo->sdriver.rmode) + +#define GrCurrentVideoDriver() ((const GrVideoDriver *)( GrDriverInfo->vdriver)) +#define GrCurrentVideoMode() ((const GrVideoMode *)( GrDriverInfo->curmode)) +#define GrVirtualVideoMode() ((const GrVideoMode *)(&GrDriverInfo->actmode)) +#define GrCurrentFrameDriver() ((const GrFrameDriver *)(&GrDriverInfo->fdriver)) +#define GrScreenFrameDriver() ((const GrFrameDriver *)(&GrDriverInfo->sdriver)) + +#define GrIsFixedMode() (!( GrCurrentVideoDriver()->drvflags \ + & GR_DRIVERF_USER_RESOLUTION)) + +#define GrScreenX() (GrCurrentVideoMode()->width) +#define GrScreenY() (GrCurrentVideoMode()->height) +#define GrVirtualX() (GrVirtualVideoMode()->width) +#define GrVirtualY() (GrVirtualVideoMode()->height) +#define GrViewportX() (GrDriverInfo->vposx) +#define GrViewportY() (GrDriverInfo->vposy) + +#define GrScreenIsVirtual() ((GrScreenX() + GrScreenY()) < (GrVirtualX() + GrVirtualY())) + +#define GrNumPlanes() GrFrameNumPlanes(GrCoreFrameMode()) +#define GrLineOffset(w) GrFrameLineOffset(GrCoreFrameMode(),w) +#define GrPlaneSize(w,h) GrFramePlaneSize(GrCoreFrameMode(),w,h) +#define GrContextSize(w,h) GrFrameContextSize(GrCoreFrameMode(),w,h) +#endif /* GRX_SKIP_INLINES */ + + +/* ================================================================== */ +/* FRAME BUFFER, CONTEXT AND CLIPPING STUFF */ +/* ================================================================== */ + +struct _GR_frame { + char far *gf_baseaddr[4]; /* base address of frame memory */ + short gf_selector; /* frame memory segment selector */ + char gf_onscreen; /* is it in video memory ? */ + char gf_memflags; /* memory allocation flags */ + int gf_lineoffset; /* offset to next scan line in bytes */ + struct _GR_frameDriver *gf_driver; /* frame access functions */ +}; + +struct _GR_context { + struct _GR_frame gc_frame; /* frame buffer info */ + struct _GR_context *gc_root; /* context which owns frame */ + int gc_xmax; /* max X coord (width - 1) */ + int gc_ymax; /* max Y coord (height - 1) */ + int gc_xoffset; /* X offset from root's base */ + int gc_yoffset; /* Y offset from root's base */ + int gc_xcliplo; /* low X clipping limit */ + int gc_ycliplo; /* low Y clipping limit */ + int gc_xcliphi; /* high X clipping limit */ + int gc_ycliphi; /* high Y clipping limit */ + int gc_usrxbase; /* user window min X coordinate */ + int gc_usrybase; /* user window min Y coordinate */ + int gc_usrwidth; /* user window width */ + int gc_usrheight; /* user window height */ +# define gc_baseaddr gc_frame.gf_baseaddr +# define gc_selector gc_frame.gf_selector +# define gc_onscreen gc_frame.gf_onscreen +# define gc_memflags gc_frame.gf_memflags +# define gc_lineoffset gc_frame.gf_lineoffset +# define gc_driver gc_frame.gf_driver +}; + +extern const struct _GR_contextInfo { + struct _GR_context current; /* the current context */ + struct _GR_context screen; /* the screen context */ +} * const GrContextInfo; + +GrContext *GrCreateContext(int w,int h,char far *memory[4],GrContext *where); +GrContext *GrCreateFrameContext(GrFrameMode md,int w,int h,char far *memory[4],GrContext *where); +GrContext *GrCreateSubContext(int x1,int y1,int x2,int y2,const GrContext *parent,GrContext *where); +GrContext *GrSaveContext(GrContext *where); + +GrContext *GrCurrentContext(void); +GrContext *GrScreenContext(void); + +void GrDestroyContext(GrContext *context); +void GrResizeSubContext(GrContext *context,int x1,int y1,int x2,int y2); +void GrSetContext(const GrContext *context); + +void GrSetClipBox(int x1,int y1,int x2,int y2); +void GrSetClipBoxC(GrContext *c,int x1,int y1,int x2,int y2); +void GrGetClipBox(int *x1p,int *y1p,int *x2p,int *y2p); +void GrGetClipBoxC(const GrContext *c,int *x1p,int *y1p,int *x2p,int *y2p); +void GrResetClipBox(void); +void GrResetClipBoxC(GrContext *c); + +int GrMaxX(void); +int GrMaxY(void); +int GrSizeX(void); +int GrSizeY(void); +int GrLowX(void); +int GrLowY(void); +int GrHighX(void); +int GrHighY(void); + +#ifndef GRX_SKIP_INLINES +#define GrCreateContext(w,h,m,c) (GrCreateFrameContext(GrCoreFrameMode(),w,h,m,c)) +#define GrCurrentContext() ((GrContext *)(&GrContextInfo->current)) +#define GrScreenContext() ((GrContext *)(&GrContextInfo->screen)) +#define GrMaxX() (GrCurrentContext()->gc_xmax) +#define GrMaxY() (GrCurrentContext()->gc_ymax) +#define GrSizeX() (GrMaxX() + 1) +#define GrSizeY() (GrMaxY() + 1) +#define GrLowX() (GrCurrentContext()->gc_xcliplo) +#define GrLowY() (GrCurrentContext()->gc_ycliplo) +#define GrHighX() (GrCurrentContext()->gc_xcliphi) +#define GrHighY() (GrCurrentContext()->gc_ycliphi) +#define GrGetClipBoxC(C,x1p,y1p,x2p,y2p) do { \ + *(x1p) = (C)->gc_xcliplo; \ + *(y1p) = (C)->gc_ycliplo; \ + *(x2p) = (C)->gc_xcliphi; \ + *(y2p) = (C)->gc_ycliphi; \ +} while(0) +#define GrGetClipBox(x1p,y1p,x2p,y2p) do { \ + *(x1p) = GrLowX(); \ + *(y1p) = GrLowY(); \ + *(x2p) = GrHighX(); \ + *(y2p) = GrHighY(); \ +} while(0) +#endif /* GRX_SKIP_INLINES */ + +/* ================================================================== */ +/* COLOR STUFF */ +/* ================================================================== */ + +/* + * Flags to 'OR' to colors for various operations + */ +#define GrWRITE 0UL /* write color */ +#define GrXOR 0x01000000UL /* to "XOR" any color to the screen */ +#define GrOR 0x02000000UL /* to "OR" to the screen */ +#define GrAND 0x03000000UL /* to "AND" to the screen */ +#define GrIMAGE 0x04000000UL /* BLIT: write, except given color */ +#define GrCVALUEMASK 0x00ffffffUL /* color value mask */ +#define GrCMODEMASK 0xff000000UL /* color operation mask */ +#define GrNOCOLOR (GrXOR | 0) /* GrNOCOLOR is used for "no" color */ + +GrColor GrColorValue(GrColor c); +GrColor GrColorMode(GrColor c); +GrColor GrWriteModeColor(GrColor c); +GrColor GrXorModeColor(GrColor c); +GrColor GrOrModeColor(GrColor c); +GrColor GrAndModeColor(GrColor c); +GrColor GrImageModeColor(GrColor c); + +/* + * color system info structure (all [3] arrays are [r,g,b]) + */ +extern const struct _GR_colorInfo { + GrColor ncolors; /* number of colors */ + GrColor nfree; /* number of unallocated colors */ + GrColor black; /* the black color */ + GrColor white; /* the white color */ + unsigned int RGBmode; /* set when RGB mode */ + unsigned int prec[3]; /* color field precisions */ + unsigned int pos[3]; /* color field positions */ + unsigned int mask[3]; /* masks for significant bits */ + unsigned int round[3]; /* add these for rounding */ + unsigned int shift[3]; /* shifts for (un)packing color */ + unsigned int norm; /* normalization for (un)packing */ + struct { /* color table for non-RGB modes */ + unsigned char r,g,b; /* loaded components */ + unsigned int defined:1; /* r,g,b values are valid if set */ + unsigned int writable:1; /* can be changed by 'GrSetColor' */ + unsigned long int nused; /* usage count */ + } ctable[256]; +} * const GrColorInfo; + +void GrResetColors(void); +void GrSetRGBcolorMode(void); +void GrRefreshColors(void); + +GrColor GrNumColors(void); +GrColor GrNumFreeColors(void); + +GrColor GrBlack(void); +GrColor GrWhite(void); + +GrColor GrBuildRGBcolorT(int r,int g,int b); +GrColor GrBuildRGBcolorR(int r,int g,int b); +int GrRGBcolorRed(GrColor c); +int GrRGBcolorGreen(GrColor c); +int GrRGBcolorBlue(GrColor c); + +GrColor GrAllocColor(int r,int g,int b); /* shared, read-only */ +GrColor GrAllocColorID(int r,int g,int b); /* potentially inlined version */ +GrColor GrAllocColor2(long hcolor); /* shared, read-only, 0xRRGGBB */ +GrColor GrAllocColor2ID(long hcolor); /* potentially inlined version */ +GrColor GrAllocCell(void); /* unshared, read-write */ + +GrColor *GrAllocEgaColors(void); /* shared, read-only standard EGA colors */ + +void GrSetColor(GrColor c,int r,int g,int b); +void GrFreeColor(GrColor c); +void GrFreeCell(GrColor c); + +void GrQueryColor(GrColor c,int *r,int *g,int *b); +void GrQueryColorID(GrColor c,int *r,int *g,int *b); +void GrQueryColor2(GrColor c,long *hcolor); +void GrQueryColor2ID(GrColor c,long *hcolor); + +int GrColorSaveBufferSize(void); +void GrSaveColors(void *buffer); +void GrRestoreColors(void *buffer); + +#ifndef GRX_SKIP_INLINES +#define GrColorValue(c) ((GrColor)(c) & GrCVALUEMASK) +#define GrColorMode(c) ((GrColor)(c) & GrCMODEMASK) +#define GrWriteModeColor(c) (GrColorValue(c) | GrWRITE) +#define GrXorModeColor(c) (GrColorValue(c) | GrXOR) +#define GrOrModeColor(c) (GrColorValue(c) | GrOR) +#define GrAndModeColor(c) (GrColorValue(c) | GrAND) +#define GrImageModeColor(c) (GrColorValue(c) | GrIMAGE) +#define GrNumColors() (GrColorInfo->ncolors) +#define GrNumFreeColors() (GrColorInfo->nfree) +#define GrBlack() ( \ + (GrColorInfo->black == GrNOCOLOR) ? \ + (GrBlack)() : \ + GrColorInfo->black \ +) +#define GrWhite() ( \ + (GrColorInfo->white == GrNOCOLOR) ? \ + (GrWhite)() : \ + GrColorInfo->white \ +) +#define GrBuildRGBcolorT(r,g,b) (( \ + ((GrColor)((int)(r) & GrColorInfo->mask[0]) << GrColorInfo->shift[0]) |\ + ((GrColor)((int)(g) & GrColorInfo->mask[1]) << GrColorInfo->shift[1]) |\ + ((GrColor)((int)(b) & GrColorInfo->mask[2]) << GrColorInfo->shift[2]) \ + ) >> GrColorInfo->norm \ +) +#define GrBuildRGBcolorR(r,g,b) GrBuildRGBcolorT( \ + (((unsigned int)(r)) > GrColorInfo->mask[0]) ? 255 : (unsigned int)(r) + GrColorInfo->round[0], \ + (((unsigned int)(g)) > GrColorInfo->mask[1]) ? 255 : (unsigned int)(g) + GrColorInfo->round[1], \ + (((unsigned int)(b)) > GrColorInfo->mask[2]) ? 255 : (unsigned int)(b) + GrColorInfo->round[2] \ +) +#define GrRGBcolorRed(c) ( \ + (int)(((GrColor)(c) << GrColorInfo->norm) >> GrColorInfo->shift[0]) & \ + (GrColorInfo->mask[0]) \ +) +#define GrRGBcolorGreen(c) ( \ + (int)(((GrColor)(c) << GrColorInfo->norm) >> GrColorInfo->shift[1]) & \ + (GrColorInfo->mask[1]) \ +) +#define GrRGBcolorBlue(c) ( \ + (int)(((GrColor)(c) << GrColorInfo->norm) >> GrColorInfo->shift[2]) & \ + (GrColorInfo->mask[2]) \ +) +#define GrAllocColorID(r,g,b) (GrColorInfo->RGBmode ? \ + GrBuildRGBcolorR(r,g,b) : \ + GrAllocColor(r,g,b) \ +) +#define GrAllocColor2(hcolor) (GrAllocColor( \ + ((hcolor & 0xff0000) >> 16), \ + ((hcolor & 0x00ff00) >> 8), \ + (hcolor & 0x0000ff)) \ +) +#define GrAllocColor2ID(hcolor) (GrAllocColorID( \ + ((hcolor & 0xff0000) >> 16), \ + ((hcolor & 0x00ff00) >> 8), \ + (hcolor & 0x0000ff)) \ +) +#define GrQueryColorID(c,r,g,b) do { \ + if(GrColorInfo->RGBmode) { \ + *(r) = GrRGBcolorRed(c); \ + *(g) = GrRGBcolorGreen(c); \ + *(b) = GrRGBcolorBlue(c); \ + break; \ + } \ + if(((GrColor)(c) < GrColorInfo->ncolors) && \ + (GrColorInfo->ctable[(GrColor)(c)].defined)) { \ + *(r) = GrColorInfo->ctable[(GrColor)(c)].r; \ + *(g) = GrColorInfo->ctable[(GrColor)(c)].g; \ + *(b) = GrColorInfo->ctable[(GrColor)(c)].b; \ + break; \ + } \ + *(r) = *(g) = *(b) = 0; \ +} while(0) +#define GrQueryColor2ID(c,hcolor) do { \ + if(GrColorInfo->RGBmode) { \ + *(hcolor) = GrRGBcolorRed(c) << 16; \ + *(hcolor) |= GrRGBcolorGreen(c) << 8; \ + *(hcolor) |= GrRGBcolorBlue(c); \ + break; \ + } \ + if(((GrColor)(c) < GrColorInfo->ncolors) && \ + (GrColorInfo->ctable[(GrColor)(c)].defined)) { \ + *(hcolor) = GrColorInfo->ctable[(GrColor)(c)].r; \ + *(hcolor) = GrColorInfo->ctable[(GrColor)(c)].g; \ + *(hcolor) = GrColorInfo->ctable[(GrColor)(c)].b; \ + break; \ + } \ + *(hcolor) = 0; \ +} while(0) +#endif /* GRX_SKIP_INLINES */ + +/* + * color table (for primitives using several colors): + * it is an array of colors with the first element being + * the number of colors in the table + */ +typedef GrColor *GrColorTableP; + +#define GR_CTABLE_SIZE(table) ( \ + (table) ? (unsigned int)((table)[0]) : 0U \ +) +#define GR_CTABLE_COLOR(table,index) ( \ + ((unsigned)(index) < GR_CTABLE_SIZE(table)) ? \ + (table)[((unsigned)(index)) + 1] : \ + GrNOCOLOR \ +) +#define GR_CTABLE_ALLOCSIZE(ncolors) ((ncolors) + 1) + +/* ================================================================== */ +/* GRAPHICS PRIMITIVES */ +/* ================================================================== */ + +#ifdef __TURBOC__ +/* this is for GRX compiled with SMALL_STACK: */ +#define GR_MAX_POLYGON_POINTS (8192) +#define GR_MAX_ELLIPSE_POINTS (1024 + 5) +/* old values without SMALL_STACK: */ +/* #define GR_MAX_POLYGON_POINTS (512) */ +/* #define GR_MAX_ELLIPSE_POINTS (256 + 5) */ +#else +#define GR_MAX_POLYGON_POINTS (1000000) +#define GR_MAX_ELLIPSE_POINTS (1024 + 5) +#endif +#define GR_MAX_ANGLE_VALUE (3600) +#define GR_ARC_STYLE_OPEN 0 +#define GR_ARC_STYLE_CLOSE1 1 +#define GR_ARC_STYLE_CLOSE2 2 + +typedef struct { /* framed box colors */ + GrColor fbx_intcolor; + GrColor fbx_topcolor; + GrColor fbx_rightcolor; + GrColor fbx_bottomcolor; + GrColor fbx_leftcolor; +} GrFBoxColors; + +void GrClearScreen(GrColor bg); +void GrClearContext(GrColor bg); +void GrClearContextC(GrContext *ctx, GrColor bg); +void GrClearClipBox(GrColor bg); +void GrPlot(int x,int y,GrColor c); +void GrLine(int x1,int y1,int x2,int y2,GrColor c); +void GrHLine(int x1,int x2,int y,GrColor c); +void GrVLine(int x,int y1,int y2,GrColor c); +void GrBox(int x1,int y1,int x2,int y2,GrColor c); +void GrFilledBox(int x1,int y1,int x2,int y2,GrColor c); +void GrFramedBox(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c); +int GrGenerateEllipse(int xc,int yc,int xa,int ya,int points[GR_MAX_ELLIPSE_POINTS][2]); +int GrGenerateEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int points[GR_MAX_ELLIPSE_POINTS][2]); +void GrLastArcCoords(int *xs,int *ys,int *xe,int *ye,int *xc,int *yc); +void GrCircle(int xc,int yc,int r,GrColor c); +void GrEllipse(int xc,int yc,int xa,int ya,GrColor c); +void GrCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c); +void GrEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrColor c); +void GrFilledCircle(int xc,int yc,int r,GrColor c); +void GrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c); +void GrFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c); +void GrFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrColor c); +void GrPolyLine(int numpts,int points[][2],GrColor c); +void GrPolygon(int numpts,int points[][2],GrColor c); +void GrFilledConvexPolygon(int numpts,int points[][2],GrColor c); +void GrFilledPolygon(int numpts,int points[][2],GrColor c); +void GrBitBlt(GrContext *dst,int x,int y,GrContext *src,int x1,int y1,int x2,int y2,GrColor op); +void GrBitBlt1bpp(GrContext *dst,int dx,int dy,GrContext *src,int x1,int y1,int x2,int y2,GrColor fg,GrColor bg); +void GrFloodFill(int x, int y, GrColor border, GrColor c); +void GrFloodSpill(int x1, int y1, int x2, int y2, GrColor old_c, GrColor new_c); +void GrFloodSpill2(int x1, int y1, int x2, int y2, GrColor old_c1, GrColor new_c1, GrColor old_c2, GrColor new_c2); +void GrFloodSpillC(GrContext *ctx, int x1, int y1, int x2, int y2, GrColor old_c, GrColor new_c); +void GrFloodSpillC2(GrContext *ctx, int x1, int y1, int x2, int y2, GrColor old_c1, GrColor new_c1, GrColor old_c2, GrColor new_c2); + +GrColor GrPixel(int x,int y); +GrColor GrPixelC(GrContext *c,int x,int y); + +const GrColor *GrGetScanline(int x1,int x2,int yy); +const GrColor *GrGetScanlineC(GrContext *ctx,int x1,int x2,int yy); +/* Input ctx: source context, if NULL the current context is used */ +/* x1 : first x coordinate read */ +/* x2 : last x coordinate read */ +/* yy : y coordinate */ +/* Output NULL : error / no data (clipping occured) */ +/* else */ +/* p[0..w]: pixel values read */ +/* (w = |x2-y1|) */ +/* Output data is valid until next GRX call ! */ + +void GrPutScanline(int x1,int x2,int yy,const GrColor *c, GrColor op); +/* Input x1 : first x coordinate to be set */ +/* x2 : last x coordinate to be set */ +/* yy : y coordinate */ +/* c : c[0..(|x2-x1|] hold the pixel data */ +/* op : Operation (GrWRITE/GrXOR/GrOR/GrAND/GrIMAGE) */ +/* */ +/* Note c[..] data must fit GrCVALUEMASK otherwise the results */ +/* are implementation dependend. */ +/* => You can't supply operation code with the pixel data! */ + + +#ifndef GRX_SKIP_INLINES +#define GrGetScanline(x1,x2,yy) \ + GrGetScanlineC(NULL,(x1),(x2),(yy)) +#endif + +/* ================================================================== */ +/* NON CLIPPING DRAWING PRIMITIVES */ +/* ================================================================== */ + +void GrPlotNC(int x,int y,GrColor c); +void GrLineNC(int x1,int y1,int x2,int y2,GrColor c); +void GrHLineNC(int x1,int x2,int y,GrColor c); +void GrVLineNC(int x,int y1,int y2,GrColor c); +void GrBoxNC(int x1,int y1,int x2,int y2,GrColor c); +void GrFilledBoxNC(int x1,int y1,int x2,int y2,GrColor c); +void GrFramedBoxNC(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c); +void GrBitBltNC(GrContext *dst,int x,int y,GrContext *src,int x1,int y1,int x2,int y2,GrColor op); + +GrColor GrPixelNC(int x,int y); +GrColor GrPixelCNC(GrContext *c,int x,int y); + +#ifndef GRX_SKIP_INLINES +#define GrPlotNC(x,y,c) ( \ + (*GrCurrentFrameDriver()->drawpixel)( \ + ((x) + GrCurrentContext()->gc_xoffset), \ + ((y) + GrCurrentContext()->gc_yoffset), \ + ((c)) \ + ) \ +) +#define GrPixelNC(x,y) ( \ + (*GrCurrentFrameDriver()->readpixel)( \ + (GrFrame *)(&GrCurrentContext()->gc_frame), \ + ((x) + GrCurrentContext()->gc_xoffset), \ + ((y) + GrCurrentContext()->gc_yoffset) \ + ) \ +) +#define GrPixelCNC(c,x,y) ( \ + (*(c)->gc_driver->readpixel)( \ + (&(c)->gc_frame), \ + ((x) + (c)->gc_xoffset), \ + ((y) + (c)->gc_yoffset) \ + ) \ +) +#endif /* GRX_SKIP_INLINES */ + +/* ================================================================== */ +/* FONTS AND TEXT PRIMITIVES */ +/* ================================================================== */ + +/* + * text drawing directions + */ +#define GR_TEXT_RIGHT 0 /* normal */ +#define GR_TEXT_DOWN 1 /* downward */ +#define GR_TEXT_LEFT 2 /* upside down, right to left */ +#define GR_TEXT_UP 3 /* upward */ +#define GR_TEXT_DEFAULT GR_TEXT_RIGHT +#define GR_TEXT_IS_VERTICAL(d) ((d) & 1) + +/* + * text alignment options + */ +#define GR_ALIGN_LEFT 0 /* X only */ +#define GR_ALIGN_TOP 0 /* Y only */ +#define GR_ALIGN_CENTER 1 /* X, Y */ +#define GR_ALIGN_RIGHT 2 /* X only */ +#define GR_ALIGN_BOTTOM 2 /* Y only */ +#define GR_ALIGN_BASELINE 3 /* Y only */ +#define GR_ALIGN_DEFAULT GR_ALIGN_LEFT + +/* + * character types in text strings + */ +#define GR_BYTE_TEXT 0 /* one byte per character */ +#define GR_WORD_TEXT 1 /* two bytes per character */ +#define GR_ATTR_TEXT 2 /* chr w/ PC style attribute byte */ + +/* + * macros to access components of various string/character types + */ +#define GR_TEXTCHR_SIZE(ty) (((ty) == GR_BYTE_TEXT) ? sizeof(char) : sizeof(short)) +#define GR_TEXTCHR_CODE(ch,ty) (((ty) == GR_WORD_TEXT) ? (unsigned short)(ch) : (unsigned char)(ch)) +#define GR_TEXTCHR_ATTR(ch,ty) (((ty) == GR_ATTR_TEXT) ? ((unsigned short)(ch) >> 8) : 0) +#define GR_TEXTSTR_CODE(pt,ty) (((ty) == GR_WORD_TEXT) ? ((unsigned short *)(pt))[0] : ((unsigned char *)(pt))[0]) +#define GR_TEXTSTR_ATTR(pt,ty) (((ty) == GR_ATTR_TEXT) ? ((unsigned char *)(pt))[1] : 0) + +/* + * text attribute macros for the GR_ATTR_TEXT type + * _GR_textattrintensevideo drives if the eighth bit is used for + * underline (false, default) or more background colors (true) + */ +extern int _GR_textattrintensevideo; + +#define GR_BUILD_ATTR(fg,bg,ul) (_GR_textattrintensevideo ? \ + (((fg) & 15) | (((bg) & 15) << 4)) \ + : \ + (((fg) & 15) | (((bg) & 7) << 4) | ((ul) ? 128 : 0)) \ + ) +#define GR_ATTR_FGCOLOR(attr) (((attr) ) & 15) +#define GR_ATTR_BGCOLOR(attr) (_GR_textattrintensevideo ? \ + (((attr) >> 4) & 15) \ + : \ + (((attr) >> 4) & 7) \ + ) +#define GR_ATTR_UNDERLINE(attr) (_GR_textattrintensevideo ? \ + (0) \ + : \ + (((attr) ) & 128) \ + ) + +/* + * OR this to the foreground color value for underlined text when + * using GR_BYTE_TEXT or GR_WORD_TEXT modes. + */ +#define GR_UNDERLINE_TEXT (GrXOR << 4) + +/* + * Font conversion flags for 'GrLoadConvertedFont'. OR them as desired. + */ +#define GR_FONTCVT_NONE 0 /* no conversion */ +#define GR_FONTCVT_SKIPCHARS 1 /* load only selected characters */ +#define GR_FONTCVT_RESIZE 2 /* resize the font */ +#define GR_FONTCVT_ITALICIZE 4 /* tilt font for "italic" look */ +#define GR_FONTCVT_BOLDIFY 8 /* make a "bold"(er) font */ +#define GR_FONTCVT_FIXIFY 16 /* convert prop. font to fixed wdt */ +#define GR_FONTCVT_PROPORTION 32 /* convert fixed font to prop. wdt */ + +/* + * font structures + */ +typedef struct _GR_fontHeader { /* font descriptor */ + char *name; /* font name */ + char *family; /* font family name */ + char proportional; /* characters have varying width */ + char scalable; /* derived from a scalable font */ + char preloaded; /* set when linked into program */ + char modified; /* "tweaked" font (resized, etc..) */ + unsigned int width; /* width (proportional=>average) */ + unsigned int height; /* font height */ + unsigned int baseline; /* baseline pixel pos (from top) */ + unsigned int ulpos; /* underline pixel pos (from top) */ + unsigned int ulheight; /* underline width */ + unsigned int minchar; /* lowest character code in font */ + unsigned int numchars; /* number of characters in font */ +} GrFontHeader; + +typedef struct _GR_fontChrInfo { /* character descriptor */ + unsigned int width; /* width of this character */ + unsigned int offset; /* offset from start of bitmap */ +} GrFontChrInfo; + +typedef struct _GR_font { /* the complete font */ + struct _GR_fontHeader h; /* the font info structure */ + char far *bitmap; /* character bitmap array */ + char far *auxmap; /* map for rotated & underline chrs */ + unsigned int minwidth; /* width of narrowest character */ + unsigned int maxwidth; /* width of widest character */ + unsigned int auxsize; /* allocated size of auxiliary map */ + unsigned int auxnext; /* next free byte in auxiliary map */ + unsigned int far *auxoffs[7]; /* offsets to completed aux chars */ + struct _GR_fontChrInfo chrinfo[1]; /* character info (not act. size) */ +} GrFont; + +extern GrFont GrFont_PC6x8; +extern GrFont GrFont_PC8x8; +extern GrFont GrFont_PC8x14; +extern GrFont GrFont_PC8x16; +#define GrDefaultFont GrFont_PC8x14 + +GrFont *GrLoadFont(char *name); +GrFont *GrLoadConvertedFont(char *name,int cvt,int w,int h,int minch,int maxch); +GrFont *GrBuildConvertedFont(const GrFont *from,int cvt,int w,int h,int minch,int maxch); + +void GrUnloadFont(GrFont *font); +void GrDumpFont(const GrFont *f,char *CsymbolName,char *fileName); +void GrDumpFnaFont(const GrFont *f, char *fileName); +void GrSetFontPath(char *path_list); + +int GrFontCharPresent(const GrFont *font,int chr); +int GrFontCharWidth(const GrFont *font,int chr); +int GrFontCharHeight(const GrFont *font,int chr); +int GrFontCharBmpRowSize(const GrFont *font,int chr); +int GrFontCharBitmapSize(const GrFont *font,int chr); +int GrFontStringWidth(const GrFont *font,void *text,int len,int type); +int GrFontStringHeight(const GrFont *font,void *text,int len,int type); +int GrProportionalTextWidth(const GrFont *font,const void *text,int len,int type); + +char far *GrBuildAuxiliaryBitmap(GrFont *font,int chr,int dir,int ul); +char far *GrFontCharBitmap(const GrFont *font,int chr); +char far *GrFontCharAuxBmp(GrFont *font,int chr,int dir,int ul); + +typedef union _GR_textColor { /* text color union */ + GrColor v; /* color value for "direct" text */ + GrColorTableP p; /* color table for attribute text */ +} GrTextColor; + +typedef struct _GR_textOption { /* text drawing option structure */ + struct _GR_font *txo_font; /* font to be used */ + union _GR_textColor txo_fgcolor; /* foreground color */ + union _GR_textColor txo_bgcolor; /* background color */ + char txo_chrtype; /* character type (see above) */ + char txo_direct; /* direction (see above) */ + char txo_xalign; /* X alignment (see above) */ + char txo_yalign; /* Y alignment (see above) */ +} GrTextOption; + +typedef struct { /* fixed font text window desc. */ + struct _GR_font *txr_font; /* font to be used */ + union _GR_textColor txr_fgcolor; /* foreground color */ + union _GR_textColor txr_bgcolor; /* background color */ + void *txr_buffer; /* pointer to text buffer */ + void *txr_backup; /* optional backup buffer */ + int txr_width; /* width of area in chars */ + int txr_height; /* height of area in chars */ + int txr_lineoffset; /* offset in buffer(s) between rows */ + int txr_xpos; /* upper left corner X coordinate */ + int txr_ypos; /* upper left corner Y coordinate */ + char txr_chrtype; /* character type (see above) */ +} GrTextRegion; + +int GrCharWidth(int chr,const GrTextOption *opt); +int GrCharHeight(int chr,const GrTextOption *opt); +void GrCharSize(int chr,const GrTextOption *opt,int *w,int *h); +int GrStringWidth(void *text,int length,const GrTextOption *opt); +int GrStringHeight(void *text,int length,const GrTextOption *opt); +void GrStringSize(void *text,int length,const GrTextOption *opt,int *w,int *h); + +void GrDrawChar(int chr,int x,int y,const GrTextOption *opt); +void GrDrawString(void *text,int length,int x,int y,const GrTextOption *opt); +void GrTextXY(int x,int y,char *text,GrColor fg,GrColor bg); + +void GrDumpChar(int chr,int col,int row,const GrTextRegion *r); +void GrDumpText(int col,int row,int wdt,int hgt,const GrTextRegion *r); +void GrDumpTextRegion(const GrTextRegion *r); + +#ifndef GRX_SKIP_INLINES +#define GrFontCharPresent(f,ch) ( \ + ((unsigned int)(ch) - (f)->h.minchar) < (f)->h.numchars \ +) +#define GrFontCharWidth(f,ch) ( \ + GrFontCharPresent(f,ch) ? \ + (int)(f)->chrinfo[(unsigned int)(ch) - (f)->h.minchar].width : \ + (f)->h.width \ +) +#define GrFontCharHeight(f,ch) ( \ + (f)->h.height \ +) +#define GrFontCharBmpRowSize(f,ch) ( \ + GrFontCharPresent(f,ch) ? \ + (((f)->chrinfo[(unsigned int)(ch) - (f)->h.minchar].width + 7) >> 3) : \ + 0 \ +) +#define GrFontCharBitmapSize(f,ch) ( \ + GrFontCharBmpRowSize(f,ch) * (f)->h.height \ +) +#define GrFontStringWidth(f,t,l,tp) ( \ + (f)->h.proportional ? \ + GrProportionalTextWidth((f),(t),(l),(tp)) : \ + (f)->h.width * (l) \ +) +#define GrFontStringHeight(f,t,l,tp) ( \ + (f)->h.height \ +) +#define GrFontCharBitmap(f,ch) ( \ + GrFontCharPresent(f,ch) ? \ + &(f)->bitmap[(f)->chrinfo[(unsigned int)(ch) - (f)->h.minchar].offset]:\ + (char far *)0 \ +) +#define GrFontCharAuxBmp(f,ch,dir,ul) ( \ + (((dir) == GR_TEXT_DEFAULT) && !(ul)) ? \ + GrFontCharBitmap(f,ch) : \ + GrBuildAuxiliaryBitmap((f),(ch),(dir),(ul)) \ +) +#define GrCharWidth(c,o) ( \ + GR_TEXT_IS_VERTICAL((o)->txo_direct) ? \ + GrFontCharHeight((o)->txo_font,GR_TEXTCHR_CODE(c,(o)->txo_chrtype)) : \ + GrFontCharWidth( (o)->txo_font,GR_TEXTCHR_CODE(c,(o)->txo_chrtype)) \ +) +#define GrCharHeight(c,o) ( \ + GR_TEXT_IS_VERTICAL((o)->txo_direct) ? \ + GrFontCharWidth( (o)->txo_font,GR_TEXTCHR_CODE(c,(o)->txo_chrtype)) : \ + GrFontCharHeight((o)->txo_font,GR_TEXTCHR_CODE(c,(o)->txo_chrtype)) \ +) +#define GrCharSize(c,o,wp,hp) do { \ + *(wp) = GrCharHeight(c,o); \ + *(hp) = GrCharWidth( c,o); \ +} while(0) +#define GrStringWidth(t,l,o) ( \ + GR_TEXT_IS_VERTICAL((o)->txo_direct) ? \ + GrFontStringHeight((o)->txo_font,(t),(l),(o)->txo_chrtype) : \ + GrFontStringWidth( (o)->txo_font,(t),(l),(o)->txo_chrtype) \ +) +#define GrStringHeight(t,l,o) ( \ + GR_TEXT_IS_VERTICAL((o)->txo_direct) ? \ + GrFontStringWidth( (o)->txo_font,(t),(l),(o)->txo_chrtype) : \ + GrFontStringHeight((o)->txo_font,(t),(l),(o)->txo_chrtype) \ +) +#define GrStringSize(t,l,o,wp,hp) do { \ + *(wp) = GrStringWidth( t,l,o); \ + *(hp) = GrStringHeight(t,l,o); \ +} while(0) +#endif /* GRX_SKIP_INLINES */ + +/* ================================================================== */ +/* THICK AND DASHED LINE DRAWING PRIMITIVES */ +/* ================================================================== */ + +/* + * custom line option structure + * zero or one dash pattern length means the line is continuous + * the dash pattern always begins with a drawn section + */ +typedef struct { + GrColor lno_color; /* color used to draw line */ + int lno_width; /* width of the line */ + int lno_pattlen; /* length of the dash pattern */ + unsigned char *lno_dashpat; /* draw/nodraw pattern */ +} GrLineOption; + +void GrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrCustomCircle(int xc,int yc,int r,const GrLineOption *o); +void GrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o); +void GrCustomCircleArc(int xc,int yc,int r,int start,int end,int style,const GrLineOption *o); +void GrCustomEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,const GrLineOption *o); +void GrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o); +void GrCustomPolygon(int numpts,int points[][2],const GrLineOption *o); + +/* ================================================================== */ +/* PATTERNED DRAWING AND FILLING PRIMITIVES */ +/* ================================================================== */ + +/* + * BITMAP: a mode independent way to specify a fill pattern of two + * colors. It is always 8 pixels wide (1 byte per scan line), its + * height is user-defined. SET THE TYPE FLAG TO ZERO!!! + */ +typedef struct _GR_bitmap { + int bmp_ispixmap; /* type flag for pattern union */ + int bmp_height; /* bitmap height */ + char *bmp_data; /* pointer to the bit pattern */ + GrColor bmp_fgcolor; /* foreground color for fill */ + GrColor bmp_bgcolor; /* background color for fill */ + int bmp_memflags; /* set if dynamically allocated */ +} GrBitmap; + +/* + * PIXMAP: a fill pattern stored in a layout identical to the video RAM + * for filling using 'bitblt'-s. It is mode dependent, typically one + * of the library functions is used to build it. KEEP THE TYPE FLAG + * NONZERO!!! + */ +typedef struct _GR_pixmap { + int pxp_ispixmap; /* type flag for pattern union */ + int pxp_width; /* pixmap width (in pixels) */ + int pxp_height; /* pixmap height (in pixels) */ + GrColor pxp_oper; /* bitblt mode (SET, OR, XOR, AND, IMAGE) */ + struct _GR_frame pxp_source; /* source context for fill */ +} GrPixmap; + +/* + * Fill pattern union -- can either be a bitmap or a pixmap + */ +typedef union _GR_pattern { + int gp_ispixmap; /* nonzero for pixmaps */ + GrBitmap gp_bitmap; /* fill bitmap */ + GrPixmap gp_pixmap; /* fill pixmap */ +} GrPattern; + +#define gp_bmp_data gp_bitmap.bmp_data +#define gp_bmp_height gp_bitmap.bmp_height +#define gp_bmp_fgcolor gp_bitmap.bmp_fgcolor +#define gp_bmp_bgcolor gp_bitmap.bmp_bgcolor + +#define gp_pxp_width gp_pixmap.pxp_width +#define gp_pxp_height gp_pixmap.pxp_height +#define gp_pxp_oper gp_pixmap.pxp_oper +#define gp_pxp_source gp_pixmap.pxp_source + +/* + * Draw pattern for line drawings -- specifies both the: + * (1) fill pattern, and the + * (2) custom line drawing option + */ +typedef struct { + GrPattern *lnp_pattern; /* fill pattern */ + GrLineOption *lnp_option; /* width + dash pattern */ +} GrLinePattern; + +GrPattern *GrBuildPixmap(const char *pixels,int w,int h,const GrColorTableP colors); +GrPattern *GrBuildPixmapFromBits(const char *bits,int w,int h,GrColor fgc,GrColor bgc); +GrPattern *GrConvertToPixmap(GrContext *src); + +void GrDestroyPattern(GrPattern *p); + +void GrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp); +void GrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp); +void GrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp); +void GrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp); +void GrPatternedCircleArc(int xc,int yc,int r,int start,int end,int style,GrLinePattern *lp); +void GrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrLinePattern *lp); +void GrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp); +void GrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp); + +void GrPatternFilledPlot(int x,int y,GrPattern *p); +void GrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p); +void GrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p); +void GrPatternFilledCircle(int xc,int yc,int r,GrPattern *p); +void GrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p); +void GrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrPattern *p); +void GrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrPattern *p); +void GrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p); +void GrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p); +void GrPatternFloodFill(int x, int y, GrColor border, GrPattern *p); + +void GrPatternDrawChar(int chr,int x,int y,const GrTextOption *opt,GrPattern *p); +void GrPatternDrawString(void *text,int length,int x,int y,const GrTextOption *opt,GrPattern *p); +void GrPatternDrawStringExt(void *text,int length,int x,int y,const GrTextOption *opt,GrPattern *p); + +/* ================================================================== */ +/* IMAGE MANIPULATION */ +/* ================================================================== */ + +/* + * by Michal Stencl Copyright (c) 1998 for GRX + * - [stenclpmd@ba.telecom.sk] + */ + +#ifndef GrImage +#define GrImage GrPixmap +#endif + +/* Flags for GrImageInverse() */ + +#define GR_IMAGE_INVERSE_LR 0x01 /* inverse left right */ +#define GR_IMAGE_INVERSE_TD 0x02 /* inverse top down */ + +GrImage *GrImageBuild(const char *pixels,int w,int h,const GrColorTableP colors); +void GrImageDestroy(GrImage *i); +void GrImageDisplay(int x,int y, GrImage *i); +void GrImageDisplayExt(int x1,int y1,int x2,int y2, GrImage *i); +void GrImageFilledBoxAlign(int xo,int yo,int x1,int y1,int x2,int y2,GrImage *p); +void GrImageHLineAlign(int xo,int yo,int x,int y,int width,GrImage *p); +void GrImagePlotAlign(int xo,int yo,int x,int y,GrImage *p); + +GrImage *GrImageInverse(GrImage *p,int flag); +GrImage *GrImageStretch(GrImage *p,int nwidth,int nheight); + +GrImage *GrImageFromPattern(GrPattern *p); +GrImage *GrImageFromContext(GrContext *c); +GrImage *GrImageBuildUsedAsPattern(const char *pixels,int w,int h,const GrColorTableP colors); + +GrPattern *GrPatternFromImage(GrImage *p); + + +#ifndef GRX_SKIP_INLINES +#define GrImageFromPattern(p) \ + (((p) && (p)->gp_ispixmap) ? (&(p)->gp_pixmap) : NULL) +#define GrImageFromContext(c) \ + (GrImage *)GrConvertToPixmap(c) +#define GrPatternFromImage(p) \ + (GrPattern *)(p) +#define GrImageBuildUsedAsPattern(pixels,w,h,colors) \ + (GrImage *)GrBuildPixmap(pixels,w,h,colors); +#define GrImageDestroy(i) \ + GrDestroyPattern((GrPattern *)(i)); +#endif + +/* ================================================================== */ +/* DRAWING IN USER WINDOW COORDINATES */ +/* ================================================================== */ + +void GrSetUserWindow(int x1,int y1,int x2,int y2); +void GrGetUserWindow(int *x1,int *y1,int *x2,int *y2); +void GrGetScreenCoord(int *x,int *y); +void GrGetUserCoord(int *x,int *y); + +void GrUsrPlot(int x,int y,GrColor c); +void GrUsrLine(int x1,int y1,int x2,int y2,GrColor c); +void GrUsrHLine(int x1,int x2,int y,GrColor c); +void GrUsrVLine(int x,int y1,int y2,GrColor c); +void GrUsrBox(int x1,int y1,int x2,int y2,GrColor c); +void GrUsrFilledBox(int x1,int y1,int x2,int y2,GrColor c); +void GrUsrFramedBox(int x1,int y1,int x2,int y2,int wdt,GrFBoxColors *c); +void GrUsrCircle(int xc,int yc,int r,GrColor c); +void GrUsrEllipse(int xc,int yc,int xa,int ya,GrColor c); +void GrUsrCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c); +void GrUsrEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrColor c); +void GrUsrFilledCircle(int xc,int yc,int r,GrColor c); +void GrUsrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c); +void GrUsrFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c); +void GrUsrFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrColor c); +void GrUsrPolyLine(int numpts,int points[][2],GrColor c); +void GrUsrPolygon(int numpts,int points[][2],GrColor c); +void GrUsrFilledConvexPolygon(int numpts,int points[][2],GrColor c); +void GrUsrFilledPolygon(int numpts,int points[][2],GrColor c); +void GrUsrFloodFill(int x, int y, GrColor border, GrColor c); + +GrColor GrUsrPixel(int x,int y); +GrColor GrUsrPixelC(GrContext *c,int x,int y); + +void GrUsrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrUsrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o); +void GrUsrCustomCircle(int xc,int yc,int r,const GrLineOption *o); +void GrUsrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o); +void GrUsrCustomCircleArc(int xc,int yc,int r,int start,int end,int style,const GrLineOption *o); +void GrUsrCustomEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,const GrLineOption *o); +void GrUsrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o); +void GrUsrCustomPolygon(int numpts,int points[][2],const GrLineOption *o); + +void GrUsrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp); +void GrUsrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp); +void GrUsrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp); +void GrUsrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp); +void GrUsrPatternedCircleArc(int xc,int yc,int r,int start,int end,int style,GrLinePattern *lp); +void GrUsrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrLinePattern *lp); +void GrUsrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp); +void GrUsrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp); + +void GrUsrPatternFilledPlot(int x,int y,GrPattern *p); +void GrUsrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p); +void GrUsrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p); +void GrUsrPatternFilledCircle(int xc,int yc,int r,GrPattern *p); +void GrUsrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p); +void GrUsrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrPattern *p); +void GrUsrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrPattern *p); +void GrUsrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p); +void GrUsrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p); +void GrUsrPatternFloodFill(int x, int y, GrColor border, GrPattern *p); + +void GrUsrDrawChar(int chr,int x,int y,const GrTextOption *opt); +void GrUsrDrawString(char *text,int length,int x,int y,const GrTextOption *opt); +void GrUsrTextXY(int x,int y,char *text,GrColor fg,GrColor bg); + +/* ================================================================== */ +/* GRAPHICS CURSOR UTILITIES */ +/* ================================================================== */ + +typedef struct _GR_cursor { + struct _GR_context work; /* work areas (4) */ + int xcord,ycord; /* cursor position on screen */ + int xsize,ysize; /* cursor size */ + int xoffs,yoffs; /* LU corner to hot point offset */ + int xwork,ywork; /* save/work area sizes */ + int xwpos,ywpos; /* save/work area position on screen */ + int displayed; /* set if displayed */ +} GrCursor; + +GrCursor *GrBuildCursor(char far *pixels,int pitch,int w,int h,int xo,int yo,const GrColorTableP c); +void GrDestroyCursor(GrCursor *cursor); +void GrDisplayCursor(GrCursor *cursor); +void GrEraseCursor(GrCursor *cursor); +void GrMoveCursor(GrCursor *cursor,int x,int y); + +/* ================================================================== */ +/* MOUSE AND KEYBOARD INPUT UTILITIES */ +/* ================================================================== */ + +#define GR_M_MOTION 0x001 /* mouse event flag bits */ +#define GR_M_LEFT_DOWN 0x002 +#define GR_M_LEFT_UP 0x004 +#define GR_M_RIGHT_DOWN 0x008 +#define GR_M_RIGHT_UP 0x010 +#define GR_M_MIDDLE_DOWN 0x020 +#define GR_M_MIDDLE_UP 0x040 +#define GR_M_P4_DOWN 0x400 +#define GR_M_P4_UP 0x800 +#define GR_M_P5_DOWN 0x2000 +#define GR_M_P5_UP 0x4000 +#define GR_M_BUTTON_DOWN (GR_M_LEFT_DOWN | GR_M_MIDDLE_DOWN | GR_M_RIGHT_DOWN | GR_M_P4_DOWN | GR_M_P5_DOWN) +#define GR_M_BUTTON_UP (GR_M_LEFT_UP | GR_M_MIDDLE_UP | GR_M_RIGHT_UP | GR_M_P4_UP | GR_M_P5_UP) +#define GR_M_BUTTON_CHANGE (GR_M_BUTTON_UP | GR_M_BUTTON_DOWN ) + +#define GR_M_LEFT 0x01 /* mouse button index bits */ +#define GR_M_RIGHT 0x02 +#define GR_M_MIDDLE 0x04 +#define GR_M_P4 0x08 +#define GR_M_P5 0x10 + +#define GR_M_KEYPRESS 0x080 /* other event flag bits */ +#define GR_M_POLL 0x100 +#define GR_M_NOPAINT 0x200 +#define GR_COMMAND 0x1000 +#define GR_M_EVENT (GR_M_MOTION | GR_M_KEYPRESS | GR_M_BUTTON_CHANGE | GR_COMMAND) + +#define GR_KB_RIGHTSHIFT 0x01 /* Keybd states: right shift key depressed */ +#define GR_KB_LEFTSHIFT 0x02 /* left shift key depressed */ +#define GR_KB_CTRL 0x04 /* CTRL depressed */ +#define GR_KB_ALT 0x08 /* ALT depressed */ +#define GR_KB_SCROLLOCK 0x10 /* SCROLL LOCK active */ +#define GR_KB_NUMLOCK 0x20 /* NUM LOCK active */ +#define GR_KB_CAPSLOCK 0x40 /* CAPS LOCK active */ +#define GR_KB_INSERT 0x80 /* INSERT state active */ +#define GR_KB_SHIFT (GR_KB_LEFTSHIFT | GR_KB_RIGHTSHIFT) + +#define GR_M_CUR_NORMAL 0 /* MOUSE CURSOR modes: just the cursor */ +#define GR_M_CUR_RUBBER 1 /* rectangular rubber band (XOR-d to the screen) */ +#define GR_M_CUR_LINE 2 /* line attached to the cursor */ +#define GR_M_CUR_BOX 3 /* rectangular box dragged by the cursor */ + +#define GR_M_QUEUE_SIZE 128 /* default queue size */ + +typedef struct _GR_mouseEvent { /* mouse event buffer structure */ + int flags; /* event type flags (see above) */ + int x,y; /* mouse coordinates */ + int buttons; /* mouse button state */ + int key; /* key code from keyboard */ + int kbstat; /* keybd status (ALT, CTRL, etc..) */ + long dtime; /* time since last event (msec) */ +} GrMouseEvent; + +/* + * mouse status information + */ +extern const struct _GR_mouseInfo { + int (*block)(GrContext*,int,int,int,int); /* mouse block function */ + void (*unblock)(int flags); /* mouse unblock function */ + void (*uninit)(void); /* mouse cleanupt function */ + struct _GR_cursor *cursor; /* the mouse cursor */ + struct _GR_mouseEvent *queue; /* queue of pending input events */ + int msstatus; /* -1:missing, 0:unknown, 1:present, 2:initted */ + int displayed; /* cursor is (generally) drawn */ + int blockflag; /* cursor temp. erase/block flag */ + int docheck; /* need to check before gr. op. to screen */ + int cursmode; /* mouse cursor draw mode */ + int x1,y1,x2,y2; /* auxiliary params for some cursor draw modes */ + GrColor curscolor; /* color for some cursor draw modes */ + int owncursor; /* auto generated cursor */ + int xpos,ypos; /* current mouse position */ + int xmin,xmax; /* mouse movement X coordinate limits */ + int ymin,ymax; /* mouse movement Y coordinate limits */ + int spmult,spdiv; /* mouse cursor speed factors */ + int thresh,accel; /* mouse acceleration parameters */ + int moved; /* mouse cursor movement flag */ + int qsize; /* max size of the queue */ + int qlength; /* current # of items in the queue */ + int qread; /* read pointer for the queue */ + int qwrite; /* write pointer for the queue */ +} * const GrMouseInfo; + +int GrMouseDetect(void); +void GrMouseEventMode(int dummy); +void GrMouseInit(void); +void GrMouseInitN(int queue_size); +void GrMouseUnInit(void); +void GrMouseSetSpeed(int spmult,int spdiv); +void GrMouseSetAccel(int thresh,int accel); +void GrMouseSetLimits(int x1,int y1,int x2,int y2); +void GrMouseGetLimits(int *x1,int *y1,int *x2,int *y2); +void GrMouseWarp(int x,int y); +void GrMouseEventEnable(int enable_kb,int enable_ms); +void GrMouseGetEvent(int flags,GrMouseEvent *event); + +void GrMouseGetEventT(int flags,GrMouseEvent *event,long timout_msecs); +/* Note: +** event->dtime is only valid if any event occured (event->flags !=0) +** otherwise it's set as -1. +** Additionally event timing is now real world time. (X11 && Linux +** used clock(), user process time, up to 2.28f) +*/ + +int GrMousePendingEvent(void); + +GrCursor *GrMouseGetCursor(void); +void GrMouseSetCursor(GrCursor *cursor); +void GrMouseSetColors(GrColor fg,GrColor bg); +void GrMouseSetCursorMode(int mode,...); +void GrMouseDisplayCursor(void); +void GrMouseEraseCursor(void); +void GrMouseUpdateCursor(void); +int GrMouseCursorIsDisplayed(void); + +int GrMouseBlock(GrContext *c,int x1,int y1,int x2,int y2); +void GrMouseUnBlock(int return_value_from_GrMouseBlock); + +#if 0 +/* !! old style (before grx v2.26) keyboard interface !! + !! old functions still linkable but for compatibility !! + !! across platforms and with future versions of GRX !! + !! one use functions from grkeys.h !! */ +#ifndef __MSDOS__ +int kbhit(void); +int getch(void); +#endif +#ifndef __DJGPP__ +int getkey(void); +int getxkey(void); +#endif +int getkbstat(void); +#endif +/* Why this ??? +#ifdef __WATCOMC__ +int getxkey(void); +#endif +*/ + +#ifndef GRX_SKIP_INLINES +#define GrMouseEventMode(x) /* nothing! */ +#define GrMouseGetCursor() (GrMouseInfo->cursor) +#define GrMouseCursorIsDisplayed() (GrMouseInfo->displayed) +#define GrMouseInit() GrMouseInitN(GR_M_QUEUE_SIZE); +#define GrMouseGetEvent(f,ev) GrMouseGetEventT((f),(ev),(-1L)); +#define GrMousePendingEvent() ( \ + GrMouseUpdateCursor(), \ + (GrMouseInfo->qlength > 0) \ +) +#define GrMouseUnInit() do { \ + if(GrMouseInfo->uninit) { \ + (*GrMouseInfo->uninit)(); \ + } \ +} while(0) +#define GrMouseGetLimits(x1p,y1p,x2p,y2p) do { \ + *(x1p) = GrMouseInfo->xmin; *(y1p) = GrMouseInfo->ymin; \ + *(x2p) = GrMouseInfo->xmax; *(y2p) = GrMouseInfo->ymax; \ +} while(0) +#define GrMouseBlock(c,x1,y1,x2,y2) ( \ + (((c) ? (const GrContext*)(c) : GrCurrentContext())->gc_onscreen && \ + (GrMouseInfo->docheck)) ? \ + (*GrMouseInfo->block)((c),(x1),(y1),(x2),(y2)) : \ + 0 \ +) +#define GrMouseUnBlock(f) do { \ + if((f) && GrMouseInfo->displayed) { \ + (*GrMouseInfo->unblock)((f)); \ + } \ +} while(0) +#endif /* GRX_SKIP_INLINES */ + +/* ================================================================== */ +/* PNM FUNCTIONS */ +/* ================================================================== */ + +/* + * The PNM formats, grx support load/save of + * binaries formats (4,5,6) only + */ + +#define PLAINPBMFORMAT 1 +#define PLAINPGMFORMAT 2 +#define PLAINPPMFORMAT 3 +#define PBMFORMAT 4 +#define PGMFORMAT 5 +#define PPMFORMAT 6 + +/* The PNM functions */ + +int GrSaveContextToPbm( GrContext *grc, char *pbmfn, char *docn ); +int GrSaveContextToPgm( GrContext *grc, char *pgmfn, char *docn ); +int GrSaveContextToPpm( GrContext *grc, char *ppmfn, char *docn ); +int GrLoadContextFromPnm( GrContext *grc, char *pnmfn ); +int GrQueryPnm( char *pnmfn, int *width, int *height, int *maxval ); +int GrLoadContextFromPnmBuffer( GrContext *grc, const char *buffer ); +int GrQueryPnmBuffer( const char *buffer, int *width, int *height, int *maxval ); + +/* ================================================================== */ +/* PNG FUNCTIONS */ +/* these functions may not be installed or available on all system */ +/* ================================================================== */ + +int GrPngSupport( void ); +int GrSaveContextToPng( GrContext *grc, char *pngfn ); +int GrLoadContextFromPng( GrContext *grc, char *pngfn, int use_alpha ); +int GrQueryPng( char *pngfn, int *width, int *height ); + +/* ================================================================== */ +/* JPEG FUNCTIONS */ +/* these functions may not be installed or available on all system */ +/* ================================================================== */ + +int GrJpegSupport( void ); +int GrLoadContextFromJpeg( GrContext *grc, char *jpegfn, int scale ); +int GrQueryJpeg( char *jpegfn, int *width, int *height ); +int GrSaveContextToJpeg( GrContext *grc, char *jpegfn, int quality ); +int GrSaveContextToGrayJpeg( GrContext *grc, char *jpegfn, int quality ); + +/* ================================================================== */ +/* MISCELLANEOUS UTILITIY FUNCTIONS */ +/* ================================================================== */ + +void GrResizeGrayMap(unsigned char far *map,int pitch,int ow,int oh,int nw,int nh); +int GrMatchString(const char *pattern,const char *strg); +void GrSetWindowTitle(char *title); +void GrSleep(int msec); +void GrFlush(void); +long GrMsecTime(void); + +/* ================================================================== */ +/* TIFF ADDON FUNCTIONS */ +/* these functions may not be installed or available on all system */ +/* ================================================================== */ + +/* +** SaveContextToTiff - Dump a context in a TIFF file +** +** Arguments: +** cxt: Context to be saved (NULL -> use current context) +** tiffn: Name of tiff file +** compr: Compression method (see tiff.h), 0: automatic selection +** docn: string saved in the tiff file (DOCUMENTNAME tag) +** +** Returns 0 on success +** -1 on error +** +** requires tifflib by Sam Leffler (sam@engr.sgi.com) +** available at ftp://ftp.sgi.com/graphics/tiff +*/ +int SaveContextToTiff(GrContext *cxt, char *tiffn, unsigned compr, char *docn); + +#ifdef __cplusplus +} +#endif +#endif /* whole file */ diff --git a/thirdparty/grx249/include/grxkeys.h b/thirdparty/grx249/include/grxkeys.h new file mode 100644 index 0000000..c0213f3 --- /dev/null +++ b/thirdparty/grx249/include/grxkeys.h @@ -0,0 +1,363 @@ +/** + ** grxkeys.h ---- platform independent key definitions + ** + ** Copyright (c) 1997 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __GRKEYS_H_INCLUDED__ +#define __GRKEYS_H_INCLUDED__ + +/* +** NOTES - some keys may not be available under all systems +** - key values will be differ on different systems +*/ + +#ifndef __GRX20_H_INCLUDED__ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* all keycodes should fit into 16 bit unsigned */ +typedef unsigned short GrKeyType; + +/* no key available */ +#define GrKey_NoKey 0x0000 + +/* key typed but code outside 1..GrKey_LastDefinedKeycode */ +#define GrKey_OutsideValidRange 0x0100 + +/* standard ASCII key codes */ +#define GrKey_Control_A 0x0001 +#define GrKey_Control_B 0x0002 +#define GrKey_Control_C 0x0003 +#define GrKey_Control_D 0x0004 +#define GrKey_Control_E 0x0005 +#define GrKey_Control_F 0x0006 +#define GrKey_Control_G 0x0007 +#define GrKey_Control_H 0x0008 +#define GrKey_Control_I 0x0009 +#define GrKey_Control_J 0x000a +#define GrKey_Control_K 0x000b +#define GrKey_Control_L 0x000c +#define GrKey_Control_M 0x000d +#define GrKey_Control_N 0x000e +#define GrKey_Control_O 0x000f +#define GrKey_Control_P 0x0010 +#define GrKey_Control_Q 0x0011 +#define GrKey_Control_R 0x0012 +#define GrKey_Control_S 0x0013 +#define GrKey_Control_T 0x0014 +#define GrKey_Control_U 0x0015 +#define GrKey_Control_V 0x0016 +#define GrKey_Control_W 0x0017 +#define GrKey_Control_X 0x0018 +#define GrKey_Control_Y 0x0019 +#define GrKey_Control_Z 0x001a +#define GrKey_Control_LBracket 0x001b +#define GrKey_Control_BackSlash 0x001c +#define GrKey_Control_RBracket 0x001d +#define GrKey_Control_Caret 0x001e +#define GrKey_Control_Underscore 0x001f +#define GrKey_Space 0x0020 +#define GrKey_ExclamationPoint 0x0021 +#define GrKey_DoubleQuote 0x0022 +#define GrKey_Hash 0x0023 +#define GrKey_Dollar 0x0024 +#define GrKey_Percent 0x0025 +#define GrKey_Ampersand 0x0026 +#define GrKey_Quote 0x0027 +#define GrKey_LParen 0x0028 +#define GrKey_RParen 0x0029 +#define GrKey_Star 0x002a +#define GrKey_Plus 0x002b +#define GrKey_Comma 0x002c +#define GrKey_Dash 0x002d +#define GrKey_Period 0x002e +#define GrKey_Slash 0x002f +#define GrKey_0 0x0030 +#define GrKey_1 0x0031 +#define GrKey_2 0x0032 +#define GrKey_3 0x0033 +#define GrKey_4 0x0034 +#define GrKey_5 0x0035 +#define GrKey_6 0x0036 +#define GrKey_7 0x0037 +#define GrKey_8 0x0038 +#define GrKey_9 0x0039 +#define GrKey_Colon 0x003a +#define GrKey_SemiColon 0x003b +#define GrKey_LAngle 0x003c +#define GrKey_Equals 0x003d +#define GrKey_RAngle 0x003e +#define GrKey_QuestionMark 0x003f +#define GrKey_At 0x0040 +#define GrKey_A 0x0041 +#define GrKey_B 0x0042 +#define GrKey_C 0x0043 +#define GrKey_D 0x0044 +#define GrKey_E 0x0045 +#define GrKey_F 0x0046 +#define GrKey_G 0x0047 +#define GrKey_H 0x0048 +#define GrKey_I 0x0049 +#define GrKey_J 0x004a +#define GrKey_K 0x004b +#define GrKey_L 0x004c +#define GrKey_M 0x004d +#define GrKey_N 0x004e +#define GrKey_O 0x004f +#define GrKey_P 0x0050 +#define GrKey_Q 0x0051 +#define GrKey_R 0x0052 +#define GrKey_S 0x0053 +#define GrKey_T 0x0054 +#define GrKey_U 0x0055 +#define GrKey_V 0x0056 +#define GrKey_W 0x0057 +#define GrKey_X 0x0058 +#define GrKey_Y 0x0059 +#define GrKey_Z 0x005a +#define GrKey_LBracket 0x005b +#define GrKey_BackSlash 0x005c +#define GrKey_RBracket 0x005d +#define GrKey_Caret 0x005e +#define GrKey_UnderScore 0x005f +#define GrKey_BackQuote 0x0060 +#define GrKey_a 0x0061 +#define GrKey_b 0x0062 +#define GrKey_c 0x0063 +#define GrKey_d 0x0064 +#define GrKey_e 0x0065 +#define GrKey_f 0x0066 +#define GrKey_g 0x0067 +#define GrKey_h 0x0068 +#define GrKey_i 0x0069 +#define GrKey_j 0x006a +#define GrKey_k 0x006b +#define GrKey_l 0x006c +#define GrKey_m 0x006d +#define GrKey_n 0x006e +#define GrKey_o 0x006f +#define GrKey_p 0x0070 +#define GrKey_q 0x0071 +#define GrKey_r 0x0072 +#define GrKey_s 0x0073 +#define GrKey_t 0x0074 +#define GrKey_u 0x0075 +#define GrKey_v 0x0076 +#define GrKey_w 0x0077 +#define GrKey_x 0x0078 +#define GrKey_y 0x0079 +#define GrKey_z 0x007a +#define GrKey_LBrace 0x007b +#define GrKey_Pipe 0x007c +#define GrKey_RBrace 0x007d +#define GrKey_Tilde 0x007e +#define GrKey_Control_Backspace 0x007f + +/* extended key codes as defined in DJGPP */ +#define GrKey_Alt_Escape 0x0101 +#define GrKey_Control_At 0x0103 +#define GrKey_Alt_Backspace 0x010e +#define GrKey_BackTab 0x010f +#define GrKey_Alt_Q 0x0110 +#define GrKey_Alt_W 0x0111 +#define GrKey_Alt_E 0x0112 +#define GrKey_Alt_R 0x0113 +#define GrKey_Alt_T 0x0114 +#define GrKey_Alt_Y 0x0115 +#define GrKey_Alt_U 0x0116 +#define GrKey_Alt_I 0x0117 +#define GrKey_Alt_O 0x0118 +#define GrKey_Alt_P 0x0119 +#define GrKey_Alt_LBracket 0x011a +#define GrKey_Alt_RBracket 0x011b +#define GrKey_Alt_Return 0x011c +#define GrKey_Alt_A 0x011e +#define GrKey_Alt_S 0x011f +#define GrKey_Alt_D 0x0120 +#define GrKey_Alt_F 0x0121 +#define GrKey_Alt_G 0x0122 +#define GrKey_Alt_H 0x0123 +#define GrKey_Alt_J 0x0124 +#define GrKey_Alt_K 0x0125 +#define GrKey_Alt_L 0x0126 +#define GrKey_Alt_Semicolon 0x0127 +#define GrKey_Alt_Quote 0x0128 +#define GrKey_Alt_Backquote 0x0129 +#define GrKey_Alt_Backslash 0x012b +#define GrKey_Alt_Z 0x012c +#define GrKey_Alt_X 0x012d +#define GrKey_Alt_C 0x012e +#define GrKey_Alt_V 0x012f +#define GrKey_Alt_B 0x0130 +#define GrKey_Alt_N 0x0131 +#define GrKey_Alt_M 0x0132 +#define GrKey_Alt_Comma 0x0133 +#define GrKey_Alt_Period 0x0134 +#define GrKey_Alt_Slash 0x0135 +#define GrKey_Alt_KPStar 0x0137 +#define GrKey_F1 0x013b +#define GrKey_F2 0x013c +#define GrKey_F3 0x013d +#define GrKey_F4 0x013e +#define GrKey_F5 0x013f +#define GrKey_F6 0x0140 +#define GrKey_F7 0x0141 +#define GrKey_F8 0x0142 +#define GrKey_F9 0x0143 +#define GrKey_F10 0x0144 +#define GrKey_Home 0x0147 +#define GrKey_Up 0x0148 +#define GrKey_PageUp 0x0149 +#define GrKey_Alt_KPMinus 0x014a +#define GrKey_Left 0x014b +#define GrKey_Center 0x014c +#define GrKey_Right 0x014d +#define GrKey_Alt_KPPlus 0x014e +#define GrKey_End 0x014f +#define GrKey_Down 0x0150 +#define GrKey_PageDown 0x0151 +#define GrKey_Insert 0x0152 +#define GrKey_Delete 0x0153 +#define GrKey_Shift_F1 0x0154 +#define GrKey_Shift_F2 0x0155 +#define GrKey_Shift_F3 0x0156 +#define GrKey_Shift_F4 0x0157 +#define GrKey_Shift_F5 0x0158 +#define GrKey_Shift_F6 0x0159 +#define GrKey_Shift_F7 0x015a +#define GrKey_Shift_F8 0x015b +#define GrKey_Shift_F9 0x015c +#define GrKey_Shift_F10 0x015d +#define GrKey_Control_F1 0x015e +#define GrKey_Control_F2 0x015f +#define GrKey_Control_F3 0x0160 +#define GrKey_Control_F4 0x0161 +#define GrKey_Control_F5 0x0162 +#define GrKey_Control_F6 0x0163 +#define GrKey_Control_F7 0x0164 +#define GrKey_Control_F8 0x0165 +#define GrKey_Control_F9 0x0166 +#define GrKey_Control_F10 0x0167 +#define GrKey_Alt_F1 0x0168 +#define GrKey_Alt_F2 0x0169 +#define GrKey_Alt_F3 0x016a +#define GrKey_Alt_F4 0x016b +#define GrKey_Alt_F5 0x016c +#define GrKey_Alt_F6 0x016d +#define GrKey_Alt_F7 0x016e +#define GrKey_Alt_F8 0x016f +#define GrKey_Alt_F9 0x0170 +#define GrKey_Alt_F10 0x0171 +#define GrKey_Control_Print 0x0172 +#define GrKey_Control_Left 0x0173 +#define GrKey_Control_Right 0x0174 +#define GrKey_Control_End 0x0175 +#define GrKey_Control_PageDown 0x0176 +#define GrKey_Control_Home 0x0177 +#define GrKey_Alt_1 0x0178 +#define GrKey_Alt_2 0x0179 +#define GrKey_Alt_3 0x017a +#define GrKey_Alt_4 0x017b +#define GrKey_Alt_5 0x017c +#define GrKey_Alt_6 0x017d +#define GrKey_Alt_7 0x017e +#define GrKey_Alt_8 0x017f +#define GrKey_Alt_9 0x0180 +#define GrKey_Alt_0 0x0181 +#define GrKey_Alt_Dash 0x0182 +#define GrKey_Alt_Equals 0x0183 +#define GrKey_Control_PageUp 0x0184 +#define GrKey_F11 0x0185 +#define GrKey_F12 0x0186 +#define GrKey_Shift_F11 0x0187 +#define GrKey_Shift_F12 0x0188 +#define GrKey_Control_F11 0x0189 +#define GrKey_Control_F12 0x018a +#define GrKey_Alt_F11 0x018b +#define GrKey_Alt_F12 0x018c +#define GrKey_Control_Up 0x018d +#define GrKey_Control_KPDash 0x018e +#define GrKey_Control_Center 0x018f +#define GrKey_Control_KPPlus 0x0190 +#define GrKey_Control_Down 0x0191 +#define GrKey_Control_Insert 0x0192 +#define GrKey_Control_Delete 0x0193 +#define GrKey_Control_Tab 0x0194 +#define GrKey_Control_KPSlash 0x0195 +#define GrKey_Control_KPStar 0x0196 +#define GrKey_Alt_KPSlash 0x01a4 +#define GrKey_Alt_Tab 0x01a5 +#define GrKey_Alt_Enter 0x01a6 + +/* some additional codes not in DJGPP */ +#define GrKey_Alt_LAngle 0x01b0 +#define GrKey_Alt_RAngle 0x01b1 +#define GrKey_Alt_At 0x01b2 +#define GrKey_Alt_LBrace 0x01b3 +#define GrKey_Alt_Pipe 0x01b4 +#define GrKey_Alt_RBrace 0x01b5 +#define GrKey_Print 0x01b6 +#define GrKey_Shift_Insert 0x01b7 +#define GrKey_Shift_Home 0x01b8 +#define GrKey_Shift_End 0x01b9 +#define GrKey_Shift_PageUp 0x01ba +#define GrKey_Shift_PageDown 0x01bb +#define GrKey_Alt_Up 0x01bc +#define GrKey_Alt_Left 0x01bd +#define GrKey_Alt_Center 0x01be +#define GrKey_Alt_Right 0x01c0 +#define GrKey_Alt_Down 0x01c1 +#define GrKey_Alt_Insert 0x01c2 +#define GrKey_Alt_Delete 0x01c3 +#define GrKey_Alt_Home 0x01c4 +#define GrKey_Alt_End 0x01c5 +#define GrKey_Alt_PageUp 0x01c6 +#define GrKey_Alt_PageDown 0x01c7 +#define GrKey_Shift_Up 0x01c8 +#define GrKey_Shift_Down 0x01c9 +#define GrKey_Shift_Right 0x01ca +#define GrKey_Shift_Left 0x01cb + +/* this may be usefull for table allocation ... */ +#define GrKey_LastDefinedKeycode GrKey_Shift_Left + +/* some well known synomyms */ +#define GrKey_BackSpace GrKey_Control_H +#define GrKey_Tab GrKey_Control_I +#define GrKey_LineFeed GrKey_Control_J +#define GrKey_Escape GrKey_Control_LBracket +#define GrKey_Return GrKey_Control_M + +/* +** new functions to replace the old style +** kbhit / getch / getkey / getxkey / getkbstat +** keyboard interface +*/ +extern int GrKeyPressed(void); +extern GrKeyType GrKeyRead(void); +extern int GrKeyStat(void); + +/* some compatibility interface here ?? */ +/* eg., #define kbhit() GrKeyPressed() ?? */ + +#ifdef __cplusplus +} +#endif + +#endif /* whole file */ diff --git a/thirdparty/grx249/include/libbcc.h b/thirdparty/grx249/include/libbcc.h new file mode 100644 index 0000000..235c65a --- /dev/null +++ b/thirdparty/grx249/include/libbcc.h @@ -0,0 +1,865 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __LIBBCC_H +#define __LIBBCC_H + +/* Version number, read as + 0x20a v2.0 alpha + 0x21b v2.1 beta + 0x230 v2.3 offical release */ +#define __BCC2GRX__ 0x22b + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TRUE +# define TRUE (1==1) +#endif +#ifndef FALSE +# define FALSE (1==0) +#endif + +#ifndef near /* get rid of these stupid keywords */ +#define near +#endif +#ifndef far +#define far +#endif +#ifndef huge +#define huge +#endif + +#define grOk 0 +#define grNoInitGraph -1 +#define grNotDetected -2 +#define grFileNotFound -3 +#define grInvalidDriver -4 +#define grNoLoadMem -5 +#define grNoScanMem -6 +#define grNoFloodMem -7 +#define grFontNotFound -8 +#define grNoFontMem -9 +#define grInvalidMode -10 +#define grError -11 +#define grIOerror -12 +#define grInvalidFont -13 +#define grInvalidFontNum -14 +#define grInvalidVersion -18 + +#define DETECT (-2) +#define DETECT_PAS (0) +#define NATIVE_GRX (-3) +#define CURRENT_DRIVER (-1) +#define VGA ( 9) +#define EGA ( 3) +#define IBM8514 ( 6) +#define HERCMONO ( 7) +#define EGA64 ( 4) +#define EGAMONO ( 5) +#define CGA ( 1) +#define MCGA ( 2) +#define ATT400 ( 8) +#define PC3270 (10) +/* driver definitions from BC++ 4.5 : */ +#define DETECTX (DETECT) +#define VGA256 (11) +#define ATTDEB (12) +#define TOSHIBA (13) +#define SVGA16 (14) +#define SVGA256 (15) +#define SVGA32K (16) +#define SVGA64K (17) +#define VESA16 (18) +#define VESA256 (19) +#define VESA32K (20) +#define VESA64K (21) +#define VESA16M (22) +#define ATI16 (23) +#define ATI256 (24) +#define ATI32K (25) +#define COMPAQ (26) +#define TSENG316 (27) +#define TSENG3256 (28) +#define TSENG416 (29) +#define TSENG4256 (30) +#define TSENG432K (31) +#define GENOA5 (32) +#define GENOA6 (33) +#define OAK (34) +#define PARADIS16 (35) +#define PARADIS256 (36) +#define TECMAR (37) +#define TRIDENT16 (38) +#define TRIDENT256 (39) +#define VIDEO7 (40) +#define VIDEO7II (41) +#define S3 (42) +#define ATIGUP (43) + +#define VGALO 0 +#define VGAMED 1 +#define VGAHI 2 +#define IBM8514LO 0 +#define IBM8514HI 1 +#define HERCMONOHI 0 +#define CGAC0 0 +#define CGAC1 1 +#define CGAC2 2 +#define CGAC3 3 +#define CGAHI 4 +#define MCGAC0 CGAC0 +#define MCGAC1 CGAC1 +#define MCGAC2 CGAC2 +#define MCGAC3 CGAC3 +#define MCGAMED CGAHI +#define MCGAHI 5 +#define ATT400C0 MCGAC0 +#define ATT400C1 MCGAC1 +#define ATT400C2 MCGAC2 +#define ATT400C3 MCGAC3 +#define ATT400MED MCGAMED +#define ATT400HI MCGAHI +#define EGA64LO 0 +#define EGA64HI 1 +#define EGALO 0 +#define EGAHI 1 +#define EGAMONOHI 0 +#define EGAMONOHI_PAS 3 +#define PC3270HI 0 +/* mode definitions from BC++ 4.5 : */ +#define RES640x350 0 +#define RES640x480 1 +#define RES800x600 2 +#define RES1024x768 3 +#define RES1280x1024 4 + +/* NATIVE_GRX modes : */ +#define GRX_DEFAULT_GRAPHICS 0 +#define GRX_BIGGEST_NONINTERLACED_GRAPHICS 1 +#define GRX_BIGGEST_GRAPHICS 2 +#define GRX_BGI_EMULATION 3 +#define __FIRST_DRIVER_SPECIFIC_MODE 4 + + +#ifndef BLACK +# define BLACK 0 +#endif +#ifndef BLUE +# define BLUE 1 +#endif +#ifndef GREEN +# define GREEN 2 +#endif +#ifndef CYAN +# define CYAN 3 +#endif +#ifndef RED +# define RED 4 +#endif +#ifndef MAGENTA +# define MAGENTA 5 +#endif +#ifndef BROWN +# define BROWN 6 +#endif +#ifndef LIGHTGRAY +# define LIGHTGRAY 7 +#endif +#ifndef DARKGRAY +# define DARKGRAY 8 +#endif +#ifndef LIGHTBLUE +# define LIGHTBLUE 9 +#endif +#ifndef LIGHTGREEN +# define LIGHTGREEN 10 +#endif +#ifndef LIGHTCYAN +# define LIGHTCYAN 11 +#endif +#ifndef LIGHTRED +# define LIGHTRED 12 +#endif +#ifndef LIGHTMAGENTA +# define LIGHTMAGENTA 13 +#endif +#ifndef YELLOW +# define YELLOW 14 +#endif +#ifndef WHITE +# define WHITE (__gr_White()) +#endif + +#define EGA_BLACK 0 +#define EGA_BLUE 1 +#define EGA_GREEN 2 +#define EGA_RED 4 +#define EGA_LIGHTBLUE 57 +#define EGA_LIGHTGREEN 58 +#define EGA_LIGHTRED 60 +#define EGA_CYAN 3 +#define EGA_LIGHTCYAN 59 +#define EGA_MAGENTA 5 +#define EGA_LIGHTMAGENTA 61 +#define EGA_BROWN 20 +#define EGA_LIGHTGRAY 7 +#define EGA_DARKGRAY 56 +#define EGA_YELLOW 62 +#define EGA_WHITE 63 + +#define SOLID_LINE 0 +#define DOTTED_LINE 1 +#define CENTER_LINE 2 +#define DASHED_LINE 3 +#define USERBIT_LINE 4 + +#define NORM_WIDTH 1 +#define THICK_WIDTH 3 + +#define DEFAULT_FONT 0 /* 8x8 bit mapped font */ +#define TRIPLEX_FONT 1 +#define SMALL_FONT 2 +#define SANS_SERIF_FONT 3 +#define GOTHIC_FONT 4 +#define SCRIPT_FONT 5 +#define SIMPLEX_FONT 6 +#define TRIPLEX_SCR_FONT 7 +#define COMPLEX_FONT 8 +#define EUROPEAN_FONT 9 +#define BOLD_FONT 10 + +#define HORIZ_DIR 0 /* left to right */ +#define VERT_DIR 1 /* bottom to top */ + +#define USER_CHAR_SIZE 0 /* user-defined char size */ + +enum fill_patterns { /* Fill patterns for get/setfillstyle */ + EMPTY_FILL, /* fills area in background color */ + SOLID_FILL, /* fills area in solid fill color */ + LINE_FILL, /* --- fill */ + LTSLASH_FILL, /* /// fill */ + SLASH_FILL, /* /// fill with thick lines */ + BKSLASH_FILL, /* \\\ fill with thick lines */ + LTBKSLASH_FILL, /* \\\ fill */ + HATCH_FILL, /* light hatch fill */ + XHATCH_FILL, /* heavy cross hatch fill */ + INTERLEAVE_FILL, /* interleaving line fill */ + WIDE_DOT_FILL, /* Widely spaced dot fill */ + CLOSE_DOT_FILL, /* Closely spaced dot fill */ + USER_FILL /* user defined fill */ +}; + +#define COPY_PUT 0 +#define XOR_PUT 1 +#define OR_PUT 2 +#define AND_PUT 3 +#define NOT_PUT 4 + +#define LEFT_TEXT 0 +#define CENTER_TEXT 1 +#define RIGHT_TEXT 2 +#define BOTTOM_TEXT 0 +#define TOP_TEXT 2 + +#define MAXCOLORS 15 + +struct palettetype { + unsigned char size; + signed char colors[MAXCOLORS+1]; +}; + +struct linesettingstype { + int linestyle; + unsigned short upattern; /* Note : BCC defines unsigned ! */ + int thickness; +}; + +struct textsettingstype { + int font; + int direction; + int charsize; + int horiz; + int vert; +}; + +struct fillsettingstype { + int pattern; + int color; +}; + +/* This definition is compatible with the grx + definition 'int pts[][2]' used to define polygons */ +struct pointtype { + int x, y; +}; + +struct viewporttype { + int left, top, right, bottom; + int clip; +}; + +struct arccoordstype { + int x, y; + int xstart, ystart, xend, yend; +}; + +/* ------------------------------------------------------------------ */ +/* --- Internal definitions --- */ +/* --- Don't access one of these variable and functions directly! --- */ + +extern int __gr_Mode; +extern int __gr_INIT; +extern int __gr_MaxMode; +extern int __gr_Result; +extern int __gr_X, __gr_Y; /* graphics cursor pos */ +extern int __gr_vpl, __gr_vpt, /* actual viewport */ + __gr_vpr, __gr_vpb; +extern int __gr_color; /* drawing color */ +extern int __gr_colorbg; /* background color */ +extern int __gr_colorfill; /* fill color */ +#if defined(__TURBOC__) && defined(__MSDOS__) +extern unsigned long __gr_WR; /* Write mode, type */ +#else +extern unsigned int __gr_WR; /* must match GrColor */ +#endif +extern int __gr_Xasp; /* Aspect ratio */ +extern int __gr_Yasp; +extern int __gr_fpatno; +extern int __gr_lstyle; +extern int __gr_clip; /* actual clipping state */ +extern int __gr_ADAPTER; /* Adapter used */ +extern unsigned char __gr_fpatterns[][8]; +extern struct palettetype __gr_EGAdef; +extern int __gr_BGI_w; /* Width, height and color */ +extern int __gr_BGI_h; /* used in */ +extern int __gr_BGI_c; /* GRX_BGI_EMULATION mode */ +extern int __gr_TextLineStyle; /* use setlinestyle() while + plotting .chr fonts */ + +void __gr_set_up_modes(void); +int __gr_White(void); + +/* ------------------------------------------------------------------ */ +/* --- BGI - API definitions --- */ + +void detectgraph(int *graphdriver,int *graphmode); +void initgraph(int *graphdriver, int *graphmode, char *pathtodriver); +void closegraph(void); +void setgraphmode(int mode); +char *getmodename( int mode_number ); +void graphdefaults(void); +char *getdrivername( void ); +char *grapherrormsg(int errorcode); +int getmaxx(void); +int getmaxy(void); +int getmaxcolor(void); +void getviewsettings(struct viewporttype *viewport); +void setviewport(int left, int top, int right, int bottom, int clip); +void getlinesettings(struct linesettingstype *lineinfo); +void setlinestyle(int linestyle, unsigned upattern, int thickness); +void clearviewport(void); +unsigned getpixel(int x, int y); +void putpixel(int x, int y, int color); +void bar3d(int left,int top,int right,int bottom,int depth, int topflag); +void rectangle(int left, int top, int right, int bottom); +void fillpoly(int numpoints, void *polypoints); +void fillellipse( int x, int y, int xradius, int yradius ); +void getarccoords(struct arccoordstype *arccoords); +void floodfill(int x, int y, int border); +void setfillpattern( char *upattern, int color); +void setfillstyle(int pattern, int color); +void getimage(int left, int top, int right, int bottom, void *bitmap); +void putimage(int left, int top, void *bitmap, int op); +unsigned imagesize(int left, int top, int right, int bottom); +void gettextsettings(struct textsettingstype *texttypeinfo); +void settextjustify(int horiz, int vert); +void settextstyle(int font, int direction, int charsize); +void setrgbpalette(int color, int red, int green, int blue); +void setusercharsize(int multx, int divx, int multy, int divy); +void setwritemode( int mode ); +void outtext(const char *textstring); +void outtextxy(int x, int y, const char *textstring); +int textheight(const char *textstring); +int textwidth(const char *textstring); + +int registerbgifont(void *font); +int installuserfont(const char *name); + +int getpalettesize(void); +void getpalette(struct palettetype *palette); +void setallpalette( const struct palettetype *palette); + + + +/* ------------------------------------------------------------------ */ +/* --- BGI - API extensions --- */ + +extern int _bold_font, _euro_font, /* Linkable font files */ + _goth_font, _lcom_font, + _litt_font, _sans_font, + _scri_font, _simp_font, + _trip_font, _tscr_font; +void set_BGI_mode(int *graphdriver, int *graphmode); +/*void set_BGI_mode_whc() declared inline */ +void __getrgbpalette(int color, int *red, int *green, int *blue); + + +void __gr_set_libbcc_init_hooks ( + int (*init) (void) , + int (*close) (void) ); + + +int set_BGI_print_mode ( int mode , char * dest ); + +extern unsigned char _dac_g256[][3]; /* 256 shading dac values */ +extern unsigned char _dac_normal[][3]; /* 256 standard colors */ + +extern void setrgbdefaults(void); +extern void setrgbgray256(void); +int _ega_color(int egacol); + + +/* ------------------------------------------------------------------ */ +/* --- direct linkable API functions --- */ +/* --- ( mainly for GNU Pascal Graph unit usage ) --- */ + +void __gr_restorecrtmode(void); +void __gr_closegraph(void); +int __gr_getgraphmode(void); +int __gr_getmaxmode(void); +void __gr_getmoderange(int gd, int *lomode, int *himode); +int __gr_graphresult(void); +int __gr_getx(void); +int __gr_gety(void); +void __gr_moveto(int x, int y); +void __gr_moverel(int dx, int dy); +int __gr_getbkcolor(void); +int __gr_getcolor(void); +void __gr_cleardevice(void); +void __gr_setbkcolor(int color); +void __gr_setcolor(int color); +void __gr_line(int x1, int y1, int x2, int y2); +void __gr_linerel(int dx, int dy); +void __gr_lineto(int x, int y); +void __gr_drawpol(int numpoints, void *polypoints, int close); +void __gr_drawpoly(int numpoints, void *polypoints); +void __gr_bar(int left, int top, int right, int bottom); +void __gr_circle(int x, int y, int radius); +void __gr_ellipse(int x,int y,int stangle,int endangle,int xradius,int yradius); +void __gr_arc(int x, int y, int stangle, int endangle, int radius); +void __gr_getaspectratio(int *xasp, int *yasp); +void __gr_setaspectratio( int xasp, int yasp ); +void __gr_getfillsettings(struct fillsettingstype *fillinfo); +void __gr_getfillpattern(char *pattern); +void __gr_sector(int x,int y,int stangle,int endangle,int xradius,int yradius); +void __gr_pieslice(int x, int y, int stangle, int endangle, int radius); +unsigned __gr_setgraphbufsize(unsigned bufsize); +struct palettetype *__gr_getdefaultpalette(void); +int __gr_installbgidriver(char *name, void *detect); +int __gr_registerfarbgidriver(void *driver); +int __gr_registerfarbgifont(void *font); +void __gr_textlinestyle(int on); +void __gr_setpalette(int colornum, int color); +int __gr_getvisualpage(void); +void __gr_setvisualpage(int p); +int __gr_getactivepage(void); +void __gr_setactivepage(int p); +int __gr_setrgbcolor(int r, int g, int b); +int __gr_getmodemaxy(int mode); +int __gr_getmodemaxx(int mode); +int __gr_getmodemaxcolor(int mode); +void __gr_set_BGI_mode_whc(int *gd, int *gm, int width, int height, int colors); +int __gr_get_BGI_mode_pages(void); +void __gr_set_BGI_mode_pages(int p); + +#ifdef __cplusplus +} +#endif + +/* ----------------------------------------------------------------- */ +/* --- API functions with macro equivalents --- */ +/* --- (for inlining) --- */ +/* ----------------------------------------------------------------- */ +void restorecrtmode(void); +int getgraphmode(void); +int getmaxmode(void); +void getmoderange(int gd, int *lomode, int *himode); +int graphresult(void); +int getx(void); +int gety(void); +void moveto(int x, int y); +void moverel(int dx, int dy); +int getbkcolor(void); +int getcolor(void); +void cleardevice(void); +void setbkcolor(int color); +void setcolor(int color); +void line(int x1, int y1, int x2, int y2); +void linerel(int dx, int dy); +void lineto(int x, int y); +void drawpoly(int numpoints, void *polypoints); +void bar(int left, int top, int right, int bottom); +void circle(int x, int y, int radius); +void ellipse( int x, int y, int stangle, int endangle, + int xradius, int yradius ); +void arc(int x, int y, int stangle, int endangle, int radius); +void getaspectratio(int *xasp, int *yasp); +void setaspectratio( int xasp, int yasp ); +void getfillsettings(struct fillsettingstype *fillinfo); +void getfillpattern(char *pattern); +void sector( int x, int y, int stangle, int endangle, + int xradius, int yradius ); +void pieslice(int x, int y, int stangle, int endangle, int radius); +unsigned setgraphbufsize(unsigned bufsize); +struct palettetype *getdefaultpalette(void); +int installbgidriver(char *name, void *detect); +int registerfarbgidriver(void *driver); +int registerfarbgifont(void *font); +void textlinestyle(int on); +void setpalette(int colornum, int color); +void set_BGI_mode_pages(int p); +int get_BGI_mode_pages(void); +void set_BGI_mode_whc(int *gd, int *gm, int width, int height, int colors); +int getmodemaxcolor(int mode); +int getmodemaxx(int mode); +int getmodemaxy(int mode); +int setrgbcolor(int r, int g, int b); +void setactivepage(int p); +int getactivepage(void); +void setvisualpage(int p); +int getvisualpage(void); + +/* ----------------------------------------------------------------- */ +#define restorecrtmode() __gr_restorecrtmode() +#define getgraphmode() (__gr_INIT ? __gr_Mode : (__gr_Result=grNoInitGraph)) +#define getmaxmode() (__gr_set_up_modes(), __gr_MaxMode) +#define getmoderange(gd, lomode, himode) \ + __gr_getmoderange((gd),(lomode),(himode)) +#define graphresult() __gr_graphresult() +#define getx() (__gr_X+0) +#define gety() (__gr_Y+0) +#define moveto(x, y) do { __gr_X = (x); __gr_Y = (y); } while(0) +#define moverel(dx, dy) moveto(getx()+(dx),gety()+(dy)) +#define getbkcolor() (__gr_colorbg+0) +#define getcolor() (__gr_color+0) +#define cleardevice() __gr_cleardevice() +#define setbkcolor(color) do __gr_colorbg = (color); while(0) +#define setcolor(color) do __gr_color = (color); while(0) +#define line(x1, y1, x2, y2) __gr_line((x1),(y1),(x2),(y2)) +#define linerel(dx, dy) __gr_line(getx(),gety(),getx()+(dx),gety()+(dy)) +#define lineto(x, y) __gr_line(getx(),gety(),(x),(y)) +#define drawpoly(numpoints, polypoints) \ + __gr_drawpol((numpoints), (polypoints), FALSE) +#define bar(left, top, right, bottom) __gr_bar((left),(top),(right),(bottom)) +#define circle(x, y, radius) __gr_circle((x),(y),(radius)) +#define ellipse(x, y, stangle, endangle, xradius, yradius) \ + __gr_ellipse((x),(y),(stangle),(endangle),(xradius),(yradius)) +/* arc() uses radius twice */ +#define getaspectratio(xasp, yasp) \ + do { *(xasp) = __gr_Xasp; *(yasp) = __gr_Yasp; } while(0) +#define setaspectratio(xasp, yasp ) \ + do { __gr_Xasp = (xasp); __gr_Yasp = (yasp); } while(0) +/* getfillsettings() uses fillinfo twice */ +#define getfillpattern(pattern) __gr_getfillpattern(pattern) +#define sector(x, y, stangle, endangle, xradius, yradius) \ + __gr_sector((x),(y),(stangle),(endangle),(xradius), (yradius)); +/* pieslice() uses radius twice */ +#define setgraphbufsize(bufsize) __gr_setgraphbufsize(bufsize) +#define getdefaultpalette() (&__gr_EGAdef) +#define installbgidriver(name, detect) __gr_installbgidriver((name), (detect)) +#define registerfarbgidriver(driver) __gr_registerfarbgidriver(driver) +#define registerfarbgifont(font) registerbgifont(font) +#define textlinestyle(on) do __gr_TextLineStyle = on; while(0); +#define setpalette(colornum, color) __gr_setpalette((colornum),(color)) +#define set_BGI_mode_pages(p) __gr_set_BGI_mode_pages(p) +#define get_BGI_mode_pages() __gr_get_BGI_mode_pages() +#define set_BGI_mode_whc(gd, gm, width, height, colors) \ + do { \ + __gr_set_BGI_mode_pages(1); \ + __gr_BGI_w = (width); \ + __gr_BGI_h = (height); \ + __gr_BGI_c = (colors); \ + *(gd) = NATIVE_GRX; \ + *(gm) = GRX_BGI_EMULATION; \ + } while(0) +#define getmodemaxcolor(mode) __gr_getmodemaxcolor(mode) +#define getmodemaxx(mode) __gr_getmodemaxx(mode) +#define getmodemaxy(mode) __gr_getmodemaxx(mode) +#define setrgbcolor(r, g, b) __gr_setrgbcolor((r),(g),(b)) +#define setactivepage(p) __gr_setactivepage(p) +#define getactivepage() __gr_getactivepage() +#define setvisualpage(p) __gr_setvisualpage(p) +#define getvisualpage() __gr_getvisualpage() + +#ifdef __BCCGRX_C + +/* ----------------------------------------------------------------- */ +void (restorecrtmode)(void) { + __gr_restorecrtmode(); +} + +/* ----------------------------------------------------------------- */ +int (getgraphmode)(void) { + return (__gr_INIT ? __gr_Mode : (__gr_Result=grNoInitGraph)); +} + +/* ----------------------------------------------------------------- */ +int (getmaxmode)(void) { + __gr_set_up_modes(); + return __gr_MaxMode; +} + +/* ----------------------------------------------------------------- */ +void (getmoderange)(int gd, int *lomode, int *himode) { + __gr_getmoderange(gd, lomode, himode); +} + +/* ----------------------------------------------------------------- */ +int (graphresult)(void) { + return __gr_graphresult(); +} + +/* ----------------------------------------------------------------- */ +int (getx)(void) { + return __gr_X; +} + +/* ----------------------------------------------------------------- */ +int (gety)(void) { + return __gr_Y; +} + +/* ----------------------------------------------------------------- */ +void (moveto)(int x, int y) { + __gr_X = x; __gr_Y = y; +} + +/* ----------------------------------------------------------------- */ +void (moverel)(int dx, int dy) { + moveto( getx()+dx, gety()+dy); +} + +/* ----------------------------------------------------------------- */ +int (getbkcolor)(void) { + return __gr_colorbg; +} + +/* ----------------------------------------------------------------- */ +int (getcolor)(void) { + return __gr_color; +} + +/* ----------------------------------------------------------------- */ +void (cleardevice)(void) { + __gr_cleardevice(); +} + +/* ----------------------------------------------------------------- */ +void (setbkcolor)(int color) { + __gr_colorbg= color; +} + +/* ----------------------------------------------------------------- */ +void (setcolor)(int color) { + __gr_color= color; +} + +/* ----------------------------------------------------------------- */ +void (line)(int x1, int y1, int x2, int y2) { + __gr_line(x1,y1,x2,y2); +} + +/* ----------------------------------------------------------------- */ +void (linerel)(int dx, int dy) { + register int x = getx(); + register int y = gety(); + __gr_line(x,y,x+dx,y+dy); +} + +/* ----------------------------------------------------------------- */ +void (lineto)(int x, int y) { + __gr_line( getx(), gety(), x, y); +} + +/* ----------------------------------------------------------------- */ +void (drawpoly)(int numpoints, void *polypoints) { + __gr_drawpol(numpoints, polypoints, FALSE); +} + +/* ----------------------------------------------------------------- */ +void (bar)(int left, int top, int right, int bottom) { + __gr_bar(left,top,right, bottom); +} + +/* ----------------------------------------------------------------- */ +void (circle)(int x, int y, int radius) { + __gr_circle(x,y,radius); +} + +/* ----------------------------------------------------------------- */ +void (ellipse)( int x, int y, int stangle, int endangle, + int xradius, int yradius ) { + __gr_ellipse( x, y, stangle, endangle, xradius, yradius); +} + +/* ----------------------------------------------------------------- */ +void (arc)(int x, int y, int stangle, int endangle, int radius) { + __gr_ellipse(x,y,stangle,endangle,radius,radius); +} + +/* ----------------------------------------------------------------- */ +void (getaspectratio)(int *xasp, int *yasp) { + *xasp = __gr_Xasp; *yasp = __gr_Yasp; +} + +/* ----------------------------------------------------------------- */ +void (setaspectratio)( int xasp, int yasp ) { + __gr_Xasp = xasp; __gr_Yasp = yasp; +} + +/* ----------------------------------------------------------------- */ +void (getfillsettings)(struct fillsettingstype *fillinfo) { + fillinfo->pattern = __gr_fpatno; + fillinfo->color = __gr_colorfill; +} + +/* ----------------------------------------------------------------- */ +void (getfillpattern)(char *pattern) { + __gr_getfillpattern(pattern); +} + +/* ----------------------------------------------------------------- */ +void (sector)( int x, int y, int stangle, int endangle, + int xradius, int yradius ) { + __gr_sector(x,y,stangle,endangle,xradius, yradius); +} + +/* ----------------------------------------------------------------- */ +void (pieslice)(int x, int y, int stangle, int endangle, int radius) { + __gr_sector(x,y,stangle,endangle,radius,radius); +} + +/* ----------------------------------------------------------------- */ +unsigned (setgraphbufsize)(unsigned bufsize) { + return __gr_setgraphbufsize(bufsize); +} + +/* ----------------------------------------------------------------- */ +struct palettetype *(getdefaultpalette)(void) { + return &__gr_EGAdef; +} + +/* ----------------------------------------------------------------- */ +int (installbgidriver)(char *name, void *detect) { + return __gr_installbgidriver(name, detect); +} + +/* ----------------------------------------------------------------- */ +int (registerfarbgidriver)(void *driver) { + return __gr_registerfarbgidriver(driver); +} + +/* ----------------------------------------------------------------- */ +int (registerfarbgifont)(void *font) { + return registerbgifont(font); +} + +/* ----------------------------------------------------------------- */ +void (textlinestyle)(int on) { + __gr_TextLineStyle = on; +} + +/* ----------------------------------------------------------------- */ +void (setpalette)(int colornum, int color) { + __gr_setpalette(colornum,color); +} + +/* ----------------------------------------------------------------- */ +void (set_BGI_mode_pages)(int p) { + __gr_set_BGI_mode_pages(p); +} + +/* ----------------------------------------------------------------- */ +int (get_BGI_mode_pages)(void) { + return __gr_get_BGI_mode_pages(); +} + +/* ----------------------------------------------------------------- */ +void (set_BGI_mode_whc)(int *gd, int *gm, int width, int height, int colors) { + __gr_set_BGI_mode_pages(1); + __gr_BGI_w = width; + __gr_BGI_h = height; + __gr_BGI_c = colors; + *gd = NATIVE_GRX; + *gm = GRX_BGI_EMULATION; +} + +/* ----------------------------------------------------------------- */ +int (getmodemaxcolor)(int mode) { + /* works like getmaxcolor() for mode */ + return __gr_getmodemaxcolor(mode); +} + +/* ----------------------------------------------------------------- */ +int (getmodemaxx)(int mode) { + /* works like getmaxx() for mode */ + return __gr_getmodemaxx(mode); +} + +/* ----------------------------------------------------------------- */ +int (getmodemaxy)(int mode) { + /* works like getmaxy() for mode */ + return __gr_getmodemaxx(mode); +} + +/* ----------------------------------------------------------------- */ +int (setrgbcolor)(int r, int g, int b) { + return __gr_setrgbcolor(r,g,b); +} + +/* ----------------------------------------------------------------- */ +void (setactivepage)(int p) { + __gr_setactivepage(p); +} + +/* ----------------------------------------------------------------- */ +int (getactivepage)(void) { + return __gr_getactivepage(); +} + +/* ----------------------------------------------------------------- */ +void (setvisualpage)(int p) { + __gr_setvisualpage(p); +} + +/* ----------------------------------------------------------------- */ +int (getvisualpage)(void) { + return __gr_getvisualpage(); +} + +#endif /* __BCCGRX_C */ +/* ----------------------------------------------------------------- */ + +#endif diff --git a/thirdparty/grx249/lib/bcc/readme b/thirdparty/grx249/lib/bcc/readme new file mode 100644 index 0000000..995cc75 --- /dev/null +++ b/thirdparty/grx249/lib/bcc/readme @@ -0,0 +1,10 @@ +GRX library for Turbo-C / Borland-C++ + +Models supported: + + large + +Recompile: - go to the grx base dir (cd ..\..) + - edit the makedefs.bcc file + - run Borland make: + make -f makefile.bcc libs diff --git a/thirdparty/grx249/lib/dj2/readme b/thirdparty/grx249/lib/dj2/readme new file mode 100644 index 0000000..2ab13ca --- /dev/null +++ b/thirdparty/grx249/lib/dj2/readme @@ -0,0 +1,6 @@ +GRX library for DJGPP v2.x + +Recompile: - go to the grx base dir (cd ..\..) + - edit the makedefs.grx file + - run GNU make: + make -f makefile.dj2 libs diff --git a/thirdparty/grx249/lib/unix/dummy b/thirdparty/grx249/lib/unix/dummy new file mode 100644 index 0000000..cd301b1 --- /dev/null +++ b/thirdparty/grx249/lib/unix/dummy @@ -0,0 +1 @@ +-- empty -- diff --git a/thirdparty/grx249/lib/watcom32/readme b/thirdparty/grx249/lib/watcom32/readme new file mode 100644 index 0000000..4769766 --- /dev/null +++ b/thirdparty/grx249/lib/watcom32/readme @@ -0,0 +1,2 @@ +GRX library for Watcom C++ 11.0 (32bit) + diff --git a/thirdparty/grx249/lib/win32/dummy b/thirdparty/grx249/lib/win32/dummy new file mode 100644 index 0000000..cd301b1 --- /dev/null +++ b/thirdparty/grx249/lib/win32/dummy @@ -0,0 +1 @@ +-- empty -- diff --git a/thirdparty/grx249/makedefs.bcc b/thirdparty/grx249/makedefs.bcc new file mode 100644 index 0000000..bc2ccf5 --- /dev/null +++ b/thirdparty/grx249/makedefs.bcc @@ -0,0 +1,18 @@ +BCCROOT =c:\comp\bc +BCC =$(BCCROOT)\bin\bcc +TLIB =$(BCCROOT)\bin\tlib +TASM =$(BCCROOT)\bin\tasm +STRIP =$(BCCROOT)\bin\tdstrip +MAKE =$(BCCROOT)\bin\maker -fmakefile.bcc + +MODEL= l + +GRX_LIB_SUBDIR=bcc + +!if $d(DEBUG) +CCOPT= -O -G -Z -2 -m$(MODEL) -w -w-par -w-stv -d -v -DDEBUG=$(DEBUG) +LDOPT= -m$(MODEL) -v +!else +CCOPT= -O -G -Z -2 -m$(MODEL) -w -w-par -w-stv -d -k- +LDOPT= -m$(MODEL) +!endif diff --git a/thirdparty/grx249/makedefs.grx b/thirdparty/grx249/makedefs.grx new file mode 100644 index 0000000..c39cfe4 --- /dev/null +++ b/thirdparty/grx249/makedefs.grx @@ -0,0 +1,261 @@ +### CONFIGURATION ######################################################## + +# This file sets variables that direct the libary build for the +# programmer needs. The file is used for the four standard plattforms + +# Specify version of GRX +# Currently only used to generate name of shared libraries for linux +GRX_VERSION=2.4.9 + +# Specify if you have libtiff.a and corresponding .h files. +# Change setting to 'y' if you have it, or to 'n' if not. +HAVE_LIBTIFF=n + +# Specify if you have libjpeg.a and corresponding .h files. +HAVE_LIBJPEG=y + +# Specify if you have libpng.a and corresponding .h files. +HAVE_LIBPNG=y + +# Specify if one of the above libs requires the +# zlib compression library +NEED_ZLIB=y + +# Specify if you want to include printing code from addons +INCLUDE_PRINTING_CODE=n + +# Specify if you want to include bmp image code from addons +INCLUDE_BMP_CODE=y + +# Specify if you want to include GNU_Pascal (gpc) support +INCLUDE_GPC_SUPPORT=n + +# Specify if you want shared library support (Linux console and X11) +INCLUDE_SHARED_SUPPORT=n + +# Specify if you want to include BGI support +INCLUDE_BGI_SUPPORT=n + +# For cross-compiling, specify prefix for tools including the trailing dash +# (e.g. i386-mingw32- for using i386-mingw32-gcc instead of just gcc) +#CROSS_PLATFORM=i586-pc-msdosdjgpp- + +# Specify if you want to use Unix tools on DOS-like platforms +HAVE_UNIX_TOOLS=y + +# Specify in linux if you want to build the library for x86_64 +BUILD_X86_64=y + +# For SDL driver the executable prefix EP is used to discriminate +# between linux X11 and mingw32. Set +#EP=x ... For linux X11. +#EP= ... For mingw32 +EP=x + +### SYSTEM SETTINGS ###################################################### + +CC = $(CROSS_PLATFORM)gcc +PC = $(CROSS_PLATFORM)gpc +AR = $(CROSS_PLATFORM)ar +RANLIB = $(CROSS_PLATFORM)ranlib +STRIP = $(CROSS_PLATFORM)strip + +# Different systems / setups may generate .o files +# this tag files will show what version is present +SYSTEM_TAG_PREFIX = systag +LINUX_i386_CONSOLE = $(SYSTEM_TAG_PREFIX).000 +LINUX_i386_X11 = $(SYSTEM_TAG_PREFIX).002 +DOS_DJGPP_V2 = $(SYSTEM_TAG_PREFIX).004 +WIN32_GCC_i386_STATIC = $(SYSTEM_TAG_PREFIX).006 +ANY_GCC_SDL_STATIC = $(SYSTEM_TAG_PREFIX).008 + +ifdef DEBUG +CCOPT = -O2 -fno-strict-aliasing -Wall -g -DDEBUG=$(DEBUG) ${C_FLAGS} +LDOPT = -g ${L_FLAGS} +else +CCOPT = -O2 -fno-strict-aliasing -Wall ${C_FLAGS} +LDOPT = -s ${L_FLAGS} +endif + +ifdef PROFILE +CCOPT += -pg +endif + +# Additional warnings for development +WARNOPTS = -W -Wshadow -Wpointer-arith -Wbad-function-cast \ + -Wcast-align -Wconversion -Wmissing-prototypes \ + -Wnested-externs -Wstrict-prototypes +#CCOPT += $(WARNOPTS) + +# Some systems can't allocate big arrays on stack. +# If test/xcirctest fails on bigger diameters, try +#CCOPT += -DSMALL_STACK + +# You may want to enable one (or both) of the following +# switches if your get lots of warnings when compiling GRX +#CCOPT += -DNO_LEFTSIDE_LVALUE_CAST +#CCOPT += -DNO_LEFTSIDE_PTR_CAST + +########################################################################## + +ifdef GRXVSDL +ifeq ($(EP),x) +GRXVX11=y +else +GRXVW32=y +endif +endif + +ifdef GRXVLNX +GRXVUNX=y +endif + +ifdef GRXVX11 +GRXVUNX=y +endif + +### UNIX SPECIFIC ######################################################## + +ifdef GRXVUNX + +# Put libgrx20.a, libgrx20.so, libgrx20X.a, libgrx20X.so and libgrx20S.a +# in lib/unix +GRX_LIB_SUBDIR=unix + +# Set here the default destination dirs for install and uninstall targets +prefix=/usr/local + +# Set the default GRX font path +#GRX_DEFAULT_FONT_PATH=${datadir}/grx/fonts + +# check for i386 or x86_64 build +ifeq ($(BUILD_X86_64),y) +CCOPT += -m64 +LDOPT += -m64 +else +CCOPT += -m32 +LDOPT += -m32 +endif + +endif + +### LINUX CONSOLE SPECIFIC ############################################### + +ifdef GRXVLNX + +# Use direct PS/2 mouse driver instead the svgalib one +USE_DIRECT_MOUSE_DRIVER=n + +# Set the videodrivers to be included, you can set both or only one of them +# (remember to set USE_DIRECT_MOUSE_DRIVER to 'y' if you set only the +# framebuffer driver) +USE_SVGALIB_DRIVER=y +USE_FRAMEBUFFER_DRIVER=y + +# Set or not set suid root. This is required for the svgalib 1.4.x stable +# release, it can be set to 'n' if you use the framebuffer driver only or +# the svgalib 1.9.x alpha release without the 1 and 4 bpp resolutions +# (see bellow) +SET_SUIDROOT=y + +# Set to 'y' this variable if you want to add the framedrivers that use +# inport/outport instructions: 1 and 4 bpp modes and the 8 bpp mode X. But +# beware this works only with svgalib 1.4.x (not with 1.9.x) and without +# the linux framebuffer enabled +USE_INOUTP_FRAMEDRIVERS=y + +endif + +### LINUX X11 SPECIFIC ################################################### + +ifdef GRXVX11 + +# The X11 base dir on your system +X11BASE=/usr/X11R6 + +# Add directories with X11 include files here +X11INCS=-I$(X11BASE)/include + +# put X11 required libraries and directories here +# note: some systems need -lsocket added +X11LIB=$(X11BASE)/lib +X11LIBS=-L$(X11LIB) -lX11 + +# Set to try to use the XFree86 Direct Graphics Access driver (DGA2) +# (if DGA2 is not available, fall back to the windowed X11 driver) +# As of XFree-4.3.99.5 DGA/DGA2 seems stable, but use with caution. +USE_XF86DGA_DRIVER=n +# Set to 'y' this variable if you want the DGA2 driver to use direct +# framebuffer access. That should not make DGA2 more unstable and is +# faster. If this setting is 'y', the DGA2 driver (see above) must +# also be 'y', or you will get compilation/linkage errors. +USE_XF86DGA_FRAMEBUFFER=n +# Set or not set suid root for X11. This is required for the DGA2 +# framebuffer access, it can be set to 'n' if you use the standard +# X11 driver only or DGA2 without framebuffer access. +SET_XSUIDROOT=n + +endif + +### DOS DJGPPv2 SPECIFIC ################################################# + +ifdef GRXVDJ2 + +# Put libgrx20.a to lib/dj2 +GRX_LIB_SUBDIR=dj2 + +# Set here the destination dir for install and uninstall targets +prefix=/dev/env/DJDIR + +# Set the default GRX font path +#GRX_DEFAULT_FONT_PATH=/dev/env/DJDIR/share/grx/fonts + +# If you want to use 'upx.exe' compressor +# disable the echo line and enable upx line. +EXE_COMPRESS = -echo +#EXE_COMPRESS = upx --best + +# Default compiler switches. In djgpp.env. under [make], +# add the line "BUTT=-mcpu=i386", if that is your target, +# or directly add -mcpu here. +# At present gcc supports 'i386', 'i486', 'i586' ('pentium'), +# 'i686' ('pentiumpro') and 'k6'. +#CCOPT += $(BUTT) +#CCOPT += -mcpu=i586 + +# GRX uses "uclock" to gets 1 ms resolution in the input code, +# this can causes problems in Win3.1, so you may want to enable +# the following switch +#CCOPT += -DNO_REPROGRAM_TIMER + +endif + +### WIN32 MINGW SPECIFIC ################################################# + +ifdef GRXVW32 + +# Put libgrx20.a and libgrx20S.a to lib/win32 +GRX_LIB_SUBDIR=win32 + +# Set here the destination dir for install and uninstall targets +prefix=C:\MINGW + +# Set the default GRX font path +#GRX_DEFAULT_FONT_PATH=c:/grxfonts + +endif + +### COMMON ############################################################## + +exec_prefix=${prefix} + +bindir=${exec_prefix}/bin +libdir=${exec_prefix}/lib +datadir=${prefix}/share + +infodir=${prefix}/info +includedir=${prefix}/include +unitsdir=${exec_prefix}/units + +########################################################################## + diff --git a/thirdparty/grx249/makedefs.orig b/thirdparty/grx249/makedefs.orig new file mode 100644 index 0000000..670cbb8 --- /dev/null +++ b/thirdparty/grx249/makedefs.orig @@ -0,0 +1,261 @@ +### CONFIGURATION ######################################################## + +# This file sets variables that direct the libary build for the +# programmer needs. The file is used for the four standard plattforms + +# Specify version of GRX +# Currently only used to generate name of shared libraries for linux +GRX_VERSION=2.4.9 + +# Specify if you have libtiff.a and corresponding .h files. +# Change setting to 'y' if you have it, or to 'n' if not. +HAVE_LIBTIFF=n + +# Specify if you have libjpeg.a and corresponding .h files. +HAVE_LIBJPEG=n + +# Specify if you have libpng.a and corresponding .h files. +HAVE_LIBPNG=n + +# Specify if one of the above libs requires the +# zlib compression library +NEED_ZLIB=n + +# Specify if you want to include printing code from addons +INCLUDE_PRINTING_CODE=n + +# Specify if you want to include bmp image code from addons +INCLUDE_BMP_CODE=n + +# Specify if you want to include GNU_Pascal (gpc) support +INCLUDE_GPC_SUPPORT=n + +# Specify if you want shared library support (Linux console and X11) +INCLUDE_SHARED_SUPPORT=n + +# Specify if you want to include BGI support +INCLUDE_BGI_SUPPORT=n + +# For cross-compiling, specify prefix for tools including the trailing dash +# (e.g. i386-mingw32- for using i386-mingw32-gcc instead of just gcc) +#CROSS_PLATFORM=i586-pc-msdosdjgpp- + +# Specify if you want to use Unix tools on DOS-like platforms +HAVE_UNIX_TOOLS=y + +# Specify in linux if you want to build the library for x86_64 +BUILD_X86_64=y + +# For SDL driver the executable prefix EP is used to discriminate +# between linux X11 and mingw32. Set +#EP=x ... For linux X11. +#EP= ... For mingw32 +EP=x + +### SYSTEM SETTINGS ###################################################### + +CC = $(CROSS_PLATFORM)gcc +PC = $(CROSS_PLATFORM)gpc +AR = $(CROSS_PLATFORM)ar +RANLIB = $(CROSS_PLATFORM)ranlib +STRIP = $(CROSS_PLATFORM)strip + +# Different systems / setups may generate .o files +# this tag files will show what version is present +SYSTEM_TAG_PREFIX = systag +LINUX_i386_CONSOLE = $(SYSTEM_TAG_PREFIX).000 +LINUX_i386_X11 = $(SYSTEM_TAG_PREFIX).002 +DOS_DJGPP_V2 = $(SYSTEM_TAG_PREFIX).004 +WIN32_GCC_i386_STATIC = $(SYSTEM_TAG_PREFIX).006 +ANY_GCC_SDL_STATIC = $(SYSTEM_TAG_PREFIX).008 + +ifdef DEBUG +CCOPT = -O2 -fno-strict-aliasing -Wall -g -DDEBUG=$(DEBUG) +LDOPT = -g +else +CCOPT = -O2 -fno-strict-aliasing -Wall +LDOPT = -s +endif + +ifdef PROFILE +CCOPT += -pg +endif + +# Additional warnings for development +WARNOPTS = -W -Wshadow -Wpointer-arith -Wbad-function-cast \ + -Wcast-align -Wconversion -Wmissing-prototypes \ + -Wnested-externs -Wstrict-prototypes +#CCOPT += $(WARNOPTS) + +# Some systems can't allocate big arrays on stack. +# If test/xcirctest fails on bigger diameters, try +#CCOPT += -DSMALL_STACK + +# You may want to enable one (or both) of the following +# switches if your get lots of warnings when compiling GRX +#CCOPT += -DNO_LEFTSIDE_LVALUE_CAST +#CCOPT += -DNO_LEFTSIDE_PTR_CAST + +########################################################################## + +ifdef GRXVSDL +ifeq ($(EP),x) +GRXVX11=y +else +GRXVW32=y +endif +endif + +ifdef GRXVLNX +GRXVUNX=y +endif + +ifdef GRXVX11 +GRXVUNX=y +endif + +### UNIX SPECIFIC ######################################################## + +ifdef GRXVUNX + +# Put libgrx20.a, libgrx20.so, libgrx20X.a, libgrx20X.so and libgrx20S.a +# in lib/unix +GRX_LIB_SUBDIR=unix + +# Set here the default destination dirs for install and uninstall targets +prefix=/usr/local + +# Set the default GRX font path +#GRX_DEFAULT_FONT_PATH=${datadir}/grx/fonts + +# check for i386 or x86_64 build +ifeq ($(BUILD_X86_64),y) +CCOPT += -m64 +LDOPT += -m64 +else +CCOPT += -m32 +LDOPT += -m32 +endif + +endif + +### LINUX CONSOLE SPECIFIC ############################################### + +ifdef GRXVLNX + +# Use direct PS/2 mouse driver instead the svgalib one +USE_DIRECT_MOUSE_DRIVER=n + +# Set the videodrivers to be included, you can set both or only one of them +# (remember to set USE_DIRECT_MOUSE_DRIVER to 'y' if you set only the +# framebuffer driver) +USE_SVGALIB_DRIVER=y +USE_FRAMEBUFFER_DRIVER=y + +# Set or not set suid root. This is required for the svgalib 1.4.x stable +# release, it can be set to 'n' if you use the framebuffer driver only or +# the svgalib 1.9.x alpha release without the 1 and 4 bpp resolutions +# (see bellow) +SET_SUIDROOT=y + +# Set to 'y' this variable if you want to add the framedrivers that use +# inport/outport instructions: 1 and 4 bpp modes and the 8 bpp mode X. But +# beware this works only with svgalib 1.4.x (not with 1.9.x) and without +# the linux framebuffer enabled +USE_INOUTP_FRAMEDRIVERS=n + +endif + +### LINUX X11 SPECIFIC ################################################### + +ifdef GRXVX11 + +# The X11 base dir on your system +X11BASE=/usr/X11R6 + +# Add directories with X11 include files here +X11INCS=-I$(X11BASE)/include + +# put X11 required libraries and directories here +# note: some systems need -lsocket added +X11LIB=$(X11BASE)/lib +X11LIBS=-L$(X11LIB) -lX11 + +# Set to try to use the XFree86 Direct Graphics Access driver (DGA2) +# (if DGA2 is not available, fall back to the windowed X11 driver) +# As of XFree-4.3.99.5 DGA/DGA2 seems stable, but use with caution. +USE_XF86DGA_DRIVER=n +# Set to 'y' this variable if you want the DGA2 driver to use direct +# framebuffer access. That should not make DGA2 more unstable and is +# faster. If this setting is 'y', the DGA2 driver (see above) must +# also be 'y', or you will get compilation/linkage errors. +USE_XF86DGA_FRAMEBUFFER=n +# Set or not set suid root for X11. This is required for the DGA2 +# framebuffer access, it can be set to 'n' if you use the standard +# X11 driver only or DGA2 without framebuffer access. +SET_XSUIDROOT=n + +endif + +### DOS DJGPPv2 SPECIFIC ################################################# + +ifdef GRXVDJ2 + +# Put libgrx20.a to lib/dj2 +GRX_LIB_SUBDIR=dj2 + +# Set here the destination dir for install and uninstall targets +prefix=/dev/env/DJDIR + +# Set the default GRX font path +#GRX_DEFAULT_FONT_PATH=/dev/env/DJDIR/share/grx/fonts + +# If you want to use 'upx.exe' compressor +# disable the echo line and enable upx line. +EXE_COMPRESS = -echo +#EXE_COMPRESS = upx --best + +# Default compiler switches. In djgpp.env. under [make], +# add the line "BUTT=-mcpu=i386", if that is your target, +# or directly add -mcpu here. +# At present gcc supports 'i386', 'i486', 'i586' ('pentium'), +# 'i686' ('pentiumpro') and 'k6'. +#CCOPT += $(BUTT) +#CCOPT += -mcpu=i586 + +# GRX uses "uclock" to gets 1 ms resolution in the input code, +# this can causes problems in Win3.1, so you may want to enable +# the following switch +#CCOPT += -DNO_REPROGRAM_TIMER + +endif + +### WIN32 MINGW SPECIFIC ################################################# + +ifdef GRXVW32 + +# Put libgrx20.a and libgrx20S.a to lib/win32 +GRX_LIB_SUBDIR=win32 + +# Set here the destination dir for install and uninstall targets +prefix=C:\MINGW + +# Set the default GRX font path +#GRX_DEFAULT_FONT_PATH=c:/grxfonts + +endif + +### COMMON ############################################################## + +exec_prefix=${prefix} + +bindir=${exec_prefix}/bin +libdir=${exec_prefix}/lib +datadir=${prefix}/share + +infodir=${prefix}/info +includedir=${prefix}/include +unitsdir=${exec_prefix}/units + +########################################################################## + diff --git a/thirdparty/grx249/makefile.bcc b/thirdparty/grx249/makefile.bcc new file mode 100644 index 0000000..df23c20 --- /dev/null +++ b/thirdparty/grx249/makefile.bcc @@ -0,0 +1,35 @@ +# +# GRX 2.0 makefile for Borland C distribution version +# +!include "makedefs.bcc" + +all: libs test bgitest + +libs: + cd src + $(MAKE) + cd .. + +test: libs + cd test + $(MAKE) + cd .. + +bgitest: libs + cd test\bgi + $(MAKE) + cd ..\.. + +clean: + cd src + $(MAKE) clean + cd ..\test + $(MAKE) clean + cd bgi + $(MAKE) clean + cd ..\.. + +cleanall: clean + cd src + $(MAKE) cleanall + cd .. diff --git a/thirdparty/grx249/makefile.dj2 b/thirdparty/grx249/makefile.dj2 new file mode 100644 index 0000000..00cb852 --- /dev/null +++ b/thirdparty/grx249/makefile.dj2 @@ -0,0 +1,69 @@ +# +# GRX makefile for DJGPPv2 version +# +.PHONY : libs test bgitest clean cleanall install uninstall \ + install-bin uninstall-bin install-fonts uninstall-fonts \ + install-info uninstall-info + +GRXVDJ2=y + +include makedefs.grx + +all: libs test bgitest + +libs: + $(MAKE) -C src -f makefile.dj2 + +test: libs + $(MAKE) -C test -f makefile.dj2 +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal -f makefile.dj2 +endif + +bgitest: libs +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C test/bgi -f makefile.dj2 +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal/bgi -f makefile.dj2 +endif +endif + +clean: + $(MAKE) -C test -f makefile.dj2 clean +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C test/bgi -f makefile.dj2 clean +endif + $(MAKE) -C src -f makefile.dj2 clean +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal -f makefile.dj2 clean +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C pascal/bgi -f makefile.dj2 clean +endif +endif + +cleanall: clean + $(MAKE) -C src -f makefile.dj2 cleanall + +install: + $(MAKE) -C src -f makefile.dj2 install + +uninstall: + $(MAKE) -C src -f makefile.dj2 uninstall + +install-info: + $(MAKE) -C src -f makefile.dj2 install-info + +uninstall-info: + $(MAKE) -C src -f makefile.dj2 uninstall-info + +install-bin: + $(MAKE) -C src -f makefile.dj2 install-bin + +uninstall-bin: + $(MAKE) -C src -f makefile.dj2 uninstall-bin + +install-fonts: + $(MAKE) -C src -f makefile.dj2 install-fonts + +uninstall-fonts: + $(MAKE) -C src -f makefile.dj2 uninstall-fonts diff --git a/thirdparty/grx249/makefile.lnx b/thirdparty/grx249/makefile.lnx new file mode 100644 index 0000000..4612440 --- /dev/null +++ b/thirdparty/grx249/makefile.lnx @@ -0,0 +1,77 @@ +# +# GRX makefile for LINUX/console version +# +.PHONY : libs test bgitest clean cleanall install uninstall setsuid \ + install-bin uninstall-bin install-fonts uninstall-fonts \ + install-info uninstall-info + +GRXVLNX=y + +include makedefs.grx + +all: libs test bgitest + +libs: + $(MAKE) -C src -f makefile.lnx + +test: libs + $(MAKE) -C test -f makefile.lnx +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal -f makefile.lnx +endif + +bgitest: libs +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C test/bgi -f makefile.lnx +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal/bgi -f makefile.lnx +endif +endif + +clean: + $(MAKE) -C test -f makefile.lnx clean +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C test/bgi -f makefile.lnx clean +endif + $(MAKE) -C src -f makefile.lnx clean +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal -f makefile.lnx clean +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C pascal/bgi -f makefile.lnx clean +endif +endif + +cleanall: clean + $(MAKE) -C src -f makefile.lnx cleanall + +install: + $(MAKE) -C src -f makefile.lnx install + +uninstall: + $(MAKE) -C src -f makefile.lnx uninstall + +install-info: + $(MAKE) -C src -f makefile.lnx install-info + +uninstall-info: + $(MAKE) -C src -f makefile.lnx uninstall-info + +install-bin: + $(MAKE) -C src -f makefile.lnx install-bin + +uninstall-bin: + $(MAKE) -C src -f makefile.lnx uninstall-bin + +install-fonts: + $(MAKE) -C src -f makefile.lnx install-fonts + +uninstall-fonts: + $(MAKE) -C src -f makefile.lnx uninstall-fonts + +setsuid: + $(MAKE) -C src -f makefile.lnx setsuid + $(MAKE) -C test -f makefile.lnx setsuid +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C test/bgi -f makefile.lnx setsuid +endif + diff --git a/thirdparty/grx249/makefile.sdl b/thirdparty/grx249/makefile.sdl new file mode 100644 index 0000000..c936fa8 --- /dev/null +++ b/thirdparty/grx249/makefile.sdl @@ -0,0 +1,62 @@ +# +# GRX makefile for SDL version +# +.PHONY : libs test bgitest clean cleanall install uninstall \ + install-bin uninstall-bin install-fonts uninstall-fonts + +GRXVSDL=y + +include makedefs.grx + +all: libs test bgitest + +libs: + $(MAKE) -C src -f makefile.sdl + +test: libs + $(MAKE) -C test -f makefile.sdl +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal -f makefile.sdl +endif + +bgitest: libs +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C test/bgi -f makefile.sdl +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal/bgi -f makefile.sdl +endif +endif + +clean: + $(MAKE) -C test -f makefile.sdl clean +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C test/bgi -f makefile.sdl clean +endif + $(MAKE) -C src -f makefile.sdl clean +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal -f makefile.sdl clean +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C pascal/bgi -f makefile.sdl clean +endif +endif + +cleanall: clean + $(MAKE) -C src -f makefile.sdl cleanall + +install: + $(MAKE) -C src -f makefile.sdl install + +uninstall: + $(MAKE) -C src -f makefile.sdl uninstall + +install-bin: + $(MAKE) -C src -f makefile.sdl install-bin + +uninstall-bin: + $(MAKE) -C src -f makefile.sdl uninstall-bin + +install-fonts: + $(MAKE) -C src -f makefile.sdl install-fonts + +uninstall-fonts: + $(MAKE) -C src -f makefile.sdl uninstall-fonts diff --git a/thirdparty/grx249/makefile.w32 b/thirdparty/grx249/makefile.w32 new file mode 100644 index 0000000..e2f653e --- /dev/null +++ b/thirdparty/grx249/makefile.w32 @@ -0,0 +1,62 @@ +# +# GRX makefile for Mingw version +# +.PHONY : libs test bgitest clean cleanall install uninstall \ + install-bin uninstall-bin install-fonts uninstall-fonts + +GRXVW32=y + +include makedefs.grx + +all: libs test bgitest + +libs: + $(MAKE) -C src -f makefile.w32 + +test: libs + $(MAKE) -C test -f makefile.w32 +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal -f makefile.w32 +endif + +bgitest: libs +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C test/bgi -f makefile.w32 +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal/bgi -f makefile.w32 +endif +endif + +clean: + $(MAKE) -C test -f makefile.w32 clean +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C test/bgi -f makefile.w32 clean +endif + $(MAKE) -C src -f makefile.w32 clean +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal -f makefile.w32 clean +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C pascal/bgi -f makefile.w32 clean +endif +endif + +cleanall: clean + $(MAKE) -C src -f makefile.w32 cleanall + +install: + $(MAKE) -C src -f makefile.w32 install + +uninstall: + $(MAKE) -C src -f makefile.w32 uninstall + +install-bin: + $(MAKE) -C src -f makefile.w32 install-bin + +uninstall-bin: + $(MAKE) -C src -f makefile.w32 uninstall-bin + +install-fonts: + $(MAKE) -C src -f makefile.w32 install-fonts + +uninstall-fonts: + $(MAKE) -C src -f makefile.w32 uninstall-fonts diff --git a/thirdparty/grx249/makefile.wat b/thirdparty/grx249/makefile.wat new file mode 100644 index 0000000..2421abe --- /dev/null +++ b/thirdparty/grx249/makefile.wat @@ -0,0 +1,105 @@ +################## +## Include Directories + +!ifndef %INCLUDE +## DEFAULT +WATCOM_HEADER_DIR=C:\WATCOM\H +!else +WATCOM_HEADER_DIR=$(%INCLUDE) +!endif + + +################## +## Locations + +GRX_LIB_SUBDIR=watcom32 +GRX_BIN_SUBDIR=bin + +################## +## Binaries + +CC = wcc386 +LIB = wlib +LINK = wlink + +################## +## Binary Flags and Options + +!ifdef DEBUG + +################## +## DEBUG FLAGS +CC_OPTS = -i=$(WATCOM_HEADER_DIR);.\include;.\src\include;.\src;.\addons\print;.\addons\bmp -w4 & +-e25 -d__MSDOS__ -dSMALL_STACK -dLFB_BY_NEAR_POINTER -dUSE_WATCOM386_ASM -dDEBUG=0x7800 -zq -od -d2 -5r & +-bt=dos -mf +LIB_OPTS = -b -c -n -q -p=512 +LINK_OPTS = d all SYS dos4g op inc op m op maxe=25 op q op symf + +!else + +################## +## RELEASE FLAGS +CC_OPTS = -i=$(WATCOM_HEADER_DIR);.\include;.\src\include;.\src;.\addons\print;.\addons\bmp -w4 & +-e25 -d__MSDOS__ -dSMALL_STACK -dLFB_BY_NEAR_POINTER -dUSE_WATCOM386_ASM -zq -otexan -d1 -5r & +-bt=dos -mf +LIB_OPTS = -b -c -n -q -p=512 +LINK_OPTS = SYS dos4g op inc op m op maxe=25 op q op symf + +!endif + +################## +## Targets + +GRXVERSION = 229 +GRXLIB = lib\$(GRX_LIB_SUBDIR)\grx$(GRXVERSION).lib +GRXLINK = wat32mak.lb1 +GRXTESTS = $(GRX_BIN_SUBDIR)\modetest.exe & +$(GRX_BIN_SUBDIR)\arctest.exe & +$(GRX_BIN_SUBDIR)\blittest.exe & +$(GRX_BIN_SUBDIR)\circtest.exe & +$(GRX_BIN_SUBDIR)\cliptest.exe & +$(GRX_BIN_SUBDIR)\colorops.exe & +$(GRX_BIN_SUBDIR)\curstest.exe & +$(GRX_BIN_SUBDIR)\fonttest.exe & +$(GRX_BIN_SUBDIR)\imgtest.exe & +$(GRX_BIN_SUBDIR)\fnt2c.exe & +$(GRX_BIN_SUBDIR)\fnt2text.exe & +$(GRX_BIN_SUBDIR)\keys.exe & +$(GRX_BIN_SUBDIR)\life.exe & +$(GRX_BIN_SUBDIR)\linetest.exe & +$(GRX_BIN_SUBDIR)\mousetst.exe & +$(GRX_BIN_SUBDIR)\pcirctst.exe & +$(GRX_BIN_SUBDIR)\polytest.exe & +$(GRX_BIN_SUBDIR)\rgbtest.exe & +$(GRX_BIN_SUBDIR)\scroltst.exe & +$(GRX_BIN_SUBDIR)\speedtst.exe & +$(GRX_BIN_SUBDIR)\textpatt.exe & +$(GRX_BIN_SUBDIR)\winclip.exe & +$(GRX_BIN_SUBDIR)\wintest.exe & +$(GRX_BIN_SUBDIR)\arctest.dat & +$(GRX_BIN_SUBDIR)\polytest.dat + + + +################## +## Rules + +all : lib tests .SYMBOLIC + +lib : $(GRXLIB) .SYMBOLIC + +tests : $(GRXTESTS) .SYMBOLIC + + +clean : .SYMBOLIC + @del *.obj + @del *.err + @del *.lb1 + @del *.lk1 + @del *.map + @del $(GRX_BIN_SUBDIR)\*.ilk + @del $(GRX_BIN_SUBDIR)\*.sym + +!include .\src\makefile.wat + +!include .\test\makefile.wat diff --git a/thirdparty/grx249/makefile.x11 b/thirdparty/grx249/makefile.x11 new file mode 100644 index 0000000..c114535 --- /dev/null +++ b/thirdparty/grx249/makefile.x11 @@ -0,0 +1,69 @@ +# +# GRX makefile for LINUX/X11 version (GNU-make) +# +.PHONY : libs test bgitest clean cleanall install uninstall \ + install-bin uninstall-bin install-fonts uninstall-fonts \ + install-info uninstall-info + +GRXVX11=y + +include makedefs.grx + +all: libs test bgitest + +libs: + $(MAKE) -C src -f makefile.x11 + +test: libs + $(MAKE) -C test -f makefile.x11 +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal -f makefile.x11 +endif + +bgitest: libs +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C test/bgi -f makefile.x11 +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal/bgi -f makefile.x11 +endif +endif + +clean: + $(MAKE) -C test -f makefile.x11 clean +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C test/bgi -f makefile.x11 clean +endif + $(MAKE) -C src -f makefile.x11 clean +ifeq ($(INCLUDE_GPC_SUPPORT),y) + $(MAKE) -C pascal -f makefile.x11 clean +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(MAKE) -C pascal/bgi -f makefile.x11 clean +endif +endif + +cleanall: clean + $(MAKE) -C src -f makefile.x11 cleanall + +install: + $(MAKE) -C src -f makefile.x11 install + +uninstall: + $(MAKE) -C src -f makefile.x11 uninstall + +install-info: + $(MAKE) -C src -f makefile.x11 install-info + +uninstall-info: + $(MAKE) -C src -f makefile.x11 uninstall-info + +install-bin: + $(MAKE) -C src -f makefile.x11 install-bin + +uninstall-bin: + $(MAKE) -C src -f makefile.x11 uninstall-bin + +install-fonts: + $(MAKE) -C src -f makefile.x11 install-fonts + +uninstall-fonts: + $(MAKE) -C src -f makefile.x11 uninstall-fonts diff --git a/thirdparty/grx249/pascal/bgi/allmodes.pas b/thirdparty/grx249/pascal/bgi/allmodes.pas new file mode 100644 index 0000000..93e4413 --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/allmodes.pas @@ -0,0 +1,84 @@ +{$X+} + +program AllModes; +{ + * test and demo program for the Graph unit + * + * Please read the copyright notices of graph.pas + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Author : Sven Hilscher + * e-mail : sven@rufus.central.de +} + +uses + Graph; + +function MyStr(Numeric, Len: Integer):WrkString; +var + RetString : WrkString; +begin + str(Numeric:Len, RetString); + MyStr := RetString; +end; + + +var + i, c, + grDriver, + grMode, + ErrCode: Integer; + +begin + grDriver := Detect; + { grDriver := InstallUserDriver('SVGA256', nil); Not used in GPC } + InitGraph(grDriver, grMode,'../../chr'); + ErrCode := GraphResult; + if ErrCode = GrOk then + begin { Do graphics } + for i := 0 to GetMaxMode do + begin + SetGraphMode(i); + + if GetMaxColor < 256 then + for c := 1 to GetMaxColor-1 do begin + begin + SetRGBPalette(c,c,0,255-c); + SetColor(c); + Line(c + 10, 5, c + 10, 30) + end; + SetRGBPalette(GetMaxColor,255,255,255); + SetColor(GetMaxColor) + end else begin + for c := 0 to 255 do + begin + SetColor(c); + Line(c + 10, 5, c + 10, 30) + end; + SetColor(White) + end; + + OutTextXY(10,40, GetDriverName); + OutTextXY(10,50, 'Resolution : ' + MyStr(GetMaxX + 1, 4) + ' x' + MyStr(GetMaxY + 1, 4)); + OutTextXY(10,60, 'Colors : ' + MyStr(GetMaxColor + 1, 10)); + OutTextXY(10,80, 'ActMode : ' + MyStr(i , 4)); + OutTextXY(10,90, 'ModeName : ' + GetModeName(i) ); + OutTextXY(10,140,'Press Enter'); + + Rectangle(0,0,GetMaxX,GetMaxY); + Rectangle(2,2,GetMaxX-2,GetMaxY-2); + + ReadKey; + end; + CloseGraph + end + else begin + Writeln('Graphics error:', GraphErrorMsg(ErrCode)); + Write ('Press Enter ...'); + ReadLn + end +end. + diff --git a/thirdparty/grx249/pascal/bgi/colors.pas b/thirdparty/grx249/pascal/bgi/colors.pas new file mode 100644 index 0000000..ca03330 --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/colors.pas @@ -0,0 +1,108 @@ +{$X+} + +program Colors; +{ + * test and demo program for the Graph unit + * + * Please read the copyright notices of graph.pas + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Author : Sven Hilscher + * e-mail : sven@rufus.central.de +} + +uses + Graph; + +var + i, grDriver, grMode, ErrCode: Integer; + +procedure ShowColors(Mode: Word); +var + y: Word; + f1, f2: Real; +begin + { Show only 8 bit, hicolor and truecolor modes } + if GetMaxColor < 255 then return; + { Show only 640 x 480 modes } + { if (GetMaxX <> 639) or (GetMaxY <> 479) then return; } + + f1 := GetMaxY / 64; + f2 := GetMaxY / 256; + + { Red } + for y := 0 to GetMaxY do begin + if GetMaxColor = 255 then begin + SetRGBPalette(trunc(y / f1), trunc(y / f1), 0, 0); + SetColor(trunc(y / f1)) + end + else + SetRGBColor(trunc(y / f2), 0, 0); + Line(0, y, GetMaxX div 4, y) + end; + + { Green } + for y := 0 to GetMaxY do begin + if GetMaxColor = 255 then begin + SetRGBPalette(64 + trunc(y / f1), 0, trunc(y / f1), 0); + SetColor(64 + trunc(y / f1)) + end + else + SetRGBColor(0, trunc(y / f2), 0); + Line(GetMaxX div 4, y, GetMaxX div 2, y) + end; + + { Blue } + for y := 0 to GetMaxY do begin + if GetMaxColor = 255 then begin + SetRGBPalette(128 + trunc(y / f1), 0, 0, trunc(y / f1)); + SetColor(128 + trunc(y / f1)) + end + else + SetRGBColor(0, 0, trunc(y / f2)); + Line(GetMaxX div 2, y, GetMaxX - GetMaxX div 4, y) + end; + + { Gray } + for y := 0 to GetMaxY do begin + if GetMaxColor = 255 then begin + SetRGBPalette(192 + trunc(y / f1), trunc(y / f1), trunc(y / f1), trunc(y / f1)); + SetColor(192 + trunc(y / f1)) + end + else + SetRGBColor(trunc(y / f2), trunc(y / f2), trunc(y / f2)); + Line(GetMaxX - GetMaxX div 4, y, GetMaxX, y) + end; + + if GetMaxColor = 255 then + SetColor(255) + else + SetColor(White); + OutTextXY(10, 2, GetModeName(Mode)) ; + Rectangle(0,0,GetMaxX,GetMaxY); + ReadKey +end; + +begin + grDriver := Detect; + InitGraph(grDriver, grMode,'../../chr'); + ErrCode := GraphResult; + if ErrCode = GrOk then + begin { Do graphics } + for i := 0 to GetMaxMode do + begin + SetGraphMode(i); + ShowColors(i) + end; + CloseGraph + end + else begin + Writeln('Graphics error:', GraphErrorMsg(ErrCode)); + Write ('Press Enter ...'); + ReadLn + end +end. + diff --git a/thirdparty/grx249/pascal/bgi/demo.pas b/thirdparty/grx249/pascal/bgi/demo.pas new file mode 100644 index 0000000..4c2e90e --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/demo.pas @@ -0,0 +1,547 @@ +program Demo; +{ + * test and demo program for the Graph unit + * + * Please read the copyright notices of graph.pas + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Author : Sven Hilscher + * e-mail : sven@rufus.central.de +} + +uses +(*$ifdef __GPC__ *) + Graph; +(*$else *) + graph, crt; +(*$endif*) + +var + Test, Corr: Real; + +procedure Pause; +const + ESC = #$1b; +var + c: Char; +begin + c := ReadKey; + if c=ESC then begin + CloseGraph; + Halt(1) + end; + if ord(c )= 0 then + c := ReadKey; + ClearDevice; +end; + +function MyStr(Numeric, Len: Integer):WrkString; +var + RetString: WrkString; +begin + str(Numeric: Len, RetString); + MyStr := RetString +end; + +procedure ColorSetup; +var i: Integer; +begin + if GetMaxColor < 2 then + else if GetMaxColor < 16 then + for i := 1 to 14 do + SetRGBPalette(i, random(64), random(64), random(64)) + else if GetMaxColor < 256 then begin + for i := 0 to 63 do begin + if i > 32 then begin + SetRGBPalette(i , i, i - random(16), i - random(16)); + SetRGBPalette(i + 64, i - random(16), i, i - random(16)); + SetRGBPalette(i + 128, i - random(16), i - random(16), i); + SetRGBPalette(i + 192, i - random(16), i - random(16), i - random(16)) + end + else begin + SetRGBPalette(i, i, i + random(16), i + random(16)); + SetRGBPalette(i + 64, i + random(16), i, i + random(16)); + SetRGBPalette(i + 128, i + random(16), i + random(16), i); + SetRGBPalette(i + 192, i + random(16), i + random(16), i + random(16)) + end; + { Set entry 15 to white for text } + SetRGBPalette(15, 63, 63, 63); + { Set entry 0 to black for text } + SetRGBPalette(0, 0, 0, 0) + end + end +end; + +procedure StartTest(HeadLine: WrkString); +begin + ClearDevice; + SetColor(White); + SetTextStyle(0,0,0); + SetTextJustify(CenterText, TopText); + OutTextXY(GetMaxX div 2, 0, HeadLine + ' Demo - Hit Any Key ...'); + SetTextJustify(LeftText, TopText); + Line(0, 9, GetMaxX, 9) +end; + +procedure SetRandomColor; +var i, c : Integer; +begin + if GetMaxColor < 256 then begin + SetColor(random(GetMaxColor + 1)); + SetFillStyle(random(UserFill + 1), random(GetMaxColor + 1)); + end + else begin + (*$ifdef __GPC__ *) + i := random(4); + c := random(128) + 32; + case i of + 0: SetRGBColor(c, c - random(32), c + random(32)); + 1: SetRGBColor(c - random(32), c + random(32), c); + 2: SetRGBColor(c + random(32), c, c - random(32)); + else + SetRGBColor(c, c, c) + end; + SetFillStyle(random(UserFill + 1), random(255) shl 16 + random(255) shl 8 + random(255)) + (*$endif*) + end; +end; + +procedure BGIInfo(Mode: Integer); +var + x, y: Integer; +begin + StartTest('Info Functions'); + OutTextXY( 2, 20, 'GetDriverName : ' + GetDriverName); + OutTextXY( 2, 30, 'GetMaxMode : ' + MyStr(GetMaxMode , 10)); + OutTextXY( 2, 40, 'GetGraphMode : ' + MyStr(GetGraphMode , 10)); + OutTextXY( 2, 50, 'GetModeName : ' + GetModeName(Mode)); + OutTextXY( 2, 70, 'GetMaxColor : ' + MyStr(GetMaxColor , 10)); + OutTextXY( 2, 80, 'GetPaletteSize : ' + MyStr(GetPaletteSize, 10)); + OutTextXY( 2,100, 'GetMaxX : ' + MyStr(GetMaxX , 10)); + OutTextXY( 2,110, 'GetMaxY : ' + MyStr(GetMaxY , 10)); + GetAspectRatio(x, y); + Corr := ((GetMaxY+1)/(GetMaxX+1)) / 0.75; + OutTextXY( 2,120, 'GetAspectRatio->X : ' + MyStr(x , 10)); + OutTextXY( 2,130, 'GetAspectRatio->Y : ' + MyStr(y , 10)); + OutTextXY( 2,150, 'ImageSize(1,8,1,8) : ' + MyStr(ImageSize(1, 8, 1, 8), 10)); + repeat + until KeyPressed; + Pause; +end; + +procedure LineTest; +begin + StartTest('Line'); + repeat + SetRandomColor; + Line(0, random(GetMaxY)+10, GetMaxX, random(GetMaxY)+10); + Line(random(GetMaxX), 10, random(GetMaxX), GetMaxY); + until KeyPressed; + Pause; +end; + +procedure RectangleTest; +begin + StartTest('Rectangle'); + repeat + SetRandomColor; + Rectangle(random(GetMaxX), random(GetMaxY-10)+10, random(GetMaxX), random(GetMaxY-10)+10); + until KeyPressed; + Pause; +end; + +procedure BarTest; +begin + StartTest('Bar'); + repeat + SetRandomColor; + Bar(random(GetMaxX), random(GetMaxY-10)+10, random(GetMaxX), random(GetMaxY-10)+10); + until KeyPressed; + Pause; +end; + +procedure CircleTest; +var + r: Integer; +begin + StartTest('Circle'); + repeat + SetRandomColor; + r := random(GetMaxX div 3) + 1; + Circle(random(GetMaxX - 2 * r) + r, random(GetMaxY - (2 * Round(r * Corr) + 10)) + Round(r * Corr) + 10, Round(r*Corr)); + until KeyPressed; + Pause; +end; + +procedure EllipseTest; +var + rx, ry: Word; +begin + StartTest('Ellipse'); + repeat + SetRandomColor; + rx := random(GetMaxX div 3); + ry := random(GetMaxY div 3); + Ellipse(random(GetMaxX - 2 * rx) + rx, random(GetMaxY-(2 * ry + 10)) + ry + 10, 0, 359, + Round(rx * Corr), Round(ry * Corr)); + until KeyPressed; + Pause; +end; + +procedure Ellipse2Test; +var + i: Word; +begin + StartTest('Ellipse 2.'); + for i := 20 to GetMaxX div 2 do begin + SetRandomColor; + Test := i; + Ellipse(GetMaxX div 2, GetMaxY div 2 + 5, 0, Round(i * (720 / GetMaxX)), + i, Round(i * GetMaxY / GetMaxX) - 6); + end; + repeat + until KeyPressed; + Pause; +end; + +procedure FillEllipseTest; +var + rx, ry: Word; +begin + StartTest('FillEllipse'); + repeat + SetRandomColor; + rx := random(GetMaxX div 3); + ry := random(GetMaxY div 3); + FillEllipse(random(GetMaxX - 2 * rx) + rx, random(GetMaxY-(2 * Round(ry * Corr) + 10)) + Round(ry * Corr) + 10, + Round(rx * Corr), Round(ry * Corr)); + until KeyPressed; + Pause; +end; + +procedure ArcTest; +var + r: Word; +begin + StartTest('Arc'); + repeat + SetRandomColor; + r := random(GetMaxX div 3); + Arc(random(GetMaxX - 2 * r) + r, random(GetMaxY-(2 * Round(r * Corr) + 10)) + Round(r * Corr) + 10, 0, random(360), + Round(r * Corr)); + until KeyPressed; + Pause; +end; + +procedure SectorTest; +var + rx, ry: Word; +begin + StartTest('Sector'); + repeat + SetRandomColor; + rx := random(GetMaxX div 3); + ry := random(GetMaxY div 3); + Sector(random(GetMaxX - 2 * rx) + rx, random(GetMaxY-(2 * Round(ry * Corr) + 10)) + Round(ry * Corr) + 10, + random(360), random(360), Round(rx * Corr), Round(ry * Corr)); + until KeyPressed; + Pause; +end; + +procedure PieSliceTest; +var + r: Word; +begin + StartTest('PieSlice'); + repeat + SetRandomColor; + r := random(GetMaxX div 3); + PieSlice(random(GetMaxX - 2 * r) + r, random(GetMaxY-(2 * Round(r * Corr) + 10)) + Round(r * Corr) + 10, 0, random(360), + Round(r * Corr)); + until KeyPressed; + Pause; +end; + +procedure Bar3DTest; +var + i, h, n: Word; +begin + StartTest('Bar3D'); + n := GetMaxX div 50; + for i := 0 to (n - 1) do begin + SetRandomColor; + h := random(GetMaxY-30); + Bar3D((GetMaxX div n) * i + 2, GetMaxY -15, (GetMaxX div n) * i + (GetMaxX div n - 12), GetMaxY - (15 + h), 10, TopOn); + OutTextXY((GetMaxX div n) * i + 2, GetMaxY -12, MyStr(h,4)); + end; + repeat + until KeyPressed; + Pause; +end; + +procedure PolyTest; +var + j : Word; + a : array[1..4] of PointType; +begin + StartTest('Poly'); + repeat + SetRandomColor; + for j := 1 to 4 do begin + a[j].x := random(GetMaxX); + a[j].y := random(GetMaxY - 10) + 10; + end; + DrawPoly(4, a); + until KeyPressed; + Pause; +end; + +procedure FillPolyTest; +var + j : Word; + a : array[1..4] of PointType; +begin + StartTest('FillPoly'); + repeat + SetRandomColor; + for j := 1 to 4 do begin + a[j].x := random(GetMaxX); + a[j].y := random(GetMaxY - 10) + 10; + end; + FillPoly(4, a); + until KeyPressed; + Pause; +end; + +procedure FloodFillTest; +var + x, y: Word; + r, p : Real; +begin + StartTest('LineTo/FloodFill'); + repeat + SetRandomColor; + p := 0; { Angle } + r := 10; { Radius } + x := GetMaxX div 2; + y := 10 + GetMaxY div 2 + 10; + MoveTo(x, y); + repeat + p := p + (Pi / 20); + r := r + 0.5; + x := Round(sin(p) * r ) + GetMaxX div 2; + y := Round(cos(p) * (r * Corr)) + GetMaxY div 2 + 10; + LineTo(x, y); + until ((r + 1) * Corr) > GetMaxY div 2 - 5; + Rectangle(0, 10, GetMaxX, GetMaxY); + FloodFill(GetMaxX div 2,GetMaxY div 2 + 10, GetColor); + until KeyPressed; + Pause; +end; + + +procedure ImageTest; +const + d = 8; +var + p1, p2 : ^Byte; + Size, + x, y, c, + i, j : Word; + +begin + StartTest('GetImage/PutImage'); + + { Draw a little ball } + SetFillStyle(SolidFill, White); + FillEllipse(30, 25, 15, 15); + for j := 0 to 20 do + for i := 0 to 20 do PutPixel(2 * j + 10, 2 * i + 10, 0); + + Size := ImageSize(10, 10, 50, 40); + GetMem(p1, Size); + GetMem(p2, Size); + GetImage(10, 10, 50, 40, p1^); + + { Clear the litte ball } + GetImage(110, 110, 150, 140, p2^); + PutImage(10, 10, p2^, NormalPut); + + for i := 1 to 50 do begin + SetRandomColor; + c := GetColor; + for j := 1 to 50 do begin + PutPixel(random(GetMaxX), random(GetMaxY - 10) + 10, c) + end; + end; + x := GetMaxX div 2; + y := GetMaxY div 2; + repeat + if x < d * 3 then + x := x + random(d) + else + if x > GetMaxX - d * 3 then + x := x - random(d) + else + x := x + d - random(d * 2 + 1); + + if y < d * 3 then + y := y + random(d) + else + if y > GetMaxY - d * 3 then + y := y - random(d) + else + y := y + d - random(d * 2 + 1); + + GetImage(x, y, x+40, y+30, p2^); + PutImage(x, y, p1^, OrPut); + for i := 1 to 50 do begin + SetRandomColor; + c := GetColor; + for j := 1 to 50 do begin + PutPixel(random(GetMaxX), random(GetMaxY - 10) + 10, c) + end; + end; + PutImage(x, y, p2^, NormalPut); + until KeyPressed; + Pause; + FreeMem(p1, Size); + FreeMem(p2, Size); +end; + +procedure TextTest; +var + FontName: array[0..10] of WrkString; + i, Pos : Word; +begin + StartTest('Text'); + repeat + SetRandomColor; + OutTextXY(random(GetMaxX - 100), random(GetMaxY - 10) + 10, 'OutTextXY DefaultFont'); + until KeyPressed; + Pause; + StartTest('Vector Fonts'); + repeat + SetRandomColor; + SetTextStyle(random(10)+1, random(2), random(20) + 6); + OutTextXY(random(GetMaxX - 100), random(GetMaxY - 10), 'Vector Fonts'); + until KeyPressed; + Pause; + StartTest('Font Names'); + FontName[ 0] := 'DefaultFont'; + FontName[ 1] := 'TriplexFont'; + FontName[ 2] := 'SmallFont'; + FontName[ 3] := 'SansSerifFont'; + FontName[ 4] := 'GothicFont'; + FontName[ 5] := 'ScriptFont'; + FontName[ 6] := 'SimplexFont'; + FontName[ 7] := 'TriplexScrFont'; + FontName[ 8] := 'ComplexFont'; + FontName[ 9] := 'EuropeanFont'; + FontName[10] := 'BoldFont'; + Pos := 0; + for i := 0 to 10 do begin + SetTextStyle(i, HorizDir, 0); + OutTextXY(10, Pos + 12, chr(i div 10 + 48) + chr(i mod 10 + 48) + ' ' + FontName[i]); + Inc(Pos, TextHeight('H') + 2); + end; + repeat + until KeyPressed; + Pause; + StartTest('Vertical Fonts'); + Pos := 0; + for i := 0 to 10 do begin + SetTextStyle(i, VertDir, 0); + OutTextXY(Pos + 10, 12, chr(i div 10 + 48) + chr(i mod 10 + 48) + ' ' + FontName[i]); + Inc(Pos, TextHeight('H') + 2); + end; + repeat + until KeyPressed; + Pause; + StartTest('SetTextJustify'); + for i := 1 to 10 do begin + SetTextJustify(CenterText, TopText); + if GetMaxX < 320 then + SetTextStyle(SmallFont, HorizDir, 5) + else + SetTextStyle(SmallFont, HorizDir, 7); + OutTextXY(GetMaxX div 2, GetMaxY div 2 - 60, 'That''s all friends'); + OutTextXY(GetMaxX div 2, GetMaxY div 2 - 20, 'Have a good time while using'); + OutTextXY(GetMaxX div 2, GetMaxY div 2 + 20, 'GPC and GRX !'); + SetTextStyle(DefaultFont, HorizDir, 0); + OutTextXY(GetMaxX div 2, GetMaxY div 2 + 80, 'Contact me: sven@rufus.central.de'); + end; + repeat + until KeyPressed; + Pause; + +end; + +var + m, grDriver, grMode, ErrCode: Integer; + ModeName: array[0..200] of WrkString; + +begin + { Try different drivers in Borland Pascal } + { No difference in GPC } + + grDriver := Detect; + { grDriver := CGA; } + { grDriver := MCGA; } + { grDriver := EGA; } + { grDriver := EGA64; } + { grDriver := EGAMono; } + { grDriver := VGA; } + { grDriver := InstallUserDriver('svga256', nil) } + + InitGraph(grDriver, grMode,'../../chr'); + ErrCode := GraphResult; + if ErrCode = GrOk then + begin { Do graphics } + m := GetMaxMode; + for grMode := 0 to m do + ModeName[grMode] := GetModeName(grMode); + grMode := -1; + CloseGraph; + while (grMode < 0) or (grMode > m) do begin + WriteLn; + for grMode := 0 to m do begin + if grMode mod 2 = 0 then WriteLn; + Write(' #',grMode:1, ' = "', ModeName[grMode],'"'); + end; + WriteLn; + Write('Modenumber (0..',m:1,') : '); + ReadLn(grMode); + end; + m := grMode; + InitGraph(grDriver, grMode,'../../chr'); + SetGraphMode(m); + ColorSetup; + BGIInfo(m); + LineTest; + RectangleTest; + BarTest; + CircleTest; + EllipseTest; + Ellipse2Test; + FillEllipseTest; + ArcTest; + Bar3DTest; + SectorTest; + PieSliceTest; + PolyTest; + FillPolyTest; + FloodFillTest; + ImageTest; + TextTest; + CloseGraph; + end + else begin + WriteLn ('Graphics error:', GraphErrorMsg(ErrCode)); + Write ('Press Enter ...'); + ReadLn + end; +end. diff --git a/thirdparty/grx249/pascal/bgi/graph.pas b/thirdparty/grx249/pascal/bgi/graph.pas new file mode 100644 index 0000000..c0dc978 --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/graph.pas @@ -0,0 +1,659 @@ +{ Graph - Interfacing BGI based graphics programs to LIBGRX + Copyright (C) 96 by Sven Hilscher + + This file is part of the GRX graphics library. + + The GRX graphics library is free software; you can redistribute it + and/or modify it under some conditions; see the "copying.grx" file + for details. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + Author: Sven Hilscher + e-mail: sven@rufus.lan-ks.de + + Version 1.0 12/96 + + 22/02/01 patches by Maurice Lombardi + Necessary to correct the drawpoly and fillpoly declarations. + + Maurice Lombardi, Frank Heckenbach : Some changes + to make this file compile with more recent versions of GPC. } + +{ Define this if you don't want this unit to declare a KeyPressed + and a ReadKey function. } +{.$define NO_GRAPH_KEY_FUNCTIONS} + +{ Define this if you want to use the Linux console version. + (Ignored on non-Linux systems.) } +{.$define LINUX_CONSOLE} + {and this if you use the svgalib (instead of only the framebuffer) driver} +{.$define SVGALIB} + +{ Define this if you want to use the SDL driver in mingw or x11} +{.$define __SDL__} + +{$gnu-pascal,I-} +{$ifdef __DJGPP__} + {$L grx20} +{$elif defined (__MINGW32__)} + {$ifdef __SDL__} + {$L grx20S, SDL} + {$else} + {$L grx20} + {$endif} +{$elif defined (_WIN32)} + {$L grxW32, vfs.c, user32, gdi32} +{$elif defined (linux) and defined (LINUX_CONSOLE)} + {$L grx20} + {$ifdef SVGALIB} + {$L vga} + {$endif} +{$else} + {$ifdef __SDL__} + {$L grx20S, SDL, pthread, X11} + {$else} + {$L grx20X, X11} + {$endif} +{$endif} + +{ Uncomment those of the following libraries that you need } +{.$L tiff} +{.$L jpeg} +{.$L png} +{.$L z} +{.$L socket} + +unit Graph; + +interface + +{$if __GPC_RELEASE__ >= 20030303} +{$define asmname external name} +{$define varasmname external name} +{$else} +{$define varasmname external; asmname} +{$endif} +{$if __GPC_RELEASE__ < 20040917} +type + CInteger = Integer; + CCardinal = Cardinal; +{$endif} + +type + PByte = ^Byte; + WrkString = String[255]; + +const + GrOk = 0; + GrNoInitGraph = -1; + GrNotDetected = -2; + GrFileNotFound = -3; + GrInvalidDriver = -4; + GrNoLoadMem = -5; + GrNoScanMem = -6; + GrNoFloodMem = -7; + GrFontNotFound = -8; + GrNoFontMem = -9; + GrInvalidMode = -10; + GrError = -11; + GrIOError = -12; + GrInvalidFont = -13; + GrInvalidFontNum = -14; + GrInvalidVersion = -18; + + Detect = 0; + Native_GRX = -3; + CurrentDriver = -128; + VGA = 9; + EGA = 3; + IBM8514 = 6; + HercMono = 7; + EGA64 = 4; + EGAMono = 5; + CGA = 1; + MCGA = 2; + ATT400 = 8; + PC3270 = 10; + + { driver definitions from BC++ 4.5: } + DetectX = Detect; + VGA256 = 11; + ATTDEB = 12; + Toshiba = 13; + SVGA16 = 14; + SVGA256 = 15; + SVGA32K = 16; + SVGA64K = 17; + VESA16 = 18; + VESA256 = 19; + VESA32K = 20; + VESA64K = 21; + VESA16M = 22; + ATI16 = 23; + ATI256 = 24; + ATI32K = 25; + Compaq = 26; + Tseng316 = 27; + Tseng3256 = 28; + Tseng416 = 29; + Tseng4256 = 30; + Tseng432K = 31; + Genoa5 = 32; + Genoa6 = 33; + OAK = 34; + Paradis16 = 35; + Paradis256 = 36; + Tecmar = 37; + Trident16 = 38; + Trident256 = 39; + Video7 = 40; + Video7ii = 41; + S3 = 42; + ATIGUP = 43; + + VGALo = 0; + VGAMed = 1; + VGAHi = 2; + IBM8514Lo = 0; + IBM8514Hi = 1; + HercMonoHi = 0; + CGAC0 = 0; + CGAC1 = 1; + CGAC2 = 2; + CGAC3 = 3; + CGAHi = 4; + MCGAC0 = CGAC0; + MCGAC1 = CGAC1; + MCGAC2 = CGAC2; + MCGAC3 = CGAC3; + MCGAMed = CGAHi; + MCGAHi = 5; + ATT400C0 = MCGAC0; + ATT400C1 = MCGAC1; + ATT400C2 = MCGAC2; + ATT400C3 = MCGAC3; + ATT400Med = MCGAMed; + ATT400Hi = MCGAHi; + EGA64Lo = 0; + EGA64Hi = 1; + EGALo = 0; + EGAHi = 1; + EGAMonoHi = 3; + PC3270Hi = 0; + + { mode definitions from BC++ 4.5: } + Res640x350 = 0; + Res640x480 = 1; + Res800x600 = 2; + Res1024x768 = 3; + Res1280x1024 = 4; + + { NATIVE_GRX modes: } + GRX_Default_Graphics = 0; + GRX_Biggest_Noninterlaced_Graphics = 1; + GRX_Biggest_Graphics = 2; + GRX_BGI_Emulation = 3; + First_Driver_Specific_Mode = 4; + + EGABlack = 0; + EGABlue = 1; + EGAGreen = 2; + EGACyan = 3; + EGARed = 4; + EGAMagenta = 5; + EGABrown = 20; + EGALightGray = 7; + EGADarkGray = 56; + EGALightBlue = 57; + EGALightGreen = 58; + EGALightCyan = 59; + EGALightRed = 60; + EGALightMagenta = 61; + EGAYellow = 62; + EGAWhite = 63; + + SolidLn = 0; + DottedLn = 1; + CenterLn = 2; + DashedLn = 3; + UserBitLn = 4; + + NormWidth = 1; + ThickWidth = 3; + + DefaultFont = 0; { 8x8 bit mapped font } + TriplexFont = 1; + SmallFont = 2; + SansSerifFont = 3; + GothicFont = 4; + ScriptFont = 5; + SimplexFont = 6; + TriplexScrFont = 7; + ComplexFont = 8; + EuropeanFont = 9; + BoldFont = 10; + + HorizDir = 0; { left to right } + VertDir = 1; { bottom to top } + + UserCharSize = 0; { user-defined char size } + + NormalPut = 0; { copy } + CopyPut = 0; { copy } + XORPut = 1; { xor } + OrPut = 2; { or } + AndPut = 3; { and } + NotPut = 4; { not } + + LeftText = 0; + CenterText = 1; + RightText = 2; + BottomText = 0; + TopText = 2; + + MaxColors = 15; + + { Clipping } + ClipOn = True; + ClipOff = False; + + { Bar3D } + TopOn = True; + TopOff = False; + + { FillStyles } + EmptyFill = 0; { fills area in background color } + SolidFill = 1; { fills area in solid fill color } + LineFill = 2; { --- fill } + LtSlashFill = 3; { /// fill } + SlashFill = 4; { /// fill with thick lines } + BkSlashFill = 5; { \\\ fill with thick lines } + LtBkSlashFill = 6; { \\\ fill } + HatchFill = 7; { light hatch fill } + XHatchFill = 8; { heavy cross hatch fill } + InterleaveFill = 9; { interleaving line fill } + WideDotFill = 10; { Widely spaced dot fill } + CloseDotFill = 11; { Closely spaced dot fill } + UserFill = 12; { user defined fill } + +type + PaletteType = record + Size : Byte; + Colors: array [0 .. MaxColors] of Byte + end; + + LineSettingsType = record + LineStyle: CInteger; + UPattern : ShortCard; + Thickness: CInteger + end; + + TextSettingsType = record + Font, + Direction, + CharSize, + Horiz, + Vert: CInteger + end; + + FillSettingsType = record + Pattern, + Color: CInteger + end; + + FillPatternType = array [1 .. 8] of Byte; + + { This definition is compatible with the grx + definition `int pts[][2]' used to define polygons } + PointType = record + x, y: CInteger + end; + + ViewPortType = record + x1, y1, x2, y2: CInteger; + Clip: WordBool + end; + + ArcCoordsType = record + x, y, + XStart, YStart, XEnd, YEnd: CInteger + end; + +var + GraphGetMemPtr : Pointer; { Dummy! } + GraphFreeMemPtr: Pointer; { Dummy! } + +{ BGI - API definitions } + +procedure DetectGraph(var GraphDriver, GraphMode: Integer); +procedure InitGraph(var GraphDriver, GraphMode: Integer; PathToDriver: CString); +procedure SetGraphMode(Mode: CInteger); asmname 'setgraphmode'; +function GetModeName(ModeNumber: CInteger): WrkString; +procedure GraphDefaults; asmname 'graphdefaults'; +function GetDriverName: WrkString; +function GraphErrorMsg(ErrorCode: CInteger): WrkString; +function GetMaxX: CInteger; asmname 'getmaxx'; +function GetMaxY: CInteger; asmname 'getmaxy'; +function GetMaxColor: CInteger; asmname 'getmaxcolor'; +procedure GetViewSettings(var ViewPort: ViewPortType); asmname 'getviewsettings'; +procedure SetViewPort(Left, Top, Right, Bottom: CInteger; Clip: Boolean); asmname 'setviewport'; +procedure GetLineSettings(var LineInfo: LineSettingsType); asmname 'getlinesettings'; +procedure SetLineStyle(LineStyle: CInteger; Pattern: CInteger; Thickness: CInteger); asmname 'setlinestyle'; +procedure ClearViewPort; asmname 'clearviewport'; +function GetPixel(x,y: CInteger): CInteger; asmname 'getpixel'; +procedure PutPixel(x, y: CInteger; Pixel: CInteger); asmname 'putpixel'; +procedure Bar3D(Left, Top, Right, Bottom: CInteger; Depth: CInteger; TopFlag: Boolean); asmname 'bar3d'; +procedure Rectangle(Left, Top, Right, Bottom: CInteger); asmname 'rectangle'; +procedure FillPoly(NumPoints: CCardinal; var PolyPoints { : array of PointType }); asmname 'fillpoly'; +procedure FillEllipse(x, y: CInteger; XRadius, YRadius: CInteger); asmname 'fillellipse'; +procedure GetArcCoords(var ArcCoords: ArcCoordsType); asmname 'getarccoords'; +procedure FloodFill(x, y: CInteger; Border: CInteger); asmname 'floodfill'; +procedure SetFillPattern(UPattern: FillPatternType; Color: CInteger); asmname 'setfillpattern'; +procedure SetFillStyle(Pattern: CInteger; Color: CInteger); asmname 'setfillstyle'; +procedure GetImage(Left, Top, Right, Bottom: CInteger; var BitMap); asmname 'getimage'; +procedure PutImage(Left, Top: CInteger; var BitMap; Op: CInteger); asmname 'putimage'; +function ImageSize(Left, Top, Right, Bottom: CInteger): CInteger; asmname 'imagesize'; +procedure GetTextSettings(var TextTypeInfo: TextSettingsType); asmname 'gettextsettings'; +procedure SetTextJustify(Horiz, Vert: CInteger); asmname 'settextjustify'; +procedure SetTextStyle(Font, Direction: CInteger; CharSize: CInteger); asmname 'settextstyle'; +procedure SetRGBPalette(Color, Red, Green, Blue: CInteger); asmname 'setrgbpalette'; +procedure SetUserCharSize(MultX, DivX, MultY, DivY: CInteger); asmname 'setusercharsize'; +procedure SetWriteMode(Mode: CInteger); asmname 'setwritemode'; +procedure OutText(TextString: CString); asmname 'outtext'; +procedure OutTextXY(x, y: CInteger; TextString: CString); asmname 'outtextxy'; +function TextHeight(TextString: CString): CInteger; asmname 'textheight'; +function TextWidth(TextString: CString): CInteger; asmname 'textwidth'; + +function RegisterBGIfont(Font: Pointer): CInteger; asmname 'registerbgifont'; +function InstallUserFont(FontName: CString): CInteger; asmname 'installuserfont'; + +function GetPaletteSize: CInteger; asmname 'getpalettesize'; +procedure GetPalette(var Palette: PaletteType); asmname 'getpalette'; +procedure SetPalette(ColorNum: CCardinal; Color: CInteger); asmname '__gr_setpalette'; +procedure SetAllPalette(protected var Palette: PaletteType); asmname 'setallpalette'; + +procedure RestoreCrtMode; asmname '__gr_restorecrtmode'; +procedure CloseGraph; asmname '__gr_closegraph'; +procedure SetColor(Color: CInteger); asmname '__gr_setcolor'; +procedure SetBkColor(Color: CInteger); asmname '__gr_setbkcolor'; +procedure Bar(Left, Top, Right, Bottom: CInteger); asmname '__gr_bar'; +function GraphResult:CInteger; asmname '__gr_graphresult'; +procedure Line(x1, y1, x2, y2: CInteger); asmname '__gr_line'; +procedure MoveTo(x, y: CInteger); asmname '__gr_moveto'; +procedure Arc(x, y: CInteger; StAngle, EndAngle, Radius: CCardinal); asmname '__gr_arc'; +procedure Circle(x, y: CInteger; Radius: CCardinal); asmname '__gr_circle'; +procedure ClearDevice; asmname '__gr_cleardevice'; +procedure DrawPoly(NumPoints: CCardinal; var PolyPoints { : array of PointType }); asmname '__gr_drawpoly'; +procedure Ellipse(x, y: CInteger; StAngle, EndAngle: CCardinal; XRadius, YRadius: CCardinal); asmname '__gr_ellipse'; +procedure GetAspectRatio(var XAsp, YAsp: Integer); +function GetBkColor: CCardinal; asmname '__gr_getbkcolor'; +function GetColor: CCardinal; asmname '__gr_getcolor'; +procedure GetFillPattern(var FillPattern: FillPatternType); asmname '__gr_getfillpattern'; +procedure GetFillSettings(var FillInfo: FillSettingsType); asmname '__gr_getfillsettings'; +function GetMaxMode: CInteger; asmname '__gr_getmaxmode'; +function GetGraphMode: CInteger; asmname '__gr_getgraphmode'; +function GetX: CInteger; asmname '__gr_getx'; +function GetY: CInteger; asmname '__gr_gety'; +function InstallUserDriver(const DriverName: String; AutoDetectPtr: Pointer):CInteger; +procedure LineRel(dx, dy: CInteger); asmname '__gr_linerel'; +procedure LineTo(x, y: CInteger); asmname '__gr_lineto'; +procedure MoveRel(dx, dy: CInteger); asmname '__gr_moverel'; +procedure PieSlice(x, y: CInteger; StAngle, EndAngle, Radius: CCardinal); asmname '__gr_pieslice'; +function RegisterBGIdriver(Driver: Pointer): CInteger; +procedure Sector(x, y: CInteger; StAngle,EndAngle, XRadius, YRadius: CCardinal); asmname '__gr_sector'; +procedure SetAspectRatio(XAsp, YAsp: CInteger); asmname '__gr_setaspectratio'; +procedure SetGraphBufSize(BufSize: CCardinal); asmname '__gr_setgraphbufsize'; +procedure SetActivePage(Page: CCardinal); asmname '__gr_setactivepage'; +procedure SetVisualPage(Page: CCardinal); asmname '__gr_setvisualpage'; +procedure GetDefaultPalette(var Palette: PaletteType); +procedure GetModeRange(GraphDriver:CInteger; var LoMode, HiMode:Integer); + +function Black : CInteger; +function Blue : CInteger; +function Green : CInteger; +function Cyan : CInteger; +function Red : CInteger; +function Magenta : CInteger; +function Brown : CInteger; +function LightGray : CInteger; +function DarkGray : CInteger; +function LightBlue : CInteger; +function LightGreen : CInteger; +function LightCyan : CInteger; +function LightRed : CInteger; +function LightMagenta: CInteger; +function Yellow : CInteger; +function White : CInteger; + +{ BGI - API extensions } + +{ Linkable font files } +var + Bold_Font: PByte; varasmname '_bold_font'; + Euro_Font: PByte; varasmname '_euro_font'; + Goth_Font: PByte; varasmname '_goth_font'; + Lcom_Font: PByte; varasmname '_lcom_font'; + Litt_Font: PByte; varasmname '_litt_font'; + Sans_Font: PByte; varasmname '_sans_font'; + Scri_Font: PByte; varasmname '_scri_font'; + Simp_Font: PByte; varasmname '_simp_font'; + Trip_Font: PByte; varasmname '_trip_font'; + Tscr_Font: PByte; varasmname '_tscr_font'; + + +{ Translates BGI driver/mode into a driver/mode pair for this unit + for usage with InitGraph / SetGraphMode } +procedure SetBGImode(var GDrv, GMode: CInteger); asmname 'set_BGI_mode'; + +{ Determines a driver/mode pair for InitGraph that will set + up a graphics mode with the desired resolution and colors } +procedure SetBGImodeWHC(var GDrv, GMode: CInteger; Width, Height, Colors: CInteger); asmname '__gr_set_BGI_mode_whc'; + +{ enable multiple graphics pages by + SetBGIModePages (2); + InitGraph (gd, gm, ''); + if (GraphResult = grOk) and (GetBGIModePages=2) then PlayWithPages; } +procedure SetBGIModePages(p: CInteger); asmname '__gr_set_BGI_mode_pages'; +function GetBGIModePages: CInteger; asmname '__gr_get_BGI_mode_pages'; + +{ like GetMaxColor, GetMaxX, GetMaxY but for any available mode } +function GetModeMaxColor(Mode: CInteger): CInteger; asmname '__gr_getmodemaxcolor'; +function GetModeMaxX(Mode: CInteger): CInteger; asmname '__gr_getmodemaxx'; +function GetModeMaxY(Mode: CInteger): CInteger; asmname '__gr_getmodemaxy'; + +{ Set the actual drawing color to r/g/b. + Functional in HiColor/TrueColor modes only } +procedure SetRGBColor(Red, Green, Blue: CCardinal); asmname '__gr_setrgbcolor'; + +{ Returns the actual RGB palette. } +procedure GetRGBPalette(Color: CInteger; var Red, Green, Blue: CInteger); asmname '__getrgbpalette'; + +{ Transforms the predefined 16 EGA colors (RED, BLUE, MAGENTA, ...) + into the correct color value for the active graphics mode } +function EGAColor(EGACol: CInteger): CInteger; asmname '_ega_color'; + +{ Enable/disable linestyle drawing of vector fonts. + Currently only functional with GRX v1.x } +procedure TextLineStyle(On: Boolean); asmname '__gr_textlinestyle'; + +{ Counterparts of SetActivePage/SetVisualPage } +function GetActivePage: CInteger; asmname '__gr_getactivepage'; +function GetVisualPage: CInteger; asmname '__gr_getvisualpage'; + +{$ifndef NO_GRAPH_KEY_FUNCTIONS} +function KeyPressed: Boolean; asmname 'kbhit'; +function ReadKey: Char; asmname 'getch'; +{$endif} + +{flush the graphics: useful only in X windows when switching + between graphics and console windows open simultaneously} +procedure GrFlush; asmname 'GrFlush'; + +implementation + +procedure dg(var GraphDriver, GraphMode: CInteger); asmname 'detectgraph'; +procedure DetectGraph(var GraphDriver, GraphMode: Integer); +var gd, gm: CInteger; +begin + gd := GraphDriver; + gm := GraphMode; + dg (gd, gm); + GraphDriver := gd; + GraphMode := gm +end; + +procedure ig(var gd, gm: CInteger; PathToDriver: CString); asmname 'initgraph'; +procedure InitGraph(var GraphDriver, GraphMode: Integer; PathToDriver: CString); +var gd, gm: CInteger; +begin + gd := GraphDriver; + gm := GraphMode; + ig (gd, gm, PathToDriver); + GraphDriver := gd; + GraphMode := gm +end; + +function gem(ec: CInteger): CString; asmname 'grapherrormsg'; +function GraphErrorMsg(ErrorCode: CInteger): WrkString; +begin + GraphErrorMsg := CString2String (gem (ErrorCode)) +end; + +function gmn(mn: CInteger): CString; asmname 'getmodename'; +function GetModeName(ModeNumber: CInteger): WrkString; +begin + GetModeName := CString2String (gmn (ModeNumber)) +end; + +function gdn: CString; asmname 'getdrivername'; +function GetDriverName: WrkString; +begin + GetDriverName := CString2String (gdn) +end; + +procedure gar(var XAsp, YAsp: CInteger); asmname '__gr_getaspectratio'; +procedure GetAspectRatio(var XAsp, YAsp: Integer); +var xa, ya: CInteger; +begin + gar (xa, ya); + XAsp := xa; + YAsp := ya +end; + +type pPT = ^PaletteType; +function gdp: pPT; asmname '__gr_getdefaultpalette'; +procedure GetDefaultPalette(var Palette: PaletteType); +begin + Palette := gdp^ +end; + +procedure gmr(GraphDriver:CInteger; var LoMode, HiMode:CInteger); asmname '__gr_getmoderange'; +procedure GetModeRange(GraphDriver:CInteger; var LoMode, HiMode:Integer); +var lm, hm: CInteger; +begin + gmr (GraphDriver, lm, hm); + LoMode := lm; + HiMode := hm +end; + +function InstallUserDriver(const DriverName: String; AutoDetectPtr: Pointer):CInteger; +var + Dummy1: Integer; + Dummy2: Pointer; +begin + Dummy1 := Length (DriverName); + Dummy2 := AutoDetectPtr; + InstallUserDriver := GrError +end; + +function RegisterBGIdriver(Driver: Pointer): CInteger; +var Dummy: Pointer; +begin + Dummy := Driver; + RegisterBGIdriver := GrError +end; + +function Black: CInteger; +begin + Black := EGAColor (0) +end; + +function Blue: CInteger; +begin + Blue := EGAColor (1) +end; + +function Green: CInteger; +begin + Green := EGAColor (2) +end; + +function Cyan: CInteger; +begin + Cyan := EGAColor (3) +end; + +function Red: CInteger; +begin + Red := EGAColor (4) +end; + +function Magenta: CInteger; +begin + Magenta := EGAColor (5) +end; + +function Brown: CInteger; +begin + Brown := EGAColor (6) +end; + +function LightGray: CInteger; +begin + LightGray := EGAColor (7) +end; + +function DarkGray: CInteger; +begin + DarkGray := EGAColor (8) +end; + +function LightBlue: CInteger; +begin + LightBlue := EGAColor (9) +end; + +function LightGreen: CInteger; +begin + LightGreen := EGAColor (10) +end; + +function LightCyan: CInteger; +begin + LightCyan := EGAColor (11) +end; + +function LightRed: CInteger; +begin + LightRed := EGAColor (12) +end; + +function LightMagenta: CInteger; +begin + LightMagenta := EGAColor (13) +end; + +function Yellow: CInteger; +begin + Yellow := EGAColor (14) +end; + +function White: CInteger; +begin + White := EGAColor (15) +end; + +end. diff --git a/thirdparty/grx249/pascal/bgi/makefile.dj2 b/thirdparty/grx249/pascal/bgi/makefile.dj2 new file mode 100644 index 0000000..fc50a21 --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/makefile.dj2 @@ -0,0 +1,49 @@ +# +# GRX test programs makefile for DJGPP v2. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean + +GRXVDJ2=y + +include ../../makedefs.grx + +# The following line is useful only in this makefile to force recompilation +GRXLIB = ../../lib/$(GRX_LIB_SUBDIR)/libgrx20.a +# In normal use the library libgrx20.a is linked in through +# {$L grx20} contained in the unit graph.pas called by "uses graph". +# The same is valid for other ADDON libraries. +# If the library is NOT installed give its path +# (default when first compiling/testing the library) +GRXLIBPATH = -L../../lib/$(GRX_LIB_SUBDIR) +# When it is installed in a standard system location +# (normal use) this is no more necessary + +LIBS= $(GRXLIBPATH) + +# Compiler and options on your system +COMPILER = $(PC) --automake + +PROGS= \ + allmodes.exe \ + modelist.exe \ + colors.exe \ + demo.exe \ + small.exe \ + palette.exe + +all: $(PROGS) + +$(PROGS): %.exe : %.pas $(GRXLIB) graph.pas + $(COMPILER) $(CCOPT) -o $*.exe $*.pas $(LDOPT) $(LIBS) + +clean: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f *.o *.exe *.gpi *.gpm +else + if exist *.o del *.o + if exist *.exe del *.exe + if exist *.gpi del *.gpi + if exist *.gpm del *.gpm +endif diff --git a/thirdparty/grx249/pascal/bgi/makefile.lnx b/thirdparty/grx249/pascal/bgi/makefile.lnx new file mode 100644 index 0000000..c5e2a0b --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/makefile.lnx @@ -0,0 +1,50 @@ +# +# GRX test programs makefile for LINUX/console. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean + +GRXVLNX=y + +include ../../makedefs.grx + +# The following line is useful only in this makefile to force recompilation +GRXLIB = ../../lib/$(GRX_LIB_SUBDIR)/libgrx20.a +# In normal use the library libgrx20.a or libgrx20.so is linked in through +# {$L grx20} contained in the unit graph.pas called by "uses graph". +# The same is valid for other ADDON libraries. +# If the library is NOT installed give its path +# (default when first compiling/testing the library) +GRXLIBPATH = -L../../lib/$(GRX_LIB_SUBDIR) +# When it is installed in a standard system location +# (normal use) this is no more necessary + +ifeq ($(SET_SUIDROOT),y) +EXECBITS = 4755 +else +EXECBITS = 0755 +endif + +LIBS= $(GRXLIBPATH) + +# Compiler and options on your system +COMPILER = $(PC) --automake + +PROGS= \ + allmodes \ + modelist \ + colors \ + demo \ + small \ + palette + +all: $(PROGS) + +$(PROGS): % : %.pas $(GRXLIB) graph.pas + $(COMPILER) $(CCOPT) -o $* $*.pas $(LIBS) + chmod $(EXECBITS) $@ + +clean: + rm -f *.o *.gpi *.gpm $(PROGS) + diff --git a/thirdparty/grx249/pascal/bgi/makefile.sdl b/thirdparty/grx249/pascal/bgi/makefile.sdl new file mode 100644 index 0000000..5e3e82e --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/makefile.sdl @@ -0,0 +1,47 @@ +# +# GRX test programs makefile for SDL. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean + +GRXVSDL=y + +include ../../makedefs.grx + +# The following line is useful only in this makefile to force recompilation +GRXLIB = ../../lib/$(GRX_LIB_SUBDIR)/libgrx20S.a +# In normal use the library libgrx20S.a is linked in through +# {$L grx20S} contained in the unit graph.pas called by "uses graph". +# The same is valid for other ADDON libraries. +# If the library is NOT installed give its path +# (default when first compiling/testing the library) +GRXLIBPATH = -L../../lib/$(GRX_LIB_SUBDIR) +# When it is installed in a standard system location +# (normal use) this is no more necessary + +ifneq ($(EP),x) + EX = .exe +endif + +LIBS = $(GRXLIBPATH) + +# Compiler and options on your system +COMPILER = $(PC) --autobuild + + +PROGS= \ + $(EP)allmodes$(EX) \ + $(EP)modelist$(EX) \ + $(EP)colors$(EX) \ + $(EP)demo$(EX) \ + $(EP)small$(EX) \ + $(EP)palette$(EX) + +all: $(PROGS) + +$(PROGS): $(EP)%$(EX) : %.pas $(GRXLIB) graph.pas + $(COMPILER) $(CCOPT) -o $@ $*.pas $(LDOPT) $(LIBS) + +clean: + rm -f *.o *.gpi *.gpm $(PROGS) diff --git a/thirdparty/grx249/pascal/bgi/makefile.w32 b/thirdparty/grx249/pascal/bgi/makefile.w32 new file mode 100644 index 0000000..ba65d9c --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/makefile.w32 @@ -0,0 +1,50 @@ +# +# GRX test programs makefile for Mingw. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean + +GRXVW32=y + +include ../../makedefs.grx + +# The following line is useful only in this makefile to force recompilation +GRXLIB = ../../lib/$(GRX_LIB_SUBDIR)/libgrx20.a +# In normal use the library libgrx20.a is linked in through +# {$L grx20} contained in the unit graph.pas called by "uses graph". +# The same is valid for other ADDON libraries. +# If the library is NOT installed give its path +# (default when first compiling/testing the library) +GRXLIBPATH = -L../../lib/$(GRX_LIB_SUBDIR) +# When it is installed in a standard system location +# (normal use) this is no more necessary + +LIBS= $(GRXLIBPATH) -mwindows -mconsole + +# Compiler and options on your system +COMPILER = $(PC) --autobuild + + +PROGS= \ + allmodes.exe \ + modelist.exe \ + colors.exe \ + demo.exe \ + small.exe \ + palette.exe + +all: $(PROGS) + +$(PROGS): %.exe : %.pas $(GRXLIB) graph.pas + $(COMPILER) $(CCOPT) -o $*.exe $*.pas $(LDOPT) $(LIBS) + +clean: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f *.o *.exe *.gpi *.gpm +else + if exist *.o del *.o + if exist *.exe del *.exe + if exist *.gpi del *.gpi + if exist *.gpm del *.gpm +endif diff --git a/thirdparty/grx249/pascal/bgi/makefile.x11 b/thirdparty/grx249/pascal/bgi/makefile.x11 new file mode 100644 index 0000000..745bc45 --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/makefile.x11 @@ -0,0 +1,57 @@ +# +# GRX test programs makefile for LINUX/X11. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean + +GRXVX11=y + +include ../../makedefs.grx + +# The following line is useful only in this makefile to force recompilation +GRXLIB = ../../lib/$(GRX_LIB_SUBDIR)/libgrx20X.a +# In normal use the library libgrx20X.a or libgrx20X.so is linked in through +# {$L grx20X} contained in the unit graph.pas called by "uses graph". +# The same is valid for other ADDON libraries. +# If the library is NOT installed give its path +# (default when first compiling/testing the library) +GRXLIBPATH = -L../../lib/$(GRX_LIB_SUBDIR) +# When it is installed in a standard system location +# (normal use) this is no more necessary + +ifeq ($(SET_XSUIDROOT),y) +EXECBITS = 4755 +else +EXECBITS = 0755 +endif + +ADDON_LIBS= + +ifeq ($(USE_XF86DGA_DRIVER),y) + ADDON_LIBS += -lXxf86dga -lXext #NOT included in graph.pas +endif + +LIBS= $(GRXLIBPATH) $(ADDON_LIBS) + +# Compiler and options on your system +COMPILER = $(PC) --automake + +PROGS= \ + xallmodes \ + xmodelist \ + xcolors \ + xdemo \ + xsmall \ + xpalette + +all: $(PROGS) + +$(PROGS): x% : %.pas $(GRXLIB) graph.pas + $(COMPILER) $(CCOPT) -o $@ $*.pas $(LIBS) + chmod $(EXECBITS) $@ + +clean: + rm -f *.o *.gpi *.gpm $(PROGS) + + diff --git a/thirdparty/grx249/pascal/bgi/modelist.pas b/thirdparty/grx249/pascal/bgi/modelist.pas new file mode 100644 index 0000000..c165de1 --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/modelist.pas @@ -0,0 +1,47 @@ +program ModeList; +{ + * test and demo program for the Graph unit + * + * Please read the copyright notices of graph.pas + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Author : Sven Hilscher + * e-mail : sven@rufus.central.de +} + +uses Graph; + +var + i, + grDriver, + grMode, + ErrCode: Integer; + +begin + { InitGraph is not needed for GetMaxMode and GetModeName in GPC } + grDriver := Detect; + {grDriver := InstallUserDriver('SVGA256', nil);} { Not used in GPC } + InitGraph(grDriver, grMode,'../../chr'); + ErrCode := GraphResult; + if ErrCode = GrOk then + begin { Do graphics } + (*$ifdef __GPC__ *) + CloseGraph; + (*$endif*) + for i := 0 to GetMaxMode do begin + WriteLn(i:4, ' ' + GetModeName(i)) + end; + ReadLn; + (*$ifndef __GPC__ *) + CloseGraph + (*$endif*) + end + else begin + WriteLn('Graphics error:', GraphErrorMsg(ErrCode)); + Write ('Press Enter ...'); + ReadLn + end +end. diff --git a/thirdparty/grx249/pascal/bgi/palette.pas b/thirdparty/grx249/pascal/bgi/palette.pas new file mode 100644 index 0000000..305ca09 --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/palette.pas @@ -0,0 +1,35 @@ +program Test_GetDefaultPalette; +{ + * test program for the Graph unit +} + +uses Graph; + +var + i, + grDriver, + grMode, + ErrCode: Integer; + pal : PaletteType; +begin + { InitGraph is not needed for GetMaxMode and GetModeName in GPC } + { grDriver := Detect; } + grDriver := InstallUserDriver('SVGA256', nil); { Not used in GPC } + InitGraph(grDriver, grMode,'../../chr'); + ErrCode := GraphResult; + if ErrCode = GrOk then + begin { Do graphics } + GetDefaultPalette(pal); + CloseGraph; + i := pal.Size; + WriteLn('Palette size: ', i); + for i := 0 to pal.Size-1 do + WriteLn('Color ', i:3, ' : ', pal.Colors[i]); + ReadLn; + end + else begin + WriteLn('Graphics error:', GraphErrorMsg(ErrCode)); + Write ('Press Enter ...'); + ReadLn + end +end. diff --git a/thirdparty/grx249/pascal/bgi/readme b/thirdparty/grx249/pascal/bgi/readme new file mode 100644 index 0000000..5fcf9e3 --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/readme @@ -0,0 +1,49 @@ + + BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + Copyright (C) 1993-97 by Hartmut Schirmer + + This library is now part of the GRX graphics library. + + Contact : Hartmut Schirmer + Feldstrasse 118 + D-24105 Kiel + Germany + e-mail : hsc@techfak.uni-kiel.de + + +Pascal (GPC) demo Programs + +graph.pas is the unit import file, as far as possible a plug-in +replacement for the BP unit of the same name +(see doc/readme.bgi for differences) + +* small.pas opens and closes the graphics to check for improper installation. +* modelist.pas prints out the available modes. +* palette.pas prints out the colors in the default palette. +* allmodes.pas for each available mode prints out mode number and its parameters + and displays one color rainbow. +* colors.pas for each avalaible mode with nc>=256 prints out mode name + and displays red, green, blue gray degraded stripes. +* demo.pas displays various demos to illustrate graphics possibilities. + It supposes for some of them that borland .chr files have been put in + the chr directory (otherwise it uses the always available default font). + +Makefiles are supplied to build up the demo programs for +djgpp, mingw32, LINUX/svga and LINUX/X11. +They should have been built with the library and C tests if you +used the top level makefiles. +If you want to rebuild only the demos type from this dir + make -f +Pathes and parameters will be borrowed from corresponding top level +makedefs files + +Have fun! + + + + + + + + + diff --git a/thirdparty/grx249/pascal/bgi/small.pas b/thirdparty/grx249/pascal/bgi/small.pas new file mode 100644 index 0000000..df2a33b --- /dev/null +++ b/thirdparty/grx249/pascal/bgi/small.pas @@ -0,0 +1,15 @@ +program Minimum_Size_Test; +{ + * test program for the Graph unit +} + +uses + Graph; + +var + grDriver, grMode: Integer; +begin + grDriver := Detect; + InitGraph(grDriver, grMode,''); + CloseGraph +end. diff --git a/thirdparty/grx249/pascal/blt_test.pas b/thirdparty/grx249/pascal/blt_test.pas new file mode 100644 index 0000000..1685e5a --- /dev/null +++ b/thirdparty/grx249/pascal/blt_test.pas @@ -0,0 +1,59 @@ +{$X+} + +Program Blt_Test; + +uses GRX; + +procedure TestFunc; +var + x, y, ww, wh, ii, jj, c : Integer; + +begin + x := GrSizeX; + y := GrSizeY; + ww := round((x-10)/32); + wh := round((y-10)/8); + + GrSetRGBcolorMode; + for ii := 0 to 7 do + for jj := 0 to 31 do begin + c := ii*32+jj; + {gives the same color independently of BPP: not all drivers have good BPP=8} + c := GrAllocColor(c and 2#11100000,(c and 2#11100) shl 3, (c and 2#11) shl 6); + GrFilledBox(5+jj*ww,5+ii*wh,5+jj*ww+ww-1,5+ii*wh+wh-1,c); + end; +end; { TestFunc } + +var + x, y, xv, yv, BPP, + m : Integer; + +begin + x := 1000; + y := 1000; + xv := 1280; + yv := 1024; + BPP:= 24; + +(* m := GrSetMode(Gr_Width_Height_BPP_Graphics,x,y,bpp,0,0); *) + m := GrSetMode(Gr_Custom_BPP_Graphics,x,y,BPP,xv,yv); + + TestFunc; + GrCircle(400,400,200,GrWhite); + GrCircle(400,400,205,GrWhite); + GrLineNC(0, 0, GrScreenX-1, GrScreenY-1, GrWhite); + GrLineNC(0, GrScreenY-1, GrScreenX-1, 0, GrWhite); + GrKeyRead; + GrTextXY(0,0,'GrScreenContext',GrWhite,GrBlack); + GrBitBltNC(GrScreenContext, 200, 200, GrScreenContext, 0, 0, 200, 200, GrWrite); + GrKeyRead; + GrBitBltNC(GrScreenContext, 300, 300, GrScreenContext, 0, 0, 200, 200, GrOr); + GrKeyRead; + GrBitBltNC(GrScreenContext, 400, 400, GrScreenContext, 0, 0, 200, 200, GrAnd); + GrKeyRead; + GrBitBltNC(GrScreenContext, 500, 500, GrScreenContext, 0, 0, 200, 200, GrXor); + GrKeyRead; + GrBitBltNC(GrScreenContext, 600, 600, GrScreenContext, 0, 0, 200, 200, GrImage); + GrKeyRead; +end. + diff --git a/thirdparty/grx249/pascal/colortst.pas b/thirdparty/grx249/pascal/colortst.pas new file mode 100644 index 0000000..77b4bbc --- /dev/null +++ b/thirdparty/grx249/pascal/colortst.pas @@ -0,0 +1,47 @@ +{ GRX color allocation test. + + Copyright (C) 2001 Frank Heckenbach + + This file is free software; as a special exception the author + gives unlimited permission to copy and/or distribute it, with or + without modifications, as long as this notice is preserved. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY, to the extent permitted by law; without + even the implied warranty of MERCHANTABILITY or FITNESS FOR A + PARTICULAR PURPOSE. } + +{$X+} + +program ColorTest; + +uses GRX; + +var + Dummy, i, x, y, j: Integer = 0; + Color: array [0 .. 1023] of Integer; + s : string[255]; + +begin + Dummy := GrSetMode (Gr_Width_Height_BPP_Graphics, 800, 300, 16, 0, 0); + for x := 0 to 1023 do + begin + { GrAllocCell; GrSetColor (x, x, x, x); } + if x < 256 then + Color[x] := GrAllocColor (x, x, x) + else if x < 512 then + Color[x] := GrAllocColor (x - 256, 0, 0) + else if x < 768 then + Color[x] := GrAllocColor (0, x - 512, 0) + else + Color[x] := GrAllocColor (0, 0, x - 768); + Inc (j); + if Color[x] <= $100000 then Inc (i) + end; + WriteStr (s, i, ' of ', j, ' colors allocated.'); + for y := 0 to 299 do + for x := 0 to 799 do + GrPlot (x, y, Color[(x + y) mod 1024]); + GrTextXY(300, 10, s, GrWhite, GrNoColor); + i := GrKeyRead +end. diff --git a/thirdparty/grx249/pascal/grx.pas b/thirdparty/grx249/pascal/grx.pas new file mode 100644 index 0000000..31a159f --- /dev/null +++ b/thirdparty/grx249/pascal/grx.pas @@ -0,0 +1,1485 @@ +{ Converted by Sven Hilscher eMail sven@rufus.lan-ks.de + from header file grx20.h + + grx20.h ---- GRX 2.x API functions and data structure declarations + + Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + [e-mail: csaba@vuse.vanderbilt.edu] + + This file is part of the GRX graphics library. + + The GRX graphics library is free software; you can redistribute it + and/or modify it under some conditions; see the "copying.grx" file + for details. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. } + +{ Define this if you want to use the Linux console version. + (Ignored on non-Linux systems.) } +{.$define LINUX_CONSOLE} + {and this if you use the svgalib (instead of only the framebuffer) driver} +{.$define SVGALIB} + +{ Define this if you want to use the SDL driver in mingw or x11} +{.$define __SDL__} + +{$gnu-pascal,I-} +{$ifdef __DJGPP__} + {$L grx20} +{$elif defined (__MINGW32__)} + {$ifdef __SDL__} + {$L grx20S, SDL} + {$else} + {$L grx20} + {$endif} +{$elif defined (_WIN32)} + {$L grxW32, vfs.c, user32, gdi32} +{$elif defined (linux) and defined (LINUX_CONSOLE)} + {$L grx20} + {$ifdef SVGALIB} + {$L vga} + {$endif} +{$else} + {$ifdef __SDL__} + {$L grx20S, SDL, pthread, X11} + {$else} + {$L grx20X, X11} + {$endif} +{$endif} + +{ Uncomment those of the following libraries that you need } +{.$L tiff} +{.$L jpeg} +{.$L png} +{.$L z} +{.$L socket} + +unit GRX; + +interface + +{$if __GPC_RELEASE__ >= 20030303} +{$define asmname external name} +{$define varasmname external name} +{$else} +{$define varasmname external; asmname} +{$endif} +{$if __GPC_RELEASE__ < 20040917} +type + CInteger = Integer; + CCardinal = Cardinal; +{$endif} + +const + MaxVarSize = MaxInt div 8; + +type + MemPtr = ^Char; +{$if __GPC_RELEASE__ >= 20030424} + GrColor = Integer attribute (Size = 32); { color and operation type, must be 32bit } +{$else} + GrColor = Integer (32); { color and operation type, must be 32bit } +{$endif} + GrColorPtr = ^GrColor; + GrColors = array [0 .. MaxVarSize div SizeOf (GrColor) - 1] of GrColor; + GrColorsPtr = ^GrColors; + + { This definition is compatible with the grx + definition 'int pts[][2]' used to define polygons } + PointType = record + x, y: CInteger + end; + +const + { these are the supported configurations: } + GRX_Version_TCC_8086_DOS = 1; { also works with BCC } + GRX_Version_GCC_386_GO32 = 2; { DJGPP } + GRX_Version_GCC_386_Linux = 3; { the real stuff } + GRX_Version_Generic_X11 = 4; { generic X11 version } + GRX_Version_Watcom_DOS4GW = 5; { Watcom C++ 11.0 32 Bit } + GRX_VERSION_GCC_386_WIN32 = 7; { WIN32 using Mingw32 } + GRX_VERSION_MSC_386_WIN32 = 8; { WIN32 using MS-VC } + GRX_VERSION_GCC_386_CYG32 = 9; { WIN32 using CYGWIN } + GRX_VERSION_GCC_386_X11 = 10; { X11 version } + GRX_VERSION_GCC_X86_64_LINUX = 11; { console framebuffer 64 } + GRX_VERSION_GCC_X86_64_X11 = 12; { X11 version 64 } + + { available video modes (for 'GrSetMode') } + + Gr_Unknown_Mode = -1; { initial state } + { ============= modes which clear the video memory ============= } + Gr_80_25_Text = 0; { Extra parameters for GrSetMode: } + Gr_Default_Text = 1; + Gr_Width_Height_Text = 2; { Integer w,Integer h } + Gr_Biggest_Text = 3; + Gr_320_200_Graphics = 4; + Gr_Default_Graphics = 5; + Gr_Width_Height_Graphics = 6; { Integer w,Integer h } + Gr_Biggest_Noninterlaced_Graphics = 7; + Gr_Biggest_Graphics = 8; + Gr_Width_Height_Color_Graphics = 9; { Integer w,Integer h,Cardinal nc } + Gr_Width_Height_Color_Text = 10; { Integer w,Integer h,Cardinal nc } + Gr_Custom_Graphics = 11; { Integer w,Integer h,Cardinal nc,Integer vx,Integer vy } + { ==== equivalent modes which do not clear the video memory ==== } + Gr_NC_80_25_Text = 12; + Gr_NC_Default_Text = 13; + Gr_NC_Width_Height_Text = 14; { Integer w,Integer h } + Gr_NC_Biggest_Text = 15; + Gr_NC_320_200_Graphics = 16; + Gr_NC_Default_Graphics = 17; + Gr_NC_Width_Height_Graphics = 18; { Integer w,Integer h } + Gr_NC_Biggest_Noninterlaced_Graphics = 19; + Gr_NC_Biggest_Graphics = 20; + Gr_NC_Width_Height_Color_Graphics = 21; { Integer w,Integer h,Cardinal nc } + Gr_NC_Width_Height_Color_Text = 22; { Integer w,Integer h,Cardinal nc } + Gr_NC_Custom_Graphics = 23; { Integer w,Integer h,Cardinal nc,Integer vx,Integer vy } + { ==== plane instead of color based modes ==== } + { colors = 1 << bpp >>> resort enum for GRX3 <<< } + Gr_Width_Height_BPP_Graphics = 24; { Integer w,Integer h,Integer bpp } + Gr_Width_Height_BPP_Text = 25; { Integer w,Integer h,Integer bpp } + Gr_Custom_BPP_Graphics = 26; { Integer w,Integer h,Integer bpp,Integer vx,Integer vy } + Gr_NC_Width_Height_BPP_Graphics = 27; { Integer w,Integer h,Integer bpp } + Gr_NC_Width_Height_BPP_Text = 28; { Integer w,Integer h,Integer bpp } + Gr_NC_Custom_BPP_Graphics = 29; { Integer w,Integer h,Integer bpp,Integer vx,Integer vy } + + { Available frame modes (video memory layouts) } + + { ====== video frame buffer modes ====== } + Gr_FrameUndef = 0; { undefined } + Gr_FrameText = 1; { text modes } + Gr_FrameHerc1 = 2; { Hercules mono } + Gr_FrameEGAVGA1 = 3; { EGA VGA mono } + Gr_FrameEGA4 = 4; { EGA 16 color } + Gr_FrameSVGA4 = 5; { (Super) VGA 16 color } + Gr_FrameSVGA8 = 6; { (Super) VGA 256 color } + Gr_FrameVGA8X = 7; { VGA 256 color mode X } + Gr_FrameSVGA16 = 8; { Super VGA 32768/65536 color } + Gr_FrameSVGA24 = 9; { Super VGA 16M color } + Gr_FrameSVGA32L = 10; { Super VGA 16M color padded #1 } + Gr_FrameSVGA32H = 11; { Super VGA 16M color padded #2 } + { ==== modes provided by the X11 driver ===== } + Gr_FrameXWin1 = Gr_FrameEGAVGA1; + Gr_FrameXWin4 = Gr_FrameSVGA4; + Gr_FrameXWin8 = Gr_FrameSVGA8; + Gr_FrameXWin16 = Gr_FrameSVGA16; + Gr_FrameXWin24 = Gr_FrameSVGA24; + Gr_FrameXWin32L = Gr_FrameSVGA32L; + Gr_FrameXWin32H = Gr_FrameSVGA32H; + { ==== modes provided by the WIN32 driver ===== } + Gr_FrameWIN32_1 = Gr_FrameEGAVGA1; + Gr_FrameWIN32_4 = Gr_FrameSVGA4; + Gr_FrameWIN32_8 = Gr_FrameSVGA8; + Gr_FrameWIN32_16 = Gr_FrameSVGA16; + Gr_FrameWIN32_24 = Gr_FrameSVGA24; + Gr_FrameWIN32_32L = Gr_FrameSVGA32L; + Gr_FrameWIN32_32H = Gr_FrameSVGA32H; + { ==== modes provided by the SDL driver ===== } + Gr_FrameSDL8 = Gr_FrameSVGA8; + Gr_FrameSDL16 = Gr_FrameSVGA16; + Gr_FrameSDL24 = Gr_FrameSVGA24; + Gr_FrameSDL32L = Gr_FrameSVGA32L; + Gr_FrameSDL32H = Gr_FrameSVGA32H; + { ==== linear frame buffer modes ====== } + Gr_FrameSVGA8_LFB = 12; { (Super) VGA 256 color } + Gr_FrameSVGA16_LFB = 13; { Super VGA 32768/65536 color } + Gr_FrameSVGA24_LFB = 14; { Super VGA 16M color } + Gr_FrameSVGA32L_LFB = 15; { Super VGA 16M color padded #1 } + Gr_FrameSVGA32H_LFB = 16; { Super VGA 16M color padded #2 } + { ====== system RAM frame buffer modes ====== } + Gr_FrameRAM1 = 17; { mono } + Gr_FrameRAM4 = 18; { 16 color planar } + Gr_FrameRAM8 = 19; { 256 color } + Gr_FrameRAM16 = 20; { 32768/65536 color } + Gr_FrameRAM24 = 21; { 16M color } + Gr_FrameRAM32L = 22; { 16M color padded #1 } + Gr_FrameRAM32H = 23; { 16M color padded #2 } + Gr_FrameRAM3x8 = 24; { 16M color planar (image mode) } + { ====== markers for scanning modes ====== } + Gr_FirstTextFrameMode = Gr_FrameText; + Gr_LastTextFrameMode = Gr_FrameText; + Gr_FirstGraphicsFrameMode = Gr_FrameHerc1; + Gr_LastGraphicsFrameMode = Gr_FrameSVGA32H_LFB; + Gr_FirstRAMframeMode = Gr_FrameRAM1; + Gr_LastRAMframeMode = Gr_FrameRAM3x8; + + { supported video adapter types } + + Gr_Unknown = -1; { not known (before driver set) } + Gr_VGA = 0; { VGA adapter } + Gr_EGA = 1; { EGA adapter } + Gr_Herc = 2; { Hercules mono adapter } + Gr_8514A = 3; { 8514A or compatible } + Gr_S3 = 4; { S3 graphics accelerator } + Gr_XWin = 5; { X11 driver } + Gr_WIN32 = 6; { WIN32 driver } + Gr_LNXFB = 7; { Linux framebuffer } + Gr_SDL = 8; { SDL driver } + Gr_Mem = 9; { memory only driver } + + Gr_Max_Polygon_Pointers = 1000000; + Gr_Max_Ellipse_Pointers = 1024 + 5; + Gr_Max_Angle_Value = 3600; + Gr_Arc_Style_Open = 0; + Gr_Arc_Style_Close1 = 1; + Gr_Arc_Style_Close2 = 2; + + { bits in the GrVideoDriver.drvflags field: } + Gr_DriverF_User_Resolution = 1; { set if driver supports user setable arbitrary resolution } + +type + + GrVideoModePtr = ^GrVideoMode; + + { The video driver descriptor structure } + { struct _GR_videoDriver } + GrVideoDriverPtr = ^GrVideoDriver; + GrVideoDriver = record + Name : CString; { driver name } + Adapter : CInteger; { adapter type } + Inherit : GrVideoDriverPtr; { inherit video modes from this } + Modes : GrVideoModePtr; { table of supported modes } + NModes : CInteger; { number of modes } + Detect : function: CInteger; + Init : function (Options: CString): CInteger; + Reset : procedure; + SelectMode: function (Drv: GrVideoDriverPtr; w, h, BPP, txt: CInteger; var ep: CCardinal): GrVideoModePtr; + DrvFlags : CCardinal + end; + + { Video driver mode descriptor structure } + { struct _GR_videoMode } + GrVideoMode = record + Present: ByteBool; { is it really available? } + BPP: Byte; { log2 of # of colors } + Width, Height, { video mode geometry } + Mode: ShortInt; { BIOS mode number (if any) } + LineOffset, { scan line length } + PrivData: CInteger; { driver can use it for anything } + ExtInfo: ^GrVideoModeExt { extra info (maybe shared) } + end; + + { Video driver mode descriptor extension structure. This is a separate + structure accessed via a pointer from the main mode descriptor. The + reason for this is that frequently several modes can share the same + extended info. } + + { struct _GR_videoModeExt } + Int2 = array [0 .. 1] of CInteger; + GrVideoModeExt = record + Mode : CInteger; { frame driver for this video mode } + Drv : ^GrFrameDriver; { optional frame driver override } + Frame : MemPtr; { frame buffer address } + CPrec : array [1 .. 3] of ByteCard; { color component precisions } + CPos : array [1 .. 3] of ByteCard; { color component bit positions } + Flags : CInteger; { mode flag bits; see "grdriver.h" } + Setup : function (var md: GrVideoMode; NoClear: CInteger): CInteger; + SetVSize : function (var md: GrVideoMode; w, h: CInteger; var Result: GrVideoMode): CInteger; + Scroll : function (var md: GrVideoMode; x, y: CInteger; var Result: Int2): CInteger; + SetBank : procedure (bk: CInteger); + SetRWBanks : procedure (rb, wb: CInteger); + LoadColor : procedure (c, r, g, b: CInteger); + LFB_Selector: CInteger + end; + + GrFrameDriverPtr = ^GrFrameDriver; + + GrFrameType = record + gf_BaseAddr : array [0 .. 3] of MemPtr; { base address of frame memory } + gf_Selector : ShortInt; { frame memory segment selector } + gf_OnScreen : ByteBool; { is it in video memory ? } + gf_MemFlags : Byte; { memory allocation flags } + gf_LineOffset: CInteger; { offset to next scan line in bytes } + gf_Driver : GrFrameDriverPtr { frame access functions } + end; + + { The frame driver descriptor structure. } + + { struct _GR_frameDriver } + GrFrameDriver = record + Mode, { supported frame access mode } + RMode, { matching RAM frame (if video) } + Is_Video, { video RAM frame driver ? } + Row_Align, { scan line size alignment } + Num_Planes, { number of planes } + Bits_Per_Pixel : CInteger; { bits per pixel } + Max_Plane_Size : MedInt; { maximum plane size in bytes } + Init : function (var md: GrVideoMode): CInteger; + ReadPixel : function (var c: GrFrameType; x, y: CInteger): GrColor; + DrawPixel : procedure (x, y: CInteger; c: GrColor); + DrawLine : procedure (x, y, dx, dy: CInteger; c: GrColor); + DrawHLine : procedure (x, y, w: CInteger; c: GrColor); + DrawVLine : procedure (x, y, h: CInteger; c: GrColor); + DrawBlock : procedure (x, y, w, h: CInteger; c: GrColor); + DrawBitmap : procedure (x, y, w, h: CInteger; BMP: MemPtr; Pitch, Start: CInteger; fg, bg: GrColor); + DrawPattern : procedure (x, y, w: CInteger; Patt: Byte; fg, bg: GrColor); + BitBlt : procedure (var Dst: GrFrameType; dx, dy: CInteger; var Src: GrFrameType; x, y, w, h: CInteger; Op: GrColor); + BltV2R : procedure (var Dst: GrFrameType; dx, dy: CInteger; var Src: GrFrameType; x, y, w, h: CInteger; Op: GrColor); + BltR2V : procedure (var Dst: GrFrameType; dx, dy: CInteger; var Src: GrFrameType; x, y, w, h: CInteger; Op: GrColor); + GetIndexedScanline: function (var c: GrFrameType; x, y, w: CInteger; var Index: CInteger): GrColorsPtr; + PutScanLine : procedure (x, y, w: CInteger; scl: GrColorsPtr; Op: GrColor); + end; + + { driver and mode info structure } + + { extern const struct _GR_driverInfo } + GrDriverInfoType = record + VDriver : GrVideoDriverPtr; { the current video driver } + CurMode : GrVideoModePtr; { current video mode pointer } + ActMode : GrVideoMode; { copy of above, resized if virtual } + FDriver, { frame driver for the current context } + SDriver, { frame driver for the screen } + TDriver : GrFrameDriver; { a dummy driver for text modes } + MCode, { code for the current mode } + DefTW,DefTH, { default text mode size } + DefGW,DefGH: CInteger; { default graphics mode size } + DefTC,DefGC: GrColor; { default text and graphics colors } + VPosX,VPosY, { current virtual viewport position } + ErrsFatal, { if set, exit upon errors } + ModeRestore, { restore startup video mode if set } + SplitBanks, { indicates separate R/W banks } + CurBank : CInteger; { currently mapped bank } + MdSetHook : procedure; { callback for mode set } + SetBank : procedure (bk: CInteger); { banking routine } + SetRWBanks : procedure (rb, wb: CInteger); { split banking routine } + end; + +var + GrDriverInfo: ^GrDriverInfoType; varasmname 'GrDriverInfo'; + +{ setup stuff } + +function GrSetDriver(DrvSpec: CString):CInteger; asmname 'GrSetDriver'; +function GrSetMode(m, w, h, nc, vx, vy:CInteger):CInteger; asmname 'GrSetMode'; +function GrSetViewport(XPos, YPos: CInteger):CInteger; asmname 'GrSetViewport'; +procedure GrSetModeHook(HookFunc:Pointer); asmname 'GrSetModeHook'; +procedure GrSetModeRestore(RestoreFlag:Boolean); asmname 'GrSetModeRestore'; + +procedure GrSetErrorHandling(ExitIfError:Boolean); asmname 'GrSetErrorHandling'; +procedure GrSetEGAVGAmonoDrawnPlane(Plane:CInteger); asmname 'GrSetEGAVGAmonoDrawnPlane'; +procedure GrSetEGAVGAmonoShownPlane(Plane:CInteger); asmname 'GrSetEGAVGAmonoShownPlane'; + +function GrGetLibraryVersion: CInteger; asmname 'GrGetLibraryVersion'; +function GrGetLibrarySystem: CInteger; asmname 'GrGetLibrarySystem'; + +{ inquiry stuff ---- many of these can be macros } + +function GrCurrentMode:CInteger; asmname 'GrCurrentMode'; +function GrAdapterType:CInteger; asmname 'GrAdapterType'; +function GrCurrentFrameMode:CInteger; asmname 'GrCurrentFrameMode'; +function GrScreenFrameMode:CInteger; asmname 'GrScreenFrameMode'; +function GrCoreFrameMode:CInteger; asmname 'GrCoreFrameMode'; + +function GrCurrentVideoDriver: GrVideoDriverPtr; asmname 'GrCurrentVideoDriver' ; +function GrCurrentVideoMode:GrVideoModePtr; asmname 'GrCurrentVideoMode'; +function GrVirtualVideoMode:GrVideoModePtr; asmname 'GrVirtualVideoMode'; +function GrCurrentFrameDriver: GrFrameDriverPtr; asmname 'GrCurrentFrameDriver'; +function GrScreenFrameDriver: GrFrameDriverPtr; asmname 'GrScreenFrameDriver'; + +function GrFirstVideoMode(FMode:CInteger):GrVideoModePtr; asmname 'GrFirstVideoMode'; +function GrNextVideoMode(Prev:GrVideoModePtr):GrVideoModePtr; asmname 'GrNextVideoMode'; + +function GrScreenX:CInteger; asmname 'GrScreenX'; +function GrScreenY:CInteger; asmname 'GrScreenY'; +function GrVirtualX:CInteger; asmname 'GrVirtualX'; +function GrVirtualY:CInteger; asmname 'GrVirtualY'; +function GrViewportX:CInteger; asmname 'GrViewportX'; +function GrViewportY:CInteger; asmname 'GrViewportY'; +function GrScreenIsVirtual:Boolean; asmname 'GrScreenIsVirtual'; + +{ RAM context geometry and memory allocation inquiry stuff } + +function GrFrameNumPlanes(md:CInteger):CInteger; asmname 'GrFrameNumPlanes'; +function GrFrameLineOffset(md,Width:CInteger):CInteger; asmname 'GrFrameLineOffset'; +function GrFramePlaneSize(md,w,h:CInteger):CInteger; asmname 'GrFramePlaneSize'; +function GrFrameContextSize(md,w,h:CInteger):CInteger; asmname 'GrFrameContextSize'; + +function GrNumPlanes:CInteger; asmname 'GrNumPlanes'; +function GrLineOffset(Width:CInteger):CInteger; asmname 'GrLineOffset'; +function GrPlaneSize(w,h:CInteger):CInteger; asmname 'GrPlaneSize'; +function GrContextSize(w,h:CInteger):CInteger; asmname 'GrContextSize'; + +{ ================================================================== + FRAME BUFFER, CONTEXT AND CLIPPING STUFF + ================================================================== } + +type + { struct _GR_context } + GrContextPtr = ^GrContext; + GrContext = record + gc_Frame: GrFrameType; { frame buffer info } + gc_Root: GrContextPtr; { context which owns frame } + gc_XMax, { max X coord (width - 1) } + gc_YMax, { max Y coord (height - 1) } + gc_XOffset, { X offset from root's base } + gc_YOffset, { Y offset from root's base } + gc_XClipLo, { low X clipping limit } + gc_YClipLo, { low Y clipping limit } + gc_XClipHi, { high X clipping limit } + gc_YClipHi, { high Y clipping limit } + gc_UsrXBase, { user window min X coordinate } + gc_UsrYBase, { user window min Y coordinate } + gc_UsrWidth, { user window width } + gc_UsrHeight: CInteger { user window height } + end; + + { extern const struct _GR_contextInfo } + GrContextInfoType = record + Current, { the current context } + Screen: GrContext { the screen context } + end; + +var + GrContextInfo: GrContextInfoType; varasmname 'GrContextInfo'; + +function GrCreateContext(w, h: CInteger; Memory: MemPtr; Where: GrContextPtr): GrContextPtr; asmname 'GrCreateContext'; +function GrCreateFrameContext(md: ByteCard; w, h: CInteger; Memory: MemPtr; Where: GrContextPtr): GrContextPtr; asmname 'GrCreateFrameContext'; +function GrCreateSubContext(x1, y1, x2, y2: CInteger; Parent, Where: GrContextPtr): GrContextPtr; asmname 'GrCreateSubContext'; +function GrSaveContext(Where: GrContextPtr): GrContextPtr; asmname 'GrSaveContext'; +function GrCurrentContext: GrContextPtr; asmname 'GrCurrentContext'; +function GrScreenContext: GrContextPtr; asmname 'GrScreenContext'; + +procedure GrDestroyContext(Context: GrContextPtr); asmname 'GrDestroyContext'; +procedure GrResizeSubContext(Context: GrContextPtr; x1, y1, x2, y2: CInteger); asmname 'GrResizeSubContext'; +procedure GrSetContext(Context: GrContextPtr); asmname 'GrSetContext'; + +procedure GrSetClipBox(x1, y1, x2, y2:CInteger); asmname 'GrSetClipBox'; +procedure GrGetClipBox(var x1p, y1p, x2p, y2p: CInteger); asmname 'GrGetClipBox'; +procedure GrResetClipBox; asmname 'GrResetClipBox'; + +function GrMaxX: CInteger; asmname 'GrMaxX'; +function GrMaxY: CInteger; asmname 'GrMaxY'; +function GrSizeX:CInteger; asmname 'GrSizeX'; +function GrSizeY:CInteger; asmname 'GrSizeY'; +function GrLowX: CInteger; asmname 'GrLowX'; +function GrLowY: CInteger; asmname 'GrLowY'; +function GrHighX:CInteger; asmname 'GrHighX'; +function GrHighY:CInteger; asmname 'GrHighY'; + +{ ================================================================== + COLOR STUFF + ================================================================== } + +{ Flags to 'OR' to colors for various operations } +const + GrWrite = 0 ; { write color } + GrXor = $01000000 ; { to "xor" any color to the screen } + GrOr = $02000000 ; { to "or" to the screen } + GrAnd = $03000000 ; { to "and" to the screen } + GrImage = $04000000 ; { BLIT: write, except given color } + GrCValueMask = $00ffffff ; { color value mask } + GrCModeMask = $ff000000 ; { color operation mask } + GrNoColor = GrXor or 0 ; { GrNoColor is used for "no" color } + +function GrColorValue(c:GrColor):GrColor; asmname 'GrColorValue'; +function GrColorMode(c:GrColor):GrColor; asmname 'GrColorMode'; +function GrWriteModeColor(c:GrColor):GrColor; asmname 'GrWriteModeColor'; +function GrXorModeColor(c:GrColor):GrColor; asmname 'GrXorModeColor'; +function GrOrModeColor(c:GrColor):GrColor; asmname 'GrOrModeColor'; +function GrAndModeColor(c:GrColor):GrColor; asmname 'GrAndModeColor'; +function GrImageModeColor(c:GrColor):GrColor; asmname 'GrImageModeColor'; + +procedure GrResetColors; asmname 'GrResetColors'; +procedure GrSetRGBcolorMode; asmname 'GrSetRGBcolorMode'; +procedure GrRefreshColors; asmname 'GrRefreshColors'; + +function GrNumColors:GrColor; asmname 'GrNumColors'; +function GrNumFreeColors:GrColor; asmname 'GrNumFreeColors'; + +function GrBlack:GrColor; asmname 'GrBlack'; +function GrWhite:GrColor; asmname 'GrWhite'; + +function GrBuildRGBcolorT(r,g,b:CInteger):GrColor; asmname 'GrBuildRGBcolorT'; +function GrBuildRGBcolorR(r,g,b:CInteger):GrColor; asmname 'GrBuildRGBcolorR'; +function GrRGBcolorRed(c:GrColor):CInteger ; asmname 'GrRGBcolorRed'; +function GrRGBcolorGreen(c:GrColor):CInteger ; asmname 'GrRGBcolorGreen'; +function GrRGBcolorBlue(c:GrColor):CInteger ; asmname 'GrRGBcolorBlue'; + +function GrAllocColor(r,g,b:CInteger):GrColor; asmname 'GrAllocColor'; { shared, read-only } +function GrAllocColorID(r,g,b:CInteger):GrColor; asmname 'GrAllocColorID'; { potentially inlined version } +function GrAllocColor2(hcolor:MedInt):GrColor; asmname 'GrAllocColor2'; { $RRGGBB shared, read-only } +function GrAllocColor2ID(hcolor:MedInt):GrColor; asmname 'GrAllocColor2ID'; { potentially inlined version } +function GrAllocCell:GrColor; asmname 'GrAllocCell'; { unshared, read-write } + +function GrAllocEgaColors:GrColorsPtr; asmname 'GrAllocEgaColors'; { shared, read-only standard EGA colors } + +procedure GrSetColor(c:GrColor; r,g,b:CInteger); asmname 'GrSetColor'; +procedure GrFreeColor(c:GrColor); asmname 'GrFreeColor'; +procedure GrFreeCell(c:GrColor); asmname 'GrFreeCell'; + +procedure GrQueryColor(c:GrColor; var r,g,b:CInteger); asmname 'GrQueryColor'; +procedure GrQueryColorID(c:GrColor; var r,g,b:CInteger); asmname 'GrQueryColorID'; +procedure GrQueryColor2(c:GrColor; var hcolor:MedInt); asmname 'GrQueryColor2'; +procedure GrQueryColor2ID(c:GrColor; var hcolor:MedInt); asmname 'GrQueryColor2ID'; + +function GrColorSaveBufferSize:CInteger ; asmname 'GrColorSaveBufferSize'; +procedure GrSaveColors(Buffer:Pointer); asmname 'GrSaveColors'; +procedure GrRestoreColors(Buffer:Pointer); asmname 'GrRestoreColors'; + +{ ================================================================== + GRAPHICS PRIMITIVES + ================================================================== } + +type + { framed box colors } + GrFBoxColors = record + fbx_IntColor, + fbx_TopColor, + fbx_RightColor, + fbx_BottomColor, + fbx_LeftColor: GrColor + end; + +procedure GrClearScreen(bg:GrColor); asmname 'GrClearScreen'; +procedure GrClearContext(bg:GrColor); asmname 'GrClearContext'; +procedure GrClearContextC(ctx:GrContextPtr; bg:GrColor); asmname 'GrClearContextC'; +procedure GrClearClipBox(bg:GrColor); asmname 'GrClearClipBox'; +procedure GrPlot(x, y: CInteger; c:GrColor); asmname 'GrPlot'; +procedure GrLine(x1, y1, x2, y2: CInteger; c:GrColor); asmname 'GrLine'; +procedure GrHLine(x1, x2, y:CInteger; c:GrColor); asmname 'GrHLine'; +procedure GrVLine(x, y1, y2: CInteger; c: GrColor); asmname 'GrVLine'; +procedure GrBox(x1, y1, x2, y2: CInteger; c: GrColor); asmname 'GrBox'; +procedure GrFilledBox(x1, y1, x2, y2: CInteger; c: GrColor); asmname 'GrFilledBox'; +procedure GrFramedBox(x1, y1, x2, y2, Wdt: CInteger; protected var c: GrFBoxColors); asmname 'GrFramedBox'; +function GrGenerateEllipse(xc, yc, xa, ya:CInteger; var Points{ : array of PointType }):CInteger; asmname 'GrGenerateEllipse'; +function GrGenerateEllipseArc(xc, yc, xa, ya, Start, Ende: CInteger; var Points{ : array of PointType }):CInteger; asmname 'GrGenerateEllipseArc'; +procedure GrLastArcCoords(var xs, ys, xe, ye, xc, yc: CInteger); asmname 'GrLastArcCoords'; +procedure GrCircle(xc, yc, r: CInteger; c: GrColor); asmname 'GrCircle'; +procedure GrEllipse(xc, yc, xa, ya: CInteger; c: GrColor); asmname 'GrEllipse'; +procedure GrCircleArc(xc, yc, r, Start, Ende, Style: CInteger; c: GrColor); asmname 'GrCircleArc'; +procedure GrEllipseArc(xc, yc, xa, ya, Start, Ende, Style: CInteger; c: GrColor); asmname 'GrEllipseArc'; +procedure GrFilledCircle(xc, yc, r: CInteger; c: GrColor); asmname 'GrFilledCircle'; +procedure GrFilledEllipse(xc, yc, xa, ya: CInteger; c: GrColor); asmname 'GrFilledEllipse'; +procedure GrFilledCircleArc(xc, yc, r, Start, Ende, Style: CInteger; c: GrColor); asmname 'GrFilledCircleArc'; +procedure GrFilledEllipseArc(xc, yc, xa, ya, Start, Ende, Style: CInteger; c: GrColor); asmname 'GrFilledEllipseArc'; +procedure GrPolyLine(NumPts: CInteger; var Points{ : array of PointType }; c: GrColor); asmname 'GrPolyLine'; +procedure GrPolygon(NumPts: CInteger; var Points{ : array of PointType }; c: GrColor); asmname 'GrPolygon'; +procedure GrFilledConvexPolygon(NumPts: CInteger; var Points{ : array of PointType }; c: GrColor); asmname 'GrFilledConvexPolygon'; +procedure GrFilledPolygon(NumPts: CInteger; var Points{ : array of PointType }; c: GrColor); asmname 'GrFilledPolygon'; +procedure GrBitBlt(Dest: GrContextPtr; x, y: CInteger; Src: GrContextPtr; x1, y1, x2, y2: CInteger; Op: GrColor); asmname 'GrBitBlt'; +function GrPixel(x, y:CInteger):GrColor; asmname 'GrPixel'; +function GrPixelC(c: GrContextPtr; x, y: CInteger): GrColor; asmname 'GrPixelC'; + +procedure GrFloodFill(x, y: CInteger; Border, c: GrColor); asmname 'GrFloodFill'; +procedure GrFloodSpill(x1, y1, x2, y2: CInteger; old_c, new_c: GrColor); asmname 'GrFloodSpill'; +procedure GrFloodSpill2( x1, y1, x2, y2: CInteger; old_c1, new_c1, old_c2, new_c2: GrColor); asmname 'GrFloodSpill2'; +procedure GrFloodSpillC(var ctx: GrContext; x1, y1, x2, y2: CInteger; old_c, new_c: GrColor); asmname 'GrFloodSpillC'; +procedure GrFloodSpillC2(var ctx: GrContext; x1, y1, x2, y2: CInteger; old_c1, new_c1, old_c2, new_c2: GrColor); asmname 'GrFloodSpillC2'; + +function GrGetScanline(x1,x2,yy: CInteger): GrColorsPtr; asmname 'GrGetScanline'; +function GrGetScanlineC(ctx: GrContextPtr; x1,x2,yy: CInteger): GrColorsPtr; asmname 'GrGetScanlineC'; +{ Input ctx: source context, if NULL the current context is used } +{ x1 : first x coordinate read } +{ x2 : last x coordinate read } +{ yy : y coordinate } +{ Output nil : error / no data (clipping occurred) } +{ else } +{ p[0..w]: pixel values read } +{ (w = |x2-y1|) } +{ Output data is valid until next GRX call ! } + +procedure GrPutScanline(x1,x2,yy: CInteger;c: GrColorsPtr; Op: GrColor); asmname 'GrPutScanline'; +{ Input x1: first x coordinate to be set } +{ x2: last x coordinate to be set } +{ yy: y coordinate } +{ c : c[0..(|x2-x1|] hold the pixel data } +{ Op: Operation (GrWRITE/GrXOR/GrOR/GrAND/GrIMAGE) } +{ } +{ Note c[..] data must fit GrCVALUEMASK otherwise the results } +{ are implementation dependend. } +{ => You can't supply operation code with the pixel data! } + + +{ ================================================================== + NON CLIPPING DRAWING PRIMITIVES + ================================================================== } + +procedure GrPlotNC(x, y: CInteger; c: GrColor); asmname 'GrPlotNC'; +procedure GrLineNC(x1, y1, x2, y2: CInteger; c: GrColor); asmname 'GrLineNC'; +procedure GrHLineNC(x1, x2, y: CInteger; c: GrColor); asmname 'GrHLineNC'; +procedure GrVLineNC(x, y1, y2: CInteger; c: GrColor); asmname 'GrVLineNC'; +procedure GrBoxNC(x1, y1, x2, y2: CInteger; c: GrColor); asmname 'GrBoxNC'; +procedure GrFilledBoxNC(x1, y1, x2, y2: CInteger; c: GrColor); asmname 'GrFilledBoxNC'; +procedure GrFramedBoxNC(x1, y1, x2, y2, Wdt: CInteger; protected var c: GrFBoxColors); asmname 'GrFramedBoxNC'; +procedure GrBitBltNC(Dest: GrContextPtr; x, y: CInteger; Src: GrContextPtr; x1, y1, x2, y2: CInteger; Op: GrColor); asmname 'GrBitBltNC'; +function GrPixelNC(x, y:CInteger):GrColor; asmname 'GrPixelNC'; +function GrPixelCNC(c: GrContextPtr; x, y: CInteger): GrColor; asmname 'GrPixelCNC'; + +{ ================================================================== + FONTS AND TEXT PRIMITIVES + ================================================================== } + +const + { text drawing directions } + Gr_Text_Right = 0; { normal } + Gr_Text_Down = 1; { downward } + Gr_Text_Left = 2; { upside down, right to left } + Gr_Text_Up = 3; { upward } + Gr_Text_Default = Gr_Text_Right; + { Gr_Text_Is_Vertical(d) = ((d) and 1); } + + { text alignment options } + Gr_Align_Left = 0; { X only } + Gr_Align_Top = 0; { Y only } + Gr_Align_Center = 1; { X, Y } + Gr_Align_Right = 2; { X only } + Gr_Align_Bottom = 2; { Y only } + Gr_Align_Baseline = 3; { Y only } + Gr_Align_Default = Gr_Align_Left; + + { character types in text strings } + Gr_Byte_Text = 0; { one byte per character } + Gr_Word_Text = 1; { two bytes per character } + Gr_Attr_Text = 2; { chr w/ PC style attribute byte } + + { OR this to the foreground color value for underlined text when + using Gr_Byte_Text or Gr_Word_Text modes. } + Gr_Underline_Text = GrXor shl 4; + + { Font conversion flags for 'GrLoadConvertedFont'. OR them as desired. } + Gr_FontCvt_None = 0; { no conversion } + Gr_FontCvt_SkipChars = 1; { load only selected characters } + Gr_FontCvt_Resize = 2; { resize the font } + Gr_FontCvt_Italicize = 4; { tilt font for "italic" look } + Gr_FontCvt_Boldify = 8; { make a "bold"(er) font } + Gr_FontCvt_Fixify = 16; { convert prop. font to fixed wdt } + Gr_FontCvt_Proportion = 32; { convert fixed font to prop. wdt } + +{ font structures } +type + { font descriptor } + GrFontHeader = record + Name, { font name } + Family: CString; { font family name } + Proportional, { characters have varying width } + Scalable, { derived from a scalable font } + Preloaded, { set when linked Integero program } + Modified: ByteBool; { "tweaked" font (resized, etc..) } + Width, { width (proportional=>average) } + Height, { font height } + Baseline, { baseline pixel pos (from top) } + ULPos, { underline pixel pos (from top) } + ULHeight, { underline width } + MinChar, { lowest character code in font } + NumChars: CCardinal { number of characters in font } + end; + + { character descriptor } + GrFontChrInfo = record + Width, { width of this character } + Offset: CCardinal { offset from start of bitmap } + end; + + { the complete font } + AuxOffsType = array [0 .. 6] of CInteger; + GrFont = record + h: GrFontHeader; { the font info structure } + BitMap, { character bitmap array } + AuxMap: MemPtr; { map for rotated & underline chrs } + MinWidth, { width of narrowest character } + MaxWidth, { width of widest character } + AuxSize, { allocated size of auxiliary map } + AuxNext: CCardinal; { next free byte in auxiliary map } + AuxOffs: ^AuxOffsType; { offsets to completed aux chars } + ChrInfo: array [1 .. 1] of GrFontChrInfo { character info (not act. size) } + end; + GrFontPtr = ^GrFont; + +var + GrFont_PC6x8 : GrFont; varasmname 'GrFont_PC6x8'; + GrFont_PC8x8 : GrFont; varasmname 'GrFont_PC8x8'; + GrFont_PC8x14: GrFont; varasmname 'GrFont_PC8x14'; + GrFont_PC8x16: GrFont; varasmname 'GrFont_PC8x16'; + GrDefaultFont: GrFont; varasmname 'GrFont_PC8x14'; + +function GrLoadFont(FontName: CString): GrFontPtr; asmname 'GrLoadFont'; +function GrLoadConvertedFont(FontName: CString; cvt, w, h, MinCh, MaxCh: CInteger): GrFontPtr; asmname 'GrLoadConvertedFont'; +function GrBuildConvertedFont(protected var From: GrFont; cvt, w, h, MinCh, MaxCh: CInteger): GrFontPtr; asmname 'GrBuildConvertedFont'; + +procedure GrUnloadFont(var Font: GrFont); asmname 'GrUnloadFont'; +procedure GrDumpFont(protected var f: GrFont; CsymbolName, FileName: CString); asmname 'GrDumpFont'; +procedure GrSetFontPath(path_list: CString); asmname 'GrSetFontPath'; + +function GrFontCharPresent(protected var Font: GrFont; Chr: CInteger): Boolean; asmname 'GrFontCharPresent'; +function GrFontCharWidth(protected var Font: GrFont; Chr: CInteger): CInteger; asmname 'GrFontCharWidth'; +function GrFontCharHeight(protected var Font: GrFont; Chr: CInteger): CInteger; asmname 'GrFontCharHeight'; +function GrFontCharBmpRowSize(protected var Font: GrFont; Chr: CInteger): CInteger; asmname 'GrFontCharBmpRowSize'; +function GrFontCharBitmapSize(protected var Font: GrFont; Chr: CInteger): CInteger; asmname 'GrFontCharBitmapSize'; +function GrFontStringWidth(protected var Font: GrFont; Text: CString; Len, Typ_e: CInteger): CInteger; asmname 'GrFontStringWidth'; +function GrFontStringHeight(protected var Font: GrFont; Text: CString; Len, Typ_e: CInteger): CInteger; asmname 'GrFontStringHeight'; +function GrProportionalTextWidth(protected var Font: GrFont; Text: CString; Len, Typ_e: CInteger): CInteger; asmname 'GrProportionalTextWidth'; +function GrBuildAuxiliaryBitmap(var Font: GrFont; Chr, Dir, ul: CInteger): MemPtr; asmname 'GrBuildAuxiliaryBitmap'; +function GrFontCharBitmap(protected var Font: GrFont; Chr: CInteger): MemPtr; asmname 'GrFontCharBitmap'; +function GrFontCharAuxBmp(var Font: GrFont; Chr, Dir, ul: CInteger): MemPtr; asmname 'GrFontCharAuxBmp'; + +type + GrColorTableP = ^GrColors; + + { text color union } + GrTextColor = record + case 1 .. 2 of + 1: (v: GrColor); { color value for "direct" text } + 2: (p: GrColorTableP); { color table for attribute text } + end; + + { text drawing option structure } + GrTextOption = record + txo_Font: GrFontPtr; { font to be used } + txo_FgColor, { foreground color } + txo_BgColor: GrTextColor; { background color } + txo_ChrType, { character type (see above) } + txo_Direct, { direction (see above) } + txo_XAlign, { X alignment (see above) } + txo_YAlign: ByteCard { Y alignment (see above) } + end; + + { fixed font text window desc. } + GrTextRegion = record + txr_Font: GrFontPtr; { font to be used } + txr_FgColor, { foreground color } + txr_BgColor: GrTextColor; { background color } + txr_Buffer, { pointer to text buffer } + txr_Backup: Pointer; { optional backup buffer } + txr_Width, { width of area in chars } + txr_Height, { height of area in chars } + txr_LineOffset, { offset in buffer(s) between rows } + txr_XPos, { upper left corner X coordinate } + txr_YPos: CInteger; { upper left corner Y coordinate } + txr_ChrType: ByteCard { character type (see above) } + end; + +function GrCharWidth(Chr: CInteger; protected var Opt: GrTextOption): CInteger; asmname 'GrCharWidth'; +function GrCharHeight(Chr: CInteger; protected var Opt: GrTextOption): CInteger; asmname 'GrCharHeight'; +procedure GrCharSize(Chr: CInteger; protected var Opt: GrTextOption; var w, h: CInteger); asmname 'GrCharSize'; +function GrStringWidth(Text: CString; Length: CInteger; protected var Opt: GrTextOption): CInteger; asmname 'GrStringWidth'; +function GrStringHeight(Text: CString; Length: CInteger; protected var Opt: GrTextOption): CInteger; asmname 'GrStringHeight'; +procedure GrStringSize(Text: CString; Length: CInteger; protected var Opt: GrTextOption;var w, h: CInteger); asmname 'GrStringSize'; + +procedure GrDrawChar(Chr, x, y: CInteger; protected var Opt: GrTextOption); asmname 'GrDrawChar'; +procedure GrDrawString(Text: CString; Length, x, y: CInteger; protected var Opt: GrTextOption); asmname 'GrDrawString'; +procedure GrTextXY(x, y: CInteger; Text: CString; fg, bg: GrColor); asmname 'GrTextXY'; + +procedure GrDumpChar(Chr, Col, Row: CInteger; protected var r: GrTextRegion); asmname 'GrDumpChar'; +procedure GrDumpText(Col, Row, Wdt, Hgt: CInteger; protected var r: GrTextRegion); asmname 'GrDumpText'; +procedure GrDumpTextRegion(protected var r: GrTextRegion); asmname 'GrDumpTextRegion'; + +{ ================================================================= + THICK AND DASHED LINE DRAWING PRIMITIVES + ================================================================== } + +{ custom line option structure + zero or one dash pattern length means the line is continuous + the dash pattern always begins with a drawn section } + +type + GrLineOption = record + Lno_Color : GrColor; { color used to draw line } + Lno_Width, { width of the line } + Lno_PattLen: CInteger; { length of the dash pattern } + Lno_DashPat: MemPtr { draw/nodraw pattern } + end; + +procedure GrCustomLine(x1, y1, x2, y2: CInteger; protected var o: GrLineOption); asmname 'GrCustomLine'; +procedure GrCustomBox(x1, y1, x2, y2: CInteger; protected var o: GrLineOption); asmname 'GrCustomBox'; +procedure GrCustomCircle(xc, yc, r: CInteger; protected var o: GrLineOption); asmname 'GrCustomCircle'; +procedure GrCustomEllipse(xc, yc, r: CInteger; protected var o: GrLineOption); asmname 'GrCustomEllipse'; +procedure GrCustomCircleArc(xc, yc, r, Start, Ende, Style: CInteger; protected var o: GrLineOption); asmname 'GrCustomCircleArc'; +procedure GrCustomEllipseArc(xc, yc, xa, ya, Start, Ende, Style: CInteger; protected var o: GrLineOption); asmname 'GrCustomEllipseArc'; +procedure GrCustomPolyLine(NumPts: CInteger; var Points{ : array of PointType }; protected var o: GrLineOption); asmname 'GrCustomPolyLine'; +procedure GrCustomPolygon(NumPts: CInteger; var Points{ : array of PointType }; protected var o: GrLineOption); asmname 'GrCustomPolygon'; + +{ ================================================================== + PATTERNED DRAWING AND FILLING PRIMITIVES + ================================================================== } + +{ BITMAP: a mode independent way to specify a fill pattern of two + colors. It is always 8 pixels wide (1 byte per scan line), its + height is user-defined. SET THE TYPE FLAG TO ZERO!!! } + +type + GrBitmap = record + bmp_IsPixMap, { type flag for pattern union } + bmp_Height: CInteger; { bitmap height } + bmp_Data: MemPtr; { pointer to the bit pattern } + bmp_FgColor, { foreground color for fill } + bmp_BgColor: GrColor; { background color for fill } + bmp_MemFlags: CInteger { set if dynamically allocated } + end; + + { PIXMAP: a fill pattern stored in a layout identical to the video RAM + for filling using 'bitblt'-s. It is mode dependent, typically one + of the library functions is used to build it. KEEP THE TYPE FLAG + NONZERO!!! } + + GrPixmap = record + pxp_IsPixMap, { type flag for pattern union } + pxp_Width, { pixmap width (in pixels) } + pxp_Height: CInteger; { pixmap height (in pixels) } + pxp_Oper: GrColor; { bitblt mode (SET, OR, XOR, AND, IMAGE) } + pxp_Source: GrFrameType { source context for fill } + end; + + { Fill pattern union -- can either be a bitmap or a pixmap } + + GrPattern = record + case 1 .. 3 of + 1: (gp_IsPixMap: CInteger); { nonzero for pixmaps } + 2: (gp_BitMap : GrBitmap); { fill bitmap } + 3: (gp_PixMap : GrPixmap); { fill pixmap } + end; + GrPatternPtr = ^GrPattern; + + { Draw pattern for line drawings -- specifies both the: + (1) fill pattern, and the + (2) custom line drawing option } + GrLinePattern = record + lnp_Pattern: GrPatternPtr; { fill pattern } + lnp_Option : ^GrLineOption { width + dash pattern } + end; + GrLinePatternPtr = GrLinePattern; + +function GrBuildPixmap(protected var Pixels; w, h: CInteger; protected var Colors { : array of GrColor }): GrPatternPtr; asmname 'GrBuildPixmap'; +function GrBuildPixmapFromBits(protected var Bits; w, h: CInteger; fgc, bgc: GrColor): GrPatternPtr; asmname 'GrBuildPixmapFromBits'; +function GrConvertToPixmap(Src: GrContextPtr): GrPatternPtr; asmname 'GrConvertToPixmap'; + +procedure GrDestroyPattern(p: GrPatternPtr); asmname 'GrDestroyPattern'; + +procedure GrPatternedLine(x1, y1, x2, y2: CInteger; lp: GrLinePatternPtr); asmname 'GrPatternedLine'; +procedure GrPatternedBox(x1, y1, x2, y2: CInteger; lp: GrLinePatternPtr); asmname 'GrPatternedBox'; +procedure GrPatternedCircle(xc, yc, r: CInteger; lp: GrLinePatternPtr); asmname 'GrPatternedCircle'; +procedure GrPatternedEllipse(xc, yc, xa, ya: CInteger; lp: GrLinePatternPtr); asmname 'GrPatternedEllipse'; +procedure GrPatternedCircleArc(xc, yc, r, Start, Ende, Style: CInteger; lp: GrLinePatternPtr); asmname 'GrPatternedCircleArc'; +procedure GrPatternedEllipseArc(xc, yc, xa, ya, Start, Ende, Style: CInteger; lp: GrLinePatternPtr); asmname 'GrPatternedEllipseArc'; +procedure GrPatternedPolyLine(NumPts: CInteger; var Points{ : array of PointType }; lp: GrLinePatternPtr); asmname 'GrPatternedPolyLine'; +procedure GrPatternedPolygon(NumPts: CInteger; var Points{ : array of PointType }; lp: GrLinePatternPtr); asmname 'GrPatternedPolygon'; + +procedure GrPatternFilledPlot(x, y: CInteger; p: GrPatternPtr); asmname 'GrPatternFilledPlot'; +procedure GrPatternFilledLine(x1, y1, x2, y2: CInteger; p: GrPatternPtr); asmname 'GrPatternFilledLine'; +procedure GrPatternFilledBox(x1, y1, x2, y2: CInteger; p: GrPatternPtr); asmname 'GrPatternFilledBox'; +procedure GrPatternFilledCircle(xc, yc, r: CInteger; p: GrPatternPtr); asmname 'GrPatternFilledCircle'; +procedure GrPatternFilledEllipse(xc, yc, xa, ya: CInteger; p: GrPatternPtr); asmname 'GrPatternFilledEllipse'; +procedure GrPatternFilledCircleArc(xc, yc, r, Start, Ende, Style: CInteger; p: GrPatternPtr); asmname 'GrPatternFilledCircleArc'; +procedure GrPatternFilledEllipseArc(xc, yc, xa, ya, Start, Ende, Style: CInteger; p: GrPatternPtr); asmname 'GrPatternFilledEllipseArc'; +procedure GrPatternFilledConvexPolygon(NumPts: CInteger; var Points{ : array of PointType }; p: GrPatternPtr); asmname 'GrPatternFilledConvexPolygon'; +procedure GrPatternFilledPolygon(NumPts: CInteger; var Points{ : array of PointType }; p: GrPatternPtr); asmname 'GrPatternFilledPolygon'; +procedure GrPatternFloodFill(x, y: CInteger; Border: GrColor; p: GrPatternPtr); asmname 'GrPatternFloodFill'; + +procedure GrPatternDrawChar(Chr, x, y: CInteger; protected var Opt: GrTextOption; p: GrPatternPtr); asmname 'GrPatternDrawChar'; +procedure GrPatternDrawString(Text: CString; Length, x, y: CInteger; protected var Opt: GrTextOption; p: GrPatternPtr); asmname 'GrPatternDrawString'; +procedure GrPatternDrawStringExt(Text: CString; Length, x, y: CInteger; protected var Opt: GrTextOption; p: GrPatternPtr); asmname 'GrPatternDrawStringExt'; + + +{ ================================================================== + IMAGE MANIPULATION + ================================================================== } + +{ - Image Utility + by Michal Stencl Copyright (c) 1998 for GRX + - [stenclpmd@ba.telecom.sk] } + +type + GrImagePtr = ^GrPixmap; + +{ Flags for GrImageInverse() } +const + Gr_Image_Inverse_LR = 1; { inverse left right } + Gr_Image_Inverse_TD = 2; { inverse top down } + +function GrImageBuild(protected var Pixels; w, h: CInteger; protected var Colors { : array of GrColor }): GrImagePtr; asmname 'GrImageBuild'; +procedure GrImageDestroy(i: GrImagePtr); asmname 'GrImageDestroy'; +procedure GrImageDisplay(x,y: CInteger; i: GrImagePtr); asmname 'GrImageDisplay'; +procedure GrImageDisplayExt(x1,y1,x2,y2: CInteger; i: GrImagePtr); asmname 'GrImageDisplayExt'; +procedure GrImageFilledBoxAlign(xo,yo,x1,y1,x2,y2: CInteger; p: GrImagePtr); asmname 'GrImageFilledBoxAlign'; +procedure GrImageHLineAlign(xo,yo,x,y,Width: CInteger; p: GrImagePtr); asmname 'GrImageHLineAlign'; +procedure GrImagePlotAlign(xo,yo,x,y: CInteger; p: GrImagePtr); asmname 'GrImagePlotAlign'; + +function GrImageInverse(p: GrImagePtr; Flag: CInteger): GrImagePtr; asmname 'GrImageInverse'; +function GrImageStretch(p: GrImagePtr; NWidth, NHeight: CInteger): GrImagePtr; asmname 'GrImageStretch'; + +function GrImageFromPattern(p: GrPatternPtr): GrImagePtr; asmname 'GrImageFromPattern'; +function GrImageFromContext(c: GrContextPtr): GrImagePtr; asmname 'GrImageFromContext'; +function GrImageBuildUsedAsPattern(protected var Pixels; w, h: CInteger; protected var Colors { : array of GrColor }): GrImagePtr; asmname 'GrImageBuildUsedAsPattern'; + +function GrPatternFromImage(i: GrImagePtr): GrPatternPtr; asmname 'GrPatternFromImage'; + +{ ================================================================== + DRAWING IN USER WINDOW COORDINATES + ================================================================== } + +procedure GrSetUserWindow(x1, y1, x2, y2: CInteger); asmname 'GrSetUserWindow'; +procedure GrGetUserWindow(var x1, y1, x2, y2: CInteger); asmname 'GrGetUserWindow'; +procedure GrGetScreenCoord(var x, y: CInteger); asmname 'GrGetScreenCoord'; +procedure GrGetUserCoord(var x, y: CInteger); asmname 'GrGetUserCoord'; + +procedure GrUsrPlot(x, y: CInteger; c:GrColor); asmname 'GrUsrPlot'; +procedure GrUsrLine(x1, y1, x2, y2: CInteger; c:GrColor); asmname 'GrUsrLine'; +procedure GrUsrHLine(x1, x2, y:CInteger; c:GrColor); asmname 'GrUsrHLine'; +procedure GrUsrVLine(x, y1, y2: CInteger; c: GrColor); asmname 'GrUsrVLine'; +procedure GrUsrBox(x1, y1, x2, y2: CInteger; c: GrColor); asmname 'GrUsrBox'; +procedure GrUsrFilledBox(x1, y1, x2, y2: CInteger; c: GrColor); asmname 'GrUsrFilledBox'; +procedure GrUsrFramedBox(x1, y1, x2, y2, Wdt: CInteger; c: GrFBoxColors); asmname 'GrUsrFramedBox'; + +procedure GrUsrCircle(xc, yc, r: CInteger; c: GrColor); asmname 'GrUsrCircle'; +procedure GrUsrEllipse(xc, yc, xa, ya: CInteger; c: GrColor); asmname 'GrUsrEllipse'; +procedure GrUsrCircleArc(xc, yc, r, Start, Ende, Style: CInteger; c: GrColor); asmname 'GrUsrCircleArc'; +procedure GrUsrEllipseArc(xc, yc, xa, ya, Start, Ende, Style: CInteger; c: GrColor); asmname 'GrUsrEllipseArc'; +procedure GrUsrFilledCircle(xc, yc, r: CInteger; c: GrColor); asmname 'GrUsrFilledCircle'; +procedure GrUsrFilledEllipse(xc, yc, xa, ya: CInteger; c: GrColor); asmname 'GrUsrFilledEllipse'; +procedure GrUsrFilledCircleArc(xc, yc, r, Start, Ende, Style: CInteger; c: GrColor); asmname 'GrUsrFilledCircleArc'; +procedure GrUsrFilledEllipseArc(xc, yc, xa, ya, Start, Ende, Style: CInteger; c: GrColor); asmname 'GrUsrFilledEllipseArc'; +procedure GrUsrPolyLine(NumPts: CInteger; var Points{ : array of PointType }; c: GrColor); asmname 'GrUsrPolyLine'; +procedure GrUsrPolygon(NumPts: CInteger; var Points{ : array of PointType }; c: GrColor); asmname 'GrUsrPolygon'; +procedure GrUsrFilledConvexPolygon(NumPts: CInteger; var Points{ : array of PointType }; c: GrColor); asmname 'GrUsrFilledConvexPolygon'; +procedure GrUsrFilledPolygon(NumPts: CInteger; var Points{ : array of PointType }; c: GrColor); asmname 'GrUsrFilledPolygon'; +procedure GrUsrFloodFill(x, y: CInteger; Border, c: GrColor); asmname 'GrUsrFloodFill'; + +function GrUsrPixel(x, y:CInteger):GrColor; asmname 'GrUsrPixel'; +function GrUsrPixelC(c: GrContextPtr; x, y: CInteger):GrColor; asmname 'GrUsrPixelC'; + +procedure GrUsrCustomLine(x1, y1, x2, y2: CInteger; protected var o: GrLineOption); asmname 'GrUsrCustomLine'; +procedure GrUsrCustomBox(x1, y1, x2, y2: CInteger; protected var o: GrLineOption); asmname 'GrUsrCustomBox'; +procedure GrUsrCustomCircle(xc, yc, r: CInteger; protected var o: GrLineOption); asmname 'GrUsrCustomCircle'; +procedure GrUsrCustomEllipse(xc, yc, r: CInteger; protected var o: GrLineOption); asmname 'GrUsrCustomEllipse'; +procedure GrUsrCustomCircleArc(xc, yc, r, Start, Ende, Style: CInteger; protected var o: GrLineOption); asmname 'GrUsrCustomCircleArc'; +procedure GrUsrCustomEllipseArc(xc, yc, xa, ya, Start, Ende, Style: CInteger; protected var o: GrLineOption); asmname 'GrUsrCustomEllipseArc'; +procedure GrUsrCustomPolyLine(NumPts: CInteger; var Points{ : array of PointType }; protected var o: GrLineOption); asmname 'GrUsrCustomPolyLine'; +procedure GrUsrCustomPolygon(NumPts: CInteger; var Points{ : array of PointType }; protected var o: GrLineOption); asmname 'GrUsrCustomPolygon'; + +procedure GrUsrPatternedLine(x1, y1, x2, y2: CInteger; lp: GrLinePatternPtr); asmname 'GrUsrPatternedLine'; +procedure GrUsrPatternedBox(x1, y1, x2, y2: CInteger; lp: GrLinePatternPtr); asmname 'GrUsrPatternedBox'; +procedure GrUsrPatternedCircle(xc, yc, r: CInteger; lp: GrLinePatternPtr); asmname 'GrUsrPatternedCircle'; +procedure GrUsrPatternedEllipse(xc, yc, xa, ya: CInteger; lp: GrLinePatternPtr); asmname 'GrUsrPatternedEllipse'; +procedure GrUsrPatternedCircleArc(xc, yc, r, Start, Ende, Style: CInteger; lp: GrLinePatternPtr); asmname 'GrUsrPatternedCircleArc'; +procedure GrUsrPatternedEllipseArc(xc, yc, xa, ya, Start, Ende, Style: CInteger; lp: GrLinePatternPtr); asmname 'GrUsrPatternedEllipseArc'; +procedure GrUsrPatternedPolyLine(NumPts: CInteger; var Points{ : array of PointType }; lp: GrLinePatternPtr); asmname 'GrUsrPatternedPolyLine'; +procedure GrUsrPatternedPolygon(NumPts: CInteger; var Points{ : array of PointType }; lp: GrLinePatternPtr); asmname 'GrUsrPatternedPolygon'; + +procedure GrUsrPatternFilledPlot(x, y: CInteger; p: GrPatternPtr); asmname 'GrPatternFilledPlot'; +procedure GrUsrPatternFilledLine(x1, y1, x2, y2: CInteger; p: GrPatternPtr); asmname 'GrUsrPatternFilledLine'; +procedure GrUsrPatternFilledBox(x1, y1, x2, y2: CInteger; p: GrPatternPtr); asmname 'GrUsrPatternFilledBox'; +procedure GrUsrPatternFilledCircle(xc, yc, r: CInteger; p: GrPatternPtr); asmname 'GrUsrPatternFilledCircle'; +procedure GrUsrPatternFilledEllipse(xc, yc, xa, ya: CInteger; p: GrPatternPtr); asmname 'GrUsrPatternFilledEllipse'; +procedure GrUsrPatternFilledCircleArc(xc, yc, r, Start, Ende, Style: CInteger; p: GrPatternPtr); asmname 'GrUsrPatternFilledCircleArc'; +procedure GrUsrPatternFilledEllipseArc(xc, yc, xa, ya, Start, Ende, Style: CInteger; p: GrPatternPtr); asmname 'GrUsrPatternFilledEllipseArc'; +procedure GrUsrPatternFilledConvexPolygon(NumPts: CInteger; var Points{ : array of PointType }; p: GrPatternPtr); asmname 'GrUsrPatternFilledConvexPolygon'; +procedure GrUsrPatternFilledPolygon(NumPts: CInteger; var Points{ : array of PointType }; p: GrPatternPtr); asmname 'GrUsrPatternFilledPolygon'; +procedure GrUsrPatternFloodFill(x, y: CInteger; Border: GrColor; p: GrPatternPtr); asmname 'GrUsrPatternFloodFill'; + +procedure GrUsrDrawChar(Chr, x, y: CInteger; protected var Opt: GrTextOption); asmname 'GrUsrDrawChar'; +procedure GrUsrDrawString(Text: CString; Length, x, y: CInteger; protected var Opt: GrTextOption); asmname 'GrUsrDrawString'; +procedure GrUsrTextXY(x, y: CInteger; Text: CString; fg, bg: CInteger); asmname 'GrUsrTextXY'; + +{ ================================================================== + GRAPHICS CURSOR UTILITIES + ================================================================== } + +type + GrCursor = record + Work: GrContext; { work areas (4) } + XCord,YCord, { cursor position on screen } + XSize,YSize, { cursor size } + XOffs,YOffs, { LU corner to hot point offset } + XWork,YWork, { save/work area sizes } + XWPos,YWPos, { save/work area position on screen } + Displayed: CInteger { set if displayed } + end; + GrCursorPtr = ^GrCursor; + +function GrBuildCursor(Pixels: Pointer; Pitch, w, h, xo, yo: CInteger; protected var Colors { : array of GrColor }): GrCursorPtr; asmname 'GrBuildCursor'; +procedure GrDestroyCursor(Cursor: GrCursorPtr); asmname 'GrDestroyCursor'; +procedure GrDisplayCursor(Cursor: GrCursorPtr); asmname 'GrDisplayCursor'; +procedure GrEraseCursor(Cursor: GrCursorPtr); asmname 'GrEraseCursor'; +procedure GrMoveCursor(Cursor: GrCursorPtr; x, y: CInteger); asmname 'GrMoveCursor'; + +{ ================================================================== + MOUSE AND KEYBOARD INPUT UTILITIES + ================================================================== } + +const + Gr_M_Motion = $0001; { mouse event flag bits } + Gr_M_Left_Down = $0002; + Gr_M_Left_Up = $0004; + Gr_M_Right_Down = $0008; + Gr_M_Right_Up = $0010; + Gr_M_Middle_Down = $0020; + Gr_M_Middle_Up = $0040; + Gr_M_P4_Down = $0400; + Gr_M_P4_Up = $0800; + Gr_M_P5_Down = $2000; + Gr_M_P5_Up = $4000; + Gr_M_Button_Down = Gr_M_Left_Down or Gr_M_Middle_Down or Gr_M_Right_Down or Gr_M_P4_Down or Gr_M_P5_Down; + Gr_M_Button_Up = Gr_M_Left_Up or Gr_M_Middle_Up or Gr_M_Right_Up or Gr_M_P4_Up or Gr_M_P5_Up; + Gr_M_Button_Change = Gr_M_Button_Up or Gr_M_Button_Down; + + Gr_M_Left = $01; { mouse button index bits } + Gr_M_Right = $02; + Gr_M_Middle = $04; + Gr_M_P4 = $08; + Gr_M_P5 = $10; + + Gr_M_KeyPress = $0080; { other event flag bits } + Gr_M_Poll = $0100; + Gr_M_NoPaint = $0200; + Gr_Command = $1000; + Gr_M_Event = Gr_M_Motion or Gr_M_KeyPress or Gr_M_Button_Change or Gr_Command; + + Gr_KB_RightShift = $01; { Keybd states: right shift key depressed } + Gr_KB_LeftShift = $02; { left shift key depressed } + Gr_KB_Ctrl = $04; { CTRL depressed } + Gr_KB_Alt = $08; { ALT depressed } + Gr_KB_ScrolLock = $10; { SCROLL LOCK active } + Gr_KB_NumLock = $20; { NUM LOCK active } + Gr_KB_CapsLock = $40; { CAPS LOCK active } + Gr_KB_Insert = $80; { INSERT state active } + Gr_KB_Shift = Gr_KB_LeftShift or Gr_KB_RightShift; + + Gr_M_Cur_Normal = 0; { MOUSE CURSOR modes: just the cursor } + Gr_M_Cur_Rubber = 1; { rectangular rubber band (XOR-d to the screen) } + Gr_M_Cur_Line = 2; { line attached to the cursor } + Gr_M_Cur_Box = 3; { rectangular box dragged by the cursor } + Gr_M_Cur_Cross = 4; { crosshair } + + Gr_M_Queue_Size = 128; { default queue size } + +type + { mouse event buffer structure } + GrMouseEvent = record + Flags, { event type flags (see above) } + x, y, { mouse coordinates } + Buttons, { mouse button state } + Key, { key code from keyboard } + KBStat: CInteger; { keybd status (ALT, CTRL, etc..) } + DTime: MedInt { time since last event (msec) } + end; + GrMouseEventPtr = ^GrMouseEvent; + +function GrMouseDetect: Boolean; asmname 'GrMouseDetect'; +procedure GrMouseEventMode(Dummy: CInteger); asmname 'GrMouseEventMode'; +procedure GrMouseInit; asmname 'GrMouseInit'; +procedure GrMouseInitN(Queue_Size: CInteger); asmname 'GrMouseInitN'; +procedure GrMouseUnInit; asmname 'GrMouseUnInit'; +procedure GrMouseSetSpeed(SPMult, SPDiv: CInteger); asmname 'GrMouseSetSpeed'; +procedure GrMouseSetAccel(Thresh, Accel: CInteger); asmname 'GrMouseSetAccel'; +procedure GrMouseSetLimits(x1, y1, x2, y2: CInteger); asmname 'GrMouseSetLimits'; +procedure GrMouseGetLimits(var x1, y1, x2, y2: CInteger); asmname 'GrMouseGetLimits'; +procedure GrMouseWarp(x, y: CInteger); asmname 'GrMouseWarp'; +procedure GrMouseEventEnable(Enable_KB, Enable_MS: Boolean); asmname 'GrMouseEventEnable'; +procedure GrMouseGetEvent(Flags: CInteger; Event: GrMouseEventPtr); asmname 'GrMouseGetEvent'; +procedure GrMouseGetEventT(Flags: CInteger; Event: GrMouseEventPtr; timout_msecs: CInteger); asmname 'GrMouseGetEventT'; +function GrMousePendingEvent: CInteger; asmname 'GrMousePendingEvent'; + +function GrMouseGetCursor: GrCursorPtr; asmname 'GrMouseGetCursor'; +procedure GrMouseSetCursor(Cursor: GrCursorPtr); asmname 'GrMouseSetCursor'; +procedure GrMouseSetColors(fg,bg: GrColor); asmname 'GrMouseSetColors'; +procedure GrMouseSetCursorMode(Mode: CInteger; x1, y1, x2, y2: CInteger; c: CInteger); asmname 'GrMouseSetCursorMode'; +procedure GrMouseDisplayCursor; asmname 'GrMouseDisplayCursor'; +procedure GrMouseEraseCursor; asmname 'GrMouseEraseCursor'; +procedure GrMouseUpdateCursor; asmname 'GrMouseUpdateCursor'; +function GrMouseCursorIsDisplayed: Boolean; asmname 'GrMouseCursorIsDisplayed'; + +function GrMouseBlock(c: GrContextPtr; x1, y1, x2, y2: CInteger): CInteger; asmname 'GrMouseBlock'; +procedure GrMouseUnBlock(Return_Value_From_GrMouseBlock: CInteger); asmname 'GrMouseUnBlock'; + +{ ================================================================== + KEYBOARD INTERFACE + ================================================================== } + +const + GrKey_NoKey = $0000; { no key available } + GrKey_OutsideValidRange = $0100; { key typed but code outside 1 .. GrKey_LastDefinedKeycode } + + { standard ASCII key codes } + GrKey_Control_A = $0001; + GrKey_Control_B = $0002; + GrKey_Control_C = $0003; + GrKey_Control_D = $0004; + GrKey_Control_E = $0005; + GrKey_Control_F = $0006; + GrKey_Control_G = $0007; + GrKey_Control_H = $0008; + GrKey_Control_I = $0009; + GrKey_Control_J = $000a; + GrKey_Control_K = $000b; + GrKey_Control_L = $000c; + GrKey_Control_M = $000d; + GrKey_Control_N = $000e; + GrKey_Control_O = $000f; + GrKey_Control_P = $0010; + GrKey_Control_Q = $0011; + GrKey_Control_R = $0012; + GrKey_Control_S = $0013; + GrKey_Control_T = $0014; + GrKey_Control_U = $0015; + GrKey_Control_V = $0016; + GrKey_Control_W = $0017; + GrKey_Control_X = $0018; + GrKey_Control_Y = $0019; + GrKey_Control_Z = $001a; + GrKey_Control_LBracket = $001b; + GrKey_Control_BackSlash = $001c; + GrKey_Control_RBracket = $001d; + GrKey_Control_Caret = $001e; + GrKey_Control_Underscore = $001f; + GrKey_Space = $0020; + GrKey_ExclamationPoint = $0021; + GrKey_DoubleQuote = $0022; + GrKey_Hash = $0023; + GrKey_Dollar = $0024; + GrKey_Percent = $0025; + GrKey_Ampersand = $0026; + GrKey_Quote = $0027; + GrKey_LParen = $0028; + GrKey_RParen = $0029; + GrKey_Star = $002a; + GrKey_Plus = $002b; + GrKey_Comma = $002c; + GrKey_Dash = $002d; + GrKey_Period = $002e; + GrKey_Slash = $002f; + GrKey_0 = $0030; + GrKey_1 = $0031; + GrKey_2 = $0032; + GrKey_3 = $0033; + GrKey_4 = $0034; + GrKey_5 = $0035; + GrKey_6 = $0036; + GrKey_7 = $0037; + GrKey_8 = $0038; + GrKey_9 = $0039; + GrKey_Colon = $003a; + GrKey_SemiColon = $003b; + GrKey_LAngle = $003c; + GrKey_Equals = $003d; + GrKey_RAngle = $003e; + GrKey_QuestionMark = $003f; + GrKey_At = $0040; + GrKey_A = $0041; + GrKey_B = $0042; + GrKey_C = $0043; + GrKey_D = $0044; + GrKey_E = $0045; + GrKey_F = $0046; + GrKey_G = $0047; + GrKey_H = $0048; + GrKey_I = $0049; + GrKey_J = $004a; + GrKey_K = $004b; + GrKey_L = $004c; + GrKey_M = $004d; + GrKey_N = $004e; + GrKey_O = $004f; + GrKey_P = $0050; + GrKey_Q = $0051; + GrKey_R = $0052; + GrKey_S = $0053; + GrKey_T = $0054; + GrKey_U = $0055; + GrKey_V = $0056; + GrKey_W = $0057; + GrKey_X = $0058; + GrKey_Y = $0059; + GrKey_Z = $005a; + GrKey_LBracket = $005b; + GrKey_BackSlash = $005c; + GrKey_RBracket = $005d; + GrKey_Caret = $005e; + GrKey_UnderScore = $005f; + GrKey_BackQuote = $0060; + GrKey_Small_a = $0061; + GrKey_Small_b = $0062; + GrKey_Small_c = $0063; + GrKey_Small_d = $0064; + GrKey_Small_e = $0065; + GrKey_Small_f = $0066; + GrKey_Small_g = $0067; + GrKey_Small_h = $0068; + GrKey_Small_i = $0069; + GrKey_Small_j = $006a; + GrKey_Small_k = $006b; + GrKey_Small_l = $006c; + GrKey_Small_m = $006d; + GrKey_Small_n = $006e; + GrKey_Small_o = $006f; + GrKey_Small_p = $0070; + GrKey_Small_q = $0071; + GrKey_Small_r = $0072; + GrKey_Small_s = $0073; + GrKey_Small_t = $0074; + GrKey_Small_u = $0075; + GrKey_Small_v = $0076; + GrKey_Small_w = $0077; + GrKey_Small_x = $0078; + GrKey_Small_y = $0079; + GrKey_Small_z = $007a; + GrKey_LBrace = $007b; + GrKey_Pipe = $007c; + GrKey_RBrace = $007d; + GrKey_Tilde = $007e; + GrKey_Control_Backspace = $007f; + + { extended key codes as defined in DJGPP } + GrKey_Alt_Escape = $0101; + GrKey_Control_At = $0103; + GrKey_Alt_Backspace = $010e; + GrKey_BackTab = $010f; + GrKey_Alt_Q = $0110; + GrKey_Alt_W = $0111; + GrKey_Alt_E = $0112; + GrKey_Alt_R = $0113; + GrKey_Alt_T = $0114; + GrKey_Alt_Y = $0115; + GrKey_Alt_U = $0116; + GrKey_Alt_I = $0117; + GrKey_Alt_O = $0118; + GrKey_Alt_P = $0119; + GrKey_Alt_LBracket = $011a; + GrKey_Alt_RBracket = $011b; + GrKey_Alt_Return = $011c; + GrKey_Alt_A = $011e; + GrKey_Alt_S = $011f; + GrKey_Alt_D = $0120; + GrKey_Alt_F = $0121; + GrKey_Alt_G = $0122; + GrKey_Alt_H = $0123; + GrKey_Alt_J = $0124; + GrKey_Alt_K = $0125; + GrKey_Alt_L = $0126; + GrKey_Alt_Semicolon = $0127; + GrKey_Alt_Quote = $0128; + GrKey_Alt_Backquote = $0129; + GrKey_Alt_Backslash = $012b; + GrKey_Alt_Z = $012c; + GrKey_Alt_X = $012d; + GrKey_Alt_C = $012e; + GrKey_Alt_V = $012f; + GrKey_Alt_B = $0130; + GrKey_Alt_N = $0131; + GrKey_Alt_M = $0132; + GrKey_Alt_Comma = $0133; + GrKey_Alt_Period = $0134; + GrKey_Alt_Slash = $0135; + GrKey_Alt_KPStar = $0137; + GrKey_F1 = $013b; + GrKey_F2 = $013c; + GrKey_F3 = $013d; + GrKey_F4 = $013e; + GrKey_F5 = $013f; + GrKey_F6 = $0140; + GrKey_F7 = $0141; + GrKey_F8 = $0142; + GrKey_F9 = $0143; + GrKey_F10 = $0144; + GrKey_Home = $0147; + GrKey_Up = $0148; + GrKey_PageUp = $0149; + GrKey_Alt_KPMinus = $014a; + GrKey_Left = $014b; + GrKey_Center = $014c; + GrKey_Right = $014d; + GrKey_Alt_KPPlus = $014e; + GrKey_End = $014f; + GrKey_Down = $0150; + GrKey_PageDown = $0151; + GrKey_Insert = $0152; + GrKey_Delete = $0153; + GrKey_Shift_F1 = $0154; + GrKey_Shift_F2 = $0155; + GrKey_Shift_F3 = $0156; + GrKey_Shift_F4 = $0157; + GrKey_Shift_F5 = $0158; + GrKey_Shift_F6 = $0159; + GrKey_Shift_F7 = $015a; + GrKey_Shift_F8 = $015b; + GrKey_Shift_F9 = $015c; + GrKey_Shift_F10 = $015d; + GrKey_Control_F1 = $015e; + GrKey_Control_F2 = $015f; + GrKey_Control_F3 = $0160; + GrKey_Control_F4 = $0161; + GrKey_Control_F5 = $0162; + GrKey_Control_F6 = $0163; + GrKey_Control_F7 = $0164; + GrKey_Control_F8 = $0165; + GrKey_Control_F9 = $0166; + GrKey_Control_F10 = $0167; + GrKey_Alt_F1 = $0168; + GrKey_Alt_F2 = $0169; + GrKey_Alt_F3 = $016a; + GrKey_Alt_F4 = $016b; + GrKey_Alt_F5 = $016c; + GrKey_Alt_F6 = $016d; + GrKey_Alt_F7 = $016e; + GrKey_Alt_F8 = $016f; + GrKey_Alt_F9 = $0170; + GrKey_Alt_F10 = $0171; + GrKey_Control_Print = $0172; + GrKey_Control_Left = $0173; + GrKey_Control_Right = $0174; + GrKey_Control_End = $0175; + GrKey_Control_PageDown = $0176; + GrKey_Control_Home = $0177; + GrKey_Alt_1 = $0178; + GrKey_Alt_2 = $0179; + GrKey_Alt_3 = $017a; + GrKey_Alt_4 = $017b; + GrKey_Alt_5 = $017c; + GrKey_Alt_6 = $017d; + GrKey_Alt_7 = $017e; + GrKey_Alt_8 = $017f; + GrKey_Alt_9 = $0180; + GrKey_Alt_0 = $0181; + GrKey_Alt_Dash = $0182; + GrKey_Alt_Equals = $0183; + GrKey_Control_PageUp = $0184; + GrKey_F11 = $0185; + GrKey_F12 = $0186; + GrKey_Shift_F11 = $0187; + GrKey_Shift_F12 = $0188; + GrKey_Control_F11 = $0189; + GrKey_Control_F12 = $018a; + GrKey_Alt_F11 = $018b; + GrKey_Alt_F12 = $018c; + GrKey_Control_Up = $018d; + GrKey_Control_KPDash = $018e; + GrKey_Control_Center = $018f; + GrKey_Control_KPPlus = $0190; + GrKey_Control_Down = $0191; + GrKey_Control_Insert = $0192; + GrKey_Control_Delete = $0193; + GrKey_Control_Tab = $0194; + GrKey_Control_KPSlash = $0195; + GrKey_Control_KPStar = $0196; + GrKey_Alt_KPSlash = $01a4; + GrKey_Alt_Tab = $01a5; + GrKey_Alt_Enter = $01a6; + + { some additional codes not in DJGPP } + GrKey_Alt_LAngle = $01b0; + GrKey_Alt_RAngle = $01b1; + GrKey_Alt_At = $01b2; + GrKey_Alt_LBrace = $01b3; + GrKey_Alt_Pipe = $01b4; + GrKey_Alt_RBrace = $01b5; + GrKey_Print = $01b6; + GrKey_Shift_Insert = $01b7; + GrKey_Shift_Home = $01b8; + GrKey_Shift_End = $01b9; + GrKey_Shift_PageUp = $01ba; + GrKey_Shift_PageDown = $01bb; + GrKey_Alt_Up = $01bc; + GrKey_Alt_Left = $01bd; + GrKey_Alt_Center = $01be; + GrKey_Alt_Right = $01c0; + GrKey_Alt_Down = $01c1; + GrKey_Alt_Insert = $01c2; + GrKey_Alt_Delete = $01c3; + GrKey_Alt_Home = $01c4; + GrKey_Alt_End = $01c5; + GrKey_Alt_PageUp = $01c6; + GrKey_Alt_PageDown = $01c7; + GrKey_Shift_Up = $01c8; + GrKey_Shift_Down = $01c9; + GrKey_Shift_Right = $01ca; + GrKey_Shift_Left = $01cb; + + { this may be usefull for table allocation ... } + GrKey_LastDefinedKeycode = GrKey_Shift_Left; + + { some well known synomyms } + GrKey_BackSpace = GrKey_Control_H; + GrKey_Tab = GrKey_Control_I; + GrKey_LineFeed = GrKey_Control_J; + GrKey_Escape = GrKey_Control_LBracket; + GrKey_Return = GrKey_Control_M; + +type + GrKeyType = ShortInt; + +{ new functions to replace the old style + kbhit / getch / getkey / getxkey / getkbstat + keyboard interface } +function GrKeyPressed: CInteger; asmname 'GrKeyPressed'; +function GrKeyRead: GrKeyType; asmname 'GrKeyRead'; +function GrKeyStat: CInteger; asmname 'GrKeyStat'; + +{ ================================================================== + MISCELLANEOUS UTILITIY FUNCTIONS + ================================================================== } + +procedure GrResizeGrayMap (var Map; Pitch, ow, oh, nw, nh: CInteger); asmname 'GrResizeGrayMap'; +function GrMatchString (Pattern, Strg: CString): CInteger; asmname 'GrMatchString'; +procedure GrSetWindowTitle (Title: CString); asmname 'GrSetWindowTitle'; +procedure GrSleep (MSec: CInteger); asmname 'GrSleep'; +procedure GrFlush; asmname 'GrFlush'; + +{ ================================================================== + PNM FUNCTIONS + ================================================================== } + +{ The PNM formats, grx support load/save of binaries formats (4,5,6) only } + +const + PlainPBMFormat = 1; + PlainPGMFormat = 2; + PlainPPMFormat = 3; + PBMFormat = 4; + PGMFormat = 5; + PPMFormat = 6; + +{ The PNM functions } + +function GrSaveContextToPbm (grc: GrContextPtr; FileName, Comment: CString): CInteger; asmname 'GrSaveContextToPbm'; +function GrSaveContextToPgm (grc: GrContextPtr; FileName, Comment: CString): CInteger; asmname 'GrSaveContextToPgm'; +function GrSaveContextToPpm (grc: GrContextPtr; FileName, Comment: CString): CInteger; asmname 'GrSaveContextToPpm'; +function GrLoadContextFromPnm (grc: GrContextPtr; FileName: CString): CInteger; asmname 'GrLoadContextFromPnm'; +function GrQueryPnm (FileName: CString; var Width, Height, MaxVal: CInteger): CInteger; asmname 'GrQueryPnm'; +function GrLoadContextFromPnmBuffer (grc: GrContextPtr; protected var Buffer): CInteger; asmname 'GrLoadContextFromPnmBuffer'; +function GrQueryPnmBuffer (protected var Buffer; var Width, Height, MaxVal: CInteger): CInteger; asmname 'GrQueryPnmBuffer'; + +{ ================================================================== + ADDON FUNCTIONS + these functions may not be installed or available on all systems + ================================================================== } + +function GrPngSupport: CInteger; asmname 'GrPngSupport'; +function GrSaveContextToPng (grc: GrContextPtr; FileName: CString): CInteger; asmname 'GrSaveContextToPng'; +function GrLoadContextFromPng (grc: GrContextPtr; FileName: CString; UseAlpha: CInteger): CInteger; asmname 'GrLoadContextFromPng'; +function GrQueryPng (FileName: CString; var Width, Height: CInteger): CInteger; asmname 'GrQueryPng'; + +{ SaveContextToTiff - Dump a context in a TIFF file + + Arguments: + cxt: Context to be saved (nil -> use current context) + tiffn: Name of tiff file + compr: Compression method (see tiff.h), 0: automatic selection + docn: string saved in the tiff file (DOCUMENTNAME tag) + + Returns 0 on success + -1 on error + + requires tifflib by Sam Leffler (sam@engr.sgi.com) + available at ftp://ftp.sgi.com/graphics/tiff } +function SaveContextToTiff(Cxt: GrContextPtr; TiffN: CString; Compr: CInteger; DocN: CString): CInteger; asmname 'SaveContextToTiff'; + +{ GrSaveContextToJpeg - Dump a context in a JPEG file + + Arguments: + grc: Context to be saved (nil -> use current context) + Filename: Name of the jpeg file + accuracy: Accuracy percentage (100 for no loss of quality) + + Returns 0 on success + -1 on error + + requires jpeg-6a by IJG (Independent JPEG Group) + available at ftp.uu.net as graphics/jpeg/jpegsrc.v6a.tar.gz } +function GrSaveContextToJpeg(grc: GrContextPtr; FileName: CString; Accuracy: CInteger): CInteger; asmname 'GrSaveContextToJpeg'; +function GrSaveContextToGrayJpeg(grc: GrContextPtr; FileName: CString; Accuracy: CInteger): CInteger; asmname 'GrSaveContextToGrayJpeg'; +function GrJpegSupport: CInteger; asmname 'GrJpegSupport'; +function GrLoadContextFromJpeg(grc: GrContextPtr; FileName: CString; Scale: CInteger): CInteger; asmname 'GrLoadContextFromJpeg'; +function GrQueryJpeg(FileName: CString; var Width, Height: CInteger): CInteger; asmname 'GrQueryJpeg'; + +implementation + +end. diff --git a/thirdparty/grx249/pascal/imgview.pas b/thirdparty/grx249/pascal/imgview.pas new file mode 100644 index 0000000..81215e9 --- /dev/null +++ b/thirdparty/grx249/pascal/imgview.pas @@ -0,0 +1,139 @@ +{ PNG and JPEG viewer demo for GRX. + + Copyright (C) 2001 Frank Heckenbach + + This file is free software; as a special exception the author + gives unlimited permission to copy and/or distribute it, with or + without modifications, as long as this notice is preserved. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY, to the extent permitted by law; without + even the implied warranty of MERCHANTABILITY or FITNESS FOR A + PARTICULAR PURPOSE. } + +program ImgViewer; + +uses GPC, GRX; + +var + GraphicsActive: Boolean = False; + +procedure CloseGraph; +var Dummy: Integer; +begin + if GraphicsActive then Dummy := GrSetMode (Gr_Default_Text, 0, 0, 0, 0, 0); + GraphicsActive := False +end; + +procedure Warning (const Msg: String); +begin + WriteLn (StdErr, ParamStr (0), ': ', Msg) +end; + +procedure Error (const Msg: String); +begin + CloseGraph; + Warning (Msg); + Halt (1) +end; + +procedure OpenGraph (GWidth, GHeight: Integer); +var Width, Height: Integer; +begin + Width := (GWidth + 7) div 8 * 8; + Height := GHeight; + if GrSetMode (Gr_Width_Height_BPP_Graphics, Width, Height, 24, 0, 0) <> 1 then + Error ('could not initialize graphics'); + GraphicsActive := True +end; + +var + ImgFileName: TString; + ArgStart, ArgN, Key: Integer; + ImgWidth, ImgHeight: CInteger; + grc: GrContextPtr; + Centered: Boolean; + +begin + { Handle command-line arguments } + Centered := ParamStr (1) = '-c'; + ArgStart := 1 + Ord (Centered); + if ParamCount < ArgStart then + begin + WriteLn (StdErr, 'Usage: ', ParamStr (0), ' [-c] PNG-or-JPEG-file...'); + WriteLn (StdErr, ' -c Center images in a larger window'); + Halt (1) + end; + + { Check if library supports PNG and/or JPEG } + if GrPngSupport = 0 then + if GrJpegSupport = 0 then + Error ('your version of GRX was compiled without PNG and JPEG support, sorry.') + else + Warning ('your version of GRX was compiled without PNG support, PNGs will not be recognized') + else if GrJpegSupport = 0 then + Warning ('your version of GRX was compiled without JPEG support, JPEGs will not be recognized'); + + for ArgN := ArgStart to ParamCount do + begin + ImgFileName := ParamStr (ArgN); + if not FileExists (ImgFileName) then + Error ('file `' + ImgFileName + ''' not found'); + + { PNG files } + { Check if file is PNG and get its size } + if GrQueryPng (ImgFileName, ImgWidth, ImgHeight) = 0 then + begin + if not Centered then + begin + + { Simple example: window size = image size } + OpenGraph (ImgWidth, ImgHeight); + if GrLoadContextFromPng (nil, ImgFileName, 0) <> 0 then + Error ('could not load ' + ImgFileName) + + end + else + begin + + { More complex example: window larger than image, display image centered } + OpenGraph (2 * ImgWidth, 2 * ImgHeight); + GrClearScreen (GrWhite); + grc := GrCreateSubContext (Max (0, (GrScreenX - ImgWidth) div 2), + Max (0, (GrScreenY - ImgHeight) div 2), + GrScreenX, GrScreenY, nil, nil); + if GrLoadContextFromPng (grc, ImgFileName, 0) <> 0 then + Error ('could not load ' + ImgFileName); + GrDestroyContext (grc) + + end + end + + { Same for JPEG files (see the comments for PNG above) } + else if GrQueryJpeg (ImgFileName, ImgWidth, ImgHeight) = 0 then + begin + if not Centered then + begin + OpenGraph (ImgWidth, ImgHeight); + if GrLoadContextFromJpeg (nil, ImgFileName, 1) <> 0 then + Error ('could not load ' + ImgFileName) + end + else + begin + OpenGraph (2 * ImgWidth, 2 * ImgHeight); + GrClearScreen (GrWhite); + grc := GrCreateSubContext (Max (0, (GrScreenX - ImgWidth) div 2), + Max (0, (GrScreenY - ImgHeight) div 2), + GrScreenX, GrScreenY, nil, nil); + if GrLoadContextFromJpeg (grc, ImgFileName, 1) <> 0 then + Error ('could not load ' + ImgFileName); + GrDestroyContext (grc) + end + end + + else + Error (ImgFileName + ' does not seem to be a PNG or JPEG file'); + Key := GrKeyRead; + CloseGraph + end +end. diff --git a/thirdparty/grx249/pascal/jpgtest.pas b/thirdparty/grx249/pascal/jpgtest.pas new file mode 100644 index 0000000..09bbf8c --- /dev/null +++ b/thirdparty/grx249/pascal/jpgtest.pas @@ -0,0 +1,114 @@ +(** + ** jpgtest.pas ---- test the ctx2jpeg routines + ** + ** Copyright (c) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + **) + +{$X+} + +program jpgtest; + +uses GPC, GRX; + +var grc: GrContextPtr; + +procedure imagen( nf: String; Scale: Integer ); +var + grc : GrContextPtr; + Width, Height : Integer; + s : String[81]; + w, h : CInteger; +begin + GrQueryJpeg( nf,w,h ); + WriteStr( s,nf,' ',w,' ',h,' Scale 1/',Scale ); + Width := min(600 , w div Scale); + Height := min(400 , h div Scale); + GrClearScreen( GrAllocColor( 0,0,200 ) ); + + GrBox( 10,40,10+Width+1,40+Height+1,GrWhite ); + grc := GrCreateSubContext( 11,41,11+Width-1,41+Height-1,NIL,NIL ); + GrLoadContextFromJpeg( grc,nf,Scale ); + GrDestroyContext( grc ); + + GrTextXY( 10,10,s,GrBlack,GrWhite ); + GrTextXY( 10,50+Height,'Press any key to continue',GrBlack,GrWhite ); + GrKeyRead +end; + +procedure nojpegsupport; +const + s: array[0..5] of String[50] = ( + 'Warning!', + 'You need libjpeg (http://www.ijg.org) and enable', + 'jpeg support in the GRX lib (edit makedefs.grx)', + 'to run this demo', + ' ', + 'Press any key to continue...' ); +var + i: Integer; +begin + GrClearScreen( GrAllocColor( 0,0,100 ) ); + for i:=0 to 5 do + GrTextXY( 90,160+i*18,s[i],GrWhite,GrNoColor); + GrKeyRead +end; + +begin + GrSetMode( Gr_Width_Height_BPP_Graphics,640,480,24,0,0 ); + + if GrJpegSupport = 0 then begin + nojpegsupport; + GrSetMode(Gr_Default_Text,0,0,0,0,0); + halt( 1 ); + end; + + imagen( '../test/jpeg1.jpg',1 ); + imagen( '../test/jpeg1.jpg',2 ); + imagen( '../test/jpeg1.jpg',4 ); + imagen( '../test/jpeg1.jpg',8 ); + imagen( '../test/jpeg2.jpg',1 ); + imagen( '../test/jpeg2.jpg',2 ); + imagen( '../test/jpeg2.jpg',4 ); + imagen( '../test/jpeg2.jpg',8 ); + + GrClearScreen( GrAllocColor( 0,100,0 ) ); + grc := GrCreateSubContext( 10,40,10+400-1,40+300-1,NIL,NIL ); + GrLoadContextFromJpeg( grc,'../test/jpeg1.jpg',2 ); + GrDestroyContext( grc ); + grc := GrCreateSubContext( 210,150,210+400-1,150+300-1,NIL,NIL ); + GrLoadContextFromJpeg( grc,'../test/jpeg2.jpg',2 ); + GrDestroyContext( grc ); + + GrTextXY( 10,10,'Press any key to save color and gray screen',GrBlack,GrWhite ); + GrKeyRead; + + GrSaveContextToJpeg( NIL,'p.jpg',75 ); + GrSaveContextToGrayJpeg( NIL,'pgray.jpg',75 ); + + GrClearScreen( GrBlack ); + GrTextXY( 10,10,'Press any key to reload color screen ',GrBlack,GrWhite ); + GrKeyRead; + GrLoadContextFromJpeg( NIL,'p.jpg',1 ); + + GrTextXY( 10,10,'Press any key to reload gray screen ',GrBlack,GrWhite ); + GrKeyRead; + GrClearScreen(GrBlack); + GrLoadContextFromJpeg( NIL,'pgray.jpg',1 ); + + GrTextXY( 10,10,'Press any key to end ',GrBlack,GrWhite ); + GrKeyRead; + + GrSetMode(Gr_Default_Text,0,0,0,0,0) +end. diff --git a/thirdparty/grx249/pascal/keytest.pas b/thirdparty/grx249/pascal/keytest.pas new file mode 100644 index 0000000..da9e9db --- /dev/null +++ b/thirdparty/grx249/pascal/keytest.pas @@ -0,0 +1,46 @@ +program KeyTest; + +uses GRX; + +var + MouseMode, DrawMode, + m, x, y, co : Integer; + evt: GrMouseEvent; + Key : Char; + Finito : boolean; + +procedure MouseRoutine; + var st: String[80]; +begin + if (evt.Flags and Gr_M_KeyPress) > 0 then begin + Key := Chr (evt.Key and $FF); + writestr(st,'Key :', Key:2, Ord(Key):4, evt.Key mod 256: 4, evt.Key div 256: 4, evt.Key: 6); + GrTextXY(evt.x,evt.y,st,GrWhite,GrBlack); + case evt.Key of + 81, 113 : Finito := true; {'Q', 'q'} + end; + end; +end; + +begin + x := 640; + y := 480; + co := 256; + m := GrSetMode(Gr_Default_Graphics,x,y,co,0,0); + + if GrMouseDetect then begin + GrMouseEventMode(1); + GrMouseInit; + GrMouseDisplayCursor; + DrawMode := 0; + MouseMode := 4; + end else + exit; + + GrTextXY(0,0,'Use ''Q'' to Quit',GrWhite,GrBlack); + repeat + Finito := false; + GrMouseGetEventT(Gr_M_Event,@evt,0); + if evt.Flags > 0 then MouseRoutine; + until Finito +end. diff --git a/thirdparty/grx249/pascal/makefile b/thirdparty/grx249/pascal/makefile new file mode 100644 index 0000000..eef5674 --- /dev/null +++ b/thirdparty/grx249/pascal/makefile @@ -0,0 +1,50 @@ +# -------------------------------- +# Check, if the paths are correct +# -------------------------------- + +# Set the library-path to libgrx +GRXLIB = -L/usr/X11R6/lib + +# Set the library-path to libjpeg and libtiff +GRAPHICSLIB = -L/usr/lib + +# Compiler and options on your system +COMPILER = $(PC) --automake -Wall + +# -------------------------------------------- +# I Think, you don't need to change from here +# -------------------------------------------- + +all: blt_test modetest keytest txt_test vir_test polytest jpgtest colortst imgview + +blt_test:blt_test.pas + $(COMPILER) $(GRXLIB) $(GRAPHICSLIB) blt_test.pas -oblt_test + +modetest:modetest.pas + $(COMPILER) $(GRXLIB) $(GRAPHICSLIB) modetest.pas -omodetest + +keytest: keytest.pas + $(COMPILER) $(GRXLIB) $(GRAPHICSLIB) keytest.pas -okeytest + +txt_test:txt_test.pas + $(COMPILER) $(GRXLIB) $(GRAPHICSLIB) txt_test.pas -otxt_test + +vir_test:vir_test.pas + $(COMPILER) $(GRXLIB) $(GRAPHICSLIB) vir_test.pas -ovir_test + +polytest:polytest.pas + $(COMPILER) $(GRXLIB) $(GRAPHICSLIB) polytest.pas -opolytest + +jpgtest:jpgtest.pas + $(COMPILER) $(GRXLIB) $(GRAPHICSLIB) jpgtest.pas -ojpgtest + +colortst:colortst.pas + $(COMPILER) $(GRXLIB) $(GRAPHICSLIB) colortst.pas -ocolortst + +imgview:imgview.pas + $(COMPILER) $(GRXLIB) $(GRAPHICSLIB) imgview.pas -oimgview + +clean: + rm -f *.o *.gpi blt_test modetest keytest txt_test vir_test polytest jpgtest colortst imgview + + diff --git a/thirdparty/grx249/pascal/makefile.dj2 b/thirdparty/grx249/pascal/makefile.dj2 new file mode 100644 index 0000000..cd25ec1 --- /dev/null +++ b/thirdparty/grx249/pascal/makefile.dj2 @@ -0,0 +1,53 @@ +# +# GRX test programs makefile for DJGPP v2. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean + +GRXVDJ2=y + +include ../makedefs.grx + +# The following line is useful only in this makefile to force recompilation +GRXLIB = ../lib/$(GRX_LIB_SUBDIR)/libgrx20.a +# In normal use the library libgrx20.a is linked in through +# {$L grx20} contained in the unit grx.pas called by "uses grx". +# The same is valid for other ADDON libraries. +# If the library is NOT installed give its path +# (default when first compiling/testing the library) +GRXLIBPATH = -L../lib/$(GRX_LIB_SUBDIR) +# When it is installed in a standard system location +# (normal use) this is no more necessary + +LIBS= $(GRXLIBPATH) + +# Compiler and options on your system +COMPILER = $(PC) --automake + + +PROGS= \ + blt_test.exe \ + modetest.exe \ + keytest.exe \ + txt_test.exe \ + vir_test.exe \ + polytest.exe \ + jpgtest.exe \ + colortst.exe \ + imgview.exe + +all: $(PROGS) + +$(PROGS): %.exe : %.pas $(GRXLIB) grx.pas + $(COMPILER) $(CCOPT) -o $*.exe $*.pas $(LDOPT) $(LIBS) + +clean: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f *.o *.exe *.gpi *.gpm +else + if exist *.o del *.o + if exist *.exe del *.exe + if exist *.gpi del *.gpi + if exist *.gpm del *.gpm +endif diff --git a/thirdparty/grx249/pascal/makefile.lnx b/thirdparty/grx249/pascal/makefile.lnx new file mode 100644 index 0000000..2189629 --- /dev/null +++ b/thirdparty/grx249/pascal/makefile.lnx @@ -0,0 +1,54 @@ +# +# GRX test programs makefile for LINUX/console. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean + +GRXVLNX=y + +include ../makedefs.grx + +# The following line is useful only in this makefile to force recompilation +GRXLIB = ../lib/$(GRX_LIB_SUBDIR)/libgrx20.a +# In normal use the library libgrx20.a or libgrx20.so is linked in through +# {$L grx20} contained in the unit grx.pas called by "uses grx". +# The same is valid for other ADDON libraries. +# If the library is NOT installed give its path +# (default when first compiling/testing the library) +GRXLIBPATH = -L../lib/$(GRX_LIB_SUBDIR) +# When it is installed in a standard system location +# (normal use) this is no more necessary + +ifeq ($(SET_SUIDROOT),y) +EXECBITS = 4755 +else +EXECBITS = 0755 +endif + +LIBS= $(GRXLIBPATH) + +# Compiler and options on your system +COMPILER = $(PC) --automake + + +PROGS= \ + blt_test \ + modetest \ + keytest \ + txt_test \ + vir_test \ + polytest \ + jpgtest \ + colortst \ + imgview + +all: $(PROGS) + +$(PROGS): % : %.pas $(GRXLIB) grx.pas + $(COMPILER) $(CCOPT) -o $* $*.pas $(LIBS) + chmod $(EXECBITS) $@ + +clean: + rm -f *.o *.gpi *.gpm $(PROGS) + diff --git a/thirdparty/grx249/pascal/makefile.sdl b/thirdparty/grx249/pascal/makefile.sdl new file mode 100644 index 0000000..b434380 --- /dev/null +++ b/thirdparty/grx249/pascal/makefile.sdl @@ -0,0 +1,50 @@ +# +# GRX test programs makefile for SDL. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean + +GRXVSDL=y + +include ../makedefs.grx + +# The following line is useful only in this makefile to force recompilation +GRXLIB = ../lib/$(GRX_LIB_SUBDIR)/libgrx20S.a +# In normal use the library libgrx20S.a is linked in through +# {$L grx20S} contained in the unit grx.pas called by "uses grx". +# The same is valid for other ADDON libraries. +# If the library is NOT installed give its path +# (default when first compiling/testing the library) +GRXLIBPATH = -L../lib/$(GRX_LIB_SUBDIR) +# When it is installed in a standard system location +# (normal use) this is no more necessary + +ifneq ($(EP),x) + EX = .exe +endif + +LIBS = $(GRXLIBPATH) + +# Compiler and options on your system +COMPILER = $(PC) --autobuild + + +PROGS= \ + $(EP)blt_test$(EX) \ + $(EP)modetest$(EX) \ + $(EP)keytest$(EX) \ + $(EP)txt_test$(EX) \ + $(EP)vir_test$(EX) \ + $(EP)polytest$(EX) \ + $(EP)jpgtest$(EX) \ + $(EP)colortst$(EX) \ + $(EP)imgview$(EX) + +all: $(PROGS) + +$(PROGS): $(EP)%$(EX) : %.pas $(GRXLIB) grx.pas + $(COMPILER) $(CCOPT) -o $@ $*.pas $(LDOPT) $(LIBS) + +clean: + rm -f *.o *.gpi *.gpm $(PROGS) diff --git a/thirdparty/grx249/pascal/makefile.w32 b/thirdparty/grx249/pascal/makefile.w32 new file mode 100644 index 0000000..dd1f775 --- /dev/null +++ b/thirdparty/grx249/pascal/makefile.w32 @@ -0,0 +1,58 @@ +# +# GRX test programs makefile for mingw32. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean + +GRXVW32=y + +include ../makedefs.grx + +# The following line is useful only in this makefile to force recompilation +GRXLIB = ../lib/$(GRX_LIB_SUBDIR)/libgrx20.a +# In normal use the library libgrx20.a is linked in through +# {$L grx20} contained in the unit grx.pas called by "uses grx". +# The same is valid for other ADDON libraries. +# If the library is NOT installed give its path +# (default when first compiling/testing the library) +GRXLIBPATH = -L../lib/$(GRX_LIB_SUBDIR) +# When it is installed in a standard system location +# (normal use) this is no more necessary + +LIBS= $(GRXLIBPATH) -mwindows + +# Compiler and options on your system +COMPILER = $(PC) --autobuild + + +PROGS= \ + blt_test.exe \ + keytest.exe \ + txt_test.exe \ + vir_test.exe \ + jpgtest.exe \ + colortst.exe \ + imgview.exe + +PROGS_C= \ + polytest.exe \ + modetest.exe + +all: $(PROGS) $(PROGS_C) + +$(PROGS): %.exe : %.pas $(GRXLIB) grx.pas + $(COMPILER) $(CCOPT) -o $*.exe $*.pas $(LIBS) + +$(PROGS_C): %.exe : %.pas $(GRXLIB) grx.pas + $(COMPILER) $(CCOPT) -o $*.exe $*.pas $(LIBS) -mconsole + +clean: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f *.o *.exe *.gpi *.gpm +else + if exist *.o del *.o + if exist *.exe del *.exe + if exist *.gpi del *.gpi + if exist *.gpm del *.gpm +endif diff --git a/thirdparty/grx249/pascal/makefile.x11 b/thirdparty/grx249/pascal/makefile.x11 new file mode 100644 index 0000000..93eff90 --- /dev/null +++ b/thirdparty/grx249/pascal/makefile.x11 @@ -0,0 +1,61 @@ +# +# GRX test programs makefile for LINUX/X11. Uses GNU make. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean + +GRXVX11=y + +include ../makedefs.grx + +# The following line is useful only in this makefile to force recompilation +GRXLIB = ../lib/$(GRX_LIB_SUBDIR)/libgrx20X.a +# In normal use the library libgrx20X.a or libgrx20X.so is linked in through +# {$L grx20X} contained in the unit grx.pas called by "uses grx". +# The same is valid for other ADDON libraries. +# If the library is NOT installed give its path +# (default when first compiling/testing the library) +GRXLIBPATH = -L../lib/$(GRX_LIB_SUBDIR) +# When it is installed in a standard system location +# (normal use) this is no more necessary + +ifeq ($(SET_XSUIDROOT),y) +EXECBITS = 4755 +else +EXECBITS = 0755 +endif + +ADDON_LIBS= + +ifeq ($(USE_XF86DGA_DRIVER),y) + ADDON_LIBS += -lXxf86dga -lXext #NOT included in grx.pas +endif + +LIBS= $(GRXLIBPATH) $(ADDON_LIBS) + +# Compiler and options on your system +COMPILER = $(PC) --automake + + +PROGS= \ + xblt_test \ + xmodetest \ + xkeytest \ + xtxt_test \ + xvir_test \ + xpolytest \ + xjpgtest \ + xcolortst \ + ximgview + +all: $(PROGS) + +$(PROGS): x% : %.pas $(GRXLIB) grx.pas + $(COMPILER) $(CCOPT) -o $@ $*.pas $(LIBS) + chmod $(EXECBITS) $@ + +clean: + rm -f *.o *.gpi *.gpm $(PROGS) + + diff --git a/thirdparty/grx249/pascal/modetest.pas b/thirdparty/grx249/pascal/modetest.pas new file mode 100644 index 0000000..5337a5e --- /dev/null +++ b/thirdparty/grx249/pascal/modetest.pas @@ -0,0 +1,32 @@ +{$X+} + +program Vir_Test; + +uses GRX; + +var + i, f, m : Integer; + gvm : GrVideoMode; + fivm : GrVideoModePtr; + +begin + { intializes grx20 } + m := GrSetMode(Gr_Default_Text, 0, 0, 0, 0, 0); + + GrSetModeRestore(False); + + for f := Gr_Unknown_Mode to Gr_FrameSVGA32H do begin + fivm := GrFirstVideoMode(f); + while fivm <> Nil do begin + gvm := fivm^; + i := i + 1; + Write (i:3); + Write (f:3); + Write (gvm.Mode:6); + Write (gvm.Width:5, 'x',gvm.Height:4, 'x', gvm.BPP:3); + WriteLn; + fivm := GrNextVideoMode(fivm) + end + end; + Readln +end. diff --git a/thirdparty/grx249/pascal/polytest.pas b/thirdparty/grx249/pascal/polytest.pas new file mode 100644 index 0000000..fba7c38 --- /dev/null +++ b/thirdparty/grx249/pascal/polytest.pas @@ -0,0 +1,148 @@ +(** + ** polytest.pas ---- test polygon rendering + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **) + +{$R-} + +program polytest; + +uses GPC, GRX, Test; + +type WrkString = String[80]; + +var f : Text; + Line,msg : WrkString; + nb : Integer; + convex,collect : boolean; + k : GrKeyType; + polygon : array [0..300] of PointType; + pEGA : GrColorsPtr; + black,white,red : GrColor; + +procedure TestPoly(n:Integer; var Points: array of PointType; convex:boolean); +begin + GrClearScreen(black); + GrPolygon(n,Points,white); + GrFilledPolygon(n,Points,(red or GrXor)); + k:=GrKeyRead; + if convex or (n <= 3) then begin + GrClearScreen(black); + GrFilledPolygon(n,Points,white); + GrFilledConvexPolygon(n,Points,(red or GrXor)); + k:=GrKeyRead + end +end; + +procedure SpeedTest; +var + pts : array[0..3,0..1] of CInteger; + ww : Integer = GrSizeX div 10; + hh : Integer = GrSizeY div 10; + sx : Integer = (GrSizeX - 2*ww) div 32; + sy : Integer = (GrSizeY - 2*hh) div 32; + ii,jj : Integer; + color : GrColor; + t1,t2,t3,mu1,mu2,mu3: CInteger; +begin + GrClearScreen(black); + t1 := GetCPUTime(mu1); + pts[0][1] := 0; + pts[1][1] := hh; + pts[2][1] := 2*hh; + pts[3][1] := hh; + color := 0; + for ii := 0 to 31 do begin + pts[0][0] := ww; + pts[1][0] := 2*ww; + pts[2][0] := ww; + pts[3][0] := 0; + for jj := 0 to 31 do begin + GrFilledPolygon(4,pts, pEGA^[color] or GrXor); + color := (color + 1) and 15; + Inc(pts[0][0],sx); + Inc(pts[1][0],sx); + Inc(pts[2][0],sx); + Inc(pts[3][0],sx); + end; + Inc(pts[0][1],sy); + Inc(pts[1][1],sy); + Inc(pts[2][1],sy); + Inc(pts[3][1],sy); + end; + t2 := GetCPUTime(mu2); + pts[0][1] := 0; + pts[1][1] := hh; + pts[2][1] := 2*hh; + pts[3][1] := hh; + color := 0; + for ii := 0 to 31 do begin + pts[0][0] := ww; + pts[1][0] := 2*ww; + pts[2][0] := ww; + pts[3][0] := 0; + for jj := 0 to 31 do begin + GrFilledConvexPolygon(4,pts, pEGA^[color] or GrXor); + color := (color + 1) and 15; + Inc(pts[0][0],sx); + Inc(pts[1][0],sx); + Inc(pts[2][0],sx); + Inc(pts[3][0],sx); + end; + Inc(pts[0][1],sy); + Inc(pts[1][1],sy); + Inc(pts[2][1],sy); + Inc(pts[3][1],sy); + end; + t3 := GetCPUTime(mu3); + GrTextXY(0, 0, 'Times to scan 1024 polygons', white, black); + WriteStr(msg, ' with GrFilledPolygon: ',((t2+mu2/1e6)-(t1+mu1/1e6)):0:2,' (s)'); + GrTextXY(0, 18, msg, white, black); + WriteStr(msg, ' with GrFilledConvexPolygon: ',((t3+mu3/1e6)-(t2+mu2/1e6)):0:2,' (s)'); + GrTextXY(0, 36, msg, white, black); +end; + +begin + InitTest; + pEGA:=GrAllocEgaColors; + black:=pEGA^[0]; red:=pEGA^[12]; white:=pEGA^[15]; + + Assign(f,'../test/polytest.dat'); Reset(f); + collect:=false; + while not eof(f) do begin + ReadLn(f,Line); + if not collect then begin + if Copy(Line,1,5)='begin' then begin + collect:=true; + convex := Line[6]='c'; + nb:=0; + end + end else begin + if Copy(Line,1,3)='end' then begin + if nb>0 then TestPoly(nb,polygon,convex); + collect:=false; + end else begin + with polygon[nb] do ReadStr(Line,x, y); + Inc(nb); + end; + end; + end; + Close(f); + SpeedTest; + k:=GrKeyRead; + EndTest +end. diff --git a/thirdparty/grx249/pascal/readme b/thirdparty/grx249/pascal/readme new file mode 100644 index 0000000..27e95da --- /dev/null +++ b/thirdparty/grx249/pascal/readme @@ -0,0 +1,51 @@ + +Welcome to the wonderful world of GRX for pascal-users. +======================================================= + +If you are interested in GNU-Pascal (gpc), visit +http://gnu-pascal.de/gpc/h-index.html +There is a mailinglist available. + +This directory contains several test-programs for GRX +and GNU-Pascal. + +* blt_test.pas draws some circles +* modetest.pas prints out the available modes +* keytest.pas prints out the character-codes. Use "Q" to quit. +* txt_test.pas prints out some text. Press Return to exit. +* vir_test.pas lets you draw something. + Press "1", to place some sqares with the mouse. + Press "2" to draw some lines + Press "3" to copy some drawings from one place to another + ("<" and ">" change the size of your "copy-area") + Press "4" to draw whatever you like :-) + Press "0" to leave drawing-mode + "Q" leaves vir_test. +* polytest.pas draws some polygons +* jpgtest.pas loads/saves jpeg images +* imgview.pas loads png and jpeg images +* colortst.pas tests allocating many colors + +To build up the programs, either + +- use the generic makefile and edit the paths, then type + make + +- For djgpp, mingw32, LINUX/svga and LINUX/X11, sdl, they should +have been built with the library and C tests from top level makefile, +if you used them. +If you want to rebuild only the tests type from this dir + make -f +Pathes and parameters will be borrowed from corresponding top level +makedefs files + +Have fun! + + + + + + + + + diff --git a/thirdparty/grx249/pascal/test.pas b/thirdparty/grx249/pascal/test.pas new file mode 100644 index 0000000..47e8e2b --- /dev/null +++ b/thirdparty/grx249/pascal/test.pas @@ -0,0 +1,55 @@ +unit Test; + +interface + +uses GRX; + +var exit_message: String [1000]; + +procedure InitTest; +procedure EndTest; + +implementation + +procedure InitTest; + var m,n,i: Integer; + w,h,c,xv,yv: Integer = 0; +begin + if ParamCount < 2 then + m := GrSetMode(Gr_Default_Graphics,0,0,0,0,0) + else begin + for n:=1 to ParamCount do begin + ReadStr(ParamStr(n),i); + if n = 3 then + case ParamStr(n)[Length(ParamStr(n))] of + 'k','K': i := i shl 10; + 'm','M': i := i shl 20; + end; + case n of + 1: w := i; + 2: h := i; + 3: c := i; + 4: xv := i; + 5: yv := i; + end + end; + if ParamCount = 5 then + m := GrSetMode(Gr_Custom_Graphics,w,h,c,xv,yv) + else if ParamCount = 2 then + m := GrSetMode(Gr_Width_Height_Graphics,w,h,0,0,0) + else + m := GrSetMode(Gr_Width_Height_Color_Graphics,w,h,c,0,0) + end +end; + +procedure EndTest; + var m:Integer; +begin + m:=GrSetMode(Gr_Default_Text,0,0,0,0,0); + if exit_message <> '' then begin + WriteLn(exit_message); + Readln + end +end; + +end. diff --git a/thirdparty/grx249/pascal/txt_test.pas b/thirdparty/grx249/pascal/txt_test.pas new file mode 100644 index 0000000..b219ba2 --- /dev/null +++ b/thirdparty/grx249/pascal/txt_test.pas @@ -0,0 +1,83 @@ +{$X+} + +program Text_Test; + +uses GRX; + +procedure TestFunc; +var + x, y, ww, wh, ii, jj, c : Integer; + +begin + x := GrSizeX; + y := GrSizeY; + ww := round((x-10)/32); + wh := round((y-10)/8); + + GrSetRGBcolorMode; + for ii := 0 to 7 do + for jj := 0 to 31 do begin + c := ii*32+jj; + {gives the same color independently of BPP: not all drivers have good BPP=8} + c := GrAllocColor(c and 2#11100000,(c and 2#11100) shl 3, (c and 2#11) shl 6); + GrFilledBox(5+jj*ww,5+ii*wh,5+jj*ww+ww-1,5+ii*wh+wh-1,c); + end; +end; { TestFunc } + +var + x, y, xv, yv, c, + m : Integer; + St : String(255); + o : GrTextOption; + +begin + x := 640; + y := 480; + xv := 640; + yv := 480; + c := 65536; + + m := GrSetMode(Gr_Width_Height_Color_Graphics,x,y,c,xv,yv); + { M := GrSetMode(Gr_Custom_Graphics,x,y,c,xv,yv); } + + TestFunc; + GrCircle(400,400,200,GrWhite); + GrCircle(400,400,205,GrWhite); + GrLineNC(0, 0, GrScreenX-1, GrScreenY-1, GrWhite); + GrLineNC(0, GrScreenY-1, GrScreenX-1, 0, GrWhite); + + { o.txo_font := @GrFont_PC8x16; } + o.txo_Font := GrLoadFont('pc8x16.fnt'); + o.txo_FgColor.v := GrBlack; + o.txo_BgColor.v := GrWhite; + o.txo_ChrType := Gr_Byte_Text; + o.txo_Direct := Gr_Text_Default; + o.txo_XAlign := Gr_Align_Default; + o.txo_YAlign := Gr_Align_Default; + + GrDrawString('This is simple text', 16, 20, 20, o); + St := 'This text is more complex'; + o.txo_Font := @GrFont_PC8x8; + GrDrawString(St, Length(St), 20, 50, o); + GrTextXY(20, 80, 'This is another text', GrBlack, GrWhite); + + o.txo_Font := GrLoadFont('helv22.fnt'); + GrDrawString(St, Length(St), 20, 100, o); + + { GrLoadConvertedFont(var name: Char; cvt, w, h, minch, maxch: Integer): GrFontPt;} + o.txo_Font := GrLoadConvertedFont('helv22.fnt', + { Gr_FontCvt_None = 0; + Gr_FontCvt_Skipchars = 1; + Gr_FontCvt_Resize = 2; + Gr_FontCvt_Italicize = 4; + Gr_FontCvt_Boldify = 8; + Gr_FontCvt_Fixify = 16; + Gr_FontCvt_Proportion = 32; } + Gr_FontCvt_Resize or + Gr_FontCvt_Italicize, + 20, 30, + 32, 127); + GrDrawString(St, Length(St), 20, 130, o); + + GrKeyRead; +end. diff --git a/thirdparty/grx249/pascal/vir_test.pas b/thirdparty/grx249/pascal/vir_test.pas new file mode 100644 index 0000000..9360834 --- /dev/null +++ b/thirdparty/grx249/pascal/vir_test.pas @@ -0,0 +1,190 @@ +program Vir_Test; + +uses GRX; + +procedure TestFunc; +var + x, y, ww, wh, ii, jj, c : Integer; + +begin + x := GrSizeX; + y := GrSizeY; + ww := round((x-10)/32); + wh := round((y-10)/8); + + GrSetRGBcolorMode; + for ii := 0 to 7 do + for jj := 0 to 31 do begin + c := ii*32+jj; + {gives the same color independently of BPP: not all drivers have good BPP=8} + c := GrAllocColor(c and 2#11100000,(c and 2#11100) shl 3, (c and 2#11) shl 6); + GrFilledBox(5+jj*ww,5+ii*wh,5+jj*ww+ww-1,5+ii*wh+wh-1,c); + end; +end; { TestFunc } + +var + x1, y1, + MouseMode, DrawMode, + xc, yc, + x, y, xv, yv, c : Integer; + m : Integer; + evt: GrMouseEvent; + Key : Char; + Finito : Boolean; + Conti: GrContext; + ContiPtr : GrContextPtr; + +begin + x := 640; + y := 480; + xv := 1024; + yv := 1024; + c := 65536; + xc := 40; + yc := 30; + + m := GrSetMode(Gr_Custom_Graphics,x,y,c,xv,yv); + GrSetModeRestore(False); + + xv := GrVirtualX; + yv := GrVirtualY; + + TestFunc; + GrTextXY(10, 10, ' Use the Keys <1> <2> <3> <4> <0> and press the mousebutton ', GrBlack, GrWhite); + GrTextXY(10, 30, ' In "mode 3" use "<" and ">" to resize the area "Q" = Quit ', GrBlack, GrWhite); + + if GrMouseDetect then begin + GrMouseEventMode(1); + GrMouseInit; + GrMouseSetColors(GrAllocColor(200,50,150),GrBlack); + { GrMouseSetLimits(10, 10, xv-10, yv-10); } + GrMouseDisplayCursor; + Finito := False; + repeat + GrMouseGetEvent(Gr_M_Event,@evt); + if (evt.Flags and Gr_M_KeyPress) > 0 then begin + Key := Chr (evt.Key and $FF); + case Key of + 'Q', 'q': Finito := True; + 'W', 'w': GrMouseWarp(2, 2); + 'U', 'u': GrMouseUpdateCursor; + '>': if (xc < x) and (MouseMode = 3) and ((evt.Flags and Gr_M_Left_Down) = 0) then begin + xc := xc + 8; + yc := yc + 6; + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Box, -xc div 2, -yc div 2, xc div 2, yc div 2,GrWhite); + GrMouseDisplayCursor; + end; + '<': if (xc > 8) and (MouseMode = 3) and ((evt.Flags and Gr_M_Left_Down) = 0) then begin + xc := xc - 8; + yc := yc - 6; + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Box, -xc div 2, -yc div 2, xc div 2, yc div 2,GrWhite); + GrMouseDisplayCursor; + end; + '1': begin + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Normal,0,0,0,0,0); + GrMouseDisplayCursor; + MouseMode := 1; + end; + '2': begin + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Normal,0,0,0,0,0); + GrMouseDisplayCursor; + MouseMode := 2; + end; + '3': begin + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Box, -xc div 2, -yc div 2, xc div 2, yc div 2,GrWhite); + GrMouseDisplayCursor; + MouseMode := 3; + end; + '0': begin + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Normal,0,0,0,0,0); + GrMouseDisplayCursor; + MouseMode := 0; + end; + '4': begin + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Normal,0,0,0,0,0); + GrMouseDisplayCursor; + MouseMode := 4; + end; + '5': begin + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Cross,0,0,GrWhite,0,0); + GrMouseDisplayCursor; + MouseMode := 4; + end; + end; + end; + if (evt.Flags and Gr_M_Left_Down) > 0 then begin + case MouseMode of + 1: begin + x1 := evt.x; + y1 := evt.y; + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Rubber,evt.x,evt.y,GrWhite,0,0); + GrMouseDisplayCursor; + end; + 2: begin + x1 := evt.x; + y1 := evt.y; + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Line,evt.x,evt.y,GrWhite,0,0); + GrMouseDisplayCursor; + end; + 3: begin + x1 := evt.x; + y1 := evt.y; { Why I have to save the position ??? } + ContiPtr := GrCreateContext(xc + 1, yc + 1, Nil, @Conti); + GrMouseEraseCursor; + GrBitBlt(@Conti, 0, 0, GrScreenContext, x1 - (xc div 2), y1 - (yc div 2), x1 + (xc div 2), y1 + (yc div 2), GrWrite); + GrMouseDisplayCursor; + end; + 4: begin + x1 := evt.x; + y1 := evt.y; + DrawMode := 4; + end; + end; + end; + if (evt.Flags and Gr_M_Left_Up) > 0 then begin + case MouseMode of + 1: begin + GrBox(x1, y1, evt.x, evt.y, GrAllocColor(50,100,150)); + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Normal,0,0,0,0,0); + GrMouseDisplayCursor; + end; + 2: begin + GrLine(x1, y1, evt.x, evt.y, GrAllocColor(150,100,50)); + GrMouseEraseCursor; + GrMouseSetCursorMode(Gr_M_Cur_Normal,0,0,0,0,0); + GrMouseDisplayCursor; + end; + 3: begin + GrMouseEraseCursor; + GrBitBlt(GrScreenContext, evt.x - (xc div 2), evt.y - (yc div 2), @Conti, 0, 0, xc, yc, GrWrite); + GrDestroyContext(@Conti); + GrMouseDisplayCursor; + end; + 4: DrawMode := 0; + end; + end; + if DrawMode = 4 then begin + GrLine(x1, y1, evt.x, evt.y, GrWhite); + x1 := evt.x; + y1 := evt.y; + end; + if (evt.Flags and Gr_M_Right_Down) > 0 then begin + end; + { Move the visible Part of the virtual screen } + m := GrSetViewport(evt.x - x div 2, evt.y - y div 2); + until Finito; + GrMouseUnInit; + end; +end. + diff --git a/thirdparty/grx249/readme b/thirdparty/grx249/readme new file mode 100644 index 0000000..a66254f --- /dev/null +++ b/thirdparty/grx249/readme @@ -0,0 +1,351 @@ +Welcome to GRX 2.4.9! + +GRX is a 2D graphics C library originaly written by Csaba Biegl for +DJ Delorie's DOS port of the GCC compiler. Now it support a big range +of platforms. + + +Supported platforms +=================== + +Directly supported platforms: +----------------------------- + + Currently GRX directly supports the following four platforms: + + DOS / DJGPP v>=2.03 EGA, VGA and VESA drivers + Linux / console svgalib and framebuffer drivers + Linux / X11R6 xwin driver (windowed) and SDL (full screen) + Win32 / Mingw win32 driver (windowed) and SDL (full screen) + + The Linux console framebuffer driver is new from GRX 2.4.2. + The SDL driver, compiled separately, is new from GRX 2.4.7. + Both i386 and x86_64 architectures are supported for the linux + console and the linux X11 versions. See below. + +Other DOS platforms: +-------------------- + + Makefiles for Borland C++ have been updated in GRX 2.4.6 + + Until 2.3 the Watcom C++ compiler was supported, probably it still work, + but the makefiles must be updated: + +Other X11 platforms: +-------------------- + + GRX should work on any X11R5 (or later) system after a few changes + in "makedefs.grx" + + New in GRX 2.4.6 is a DGA (Direct Graphics Access) driver for Xfree86, + experimental, not compiled by default, it must be enabled editing + the "makedefs.grx" file. + + New in GRX 2.4.7 is a SDL driver. Compiled separately after editing + the "makedefs.grx" file, SDL section, EP=x . + +Other Win32 platforms: +---------------------- + + GRX is reported to compile with MSVC, and there is support in the source + files, so you only need to generate the project files. + + New in GRX 2.4.7 is a SDL driver. Compiled separately after editing + the "makedefs.grx" file, SDL section, EP= . + + Other Win32 compilers may probably work. + +Other platforms: +---------------- + + Some people has ported GRX to embeded devices. For this you need a good + understanding of GRX internals. + + +GRX installation instructions +============================= + +Requirements: +------------- + + The source files and fonts: grx249.tar.gz or grx249.zip + This document: readme + +A. Unpacking the GRX archive +---------------------------- + + 1) Choose and download the .tar.gz or .zip package. You can use either. + The .zip is intended for dos and win32 users, specialy for DJGPP users, + because it expand to the contrib subdir and has manifest files. + + 2) 'cd' to a directory where you want the GRX file tree to be created + as a subdirectory. Examples are: + + DJGPP : C:\DJGPP\ + Mingw : C:\MINGW\ + Linux : /usr/local/src/ + + 3) unpack the GRX archive: + + tar xzvf grx249.tar.gz (1) + or + unzip grx249.zip (2) + + (1) This will create the subdirectory 'grx249'. + (2) This will create the subdirectory 'contrib/grx249'. + +B. Compiling GRX +---------------- + + 1) Go to GRX base dir and edit "makedefs.grx" to customize it for + your system. + + 2) Switch to "src" sub dir + + 3) run 'make -f ': + + makefile.dj2 for DOS/DJGPPv2 + makefile.w32 for Win32/Mingw + makefile.lnx for Linux/console + makefile.x11 for Linux/X11 + makefile.sdl for SDL driver on MingW and X11 + + This process generates the GRX lib in the "lib/---" (where --- is + dj2, w32, lnx, x11) subdir and some utility programs in the + "bin" subdir. + + Note for DJGPP/Mingw users: If you set in makedefs.grx HAVE_UNIX_TOOLS=n + do _not_ use an environment variable `SHELL' leading to `bash', e.g. + `SHELL=/djgpp/bin/bash.exe'. For mingw use mingw32-make instead of make. + Some parts of the DJGPP/Mingw Makefiles with this option require + `command.com'. If you set HAVE_UNIX_TOOLS=y (i.e. work under bash + for djgpp or msys for mingw32), there are no problems. + + Note for Linux/console users: At the end you must become root and + run 'make -f makefile.lnx setsuid' in order to set de suid flag of + the modetest utility program. (This is required by the SVGALIB + video driver). + +C. Testing GRX +-------------- + + 1) Switch to "test" sub dir + + 2) run 'make -f ' + + 3) run the 'demogrx' program + + 4) Switch to "test/bgi" sub dir + + 5) run 'make -f ' + + 6) run the 'bccbgi' program + + Note for Linux/console users: you must compile test programs as root. + (This is required by the SVGALIB video driver). + +D. Installing GRX lib for your compiler +--------------------------------------- + + You'll either need to 1: copy some GRX files to places where your compiler + will find them or 2: change your compiler setup so it will find the GRX + files in there default place. + + 1) Copy the library from /lib/ to the compiler + library directory. + Copy the header files from /include to your compiler include + directory. + + Or you can let makefiles do it for you, switch to "src" sub dir and + run 'make -f install'. You can uninstall the library + running 'make -f uninstall'. + + Note for Linux users: probably you must be root to do that. Don't forget + to run 'ldconfig' to register the shared libraries. + + 2) See compiler documentation. Either change the default compiler behaviour + (eg., change djgpp.env) or use command line switches to tell the + compiler where to find the GRX files. + +E. Installing GRX utility programs +---------------------------------- + + Run 'make -f install-bin' + + You can uninstall them running 'make -f uninstall-bin' + + Note for Linux users: probably you must be root to do that. + +F. Installing GRX fonts +----------------------- + + Only if you have defined a default font directory in "makedefs.grx" + you can install them running 'make -f install-fonts' + + You can uninstall them running 'make -f uninstall-fonts' + + Note for Linux users: probably you must be root to do that. + +G. Installing GRX info doc +-------------------------- + + Except for the 'w32' target you can install the GRX info doc in your + info tree. Run 'make -f install-info' + + You can uninstall them running 'make -f uninstall-info' + + Note for Linux users: probably you must be root to do that. + + +Support for the x86_64 architecture +=================================== + + By default, on linux, the makefiles build the library for the i386 + architecture even in a x86_64 cpu. To build the x86_64 library (in + a x86_64 compatible cpu of course) you must set to 'y' the BUILD_X86_64 + variable in the makedefs.grx file. + +Alternate installation by a Configure script +============================================ + + For people who know how to use it, a configure script is provided, + run './configure --help' to show the options. + + +Environment variables for using GRX programs +============================================ + + 1) set the default driver and graphics mode info (very useful but not + required), in DOS or Windows: + + SET GRX20DRV= gw gh nc + + in Linux: + + export GRX20DRV=" gw gh nc " + + Available drivers are for: + + DOS : herc, stdvga, stdega, et4000, cl5426, mach64, + ati28800, s3, VESA, memory + Linux: svgalib, linuxfb, memory + X11 : xwin, memory + Win32: win32, memory + + There is also a sdl driver for x11 and win32, compiled separately. + In this case GRX20DRV="sdl::fs" gives full screen, GRX20DRV="sdl::ww" + gives windowed graphics. You can also change inside a program: + see test/fswwtest.c. + + Values for gw and gh can be by example 640,480 or 800,600 + Values for nc can be 2, 16, 256, 64K or 16M. + + 2) set the GRX font dir, in DOS or Windows: + + SET GRXFONT= + + in linux: + + export GRXFONT= + + This is required for GRX graphics text output. Path: /fonts + + NOTE: You can define a default font directory when compiling GRX. + Check the "makedefs.grx" file. + + 3) the linux framebuffer driver opens the "/dev/fb0" device file by + default, if you want to open an alternate device file, set the + $FRAMEBUFFER environment variable: + + export FRAMEBUFFER= + + +Suidroot in the Linux console platform +====================================== + + You know setting suidroot is a security flaw, if you want your grx linux + console program really portable yo have not options, because the svgalib + stable version requires it. But if you really wants a suidroot aware + libgrx you can modify makedefs.grx to obtain: + + * a framebuffer only linux console libgrx version + + * a libgrx version without some framedrivers than do direct in/out port, + so you can link it with the svgalib alpha version (1.9.x) that not + requires suidroot. + + +Pascal users +============ + + GRX has a Pascal interface (gpc), if you plan to use it don't forget + next steps before compiling: + + 1) Activate INCLUDE_GPC_SUPPORT editing the "makedefs.grx" file. + + 2) Edit the files pascal/grx.pas and pascal/bgi/graph.pas to uncomment + the '{.$L ...}' directives (near the beginning) to load the auxiliary + libraries (tiff, jpeg, png, z and socket) you need. + + Alternatively you can use the configure script. + + See the "pascal/readme" file for other details. + + +Help +==== + + Read the user's guide in the "doc/grx249um.htm" file. If you ran + 'make install-info', just type 'info grx' to view + the info version of the manual. + + If you have problems installing or running GRX check + + http://www.gnu.de/software/GRX/ + + for updates, pre-compiled libs, ... + + If this doesn't help, check your system/compiler FAQ (eg., the + DJGPP v2 FAQ is at http://www.delorie.com/djgpp/v2faq) + + Check the GRX mailing list archive at + http://grx.gnu.de/archive/grx/en/ + + Check out the DJGPP newsgroup comp.os.msdos.djgpp (archive at + http://www.delorie.com/djgpp/mail-archives/ ) + + Send a problem report to comp.os.msdos.djgpp or to the GRX mailing + list (see below). + + There is a GRX mailing list and a separate, moderated + mailing list for GRX announcements . To + subscribe to one of the lists, send an email containing "subscribe + grx" or "subscribe grx-announce" in the body to . + (The subject will be ignored.) + + +License +======= + + The GRX graphics library is free software; you can redistribute it + and/or modify it under some conditions; see the "copying.grx" file + for details. + + +Credits +======= + + I am maintainig GRX now by accident, but if GRX is a so good library + it is thanks to: + + Csaba Biegl who wrote it. + Michael Goffioul who released 2.1 + Hartmut Schirmer who released 2.2 and 2.3 + Peter Gerwinski released GRX 2.3.1 and 2.3.2. + Mariano Alvarez Fernandez who released 2.3.3-4 and 2.4.0-6. + + and other people, see the "doc/credits.doc" for details. + + +Enjoy, M. Lombardi + diff --git a/thirdparty/grx249/src/bgi/arc.c b/thirdparty/grx249/src/bgi/arc.c new file mode 100644 index 0000000..7451335 --- /dev/null +++ b/thirdparty/grx249/src/bgi/arc.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_arc(int x, int y, int stangle, int endangle, int radius) { + arc(x, y, stangle, endangle, radius); +} + diff --git a/thirdparty/grx249/src/bgi/arc.lo b/thirdparty/grx249/src/bgi/arc.lo new file mode 100644 index 0000000..75d0ab7 Binary files /dev/null and b/thirdparty/grx249/src/bgi/arc.lo differ diff --git a/thirdparty/grx249/src/bgi/aspectra.c b/thirdparty/grx249/src/bgi/aspectra.c new file mode 100644 index 0000000..2610d6a --- /dev/null +++ b/thirdparty/grx249/src/bgi/aspectra.c @@ -0,0 +1,35 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void __gr_getaspectratio(int *xasp, int *yasp) { + getaspectratio(xasp, yasp); +} + +/* ----------------------------------------------------------------- */ +void __gr_setaspectratio( int xasp, int yasp ) { + setaspectratio( xasp, yasp ); +} diff --git a/thirdparty/grx249/src/bgi/aspectra.lo b/thirdparty/grx249/src/bgi/aspectra.lo new file mode 100644 index 0000000..7e933e1 Binary files /dev/null and b/thirdparty/grx249/src/bgi/aspectra.lo differ diff --git a/thirdparty/grx249/src/bgi/bar.c b/thirdparty/grx249/src/bgi/bar.c new file mode 100644 index 0000000..b877958 --- /dev/null +++ b/thirdparty/grx249/src/bgi/bar.c @@ -0,0 +1,49 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_bar(int left, int top, int right, int bottom) +{ + _DO_INIT_CHECK; + + if (left > right) SWAP(int,left,right); + if (bottom < top) SWAP(int,bottom,top); + + left += VL; right += VL; + top += VT+PY; bottom += VT+PY; + + switch (FPATT) { + case SOLID_FILL : GrFilledBox( left, top, right, bottom, FILL); + break; + case EMPTY_FILL : GrFilledBox( left, top, right, bottom, COLBG); + break; + default : FILLP.gp_bmp_fgcolor = FILL; + FILLP.gp_bmp_bgcolor = COLBG; + GrPatternFilledBox( left, top, right, bottom, &FILLP); + break; + } +} + + diff --git a/thirdparty/grx249/src/bgi/bar.lo b/thirdparty/grx249/src/bgi/bar.lo new file mode 100644 index 0000000..fe5d61d Binary files /dev/null and b/thirdparty/grx249/src/bgi/bar.lo differ diff --git a/thirdparty/grx249/src/bgi/bar3d.c b/thirdparty/grx249/src/bgi/bar3d.c new file mode 100644 index 0000000..186ef44 --- /dev/null +++ b/thirdparty/grx249/src/bgi/bar3d.c @@ -0,0 +1,74 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void bar3d(int left,int top,int right,int bottom,int depth, int topflag) +{ + int yofs, l_d, r_d, t_y, fast, col; + + _DO_INIT_CHECK; + + if (left > right) SWAP(int,left,right); + if (bottom < top) SWAP(int,bottom,top); + + __gr_bar(left,top,right,bottom); + + left += VL; + top += VT+PY; + right += VL; + bottom += VT+PY; + if (left > right) SWAP(int,left,right); + if (bottom < top) SWAP(int,bottom,top); + + fast = (__gr_lstyle == SOLID_LINE) && (LNE.lno_width == 1); + LNE.lno_color = col = COL|WR; + if (fast) GrBox( left, top, right, bottom, col); + else GrCustomBox( left, top, right, bottom, &LNE); + + if (depth == 0) return; + + yofs = -depth * getmaxy() / getmaxx(); + r_d = right+depth; + t_y = top + yofs; + if (fast) { + GrLine( right, bottom, r_d, bottom+yofs, col); + GrVLine(r_d, bottom+yofs, t_y, col); + } else { + GrCustomLine( right, bottom, r_d, bottom+yofs, &LNE); + GrCustomLine( r_d, bottom+yofs, r_d, t_y, &LNE); + } + if (topflag) { + l_d = left+depth; + if (fast) { + GrHLine( r_d, l_d, t_y, col); + GrLine( l_d, t_y, left, top, col); + GrLine( r_d, t_y, right, top, col); + } else { + GrCustomLine( r_d, t_y, l_d, t_y, &LNE); + GrCustomLine( l_d, t_y, left, top, &LNE); + GrCustomLine( r_d, t_y, right, top, &LNE); + } + } +} diff --git a/thirdparty/grx249/src/bgi/bar3d.lo b/thirdparty/grx249/src/bgi/bar3d.lo new file mode 100644 index 0000000..00d56d1 Binary files /dev/null and b/thirdparty/grx249/src/bgi/bar3d.lo differ diff --git a/thirdparty/grx249/src/bgi/bccgrx.c b/thirdparty/grx249/src/bgi/bccgrx.c new file mode 100644 index 0000000..23b6879 --- /dev/null +++ b/thirdparty/grx249/src/bgi/bccgrx.c @@ -0,0 +1,476 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#define __BCCGRX_C + +#include "bccgrx00.h" + +#define MAX_MODES 256 + +/* ----------------------------------------------------------------- */ + +static char copyright[]="Copyright (C) 1993-1994 Hartmut Schirmer"; +int __gr_Mode = 0; /* actual graphics mode */ +int __gr_INIT = FALSE; /* TRUE after initgraph() */ +char __gr_BGICHR[128]; /* Path to .chr files */ +int __gr_MaxMode = 0; /* Last available mode */ +int __gr_Result = grOk; /* stores error code */ +int __gr_X, __gr_Y; /* graphics cursor pos */ +int __gr_vpl, __gr_vpt, /* actual viewport */ + __gr_vpr, __gr_vpb; +int __gr_color; /* drawing color */ +int __gr_colorbg; /* background color */ +int __gr_colorfill; /* fill color */ +GrColor __gr_WR = GrWRITE; /* Write mode */ +int __gr_lstyle = SOLID_LINE; /* Actual line style */ +int __gr_fpatno = SOLID_FILL; /* Actual filling pattern */ +int __gr_Xasp = 10000; /* Aspect ratio */ +int __gr_Yasp = 10000; +int __gr_clip = TRUE; /* actual clipping state */ + +int __gr_Y_page_offs = 0; /* Y offset for page simulation */ + +int __gr_ADAPTER = GR_VGA; /* Adapter used */ +int __gr_TextLineStyle = 0; /* use setlinestyle() while + plotting .chr fonts */ + +int (*__gr_initgraph_hook)(void)=NULL; /* hook for overriding mode */ + /* setting in initgraph */ +int (*__gr_closegraph_hook)(void)=NULL; + +GrPattern __gr_fillpattern; /* GRX filling settings */ +GrLineOption __gr_Line; /* GRX line settings */ + +unsigned char __gr_fpatterns[][8] = { /* BGI fill patterns */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* EMPTY_FILL */ + { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, /* SOLID_FILL */ + { 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00}, /* LINE_FILL */ + { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}, /* LTSLASH_FILL */ + { 0xE0, 0xC1, 0x83, 0x07, 0x0E, 0x1C, 0x38, 0x70}, /* SLASH_FILL */ + { 0xF0, 0x78, 0x3C, 0x1E, 0x0F, 0x87, 0xC3, 0xE1}, /* BKSLASH_FILL */ + { 0xA5, 0xD2, 0x69, 0xB4, 0x5A, 0x2D, 0x96, 0x4B}, /* LTBKSLASH_FILL */ + { 0xFF, 0x88, 0x88, 0x88, 0xFF, 0x88, 0x88, 0x88}, /* HATCH_FILL */ + { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81}, /* XHATCH_FILL */ + { 0xCC, 0x33, 0xCC, 0x33, 0xCC, 0x33, 0xCC, 0x33}, /* INTERLEAVE_FILL */ + { 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x08, 0x00}, /* WIDE_DOT_FILL */ + { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00}, /* CLOSE_DOT_FILL */ + { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} /* USER_FILL */ +}; + +#ifdef GRX_VERSION +int __gr_BGI_p = 1; /* requested / available # of pages (valid: 1,2) */ +#endif +int __gr_BGI_w = 640; /* resulution and colors needed to emulate */ +int __gr_BGI_h = 480; /* BGI driver modes */ +int __gr_BGI_c = 16; /* default : Standard VGA */ + + +#ifdef __GNUC__ +#define NULL_IS_EMPTY(s) ((s) ? : "") +#else +#define NULL_IS_EMPTY(s) ((s) ? (s) : "") +#endif + +/* ----------------------------------------------------------------- */ + +GraphicsMode *__gr_Modes = NULL; + +static int ModeCompare(GraphicsMode *a, GraphicsMode *b) { + int size_a, size_b; + if (a->colors < b->colors) return -1; + if (a->colors > b->colors) return +1; + size_a = a->width * a->height; + size_b = b->width * b->height; + if (size_a < size_b) return -1; + if (size_a > size_b) return +1; + if (a->width < b->width) return -1; + if (a->width > b->width) return +1; + return 0; +} + +static void NewMode(int w, int h, long c) { + GraphicsMode *p, *q, *qn; + p = malloc(sizeof(GraphicsMode)); + if (p != NULL) { + p->width = w; + p->height = h; + p->colors = c; + p->next = NULL; + if (__gr_Modes == NULL) { + __gr_Modes = p; + return; + } + switch(ModeCompare(p,__gr_Modes)) { + case -1 : /* p < __gr_Modes */ + p->next = __gr_Modes; + __gr_Modes = p; + return; + case 0 : /* p == __gr_Modes */ + free(p); + return; + } + q = __gr_Modes; + while ((qn=q->next) != NULL) { + switch (ModeCompare(p,qn)) { + case -1 : /* p < q->next */ + p->next = qn; + q->next = p; + return; + case 0 : /* p == q->next */ + free(p); + return; + } + q = q->next; + } + /* append to end */ + p->next = q->next; + q->next = p; + } +} + +int __gr_getmode_whc(int mode, int *w, int *h, long *c) { + GraphicsMode *p; + p = __gr_Modes; + mode -= __FIRST_DRIVER_SPECIFIC_MODE; + if (mode < 0) + return FALSE; + while (p != NULL && mode-->0) + p = p->next; + if (p==NULL) return FALSE; + *w = p->width; + *h = p->height; + *c = p->colors; + return TRUE; +} + +#ifdef GRX_VERSION + + /* ---- GRX v2.0 */ + static void build_mode_table(void) { + GrFrameMode fmode; + const GrVideoMode *mp; + char ubpp; + + for (fmode = GR_firstGraphicsFrameMode; + fmode <= GR_lastGraphicsFrameMode; + ++fmode ) { + mp = GrFirstVideoMode(fmode); + while (mp != NULL) { + ubpp = mp->bpp; + if(ubpp > 24) ubpp = 24; +#if defined(__TURBOC__) && defined(__MSDOS__) + if(ubpp < 15) +#endif + NewMode(mp->width, mp->height, 1L << ubpp); + mp = GrNextVideoMode(mp); + } + } + } + + #define COLOR_NR2DRV(col) (col) + +#else + + /* ---- GRX v1.0x */ + #ifdef GR_DRV_VER_GRD + #define _GRD GR_DRV_VER_GRD + #define _GRN GR_DRV_VER_GRN + #define _VDR GR_DRV_VER_VDR + #endif + + static long COLOR_NR2DRV(int col) { + switch (col) { + case 1<<16 : return 0xC010; + case 1<<24 : return 0xC018; + } + return col; + } + + static long COLOR_DRV2NR(int c) { + if ( (c & 0xC000) == 0xC000) + c = 1<<(c & 0x00ff); + return c; + } + + static int color_ok(long c) { + /* Check if GRX supports requested color mode */ + int old_colors, res; + extern int _GrNumColors; /* happy hacking ... */ + c = COLOR_DRV2NR(c); + switch (c) { + case 1<<15 : + case 1<<16 : + case 1<<24 : old_colors = _GrNumColors; + _GrNumColors = c; + res = GrLineOffset(128) != 0; + _GrNumColors = old_colors; + return res; + } + return TRUE; /* No way to check other colors ... */ + } + + #ifdef _VDR + static int driver = _GRD; + #endif + + static int CheckTableEntry(GR_DRIVER_MODE_ENTRY *gm) { + if (gm == NULL) return FALSE; + if (!color_ok(gm->number_of_colors) ) + return FALSE; + #ifdef _VDR + if (driver == _VDR) + return gm->mode.vdr.BIOS_mode != 0xFFF; + if (driver == _GRN) + return gm->mode.grn.BIOS_mode != 0xFF; + return FALSE; + #else + return gm->BIOS_mode != 0xFF; + #endif + } + + static void build_mode_table(void) { + GR_DRIVER_MODE_ENTRY *tm, *gm; + #ifdef _VDR + driver = 0xFFFF0000 & + #endif + GrGetDriverModes(&tm, &gm); + + while (gm->width != 0 && gm->height != 0 && gm->number_of_colors != 0) { + if (CheckTableEntry(gm)) + NewMode(gm->width, gm->height, COLOR_DRV2NR(gm->number_of_colors)); + ++gm; + } + } + +#endif + +/* ----------------------------------------------------------------- */ + +void __gr_set_up_modes(void) +{ + int mode; + GraphicsMode *p; + static int DidInit = FALSE; + + if (DidInit) return; + if (strlen(copyright) != sizeof(copyright)-1) + ; // exit(1); +# ifdef __linux__ + /* vga_init(); */ +# endif + MM = 1; + GrSetMode( GrCurrentMode()); /* Init grx */ + __gr_ADAPTER = GrAdapterType(); + if (__gr_ADAPTER == GR_S3) + __gr_ADAPTER = GR_VGA; + build_mode_table(); + p = __gr_Modes; + mode = __FIRST_DRIVER_SPECIFIC_MODE-1; + while (p != NULL) { + ++mode; + p = p->next; + } + MM = mode; + DidInit = TRUE; +} + +/* ----------------------------------------------------------------- */ + +int __gr_White(void) { + return GrNumColors() > 256 ? GrWhite() : 15; +} + +int getmaxx(void) { + return GrScreenX()-1; +} + +int getmaxy(void) { + return GrScreenY()-1; +} + +/* ----------------------------------------------------------------- */ +void graphdefaults(void) +{ + ERR = grOk; + moveto( 0, 0); + COL = FILL = WHITE; + COLBG = BLACK; + __gr_WR = GrWRITE; + + _DO_INIT_CHECK; + GrSetContext( NULL); /* ViewPort == Full screen */ +#ifdef GRX_VERSION + GrSetViewport(0,0); + PY = 0; +#endif + VL = VT = 0; + VR = getmaxx(); + VB = getmaxy(); + __gr_clip = TRUE; + + __gr_Xasp = 10000; + __gr_Yasp = __gr_Xasp * ((VR+1)*3L) / ((VB+1)*4L); + + __gr_lstyle = SOLID_LINE; + LNE.lno_pattlen = 0; + LNE.lno_dashpat = NULL; + LNE.lno_width = 1; + + FPATT = SOLID_FILL; + FILLP.gp_ispixmap = 0; /* Bitmap fill pattern */ + FILLP.gp_bmp_data = (unsigned char *)&__gr_fpatterns[FPATT]; + FILLP.gp_bmp_height = 8; + FILLP.gp_bmp_fgcolor = COL; + FILLP.gp_bmp_bgcolor = COLBG; + + __gr_TextLineStyle = 0; +} + +/* ----------------------------------------------------------------- */ + +int __gr_adaptcnv(int grx) { + switch (grx) { + case GR_VGA : return VGA; + case GR_EGA : return EGA; + case GR_8514A : return IBM8514; + case GR_HERC : return HERCMONO; + } + return grx; +} + +/* ----------------------------------------------------------------- */ +void setgraphmode(int mode) +{ + int w, h; + long c; + + _DO_INIT_CHECK; + switch (mode) { + case GRX_DEFAULT_GRAPHICS: +#ifdef GRX_VERSION + w = GrDriverInfo->defgw; + h = GrDriverInfo->defgh; + c = GrDriverInfo->defgc; + goto Default; +#else + GrSetMode( GR_default_graphics); + break; +#endif + case GRX_BIGGEST_NONINTERLACED_GRAPHICS: + GrSetMode( GR_biggest_noninterlaced_graphics); + break; + case GRX_BIGGEST_GRAPHICS: + GrSetMode( GR_biggest_graphics); + break; + case GRX_BGI_EMULATION: +#ifdef GRX_VERSION + if (__gr_BGI_p > 1) { + __gr_BGI_p = 2; + GrSetMode( GR_custom_graphics , __gr_BGI_w, __gr_BGI_h, + COLOR_NR2DRV(__gr_BGI_c), __gr_BGI_w, 2*__gr_BGI_h); + if (GrVirtualY() < 2*GrScreenY()) __gr_BGI_p = 1; + } else +#endif + GrSetMode( GR_width_height_color_graphics, __gr_BGI_w, + __gr_BGI_h, COLOR_NR2DRV(__gr_BGI_c)); + break; + default: + if (mode < __FIRST_DRIVER_SPECIFIC_MODE || mode > MM) { + ERR = grInvalidMode; + return; + } + if (!__gr_getmode_whc(mode, &w, &h, &c)) { + ERR = grInvalidMode; + return; + } +#ifdef GRX_VERSION +Default: + if (__gr_BGI_p > 1) { + __gr_BGI_p = 2; + GrSetMode( GR_custom_graphics , w, h, COLOR_NR2DRV(c), w, 2*h); + if (GrVirtualY() < 2*GrScreenY()) __gr_BGI_p = 1; + } else +#endif + GrSetMode( GR_width_height_color_graphics, w, h, COLOR_NR2DRV(c)); + break; + } + __gr_Mode = mode; + graphdefaults(); + GrClearScreen(BLACK); +} + +/* ----------------------------------------------------------------- */ +void __gr_initgraph(int *graphdriver, int *graphmode) { + ERR = grOk; + if (__gr_initgraph_hook) { + (*__gr_initgraph_hook) (); + if (ERR != grOk) { + __gr_INIT = FALSE; + return; + } + } else if (!__gr_INIT) { + __gr_set_up_modes(); + if (ERR != grOk) return; + if ( *graphdriver != NATIVE_GRX || *graphmode < 0 || *graphmode > MM) + *graphmode = 0; + __gr_INIT = TRUE; + setgraphmode(*graphmode); + if (ERR != grOk) { + __gr_INIT = FALSE; + return; + } + } + if (*graphmode == 0) *graphdriver = __gr_adaptcnv(__gr_ADAPTER); + else *graphdriver = NATIVE_GRX; +} + + + +void closegraph(void) +{ + if (__gr_closegraph_hook) { + (*__gr_closegraph_hook) (); + __gr_initgraph_hook = NULL; + __gr_closegraph_hook = NULL; + } else + restorecrtmode(); + __gr_INIT = FALSE; +} + + + +void __gr_set_libbcc_init_hooks ( + int (*init) (void) , + int (*close) (void) ) +{ + __gr_initgraph_hook = init; + __gr_closegraph_hook = close; +} + + + +void initgraph(int *graphdriver, int *graphmode, char *pathtodriver) { + __gr_initgraph(graphdriver, graphmode); + strcpy(__gr_BGICHR, NULL_IS_EMPTY(pathtodriver)); +} diff --git a/thirdparty/grx249/src/bgi/bccgrx.lo b/thirdparty/grx249/src/bgi/bccgrx.lo new file mode 100644 index 0000000..d52a094 Binary files /dev/null and b/thirdparty/grx249/src/bgi/bccgrx.lo differ diff --git a/thirdparty/grx249/src/bgi/bccgrx00.h b/thirdparty/grx249/src/bgi/bccgrx00.h new file mode 100644 index 0000000..aaeea4e --- /dev/null +++ b/thirdparty/grx249/src/bgi/bccgrx00.h @@ -0,0 +1,151 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __BCCGRX00_H +#define __BCCGRX00_H + +#include +#include +#include + +#include "../include/grx20.h" +#include "../include/grdriver.h" +#include "../include/libbcc.h" + + +#define __ABS(a) (a<0 ? -a : a) +#define YR(r) ((r)*__gr_Xasp/__gr_Yasp) +#define XR(r) (r) + +/* --- from grx/genellipse (LIBGRX 1.02+ only) : */ + +#if !defined(GR_DRV_VER_GRD) && !defined(GRX_VERSION) +extern int _grx_arc_xc, _grx_arc_yc, + _grx_arc_xs, _grx_arc_ys, + _grx_arc_xe, _grx_arc_ye; +#endif + +/* --- from bccgrx.c : */ + +extern GrLineOption __gr_Line; +extern short *__gr_modeindx; +extern GrContext *__gr_viewport; +extern char __gr_BGICHR[]; +extern GrPattern __gr_fillpattern; +void __gr_initgraph(int *graphdriver, int *graphmode); + +/* --- some things require GRX v2 */ +#ifdef GRX_VERSION +extern int __gr_BGI_p; +extern int __gr_Y_page_offs; +#endif + +/* ------------------------------ */ + +/* internal graphics modes */ +typedef struct GraphicsMode { + int width, height; + long colors; + struct GraphicsMode *next; +} GraphicsMode; +extern GraphicsMode *__gr_Modes; + +/* ------------------------- */ + +#define ERR __gr_Result +#define MM __gr_MaxMode +#define X __gr_X +#define Y __gr_Y +#define LNE __gr_Line +#define LNEP __gr_LineP +#define COL __gr_color +#define COLBG __gr_colorbg +#define FILL __gr_colorfill +#define WR __gr_WR +#define FPATT __gr_fpatno +#define FILLP __gr_fillpattern +#define VL __gr_vpl +#define VR __gr_vpr +#define VT __gr_vpt +#define VB __gr_vpb +#ifdef GRX_VERSION +#define PY __gr_Y_page_offs +#else +#define PY (0) +#endif + +#define SWAP(ty,a,b) do { ty _tmp_; _tmp_=(a);(a)=(b);(b)=_tmp_; } while(0) + +#define _DO_INIT_CHECK do {if (!__gr_INIT) {__gr_Result=grNoInitGraph;return; }} while (0) +#define _DO_INIT_CHECK_RV(rv) do {if (!__gr_INIT) {__gr_Result=grNoInitGraph;return (rv);}} while (0) + +#define IMAGE_CONTEXT_SIZE (((sizeof(GrContext)+15)&~15)+4) + +/* ----------------------------------------------------------------- */ +#ifdef GRX_VERSION +#define GrResetClipBox() GrSetClipBox( 0, PY, getmaxx(), getmaxy()+PY) +#endif + +void __gr_Reset_ClipBox(void); +#define __gr_Reset_ClipBox() \ + do { \ + if (__gr_clip) GrSetClipBox( VL, VT+PY, VR, VB+PY); \ + else GrResetClipBox(); \ + } while(0) + +#ifdef GRX_VERSION +#undef GrResetClipBox +#endif + +#ifdef __BCCGRX_C + +void (__gr_Reset_ClipBox)(void) +{ + if (__gr_clip) GrSetClipBox( VL, VT+PY, VR, VB+PY); + else +#ifdef GRX_VERSION + GrSetClipBox( 0, PY, getmaxx(), getmaxy()+PY); +#else + GrResetClipBox(); +#endif +} + +#endif + +/* ----------------------------------------------------------------- */ + +extern int __gr_getmode_whc(int idx, int *width, int *height, long *colors); +extern int __gr_adaptcnv(int grx); + +#ifndef GRX_VERSION +/* Some usefull GRX 2.0 functions for 1.0x libraries */ +#define MMSK (GrXOR|GrOR|GrAND) +#define GrWriteModeColor(c) (((c)&MMSK) | GrWRITE) +#define GrXorModeColor(c) (((c)&MMSK) | GrXOR) +#define GrOrModeColor(c) (((c)&MMSK) | GrOR) +#define GrAndModeColor(c) (((c)&MMSK) | GrAND) +#endif + +#endif + diff --git a/thirdparty/grx249/src/bgi/bgiext01.c b/thirdparty/grx249/src/bgi/bgiext01.c new file mode 100644 index 0000000..6d51cf3 --- /dev/null +++ b/thirdparty/grx249/src/bgi/bgiext01.c @@ -0,0 +1,102 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libbcc.h" +#include "bgiext.h" + +unsigned char _dac_normal[256][3] = { + { 0, 0, 0}, { 0, 0,42}, { 0,42, 0}, { 0,42,42}, + {42, 0, 0}, {42, 0,42}, {42,21, 0}, {42,42,42}, + {21,21,21}, {21,21,63}, {21,63,21}, {21,63,63}, + {63,21,21}, {63,21,63}, {63,63,21}, {63,63,63}, + { 0, 0, 0}, { 5, 5, 5}, { 8, 8, 8}, {11,11,11}, + {14,14,14}, {17,17,17}, {20,20,20}, {24,24,24}, + {28,28,28}, {32,32,32}, {36,36,36}, {40,40,40}, + {45,45,45}, {50,50,50}, {56,56,56}, {63,63,63}, + { 0, 0,63}, {16, 0,63}, {31, 0,63}, {47, 0,63}, + {63, 0,63}, {63, 0,47}, {63, 0,31}, {63, 0,16}, + {63, 0, 0}, {63,16, 0}, {63,31, 0}, {63,47, 0}, + {63,63, 0}, {47,63, 0}, {31,63, 0}, {16,63, 0}, + { 0,63, 0}, { 0,63,16}, { 0,63,31}, { 0,63,47}, + { 0,63,63}, { 0,47,63}, { 0,31,63}, { 0,16,63}, + {31,31,63}, {39,31,63}, {47,31,63}, {55,31,63}, + {63,31,63}, {63,31,55}, {63,31,47}, {63,31,39}, + {63,31,31}, {63,39,31}, {63,47,31}, {63,55,31}, + {63,63,31}, {55,63,31}, {47,63,31}, {39,63,31}, + {31,63,31}, {31,63,39}, {31,63,47}, {31,63,55}, + {31,63,63}, {31,55,63}, {31,47,63}, {31,39,63}, + {45,45,63}, {49,45,63}, {54,45,63}, {58,45,63}, + {63,45,63}, {63,45,58}, {63,45,54}, {63,45,49}, + {63,45,45}, {63,49,45}, {63,54,45}, {63,58,45}, + {63,63,45}, {58,63,45}, {54,63,45}, {49,63,45}, + {45,63,45}, {45,63,49}, {45,63,54}, {45,63,58}, + {45,63,63}, {45,58,63}, {45,54,63}, {45,49,63}, + { 0, 0,28}, { 7, 0,28}, {14, 0,28}, {21, 0,28}, + {28, 0,28}, {28, 0,21}, {28, 0,14}, {28, 0, 7}, + {28, 0, 0}, {28, 7, 0}, {28,14, 0}, {28,21, 0}, + {28,28, 0}, {21,28, 0}, {14,28, 0}, { 7,28, 0}, + { 0,28, 0}, { 0,28, 7}, { 0,28,14}, { 0,28,21}, + { 0,28,28}, { 0,21,28}, { 0,14,28}, { 0, 7,28}, + {14,14,28}, {17,14,28}, {21,14,28}, {24,14,28}, + {28,14,28}, {28,14,24}, {28,14,21}, {28,14,17}, + {28,14,14}, {28,17,14}, {28,21,14}, {28,24,14}, + {28,28,14}, {24,28,14}, {21,28,14}, {17,28,14}, + {14,28,14}, {14,28,17}, {14,28,21}, {14,28,24}, + {14,28,28}, {14,24,28}, {14,21,28}, {14,17,28}, + {20,20,28}, {22,20,28}, {24,20,28}, {26,20,28}, + {28,20,28}, {28,20,26}, {28,20,24}, {28,20,22}, + {28,20,20}, {28,22,20}, {28,24,20}, {28,26,20}, + {28,28,20}, {26,28,20}, {24,28,20}, {22,28,20}, + {20,28,20}, {20,28,22}, {20,28,24}, {20,28,26}, + {20,28,28}, {20,26,28}, {20,24,28}, {20,22,28}, + { 0, 0,16}, { 4, 0,16}, { 8, 0,16}, {12, 0,16}, + {16, 0,16}, {16, 0,12}, {16, 0, 8}, {16, 0, 4}, + {16, 0, 0}, {16, 4, 0}, {16, 8, 0}, {16,12, 0}, + {16,16, 0}, {12,16, 0}, { 8,16, 0}, { 4,16, 0}, + { 0,16, 0}, { 0,16, 4}, { 0,16, 8}, { 0,16,12}, + { 0,16,16}, { 0,12,16}, { 0, 8,16}, { 0, 4,16}, + { 8, 8,16}, {10, 8,16}, {12, 8,16}, {14, 8,16}, + {16, 8,16}, {16, 8,14}, {16, 8,12}, {16, 8,10}, + {16, 8, 8}, {16,10, 8}, {16,12, 8}, {16,14, 8}, + {16,16, 8}, {14,16, 8}, {12,16, 8}, {10,16, 8}, + { 8,16, 8}, { 8,16,10}, { 8,16,12}, { 8,16,14}, + { 8,16,16}, { 8,14,16}, { 8,12,16}, { 8,10,16}, + {11,11,16}, {12,11,16}, {13,11,16}, {15,11,16}, + {16,11,16}, {16,11,15}, {16,11,13}, {16,11,12}, + {16,11,11}, {16,12,11}, {16,13,11}, {16,15,11}, + {16,16,11}, {15,16,11}, {13,16,11}, {12,16,11}, + {11,16,11}, {11,16,12}, {11,16,13}, {11,16,15}, + {11,16,16}, {11,15,16}, {11,13,16}, {11,12,16}, + {21,21,21}, {21,21,63}, {21,63,21}, {21,63,63}, + {63,21,21}, {63,21,63}, {63,63,21}, {63,63,63} +}; + +void setrgbdefaults(void) +{ + int i; + + for (i = 0; i < 256; ++i) + setrgbpalette(i,_dac_normal[i][0],_dac_normal[i][1],_dac_normal[i][2]); +} + diff --git a/thirdparty/grx249/src/bgi/bgiext01.lo b/thirdparty/grx249/src/bgi/bgiext01.lo new file mode 100644 index 0000000..d6e2b05 Binary files /dev/null and b/thirdparty/grx249/src/bgi/bgiext01.lo differ diff --git a/thirdparty/grx249/src/bgi/bgiext02.c b/thirdparty/grx249/src/bgi/bgiext02.c new file mode 100644 index 0000000..8c853ae --- /dev/null +++ b/thirdparty/grx249/src/bgi/bgiext02.c @@ -0,0 +1,102 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libbcc.h" +#include "bgiext.h" + +unsigned char _dac_g256[256][3] = { + { 0, 0, 0}, { 1, 0, 0}, { 1, 0, 2}, { 0, 1, 1}, + { 1, 1, 1}, { 2, 1, 1}, { 2, 1, 3}, { 1, 2, 2}, + { 2, 2, 2}, { 3, 2, 2}, { 3, 2, 4}, { 2, 3, 3}, + { 3, 3, 3}, { 4, 3, 3}, { 4, 3, 5}, { 3, 4, 4}, + { 4, 4, 4}, { 5, 4, 4}, { 5, 4, 6}, { 4, 5, 5}, + { 5, 5, 5}, { 6, 5, 5}, { 6, 5, 7}, { 5, 6, 6}, + { 6, 6, 6}, { 7, 6, 6}, { 7, 6, 8}, { 6, 7, 7}, + { 7, 7, 7}, { 8, 7, 7}, { 8, 7, 9}, { 7, 8, 8}, + { 8, 8, 8}, { 9, 8, 8}, { 9, 8,10}, { 8, 9, 9}, + { 9, 9, 9}, {10, 9, 9}, {10, 9,11}, { 9,10,10}, + {10,10,10}, {11,10,10}, {11,10,12}, {10,11,11}, + {11,11,11}, {12,11,11}, {12,11,13}, {11,12,12}, + {12,12,12}, {13,12,12}, {13,12,14}, {12,13,13}, + {13,13,13}, {14,13,13}, {14,13,15}, {13,14,14}, + {14,14,14}, {15,14,14}, {15,14,16}, {14,15,15}, + {15,15,15}, {16,15,15}, {16,15,17}, {15,16,16}, + {16,16,16}, {17,16,16}, {17,16,18}, {16,17,17}, + {17,17,17}, {18,17,17}, {18,17,19}, {17,18,18}, + {18,18,18}, {19,18,18}, {19,18,20}, {18,19,19}, + {19,19,19}, {20,19,19}, {20,19,21}, {19,20,20}, + {20,20,20}, {21,20,20}, {21,20,22}, {20,21,21}, + {21,21,21}, {22,21,21}, {22,21,23}, {21,22,22}, + {22,22,22}, {23,22,22}, {23,22,24}, {22,23,23}, + {23,23,23}, {24,23,23}, {24,23,25}, {23,24,24}, + {24,24,24}, {25,24,24}, {25,24,26}, {24,25,25}, + {25,25,25}, {26,25,25}, {26,25,27}, {25,26,26}, + {26,26,26}, {27,26,26}, {27,26,28}, {26,27,27}, + {27,27,27}, {28,27,27}, {28,27,29}, {27,28,28}, + {28,28,28}, {29,28,28}, {29,28,30}, {28,29,29}, + {29,29,29}, {30,29,29}, {30,29,31}, {29,30,30}, + {30,30,30}, {31,30,30}, {31,30,32}, {30,31,31}, + {31,31,31}, {32,31,31}, {32,31,33}, {31,32,32}, + {32,32,32}, {33,32,32}, {33,32,34}, {32,33,33}, + {33,33,33}, {34,33,33}, {34,33,35}, {33,34,34}, + {34,34,34}, {35,34,34}, {35,34,36}, {34,35,35}, + {35,35,35}, {36,35,35}, {36,35,37}, {35,36,36}, + {36,36,36}, {37,36,36}, {37,36,38}, {36,37,37}, + {37,37,37}, {38,37,37}, {38,37,39}, {37,38,38}, + {38,38,38}, {39,38,38}, {39,38,40}, {38,39,39}, + {39,39,39}, {40,39,39}, {40,39,41}, {39,40,40}, + {40,40,40}, {41,40,40}, {41,40,42}, {40,41,41}, + {41,41,41}, {42,41,41}, {42,41,43}, {41,42,42}, + {42,42,42}, {43,42,42}, {43,42,44}, {42,43,43}, + {43,43,43}, {44,43,43}, {44,43,45}, {43,44,44}, + {44,44,44}, {45,44,44}, {45,44,46}, {44,45,45}, + {45,45,45}, {46,45,45}, {46,45,47}, {45,46,46}, + {46,46,46}, {47,46,46}, {47,46,48}, {46,47,47}, + {47,47,47}, {48,47,47}, {48,47,49}, {47,48,48}, + {48,48,48}, {49,48,48}, {49,48,50}, {48,49,49}, + {49,49,49}, {50,49,49}, {50,49,51}, {49,50,50}, + {50,50,50}, {51,50,50}, {51,50,52}, {50,51,51}, + {51,51,51}, {52,51,51}, {52,51,53}, {51,52,52}, + {52,52,52}, {53,52,52}, {53,52,54}, {52,53,53}, + {53,53,53}, {54,53,53}, {54,53,55}, {53,54,54}, + {54,54,54}, {55,54,54}, {55,54,56}, {54,55,55}, + {55,55,55}, {56,55,55}, {56,55,57}, {55,56,56}, + {56,56,56}, {57,56,56}, {57,56,58}, {56,57,57}, + {57,57,57}, {58,57,57}, {58,57,59}, {57,58,58}, + {58,58,58}, {59,58,58}, {59,58,60}, {58,59,59}, + {59,59,59}, {60,59,59}, {60,59,61}, {59,60,60}, + {60,60,60}, {61,60,60}, {61,60,62}, {60,61,61}, + {61,61,61}, {62,61,61}, {62,61,63}, {61,62,62}, + {62,62,62}, {63,62,62}, {63,62,63}, {62,63,63}, + {63,63,63}, {63,63,63}, {63,63,63}, {63,63,63} +}; + +void setrgbgray256(void) +{ + int ci; + + for (ci = 0; ci < 256; ++ci) + setrgbpalette( ci, _dac_g256[ci][0], _dac_g256[ci][1], _dac_g256[ci][2]); +} + diff --git a/thirdparty/grx249/src/bgi/bgiext02.lo b/thirdparty/grx249/src/bgi/bgiext02.lo new file mode 100644 index 0000000..e381015 Binary files /dev/null and b/thirdparty/grx249/src/bgi/bgiext02.lo differ diff --git a/thirdparty/grx249/src/bgi/bgimode.c b/thirdparty/grx249/src/bgi/bgimode.c new file mode 100644 index 0000000..944a03b --- /dev/null +++ b/thirdparty/grx249/src/bgi/bgimode.c @@ -0,0 +1,155 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void set_BGI_mode(int *graphdriver, int *graphmode) +{ + int rx = 0; + int ry = 0; + int rc = 0; + + switch (*graphdriver) { + case VGA : switch (*graphmode) { + case VGALO : rx = 640; ry = 200; rc = 16; break; + case VGAMED: rx = 640; ry = 350; rc = 16; break; + case VGAHI : rx = 640; ry = 480; rc = 16; break; + } + break; + case IBM8514 : switch (*graphmode) { + case IBM8514LO: rx = 640; ry = 480; rc = 256; break; + case IBM8514HI: rx = 1024; ry = 768; rc = 256; break; + } + break; + case HERCMONO: if (*graphmode == HERCMONOHI) { + rx = 720; + ry = ((__gr_ADAPTER == GR_HERC) ? 348 : 350); + rc = ((__gr_ADAPTER == GR_HERC) ? 2 : 16); + } + break; + case CGA : + case MCGA : + case ATT400 : switch (*graphmode) { + case CGAC0 : + case CGAC1 : + case CGAC2 : + case CGAC3 : rx = 320; ry = 200; break; + case CGAHI : /* == MCGAMED == ATT400MED */ + rx = 640; ry = 200; break; + case MCGAHI: /* == ATT400HI */ + switch (*graphdriver) { + case MCGA : rx = 640; ry = 480; break; + case ATT400: rx = 640; ry = 400; break; + } + break; + } + rc = 16; + break; + case EGA64 : switch (*graphmode) { + case EGA64LO : rx = 640; ry = 200; rc = 16; break; + case EGA64HI : rx = 640; + ry = 350; + rc = ((__gr_ADAPTER == GR_EGA) ? 4 : 16); + break; + } + break; + case EGA : switch (*graphmode) { + case EGALO : rx = 640; ry = 200; rc = 16; break; + case EGAHI : rx = 640; ry = 350; rc = 16; break; + } + break; + case EGAMONO : if (*graphmode == EGAMONOHI || *graphmode == EGAMONOHI_PAS) { + rx = 640; ry = 350; rc = 16; + } + break; + case PC3270 : if (*graphmode == PC3270HI) { + rx = 720; ry = 350; rc = 16; + } + break; + /* ---- extende modes from BCC++ 4.5 */ + /* unknown modes - assume 16 colors */ + case ATTDEB: + case COMPAQ: + case GENOA5: + case GENOA6: + case OAK: + case TECMAR: + case TOSHIBA: + case VIDEO7: + case VIDEO7II: + case S3: + case ATIGUP: + /* 16 color modes */ + case ATI16: + case PARADIS16: + case SVGA16: + case TRIDENT16: + case TRIDENT256: + case TSENG316: + case TSENG416: + case VESA16: rc = 16; + goto ExModes; + /* 256 color modes */ + case ATI256: + case PARADIS256: + case SVGA256: + case TSENG3256: + case TSENG4256: + case VESA256: + case VGA256: rc = 256; + goto ExModes; + /* 32k color modes */ + case ATI32K: + case SVGA32K: + case TSENG432K: + case VESA32K: rc = 1<<15; + goto ExModes; + /* 64k color modes */ + case SVGA64K: + case VESA64K: rc = 1<<16; + goto ExModes; + /* 16M color modes */ + case VESA16M: rc = 1<<24; + ExModes:switch (*graphmode) { + case RES640x350 : rx = 640; ry = 350; break; + case RES640x480 : rx = 640; ry = 480; break; + case RES800x600 : rx = 800; ry = 600; break; + case RES1024x768 : rx = 1024; ry = 768; break; + case RES1280x1024: rx = 1280; ry = 1024; break; + } + break; + default : ERR = grInvalidDriver; + return; + } + + if (rx != 0 && ry != 0 && rc != 0) { + set_BGI_mode_pages(1); + __gr_BGI_w = rx; + __gr_BGI_h = ry; + __gr_BGI_c = rc; + *graphdriver = NATIVE_GRX; + *graphmode = GRX_BGI_EMULATION; + } else + ERR = grInvalidMode; +} diff --git a/thirdparty/grx249/src/bgi/bgimode.lo b/thirdparty/grx249/src/bgi/bgimode.lo new file mode 100644 index 0000000..4af6b23 Binary files /dev/null and b/thirdparty/grx249/src/bgi/bgimode.lo differ diff --git a/thirdparty/grx249/src/bgi/bgiprint.c b/thirdparty/grx249/src/bgi/bgiprint.c new file mode 100644 index 0000000..bc8e245 --- /dev/null +++ b/thirdparty/grx249/src/bgi/bgiprint.c @@ -0,0 +1,69 @@ +/************************************************************************ + * * + * Printing from BCC2GRX * + * * + * Author: Andris Pavenis (pavenis@latnet.lv) * + * * + ************************************************************************/ + + +#include +#include +#include +#include +#include +#include "bccgrx00.h" + + + +int __gr_print_mode = -1; +char * __gr_print_dest = NULL; + + +static int bgiprint_init (void); +static int bgiprint_close (void); + + +int set_BGI_print_mode ( int mode , char * dest ) + { + if (dest) + if (*dest==0) + dest = 0; + __gr_print_mode = mode; + if (__gr_print_dest) free(__gr_print_dest); + __gr_print_dest = dest ? strdup(dest) : NULL; + __gr_set_libbcc_init_hooks (bgiprint_init,bgiprint_close); + return 0; + } + + + +static int bgiprint_init (void) + { + int ret; + ret = GrPrintSetMode (__gr_print_mode); + if (ret!=TRUE) { ERR=grInvalidMode; return -1; } + __gr_Mode = 1; + __gr_INIT = 1; + graphdefaults(); + return 0; + } + + +static int bgiprint_close (void) + { + if (__gr_print_dest) + { + GrPrintToFile (__gr_print_dest); + free (__gr_print_dest); + __gr_print_dest = 0; + } + else + { + GrDoPrinting (); + } + return 0; + } + + + diff --git a/thirdparty/grx249/src/bgi/bgiprint.lo b/thirdparty/grx249/src/bgi/bgiprint.lo new file mode 100644 index 0000000..2fb0751 Binary files /dev/null and b/thirdparty/grx249/src/bgi/bgiprint.lo differ diff --git a/thirdparty/grx249/src/bgi/circle.c b/thirdparty/grx249/src/bgi/circle.c new file mode 100644 index 0000000..1b79c48 --- /dev/null +++ b/thirdparty/grx249/src/bgi/circle.c @@ -0,0 +1,35 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_circle(int x, int y, int radius) +{ + _DO_INIT_CHECK; + if (__gr_Xasp==__gr_Yasp) + GrCircle(x+VL,y+VT+PY, XR(radius), COL); + else + GrEllipse(x+VL,y+VT+PY, XR(radius), YR(radius), COL); +} + diff --git a/thirdparty/grx249/src/bgi/circle.lo b/thirdparty/grx249/src/bgi/circle.lo new file mode 100644 index 0000000..388af6d Binary files /dev/null and b/thirdparty/grx249/src/bgi/circle.lo differ diff --git a/thirdparty/grx249/src/bgi/clearvp.c b/thirdparty/grx249/src/bgi/clearvp.c new file mode 100644 index 0000000..309eac0 --- /dev/null +++ b/thirdparty/grx249/src/bgi/clearvp.c @@ -0,0 +1,33 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void clearviewport(void) +{ + _DO_INIT_CHECK; + GrFilledBox( VL, VT+PY, VR, VB+PY, COLBG); + moveto(0,0); +} + diff --git a/thirdparty/grx249/src/bgi/clearvp.lo b/thirdparty/grx249/src/bgi/clearvp.lo new file mode 100644 index 0000000..54b8b16 Binary files /dev/null and b/thirdparty/grx249/src/bgi/clearvp.lo differ diff --git a/thirdparty/grx249/src/bgi/closegra.c b/thirdparty/grx249/src/bgi/closegra.c new file mode 100644 index 0000000..302259d --- /dev/null +++ b/thirdparty/grx249/src/bgi/closegra.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void __gr_closegraph(void) { + closegraph(); +} diff --git a/thirdparty/grx249/src/bgi/closegra.lo b/thirdparty/grx249/src/bgi/closegra.lo new file mode 100644 index 0000000..ffefcab Binary files /dev/null and b/thirdparty/grx249/src/bgi/closegra.lo differ diff --git a/thirdparty/grx249/src/bgi/clrdev.c b/thirdparty/grx249/src/bgi/clrdev.c new file mode 100644 index 0000000..0e4a9ef --- /dev/null +++ b/thirdparty/grx249/src/bgi/clrdev.c @@ -0,0 +1,34 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_cleardevice(void) { + _DO_INIT_CHECK; + GrResetClipBox(); + GrFilledBox( 0, 0+PY, getmaxx(), getmaxy()+PY, __gr_colorbg); + __gr_Reset_ClipBox(); + moveto( 0, 0); +} + diff --git a/thirdparty/grx249/src/bgi/clrdev.lo b/thirdparty/grx249/src/bgi/clrdev.lo new file mode 100644 index 0000000..a25d7f9 Binary files /dev/null and b/thirdparty/grx249/src/bgi/clrdev.lo differ diff --git a/thirdparty/grx249/src/bgi/detectg.c b/thirdparty/grx249/src/bgi/detectg.c new file mode 100644 index 0000000..0e70070 --- /dev/null +++ b/thirdparty/grx249/src/bgi/detectg.c @@ -0,0 +1,33 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void detectgraph(int *graphdriver,int *graphmode) +{ + __gr_set_up_modes(); + *graphdriver = __gr_adaptcnv(__gr_ADAPTER); + *graphmode = 0; +} + diff --git a/thirdparty/grx249/src/bgi/detectg.lo b/thirdparty/grx249/src/bgi/detectg.lo new file mode 100644 index 0000000..f216606 Binary files /dev/null and b/thirdparty/grx249/src/bgi/detectg.lo differ diff --git a/thirdparty/grx249/src/bgi/drvname.c b/thirdparty/grx249/src/bgi/drvname.c new file mode 100644 index 0000000..3213dcf --- /dev/null +++ b/thirdparty/grx249/src/bgi/drvname.c @@ -0,0 +1,55 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +char *getdrivername( void ) +{ + _DO_INIT_CHECK_RV(NULL); +#ifdef GRX_VERSION +{ + static char *grxname = NULL; + const GrVideoDriver *vd = GrCurrentVideoDriver(); + if (vd != NULL) { + grxname = realloc(grxname, 16+strlen(vd->name)); + if (grxname != NULL) { + strcpy(grxname, "GRX driver \""); + strcat(grxname, vd->name); + strcat(grxname, "\""); + return grxname; + } + } +} +#else + switch (__gr_ADAPTER) { + case GR_VGA : return "VGA driver"; + case GR_EGA : return "EGA driver"; + case GR_HERC : return "Hercules mono driver"; + case GR_8514A : return "8514A driver"; + case GR_S3 : return "S3 graphics accelerator driver"; + } +#endif + return "unknown graphics driver"; +} + diff --git a/thirdparty/grx249/src/bgi/drvname.lo b/thirdparty/grx249/src/bgi/drvname.lo new file mode 100644 index 0000000..9b42137 Binary files /dev/null and b/thirdparty/grx249/src/bgi/drvname.lo differ diff --git a/thirdparty/grx249/src/bgi/egacolor.c b/thirdparty/grx249/src/bgi/egacolor.c new file mode 100644 index 0000000..9b91a67 --- /dev/null +++ b/thirdparty/grx249/src/bgi/egacolor.c @@ -0,0 +1,91 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +#ifdef __GNUC__ +#define _tc(r,g,b) ((r)<<2),((g)<<2),((b)<<2) +#define UNSIGNED unsigned char +#else +#define _hi15(r,g,b) ( (((r)>>1)<<10)|(((g)>>1)<<5)|((b)>>1) ) +#define _hi16(r,g,b) ( (((r)>>1)<<11)|((g)<<5)|((b)>>1) ) +#define _tc(r,g,b) ( ((r)<<2) | ((g)<<2) | ((b)<<2) ) +#define UNSIGNED unsigned +static unsigned short _hi15_ega[16] = { + _hi15( 0, 0, 0), _hi15( 0, 0,42), _hi15( 0,42, 0), _hi15( 0,42,42), + _hi15(42, 0, 0), _hi15(42, 0,42), _hi15(42,21, 0), _hi15(42,42,42), + _hi15(21,21,21), _hi15(21,21,63), _hi15(21,63,21), _hi15(21,63,63), + _hi15(63,21,21), _hi15(63,21,63), _hi15(63,63,21), _hi15(63,63,63) +}; +static unsigned short _hi16_ega[16] = { + _hi16( 0, 0, 0), _hi16( 0, 0,42), _hi16( 0,42, 0), _hi16( 0,42,42), + _hi16(42, 0, 0), _hi16(42, 0,42), _hi16(42,21, 0), _hi16(42,42,42), + _hi16(21,21,21), _hi16(21,21,63), _hi16(21,63,21), _hi16(21,63,63), + _hi16(63,21,21), _hi16(63,21,63), _hi16(63,63,21), _hi16(63,63,63) +}; +#endif + +static UNSIGNED _tc_ega[] = { + _tc( 0, 0, 0), _tc( 0, 0,42), _tc( 0,42, 0), _tc( 0,42,42), + _tc(42, 0, 0), _tc(42, 0,42), _tc(42,21, 0), _tc(42,42,42), + _tc(21,21,21), _tc(21,21,63), _tc(21,63,21), _tc(21,63,63), + _tc(63,21,21), _tc(63,21,63), _tc(63,63,21), _tc(63,63,63) +}; + +#ifdef __GNUC__ + +int _ega_color(int color) +{ + _DO_INIT_CHECK_RV(0); + switch(GrNumColors()) { + case 1L<<15: + case 1L<<16: + case 1L<<24: + if ((color&15) == 15) + color = GrWhite(); + else { + int oldc = COL; + color = (color&15)*3; + color = setrgbcolor(_tc_ega[color], _tc_ega[color+1], _tc_ega[color+2]); + COL = oldc; + } + break; + } + return color; +} + +#else + +int _ega_color(int color) +{ + switch (getmaxcolor()+1) { + case 1L<<15: return _hi15_ega[color&15]; +#if 0 + case 1L<<16: return _hi16_ega[color&15]; + case 1L<<24: return _tc_ega[color&15]; +#endif + } + return color; +} +#endif diff --git a/thirdparty/grx249/src/bgi/egacolor.lo b/thirdparty/grx249/src/bgi/egacolor.lo new file mode 100644 index 0000000..03ec337 Binary files /dev/null and b/thirdparty/grx249/src/bgi/egacolor.lo differ diff --git a/thirdparty/grx249/src/bgi/ellipse.c b/thirdparty/grx249/src/bgi/ellipse.c new file mode 100644 index 0000000..0d3b3f2 --- /dev/null +++ b/thirdparty/grx249/src/bgi/ellipse.c @@ -0,0 +1,73 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +static struct arccoordstype ac; + +#ifdef GRX_VERSION +#define GrGetLastArcCoords GrLastArcCoords +#endif + +/* ----------------------------------------------------------------- */ +void __gr_ellipse(int x, int y, int st, int en, + int xradius, int yradius ) +{ + _DO_INIT_CHECK; + st *= 10; + en *= 10; + GrEllipseArc(x+VL,y+VT+PY,XR(xradius),YR(yradius),st,en, + #ifdef GRX_VERSION + (en-st!=0&&(en-st)%3600==0) ? GR_ARC_STYLE_CLOSE1 : GR_ARC_STYLE_OPEN, + #endif + COL); + { +#if defined(GR_DRV_VER_GRD) || defined(GRX_VERSION) + /* GRX 1.03 or newer */ + int xs, ys, xc, yc, xe, ye; + GrGetLastArcCoords(&xs,&ys,&xe,&ye,&xc,&yc); +#else + /* GRX 1.02+ */ +# define xs _grx_arc_xs +# define ys _grx_arc_ys +# define xc _grx_arc_xc +# define yc _grx_arc_yc +# define xe _grx_arc_xe +# define ye _grx_arc_ye +#endif + ac.x = xc - VL; + ac.y = yc - VT - PY; + ac.xstart = xs - VL; + ac.ystart = ys - VT - PY; + ac.xend = xe - VL; + ac.yend = ye - VT - PY; + } +} + +/* ----------------------------------------------------------------- */ +void getarccoords(struct arccoordstype *arccoords) +{ + _DO_INIT_CHECK; + memcpy( arccoords, &ac, sizeof(ac)); +} diff --git a/thirdparty/grx249/src/bgi/ellipse.lo b/thirdparty/grx249/src/bgi/ellipse.lo new file mode 100644 index 0000000..99ae9bf Binary files /dev/null and b/thirdparty/grx249/src/bgi/ellipse.lo differ diff --git a/thirdparty/grx249/src/bgi/errmsg.c b/thirdparty/grx249/src/bgi/errmsg.c new file mode 100644 index 0000000..34e2af7 --- /dev/null +++ b/thirdparty/grx249/src/bgi/errmsg.c @@ -0,0 +1,49 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +char *grapherrormsg(int errorcode) +{ + switch (errorcode) { + case grOk : return "No error"; + case grNoInitGraph : return "graphics not initialized"; + case grNotDetected : return "Graphics hardware not detected"; + case grFileNotFound : return "Device driver file not found"; + case grInvalidDriver : return "Invalid device driver file"; + case grNoLoadMem : return "Not enough memory to load driver"; + case grNoScanMem : return "Out of memory in scan fill"; + case grNoFloodMem : return "Out of memory in flood fill"; + case grFontNotFound : return "Font file not found"; + case grNoFontMem : return "Not enough memory to load font"; + case grInvalidMode : return "Invalid graphics mode"; + case grError : return "Graphics error"; + case grIOerror : return "Graphics I/O error"; + case grInvalidFont : return "Invalid font file"; + case grInvalidFontNum : return "Invalid font number"; + case grInvalidVersion : return "Invalid File Version Number"; + } + return "Unknown graphics error"; +} diff --git a/thirdparty/grx249/src/bgi/errmsg.lo b/thirdparty/grx249/src/bgi/errmsg.lo new file mode 100644 index 0000000..7f835db Binary files /dev/null and b/thirdparty/grx249/src/bgi/errmsg.lo differ diff --git a/thirdparty/grx249/src/bgi/fellipse.c b/thirdparty/grx249/src/bgi/fellipse.c new file mode 100644 index 0000000..0aafd1a --- /dev/null +++ b/thirdparty/grx249/src/bgi/fellipse.c @@ -0,0 +1,53 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void fillellipse( int x, int y, int xradius, int yradius) +{ + _DO_INIT_CHECK; + x += VL; + y += VT+PY; + xradius = XR(xradius); + yradius = YR(yradius); + switch (FPATT) { + case SOLID_FILL : + GrFilledEllipse( x, y, xradius, yradius, FILL); + if (COL != FILL) + GrEllipse( x, y, xradius, yradius, COL); + break; + case EMPTY_FILL : + GrFilledEllipse( x, y, xradius, yradius, COLBG); + if (COL != COLBG) + GrEllipse( x, y, xradius, yradius, COL); + break; + default : + FILLP.gp_bmp_fgcolor = FILL; + FILLP.gp_bmp_bgcolor = COLBG; + GrPatternFilledEllipse( x, y, xradius, yradius, &FILLP); + GrEllipse( x, y, xradius, yradius, COL); + break; + } +} + diff --git a/thirdparty/grx249/src/bgi/fellipse.lo b/thirdparty/grx249/src/bgi/fellipse.lo new file mode 100644 index 0000000..4f3e414 Binary files /dev/null and b/thirdparty/grx249/src/bgi/fellipse.lo differ diff --git a/thirdparty/grx249/src/bgi/fillpatb.c b/thirdparty/grx249/src/bgi/fillpatb.c new file mode 100644 index 0000000..f5a7c11 --- /dev/null +++ b/thirdparty/grx249/src/bgi/fillpatb.c @@ -0,0 +1,36 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void setfillpattern( char *upattern, int color) +{ + _DO_INIT_CHECK; + FILL = color; + FPATT = USER_FILL; + memcpy(__gr_fpatterns[USER_FILL], upattern, 8); + FILLP.gp_bmp_data = (unsigned char *)&__gr_fpatterns[USER_FILL]; +} + diff --git a/thirdparty/grx249/src/bgi/fillpatb.lo b/thirdparty/grx249/src/bgi/fillpatb.lo new file mode 100644 index 0000000..6ec297c Binary files /dev/null and b/thirdparty/grx249/src/bgi/fillpatb.lo differ diff --git a/thirdparty/grx249/src/bgi/fillpolb.c b/thirdparty/grx249/src/bgi/fillpolb.c new file mode 100644 index 0000000..b9c88ed --- /dev/null +++ b/thirdparty/grx249/src/bgi/fillpolb.c @@ -0,0 +1,74 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "bccgrx00.h" + +/* + - Take care : Borland C defines polypoints as int * but + - assumes struct pointtype * . + - GRX requires int points[][2] ! + - The good news are : Both definitions are compatible ! +*/ + +void fillpoly(int numpoints, void *polypoints) +{ + void *cpp; + + _DO_INIT_CHECK; + if (VL != 0 || VT+PY != 0) { + int i, *ppd, *pps; + + pps = polypoints; + ppd = cpp = alloca( sizeof(int) * 2 * numpoints); + if (cpp==NULL) { + ERR = grNoScanMem; + return; + } + for (i=0; i < numpoints; ++i) { + *(ppd++) = *(pps++) + VL; + *(ppd++) = *(pps++) + VT+PY; + } + } else + cpp = polypoints; + + switch (FPATT) { + case SOLID_FILL : + GrFilledPolygon(numpoints, cpp, FILL); + if (COL != FILL) + __gr_drawpol(numpoints, polypoints, TRUE); + break; + case EMPTY_FILL : + GrFilledPolygon(numpoints, cpp, COLBG); + if (COL != COLBG) + __gr_drawpol(numpoints, polypoints, TRUE); + break; + default : + FILLP.gp_bmp_fgcolor = FILL; + FILLP.gp_bmp_bgcolor = COLBG; + GrPatternFilledPolygon( numpoints, cpp, &FILLP); + __gr_drawpol( numpoints, polypoints, TRUE); + break; + } +} diff --git a/thirdparty/grx249/src/bgi/fillpolb.lo b/thirdparty/grx249/src/bgi/fillpolb.lo new file mode 100644 index 0000000..f9fa6e7 Binary files /dev/null and b/thirdparty/grx249/src/bgi/fillpolb.lo differ diff --git a/thirdparty/grx249/src/bgi/fillstyl.c b/thirdparty/grx249/src/bgi/fillstyl.c new file mode 100644 index 0000000..303cc13 --- /dev/null +++ b/thirdparty/grx249/src/bgi/fillstyl.c @@ -0,0 +1,38 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void setfillstyle(int pattern, int color) +{ + _DO_INIT_CHECK; + if (pattern < 0 || pattern > USER_FILL) { + ERR = grError; + return; + } + FPATT = pattern; + FILL = color; + FILLP.gp_bmp_data = (unsigned char *)&__gr_fpatterns[FPATT]; +} + diff --git a/thirdparty/grx249/src/bgi/fillstyl.lo b/thirdparty/grx249/src/bgi/fillstyl.lo new file mode 100644 index 0000000..e30a58a Binary files /dev/null and b/thirdparty/grx249/src/bgi/fillstyl.lo differ diff --git a/thirdparty/grx249/src/bgi/fldfill.c b/thirdparty/grx249/src/bgi/fldfill.c new file mode 100644 index 0000000..fe82ed4 --- /dev/null +++ b/thirdparty/grx249/src/bgi/fldfill.c @@ -0,0 +1,305 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +#if 0 && ((GRX_VERSION_API-0)>=0x0225) +/* GRX has floodfill */ + +void floodfill(int x, int y, int border) +{ + _DO_INIT_CHECK; + x += VL; + y += VT+PY; + + if ( FPATT == SOLID_FILL || FPATT == EMPTY_FILL) { + GrColor color = (FPATT==SOLID_FILL) ? FILL : COLBG; + GrFloodFill( x, y, (GrColor)border, color); + } else { + FILLP.gp_bmp_fgcolor = FILL; + FILLP.gp_bmp_bgcolor = COLBG; + GrPatternFloodFill( x, y, (GrColor)border, &FILLP); + } +} + +#else +/* use BCC2GRX flood fill function */ + +#include + +static int lx, ly, mx, my; +static GrColor _border; +static GrColor _color; +static jmp_buf error; + +typedef unsigned char element; /* for 1bit/pixel images */ +typedef unsigned short line_index; /* start index table */ +static element **done = NULL; /* bitmap of already processed pixel */ +static element **start = NULL; /* pixel that need to be processed */ +static int elements; /* no. bytes in each bitmap line */ +static line_index *start_flg = NULL; /* !=0: index+1 of first start element !=0 */ + /* ==0: nothing to do */ + +#define bits_per_element (sizeof(element)*8) +#define offset_div (bits_per_element) +#define calc_bit(x) ( ((element)1) << ((x)&(bits_per_element-1))) +#define calc_high_bits(x) ( (~((element)0)) << ((x)&(bits_per_element-1))) +#define calc_ofs(x) ((x) / offset_div) + +/* ----------------------------------------------------------------- */ +#if defined(__GNUC__) +#define _BGI_INLINE_ __inline__ +#elif defined(_MSC_VER) +#define _BGI_INLINE_ _inline +#else +#define _BGI_INLINE_ +#endif +/* ----------------------------------------------------------------- */ + +/* -------- internal line buffer functions +** +** (x,y) scaled to (0..mx,0..my) +*/ + +static _BGI_INLINE_ element *generate_line(element **buf, int y) { + if (buf[y] == NULL) + if ( (buf[y] = calloc(sizeof(element),elements)) == NULL) + longjmp(error,1); + return buf[y]; +} + +static _BGI_INLINE_ void mark_line( element **buf, int x1, int x2, int y) { + element *l = generate_line(buf,y); + element *anf, *ende; + int start_bit, stop_bit; + + anf = &l[calc_ofs(x1)]; + ende = &l[calc_ofs(x2)]; + start_bit = calc_high_bits(x1); + if (anf != ende) { + *(anf++) |= start_bit; + if (anf != ende) + memset(anf,~0,(ende-anf)*sizeof(element)); + start_bit = ~0; + } + /* start_bit rejects all invalid low bits, let stop_bit discard + all invalid high bits, but make sure stop_bit won't get zero */ + stop_bit = ~calc_high_bits(x2+1); + if ( stop_bit ) + start_bit &= stop_bit; + *ende |= start_bit; +} + +static _BGI_INLINE_ void set_pix(element **buf, int x, int y) { + element *l = generate_line(buf,y); + l[calc_ofs(x)] |= calc_bit(x); +} + +static _BGI_INLINE_ int test_pix(element **buf, int x, int y) { + element *l = buf[y]; + if (l != NULL) + return (l[calc_ofs(x)] & calc_bit(x)) != 0; + return FALSE; +} + +static _BGI_INLINE_ int test_screen(int x, int y) { + return (GrPixelNC(x+lx,y+ly) == _border); +} + +static _BGI_INLINE_ int test_pixel(int x, int y) { + if (test_pix(done,x,y)) return TRUE; + if (test_screen(x,y)) { + set_pix(done,x,y); + return TRUE; + } + return FALSE; +} + +static _BGI_INLINE_ void SetStartFlag(int x, int y) { + int _x = calc_ofs(x); + if ( !start_flg[y] + || _x 0 && !test_pixel(sx-1,y)) + --sx; + while ( x < mx && !test_pixel(x+1,y)) + ++x; + GrHLine( sx+lx, x+lx, y+ly, _color); + mark_line( done, sx, x, y); + if (y>0) { mark_line( start, sx, x, y-1); + SetStartFlag(sx,y-1); } + if (y 0 && !test_pixel(sx-1,y)) + --sx; + while ( x < mx && !test_pixel(x+1,y)) + ++x; + GrPatternFilledLine( sx+lx, y+ly, x+lx, y+ly, &FILLP); + mark_line( done, sx, x, y); + if (y>0) { mark_line( start, sx, x, y-1); + SetStartFlag(sx,y-1); } + if (y mx || y > my || GrPixel(x,y) == _border) + return; + + mx -= lx; _x = x - lx; + my -= ly; _y = y - ly; + done = calloc(sizeof(element *), my+1); + start = calloc(sizeof(element *), my+1); + start_flg = calloc(sizeof(line_index), my+1); + if (done==NULL || start==NULL || start_flg==NULL) { + ERR = grNoFloodMem; + goto FreeMem; + } + + if (setjmp(error) == 0) { + elements = calc_ofs(mx + bits_per_element) + 1; + + set_pix(start, _x, _y); + SetStartFlag(_x,_y); + if ( FPATT == SOLID_FILL || FPATT == EMPTY_FILL) { + _color = (FPATT==SOLID_FILL) ? FILL : COLBG; + work(solid_fill); + } else { + FILLP.gp_bmp_fgcolor = FILL; + FILLP.gp_bmp_bgcolor = COLBG; + work(pattern_fill); + } + } else { + /* generate_line() called longjmp() : out of memory error */ + ERR = grNoFloodMem; + } + +FreeMem: + if (done != NULL) { + int i; + for (i=my; i >= 0; --i) + if (done[i] != NULL) + free(done[i]); + free(done); + done = NULL; + } + if (start != NULL) { + int i; + for (i=my; i >= 0; --i) + if (start[i] != NULL) + free(start[i]); + free(start); + start = NULL; + } + if (start_flg != NULL) { + free(start_flg); + start_flg = NULL; + } +} + +#endif diff --git a/thirdparty/grx249/src/bgi/fldfill.lo b/thirdparty/grx249/src/bgi/fldfill.lo new file mode 100644 index 0000000..64f6034 Binary files /dev/null and b/thirdparty/grx249/src/bgi/fldfill.lo differ diff --git a/thirdparty/grx249/src/bgi/getbkcol.c b/thirdparty/grx249/src/bgi/getbkcol.c new file mode 100644 index 0000000..b6b8e6b --- /dev/null +++ b/thirdparty/grx249/src/bgi/getbkcol.c @@ -0,0 +1,29 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int __gr_getbkcolor(void) { + return getbkcolor(); +} diff --git a/thirdparty/grx249/src/bgi/getbkcol.lo b/thirdparty/grx249/src/bgi/getbkcol.lo new file mode 100644 index 0000000..1510e10 Binary files /dev/null and b/thirdparty/grx249/src/bgi/getbkcol.lo differ diff --git a/thirdparty/grx249/src/bgi/getcol.c b/thirdparty/grx249/src/bgi/getcol.c new file mode 100644 index 0000000..b3c6909 --- /dev/null +++ b/thirdparty/grx249/src/bgi/getcol.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +int __gr_getcolor(void) { + return getcolor(); +} diff --git a/thirdparty/grx249/src/bgi/getcol.lo b/thirdparty/grx249/src/bgi/getcol.lo new file mode 100644 index 0000000..43dd7ff Binary files /dev/null and b/thirdparty/grx249/src/bgi/getcol.lo differ diff --git a/thirdparty/grx249/src/bgi/getdefpa.c b/thirdparty/grx249/src/bgi/getdefpa.c new file mode 100644 index 0000000..d8f89fe --- /dev/null +++ b/thirdparty/grx249/src/bgi/getdefpa.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +struct palettetype *__gr_getdefaultpalette(void) { + return getdefaultpalette(); +} diff --git a/thirdparty/grx249/src/bgi/getdefpa.lo b/thirdparty/grx249/src/bgi/getdefpa.lo new file mode 100644 index 0000000..5fc317c Binary files /dev/null and b/thirdparty/grx249/src/bgi/getdefpa.lo differ diff --git a/thirdparty/grx249/src/bgi/getfillp.c b/thirdparty/grx249/src/bgi/getfillp.c new file mode 100644 index 0000000..9a84613 --- /dev/null +++ b/thirdparty/grx249/src/bgi/getfillp.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void __gr_getfillpattern(char *pattern) { + memcpy(pattern, &__gr_fpatterns[USER_FILL], 8); +} diff --git a/thirdparty/grx249/src/bgi/getfillp.lo b/thirdparty/grx249/src/bgi/getfillp.lo new file mode 100644 index 0000000..9808c76 Binary files /dev/null and b/thirdparty/grx249/src/bgi/getfillp.lo differ diff --git a/thirdparty/grx249/src/bgi/getfills.c b/thirdparty/grx249/src/bgi/getfills.c new file mode 100644 index 0000000..0df276b --- /dev/null +++ b/thirdparty/grx249/src/bgi/getfills.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void __gr_getfillsettings(struct fillsettingstype *fillinfo) { + getfillsettings(fillinfo); +} diff --git a/thirdparty/grx249/src/bgi/getfills.lo b/thirdparty/grx249/src/bgi/getfills.lo new file mode 100644 index 0000000..c84c2dc Binary files /dev/null and b/thirdparty/grx249/src/bgi/getfills.lo differ diff --git a/thirdparty/grx249/src/bgi/getgramo.c b/thirdparty/grx249/src/bgi/getgramo.c new file mode 100644 index 0000000..e2ee38a --- /dev/null +++ b/thirdparty/grx249/src/bgi/getgramo.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +int __gr_getgraphmode(void) { + return getgraphmode(); +} diff --git a/thirdparty/grx249/src/bgi/getgramo.lo b/thirdparty/grx249/src/bgi/getgramo.lo new file mode 100644 index 0000000..ddd2c37 Binary files /dev/null and b/thirdparty/grx249/src/bgi/getgramo.lo differ diff --git a/thirdparty/grx249/src/bgi/getimage.c b/thirdparty/grx249/src/bgi/getimage.c new file mode 100644 index 0000000..4fa0b7e --- /dev/null +++ b/thirdparty/grx249/src/bgi/getimage.c @@ -0,0 +1,58 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void getimage(int left, int top, int right, int bottom, void *bitmap) +{ + GrContext *gc; + int w, h; +#ifdef GRX_VERSION + char *memory[4]; + int i, np, ps; +#else + char *memory; +#endif + + _DO_INIT_CHECK; + GrSetContext(NULL); + GrResetClipBox(); + gc = bitmap; + w = __ABS(right-left)+1; + h = __ABS(bottom-top)+1; +#ifdef GRX_VERSION + np = GrNumPlanes(); + ps = GrPlaneSize(w,h); + for (i=0; i < np; ++i) + memory[i] = ((char *)bitmap) + (IMAGE_CONTEXT_SIZE + i*ps); + while (i<4) + memory[i++] = NULL; +#else + memory = ((char *)bitmap) + IMAGE_CONTEXT_SIZE; +#endif + GrCreateContext( w, h, memory, gc); + GrBitBlt( gc, 0, 0, NULL, left+VL, top+VT+PY, right+VL, bottom+VT+PY, GrWRITE); + __gr_Reset_ClipBox(); +} diff --git a/thirdparty/grx249/src/bgi/getimage.lo b/thirdparty/grx249/src/bgi/getimage.lo new file mode 100644 index 0000000..fd4b61b Binary files /dev/null and b/thirdparty/grx249/src/bgi/getimage.lo differ diff --git a/thirdparty/grx249/src/bgi/getmaxmo.c b/thirdparty/grx249/src/bgi/getmaxmo.c new file mode 100644 index 0000000..1568698 --- /dev/null +++ b/thirdparty/grx249/src/bgi/getmaxmo.c @@ -0,0 +1,29 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int __gr_getmaxmode(void) { + return getmaxmode(); +} diff --git a/thirdparty/grx249/src/bgi/getmaxmo.lo b/thirdparty/grx249/src/bgi/getmaxmo.lo new file mode 100644 index 0000000..f440715 Binary files /dev/null and b/thirdparty/grx249/src/bgi/getmaxmo.lo differ diff --git a/thirdparty/grx249/src/bgi/getmoran.c b/thirdparty/grx249/src/bgi/getmoran.c new file mode 100644 index 0000000..9821181 --- /dev/null +++ b/thirdparty/grx249/src/bgi/getmoran.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_getmoderange(int gd, int *lomode, int *himode) { + *lomode = 0; + *himode = getmaxmode(); +} diff --git a/thirdparty/grx249/src/bgi/getmoran.lo b/thirdparty/grx249/src/bgi/getmoran.lo new file mode 100644 index 0000000..eff2200 Binary files /dev/null and b/thirdparty/grx249/src/bgi/getmoran.lo differ diff --git a/thirdparty/grx249/src/bgi/getpixel.c b/thirdparty/grx249/src/bgi/getpixel.c new file mode 100644 index 0000000..3fd1655 --- /dev/null +++ b/thirdparty/grx249/src/bgi/getpixel.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +unsigned getpixel(int x, int y) { + _DO_INIT_CHECK_RV(0); + return GrPixel(x+VL,y+VT+PY); +} diff --git a/thirdparty/grx249/src/bgi/getpixel.lo b/thirdparty/grx249/src/bgi/getpixel.lo new file mode 100644 index 0000000..a07cea7 Binary files /dev/null and b/thirdparty/grx249/src/bgi/getpixel.lo differ diff --git a/thirdparty/grx249/src/bgi/getviewp.c b/thirdparty/grx249/src/bgi/getviewp.c new file mode 100644 index 0000000..0ae865c --- /dev/null +++ b/thirdparty/grx249/src/bgi/getviewp.c @@ -0,0 +1,36 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void getviewsettings(struct viewporttype *viewport) +{ + _DO_INIT_CHECK; + viewport->left = VL; + viewport->right = VR; + viewport->top = VT; + viewport->bottom = VB; + viewport->clip = __gr_clip; +} + diff --git a/thirdparty/grx249/src/bgi/getviewp.lo b/thirdparty/grx249/src/bgi/getviewp.lo new file mode 100644 index 0000000..c57be9b Binary files /dev/null and b/thirdparty/grx249/src/bgi/getviewp.lo differ diff --git a/thirdparty/grx249/src/bgi/getx.c b/thirdparty/grx249/src/bgi/getx.c new file mode 100644 index 0000000..a2419d9 --- /dev/null +++ b/thirdparty/grx249/src/bgi/getx.c @@ -0,0 +1,29 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int __gr_getx(void) { + return getx(); +} diff --git a/thirdparty/grx249/src/bgi/getx.lo b/thirdparty/grx249/src/bgi/getx.lo new file mode 100644 index 0000000..9766713 Binary files /dev/null and b/thirdparty/grx249/src/bgi/getx.lo differ diff --git a/thirdparty/grx249/src/bgi/gety.c b/thirdparty/grx249/src/bgi/gety.c new file mode 100644 index 0000000..8396a45 --- /dev/null +++ b/thirdparty/grx249/src/bgi/gety.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +int __gr_gety(void) { + return gety(); +} diff --git a/thirdparty/grx249/src/bgi/gety.lo b/thirdparty/grx249/src/bgi/gety.lo new file mode 100644 index 0000000..de7a0a6 Binary files /dev/null and b/thirdparty/grx249/src/bgi/gety.lo differ diff --git a/thirdparty/grx249/src/bgi/gmaxcol.c b/thirdparty/grx249/src/bgi/gmaxcol.c new file mode 100644 index 0000000..c83605d --- /dev/null +++ b/thirdparty/grx249/src/bgi/gmaxcol.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int getmaxcolor(void) { + _DO_INIT_CHECK_RV(0); + return GrNumColors()-1; +} diff --git a/thirdparty/grx249/src/bgi/gmaxcol.lo b/thirdparty/grx249/src/bgi/gmaxcol.lo new file mode 100644 index 0000000..368d116 Binary files /dev/null and b/thirdparty/grx249/src/bgi/gmaxcol.lo differ diff --git a/thirdparty/grx249/src/bgi/gmmaxcol.c b/thirdparty/grx249/src/bgi/gmmaxcol.c new file mode 100644 index 0000000..4493a3a --- /dev/null +++ b/thirdparty/grx249/src/bgi/gmmaxcol.c @@ -0,0 +1,43 @@ +/* + * BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + * Copyright (C) 1993-97 by Hartmut Schirmer + * + * This library is copyrighted (see above). It might be used and + * distributed freely as long as all copyright notices are left + * intact. + * + * You may not distribute any changed versions of BCC2GRX without + * written permission by Hartmut Schirmer. + * + * You are permitted to distribute an application linked with BCC2GRX + * in binary only, provided that the documentation of the program: + * + * a) informs the user that BCC2GRX is used in the program, AND + * + * b) provides the user with the necessary information about + * how to obtain BCC2GRX. (i.e. ftp site, etc..) + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Contact : Hartmut Schirmer + * Feldstrasse 118 + * D-24105 Kiel + * Germany + * + * e-mail : hsc@techfak.uni-kiel.de + */ + +#include "bccgrx00.h" + +int __gr_getmodemaxcolor(int mode) { + int w, h; + long c; + _DO_INIT_CHECK_RV(-1); + if (!__gr_getmode_whc(mode, &w, &h, &c)) { + ERR = grInvalidMode; + return -1; + } + return (int)(c-1); +} diff --git a/thirdparty/grx249/src/bgi/gmmaxcol.lo b/thirdparty/grx249/src/bgi/gmmaxcol.lo new file mode 100644 index 0000000..f96284a Binary files /dev/null and b/thirdparty/grx249/src/bgi/gmmaxcol.lo differ diff --git a/thirdparty/grx249/src/bgi/gmmaxx.c b/thirdparty/grx249/src/bgi/gmmaxx.c new file mode 100644 index 0000000..d1cb74b --- /dev/null +++ b/thirdparty/grx249/src/bgi/gmmaxx.c @@ -0,0 +1,36 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int __gr_getmodemaxx(int mode) { + int w, h; + long c; + _DO_INIT_CHECK_RV(-1); + if (!__gr_getmode_whc(mode, &w, &h, &c)) { + ERR = grInvalidMode; + return -1; + } + return (int)(w-1); +} diff --git a/thirdparty/grx249/src/bgi/gmmaxx.lo b/thirdparty/grx249/src/bgi/gmmaxx.lo new file mode 100644 index 0000000..a1f85b9 Binary files /dev/null and b/thirdparty/grx249/src/bgi/gmmaxx.lo differ diff --git a/thirdparty/grx249/src/bgi/gmmaxy.c b/thirdparty/grx249/src/bgi/gmmaxy.c new file mode 100644 index 0000000..d63c13e --- /dev/null +++ b/thirdparty/grx249/src/bgi/gmmaxy.c @@ -0,0 +1,36 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int __gr_getmodemaxy(int mode) { + int w, h; + long c; + _DO_INIT_CHECK_RV(-1); + if (!__gr_getmode_whc(mode, &w, &h, &c)) { + ERR = grInvalidMode; + return -1; + } + return (int)(h-1); +} diff --git a/thirdparty/grx249/src/bgi/gmmaxy.lo b/thirdparty/grx249/src/bgi/gmmaxy.lo new file mode 100644 index 0000000..8051211 Binary files /dev/null and b/thirdparty/grx249/src/bgi/gmmaxy.lo differ diff --git a/thirdparty/grx249/src/bgi/gpalsize.c b/thirdparty/grx249/src/bgi/gpalsize.c new file mode 100644 index 0000000..8ec3674 --- /dev/null +++ b/thirdparty/grx249/src/bgi/gpalsize.c @@ -0,0 +1,31 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int getpalettesize(void) { + __gr_set_up_modes(); + if (__gr_ADAPTER == GR_HERC) return 0; + else return 16; +} diff --git a/thirdparty/grx249/src/bgi/gpalsize.lo b/thirdparty/grx249/src/bgi/gpalsize.lo new file mode 100644 index 0000000..4118b4d Binary files /dev/null and b/thirdparty/grx249/src/bgi/gpalsize.lo differ diff --git a/thirdparty/grx249/src/bgi/graphres.c b/thirdparty/grx249/src/bgi/graphres.c new file mode 100644 index 0000000..3fe027b --- /dev/null +++ b/thirdparty/grx249/src/bgi/graphres.c @@ -0,0 +1,31 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int __gr_graphresult(void) { + int res = (__gr_INIT ? __gr_Result : grNoInitGraph); + __gr_Result = grOk; + return res; +} diff --git a/thirdparty/grx249/src/bgi/graphres.lo b/thirdparty/grx249/src/bgi/graphres.lo new file mode 100644 index 0000000..65f1f3e Binary files /dev/null and b/thirdparty/grx249/src/bgi/graphres.lo differ diff --git a/thirdparty/grx249/src/bgi/imagesze.c b/thirdparty/grx249/src/bgi/imagesze.c new file mode 100644 index 0000000..63e816a --- /dev/null +++ b/thirdparty/grx249/src/bgi/imagesze.c @@ -0,0 +1,41 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +unsigned imagesize(int left, int top, int right, int bottom) +{ + unsigned result; + int w, h; + + _DO_INIT_CHECK_RV(0); + w = __ABS(right-left)+1; + h = __ABS(bottom-top)+1; + result = GrContextSize( w, h); + if (result == 0) + return 0; + return result + IMAGE_CONTEXT_SIZE; +} + diff --git a/thirdparty/grx249/src/bgi/imagesze.lo b/thirdparty/grx249/src/bgi/imagesze.lo new file mode 100644 index 0000000..d5f869f Binary files /dev/null and b/thirdparty/grx249/src/bgi/imagesze.lo differ diff --git a/thirdparty/grx249/src/bgi/instbgid.c b/thirdparty/grx249/src/bgi/instbgid.c new file mode 100644 index 0000000..e61821a --- /dev/null +++ b/thirdparty/grx249/src/bgi/instbgid.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +int __gr_installbgidriver(char *name, void *detect) { + return grError; +} diff --git a/thirdparty/grx249/src/bgi/instbgid.lo b/thirdparty/grx249/src/bgi/instbgid.lo new file mode 100644 index 0000000..1b85e27 Binary files /dev/null and b/thirdparty/grx249/src/bgi/instbgid.lo differ diff --git a/thirdparty/grx249/src/bgi/lineb.c b/thirdparty/grx249/src/bgi/lineb.c new file mode 100644 index 0000000..eeacd71 --- /dev/null +++ b/thirdparty/grx249/src/bgi/lineb.c @@ -0,0 +1,45 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_line(int x1, int y1, int x2, int y2) +{ + _DO_INIT_CHECK; + moveto( x2, y2); + x1 += VL; x2 += VL; + y1 += VT+PY; y2 += VT+PY; + if (__gr_lstyle == SOLID_LINE && LNE.lno_width == 1) { + if (y1==y2) + GrHLine(x1, x2, y1, COL|WR); + else + if (x1==x2) + GrVLine(x1, y1, y2, COL|WR); + else + GrLine( x1, y1, x2, y2, COL|WR); + } else { + LNE.lno_color= COL|WR; + GrCustomLine( x1, y1, x2, y2, &LNE); + } +} diff --git a/thirdparty/grx249/src/bgi/lineb.lo b/thirdparty/grx249/src/bgi/lineb.lo new file mode 100644 index 0000000..53dd214 Binary files /dev/null and b/thirdparty/grx249/src/bgi/lineb.lo differ diff --git a/thirdparty/grx249/src/bgi/linerel.c b/thirdparty/grx249/src/bgi/linerel.c new file mode 100644 index 0000000..56e3b16 --- /dev/null +++ b/thirdparty/grx249/src/bgi/linerel.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void __gr_linerel(int dx, int dy) { + linerel( dx, dy); +} diff --git a/thirdparty/grx249/src/bgi/linerel.lo b/thirdparty/grx249/src/bgi/linerel.lo new file mode 100644 index 0000000..9065427 Binary files /dev/null and b/thirdparty/grx249/src/bgi/linerel.lo differ diff --git a/thirdparty/grx249/src/bgi/lineto.c b/thirdparty/grx249/src/bgi/lineto.c new file mode 100644 index 0000000..62e9c22 --- /dev/null +++ b/thirdparty/grx249/src/bgi/lineto.c @@ -0,0 +1,29 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_lineto(int x, int y) { + lineto( x, y); +} diff --git a/thirdparty/grx249/src/bgi/lineto.lo b/thirdparty/grx249/src/bgi/lineto.lo new file mode 100644 index 0000000..70e0a65 Binary files /dev/null and b/thirdparty/grx249/src/bgi/lineto.lo differ diff --git a/thirdparty/grx249/src/bgi/linkall.c b/thirdparty/grx249/src/bgi/linkall.c new file mode 100644 index 0000000..06988fb --- /dev/null +++ b/thirdparty/grx249/src/bgi/linkall.c @@ -0,0 +1,6 @@ +#include "libbcc.h" + +int main(void) { + printf("Do nothing DUMMY !\n"); + return 0; +} diff --git a/thirdparty/grx249/src/bgi/lnestyle.c b/thirdparty/grx249/src/bgi/lnestyle.c new file mode 100644 index 0000000..bd573d1 --- /dev/null +++ b/thirdparty/grx249/src/bgi/lnestyle.c @@ -0,0 +1,98 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +static unsigned short usr_pat = 0x0000; + +#define user_len (2*16+1) +static unsigned char user[user_len]; + +void getlinesettings(struct linesettingstype *lineinfo) +{ + _DO_INIT_CHECK; + lineinfo->linestyle = __gr_lstyle; + lineinfo->upattern = usr_pat; + lineinfo->thickness = LNE.lno_width; +} + +/* ----------------------------------------------------------------- */ +void setlinestyle(int linestyle, unsigned upattern, int thickness) +{ + int i, j; + + _DO_INIT_CHECK; + switch (linestyle) { + case SOLID_LINE : LNE.lno_pattlen = 0; + LNE.lno_dashpat = NULL; + break; + case DOTTED_LINE : LNE.lno_pattlen = 4; + LNE.lno_dashpat = "\0\2\2\0"; + break; + case CENTER_LINE : LNE.lno_pattlen = 6; + LNE.lno_dashpat = "\0\3\4\3\6\0"; + break; + case DASHED_LINE : LNE.lno_pattlen = 6; + LNE.lno_dashpat = "\0\3\5\3\5\0"; + break; + case USERBIT_LINE: usr_pat = upattern; + if (upattern == 0xFFFF) { + LNE.lno_pattlen = 0; + LNE.lno_dashpat = NULL; + break; + } + j = 0; + user[0] = 0; + for (i=0; i < 16; ++i) { + if ( (upattern & 1) == 0) { + if ( (j&1) == 0) { + ++j; + user[j] = 0; + } + ++user[j]; + } else { + if ( (j&1) != 0) { + ++j; + user[j] = 0; + } + ++user[j]; + } + upattern >>= 1; + } +#ifdef GRX_VERSION + if (j==1 && user[0]==0) + j = 0; + else +#endif + if ( (j&1) == 0) + user[++j] = 0; + LNE.lno_pattlen = j+1; + LNE.lno_dashpat = user; + break; + default : ERR = grError; + return; + } + __gr_lstyle = linestyle; + LNE.lno_width = thickness; +} diff --git a/thirdparty/grx249/src/bgi/lnestyle.lo b/thirdparty/grx249/src/bgi/lnestyle.lo new file mode 100644 index 0000000..c8edadb Binary files /dev/null and b/thirdparty/grx249/src/bgi/lnestyle.lo differ diff --git a/thirdparty/grx249/src/bgi/modename.c b/thirdparty/grx249/src/bgi/modename.c new file mode 100644 index 0000000..0a831a2 --- /dev/null +++ b/thirdparty/grx249/src/bgi/modename.c @@ -0,0 +1,59 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" +#include + +char *getmodename(int mode_number) +{ + static char result[50]; + char cols[20]; + int xw, yw; + long nc; + +/* _DO_INIT_CHECK_RV(NULL); */ + __gr_set_up_modes(); + if (mode_number < 0 || mode_number > MM) { + ERR = grInvalidMode; + return NULL; + } + switch (mode_number) { + case GRX_DEFAULT_GRAPHICS : return "default graphics mode"; + case GRX_BIGGEST_NONINTERLACED_GRAPHICS : return "biggest non interlaced graphics mode"; + case GRX_BIGGEST_GRAPHICS : return "biggest graphics mode"; + case GRX_BGI_EMULATION : return "BGI emulation mode"; + } + if (!__gr_getmode_whc(mode_number, &xw, &yw, &nc)) + return NULL; + switch (nc) { + case 1L<<15 : strcpy(cols,"32K"); break; + case 1L<<16 : strcpy(cols,"64K"); break; + case 1L<<24 : strcpy(cols,"16M"); break; + default : sprintf(cols, "%ld", nc); + break; + } + sprintf(result, "%d x %d x %s", xw, yw, cols); + return result; +} + diff --git a/thirdparty/grx249/src/bgi/modename.lo b/thirdparty/grx249/src/bgi/modename.lo new file mode 100644 index 0000000..b600da8 Binary files /dev/null and b/thirdparty/grx249/src/bgi/modename.lo differ diff --git a/thirdparty/grx249/src/bgi/moverel.c b/thirdparty/grx249/src/bgi/moverel.c new file mode 100644 index 0000000..95a6d64 --- /dev/null +++ b/thirdparty/grx249/src/bgi/moverel.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void __gr_moverel(int dx, int dy) { + moverel( dx, dy); +} diff --git a/thirdparty/grx249/src/bgi/moverel.lo b/thirdparty/grx249/src/bgi/moverel.lo new file mode 100644 index 0000000..c76ca0c Binary files /dev/null and b/thirdparty/grx249/src/bgi/moverel.lo differ diff --git a/thirdparty/grx249/src/bgi/moveto.c b/thirdparty/grx249/src/bgi/moveto.c new file mode 100644 index 0000000..48610c7 --- /dev/null +++ b/thirdparty/grx249/src/bgi/moveto.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void __gr_moveto(int x, int y) { + moveto(x, y); +} diff --git a/thirdparty/grx249/src/bgi/moveto.lo b/thirdparty/grx249/src/bgi/moveto.lo new file mode 100644 index 0000000..8d9cddf Binary files /dev/null and b/thirdparty/grx249/src/bgi/moveto.lo differ diff --git a/thirdparty/grx249/src/bgi/page1.c b/thirdparty/grx249/src/bgi/page1.c new file mode 100644 index 0000000..d60bf68 --- /dev/null +++ b/thirdparty/grx249/src/bgi/page1.c @@ -0,0 +1,34 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int __gr_get_BGI_mode_pages(void) { +#ifdef GRX_VERSION + return __gr_BGI_p; +#else + return 1; +#endif +} + diff --git a/thirdparty/grx249/src/bgi/page1.lo b/thirdparty/grx249/src/bgi/page1.lo new file mode 100644 index 0000000..d63e61d Binary files /dev/null and b/thirdparty/grx249/src/bgi/page1.lo differ diff --git a/thirdparty/grx249/src/bgi/page2.c b/thirdparty/grx249/src/bgi/page2.c new file mode 100644 index 0000000..2c7afd1 --- /dev/null +++ b/thirdparty/grx249/src/bgi/page2.c @@ -0,0 +1,32 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_set_BGI_mode_pages(int p) { +#ifdef GRX_VERSION + __gr_BGI_p = (p>1) ? 2 : 1; +#endif +} + diff --git a/thirdparty/grx249/src/bgi/page2.lo b/thirdparty/grx249/src/bgi/page2.lo new file mode 100644 index 0000000..fd626e7 Binary files /dev/null and b/thirdparty/grx249/src/bgi/page2.lo differ diff --git a/thirdparty/grx249/src/bgi/page3.c b/thirdparty/grx249/src/bgi/page3.c new file mode 100644 index 0000000..72ff599 --- /dev/null +++ b/thirdparty/grx249/src/bgi/page3.c @@ -0,0 +1,37 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_setvisualpage(int p) { +#ifdef GRX_VERSION + _DO_INIT_CHECK; + if (p < 0 || p >= __gr_BGI_p) { + ERR = grError; + return; + } + if (p!=0) GrSetViewport(0, GrScreenY()); + else GrSetViewport(0, 0); +#endif +} diff --git a/thirdparty/grx249/src/bgi/page3.lo b/thirdparty/grx249/src/bgi/page3.lo new file mode 100644 index 0000000..b6977a9 Binary files /dev/null and b/thirdparty/grx249/src/bgi/page3.lo differ diff --git a/thirdparty/grx249/src/bgi/page4.c b/thirdparty/grx249/src/bgi/page4.c new file mode 100644 index 0000000..9e8e379 --- /dev/null +++ b/thirdparty/grx249/src/bgi/page4.c @@ -0,0 +1,34 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int __gr_getvisualpage(void) { +#ifdef GRX_VERSION + _DO_INIT_CHECK_RV(0); + return GrVirtualY() ? 1 : 0; +#else + return 0; +#endif +} diff --git a/thirdparty/grx249/src/bgi/page4.lo b/thirdparty/grx249/src/bgi/page4.lo new file mode 100644 index 0000000..7ef556f Binary files /dev/null and b/thirdparty/grx249/src/bgi/page4.lo differ diff --git a/thirdparty/grx249/src/bgi/page5.c b/thirdparty/grx249/src/bgi/page5.c new file mode 100644 index 0000000..14bebd5 --- /dev/null +++ b/thirdparty/grx249/src/bgi/page5.c @@ -0,0 +1,39 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_setactivepage(int p) { +#ifdef GRX_VERSION + _DO_INIT_CHECK; + if (p < 0 || p >= __gr_BGI_p) { + ERR = grError; + return; + } + if (p!=0) PY = GrScreenY(); + else PY = 0; + __gr_Reset_ClipBox(); +#endif +} + diff --git a/thirdparty/grx249/src/bgi/page5.lo b/thirdparty/grx249/src/bgi/page5.lo new file mode 100644 index 0000000..75b50b3 Binary files /dev/null and b/thirdparty/grx249/src/bgi/page5.lo differ diff --git a/thirdparty/grx249/src/bgi/page6.c b/thirdparty/grx249/src/bgi/page6.c new file mode 100644 index 0000000..6e4b417 --- /dev/null +++ b/thirdparty/grx249/src/bgi/page6.c @@ -0,0 +1,35 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int __gr_getactivepage(void) { +#ifdef GRX_VERSION + _DO_INIT_CHECK_RV(0); + return PY ? 1 : 0; +#else + return 0; +#endif +} + diff --git a/thirdparty/grx249/src/bgi/page6.lo b/thirdparty/grx249/src/bgi/page6.lo new file mode 100644 index 0000000..56cbf31 Binary files /dev/null and b/thirdparty/grx249/src/bgi/page6.lo differ diff --git a/thirdparty/grx249/src/bgi/palette.c b/thirdparty/grx249/src/bgi/palette.c new file mode 100644 index 0000000..d608a85 --- /dev/null +++ b/thirdparty/grx249/src/bgi/palette.c @@ -0,0 +1,86 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +#define DEFAULT_PALETTE \ + { /*size:*/16, \ + /*colors:*/ {EGA_BLACK, EGA_BLUE, EGA_GREEN, EGA_CYAN, EGA_RED, \ + EGA_MAGENTA, EGA_BROWN, EGA_LIGHTGRAY, EGA_DARKGRAY, \ + EGA_LIGHTBLUE, EGA_LIGHTGREEN, EGA_LIGHTCYAN, \ + EGA_LIGHTRED, EGA_LIGHTMAGENTA, EGA_YELLOW, EGA_WHITE} } + +struct palettetype __gr_EGAdef = DEFAULT_PALETTE; +static struct palettetype UsrPal = DEFAULT_PALETTE; + +/* ----------------------------------------------------------------- */ + +void __gr_setpalette(int colornum, int color) +{ +#ifdef __DJGPP__ +# include +//# include + _go32_dpmi_registers regs; + + _DO_INIT_CHECK; + colornum &= 0x0f; + color &= 0x3f; + UsrPal.colors[colornum] = color; + + memset(®s, 0, sizeof(regs)); + regs.x.ax = 0x1000; + regs.x.bx = colornum | (color << 8); + /* real mode interruts may be called by + _go32_dpmi_simulate_int() (v1 & v2) + and + __dpmi_simulate_real_mode_interrupt() (v2 only) + + Under v2 the _go32_dpmi_simulate_int is actually a macro + referencing __dpmi_simulate_real_mode_interrupt(). Undefining + this macro makes the library linkable under both DJGPP v1 and + v2 since there _is_ a compatible _go32_dpmi_simulate_int() in + the v2 library! Don't worry about the compiler warning here ! */ + #undef _go32_dpmi_simulate_int + _go32_dpmi_simulate_int(0x10,®s); +#endif +} +/* ----------------------------------------------------------------- */ +void getpalette(struct palettetype *palette) +{ + _DO_INIT_CHECK; + *palette = UsrPal; +} + +/* ----------------------------------------------------------------- */ +void setallpalette(const struct palettetype *palette) +{ + int i, col; + + _DO_INIT_CHECK; + if (palette == NULL) + return; + for (i=0; i < palette->size; ++i) + if ( (col = palette->colors[i]) >= 0) + __gr_setpalette( i, col); +} diff --git a/thirdparty/grx249/src/bgi/palette.lo b/thirdparty/grx249/src/bgi/palette.lo new file mode 100644 index 0000000..1dd71a2 Binary files /dev/null and b/thirdparty/grx249/src/bgi/palette.lo differ diff --git a/thirdparty/grx249/src/bgi/pieslice.c b/thirdparty/grx249/src/bgi/pieslice.c new file mode 100644 index 0000000..ded7f5b --- /dev/null +++ b/thirdparty/grx249/src/bgi/pieslice.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void __gr_pieslice(int x, int y, int stangle, int endangle, int radius) { + pieslice( x, y, stangle, endangle, radius); +} diff --git a/thirdparty/grx249/src/bgi/pieslice.lo b/thirdparty/grx249/src/bgi/pieslice.lo new file mode 100644 index 0000000..535d741 Binary files /dev/null and b/thirdparty/grx249/src/bgi/pieslice.lo differ diff --git a/thirdparty/grx249/src/bgi/polygonb.c b/thirdparty/grx249/src/bgi/polygonb.c new file mode 100644 index 0000000..0ccf8fc --- /dev/null +++ b/thirdparty/grx249/src/bgi/polygonb.c @@ -0,0 +1,67 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* + - Take care : Borland C defines polypoints as int * but + - assumes struct pointtype * . + - GRX requires int points[][2] ! + - The good news are : Both definitions are compatible ! +*/ + +void __gr_drawpol(int numpoints, void *polypoints, int close) +{ + int *pp, x, y, sx, sy, nx, ny, fast; + + _DO_INIT_CHECK; + LNE.lno_color = COL|WR; + fast = (__gr_lstyle == SOLID_LINE) && (LNE.lno_width == 1); + pp = (int *)polypoints; + while (numpoints > 0) { + x = sx = *(pp++)+VL; + y = sy = *(pp++)+VT+PY; + --numpoints; + while (numpoints > 0) { + nx = *(pp++) + VL; + ny = *(pp++) + VT + PY; + if (fast) GrLine( x, y, nx, ny, LNE.lno_color); + else GrCustomLine( x, y, nx, ny, &LNE); + x = nx; y = ny; + --numpoints; + if ( x==sx && y==sy) + break; + } + if ( close && (x != sx || y != sy)) + { + if (fast) GrLine( x, y, sx, sy, LNE.lno_color); + else GrCustomLine( x, y, sx, sy, &LNE); + } + } +} + +void __gr_drawpoly(int numpoints, void *polypoints) { + drawpoly(numpoints, polypoints); +} + diff --git a/thirdparty/grx249/src/bgi/polygonb.lo b/thirdparty/grx249/src/bgi/polygonb.lo new file mode 100644 index 0000000..309023c Binary files /dev/null and b/thirdparty/grx249/src/bgi/polygonb.lo differ diff --git a/thirdparty/grx249/src/bgi/putimage.c b/thirdparty/grx249/src/bgi/putimage.c new file mode 100644 index 0000000..4b33912 --- /dev/null +++ b/thirdparty/grx249/src/bgi/putimage.c @@ -0,0 +1,62 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +static void invert_image (GrContext *gc) +{ + int i, j, psize = GrPlaneSize(gc->gc_xmax + 1,gc->gc_ymax + 1); + for (i = 0; i < 4; ++i) + { + char *p = gc->gc_baseaddr[i]; + if (p) + for (j = 0; j < psize; ++j) + p[j] ^= 0xff; + } +} + +void putimage(int left, int top, void *bitmap, int op) +{ + GrContext *gc; + GrColor gr_op; + + _DO_INIT_CHECK; + GrSetContext(NULL); + GrResetClipBox(); + gc = bitmap; + switch (op) { + case XOR_PUT : gr_op = GrXorModeColor(0); break; + case OR_PUT : gr_op = GrOrModeColor(0); break; + case AND_PUT : gr_op = GrAndModeColor(0); break; + default : gr_op = GrWriteModeColor(0); break; + } + if (op == NOT_PUT) + invert_image (gc); + GrBitBlt( NULL, left+VL, top+VT+PY, gc, 0, 0, gc->gc_xmax, gc->gc_ymax, gr_op); + if (op == NOT_PUT) + invert_image (gc); + __gr_Reset_ClipBox(); +} + diff --git a/thirdparty/grx249/src/bgi/putimage.lo b/thirdparty/grx249/src/bgi/putimage.lo new file mode 100644 index 0000000..b8141b9 Binary files /dev/null and b/thirdparty/grx249/src/bgi/putimage.lo differ diff --git a/thirdparty/grx249/src/bgi/putpixel.c b/thirdparty/grx249/src/bgi/putpixel.c new file mode 100644 index 0000000..a103ecf --- /dev/null +++ b/thirdparty/grx249/src/bgi/putpixel.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void putpixel(int x, int y, int color) { + _DO_INIT_CHECK; + GrPlot( x+VL, y+VT+PY, color); +} diff --git a/thirdparty/grx249/src/bgi/putpixel.lo b/thirdparty/grx249/src/bgi/putpixel.lo new file mode 100644 index 0000000..d4de2b3 Binary files /dev/null and b/thirdparty/grx249/src/bgi/putpixel.lo differ diff --git a/thirdparty/grx249/src/bgi/rectang.c b/thirdparty/grx249/src/bgi/rectang.c new file mode 100644 index 0000000..1f09c77 --- /dev/null +++ b/thirdparty/grx249/src/bgi/rectang.c @@ -0,0 +1,37 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void rectangle(int left, int top, int right, int bottom) +{ + _DO_INIT_CHECK; + if (__gr_lstyle == SOLID_LINE && LNE.lno_width == 1) + GrBox( left+VL, top+VT+PY, right+VL, bottom+VT+PY, COL|WR); + else { + LNE.lno_color = COL|WR; + GrCustomBox( left+VL, top+VT+PY, right+VL, bottom+VT+PY, &__gr_Line); + } +} + diff --git a/thirdparty/grx249/src/bgi/rectang.lo b/thirdparty/grx249/src/bgi/rectang.lo new file mode 100644 index 0000000..6746df0 Binary files /dev/null and b/thirdparty/grx249/src/bgi/rectang.lo differ diff --git a/thirdparty/grx249/src/bgi/regbgidr.c b/thirdparty/grx249/src/bgi/regbgidr.c new file mode 100644 index 0000000..4b928c3 --- /dev/null +++ b/thirdparty/grx249/src/bgi/regbgidr.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +int __gr_registerfarbgidriver(void *driver) { + return grError; +} diff --git a/thirdparty/grx249/src/bgi/regbgidr.lo b/thirdparty/grx249/src/bgi/regbgidr.lo new file mode 100644 index 0000000..f07ea73 Binary files /dev/null and b/thirdparty/grx249/src/bgi/regbgidr.lo differ diff --git a/thirdparty/grx249/src/bgi/rgbpal_g.c b/thirdparty/grx249/src/bgi/rgbpal_g.c new file mode 100644 index 0000000..e505c96 --- /dev/null +++ b/thirdparty/grx249/src/bgi/rgbpal_g.c @@ -0,0 +1,84 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +#if 0 +/* The following io routines were taken from Csaba Biegl's + GRX v2.0 source. Many thanks Csaba ! */ +#define __INLINE_LOW_PORT_TEST__(P) ( \ + (__builtin_constant_p((P))) && \ + ((unsigned)(P) < 0x100U) \ +) +#define inportb(P) ({ \ + register unsigned char _value; \ + if(__INLINE_LOW_PORT_TEST__(P)) __asm__ volatile( \ + "inb %1,%0" \ + : "=a" (_value) \ + : "n" ((unsigned short)(P)) \ + ); \ + else __asm__ volatile( \ + "inb %1,%0" \ + : "=a" (_value) \ + : "d" ((unsigned short)(P)) \ + ); \ + _value; \ +}) + +#define outportb(p,v) ({ \ + __asm__ volatile( \ + "outb %0,%1" \ + : /* no outputs */ \ + : "a" ((unsigned char)(v)), \ + "d" ((unsigned short)(p)) \ + ); \ +}) + +static volatile int dummy; + +#define WAIT() do { \ + dummy += inportb(0x80); \ +} while(0) + +void __getrgbpalette(int color, int *red, int *green, int *blue) { +#ifdef GO32 + _DO_INIT_CHECK; + WAIT(); + outportb(0x3c8, color&0xff); + WAIT(); + *red = inportb(0x3c9)<<2; + WAIT(); + *green = inportb(0x3c9)<<2; + WAIT(); + *blue = inportb(0x3c9)<<2; +#else + *red = *green = *blue = 0; +#endif +} + +#else +void __getrgbpalette(int color, int *red, int *green, int *blue) { + GrQueryColor(color,red,green,blue); +} +#endif diff --git a/thirdparty/grx249/src/bgi/rgbpal_g.lo b/thirdparty/grx249/src/bgi/rgbpal_g.lo new file mode 100644 index 0000000..da17036 Binary files /dev/null and b/thirdparty/grx249/src/bgi/rgbpal_g.lo differ diff --git a/thirdparty/grx249/src/bgi/rgbpal_s.c b/thirdparty/grx249/src/bgi/rgbpal_s.c new file mode 100644 index 0000000..59f80db --- /dev/null +++ b/thirdparty/grx249/src/bgi/rgbpal_s.c @@ -0,0 +1,36 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +#define SIX(a) ((a)&63) + +void setrgbpalette(int color, int red, int green, int blue) +{ + _DO_INIT_CHECK; + GrSetColor( color, SIX(red)<<2, SIX(green)<<2, SIX(blue)<<2); +#if defined(__WIN32__) && !defined(__SDL__) + GrSleep(5); /* yields for win32 driver which redraws whole screen */ +#endif +} diff --git a/thirdparty/grx249/src/bgi/rgbpal_s.lo b/thirdparty/grx249/src/bgi/rgbpal_s.lo new file mode 100644 index 0000000..2aea46c Binary files /dev/null and b/thirdparty/grx249/src/bgi/rgbpal_s.lo differ diff --git a/thirdparty/grx249/src/bgi/rstcrtmd.c b/thirdparty/grx249/src/bgi/rstcrtmd.c new file mode 100644 index 0000000..1508a4c --- /dev/null +++ b/thirdparty/grx249/src/bgi/rstcrtmd.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_restorecrtmode(void) { + GrSetMode(GR_default_text); +} + diff --git a/thirdparty/grx249/src/bgi/rstcrtmd.lo b/thirdparty/grx249/src/bgi/rstcrtmd.lo new file mode 100644 index 0000000..24e2a2e Binary files /dev/null and b/thirdparty/grx249/src/bgi/rstcrtmd.lo differ diff --git a/thirdparty/grx249/src/bgi/sector.c b/thirdparty/grx249/src/bgi/sector.c new file mode 100644 index 0000000..54ed0ac --- /dev/null +++ b/thirdparty/grx249/src/bgi/sector.c @@ -0,0 +1,87 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +#ifdef GRX_VERSION +#define FilledEllipseArc(x,y,xr,yr,st,en,fi) \ + GrFilledEllipseArc(x,y,xr,yr,st,en,GR_ARC_STYLE_CLOSE2,fi) +#define PatternFilledEllipseArc(x,y,xr,yr,st,en,fp) \ + GrPatternFilledEllipseArc(x,y,xr,yr,st,en,GR_ARC_STYLE_CLOSE2,fp) +#define EllipseArc(x,y,xr,yr,st,en,co) \ + GrEllipseArc(x,y,xr,yr,st,en,GR_ARC_STYLE_CLOSE2,co) +#else +#define FilledEllipseArc GrFilledEllipseArc +#define PatternFilledEllipseArc GrPatternFilledEllipseArc +#define EllipseArc GrEllipseArc +#endif + +void __gr_sector(int x,int y,int stangle,int endangle,int xradius,int yradius) +{ + _DO_INIT_CHECK; + x += VL; + y += VT + PY; + stangle *= 10; + endangle *= 10; + xradius = XR(xradius); + yradius = YR(yradius); + switch (FPATT) { + case SOLID_FILL : + FilledEllipseArc(x,y,xradius,yradius,stangle,endangle, FILL); + if (COL != FILL) + goto frame; + break; + case EMPTY_FILL : + FilledEllipseArc(x,y,xradius,yradius,stangle,endangle, COLBG); + if (COL != COLBG) + goto frame; + break; + default : + FILLP.gp_bmp_fgcolor = FILL; + FILLP.gp_bmp_bgcolor = COLBG; + PatternFilledEllipseArc(x,y,xradius,yradius,stangle,endangle, &FILLP); +frame: + EllipseArc( x, y, xradius, yradius, stangle, endangle, COL); +#ifndef GRX_VERSION + { +#ifdef GR_DRV_VER_GRD + /* GRX 1.03 */ + int xs, ys, xc, yc, xe, ye; + GrGetLastArcCoords(&xs,&ys,&xe,&ye,&xc,&yc); +#else + /* GRX 1.02+ */ +# define xs _grx_arc_xs +# define ys _grx_arc_ys +# define xc _grx_arc_xc +# define yc _grx_arc_yc +# define xe _grx_arc_xe +# define ye _grx_arc_ye +#endif + GrLine( xs, ys, xc, yc, COL); + GrLine( xc, yc, xe, ye, COL); + } +#endif + break; + } +} diff --git a/thirdparty/grx249/src/bgi/sector.lo b/thirdparty/grx249/src/bgi/sector.lo new file mode 100644 index 0000000..5d12f04 Binary files /dev/null and b/thirdparty/grx249/src/bgi/sector.lo differ diff --git a/thirdparty/grx249/src/bgi/setbgiwh.c b/thirdparty/grx249/src/bgi/setbgiwh.c new file mode 100644 index 0000000..0244d26 --- /dev/null +++ b/thirdparty/grx249/src/bgi/setbgiwh.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_set_BGI_mode_whc(int *gd, int *gm, + int width, int height, int colors) { + set_BGI_mode_whc( gd, gm, width, height, colors); +} diff --git a/thirdparty/grx249/src/bgi/setbgiwh.lo b/thirdparty/grx249/src/bgi/setbgiwh.lo new file mode 100644 index 0000000..4e3f55a Binary files /dev/null and b/thirdparty/grx249/src/bgi/setbgiwh.lo differ diff --git a/thirdparty/grx249/src/bgi/setbkcol.c b/thirdparty/grx249/src/bgi/setbkcol.c new file mode 100644 index 0000000..1b750a7 --- /dev/null +++ b/thirdparty/grx249/src/bgi/setbkcol.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void __gr_setbkcolor(int color) { + setbkcolor(color); +} diff --git a/thirdparty/grx249/src/bgi/setbkcol.lo b/thirdparty/grx249/src/bgi/setbkcol.lo new file mode 100644 index 0000000..8dfd721 Binary files /dev/null and b/thirdparty/grx249/src/bgi/setbkcol.lo differ diff --git a/thirdparty/grx249/src/bgi/setbusze.c b/thirdparty/grx249/src/bgi/setbusze.c new file mode 100644 index 0000000..6e83b93 --- /dev/null +++ b/thirdparty/grx249/src/bgi/setbusze.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +unsigned __gr_setgraphbufsize(unsigned bufsize) { + return 4096; /* BCC default value */ +} diff --git a/thirdparty/grx249/src/bgi/setbusze.lo b/thirdparty/grx249/src/bgi/setbusze.lo new file mode 100644 index 0000000..6b5e076 Binary files /dev/null and b/thirdparty/grx249/src/bgi/setbusze.lo differ diff --git a/thirdparty/grx249/src/bgi/setcolor.c b/thirdparty/grx249/src/bgi/setcolor.c new file mode 100644 index 0000000..bfbd3ca --- /dev/null +++ b/thirdparty/grx249/src/bgi/setcolor.c @@ -0,0 +1,30 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +/* ----------------------------------------------------------------- */ +void __gr_setcolor(int color) { + setcolor(color); +} diff --git a/thirdparty/grx249/src/bgi/setcolor.lo b/thirdparty/grx249/src/bgi/setcolor.lo new file mode 100644 index 0000000..5bdd83f Binary files /dev/null and b/thirdparty/grx249/src/bgi/setcolor.lo differ diff --git a/thirdparty/grx249/src/bgi/setrgbc.c b/thirdparty/grx249/src/bgi/setrgbc.c new file mode 100644 index 0000000..9accaab --- /dev/null +++ b/thirdparty/grx249/src/bgi/setrgbc.c @@ -0,0 +1,46 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +int __gr_setrgbcolor(int r, int g, int b) { +#ifdef GRX_VERSION + COL = (int) GrBuildRGBcolorT(r,g,b); + return COL; +#else + switch (GrNumColors()) { + case 1<<15 : return COL = ((r&0xf8)<<7) + | ((g&0xf8)<<2) + | ((b&0xf8)>>3); + case 1<<16 : return COL = ((r&0xf8)<<8) + | ((g&0xfc)<<3) + | ((b&0xf8)>>3); + case 1<<24 : return COL = ((r&0xff)<<16) + | ((g&0xff)<< 8) + | ((b&0xff) ); + } + ERR = grError; + return -1; +#endif +} diff --git a/thirdparty/grx249/src/bgi/setrgbc.lo b/thirdparty/grx249/src/bgi/setrgbc.lo new file mode 100644 index 0000000..0223284 Binary files /dev/null and b/thirdparty/grx249/src/bgi/setrgbc.lo differ diff --git a/thirdparty/grx249/src/bgi/setviewp.c b/thirdparty/grx249/src/bgi/setviewp.c new file mode 100644 index 0000000..b4da3b8 --- /dev/null +++ b/thirdparty/grx249/src/bgi/setviewp.c @@ -0,0 +1,46 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void setviewport(int left, int top, int right, int bottom, int clip) +{ + int mm; + + _DO_INIT_CHECK; + GrSetContext( NULL); /* ViewPort == Full screen */ + if (left > right) SWAP(int,left,right); + if (bottom < top) SWAP(int,bottom,top); + if (left < 0) left = 0; + if (right > (mm=getmaxx())) right = mm; + if (top < 0) top = 0; + if (bottom > (mm=getmaxy())) bottom = mm; + __gr_clip = clip; + VL = left; + VR = right; + VT = top; + VB = bottom; + __gr_Reset_ClipBox(); + moveto( 0,0); +} diff --git a/thirdparty/grx249/src/bgi/setviewp.lo b/thirdparty/grx249/src/bgi/setviewp.lo new file mode 100644 index 0000000..cbd6fc6 Binary files /dev/null and b/thirdparty/grx249/src/bgi/setviewp.lo differ diff --git a/thirdparty/grx249/src/bgi/setwrmod.c b/thirdparty/grx249/src/bgi/setwrmod.c new file mode 100644 index 0000000..22af8b5 --- /dev/null +++ b/thirdparty/grx249/src/bgi/setwrmod.c @@ -0,0 +1,37 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void setwritemode( int mode ) { + switch (mode) { + case XOR_PUT : WR = GrXorModeColor(0); break; + case OR_PUT : WR = GrOrModeColor(0); break; + case AND_PUT : WR = GrAndModeColor(0); break; +/* case NOT_PUT : not available */ + case COPY_PUT : + default : WR = GrWriteModeColor(0); break; + } +} + diff --git a/thirdparty/grx249/src/bgi/setwrmod.lo b/thirdparty/grx249/src/bgi/setwrmod.lo new file mode 100644 index 0000000..14d05f5 Binary files /dev/null and b/thirdparty/grx249/src/bgi/setwrmod.lo differ diff --git a/thirdparty/grx249/src/bgi/text.c b/thirdparty/grx249/src/bgi/text.c new file mode 100644 index 0000000..bce1539 --- /dev/null +++ b/thirdparty/grx249/src/bgi/text.c @@ -0,0 +1,84 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +CharInfo *fntptr = NULL; +char *StdFonts[BOLD_FONT+1] = { + "", "TRIP.CHR", "LITT.CHR", "SANS.CHR", "GOTH.CHR", "SCRI.CHR", + "SIMP.CHR", "TSCR.CHR", "LCOM.CHR", "EURO.CHR", "BOLD.CHR" }; + +int __gr_text_height; +int __gr_text_multx, __gr_text_divx, + __gr_text_multy, __gr_text_divy; +int __gr_text_usr_multx=1, __gr_text_usr_divx=1, + __gr_text_usr_multy=1, __gr_text_usr_divy=1; + +void *Fonts[NrFonts]; +struct textsettingstype __gr_text_setting; +GrTextOption Style; + +#ifdef GRX_VERSION +GrFont *DefaultFonts[11]; +#endif + + +void __gr_text_init(void) +{ + static int Init = FALSE; + int i; + + if (Init) return; + for (i=0; i < NrFonts; ++i) + Fonts[i] = NULL; + +#ifdef GRX_VERSION + for (i=2; i < sizeof(DefaultFonts)/sizeof(GrFont *); ++i) + DefaultFonts[i] = NULL; + Fonts[DEFAULT_FONT] = + DefaultFonts[0] = + DefaultFonts[1] = + #ifdef LOAD_8x8_FONT + Fonts[DEFAULT_FONT] = (void *) GrLoadFont("pc8x8.fnt"); + #else + &GrFont_PC8x8; + #endif +#else + Fonts[DEFAULT_FONT] = (void *) GrLoadFont("@:pc8x8.fnt"); +#endif + Style.txo_font = (GrFont *)Fonts[DEFAULT_FONT]; + Style.txo_chrtype = GR_BYTE_TEXT; + + TXT.font = DEFAULT_FONT; + TXT.direction = HORIZ_DIR; + TXT.charsize = 1; + TXT.horiz = LEFT_TEXT; + TXT.vert = TOP_TEXT; + __gr_text_usr_multx = __gr_text_usr_divx = + __gr_text_usr_multy = __gr_text_usr_divy = + __gr_text_multx = __gr_text_divx = + __gr_text_multy = __gr_text_divy = 1; + + Init = TRUE; +} diff --git a/thirdparty/grx249/src/bgi/text.h b/thirdparty/grx249/src/bgi/text.h new file mode 100644 index 0000000..051b5ff --- /dev/null +++ b/thirdparty/grx249/src/bgi/text.h @@ -0,0 +1,139 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __BCC2GRX_TEXT_H__ +#define __BCC2GRX_TEXT_H__ + +#include +#include +#include + +typedef unsigned char uchar; +typedef signed char schar; +typedef unsigned short _ushort; + +#if defined(__TURBOC__) || (defined(_MSC_VER) && defined(_WIN32)) +#include +#else +#include +#endif +#include "bccgrx00.h" + +#define FirstUserFont 11 +#define LastUserFont (FirstUserFont+9) +#define FirstGrxFont (LastUserFont+1) +#define LastGrxFont (FirstGrxFont+9) +#define NrFonts (LastGrxFont+1) +#define PreSkip 0x080 + +#ifdef __GNUC__ +#define ZERO2ONE(chrsze) ((chrsze) ? : 1) +#else +#define ZERO2ONE(chrsze) ((chrsze) ? (chrsze) : 1) +#endif + +#define BITMAP(f) ((f)==DEFAULT_FONT || ((f)>=FirstGrxFont && (f)<=LastGrxFont)) + +typedef struct { + uchar width; + _ushort *cmd; +} CharInfo; + +/* -------------------------------------------------------------- */ + +typedef char FontNameTyp[4]; + +#ifdef __GNUC__ +#define PACKED __attribute ((packed)) +#elif defined(_MSC_VER) +#pragma pack(push,1) +#endif + +#ifndef PACKED +#define PACKED +#endif + +typedef struct FontFileHeader { + _ushort header_size PACKED; /* Version 2.0 Header Format */ + FontNameTyp font_name PACKED; /* Font Internal Name */ + _ushort font_size PACKED; /* filesize in byte */ + uchar font_major PACKED, /* Driver Version Information */ + font_minor PACKED; + uchar min_major PACKED, /* BGI Revision Information */ + min_minor PACKED; +} FontFileHeader; + +typedef struct FontHeaderTyp { + char sig PACKED; /* SIGNATURE byte */ + _ushort nchrs PACKED; /* number of characters in file */ + char unused1 PACKED; /* Currently Undefined */ + uchar firstch PACKED; /* first character in file */ + _ushort cdefs PACKED; /* offset to char definitions */ + uchar scan_flag PACKED; /* <> 0 if set is scanable */ + uchar org_to_cap PACKED; /* Height from origin to top of capitol */ + uchar org_to_base PACKED; /* Height from origin to baseline */ + schar org_to_dec PACKED; /* Height from origin to bot of decender */ + uchar unused2[0x5] PACKED; /* Currently undefined */ +} FontHeaderTyp; + +#undef PACKED +#if defined(_MSC_VER) +#pragma pack(pop) +#endif + +extern int __gr_text_height; +extern int __gr_text_multx, __gr_text_divx, + __gr_text_multy, __gr_text_divy; +extern int __gr_text_usr_multx, __gr_text_usr_divx, + __gr_text_usr_multy, __gr_text_usr_divy; + +extern void *__gr_text_Fonts[]; +#define Fonts __gr_text_Fonts +extern CharInfo *__gr_text_fntptr; +#define fntptr __gr_text_fntptr +extern char *__gr_text_StdFonts[]; +#define StdFonts __gr_text_StdFonts + +extern GrTextOption __gr_text_style; +#define Style __gr_text_style + +extern struct textsettingstype __gr_text_setting; +#define TXT __gr_text_setting + +#ifdef GRX_VERSION +extern GrFont *__gr_text_DefaultFonts[11]; +#define DefaultFonts __gr_text_DefaultFonts +#endif + +extern void __gr_text_init(void); +extern void __gr_text_vec(int *xx, int *yy, int XX, int YY, int len, uchar *textstring); +extern void __gr_text_bit(GrFont *fnt, int *xx, int *yy, int XX, int YY, int len, uchar *txt); +extern int __gr_text_ChrFontInfo(void *Font, CharInfo *fntptr, int *height); +extern int __gr_text_registerfont( int start, int stop, void *font); +extern int __gr_text_installfont( int start, int stop, const char *name); + +extern int __gr_text_Width(int len, const char *txt); +extern int __gr_text_Height(int len, const char *txt); + +#endif diff --git a/thirdparty/grx249/src/bgi/text.lo b/thirdparty/grx249/src/bgi/text.lo new file mode 100644 index 0000000..30992bd Binary files /dev/null and b/thirdparty/grx249/src/bgi/text.lo differ diff --git a/thirdparty/grx249/src/bgi/text1.c b/thirdparty/grx249/src/bgi/text1.c new file mode 100644 index 0000000..e6d0347 --- /dev/null +++ b/thirdparty/grx249/src/bgi/text1.c @@ -0,0 +1,115 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + + +/* -------------------------------------------------------------- */ + +int __gr_text_registerfont( int start, int stop, void *font) +{ + int i; + char *Header; + char *name; + + __gr_text_init(); + Header = (char *)font + PreSkip; + if ( memcmp( font, "PK\x8\x8",4)!=0 || *Header != '+') + return grInvalidFont; + + name = (char *) font; + while (*name != '\x1a') { + if ( name-(char *)font > 128) + return grInvalidFont; + ++name; + } + name += 3; + + for (i=1; i <= BOLD_FONT; ++i) + if (memcmp( name, StdFonts[i], 4) == 0) + break; + if (i > BOLD_FONT) { + i = start; + while ( i <= stop && Fonts[i] != NULL) + ++i; + if (i > stop) + return grNoFontMem; + } + Fonts[i] = font; + return i; +} + +int __gr_text_installfont( int start, int stop, const char *name) +{ + FILE *ff; + long size; + void *font; + int res; + char *temp = alloca(strlen(name)+1+4); + char *temp1; + +#ifdef __linux__ +# define CHG_CHAR '\\' +# define NEW_CHAR '/' +#else +# define CHG_CHAR '/' +# define NEW_CHAR '\\' +#endif + + if (temp != NULL) { + int have_ext = FALSE; + strcpy(temp, name); + temp1 = temp; + while (*temp != '\0') { + if (*temp == CHG_CHAR) *temp = NEW_CHAR; + else *temp = (tolower)(*temp); + if (*temp == NEW_CHAR) have_ext = FALSE; + else have_ext |= *temp == '.'; + ++temp; + } + if (!have_ext) + strcat(temp1, ".chr"); + ff = fopen(temp1, "rb"); + } + else + ff = NULL; + + if (ff == NULL) + return grFileNotFound; + fseek( ff, 0, SEEK_END); + size = ftell(ff); + fseek( ff, 0, SEEK_SET); + font = malloc( (size_t) size); + if (font == NULL) { + fclose( ff); + return grNoFontMem; + } + fread( font, (size_t) size, 1, ff); + fclose( ff); + res = __gr_text_registerfont(start, stop, font); + if (res < 0) + free( font); + return res; +} + diff --git a/thirdparty/grx249/src/bgi/text1.lo b/thirdparty/grx249/src/bgi/text1.lo new file mode 100644 index 0000000..bc201c1 Binary files /dev/null and b/thirdparty/grx249/src/bgi/text1.lo differ diff --git a/thirdparty/grx249/src/bgi/text2.c b/thirdparty/grx249/src/bgi/text2.c new file mode 100644 index 0000000..cdc78e5 --- /dev/null +++ b/thirdparty/grx249/src/bgi/text2.c @@ -0,0 +1,56 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +static int GRX_textheight(int len, char *txt) { + Style.txo_font = (GrFont *)Fonts[TXT.font]; + Style.txo_direct = GR_TEXT_RIGHT; + return GrStringHeight(txt, len, &Style); +} + +/* ----------------------------------------------------------------- */ + +int textheight(const char *textstring) +{ + _DO_INIT_CHECK_RV(0); + __gr_text_init(); + if (TXT.font == DEFAULT_FONT) + return 8*ZERO2ONE(TXT.charsize); + if (TXT.font >= FirstGrxFont && TXT.font <= LastGrxFont) + return GRX_textheight(strlen(textstring), (char *) textstring); + return __gr_text_height * __gr_text_multy / __gr_text_divy; +} + +/* ----------------------------------------------------------------- */ + +int __gr_text_Height(int len, const char *txt) { + _DO_INIT_CHECK_RV(0); + __gr_text_init(); + if (TXT.font == DEFAULT_FONT) + return 8*ZERO2ONE(TXT.charsize); + if (TXT.font >= FirstGrxFont && TXT.font <= LastGrxFont) + return GRX_textheight(len, (char *) txt); + return __gr_text_height * __gr_text_multy / __gr_text_divy; +} diff --git a/thirdparty/grx249/src/bgi/text2.lo b/thirdparty/grx249/src/bgi/text2.lo new file mode 100644 index 0000000..808b01e Binary files /dev/null and b/thirdparty/grx249/src/bgi/text2.lo differ diff --git a/thirdparty/grx249/src/bgi/text3.c b/thirdparty/grx249/src/bgi/text3.c new file mode 100644 index 0000000..981b936 --- /dev/null +++ b/thirdparty/grx249/src/bgi/text3.c @@ -0,0 +1,50 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +/* ----------------------------------------------------------------- */ +int __gr_text_Width(int len, const char *txt) { + int sum; + + _DO_INIT_CHECK_RV(0); + __gr_text_init(); + if (TXT.font == DEFAULT_FONT) + return 8*ZERO2ONE(TXT.charsize) * len; + if (TXT.font >= FirstGrxFont && TXT.font <= LastGrxFont) { + Style.txo_font = (GrFont *)Fonts[TXT.font]; + Style.txo_direct = GR_TEXT_RIGHT; + return GrStringWidth((char *) txt, len, &Style); + } + sum = 0; + while (len-- > 0) + sum += fntptr[*((uchar *)txt++)].width * __gr_text_multx / __gr_text_divx; + return sum; +} + +/* ----------------------------------------------------------------- */ + +int textwidth( const char *textstring) { + return __gr_text_Width(strlen(textstring), textstring); +} diff --git a/thirdparty/grx249/src/bgi/text3.lo b/thirdparty/grx249/src/bgi/text3.lo new file mode 100644 index 0000000..d31468d Binary files /dev/null and b/thirdparty/grx249/src/bgi/text3.lo differ diff --git a/thirdparty/grx249/src/bgi/text4.c b/thirdparty/grx249/src/bgi/text4.c new file mode 100644 index 0000000..681f4df --- /dev/null +++ b/thirdparty/grx249/src/bgi/text4.c @@ -0,0 +1,128 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +/* ----------------------------------------------------------------- */ +#define xoff(x) ((int)(signed char)(((_ushort) (x)) << 1) >> 1) +#define yoff(y) (-((int)(signed char)(((_ushort) (y)) >> 7) >> 1)) + +/* ----------------------------------------------------------------- */ +void __gr_text_vec(int *xx, int *yy, int XX, int YY, int len, uchar *txt) +{ + if (__gr_TextLineStyle) + LNE.lno_color= COL|WR; + if (TXT.direction == HORIZ_DIR) { + int _XX, x, y, nx, ny, w; + _ushort *dc; + + switch (TXT.horiz) { + case CENTER_TEXT : XX -= __gr_text_Width(len, txt) / 2; break; + case RIGHT_TEXT : XX -= __gr_text_Width(len, txt); break; + default : break; + } + switch (TXT.vert) { + case CENTER_TEXT : YY += __gr_text_Height(len, txt) / 2; break; + case TOP_TEXT : YY += __gr_text_Height(len, txt); break; + default : break; + } + _XX = XX; + x = y = 0; + while (len-- > 0) { + w = fntptr[*txt].width; + dc = fntptr[*(txt++)].cmd; + while (dc != NULL) { + switch ( *dc & 0x8080) { + case 0x0000 : dc = NULL; + XX += w * __gr_text_multx / __gr_text_divx; + break; + case 0x8000 : /* DO_SCAN op, any font using this ? */ + ++dc; + break; + case 0x0080 : x = xoff(*dc) * __gr_text_multx / __gr_text_divx; + y = yoff(*dc) * __gr_text_multy / __gr_text_divy; + ++dc; + break; + case 0x8080 : nx = xoff(*dc) * __gr_text_multx / __gr_text_divx; + ny = yoff(*dc) * __gr_text_multy / __gr_text_divy; + if (__gr_TextLineStyle) + GrCustomLine( XX+x, YY+y, XX+nx, YY+ny, &LNE); + else + GrLine( XX+x, YY+y, XX+nx, YY+ny, COL); + x = nx; + y = ny; + ++dc; + break; + } + } + } + *xx += XX-_XX; + } else { + int _YY, x, y, nx, ny, w; + _ushort *dc; + + switch (TXT.horiz) { + case LEFT_TEXT : XX += __gr_text_Height(len, txt); break; + case CENTER_TEXT : XX += __gr_text_Height(len, txt) / 2; break; + default : break; + } + switch (TXT.vert) { + case CENTER_TEXT : YY += __gr_text_Width(len,txt) / 2; break; + case TOP_TEXT : YY += __gr_text_Width(len,txt); break; + default : break; + } + _YY = YY; + x = y = 0; + while (len-- > 0) { + w = fntptr[*txt].width; + dc = fntptr[*(txt++)].cmd; + while (dc != NULL) { + switch ( *dc & 0x8080) { + case 0x0000 : dc = NULL; + YY -= w * __gr_text_multx / __gr_text_divx; + break; + case 0x8000 : /* DO_SCAN op, any font using this ? */ + ++dc; + break; + case 0x0080 : y = -xoff(*dc) * __gr_text_multx / __gr_text_divx; + x = yoff(*dc) * __gr_text_multy / __gr_text_divy; + ++dc; + break; + case 0x8080 : ny = -xoff(*dc) * __gr_text_multx / __gr_text_divx; + nx = yoff(*dc) * __gr_text_multy / __gr_text_divy; + if (__gr_TextLineStyle) + GrCustomLine( XX+x, YY+y, XX+nx, YY+ny, &LNE); + else + GrLine( XX+x, YY+y, XX+nx, YY+ny, COL); + x = nx; + y = ny; + ++dc; + break; + } + } + } + *yy += YY-_YY; + } +} + diff --git a/thirdparty/grx249/src/bgi/text4.lo b/thirdparty/grx249/src/bgi/text4.lo new file mode 100644 index 0000000..ae7e34b Binary files /dev/null and b/thirdparty/grx249/src/bgi/text4.lo differ diff --git a/thirdparty/grx249/src/bgi/text5.c b/thirdparty/grx249/src/bgi/text5.c new file mode 100644 index 0000000..f72e29f --- /dev/null +++ b/thirdparty/grx249/src/bgi/text5.c @@ -0,0 +1,61 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +void __gr_text_bit(GrFont *fnt, int *xx, int *yy, int XX, int YY, + int len, uchar *txt) +{ + if ( (Style.txo_font = fnt) == NULL) { + ERR = grError; + return; + } +#ifndef GRX_VERSION + Style.txo_xmag = + Style.txo_ymag = ZERO2ONE( TXT.charsize); +#endif + Style.txo_fgcolor.v = COL; + Style.txo_bgcolor.v = GrNOCOLOR; + Style.txo_direct = (TXT.direction == HORIZ_DIR) ? GR_TEXT_RIGHT:GR_TEXT_UP; + switch (TXT.horiz) { + case LEFT_TEXT : Style.txo_xalign = GR_ALIGN_LEFT; break; + case RIGHT_TEXT : Style.txo_xalign = GR_ALIGN_RIGHT; break; + case CENTER_TEXT : + default : Style.txo_xalign = GR_ALIGN_CENTER; break; + } + switch (TXT.vert) { + case BOTTOM_TEXT : Style.txo_yalign = GR_ALIGN_BOTTOM; break; + case TOP_TEXT : Style.txo_yalign = GR_ALIGN_TOP; break; + case CENTER_TEXT : + default : Style.txo_yalign = GR_ALIGN_CENTER; break; + } + GrDrawString( txt, len, XX, YY, &Style); + if (TXT.direction == HORIZ_DIR) + *xx += GrStringWidth(txt, len, &Style); + else { + Style.txo_direct = GR_TEXT_RIGHT; + *yy -= GrStringWidth(txt,len, &Style); + } +} + diff --git a/thirdparty/grx249/src/bgi/text5.lo b/thirdparty/grx249/src/bgi/text5.lo new file mode 100644 index 0000000..8f5be9c Binary files /dev/null and b/thirdparty/grx249/src/bgi/text5.lo differ diff --git a/thirdparty/grx249/src/bgi/text6.c b/thirdparty/grx249/src/bgi/text6.c new file mode 100644 index 0000000..1cda9a5 --- /dev/null +++ b/thirdparty/grx249/src/bgi/text6.c @@ -0,0 +1,36 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +int registerbgifont(void *font) +{ + return __gr_text_registerfont( FirstUserFont, LastUserFont, font); +} + +/* ----------------------------------------------------------------- */ + +int __gr_registerfarbgifont(void *font) { + return registerfarbgifont(font); +} diff --git a/thirdparty/grx249/src/bgi/text6.lo b/thirdparty/grx249/src/bgi/text6.lo new file mode 100644 index 0000000..a022d4d Binary files /dev/null and b/thirdparty/grx249/src/bgi/text6.lo differ diff --git a/thirdparty/grx249/src/bgi/text7.c b/thirdparty/grx249/src/bgi/text7.c new file mode 100644 index 0000000..cb1e831 --- /dev/null +++ b/thirdparty/grx249/src/bgi/text7.c @@ -0,0 +1,65 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +static void _outtextxy(int *xx, int *yy, int XX, int YY, + int len, const uchar *textstring); + +/* ----------------------------------------------------------------- */ +void outtext(const char *textstring) +{ + _outtextxy(&X, &Y, X+VL, Y+VT+PY, strlen(textstring), (uchar *)textstring); +} + +/* ----------------------------------------------------------------- */ +void outtextxy(int x, int y, const char *textstring) +{ + _outtextxy( &x, &y, x+VL, y+VT+PY, strlen(textstring), (uchar *)textstring); +} + +/* ----------------------------------------------------------------- */ +static void _outtextxy(int *xx, int *yy, int XX, int YY, + int len, const uchar *textstring) +{ + _DO_INIT_CHECK; + __gr_text_init(); +#ifdef GRX_VERSION + if (TXT.font==DEFAULT_FONT) { + if (DefaultFonts[TXT.charsize] == NULL) + DefaultFonts[TXT.charsize] = + GrBuildConvertedFont( + DefaultFonts[1], + GR_FONTCVT_RESIZE, + 8*ZERO2ONE(TXT.charsize), + 8*ZERO2ONE(TXT.charsize), + 0, 0); + __gr_text_bit(DefaultFonts[TXT.charsize],xx,yy,XX,YY,len,(char *) textstring); + } else +#endif + if (BITMAP(TXT.font)) + __gr_text_bit((GrFont *)Fonts[TXT.font],xx,yy,XX,YY,len,(char *) textstring); + else + __gr_text_vec(xx,yy,XX,YY,len,(char *) textstring); +} diff --git a/thirdparty/grx249/src/bgi/text7.lo b/thirdparty/grx249/src/bgi/text7.lo new file mode 100644 index 0000000..a8feb0d Binary files /dev/null and b/thirdparty/grx249/src/bgi/text7.lo differ diff --git a/thirdparty/grx249/src/bgi/text8.c b/thirdparty/grx249/src/bgi/text8.c new file mode 100644 index 0000000..db6f2a1 --- /dev/null +++ b/thirdparty/grx249/src/bgi/text8.c @@ -0,0 +1,33 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +void gettextsettings(struct textsettingstype *texttypeinfo) +{ + _DO_INIT_CHECK; + __gr_text_init(); + memcpy( texttypeinfo, &TXT, sizeof(TXT)); +} + diff --git a/thirdparty/grx249/src/bgi/text8.lo b/thirdparty/grx249/src/bgi/text8.lo new file mode 100644 index 0000000..62fae20 Binary files /dev/null and b/thirdparty/grx249/src/bgi/text8.lo differ diff --git a/thirdparty/grx249/src/bgi/text9.c b/thirdparty/grx249/src/bgi/text9.c new file mode 100644 index 0000000..21c94fe --- /dev/null +++ b/thirdparty/grx249/src/bgi/text9.c @@ -0,0 +1,34 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +void settextjustify(int horiz, int vert) +{ + _DO_INIT_CHECK; + __gr_text_init(); + TXT.horiz = horiz; + TXT.vert = vert; +} + diff --git a/thirdparty/grx249/src/bgi/text9.lo b/thirdparty/grx249/src/bgi/text9.lo new file mode 100644 index 0000000..0599617 Binary files /dev/null and b/thirdparty/grx249/src/bgi/text9.lo differ diff --git a/thirdparty/grx249/src/bgi/texta.c b/thirdparty/grx249/src/bgi/texta.c new file mode 100644 index 0000000..32f641e --- /dev/null +++ b/thirdparty/grx249/src/bgi/texta.c @@ -0,0 +1,98 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +static int _mult[11] = { 1, 3, 2, 3, 1, 4, 5, 2, 5, 3, 4}; +static int _div[11] = { 1, 5, 3, 4, 1, 3, 3, 1, 2, 1, 1}; +static CharInfo *chi[LastUserFont+1] = { NULL }; +static int Heights[LastUserFont+1]; + +static int SetFont(int fnt) +{ + if (Fonts[fnt] == NULL) + return FALSE; + + if (chi[fnt] == NULL) { + chi[fnt] = calloc(256,sizeof(CharInfo)); + if (chi[fnt] == NULL) + return FALSE; + fntptr = chi[fnt]; + + if (!__gr_text_ChrFontInfo(Fonts[fnt], fntptr, &Heights[fnt])) + return FALSE; + } + fntptr = chi[fnt]; + __gr_text_height = Heights[fnt]; + return TRUE; +} + +void settextstyle(int font, int direction, int charsize) +{ + _DO_INIT_CHECK; + __gr_text_init(); + if (font < DEFAULT_FONT || font >= NrFonts || + (font > BOLD_FONT && Fonts[font] == NULL)) { + ERR = grInvalidFontNum; + return; + } + if (BITMAP(font) && charsize < 1) charsize = 1; + if (charsize < 0) charsize = 4; /* 100% */ + if (charsize > 10) charsize = 10; + + if (!BITMAP(font)) { + if (Fonts[font] == NULL) { + char fn[256], *cp; + + strcpy(fn, (*__gr_BGICHR != '\0' ? __gr_BGICHR : ".\\")); + cp = fn; + while ( *cp != '\0') ++cp; + if ( *(--cp) != '\\' && *cp != '/') { + *(++cp) = '\\'; + *(cp+1) = '\0'; + } + strcat( fn, StdFonts[font]); + __gr_text_installfont( font, font, fn); + } + if (!SetFont( font)) { + ERR = grFontNotFound; + font = DEFAULT_FONT; + charsize = 1; + } + } + TXT.font = font; + TXT.direction = direction; + TXT.charsize = charsize; + if (charsize == USER_CHAR_SIZE) { + __gr_text_multx = __gr_text_usr_multx; + __gr_text_divx = __gr_text_usr_divx; + __gr_text_multy = __gr_text_usr_multy; + __gr_text_divy = __gr_text_usr_divy; + } else { + __gr_text_multx = __gr_text_multy = _mult[charsize]; + __gr_text_divx = __gr_text_divy = _div[charsize]; + } +} + + diff --git a/thirdparty/grx249/src/bgi/texta.lo b/thirdparty/grx249/src/bgi/texta.lo new file mode 100644 index 0000000..3a002fc Binary files /dev/null and b/thirdparty/grx249/src/bgi/texta.lo differ diff --git a/thirdparty/grx249/src/bgi/textb.c b/thirdparty/grx249/src/bgi/textb.c new file mode 100644 index 0000000..48f77f2 --- /dev/null +++ b/thirdparty/grx249/src/bgi/textb.c @@ -0,0 +1,41 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +void setusercharsize(int multx, int divx, int multy, int divy) +{ + _DO_INIT_CHECK; + __gr_text_init(); + if (divx <= 0 || divy <= 0 || multx < 0 || multy < 0 || BITMAP(TXT.font)) { + ERR = grError; + return; + } + TXT.charsize = USER_CHAR_SIZE; + __gr_text_multx = __gr_text_usr_multx = multx; + __gr_text_divx = __gr_text_usr_divx = divx; + __gr_text_multy = __gr_text_usr_multy = multy; + __gr_text_divy = __gr_text_usr_divy = divy; +} + diff --git a/thirdparty/grx249/src/bgi/textb.lo b/thirdparty/grx249/src/bgi/textb.lo new file mode 100644 index 0000000..fe2b35e Binary files /dev/null and b/thirdparty/grx249/src/bgi/textb.lo differ diff --git a/thirdparty/grx249/src/bgi/textc.c b/thirdparty/grx249/src/bgi/textc.c new file mode 100644 index 0000000..60183ca --- /dev/null +++ b/thirdparty/grx249/src/bgi/textc.c @@ -0,0 +1,64 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" + +int __gr_text_ChrFontInfo(void *Font, CharInfo *fntptr, int *height) { + int i, LstChar; + char *cp; + _ushort *Offsets; + uchar *Widths; + char *Data; + FontFileHeader *ffh; + FontHeaderTyp *fht; + + cp = (char *)Font; + i = 256; + while (*cp != '\x1a' ) { /* \x1a = ^Z */ + ++cp; + --i; + if (i == 0) /* Error, no ^Z at end of copyright */ + return FALSE; + } + ++cp; + ffh = (FontFileHeader *)cp; + fht = (FontHeaderTyp *)((char *)Font + ffh->header_size); + if (fht->sig != '+') + return FALSE; /* Magic failed */ + if (fht->scan_flag) { + /* font may have DO_SCAN op, anything we should do ? */ + } + Offsets = (_ushort *)((char *)fht + sizeof(FontHeaderTyp)); + Widths = (uchar *)Offsets + 2 * (int)fht->nchrs; + Data = (char *)Font + fht->cdefs + ffh->header_size; + LstChar = fht->firstch + fht->nchrs - 1; + + *height = (int)fht->org_to_cap - (int)fht->org_to_dec; + for (i=fht->firstch; i <= LstChar; ++i) { + fntptr[i].width = Widths[i - fht->firstch]; + fntptr[i].cmd = (_ushort *)(Data + Offsets[i - fht->firstch]); + } + return TRUE; +} + diff --git a/thirdparty/grx249/src/bgi/textc.lo b/thirdparty/grx249/src/bgi/textc.lo new file mode 100644 index 0000000..7618cf7 Binary files /dev/null and b/thirdparty/grx249/src/bgi/textc.lo differ diff --git a/thirdparty/grx249/src/bgi/textd.c b/thirdparty/grx249/src/bgi/textd.c new file mode 100644 index 0000000..f5e0ba1 --- /dev/null +++ b/thirdparty/grx249/src/bgi/textd.c @@ -0,0 +1,75 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "text.h" +#include "allocate.h" + +#include +static void StrLwrCpy(char *d, const char *s, int n) +{ + while (n-- > 0) { + *(d++) = tolower(*s); + ++s; + } + *d = '\0'; +} + +static int _installgrxfont(int start, int stop, const char *name) +{ + __gr_text_init(); + while (start < stop && Fonts[start] != NULL) ++start; + if (start >= stop) + return grNoFontMem; +#ifdef GRX_VERSION + if ( name[0] == '@' && name[1] == ':') + name += 2; +#endif + Fonts[start] = (void *) GrLoadFont((char *) name); + if (Fonts[start] == NULL) + return grFontNotFound; + return start; +} + +static int _installuserfont(int len, const char *name) +{ + int res; + char *loc_name = ALLOC(len+5); + + if ( !loc_name ) + return grNoFontMem; + + StrLwrCpy(loc_name, name, len); + if (strstr(loc_name, ".fnt") != NULL) + res = _installgrxfont( FirstGrxFont, LastGrxFont, name); + else + res = __gr_text_installfont( FirstUserFont, LastUserFont, loc_name); + + FREE(loc_name); + return res; +} + +int installuserfont(const char *name) +{ + return _installuserfont(strlen(name), name); +} diff --git a/thirdparty/grx249/src/bgi/textd.lo b/thirdparty/grx249/src/bgi/textd.lo new file mode 100644 index 0000000..d31c36a Binary files /dev/null and b/thirdparty/grx249/src/bgi/textd.lo differ diff --git a/thirdparty/grx249/src/bgi/txtlnest.c b/thirdparty/grx249/src/bgi/txtlnest.c new file mode 100644 index 0000000..ce570e7 --- /dev/null +++ b/thirdparty/grx249/src/bgi/txtlnest.c @@ -0,0 +1,29 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "bccgrx00.h" + +void __gr_textlinestyle(int on) { + textlinestyle(on); +} diff --git a/thirdparty/grx249/src/bgi/txtlnest.lo b/thirdparty/grx249/src/bgi/txtlnest.lo new file mode 100644 index 0000000..59ebfbe Binary files /dev/null and b/thirdparty/grx249/src/bgi/txtlnest.lo differ diff --git a/thirdparty/grx249/src/depend.dj2 b/thirdparty/grx249/src/depend.dj2 new file mode 100644 index 0000000..f65078f --- /dev/null +++ b/thirdparty/grx249/src/depend.dj2 @@ -0,0 +1,10 @@ +# This is just a dummy file +# If you really work on GRX and need a working +# rebuild, create a real dependencies file by +# +# make -f makefile.dj2 dep +# +# If you want to use utils/watmake to create +# a Watcom makefile you have to create a valid +# DJGPP v2 dependencies file first (see above) + diff --git a/thirdparty/grx249/src/depend.lnx b/thirdparty/grx249/src/depend.lnx new file mode 100644 index 0000000..72af130 --- /dev/null +++ b/thirdparty/grx249/src/depend.lnx @@ -0,0 +1,4 @@ +# This is just a dummy file +# If you really work on GRX and need a working +# rebuild, create a real dependencies file by +# make -f makefile.lnx dep diff --git a/thirdparty/grx249/src/depend.x11 b/thirdparty/grx249/src/depend.x11 new file mode 100644 index 0000000..b372032 --- /dev/null +++ b/thirdparty/grx249/src/depend.x11 @@ -0,0 +1,5 @@ +# This is just a dummy file +# If you really work on GRX and need a working +# rebuild, create a real dependencies file by +# make -f makefile.x11 dep + diff --git a/thirdparty/grx249/src/draw/bitblt.c b/thirdparty/grx249/src/draw/bitblt.c new file mode 100644 index 0000000..e44cf45 --- /dev/null +++ b/thirdparty/grx249/src/draw/bitblt.c @@ -0,0 +1,61 @@ +/** + ** bitblt.c ---- the pixel transfer routine + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrBitBlt(GrContext *dst,int dx,int dy, + GrContext *src,int x1,int y1,int x2,int y2,GrColor oper) +{ + int oldx1,oldy1; + int oldx2,oldy2; + int dstx2,dsty2; + void (*bltfun)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor); + if(dst == NULL) dst = CURC; + if(src == NULL) src = CURC; + isort(x1,x2); oldx1 = x1; + isort(y1,y2); oldy1 = y1; + cxclip_ordbox(src,x1,y1,x2,y2); + oldx1 = (dx += (x1 - oldx1)); + oldy1 = (dy += (y1 - oldy1)); + oldx2 = dstx2 = dx + x2 - x1; + oldy2 = dsty2 = dy + y2 - y1; + clip_ordbox(dst,dx,dy,dstx2,dsty2); + x1 += (dx - oldx1); + y1 += (dy - oldy1); + x2 -= (oldx2 - dstx2); + y2 -= (oldy2 - dsty2); + if(src->gc_driver == dst->gc_driver) + bltfun = src->gc_driver->bitblt; + else if(src->gc_driver->mode == dst->gc_driver->rmode) + bltfun = dst->gc_driver->bltr2v; + else if(src->gc_driver->rmode == dst->gc_driver->mode) + bltfun = src->gc_driver->bltv2r; + else return; + mouse_block(src,x1,y1,x2,y2); + mouse_addblock(dst,dx,dy,dstx2,dsty2); + (*bltfun)( + &dst->gc_frame,(dx + dst->gc_xoffset),(dy + dst->gc_yoffset), + &src->gc_frame,(x1 + src->gc_xoffset),(y1 + src->gc_yoffset), + (x2 - x1 + 1), + (y2 - y1 + 1), + oper + ); + mouse_unblock(); +} + diff --git a/thirdparty/grx249/src/draw/bitblt1b.c b/thirdparty/grx249/src/draw/bitblt1b.c new file mode 100644 index 0000000..1b2725d --- /dev/null +++ b/thirdparty/grx249/src/draw/bitblt1b.c @@ -0,0 +1,58 @@ +/** + ** bitblt1b.c ---- bitblt from a 1bpp context + ** + ** Copyright (c) 2001 Josu Onandia + ** [e-mail: jonandia@fagorautomation.es]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrBitBlt1bpp(GrContext *dst,int dx,int dy, + GrContext *src,int x1,int y1,int x2,int y2, + GrColor fg, GrColor bg) +{ + int oldx1,oldy1; + int oldx2,oldy2; + int dstx2,dsty2; + + if(dst == NULL) dst = CURC; + if(src == NULL) src = CURC; + + if(src->gc_driver->num_planes != 1 || src->gc_driver->bits_per_pixel != 1) + return; + + isort(x1,x2); oldx1 = x1; + isort(y1,y2); oldy1 = y1; + cxclip_ordbox(src,x1,y1,x2,y2); + oldx1 = (dx += (x1 - oldx1)); + oldy1 = (dy += (y1 - oldy1)); + oldx2 = dstx2 = dx + x2 - x1; + oldy2 = dsty2 = dy + y2 - y1; + clip_ordbox(dst,dx,dy,dstx2,dsty2); + x1 += (dx - oldx1); + y1 += (dy - oldy1); + x2 -= (oldx2 - dstx2); + y2 -= (oldy2 - dsty2); + mouse_block(src,x1,y1,x2,y2); + mouse_addblock(dst,dx,dy,dstx2,dsty2); + + (dst->gc_driver->drawbitmap)((dx + dst->gc_xoffset),(dy + dst->gc_yoffset), + (x2 - x1 + 1),(y2 - y1 + 1),src->gc_baseaddr[0],src->gc_lineoffset, + /*alex:the offset should anyway be the x1,y1 point in src, as clipped*/ + (x1 + (y1 * (src->gc_lineoffset << 3))),fg,bg); + + mouse_unblock(); +} + diff --git a/thirdparty/grx249/src/draw/bitbltnc.c b/thirdparty/grx249/src/draw/bitbltnc.c new file mode 100644 index 0000000..a8c151c --- /dev/null +++ b/thirdparty/grx249/src/draw/bitbltnc.c @@ -0,0 +1,45 @@ +/** + ** bitbltnc.c ---- the pixel transfer routine (no clip) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrBitBltNC(GrContext *dst,int dx,int dy, + GrContext *src,int x1,int y1,int x2,int y2,GrColor oper) +{ + void (*bltfun)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor); + if(dst == NULL) dst = CURC; + if(src == NULL) src = CURC; + isort(x1,x2); + isort(y1,y2); + if(src->gc_driver == dst->gc_driver) + bltfun = src->gc_driver->bitblt; + else if(src->gc_driver->mode == dst->gc_driver->rmode) + bltfun = dst->gc_driver->bltr2v; + else if(src->gc_driver->rmode == dst->gc_driver->mode) + bltfun = src->gc_driver->bltv2r; + else return; + (*bltfun)( + &dst->gc_frame,(dx + dst->gc_xoffset),(dy + dst->gc_yoffset), + &src->gc_frame,(x1 + src->gc_xoffset),(y1 + src->gc_yoffset), + (x2 - x1 + 1), + (y2 - y1 + 1), + oper + ); +} + diff --git a/thirdparty/grx249/src/draw/box.c b/thirdparty/grx249/src/draw/box.c new file mode 100644 index 0000000..1ba736f --- /dev/null +++ b/thirdparty/grx249/src/draw/box.c @@ -0,0 +1,57 @@ +/** + ** box.c ---- draw a rectangle + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrBox(int x1,int y1,int x2,int y2,GrColor c) +{ + int ox1,oy1,ox2,oy2; + isort(x1,x2); ox1 = x1; ox2 = x2; + isort(y1,y2); oy1 = y1; oy2 = y2; + clip_ordbox(CURC,x1,y1,x2,y2); + mouse_block(CURC,x1,y1,x2,y2); + if(!(oy1 -= y1)) (*FDRV->drawhline)( + x1 + CURC->gc_xoffset, + y1 + CURC->gc_yoffset, + x2 - x1 + 1, + c + ); + if(!(oy2 -= y2) && ((y1 != y2) || oy1)) (*FDRV->drawhline)( + x1 + CURC->gc_xoffset, + y2 + CURC->gc_yoffset, + x2 - x1 + 1, + c + ); + if((y2 = y2 - (oy1 ? y1 : ++y1) + (oy2 ? 1 : 0)) > 0) { + if(!(ox1 -= x1)) (*FDRV->drawvline)( + x1 + CURC->gc_xoffset, + y1 + CURC->gc_yoffset, + y2, + c + ); + if((ox2 == x2) && ((x1 != x2) || ox1)) (*FDRV->drawvline)( + x2 + CURC->gc_xoffset, + y1 + CURC->gc_yoffset, + y2, + c + ); + } + mouse_unblock(); +} + diff --git a/thirdparty/grx249/src/draw/boxnc.c b/thirdparty/grx249/src/draw/boxnc.c new file mode 100644 index 0000000..2902544 --- /dev/null +++ b/thirdparty/grx249/src/draw/boxnc.c @@ -0,0 +1,53 @@ +/** + ** boxnc.c ---- draw a rectangle (no clip) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrBoxNC(int x1,int y1,int x2,int y2,GrColor c) +{ + isort(x1,x2); + isort(y1,y2); + (*FDRV->drawhline)( + x1 + CURC->gc_xoffset, + y1 + CURC->gc_yoffset, + x2 - x1 + 1, + c + ); + if(y2 != y1) (*FDRV->drawhline)( + x1 + CURC->gc_xoffset, + y2 + CURC->gc_yoffset, + x2 - x1 + 1, + c + ); + if((y2 = y2 - y1 + 1 - 2) > 0) { + (*FDRV->drawvline)( + x1 + CURC->gc_xoffset, + y1 + CURC->gc_yoffset + 1, + y2, + c + ); + if(x2 != x1) (*FDRV->drawvline)( + x2 + CURC->gc_xoffset, + y1 + CURC->gc_yoffset + 1, + y2, + c + ); + } +} + diff --git a/thirdparty/grx249/src/draw/clearclp.c b/thirdparty/grx249/src/draw/clearclp.c new file mode 100644 index 0000000..c568ca3 --- /dev/null +++ b/thirdparty/grx249/src/draw/clearclp.c @@ -0,0 +1,25 @@ +/** + ** clearclp.c ---- clear clipbox + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +void GrClearClipBox(GrColor bg) +{ + GrFilledBox(0,0,CURC->gc_xmax,CURC->gc_ymax,bg); +} + diff --git a/thirdparty/grx249/src/draw/clearctx.c b/thirdparty/grx249/src/draw/clearctx.c new file mode 100644 index 0000000..63498b1 --- /dev/null +++ b/thirdparty/grx249/src/draw/clearctx.c @@ -0,0 +1,37 @@ +/** + ** clearctx.c ---- clear context + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: + ** 081105 Richard, GrClearContextC + ** + **/ + +#include "libgrx.h" + +void GrClearContext(GrColor bg) +{ + mouse_block(CURC,0,0,CURC->gc_xmax,CURC->gc_ymax); + GrFilledBoxNC(0,0,CURC->gc_xmax,CURC->gc_ymax,bg); + mouse_unblock(); +} + +void GrClearContextC(GrContext *ctx, GrColor bg) +{ + GrContext *s = GrCurrentContext(); + GrSetContext(ctx); + GrClearContext(bg); + GrSetContext(s); +} diff --git a/thirdparty/grx249/src/draw/clearscr.c b/thirdparty/grx249/src/draw/clearscr.c new file mode 100644 index 0000000..411c631 --- /dev/null +++ b/thirdparty/grx249/src/draw/clearscr.c @@ -0,0 +1,28 @@ +/** + ** clearscr.c ---- clear screen + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +void GrClearScreen(GrColor bg) +{ + GrContext save; + GrSaveContext(&save); + GrSetContext(SCRN); + GrClearContext(bg); + GrSetContext(&save); +} diff --git a/thirdparty/grx249/src/draw/drwinlne.c b/thirdparty/grx249/src/draw/drwinlne.c new file mode 100644 index 0000000..f47c10e --- /dev/null +++ b/thirdparty/grx249/src/draw/drwinlne.c @@ -0,0 +1,36 @@ +/** + ** drvinlne.c ---- the drawing inline functions + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +void (GrPlotNC)(int x,int y,GrColor c) +{ + GrPlotNC(x,y,c); +} + +GrColor (GrPixelNC)(int x,int y) +{ + return(GrPixelNC(x,y)); +} + +GrColor (GrPixelCNC)(GrContext *c,int x,int y) +{ + return(GrPixelCNC(c,x,y)); +} + + diff --git a/thirdparty/grx249/src/draw/fillbox.c b/thirdparty/grx249/src/draw/fillbox.c new file mode 100644 index 0000000..f947510 --- /dev/null +++ b/thirdparty/grx249/src/draw/fillbox.c @@ -0,0 +1,34 @@ +/** + ** fillbox.c ---- draw a filled rectangle + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrFilledBox(int x1,int y1,int x2,int y2,GrColor c) +{ + clip_box(CURC,x1,y1,x2,y2); + mouse_block(CURC,x1,y1,x2,y2); + (*FDRV->drawblock)( + x1 + CURC->gc_xoffset, + y1 + CURC->gc_yoffset, + x2 - x1 + 1, + y2 - y1 + 1, + c + ); + mouse_unblock(); +} diff --git a/thirdparty/grx249/src/draw/fillboxn.c b/thirdparty/grx249/src/draw/fillboxn.c new file mode 100644 index 0000000..d55f0fe --- /dev/null +++ b/thirdparty/grx249/src/draw/fillboxn.c @@ -0,0 +1,32 @@ +/** + ** fillboxn.c ---- draw a filled rectangle (no clip) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrFilledBoxNC(int x1,int y1,int x2,int y2,GrColor c) +{ + (*FDRV->drawblock)( + x1 + CURC->gc_xoffset, + y1 + CURC->gc_yoffset, + x2 - x1 + 1, + y2 - y1 + 1, + c + ); +} + diff --git a/thirdparty/grx249/src/draw/flodspil.c b/thirdparty/grx249/src/draw/flodspil.c new file mode 100644 index 0000000..8e9b9dd --- /dev/null +++ b/thirdparty/grx249/src/draw/flodspil.c @@ -0,0 +1,121 @@ +/** + ** flodspil.c ---- Floodspill is a color replacer + ** + ** Copyright (c) 2007 Richard + ** [e-mail: richard at dogcreek.ca]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "libgrx.h" + + +void GrFloodSpill(int x1, int y1, int x2, int y2, + GrColor old_c, GrColor new_c) +{ + int y; + int x; + + GrColor *scanline; + + for(y = y1; y <= y2; ++y) + { + if ((scanline = (GrColor *)GrGetScanline(x1, x2, y)) != NULL) + { + for(x = x1; x <= x2; ++x) + { + if (scanline[x] == old_c) + scanline[x] = new_c; + } + GrPutScanline(x1, x2, y, scanline, GrWRITE); + } + } +} + +void GrFloodSpill2(int x1, int y1, int x2, int y2, + GrColor old_c1, GrColor new_c1, + GrColor old_c2, GrColor new_c2) +{ + int y; + int x; + + GrColor *scanline; + + for(y = y1; y <= y2; ++y) + { + if ((scanline = (GrColor *)GrGetScanline(x1, x2, y)) != NULL) + { + for(x = x1; x <= x2; ++x) + { + if (scanline[x] == old_c1) + scanline[x] = new_c1; + else if(scanline[x] == old_c2) + scanline[x] = new_c2; + } + GrPutScanline(x1, x2, y, scanline, GrWRITE); + } + } +} + +void GrFloodSpillC(GrContext *ctx, int x1, int y1, int x2, int y2, + GrColor old_c, GrColor new_c) +{ + int y; + int x; + GrContext *ctx_save = GrCurrentContext(); + GrColor *scanline; + + GrSetContext(ctx); + + for(y = y1; y <= y2; ++y) + { + if ((scanline = (GrColor *)GrGetScanline(x1, x2, y)) != NULL) + { + for(x = x1; x <= x2; ++x) + { + if (scanline[x] == old_c) + scanline[x] = new_c; + } + GrPutScanline(x1, x2, y, scanline, GrWRITE); + } + } + GrSetContext(ctx_save); +} + +void GrFloodSpillC2(GrContext *ctx, int x1, int y1, int x2, int y2, + GrColor old_c1, GrColor new_c1, + GrColor old_c2, GrColor new_c2) +{ + int y; + int x; + GrContext *ctx_save = GrCurrentContext(); + GrColor *scanline; + + GrSetContext(ctx); + + for(y = y1; y <= y2; ++y) + { + if ((scanline = (GrColor *)GrGetScanline(x1, x2, y)) != NULL) + { + for(x = x1; x <= x2; ++x) + { + if (scanline[x] == old_c1) + scanline[x] = new_c1; + else if(scanline[x] == old_c2) + scanline[x] = new_c2; + } + GrPutScanline(x1, x2, y, scanline, GrWRITE); + } + } + GrSetContext(ctx_save); +} diff --git a/thirdparty/grx249/src/draw/frambox.c b/thirdparty/grx249/src/draw/frambox.c new file mode 100644 index 0000000..e4ac220 --- /dev/null +++ b/thirdparty/grx249/src/draw/frambox.c @@ -0,0 +1,41 @@ +/** + ** frambox.c ---- framed (possibly shaded) box primitive + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrFramedBox(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c) +{ + isort(x1,x2); + isort(y1,y2); + if(wdt < 0) wdt = 0; + mouse_block(CURC,(x1 - wdt),(y1 - wdt),(x2 + wdt),(y2 + wdt)); + if(c->fbx_intcolor != GrNOCOLOR) { + GrFilledBox(x1,y1,x2,y2,c->fbx_intcolor); + } + while(--wdt >= 0) { + x1--; x2++; + y1--; y2++; + GrHLine(x1,x2,y1,c->fbx_topcolor); + GrVLine(x1,(y1 + 1),(y2 - 1),c->fbx_leftcolor); + GrVLine(x2,(y1 + 1),(y2 - 1),c->fbx_rightcolor); + GrHLine(x1,x2,y2,c->fbx_bottomcolor); + } + mouse_unblock(); +} + diff --git a/thirdparty/grx249/src/draw/framboxn.c b/thirdparty/grx249/src/draw/framboxn.c new file mode 100644 index 0000000..09a8974 --- /dev/null +++ b/thirdparty/grx249/src/draw/framboxn.c @@ -0,0 +1,39 @@ +/** + ** framboxn.c ---- framed (possibly shaded) box primitive (no clip) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrFramedBoxNC(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c) +{ + isort(x1,x2); + isort(y1,y2); + if(wdt < 0) wdt = 0; + if(c->fbx_intcolor != GrNOCOLOR) { + GrFilledBoxNC(x1,y1,x2,y2,c->fbx_intcolor); + } + while(--wdt >= 0) { + x1--; x2++; + y1--; y2++; + GrHLineNC(x1,x2,y1,c->fbx_topcolor); + GrVLineNC(x1,(y1 + 1),(y2 - 1),c->fbx_leftcolor); + GrVLineNC(x2,(y1 + 1),(y2 - 1),c->fbx_rightcolor); + GrHLineNC(x1,x2,y2,c->fbx_bottomcolor); + } +} + diff --git a/thirdparty/grx249/src/draw/getscl.c b/thirdparty/grx249/src/draw/getscl.c new file mode 100644 index 0000000..f7d3165 --- /dev/null +++ b/thirdparty/grx249/src/draw/getscl.c @@ -0,0 +1,51 @@ +/** + ** getscl.c ---- get scanline pixels + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +const GrColor *GrGetScanlineC(GrContext *ctx,int x1,int x2,int yy) +/* Input ctx: source context, if NULL the current context is used */ +/* x1 : first x coordinate read */ +/* x2 : last x coordinate read */ +/* yy : y coordinate */ +/* Output NULL : error / no data (clipping occured) */ +/* else */ +/* p[0..w-1]: pixel values read */ +/* p[w] : GrNOCOLOR end marker */ +/* (w = |x2-y1|+1) */ +/* Output data is valid until next GRX call ! */ +{ + GrColor *res = NULL; + if (ctx == NULL) ctx = CURC; + /* don't accept any clipping .... */ + clip_hline_(ctx,x1,x2,yy,goto done,goto done); + mouse_block(ctx,x1,yy,x2,yy); + res = (*ctx->gc_driver->getindexedscanline)( + &ctx->gc_frame, + x1 + ctx->gc_xoffset, + yy + ctx->gc_yoffset, + x2 - x1 + 1, + NULL + ); + mouse_unblock(); +done: return res; +} + +const GrColor *(GrGetScanline)(int x1,int x2,int yy) { + return GrGetScanlineC(NULL, x1,x2,yy); +} diff --git a/thirdparty/grx249/src/draw/line.c b/thirdparty/grx249/src/draw/line.c new file mode 100644 index 0000000..8ccd318 --- /dev/null +++ b/thirdparty/grx249/src/draw/line.c @@ -0,0 +1,35 @@ +/** + ** LINE.C ---- line drawing + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrLine(int x1,int y1,int x2,int y2,GrColor c) +{ + clip_line(CURC,x1,y1,x2,y2); + mouse_block(CURC,x1,y1,x2,y2); + (*FDRV->drawline)( + x1 + CURC->gc_xoffset, + y1 + CURC->gc_yoffset, + x2 - x1, + y2 - y1, + c + ); + mouse_unblock(); +} + diff --git a/thirdparty/grx249/src/draw/linenc.c b/thirdparty/grx249/src/draw/linenc.c new file mode 100644 index 0000000..42b3f09 --- /dev/null +++ b/thirdparty/grx249/src/draw/linenc.c @@ -0,0 +1,32 @@ +/** + ** linenc.c ---- line drawing (no clip) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrLineNC(int x1,int y1,int x2,int y2,GrColor c) +{ + (*FDRV->drawline)( + x1 + CURC->gc_xoffset, + y1 + CURC->gc_yoffset, + x2 - x1, + y2 - y1, + c + ); +} + diff --git a/thirdparty/grx249/src/draw/majorln1.c b/thirdparty/grx249/src/draw/majorln1.c new file mode 100644 index 0000000..2e225cb --- /dev/null +++ b/thirdparty/grx249/src/draw/majorln1.c @@ -0,0 +1,33 @@ +/** + ** majorln1.c ---- lines parallel with the X axis + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrHLine(int x1,int x2,int yy,GrColor c) +{ + clip_hline(CURC,x1,x2,yy); + mouse_block(CURC,x1,yy,x2,yy); + (*FDRV->drawhline)( + x1 + CURC->gc_xoffset, + yy + CURC->gc_yoffset, + x2 - x1 + 1, + c + ); + mouse_unblock(); +} diff --git a/thirdparty/grx249/src/draw/majorln2.c b/thirdparty/grx249/src/draw/majorln2.c new file mode 100644 index 0000000..a520630 --- /dev/null +++ b/thirdparty/grx249/src/draw/majorln2.c @@ -0,0 +1,33 @@ +/** + ** majorln2.c ---- lines parallel with the Y axis + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrVLine(int xx,int y1,int y2,GrColor c) +{ + clip_vline(CURC,xx,y1,y2); + mouse_block(CURC,xx,y1,xx,y2); + (*FDRV->drawvline)( + xx + CURC->gc_xoffset, + y1 + CURC->gc_yoffset, + y2 - y1 + 1, + c + ); + mouse_unblock(); +} diff --git a/thirdparty/grx249/src/draw/majorln3.c b/thirdparty/grx249/src/draw/majorln3.c new file mode 100644 index 0000000..51f696a --- /dev/null +++ b/thirdparty/grx249/src/draw/majorln3.c @@ -0,0 +1,31 @@ +/** + ** majorln3.c---- lines parallel with the X axis (no clip) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrHLineNC(int x1,int x2,int yy,GrColor c) +{ + isort(x1,x2); + (*FDRV->drawhline)( + x1 + CURC->gc_xoffset, + yy + CURC->gc_yoffset, + x2 - x1 + 1, + c + ); +} diff --git a/thirdparty/grx249/src/draw/majorln4.c b/thirdparty/grx249/src/draw/majorln4.c new file mode 100644 index 0000000..4d64b30 --- /dev/null +++ b/thirdparty/grx249/src/draw/majorln4.c @@ -0,0 +1,33 @@ +/** + ** majorln4.c ---- lines parallel with the Y axis (no clip) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrVLineNC(int xx,int y1,int y2,GrColor c) +{ + isort(y1,y2); + (*FDRV->drawvline)( + xx + CURC->gc_xoffset, + y1 + CURC->gc_yoffset, + y2 - y1 + 1, + c + ); +} + + diff --git a/thirdparty/grx249/src/draw/pixel.c b/thirdparty/grx249/src/draw/pixel.c new file mode 100644 index 0000000..624298f --- /dev/null +++ b/thirdparty/grx249/src/draw/pixel.c @@ -0,0 +1,34 @@ +/** + ** PIXEL.C ---- pixel read routine + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +GrColor GrPixel(int x,int y) +{ + GrColor retval; + cxclip_dot_(CURC,x,y,return(GrNOCOLOR)); + mouse_block(CURC,x,y,x,y); + retval = (*FDRV->readpixel)( + &CURC->gc_frame, + x + CURC->gc_xoffset, + y + CURC->gc_yoffset + ); + mouse_unblock(); + return(retval); +} diff --git a/thirdparty/grx249/src/draw/pixelc.c b/thirdparty/grx249/src/draw/pixelc.c new file mode 100644 index 0000000..16459ec --- /dev/null +++ b/thirdparty/grx249/src/draw/pixelc.c @@ -0,0 +1,35 @@ +/** + ** pixelc.c ---- pixel read from context + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +GrColor GrPixelC(GrContext *c,int x,int y) +{ + GrColor retval; + cxclip_dot_(c,x,y,return(GrNOCOLOR)); + mouse_block(c,x,y,x,y); + retval = (*c->gc_driver->readpixel)( + &c->gc_frame, + x + c->gc_xoffset, + y + c->gc_yoffset + ); + mouse_unblock(); + return(retval); +} + diff --git a/thirdparty/grx249/src/draw/plot.c b/thirdparty/grx249/src/draw/plot.c new file mode 100644 index 0000000..0452dbd --- /dev/null +++ b/thirdparty/grx249/src/draw/plot.c @@ -0,0 +1,34 @@ +/** + ** plot.c ---- pixel draw routines + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "arith.h" +#include "clipping.h" + +void GrPlot(int x,int y,GrColor c) +{ + clip_dot(CURC,x,y); + mouse_block(CURC,x,y,x,y); + (*FDRV->drawpixel)( + x + CURC->gc_xoffset, + y + CURC->gc_yoffset, + c + ); + mouse_unblock(); +} + diff --git a/thirdparty/grx249/src/draw/putscl.c b/thirdparty/grx249/src/draw/putscl.c new file mode 100644 index 0000000..ae2f356 --- /dev/null +++ b/thirdparty/grx249/src/draw/putscl.c @@ -0,0 +1,45 @@ +/** + ** putscl.c ---- put scanline pixels + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrPutScanline(int x1,int x2,int yy,const GrColor *c, GrColor op) +/* Input x1 : first x coordinate to be set */ +/* x2 : last x coordinate to be set */ +/* yy : y coordinate */ +/* c : c[0..(|x2-x1|] hold the pixel data */ +/* op : Operation (GrWRITE/GrXOR/GrOR/GrAND/GrIMAGE) */ +/* */ +/* Note c[..] data must fit GrCVALUEMASK otherwise the results */ +/* are implementation dependend. */ +/* => You can't supply operation code with the pixel data! */ +{ + int xs; + isort(x1,x2); + xs = x1; + clip_hline(CURC,x1,x2,yy); + mouse_block(CURC,x1,yy,x2,yy); + (*FDRV->putscanline)( + x1 + CURC->gc_xoffset, + yy + CURC->gc_yoffset, + x2 - x1 + 1, + &c[x1-xs], /* adjust pixel pointer when clipped */ + op + ); + mouse_unblock(); +} diff --git a/thirdparty/grx249/src/fdrivers/banked32.h b/thirdparty/grx249/src/fdrivers/banked32.h new file mode 100644 index 0000000..cc5d33b --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/banked32.h @@ -0,0 +1,173 @@ +/** + ** banked32.h ---- the 16M color padded SVGA banked frame buffer driver + ** standard routines for 32H and 32L support + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "mempeek.h" +#include "memfill.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),((x)<<2)) + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GR_int32u offs; + char far *pp; + GRX_ENTER(); + offs = FOFS(x,y,SCRN->gc_lineoffset); + CHKBANK(BANKNUM(offs)); + pp = &SCRN->gc_baseaddr[0][BANKPOS(offs)]; + setup_far_selector(SCRN->gc_selector); + GRX_RETURN(PIX2COL(peek_l_f(pp))); +} + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + GR_int32u offs; + char far *ptr; + int op; + GRX_ENTER(); + offs = FOFS(x,y,SCRN->gc_lineoffset); + CHKBANK(BANKNUM(offs)); + ptr = &SCRN->gc_baseaddr[0][BANKPOS(offs)]; + op = C_OPER(color); + color = COL2PIX(color); + setup_far_selector(CURC->gc_selector); + switch(op) { + case C_XOR: poke_l_f_xor(ptr,color); break; + case C_OR: poke_l_f_or( ptr,color); break; + case C_AND: poke_l_f_and(ptr,color); break; + default: poke_l_f( ptr,color); break; + } + GRX_LEAVE(); +} + +#ifdef freplicate_l +static void drawhline(int x,int y,int w,GrColor color) +{ + GR_int32u offs; + GR_repl cval; + int oper; + unsigned int w1, w2; + GRX_ENTER(); + offs = FOFS(x,y,SCRN->gc_lineoffset); + w2 = BANKLFT(offs) >> 2; + w2 = w - (w1 = umin(w,w2)); + oper = C_OPER(color); + color = COL2PIX(color); + cval = freplicate_l(color); + setup_far_selector(CURC->gc_selector); + do { + char far *pp = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + offs += (w1 << 2); + switch(oper) { + case C_XOR: repfill_l_f_xor(pp,cval,w1); break; + case C_OR: repfill_l_f_or( pp,cval,w1); break; + case C_AND: repfill_l_f_and(pp,cval,w1); break; + default: repfill_l_f( pp,cval,w1); break; + } + w1 = w2; + w2 = 0; + } while(w1 != 0); + GRX_LEAVE(); +} +#else +static +#include "fdrivers/generic/hline.c" +#endif + +static +#include "fdrivers/generic/vline.c" + +static +#include "fdrivers/generic/block.c" + +static +#include "fdrivers/generic/line.c" + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +static void bitblt(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltV2V( + dst,(dx << 2),dy, + src,(sx << 2),sy, + (w << 2),h, + op + ); + GRX_LEAVE(); +} + +#ifndef GRX_USE_RAM3x8 + +static void bltv2r(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltV2R( + dst,(dx << 2),dy, + src,(sx << 2),sy, + (w << 2),h, + op + ); + GRX_LEAVE(); +} + +static void bltr2v(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltR2V( + dst,(dx << 2),dy, + src,(sx << 2),sy, + (w << 2),h, + op + ); + GRX_LEAVE(); +} + +#endif /* !GRX_USE_RAM3x8 */ diff --git a/thirdparty/grx249/src/fdrivers/dotab8.c b/thirdparty/grx249/src/fdrivers/dotab8.c new file mode 100644 index 0000000..7e84742 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/dotab8.c @@ -0,0 +1,26 @@ +/** + ** dotab8.c ---- 256 color mode operation check table + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#include "libgrx.h" +#include "docolor.h" + +unsigned int _GrFDdotable8[] = { 0xffffU, 0, 0, 0xffU }; + diff --git a/thirdparty/grx249/src/fdrivers/driver16.h b/thirdparty/grx249/src/fdrivers/driver16.h new file mode 100644 index 0000000..57bd186 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/driver16.h @@ -0,0 +1,360 @@ +/** + ** driver16.h ---- the 32k/64k color padded SVGA linear frame buffer driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "mempeek.h" +#include "memfill.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),((x) << 1)) + +/* #define FAR_ACCESS for video access routines */ + +#ifdef FAR_ACCESS +# define peek16 peek_w_f +# define poke16_xor poke_w_f_xor +# define poke16_or poke_w_f_or +# define poke16_and poke_w_f_and +# define poke16 poke_w_f +# define colfill16_xor colfill_w_f_xor +# define colfill16_or colfill_w_f_or +# define colfill16_and colfill_w_f_and +# define colfill16 colfill_w_f +# define repfill16_xor repfill_w_f_xor +# define repfill16_or repfill_w_f_or +# define repfill16_and repfill_w_f_and +# define repfill16 repfill_w_f +# define SETFARSEL(sel) setup_far_selector(sel) +# if defined(__GNUC__) && defined(__i386__) +# define ASM_386_SEL I386_GCC_FAR_SELECTOR +# endif /* GCC i386 */ +#else /* defined FAR_ACCESS */ +# define peek16 peek_w +# define poke16_xor poke_w_xor +# define poke16_or poke_w_or +# define poke16_and poke_w_and +# define poke16 poke_w +# define colfill16_xor colfill_w_xor +# define colfill16_or colfill_w_or +# define colfill16_and colfill_w_and +# define colfill16 colfill_w +# define repfill16_xor repfill_w_xor +# define repfill16_or repfill_w_or +# define repfill16_and repfill_w_and +# define repfill16 repfill_w +# define SETFARSEL(sel) +#endif + +#ifndef ASM_386_SEL +# define ASM_386_SEL +#endif + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GR_int16u far *pp; + GRX_ENTER(); +#ifdef FAR_ACCESS + pp = (GR_int16u far *)&SCRN->gc_baseaddr[0][FOFS(x,y,SCRN->gc_lineoffset)]; + setup_far_selector(SCRN->gc_selector); +#else +/* problem with LFB_BY_NEAR_POINTER here? Does c always point to screen? */ + pp = (GR_int16u far *)&c->gf_baseaddr[0][FOFS(x,y,c->gf_lineoffset)]; +#endif +#if defined(MISALIGNED_16bit_OK) && !defined(FAR_ACCESS) + GRX_RETURN(*pp); +#else + GRX_RETURN((GR_int16u)peek16(pp)); +#endif +} + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + char far *ptr; + GRX_ENTER(); + ptr = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + SETFARSEL(CURC->gc_selector); + switch(C_OPER(color)) { + case C_XOR: poke16_xor(ptr,(GR_int16u)color); break; + case C_OR: poke16_or( ptr,(GR_int16u)color); break; + case C_AND: poke16_and(ptr,(GR_int16u)color); break; + default: poke16( ptr,(GR_int16u)color); break; + } + GRX_LEAVE(); +} + +static void drawhline(int x,int y,int w,GrColor color) +{ + char far *pp; + GR_repl cval; + GRX_ENTER(); + pp = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + cval = freplicate_w(color); + SETFARSEL(CURC->gc_selector); + switch(C_OPER(color)) { + case C_XOR: repfill16_xor(pp,cval,w); break; + case C_OR: repfill16_or( pp,cval,w); break; + case C_AND: repfill16_and(pp,cval,w); break; + default: repfill16( pp,cval,w); break; + } + GRX_LEAVE(); +} + +static void drawvline(int x,int y,int h,GrColor color) +{ + unsigned lwdt; + char far *pp; + GRX_ENTER(); + lwdt = CURC->gc_lineoffset; + pp = &CURC->gc_baseaddr[0][FOFS(x,y,lwdt)]; + SETFARSEL(CURC->gc_selector); + switch(C_OPER(color)) { + case C_XOR: colfill16_xor(pp,lwdt,(GR_int16u)color,h); break; + case C_OR: colfill16_or( pp,lwdt,(GR_int16u)color,h); break; + case C_AND: colfill16_and(pp,lwdt,(GR_int16u)color,h); break; + default: colfill16( pp,lwdt,(GR_int16u)color,h); break; + } + GRX_LEAVE(); +} + +static void drawblock(int x,int y,int w,int h,GrColor color) +{ + int skip; + char far *ptr; + GR_repl cval; + + GRX_ENTER(); + skip = CURC->gc_lineoffset; + ptr = &CURC->gc_baseaddr[0][FOFS(x,y,skip)]; + skip -= w<<1; + cval = freplicate_w(color); + SETFARSEL(CURC->gc_selector); + switch (C_OPER(color)) { + case C_XOR: while (h-- != 0) { + int ww = w; + repfill16_xor(ptr,cval,ww); + ptr += skip; + } + break; + case C_OR: while (h-- != 0) { + int ww = w; + repfill16_or(ptr,cval,ww); + ptr += skip; + } + break; + case C_AND: while (h-- != 0) { + int ww = w; + repfill16_and(ptr,cval,ww); + ptr += skip; + } + break; + default: while (h-- != 0) { + int ww = w; + repfill16(ptr,cval,ww); + ptr += skip; + } + break; + } + GRX_LEAVE(); +} + +#if defined(__GNUC__) && defined(__i386__) +static void drawline(int x,int y,int dx,int dy,GrColor color) +{ + struct { + int errsub; /* subtract from error term */ + int erradd; /* add to error term when carry */ + int offset1; /* add to pointer if no carry on error term */ + int offset2; /* add to pointer if carry / banking dir */ + } lndata; + int npts,error,xstep; + char far *ptr; + + GRX_ENTER(); + +# ifdef __GNUC__ +# ifdef __i386__ +# define ASM_LINE1(OPC) asm volatile("" \ + " .align 2,0x90 \n" \ + "0: "#OPC"w %6,"ASM_386_SEL"(%0) \n" \ + " subl %7,%2 \n" \ + " jb 1f \n" \ + " leal -2(%3),%3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 2f \n" \ + " .align 2,0x90 \n" \ + "1: addl 4 + %7,%2 \n" \ + " addl 12 + %7,%3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + "2: " \ + : "=r" (ptr), "=r" (npts), "=r" (error) \ + : "0" ((long)(ptr)), "1" (npts), "2" (error), \ + "r" ((short)(color)), "o" (lndata) \ + ) +# define ASM_LINE2(OPC) asm volatile("" \ + " .align 2,0x90 \n" \ + "0: "#OPC"w %6,"ASM_386_SEL"(%0) \n" \ + " subl %7,%2 \n" \ + " jb 1f \n" \ + " addl 8 + %7,%3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 2f \n" \ + " .align 2,0x90 \n" \ + "1: addl 4 + %7,%2 \n" \ + " addl 12 + %7,%3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + "2: " \ + : "=r" (ptr), "=r" (npts), "=r" (error) \ + : "0" ((long)(ptr)), "1" (npts), "2" (error), \ + "r" ((short)(color)), "o" (lndata) \ + ) +# endif +# endif + + if(dy < 0) { + y -= (dy = (-dy)); + x -= (dx = (-dx)); + } + if(dx < 0) { + xstep = (-2); + dx = (-dx); + } else + xstep = 2; + + ptr = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + SETFARSEL(CURC->gc_selector); + if(dx > dy) { + npts = dx + 1; + error = dx >> 1; + lndata.errsub = dy; + lndata.erradd = dx; + lndata.offset1 = xstep; + lndata.offset2 = CURC->gc_lineoffset + xstep; + if(xstep < 0) { + lndata.offset1 = 1; + switch(C_OPER(color)) { + case C_XOR: ASM_LINE1(xor); break; + case C_OR: ASM_LINE1(or); break; + case C_AND: ASM_LINE1(and); break; + default: ASM_LINE1(mov); break; + } + goto done; + } + } + else { + npts = dy + 1; + error = dy >> 1; + lndata.errsub = dx; + lndata.erradd = dy; + lndata.offset1 = CURC->gc_lineoffset; + lndata.offset2 = CURC->gc_lineoffset + xstep; + } + switch(C_OPER(color)) { + case C_XOR: ASM_LINE2(xor); break; + case C_OR: ASM_LINE2(or); break; + case C_AND: ASM_LINE2(and); break; + default: ASM_LINE2(mov); break; + } + done: + GRX_LEAVE(); +} +#else +static +#include "fdrivers/generic/line.c" +#endif + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +static void bitblt(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else +#ifdef FAR_ACCESS + _GrFrDrvPackedBitBltV2V_LFB( +#else + _GrFrDrvPackedBitBltR2R( +#endif + dst,(dx << 1),dy, + src,(sx << 1),sy, + (w << 1),h, + op + ); + GRX_LEAVE(); +} + +#ifdef FAR_ACCESS +static void bltv2r(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltV2R_LFB( + dst,(dx << 1),dy, + src,(sx << 1),sy, + (w << 1),h, + op + ); + GRX_LEAVE(); +} + +static void bltr2v(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltR2V_LFB( + dst,(dx << 1),dy, + src,(sx << 1),sy, + (w << 1),h, + op + ); + GRX_LEAVE(); +} +#endif + diff --git a/thirdparty/grx249/src/fdrivers/driver24.h b/thirdparty/grx249/src/fdrivers/driver24.h new file mode 100644 index 0000000..3111dbf --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/driver24.h @@ -0,0 +1,220 @@ +/** + ** driver24.h ---- the 24bpp color padded SVGA linear frame buffer driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "mempeek.h" +#include "memfill.h" +#include "access24.h" + +/* frame offset address calculation */ +#define MULT3(x) ( (x)+(x)+(x) ) +#define FOFS(x,y,lo) umuladd32((y),(lo),MULT3(x)) + +/* #define FAR_ACCESS for video access routines */ + +#ifdef FAR_ACCESS +# define peek24(p) peek_24_f((p)) +# define poke24_xor poke_24_f_xor +# define poke24_or poke_24_f_or +# define poke24_and poke_24_f_and +# define poke24_set poke_24_f +# define repfill8_xor repfill_b_f_xor +# define repfill8_or repfill_b_f_or +# define repfill8_and repfill_b_f_and +# define repfill8_set repfill_b_f +# define repfill24_xor repfill_24_f_xor +# define repfill24_or repfill_24_f_or +# define repfill24_and repfill_24_f_and +# define repfill24_set repfill_24_f_set +# define SETFARSEL(sel) setup_far_selector(sel) +#else /* defined FAR_ACCESS */ +# define peek24(p) peek_24((p)) +# define poke24_xor poke_24_xor +# define poke24_or poke_24_or +# define poke24_and poke_24_and +# define poke24_set poke_24 +# define repfill8_xor repfill_b_xor +# define repfill8_or repfill_b_or +# define repfill8_and repfill_b_and +# define repfill8_set repfill_b +# define repfill24_xor repfill_24_xor +# define repfill24_or repfill_24_or +# define repfill24_and repfill_24_and +# define repfill24_set repfill_24_set +# define SETFARSEL(sel) +#endif + + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GrColor col; + char far *p; + GRX_ENTER(); +#ifdef FAR_ACCESS + p = &SCRN->gc_baseaddr[0][FOFS(x,y,SCRN->gc_lineoffset)]; + setup_far_selector(SCRN->gc_selector); +#else + p = &c->gf_baseaddr[0][FOFS(x,y,c->gf_lineoffset)]; +#endif + col = peek24(p); + GRX_RETURN(col); +} + + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + char far *p; + GRX_ENTER(); + p = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + SETFARSEL(CURC->gc_selector); + switch(C_OPER(color)) { + case C_XOR: poke24_xor(p,color); break; + case C_OR: poke24_or( p,color); break; + case C_AND: poke24_and(p,color); break; + default: poke24_set(p,color); break; + } + GRX_LEAVE(); +} + + +static void drawhline(int x,int y,int w,GrColor color) +{ + char far *p; + GRX_ENTER(); + p = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + + w = MULT3(w); + SETFARSEL(CURC->gc_selector); +# ifndef GRX_HAVE_FAST_REPFILL24 + { + GR_int8u c0; + c0 = RD24BYTE(color,0); + if (c0 == RD24BYTE(color,1) && c0 == RD24BYTE(color,2) ) { + GR_repl cval = freplicate_b(c0); + switch(C_OPER(color)) { + case C_XOR: repfill8_xor(p,cval,w); break; + case C_OR: repfill8_or( p,cval,w); break; + case C_AND: repfill8_and(p,cval,w); break; + default: repfill8_set(p,cval,w); break; + } + goto done; + } + } +# endif + switch (C_OPER(color)) { + case C_XOR: repfill24_xor(p,color,w); break; + case C_OR: repfill24_or( p,color,w); break; + case C_AND: repfill24_and(p,color,w); break; + default: repfill24_set(p,color,w); break; + } +#ifndef GRX_HAVE_FAST_REPFILL24 + done: +#endif + GRX_LEAVE(); +} + + + +static +#include "fdrivers/generic/vline.c" + +static +#include "fdrivers/generic/line.c" + +static +#include "fdrivers/generic/block.c" + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +static void bitblt(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else +#ifdef FAR_ACCESS + _GrFrDrvPackedBitBltV2V_LFB( +#else + _GrFrDrvPackedBitBltR2R( +#endif + dst,MULT3(dx),dy, + src,MULT3(sx),sy, + MULT3(w),h, + op + ); + GRX_LEAVE(); +} + +#ifdef FAR_ACCESS + +static void bltv2r(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltV2R_LFB( + dst,MULT3(dx),dy, + src,MULT3(sx),sy, + MULT3(w),h, + op + ); + GRX_LEAVE(); +} + +static void bltr2v(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltR2V_LFB( + dst,MULT3(dx),dy, + src,MULT3(sx),sy, + MULT3(w),h, + op + ); + GRX_LEAVE(); +} +#endif /* FAR_ACCESS */ diff --git a/thirdparty/grx249/src/fdrivers/driver32.h b/thirdparty/grx249/src/fdrivers/driver32.h new file mode 100644 index 0000000..a8ea52c --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/driver32.h @@ -0,0 +1,395 @@ +/** + ** driver32.h ---- the 16M color padded SVGA linear frame buffer driver + ** standard routines for 32H and 32L support + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "mempeek.h" +#include "memfill.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),((x)<<2)) + +/* #define FAR_ACCESS for video access routines */ + +#ifdef FAR_ACCESS +# define peek32 peek_l_f +# define poke32_xor poke_l_f_xor +# define poke32_or poke_l_f_or +# define poke32_and poke_l_f_and +# define poke32 poke_l_f +# ifdef colfill_l_f +# define colfill32_xor colfill_l_f_xor +# define colfill32_or colfill_l_f_or +# define colfill32_and colfill_l_f_and +# define colfill32 colfill_l_f +# endif /* defined colfill_l */ +# ifdef repfill_l_f +# define repfill32_xor repfill_l_f_xor +# define repfill32_or repfill_l_f_or +# define repfill32_and repfill_l_f_and +# define repfill32 repfill_l_f +# endif /* defined repfill_l */ +# define SETFARSEL(sel) setup_far_selector(sel) +# if defined(__GNUC__) && defined(__i386__) +# define ASM_386_SEL I386_GCC_FAR_SELECTOR +# endif /* GCC i386 */ +#else /* defined FAR_ACCESS */ +# define peek32 peek_l +# define poke32_xor poke_l_xor +# define poke32_or poke_l_or +# define poke32_and poke_l_and +# define poke32 poke_l +# ifdef colfill_l +# define colfill32_xor colfill_l_xor +# define colfill32_or colfill_l_or +# define colfill32_and colfill_l_and +# define colfill32 colfill_l +# endif /* defined colfill_l */ +# ifdef repfill_l +# define repfill32_xor repfill_l_xor +# define repfill32_or repfill_l_or +# define repfill32_and repfill_l_and +# define repfill32 repfill_l +# endif /* defined repfill_l */ +# define SETFARSEL(sel) +#endif + +#ifndef ASM_386_SEL +# define ASM_386_SEL +#endif + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + char far *pp; + GRX_ENTER(); +#ifdef FAR_ACCESS + pp = &SCRN->gc_baseaddr[0][FOFS(x,y,SCRN->gc_lineoffset)]; + SETFARSEL(SCRN->gc_selector); +#else +/* problem with LFB_BY_NEAR_POINTER here? Does c always point to screen? */ + pp = &c->gf_baseaddr[0][FOFS(x,y,c->gf_lineoffset)]; +#endif + GRX_RETURN(PIX2COL(peek32(pp))); +} + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + char far *ptr; + int op; + GRX_ENTER(); + ptr = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + op = C_OPER(color); + color= COL2PIX(color); + SETFARSEL(CURC->gc_selector); + switch(op) { + case C_XOR: poke32_xor(ptr,color); break; + case C_OR: poke32_or( ptr,color); break; + case C_AND: poke32_and(ptr,color); break; + default: poke32( ptr,color); break; + } + GRX_LEAVE(); +} + +#ifdef colfill32 +static void drawvline(int x,int y,int h,GrColor color) +{ + unsigned lwdt; + char far *pp; + int op; + + GRX_ENTER(); + lwdt = CURC->gc_lineoffset; + pp = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + op = C_OPER(color); + color= COL2PIX(color); + SETFARSEL(CURC->gc_selector); + switch(op) { + case C_XOR: colfill32_xor(pp,lwdt,color,h); break; + case C_OR: colfill32_or( pp,lwdt,color,h); break; + case C_AND: colfill32_and(pp,lwdt,color,h); break; + default: colfill32( pp,lwdt,color,h); break; + } + GRX_LEAVE(); +} +#else +static +#include "fdrivers/generic/vline.c" +#endif + +#ifdef repfill32 +static void drawhline(int x,int y,int w,GrColor color) +{ + int op; + char far *pp; + GR_repl cval; + + GRX_ENTER(); + pp = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + op = C_OPER(color); + color= COL2PIX(color); + cval = freplicate_l(color); + SETFARSEL(CURC->gc_selector); + switch(op) { + case C_XOR: repfill32_xor(pp,cval,w); break; + case C_OR: repfill32_or( pp,cval,w); break; + case C_AND: repfill32_and(pp,cval,w); break; + default: repfill32( pp,cval,w); break; + } + GRX_LEAVE(); +} + +static void drawblock(int x,int y,int w,int h,GrColor color) +{ + unsigned skip; + int op; + char far *pp; + GR_repl cval; + + GRX_ENTER(); + skip = CURC->gc_lineoffset; + pp = &CURC->gc_baseaddr[0][FOFS(x,y,skip)]; + skip -= w<<2; + op = C_OPER(color); + color = COL2PIX(color); + cval = freplicate_l(color); + SETFARSEL(CURC->gc_selector); + switch(op) { + case C_XOR: do { int ww = w; + repfill32_xor(pp,cval,ww); + pp += skip; + } while(--h != 0); + break; + case C_OR: do { int ww = w; + repfill32_or(pp,cval,ww); + pp += skip; + } while(--h != 0); + break; + case C_AND: do { int ww = w; + repfill32_and(pp,cval,ww); + pp += skip; + } while(--h != 0); + break; + default: do { int ww = w; + repfill32(pp,cval,ww); + pp += skip; + } while(--h != 0); + break; + } + GRX_LEAVE(); +} +#else +static +#include "fdrivers/generic/hline.c" + +static +#include "fdrivers/generic/block.c" +#endif + + +#if defined(__GNUC__) && defined(__i386__) +static void drawline(int x,int y,int dx,int dy,GrColor color) +{ + struct { + int errsub; /* subtract from error term */ + int erradd; /* add to error term when carry */ + int offset1; /* add to pointer if no carry on error term */ + int offset2; /* add to pointer if carry / banking dir */ + } lndata; + int op,npts,error,xstep; + char far *ptr; + + GRX_ENTER(); + op = C_OPER(color); + color = COL2PIX(color); + +# ifdef __GNUC__ +# ifdef __i386__ +# define ASM_LINE1(OPC) asm volatile("" \ + " .align 2,0x90 \n" \ + "0: "#OPC"l %6,"ASM_386_SEL"(%0) \n" \ + " subl %7,%2 \n" \ + " jb 1f \n" \ + " leal -4(%3),%3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 2f \n" \ + " .align 2,0x90 \n" \ + "1: addl 4 + %7,%2 \n" \ + " addl 12 + %7,%3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + "2: " \ + : "=r" (ptr), "=r" (npts), "=r" (error) \ + : "0" ((long)(ptr)), "1" (npts), "2" (error), \ + "r" ((long)(color)), "o" (lndata) \ + ) +# define ASM_LINE2(OPC) asm volatile("" \ + " .align 2,0x90 \n" \ + "0: "#OPC"l %6,"ASM_386_SEL"(%0) \n" \ + " subl %7,%2 \n" \ + " jb 1f \n" \ + " addl 8 + %7,%3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 2f \n" \ + " .align 2,0x90 \n" \ + "1: addl 4 + %7,%2 \n" \ + " addl 12 + %7,%3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + "2: " \ + : "=r" (ptr), "=r" (npts), "=r" (error) \ + : "0" ((long)(ptr)), "1" (npts), "2" (error), \ + "r" ((long)(color)), "o" (lndata) \ + ) +# endif +# endif + + if(dy < 0) { + y -= (dy = (-dy)); + x -= (dx = (-dx)); + } + if(dx < 0) { + xstep = (-4); + dx = (-dx); + } else + xstep = 4; + + ptr = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + SETFARSEL(CURC->gc_selector); + if(dx > dy) { + npts = dx + 1; + error = dx >> 1; + lndata.errsub = dy; + lndata.erradd = dx; + lndata.offset1 = xstep; + lndata.offset2 = CURC->gc_lineoffset + xstep; + if(xstep < 0) { + lndata.offset1 = 1; + switch(op) { + case C_XOR: ASM_LINE1(xor); break; + case C_OR: ASM_LINE1(or); break; + case C_AND: ASM_LINE1(and); break; + default: ASM_LINE1(mov); break; + } + goto done; + } + } + else { + npts = dy + 1; + error = dy >> 1; + lndata.errsub = dx; + lndata.erradd = dy; + lndata.offset1 = CURC->gc_lineoffset; + lndata.offset2 = CURC->gc_lineoffset + xstep; + } + switch(op) { + case C_XOR: ASM_LINE2(xor); break; + case C_OR: ASM_LINE2(or); break; + case C_AND: ASM_LINE2(and); break; + default: ASM_LINE2(mov); break; + } +done: GRX_LEAVE(); +} +#else +static +#include "fdrivers/generic/line.c" +#endif + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +static void bitblt(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else +#ifdef FAR_ACCESS + _GrFrDrvPackedBitBltV2V_LFB( +#else + _GrFrDrvPackedBitBltR2R( +#endif + dst,(dx << 2),dy, + src,(sx << 2),sy, + (w << 2),h, + op + ); + GRX_LEAVE(); +} + +#ifdef FAR_ACCESS + +static void bltv2r(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltV2R_LFB( + dst,(dx << 2),dy, + src,(sx << 2),sy, + (w << 2),h, + op + ); + GRX_LEAVE(); +} + +static void bltr2v(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltR2V_LFB( + dst,(dx << 2),dy, + src,(sx << 2),sy, + (w << 2),h, + op + ); + GRX_LEAVE(); +} +#endif /* FAR_ACCESS */ + diff --git a/thirdparty/grx249/src/fdrivers/driver8.h b/thirdparty/grx249/src/fdrivers/driver8.h new file mode 100644 index 0000000..5ead39d --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/driver8.h @@ -0,0 +1,410 @@ +/** + ** driver8.h ---- the 256 color padded SVGA linear frame buffer driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "allocate.h" +#include "arith.h" +#include "docolor.h" +#include "mempeek.h" +#include "memfill.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),(x)) + +/* #define FAR_ACCESS for video access routines */ + +#ifdef FAR_ACCESS +# define peek8 peek_b_f +# define poke8_xor poke_b_f_xor +# define poke8_or poke_b_f_or +# define poke8_and poke_b_f_and +# define poke8 poke_b_f +# define colfill8_xor colfill_b_f_xor +# define colfill8_or colfill_b_f_or +# define colfill8_and colfill_b_f_and +# define colfill8 colfill_b_f +# define repfill8_xor repfill_b_f_xor +# define repfill8_or repfill_b_f_or +# define repfill8_and repfill_b_f_and +# define repfill8 repfill_b_f +# define SETFARSEL(sel) setup_far_selector(sel) +# if defined(__GNUC__) && defined(__i386__) +# define ASM_386_SEL I386_GCC_FAR_SELECTOR +# endif /* GCC i386 */ +#else /* defined FAR_ACCESS */ +# define peek8 peek_b +# define poke8_xor poke_b_xor +# define poke8_or poke_b_or +# define poke8_and poke_b_and +# define poke8 poke_b +# define colfill8_xor colfill_b_xor +# define colfill8_or colfill_b_or +# define colfill8_and colfill_b_and +# define colfill8 colfill_b +# define repfill8_xor repfill_b_xor +# define repfill8_or repfill_b_or +# define repfill8_and repfill_b_and +# define repfill8 repfill_b +# define SETFARSEL(sel) +#endif + +#ifndef ASM_386_SEL +# define ASM_386_SEL +#endif + + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GR_int8u far *pp; + GRX_ENTER(); +#ifdef FAR_ACCESS + pp = (GR_int8u far *)&SCRN->gc_baseaddr[0][FOFS(x,y,SCRN->gc_lineoffset)]; + SETFARSEL(SCRN->gc_selector); + GRX_RETURN((GR_int8u)peek8(pp)); +#else +/* problem with LFB_BY_NEAR_POINTER here? Does c always point to screen? */ + pp = (GR_int8u far *)&c->gf_baseaddr[0][FOFS(x,y,c->gf_lineoffset)]; + GRX_RETURN(*pp); +#endif +} + +/* -------------------------------------------------------------------- */ + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + char far *pp; + GRX_ENTER(); + pp = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + SETFARSEL(CURC->gc_selector); + switch(C_OPER(color)) { + case C_XOR: poke8_xor(pp,(GR_int8u)color); break; + case C_OR: poke8_or( pp,(GR_int8u)color); break; + case C_AND: poke8_and(pp,(GR_int8u)color); break; + default: poke8( pp,(GR_int8u)color); break; + } + GRX_LEAVE(); +} + +/* -------------------------------------------------------------------- */ + +static void drawvline(int x,int y,int h,GrColor color) +{ + int copr; + GRX_ENTER(); + copr = C_OPER(color); + if(DOCOLOR8(color,copr)) { + unsigned lwdt = CURC->gc_lineoffset; + char far *pp = &CURC->gc_baseaddr[0][FOFS(x,y,lwdt)]; + SETFARSEL(CURC->gc_selector); + switch(copr) { + case C_XOR: colfill8_xor(pp,lwdt,(GR_int8u)color,h); break; + case C_OR: colfill8_or( pp,lwdt,(GR_int8u)color,h); break; + case C_AND: colfill8_and(pp,lwdt,(GR_int8u)color,h); break; + default: colfill8( pp,lwdt,(GR_int8u)color,h); break; + } + } + GRX_LEAVE(); +} + +/* -------------------------------------------------------------------- */ + +static void drawhline(int x,int y,int w,GrColor color) +{ + int copr; + GRX_ENTER(); + copr = C_OPER(color); + if(DOCOLOR8(color,copr)) { + GR_repl cval = freplicate_b(color); + char far *pp = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + SETFARSEL(CURC->gc_selector); + switch(copr) { + case C_XOR: repfill8_xor(pp,cval,w); break; + case C_OR: repfill8_or( pp,cval,w); break; + case C_AND: repfill8_and(pp,cval,w); break; + default: repfill8( pp,cval,w); break; + } + } + GRX_LEAVE(); +} + +/* -------------------------------------------------------------------- */ + +static void drawblock(int x,int y,int w,int h,GrColor color) +{ + int copr; + GRX_ENTER(); + copr = C_OPER(color); + if(DOCOLOR8(color,copr)) { + GR_repl cval = freplicate_b(color); + unsigned int skip = CURC->gc_lineoffset; + char far *pp = &CURC->gc_baseaddr[0][FOFS(x,y,skip)]; + skip -= w; + SETFARSEL(CURC->gc_selector); + switch(copr) { + case C_XOR: do { int ww = w; + repfill8_xor(pp,cval,ww); + pp += skip; + } while(--h != 0); + break; + case C_OR: do { int ww = w; + repfill8_or(pp,cval,ww); + pp += skip; + } while(--h != 0); + break; + case C_AND: do { int ww = w; + repfill8_and(pp,cval,ww); + pp += skip; + } while(--h != 0); + break; + default: do { int ww = w; + repfill8(pp,cval,ww); + pp += skip; + } while(--h != 0); + break; + } + } + GRX_LEAVE(); +} + +/* -------------------------------------------------------------------- */ + +#if defined(__GNUC__) && defined(__i386__) +static void drawline(int x,int y,int dx,int dy,GrColor color) +{ + struct { + int errsub; + int erradd; + int offset1; + int offset2; + } lndata; + int copr,xstep,npts,error; + char far *ptr; + + GRX_ENTER(); + copr = C_OPER(color); + if(!DOCOLOR8(color,copr)) goto done; + +# ifdef __GNUC__ +# ifdef __i386__ +# define ASM_LINE1(OPC) asm volatile("" \ + " .align 2,0x90 \n" \ + "0: "#OPC"b %6,"ASM_386_SEL"(%0) \n" \ + " subl %7,%2 \n" \ + " jb 1f \n" \ + " decl %3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 2f \n" \ + " .align 2,0x90 \n" \ + "1: addl 4 + %7,%2 \n" \ + " addl 12 + %7,%3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + "2: " \ + : "=r" (ptr), "=r" (npts), "=r" (error) \ + : "0" ((long)(ptr)), "1" (npts), "2" (error), \ + "q" ((char)(color)), "o" (lndata) \ + ) +# define ASM_LINE2(OPC) asm volatile("" \ + " .align 2,0x90 \n" \ + "0: "#OPC"b %6,"ASM_386_SEL"(%0) \n" \ + " subl %7,%2 \n" \ + " jb 1f \n" \ + " addl 8 + %7,%3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 2f \n" \ + " .align 2,0x90 \n" \ + "1: addl 4 + %7,%2 \n" \ + " addl 12 + %7,%3 \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + "2: " \ + : "=r" (ptr), "=r" (npts), "=r" (error) \ + : "0" ((long)(ptr)), "1" (npts), "2" (error), \ + "q" ((char)(color)), "o" (lndata) \ + ) +# endif +# endif + + if(dy < 0) { + y -= (dy = (-dy)); + x -= (dx = (-dx)); + } + if(dx < 0) { + xstep = (-1); + dx = (-dx); + } else + xstep = 1; + + ptr = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + SETFARSEL(CURC->gc_selector); + if(dx > dy) { + npts = dx + 1; + error = dx >> 1; + lndata.errsub = dy; + lndata.erradd = dx; + lndata.offset1 = xstep; + lndata.offset2 = CURC->gc_lineoffset + xstep; + if(xstep < 0) { + again_nonlinear: + lndata.offset1 = 1; + switch(copr) { + case C_XOR: ASM_LINE1(xor); break; + case C_OR: ASM_LINE1(or); break; + case C_AND: ASM_LINE1(and); break; + default: ASM_LINE1(mov); break; + } + if(npts == 0) goto done; + goto again_nonlinear; + } + } + else { + npts = dy + 1; + error = dy >> 1; + lndata.errsub = dx; + lndata.erradd = dy; + lndata.offset1 = CURC->gc_lineoffset; + lndata.offset2 = CURC->gc_lineoffset + xstep; + } + again_linear: + switch(copr) { + case C_XOR: ASM_LINE2(xor); break; + case C_OR: ASM_LINE2(or); break; + case C_AND: ASM_LINE2(and); break; + default: ASM_LINE2(mov); break; + } + if(npts == 0) goto done; + goto again_linear; + done: + GRX_LEAVE(); +} +#else +static +#include "fdrivers/generic/line.c" +#endif + +/* -------------------------------------------------------------------- */ + +static void drawbitmap(int x,int y,int w,int h, + char far *bmp,int pitch,int start,GrColor fg,GrColor bg) +{ + int fgop, bgop; + int dofg, dobg; + GRX_ENTER(); + fgop = C_OPER(fg); + bgop = C_OPER(bg); + dofg = DOCOLOR8(fg,fgop); + dobg = DOCOLOR8(bg,bgop); + if(dofg | dobg) { + long offs = FOFS(x,y,CURC->gc_lineoffset); + int once = dofg && dobg && (fgop == bgop); + int skip = CURC->gc_lineoffset; + bmp += start >> 3; + start &= 7; + SETFARSEL(CURC->gc_selector); + do { + GR_int8u far *bp = (GR_int8u far *)bmp; + GR_int8u bits = *bp; + GR_int8u mask = 0x80 >> start; + GR_int32u w1 = w; + char far *pp = &CURC->gc_baseaddr[0][offs]; +# define DOBOTH(POKEOP) do { \ + POKEOP(pp,((bits&mask)?(GR_int8u)fg:(GR_int8u)bg)); \ + if((mask >>= 1) == 0) bits = *++bp,mask = 0x80; \ + pp++; \ + } while(--w1 != 0) +# define DOFGC(POKEOP) do { \ + if((mask & bits) != 0) POKEOP(pp,(GR_int8u)fg); \ + if((mask >>= 1) == 0) bits = *++bp,mask = 0x80; \ + pp++; \ + } while(--w1 != 0) +# define DOBGC(POKEOP) do { \ + if((mask & bits) == 0) POKEOP(pp,(GR_int8u)bg); \ + if((mask >>= 1) == 0) bits = *++bp,mask = 0x80; \ + pp++; \ + } while(--w1 != 0) + if(once) switch(fgop) { + case C_XOR: DOBOTH(poke8_xor); break; + case C_OR: DOBOTH(poke8_or); break; + case C_AND: DOBOTH(poke8_and); break; + default: DOBOTH(poke8); break; + } + else { + char far *ppsave = pp; + GR_int32u w1save = w1; + if(dofg) switch(fgop) { + case C_XOR: DOFGC(poke8_xor); break; + case C_OR: DOFGC(poke8_or); break; + case C_AND: DOFGC(poke8_and); break; + default: DOFGC(poke8); break; + } + if(dobg) { + pp = ppsave; + w1 = w1save; + bp = (GR_int8u far *)bmp; + bits = *bp; + mask = 0x80 >> start; + switch(bgop) { + case C_XOR: DOBGC(poke8_xor); break; + case C_OR: DOBGC(poke8_or); break; + case C_AND: DOBGC(poke8_and); break; + default: DOBGC(poke8); break; + } + } + } + offs += skip; + bmp += pitch; + } while(--h != 0); + } + GRX_LEAVE(); +} + +/* -------------------------------------------------------------------- */ + +static +#include "fdrivers/generic/pattern.c" + +/* -------------------------------------------------------------------- */ + +#ifdef FAR_ACCESS +#define bitblit _GrFrDrvPackedBitBltV2V_LFB +#define bltr2v _GrFrDrvPackedBitBltR2V_LFB +#define bltv2r _GrFrDrvPackedBitBltV2R_LFB +#else +#define bitblit _GrFrDrvPackedBitBltR2R +#endif + +/* -------------------------------------------------------------------- */ + +static +#include "fdrivers/generic/getiscl.c" + +/* -------------------------------------------------------------------- */ + +static +#include "fdrivers/generic/putscl.c" + +/* -------------------------------------------------------------------- */ diff --git a/thirdparty/grx249/src/fdrivers/ega4.c b/thirdparty/grx249/src/fdrivers/ega4.c new file mode 100644 index 0000000..ccebcfd --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/ega4.c @@ -0,0 +1,136 @@ +/** + ** ega4.c ---- the 16 color EGA frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "mempeek.h" +#include "memcopy.h" +#include "memfill.h" +#include "vgaregs.h" +#include "ioport.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),((x) >> 3)) + +static GrColor lastcolor; +static int writeops[] = { + (VGA_FUNC_SET << 8) + VGA_ROT_FN_SEL_REG, /* C_SET */ + (VGA_FUNC_XOR << 8) + VGA_ROT_FN_SEL_REG, /* C_XOR */ + (VGA_FUNC_OR << 8) + VGA_ROT_FN_SEL_REG, /* C_OR */ + (VGA_FUNC_AND << 8) + VGA_ROT_FN_SEL_REG /* C_AND */ +}; + +static int init(GrVideoMode *mp) +{ + GRX_ENTER(); + /* set write mode 0 */ + outport_w(VGA_GR_CTRL_PORT,((0 << 8) | VGA_MODE_REG)); + /* don't care register to 0 */ + outport_w(VGA_GR_CTRL_PORT,((0 << 8) | VGA_COLOR_DONTC_REG)); + /* enable all 4 planes for writing */ + outport_w(VGA_SEQUENCER_PORT,((0x0f << 8) | VGA_WRT_PLANE_ENB_REG)); + /* enable all 4 planes for set/reset */ + outport_w(VGA_GR_CTRL_PORT,((0x0f << 8) | VGA_SET_RESET_ENB_REG)); + lastcolor = (-1L); + GRX_RETURN(TRUE); +} + + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + char far *ptr; + unsigned mask, pixval; + GRX_ENTER(); + ptr = &SCRN->gc_baseaddr[0][FOFS(x,y,SCRN->gc_lineoffset)]; + mask= 0x80U >> (x &= 7); + setup_far_selector(SCRN->gc_selector); + outport_w(VGA_GR_CTRL_PORT,((3 << 8) | VGA_RD_PLANE_SEL_REG)); + pixval = (peek_b_f(ptr) & mask); + outport_b(VGA_GR_CTRL_DATA,2); + pixval = (peek_b_f(ptr) & mask) | (pixval << 1); + outport_b(VGA_GR_CTRL_DATA,1); + pixval = (peek_b_f(ptr) & mask) | (pixval << 1); + outport_b(VGA_GR_CTRL_DATA,0); + pixval = (peek_b_f(ptr) & mask) | (pixval << 1); + lastcolor = (-1L); + GRX_RETURN((GrColor)(pixval >> (7 - x))); +} + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + char far *ptr; + GRX_ENTER(); + ptr = &CURC->gc_baseaddr[0][FOFS(x,y,SCRN->gc_lineoffset)]; + setup_far_selector(CURC->gc_selector); + if(lastcolor != color) { + outport_w(VGA_GR_CTRL_PORT,writeops[C_OPER(color) & 3]); + outport_w(VGA_GR_CTRL_PORT,((((int)color & 0x0f) << 8) | VGA_SET_RESET_REG)); + lastcolor = color; + } + outport_w(VGA_GR_CTRL_PORT,((0x8000U >> (x & 7)) | VGA_BIT_MASK_REG)); + poke_b_f_or(ptr,0); + GRX_LEAVE(); +} + +static +#include "fdrivers/generic/hline.c" + +static +#include "fdrivers/generic/vline.c" + +static +#include "fdrivers/generic/block.c" + +static +#include "fdrivers/generic/line.c" + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +static +#include "fdrivers/generic/bitblt.c" + +GrFrameDriver _GrFrameDriverEGA4 = { + GR_frameEGA4, /* frame mode */ + GR_frameRAM4, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* scan line width alignment */ + 4, /* number of planes */ + 4, /* bits per pixel */ + 64*1024L, /* max plane size the code can handle */ + init, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + _GrFrDrvGenericBitBlt, + _GrFrDrvGenericBitBlt, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; diff --git a/thirdparty/grx249/src/fdrivers/egavga1.c b/thirdparty/grx249/src/fdrivers/egavga1.c new file mode 100644 index 0000000..62535ee --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/egavga1.c @@ -0,0 +1,462 @@ +/** + ** egavga1.c ---- the mono EGA/VGA frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "allocate.h" +#include "arith.h" +#include "mempeek.h" +#include "memcopy.h" +#include "memfill.h" +#include "vgaregs.h" +#include "ioport.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),((x) >> 3)) + +void GrSetEGAVGAmonoDrawnPlane(int plane) +{ + GRX_ENTER(); + plane &= 3; + outport_w(VGA_SEQUENCER_PORT,((0x100 << plane) | VGA_WRT_PLANE_ENB_REG)); + outport_w(VGA_GR_CTRL_PORT,((plane << 8) | VGA_RD_PLANE_SEL_REG)); + GRX_LEAVE(); +} + +void GrSetEGAVGAmonoShownPlane(int plane) +{ + void (*DACload)(int c,int r,int g,int b); + int i; + GRX_ENTER(); + DACload = DRVINFO->actmode.extinfo->loadcolor; + plane &= 3; + if(DACload) for(i = 0; i < 16; i++) { + int v = (i & (1 << plane)) ? 255 : 0; + (*DACload)(i,v,v,v); + } + GRX_LEAVE(); +} + +static size_t LineBytes = 0; +static char far *LineBuff = NULL; + +static int alloc_blit_buffer(void) { + GRX_ENTER(); + LineBuff = _GrTempBufferAlloc(LineBytes); + GRX_RETURN(LineBuff != NULL); +} + +static int init(GrVideoMode *mp) +{ + GRX_ENTER(); + + /* set write mode 0 */ + outport_w(VGA_GR_CTRL_PORT,((0 << 8) | VGA_MODE_REG)); + /* don't care register to 0 */ + outport_w(VGA_GR_CTRL_PORT,((0 << 8) | VGA_COLOR_DONTC_REG)); + /* disable all planes for set/reset */ + outport_w(VGA_GR_CTRL_PORT,((0 << 8) | VGA_SET_RESET_ENB_REG)); + GrSetEGAVGAmonoShownPlane(0); + GrSetEGAVGAmonoDrawnPlane(0); + + /* set up LineBuff max. line length for blits */ + LineBytes = sizeof(char) * (((mp->width+7) >> 3)+2); + + GRX_RETURN(TRUE); +} + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + char far *ptr; + GRX_ENTER(); + ptr = &SCRN->gc_baseaddr[0][FOFS(x,y,SCRN->gc_lineoffset)]; + setup_far_selector(SCRN->gc_selector); + GRX_RETURN((GrColor)((peek_b_f(ptr) >> (7 - (x & 7)) ) & 1)); +} + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + char far *ptr; + unsigned cval; + GRX_ENTER(); + ptr = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + cval= ((unsigned int)color & 1) << (7 - (x &= 7)); + setup_far_selector(CURC->gc_selector); + switch(C_OPER(color)) { + case C_XOR: poke_b_f_xor(ptr,cval); break; + case C_OR: poke_b_f_or(ptr,cval); break; + case C_AND: poke_b_f_and(ptr,~cval); break; + default: poke_b_f(ptr,((peek_b_f(ptr) & (~0x80 >> x)) | cval)); + } + GRX_LEAVE(); +} + +#define maskoper(d,op,s,msk,SF,DF) do { \ + unsigned char _c_ = peek_b##DF(d); \ + poke_b##DF((d), (_c_ & ~(msk)) | ((_c_ op (s)) & (msk))); \ + } while (0) +#define maskset(d,c,msk,DF) \ + poke_b##DF((d),(peek_b##DF(d) & ~(msk)) | ((c) & (msk))) + +static void drawhline(int x,int y,int w,GrColor color) +{ + int oper; + GRX_ENTER(); + oper = C_OPER(color); + color = color & 1 ? ~0L : 0L; + if ( !(!color && (oper==C_OR||oper==C_XOR)) + && !( color && oper==C_AND) ) { + GR_int8u far *pp = (GR_int8u far *)&CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + GR_int8u lm = 0xff >> (x & 7); + GR_int8u rm = 0xff << ((-(w += x)) & 7); + w = ((w + 7) >> 3) - (x >> 3); + if(w == 1) lm &= rm; + setup_far_selector(CURC->gc_selector); + if( lm ) { + switch(oper) { + case C_XOR: maskoper(pp,^,(GR_int8u)color,lm,_f,_f); break; + case C_OR: maskoper(pp,|,(GR_int8u)color,lm,_f,_f); break; + case C_AND: maskoper(pp,&,(GR_int8u)color,lm,_f,_f); break; + default: maskset(pp,(GR_int8u)color,lm,_f); break; + break; + } + if (!(--w)) goto done; + ++pp; + } + if ( rm ) --w; + if (w) { + switch(oper) { + case C_XOR: repfill_b_f_xor(pp,color,w); break; + case C_OR: repfill_b_f_or( pp,color,w); break; + case C_AND: repfill_b_f_and(pp,color,w); break; + default: repfill_b_f( pp,color,w); break; + } + } + if ( rm ) { + switch(oper) { + case C_XOR: maskoper(pp,^,(GR_int8u)color,rm,_f,_f); break; + case C_OR: maskoper(pp,|,(GR_int8u)color,rm,_f,_f); break; + case C_AND: maskoper(pp,&,(GR_int8u)color,rm,_f,_f); break; + default: maskset(pp,(GR_int8u)color,rm,_f); break; + } + } + } +done: + GRX_LEAVE(); +} + + +static void drawvline(int x,int y,int h,GrColor color) +{ + char far *p; + unsigned int cval; + unsigned int lwdt; + GRX_ENTER(); + lwdt = CURC->gc_lineoffset; + cval = ((unsigned int)color & 1) << (7 - (x & 7)); + setup_far_selector(CURC->gc_selector); + switch (C_OPER(color)) { + case C_XOR: + /* no need to xor anything with 0 */ + if (cval) { + p = &CURC->gc_baseaddr[0][FOFS(x,y,lwdt)]; + colfill_b_f_xor(p,lwdt,cval,h); + } + break; + case C_OR: + /* no need to or anything with 0 */ + if (cval) { + do_OR: + p = &CURC->gc_baseaddr[0][FOFS(x,y,lwdt)]; + colfill_b_f_or(p,lwdt,cval,h); + } + break; + case C_AND: + /* no need to and anything with 1 */ + if (!cval) { + do_AND: + cval = ~(1 << (7 - (x & 7))); + p = &CURC->gc_baseaddr[0][FOFS(x,y,lwdt)]; + colfill_b_f_and(p,lwdt,cval,h); + } + break; + default: + if (cval) goto do_OR; + goto do_AND; + break; + } + GRX_LEAVE(); +} + + +static +#include "fdrivers/generic/block.c" + +static +#include "fdrivers/generic/line.c" + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +/* some routines for fast blit operations +** +** All algorithms use a preallocated buffer for temporary +** storage and manipulation of pixel data: LineBuff[4] +** +** video -> video algorithm: +** read data from scanline into LineBuff[plane] +** if bit alignment between source and destination differs +** shift LineBuff for destination bit alignment +** write LineBuff[plane] to video memory +** +** ram -> video algorithm: +** calculate 'start of line' pointer (slp) holding the first +** blitting byte in RAM +** if bit alignment between RAM and screen differs +** shift© from slp to LineBuff with destination +** bit alignment. Reload slp with LineBuff +** write slp to video memory +** +** video -> ram algorithm +** read data from scanline into LineBuff[plane] +** if bit alignment between screen and RAM differs +** shift LineBuff for RAM bit alignment +** copy from LineBuff to RAM +** +** These algorithms save a lot of VGA register port settings +** compared with the old pixel by pixel method. +*/ + +static void put_scanline(char far *dptr,char far *sptr,int w, + GR_int8u lm, GR_int8u rm, int op ) { + GRX_ENTER(); + if (w==1) lm &= rm; + if ( ((GR_int8u)(~lm)) ) { + switch (op) { + case C_XOR: maskoper(dptr,^,*sptr,lm,_set,_f); break; + case C_OR : maskoper(dptr,|,*sptr,lm,_set,_f); break; + case C_AND: maskoper(dptr,&,*sptr,lm,_set,_f); break; + default : maskset(dptr,*sptr,lm,_f); break; + } + if (--w == 0) goto done; + ++dptr; + ++sptr; + } + if ( ((GR_int8u)(~rm)) ) --w; + if (w) switch (op) { + case C_XOR: fwdcopy_f_xor(dptr,dptr,sptr,w); break; + case C_OR : fwdcopy_f_or( dptr,dptr,sptr,w); break; + case C_AND: fwdcopy_f_and(dptr,dptr,sptr,w); break; + default : fwdcopy_f_set(dptr,dptr,sptr,w); break; + } + if ( ((GR_int8u)(~rm)) ) + switch (op) { + case C_XOR: maskoper(dptr,^,*sptr,rm,_set,_f); break; + case C_OR : maskoper(dptr,|,*sptr,rm,_set,_f); break; + case C_AND: maskoper(dptr,&,*sptr,rm,_set,_f); break; + default : maskset(dptr,*sptr,rm,_f); break; + } +done: + GRX_LEAVE(); +} + +static void get_scanline(char far *dptr, char far *sptr, int w) { + GRX_ENTER(); + fwdcopy_set_f(sptr,dptr,sptr,w); + GRX_LEAVE(); +} + +extern void _GR_shift_scanline(GR_int8u far **dst, + GR_int8u far **src, + int ws, int shift, int planes ); +#define shift_scanline(dst,src,w,sh) \ + _GR_shift_scanline((GR_int8u **)&(dst),(GR_int8u **)&(src),(w),(sh),1) + + +static +#include "fdrivers/generic/bitblt.c" + +static void bltv2v(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y,int w,int h, + GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) != GrIMAGE && alloc_blit_buffer()) { + int shift = ((int)(x&7)) - ((int)(dx&7)); + char far *dptr, *sptr; + int skip, lo = SCRN->gc_lineoffset; + int oper= C_OPER(op); + GR_int8u lm = 0xff >> (dx & 7); + GR_int8u rm = 0xff << ((-(w + dx)) & 7); + int ws = ((x+w+7) >> 3) - (x >> 3); + int wd = ((dx+w+7) >> 3) - (dx >> 3); + setup_far_selector(SCRN->gc_selector); + if (dy < y) { + skip = lo; + } else { + y += h-1; dy += h-1; + skip = -lo; + } + sptr = &SCRN->gc_baseaddr[0][FOFS(x,y,lo)]; + dptr = &SCRN->gc_baseaddr[0][FOFS(dx,dy,lo)]; + while (h-- > 0) { + get_scanline(LineBuff,sptr,ws); + if (shift) + shift_scanline(LineBuff,LineBuff,ws,shift); + put_scanline(dptr,LineBuff, wd, lm, rm, oper); + dptr += skip; + sptr += skip; + } + } else + bitblt(dst,dx,dy,src,x,y,w,h,op); + GRX_LEAVE(); +} + +static void bltr2v(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y,int w,int h, + GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) != GrIMAGE && alloc_blit_buffer()) { + int oper = C_OPER(op); + int shift = ((int)(x&7)) - ((int)(dx&7)); + char far *dptr, *sptr; + int sskip,dskip; + GR_int8u lm = 0xff >> (dx & 7); + GR_int8u rm = 0xff << ((-(w + dx)) & 7); + int ws = ((x+w+7) >> 3) - (x >> 3); + int wd = ((dx+w+7) >> 3) - (dx >> 3); + setup_far_selector(SCRN->gc_selector); + dskip = SCRN->gc_lineoffset; + dptr = &SCRN->gc_baseaddr[0][FOFS(dx,dy,dskip)]; + sskip = src->gf_lineoffset; + sptr = &src->gf_baseaddr[0][FOFS(x,y,sskip)]; + if (shift) + while (h-- > 0) { + shift_scanline(LineBuff,sptr,ws,shift); + put_scanline(dptr,LineBuff,wd,lm,rm,oper); + dptr += dskip; + sptr += sskip; + } + else + while (h-- > 0) { + put_scanline(dptr,sptr,wd,lm,rm,oper); + dptr += dskip; + sptr += sskip; + } + } else + _GrFrDrvGenericBitBlt(dst,dx,dy,src,x,y,w,h,op); + GRX_LEAVE(); +} + + +static void bltv2r(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y,int w,int h, + GrColor op) +{ + GRX_ENTER(); + while(GrColorMode(op) != GrIMAGE) + if(alloc_blit_buffer()) { + int oper = C_OPER(op); + int shift = ((int)(x&7)) - ((int)(dx&7)); + char far *dp, *dptr, *sp, *sptr; + int sskip,dskip; + GR_int8u lm = 0xff >> (dx & 7); + GR_int8u rm = 0xff << ((-(w + dx)) & 7); + int ws = ((x+w+7) >> 3) - (x >> 3); + int wd = ((dx+w+7) >> 3) - (dx >> 3); + if (wd==1) break; + setup_far_selector(SCRN->gc_selector); + sskip = SCRN->gc_lineoffset; + sp = &SCRN->gc_baseaddr[0][FOFS(x,y,sskip)]; + dskip = dst->gf_lineoffset; + dp = &dst->gf_baseaddr[0][FOFS(x,y,dskip)]; + while (h-- > 0) { + int ww = wd; + get_scanline(LineBuff,sp,ws); + if (shift) + shift_scanline(LineBuff,LineBuff,ws,shift); + sptr = LineBuff; + dptr = dp; + if ( ((GR_int8u)(~lm)) ) { + switch (op) { + case C_XOR: maskoper(dptr,^,*sptr,lm,_set,_n); break; + case C_OR : maskoper(dptr,|,*sptr,lm,_set,_n); break; + case C_AND: maskoper(dptr,&,*sptr,lm,_set,_n); break; + default : maskset(dptr,*sptr,lm,_n); break; + } + ++dptr; + ++sptr; + if (!(--ww)) goto next; + } + if ( ((GR_int8u)(~rm)) ) --ww; + if (ww) switch(oper) { + case C_XOR: fwdcopy_xor(dptr,dptr,sptr,ww); break; + case C_OR: fwdcopy_or( dptr,dptr,sptr,ww); break; + case C_AND: fwdcopy_and(dptr,dptr,sptr,ww); break; + default: fwdcopy_set(dptr,dptr,sptr,ww); break; + } + if ( ((GR_int8u)(~rm)) ) { + switch (op) { + case C_XOR: maskoper(dptr,^,*sptr,rm,_set,_n); break; + case C_OR : maskoper(dptr,|,*sptr,rm,_set,_n); break; + case C_AND: maskoper(dptr,&,*sptr,rm,_set,_n); break; + default : maskset(dptr,*sptr,rm,_n); break; + } + } + next: + sp += sskip; + dp += dskip; + } + goto done; + } + _GrFrDrvGenericBitBlt(dst,dx,dy,src,x,y,w,h,op); +done: + GRX_LEAVE(); +} + + +GrFrameDriver _GrFrameDriverEGAVGA1 = { + GR_frameEGAVGA1, /* frame mode */ + GR_frameRAM1, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 1, /* bits per pixel */ + 64*1024L, /* max plane size the code can handle */ + init, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bltv2v, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + diff --git a/thirdparty/grx249/src/fdrivers/fd_xwin.c b/thirdparty/grx249/src/fdrivers/fd_xwin.c new file mode 100644 index 0000000..a79089e --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/fd_xwin.c @@ -0,0 +1,814 @@ +/** + ** fd_xwin.c - the X Window color frame driver + ** + ** Author: Ulrich Leodolter + ** E-mail: ulrich@lab1.psy.univie.ac.at + ** Date: Thu Sep 28 10:31:08 1995 + ** RCSId: $Id: fd_xwin.c 1.1 1995/11/19 17:42:55 ulrich Exp $ + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** 070505 M.Alvarez, Using a Pixmap for BackingStore + ** 080801 M.Alvarez, Sanitized pixel cache code + ** 080801 M.Alvarez, New faster and specific for X11 putscanline function + ** + **/ + +#include +#include "libgrx.h" +#include "libxwin.h" +#include "arith.h" +#include "memfill.h" +#include "grdriver.h" + +INLINE +void _XGrCopyBStore(int x, int y, int width, int lenght) +{ + if (USE_PIXMAP_FOR_BS) { + XCopyArea (_XGrDisplay, + _XGrBStore, + _XGrWindow, + DefaultGC (_XGrDisplay, _XGrScreen), + x, + y, + width, + lenght, + x, + y); + } +} + +static INLINE +void _XGrSetForeColor (GrColor color) +{ + GRX_ENTER(); + color &= GrCVALUEMASK; + if (color != _XGrForeColor) + { + DBGPRINTF(DBG_DRIVER,("New foreground color: %x\n",(unsigned)color)); + _XGrForeColor = color; + XSetForeground (_XGrDisplay, _XGrGC, _XGrForeColor); + } + GRX_LEAVE(); +} + +static INLINE +void _XGrSetBackColor (GrColor color) +{ + GRX_ENTER(); + color &= GrCVALUEMASK; + if (color != _XGrBackColor) + { + DBGPRINTF(DBG_DRIVER,("New background color: %x\n",(unsigned)color)); + _XGrBackColor = color; + XSetBackground (_XGrDisplay, _XGrGC, _XGrBackColor); + } + GRX_LEAVE(); +} + +static INLINE +void _XGrSetColorOper (GrColor color) +{ + static int _GXtable[4] = { + GXcopy, /* C_WRITE */ + GXxor, /* C_XOR */ + GXor, /* C_OR */ + GXand /* C_AND */ + }; + unsigned int coper; + + GRX_ENTER(); + coper = C_OPER(color) & 0x03; + if (coper != _XGrColorOper) + { + _XGrColorOper = coper; + XSetFunction (_XGrDisplay, _XGrGC, _GXtable[_XGrColorOper]); + } + GRX_LEAVE(); +} + +/* + * PixelCache uses complete rows now + * Designed for loops like: + * + * for (y = 0; y < height; y++) + * for (x = 0; x < width; x++) + * *dest++ = GrPixel (x, y); + */ + +#define PIXEL_CACHE_HEIGHT 4 + +static XImage * _XGrPixelCacheImage = NULL; +static Drawable _XGrPixelCacheDrawable = None; +static int _XGrPixelCacheWidth = 0; +static int _XGrPixelCacheHeight = 0; +static int _XGrPixelCacheY1 = 0; +static int _XGrPixelCacheY2 = 0; + +/* y1 <= y2 required ! */ +#define AREA_OVERLAP_PIXEL_CACHE(y1,y2) \ + ( (y2) >= _XGrPixelCacheY1 \ + && (y1) <= _XGrPixelCacheY2 ) + +#define PIXEL_CACHE_INVALIDATE() do { \ + _XGrPixelCacheDrawable = None; \ + if (_XGrPixelCacheImage) { \ + XDestroyImage (_XGrPixelCacheImage); \ + _XGrPixelCacheImage = NULL; \ + } \ + } while (0) + +static INLINE +void _XGrCheckPixelCache(int y1, int y2) +{ + if (_XGrPixelCacheDrawable == None) return; + if (AREA_OVERLAP_PIXEL_CACHE(y1,y2)) + PIXEL_CACHE_INVALIDATE(); +} + +static +GrColor readpixel(GrFrame *c, int x, int y) +{ + GrColor col; + GRX_ENTER(); + if (_XGrPixelCacheDrawable != (Drawable) c->gf_baseaddr[0] + || _XGrPixelCacheImage == NULL + || !AREA_OVERLAP_PIXEL_CACHE(y,y)) { + + if (_XGrPixelCacheImage) { + XDestroyImage (_XGrPixelCacheImage); + _XGrPixelCacheImage = NULL; + } + _XGrPixelCacheDrawable = (Drawable) c->gf_baseaddr[0]; + + _XGrPixelCacheWidth = GrScreenX(); + _XGrPixelCacheY1 = y; + _XGrPixelCacheY2 = y + PIXEL_CACHE_HEIGHT - 1; + if (_XGrPixelCacheY2 >= GrScreenY()) + _XGrPixelCacheY2 = GrScreenY() - 1; + _XGrPixelCacheHeight = _XGrPixelCacheY2 - _XGrPixelCacheY1 + 1; + + _XGrPixelCacheImage = XGetImage (_XGrDisplay, + _XGrPixelCacheDrawable, + 0, + _XGrPixelCacheY1, + _XGrPixelCacheWidth, + _XGrPixelCacheHeight, + AllPlanes, + ZPixmap); + if (! _XGrPixelCacheImage) { + col = GrNOCOLOR; + goto done; + } + } + col = XGetPixel (_XGrPixelCacheImage, x, y - _XGrPixelCacheY1); +done: + GRX_RETURN( col ); +} + +static INLINE +void drawpixel(int x,int y,GrColor c) +{ + GRX_ENTER(); + _XGrSetForeColor (c); + _XGrSetColorOper (c); + XDrawPoint (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, + x, + y); + _XGrCopyBStore(x, y, 1, 1); + _XGrCheckPixelCache(y, y); + + GRX_LEAVE(); +} + +static +void drawhline(int x,int y,int w,GrColor c) +{ + int x2; + + GRX_ENTER(); + _XGrSetForeColor (c); + _XGrSetColorOper (c); + x2 = x + w - 1; + XDrawLine (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, + x, y, + x2, y); + _XGrCopyBStore(x, y, w, 1); + _XGrCheckPixelCache(y, y); + + GRX_LEAVE(); +} + +static +void drawvline(int x,int y,int h,GrColor c) +{ + int y2; + + GRX_ENTER(); + _XGrSetForeColor (c); + _XGrSetColorOper (c); + y2 = y + h - 1; + XDrawLine (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, + x, y, + x, y2); + _XGrCopyBStore(x, y, 1, h); + _XGrCheckPixelCache(y, y2); + + GRX_LEAVE(); +} + +static +void drawblock(int x,int y,int w,int h,GrColor c) +{ + GRX_ENTER(); + _XGrSetForeColor (c); + _XGrSetColorOper (c); + XFillRectangle (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, + x, + y, + w, + h); + _XGrCopyBStore(x, y, w, h); + _XGrCheckPixelCache(y, y+h-1); + + GRX_LEAVE(); +} + + +static +void drawline(int x,int y,int dx,int dy,GrColor c) +{ + GRX_ENTER(); + _XGrSetForeColor (c); + _XGrSetColorOper (c); + dx += x; + dy += y; + XDrawLine (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, + x, y, + dx, dy); + isort(x,dx); + isort(y,dy); + _XGrCopyBStore(x, y, dx-x+1, dy-y+1); + _XGrCheckPixelCache(y, dy); + + GRX_LEAVE(); +} + +static +void drawbitmap(int x,int y,int w,int h,char far *bmp,int pitch,int start,GrColor fg,GrColor bg) +{ + XImage ximage; + + GRX_ENTER(); + bmp += (unsigned int)start >> 3; + start &= 7; + + ximage.width = w; + ximage.height = h; + ximage.xoffset = start; + ximage.format = XYBitmap; + ximage.data = bmp; + ximage.byte_order = LSBFirst; + ximage.bitmap_unit = 8; + ximage.bitmap_bit_order = MSBFirst; + ximage.bitmap_pad = 8; + ximage.depth = 1; + ximage.bytes_per_line = pitch; + ximage.bits_per_pixel = 1; + ximage.red_mask = 0L; + ximage.green_mask = 0L; + ximage.blue_mask = 0L; + ximage.obdata = NULL; + sttzero(&ximage.f); + +# ifndef PRE_R6_ICCCM + if ( XInitImage (&ximage) != 0) +# endif + { + if ((C_OPER(fg) == C_OPER(bg)) && (fg != GrNOCOLOR)) { + _XGrSetForeColor (fg); + _XGrSetBackColor (bg); + _XGrSetColorOper (fg); + DBGPRINTF(DBG_DRIVER,("Calling XPutImage (1) ...\n")); + XPutImage (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, + &ximage, + 0, + 0, + x, + y, + w, + h); + DBGPRINTF(DBG_DRIVER,("Calling XPutImage (1) done\n")); + } + else { + if (fg != GrNOCOLOR) { + XSetForeground (_XGrDisplay, _XGrBitmapGC, 1); + XSetBackground (_XGrDisplay, _XGrBitmapGC, 0); + DBGPRINTF(DBG_DRIVER,("Calling XPutImage (2) ...\n")); + XPutImage (_XGrDisplay, + _XGrBitmap, + _XGrBitmapGC, + &ximage, + 0, + 0, + 0, + 0, + w, + h); + DBGPRINTF(DBG_DRIVER,("Calling XPutImage (2) done\n")); + XSetStipple (_XGrDisplay, _XGrGC, _XGrBitmap); + XSetTSOrigin (_XGrDisplay, _XGrGC, x, y); + XSetFillStyle (_XGrDisplay, _XGrGC, FillStippled); + _XGrSetForeColor (fg); + _XGrSetColorOper (fg); + XFillRectangle (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, + x, + y, + w, + h); + } + if (bg != GrNOCOLOR) { + XSetForeground (_XGrDisplay, _XGrBitmapGC, 0); + XSetBackground (_XGrDisplay, _XGrBitmapGC, 1); + DBGPRINTF(DBG_DRIVER,("Calling XPutImage (3) ...\n")); + XPutImage (_XGrDisplay, + _XGrBitmap, + _XGrBitmapGC, + &ximage, + 0, + 0, + 0, + 0, + w, + h); + DBGPRINTF(DBG_DRIVER,("Calling XPutImage (3) done\n")); + XSetStipple (_XGrDisplay, _XGrGC, _XGrBitmap); + XSetTSOrigin (_XGrDisplay, _XGrGC, x, y); + XSetFillStyle (_XGrDisplay, _XGrGC, FillStippled); + _XGrSetForeColor (bg); + _XGrSetColorOper (bg); + XFillRectangle (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, + x, + y, + w, + h); + } + XSetFillStyle (_XGrDisplay, _XGrGC, FillSolid); + } + + _XGrCopyBStore(x, y, w, h); + _XGrCheckPixelCache(y, y+h-1); + } + GRX_LEAVE(); +} + +/* Note: drawpattern is not tested because it's not used in this GRX version */ +static +void drawpattern(int x,int y,int w,char patt,GrColor fg,GrColor bg) +{ + XImage ximage; + + GRX_ENTER(); + ximage.width = 8; + ximage.height = 1; + ximage.xoffset = 0; + ximage.format = XYBitmap; + ximage.data = &patt; + ximage.byte_order = LSBFirst; + ximage.bitmap_unit = 8; + ximage.bitmap_bit_order = MSBFirst; + ximage.bitmap_pad = 8; + ximage.depth = 1; + ximage.bytes_per_line = 1; + ximage.bits_per_pixel = 1; + ximage.red_mask = 0L; + ximage.green_mask = 0L; + ximage.blue_mask = 0L; + ximage.obdata = NULL; + sttzero(&ximage.f); + +# ifndef PRE_R6_ICCCM + if (XInitImage (&ximage) != 0) +# endif + { + if ((C_OPER(fg) == C_OPER(bg)) && (fg != GrNOCOLOR)) { + XSetForeground (_XGrDisplay, _XGrPatternGC, 1); + XSetBackground (_XGrDisplay, _XGrPatternGC, 0); + XPutImage (_XGrDisplay, + _XGrPattern, + _XGrPatternGC, + &ximage, + 0, + 0, + 0, + 0, + 8, + 1); + XSetStipple (_XGrDisplay, _XGrGC, _XGrPattern); + XSetTSOrigin (_XGrDisplay, _XGrGC, x, y); + XSetFillStyle (_XGrDisplay, _XGrGC, FillOpaqueStippled); + _XGrSetForeColor (fg); + _XGrSetBackColor (bg); + _XGrSetColorOper (fg); + XFillRectangle (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, + x, + y, + w, + 1); + } + else { + if (fg != GrNOCOLOR) { + XSetForeground (_XGrDisplay, _XGrPatternGC, 1); + XSetBackground (_XGrDisplay, _XGrPatternGC, 0); + XPutImage (_XGrDisplay, + _XGrPattern, + _XGrPatternGC, + &ximage, + 0, + 0, + 0, + 0, + 8, + 1); + XSetStipple (_XGrDisplay, _XGrGC, _XGrPattern); + XSetTSOrigin (_XGrDisplay, _XGrGC, x, y); + XSetFillStyle (_XGrDisplay, _XGrGC, FillStippled); + _XGrSetForeColor (fg); + _XGrSetColorOper (fg); + XFillRectangle (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, + x, + y, + w, + 1); + } + if (bg != GrNOCOLOR) { + XSetForeground (_XGrDisplay, _XGrPatternGC, 0); + XSetBackground (_XGrDisplay, _XGrPatternGC, 1); + XPutImage (_XGrDisplay, + _XGrPattern, + _XGrPatternGC, + &ximage, + 0, + 0, + 0, + 0, + 8, + 1); + XSetStipple (_XGrDisplay, _XGrGC, _XGrPattern); + XSetTSOrigin (_XGrDisplay, _XGrGC, x, y); + XSetFillStyle (_XGrDisplay, _XGrGC, FillStippled); + _XGrSetForeColor (bg); + _XGrSetColorOper (bg); + XFillRectangle (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, + x, + y, + w, + 1); + } + } + XSetFillStyle (_XGrDisplay, _XGrGC, FillSolid); + + _XGrCopyBStore(x, y, w, 1); + _XGrCheckPixelCache(y, y); + } + GRX_LEAVE(); +} + +static +void bitblt(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op) +{ + GRX_ENTER(); + _XGrSetColorOper (op); + XCopyArea (_XGrDisplay, + (Drawable) src->gf_baseaddr[0], + (Drawable) dst->gf_baseaddr[0], + _XGrGC, + x, + y, + w, + h, + dx, + dy); + + _XGrCopyBStore(dx, dy, w, h); + _XGrCheckPixelCache(dy, dy+h-1); + + GRX_LEAVE(); +} + +static +void bltv2r(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) + _GrFrDrvGenericBitBlt(dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else { + XImage *ximage; + + ximage = XGetImage (_XGrDisplay, + (Drawable) src->gf_baseaddr[0], + sx, + sy, + w, + h, + AllPlanes, + ZPixmap); + if (ximage) { + int bytes_per_pixel = _XGrBitsPerPixel >> 3; + GrFrame tmp = *dst; + + tmp.gf_baseaddr[0] = + tmp.gf_baseaddr[1] = + tmp.gf_baseaddr[2] = + tmp.gf_baseaddr[3] = ximage->data; + tmp.gf_lineoffset = ximage->bytes_per_line; + + _GrFrDrvPackedBitBltR2R(dst, (dx * bytes_per_pixel), dy, + &tmp, 0, 0, + (w * bytes_per_pixel), h, + op + ); + XDestroyImage (ximage); + } + } + GRX_LEAVE(); +} + +static void bltr2v(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) + _GrFrDrvGenericBitBlt(dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else { + XImage ximage; + Visual *visual = DefaultVisual(_XGrDisplay,_XGrScreen); + + ximage.width = sx + w; + ximage.height = sy + h; + ximage.xoffset = 0; + ximage.format = ZPixmap; + ximage.data = src->gf_baseaddr[0]; + ximage.byte_order = LSBFirst; + ximage.bitmap_unit = BitmapUnit(_XGrDisplay); + ximage.bitmap_bit_order = BitmapBitOrder(_XGrDisplay); + ximage.bitmap_pad = BitmapPad(_XGrDisplay); + ximage.depth = _XGrDepth; + ximage.bytes_per_line = src->gf_lineoffset; + ximage.bits_per_pixel = _XGrBitsPerPixel; + ximage.red_mask = visual->red_mask; + ximage.green_mask = visual->green_mask; + ximage.blue_mask = visual->blue_mask; + ximage.obdata = NULL; + sttzero(&ximage.f); + +# ifndef PRE_R6_ICCCM + if (XInitImage (&ximage) != 0) +# endif + { + _XGrSetColorOper (op); + XPutImage (_XGrDisplay, + (Drawable) dst->gf_baseaddr[0], + _XGrGC, + &ximage, + sx, + sy, + dx, + dy, + w, + h); + _XGrCopyBStore(dx, dy, w, h); + _XGrCheckPixelCache(dy, dy+h-1); + } + } + GRX_LEAVE(); +} + +static +void putscanline(int x, int y, int w, const GrColor *scl, GrColor op) +{ + GrColor skipc; + int ind; + GRX_ENTER(); + skipc = op ^ GrIMAGE; + _XGrSetColorOper(op); + + for (ind = 0; ind < w; ind++) { + if (scl[ind] != skipc) { + _XGrSetForeColor(scl[ind]); + XDrawPoint (_XGrDisplay, + (Drawable) CURC->gc_baseaddr[0], + _XGrGC, x+ind, y); + } + } + + _XGrCopyBStore(x, y, w, 1); + _XGrCheckPixelCache(y, y); + + GRX_LEAVE(); +} + +#define ROUNDCOLORCOMP(x,n) ( \ + ((uint)(x) >= CLRINFO->mask[n]) ? \ + CLRINFO->mask[n] : \ + (((x) + CLRINFO->round[n]) & CLRINFO->mask[n]) \ +) + +static int init(GrVideoMode *mp) +{ + + if (_XGrColorNumPixels == 1) { + unsigned long i; + + for (i = 0; i < CLRINFO->ncolors; i++) { + if (i >= _XGrColorPixels[0] && i <= _XGrColorPixels[1]) { + CLRINFO->ctable[i].defined = FALSE; + } + else { + int r, g, b; + XColor xcolor; + + xcolor.red = 0; + xcolor.green = 0; + xcolor.blue = 0; + xcolor.pixel = i; + XQueryColors (_XGrDisplay, _XGrColormap, &xcolor, 1); + r = xcolor.red >> 8; + g = xcolor.green >> 8; + b = xcolor.blue >> 8; + /* + * Preallocate Cell; Only a buggy program will free this entry. + */ + CLRINFO->ctable[i].r = ROUNDCOLORCOMP(r,0); + CLRINFO->ctable[i].g = ROUNDCOLORCOMP(g,1); + CLRINFO->ctable[i].b = ROUNDCOLORCOMP(b,2); + CLRINFO->ctable[i].defined = TRUE; + CLRINFO->ctable[i].writable = FALSE; + CLRINFO->ctable[i].nused = 1; + CLRINFO->nfree--; + } + } + } + PIXEL_CACHE_INVALIDATE(); + return(TRUE); +} + + +GrFrameDriver _GrFrameDriverXWIN8 = { + GR_frameXWIN8, /* frame mode */ + GR_frameRAM8, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 8, /* bits per pixel */ + 8*16*1024L*1024L, /* max plane size the code can handle */ + init, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + putscanline +}; + +GrFrameDriver _GrFrameDriverXWIN16 = { + GR_frameXWIN16, /* frame mode */ + GR_frameRAM16, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 16, /* bits per pixel */ + 16*16*1024L*1024L, /* max plane size the code can handle */ + init, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + putscanline +}; + +GrFrameDriver _GrFrameDriverXWIN24 = { + GR_frameXWIN24, /* frame mode */ + GR_frameRAM24, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 24, /* bits per pixel */ + 24*16*1024L*1024L, /* max plane size the code can handle */ + init, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + putscanline +}; + +GrFrameDriver _GrFrameDriverXWIN32L = { + GR_frameXWIN32L, /* frame mode */ + GR_frameRAM32L, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ + 32*16*1024L*1024L, /* max plane size the code can handle */ + init, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + putscanline +}; + +GrFrameDriver _GrFrameDriverXWIN32H = { + GR_frameXWIN32H, /* frame mode */ + GR_frameRAM32H, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ + 32*16*1024L*1024L, /* max plane size the code can handle */ + init, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + putscanline +}; diff --git a/thirdparty/grx249/src/fdrivers/fdw32_24.c b/thirdparty/grx249/src/fdrivers/fdw32_24.c new file mode 100644 index 0000000..f781318 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/fdw32_24.c @@ -0,0 +1,196 @@ +/** + ** w32dib24.c ---- the 16M color Win32 linear frame buffer driver using DIB + ** + ** Copyright (c) 2003 Mariano Alvarez Fernandez + ** [e-mail: malfer@telefonica.net] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libwin32.h" +#include "fdrivers/driver24.h" + +static void w32_drawpixel(int x, int y, GrColor color) +{ + HDC hDC; + COLORREF c; + + GRX_ENTER(); + drawpixel(x, y, color); + + c = GetPixel ( hDCMem, x, y ); + hDC = GetDC ( hGRXWnd ); + SetPixelV ( hDC, x, y, c ); + ReleaseDC ( hGRXWnd, hDC ); + + GRX_LEAVE(); +} + +static void w32_drawline(int x, int y, int dx, int dy, GrColor color) +{ + RECT Rect; + + GRX_ENTER(); + drawline(x, y, dx, dy, color); + if (dx > 0 ) { + Rect.left = x; + Rect.right = x + dx + 1; + } else { + Rect.left = x + dx; + Rect.right = x + 1; + } + if (dy > 0 ) { + Rect.top = y; + Rect.bottom = y + dy + 1; + } else { + Rect.top = y + dy; + Rect.bottom = y + 1; + } + InvalidateRect(hGRXWnd, &Rect, FALSE); + GRX_LEAVE(); +} + +static void w32_drawhline(int x, int y, int w, GrColor color) +{ + RECT Rect; + + GRX_ENTER(); + drawhline(x, y, w, color); + Rect.left = x; + Rect.top = y; + Rect.right = x + w; + Rect.bottom = y + 1; + InvalidateRect(hGRXWnd, &Rect, FALSE); + GRX_LEAVE(); +} + +static void w32_drawvline(int x, int y, int h, GrColor color) +{ + RECT Rect; + + GRX_ENTER(); + drawvline(x, y, h, color); + Rect.left = x; + Rect.top = y; + Rect.right = x + 1; + Rect.bottom = y + h; + InvalidateRect(hGRXWnd, &Rect, FALSE); + GRX_LEAVE(); +} + +static void w32_drawblock(int x, int y, int w, int h, GrColor color) +{ + RECT Rect; + + GRX_ENTER(); + drawblock(x, y, w, h, color); + Rect.left = x; + Rect.top = y; + Rect.right = x + w; + Rect.bottom = y + h; + InvalidateRect(hGRXWnd, &Rect, FALSE); + GRX_LEAVE(); +} + +static void w32_drawbitmap(int x, int y, int w, int h, char far *bmp, + int pitch, int start, GrColor fg, GrColor bg) +{ + RECT Rect; + + GRX_ENTER(); + drawbitmap(x, y, w, h, bmp, pitch, start, fg, bg); + Rect.left = x; + Rect.top = y; + Rect.right = x + w; + Rect.bottom = y + h; + InvalidateRect(hGRXWnd, &Rect, FALSE); + GRX_LEAVE(); +} + +static void w32_drawpattern(int x, int y, int w, char patt, + GrColor fg, GrColor bg) +{ + RECT Rect; + + GRX_ENTER(); + drawpattern(x, y, w, patt, fg, bg); + Rect.left = x; + Rect.top = y; + Rect.right = x + w; + Rect.bottom = y + 1; + InvalidateRect(hGRXWnd, &Rect, FALSE); + GRX_LEAVE(); +} + +static void w32_bitblt(GrFrame *dst, int dx, int dy, GrFrame *src, + int sx, int sy, int w, int h, GrColor op) +{ + RECT Rect; + + GRX_ENTER(); + bitblt(dst, dx, dy, src, sx, sy, w, h, op); + Rect.left = dx; + Rect.top = dy; + Rect.right = dx + w; + Rect.bottom = dy + h; + InvalidateRect(hGRXWnd, &Rect, FALSE); + GRX_LEAVE(); +} + +void w32_putscanline(int x, int y, int w, + const GrColor far *scl, GrColor op ) +{ + GrColor skipc; + RECT Rect; + + GRX_ENTER(); + Rect.left = x; + Rect.top = y; + Rect.right = x + w; + Rect.bottom = y + 1; + + skipc = op ^ GrIMAGE; + op &= GrCMODEMASK; + for ( w += x; x < w; ++x) { + GrColor c = *(scl++); + if (c != skipc) drawpixel(x, y, (c|op)); + } + + InvalidateRect(hGRXWnd, &Rect, FALSE); + GRX_LEAVE(); +} + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverWIN32_24 = { + GR_frameWIN32_24, /* frame mode */ + GR_frameRAM24, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 24, /* bits per pixel */ + 24 * 16 * 1024L * 1024L, /* max plane size the code can handle */ + NULL, + readpixel, + w32_drawpixel, + w32_drawline, + w32_drawhline, + w32_drawvline, + w32_drawblock, + w32_drawbitmap, + w32_drawpattern, + w32_bitblt, + bitblt, + w32_bitblt, + _GrFrDrvGenericGetIndexedScanline, + w32_putscanline +}; diff --git a/thirdparty/grx249/src/fdrivers/fdw32_8.c b/thirdparty/grx249/src/fdrivers/fdw32_8.c new file mode 100644 index 0000000..fabeec5 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/fdw32_8.c @@ -0,0 +1,189 @@ +/** + ** w32dib24.c ---- the 256 color Win32 linear frame buffer driver using DIB + ** + ** Copyright (c) 2003 Josu Onandia + ** [e-mail: jonandia@fagorautomation.es] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libwin32.h" +#include "fdrivers/driver8.h" + +static void w32_drawpixel(int x, int y, GrColor color) +{ + HDC hDC; + COLORREF c; + + GRX_ENTER(); + drawpixel(x, y, color); + + c = GetPixel ( hDCMem, x, y ); + hDC = GetDC ( hGRXWnd ); + SetPixelV ( hDC, x, y, c ); + ReleaseDC ( hGRXWnd, hDC ); + + GRX_LEAVE(); +} + +static void w32_drawline(int x, int y, int dx, int dy, GrColor c) +{ + RECT r; + + GRX_ENTER(); + drawline(x, y, dx, dy, c); + if (dx > 0 ) { + r.left = x; + r.right = x + dx + 1; + } else { + r.left = x + dx; + r.right = x + 1; + } + if (dy > 0 ) { + r.top = y; + r.bottom = y + dy + 1; + } else { + r.top = y + dy; + r.bottom = y + 1; + } + InvalidateRect(hGRXWnd, &r, FALSE); + GRX_LEAVE(); +} + +static void w32_drawhline(int x, int y, int w, GrColor c) +{ + RECT r; + + GRX_ENTER(); + drawhline(x, y, w, c); + r.left = x; + r.top = y; + r.right = x + w; + r.bottom = y + 1; + InvalidateRect(hGRXWnd, &r, FALSE); + GRX_LEAVE(); +} + +static void w32_drawvline(int x, int y, int h, GrColor c) +{ + RECT r; + + GRX_ENTER(); + drawvline(x, y, h, c); + r.left = x; + r.top = y; + r.right = x + 1; + r.bottom = y + h; + InvalidateRect(hGRXWnd, &r, FALSE); + GRX_LEAVE(); +} + +static void w32_drawpattern(int x, int y, int w, char patt, + GrColor fg, GrColor bg) +{ + RECT r; + + GRX_ENTER(); + drawpattern(x, y, w, patt, fg, bg); + r.left = x; + r.top = y; + r.right = x + w; + r.bottom = y + 1; + InvalidateRect(hGRXWnd, &r, FALSE); + GRX_LEAVE(); +} + +static void w32_putscanline(int x, int y, int w, + const GrColor far *scl, GrColor op) +{ + RECT r; + + GRX_ENTER(); + putscanline(x, y, w, scl, op); + r.left = x; + r.top = y; + r.right = x + w; + r.bottom = y + 1; + InvalidateRect(hGRXWnd, &r, FALSE); + GRX_LEAVE(); +} + +static void w32_drawblock(int x, int y, int w, int h, GrColor c) +{ + RECT r; + + GRX_ENTER(); + drawblock(x, y, w, h, c); + r.left = x; + r.top = y; + r.right = x + w; + r.bottom = y + h; + InvalidateRect(hGRXWnd, &r, FALSE); + GRX_LEAVE(); +} + +static void w32_drawbitmap(int x, int y, int w, int h, char far *bmp, + int pitch, int start, GrColor fg, GrColor bg) +{ + RECT r; + + GRX_ENTER(); + drawbitmap(x, y, w, h, bmp, pitch, start, fg, bg); + r.left = x; + r.top = y; + r.right = x + w; + r.bottom = y + h; + InvalidateRect(hGRXWnd, &r, FALSE); + GRX_LEAVE(); +} + +static void w32_bitblit(GrFrame *dst, int dx, int dy, GrFrame *src, + int sx, int sy, int w, int h, GrColor op) +{ + RECT r; + + GRX_ENTER(); + bitblit(dst, dx, dy, src, sx, sy, w, h, op); + r.left = dx; + r.top = dy; + r.right = dx + w; + r.bottom = dy + h; + InvalidateRect(hGRXWnd, &r, FALSE); + GRX_LEAVE(); +} + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverWIN32_8 = { + GR_frameWIN32_8, /* frame mode */ + GR_frameRAM8, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 8, /* bits per pixel */ + 8 * 16 * 1024L * 1024L, /* max plane size the code can handle */ + NULL, + readpixel, + w32_drawpixel, + w32_drawline, + w32_drawhline, + w32_drawvline, + w32_drawblock, + w32_drawbitmap, + w32_drawpattern, + w32_bitblit, + bitblit, + w32_bitblit, + getindexedscanline, + w32_putscanline +}; + diff --git a/thirdparty/grx249/src/fdrivers/ftable.c b/thirdparty/grx249/src/fdrivers/ftable.c new file mode 100644 index 0000000..9e9a430 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/ftable.c @@ -0,0 +1,84 @@ +/** + ** ftable.c ---- a table of available frame drivers + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" + +GrFrameDriver *_GrFrameDriverTable[] = { +/* first the drivers for video based context */ +#if defined(__DJGPP__) || defined(__TURBOC__) || defined (__WATCOMC__) + &_GrFrameDriverHERC1, +#endif +#if defined(__MSDOS__) || (defined(__linux__) && !defined(__XWIN__)) +#ifdef __i386__ + &_GrFrameDriverEGAVGA1, + &_GrFrameDriverEGA4, + &_GrFrameDriverSVGA4, + &_GrFrameDriverVGA8X, +#endif + &_GrFrameDriverSVGA8, + &_GrFrameDriverSVGA16, + &_GrFrameDriverSVGA24, + &_GrFrameDriverSVGA32L, + &_GrFrameDriverSVGA32H, +#endif +#if defined(__DJGPP__) || defined(XF86DGA_FRAMEBUFFER) \ + || ( defined(LFB_BY_NEAR_POINTER) && !defined(__WIN32__) ) \ + || ( defined(__WATCOMC__) && defined ( __386__ ) ) + &_GrFrameDriverSVGA8_LFB, + &_GrFrameDriverSVGA16_LFB, + &_GrFrameDriverSVGA24_LFB, + &_GrFrameDriverSVGA32L_LFB, + &_GrFrameDriverSVGA32H_LFB, +#endif +#if defined(__XWIN__) && !defined(__SDL__) + &_GrFrameDriverXWIN8, + &_GrFrameDriverXWIN16, + &_GrFrameDriverXWIN24, + &_GrFrameDriverXWIN32L, + &_GrFrameDriverXWIN32H, +#endif +#if defined(__WIN32__) && !defined(__SDL__) + &_GrFrameDriverWIN32_8, + &_GrFrameDriverWIN32_24, +#endif +#if defined(__SDL__) + &_GrFrameDriverSDL8, + &_GrFrameDriverSDL16, + &_GrFrameDriverSDL24, + &_GrFrameDriverSDL32L, + &_GrFrameDriverSDL32H, +#endif +/* now the drivers for RAM based context */ + &_GrFrameDriverRAM1, + &_GrFrameDriverRAM4, + &_GrFrameDriverRAM8, + &_GrFrameDriverRAM16, +#ifdef GRX_USE_RAM3x8 + &_GrFrameDriverRAM3x8, +#else + &_GrFrameDriverRAM24, + &_GrFrameDriverRAM32L, + &_GrFrameDriverRAM32H, +#endif + NULL +}; + diff --git a/thirdparty/grx249/src/fdrivers/genblit.c b/thirdparty/grx249/src/fdrivers/genblit.c new file mode 100644 index 0000000..cc8bef9 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/genblit.c @@ -0,0 +1,55 @@ +/** + ** genblit.c ---- generic, VERY SLOW bitblt routine + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "memcopy.h" + +void _GrFrDrvGenericBitBlt(GrFrame *dst,int dx,int dy,GrFrame *src,int x,int y,int w,int h,GrColor op) +{ + GrFrame csave; + GrColor (*readpix)(GrFrame *,int,int); + void (*drawpix)(int,int,GrColor); + GrColor skipc; + int step; + GRX_ENTER(); + readpix = src->gf_driver->readpixel; + drawpix = dst->gf_driver->drawpixel; + skipc = op ^ GrIMAGE; + step = 1; + op &= GrCMODEMASK; + sttcopy(&csave,&CURC->gc_frame); + sttcopy(&CURC->gc_frame,dst); + if((dy > y) || ((dy == y) && (dx > x))) { + x += (w - 1); dx += (w - 1); + y += (h - 1); dy += (h - 1); + step = (-1); + } + do { + int dxx = dx,xx = x,ww = w; + do { + GrColor c = (*readpix)(src,xx,y); + if(c != skipc) (*drawpix)(dxx,dy,(c | op)); + dxx += step; xx += step; + } while(--ww > 0); + dy += step; y += step; + } while(--h > 0); + sttcopy(&CURC->gc_frame,&csave); + GRX_LEAVE(); +} + diff --git a/thirdparty/grx249/src/fdrivers/generic/bitblt.c b/thirdparty/grx249/src/fdrivers/generic/bitblt.c new file mode 100644 index 0000000..5472d77 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/generic/bitblt.c @@ -0,0 +1,48 @@ +/** + ** generic/bitblt.c ---- generic (slow) bitblt routine + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +void bitblt(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y,int w,int h,GrColor op) +{ + GrFrame csave; + GrColor skipc; + int step; + GRX_ENTER(); + skipc = op ^ GrIMAGE; + step = 1; + op &= GrCMODEMASK; + sttcopy(&csave,&CURC->gc_frame); + sttcopy(&CURC->gc_frame,dst); + if((dy > y) || ((dy == y) && (dx > x))) { + x += (w - 1); dx += (w - 1); + y += (h - 1); dy += (h - 1); + step = (-1); + } + do { + int dxx = dx,xx = x,ww = w; + do { + GrColor c = readpixel(src,xx,y); + if(c != skipc) drawpixel(dxx,dy,(c | op)); + dxx += step; xx += step; + } while(--ww > 0); + dy += step; y += step; + } while(--h > 0); + sttcopy(&CURC->gc_frame,&csave); + GRX_LEAVE(); +} + diff --git a/thirdparty/grx249/src/fdrivers/generic/bitmap.c b/thirdparty/grx249/src/fdrivers/generic/bitmap.c new file mode 100644 index 0000000..7d7b70a --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/generic/bitmap.c @@ -0,0 +1,39 @@ +/** + ** generic/bitmap.c ---- generic (=slow) font or bitmap draw routine + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +void drawbitmap(int x,int y,int w,int h, + char far *bmp,int pitch,int start,GrColor fg,GrColor bg) +{ + GRX_ENTER(); + w += x; h += y; + bmp += (unsigned int)start >> 3; + start &= 7; + do { + unsigned char far *bitp = (unsigned char far *)bmp; + unsigned char bits = *bitp; + unsigned char mask = 0x80 >> start; + int xx = x; + do { + drawpixel(xx,y,(bits & mask) ? fg : bg); + if((mask >>= 1) == 0) bits = *++bitp,mask = 0x80; + } while(++xx != w); + bmp += pitch; + } while(++y != h); + GRX_LEAVE(); +} + diff --git a/thirdparty/grx249/src/fdrivers/generic/block.c b/thirdparty/grx249/src/fdrivers/generic/block.c new file mode 100644 index 0000000..116a507 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/generic/block.c @@ -0,0 +1,26 @@ +/** + ** generic/block.c ---- generic (=slow) rectangle fill routine + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +void drawblock(int x,int y,int w,int h,GrColor c) +{ + GRX_ENTER(); + h += y; + do { drawhline(x,y,w,c); } while(++y != h); + GRX_LEAVE(); +} + diff --git a/thirdparty/grx249/src/fdrivers/generic/getiscl.c b/thirdparty/grx249/src/fdrivers/generic/getiscl.c new file mode 100644 index 0000000..3ef09c7 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/generic/getiscl.c @@ -0,0 +1,48 @@ + /** + ** generic/getiscl.c ---- generic getindexscanline routine + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + + +GrColor far *getindexedscanline(GrFrame *c, + int x,int y,int w, + int *indx ) +{ + GrColor far *pixels; + GrColor far *p; + GRX_ENTER(); + p = pixels = _GrTempBufferAlloc(sizeof(GrColor) * (w+1)); + if (pixels) { + if (indx) { + int i, oldx = -1; + GrColor col = 0; + for (i=0; i < w; ++i) { + int xx = x+indx[i]; + if (oldx != xx) { + oldx = xx; + col = readpixel(c,xx,y); + } + *(p++) = col; + } + } else { + for ( ; w > 0; --w) + *(p++) = readpixel(c,x++,y); + } + } + GRX_RETURN(pixels); +} +/* will return an array of pixel values pv[] read from frame */ +/* if indx == NULL: pv[i=0..w-1] = readpixel(x+i,y) */ +/* else pv[i=0..w-1] = readpixel(x+indx[i],y) */ diff --git a/thirdparty/grx249/src/fdrivers/generic/hline.c b/thirdparty/grx249/src/fdrivers/generic/hline.c new file mode 100644 index 0000000..e59fbb7 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/generic/hline.c @@ -0,0 +1,26 @@ +/** + ** generic/hline.c ---- generic (=slow) scan line fill routine + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +void drawhline(int x,int y,int w,GrColor c) +{ + GRX_ENTER(); + w += x; + do { drawpixel(x,y,c); } while(++x != w); + GRX_LEAVE(); +} + diff --git a/thirdparty/grx249/src/fdrivers/generic/line.c b/thirdparty/grx249/src/fdrivers/generic/line.c new file mode 100644 index 0000000..7164468 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/generic/line.c @@ -0,0 +1,50 @@ +/** + ** generic/line.c ---- generic (=slow) line draw routine + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +void drawline(int x,int y,int dx,int dy,GrColor c) +{ + int cnt,err,yoff; + GRX_ENTER(); + yoff = 1; + if(dx < 0) { + x += dx; dx = (-dx); + y += dy; dy = (-dy); + } + if(dy < 0) { + yoff = (-1); + dy = (-dy); + } + if(dx > dy) { + err = (cnt = dx) >> 1; + do { + drawpixel(x,y,c); + if((err -= dy) < 0) err += dx,y += yoff; + x++; + } while(--cnt >= 0); + } + else { + err = (cnt = dy) >> 1; + do { + drawpixel(x,y,c); + if((err -= dx) < 0) err += dy,x++; + y += yoff; + } while(--cnt >= 0); + } + GRX_LEAVE(); +} + diff --git a/thirdparty/grx249/src/fdrivers/generic/pattern.c b/thirdparty/grx249/src/fdrivers/generic/pattern.c new file mode 100644 index 0000000..fc37b93 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/generic/pattern.c @@ -0,0 +1,32 @@ +/** + ** generic/pattern.c ---- generic (=slow) patterned scan line fill routine + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +void drawpattern(int x,int y,int w,char patt,GrColor fg,GrColor bg) +{ + GR_int8u mask; + GRX_ENTER(); + mask = 0x80; + w += x; + do { + drawpixel(x,y,(patt & mask) ? fg : bg); + if((mask >>= 1) == 0) mask = 0x80; + } while(++x != w); + GRX_LEAVE(); +} + + diff --git a/thirdparty/grx249/src/fdrivers/generic/putscl.c b/thirdparty/grx249/src/fdrivers/generic/putscl.c new file mode 100644 index 0000000..272fb8d --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/generic/putscl.c @@ -0,0 +1,30 @@ +/** + ** generic/putscl.c ---- generic putscanline routine + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +void putscanline(int x,int y,int w, + const GrColor far *scl, GrColor op ) +{ + GrColor skipc; + GRX_ENTER(); + skipc = op ^ GrIMAGE; + op &= GrCMODEMASK; + for ( w += x; x < w; ++x) { + GrColor c = *(scl++); + if (c != skipc) drawpixel(x,y,(c|op)); + } + GRX_LEAVE(); +} diff --git a/thirdparty/grx249/src/fdrivers/generic/vline.c b/thirdparty/grx249/src/fdrivers/generic/vline.c new file mode 100644 index 0000000..add3728 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/generic/vline.c @@ -0,0 +1,26 @@ +/** + ** generic/bitblt.c ---- generic (=slow) vertical line draw routine + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +void drawvline(int x,int y,int h,GrColor c) +{ + GRX_ENTER(); + h += y; + do { drawpixel(x,y,c); } while(++y != h); + GRX_LEAVE(); +} + diff --git a/thirdparty/grx249/src/fdrivers/gengiscl.c b/thirdparty/grx249/src/fdrivers/gengiscl.c new file mode 100644 index 0000000..05246ba --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/gengiscl.c @@ -0,0 +1,54 @@ +/** + ** gengiscl.c ---- generic, VERY SLOW getindexscanline routine + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "allocate.h" + +/* will return an array of pixel values pv[] read from frame */ +/* if indx == NULL: pv[i=0..w-1] = readpixel(x+i,y) */ +/* else pv[i=0..w-1] = readpixel(x+indx[i],y) */ + +GrColor far *_GrFrDrvGenericGetIndexedScanline(GrFrame *c, + int x,int y,int w, + int *indx ) +{ + GrColor far *pixels; + GrColor far *p; + GRX_ENTER(); + DBGPRINTF(DBG_DRIVER,("x=%d, y=%d, w=%d\n",x,y,w)); + p = pixels = _GrTempBufferAlloc(sizeof(GrColor) * (w+1)); + if (pixels) { + _GR_readPix readpix = c->gf_driver->readpixel; + if (indx) { + int i, oldx = -1; + GrColor col = 0; + for (i=0; i < w; ++i) { + int xx = x+indx[i]; + if (oldx != xx) { + oldx = xx; + col = (*readpix)(c,xx,y); + } + *(p++) = col; + } + } else { + for ( ; w > 0; --w) + *(p++) = (*readpix)(c,x++,y); + } + } + GRX_RETURN(pixels); +} diff --git a/thirdparty/grx249/src/fdrivers/genptscl.c b/thirdparty/grx249/src/fdrivers/genptscl.c new file mode 100644 index 0000000..e36b883 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/genptscl.c @@ -0,0 +1,38 @@ +/** + ** genptscl.c ---- generic, VERY SLOW putscanline routine + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" + +/* will draw array of pixel values to current context */ + +void _GrFrDrvGenericPutScanline(int x,int y,int w, + const GrColor far *scl, GrColor op ) +{ + GrColor skipc; + _GR_drawPix drawpixel; + GRX_ENTER(); + drawpixel = CURC->gc_driver->drawpixel; + DBGPRINTF(DBG_DRIVER,("x=%d, y=%d, w=%d, op=%lx\n",x,y,w,op)); + skipc = op ^ GrIMAGE; + op &= GrCMODEMASK; + for ( w += x; x < w; ++x) { + GrColor c = *(scl++); + if (c != skipc) (*drawpixel)(x,y,(c|op)); + } + GRX_LEAVE(); +} diff --git a/thirdparty/grx249/src/fdrivers/genstrch.c b/thirdparty/grx249/src/fdrivers/genstrch.c new file mode 100644 index 0000000..b784850 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/genstrch.c @@ -0,0 +1,150 @@ +/** + ** genstrch.c ---- generic (and slow) stretching bitblt routine + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "allocate.h" +#include "arith.h" +#include "mempeek.h" +#include "memcopy.h" + +/* ----------------------------- generic Bresenham line code for stretching */ + +typedef struct { + int x, y; + int dx, dy; + int cnt; + int err; +} _GR_lineData; + +static INLINE int XLineInit(_GR_lineData *ld, int x,int y,int dx,int dy) +{ + GRX_ENTER(); + ld->x = x; + ld->y = y; + ld->dx = dx; + ld->dy = dy; + ld->cnt = dx; + if (dx <= dy) ld->err = dx >> 1; + else ld->err = dx-dy; + GRX_RETURN(ld->cnt > 0); +} + +#define XLineStep(ldp) do { \ + (ldp)->err -= (ldp)->dy; \ + while((ldp)->err < 0) { \ + (ldp)->err += (ldp)->dx; \ + (ldp)->y += 1; \ + } \ + (ldp)->x++; \ + --((ldp)->cnt); \ +} while(0) + +#define XLineCheckDone(ldp) ((ldp)->cnt <= 0) + +/* ---------------------------------------------------- x- and y-dir stretch */ +static void stretch(GrFrame *dst,int dx,int dy,int dw, int dh, + GrFrame *src,int sx,int sy,int sw, int sh, + GrColor op) +{ + int maxi; + GRX_ENTER(); + setup_ALLOC(); + do { + GrFrame csave; + GrColor far *pixels = NULL; + _GR_lineData lne; + _GR_getIndexedScanline getscl = src->gf_driver->getindexedscanline; + _GR_putScanline putscl = dst->gf_driver->putscanline; + int rd_y = -1; + int *xsrc = ALLOC(sizeof(int) * dw); + if (!xsrc) break; + /* set up xsrc[0..dw-1] = (line 0,sx to dw-1,sx+sw-1).y */ + if(!XLineInit(&lne,0,sx,dw,sw)) { + FREE(xsrc); + break; + } + DBGPRINTF(DBG_DRIVER,("dw=%d, sw=%d\n",dw,sw)); + maxi = sx+sw-1; + do { + /* we need to check for upper bound here */ + /* in rare cases the last element could overflow */ + xsrc[lne.x] = min(lne.y,maxi); + DBGPRINTF(DBG_DRIVER,("xsrc[%d] = %d\n",lne.x,xsrc[lne.x])); + XLineStep(&lne); + } while (!XLineCheckDone(&lne)); + + if(!XLineInit(&lne,dy,sy,dh,sh)) { + FREE(xsrc); + break; + } + maxi = sy+sh-1; + sttcopy(&csave,&CURC->gc_frame); + sttcopy(&CURC->gc_frame,dst); + do { + int y = min(lne.y,maxi); + if (!pixels || y != rd_y) + pixels = getscl(src,sx,(rd_y=y),dw,xsrc); + if (pixels) + putscl(dx,lne.x,dw,pixels,op); + XLineStep(&lne); + } while (!XLineCheckDone(&lne)); + sttcopy(&CURC->gc_frame,&csave); + FREE(xsrc); + } while (0); + reset_ALLOC(); + GRX_LEAVE(); +} + +/* -----------------------------------------------------general stretch blit */ + +void _GrFrDrvGenericStretchBlt(GrFrame *dst,int dx,int dy,int dw,int dh, + GrFrame *src,int sx,int sy,int sw,int sh, + GrColor op) +{ + GRX_ENTER(); + if (sw > 0 && dw > 0 && sh > 0 && dh > 0) { + if (sw == dw) { + _GR_blitFunc blit; + if (dst->gf_onscreen) { + if(src->gf_onscreen) blit = dst->gf_driver->bitblt; + else blit = dst->gf_driver->bltr2v; + } else { + if(src->gf_onscreen) blit = dst->gf_driver->bltv2r; + else blit = dst->gf_driver->bitblt; + } + + if (sh == dh) { + /* no stretching required */ + (*blit)(dst,dx,dy,src,sx,sy,sw,sh,op); + } else { + /* can blit line by line */ + _GR_lineData yline; + if (XLineInit(&yline,dy,sy,dh,sh)) { + do { + (*blit)(dst,dx,yline.x,src,sx,yline.y,sw,1,op); + XLineStep(&yline); + } while (!XLineCheckDone(&yline)); + } + } + } else + stretch(dst,dx,dy,dw,dh, + src,sx,sy,sw,sh, + op); + } + GRX_LEAVE(); +} diff --git a/thirdparty/grx249/src/fdrivers/herc1.c b/thirdparty/grx249/src/fdrivers/herc1.c new file mode 100644 index 0000000..9003a7e --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/herc1.c @@ -0,0 +1,121 @@ +/** + ** herc1.c ---- the mono Hercules frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "mempeek.h" +#include "memcopy.h" +#include "memfill.h" + +#define HRES 720 +#define VRES 348 + +static unsigned int offtab[2 * VRES]; + +/* frame offset address calculation */ +#define FOFS(x,y) ( offtab[y] + ((x) >> 3) ) + +static int init(GrVideoMode *mp) +{ + int i, res; + GRX_ENTER(); + res = ( (mp->height == VRES) || (mp->height == 2*VRES) ) + && (mp->width == HRES); + if (res) { + for(i = 0; i < VRES; i++) { + offtab[i] = ((i & 3) * 0x2000U) + ((i >> 2) * (HRES / 8)); + offtab[i + VRES] = offtab[i] + 0x8000U; + } + } + GRX_RETURN(res); +} + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + char far *ptr; + GRX_ENTER(); + ptr = &SCRN->gc_baseaddr[0][FOFS(x,y)]; + setup_far_selector(SCRN->gc_selector); + GRX_RETURN((GrColor)(( peek_b_f(ptr) >> (7 - (x & 7)) ) & 1)); +} + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + char far *ptr; + unsigned cval; + GRX_ENTER(); + ptr = &CURC->gc_baseaddr[0][FOFS(x,y)]; + cval = ((unsigned)color & 1) << (7 - (x &= 7)); + setup_far_selector(CURC->gc_selector); + switch(C_OPER(color)) { + case C_XOR: poke_b_f_xor(ptr,cval); break; + case C_OR: poke_b_f_or(ptr,cval); break; + case C_AND: poke_b_f_and(ptr,~cval); break; + default: poke_b_f(ptr,((peek_b_f(ptr) & (~0x80 >> x)) | cval)); + } + GRX_LEAVE(); +} + +static +#include "fdrivers/generic/hline.c" + +static +#include "fdrivers/generic/vline.c" + +static +#include "fdrivers/generic/block.c" + +static +#include "fdrivers/generic/line.c" + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +static +#include "fdrivers/generic/bitblt.c" + +GrFrameDriver _GrFrameDriverHERC1 = { + GR_frameHERC1, /* frame mode */ + GR_frameRAM1, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 1, /* bits per pixel */ + 64*1024L, /* max plane size the code can handle */ + init, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + _GrFrDrvGenericBitBlt, + _GrFrDrvGenericBitBlt, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + diff --git a/thirdparty/grx249/src/fdrivers/lfb16.c b/thirdparty/grx249/src/fdrivers/lfb16.c new file mode 100644 index 0000000..16e4521 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/lfb16.c @@ -0,0 +1,63 @@ +/** + ** lfb16.c ---- the 32768/65536 color Super VGA linear frame buffer driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* -------------------------------------------------------------------- */ + +#define FAR_ACCESS +#include "fdrivers/driver16.h" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverSVGA16_LFB = { + GR_frameSVGA16_LFB, /* frame mode */ + GR_frameRAM16, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 16, /* bits per pixel */ + 16*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/lfb24.c b/thirdparty/grx249/src/fdrivers/lfb24.c new file mode 100644 index 0000000..152727a --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/lfb24.c @@ -0,0 +1,63 @@ +/** + ** lfb24.c ---- the 16M color Super VGA linear frame buffer driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* -------------------------------------------------------------------- */ + +#define FAR_ACCESS +#include "fdrivers/driver24.h" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverSVGA24_LFB = { + GR_frameSVGA24_LFB, /* frame mode */ + GR_frameRAM24, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 24, /* bits per pixel */ + 24*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + +#endif /* !defined(LFB_BY_NEAR_POINTER) */ diff --git a/thirdparty/grx249/src/fdrivers/lfb32h.c b/thirdparty/grx249/src/fdrivers/lfb32h.c new file mode 100644 index 0000000..9709d82 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/lfb32h.c @@ -0,0 +1,65 @@ +/** + ** lfb32h.c ---- the 16M color padded SVGA linear frame buffer driver (high) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* -------------------------------------------------------------------- */ + +#define PIX2COL(col) ((col)>>8) +#define COL2PIX(col) ((col)<<8) +#define FAR_ACCESS +#include "fdrivers/driver32.h" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverSVGA32H_LFB = { + GR_frameSVGA32H_LFB, /* frame mode */ + GR_frameRAM32H, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ + 32*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/lfb32l.c b/thirdparty/grx249/src/fdrivers/lfb32l.c new file mode 100644 index 0000000..d533707 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/lfb32l.c @@ -0,0 +1,65 @@ +/** + ** lfb32l.c ---- the 16M color padded SVGA linear frame buffer driver (low) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* -------------------------------------------------------------------- */ + +#define PIX2COL(col) ((col)&0xFFFFFF) +#define COL2PIX(col) ((col)&0xFFFFFF) +#define FAR_ACCESS +#include "fdrivers/driver32.h" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverSVGA32L_LFB = { + GR_frameSVGA32L_LFB, /* frame mode */ + GR_frameRAM32L, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ + 32*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/lfb8.c b/thirdparty/grx249/src/fdrivers/lfb8.c new file mode 100644 index 0000000..6f73d38 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/lfb8.c @@ -0,0 +1,63 @@ +/** + ** lfb8.c ---- the 256 color Super VGA linear frame buffer driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* -------------------------------------------------------------------- */ + +#define FAR_ACCESS +#include "fdrivers/driver8.h" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverSVGA8_LFB = { + GR_frameSVGA8_LFB, /* frame mode */ + GR_frameRAM8, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 8, /* bits per pixel */ + 8*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblit, + bltv2r, + bltr2v, + getindexedscanline, + putscanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/lfbbltrv.c b/thirdparty/grx249/src/fdrivers/lfbbltrv.c new file mode 100644 index 0000000..bad30ea --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/lfbbltrv.c @@ -0,0 +1,46 @@ +/** + ** lfbbltrv.c ---- packed ram->video blit operations for + ** 8,16,24 and 32bpp Super VGA linear frame buffer modes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* name of blit function to be created */ +#define BLITFUNC _GrFrDrvPackedBitBltR2V_LFB + +/* destination is video */ +#define WRITE_FAR _f +/* source is ram */ +#define READ_FAR _n + +/* need a selector before video access */ +#define BLITSEL dst->gf_selector + +#include "fdrivers/pblit_nb.h" + +#endif diff --git a/thirdparty/grx249/src/fdrivers/lfbbltvr.c b/thirdparty/grx249/src/fdrivers/lfbbltvr.c new file mode 100644 index 0000000..5a5c026 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/lfbbltvr.c @@ -0,0 +1,46 @@ +/** + ** lfbbltvr.c ---- packed video->ram blit operations for + ** 8,16,24 and 32bpp Super VGA linear frame buffer modes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* name of blit function to be created */ +#define BLITFUNC _GrFrDrvPackedBitBltV2R_LFB + +/* destination is RAM */ +#define WRITE_FAR _n +/* source is video */ +#define READ_FAR _f + +/* need a selector before video access */ +#define BLITSEL src->gf_selector + +#include "fdrivers/pblit_nb.h" + +#endif diff --git a/thirdparty/grx249/src/fdrivers/lfbbltvv.c b/thirdparty/grx249/src/fdrivers/lfbbltvv.c new file mode 100644 index 0000000..b6fd35b --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/lfbbltvv.c @@ -0,0 +1,49 @@ +/** + ** lfbbltvv.c ---- packed video->video blit operations for + ** 8,16,24 and 32bpp Super VGA linear frame buffer modes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* name of blit function to be created */ +#define BLITFUNC _GrFrDrvPackedBitBltV2V_LFB + +/* destination is video */ +#define WRITE_FAR _f +/* source is video */ +#define READ_FAR _f + +/* need a selector before video access */ +#define BLITSEL dst->gf_selector + +/* source and destination may overlap */ +#define BLIT_CAN_OVERLAP + +#include "fdrivers/pblit_nb.h" + +#endif diff --git a/thirdparty/grx249/src/fdrivers/pblit_nb.h b/thirdparty/grx249/src/fdrivers/pblit_nb.h new file mode 100644 index 0000000..364d4fd --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/pblit_nb.h @@ -0,0 +1,128 @@ +/** + ** pblit_nb.h ---- bitblt routine for packed (8,16,24,32 bpp) modes + ** (non banking, source and destination may overlap) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "mempeek.h" + +#include "pblit.h" + +/* WRITE_FAR should be defined as _f if destination is video */ +/* READ_FAR should be defined as _f if source is video */ + +#define __DOCPYF(WF,OP,RF) fwdcopy##WF##OP##RF(dptr,dptr,sptr,ww) +#define __DOCPYR(WF,OP,RF) revcopy##WF##OP##RF(dptr,dptr,sptr,ww) + +#define __DOIMGCPYF(WF,RF) DOIMGCOPY(FW,WF,RF,ww) +#define __DOIMGCPYR(WF,RF) DOIMGCOPY(RV,WF,RF,ww) + +/* indirection to resolve WF=WRITE_FAR / RF=READ_FAR macros */ +#define DOCPYF(WF,OP,RF) __DOCPYF(WF,OP,RF) +#define DOCPYR(WF,OP,RF) __DOCPYR(WF,OP,RF) +#define DOIMGCPYF(WF,RF) __DOIMGCPYF(WF,RF) +#define DOIMGCPYR(WF,RF) __DOIMGCPYR(WF,RF) + +/* check if forward blit would overwrite source */ +#ifdef BLIT_CAN_OVERLAP +#ifdef __TURBOC__ +#define _USEG_(p) ((unsigned)(void _seg *)(void far *)(p)) +#define _UOFF_(p) ((unsigned)(void near *)(p)) +#define OVERLAP(dp,sp) ( _USEG_(dp) == _USEG_(sp) && _UOFF_(dp) > _UOFF_(sp) ) +#endif +#ifndef OVERLAP +#define OVERLAP(dp,sp) ( ((GR_int8 far *)dp) > ((GR_int8 far *)sp) ) +#endif +#endif + +/* for RAM3x8 support */ +#ifndef PLANE_ARG +#define PLANE 0 +#endif + +#ifdef LOCALFUNC +static +#endif +void BLITFUNC(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op +#ifdef PLANE_ARG + ,int PLANE +#endif + ) +{ + char far *dptr, *sptr; + unsigned dskip, sskip; + int oper, ww; + GR_int8u cval; + + GRX_ENTER(); + dskip = dst->gf_lineoffset - w; + sskip = src->gf_lineoffset - w; + oper = C_OPER(op); + cval = (GR_int8u)op; + + dptr = &dst->gf_baseaddr[PLANE][umuladd32(dy,dst->gf_lineoffset,dx)]; + sptr = &src->gf_baseaddr[PLANE][umuladd32(sy,src->gf_lineoffset,sx)]; + +# ifdef BLITSEL + setup_far_selector(BLITSEL); +# endif + +# ifdef BLIT_CAN_OVERLAP + if(OVERLAP(dptr,sptr)) { + dptr += umuladd32((h-1),dst->gf_lineoffset,w-1); + sptr += umuladd32((h-1),src->gf_lineoffset,w-1); + do { + ww = w; + switch(oper) { + case C_IMAGE: DOIMGCPYR(WRITE_FAR,READ_FAR); break; + case C_XOR: DOCPYR(WRITE_FAR,_xor,READ_FAR); break; + case C_OR: DOCPYR(WRITE_FAR,_or,READ_FAR); break; + case C_AND: DOCPYR(WRITE_FAR,_and,READ_FAR); break; + default: DOCPYR(WRITE_FAR,_set,READ_FAR); break; + } + dptr -= dskip; + sptr -= sskip; + } while(--h != 0); + } else +#endif /* BLIT_CAN_OVERLAP */ + do { + ww = w; + switch(oper) { + case C_IMAGE: DOIMGCPYF(WRITE_FAR,READ_FAR); break; + case C_XOR: DOCPYF(WRITE_FAR,_xor,READ_FAR); break; + case C_OR: DOCPYF(WRITE_FAR,_or,READ_FAR); break; + case C_AND: DOCPYF(WRITE_FAR,_and,READ_FAR); break; + default: DOCPYF(WRITE_FAR,_set,READ_FAR); break; + } + dptr += dskip; + sptr += sskip; + } while(--h != 0); + GRX_LEAVE(); +} + +#undef __DOCPYF +#undef __DOCPYR +#undef DOCPYF +#undef DOCPYR diff --git a/thirdparty/grx249/src/fdrivers/pblitr2r.c b/thirdparty/grx249/src/fdrivers/pblitr2r.c new file mode 100644 index 0000000..dfa47df --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/pblitr2r.c @@ -0,0 +1,54 @@ +/** + ** pblitr2r.c ---- RAM to RAM bitblt routine for packed (8,16,24,32 bpp) modes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#ifdef GRX_USE_RAM3x8 + +/* name of blit function to be created */ +#define BLITFUNC _GrFrDrvPackedBitBltR2Rpl +/* create function with additional 'int plane' as last arg */ +#define PLANE_ARG + +#else /* GRX_USE_RAM3x8 */ + +/* name of blit function to be created */ +#define BLITFUNC _GrFrDrvPackedBitBltR2R + +#endif /* GRX_USE_RAM3x8 */ + +/* only RAM access, use _n to keep preprocessor happy */ + +#define WRITE_FAR _n +#define READ_FAR _n + +/* source and destination may overlap */ +#define BLIT_CAN_OVERLAP + +#include "fdrivers/pblit_nb.h" + + +#ifdef GRX_USE_RAM3x8 +void _GrFrDrvPackedBitBltR2R(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + _GrFrDrvPackedBitBltR2Rpl(dst,dx,dy,src,sx,sy,w,h,op,0); +} +#endif diff --git a/thirdparty/grx249/src/fdrivers/pblitr2v.c b/thirdparty/grx249/src/fdrivers/pblitr2v.c new file mode 100644 index 0000000..49fa2df --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/pblitr2v.c @@ -0,0 +1,74 @@ +/** + ** pblitr2v.c ---- RAM to video bitblt routine for packed (8, 16, 24, 32 bpp) modes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "mempeek.h" +#include "memcopy.h" +#include "pblit.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),(x)) + +void _GrFrDrvPackedBitBltR2V(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + GR_int32u doff; + char far *dptr, *sptr; + unsigned int dskip, sskip; + int oper; + GR_int8u cval; + + GRX_ENTER(); + dskip = dst->gf_lineoffset; + doff = FOFS(dx,dy,dskip); + sskip = src->gf_lineoffset; + sptr = &src->gf_baseaddr[0][FOFS(sx,sy,sskip)]; + dskip -= w; + sskip -= w; + oper = C_OPER(op); + cval = (GR_int8u)op; + +# define DOICPY() DOIMGCOPY(FW,_f,_n,w1) + + setup_far_selector(dst->gf_selector); + do { + unsigned int w1 = BANKLFT(doff); + unsigned int w2 = w - (w1 = umin(w,w1)); + do { + dptr = &dst->gf_baseaddr[0][BANKPOS(doff)]; + CHKBANK(BANKNUM(doff)); + doff += w1; + if (w1) switch(oper) { + case C_IMAGE: DOICPY(); break; + case C_XOR: fwdcopy_f_xor(dptr,dptr,sptr,w1); break; + case C_OR: fwdcopy_f_or (dptr,dptr,sptr,w1); break; + case C_AND: fwdcopy_f_and(dptr,dptr,sptr,w1); break; + default: fwdcopy_f_set(dptr,dptr,sptr,w1); break; + } + w1 = w2; + w2 = 0; + } while(w1 != 0); + doff += dskip; + sptr += sskip; + } while(--h != 0); + GRX_LEAVE(); +} + diff --git a/thirdparty/grx249/src/fdrivers/pblitv2r.c b/thirdparty/grx249/src/fdrivers/pblitv2r.c new file mode 100644 index 0000000..64aefc5 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/pblitv2r.c @@ -0,0 +1,72 @@ +/** + ** pblitv2r.c ---- video to RAM bitblt routine for packed (8, 16, 24, 32 bpp) modes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "mempeek.h" +#include "memcopy.h" +#include "pblit.h" + + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),(x)) + +void _GrFrDrvPackedBitBltV2R(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + char far *dptr, *sptr; + GR_int32u soff; + unsigned dskip, sskip; + int oper; + GR_int8u cval; + + GRX_ENTER(); + dptr = &dst->gf_baseaddr[0][FOFS(dx,dy,dst->gf_lineoffset)]; + soff = FOFS(sx,sy,src->gf_lineoffset); + dskip = dst->gf_lineoffset - w; + sskip = src->gf_lineoffset - w; + oper = C_OPER(op); + cval = (GR_int8u)op; + +# define DOICPY() DOIMGCOPY(FW,_n,_f,w1) + + setup_far_selector(src->gf_selector); + do { + unsigned w1 = BANKLFT(soff); + unsigned w2 = w - (w1 = umin(w,w1)); + do { + sptr = &src->gf_baseaddr[0][BANKPOS(soff)]; + CHKBANK(BANKNUM(soff)); + soff += w1; + if (w1) switch(oper) { + case C_IMAGE: DOICPY(); break; + case C_XOR: fwdcopy_xor_f(sptr,dptr,sptr,w1); break; + case C_OR: fwdcopy_or_f( sptr,dptr,sptr,w1); break; + case C_AND: fwdcopy_and_f(sptr,dptr,sptr,w1); break; + default: fwdcopy_set_f(sptr,dptr,sptr,w1); break; + } + w1 = w2; + w2 = 0; + } while(w1 != 0); + dptr += dskip; + soff += sskip; + } while(--h != 0); + GRX_LEAVE(); +} diff --git a/thirdparty/grx249/src/fdrivers/pblitv2v.c b/thirdparty/grx249/src/fdrivers/pblitv2v.c new file mode 100644 index 0000000..55317c7 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/pblitv2v.c @@ -0,0 +1,163 @@ +/** + ** pblitv2v.c ---- video to video bitblt routine for packed (8, 16, 24, 32 bpp) modes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "allocate.h" +#include "arith.h" +#include "mempeek.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),(x)) + +#ifndef __XWIN__ +static INLINE +void dualpageblt(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h) +{ + unsigned long doff,soff; + int dskip,sskip; + int rb,rbb; + int wb,wbb; + + GRX_ENTER(); + if(dy > sy) { + dy += (h - 1); + sy += (h - 1); + dskip = -(dst->gf_lineoffset + w); + sskip = -(src->gf_lineoffset + w); + } + else { + dskip = dst->gf_lineoffset - w; + sskip = src->gf_lineoffset - w; + } + doff = FOFS(dx,dy,dst->gf_lineoffset); + soff = FOFS(sx,sy,src->gf_lineoffset); + wbb = (-1); + rbb = (-1); + setup_far_selector(dst->gf_selector); + do { + unsigned w1 = BANKLFT(doff); + unsigned w2 = BANKLFT(soff); + unsigned w3,ww; + w1 = umin(w,w1); + w2 = umin(w,w2); + usort(w1,w2); + w3 = w - w2; + w2 = w2 - w1; + if(w2 == 0) w2=w3 , w3=0; + do { + char far *dptr = &dst->gf_baseaddr[0][BANKPOS(doff)]; + char far *sptr = &src->gf_baseaddr[0][BANKPOS(soff)]; + wb = BANKNUM(doff); + rb = BANKNUM(soff); + if((rbb - rb) | (wbb - wb)) SRWBANK((rbb = rb),(wbb = wb)); + doff += w1; + soff += w1; +#ifndef MISALIGNED_16bit_OK + do { + poke_b_f(dptr,peek_b_f(sptr)); + dptr++; sptr++; + } while (w1--); +#else + if(w1 >= 3) { + if((int)(dptr) & 1) { + poke_b_f(dptr,peek_b_f(sptr)); + dptr++; sptr++; w1--; + } + if((int)(dptr) & 2) { + poke_w_f(dptr,peek_w_f(sptr)); + dptr += 2; sptr += 2; w1 -= 2; + } + if((ww = w1 >> 2) > 0) do { + poke_l_f(dptr,peek_l_f(sptr)); + dptr += 4; sptr += 4; + } while(--ww != 0); + } + if(w1 & 2) { + poke_w_f(dptr,peek_w_f(sptr)); + dptr += 2; sptr += 2; + } + if(w1 & 1) { + poke_b_f(dptr,peek_b_f(sptr)); + } +#endif + w1 = w2; + w2 = w3; + w3 = 0; + } while(w1 != 0); + doff += dskip; + soff += sskip; + } while(--h != 0); + GRX_LEAVE(); +} +#endif /* !__XWIN__ */ + +#define TMPSIZE 16384 + +void _GrFrDrvPackedBitBltV2V(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + + GRX_ENTER(); +#ifndef __XWIN__ + if((C_OPER(op) == C_WRITE) && DRVINFO->splitbanks && + ((dy != sy) || (sx >= dx))) { + dualpageblt(dst,dx,dy,src,sx,sy,w,h); + } else +#endif + { + GrFrame tmp; + int tmpx,tmpn; + tmp.gf_lineoffset = (w + 7) & ~3; + tmpn = umax(umin(h,(TMPSIZE / tmp.gf_lineoffset)),1); + tmpx = tmp.gf_lineoffset * tmpn; +#ifdef SMALL_STACK + tmp.gf_baseaddr[0] = _GrTempBufferAlloc(tmpx); +#else + setup_alloca(); + tmp.gf_baseaddr[0] = alloca((size_t)tmpx); +#endif + if(tmp.gf_baseaddr[0]) { + int ydir = 0; + tmpx = sx & 3; + if(dy > sy) { + dy += h; + sy += h; + ydir = ~0; + } + do { + int cnt = umin(h,tmpn); + dy -= (ydir & cnt); + sy -= (ydir & cnt); + _GrFrDrvPackedBitBltV2R(&tmp,tmpx,0,src,sx,sy,w,cnt,GrWRITE); + _GrFrDrvPackedBitBltR2V(dst,dx,dy,&tmp,tmpx,0,w,cnt,op); + dy += (~ydir & cnt); + sy += (~ydir & cnt); + h -= cnt; + } while(h != 0); + } +#ifndef SMALL_STACK + reset_alloca(); +#endif + } + GRX_LEAVE(); +} + diff --git a/thirdparty/grx249/src/fdrivers/ram1.c b/thirdparty/grx249/src/fdrivers/ram1.c new file mode 100644 index 0000000..7948817 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/ram1.c @@ -0,0 +1,212 @@ +/** + ** ram1.c ---- the mono system RAM frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "allocate.h" +#include "arith.h" +#include "mempeek.h" +#include "memcopy.h" +#include "memfill.h" + +#include "fdrivers/rblit_14.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),((x)>>3)) + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GR_int8u far *ptr; + GRX_ENTER(); + ptr = (GR_int8u far *)&c->gf_baseaddr[0][FOFS(x,y,c->gf_lineoffset)]; + GRX_RETURN((GrColor)( (*ptr >> (7 - (x & 7)) ) & 1)); +} + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + GR_int8u far *ptr; + GR_int8u cval; + + GRX_ENTER(); + ptr = (GR_int8u far *)&CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + cval = (color & 1) << (7 - (x &= 7)); + switch(C_OPER(color)) { + case C_XOR: *ptr ^= cval; break; + case C_OR: *ptr |= cval; break; + case C_AND: *ptr &= ~cval; break; + default: *ptr = (*ptr & (~0x80 >> x)) | cval; break; + } + GRX_LEAVE(); +} + +#define maskoper(d,op,s,msk,SF,DF) do { \ + unsigned char _c_ = peek_b##DF(d); \ + poke_b##DF((d), (_c_ & ~(msk)) | ((_c_ op (s)) & (msk))); \ + } while (0) +#define maskset(d,c,msk,DF) \ + poke_b##DF((d),(peek_b##DF(d) & ~(msk)) | ((c) & (msk))) + +static void drawhline(int x,int y,int w,GrColor color) { + int oper; + + GRX_ENTER(); + oper = C_OPER(color); + color &= 1; + if (!( !color && (oper==C_OR||oper==C_XOR)) && !(color && oper==C_AND) ) { + GR_int8u lm = 0xff >> (x & 7); + GR_int8u rm = 0xff << ((-(w + x)) & 7); + GR_int8u far *p = (GR_int8u far *)&CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + GR_repl cv = 0; + if (color) cv = ~cv; + w = ((x+w+7) >> 3) - (x >> 3); + if (w==1) lm &= rm; + if ( ((GR_int8u)(~lm)) ) { + switch(oper) { + case C_XOR: maskoper(p,^,(GR_int8u)cv,lm,_set,_n); break; + case C_OR: maskoper(p,|,(GR_int8u)cv,lm,_set,_n); break; + case C_AND: maskoper(p,&,(GR_int8u)cv,lm,_set,_n); break; + default: maskset(p,(GR_int8u)cv,lm,_n); break; + } + if (!(--w)) goto done; + ++p; + } + if ( ((GR_int8u)(~rm)) ) --w; + if (w) { + switch(oper) { + case C_XOR: repfill_b_xor(p,cv,w); break; + case C_OR: repfill_b_or(p,cv,w); break; + case C_AND: repfill_b_and(p,cv,w); break; + default: repfill_b(p,cv,w); break; + } + } + if ( ((GR_int8u)(~rm)) ) { + switch(oper) { + case C_XOR: maskoper(p,^,(GR_int8u)cv,rm,_set,_n); break; + case C_OR: maskoper(p,|,(GR_int8u)cv,rm,_set,_n); break; + case C_AND: maskoper(p,&,(GR_int8u)cv,rm,_set,_n); break; + default: maskset(p,(GR_int8u)cv,rm,_n); break; + } + } + } +done: + GRX_LEAVE(); +} + +static void drawvline(int x,int y,int h,GrColor color) +{ + unsigned int lwdt, mask, oper; + char far *p; + GRX_ENTER(); + oper = C_OPER(color); + color &= 1; + lwdt = CURC->gc_lineoffset; + mask = 0x80 >> (x & 7); + switch (oper) { + case C_XOR: + /* no need to xor anything with 0 */ + if (color) { + p = &CURC->gc_baseaddr[0][FOFS(x,y,lwdt)]; + colfill_b_xor(p,lwdt,mask,h); + } + break; + case C_OR: + /* no need to or anything with 0 */ + if (color) { + do_OR: + p = &CURC->gc_baseaddr[0][FOFS(x,y,lwdt)]; + colfill_b_or(p,lwdt,mask,h); + } + break; + case C_AND: + /* no need to and anything with 1 */ + if (!color) { + do_AND: + mask = ~mask; + p = &CURC->gc_baseaddr[0][FOFS(x,y,lwdt)]; + colfill_b_and(p,lwdt,mask,h); + } + break; + default: + if (color) goto do_OR; + goto do_AND; + } + GRX_LEAVE(); +} + +static +#include "fdrivers/generic/block.c" + +static +#include "fdrivers/generic/line.c" + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +static +#include "fdrivers/generic/bitblt.c" + +static void bltr2r(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y,int w,int h, + GrColor op) +{ + GRX_ENTER(); + _GR_rblit_14(dst,dx,dy,src,x,y,w,h,op,1,bitblt); + GRX_LEAVE(); +} + + +/* -------------------------------------------------------------------- */ + +static +#include "fdrivers/generic/getiscl.c" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverRAM1 = { + GR_frameRAM1, /* frame mode */ + GR_frameUndef, /* compatible RAM frame mode */ + FALSE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 1, /* bits per pixel */ +#ifdef __TURBOC__ + 65520L, /* max plane size the code can handle */ +#else + 16*1024L*1024L, /* max plane size the code can handle */ +#endif + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bltr2r, + NULL, + NULL, + getindexedscanline, + _GrFrDrvGenericPutScanline +}; + diff --git a/thirdparty/grx249/src/fdrivers/ram16.c b/thirdparty/grx249/src/fdrivers/ram16.c new file mode 100644 index 0000000..9f664f9 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/ram16.c @@ -0,0 +1,83 @@ +/** + ** ram16.c ---- the 32768/65536 color system RAM frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#include "fdrivers/driver16.h" + +GrFrameDriver _GrFrameDriverRAM16 = { + GR_frameRAM16, /* frame mode */ + GR_frameUndef, /* compatible RAM frame mode */ + FALSE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 16, /* bits per pixel */ +#ifdef __TURBOC__ + 65520L, /* max plane size the code can handle */ +#else + 16*16*1024L*1024L, /* max plane size the code can handle */ +#endif + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + NULL, + NULL, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +#ifdef LFB_BY_NEAR_POINTER + +/* always do RAM to RAM blit. May result in ** +** bottom first blits but this shouldn't matter */ + +GrFrameDriver _GrFrameDriverSVGA16_LFB = { + GR_frameSVGA16_LFB, /* frame mode */ + GR_frameRAM16, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 16, /* bits per pixel */ + 16*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bitblt, + bitblt, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/ram24.c b/thirdparty/grx249/src/fdrivers/ram24.c new file mode 100644 index 0000000..ccce5a7 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/ram24.c @@ -0,0 +1,84 @@ +/** + ** ram24.c ---- the 16M color system RAM frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + + +#undef FAR_ACCESS +#include "fdrivers/driver24.h" + +GrFrameDriver _GrFrameDriverRAM24 = { + GR_frameRAM24, /* frame mode */ + GR_frameUndef, /* compatible RAM frame mode */ + FALSE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 24, /* bits per pixel */ +#ifdef __TURBOC__ + 65520L, /* max plane size the code can handle */ +#else + 24*16*1024L*1024L, /* max plane size the code can handle */ +#endif + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + NULL, + NULL, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +#ifdef LFB_BY_NEAR_POINTER + +/* always do RAM to RAM blit. May result in ** +** bottom first blits but this shouldn't matter */ + +GrFrameDriver _GrFrameDriverSVGA24_LFB = { + GR_frameSVGA24_LFB, /* frame mode */ + GR_frameRAM24, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 24, /* bits per pixel */ + 24*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bitblt, + bitblt, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; +#endif /* defined(LFB_BY_NEAR_POINTER) */ diff --git a/thirdparty/grx249/src/fdrivers/ram32h.c b/thirdparty/grx249/src/fdrivers/ram32h.c new file mode 100644 index 0000000..f0c10d1 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/ram32h.c @@ -0,0 +1,86 @@ +/** + ** ram32h.c ---- the 16M color padded system RAM frame driver (high) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#define PIX2COL(col) ((col)>>8) +#define COL2PIX(col) ((col)<<8) + +#include "fdrivers/driver32.h" + +GrFrameDriver _GrFrameDriverRAM32H = { + GR_frameRAM32H, /* frame mode */ + GR_frameUndef, /* compatible RAM frame mode */ + FALSE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ +#ifdef __TURBOC__ + 65520L, /* max plane size the code can handle */ +#else + 32*16*1024L*1024L, /* max plane size the code can handle */ +#endif + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + NULL, + NULL, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +#ifdef LFB_BY_NEAR_POINTER + +/* always do RAM to RAM blit. May result in ** +** bottom first blits but this shouldn't matter */ + +GrFrameDriver _GrFrameDriverSVGA32H_LFB = { + GR_frameSVGA32H_LFB, /* frame mode */ + GR_frameRAM32H, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ + 32*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bitblt, + bitblt, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/ram32l.c b/thirdparty/grx249/src/fdrivers/ram32l.c new file mode 100644 index 0000000..361d300 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/ram32l.c @@ -0,0 +1,86 @@ +/** + ** ram32l.c ---- the 16M color padded system RAM frame driver (low) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#define PIX2COL(col) ((col)&0xFFFFFF) +#define COL2PIX(col) ((col)&0xFFFFFF) + +#include "fdrivers/driver32.h" + +GrFrameDriver _GrFrameDriverRAM32L = { + GR_frameRAM32L, /* frame mode */ + GR_frameUndef, /* compatible RAM frame mode */ + FALSE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ +#ifdef __TURBOC__ + 65520L, /* max plane size the code can handle */ +#else + 32*16*1024L*1024L, /* max plane size the code can handle */ +#endif + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + NULL, + NULL, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +#ifdef LFB_BY_NEAR_POINTER + +/* always do RAM to RAM blit. May result in ** +** bottom first blits but this shouldn't matter */ + +GrFrameDriver _GrFrameDriverSVGA32L_LFB = { + GR_frameSVGA32L_LFB, /* frame mode */ + GR_frameRAM32L, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ + 32*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bitblt, + bitblt, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/ram3x8.c b/thirdparty/grx249/src/fdrivers/ram3x8.c new file mode 100644 index 0000000..e5a30d4 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/ram3x8.c @@ -0,0 +1,200 @@ +/** + ** ram3x8.c ---- the 16M color planar (image) system RAM frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "access24.h" +#include "arith.h" +#include "docolor.h" +#include "mempeek.h" +#include "memcopy.h" +#include "memfill.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),(x)) + + +/* -------------------------------------------------------------------- */ + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GR_int32u offs; + GrColor pix; + GRX_ENTER(); + offs = FOFS(x,y,c->gf_lineoffset); + pix = 0; + WR24BYTE(pix,0,peek_b(&c->gf_baseaddr[0][offs])); + WR24BYTE(pix,1,peek_b(&c->gf_baseaddr[1][offs])); + WR24BYTE(pix,2,peek_b(&c->gf_baseaddr[2][offs])); + GRX_RETURN(pix); +} + +/* -------------------------------------------------------------------- */ + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + GR_int32u offs; + char far *p0,*p1,*p2; + GRX_ENTER(); + offs = FOFS(x,y,CURC->gc_lineoffset); + p0 = &CURC->gc_baseaddr[0][offs]; + p1 = &CURC->gc_baseaddr[1][offs]; + p2 = &CURC->gc_baseaddr[2][offs]; + switch(C_OPER(color)) { + case C_XOR: poke_b_xor(p0,RD24BYTE(color,0)); + poke_b_xor(p1,RD24BYTE(color,1)); + poke_b_xor(p2,RD24BYTE(color,2)); + break; + case C_OR: poke_b_or(p0,RD24BYTE(color,0)); + poke_b_or(p1,RD24BYTE(color,1)); + poke_b_or(p2,RD24BYTE(color,2)); + break; + case C_AND: poke_b_and(p0,RD24BYTE(color,0)); + poke_b_and(p1,RD24BYTE(color,1)); + poke_b_and(p2,RD24BYTE(color,2)); + break; + default: poke_b(p0,RD24BYTE(color,0)); + poke_b(p1,RD24BYTE(color,1)); + poke_b(p2,RD24BYTE(color,2)); + break; + } + GRX_LEAVE(); +} + +/* -------------------------------------------------------------------- */ + +static void drawhline(int x,int y,int w,GrColor color) { + int copr, pl; + GR_int32u offs; + GRX_ENTER(); + copr = C_OPER(color); + offs = FOFS(x,y,CURC->gc_lineoffset); + for (pl=0; pl < 3; ++pl) { + if(DOCOLOR8(color,copr)) { + GR_repl cval = freplicate_b(color); + char far *pp = &CURC->gc_baseaddr[pl][offs]; + int ww = w; + switch(copr) { + case C_XOR: repfill_b_xor(pp,cval,ww); break; + case C_OR: repfill_b_or( pp,cval,ww); break; + case C_AND: repfill_b_and(pp,cval,ww); break; + default: repfill_b( pp,cval,ww); break; + } + } + color >>= 8; + } + GRX_LEAVE(); +} + + +/* -------------------------------------------------------------------- */ + +static void drawvline(int x,int y,int h,GrColor color) +{ + int copr, pl; + GR_int32u offs; + unsigned lwdt; + GRX_ENTER(); + copr = C_OPER(color); + lwdt = CURC->gc_lineoffset; + offs = FOFS(x,y,lwdt); + for (pl=0; pl < 3; ++pl) { + if(DOCOLOR8(color,copr)) { + char far *pp = &CURC->gc_baseaddr[pl][offs]; + int hh = h; + switch(copr) { + case C_XOR: colfill_b_xor(pp,lwdt,(GR_int8u)color,hh); break; + case C_OR: colfill_b_or( pp,lwdt,(GR_int8u)color,hh); break; + case C_AND: colfill_b_and(pp,lwdt,(GR_int8u)color,hh); break; + default: colfill_b( pp,lwdt,(GR_int8u)color,hh); break; + } + } + color >>= 8; + } + GRX_LEAVE(); +} + +/* -------------------------------------------------------------------- */ + +static +#include "fdrivers/generic/block.c" + +static +#include "fdrivers/generic/line.c" + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +/* -------------------------------------------------------------------- */ + +static +#include "fdrivers/generic/bitblt.c" + +/* in pblitr2r.c if GRX_USE_RAM3x8 defined */ +extern void _GrFrDrvPackedBitBltR2Rpl(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y, + int w,int h,GrColor op,int plane); + +static void bitblit(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + int pl; + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) + bitblt(dst,dx,dy,src,sx,sy,w,h,op); + else + for (pl=0; pl < 3; ++pl) + _GrFrDrvPackedBitBltR2Rpl(dst,dx,dy,src,sx,sy,w,h,op,pl); + GRX_LEAVE(); +} + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverRAM3x8 = { + GR_frameRAM3x8, /* frame mode */ + GR_frameUndef, /* compatible RAM frame mode */ + FALSE, /* onscreen */ + 4, /* scan line width alignment */ + 3, /* number of planes */ + 24, /* bits per pixel */ +#ifdef __TURBOC__ + 65520L, /* max plane size the code can handle */ +#else + 8*16*1024L*1024L, /* max plane size the code can handle */ +#endif + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblit, + NULL, + NULL, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; diff --git a/thirdparty/grx249/src/fdrivers/ram4.c b/thirdparty/grx249/src/fdrivers/ram4.c new file mode 100644 index 0000000..f5aa2fa --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/ram4.c @@ -0,0 +1,293 @@ +/** + ** ram4.c ---- the 16 color RAM frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "memcopy.h" +#include "memfill.h" + +#include "fdrivers/rblit_14.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) ( umul32((y),(int)(lo)) + ((x)>>3) ) + + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GR_int32u offs; + unsigned mask; + GrColor pix; + GRX_ENTER(); + offs = FOFS(x,y,c->gf_lineoffset); + mask = 0x80 >> (x &= 7); + pix = (GrColor)( + (((c->gf_baseaddr[0][offs] & mask) ) | + ((c->gf_baseaddr[1][offs] & mask) << 1) | + ((c->gf_baseaddr[2][offs] & mask) << 2) | + ((c->gf_baseaddr[3][offs] & mask) << 3) + ) >> (7 - x) + ); + GRX_RETURN(pix); +} + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + GR_int32u offs; + unsigned int mask; + unsigned int cval; + int op; + GRX_ENTER(); + offs = FOFS(x,y,CURC->gc_lineoffset); + mask = 0x80 >> (x &= 7); + cval = (unsigned int)color << (7 - x); + switch(op = C_OPER(color) & 3) { + case C_WRITE: + case C_AND: + CURC->gc_baseaddr[0][offs] &= ((cval ) | ~mask); + CURC->gc_baseaddr[1][offs] &= ((cval >> 1) | ~mask); + CURC->gc_baseaddr[2][offs] &= ((cval >> 2) | ~mask); + CURC->gc_baseaddr[3][offs] &= ((cval >> 3) | ~mask); + if(op != C_WRITE) break; + case C_OR: + CURC->gc_baseaddr[0][offs] |= ((cval ) & mask); + CURC->gc_baseaddr[1][offs] |= ((cval >> 1) & mask); + CURC->gc_baseaddr[2][offs] |= ((cval >> 2) & mask); + CURC->gc_baseaddr[3][offs] |= ((cval >> 3) & mask); + break; + default: + CURC->gc_baseaddr[0][offs] ^= ((cval ) & mask); + CURC->gc_baseaddr[1][offs] ^= ((cval >> 1) & mask); + CURC->gc_baseaddr[2][offs] ^= ((cval >> 2) & mask); + CURC->gc_baseaddr[3][offs] ^= ((cval >> 3) & mask); + break; + } + GRX_LEAVE(); +} + +#define maskoper(d,op,s,msk) do { \ + unsigned char _c_ = peek_b(d); \ + poke_b((d),(_c_ & ~(msk)) | ((_c_ op (s)) & (msk)) ); \ +} while (0) +#define maskset(d,c,msk) \ + poke_b((d),(peek_b(d) & ~(msk)) | ((c) & (msk))) + +static void drawhline(int x,int y,int w,GrColor color) { + int oper, cval, wd, pl; + GR_int32u DO; + GR_int8u lm, rm; + GRX_ENTER(); + oper = C_OPER(color); + cval = (int)color; + DO = FOFS(x,y,CURC->gc_lineoffset); + lm = 0xff >> (x & 7); + rm = 0xff << ((-(w + x)) & 7); + wd = ((x+w+7) >> 3) - (x >> 3); + if (wd == 1) lm &= rm; + for (pl = 0; pl < 4; ++pl) { + GR_int32u cv = cval & 1 ? ~0L : 0L; + cval >>= 1; + if (!( !cv && (oper==C_OR||oper==C_XOR)) && !(cv && oper==C_AND) ) { + GR_int8u far *dptr = (GR_int8u far *)&CURC->gc_baseaddr[pl][DO]; + int ww = wd; + if ( ((GR_int8u)(~lm)) ) { + switch(oper) { + case C_XOR: maskoper(dptr,^,(GR_int8u)cv,lm); break; + case C_OR: maskoper(dptr,|,(GR_int8u)cv,lm); break; + case C_AND: maskoper(dptr,&,(GR_int8u)cv,lm); break; + default: maskset(dptr,(GR_int8u)cv,lm); break; + } + if (!(--ww)) continue; + ++dptr; + } + if ( ((GR_int8u)(~rm)) ) --ww; + if (ww) { + switch(oper) { + case C_XOR: repfill_b_xor(dptr,cv,ww); break; + case C_OR: repfill_b_or( dptr,cv,ww); break; + case C_AND: repfill_b_and(dptr,cv,ww); break; + default: repfill_b( dptr,cv,ww); break; + } + } + if ( ((GR_int8u)(~rm)) ) { + switch(oper) { + case C_XOR: maskoper(dptr,^,(GR_int8u)cv,rm); break; + case C_OR: maskoper(dptr,|,(GR_int8u)cv,rm); break; + case C_AND: maskoper(dptr,&,(GR_int8u)cv,rm); break; + default: maskset(dptr,(GR_int8u)cv,rm); break; + } + } + } + } + GRX_LEAVE(); +} +#undef maskoper + +static void drawvline(int x,int y,int h,GrColor color) +{ + unsigned int lwdt, mask, oper, hh; + char far *p; + GR_int32u offs; + GRX_ENTER(); + oper = C_OPER(color); + lwdt = CURC->gc_lineoffset; + offs = FOFS(x,y,lwdt); + mask = 0x80 >> (x & 7); + switch (oper) { + case C_XOR: + /* no need to xor anything with 0 */ + if (color&1) { + p = &CURC->gc_baseaddr[0][offs]; + hh = h; + colfill_b_xor(p,lwdt,mask,hh); + } + if (color&2) { + p = &CURC->gc_baseaddr[1][offs]; + hh = h; + colfill_b_xor(p,lwdt,mask,hh); + } + if (color&4) { + p = &CURC->gc_baseaddr[2][offs]; + hh = h; + colfill_b_xor(p,lwdt,mask,hh); + } + if (color&8) { + p = &CURC->gc_baseaddr[3][offs]; + colfill_b_xor(p,lwdt,mask,h); + } + break; + case C_OR: + /* no need to or anything with 0 */ + if (color&1) { + p = &CURC->gc_baseaddr[0][offs]; + hh = h; + colfill_b_or(p,lwdt,mask,hh); + } + if (color&2) { + p = &CURC->gc_baseaddr[1][offs]; + hh = h; + colfill_b_or(p,lwdt,mask,hh); + } + if (color&4) { + p = &CURC->gc_baseaddr[2][offs]; + hh = h; + colfill_b_or(p,lwdt,mask,hh); + } + if (color&8) { + p = &CURC->gc_baseaddr[3][offs]; + colfill_b_or(p,lwdt,mask,h); + } + break; + case C_AND: + /* no need to and anything with 1 */ + mask = ~mask; /* set up reset mask */ + if (!(color&1)) { + p = &CURC->gc_baseaddr[0][offs]; + hh = h; + colfill_b_and(p,lwdt,mask,hh); + } + if (!(color&2)) { + p = &CURC->gc_baseaddr[1][offs]; + hh = h; + colfill_b_and(p,lwdt,mask,hh); + } + if (!(color&4)) { + p = &CURC->gc_baseaddr[2][offs]; + hh = h; + colfill_b_and(p,lwdt,mask,hh); + } + if (!(color&8)) { + p = &CURC->gc_baseaddr[3][offs]; + colfill_b_and(p,lwdt,mask,h); + } + break; + default: { + p = &CURC->gc_baseaddr[0][offs]; + hh = h; + if (color&1) colfill_b_or(p,lwdt,mask,hh); + else colfill_b_and(p,lwdt,~mask,hh); + p = &CURC->gc_baseaddr[1][offs]; + hh = h; + if (color&2) colfill_b_or(p,lwdt,mask,hh); + else colfill_b_and(p,lwdt,~mask,hh); + p = &CURC->gc_baseaddr[2][offs]; + hh = h; + if (color&4) colfill_b_or(p,lwdt,mask,hh); + else colfill_b_and(p,lwdt,~mask,hh); + p = &CURC->gc_baseaddr[3][offs]; + if (color&8) colfill_b_or(p,lwdt,mask,h); + else colfill_b_and(p,lwdt,~mask,h); + break; + } + } + GRX_LEAVE(); +} + +static +#include "fdrivers/generic/block.c" + +static +#include "fdrivers/generic/line.c" + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +static +#include "fdrivers/generic/bitblt.c" + +static void bltr2r(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y,int w,int h, + GrColor op) +{ + GRX_ENTER(); + _GR_rblit_14(dst,dx,dy,src,x,y,w,h,op,4,bitblt); + GRX_LEAVE(); +} + +GrFrameDriver _GrFrameDriverRAM4 = { + GR_frameRAM4, /* frame mode */ + GR_frameUndef, /* compatible RAM frame mode */ + FALSE, /* onscreen */ + 4, /* scan line width alignment */ + 4, /* number of planes */ + 4, /* bits per pixel */ +#ifdef __TURBOC__ + 65520L, /* max plane size the code can handle */ +#else + 16*1024L*1024L, /* max plane size the code can handle */ +#endif + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bltr2r, + NULL, + NULL, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; diff --git a/thirdparty/grx249/src/fdrivers/ram8.c b/thirdparty/grx249/src/fdrivers/ram8.c new file mode 100644 index 0000000..b373d1b --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/ram8.c @@ -0,0 +1,89 @@ +/** + ** ram8.c ---- the 256 color system RAM frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +/* -------------------------------------------------------------------- */ + +#include "fdrivers/driver8.h" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverRAM8 = { + GR_frameRAM8, /* frame mode */ + GR_frameUndef, /* compatible RAM frame mode */ + FALSE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 8, /* bits per pixel */ +#ifdef __TURBOC__ + 65520L, /* max plane size the code can handle */ +#else + 8*16*1024L*1024L, /* max plane size the code can handle */ +#endif + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblit, + NULL, + NULL, + getindexedscanline, + putscanline +}; + + +/* -------------------------------------------------------------------- */ +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +#ifdef LFB_BY_NEAR_POINTER + +/* always do RAM to RAM blit. May result in ** +** bottom first blits but this shouldn't matter */ + +GrFrameDriver _GrFrameDriverSVGA8_LFB = { + GR_frameSVGA8_LFB, /* frame mode */ + GR_frameRAM8, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 8, /* bits per pixel */ + 8*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblit, + bitblit, + bitblit, + getindexedscanline, + putscanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/rblit_14.c b/thirdparty/grx249/src/fdrivers/rblit_14.c new file mode 100644 index 0000000..ef5cd39 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/rblit_14.c @@ -0,0 +1,166 @@ +/** + ** rblit_14.c ---- ram to ram blit support functions for 1bpp and + ** 4bpp RAM frame drivers + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "allocate.h" +#include "arith.h" +#include "mempeek.h" +#include "memcopy.h" +#include "memfill.h" + +#include "fdrivers/rblit_14.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),((x)>>3)) + +#define maskoper(d,op,s,msk) do { \ + unsigned char _c_ = peek_b(d); \ + poke_b((d), (_c_ & ~(msk)) | ((_c_ op (s)) & (msk))); \ + } while (0) +#define maskset(d,c,msk) \ + poke_b((d),(peek_b(d) & ~(msk)) | ((c) & (msk))) + +static char far *LineBuff = NULL; + +static int do_alloc(int width) { + size_t bytes; + GRX_ENTER(); + bytes = sizeof(char) * (((width+7) >> 3)+2); + LineBuff = _GrTempBufferAlloc(bytes); + GRX_RETURN(LineBuff != NULL); +} + + +static void get_scanline(char far *dptr, char far *sptr, int w) { + GRX_ENTER(); + fwdcopy_set(sptr,dptr,sptr,w); + GRX_LEAVE(); +} + +static void put_scanline(char far *dptr,char far *sptr,int w, + GR_int8u lm, GR_int8u rm, int op ) { + GRX_ENTER(); + if (w==1) lm &= rm; + if ( ((GR_int8u)(~lm)) ) { + switch (op) { + case C_XOR: maskoper(dptr,^,*sptr,lm); break; + case C_OR : maskoper(dptr,|,*sptr,lm); break; + case C_AND: maskoper(dptr,&,*sptr,lm); break; + default : maskset(dptr,*sptr,lm); break; + } + if (--w == 0) goto done; + ++dptr; + ++sptr; + } + if ( ((GR_int8u)(~rm)) ) --w; + if (w) switch (op) { + case C_XOR: fwdcopy_xor(dptr,dptr,sptr,w); break; + case C_OR : fwdcopy_or( dptr,dptr,sptr,w); break; + case C_AND: fwdcopy_and(dptr,dptr,sptr,w); break; + default : fwdcopy_set(dptr,dptr,sptr,w); break; + } + if ( ((GR_int8u)(~rm)) ) + switch (op) { + case C_XOR: maskoper(dptr,^,*sptr,rm); break; + case C_OR : maskoper(dptr,|,*sptr,rm); break; + case C_AND: maskoper(dptr,&,*sptr,rm); break; + default : maskset(dptr,*sptr,rm); break; + } +done: + GRX_LEAVE(); +} + + +extern void _GR_shift_scanline(GR_int8u far **dst, + GR_int8u far **src, + int ws, int shift, int planes ); +#define shift_scanline(dst,src,w,sh) \ + _GR_shift_scanline((GR_int8u **)&(dst),(GR_int8u **)&(src),(w),(sh),1) + + +void _GR_rblit_14(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y,int w,int h, + GrColor op, int planes, _GR_blitFunc bitblt) +{ + int pl; + GRX_ENTER(); + if(GrColorMode(op) != GrIMAGE && do_alloc(w)) { + GR_int32u doffs, soffs; + int oper = C_OPER(op); + int shift = ((int)(x&7)) - ((int)(dx&7)); + GR_int8u lm = 0xff >> (dx & 7); + GR_int8u rm = 0xff << ((-(w + dx)) & 7); + int ws = ((x+w+7) >> 3) - (x >> 3); + int wd = ((dx+w+7) >> 3) - (dx >> 3); + int dskip = dst->gf_lineoffset; + int sskip = src->gf_lineoffset; + if ((dy>y) && (dst->gf_baseaddr[0]==src->gf_baseaddr[0])) { + /* reverse */ + dy += h-1; + y += h-1; + doffs = FOFS(dx,dy,dskip); + soffs = FOFS( x, y,sskip); + for (pl=0; pl < planes; ++pl) { + char far *dptr = &dst->gf_baseaddr[pl][doffs]; + char far *sptr = &src->gf_baseaddr[pl][soffs]; + int hh = h; + if (shift) { + while (hh-- > 0) { + shift_scanline(LineBuff,sptr,ws,shift); + put_scanline(dptr,LineBuff,wd,lm,rm,oper); + dptr -= dskip; + sptr -= sskip; + } + } else { + while (hh-- > 0) { + get_scanline(LineBuff, sptr, ws); + put_scanline(dptr,LineBuff,wd,lm,rm,oper); + dptr -= dskip; + sptr -= sskip; + } + } + } + } else { + /* forward */ + doffs = FOFS(dx,dy,dst->gf_lineoffset); + soffs = FOFS( x, y,src->gf_lineoffset); + for (pl=0; pl < planes; ++pl) { + char far *dptr = &dst->gf_baseaddr[pl][doffs]; + char far *sptr = &src->gf_baseaddr[pl][soffs]; + int hh = h; + if (shift) { + while (hh-- > 0) { + shift_scanline(LineBuff,sptr,ws,shift); + put_scanline(dptr,LineBuff,wd,lm,rm,oper); + dptr += dskip; + sptr += sskip; + } + } else { + while (hh-- > 0) { + put_scanline(dptr,sptr,wd,lm,rm,oper); + dptr += dskip; + sptr += sskip; + } + } + } + } + } else + bitblt(dst,dx,dy,src,x,y,w,h,op); + GRX_LEAVE(); +} diff --git a/thirdparty/grx249/src/fdrivers/rblit_14.h b/thirdparty/grx249/src/fdrivers/rblit_14.h new file mode 100644 index 0000000..9e42fcc --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/rblit_14.h @@ -0,0 +1,21 @@ +/** + ** rblit_14.h ---- ram to ram blit support functions for 1bpp and + ** 4bpp RAM frame drivers + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +void _GR_rblit_14(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y,int w,int h, + GrColor op, int planes, _GR_blitFunc bitblt); diff --git a/thirdparty/grx249/src/fdrivers/sdl16.c b/thirdparty/grx249/src/fdrivers/sdl16.c new file mode 100644 index 0000000..bb4077a --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/sdl16.c @@ -0,0 +1,65 @@ +/** + ** sdl16.c ---- the 32768/65536 color SDL frame buffer driver + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* -------------------------------------------------------------------- */ + + +#define FAR_ACCESS +#include "fdrivers/driver16.h" + +static +#include "fdrivers/generic/putscl.c" + +#include "fdrivers/sdlframe.h" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverSDL16 = { + GR_frameSDL16, /* frame mode */ + GR_frameRAM16, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 16, /* bits per pixel */ + 16*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + sdl_drawpixel, + sdl_drawline, + sdl_drawhline, + sdl_drawvline, + sdl_drawblock, + sdl_drawbitmap, + sdl_drawpattern, + sdl_bitblt, + bltv2r, + sdl_bltr2v, + _GrFrDrvGenericGetIndexedScanline, + sdl_putscanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/sdl24.c b/thirdparty/grx249/src/fdrivers/sdl24.c new file mode 100644 index 0000000..43ab073 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/sdl24.c @@ -0,0 +1,64 @@ +/** + ** sdl24.c ---- the 16M color SDL frame buffer driver + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* -------------------------------------------------------------------- */ + +#define FAR_ACCESS +#include "fdrivers/driver24.h" + +static +#include "fdrivers/generic/putscl.c" + +#include "fdrivers/sdlframe.h" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverSDL24 = { + GR_frameSDL24, /* frame mode */ + GR_frameRAM24, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 24, /* bits per pixel */ + 24*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + sdl_drawpixel, + sdl_drawline, + sdl_drawhline, + sdl_drawvline, + sdl_drawblock, + sdl_drawbitmap, + sdl_drawpattern, + sdl_bitblt, + bltv2r, + sdl_bltr2v, + _GrFrDrvGenericGetIndexedScanline, + sdl_putscanline +}; + +#endif /* !defined(LFB_BY_NEAR_POINTER) */ diff --git a/thirdparty/grx249/src/fdrivers/sdl32h.c b/thirdparty/grx249/src/fdrivers/sdl32h.c new file mode 100644 index 0000000..6f9fe23 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/sdl32h.c @@ -0,0 +1,66 @@ +/** + ** sdl32h.c ---- the 16M color padded SDL frame buffer driver (high) + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* -------------------------------------------------------------------- */ + +#define PIX2COL(col) ((col)>>8) +#define COL2PIX(col) ((col)<<8) +#define FAR_ACCESS +#include "fdrivers/driver32.h" + +static +#include "fdrivers/generic/putscl.c" + +#include "fdrivers/sdlframe.h" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverSDL32H = { + GR_frameSDL32H, /* frame mode */ + GR_frameRAM32H, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ + 32*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + sdl_drawpixel, + sdl_drawline, + sdl_drawhline, + sdl_drawvline, + sdl_drawblock, + sdl_drawbitmap, + sdl_drawpattern, + sdl_bitblt, + bltv2r, + sdl_bltr2v, + _GrFrDrvGenericGetIndexedScanline, + sdl_putscanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/sdl32l.c b/thirdparty/grx249/src/fdrivers/sdl32l.c new file mode 100644 index 0000000..a9aa717 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/sdl32l.c @@ -0,0 +1,66 @@ +/** + ** sdl32l.c ---- the 16M color padded SDL frame buffer driver (low) + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* -------------------------------------------------------------------- */ + +#define PIX2COL(col) ((col)&0xFFFFFF) +#define COL2PIX(col) ((col)&0xFFFFFF) +#define FAR_ACCESS +#include "fdrivers/driver32.h" + +static +#include "fdrivers/generic/putscl.c" + +#include "fdrivers/sdlframe.h" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverSDL32L = { + GR_frameSDL32L, /* frame mode */ + GR_frameRAM32L, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ + 32*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + sdl_drawpixel, + sdl_drawline, + sdl_drawhline, + sdl_drawvline, + sdl_drawblock, + sdl_drawbitmap, + sdl_drawpattern, + sdl_bitblt, + bltv2r, + sdl_bltr2v, + _GrFrDrvGenericGetIndexedScanline, + sdl_putscanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/sdl8.c b/thirdparty/grx249/src/fdrivers/sdl8.c new file mode 100644 index 0000000..94b0bf4 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/sdl8.c @@ -0,0 +1,62 @@ +/** + ** sdl8.c ---- the 256 color SDL frame buffer driver + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* some systems map LFB in normal user space (eg. Linux/svgalib) */ +/* near pointer stuff is equal to ram stuff :) */ +/* in this is the far pointer code using %fs descriptor */ +#ifndef LFB_BY_NEAR_POINTER + +#ifdef __TURBOC__ +#error This library will not work with as a 16-bit real-mode code +#endif + +/* -------------------------------------------------------------------- */ + +#define FAR_ACCESS +#include "fdrivers/driver8.h" + +#define bitblt bitblit +#include "fdrivers/sdlframe.h" + +/* -------------------------------------------------------------------- */ + +GrFrameDriver _GrFrameDriverSDL8 = { + GR_frameSDL8, /* frame mode */ + GR_frameRAM8, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 8, /* bits per pixel */ + 8*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + sdl_drawpixel, + sdl_drawline, + sdl_drawhline, + sdl_drawvline, + sdl_drawblock, + sdl_drawbitmap, + sdl_drawpattern, + sdl_bitblt, + bltv2r, + sdl_bltr2v, + getindexedscanline, + sdl_putscanline +}; + +#endif diff --git a/thirdparty/grx249/src/fdrivers/sdlframe.h b/thirdparty/grx249/src/fdrivers/sdlframe.h new file mode 100644 index 0000000..9c3891b --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/sdlframe.h @@ -0,0 +1,99 @@ +/** + ** sdlframe.h ---- the SDL wrapper for linear framebuffer drivers + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Using SDL_FillRect() does not provide any speedup above the margin + ** of error. Our main problem is sdl_drawpixel() and sdl_drawline() + ** being too slow in windowed modes. + ** + **/ + +#include "libsdl.h" +#include "memcopy.h" + +static INLINE void sdl_drawpixel(int x, int y, GrColor color) +{ + drawpixel(x, y, color); + SDL_UpdateRect(_SGrScreen, x, y, 1, 1); +} + +static void sdl_drawline(int x, int y, int dx, int dy, GrColor color) +{ + drawline(x, y, dx, dy, color); + + if(dx < 0) { + x += dx; + dx = -dx; + } + if(dy < 0) { + y += dy; + dy = -dy; + } + + SDL_UpdateRect(_SGrScreen, x, y, dx + 1, dy + 1); +} + +static INLINE void sdl_drawhline(int x, int y, int w, GrColor color) +{ + drawhline(x, y, w, color); + SDL_UpdateRect(_SGrScreen, x, y, w, 1); +} + +static INLINE void sdl_drawvline(int x, int y, int h, GrColor color) +{ + drawvline(x, y, h, color); + SDL_UpdateRect(_SGrScreen, x, y, 1, h); +} + +static INLINE void sdl_drawblock(int x, int y, int w, int h, GrColor color) +{ + drawblock(x, y, w, h, color); + SDL_UpdateRect(_SGrScreen, x, y, w, h); +} + +static INLINE void sdl_drawbitmap(int x, int y, int w, int h, char far *bmp, + int pitch, int start, GrColor fg, GrColor bg) +{ + drawbitmap(x, y, w, h, bmp, pitch, start, fg, bg); + SDL_UpdateRect(_SGrScreen, x, y, w, h); +} + +static INLINE void sdl_drawpattern(int x, int y, int w, char patt, GrColor fg, + GrColor bg) +{ + drawpattern(x, y, w, patt, fg, bg); + SDL_UpdateRect(_SGrScreen, x, y, w, 1); +} + +static INLINE void sdl_bitblt(GrFrame *dst, int dx, int dy, GrFrame *src, + int sx, int sy,int w,int h, GrColor op) +{ + bitblt(dst, dx, dy, src, sx, sy, w, h, op); + SDL_UpdateRect(_SGrScreen, dx, dy, w, h); +} + +static INLINE void sdl_bltr2v(GrFrame *dst, int dx, int dy, GrFrame *src, + int sx, int sy, int w, int h, GrColor op) +{ + bltr2v(dst, dx, dy, src, sx, sy, w, h, op); + SDL_UpdateRect(_SGrScreen, dx, dy, w, h); +} + +static INLINE void sdl_putscanline(int x, int y, int w, const GrColor far *scl, + GrColor op) +{ + putscanline(x, y, w, scl, op); + SDL_UpdateRect(_SGrScreen, x, y, w, 1); +} diff --git a/thirdparty/grx249/src/fdrivers/svga16.c b/thirdparty/grx249/src/fdrivers/svga16.c new file mode 100644 index 0000000..f27c7fe --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/svga16.c @@ -0,0 +1,435 @@ +/** + ** svga18.c ---- the 32768/65536 color Super VGA frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifdef __TURBOC__ +#pragma inline +#endif + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "mempeek.h" +#include "memfill.h" + +#if BYTE_ORDER!=HARDWARE_BYTE_ORDER +#error Mismatching byte order between ram and video ram ! +#endif + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),((x) << 1)) + + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GR_int32u offs; + GRX_ENTER(); + offs = FOFS(x,y,SCRN->gc_lineoffset); + CHKBANK(BANKNUM(offs)); + setup_far_selector(SCRN->gc_selector); + GRX_RETURN((GR_int16u)peek_w_f(&SCRN->gc_baseaddr[0][BANKPOS(offs)])); +} + + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + GR_int32u offs; + char far *ptr; + GRX_ENTER(); + offs = FOFS(x,y,CURC->gc_lineoffset); + ptr = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + setup_far_selector(CURC->gc_selector); + switch(C_OPER(color)) { + case C_XOR: poke_w_f_xor(ptr,(GR_int16u)color); break; + case C_OR: poke_w_f_or( ptr,(GR_int16u)color); break; + case C_AND: poke_w_f_and(ptr,(GR_int16u)color); break; + default: poke_w_f( ptr,(GR_int16u)color); break; + } + GRX_LEAVE(); +} + + +static void drawhline(int x,int y,int w,GrColor color) +{ + GR_int32u offs; + GR_repl cval; + unsigned int w1,w2; + GRX_ENTER(); + offs = FOFS(x,y,CURC->gc_lineoffset); + w2 = BANKLFT(offs) >> 1; + w2 = w - (w1 = umin(w,w2)); + cval = freplicate_w(color); + setup_far_selector(CURC->gc_selector); + do { + char far *pp = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + offs += (w1 << 1); + switch(C_OPER(color)) { + case C_XOR: repfill_w_f_xor(pp,cval,w1); break; + case C_OR: repfill_w_f_or( pp,cval,w1); break; + case C_AND: repfill_w_f_and(pp,cval,w1); break; + default: repfill_w_f( pp,cval,w1); break; + } + w1 = w2; + w2 = 0; + } while(w1 != 0); + GRX_LEAVE(); +} + + +static void drawvline(int x,int y,int h,GrColor color) +{ + unsigned int lwdt; + GR_int32u offs; + GRX_ENTER(); + lwdt = CURC->gc_lineoffset; + offs = FOFS(x,y,lwdt); + setup_far_selector(CURC->gc_selector); + do { + char far *pp = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + unsigned int h1 = BANKLFT(offs) / lwdt; + h -= (h1 = umin(h,umax(h1,1))); + CHKBANK(BANKNUM(offs)); + offs += (h1 * lwdt); + switch(C_OPER(color)) { + case C_XOR: colfill_w_f_xor(pp,lwdt,(GR_int16u)color,h1); break; + case C_OR: colfill_w_f_or( pp,lwdt,(GR_int16u)color,h1); break; + case C_AND: colfill_w_f_and(pp,lwdt,(GR_int16u)color,h1); break; + default: colfill_w_f( pp,lwdt,(GR_int16u)color,h1); break; + } + } while(h != 0); + GRX_LEAVE(); +} + + +static void drawblock(int x,int y,int w,int h,GrColor color) +{ + GR_int32u offs; + GR_repl cval; + int copr, skip; + GRX_ENTER(); + skip = CURC->gc_lineoffset; + offs = FOFS(x,y,skip); + skip -= w << 1; + cval = freplicate_w(color); + copr = C_OPER(color); + setup_far_selector(CURC->gc_selector); + do { + unsigned int w1,w2 = BANKLFT(offs) >> 1; + w2 = w - (w1 = umin(w,w2)); + do { + char far *pp = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + offs += (w1 << 1); + switch(copr) { + case C_XOR: repfill_w_f_xor(pp,cval,w1); break; + case C_OR: repfill_w_f_or( pp,cval,w1); break; + case C_AND: repfill_w_f_and(pp,cval,w1); break; + default: repfill_w_f( pp,cval,w1); break; + } + w1 = w2; + w2 = 0; + } while(w1 != 0); + offs += skip; + } while(--h != 0); + GRX_LEAVE(); +} + + +#if !defined(__WATCOMC__) && (defined(__DJGPP__) || defined(__TURBOC__)) +/* The VGA banked frame buffer must start on a 64k boundary +** for this optimized assembler code. +** Linux: mmap may place the frame buffer on a 4k boundary :( +** Watcom C++: Can't use ES register :( +*/ +static void drawline(int x,int y,int dx,int dy,GrColor color) +{ + struct { + int errsub; /* subtract from error term */ + int erradd; /* add to error term when carry */ + int offset1; /* add to pointer if no carry on error term */ + int offset2; /* add to pointer if carry / banking dir */ + } lndata; + long offs; + int npts,error,xstep; + char far *ptr; + + GRX_ENTER(); + +# ifdef __GNUC__ +# ifdef __i386__ +# define ASM_LINE1(OPC) asm volatile("" \ + " .align 2,0x90 \n" \ + "0: "#OPC"w %6,"I386_GCC_FAR_SELECTOR"(%0) \n" \ + " subl %7,%2 \n" \ + " jb 1f \n" \ + " subw $2,%3 \n" \ + " jb 2f \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 4f \n" \ + " .align 2,0x90 \n" \ + "1: addl 4 + %7,%2 \n" \ + " addw 12 + %7,%3 \n" \ + " jb 3f \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 4f \n" \ + "2: negl 8 + %7 \n" \ + "3: decl %1 \n" \ + "4: " \ + : "=r" (ptr), "=r" (npts), "=r" (error) \ + : "0" ((short)(long)(ptr)), "1" (npts), "2" (error), \ + "r" ((short)(color)), "o" (lndata) \ + ) +# define ASM_LINE2(OPC) asm volatile("" \ + " .align 2,0x90 \n" \ + "0: "#OPC"w %6,"I386_GCC_FAR_SELECTOR"(%0) \n" \ + " subl %7,%2 \n" \ + " jb 1f \n" \ + " addw 8 + %7,%3 \n" \ + " jb 2f \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 3f \n" \ + " .align 2,0x90 \n" \ + "1: addl 4 + %7,%2 \n" \ + " addw 12 + %7,%3 \n" \ + " jb 2f \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 3f \n" \ + "2: decl %1 \n" \ + "3: " \ + : "=r" (ptr), "=r" (npts), "=r" (error) \ + : "0" ((short)(long)(ptr)), "1" (npts), "2" (error), \ + "r" ((short)(color)), "o" (lndata) \ + ) +# endif +# endif +# ifdef __TURBOC__ +# define ASM_LINE1(OPC) { \ + _ES = FP_SEG(ptr); \ + _BX = FP_OFF(ptr); \ + _CX = npts; \ + _DX = error; \ + _AX = (int)color; \ + OPC##1loop: \ + asm OPC word ptr es:[bx],ax; \ + asm sub dx,word ptr lndata.errsub; \ + asm jb OPC##1adjust; \ + asm sub bx,2; \ + asm jb OPC##1newbank1; \ + asm loop OPC##1loop; \ + asm jmp OPC##1done; \ + OPC##1adjust: \ + asm add dx,word ptr lndata.erradd; \ + asm add bx,word ptr lndata.offset2; \ + asm jb OPC##1newbank2; \ + asm loop OPC##1loop; \ + asm jmp OPC##1done; \ + OPC##1newbank1: \ + asm neg word ptr lndata.offset1; \ + OPC##1newbank2: \ + asm dec cx; \ + OPC##1done: \ + *((short *)(&ptr)) = _BX; \ + npts = _CX; \ + error = _DX; \ + } +# define ASM_LINE2(OPC) { \ + _ES = FP_SEG(ptr); \ + _BX = FP_OFF(ptr); \ + _CX = npts; \ + _DX = error; \ + _AX = (int)color; \ + OPC##2loop: \ + asm OPC word ptr es:[bx],ax; \ + asm sub dx,word ptr lndata.errsub; \ + asm jb OPC##2adjust; \ + asm add bx,word ptr lndata.offset1; \ + asm jb OPC##2newbank; \ + asm loop OPC##2loop; \ + asm jmp OPC##2done; \ + OPC##2adjust: \ + asm add dx,word ptr lndata.erradd; \ + asm add bx,word ptr lndata.offset2; \ + asm jb OPC##2newbank; \ + asm loop OPC##2loop; \ + asm jmp OPC##2done; \ + OPC##2newbank: \ + asm dec cx; \ + OPC##2done: \ + *((short *)(&ptr)) = _BX; \ + npts = _CX; \ + error = _DX; \ + } +# endif + + if(dy < 0) { + y -= (dy = (-dy)); + x -= (dx = (-dx)); + } + if(dx < 0) { + xstep = (-2); + dx = (-dx); + } else + xstep = 2; + + offs = FOFS(x,y,CURC->gc_lineoffset); + ptr = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + setup_far_selector(CURC->gc_selector); + if(dx > dy) { + npts = dx + 1; + error = dx >> 1; + lndata.errsub = dy; + lndata.erradd = dx; + lndata.offset1 = xstep; + lndata.offset2 = CURC->gc_lineoffset + xstep; + if(xstep < 0) { + again_nonlinear: + lndata.offset1 = 1; + switch(C_OPER(color)) { + case C_XOR: ASM_LINE1(xor); break; + case C_OR: ASM_LINE1(or); break; + case C_AND: ASM_LINE1(and); break; + default: ASM_LINE1(mov); break; + } + if(npts == 0) goto done; + SETBANK(DRVINFO->curbank + lndata.offset1); + goto again_nonlinear; + } + } + else { + npts = dy + 1; + error = dy >> 1; + lndata.errsub = dx; + lndata.erradd = dy; + lndata.offset1 = CURC->gc_lineoffset; + lndata.offset2 = CURC->gc_lineoffset + xstep; + } + again_linear: + switch(C_OPER(color)) { + case C_XOR: ASM_LINE2(xor); break; + case C_OR: ASM_LINE2(or); break; + case C_AND: ASM_LINE2(and); break; + default: ASM_LINE2(mov); break; + } + if(npts == 0) goto done; + SETBANK(DRVINFO->curbank + 1); + goto again_linear; + done: + GRX_LEAVE(); +} +#else +static +#include "fdrivers/generic/line.c" +#endif + + +static +#include "fdrivers/generic/bitmap.c" + + +static +#include "fdrivers/generic/pattern.c" + + +static void bitblt(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltV2V( + dst,(dx << 1),dy, + src,(sx << 1),sy, + (w << 1),h, + op + ); + GRX_LEAVE(); +} + + +static void bltv2r(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltV2R( + dst,(dx << 1),dy, + src,(sx << 1),sy, + (w << 1),h, + op + ); + GRX_LEAVE(); +} + + +static void bltr2v(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltR2V( + dst,(dx << 1),dy, + src,(sx << 1),sy, + (w << 1),h, + op + ); + GRX_LEAVE(); +} + + +GrFrameDriver _GrFrameDriverSVGA16 = { + GR_frameSVGA16, /* frame mode */ + GR_frameRAM16, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 16, /* bits per pixel */ + 16*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; diff --git a/thirdparty/grx249/src/fdrivers/svga24.c b/thirdparty/grx249/src/fdrivers/svga24.c new file mode 100644 index 0000000..4bdcf4e --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/svga24.c @@ -0,0 +1,406 @@ +/** + ** svga24.c ---- the 16M color Super VGA frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "mempeek.h" +#include "memfill.h" +#include "access24.h" + +#if BYTE_ORDER!=HARDWARE_BYTE_ORDER +#error Mismatching byte order between ram and video ram ! +#endif + +/* helper ... */ +#define MULT3(x) ( (x)+(x)+(x) ) +#ifdef __TURBOC__ +#define REMAIN3(x) ( ((unsigned int)(x)) % 3 ) +#else +#define REMAIN3(x) ( (x) % 3 ) +#endif + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),MULT3(x)) + + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GrColor cval; + GR_int32u offs; + int bank; + char far *p; + GRX_ENTER(); + cval = (GrColor)0; + offs = FOFS(x,y,SCRN->gc_lineoffset); + bank = BANKNUM(offs); + p = &SCRN->gc_baseaddr[0][BANKPOS(offs)]; + setup_far_selector(SCRN->gc_selector); + CHKBANK(bank); + switch (BANKLFT(offs)) { + case 1 : cval = peek_b_f(p); + ++bank; + SETBANK(bank); + p = SCRN->gc_baseaddr[0]; + cval |= ((GR_int32u)peek_w_f(p)) << 8; + break; + case 2 : cval = peek_w_f(p); + ++bank; + SETBANK(bank); + p = SCRN->gc_baseaddr[0]; + WR24BYTE(cval,2,peek_b_f(p)); + break; +#ifdef PEEK_24_F_READS_ONE_MORE + case 3 : cval = peek_w_f(p); + WR24BYTE(cval,2,peek_b_f(p+2)); + break; +#endif + default: cval = peek_24_f(p); + break; + } + GRX_RETURN(cval); +} + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + GR_int32u offs; + int bank; + char far *p; + GRX_ENTER(); + offs = FOFS(x,y,CURC->gc_lineoffset); + p = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + setup_far_selector(CURC->gc_selector); + bank = BANKNUM(offs); + CHKBANK(bank); + switch(C_OPER(color)) { + case C_XOR: + switch (BANKLFT(offs)) { + case 1: + poke_b_f_xor(p,(GR_int8u)color); + SETBANK(++bank); + p = SCRN->gc_baseaddr[0]; + poke_b_f_xor(p,RD24BYTE(color,1)); + poke_b_f_xor(p+1,RD24BYTE(color,2)); + break; + case 2: + poke_w_f_xor(p,(GR_int16u)color); + SETBANK(++bank); + p = SCRN->gc_baseaddr[0]; + poke_b_f_xor(p,RD24BYTE(color,2)); + break; + default: + poke_24_f_xor(p,color); + break; + } + break; + case C_OR: + switch (BANKLFT(offs)) { + case 1: + poke_b_f_or(p,(GR_int8u)color); + SETBANK(++bank); + p = SCRN->gc_baseaddr[0]; + poke_b_f_or(p,RD24BYTE(color,1)); + poke_b_f_or(p+1,RD24BYTE(color,2)); + break; + case 2: + poke_w_f_or(p,(GR_int16u)color); + SETBANK(++bank); + p = SCRN->gc_baseaddr[0]; + poke_b_f_or(p,RD24BYTE(color,2)); + break; + default: + poke_24_f_or(p,color); + break; + } + break; + case C_AND: + switch (BANKLFT(offs)) { + case 1: + poke_b_f_and(p,(GR_int8u)color); + SETBANK(++bank); + p = SCRN->gc_baseaddr[0]; + poke_b_f_and(p,RD24BYTE(color,1)); + poke_b_f_and(p+1,RD24BYTE(color,2)); + break; + case 2: + poke_w_f_and(p,(GR_int16u)color); + SETBANK(++bank); + p = SCRN->gc_baseaddr[0]; + poke_b_f_and(p,RD24BYTE(color,2)); + break; + default: + poke_24_f_and(p,color); + break; + } + break; + default: + switch (BANKLFT(offs)) { + case 1: + poke_b_f(p,(GR_int8u)color); + SETBANK(++bank); + p = SCRN->gc_baseaddr[0]; + poke_b_f(p,RD24BYTE(color,1)); + poke_b_f(p+1,RD24BYTE(color,2)); + break; + case 2: + poke_w_f(p,(GR_int16u)color); + SETBANK(++bank); + p = SCRN->gc_baseaddr[0]; + poke_b_f(p,RD24BYTE(color,2)); + break; + default: + poke_24_f(p,color); + break; + } + break; + } + GRX_LEAVE(); +} + + +static void drawhline(int x,int y,int w,GrColor color) +{ + char far *p; + int op, bank; + unsigned int w1, w2; + GR_int32u offs; + GR_int8u c2; + + GRX_ENTER(); + op = C_OPER(color); + offs = FOFS(x,y,CURC->gc_lineoffset); + p = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + setup_far_selector(CURC->gc_selector); + + c2 = RD24BYTE(color,2); + bank = BANKNUM(offs); + CHKBANK(bank); + w = MULT3(w); +# ifndef GRX_HAVE_FAST_REPFILL24 + if (c2 == RD24BYTE(color,0) && c2 == RD24BYTE(color,1) ) { + GR_repl cval = freplicate_b(c2); + w1 = BANKLFT(offs); + w2 = w - (w1 = umin(w,w1)); + for (;;) { + switch(op) { + case C_XOR: repfill_b_f_xor(p,cval,w1); break; + case C_OR: repfill_b_f_or( p,cval,w1); break; + case C_AND: repfill_b_f_and(p,cval,w1); break; + default: repfill_b_f( p,cval,w1); break; + } + if (!w2) break; + w1 = w2; + w2 = 0; + ++bank; + SETBANK(bank); + p = CURC->gc_baseaddr[0]; + } + goto done; + } +# endif + for (;;) { + w1 = BANKLFT(offs); + w1 = umin(w,w1); + w -= w1; + if (w1 <= 3) { + /* make sure we don't run in problems on first pixel */ + w2 = w1; + switch (w1) { + case 1 : switch (op) { + case C_XOR: poke_b_f_xor(p,color); break; + case C_OR: poke_b_f_or( p,color); break; + case C_AND: poke_b_f_and(p,color); break; + default: poke_b_f_set(p,color); break; + } + break; + case 2 : switch (op) { + case C_XOR: poke_w_f_xor(p,color); break; + case C_OR: poke_w_f_or( p,color); break; + case C_AND: poke_w_f_and(p,color); break; + default: poke_w_f_set(p,color); break; + } + break; + case 3 : switch (op) { + case C_XOR: poke_24_f_xor(p,color); break; + case C_OR: poke_24_f_or( p,color); break; + case C_AND: poke_24_f_and(p,color); break; + default: poke_24_f_set(p,color); break; + } + goto next_bank; + } + goto complete; + } + if (w) w2 = REMAIN3(w1); + else w2 = 0; + switch (op) { + case C_XOR: repfill_24_f_xor(p,color,w1); break; + case C_OR: repfill_24_f_or( p,color,w1); break; + case C_AND: repfill_24_f_and(p,color,w1); break; + default: repfill_24_f_set(p,color,w1); break; + } + if (w2) { + /* complete pixel on next bank */ + complete: + bank++; + SETBANK(bank); + p = CURC->gc_baseaddr[0]; + switch (w2) { + case 1 : offs = 2; + switch (op) { + case C_XOR: poke_w_f_xor(p,color>>8); break; + case C_OR: poke_w_f_or( p,color>>8); break; + case C_AND: poke_w_f_and(p,color>>8); break; + default: poke_w_f_set(p,color>>8); break; + } + if ( !(w-=2) ) goto done; + p += 2; + break; + case 2 : offs = 1; + switch (op) { + case C_XOR: poke_b_f_xor(p,c2); break; + case C_OR: poke_b_f_or( p,c2); break; + case C_AND: poke_b_f_and(p,c2); break; + default: poke_b_f_set(p,c2); break; + } + if ( !(--w) ) goto done; + ++p; + break; + } + continue; + } + next_bank: + if (!w) goto done; + bank++; + SETBANK(bank); + p = CURC->gc_baseaddr[0]; + offs = 0; + } + done: + GRX_LEAVE(); +} + +static +#include "fdrivers/generic/vline.c" + +static +#include "fdrivers/generic/block.c" + +static +#include "fdrivers/generic/line.c" + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +static void bitblt(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltV2V( + dst,MULT3(dx),dy, + src,MULT3(sx),sy, + MULT3(w),h, + op + ); + GRX_LEAVE(); +} + +#ifndef GRX_USE_RAM3x8 + +static void bltv2r(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltV2R( + dst,MULT3(dx),dy, + src,MULT3(sx),sy, + MULT3(w),h, + op + ); + GRX_LEAVE(); +} + +static void bltr2v(GrFrame *dst,int dx,int dy,GrFrame *src,int sx,int sy,int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) _GrFrDrvGenericBitBlt( + dst,dx,dy, + src,sx,sy, + w,h, + op + ); + else _GrFrDrvPackedBitBltR2V( + dst,MULT3(dx),dy, + src,MULT3(sx),sy, + MULT3(w),h, + op + ); + GRX_LEAVE(); +} + +#endif /* !GRX_USE_RAM3x8 */ + +GrFrameDriver _GrFrameDriverSVGA24 = { + GR_frameSVGA24, /* frame mode */ +#ifdef GRX_USE_RAM3x8 + GR_frameRAM3x8, /* compatible RAM frame mode */ +#else + GR_frameRAM24, /* compatible RAM frame mode */ +#endif + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 24, /* bits per pixel */ + 24*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, +#ifdef GRX_USE_RAM3x8 + _GrFrDrvGenericBitBlt, + _GrFrDrvGenericBitBlt, +#else + bltv2r, + bltr2v, +#endif + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; diff --git a/thirdparty/grx249/src/fdrivers/svga32h.c b/thirdparty/grx249/src/fdrivers/svga32h.c new file mode 100644 index 0000000..b6a45f7 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/svga32h.c @@ -0,0 +1,60 @@ +/** + ** svga32h.c ---- the 16M color padded Super VGA frame driver (high) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +#define PIX2COL(col) ((col)>>8) +#define COL2PIX(col) ((col)<<8) + +#include "fdrivers/banked32.h" + +GrFrameDriver _GrFrameDriverSVGA32H = { + GR_frameSVGA32H, /* frame mode */ +#ifdef GRX_USE_RAM3x8 + GR_frameRAM3x8, /* compatible RAM frame mode */ +#else + GR_frameRAM32H, /* compatible RAM frame mode */ +#endif + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ + 32*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, +#ifdef GRX_USE_RAM3x8 + _GrFrDrvGenericBitBlt, + _GrFrDrvGenericBitBlt, +#else + bltv2r, + bltr2v, +#endif + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + diff --git a/thirdparty/grx249/src/fdrivers/svga32l.c b/thirdparty/grx249/src/fdrivers/svga32l.c new file mode 100644 index 0000000..97a0f26 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/svga32l.c @@ -0,0 +1,59 @@ +/** + ** svga32l.c ---- the 16M color padded Super VGA frame driver (low) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + **/ + +#define PIX2COL(col) ((col)&((GrColor)0xFFFFFFUL)) +#define COL2PIX(col) ((col)&((GrColor)0xFFFFFFUL)) + +#include "fdrivers/banked32.h" + +GrFrameDriver _GrFrameDriverSVGA32L = { + GR_frameSVGA32L, /* frame mode */ +#ifdef GRX_USE_RAM3x8 + GR_frameRAM3x8, /* compatible RAM frame mode */ +#else + GR_frameRAM32L, /* compatible RAM frame mode */ +#endif + TRUE, /* onscreen */ + 4, /* line width alignment */ + 1, /* number of planes */ + 32, /* bits per pixel */ + 32*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bitblt, +#ifdef GRX_USE_RAM3x8 + _GrFrDrvGenericBitBlt, + _GrFrDrvGenericBitBlt, +#else + bltv2r, + bltr2v, +#endif + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; diff --git a/thirdparty/grx249/src/fdrivers/svga4.c b/thirdparty/grx249/src/fdrivers/svga4.c new file mode 100644 index 0000000..fc5fd83 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/svga4.c @@ -0,0 +1,624 @@ +/** + ** svga4.c ---- the 16 color (Super) VGA frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "allocate.h" +#include "arith.h" +#include "mempeek.h" +#include "memcopy.h" +#include "memfill.h" +#include "vgaregs.h" +#include "ioport.h" +#include "highlow.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(int)(lo),((x)>>3)) + +static GrColor lastcolor; +static int modereg; +static int writeops[] = { + (VGA_FUNC_SET << 8) + VGA_ROT_FN_SEL_REG, /* C_SET */ + (VGA_FUNC_XOR << 8) + VGA_ROT_FN_SEL_REG, /* C_XOR */ + (VGA_FUNC_OR << 8) + VGA_ROT_FN_SEL_REG, /* C_OR */ + (VGA_FUNC_AND << 8) + VGA_ROT_FN_SEL_REG /* C_AND */ +}; + +static size_t LineBytes = 0; +static GR_int8u far *LineBuff[4] = {NULL, NULL, NULL, NULL}; + +static INLINE +void reginit(void) { + GRX_ENTER(); + /* set write mode 3 and enable color compare */ + outport_w(VGA_GR_CTRL_PORT,(((8 + 3) << 8) | modereg)); + /* don't care register to 0 */ + outport_w(VGA_GR_CTRL_PORT,((0 << 8) | VGA_COLOR_DONTC_REG)); + /* enable all 4 planes for writing */ + outport_w(VGA_SEQUENCER_PORT,((0x0f << 8) | VGA_WRT_PLANE_ENB_REG)); + /* enable all 4 planes for set/reset */ + outport_w(VGA_GR_CTRL_PORT,((0x0f << 8) | VGA_SET_RESET_ENB_REG)); + lastcolor = (-1L); + GRX_LEAVE(); +} + +static int alloc_blit_buffer(void) { + size_t bytes; + GR_int8u far *base; + + GRX_ENTER(); + + bytes = LineBytes<<2; + base = (GR_int8u far *)_GrTempBufferAlloc(bytes); + LineBuff[0] = base; + LineBuff[1] = base+LineBytes; + LineBuff[2] = base+LineBytes*2; + LineBuff[3] = base+LineBytes*3; + GRX_RETURN(base != NULL); +} + +static int init(GrVideoMode *mp) +{ + GRX_ENTER(); + + /* save original mode register */ + outport_b(VGA_GR_CTRL_PORT,VGA_MODE_REG); + modereg = ((inport_b(VGA_GR_CTRL_DATA) & 0xfc) << 8) | VGA_MODE_REG; + + /* set up default register values */ + reginit(); + + /* set up LineBuff max. line length for blits */ + LineBytes = sizeof(char) * (((mp->width+7) >> 3)+2); + + GRX_RETURN(TRUE); +} + + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GR_int32u offs; + char far *ptr; + unsigned int mask, pixval; + GRX_ENTER(); + offs = FOFS(x,y,SCRN->gc_lineoffset); + ptr = &SCRN->gc_baseaddr[0][BANKPOS(offs)]; + mask = 0x80 >> (x &= 7); + CHKBANK(BANKNUM(offs)); + setup_far_selector(SCRN->gc_selector); + outport_w(VGA_GR_CTRL_PORT,modereg); + outport_w(VGA_GR_CTRL_PORT,((3 << 8) | VGA_RD_PLANE_SEL_REG)); + pixval = peek_b_f(ptr) & mask; + outport_b(VGA_GR_CTRL_DATA,2); + pixval = (peek_b_f(ptr) & mask) | (pixval << 1); + outport_b(VGA_GR_CTRL_DATA,1); + pixval = (peek_b_f(ptr) & mask) | (pixval << 1); + outport_b(VGA_GR_CTRL_DATA,0); + pixval = (peek_b_f(ptr) & mask) | (pixval << 1); + outport_w(VGA_GR_CTRL_PORT,(((8 + 3) << 8) | modereg)); + lastcolor = (-1L); + GRX_RETURN((GrColor)(pixval >> (7 - x))); +} + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + GR_int32u offs; + char far *ptr; + GRX_ENTER(); + offs = umul32(y,CURC->gc_lineoffset) + (x >> 3); + ptr = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + setup_far_selector(CURC->gc_selector); + if(lastcolor != color) { + outport_w(VGA_GR_CTRL_PORT,writeops[C_OPER(color) & 3]); + outport_w(VGA_GR_CTRL_PORT,((((int)color & 0x0f) << 8) | VGA_SET_RESET_REG)); + lastcolor = color; + } + poke_b_f_and(ptr,(0x80U >> (x & 7))); + GRX_LEAVE(); +} + +static void drawhline(int x,int y,int w,GrColor color) +{ + GR_int32u offs; + GR_int8u lmask, rmask; + unsigned int w1, w2; + int oper; + GRX_ENTER(); + oper = C_OPER(color); + offs = FOFS(x,y,CURC->gc_lineoffset); + w2 = BANKLFT(offs); + lmask = 0xff >> (x & 7); + rmask = 0xff << ((-(w += x)) & 7); + w = ((w + 7) >> 3) - (x >> 3); + w2 = w - (w1 = umin(w,w2)); + if(w == 1) lmask &= rmask; + setup_far_selector(CURC->gc_selector); + if(lastcolor != color) { + outport_w(VGA_GR_CTRL_PORT,writeops[oper & 3]); + outport_w(VGA_GR_CTRL_PORT,((((int)color & 0x0f) << 8) | VGA_SET_RESET_REG)); + lastcolor = color; + } + do { + GR_int8u far *pp = (GR_int8u far *)&CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + offs += w1; + if( ((GR_int8u)(~lmask)) ) { + poke_b_f_and(pp,lmask); + lmask = 0xff; + if(--w1 == 0) goto nextbank; + pp++; + } + if( ((GR_int8u)(~rmask)) && (w2 == 0)) { + w1--; + poke_b_f_and(&pp[w1],rmask); + if(w1 == 0) break; + } + if(oper == C_WRITE) repfill_b_f( pp,(-1),w1); + else rowfill_b_f_or(pp,0xff,w1); + nextbank: + w1 = w2; + w2 = 0; + } while(w1 != 0); + GRX_LEAVE(); +} + +static void drawvline(int x,int y,int h,GrColor color) +{ + unsigned int lwdt, mask; + GR_int32u offs; + GRX_ENTER(); + if(lastcolor != color) { + outport_w(VGA_GR_CTRL_PORT,writeops[C_OPER(color) & 3]); + outport_w(VGA_GR_CTRL_PORT,((((int)color & 0x0f) << 8) | VGA_SET_RESET_REG)); + lastcolor = color; + } + lwdt = CURC->gc_lineoffset; + offs = FOFS(x,y,lwdt); + mask = 0x80 >> (x & 7); + setup_far_selector(CURC->gc_selector); + do { + char far *pp = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + unsigned h1 = BANKLFT(offs) / lwdt; + h -= (h1 = umin(h,umax(h1,1))); + CHKBANK(BANKNUM(offs)); + offs += (h1 * lwdt); + colfill_b_f_and(pp,lwdt,mask,h1); + } while(h != 0); + GRX_LEAVE(); +} + +static void drawline(int x,int y,int dx,int dy,GrColor color) +{ + int cnt,err, yoff, mask; + GR_int32u offs; + GRX_ENTER(); + if(dx < 0) { + x += dx; dx = (-dx); + y += dy; dy = (-dy); + } + yoff = CURC->gc_lineoffset; + offs = FOFS(x,y,yoff); + if(dy < 0) { + yoff = (-yoff); + dy = (-dy); + } + mask = 0x80 >> (x & 7); + setup_far_selector(CURC->gc_selector); + if(lastcolor != color) { + outport_w(VGA_GR_CTRL_PORT,writeops[C_OPER(color) & 3]); + outport_w(VGA_GR_CTRL_PORT,((((int)color & 0x0f) << 8) | VGA_SET_RESET_REG)); + lastcolor = color; + } + if(dx > dy) { + char far *pp = NULL; + int newoffs = TRUE; + err = (cnt = dx) >> 1; + do { + if (newoffs) { + CHKBANK(BANKNUM(offs)); + pp = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + newoffs = FALSE; + } + poke_b_f_and(pp,mask); + if((err -= dy) < 0) { + err += dx; + offs += yoff; + newoffs = TRUE; + } + if((mask >>= 1) == 0) { + mask = 0x80; + offs++; + newoffs = TRUE; + } + } while(--cnt >= 0); + } + else { + err = (cnt = dy) >> 1; + do { + CHKBANK(BANKNUM(offs)); + poke_b_f_and(&CURC->gc_baseaddr[0][BANKPOS(offs)],mask); + if((err -= dx) < 0) { + err += dy; + if((mask >>= 1) == 0) { + mask = 0x80; + offs++; + } + } + offs += yoff; + } while(--cnt >= 0); + } + GRX_LEAVE(); +} + + +static +#include "fdrivers/generic/block.c" + + +static +#include "fdrivers/generic/bitmap.c" + + +static +#include "fdrivers/generic/pattern.c" + + +/* some routines for fast blit operations +** +** All algorithms use a preallocated buffer for temporary +** storage and manipulation of pixel data: LineBuff[4] +** +** video -> video algorithm: +** for plane = 0 .. 3 +** select plane +** read data from scanline into LineBuff[plane] +** if bit alignment between source and destination differs +** shift LineBuff for destination bit alignment +** for plane = 0 .. 3 +** select plane +** write LineBuff[plane] to video memory +** +** ram -> video algorithm: +** for plane = 0 .. 3 +** calculate 'start of line' pointer (slp) +** holding the first blitting byte in RAM +** if bit alignment between RAM and screen differs +** shift© from slp to LineBuff with destination +** bit alignment. Reload slp with LineBuff +** for plane = 0 .. 3 +** select plane +** write slp[plane] to video memory +** +** video -> ram algorithm +** for plane = 0 .. 3 +** select plane +** read data from scanline into LineBuff[plane] +** if bit alignment between screen and RAM differs +** shift LineBuff for RAM bit alignment +** for plane = 0 .. 3 +** copy from LineBuff[plane] to RAM +** +** These algorithms save a lot of VGA register port settings +** compared with the old pixel by pixel method. There's one +** minor problem: When writing the scanline intermediate +** pixel colors may occur since not all color bits will +** be updated simultanously. Heavy blitting to video RAM +** may force a little 'snow' effect on screen. +*/ + +static void get_one(long offs, char far *ptr, int w, GR_int8u far *sl) { + int bnk; + int w1, w2; + GRX_ENTER(); + bnk = BANKNUM(offs); + w2 = BANKLFT(offs); + w2 = w - (w1 = umin(w,w2)); + CHKBANK(bnk); + while (w1-- > 0) { + *(sl++) = peek_b_f(ptr); + ++ptr; + } + if (w2) { + SETBANK(bnk+1); + ptr = SCRN->gc_baseaddr[0]; + while (w2-- > 0) { + *(sl++) = peek_b_f(ptr); + ++ptr; + } + } + GRX_LEAVE(); +} + + +#define poke_b_f_rw(p,v) do { \ + register GR_int8u __v = (v); \ + (void) (volatile int) peek_b_f(p); \ + poke_b_f((p),__v); \ +} while (0) + +static void put_one(int op, long offs, GR_int8u far *ptr, int w, + GR_int8u lm, GR_int8u rm, GR_int8u far *sl ) { + int w1, w2; + int bnk; + GRX_ENTER(); + bnk = BANKNUM(offs); + CHKBANK(bnk); + if (w==1) lm &= rm; + if ( ((GR_int8u)(~lm)) ) { + outport_w(VGA_GR_CTRL_PORT,((lm << 8) | VGA_BIT_MASK_REG)); + poke_b_f_rw(ptr,*sl); + if (--w == 0) goto done; + ++ptr; + ++sl; + ++offs; + } + if ( ((GR_int8u)(~rm)) ) --w; + if (w) { + w2 = BANKLFT(offs); + w2 = w - (w1 = umin(w,w2)); + outport_w(VGA_GR_CTRL_PORT,((0xff << 8) | VGA_BIT_MASK_REG)); + if (op) while (w1-- > 0) { poke_b_f_rw(ptr,*sl); + ++sl; ++ptr; } + else while (w1-- > 0) { poke_b_f(ptr, *sl); + ++sl; ++ptr; } + if (w2) { + SETBANK(bnk+1); + ptr = (GR_int8u far *)SCRN->gc_baseaddr[0]; + if (op) while (w2-- > 0) { poke_b_f_rw(ptr,*sl); + ++sl; ++ptr; } + else while (w2-- > 0) { poke_b_f(ptr, *sl); + ++sl; ++ptr; } + } + } + if ( ((GR_int8u)(~rm)) ) { + offs += w; + CHKBANK(BANKNUM(offs)); + outport_w(VGA_GR_CTRL_PORT,((rm << 8) | VGA_BIT_MASK_REG)); + poke_b_f_rw(ptr,*sl); + } +done: + GRX_LEAVE(); +} + +static void get_scanline(long offs, int w) { + char far *ptr; + int plane; + GRX_ENTER(); + ptr = &SCRN->gc_baseaddr[0][BANKPOS(offs)]; + outport_w(VGA_GR_CTRL_PORT,modereg); + for (plane = 0; plane < 4; ++plane) { + outport_w(VGA_GR_CTRL_PORT,((plane << 8) | VGA_RD_PLANE_SEL_REG)); + get_one(offs, ptr, w, LineBuff[plane]); + } + outport_w(VGA_GR_CTRL_PORT,(((8 + 3) << 8) | modereg)); + lastcolor = (-1L); + GRX_LEAVE(); +} + +extern void _GR_shift_scanline(GR_int8u far **dst, + GR_int8u far **src, + int ws, int shift, int planes ); +#define shift_scanline(dst,src,w,sh) \ + _GR_shift_scanline((dst),(src),(w),(sh),4) + +static void put_scanline(GR_int8u **src, long offs, int ws, int wd, + GR_int8u lm, GR_int8u rm, int oper) { + int plane; + GR_int8u far *ptr; + + GRX_ENTER(); + ptr = (GR_int8u far *)&CURC->gc_baseaddr[0][BANKPOS(offs)]; + + /* dump to screen */ + outport_w(VGA_GR_CTRL_PORT,modereg); + outport_w(VGA_GR_CTRL_PORT,((0 << 8) | VGA_SET_RESET_ENB_REG)); + outport_w(VGA_GR_CTRL_PORT,writeops[(unsigned)oper & 3]); + for (plane = 0; plane < 4; ++plane) { + outport_w(VGA_SEQUENCER_PORT,((1<<(plane+8)) | VGA_WRT_PLANE_ENB_REG)); + put_one(oper != C_WRITE, offs, ptr, wd, lm, rm, src[plane]); + } + outport_w(VGA_GR_CTRL_PORT,((0xff << 8) | VGA_BIT_MASK_REG)); +/* reginit(); */ + GRX_LEAVE(); +} + +static +#include "fdrivers/generic/bitblt.c" + +static void bltv2v(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y,int w,int h, + GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) != GrIMAGE && alloc_blit_buffer()) { + int shift = ((int)(x&7)) - ((int)(dx&7)); + long SO, DO; + int oper= C_OPER(op); + GR_int8u lm = 0xff >> (dx & 7); + GR_int8u rm = 0xff << ((-(w + dx)) & 7); + int ws = ((x+w+7) >> 3) - (x >> 3); + int wd = ((dx+w+7) >> 3) - (dx >> 3); + int hh = h; + setup_far_selector(SCRN->gc_selector); + if (dy < y) { + SO = FOFS(x,y,SCRN->gc_lineoffset); + DO = FOFS(dx,dy,SCRN->gc_lineoffset); + while (hh-- > 0) { + get_scanline(SO, ws); + if (shift) + shift_scanline(LineBuff,LineBuff,ws,shift); + put_scanline(LineBuff, DO, ws, wd, lm, rm, oper); + SO += SCRN->gc_lineoffset; + DO += SCRN->gc_lineoffset; + } + } else { + y += h-1; dy += h-1; + SO = FOFS(x,y,SCRN->gc_lineoffset); + DO = FOFS(dx,dy,SCRN->gc_lineoffset); + while (hh-- > 0) { + get_scanline(SO, ws); + if (shift) + shift_scanline(LineBuff,LineBuff,ws,shift); + put_scanline(LineBuff, DO, ws, wd, lm, rm, oper); + SO -= SCRN->gc_lineoffset; + DO -= SCRN->gc_lineoffset; + } + } + reginit(); + } else + bitblt(dst,dx,dy,src,x,y,w,h,op); + GRX_LEAVE(); +} + +static void bltr2v(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y,int w,int h, + GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) != GrIMAGE && alloc_blit_buffer()) { + int oper = C_OPER(op); + int shift = ((int)(x&7)) - ((int)(dx&7)); + GR_int32u SO, DO; + GR_int8u lm = 0xff >> (dx & 7); + GR_int8u rm = 0xff << ((-(w + dx)) & 7); + int ws = ((x+w+7) >> 3) - (x >> 3); + int wd = ((dx+w+7) >> 3) - (dx >> 3); + int hh = h; + setup_far_selector(SCRN->gc_selector); + SO = FOFS(x,y,src->gf_lineoffset); + DO = FOFS(dx,dy,SCRN->gc_lineoffset); + while (hh-- > 0) { + /* load pointer to RAM */ + int i; + GR_int8u far *slp[4]; + for (i=0; i < 4; ++i) + slp[i] = (GR_int8u far *)&src->gf_baseaddr[i][SO]; + if (shift) { + shift_scanline(LineBuff,slp,ws,shift); + for (i=0; i < 4; ++i) + slp[i] = LineBuff[i]; + } + put_scanline(slp, DO, ws, wd, lm, rm, oper); + SO += src->gf_lineoffset; + DO += SCRN->gc_lineoffset; + } + reginit(); + } else + _GrFrDrvGenericBitBlt(dst,dx,dy,src,x,y,w,h,op); + GRX_LEAVE(); +} + +#define mcopy(d,op,s,msk) do { \ + unsigned char _c_ = *(d); \ + *(d) = (_c_ & ~(msk)) | ((_c_ op *(s)) & (msk)); \ +} while (0) + +static void bltv2r(GrFrame *dst,int dx,int dy, + GrFrame *src,int x,int y,int w,int h, + GrColor op) +{ + GRX_ENTER(); + while(GrColorMode(op) != GrIMAGE) + if(alloc_blit_buffer()) { + int oper = C_OPER(op); + int shift = ((int)(x&7)) - ((int)(dx&7)); + GR_int32u SO, DO; + GR_int8u lm = 0xff >> (dx & 7); + GR_int8u rm = 0xff << ((-(w + dx)) & 7); + int ws = ((x+w+7) >> 3) - (x >> 3); + int wd = ((dx+w+7) >> 3) - (dx >> 3); + if (wd==1) break; + setup_far_selector(SCRN->gc_selector); + SO = FOFS(x,y,SCRN->gc_lineoffset); + DO = FOFS(dx,dy,dst->gf_lineoffset); + while (h-- > 0) { + int pl; + get_scanline(SO, ws); + if (shift) + shift_scanline(LineBuff,LineBuff,ws,shift); + for (pl = 0; pl < 4; ++pl) { + GR_int8u far *sptr = LineBuff[pl]; + GR_int8u far *dptr = (GR_int8u far *)&dst->gf_baseaddr[pl][DO]; + int ww = wd; + if ( ((GR_int8u)(~lm)) ) { + switch(oper) { + case C_XOR: mcopy(dptr,^,sptr,lm); break; + case C_OR: mcopy(dptr,|,sptr,lm); break; + case C_AND: mcopy(dptr,&,sptr,lm); break; + default: *dptr = (*dptr & ~lm) | (*sptr & lm); + break; + } + if (!(--ww)) continue; + ++dptr; ++sptr; + } + if ( ((GR_int8u)(~rm)) ) --ww; + if (ww) switch(oper) { + case C_XOR: fwdcopy_xor(dptr,dptr,sptr,ww); break; + case C_OR: fwdcopy_or( dptr,dptr,sptr,ww); break; + case C_AND: fwdcopy_and(dptr,dptr,sptr,ww); break; + default: fwdcopy_set(dptr,dptr,sptr,ww); break; + } + if ( ((GR_int8u)(~rm)) ) { + switch(oper) { + case C_XOR: mcopy(dptr,^,sptr,rm); break; + case C_OR: mcopy(dptr,|,sptr,rm); break; + case C_AND: mcopy(dptr,&,sptr,rm); break; + default: *dptr = (*dptr & ~rm) | (*sptr & rm); break; + } + } + } + SO += SCRN->gc_lineoffset; + DO += dst->gf_lineoffset; + } + goto done; + } + _GrFrDrvGenericBitBlt(dst,dx,dy,src,x,y,w,h,op); +done: + GRX_LEAVE(); +} + + +GrFrameDriver _GrFrameDriverSVGA4 = { + GR_frameSVGA4, /* frame mode */ + GR_frameRAM4, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* scan line width alignment */ + 4, /* number of planes */ + 4, /* bits per pixel */ + 16*1024L*1024L, /* max plane size the code can handle */ + init, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bltv2v, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; diff --git a/thirdparty/grx249/src/fdrivers/svga8.c b/thirdparty/grx249/src/fdrivers/svga8.c new file mode 100644 index 0000000..f3fabc3 --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/svga8.c @@ -0,0 +1,459 @@ +/** + ** svga8.c ---- the 256 color (Super) VGA frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifdef __TURBOC__ +#pragma inline +#endif + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "docolor.h" +#include "mempeek.h" +#include "memfill.h" + + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),(x)) + + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GR_int32u offs; + GRX_ENTER(); + offs = FOFS(x,y,SCRN->gc_lineoffset); + CHKBANK(BANKNUM(offs)); + setup_far_selector(SCRN->gc_selector); + GRX_RETURN((GR_int8u)peek_b_f(&SCRN->gc_baseaddr[0][BANKPOS(offs)])); +} + + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + GR_int32u offs; + char far *ptr; + GRX_ENTER(); + offs = FOFS(x,y,CURC->gc_lineoffset); + ptr = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + setup_far_selector(CURC->gc_selector); + switch(C_OPER(color)) { + case C_XOR: poke_b_f_xor(ptr,(GR_int8u)color); break; + case C_OR: poke_b_f_or( ptr,(GR_int8u)color); break; + case C_AND: poke_b_f_and(ptr,(GR_int8u)color); break; + default: poke_b_f( ptr,(GR_int8u)color); break; + } + GRX_LEAVE(); +} + + +static void drawhline(int x,int y,int w,GrColor color) +{ + int copr; + GRX_ENTER(); + copr = C_OPER(color); + if(DOCOLOR8(color,copr)) { + GR_int32u offs = FOFS(x,y,CURC->gc_lineoffset); + unsigned int w1 = BANKLFT(offs); + unsigned int w2 = w - (w1 = umin(w,w1)); + GR_repl cval = freplicate_b(color); + setup_far_selector(CURC->gc_selector); + do { + char far *pp = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + offs += w1; + switch(copr) { + case C_XOR: repfill_b_f_xor(pp,cval,w1); break; + case C_OR: repfill_b_f_or( pp,cval,w1); break; + case C_AND: repfill_b_f_and(pp,cval,w1); break; + default: repfill_b_f( pp,cval,w1); break; + } + w1 = w2; + w2 = 0; + } while(w1 != 0); + } + GRX_LEAVE(); +} + + +static void drawvline(int x,int y,int h,GrColor color) +{ + int copr; + GRX_ENTER(); + copr = C_OPER(color); + if(DOCOLOR8(color,copr)) { + unsigned int lwdt = CURC->gc_lineoffset; + GR_int32u offs = FOFS(x,y,lwdt); + setup_far_selector(CURC->gc_selector); + do { + char far *pp = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + unsigned int h1 = BANKLFT(offs) / lwdt; + h -= (h1 = umin(h,umax(h1,1))); + CHKBANK(BANKNUM(offs)); + offs += umul32(h1,lwdt); + switch(copr) { + case C_XOR: colfill_b_f_xor(pp,lwdt,(int)color,h1); break; + case C_OR: colfill_b_f_or( pp,lwdt,(int)color,h1); break; + case C_AND: colfill_b_f_and(pp,lwdt,(int)color,h1); break; + default: colfill_b_f( pp,lwdt,(int)color,h1); break; + } + } while(h != 0); + } + GRX_LEAVE(); +} + + +static void drawblock(int x,int y,int w,int h,GrColor color) +{ + int copr; + GRX_ENTER(); + copr = C_OPER(color); + if(DOCOLOR8(color,copr)) { + unsigned int skip = CURC->gc_lineoffset; + GR_int32u offs = FOFS(x,y,skip); + GR_repl cval = freplicate_b(color); + skip -= w; + setup_far_selector(CURC->gc_selector); + do { + unsigned int w1 = BANKLFT(offs); + unsigned int w2 = w - (w1 = umin(w,w1)); + do { + char far *pp = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + offs += w1; + switch(copr) { + case C_XOR: repfill_b_f_xor(pp,cval,w1); break; + case C_OR: repfill_b_f_or( pp,cval,w1); break; + case C_AND: repfill_b_f_and(pp,cval,w1); break; + default: repfill_b_f( pp,cval,w1); break; + } + w1 = w2; + w2 = 0; + } while(w1 != 0); + offs += skip; + } while(--h != 0); + } + GRX_LEAVE(); +} + + +#if !defined(__WATCOMC__) && (defined(__DJGPP__) || defined(__TURBOC__)) +/* The VGA banked frame buffer must start on a 64k boundary +** for this optimized assembler code. +** Linux: mmap may place the frame buffer on a 4k boundary :( +** Watcom C++: Can't use ES register :( +*/ +static void drawline(int x,int y,int dx,int dy,GrColor color) +{ + struct { + int errsub; /* subtract from error term */ + int erradd; /* add to error term when carry */ + int offset1; /* add to pointer if no carry on error term */ + int offset2; /* add to pointer if carry / banking dir */ + } lndata; + int copr, xstep, npts,error; + char far *ptr; + GR_int32u offs; + + GRX_ENTER(); + +# ifdef __GNUC__ +# ifdef __i386__ +# define ASM_LINE1(OPC) asm volatile("" \ + " .align 2,0x90 \n" \ + "0: "#OPC"b %6,"I386_GCC_FAR_SELECTOR"(%0) \n" \ + " subl %7,%2 \n" \ + " jb 1f \n" \ + " subw $1,%3 \n" \ + " jb 2f \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 4f \n" \ + " .align 2,0x90 \n" \ + "1: addl 4 + %7,%2 \n" \ + " addw 12 + %7,%3 \n" \ + " jb 3f \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 4f \n" \ + "2: negl 8 + %7 \n" \ + "3: decl %1 \n" \ + "4: " \ + : "=r" (ptr), "=r" (npts), "=r" (error) \ + : "0" ((short)(long)(ptr)), "1" (npts), "2" (error), \ + "q" ((char)(color)), "o" (lndata) \ + ) +# define ASM_LINE2(OPC) asm volatile("" \ + " .align 2,0x90 \n" \ + "0: "#OPC"b %6,"I386_GCC_FAR_SELECTOR"(%0) \n" \ + " subl %7,%2 \n" \ + " jb 1f \n" \ + " addw 8 + %7,%3 \n" \ + " jb 2f \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 3f \n" \ + " .align 2,0x90 \n" \ + "1: addl 4 + %7,%2 \n" \ + " addw 12 + %7,%3 \n" \ + " jb 2f \n" \ + " decl %1 \n" \ + " jne 0b \n" \ + " jmp 3f \n" \ + "2: decl %1 \n" \ + "3: " \ + : "=r" (ptr), "=r" (npts), "=r" (error) \ + : "0" ((short)(long)(ptr)), "1" (npts), "2" (error), \ + "q" ((char)(color)), "o" (lndata) \ + ) +# endif +# endif +# ifdef __TURBOC__ +# define ASM_LINE1(OPC) { \ + _ES = FP_SEG(ptr); \ + _BX = FP_OFF(ptr); \ + _CX = npts; \ + _DX = error; \ + _AX = (int)color; \ + OPC##1loop: \ + asm OPC byte ptr es:[bx],al; \ + asm sub dx,word ptr lndata.errsub; \ + asm jb OPC##1adjust; \ + asm sub bx,1; \ + asm jb OPC##1newbank1; \ + asm loop OPC##1loop; \ + asm jmp OPC##1done; \ + OPC##1adjust: \ + asm add dx,word ptr lndata.erradd; \ + asm add bx,word ptr lndata.offset2; \ + asm jb OPC##1newbank2; \ + asm loop OPC##1loop; \ + asm jmp OPC##1done; \ + OPC##1newbank1: \ + asm neg word ptr lndata.offset1; \ + OPC##1newbank2: \ + asm dec cx; \ + OPC##1done: \ + *((short *)(&ptr)) = _BX; \ + npts = _CX; \ + error = _DX; \ + } +# define ASM_LINE2(OPC) { \ + _ES = FP_SEG(ptr); \ + _BX = FP_OFF(ptr); \ + _CX = npts; \ + _DX = error; \ + _AX = (int)color; \ + OPC##2loop: \ + asm OPC byte ptr es:[bx],al; \ + asm sub dx,word ptr lndata.errsub; \ + asm jb OPC##2adjust; \ + asm add bx,word ptr lndata.offset1; \ + asm jb OPC##2newbank; \ + asm loop OPC##2loop; \ + asm jmp OPC##2done; \ + OPC##2adjust: \ + asm add dx,word ptr lndata.erradd; \ + asm add bx,word ptr lndata.offset2; \ + asm jb OPC##2newbank; \ + asm loop OPC##2loop; \ + asm jmp OPC##2done; \ + OPC##2newbank: \ + asm dec cx; \ + OPC##2done: \ + *((short *)(&ptr)) = _BX; \ + npts = _CX; \ + error = _DX; \ + } +# endif + + copr = C_OPER(color); + while(DOCOLOR8(color,copr)) { + if(dy < 0) { + y -= (dy = (-dy)); + x -= (dx = (-dx)); + } + if(dx < 0) { + xstep = (-1); + dx = (-dx); + } else + xstep = 1; + + offs = FOFS(x,y,CURC->gc_lineoffset); + ptr = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + setup_far_selector(CURC->gc_selector); + if(dx > dy) { + npts = dx + 1; + error = dx >> 1; + lndata.errsub = dy; + lndata.erradd = dx; + lndata.offset1 = xstep; + lndata.offset2 = CURC->gc_lineoffset + xstep; + if(xstep < 0) { + again_nonlinear: + lndata.offset1 = 1; + switch(copr) { + case C_XOR: ASM_LINE1(xor); break; + case C_OR: ASM_LINE1(or); break; + case C_AND: ASM_LINE1(and); break; + default: ASM_LINE1(mov); break; + } + if(npts == 0) break; + SETBANK(DRVINFO->curbank + lndata.offset1); + goto again_nonlinear; + } + } + else { + npts = dy + 1; + error = dy >> 1; + lndata.errsub = dx; + lndata.erradd = dy; + lndata.offset1 = CURC->gc_lineoffset; + lndata.offset2 = CURC->gc_lineoffset + xstep; + } + again_linear: + switch(copr) { + case C_XOR: ASM_LINE2(xor); break; + case C_OR: ASM_LINE2(or); break; + case C_AND: ASM_LINE2(and); break; + default: ASM_LINE2(mov); break; + } + if(npts == 0) break; + SETBANK(DRVINFO->curbank + 1); + goto again_linear; + } + GRX_LEAVE(); +} +#else +static +#include "fdrivers/generic/line.c" +#endif + + +static void drawbitmap(int x,int y,int w,int h,char far *bmp,int pitch,int start,GrColor fg,GrColor bg) +{ + int fgop, bgop; + int dofg, dobg; + GRX_ENTER(); + fgop = C_OPER(fg); + bgop = C_OPER(bg); + dofg = DOCOLOR8(fg,fgop); + dobg = DOCOLOR8(bg,bgop); + if(dofg | dobg) { + unsigned int skip = CURC->gc_lineoffset; + GR_int32u offs = FOFS(x,y,skip); + int once = dofg && dobg && (fgop == bgop); + skip -= w; + bmp += start >> 3; + start &= 7; + setup_far_selector(CURC->gc_selector); + do { + GR_int8u far *bp = (GR_int8u far *)bmp; + GR_int8u bits = *bp; + GR_int8u mask = 0x80 >> start; + unsigned int w1 = BANKLFT(offs); + unsigned int w2 = w - (w1 = umin(w,w1)); + do { + char far *pp = &CURC->gc_baseaddr[0][BANKPOS(offs)]; + CHKBANK(BANKNUM(offs)); + offs += w1; +# define DOBOTH(POKEOP) do { \ + POKEOP(pp,((bits&mask)?(GR_int8u)fg:(GR_int8u)bg)); \ + if((mask >>= 1) == 0) bits = *++bp,mask = 0x80; \ + pp++; \ + } while(--w1 != 0) +# define DOFGC(POKEOP) do { \ + if((mask & bits) != 0) POKEOP(pp,(GR_int8u)fg); \ + if((mask >>= 1) == 0) bits = *++bp,mask = 0x80; \ + pp++; \ + } while(--w1 != 0) +# define DOBGC(POKEOP) do { \ + if((mask & bits) == 0) POKEOP(pp,(GR_int8u)bg); \ + if((mask >>= 1) == 0) bits = *++bp,mask = 0x80; \ + pp++; \ + } while(--w1 != 0) + if(once) switch(fgop) { + case C_XOR: DOBOTH(poke_b_f_xor); break; + case C_OR: DOBOTH(poke_b_f_or); break; + case C_AND: DOBOTH(poke_b_f_and); break; + default: DOBOTH(poke_b_f); break; + } + else { + char far *ppsave = pp; + unsigned int w1save = w1; + if(dofg) switch(fgop) { + case C_XOR: DOFGC(poke_b_f_xor); break; + case C_OR: DOFGC(poke_b_f_or); break; + case C_AND: DOFGC(poke_b_f_and); break; + default: DOFGC(poke_b_f); break; + } + if(dobg) { + pp = ppsave; + w1 = w1save; + bp = (GR_int8u far *)bmp; + bits = *bp; + mask = 0x80 >> start; + switch(bgop) { + case C_XOR: DOBGC(poke_b_f_xor); break; + case C_OR: DOBGC(poke_b_f_or); break; + case C_AND: DOBGC(poke_b_f_and); break; + default: DOBGC(poke_b_f); break; + } + } + } + w1 = w2; + w2 = 0; + } while(w1 != 0); + offs += skip; + bmp += pitch; + } while(--h != 0); + } + GRX_LEAVE(); +} + + +static +#include "fdrivers/generic/pattern.c" + + +GrFrameDriver _GrFrameDriverSVGA8 = { + GR_frameSVGA8, /* frame mode */ + GR_frameRAM8, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 4, /* scan line width alignment */ + 1, /* number of planes */ + 8, /* bits per pixel */ + 8*16*1024L*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + _GrFrDrvPackedBitBltV2V, + _GrFrDrvPackedBitBltV2R, + _GrFrDrvPackedBitBltR2V, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; diff --git a/thirdparty/grx249/src/fdrivers/vga8x.c b/thirdparty/grx249/src/fdrivers/vga8x.c new file mode 100644 index 0000000..2bb140f --- /dev/null +++ b/thirdparty/grx249/src/fdrivers/vga8x.c @@ -0,0 +1,654 @@ +/** + ** vga8x.c ---- the 256 color VGA mode X frame driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu]. + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "allocate.h" +#include "arith.h" +#include "docolor.h" +#include "mempeek.h" +#include "memcopy.h" +#include "memfill.h" +#include "ioport.h" +#include "vgaregs.h" +#include "highlow.h" + +/* frame offset address calculation */ +#define FOFS(x,y,lo) umuladd32((y),(lo),((x)>>2)) + +#define _SetVGAWritePlanes(planes) \ + outport_w(VGA_SEQUENCER_PORT,highlow((planes),VGA_WRT_PLANE_ENB_REG)) + +#define _SetVGAReadPlane(plane) \ + outport_w(VGA_GR_CTRL_PORT,highlow((plane),VGA_RD_PLANE_SEL_REG)) + +#define _SetVGAWritePlane(plane) _SetVGAWritePlanes(1<<(plane)) + +#define _SetVGAWriteAllPlanes() _SetVGAWritePlanes(0x0f) + +static GR_int8u _GrPXLmaskTable[] = { 0, 0x0e, 0x0c, 0x08 }; +static GR_int8u _GrPXRmaskTable[] = { 0, 0x01, 0x03, 0x07 }; + + +#define _SetNoPlane_ +#define POKEX(P,C,OP,SRP) do { \ + switch(OP) { \ + case C_XOR: SRP; poke_b_f_xor((P),(C)); break; \ + case C_OR: SRP; poke_b_f_or( (P),(C)); break; \ + case C_AND: SRP; poke_b_f_and((P),(C)); break; \ + default: poke_b_f( (P),(C)); break; \ + } \ + } while (0) +#define POKEFAST(P,C,OP) POKEX((P),(C),(OP),_SetNoPlane_) + + +static INLINE +GrColor readpixel(GrFrame *c,int x,int y) +{ + GRX_ENTER(); + _SetVGAReadPlane(x&3); + setup_far_selector(SCRN->gc_selector); + GRX_RETURN((GR_int8u) + peek_b_f(&SCRN->gc_baseaddr[0][FOFS(x,y,SCRN->gc_lineoffset)]) + ); +} + + +static INLINE +void drawpixel(int x,int y,GrColor color) +{ + char far *ptr; + GRX_ENTER(); + ptr = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + x &= 3; + _SetVGAWritePlane(x); + setup_far_selector(CURC->gc_selector); + POKEX(ptr,color,C_OPER(color),_SetVGAReadPlane(x)); + GRX_LEAVE(); +} + + +static void drawhline(int x,int y,int w,GrColor color) { + int opr; + + GRX_ENTER(); + opr = C_OPER(color); + if (w > 0 && DOCOLOR8(color,opr)) { + GR_repl cval = freplicate_b(color); + char far *p = &CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + setup_far_selector(CURC->gc_selector); + if ((opr == C_WRITE) && (w >= 10)) { /* 10 = 3(left) + 1*4 + 3(right) */ + int rmask = (x + w) & 3; + int lmask = x & 3; + if(lmask) { + _SetVGAWritePlanes(_GrPXLmaskTable[lmask]); + poke_b_f(p,(GR_int8u)cval); + ++p; + w -= (4 - lmask); + } + w >>= 2; + if(rmask) { + _SetVGAWritePlanes(_GrPXRmaskTable[rmask]); + poke_b_f(p+w,(GR_int8u)cval); + } + _SetVGAWriteAllPlanes(); + repfill_b_f(p,cval,w); + } else { + int i, plane = x & 3; + for (i=0; i < 4; ++i) { + GR_int8u far *pp = (GR_int8u far *)p; + int ww = (w+3) >> 2; + if ( !ww ) break; + _SetVGAWritePlane(plane); + switch (opr) { + case C_XOR: _SetVGAReadPlane(plane); + repfill_b_f_xor(pp,cval,ww); + break; + case C_OR: _SetVGAReadPlane(plane); + repfill_b_f_or(pp,cval,ww); + break; + case C_AND: _SetVGAReadPlane(plane); + repfill_b_f_and(pp,cval,ww); + break; + default : repfill_b_f(pp,cval,ww); + break; + } + --w; + if (++plane == 4) { plane = 0; ++p; } + } + } + } + GRX_LEAVE(); +} + + +static void drawvline(int x,int y,int h,GrColor color) +{ + char far *ptr; + unsigned skip; + GR_int8u cv; + GRX_ENTER(); + skip = CURC->gc_lineoffset; + ptr = &CURC->gc_baseaddr[0][FOFS(x,y,skip)]; + cv = (GR_int8u)color; + x &= 3; + _SetVGAWritePlane(x); + setup_far_selector(CURC->gc_selector); + switch(C_OPER(color)) { + case C_XOR: _SetVGAReadPlane(x); + colfill_b_f_xor(ptr,skip,cv,h); + break; + case C_OR: _SetVGAReadPlane(x); + colfill_b_f_or(ptr,skip,cv,h); + break; + case C_AND: _SetVGAReadPlane(x); + colfill_b_f_and(ptr,skip,cv,h); + break; + default: colfill_b_f(ptr,skip,cv,h); + break; + } + GRX_LEAVE(); +} + + +static +#include "fdrivers/generic/block.c" + +/* ------------------------------------------------------------------------ */ + +#if 1 + +static INLINE +void xmajor(GR_int8u far *ptr, int len, int yskip, + GR_int32u ErrorAcc, GR_int32u ErrorAdj, + int op, int color) +{ + if (len) { + while (--len) { + POKEFAST(ptr,color,op); + ptrinc(ptr,1); + ErrorAcc += ErrorAdj; + + if (ErrorAcc & ~0xFFFFL) { + ErrorAcc &= 0xFFFFL; + ptrinc(ptr,yskip); + } + } + POKEFAST(ptr,color,op); + } +} + +static INLINE +void middle(GR_int8u far *ptr, int len, int yskip, + GR_int32u ErrorAcc, GR_int32u ErrorAdj, + int op, int color) +{ + if (len) { + while (--len) { + POKEFAST(ptr,color,op); + ErrorAcc += ErrorAdj; + ptrinc(ptr, (yskip * (int)(ErrorAcc >> 16)) + 1); + ErrorAcc &= 0xFFFFL; + } + POKEFAST(ptr,color,op); + } +} + + +static INLINE +void ymajor(GR_int8u *ptr, int len, int yskip, + GR_int32u ErrorAcc, GR_int32u ErrorAdj, + int op, int color) +{ + + if (len) { + int i; + GR_int32u TinyAdj = (ErrorAdj >> 2); + ErrorAdj -= TinyAdj; + + while (--len) { + ErrorAcc += TinyAdj; + i = (ErrorAcc >> 16); + ErrorAcc &= 0xFFFFL; + + while (i--) { + POKEFAST(ptr,color,op); + ptrinc(ptr,yskip); + } + + ErrorAcc += ErrorAdj; + ptrinc(ptr, (yskip * (int)(ErrorAcc >> 16)) + 1); + ErrorAcc &= 0xFFFFL; + } + ErrorAcc += TinyAdj; + i = (ErrorAcc >> 16); + while (i--) { + POKEFAST(ptr,color,op); + ptrinc(ptr,yskip); + } + } +} + + +static void drawline(int x,int y,int dx,int dy,GrColor color) +{ + int i, yskip, oper, plane; + int len[4]; + GR_int8u far *ptr; + + /* Mode X 4-way folded Bresenham line function - by David Boeren */ + + GRX_ENTER(); + /* Make sure the line runs left to right */ + if (dx < 0) { + x -= (dx=-dx); + y -= (dy=-dy); + } + + yskip = CURC->gc_lineoffset; + if (dy < 0) { + dy = -dy; /* Make dy positive */ + yskip = -yskip; + } + + if (dx == 0) { + /* Vertical Line (and one pixel lines) */ + if (yskip > 0) { + drawvline(x,y,dy+1,color); + goto done; + } + drawvline(x,y-dy,dy+1,color); + goto done; + } + + if (dy == 0) { + /* Horizontal Line */ + drawhline(x,y,dx+1,color); + goto done; + } + + oper = C_OPER(color); + ptr = (GR_int8u far *)&CURC->gc_baseaddr[0][FOFS(x,y,CURC->gc_lineoffset)]; + + /* Length of sub-line in each plane */ + plane = (x & 3); + i = dx + plane; + len[0] = ((i--) >> 2); + len[1] = ((i--) >> 2); + len[2] = ((i--) >> 2); + len[3] = (i >> 2) + 1; + + for (i=plane; i < 3; i++) len[i]++; + + if ((dx >> 2) >= dy) { + /* X-Major line (0.00 < slope <= 0.25) */ + GR_int32u ErrorAcc = 0x8000; + GR_int32u ErrorAdj = ((((GR_int32u)dy << 18) / (GR_int32u)dx)); + GR_int32u TinyAdj = (ErrorAdj >> 2); + while (i--) { + if (oper != C_WRITE) _SetVGAReadPlane(plane); + _SetVGAWritePlane(plane); + xmajor(ptr, len[plane], yskip, ErrorAcc, ErrorAdj, oper, color); + if (++plane == 4) { + plane = 0; + ptrinc(ptr,1); + } + ErrorAcc += TinyAdj; + if (ErrorAcc & ~0xFFFFL) { + ErrorAcc &= 0xFFFFL; + ptrinc(ptr,yskip); + } + } + if (oper != C_WRITE) _SetVGAReadPlane(plane); + _SetVGAWritePlane(plane); + xmajor(ptr, len[plane], yskip, ErrorAcc, ErrorAdj, oper, color); + } else if (dx >= dy) { + /* Middle line (0.25 < slope <= 1.00) */ + GR_int32u ErrorAcc = 0x8000; + GR_int32u ErrorAdj = ((((GR_int32u)dy << 18) / (GR_int32u)dx)); + GR_int32u TinyAdj = (ErrorAdj >> 2); + while (i--) { + if (oper != C_WRITE) _SetVGAReadPlane(plane); + _SetVGAWritePlane(plane); + middle(ptr, len[plane], yskip, ErrorAcc, ErrorAdj, oper, color); + if (++plane == 4) { + plane = 0; + ptrinc(ptr,1); + } + ErrorAcc += TinyAdj; + if (ErrorAcc & ~0xFFFFL) { + ptrinc(ptr,yskip); + ErrorAcc &= 0xFFFFL; + } + } + if (oper != C_WRITE) _SetVGAReadPlane(plane); + _SetVGAWritePlane(plane); + middle(ptr, len[plane], yskip, ErrorAcc, ErrorAdj, oper, color); + } else { + /* Y-Major line (slope > 1) */ + GR_int32u ErrorAcc = 0x8000; + GR_int32u ErrorAdj = ((((GR_int32u)(dy+1) << 18) / (GR_int32u)(dx+1))); + GR_int32u TinyAdj = (ErrorAdj >> 2); + while (i--) { + if (oper != C_WRITE) _SetVGAReadPlane(plane); + _SetVGAWritePlane(plane); + ymajor(ptr, len[plane], yskip, ErrorAcc, ErrorAdj, oper, color); + if (++plane == 4) { + plane = 0; + ptrinc(ptr,1); + } + ErrorAcc += TinyAdj; + ptrinc(ptr,(yskip * (ErrorAcc >> 16))); + ErrorAcc &= 0xFFFFL; + } + if (oper != C_WRITE) _SetVGAReadPlane(plane); + _SetVGAWritePlane(plane); + ymajor(ptr, len[plane], yskip, ErrorAcc, ErrorAdj, oper, color); + } + done: + GRX_LEAVE(); +} +#else +static +#include "fdrivers/generic/line.c" +#endif + +/* ------------------------------------------------------------------------ */ + +static +#include "fdrivers/generic/bitmap.c" + +static +#include "fdrivers/generic/pattern.c" + +/* ---------------------------------------------------- video -> video blit */ +static +#include "fdrivers/generic/bitblt.c" + +static char far *LineBuff = NULL; + +static void pbltv2v(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op ) +{ + GR_int32u soffs, doffs; + int skip, lo; + char far *vp; + GRX_ENTER(); + op = C_OPER(op); + lo = SCRN->gc_lineoffset; + if (dy <= sy) { + /* forward */ + skip = lo; + } else { + /* reverse */ + dy += h-1; + sy += h-1; + skip = -lo; + } + soffs = FOFS(sx,sy,lo); + doffs = FOFS(dx,dy,lo); + setup_far_selector(SCRN->gc_selector); + while (h--) { + char far *dptr, *sptr; + int ww; + int plc, pl; + pl = sx & 3; + ww = w; + vp = &SCRN->gc_baseaddr[0][soffs]; + dptr = LineBuff; + for (plc=0; plc < 4; ++plc) { + char far *sptr = vp; + int bytes = (ww+3)>>2; + _SetVGAReadPlane(pl); + fwdcopy_set_f(sptr,dptr,sptr,bytes); + if (--ww <= 0) break; + if (++pl == 4) { pl=0; ++vp; } + } + pl = dx & 3; + ww = w; + vp = &SCRN->gc_baseaddr[0][doffs]; + sptr = LineBuff; + switch (op) { + case C_XOR: + for (plc=0; plc < 4; ++plc) { + char far *dptr = vp; + int bytes = (ww+3)>>2; + _SetVGAReadPlane(pl); + _SetVGAWritePlane(pl); + fwdcopy_f_xor(dptr,dptr,sptr,bytes); + if (--ww <= 0) break; + if (++pl == 4) { pl=0; ++vp; } + } + break; + case C_OR: + for (plc=0; plc < 4; ++plc) { + char far *dptr = vp; + int bytes = (ww+3)>>2; + _SetVGAReadPlane(pl); + _SetVGAWritePlane(pl); + fwdcopy_f_or(dptr,dptr,sptr,bytes); + if (--ww <= 0) break; + if (++pl == 4) { pl=0; ++vp; } + } + break; + case C_AND: + for (plc=0; plc < 4; ++plc) { + char far *dptr = vp; + int bytes = (ww+3)>>2; + _SetVGAReadPlane(pl); + _SetVGAWritePlane(pl); + fwdcopy_f_and(dptr,dptr,sptr,bytes); + if (--ww <= 0) break; + if (++pl == 4) { pl=0; ++vp; } + } + break; + default: + for (plc=0; plc < 4; ++plc) { + char far *dptr = vp; + int bytes = (ww+3)>>2; + _SetVGAWritePlane(pl); + fwdcopy_f_set(dptr,dptr,sptr,bytes); + if (--ww <= 0) break; + if (++pl == 4) { pl=0; ++vp; } + } + break; + } + doffs += skip; + soffs += skip; + } + GRX_LEAVE(); +} + +static int alloc_blit_buffer(int width) { + GRX_ENTER(); + LineBuff = _GrTempBufferAlloc(width); + GRX_RETURN(LineBuff != NULL); +} + +static void bltv2v(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) != GrIMAGE && alloc_blit_buffer(w)) + pbltv2v(dst,dx,dy,src,sx,sy,w,h,op); + else + bitblt(dst,dx,dy,src,sx,sy,w,h,op); + GRX_LEAVE(); +} + + + +/* ------------------------------------------------- video -> ram blit */ + +#define VID2MEM_OPR(M,OP) do { \ + int _ww_ = w; \ + for (plc = 0; plc < 4; ++plc) { \ + char far *_p_ = vp; \ + char far *_dptr_ = &M[plc]; \ + int _w_ = (_ww_+3)>>2; \ + _SetVGAReadPlane(pl); \ + colcopy_b##OP##_f(_dptr_,4,_p_,1,_w_); \ + if ((--_ww_) == 0) break; \ + if (++pl == 4) { pl = 0; ++vp; } \ + } \ +} while (0) + +static void pbltv2r(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op ) +{ + GR_int32u soffs; + int sskip, dskip; + char far *rp, *vp; + GRX_ENTER(); + op = C_OPER(op); + sskip = SCRN->gc_lineoffset; + dskip = dst->gf_lineoffset; + soffs = FOFS(sx,sy,sskip); + rp = &dst->gf_baseaddr[0][umuladd32(dy,dskip,dx)]; + setup_far_selector(SCRN->gc_selector); + while (h--) { + int plc, pl; + pl = sx & 3; + vp = &SCRN->gc_baseaddr[0][soffs]; + switch (op) { + case C_XOR: VID2MEM_OPR(rp,_xor); break; + case C_OR: VID2MEM_OPR(rp,_or); break; + case C_AND: VID2MEM_OPR(rp,_and); break; + default: VID2MEM_OPR(rp,_set); break; + } + rp += dskip; + soffs += sskip; + } + GRX_LEAVE(); +} + +static void bltv2r(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) != GrIMAGE) + pbltv2r(dst,dx,dy,src,sx,sy,w,h,op); + else + _GrFrDrvGenericBitBlt(dst,dx,dy,src,sx,sy,w,h,op); + GRX_LEAVE(); +} + +/* ------------------------------------------------- ram -> video blit */ + +#define MEM2VID_OPR(M,OP) do { \ + int _ww_ = w; \ + for (plc = 0; plc < 4; ++plc) { \ + char far *_p_ = vp; \ + char far *_sptr_ = &M[plc]; \ + int _w_ = (_ww_+3)>>2; \ + _SetVGAWritePlane(pl); \ + _SetVGAReadPlane(pl); \ + colcopy_b_f##OP(_p_,1,_sptr_,4,_w_); \ + if ((--_ww_) == 0) break; \ + if (++pl == 4) { pl = 0; ++vp; } \ + } \ +} while (0) + +#define MEM2VID_SET(M) do { \ + int _ww_ = w; \ + for (plc = 0; plc < 4; ++plc) { \ + char far *_p_ = vp; \ + char far *_sptr_ = &M[plc]; \ + int _w_ = (_ww_+3)>>2; \ + _SetVGAWritePlane(pl); \ + colcopy_b_f_set(_p_,1,_sptr_,4,_w_); \ + if ((--_ww_) == 0) break; \ + if (++pl == 4) { pl = 0; ++vp; } \ + } \ +} while (0) + +static void pbltr2v(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op ) +{ + GR_int32u doffs; + int sskip, dskip; + char far *rp, *vp; + GRX_ENTER(); + op = C_OPER(op); + dskip = SCRN->gc_lineoffset; + sskip = src->gf_lineoffset; + doffs = FOFS(dx,dy,dskip); + rp = &src->gf_baseaddr[0][umuladd32(sy,sskip,sx)]; + setup_far_selector(SCRN->gc_selector); + while (h--) { + int plc, pl; + pl = dx & 3; + vp = &SCRN->gc_baseaddr[0][doffs]; + switch (op) { + case C_XOR: MEM2VID_OPR(rp,_xor); break; + case C_OR: MEM2VID_OPR(rp,_or); break; + case C_AND: MEM2VID_OPR(rp,_and); break; + default: MEM2VID_SET(rp); break; + } + doffs += dskip; + rp += sskip; + } + GRX_LEAVE(); +} + +static void bltr2v(GrFrame *dst,int dx,int dy, + GrFrame *src,int sx,int sy, + int w,int h,GrColor op) +{ + GRX_ENTER(); + if(GrColorMode(op) == GrIMAGE) + _GrFrDrvGenericBitBlt(dst,dx,dy,src,sx,sy,w,h,op); + else + pbltr2v(dst,dx,dy,src,sx,sy,w,h,op); + GRX_LEAVE(); +} + + + +GrFrameDriver _GrFrameDriverVGA8X = { + GR_frameVGA8X, /* frame mode */ + GR_frameRAM8, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 2, /* scan line width alignment */ + 4, /* number of planes */ + 8, /* bits per pixel */ + 64*1024L, /* max plane size the code can handle */ + NULL, + readpixel, + drawpixel, + drawline, + drawhline, + drawvline, + drawblock, + drawbitmap, + drawpattern, + bltv2v, + bltv2r, + bltr2v, + _GrFrDrvGenericGetIndexedScanline, + _GrFrDrvGenericPutScanline +}; + diff --git a/thirdparty/grx249/src/fonts/fdtable.c b/thirdparty/grx249/src/fonts/fdtable.c new file mode 100644 index 0000000..cfff3e2 --- /dev/null +++ b/thirdparty/grx249/src/fonts/fdtable.c @@ -0,0 +1,33 @@ +/** + ** fdtable.c ---- a table of available font drivers + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grfontdv.h" + +GrFontDriver *_GrFontDriverTable[] = { +#ifdef __XWIN__ + &_GrFontDriverXWIN, +#endif + &_GrFontDriverGRX, + &_GrFontDriverBGI, + &_GrFontDriverRAW, + &_GrFontDriverFNA, + &_GrFontDriverWIN, + NULL +}; + diff --git a/thirdparty/grx249/src/fonts/fdv_bgi.c b/thirdparty/grx249/src/fonts/fdv_bgi.c new file mode 100644 index 0000000..53f7593 --- /dev/null +++ b/thirdparty/grx249/src/fonts/fdv_bgi.c @@ -0,0 +1,352 @@ +/** + ** fdv_bgi.c -- driver for Borland BGI font file format + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contrib by Christian Domp (alma.student.uni-kl.de) See "doc/contrib.doc" + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#include +#include + +#include "libgrx.h" +#include "grfontdv.h" +#include "allocate.h" +#include "arith.h" +#include "memfill.h" +#include "ordswap.h" +#include "fonts/fdv_bgi.h" + +/* This is based on the font code in Hartmut Schirmer's BCC2GRX package */ + +/* This code requires packed structs. Should be revised for ** +** better portability hsc, 980427 */ + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +static GR_int8 far *fdata = NULL; +static GR_int8u far *wtable = NULL; +static GR_int16u far *offsets = NULL; +static GR_int8u far *vecdata = NULL; +static int far *realwdt = NULL; +static int far *xoffset = NULL; +static int realhgt = 0; +static int yoffset = 0; +static BGIfontFileHeader far *fhdr = NULL; +static BGIfontHeaderType far *fhtp = NULL; + +static void cleanup(void) +{ + if(fdata) farfree(fdata); + if(realwdt) farfree(realwdt); + fdata = NULL; + realwdt = NULL; +} + +/* fix up up sizes to account for out of box characters */ +static void fixlimits(void) +{ + int i,ymin = 32000,ymax = -32000; + int orighgt = fhtp->org_to_cap - fhtp->org_to_dec; + for(i = 0; i < fhtp->nchrs; i++) { + int xpos = 0,ypos = 0,xend,yend; + int xmin = 32000,xmax = -32000; + GR_int16u far *vp = (GR_int16u far *)(vecdata + offsets[i]); + for( ; ; vp++) { + switch(SV_COMMAND(*vp)) { + case SVC_END: + break; + case SVC_MOVE: + xpos = SV_XCOORD(*vp); + ypos = fhtp->org_to_cap - SV_YCOORD(*vp); + continue; + case SVC_SCAN: + /* what to do here ? */ + continue; + case SVC_DRAW: + xend = SV_XCOORD(*vp); + yend = fhtp->org_to_cap - SV_YCOORD(*vp); + xmin = imin(xmin,imin(xpos,xend)); + ymin = imin(ymin,imin(ypos,yend)); + xmax = imax(xmax,imax(xpos,xend)); + ymax = imax(ymax,imax(ypos,yend)); + xpos = xend; + ypos = yend; + continue; + } + break; + } + xoffset[i] = imax(0,(-xmin)); + realwdt[i] = imax(1,(imax((xmax + 1),wtable[i]) + xoffset[i])); + DBGPRINTF(DBG_FONT,( + "character %3d: origwdt=%-3d realwdt=%-3d xoffset=%-3d %c\n", + (i + fhtp->firstch), + wtable[i], + realwdt[i], + xoffset[i], + (realwdt[i] > wtable[i]) ? '*' : ' ' + )); + } + yoffset = imax(0,(-ymin)); + realhgt = imax((ymax + 1),orighgt) + yoffset; + DBGPRINTF(DBG_FONT,( + "FONT orighgt=%-3d realhgt=%-3d yoffset=%-3d\n", + orighgt, + realhgt, + yoffset + )); +} + +static int openfile(char *fname) +{ + GR_int8 far *p; + FILE *fp; + long flen; + int res; + GRX_ENTER(); + res = FALSE; + do { + cleanup(); + fp = fopen(fname,"rb"); + if(!fp) break; /* FALSE */ + fseek(fp,0L,SEEK_END); + flen = ftell(fp); + fseek(fp,0L,SEEK_SET); + if((flen <= (signed long)(sizeof(*fhdr) + sizeof(*fhtp))) || + (flen != (signed long)((size_t)flen))) + break; /* FALSE */ + fdata = farmalloc((size_t)flen); + if (!fdata) break; /* FALSE */ + if (fread(fdata,1,(size_t)flen,fp) != (size_t)flen) + break; /* FALSE */ + fclose(fp); fp = NULL; + if (strncmp(fdata,FILEMARKER,strlen(FILEMARKER)) != 0) + break; /*FALSE, magic code not found */ + p = strchr(fdata,MARKEREND); /* skip copyright text */ + if (!p || ((++p) > &fdata[128 - sizeof(*fhdr)])) break; /* FALSE */ + fhdr = (BGIfontFileHeader *)p; +# if BYTE_ORDER==BIG_ENDIAN + _GR_swap16u(&fhdr->header_size); + _GR_swap16u(&fhdr->font_size); +# endif + fhtp = (BGIfontHeaderType *)(fdata + fhdr->header_size); +# if BYTE_ORDER==BIG_ENDIAN + _GR_swap16u(&fhtp->nchrs); + _GR_swap16u(&fhtp->cdefs); +# endif + if (fhtp->sig != SIGBYTE) + break; /* FALSE */ + offsets = (GR_int16u *)(fhtp + 1); + wtable = (GR_int8u *)(offsets + fhtp->nchrs); + vecdata = (GR_int8u far *)((GR_int8u far *)fhtp + fhtp->cdefs); + realwdt = farmalloc(sizeof(int) * fhtp->nchrs * 2); + xoffset = realwdt + fhtp->nchrs; + if(!realwdt) + break; /* FALSE */ + fixlimits(); + res = TRUE; + } while (0); + if (!res) { + cleanup(); + if (fp) fclose(fp); + } + GRX_RETURN(res); +} + +static unsigned int avgwidth(void) +{ + unsigned int i,total = 0; + for(i = 0; i < fhtp->nchrs; i++) total += realwdt[i]; + return((total + (fhtp->nchrs >> 1)) / fhtp->nchrs); +} + +static int header(GrFontHeader *hdr) +{ + if(!fdata) return(FALSE); + strcpy(hdr->family,"BGI"); + memcpy(hdr->name,fhdr->font_name,sizeof(fhdr->font_name)); + hdr->name[sizeof(fhdr->font_name)] = '\0'; + hdr->proportional = TRUE; + hdr->scalable = TRUE; + hdr->preloaded = FALSE; + hdr->modified = GR_FONTCVT_NONE; + hdr->width = avgwidth(); + hdr->height = realhgt; + hdr->baseline = fhtp->org_to_cap - fhtp->org_to_base + yoffset; + hdr->ulheight = imax(1,(hdr->height / 15)); + hdr->ulpos = hdr->height - hdr->ulheight; + hdr->minchar = fhtp->firstch; + hdr->numchars = fhtp->nchrs; + DBGPRINTF(DBG_FONT,( + "Font header:\n" + " name = %s\n" + " family = %s\n" + " proportional = %d\n" + " scalable = %d\n" + " preloaded = %d\n" + " modified = %d\n" + " width = %d\n" + " height = %d\n" + " baseline = %d\n" + " ulheight = %d\n" + " ulpos = %d\n" + " minchar = %d\n" + " numchars = %d\n", + hdr->name, + hdr->family, + hdr->proportional, + hdr->scalable, + hdr->preloaded, + hdr->modified, + hdr->width, + hdr->height, + hdr->baseline, + hdr->ulheight, + hdr->ulpos, + hdr->minchar, + hdr->numchars + )); + return(TRUE); +} + +static int charwdt(int chr) +{ + chr -= fhtp->firstch; + if(!fdata) return(-1); + if((unsigned int)chr >= (unsigned int)fhtp->nchrs) return(-1); + DBGPRINTF(DBG_FONT,("charwdt for %d is %d\n",(chr + fhtp->firstch),realwdt[chr])); + return(realwdt[chr]); +} + +static void bitline(int x1,int y1,int x2,int y2,char *buffer,int pitch) +{ + int dx = x2 - x1; + int dy = y2 - y1; + int xstep = (dx < 0) ? ((dx = -dx),(-1)) : 1; + int ystep = ((dy < 0) ? ((dy = -dy),(-pitch)) : pitch) << 3; + unsigned int addr = ((y1 * pitch) << 3) + x1; + int count,error,errsub,erradd; + unsigned int step1,step2; + if(dy > dx) { + count = dy + 1; + error = dy >> 1; + erradd = dy; + errsub = dx; + step1 = ystep; + step2 = xstep + ystep; + } + else { + count = dx + 1; + error = dx >> 1; + erradd = dx; + errsub = dy; + step1 = xstep; + step2 = xstep + ystep; + } + do { + buffer[addr >> 3] |= (0x80U >> (addr & 7)); + if((error -= errsub) < 0) { + error += erradd; + addr += step2; + } + else { + addr += step1; + } + } while(--count); +} + +static int bitmap(int chr,int w,int h,char *buffer) +{ + int xmul,xdiv,ymul,ydiv; + int xpos,ypos,xend,yend; + int offs; + GR_int16u far *vp; + chr -= fhtp->firstch; + if(!fdata) return(FALSE); + if((unsigned int)chr >= (unsigned int)fhtp->nchrs) return(FALSE); + if((w <= 0) || (h <= 0)) return(FALSE); + xmul = w - 1; + xdiv = realwdt[chr] - 1; + ymul = h - 1; + ydiv = realhgt - 1; + DBGPRINTF(DBG_FONT,( + "bitmap for %d, origsize = %d %d, rendered = %d %d\n", + (chr + fhtp->firstch), + (xdiv + 1),(ydiv + 1), + (xmul + 1),(ymul + 1) + )); + vp = (GR_int16u far *)(vecdata + offsets[chr]); + offs = (w + 7) >> 3; + memfill_b(buffer,0,(offs * h)); + if(xdiv <= 0) return(TRUE); + for(xpos = ypos = 0; ; vp++) { + switch(SV_COMMAND(*vp)) { + case SVC_END: + break; + case SVC_MOVE: + xpos = SV_XCOORD(*vp) + xoffset[chr]; + ypos = fhtp->org_to_cap - SV_YCOORD(*vp) + yoffset; + DBGPRINTF(DBG_FONT,( + " cmd=0x%04x, move %-3d %d\n", + *vp,xpos,ypos + )); + continue; + case SVC_SCAN: + /* what to do here ? */ + DBGPRINTF(DBG_FONT,(" cmd=0x%04x **** SCAN COMMAND FOUND ****\n",*vp)); + continue; + case SVC_DRAW: + xend = SV_XCOORD(*vp) + xoffset[chr]; + yend = fhtp->org_to_cap - SV_YCOORD(*vp) + yoffset; + DBGPRINTF(DBG_FONT,( + " cmd=0x%04x, vector %-3d %-3d [ %-3d %-3d ] %c\n", + *vp,xend,yend,xpos,ypos, + ((((unsigned int)xend > (unsigned int)xdiv) || + ((unsigned int)yend > (unsigned int)ydiv) || + ((unsigned int)xpos > (unsigned int)xdiv) || + ((unsigned int)ypos > (unsigned int)ydiv)) ? '*' : ' ' + ) + )); + bitline( + urscale(xpos,xmul,xdiv),urscale(ypos,ymul,ydiv), + urscale(xend,xmul,xdiv),urscale(yend,ymul,ydiv), + buffer,offs + ); + xpos = xend; + ypos = yend; + continue; + } + break; + } + return(TRUE); +} + +GrFontDriver _GrFontDriverBGI = { + "BGI", /* driver name (doc only) */ + ".chr", /* font file extension */ + TRUE, /* scalable */ + openfile, /* file open and check routine */ + header, /* font header reader routine */ + charwdt, /* character width reader routine */ + bitmap, /* character bitmap reader routine */ + cleanup /* cleanup routine */ +}; diff --git a/thirdparty/grx249/src/fonts/fdv_bgi.h b/thirdparty/grx249/src/fonts/fdv_bgi.h new file mode 100644 index 0000000..ea71a96 --- /dev/null +++ b/thirdparty/grx249/src/fonts/fdv_bgi.h @@ -0,0 +1,102 @@ +/** + ** fdv_bgi.h -- Borland BGI font file format + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#ifndef __FDV_BGI_H_INCLUDED__ +#define __FDV_BGI_H_INCLUDED__ + +/* This is based on the font code in Hartmut Schirmer's BCC2GRX package */ + +#ifdef __GNUC__ +#define PACKED __attribute ((packed)) +#else +#define PACKED +#endif + +/* + * Stroked BGI font file layout: + * + * +-------------------------------------------------------------------+ + * | ASCII copyright message, starts with "PK\b\b", terminated with ^Z | + * +-------------------------------------------------------------------+ + * | BGIfontFileHeader structure | + * +-------------------------------------------------------------------+ + * | BGIfontHeaderType structure (at offset 'header_size') | + * +-------------------------------------------------------------------+ + * | table of unsigned short offsets into the data table | + * +-------------------------------------------------------------------+ + * | table of unsigned char character widths | + * +-------------------------------------------------------------------+ + * | data table containing stroke vector coordinates and commands | + * +-------------------------------------------------------------------+ + */ + +typedef struct { + GR_int16u header_size PACKED; /* Version 2.0 Header Format */ + char font_name[4] PACKED; /* Font Internal Name */ + GR_int16u font_size PACKED; /* file size in bytes */ + GR_int8u font_major PACKED; /* Driver Version Information */ + GR_int8u font_minor PACKED; + GR_int8u bgi_major PACKED; /* BGI Revision Information */ + GR_int8u bgi_minor PACKED; +} BGIfontFileHeader; + +typedef struct { + char sig PACKED; /* SIGNATURE byte */ + GR_int16u nchrs PACKED; /* number of characters in file */ + char unused1 PACKED; /* Currently Undefined */ + GR_int8u firstch PACKED; /* first character in file */ + GR_int16u cdefs PACKED; /* offset to char definitions */ + GR_int8u scan_flag PACKED; /* (!= 0) -> set is scanable */ + char org_to_cap PACKED; /* Height from origin to top of capitol */ + char org_to_base PACKED; /* Height from origin to baseline */ + char org_to_dec PACKED; /* Height from origin to bot of decender */ + char unused2[5] PACKED; /* Currently undefined */ +} BGIfontHeaderType; + +#define FILEMARKER "PK\b\b" /* file should start with this */ +#define MARKEREND ('Z' - 0x40) /* end of copyright message */ +#define SIGBYTE ('+') /* value of signature byte */ + +/* + * macros to parse data words in the stroke vector table + */ +#if BYTE_ORDER==LITTLE_ENDIAN +#define SV_COMMAND(w) ((w) & 0x8080U) +#define SV_XCOORD(w) ((int)(signed char)((w) << 1) >> 1) +#define SV_YCOORD(w) ((int)(signed char)((w) >> 7) >> 1) + +#define SVC_END 0x0000U +#define SVC_MOVE 0x0080U +#define SVC_SCAN 0x8000U +#define SVC_DRAW 0x8080U +#else +/* BIG_ENDIAN system */ +#define SV_COMMAND(w) ((w) & 0x8080U) +#define SV_YCOORD(w) ((int)(signed char)((w) << 1) >> 1) +#define SV_XCOORD(w) ((int)(signed char)((w) >> 7) >> 1) + +#define SVC_END 0x0000U +#define SVC_MOVE 0x8000U +#define SVC_SCAN 0x0080U +#define SVC_DRAW 0x8080U +#endif + +#endif /* whole file */ diff --git a/thirdparty/grx249/src/fonts/fdv_fna.c b/thirdparty/grx249/src/fonts/fdv_fna.c new file mode 100644 index 0000000..10b87b0 --- /dev/null +++ b/thirdparty/grx249/src/fonts/fdv_fna.c @@ -0,0 +1,281 @@ +/** + ** fdv_fna.c -- driver for ascii font file format + ** + ** Copyright (C) 2003 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include +#include + +#include "libgrx.h" +#include "grfontdv.h" +#include "arith.h" + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +static FILE *fontfp = NULL; + +static struct { + char buffer[131]; + long offset; + int index; + int minchar; + int maxchar; + int width; + int height; + int isfixed; +} fhdr; + +static int readline(void) +{ + int res; + char *s; + GRX_ENTER(); + res = FALSE; + do { + if(fgets(fhdr.buffer, sizeof fhdr.buffer, fontfp) == NULL) { + DBGPRINTF(DBG_FONT, ("read line failed at index %d\n", fhdr.index)); + goto done; + } + s = fhdr.buffer + strlen(fhdr.buffer); + while(--s >= fhdr.buffer && (*s == '\n' || *s == '\r')); + *++s = '\0'; + if(strlen(fhdr.buffer) > 127) { + DBGPRINTF(DBG_FONT, ("line too long \"%s\"", fhdr.buffer)); + goto done; + } + while(--s >= fhdr.buffer && isspace(*s)); + *++s = '\0'; + } while(s == fhdr.buffer || *fhdr.buffer == ';'); + res = TRUE; +done: GRX_RETURN(res); +} + +static int readindex(int chr, int y) +{ + int res; + int index; + GRX_ENTER(); + res = FALSE; + index = (chr - fhdr.minchar) * fhdr.height + y; + if(fhdr.index > index) { + DBGPRINTF(DBG_FONT, ("current index %d > requested %d\n", fhdr.index, index)); + if(fseek(fontfp, fhdr.offset, SEEK_SET) < 0) goto done; + fhdr.index = -1; + } + while(fhdr.index < index) { + if(!readline()) goto done; + fhdr.index++; + } + res = TRUE; +done: GRX_RETURN(res); +} + +static void cleanup(void) +{ + GRX_ENTER(); + if(fontfp != NULL) fclose(fontfp); + fontfp = NULL; + fhdr.index = -1; + GRX_LEAVE(); +} + +static int openfile(char *fname) +{ + int res; + GRX_ENTER(); + res = FALSE; + cleanup(); + fontfp = fopen(fname, "rb"); + if(fontfp == NULL) { + DBGPRINTF(DBG_FONT, ("fopen(\"%s\") failed\n", fname)); + goto done; + } + res = TRUE; +done: if(!res) cleanup(); + GRX_RETURN(res); +} + +static int header(GrFontHeader *hdr) +{ + int res; + char *s; + int index; + int i, n; + static char *names[] = { + "name", + "family", + "isfixed", + "width", + "height", + "minchar", + "maxchar", + "baseline", + "undwidth", + "avgwidth", + "minwidth", + "maxwidth", + "note", + NULL + }; + int attrib; + GRX_ENTER(); + res = FALSE; + if(fontfp == NULL) goto done; + attrib = 0; + while(readline() && isalpha(*fhdr.buffer)) { + fhdr.offset = ftell(fontfp); + if(fhdr.offset == -1) { + DBGPRINTF(DBG_FONT, ("ftell failed after \"%s\"\n", fhdr.buffer)); + goto done; + } + if(!strcmp(fhdr.buffer, "note")) continue; + s = fhdr.buffer; + while(isalpha(*++s)); + if(!isspace(*s)) { + DBGPRINTF(DBG_FONT, ("invalid header line \"%s\"\n", fhdr.buffer)); + goto done; + } + *s = '\0'; + while(isspace(*++s)); + for(index = 0; names[index] != NULL; index++) + if(!strcmp(fhdr.buffer, names[index])) break; + if(names[index] == NULL) { + DBGPRINTF(DBG_FONT, ("unknown attribute \"%s\"\n", fhdr.buffer)); + goto done; + } + if(index == 9) index = 3; + if(attrib & (1 << index)) { + DBGPRINTF(DBG_FONT, ("duplicate attribute \"%s\"\n", fhdr.buffer)); + goto done; + } + if(index >= 2 && index <= 11) { + if(sscanf(s, "%d%n", &i, &n) != 1 || n != strlen(s)) { + DBGPRINTF(DBG_FONT, ("invalid number \"%s\"\n", s)); + goto done; + } + if(i < 0) { + DBGPRINTF(DBG_FONT, ("negative number %d\n", i)); + goto done; + } + } + switch(index) { + case 0 : strcpy(hdr->name, s); break; + case 1 : strcpy(hdr->family, s); break; + case 2 : + fhdr.isfixed = i; + hdr->proportional = !fhdr.isfixed; + break; + case 3 : hdr->width = fhdr.width = i; break; + case 4 : hdr->height = fhdr.height = i; break; + case 5 : hdr->minchar = fhdr.minchar = i; break; + case 6 : fhdr.maxchar = i; break; + case 7 : hdr->baseline = i; break; + case 8 : hdr->ulheight = i; break; + case 10 : + if(i == 0) { + DBGPRINTF(DBG_FONT, ("invalid width %d\n", i)); + goto done; + } + break; + case 11 : + if(i > 127) { + DBGPRINTF(DBG_FONT, ("invalid width %d\n", i)); + goto done; + } + break; + case 12 : continue; + default : + DBGPRINTF(DBG_FONT, ("unsupported attribute \"%s\"\n", fhdr.buffer)); + goto done; + } + attrib |= 1 << index; + } + if((attrib & 0xFF) != 0xFF) { + DBGPRINTF(DBG_FONT, ("insufficient attributes 0x%x\n", attrib)); + goto done; + } + hdr->numchars = fhdr.maxchar - fhdr.minchar + 1; + if(hdr->numchars <= 0) { + DBGPRINTF(DBG_FONT, ("minchar %d > maxchar %d\n", fhdr.minchar, fhdr.maxchar)); + goto done; + } + fhdr.index++; + hdr->scalable = FALSE; + hdr->preloaded = FALSE; + hdr->modified = GR_FONTCVT_NONE; + if((attrib & 0x0100) == 0) hdr->ulheight = imax(1, hdr->height / 15); + hdr->ulpos = hdr->height - hdr->ulheight; + res = TRUE; +done: GRX_RETURN(res); +} + +static int charwdt(int chr) +{ + int res; + GRX_ENTER(); + DBGPRINTF(DBG_FONT, ("charwdt(%d)\n", chr)); + res = -1; + if(fontfp != NULL && chr >= fhdr.minchar && chr <= fhdr.maxchar) { + if(fhdr.isfixed) res = fhdr.width; + else if(readindex(chr, 0)) res = strlen(fhdr.buffer); + } + GRX_RETURN(res); +} + +static int bitmap(int chr, int w, int h, char *buffer) +{ + int res; + int y, x; + int bytes; + GRX_ENTER(); + DBGPRINTF(DBG_FONT, ("bitmap(%d, %d, %d)\n", chr, w, h)); + res = FALSE; + if(w != charwdt(chr) || h != fhdr.height) goto done; + bytes = (w - 1) / 8 + 1; + memset(buffer, '\0', bytes * h); + for(y = 0; y < h; y++) { + if(!readindex(chr, y)) goto done; + if(strlen(fhdr.buffer) != w) { + DBGPRINTF(DBG_FONT, ("strlen(\"%s\") != %d\n", fhdr.buffer, w)); + goto done; + } + for(x = 0; x < w; x++) { + if(fhdr.buffer[x] == '#') buffer[x >> 3] |= 1 << (7 - (x & 7)); + else if(fhdr.buffer[x] != '.') { + DBGPRINTF(DBG_FONT, ("invalid character data \'%c\'\n", fhdr.buffer[x])); + goto done; + } + } + buffer += bytes; + } + res = TRUE; +done: GRX_RETURN(res); +} + +GrFontDriver _GrFontDriverFNA = { + "FNA", /* driver name (doc only) */ + ".fna", /* font file extension */ + FALSE, /* scalable */ + openfile, /* file open and check routine */ + header, /* font header reader routine */ + charwdt, /* character width reader routine */ + bitmap, /* character bitmap reader routine */ + cleanup /* cleanup routine */ +}; diff --git a/thirdparty/grx249/src/fonts/fdv_grx.c b/thirdparty/grx249/src/fonts/fdv_grx.c new file mode 100644 index 0000000..1d03b1f --- /dev/null +++ b/thirdparty/grx249/src/fonts/fdv_grx.c @@ -0,0 +1,204 @@ +/** + ** fdv_grx.c -- driver for GRX native font file format + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include + +#include "libgrx.h" +#include "grfontdv.h" +#include "allocate.h" +#include "fonts/fdv_grx.h" + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +static GrFontFileHeaderGRX fhdr; +static FILE *fontfp = NULL; +static GR_int16u far *wtable = NULL; +static unsigned int wtsize = 0; +static int nextch = 0; + +#if BYTE_ORDER==BIG_ENDIAN +#include "ordswap.h" +static void swap_header(void) { + GRX_ENTER(); + _GR_swap32u(&fhdr.magic); + _GR_swap32u(&fhdr.bmpsize); + _GR_swap16u(&fhdr.width); + _GR_swap16u(&fhdr.height); + _GR_swap16u(&fhdr.minchar); + _GR_swap16u(&fhdr.maxchar); + _GR_swap16u(&fhdr.isfixed); + _GR_swap16u(&fhdr.reserved); + _GR_swap16u(&fhdr.baseline); + _GR_swap16u(&fhdr.undwidth); + /* no need to change fnname && family */ + GRX_LEAVE(); +} + +static void swap_wtable(void) { + GR_int16u far *wt; + unsigned int ws; + GRX_ENTER(); + wt = wtable; + ws = wtsize / sizeof(GR_int16u); + while (ws-- > 0) { + _GR_swap16u(wt); + ++wt; + } + GRX_LEAVE(); +} +#endif + +static void cleanup(void) +{ + GRX_ENTER(); + if(fontfp != NULL) fclose(fontfp); + if(wtable != NULL) farfree(wtable); + fontfp = NULL; + wtable = NULL; + nextch = 0; + wtsize = 0; + GRX_LEAVE(); +} + +static int openfile(char *fname) +{ + int res; +#if BYTE_ORDER==BIG_ENDIAN + int swap; +#endif + GRX_ENTER(); + res = FALSE; + cleanup(); + fontfp = fopen(fname,"rb"); + if(fontfp == NULL) { + DBGPRINTF(DBG_FONT,("fopen(\"%s\") failed\n", fname)); + goto done; + } + if(fread(&fhdr,sizeof(fhdr),1,fontfp) != 1) { + DBGPRINTF(DBG_FONT,("reading header failed\n")); + goto done; + } +#if BYTE_ORDER==BIG_ENDIAN + swap = 0; + if(fhdr.magic == GRX_FONTMAGIC_SWAPPED) { + swap = 1; + DBGPRINTF(DBG_FONT,("swaping header byte order\n")); + swap_header(); + } +#endif + if(fhdr.magic != GRX_FONTMAGIC) { + DBGPRINTF(DBG_FONT,("font magic doesn't fit: %lx != %lx\n", \ + (unsigned long)fhdr.magic,(unsigned long)GRX_FONTMAGIC)); + goto done; + } + if(!fhdr.isfixed) { + wtsize = sizeof(GR_int16u) * (fhdr.maxchar - fhdr.minchar + 1); + wtable = farmalloc(wtsize); + if(wtable == NULL) { + DBGPRINTF(DBG_FONT,("Allocating wtable failed\n")); + goto done; + } + if(fread(wtable,wtsize,1,fontfp) != 1) { + DBGPRINTF(DBG_FONT,("Loading wtable failed\n")); + goto done; + } +#if BYTE_ORDER==BIG_ENDIAN + if (swap) { + DBGPRINTF(DBG_FONT,("swaping wtable byte order\n")); + swap_wtable(); + } +#endif + } + nextch = fhdr.minchar; + res = TRUE; +done: if (!res) cleanup(); + GRX_RETURN(res); +} + +static int header(GrFontHeader *hdr) +{ + int res; + GRX_ENTER(); + res = FALSE; + if(fontfp != NULL) { + memcpy(hdr->name, fhdr.fnname,sizeof(fhdr.fnname)); + memcpy(hdr->family,fhdr.family,sizeof(fhdr.family)); + hdr->name [sizeof(fhdr.fnname)] = '\0'; + hdr->family[sizeof(fhdr.family)] = '\0'; + hdr->proportional = fhdr.isfixed ? FALSE : TRUE; + hdr->scalable = FALSE; + hdr->preloaded = FALSE; + hdr->modified = GR_FONTCVT_NONE; + hdr->width = fhdr.width; + hdr->height = fhdr.height; + hdr->baseline = fhdr.baseline; + hdr->ulpos = fhdr.height - fhdr.undwidth; + hdr->ulheight = fhdr.undwidth; + hdr->minchar = fhdr.minchar; + hdr->numchars = fhdr.maxchar - fhdr.minchar + 1; + res = TRUE; + } + GRX_RETURN(res); +} + +static int charwdt(int chr) +{ + int res; + GRX_ENTER(); + res = -1; + if(fontfp != NULL && + chr >= fhdr.minchar && + chr <= fhdr.maxchar ) + res = (fhdr.isfixed ? fhdr.width : wtable[chr - fhdr.minchar]); + GRX_RETURN(res); +} + +static int bitmap(int chr,int w,int h,char *buffer) +{ + int res; + GRX_ENTER(); + res = FALSE; + if( (w > 0) && (w == charwdt(chr)) + &&(h > 0) && (h == fhdr.height) ) { + if(chr != nextch) { + long fpos = sizeof(fhdr) + (fhdr.isfixed ? 0 : wtsize); + for(nextch = fhdr.minchar; nextch != chr; nextch++) { + fpos += ((charwdt(nextch) + 7) >> 3) * fhdr.height; + } + fseek(fontfp,fpos,SEEK_SET); + } + nextch = chr + 1; + res = fread(buffer,(((w + 7) >> 3) * h),1,fontfp) == 1; + } + GRX_RETURN(res); +} + +GrFontDriver _GrFontDriverGRX = { + "GRX", /* driver name (doc only) */ + ".fnt", /* font file extension */ + FALSE, /* scalable */ + openfile, /* file open and check routine */ + header, /* font header reader routine */ + charwdt, /* character width reader routine */ + bitmap, /* character bitmap reader routine */ + cleanup /* cleanup routine */ +}; + diff --git a/thirdparty/grx249/src/fonts/fdv_grx.h b/thirdparty/grx249/src/fonts/fdv_grx.h new file mode 100644 index 0000000..c67918a --- /dev/null +++ b/thirdparty/grx249/src/fonts/fdv_grx.h @@ -0,0 +1,56 @@ +/** + ** fdv_grx.h -- GRX native font file format + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __FDV_GRX_H_INCLUDED__ +#define __FDV_GRX_H_INCLUDED__ + +/* + * font file structure: + * +-----------------------+ + * | FILE HEADER | + * +-----------------------+ + * | PROPORTIONAL | + * | WIDTH TABLE | + * | (16 bit ints) | + * | (prop fonts only) | + * +-----------------------+ + * | BITMAP | + * +-----------------------+ + */ + +#define GRX_NAMEWIDTH 16 +#define GRX_FONTMAGIC 0x19590214L +#define GRX_FONTMAGIC_SWAPPED 0x14025919L + +typedef struct _GR_fontFileHeaderGRX { /* the header */ + GR_int32u magic; /* font file magic number */ + GR_int32u bmpsize; /* character bitmap size */ + GR_int16u width; /* width (average for proportional) */ + GR_int16u height; /* font height */ + GR_int16u minchar; /* lowest character code in font */ + GR_int16u maxchar; /* highest character code in font */ + GR_int16u isfixed; /* nonzero if fixed font */ + GR_int16u reserved; /* ??? */ + GR_int16u baseline; /* baseline from top of font */ + GR_int16u undwidth; /* underline width (at bottom) */ + char fnname[GRX_NAMEWIDTH]; /* font file name (w/o path) */ + char family[GRX_NAMEWIDTH]; /* font family name */ +} GrFontFileHeaderGRX; + +#endif /* whole file */ + diff --git a/thirdparty/grx249/src/fonts/fdv_raw.c b/thirdparty/grx249/src/fonts/fdv_raw.c new file mode 100644 index 0000000..eee7809 --- /dev/null +++ b/thirdparty/grx249/src/fonts/fdv_raw.c @@ -0,0 +1,222 @@ +/** + ** fdv_raw.c -- driver for raw font file format + ** + ** Copyright (C) 2003 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Changes by Dimitar Zhekov (jimmy@is-vn.bg) Nov 20 2003 + ** - Added psf2 support, raw and psf1 are now treated as pseudo-psf2. + ** - Better support for RAW files: up to 16x32, assuming scale 1:2. + ** + **/ + +#include +#include +#include +#include + +#include "libgrx.h" +#include "grfontdv.h" +#include "arith.h" +#include "fonts/fdv_raw.h" + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +static FILE *fontfp = NULL; +static int nextch = 0; +static char name[40], family[40]; +static GrFontFileHeaderPSF fhdr; + +#if BYTE_ORDER==BIG_ENDIAN +#include "ordswap.h" +static void swap_header(void) { + GRX_ENTER(); + _GR_swap32u(&fhdr.version); + _GR_swap32u(&fhdr.offset); + _GR_swap32u(&fhdr.flags); + _GR_swap32u(&fhdr.length); + _GR_swap32u(&fhdr.charsize); + _GR_swap32u(&fhdr.height); + _GR_swap32u(&fhdr.width); + GRX_LEAVE(); +} +#endif + +static void cleanup(void) +{ + GRX_ENTER(); + if(fontfp != NULL) fclose(fontfp); + fontfp = NULL; + nextch = 0; + GRX_LEAVE(); +} + +static int openfile(char *fname) +{ + int res; + long size; + char *s; + GRX_ENTER(); + res = FALSE; + cleanup(); + /* open fname and read header */ + fontfp = fopen(fname, "rb"); + if(fontfp == NULL) { + DBGPRINTF(DBG_FONT, ("fopen(\"%s\") failed\n", fname)); + goto done; + } + if(fread(&fhdr, 1, sizeof fhdr, fontfp) != sizeof fhdr) { + DBGPRINTF(DBG_FONT, ("read header failed\n")); + goto done; + } + if(fseek(fontfp, 0, SEEK_END) < 0) { + DBGPRINTF(DBG_FONT, ("seek to end of file failed\n")); + goto done; + } + size = ftell(fontfp); + if(size < 0) { + DBGPRINTF(DBG_FONT, ("tell file position failed\n")); + goto done; + } + /* try to guess file type */ + if(fhdr.id[0] == PSF1_MAGIC0 && fhdr.id[1] == PSF1_MAGIC1) { + fhdr.offset = PSF1_HDRSIZE; + fhdr.width = 8; + fhdr.height = fhdr.charsize = fhdr.size; + fhdr.numchars = (fhdr.mode & PSF1_MODE512) == 0 ? 256 : 512; + } + else if(fhdr.id[0] == PSF2_MAGIC0 && fhdr.id[1] == PSF2_MAGIC1 && fhdr.mode == PSF2_MAGIC2 && fhdr.size == PSF2_MAGIC3) + { +#if BYTE_ORDER==BIG_ENDIAN + DBGPRINTF(DBG_FONT, ("swapping header byte order\n")); + swap_header(); +#endif + fhdr.charsize = ((fhdr.width + 7) / 8) * fhdr.height; + if(fhdr.numchars == 0) { + DBGPRINTF(DBG_FONT, ("invalid numchars\n")); + goto done; + } + } + else { + if(size > 16384 || size % (size <= 4096 ? 256 : 512)) { + DBGPRINTF(DBG_FONT, ("invalid raw file size\n")); + goto done; + } + fhdr.offset = 0; + fhdr.charsize = size / 256; + if(size <= 4096) { + fhdr.width = 8; + fhdr.height = fhdr.charsize; + } + else { + fhdr.height = size / 512; + fhdr.width = (fhdr.height + 1) / 2; + } + fhdr.numchars = 256; + } + if(fhdr.offset != 0) { + if(fhdr.charsize == 0) { + DBGPRINTF(DBG_FONT, ("invalid psf charsize\n")); + goto done; + } + if(size - fhdr.offset < fhdr.charsize * fhdr.numchars) { + DBGPRINTF(DBG_FONT, ("invalid psf file size\n")); + goto done; + } + } + /* get font name and family */ + s = strrchr(fname, '/'); +#if defined(__MSDOS__) || defined(__WIN32__) + if(s == NULL) { + s = strrchr(fname, '\\'); + if(s == NULL) s = strrchr(fname, ':'); + } + else if(strrchr(s, '\\') != NULL) s = strrchr(s, '\\'); +#endif + if(s == NULL || *++s == '\0') s = fname; + strncpy(name, s, sizeof name - 1); + name[sizeof name - 1] = '\0'; + if((s = strrchr(name, '.')) != NULL) *s = '\0'; + if(*name == '\0') sprintf(name, fhdr.offset != 0 ? "psf%d" : "raw%d", (int) fhdr.height); + strcpy(family, name); + for(s = family; isalpha(*s); s++); + if(s > family) *s = '\0'; + /* finish and return */ + nextch = fhdr.numchars; + res = TRUE; +done: if(!res) cleanup(); + GRX_RETURN(res); +} + +static int header(GrFontHeader *hdr) +{ + int res; + GRX_ENTER(); + res = FALSE; + if(fontfp != NULL) { + strcpy(hdr->name, name); + strcpy(hdr->family, family); + hdr->proportional = FALSE; + hdr->scalable = FALSE; + hdr->preloaded = FALSE; + hdr->modified = GR_FONTCVT_NONE; + hdr->width = fhdr.width; + hdr->height = fhdr.height; + hdr->baseline = (hdr->height * 4) / 5 + (hdr->height < 15); + hdr->ulheight = imax(1, hdr->height / 15); + hdr->ulpos = hdr->height - hdr->ulheight; + hdr->minchar = 0; + hdr->numchars = fhdr.numchars; + res = TRUE; + } + GRX_RETURN(res); +} + +static int charwdt(int chr) +{ + int res; + GRX_ENTER(); + res = -1; + if(fontfp != NULL && chr >= 0 && chr < fhdr.numchars) res = fhdr.width; + GRX_RETURN(res); +} + +static int bitmap(int chr,int w,int h,char *buffer) +{ + int res; + GRX_ENTER(); + res = FALSE; + if(w != charwdt(chr) || h != fhdr.height) goto done; + if(chr != nextch && fseek(fontfp, fhdr.offset + fhdr.charsize * chr, SEEK_SET) < 0) goto done; + if(fread(buffer, 1, fhdr.charsize, fontfp) != fhdr.charsize) goto done; + nextch = chr + 1; + res = TRUE; +done: GRX_RETURN(res); +} + +GrFontDriver _GrFontDriverRAW = { + "RAW", /* driver name (doc only) */ + ".psf", /* font file extension */ + FALSE, /* scalable */ + openfile, /* file open and check routine */ + header, /* font header reader routine */ + charwdt, /* character width reader routine */ + bitmap, /* character bitmap reader routine */ + cleanup /* cleanup routine */ +}; diff --git a/thirdparty/grx249/src/fonts/fdv_raw.h b/thirdparty/grx249/src/fonts/fdv_raw.h new file mode 100644 index 0000000..d65f826 --- /dev/null +++ b/thirdparty/grx249/src/fonts/fdv_raw.h @@ -0,0 +1,52 @@ +/** + ** fdv_raw.h -- driver for raw font file format + ** + ** Copyright (C) 2003 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __FDV_RAW_H_INCLUDED__ +#define __FDV_RAW_H_INCLUDED__ + +#ifdef __GNUC__ +#define PACKED __attribute__((packed)) +#else +#define PACKED +#endif + +#define PSF1_MAGIC0 0x36 +#define PSF1_MAGIC1 0x04 +#define PSF1_MODE512 0x01 +#define PSF1_UNICODE 0x02 +#define PSF1_HDRSIZE 0x04 + +#define PSF2_MAGIC0 0x72 +#define PSF2_MAGIC1 0xb5 +#define PSF2_MAGIC2 0x4a +#define PSF2_MAGIC3 0x86 +#define PSF2_UNICODE 0x01 + +typedef struct _GR_fontFileHeaderPSF { /* the header */ + GR_int8u id[2]; + GR_int8u mode; /* or psf2 id[2] */ + GR_int8u size; /* or psf2 id[3] */ + GR_int32u version; + GR_int32u offset; + GR_int32u flags; + GR_int32u numchars; + GR_int32u charsize; + GR_int32u height, width; +} PACKED GrFontFileHeaderPSF; + +#endif diff --git a/thirdparty/grx249/src/fonts/fdv_win.c b/thirdparty/grx249/src/fonts/fdv_win.c new file mode 100644 index 0000000..fb342a2 --- /dev/null +++ b/thirdparty/grx249/src/fonts/fdv_win.c @@ -0,0 +1,236 @@ +/** + ** fdv_win.c -- driver for Windows resource font file format + ** + ** Copyright (C) 2003 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include +#include + +#include "libgrx.h" +#include "grfontdv.h" +#include "arith.h" +#include "allocate.h" +#include "fonts/fdv_win.h" + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +static FILE *fontfp = NULL; +static int offset = 0; +static GrResourceFileHeaderWIN rhdr; +static GrFontFileHeaderWIN fhdr; +static GrCharHeaderWIN far *ctable = NULL; + +#if BYTE_ORDER==BIG_ENDIAN +#include "ordswap.h" +static void swap_resource(void) +{ + GRX_ENTER(); + _GR_swap16u(&rhdr.type_id); + _GR_swap16u(&rhdr.name_id); + _GR_swap16u(&rhdr.flags); + _GR_swap32u(&rhdr.size); + GRX_LEAVE(); +} + +static void swap_header(void) +{ + GRX_ENTER(); + _GR_swap16u(&fhdr.version); + _GR_swap32u(&fhdr.size); + _GR_swap16u(&fhdr.type); + _GR_swap16u(&fhdr.points); + _GR_swap16u(&fhdr.vert_res); + _GR_swap16u(&fhdr.horiz_res); + _GR_swap16u(&fhdr.ascent); + _GR_swap16u(&fhdr.internal_leading); + _GR_swap16u(&fhdr.external_leading); + _GR_swap16u(&fhdr.weight); + _GR_swap16u(&fhdr.pix_width); + _GR_swap16u(&fhdr.pix_height); + _GR_swap16u(&fhdr.avg_width); + _GR_swap16u(&fhdr.max_width); + _GR_swap16u(&fhdr.width_bytes); + _GR_swap32u(&fhdr.device); + _GR_swap32u(&fhdr.face); + _GR_swap32u(&fhdr.bits_pointer); + _GR_swap32u(&fhdr.bits_offset); + GRX_LEAVE(); +} + +static void swap_ctable(void) +{ + int i; + GRX_ENTER(); + for(i = 0; i < fhdr.last_char - fhdr.first_char + 2; i++) { + _GR_swap16u(&ctable[i].width); + _GR_swap16u(&ctable[i].offset); + } + GRX_LEAVE(); +} +#endif + +static void cleanup(void) +{ + GRX_ENTER(); + if(fontfp != NULL) fclose(fontfp); + if(ctable != NULL) farfree(ctable); + fontfp = NULL; + ctable = NULL; + offset = 0; + GRX_LEAVE(); +} + +static int openfile(char *fname) +{ + int res; + unsigned size; + GRX_ENTER(); + res = FALSE; + cleanup(); + /* open and test the file */ + fontfp = fopen(fname, "rb"); + if(fontfp == NULL) { + DBGPRINTF(DBG_FONT, ("fopen(\"%s\") failed\n", fname)); + goto done; + } + if(fread(&rhdr, 1, sizeof rhdr, fontfp) != sizeof rhdr) { + DBGPRINTF(DBG_FONT, ("read resource failed\n", fname)); + goto done; + } + if(rhdr.type_ff == 0xFF) { +#if BYTE_ORDER==BIG_ENDIAN + DBGPRINTF(DBG_FONT, ("swapping resource byte order\n")); + swap_resource(); +#endif + if(rhdr.type_id != 0x0008 || rhdr.name_ff != 0xFF) { + DBGPRINTF(DBG_FONT, ("invalid or unsupported resource header\n")); + goto done; + } + offset = sizeof rhdr; + } + else if(fseek(fontfp, 0, SEEK_SET < 0)) { + DBGPRINTF(DBG_FONT, ("rewind failed")); + goto done; + } + if(fread(&fhdr, 1, sizeof fhdr, fontfp) != sizeof fhdr) { + DBGPRINTF(DBG_FONT, ("read header failed\n")); + goto done; + } +#if BYTE_ORDER==BIG_ENDIAN + DBGPRINTF(DBG_FONT, ("swapping header byte order\n")); + swap_header(); +#endif + if(fhdr.version != 0x0200 || fhdr.type != 0) { + DBGPRINTF(DBG_FONT, ("unrecognized font header\n")); + goto done; + } + /* allocate and read the ctable */ + size = (fhdr.last_char - fhdr.first_char + 2) * sizeof *ctable; + if((ctable = farmalloc(size)) == NULL) { + DBGPRINTF(DBG_FONT, ("allocate ctable failed\n")); + goto done; + } + if(fread(ctable, 1, size, fontfp) != size) { + DBGPRINTF(DBG_FONT, ("read ctable failed\n")); + goto done; + } +#if BYTE_ORDER==BIG_ENDIAN + DBGPRINTF(DBG_FONT, ("swapping ctable byte order\n")); + swap_ctable(); +#endif + res = TRUE; +done: if(!res) cleanup(); + GRX_RETURN(res); +} + +static char *families[] = { "Unknown", "Roman", "Swiss", "Modern", "Script", "Decorative" }; + +static int header(GrFontHeader *hdr) +{ + int res; + int c; + char *s; + GRX_ENTER(); + res = FALSE; + if(fontfp != NULL) { + if((c = fhdr.pitch_and_family >> 4) <= 5) strcpy(hdr->family, families[c]); + else sprintf(hdr->family, "0x%x", fhdr.pitch_and_family); + if(fhdr.face) { + s = hdr->name; + if(fseek(fontfp, offset + fhdr.face, SEEK_SET) < 0) goto done; + do { + if((c = fgetc(fontfp)) == EOF) goto done; + *(s++) = c; + } while(c && s - hdr->name < 99); + if(c) *s = '\0'; + } + else sprintf(hdr->name, "%s-%d", hdr->family, fhdr.pix_height); + hdr->proportional = fhdr.pix_width == 0; + hdr->scalable = FALSE; + hdr->preloaded = FALSE; + hdr->modified = GR_FONTCVT_NONE; + hdr->width = hdr->proportional ? fhdr.avg_width : fhdr.pix_width; + hdr->height = fhdr.pix_height; + hdr->baseline = fhdr.ascent; + hdr->ulheight = imax(1, hdr->height / 15); + hdr->ulpos = hdr->height - hdr->ulheight; + hdr->minchar = fhdr.first_char; + hdr->numchars = fhdr.last_char - fhdr.first_char + 1; + res = TRUE; + } +done: GRX_RETURN(res); +} + +static int charwdt(int chr) +{ + int res; + GRX_ENTER(); + res = -1; + if(fontfp != NULL && chr >= fhdr.first_char && chr <= fhdr.last_char) res = ctable[chr - fhdr.first_char].width; + GRX_RETURN(res); +} + +static int bitmap(int chr, int w, int h, char *buffer) +{ + int res; + int i, y; + int bytes; + GRX_ENTER(); + res = FALSE; + if(w != charwdt(chr) || h != fhdr.pix_height) goto done; + bytes = (w - 1) / 8 + 1; + if(fseek(fontfp, offset + ctable[chr - fhdr.first_char].offset, SEEK_SET) < 0) goto done; + for(i = 0; i < bytes; i++) + for(y = 0; y < h; y++) + if(fread(buffer + bytes * y + i, 1, 1, fontfp) != 1) goto done; + res = TRUE; +done: GRX_RETURN(res); +} + +GrFontDriver _GrFontDriverWIN = { + "WIN", /* driver name (doc only) */ + ".res", /* font file extension */ + FALSE, /* scalable */ + openfile, /* file open and check routine */ + header, /* font header reader routine */ + charwdt, /* character width reader routine */ + bitmap, /* character bitmap reader routine */ + cleanup /* cleanup routine */ +}; diff --git a/thirdparty/grx249/src/fonts/fdv_win.h b/thirdparty/grx249/src/fonts/fdv_win.h new file mode 100644 index 0000000..536a3a8 --- /dev/null +++ b/thirdparty/grx249/src/fonts/fdv_win.h @@ -0,0 +1,77 @@ +/** + ** fdv_win.h -- driver for Windows resource font file format + ** + ** Copyright (C) 2002 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __FDV_WIN_H_INCLUDED__ +#define __FDV_WIN_H_INCLUDED__ + +#ifdef __GNUC__ +#define PACKED __attribute__((packed)) +#else +#define PACKED +#endif + +typedef struct _GR_resourceFileHeaderWIN +{ + GR_int8u type_ff; + GR_int16u type_id; + GR_int8u name_ff; + GR_int16u name_id; + GR_int16u flags; + GR_int32u size; +} PACKED GrResourceFileHeaderWIN; + +typedef struct _GR_fontFileHeaderWIN { /* the header */ + GR_int16u version; + GR_int32u size; + GR_int8 copyright[60]; + GR_int16u type; + GR_int16u points; + GR_int16u vert_res; + GR_int16u horiz_res; + GR_int16u ascent; + GR_int16u internal_leading; + GR_int16u external_leading; + GR_int8u italic; + GR_int8u underline; + GR_int8u strike_out; + GR_int16u weight; + GR_int8u char_set; + GR_int16u pix_width; + GR_int16u pix_height; + GR_int8u pitch_and_family; + GR_int16u avg_width; + GR_int16u max_width; + GR_int8u first_char; + GR_int8u last_char; + GR_int8u default_char; + GR_int8u break_char; + GR_int16u width_bytes; + GR_int32u device; + GR_int32u face; + GR_int32u bits_pointer; + GR_int32u bits_offset; + GR_int8u reserved; +} PACKED GrFontFileHeaderWIN; + +typedef struct _GR_charHeaderWIN +{ + GR_int16u width; + GR_int16u offset; +} PACKED GrCharHeaderWIN; + +#endif diff --git a/thirdparty/grx249/src/fonts/fdv_xwin.c b/thirdparty/grx249/src/fonts/fdv_xwin.c new file mode 100644 index 0000000..ca19af9 --- /dev/null +++ b/thirdparty/grx249/src/fonts/fdv_xwin.c @@ -0,0 +1,211 @@ +/** + ** fdv_xwin.c -- driver X Windows fonts + ** + ** Author: Ulrich Leodolter + ** E-mail: ulrich@lab1.psy.univie.ac.at + ** Date: Thu Sep 28 11:21:46 1995 + ** RCSId: $Id$ + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by Dimitar Zhekov (jimmy@is-vn.bg) May 11 2003 + ** - use the default underline height instead of font descent + ** - use a separate X display and window (how costly is that?) + ** - use the real font name and font family whenever possible + **/ + +#include +#include + +#include "libgrx.h" +#include "libxwin.h" +#include +#include "grfontdv.h" +#include "allocate.h" +#include "arith.h" + +static Display * fontdsp = NULL; +static Window fontwin = None; +static XFontStruct * fontp = NULL; +static Pixmap fontbmp = None; +static GC fontgc = None; + +static unsigned char swap_byte[256]; +static unsigned char swap_byte_inited = 0; + +static void init_swap_byte (void) +{ + if (!swap_byte_inited) { + unsigned int i; + for (i = 0; i < 256; i++) { + swap_byte[i] = ( ((i&0x01)<<7) | ((i&0x02)<<5) + | ((i&0x04)<<3) | ((i&0x08)<<1) + | ((i&0x10)>>1) | ((i&0x20)>>3) + | ((i&0x40)>>5) | ((i&0x80)>>7)); + } + swap_byte_inited = 1; + } +} + +static void cleanup(void) +{ + if (fontdsp != NULL) { + if (fontp != NULL) XFreeFont (fontdsp, fontp); + if (fontbmp != None) XFreePixmap (fontdsp, fontbmp); + if (fontgc != None) XFreeGC (fontdsp, fontgc); + if (fontwin != None) XDestroyWindow (fontdsp, fontwin); + XCloseDisplay (fontdsp); + } + fontdsp = NULL; + fontwin = None; + fontp = NULL; + fontbmp = None; + fontgc = None; +} + +static int openfile(char *fname) +{ + int res; + Window root; + int i, numchars; + + res = FALSE; + init_swap_byte(); + cleanup(); + fontdsp = XOpenDisplay (""); + if (fontdsp == NULL) goto done; + root = DefaultRootWindow (fontdsp); + fontwin = XCreateSimpleWindow (fontdsp, root, 0, 0, 1, 1, 0, 0, 0); + if (fontwin == None) goto done; + + fontp = XLoadQueryFont (fontdsp, fname); + if (fontp == NULL) goto done; + + numchars = fontp->max_char_or_byte2 - fontp->min_char_or_byte2 + 1; + fontbmp = XCreatePixmap (fontdsp, fontwin, + numchars * fontp->max_bounds.width, + fontp->ascent + fontp->descent, 1); + if (fontbmp == None) goto done; + fontgc = XCreateGC (fontdsp, fontbmp, 0L, NULL); + if (fontgc == None) goto done; + XSetFont (fontdsp, fontgc, fontp->fid); + XSetForeground (fontdsp, fontgc, 0); + XFillRectangle (fontdsp, fontbmp, fontgc, 0, 0, + numchars * fontp->max_bounds.width, + fontp->ascent + fontp->descent); + XSetForeground (fontdsp, fontgc, 1); + XSetBackground (fontdsp, fontgc, 0); + for (i = 0; i < numchars; i++) { + char c = fontp->min_char_or_byte2 + i; + XDrawString (fontdsp, fontbmp, fontgc, + i * fontp->max_bounds.width, + fontp->ascent, &c, 1); + } + res = TRUE; +done: + if (!res) cleanup(); + return(res); +} + +static int header(GrFontHeader *hdr) +{ + unsigned long card32; + char *value; + + if (fontp == NULL) return(FALSE); + strcpy(hdr->family, "xwin"); + if (XGetFontProperty (fontp, XA_FAMILY_NAME, &card32)) { + value = XGetAtomName (fontdsp, card32); + if (value != NULL) { + strncpy(hdr->family, value, 99); + hdr->family[99] = '\0'; + XFree (value); + } + } + hdr->proportional = (fontp->per_char == NULL) ? FALSE : TRUE; + hdr->scalable = FALSE; + hdr->preloaded = FALSE; + hdr->modified = GR_FONTCVT_NONE; + hdr->width = fontp->max_bounds.width; + hdr->height = fontp->ascent + fontp->descent; + hdr->baseline = fontp->ascent; + hdr->ulheight = imax(1,(hdr->height / 15)); + hdr->ulpos = hdr->height - hdr->ulheight; + hdr->minchar = fontp->min_char_or_byte2; + hdr->numchars = fontp->max_char_or_byte2 - fontp->min_char_or_byte2 + 1; + strncpy(hdr->name, hdr->family, 89); + hdr->name[89] = '\0'; + sprintf(hdr->name + strlen(hdr->name), "-%d", hdr->height); + if (XGetFontProperty (fontp, XA_FONT_NAME, &card32)) { + value = XGetAtomName (fontdsp, card32); + if (value != NULL) { + strncpy(hdr->name, value, 99); + hdr->name[99] = '\0'; + XFree (value); + } + } + return(TRUE); +} + +static int charwdt(int chr) +{ + int width; + if (fontp == NULL) return(-1); + if (chr < fontp->min_char_or_byte2) return(-1); + if (chr > fontp->max_char_or_byte2) return(-1); + if (fontp->per_char == NULL) return(fontp->max_bounds.width); + width = fontp->per_char[chr - fontp->min_char_or_byte2].width; + if (width <= 0) + return fontp->per_char[fontp->default_char - fontp->min_char_or_byte2].width; + return(width); +} + +static int bitmap(int chr,int w,int h,char *buffer) +{ + XImage *img; + int x, y, bpl; + unsigned char *data; + + if (fontp == NULL || fontbmp == None) return(FALSE); + if ((w <= 0) || (w != charwdt(chr))) return(FALSE); + if ((h <= 0) || (h != (fontp->ascent + fontp->descent))) return(FALSE); + if (fontdsp == NULL) return(FALSE); + img = XGetImage (fontdsp, + fontbmp, + (chr - fontp->min_char_or_byte2) * fontp->max_bounds.width, + 0, + w, + h, + AllPlanes, + ZPixmap); + if (img == NULL) return(FALSE); + data = (unsigned char *)(img->data); + bpl = (w + 7) >> 3; + for (y = 0; y < h; y++) { + for (x = 0; x < bpl; x++) buffer[x] = swap_byte[data[x]]; + buffer += bpl; + data += img->bytes_per_line; + } + XDestroyImage (img); + return(TRUE); +} + +GrFontDriver _GrFontDriverXWIN = { + "XWIN", /* driver name (doc only) */ + "", /* font file extension */ + FALSE, /* scalable */ + openfile, /* file open and check routine */ + header, /* font header reader routine */ + charwdt, /* character width reader routine */ + bitmap, /* character bitmap reader routine */ + cleanup /* cleanup routine */ +}; + diff --git a/thirdparty/grx249/src/fonts/pc6x8.c b/thirdparty/grx249/src/fonts/pc6x8.c new file mode 100644 index 0000000..5b1d260 --- /dev/null +++ b/thirdparty/grx249/src/fonts/pc6x8.c @@ -0,0 +1,812 @@ +/** + ** pc6x8.c ---- GRX 2.0 font converted to C by 'GrDumpFont()' + ** + **/ + +#define GrFont_PC6x8 FONTNAME_TEMPORARY_REDIRECTION +#include "grx20.h" +#undef GrFont_PC6x8 + +static unsigned char far GrFont_PC6x8_bits[] = { + /* character 0 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + /* character 1 */ + 0x70,0xf8,0xa8,0xf8,0xd8,0x88,0x70,0x00, + /* character 2 */ + 0x70,0xf8,0xa8,0xf8,0x88,0xd8,0x70,0x00, + /* character 3 */ + 0x00,0x50,0xf8,0xf8,0xf8,0x70,0x20,0x00, + /* character 4 */ + 0x00,0x20,0x70,0xf8,0xf8,0x70,0x20,0x00, + /* character 5 */ + 0x70,0x50,0xf8,0xa8,0xf8,0x20,0x70,0x00, + /* character 6 */ + 0x20,0x70,0xf8,0xf8,0xf8,0x20,0x70,0x00, + /* character 7 */ + 0x00,0x00,0x20,0x70,0x70,0x20,0x00,0x00, + /* character 8 */ + 0xf8,0xf8,0xd8,0x88,0x88,0xd8,0xf8,0xf8, + /* character 9 */ + 0x00,0x00,0x20,0x50,0x50,0x20,0x00,0x00, + /* character 10 */ + 0xf8,0xf8,0xd8,0xa8,0xa8,0xd8,0xf8,0xf8, + /* character 11 */ + 0x00,0x38,0x18,0x68,0xa0,0xa0,0x40,0x00, + /* character 12 */ + 0x70,0x88,0x88,0x70,0x20,0xf8,0x20,0x00, + /* character 13 */ + 0x78,0x48,0x78,0x40,0x40,0x40,0xc0,0x00, + /* character 14 */ + 0x78,0x48,0x78,0x48,0x48,0x58,0xc0,0x00, + /* character 15 */ + 0x20,0xa8,0x70,0xd8,0xd8,0x70,0xa8,0x20, + /* character 16 */ + 0x80,0xc0,0xf0,0xf8,0xf0,0xc0,0x80,0x00, + /* character 17 */ + 0x08,0x18,0x78,0xf8,0x78,0x18,0x08,0x00, + /* character 18 */ + 0x20,0x70,0xa8,0x20,0xa8,0x70,0x20,0x00, + /* character 19 */ + 0xd8,0xd8,0xd8,0xd8,0xd8,0x00,0xd8,0x00, + /* character 20 */ + 0x78,0xa8,0xa8,0x68,0x28,0x28,0x28,0x00, + /* character 21 */ + 0x30,0x48,0x50,0x28,0x10,0x48,0x48,0x30, + /* character 22 */ + 0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0x00, + /* character 23 */ + 0x20,0x70,0xa8,0x20,0xa8,0x70,0x20,0xf8, + /* character 24 */ + 0x00,0x20,0x70,0xa8,0x20,0x20,0x20,0x00, + /* character 25 */ + 0x00,0x20,0x20,0x20,0xa8,0x70,0x20,0x00, + /* character 26 */ + 0x00,0x20,0x10,0xf8,0x10,0x20,0x00,0x00, + /* character 27 */ + 0x00,0x20,0x40,0xf8,0x40,0x20,0x00,0x00, + /* character 28 */ + 0x00,0x80,0x80,0x80,0xf8,0x00,0x00,0x00, + /* character 29 */ + 0x00,0x50,0xf8,0xf8,0x50,0x00,0x00,0x00, + /* character 30 */ + 0x00,0x20,0x20,0x70,0xf8,0xf8,0x00,0x00, + /* character 31 */ + 0x00,0xf8,0xf8,0x70,0x20,0x20,0x00,0x00, + /* character 32 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + /* character 33 */ + 0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00, + /* character 34 */ + 0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00, + /* character 35 */ + 0x50,0x50,0xf8,0x50,0xf8,0x50,0x50,0x00, + /* character 36 */ + 0x20,0x78,0xa0,0x70,0x28,0xf0,0x20,0x00, + /* character 37 */ + 0xc0,0xc8,0x10,0x20,0x40,0x98,0x18,0x00, + /* character 38 */ + 0x40,0xa0,0xa0,0x40,0xa8,0x90,0x68,0x00, + /* character 39 */ + 0x30,0x30,0x20,0x40,0x00,0x00,0x00,0x00, + /* character 40 */ + 0x10,0x20,0x40,0x40,0x40,0x20,0x10,0x00, + /* character 41 */ + 0x40,0x20,0x10,0x10,0x10,0x20,0x40,0x00, + /* character 42 */ + 0x20,0xa8,0x70,0xf8,0x70,0xa8,0x20,0x00, + /* character 43 */ + 0x00,0x20,0x20,0xf8,0x20,0x20,0x00,0x00, + /* character 44 */ + 0x00,0x00,0x00,0x00,0x30,0x30,0x20,0x40, + /* character 45 */ + 0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00, + /* character 46 */ + 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00, + /* character 47 */ + 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00, + /* character 48 */ + 0x70,0x88,0x98,0xa8,0xc8,0x88,0x70,0x00, + /* character 49 */ + 0x20,0x60,0x20,0x20,0x20,0x20,0x70,0x00, + /* character 50 */ + 0x70,0x88,0x08,0x70,0x80,0x80,0xf8,0x00, + /* character 51 */ + 0xf8,0x08,0x10,0x30,0x08,0x88,0x70,0x00, + /* character 52 */ + 0x10,0x30,0x50,0x90,0xf8,0x10,0x10,0x00, + /* character 53 */ + 0xf8,0x80,0xf0,0x08,0x08,0x88,0x70,0x00, + /* character 54 */ + 0x38,0x40,0x80,0xf0,0x88,0x88,0x70,0x00, + /* character 55 */ + 0xf8,0x08,0x08,0x10,0x20,0x40,0x80,0x00, + /* character 56 */ + 0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00, + /* character 57 */ + 0x70,0x88,0x88,0x78,0x08,0x10,0xe0,0x00, + /* character 58 */ + 0x00,0x00,0x20,0x00,0x20,0x00,0x00,0x00, + /* character 59 */ + 0x00,0x00,0x20,0x00,0x20,0x20,0x40,0x00, + /* character 60 */ + 0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x00, + /* character 61 */ + 0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00, + /* character 62 */ + 0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00, + /* character 63 */ + 0x70,0x88,0x08,0x30,0x20,0x00,0x20,0x00, + /* character 64 */ + 0x70,0x88,0xa8,0xb8,0xb0,0x80,0x78,0x00, + /* character 65 */ + 0x20,0x50,0x88,0x88,0xf8,0x88,0x88,0x00, + /* character 66 */ + 0xf0,0x88,0x88,0xf0,0x88,0x88,0xf0,0x00, + /* character 67 */ + 0x70,0x88,0x80,0x80,0x80,0x88,0x70,0x00, + /* character 68 */ + 0xf0,0x88,0x88,0x88,0x88,0x88,0xf0,0x00, + /* character 69 */ + 0xf8,0x80,0x80,0xf0,0x80,0x80,0xf8,0x00, + /* character 70 */ + 0xf8,0x80,0x80,0xf0,0x80,0x80,0x80,0x00, + /* character 71 */ + 0x78,0x88,0x80,0x80,0x98,0x88,0x78,0x00, + /* character 72 */ + 0x88,0x88,0x88,0xf8,0x88,0x88,0x88,0x00, + /* character 73 */ + 0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00, + /* character 74 */ + 0x38,0x10,0x10,0x10,0x10,0x90,0x60,0x00, + /* character 75 */ + 0x88,0x90,0xa0,0xc0,0xa0,0x90,0x88,0x00, + /* character 76 */ + 0x80,0x80,0x80,0x80,0x80,0x80,0xf8,0x00, + /* character 77 */ + 0x88,0xd8,0xa8,0xa8,0xa8,0x88,0x88,0x00, + /* character 78 */ + 0x88,0x88,0xc8,0xa8,0x98,0x88,0x88,0x00, + /* character 79 */ + 0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00, + /* character 80 */ + 0xf0,0x88,0x88,0xf0,0x80,0x80,0x80,0x00, + /* character 81 */ + 0x70,0x88,0x88,0x88,0xa8,0x90,0x68,0x00, + /* character 82 */ + 0xf0,0x88,0x88,0xf0,0xa0,0x90,0x88,0x00, + /* character 83 */ + 0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00, + /* character 84 */ + 0xf8,0xa8,0x20,0x20,0x20,0x20,0x20,0x00, + /* character 85 */ + 0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00, + /* character 86 */ + 0x88,0x88,0x88,0x88,0x88,0x50,0x20,0x00, + /* character 87 */ + 0x88,0x88,0x88,0xa8,0xa8,0xa8,0x50,0x00, + /* character 88 */ + 0x88,0x88,0x50,0x20,0x50,0x88,0x88,0x00, + /* character 89 */ + 0x88,0x88,0x50,0x20,0x20,0x20,0x20,0x00, + /* character 90 */ + 0xf8,0x08,0x10,0x70,0x40,0x80,0xf8,0x00, + /* character 91 */ + 0x78,0x40,0x40,0x40,0x40,0x40,0x78,0x00, + /* character 92 */ + 0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00, + /* character 93 */ + 0x78,0x08,0x08,0x08,0x08,0x08,0x78,0x00, + /* character 94 */ + 0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00, + /* character 95 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00, + /* character 96 */ + 0x60,0x60,0x20,0x10,0x00,0x00,0x00,0x00, + /* character 97 */ + 0x00,0x00,0x60,0x10,0x70,0x90,0x78,0x00, + /* character 98 */ + 0x80,0x80,0xb0,0xc8,0x88,0xc8,0xb0,0x00, + /* character 99 */ + 0x00,0x00,0x70,0x88,0x80,0x88,0x70,0x00, + /* character 100 */ + 0x08,0x08,0x68,0x98,0x88,0x98,0x68,0x00, + /* character 101 */ + 0x00,0x00,0x70,0x88,0xf8,0x80,0x70,0x00, + /* character 102 */ + 0x10,0x28,0x20,0x70,0x20,0x20,0x20,0x00, + /* character 103 */ + 0x00,0x00,0x70,0x98,0x98,0x68,0x08,0x70, + /* character 104 */ + 0x80,0x80,0xb0,0xc8,0x88,0x88,0x88,0x00, + /* character 105 */ + 0x20,0x00,0x60,0x20,0x20,0x20,0x70,0x00, + /* character 106 */ + 0x10,0x00,0x10,0x10,0x10,0x90,0x60,0x00, + /* character 107 */ + 0x80,0x80,0x90,0xa0,0xc0,0xa0,0x90,0x00, + /* character 108 */ + 0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00, + /* character 109 */ + 0x00,0x00,0xd0,0xa8,0xa8,0xa8,0xa8,0x00, + /* character 110 */ + 0x00,0x00,0xb0,0xc8,0x88,0x88,0x88,0x00, + /* character 111 */ + 0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00, + /* character 112 */ + 0x00,0x00,0xb0,0xc8,0xc8,0xb0,0x80,0x80, + /* character 113 */ + 0x00,0x00,0x68,0x98,0x98,0x68,0x08,0x08, + /* character 114 */ + 0x00,0x00,0xb0,0xc8,0x80,0x80,0x80,0x00, + /* character 115 */ + 0x00,0x00,0x78,0x80,0x70,0x08,0xf0,0x00, + /* character 116 */ + 0x20,0x20,0xf8,0x20,0x20,0x28,0x10,0x00, + /* character 117 */ + 0x00,0x00,0x88,0x88,0x88,0x98,0x68,0x00, + /* character 118 */ + 0x00,0x00,0x88,0x88,0x88,0x50,0x20,0x00, + /* character 119 */ + 0x00,0x00,0x88,0x88,0xa8,0xa8,0x50,0x00, + /* character 120 */ + 0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00, + /* character 121 */ + 0x00,0x00,0x88,0x88,0x78,0x08,0x88,0x70, + /* character 122 */ + 0x00,0x00,0xf8,0x10,0x20,0x40,0xf8,0x00, + /* character 123 */ + 0x10,0x20,0x20,0x40,0x20,0x20,0x10,0x00, + /* character 124 */ + 0x20,0x20,0x20,0x00,0x20,0x20,0x20,0x00, + /* character 125 */ + 0x40,0x20,0x20,0x10,0x20,0x20,0x40,0x00, + /* character 126 */ + 0x40,0xa8,0x10,0x00,0x00,0x00,0x00,0x00, + /* character 127 */ + 0x20,0x70,0xd8,0x88,0x88,0xf8,0x00,0x00, + /* character 128 */ + 0x70,0x88,0x80,0x80,0x88,0x70,0x10,0x60, + /* character 129 */ + 0x00,0x88,0x00,0x88,0x88,0x98,0x68,0x00, + /* character 130 */ + 0x18,0x00,0x70,0x88,0xf8,0x80,0x78,0x00, + /* character 131 */ + 0xf8,0x00,0x60,0x10,0x70,0x90,0x78,0x00, + /* character 132 */ + 0x88,0x00,0x60,0x10,0x70,0x90,0x78,0x00, + /* character 133 */ + 0xc0,0x00,0x60,0x10,0x70,0x90,0x78,0x00, + /* character 134 */ + 0x30,0x00,0x60,0x10,0x70,0x90,0x78,0x00, + /* character 135 */ + 0x00,0x78,0xc0,0xc0,0x78,0x10,0x30,0x00, + /* character 136 */ + 0xf8,0x00,0x70,0x88,0xf8,0x80,0x78,0x00, + /* character 137 */ + 0x88,0x00,0x70,0x88,0xf8,0x80,0x78,0x00, + /* character 138 */ + 0xc0,0x00,0x70,0x88,0xf8,0x80,0x78,0x00, + /* character 139 */ + 0x28,0x00,0x30,0x10,0x10,0x10,0x38,0x00, + /* character 140 */ + 0x30,0x48,0x30,0x10,0x10,0x10,0x38,0x00, + /* character 141 */ + 0x60,0x00,0x30,0x10,0x10,0x10,0x38,0x00, + /* character 142 */ + 0x50,0x00,0x20,0x50,0x88,0xf8,0x88,0x88, + /* character 143 */ + 0x20,0x00,0x20,0x50,0x88,0xf8,0x88,0x88, + /* character 144 */ + 0x30,0x00,0xf0,0x80,0xe0,0x80,0xf0,0x00, + /* character 145 */ + 0x00,0x00,0x7c,0x10,0x78,0x90,0x7c,0x00, + /* character 146 */ + 0x3c,0x50,0x90,0xf8,0x90,0x90,0x9c,0x00, + /* character 147 */ + 0x70,0x88,0x00,0x70,0x88,0x88,0x70,0x00, + /* character 148 */ + 0x00,0x88,0x00,0x70,0x88,0x88,0x70,0x00, + /* character 149 */ + 0x00,0xc0,0x00,0x70,0x88,0x88,0x70,0x00, + /* character 150 */ + 0x70,0x88,0x00,0x88,0x88,0x98,0x68,0x00, + /* character 151 */ + 0x00,0xc0,0x00,0x88,0x88,0x98,0x68,0x00, + /* character 152 */ + 0x48,0x00,0x48,0x48,0x48,0x38,0x08,0x70, + /* character 153 */ + 0x88,0x00,0x70,0x88,0x88,0x88,0x70,0x00, + /* character 154 */ + 0x88,0x00,0x88,0x88,0x88,0x88,0x70,0x00, + /* character 155 */ + 0x20,0x20,0xf8,0xa0,0xa0,0xf8,0x20,0x20, + /* character 156 */ + 0x30,0x58,0x48,0xe0,0x40,0x48,0xf8,0x00, + /* character 157 */ + 0xd8,0xd8,0x70,0xf8,0x20,0xf8,0x20,0x20, + /* character 158 */ + 0xe0,0x90,0x90,0xe0,0x90,0xb8,0x90,0x90, + /* character 159 */ + 0x18,0x28,0x20,0x70,0x20,0x20,0xa0,0xc0, + /* character 160 */ + 0x18,0x00,0x60,0x10,0x70,0x90,0x78,0x00, + /* character 161 */ + 0x18,0x00,0x30,0x10,0x10,0x10,0x38,0x00, + /* character 162 */ + 0x00,0x18,0x00,0x70,0x88,0x88,0x70,0x00, + /* character 163 */ + 0x00,0x18,0x00,0x88,0x88,0x98,0x68,0x00, + /* character 164 */ + 0x00,0x78,0x00,0x70,0x48,0x48,0x48,0x00, + /* character 165 */ + 0xf8,0x00,0xc8,0xe8,0xb8,0x98,0x88,0x00, + /* character 166 */ + 0x70,0x90,0x90,0x78,0x00,0xf8,0x00,0x00, + /* character 167 */ + 0x70,0x88,0x88,0x70,0x00,0xf8,0x00,0x00, + /* character 168 */ + 0x20,0x00,0x20,0x60,0x80,0x88,0x70,0x00, + /* character 169 */ + 0x00,0x00,0x00,0xf8,0x80,0x80,0x00,0x00, + /* character 170 */ + 0x00,0x00,0x00,0xf8,0x08,0x08,0x00,0x00, + /* character 171 */ + 0x80,0x88,0x90,0xb8,0x48,0x98,0x20,0x38, + /* character 172 */ + 0x80,0x88,0x90,0xa8,0x58,0xb8,0x08,0x08, + /* character 173 */ + 0x20,0x20,0x00,0x20,0x20,0x20,0x20,0x00, + /* character 174 */ + 0x00,0x28,0x50,0xa0,0x50,0x28,0x00,0x00, + /* character 175 */ + 0x00,0xa0,0x50,0x28,0x50,0xa0,0x00,0x00, + /* character 176 */ + 0x20,0x88,0x20,0x88,0x20,0x88,0x20,0x88, + /* character 177 */ + 0x54,0xa8,0x54,0xa8,0x54,0xa8,0x54,0xa8, + /* character 178 */ + 0xa8,0x54,0xa8,0x54,0xa8,0x54,0xa8,0x54, + /* character 179 */ + 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, + /* character 180 */ + 0x10,0x10,0x10,0x10,0xf0,0x10,0x10,0x10, + /* character 181 */ + 0x10,0x10,0xf0,0x10,0xf0,0x10,0x10,0x10, + /* character 182 */ + 0x28,0x28,0x28,0x28,0xe8,0x28,0x28,0x28, + /* character 183 */ + 0x00,0x00,0x00,0x00,0xf8,0x28,0x28,0x28, + /* character 184 */ + 0x00,0x00,0xf0,0x10,0xf0,0x10,0x10,0x10, + /* character 185 */ + 0x28,0x28,0xe8,0x08,0xe8,0x28,0x28,0x28, + /* character 186 */ + 0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28, + /* character 187 */ + 0x00,0x00,0xf8,0x08,0xe8,0x28,0x28,0x28, + /* character 188 */ + 0x28,0x28,0xe8,0x08,0xf8,0x00,0x00,0x00, + /* character 189 */ + 0x28,0x28,0x28,0x28,0xf8,0x00,0x00,0x00, + /* character 190 */ + 0x10,0x10,0xf0,0x10,0xf0,0x00,0x00,0x00, + /* character 191 */ + 0x00,0x00,0x00,0x00,0xf0,0x10,0x10,0x10, + /* character 192 */ + 0x10,0x10,0x10,0x10,0x1c,0x00,0x00,0x00, + /* character 193 */ + 0x10,0x10,0x10,0x10,0xfc,0x00,0x00,0x00, + /* character 194 */ + 0x00,0x00,0x00,0x00,0xfc,0x10,0x10,0x10, + /* character 195 */ + 0x10,0x10,0x10,0x10,0x1c,0x10,0x10,0x10, + /* character 196 */ + 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00, + /* character 197 */ + 0x10,0x10,0x10,0x10,0xfc,0x10,0x10,0x10, + /* character 198 */ + 0x10,0x10,0x1c,0x10,0x1c,0x10,0x10,0x10, + /* character 199 */ + 0x28,0x28,0x28,0x28,0x2c,0x28,0x28,0x28, + /* character 200 */ + 0x28,0x28,0x2c,0x20,0x3c,0x00,0x00,0x00, + /* character 201 */ + 0x00,0x00,0x3c,0x20,0x2c,0x28,0x28,0x28, + /* character 202 */ + 0x28,0x28,0xec,0x00,0xfc,0x00,0x00,0x00, + /* character 203 */ + 0x00,0x00,0xfc,0x00,0xec,0x28,0x28,0x28, + /* character 204 */ + 0x28,0x28,0x2c,0x20,0x2c,0x28,0x28,0x28, + /* character 205 */ + 0x00,0x00,0xfc,0x00,0xfc,0x00,0x00,0x00, + /* character 206 */ + 0x28,0x28,0xec,0x00,0xec,0x28,0x28,0x28, + /* character 207 */ + 0x10,0x10,0xfc,0x00,0xfc,0x00,0x00,0x00, + /* character 208 */ + 0x28,0x28,0x28,0x28,0xfc,0x00,0x00,0x00, + /* character 209 */ + 0x00,0x00,0xfc,0x00,0xfc,0x10,0x10,0x10, + /* character 210 */ + 0x00,0x00,0x00,0x00,0xfc,0x28,0x28,0x28, + /* character 211 */ + 0x28,0x28,0x28,0x28,0x3c,0x00,0x00,0x00, + /* character 212 */ + 0x10,0x10,0x1c,0x10,0x1c,0x00,0x00,0x00, + /* character 213 */ + 0x00,0x00,0x1c,0x10,0x1c,0x10,0x10,0x10, + /* character 214 */ + 0x00,0x00,0x00,0x00,0x3c,0x28,0x28,0x28, + /* character 215 */ + 0x28,0x28,0x28,0x28,0xfc,0x28,0x28,0x28, + /* character 216 */ + 0x10,0x10,0xfc,0x10,0xfc,0x10,0x10,0x10, + /* character 217 */ + 0x10,0x10,0x10,0x10,0xf0,0x00,0x00,0x00, + /* character 218 */ + 0x00,0x00,0x00,0x00,0x1c,0x10,0x10,0x10, + /* character 219 */ + 0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc, + /* character 220 */ + 0x00,0x00,0x00,0x00,0xfc,0xfc,0xfc,0xfc, + /* character 221 */ + 0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, + /* character 222 */ + 0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, + /* character 223 */ + 0xfc,0xfc,0xfc,0xfc,0x00,0x00,0x00,0x00, + /* character 224 */ + 0x00,0x00,0x68,0x90,0x90,0x90,0x68,0x00, + /* character 225 */ + 0x00,0x70,0x98,0xf0,0x98,0xf0,0x80,0x00, + /* character 226 */ + 0x00,0xf8,0x98,0x80,0x80,0x80,0x80,0x00, + /* character 227 */ + 0x00,0xf8,0x50,0x50,0x50,0x50,0x50,0x00, + /* character 228 */ + 0xf8,0x88,0x40,0x20,0x40,0x88,0xf8,0x00, + /* character 229 */ + 0x00,0x00,0x78,0x90,0x90,0x90,0x60,0x00, + /* character 230 */ + 0x00,0x50,0x50,0x50,0x50,0x68,0xc0,0x00, + /* character 231 */ + 0x00,0xf8,0xa0,0x20,0x20,0x20,0x20,0x00, + /* character 232 */ + 0xf8,0x20,0x70,0x88,0x88,0x70,0x20,0xf8, + /* character 233 */ + 0x20,0x50,0x88,0xf8,0x88,0x50,0x20,0x00, + /* character 234 */ + 0x20,0x50,0x88,0x88,0x50,0x50,0xd8,0x00, + /* character 235 */ + 0x30,0x40,0x30,0x70,0x88,0x88,0x70,0x00, + /* character 236 */ + 0x00,0x00,0x00,0x70,0xa8,0xa8,0x70,0x00, + /* character 237 */ + 0x08,0x70,0x98,0xa8,0xa8,0xc8,0x70,0x80, + /* character 238 */ + 0x70,0x80,0x80,0xf0,0x80,0x80,0x70,0x00, + /* character 239 */ + 0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x00, + /* character 240 */ + 0x00,0xf8,0x00,0xf8,0x00,0xf8,0x00,0x00, + /* character 241 */ + 0x20,0x20,0xf8,0x20,0x20,0x00,0xf8,0x00, + /* character 242 */ + 0x40,0x20,0x10,0x20,0x40,0x00,0xf8,0x00, + /* character 243 */ + 0x10,0x20,0x40,0x20,0x10,0x00,0xf8,0x00, + /* character 244 */ + 0x38,0x28,0x20,0x20,0x20,0x20,0x20,0x20, + /* character 245 */ + 0x20,0x20,0x20,0x20,0x20,0xa0,0xa0,0xe0, + /* character 246 */ + 0x30,0x30,0x00,0xfc,0x00,0x30,0x30,0x00, + /* character 247 */ + 0x00,0xe8,0xb8,0x00,0xe8,0xb8,0x00,0x00, + /* character 248 */ + 0x70,0xd8,0xd8,0x70,0x00,0x00,0x00,0x00, + /* character 249 */ + 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, + /* character 250 */ + 0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00, + /* character 251 */ + 0x38,0x20,0x20,0x20,0xa0,0xa0,0x60,0x20, + /* character 252 */ + 0x70,0x48,0x48,0x48,0x48,0x00,0x00,0x00, + /* character 253 */ + 0x70,0x18,0x30,0x60,0x78,0x00,0x00,0x00, + /* character 254 */ + 0x00,0x00,0x78,0x78,0x78,0x78,0x00,0x00, + /* character 255 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +}; + +struct { + GrFont theFont; + GrFontChrInfo rest[255]; +} GrFont_PC6x8 = { + { + { /* font header */ + "pc6x8", /* font name */ + "pc", /* font family name */ + 0, /* characters have varying width */ + 0, /* derived from a scalable font */ + 1, /* font permanently linked into program */ + GR_FONTCVT_NONE, /* 'tweaked' font (resized, etc..) */ + 6, /* width (average when proportional) */ + 8, /* font height */ + 6, /* baseline pixel pos (from top) */ + 7, /* underline pixel pos (from top) */ + 1, /* underline width */ + 0, /* lowest character code in font */ + 256 /* number of characters in font */ + }, + (char *)GrFont_PC6x8_bits, /* character bitmap array */ + 0, /* auxiliary bitmap */ + 6, /* width of narrowest character */ + 6, /* width of widest character */ + 0, /* allocated size of auxiliary bitmap */ + 0, /* free space in auxiliary bitmap */ + { 0 }, /* converted character bitmap offsets */ + {{ 6, 0 }} /* first character info */ + }, + { + { 6, 8 }, /* info for character 1 */ + { 6, 16 }, /* info for character 2 */ + { 6, 24 }, /* info for character 3 */ + { 6, 32 }, /* info for character 4 */ + { 6, 40 }, /* info for character 5 */ + { 6, 48 }, /* info for character 6 */ + { 6, 56 }, /* info for character 7 */ + { 6, 64 }, /* info for character 8 */ + { 6, 72 }, /* info for character 9 */ + { 6, 80 }, /* info for character 10 */ + { 6, 88 }, /* info for character 11 */ + { 6, 96 }, /* info for character 12 */ + { 6, 104 }, /* info for character 13 */ + { 6, 112 }, /* info for character 14 */ + { 6, 120 }, /* info for character 15 */ + { 6, 128 }, /* info for character 16 */ + { 6, 136 }, /* info for character 17 */ + { 6, 144 }, /* info for character 18 */ + { 6, 152 }, /* info for character 19 */ + { 6, 160 }, /* info for character 20 */ + { 6, 168 }, /* info for character 21 */ + { 6, 176 }, /* info for character 22 */ + { 6, 184 }, /* info for character 23 */ + { 6, 192 }, /* info for character 24 */ + { 6, 200 }, /* info for character 25 */ + { 6, 208 }, /* info for character 26 */ + { 6, 216 }, /* info for character 27 */ + { 6, 224 }, /* info for character 28 */ + { 6, 232 }, /* info for character 29 */ + { 6, 240 }, /* info for character 30 */ + { 6, 248 }, /* info for character 31 */ + { 6, 256 }, /* info for character 32 */ + { 6, 264 }, /* info for character 33 */ + { 6, 272 }, /* info for character 34 */ + { 6, 280 }, /* info for character 35 */ + { 6, 288 }, /* info for character 36 */ + { 6, 296 }, /* info for character 37 */ + { 6, 304 }, /* info for character 38 */ + { 6, 312 }, /* info for character 39 */ + { 6, 320 }, /* info for character 40 */ + { 6, 328 }, /* info for character 41 */ + { 6, 336 }, /* info for character 42 */ + { 6, 344 }, /* info for character 43 */ + { 6, 352 }, /* info for character 44 */ + { 6, 360 }, /* info for character 45 */ + { 6, 368 }, /* info for character 46 */ + { 6, 376 }, /* info for character 47 */ + { 6, 384 }, /* info for character 48 */ + { 6, 392 }, /* info for character 49 */ + { 6, 400 }, /* info for character 50 */ + { 6, 408 }, /* info for character 51 */ + { 6, 416 }, /* info for character 52 */ + { 6, 424 }, /* info for character 53 */ + { 6, 432 }, /* info for character 54 */ + { 6, 440 }, /* info for character 55 */ + { 6, 448 }, /* info for character 56 */ + { 6, 456 }, /* info for character 57 */ + { 6, 464 }, /* info for character 58 */ + { 6, 472 }, /* info for character 59 */ + { 6, 480 }, /* info for character 60 */ + { 6, 488 }, /* info for character 61 */ + { 6, 496 }, /* info for character 62 */ + { 6, 504 }, /* info for character 63 */ + { 6, 512 }, /* info for character 64 */ + { 6, 520 }, /* info for character 65 */ + { 6, 528 }, /* info for character 66 */ + { 6, 536 }, /* info for character 67 */ + { 6, 544 }, /* info for character 68 */ + { 6, 552 }, /* info for character 69 */ + { 6, 560 }, /* info for character 70 */ + { 6, 568 }, /* info for character 71 */ + { 6, 576 }, /* info for character 72 */ + { 6, 584 }, /* info for character 73 */ + { 6, 592 }, /* info for character 74 */ + { 6, 600 }, /* info for character 75 */ + { 6, 608 }, /* info for character 76 */ + { 6, 616 }, /* info for character 77 */ + { 6, 624 }, /* info for character 78 */ + { 6, 632 }, /* info for character 79 */ + { 6, 640 }, /* info for character 80 */ + { 6, 648 }, /* info for character 81 */ + { 6, 656 }, /* info for character 82 */ + { 6, 664 }, /* info for character 83 */ + { 6, 672 }, /* info for character 84 */ + { 6, 680 }, /* info for character 85 */ + { 6, 688 }, /* info for character 86 */ + { 6, 696 }, /* info for character 87 */ + { 6, 704 }, /* info for character 88 */ + { 6, 712 }, /* info for character 89 */ + { 6, 720 }, /* info for character 90 */ + { 6, 728 }, /* info for character 91 */ + { 6, 736 }, /* info for character 92 */ + { 6, 744 }, /* info for character 93 */ + { 6, 752 }, /* info for character 94 */ + { 6, 760 }, /* info for character 95 */ + { 6, 768 }, /* info for character 96 */ + { 6, 776 }, /* info for character 97 */ + { 6, 784 }, /* info for character 98 */ + { 6, 792 }, /* info for character 99 */ + { 6, 800 }, /* info for character 100 */ + { 6, 808 }, /* info for character 101 */ + { 6, 816 }, /* info for character 102 */ + { 6, 824 }, /* info for character 103 */ + { 6, 832 }, /* info for character 104 */ + { 6, 840 }, /* info for character 105 */ + { 6, 848 }, /* info for character 106 */ + { 6, 856 }, /* info for character 107 */ + { 6, 864 }, /* info for character 108 */ + { 6, 872 }, /* info for character 109 */ + { 6, 880 }, /* info for character 110 */ + { 6, 888 }, /* info for character 111 */ + { 6, 896 }, /* info for character 112 */ + { 6, 904 }, /* info for character 113 */ + { 6, 912 }, /* info for character 114 */ + { 6, 920 }, /* info for character 115 */ + { 6, 928 }, /* info for character 116 */ + { 6, 936 }, /* info for character 117 */ + { 6, 944 }, /* info for character 118 */ + { 6, 952 }, /* info for character 119 */ + { 6, 960 }, /* info for character 120 */ + { 6, 968 }, /* info for character 121 */ + { 6, 976 }, /* info for character 122 */ + { 6, 984 }, /* info for character 123 */ + { 6, 992 }, /* info for character 124 */ + { 6, 1000 }, /* info for character 125 */ + { 6, 1008 }, /* info for character 126 */ + { 6, 1016 }, /* info for character 127 */ + { 6, 1024 }, /* info for character 128 */ + { 6, 1032 }, /* info for character 129 */ + { 6, 1040 }, /* info for character 130 */ + { 6, 1048 }, /* info for character 131 */ + { 6, 1056 }, /* info for character 132 */ + { 6, 1064 }, /* info for character 133 */ + { 6, 1072 }, /* info for character 134 */ + { 6, 1080 }, /* info for character 135 */ + { 6, 1088 }, /* info for character 136 */ + { 6, 1096 }, /* info for character 137 */ + { 6, 1104 }, /* info for character 138 */ + { 6, 1112 }, /* info for character 139 */ + { 6, 1120 }, /* info for character 140 */ + { 6, 1128 }, /* info for character 141 */ + { 6, 1136 }, /* info for character 142 */ + { 6, 1144 }, /* info for character 143 */ + { 6, 1152 }, /* info for character 144 */ + { 6, 1160 }, /* info for character 145 */ + { 6, 1168 }, /* info for character 146 */ + { 6, 1176 }, /* info for character 147 */ + { 6, 1184 }, /* info for character 148 */ + { 6, 1192 }, /* info for character 149 */ + { 6, 1200 }, /* info for character 150 */ + { 6, 1208 }, /* info for character 151 */ + { 6, 1216 }, /* info for character 152 */ + { 6, 1224 }, /* info for character 153 */ + { 6, 1232 }, /* info for character 154 */ + { 6, 1240 }, /* info for character 155 */ + { 6, 1248 }, /* info for character 156 */ + { 6, 1256 }, /* info for character 157 */ + { 6, 1264 }, /* info for character 158 */ + { 6, 1272 }, /* info for character 159 */ + { 6, 1280 }, /* info for character 160 */ + { 6, 1288 }, /* info for character 161 */ + { 6, 1296 }, /* info for character 162 */ + { 6, 1304 }, /* info for character 163 */ + { 6, 1312 }, /* info for character 164 */ + { 6, 1320 }, /* info for character 165 */ + { 6, 1328 }, /* info for character 166 */ + { 6, 1336 }, /* info for character 167 */ + { 6, 1344 }, /* info for character 168 */ + { 6, 1352 }, /* info for character 169 */ + { 6, 1360 }, /* info for character 170 */ + { 6, 1368 }, /* info for character 171 */ + { 6, 1376 }, /* info for character 172 */ + { 6, 1384 }, /* info for character 173 */ + { 6, 1392 }, /* info for character 174 */ + { 6, 1400 }, /* info for character 175 */ + { 6, 1408 }, /* info for character 176 */ + { 6, 1416 }, /* info for character 177 */ + { 6, 1424 }, /* info for character 178 */ + { 6, 1432 }, /* info for character 179 */ + { 6, 1440 }, /* info for character 180 */ + { 6, 1448 }, /* info for character 181 */ + { 6, 1456 }, /* info for character 182 */ + { 6, 1464 }, /* info for character 183 */ + { 6, 1472 }, /* info for character 184 */ + { 6, 1480 }, /* info for character 185 */ + { 6, 1488 }, /* info for character 186 */ + { 6, 1496 }, /* info for character 187 */ + { 6, 1504 }, /* info for character 188 */ + { 6, 1512 }, /* info for character 189 */ + { 6, 1520 }, /* info for character 190 */ + { 6, 1528 }, /* info for character 191 */ + { 6, 1536 }, /* info for character 192 */ + { 6, 1544 }, /* info for character 193 */ + { 6, 1552 }, /* info for character 194 */ + { 6, 1560 }, /* info for character 195 */ + { 6, 1568 }, /* info for character 196 */ + { 6, 1576 }, /* info for character 197 */ + { 6, 1584 }, /* info for character 198 */ + { 6, 1592 }, /* info for character 199 */ + { 6, 1600 }, /* info for character 200 */ + { 6, 1608 }, /* info for character 201 */ + { 6, 1616 }, /* info for character 202 */ + { 6, 1624 }, /* info for character 203 */ + { 6, 1632 }, /* info for character 204 */ + { 6, 1640 }, /* info for character 205 */ + { 6, 1648 }, /* info for character 206 */ + { 6, 1656 }, /* info for character 207 */ + { 6, 1664 }, /* info for character 208 */ + { 6, 1672 }, /* info for character 209 */ + { 6, 1680 }, /* info for character 210 */ + { 6, 1688 }, /* info for character 211 */ + { 6, 1696 }, /* info for character 212 */ + { 6, 1704 }, /* info for character 213 */ + { 6, 1712 }, /* info for character 214 */ + { 6, 1720 }, /* info for character 215 */ + { 6, 1728 }, /* info for character 216 */ + { 6, 1736 }, /* info for character 217 */ + { 6, 1744 }, /* info for character 218 */ + { 6, 1752 }, /* info for character 219 */ + { 6, 1760 }, /* info for character 220 */ + { 6, 1768 }, /* info for character 221 */ + { 6, 1776 }, /* info for character 222 */ + { 6, 1784 }, /* info for character 223 */ + { 6, 1792 }, /* info for character 224 */ + { 6, 1800 }, /* info for character 225 */ + { 6, 1808 }, /* info for character 226 */ + { 6, 1816 }, /* info for character 227 */ + { 6, 1824 }, /* info for character 228 */ + { 6, 1832 }, /* info for character 229 */ + { 6, 1840 }, /* info for character 230 */ + { 6, 1848 }, /* info for character 231 */ + { 6, 1856 }, /* info for character 232 */ + { 6, 1864 }, /* info for character 233 */ + { 6, 1872 }, /* info for character 234 */ + { 6, 1880 }, /* info for character 235 */ + { 6, 1888 }, /* info for character 236 */ + { 6, 1896 }, /* info for character 237 */ + { 6, 1904 }, /* info for character 238 */ + { 6, 1912 }, /* info for character 239 */ + { 6, 1920 }, /* info for character 240 */ + { 6, 1928 }, /* info for character 241 */ + { 6, 1936 }, /* info for character 242 */ + { 6, 1944 }, /* info for character 243 */ + { 6, 1952 }, /* info for character 244 */ + { 6, 1960 }, /* info for character 245 */ + { 6, 1968 }, /* info for character 246 */ + { 6, 1976 }, /* info for character 247 */ + { 6, 1984 }, /* info for character 248 */ + { 6, 1992 }, /* info for character 249 */ + { 6, 2000 }, /* info for character 250 */ + { 6, 2008 }, /* info for character 251 */ + { 6, 2016 }, /* info for character 252 */ + { 6, 2024 }, /* info for character 253 */ + { 6, 2032 }, /* info for character 254 */ + { 6, 2040 } /* info for character 255 */ + } +}; + diff --git a/thirdparty/grx249/src/fonts/pc8x14.c b/thirdparty/grx249/src/fonts/pc8x14.c new file mode 100644 index 0000000..91fa737 --- /dev/null +++ b/thirdparty/grx249/src/fonts/pc8x14.c @@ -0,0 +1,1067 @@ +/** + ** pc8x14.c ---- GRX 2.0 font converted to C by 'GrDumpFont()' + **/ + +#define GrFont_PC8x14 FONTNAME_TEMPORARY_REDIRECTION +#include "grx20.h" +#undef GrFont_PC8x14 + +static unsigned char far GrFont_PC8x14_bits[] = { + /* character 0 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 1 */ + 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x7e,0x00, + 0x00,0x00, + /* character 2 */ + 0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0x7e,0x00, + 0x00,0x00, + /* character 3 */ + 0x00,0x00,0x00,0x36,0x7f,0x7f,0x7f,0x7f,0x3e,0x1c,0x08,0x00, + 0x00,0x00, + /* character 4 */ + 0x00,0x00,0x00,0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x08,0x00,0x00, + 0x00,0x00, + /* character 5 */ + 0x00,0x00,0x18,0x3c,0x3c,0xe7,0xe7,0xe7,0x18,0x18,0x3c,0x00, + 0x00,0x00, + /* character 6 */ + 0x00,0x00,0x18,0x3c,0x7e,0xff,0xff,0x7e,0x18,0x18,0x3c,0x00, + 0x00,0x00, + /* character 7 */ + 0x00,0x00,0x00,0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,0x00, + 0x00,0x00, + /* character 8 */ + 0xff,0xff,0xff,0xff,0xff,0xe7,0xc3,0xc3,0xe7,0xff,0xff,0xff, + 0xff,0xff, + /* character 9 */ + 0x00,0x00,0x00,0x00,0x3c,0x66,0x42,0x42,0x66,0x3c,0x00,0x00, + 0x00,0x00, + /* character 10 */ + 0xff,0xff,0xff,0xff,0xc3,0x99,0xbd,0xbd,0x99,0xc3,0xff,0xff, + 0xff,0xff, + /* character 11 */ + 0x00,0x00,0x0f,0x07,0x0d,0x19,0x3c,0x66,0x66,0x66,0x3c,0x00, + 0x00,0x00, + /* character 12 */ + 0x00,0x00,0x3c,0x66,0x66,0x66,0x3c,0x18,0x7e,0x18,0x18,0x00, + 0x00,0x00, + /* character 13 */ + 0x00,0x00,0x3f,0x33,0x3f,0x30,0x30,0x30,0x70,0xf0,0xe0,0x00, + 0x00,0x00, + /* character 14 */ + 0x00,0x00,0x7f,0x63,0x7f,0x63,0x63,0x63,0x67,0xe7,0xe6,0xc0, + 0x00,0x00, + /* character 15 */ + 0x00,0x00,0x18,0x18,0xdb,0x3c,0xe7,0x3c,0xdb,0x18,0x18,0x00, + 0x00,0x00, + /* character 16 */ + 0x00,0x00,0x40,0x60,0x70,0x7c,0x7f,0x7c,0x70,0x60,0x40,0x00, + 0x00,0x00, + /* character 17 */ + 0x00,0x00,0x01,0x03,0x07,0x1f,0x7f,0x1f,0x07,0x03,0x01,0x00, + 0x00,0x00, + /* character 18 */ + 0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00, + 0x00,0x00, + /* character 19 */ + 0x00,0x00,0x33,0x33,0x33,0x33,0x33,0x33,0x00,0x33,0x33,0x00, + 0x00,0x00, + /* character 20 */ + 0x00,0x00,0x7f,0xdb,0xdb,0xdb,0x7b,0x1b,0x1b,0x1b,0x1b,0x00, + 0x00,0x00, + /* character 21 */ + 0x00,0x3e,0x63,0x30,0x1c,0x36,0x63,0x63,0x36,0x1c,0x06,0x63, + 0x3e,0x00, + /* character 22 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x7f,0x00, + 0x00,0x00, + /* character 23 */ + 0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x7e,0x3c,0x18,0x7e, + 0x00,0x00, + /* character 24 */ + 0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x00, + 0x00,0x00, + /* character 25 */ + 0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00, + 0x00,0x00, + /* character 26 */ + 0x00,0x00,0x00,0x00,0x0c,0x06,0x7f,0x06,0x0c,0x00,0x00,0x00, + 0x00,0x00, + /* character 27 */ + 0x00,0x00,0x00,0x00,0x18,0x30,0x7f,0x30,0x18,0x00,0x00,0x00, + 0x00,0x00, + /* character 28 */ + 0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x7f,0x00,0x00,0x00, + 0x00,0x00, + /* character 29 */ + 0x00,0x00,0x00,0x00,0x24,0x66,0xff,0x66,0x24,0x00,0x00,0x00, + 0x00,0x00, + /* character 30 */ + 0x00,0x00,0x00,0x08,0x1c,0x1c,0x3e,0x3e,0x7f,0x7f,0x00,0x00, + 0x00,0x00, + /* character 31 */ + 0x00,0x00,0x00,0x7f,0x7f,0x3e,0x3e,0x1c,0x1c,0x08,0x00,0x00, + 0x00,0x00, + /* character 32 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 33 */ + 0x00,0x00,0x18,0x3c,0x3c,0x3c,0x18,0x18,0x00,0x18,0x18,0x00, + 0x00,0x00, + /* character 34 */ + 0x00,0x63,0x63,0x63,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 35 */ + 0x00,0x00,0x36,0x36,0x7f,0x36,0x36,0x36,0x7f,0x36,0x36,0x00, + 0x00,0x00, + /* character 36 */ + 0x0c,0x0c,0x3e,0x63,0x61,0x60,0x3e,0x03,0x43,0x63,0x3e,0x0c, + 0x0c,0x00, + /* character 37 */ + 0x00,0x00,0x00,0x00,0x61,0x63,0x06,0x0c,0x18,0x33,0x63,0x00, + 0x00,0x00, + /* character 38 */ + 0x00,0x00,0x1c,0x36,0x36,0x1c,0x3b,0x6e,0x66,0x66,0x3b,0x00, + 0x00,0x00, + /* character 39 */ + 0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 40 */ + 0x00,0x00,0x0c,0x18,0x30,0x30,0x30,0x30,0x30,0x18,0x0c,0x00, + 0x00,0x00, + /* character 41 */ + 0x00,0x00,0x18,0x0c,0x06,0x06,0x06,0x06,0x06,0x0c,0x18,0x00, + 0x00,0x00, + /* character 42 */ + 0x00,0x00,0x00,0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00,0x00, + 0x00,0x00, + /* character 43 */ + 0x00,0x00,0x00,0x18,0x18,0x18,0xff,0x18,0x18,0x18,0x00,0x00, + 0x00,0x00, + /* character 44 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x30, + 0x00,0x00, + /* character 45 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 46 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00, + 0x00,0x00, + /* character 47 */ + 0x00,0x00,0x01,0x03,0x06,0x0c,0x18,0x30,0x60,0x40,0x00,0x00, + 0x00,0x00, + /* character 48 */ + 0x00,0x00,0x3e,0x63,0x67,0x6f,0x7b,0x73,0x63,0x63,0x3e,0x00, + 0x00,0x00, + /* character 49 */ + 0x00,0x00,0x0c,0x1c,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3f,0x00, + 0x00,0x00, + /* character 50 */ + 0x00,0x00,0x3e,0x63,0x03,0x06,0x0c,0x18,0x30,0x63,0x7f,0x00, + 0x00,0x00, + /* character 51 */ + 0x00,0x00,0x3e,0x63,0x03,0x03,0x1e,0x03,0x03,0x63,0x3e,0x00, + 0x00,0x00, + /* character 52 */ + 0x00,0x00,0x06,0x0e,0x1e,0x36,0x66,0x7f,0x06,0x06,0x0f,0x00, + 0x00,0x00, + /* character 53 */ + 0x00,0x00,0x7f,0x60,0x60,0x60,0x7e,0x03,0x03,0x63,0x3e,0x00, + 0x00,0x00, + /* character 54 */ + 0x00,0x00,0x1c,0x30,0x60,0x60,0x7e,0x63,0x63,0x63,0x3e,0x00, + 0x00,0x00, + /* character 55 */ + 0x00,0x00,0x7f,0x63,0x03,0x06,0x0c,0x18,0x18,0x18,0x18,0x00, + 0x00,0x00, + /* character 56 */ + 0x00,0x00,0x3e,0x63,0x63,0x63,0x3e,0x63,0x63,0x63,0x3e,0x00, + 0x00,0x00, + /* character 57 */ + 0x00,0x00,0x3e,0x63,0x63,0x63,0x3f,0x03,0x03,0x06,0x3c,0x00, + 0x00,0x00, + /* character 58 */ + 0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00,0x00, + 0x00,0x00, + /* character 59 */ + 0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x30,0x00, + 0x00,0x00, + /* character 60 */ + 0x00,0x00,0x06,0x0c,0x18,0x30,0x60,0x30,0x18,0x0c,0x06,0x00, + 0x00,0x00, + /* character 61 */ + 0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x7e,0x00,0x00,0x00, + 0x00,0x00, + /* character 62 */ + 0x00,0x00,0x60,0x30,0x18,0x0c,0x06,0x0c,0x18,0x30,0x60,0x00, + 0x00,0x00, + /* character 63 */ + 0x00,0x00,0x3e,0x63,0x63,0x06,0x0c,0x0c,0x00,0x0c,0x0c,0x00, + 0x00,0x00, + /* character 64 */ + 0x00,0x00,0x3e,0x63,0x63,0x6f,0x6f,0x6f,0x6e,0x60,0x3e,0x00, + 0x00,0x00, + /* character 65 */ + 0x00,0x00,0x08,0x1c,0x36,0x63,0x63,0x7f,0x63,0x63,0x63,0x00, + 0x00,0x00, + /* character 66 */ + 0x00,0x00,0x7e,0x33,0x33,0x33,0x3e,0x33,0x33,0x33,0x7e,0x00, + 0x00,0x00, + /* character 67 */ + 0x00,0x00,0x1e,0x33,0x61,0x60,0x60,0x60,0x61,0x33,0x1e,0x00, + 0x00,0x00, + /* character 68 */ + 0x00,0x00,0x7c,0x36,0x33,0x33,0x33,0x33,0x33,0x36,0x7c,0x00, + 0x00,0x00, + /* character 69 */ + 0x00,0x00,0x7f,0x33,0x31,0x34,0x3c,0x34,0x31,0x33,0x7f,0x00, + 0x00,0x00, + /* character 70 */ + 0x00,0x00,0x7f,0x33,0x31,0x34,0x3c,0x34,0x30,0x30,0x78,0x00, + 0x00,0x00, + /* character 71 */ + 0x00,0x00,0x1e,0x33,0x61,0x60,0x60,0x6f,0x63,0x33,0x1d,0x00, + 0x00,0x00, + /* character 72 */ + 0x00,0x00,0x63,0x63,0x63,0x63,0x7f,0x63,0x63,0x63,0x63,0x00, + 0x00,0x00, + /* character 73 */ + 0x00,0x00,0x3c,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x00, + 0x00,0x00, + /* character 74 */ + 0x00,0x00,0x0f,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3c,0x00, + 0x00,0x00, + /* character 75 */ + 0x00,0x00,0x73,0x33,0x36,0x36,0x3c,0x36,0x36,0x33,0x73,0x00, + 0x00,0x00, + /* character 76 */ + 0x00,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x31,0x33,0x7f,0x00, + 0x00,0x00, + /* character 77 */ + 0x00,0x00,0xc3,0xe7,0xff,0xdb,0xc3,0xc3,0xc3,0xc3,0xc3,0x00, + 0x00,0x00, + /* character 78 */ + 0x00,0x00,0x63,0x73,0x7b,0x7f,0x6f,0x67,0x63,0x63,0x63,0x00, + 0x00,0x00, + /* character 79 */ + 0x00,0x00,0x1c,0x36,0x63,0x63,0x63,0x63,0x63,0x36,0x1c,0x00, + 0x00,0x00, + /* character 80 */ + 0x00,0x00,0x7e,0x33,0x33,0x33,0x3e,0x30,0x30,0x30,0x78,0x00, + 0x00,0x00, + /* character 81 */ + 0x00,0x00,0x3e,0x63,0x63,0x63,0x63,0x6b,0x6f,0x3e,0x06,0x07, + 0x00,0x00, + /* character 82 */ + 0x00,0x00,0x7e,0x33,0x33,0x33,0x3e,0x36,0x33,0x33,0x73,0x00, + 0x00,0x00, + /* character 83 */ + 0x00,0x00,0x3e,0x63,0x63,0x30,0x1c,0x06,0x63,0x63,0x3e,0x00, + 0x00,0x00, + /* character 84 */ + 0x00,0x00,0xff,0xdb,0x99,0x18,0x18,0x18,0x18,0x18,0x3c,0x00, + 0x00,0x00, + /* character 85 */ + 0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x3e,0x00, + 0x00,0x00, + /* character 86 */ + 0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x66,0x3c,0x18,0x00, + 0x00,0x00, + /* character 87 */ + 0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xdb,0xdb,0xff,0x66,0x66,0x00, + 0x00,0x00, + /* character 88 */ + 0x00,0x00,0xc3,0xc3,0x66,0x3c,0x18,0x3c,0x66,0xc3,0xc3,0x00, + 0x00,0x00, + /* character 89 */ + 0x00,0x00,0xc3,0xc3,0xc3,0x66,0x3c,0x18,0x18,0x18,0x3c,0x00, + 0x00,0x00, + /* character 90 */ + 0x00,0x00,0xff,0xc3,0x86,0x0c,0x3c,0x30,0x61,0xc3,0xff,0x00, + 0x00,0x00, + /* character 91 */ + 0x00,0x00,0x3c,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3c,0x00, + 0x00,0x00, + /* character 92 */ + 0x00,0x00,0x40,0x60,0x70,0x38,0x1c,0x0e,0x07,0x03,0x01,0x00, + 0x00,0x00, + /* character 93 */ + 0x00,0x00,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c,0x00, + 0x00,0x00, + /* character 94 */ + 0x08,0x1c,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 95 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0x00, + /* character 96 */ + 0x18,0x18,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 97 */ + 0x00,0x00,0x00,0x00,0x00,0x3c,0x06,0x3e,0x66,0x66,0x3b,0x00, + 0x00,0x00, + /* character 98 */ + 0x00,0x00,0x70,0x30,0x30,0x3c,0x36,0x33,0x33,0x33,0x6e,0x00, + 0x00,0x00, + /* character 99 */ + 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x60,0x60,0x63,0x3e,0x00, + 0x00,0x00, + /* character 100 */ + 0x00,0x00,0x0e,0x06,0x06,0x1e,0x36,0x66,0x66,0x66,0x3b,0x00, + 0x00,0x00, + /* character 101 */ + 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x7f,0x60,0x63,0x3e,0x00, + 0x00,0x00, + /* character 102 */ + 0x00,0x00,0x1c,0x36,0x32,0x30,0x7c,0x30,0x30,0x30,0x78,0x00, + 0x00,0x00, + /* character 103 */ + 0x00,0x00,0x00,0x00,0x00,0x3b,0x66,0x66,0x66,0x3e,0x06,0x66, + 0x3c,0x00, + /* character 104 */ + 0x00,0x00,0x70,0x30,0x30,0x36,0x3b,0x33,0x33,0x33,0x73,0x00, + 0x00,0x00, + /* character 105 */ + 0x00,0x00,0x0c,0x0c,0x00,0x1c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00, + 0x00,0x00, + /* character 106 */ + 0x00,0x00,0x06,0x06,0x00,0x0e,0x06,0x06,0x06,0x06,0x66,0x66, + 0x3c,0x00, + /* character 107 */ + 0x00,0x00,0x70,0x30,0x30,0x33,0x36,0x3c,0x36,0x33,0x73,0x00, + 0x00,0x00, + /* character 108 */ + 0x00,0x00,0x1c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00, + 0x00,0x00, + /* character 109 */ + 0x00,0x00,0x00,0x00,0x00,0xe6,0xff,0xdb,0xdb,0xdb,0xdb,0x00, + 0x00,0x00, + /* character 110 */ + 0x00,0x00,0x00,0x00,0x00,0x6e,0x33,0x33,0x33,0x33,0x33,0x00, + 0x00,0x00, + /* character 111 */ + 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x63,0x63,0x63,0x3e,0x00, + 0x00,0x00, + /* character 112 */ + 0x00,0x00,0x00,0x00,0x00,0x6e,0x33,0x33,0x33,0x3e,0x30,0x30, + 0x78,0x00, + /* character 113 */ + 0x00,0x00,0x00,0x00,0x00,0x3b,0x66,0x66,0x66,0x3e,0x06,0x06, + 0x0f,0x00, + /* character 114 */ + 0x00,0x00,0x00,0x00,0x00,0x6e,0x3b,0x33,0x30,0x30,0x78,0x00, + 0x00,0x00, + /* character 115 */ + 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x38,0x0e,0x63,0x3e,0x00, + 0x00,0x00, + /* character 116 */ + 0x00,0x00,0x08,0x18,0x18,0x7e,0x18,0x18,0x18,0x1b,0x0e,0x00, + 0x00,0x00, + /* character 117 */ + 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x3b,0x00, + 0x00,0x00, + /* character 118 */ + 0x00,0x00,0x00,0x00,0x00,0xc3,0xc3,0xc3,0x66,0x3c,0x18,0x00, + 0x00,0x00, + /* character 119 */ + 0x00,0x00,0x00,0x00,0x00,0xc3,0xc3,0xdb,0xdb,0xff,0x66,0x00, + 0x00,0x00, + /* character 120 */ + 0x00,0x00,0x00,0x00,0x00,0x63,0x36,0x1c,0x1c,0x36,0x63,0x00, + 0x00,0x00, + /* character 121 */ + 0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x63,0x63,0x3f,0x03,0x06, + 0x3c,0x00, + /* character 122 */ + 0x00,0x00,0x00,0x00,0x00,0x7f,0x66,0x0c,0x18,0x33,0x7f,0x00, + 0x00,0x00, + /* character 123 */ + 0x00,0x00,0x0e,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0x0e,0x00, + 0x00,0x00, + /* character 124 */ + 0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00, + 0x00,0x00, + /* character 125 */ + 0x00,0x00,0x70,0x18,0x18,0x18,0x0e,0x18,0x18,0x18,0x70,0x00, + 0x00,0x00, + /* character 126 */ + 0x00,0x00,0x3b,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 127 */ + 0x00,0x00,0x00,0x00,0x08,0x1c,0x36,0x63,0x63,0x7f,0x00,0x00, + 0x00,0x00, + /* character 128 */ + 0x00,0x00,0x3c,0x66,0xc2,0xc0,0xc0,0xc2,0x66,0x3c,0x0c,0x06, + 0x7c,0x00, + /* character 129 */ + 0x00,0x00,0xcc,0xcc,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00, + 0x00,0x00, + /* character 130 */ + 0x00,0x0c,0x18,0x30,0x00,0x7c,0xc6,0xfe,0xc0,0xc6,0x7c,0x00, + 0x00,0x00, + /* character 131 */ + 0x00,0x10,0x38,0x6c,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0x76,0x00, + 0x00,0x00, + /* character 132 */ + 0x00,0x00,0xcc,0xcc,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0x76,0x00, + 0x00,0x00, + /* character 133 */ + 0x00,0x60,0x30,0x18,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0x76,0x00, + 0x00,0x00, + /* character 134 */ + 0x00,0x38,0x6c,0x38,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0x76,0x00, + 0x00,0x00, + /* character 135 */ + 0x00,0x00,0x00,0x00,0x78,0xcc,0xc0,0xcc,0x78,0x18,0x0c,0x78, + 0x00,0x00, + /* character 136 */ + 0x00,0x10,0x38,0x6c,0x00,0x7c,0xc6,0xfe,0xc0,0xc6,0x7c,0x00, + 0x00,0x00, + /* character 137 */ + 0x00,0x00,0xcc,0xcc,0x00,0x7c,0xc6,0xfe,0xc0,0xc6,0x7c,0x00, + 0x00,0x00, + /* character 138 */ + 0x00,0x60,0x30,0x18,0x00,0x7c,0xc6,0xfe,0xc0,0xc6,0x7c,0x00, + 0x00,0x00, + /* character 139 */ + 0x00,0x00,0xcc,0xcc,0x00,0x70,0x30,0x30,0x30,0x30,0x78,0x00, + 0x00,0x00, + /* character 140 */ + 0x00,0x30,0x78,0xcc,0x00,0x70,0x30,0x30,0x30,0x30,0x78,0x00, + 0x00,0x00, + /* character 141 */ + 0x00,0xc0,0x60,0x30,0x00,0x70,0x30,0x30,0x30,0x30,0x78,0x00, + 0x00,0x00, + /* character 142 */ + 0x00,0xc6,0xc6,0x10,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0x00, + 0x00,0x00, + /* character 143 */ + 0x38,0x6c,0x38,0x00,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0x00, + 0x00,0x00, + /* character 144 */ + 0x18,0x30,0x60,0x00,0xfe,0x66,0x60,0x7c,0x60,0x66,0xfe,0x00, + 0x00,0x00, + /* character 145 */ + 0x00,0x00,0x00,0x00,0x6c,0xba,0x12,0x7e,0x90,0x98,0x7e,0x00, + 0x00,0x00, + /* character 146 */ + 0x00,0x00,0x3e,0x6c,0xcc,0xcc,0xfe,0xcc,0xcc,0xcc,0xce,0x00, + 0x00,0x00, + /* character 147 */ + 0x00,0x10,0x38,0x6c,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0x7c,0x00, + 0x00,0x00, + /* character 148 */ + 0x00,0x00,0xc6,0xc6,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0x7c,0x00, + 0x00,0x00, + /* character 149 */ + 0x00,0x60,0x30,0x18,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0x7c,0x00, + 0x00,0x00, + /* character 150 */ + 0x00,0x30,0x78,0xcc,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00, + 0x00,0x00, + /* character 151 */ + 0x00,0x60,0x30,0x18,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00, + 0x00,0x00, + /* character 152 */ + 0x00,0x00,0xc6,0xc6,0x00,0xc6,0xc6,0xc6,0xc6,0x7e,0x06,0x0c, + 0x78,0x00, + /* character 153 */ + 0x00,0xc6,0xc6,0x38,0x6c,0xc6,0xc6,0xc6,0xc6,0x6c,0x38,0x00, + 0x00,0x00, + /* character 154 */ + 0x00,0xc6,0xc6,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x00, + 0x00,0x00, + /* character 155 */ + 0x00,0x08,0x08,0x7e,0xc8,0xc8,0xc8,0xc8,0x7e,0x08,0x08,0x00, + 0x00,0x00, + /* character 156 */ + 0x00,0x38,0x6c,0x64,0x60,0xf0,0x60,0x60,0x60,0xe6,0xfc,0x00, + 0x00,0x00, + /* character 157 */ + 0x00,0x00,0xc6,0x6c,0x38,0x10,0xfe,0x10,0xfe,0x10,0x10,0x00, + 0x00,0x00, + /* character 158 */ + 0x00,0xf8,0xcc,0xcc,0xf8,0xc4,0xcc,0xde,0xcc,0xcc,0xe6,0x00, + 0x00,0x00, + /* character 159 */ + 0x00,0x1c,0x34,0x30,0x30,0x30,0xfc,0x30,0x30,0x30,0x30,0xb0, + 0xe0,0x00, + /* character 160 */ + 0x00,0x18,0x30,0x60,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0x76,0x00, + 0x00,0x00, + /* character 161 */ + 0x00,0x0c,0x18,0x30,0x00,0x38,0x18,0x18,0x18,0x18,0x3c,0x00, + 0x00,0x00, + /* character 162 */ + 0x00,0x18,0x30,0x60,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0x7c,0x00, + 0x00,0x00, + /* character 163 */ + 0x00,0x18,0x30,0x60,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00, + 0x00,0x00, + /* character 164 */ + 0x00,0x00,0x76,0xdc,0x00,0xdc,0x66,0x66,0x66,0x66,0x66,0x00, + 0x00,0x00, + /* character 165 */ + 0x76,0xdc,0x00,0xc6,0xe6,0xf6,0xfe,0xde,0xce,0xc6,0xc6,0x00, + 0x00,0x00, + /* character 166 */ + 0x00,0x3c,0x6c,0x6c,0x3e,0x00,0x7e,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 167 */ + 0x00,0x38,0x6c,0x6c,0x38,0x00,0x7c,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 168 */ + 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60,0xc6,0xc6,0x7c,0x00, + 0x00,0x00, + /* character 169 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x60,0x60,0x60,0x00,0x00, + 0x00,0x00, + /* character 170 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x01,0x01,0x01,0x00,0x00, + 0x00,0x00, + /* character 171 */ + 0x00,0xc0,0xc0,0xc6,0xcc,0xd8,0x30,0x60,0xdc,0x86,0x0c,0x18, + 0x3e,0x00, + /* character 172 */ + 0x00,0xc0,0xc0,0xc6,0xcc,0xd8,0x30,0x66,0xce,0x9a,0x3e,0x06, + 0x06,0x00, + /* character 173 */ + 0x00,0x00,0x18,0x18,0x00,0x18,0x18,0x3c,0x3c,0x3c,0x18,0x00, + 0x00,0x00, + /* character 174 */ + 0x00,0x00,0x00,0x00,0x36,0x6c,0xd8,0x6c,0x36,0x00,0x00,0x00, + 0x00,0x00, + /* character 175 */ + 0x00,0x00,0x00,0x00,0xd8,0x6c,0x36,0x6c,0xd8,0x00,0x00,0x00, + 0x00,0x00, + /* character 176 */ + 0x22,0x88,0x22,0x88,0x22,0x88,0x22,0x88,0x22,0x88,0x22,0x88, + 0x22,0x88, + /* character 177 */ + 0xaa,0x54,0xaa,0x54,0xaa,0x54,0xaa,0x54,0xaa,0x54,0xaa,0x54, + 0xaa,0x54, + /* character 178 */ + 0xba,0xee,0xba,0xee,0xba,0xee,0xba,0xee,0xba,0xee,0xba,0xee, + 0xba,0xee, + /* character 179 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 180 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 181 */ + 0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 182 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xf6,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 183 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 184 */ + 0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0xf8,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 185 */ + 0x36,0x36,0x36,0x36,0x36,0xf6,0x06,0xf6,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 186 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 187 */ + 0x00,0x00,0x00,0x00,0x00,0xfe,0x06,0xf6,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 188 */ + 0x36,0x36,0x36,0x36,0x36,0xf6,0x06,0xfe,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 189 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xfe,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 190 */ + 0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 191 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 192 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 193 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 194 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 195 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 196 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 197 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xff,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 198 */ + 0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 199 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x37,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 200 */ + 0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x3f,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 201 */ + 0x00,0x00,0x00,0x00,0x00,0x3f,0x30,0x37,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 202 */ + 0x36,0x36,0x36,0x36,0x36,0xf7,0x00,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 203 */ + 0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xf7,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 204 */ + 0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x37,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 205 */ + 0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 206 */ + 0x36,0x36,0x36,0x36,0x36,0xf7,0x00,0xf7,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 207 */ + 0x18,0x18,0x18,0x18,0x18,0xff,0x00,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 208 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 209 */ + 0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 210 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 211 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x3f,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 212 */ + 0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 213 */ + 0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x1f,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 214 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 215 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xff,0x36,0x36,0x36,0x36, + 0x36,0x36, + /* character 216 */ + 0x18,0x18,0x18,0x18,0x18,0xff,0x18,0xff,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 217 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 218 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 219 */ + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff, + /* character 220 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff, + /* character 221 */ + 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, + 0xf0,0xf0, + /* character 222 */ + 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, + 0x0f,0x0f, + /* character 223 */ + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 224 */ + 0x00,0x00,0x00,0x00,0x00,0x76,0xdc,0xd8,0xd8,0xdc,0x76,0x00, + 0x00,0x00, + /* character 225 */ + 0x00,0x00,0x00,0x00,0x7c,0xc6,0xfc,0xc6,0xc6,0xfc,0xc0,0xc0, + 0x40,0x00, + /* character 226 */ + 0x00,0x00,0xfe,0xc6,0xc6,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00, + 0x00,0x00, + /* character 227 */ + 0x00,0x00,0x00,0x00,0xfe,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x00, + 0x00,0x00, + /* character 228 */ + 0x00,0x00,0xfe,0xc6,0x60,0x30,0x18,0x30,0x60,0xc6,0xfe,0x00, + 0x00,0x00, + /* character 229 */ + 0x00,0x00,0x00,0x00,0x00,0x7e,0xd8,0xd8,0xd8,0xd8,0x70,0x00, + 0x00,0x00, + /* character 230 */ + 0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x7c,0x60,0x60,0xc0, + 0x00,0x00, + /* character 231 */ + 0x00,0x00,0x00,0x00,0x76,0xdc,0x18,0x18,0x18,0x18,0x18,0x00, + 0x00,0x00, + /* character 232 */ + 0x00,0x00,0xfc,0x30,0x78,0xcc,0xcc,0xcc,0x78,0x30,0xfc,0x00, + 0x00,0x00, + /* character 233 */ + 0x00,0x00,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0x6c,0x38,0x00, + 0x00,0x00, + /* character 234 */ + 0x00,0x00,0x38,0x6c,0xc6,0xc6,0xc6,0x6c,0x6c,0x6c,0xee,0x00, + 0x00,0x00, + /* character 235 */ + 0x00,0x00,0x3c,0x60,0x30,0x18,0x7c,0xcc,0xcc,0xcc,0x78,0x00, + 0x00,0x00, + /* character 236 */ + 0x00,0x00,0x00,0x00,0x00,0x7c,0xd6,0xd6,0x7c,0x00,0x00,0x00, + 0x00,0x00, + /* character 237 */ + 0x00,0x00,0x06,0x0c,0x7c,0xce,0xd6,0xe6,0x7c,0x60,0xc0,0x00, + 0x00,0x00, + /* character 238 */ + 0x00,0x00,0x38,0x60,0xc0,0xc0,0xf8,0xc0,0xc0,0x60,0x38,0x00, + 0x00,0x00, + /* character 239 */ + 0x00,0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x00, + 0x00,0x00, + /* character 240 */ + 0x00,0x00,0x00,0xfe,0x00,0x00,0xfe,0x00,0x00,0xfe,0x00,0x00, + 0x00,0x00, + /* character 241 */ + 0x00,0x00,0x30,0x30,0x30,0xfc,0x30,0x30,0x30,0x00,0xfc,0x00, + 0x00,0x00, + /* character 242 */ + 0x00,0x00,0x60,0x30,0x18,0x0c,0x18,0x30,0x60,0x00,0xfc,0x00, + 0x00,0x00, + /* character 243 */ + 0x00,0x00,0x18,0x30,0x60,0xc0,0x60,0x30,0x18,0x00,0xfc,0x00, + 0x00,0x00, + /* character 244 */ + 0x00,0x00,0x0e,0x1a,0x1a,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18, + /* character 245 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x58,0x58,0x70,0x00, + 0x00,0x00, + /* character 246 */ + 0x00,0x00,0x30,0x30,0x00,0x00,0xfc,0x00,0x00,0x30,0x30,0x00, + 0x00,0x00, + /* character 247 */ + 0x00,0x00,0x00,0x00,0x76,0xdc,0x00,0x76,0xdc,0x00,0x00,0x00, + 0x00,0x00, + /* character 248 */ + 0x00,0x70,0xd8,0xd8,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 249 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 250 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 251 */ + 0x00,0x1e,0x18,0x18,0x18,0x18,0x18,0xd8,0xd8,0x78,0x38,0x00, + 0x00,0x00, + /* character 252 */ + 0x00,0xd8,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 253 */ + 0x00,0x70,0xd8,0x30,0x60,0xc8,0xf8,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00, + /* character 254 */ + 0x00,0x00,0x00,0x00,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x00,0x00, + 0x00,0x00, + /* character 255 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00 +}; + +struct { + GrFont theFont; + GrFontChrInfo rest[255]; +} GrFont_PC8x14 = { + { + { /* font header */ + "pc8x14", /* font name */ + "pc", /* font family name */ + 0, /* characters have varying width */ + 0, /* derived from a scalable font */ + 1, /* font permanently linked into program */ + GR_FONTCVT_NONE, /* 'tweaked' font (resized, etc..) */ + 8, /* width (average when proportional) */ + 14, /* font height */ + 10, /* baseline pixel pos (from top) */ + 13, /* underline pixel pos (from top) */ + 1, /* underline width */ + 0, /* lowest character code in font */ + 256 /* number of characters in font */ + }, + (char *)GrFont_PC8x14_bits, /* character bitmap array */ + 0, /* auxiliary bitmap */ + 8, /* width of narrowest character */ + 8, /* width of widest character */ + 0, /* allocated size of auxiliary bitmap */ + 0, /* free space in auxiliary bitmap */ + { 0 }, /* converted character bitmap offsets */ + {{ 8, 0 }} /* first character info */ + }, + { + { 8, 14 }, /* info for character 1 */ + { 8, 28 }, /* info for character 2 */ + { 8, 42 }, /* info for character 3 */ + { 8, 56 }, /* info for character 4 */ + { 8, 70 }, /* info for character 5 */ + { 8, 84 }, /* info for character 6 */ + { 8, 98 }, /* info for character 7 */ + { 8, 112 }, /* info for character 8 */ + { 8, 126 }, /* info for character 9 */ + { 8, 140 }, /* info for character 10 */ + { 8, 154 }, /* info for character 11 */ + { 8, 168 }, /* info for character 12 */ + { 8, 182 }, /* info for character 13 */ + { 8, 196 }, /* info for character 14 */ + { 8, 210 }, /* info for character 15 */ + { 8, 224 }, /* info for character 16 */ + { 8, 238 }, /* info for character 17 */ + { 8, 252 }, /* info for character 18 */ + { 8, 266 }, /* info for character 19 */ + { 8, 280 }, /* info for character 20 */ + { 8, 294 }, /* info for character 21 */ + { 8, 308 }, /* info for character 22 */ + { 8, 322 }, /* info for character 23 */ + { 8, 336 }, /* info for character 24 */ + { 8, 350 }, /* info for character 25 */ + { 8, 364 }, /* info for character 26 */ + { 8, 378 }, /* info for character 27 */ + { 8, 392 }, /* info for character 28 */ + { 8, 406 }, /* info for character 29 */ + { 8, 420 }, /* info for character 30 */ + { 8, 434 }, /* info for character 31 */ + { 8, 448 }, /* info for character 32 */ + { 8, 462 }, /* info for character 33 */ + { 8, 476 }, /* info for character 34 */ + { 8, 490 }, /* info for character 35 */ + { 8, 504 }, /* info for character 36 */ + { 8, 518 }, /* info for character 37 */ + { 8, 532 }, /* info for character 38 */ + { 8, 546 }, /* info for character 39 */ + { 8, 560 }, /* info for character 40 */ + { 8, 574 }, /* info for character 41 */ + { 8, 588 }, /* info for character 42 */ + { 8, 602 }, /* info for character 43 */ + { 8, 616 }, /* info for character 44 */ + { 8, 630 }, /* info for character 45 */ + { 8, 644 }, /* info for character 46 */ + { 8, 658 }, /* info for character 47 */ + { 8, 672 }, /* info for character 48 */ + { 8, 686 }, /* info for character 49 */ + { 8, 700 }, /* info for character 50 */ + { 8, 714 }, /* info for character 51 */ + { 8, 728 }, /* info for character 52 */ + { 8, 742 }, /* info for character 53 */ + { 8, 756 }, /* info for character 54 */ + { 8, 770 }, /* info for character 55 */ + { 8, 784 }, /* info for character 56 */ + { 8, 798 }, /* info for character 57 */ + { 8, 812 }, /* info for character 58 */ + { 8, 826 }, /* info for character 59 */ + { 8, 840 }, /* info for character 60 */ + { 8, 854 }, /* info for character 61 */ + { 8, 868 }, /* info for character 62 */ + { 8, 882 }, /* info for character 63 */ + { 8, 896 }, /* info for character 64 */ + { 8, 910 }, /* info for character 65 */ + { 8, 924 }, /* info for character 66 */ + { 8, 938 }, /* info for character 67 */ + { 8, 952 }, /* info for character 68 */ + { 8, 966 }, /* info for character 69 */ + { 8, 980 }, /* info for character 70 */ + { 8, 994 }, /* info for character 71 */ + { 8, 1008 }, /* info for character 72 */ + { 8, 1022 }, /* info for character 73 */ + { 8, 1036 }, /* info for character 74 */ + { 8, 1050 }, /* info for character 75 */ + { 8, 1064 }, /* info for character 76 */ + { 8, 1078 }, /* info for character 77 */ + { 8, 1092 }, /* info for character 78 */ + { 8, 1106 }, /* info for character 79 */ + { 8, 1120 }, /* info for character 80 */ + { 8, 1134 }, /* info for character 81 */ + { 8, 1148 }, /* info for character 82 */ + { 8, 1162 }, /* info for character 83 */ + { 8, 1176 }, /* info for character 84 */ + { 8, 1190 }, /* info for character 85 */ + { 8, 1204 }, /* info for character 86 */ + { 8, 1218 }, /* info for character 87 */ + { 8, 1232 }, /* info for character 88 */ + { 8, 1246 }, /* info for character 89 */ + { 8, 1260 }, /* info for character 90 */ + { 8, 1274 }, /* info for character 91 */ + { 8, 1288 }, /* info for character 92 */ + { 8, 1302 }, /* info for character 93 */ + { 8, 1316 }, /* info for character 94 */ + { 8, 1330 }, /* info for character 95 */ + { 8, 1344 }, /* info for character 96 */ + { 8, 1358 }, /* info for character 97 */ + { 8, 1372 }, /* info for character 98 */ + { 8, 1386 }, /* info for character 99 */ + { 8, 1400 }, /* info for character 100 */ + { 8, 1414 }, /* info for character 101 */ + { 8, 1428 }, /* info for character 102 */ + { 8, 1442 }, /* info for character 103 */ + { 8, 1456 }, /* info for character 104 */ + { 8, 1470 }, /* info for character 105 */ + { 8, 1484 }, /* info for character 106 */ + { 8, 1498 }, /* info for character 107 */ + { 8, 1512 }, /* info for character 108 */ + { 8, 1526 }, /* info for character 109 */ + { 8, 1540 }, /* info for character 110 */ + { 8, 1554 }, /* info for character 111 */ + { 8, 1568 }, /* info for character 112 */ + { 8, 1582 }, /* info for character 113 */ + { 8, 1596 }, /* info for character 114 */ + { 8, 1610 }, /* info for character 115 */ + { 8, 1624 }, /* info for character 116 */ + { 8, 1638 }, /* info for character 117 */ + { 8, 1652 }, /* info for character 118 */ + { 8, 1666 }, /* info for character 119 */ + { 8, 1680 }, /* info for character 120 */ + { 8, 1694 }, /* info for character 121 */ + { 8, 1708 }, /* info for character 122 */ + { 8, 1722 }, /* info for character 123 */ + { 8, 1736 }, /* info for character 124 */ + { 8, 1750 }, /* info for character 125 */ + { 8, 1764 }, /* info for character 126 */ + { 8, 1778 }, /* info for character 127 */ + { 8, 1792 }, /* info for character 128 */ + { 8, 1806 }, /* info for character 129 */ + { 8, 1820 }, /* info for character 130 */ + { 8, 1834 }, /* info for character 131 */ + { 8, 1848 }, /* info for character 132 */ + { 8, 1862 }, /* info for character 133 */ + { 8, 1876 }, /* info for character 134 */ + { 8, 1890 }, /* info for character 135 */ + { 8, 1904 }, /* info for character 136 */ + { 8, 1918 }, /* info for character 137 */ + { 8, 1932 }, /* info for character 138 */ + { 8, 1946 }, /* info for character 139 */ + { 8, 1960 }, /* info for character 140 */ + { 8, 1974 }, /* info for character 141 */ + { 8, 1988 }, /* info for character 142 */ + { 8, 2002 }, /* info for character 143 */ + { 8, 2016 }, /* info for character 144 */ + { 8, 2030 }, /* info for character 145 */ + { 8, 2044 }, /* info for character 146 */ + { 8, 2058 }, /* info for character 147 */ + { 8, 2072 }, /* info for character 148 */ + { 8, 2086 }, /* info for character 149 */ + { 8, 2100 }, /* info for character 150 */ + { 8, 2114 }, /* info for character 151 */ + { 8, 2128 }, /* info for character 152 */ + { 8, 2142 }, /* info for character 153 */ + { 8, 2156 }, /* info for character 154 */ + { 8, 2170 }, /* info for character 155 */ + { 8, 2184 }, /* info for character 156 */ + { 8, 2198 }, /* info for character 157 */ + { 8, 2212 }, /* info for character 158 */ + { 8, 2226 }, /* info for character 159 */ + { 8, 2240 }, /* info for character 160 */ + { 8, 2254 }, /* info for character 161 */ + { 8, 2268 }, /* info for character 162 */ + { 8, 2282 }, /* info for character 163 */ + { 8, 2296 }, /* info for character 164 */ + { 8, 2310 }, /* info for character 165 */ + { 8, 2324 }, /* info for character 166 */ + { 8, 2338 }, /* info for character 167 */ + { 8, 2352 }, /* info for character 168 */ + { 8, 2366 }, /* info for character 169 */ + { 8, 2380 }, /* info for character 170 */ + { 8, 2394 }, /* info for character 171 */ + { 8, 2408 }, /* info for character 172 */ + { 8, 2422 }, /* info for character 173 */ + { 8, 2436 }, /* info for character 174 */ + { 8, 2450 }, /* info for character 175 */ + { 8, 2464 }, /* info for character 176 */ + { 8, 2478 }, /* info for character 177 */ + { 8, 2492 }, /* info for character 178 */ + { 8, 2506 }, /* info for character 179 */ + { 8, 2520 }, /* info for character 180 */ + { 8, 2534 }, /* info for character 181 */ + { 8, 2548 }, /* info for character 182 */ + { 8, 2562 }, /* info for character 183 */ + { 8, 2576 }, /* info for character 184 */ + { 8, 2590 }, /* info for character 185 */ + { 8, 2604 }, /* info for character 186 */ + { 8, 2618 }, /* info for character 187 */ + { 8, 2632 }, /* info for character 188 */ + { 8, 2646 }, /* info for character 189 */ + { 8, 2660 }, /* info for character 190 */ + { 8, 2674 }, /* info for character 191 */ + { 8, 2688 }, /* info for character 192 */ + { 8, 2702 }, /* info for character 193 */ + { 8, 2716 }, /* info for character 194 */ + { 8, 2730 }, /* info for character 195 */ + { 8, 2744 }, /* info for character 196 */ + { 8, 2758 }, /* info for character 197 */ + { 8, 2772 }, /* info for character 198 */ + { 8, 2786 }, /* info for character 199 */ + { 8, 2800 }, /* info for character 200 */ + { 8, 2814 }, /* info for character 201 */ + { 8, 2828 }, /* info for character 202 */ + { 8, 2842 }, /* info for character 203 */ + { 8, 2856 }, /* info for character 204 */ + { 8, 2870 }, /* info for character 205 */ + { 8, 2884 }, /* info for character 206 */ + { 8, 2898 }, /* info for character 207 */ + { 8, 2912 }, /* info for character 208 */ + { 8, 2926 }, /* info for character 209 */ + { 8, 2940 }, /* info for character 210 */ + { 8, 2954 }, /* info for character 211 */ + { 8, 2968 }, /* info for character 212 */ + { 8, 2982 }, /* info for character 213 */ + { 8, 2996 }, /* info for character 214 */ + { 8, 3010 }, /* info for character 215 */ + { 8, 3024 }, /* info for character 216 */ + { 8, 3038 }, /* info for character 217 */ + { 8, 3052 }, /* info for character 218 */ + { 8, 3066 }, /* info for character 219 */ + { 8, 3080 }, /* info for character 220 */ + { 8, 3094 }, /* info for character 221 */ + { 8, 3108 }, /* info for character 222 */ + { 8, 3122 }, /* info for character 223 */ + { 8, 3136 }, /* info for character 224 */ + { 8, 3150 }, /* info for character 225 */ + { 8, 3164 }, /* info for character 226 */ + { 8, 3178 }, /* info for character 227 */ + { 8, 3192 }, /* info for character 228 */ + { 8, 3206 }, /* info for character 229 */ + { 8, 3220 }, /* info for character 230 */ + { 8, 3234 }, /* info for character 231 */ + { 8, 3248 }, /* info for character 232 */ + { 8, 3262 }, /* info for character 233 */ + { 8, 3276 }, /* info for character 234 */ + { 8, 3290 }, /* info for character 235 */ + { 8, 3304 }, /* info for character 236 */ + { 8, 3318 }, /* info for character 237 */ + { 8, 3332 }, /* info for character 238 */ + { 8, 3346 }, /* info for character 239 */ + { 8, 3360 }, /* info for character 240 */ + { 8, 3374 }, /* info for character 241 */ + { 8, 3388 }, /* info for character 242 */ + { 8, 3402 }, /* info for character 243 */ + { 8, 3416 }, /* info for character 244 */ + { 8, 3430 }, /* info for character 245 */ + { 8, 3444 }, /* info for character 246 */ + { 8, 3458 }, /* info for character 247 */ + { 8, 3472 }, /* info for character 248 */ + { 8, 3486 }, /* info for character 249 */ + { 8, 3500 }, /* info for character 250 */ + { 8, 3514 }, /* info for character 251 */ + { 8, 3528 }, /* info for character 252 */ + { 8, 3542 }, /* info for character 253 */ + { 8, 3556 }, /* info for character 254 */ + { 8, 3570 } /* info for character 255 */ + } +}; + diff --git a/thirdparty/grx249/src/fonts/pc8x16.c b/thirdparty/grx249/src/fonts/pc8x16.c new file mode 100644 index 0000000..1410478 --- /dev/null +++ b/thirdparty/grx249/src/fonts/pc8x16.c @@ -0,0 +1,1067 @@ +/** + ** pc8x16.c ---- GRX 2.0 font converted to C by 'GrDumpFont()' + **/ + +#define GrFont_PC8x16 FONTNAME_TEMPORARY_REDIRECTION +#include "grx20.h" +#undef GrFont_PC8x16 + +static unsigned char far GrFont_PC8x16_bits[] = { + /* character 0 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 1 */ + 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e, + 0x00,0x00,0x00,0x00, + /* character 2 */ + 0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0xff,0x7e, + 0x00,0x00,0x00,0x00, + /* character 3 */ + 0x00,0x00,0x00,0x00,0x6c,0xfe,0xfe,0xfe,0xfe,0x7c,0x38,0x10, + 0x00,0x00,0x00,0x00, + /* character 4 */ + 0x00,0x00,0x00,0x00,0x10,0x38,0x7c,0xfe,0x7c,0x38,0x10,0x00, + 0x00,0x00,0x00,0x00, + /* character 5 */ + 0x00,0x00,0x00,0x18,0x3c,0x3c,0xe7,0xe7,0xe7,0x18,0x18,0x3c, + 0x00,0x00,0x00,0x00, + /* character 6 */ + 0x00,0x00,0x00,0x18,0x3c,0x7e,0xff,0xff,0x7e,0x18,0x18,0x3c, + 0x00,0x00,0x00,0x00, + /* character 7 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 8 */ + 0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0xc3,0xc3,0xe7,0xff,0xff, + 0xff,0xff,0xff,0xff, + /* character 9 */ + 0x00,0x00,0x00,0x00,0x00,0x3c,0x66,0x42,0x42,0x66,0x3c,0x00, + 0x00,0x00,0x00,0x00, + /* character 10 */ + 0xff,0xff,0xff,0xff,0xff,0xc3,0x99,0xbd,0xbd,0x99,0xc3,0xff, + 0xff,0xff,0xff,0xff, + /* character 11 */ + 0x00,0x00,0x1e,0x0e,0x1a,0x32,0x78,0xcc,0xcc,0xcc,0xcc,0x78, + 0x00,0x00,0x00,0x00, + /* character 12 */ + 0x00,0x00,0x3c,0x66,0x66,0x66,0x66,0x3c,0x18,0x7e,0x18,0x18, + 0x00,0x00,0x00,0x00, + /* character 13 */ + 0x00,0x00,0x3f,0x33,0x3f,0x30,0x30,0x30,0x30,0x70,0xf0,0xe0, + 0x00,0x00,0x00,0x00, + /* character 14 */ + 0x00,0x00,0x7f,0x63,0x7f,0x63,0x63,0x63,0x63,0x67,0xe7,0xe6, + 0xc0,0x00,0x00,0x00, + /* character 15 */ + 0x00,0x00,0x00,0x18,0x18,0xdb,0x3c,0xe7,0x3c,0xdb,0x18,0x18, + 0x00,0x00,0x00,0x00, + /* character 16 */ + 0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfe,0xf8,0xf0,0xe0,0xc0,0x80, + 0x00,0x00,0x00,0x00, + /* character 17 */ + 0x00,0x02,0x06,0x0e,0x1e,0x3e,0xfe,0x3e,0x1e,0x0e,0x06,0x02, + 0x00,0x00,0x00,0x00, + /* character 18 */ + 0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00, + 0x00,0x00,0x00,0x00, + /* character 19 */ + 0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x66, + 0x00,0x00,0x00,0x00, + /* character 20 */ + 0x00,0x00,0x7f,0xdb,0xdb,0xdb,0x7b,0x1b,0x1b,0x1b,0x1b,0x1b, + 0x00,0x00,0x00,0x00, + /* character 21 */ + 0x00,0x7c,0xc6,0x60,0x38,0x6c,0xc6,0xc6,0x6c,0x38,0x0c,0xc6, + 0x7c,0x00,0x00,0x00, + /* character 22 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xfe,0xfe,0xfe, + 0x00,0x00,0x00,0x00, + /* character 23 */ + 0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x7e,0x3c,0x18,0x7e, + 0x00,0x00,0x00,0x00, + /* character 24 */ + 0x00,0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x00,0x00,0x00,0x00, + /* character 25 */ + 0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7e,0x3c,0x18, + 0x00,0x00,0x00,0x00, + /* character 26 */ + 0x00,0x00,0x00,0x00,0x00,0x18,0x0c,0xfe,0x0c,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 27 */ + 0x00,0x00,0x00,0x00,0x00,0x30,0x60,0xfe,0x60,0x30,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 28 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xfe,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 29 */ + 0x00,0x00,0x00,0x00,0x00,0x28,0x6c,0xfe,0x6c,0x28,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 30 */ + 0x00,0x00,0x00,0x00,0x10,0x38,0x38,0x7c,0x7c,0xfe,0xfe,0x00, + 0x00,0x00,0x00,0x00, + /* character 31 */ + 0x00,0x00,0x00,0x00,0xfe,0xfe,0x7c,0x7c,0x38,0x38,0x10,0x00, + 0x00,0x00,0x00,0x00, + /* character 32 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 33 */ + 0x00,0x00,0x18,0x3c,0x3c,0x3c,0x18,0x18,0x18,0x00,0x18,0x18, + 0x00,0x00,0x00,0x00, + /* character 34 */ + 0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 35 */ + 0x00,0x00,0x00,0x6c,0x6c,0xfe,0x6c,0x6c,0x6c,0xfe,0x6c,0x6c, + 0x00,0x00,0x00,0x00, + /* character 36 */ + 0x18,0x18,0x7c,0xc6,0xc2,0xc0,0x7c,0x06,0x06,0x86,0xc6,0x7c, + 0x18,0x18,0x00,0x00, + /* character 37 */ + 0x00,0x00,0x00,0x00,0xc2,0xc6,0x0c,0x18,0x30,0x60,0xc6,0x86, + 0x00,0x00,0x00,0x00, + /* character 38 */ + 0x00,0x00,0x38,0x6c,0x6c,0x38,0x76,0xdc,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 39 */ + 0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 40 */ + 0x00,0x00,0x0c,0x18,0x30,0x30,0x30,0x30,0x30,0x30,0x18,0x0c, + 0x00,0x00,0x00,0x00, + /* character 41 */ + 0x00,0x00,0x30,0x18,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x18,0x30, + 0x00,0x00,0x00,0x00, + /* character 42 */ + 0x00,0x00,0x00,0x00,0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 43 */ + 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 44 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18, + 0x30,0x00,0x00,0x00, + /* character 45 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 46 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18, + 0x00,0x00,0x00,0x00, + /* character 47 */ + 0x00,0x00,0x00,0x00,0x02,0x06,0x0c,0x18,0x30,0x60,0xc0,0x80, + 0x00,0x00,0x00,0x00, + /* character 48 */ + 0x00,0x00,0x7c,0xc6,0xc6,0xce,0xde,0xf6,0xe6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 49 */ + 0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x7e, + 0x00,0x00,0x00,0x00, + /* character 50 */ + 0x00,0x00,0x7c,0xc6,0x06,0x0c,0x18,0x30,0x60,0xc0,0xc6,0xfe, + 0x00,0x00,0x00,0x00, + /* character 51 */ + 0x00,0x00,0x7c,0xc6,0x06,0x06,0x3c,0x06,0x06,0x06,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 52 */ + 0x00,0x00,0x0c,0x1c,0x3c,0x6c,0xcc,0xfe,0x0c,0x0c,0x0c,0x1e, + 0x00,0x00,0x00,0x00, + /* character 53 */ + 0x00,0x00,0xfe,0xc0,0xc0,0xc0,0xfc,0x06,0x06,0x06,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 54 */ + 0x00,0x00,0x38,0x60,0xc0,0xc0,0xfc,0xc6,0xc6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 55 */ + 0x00,0x00,0xfe,0xc6,0x06,0x06,0x0c,0x18,0x30,0x30,0x30,0x30, + 0x00,0x00,0x00,0x00, + /* character 56 */ + 0x00,0x00,0x7c,0xc6,0xc6,0xc6,0x7c,0xc6,0xc6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 57 */ + 0x00,0x00,0x7c,0xc6,0xc6,0xc6,0x7e,0x06,0x06,0x06,0x0c,0x78, + 0x00,0x00,0x00,0x00, + /* character 58 */ + 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00, + 0x00,0x00,0x00,0x00, + /* character 59 */ + 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x30, + 0x00,0x00,0x00,0x00, + /* character 60 */ + 0x00,0x00,0x00,0x06,0x0c,0x18,0x30,0x60,0x30,0x18,0x0c,0x06, + 0x00,0x00,0x00,0x00, + /* character 61 */ + 0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x7e,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 62 */ + 0x00,0x00,0x00,0x60,0x30,0x18,0x0c,0x06,0x0c,0x18,0x30,0x60, + 0x00,0x00,0x00,0x00, + /* character 63 */ + 0x00,0x00,0x7c,0xc6,0xc6,0x0c,0x18,0x18,0x18,0x00,0x18,0x18, + 0x00,0x00,0x00,0x00, + /* character 64 */ + 0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xde,0xde,0xde,0xdc,0xc0,0x7c, + 0x00,0x00,0x00,0x00, + /* character 65 */ + 0x00,0x00,0x10,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0xc6, + 0x00,0x00,0x00,0x00, + /* character 66 */ + 0x00,0x00,0xfc,0x66,0x66,0x66,0x7c,0x66,0x66,0x66,0x66,0xfc, + 0x00,0x00,0x00,0x00, + /* character 67 */ + 0x00,0x00,0x3c,0x66,0xc2,0xc0,0xc0,0xc0,0xc0,0xc2,0x66,0x3c, + 0x00,0x00,0x00,0x00, + /* character 68 */ + 0x00,0x00,0xf8,0x6c,0x66,0x66,0x66,0x66,0x66,0x66,0x6c,0xf8, + 0x00,0x00,0x00,0x00, + /* character 69 */ + 0x00,0x00,0xfe,0x66,0x62,0x68,0x78,0x68,0x60,0x62,0x66,0xfe, + 0x00,0x00,0x00,0x00, + /* character 70 */ + 0x00,0x00,0xfe,0x66,0x62,0x68,0x78,0x68,0x60,0x60,0x60,0xf0, + 0x00,0x00,0x00,0x00, + /* character 71 */ + 0x00,0x00,0x3c,0x66,0xc2,0xc0,0xc0,0xde,0xc6,0xc6,0x66,0x3a, + 0x00,0x00,0x00,0x00, + /* character 72 */ + 0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0xc6,0xc6, + 0x00,0x00,0x00,0x00, + /* character 73 */ + 0x00,0x00,0x3c,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3c, + 0x00,0x00,0x00,0x00, + /* character 74 */ + 0x00,0x00,0x1e,0x0c,0x0c,0x0c,0x0c,0x0c,0xcc,0xcc,0xcc,0x78, + 0x00,0x00,0x00,0x00, + /* character 75 */ + 0x00,0x00,0xe6,0x66,0x66,0x6c,0x78,0x78,0x6c,0x66,0x66,0xe6, + 0x00,0x00,0x00,0x00, + /* character 76 */ + 0x00,0x00,0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x62,0x66,0xfe, + 0x00,0x00,0x00,0x00, + /* character 77 */ + 0x00,0x00,0xc6,0xee,0xfe,0xfe,0xd6,0xc6,0xc6,0xc6,0xc6,0xc6, + 0x00,0x00,0x00,0x00, + /* character 78 */ + 0x00,0x00,0xc6,0xe6,0xf6,0xfe,0xde,0xce,0xc6,0xc6,0xc6,0xc6, + 0x00,0x00,0x00,0x00, + /* character 79 */ + 0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 80 */ + 0x00,0x00,0xfc,0x66,0x66,0x66,0x7c,0x60,0x60,0x60,0x60,0xf0, + 0x00,0x00,0x00,0x00, + /* character 81 */ + 0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xd6,0xde,0x7c, + 0x0c,0x0e,0x00,0x00, + /* character 82 */ + 0x00,0x00,0xfc,0x66,0x66,0x66,0x7c,0x6c,0x66,0x66,0x66,0xe6, + 0x00,0x00,0x00,0x00, + /* character 83 */ + 0x00,0x00,0x7c,0xc6,0xc6,0x60,0x38,0x0c,0x06,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 84 */ + 0x00,0x00,0x7e,0x7e,0x5a,0x18,0x18,0x18,0x18,0x18,0x18,0x3c, + 0x00,0x00,0x00,0x00, + /* character 85 */ + 0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 86 */ + 0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x6c,0x38,0x10, + 0x00,0x00,0x00,0x00, + /* character 87 */ + 0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xd6,0xd6,0xd6,0xfe,0xee,0x6c, + 0x00,0x00,0x00,0x00, + /* character 88 */ + 0x00,0x00,0xc6,0xc6,0x6c,0x7c,0x38,0x38,0x7c,0x6c,0xc6,0xc6, + 0x00,0x00,0x00,0x00, + /* character 89 */ + 0x00,0x00,0x66,0x66,0x66,0x66,0x3c,0x18,0x18,0x18,0x18,0x3c, + 0x00,0x00,0x00,0x00, + /* character 90 */ + 0x00,0x00,0xfe,0xc6,0x86,0x0c,0x18,0x30,0x60,0xc2,0xc6,0xfe, + 0x00,0x00,0x00,0x00, + /* character 91 */ + 0x00,0x00,0x3c,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3c, + 0x00,0x00,0x00,0x00, + /* character 92 */ + 0x00,0x00,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x06,0x02, + 0x00,0x00,0x00,0x00, + /* character 93 */ + 0x00,0x00,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c, + 0x00,0x00,0x00,0x00, + /* character 94 */ + 0x10,0x38,0x6c,0xc6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 95 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0xff,0x00,0x00, + /* character 96 */ + 0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 97 */ + 0x00,0x00,0x00,0x00,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 98 */ + 0x00,0x00,0xe0,0x60,0x60,0x78,0x6c,0x66,0x66,0x66,0x66,0x7c, + 0x00,0x00,0x00,0x00, + /* character 99 */ + 0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0xc0,0xc0,0xc0,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 100 */ + 0x00,0x00,0x1c,0x0c,0x0c,0x3c,0x6c,0xcc,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 101 */ + 0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 102 */ + 0x00,0x00,0x38,0x6c,0x64,0x60,0xf0,0x60,0x60,0x60,0x60,0xf0, + 0x00,0x00,0x00,0x00, + /* character 103 */ + 0x00,0x00,0x00,0x00,0x00,0x76,0xcc,0xcc,0xcc,0xcc,0xcc,0x7c, + 0x0c,0xcc,0x78,0x00, + /* character 104 */ + 0x00,0x00,0xe0,0x60,0x60,0x6c,0x76,0x66,0x66,0x66,0x66,0xe6, + 0x00,0x00,0x00,0x00, + /* character 105 */ + 0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c, + 0x00,0x00,0x00,0x00, + /* character 106 */ + 0x00,0x00,0x06,0x06,0x00,0x0e,0x06,0x06,0x06,0x06,0x06,0x06, + 0x66,0x66,0x3c,0x00, + /* character 107 */ + 0x00,0x00,0xe0,0x60,0x60,0x66,0x6c,0x78,0x78,0x6c,0x66,0xe6, + 0x00,0x00,0x00,0x00, + /* character 108 */ + 0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3c, + 0x00,0x00,0x00,0x00, + /* character 109 */ + 0x00,0x00,0x00,0x00,0x00,0xec,0xfe,0xd6,0xd6,0xd6,0xd6,0xc6, + 0x00,0x00,0x00,0x00, + /* character 110 */ + 0x00,0x00,0x00,0x00,0x00,0xdc,0x66,0x66,0x66,0x66,0x66,0x66, + 0x00,0x00,0x00,0x00, + /* character 111 */ + 0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 112 */ + 0x00,0x00,0x00,0x00,0x00,0xdc,0x66,0x66,0x66,0x66,0x66,0x7c, + 0x60,0x60,0xf0,0x00, + /* character 113 */ + 0x00,0x00,0x00,0x00,0x00,0x76,0xcc,0xcc,0xcc,0xcc,0xcc,0x7c, + 0x0c,0x0c,0x1e,0x00, + /* character 114 */ + 0x00,0x00,0x00,0x00,0x00,0xdc,0x76,0x66,0x60,0x60,0x60,0xf0, + 0x00,0x00,0x00,0x00, + /* character 115 */ + 0x00,0x00,0x00,0x00,0x00,0x7c,0xc6,0x60,0x38,0x0c,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 116 */ + 0x00,0x00,0x10,0x30,0x30,0xfc,0x30,0x30,0x30,0x30,0x36,0x1c, + 0x00,0x00,0x00,0x00, + /* character 117 */ + 0x00,0x00,0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 118 */ + 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x3c,0x18, + 0x00,0x00,0x00,0x00, + /* character 119 */ + 0x00,0x00,0x00,0x00,0x00,0xc6,0xc6,0xd6,0xd6,0xd6,0xfe,0x6c, + 0x00,0x00,0x00,0x00, + /* character 120 */ + 0x00,0x00,0x00,0x00,0x00,0xc6,0x6c,0x38,0x38,0x38,0x6c,0xc6, + 0x00,0x00,0x00,0x00, + /* character 121 */ + 0x00,0x00,0x00,0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7e, + 0x06,0x0c,0xf8,0x00, + /* character 122 */ + 0x00,0x00,0x00,0x00,0x00,0xfe,0xcc,0x18,0x30,0x60,0xc6,0xfe, + 0x00,0x00,0x00,0x00, + /* character 123 */ + 0x00,0x00,0x0e,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0x18,0x0e, + 0x00,0x00,0x00,0x00, + /* character 124 */ + 0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x18, + 0x00,0x00,0x00,0x00, + /* character 125 */ + 0x00,0x00,0x70,0x18,0x18,0x18,0x0e,0x18,0x18,0x18,0x18,0x70, + 0x00,0x00,0x00,0x00, + /* character 126 */ + 0x00,0x00,0x76,0xdc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 127 */ + 0x00,0x00,0x00,0x00,0x10,0x38,0x6c,0xc6,0xc6,0xc6,0xfe,0x00, + 0x00,0x00,0x00,0x00, + /* character 128 */ + 0x00,0x00,0x3c,0x66,0xc2,0xc0,0xc0,0xc0,0xc2,0x66,0x3c,0x0c, + 0x06,0x7c,0x00,0x00, + /* character 129 */ + 0x00,0x00,0xcc,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 130 */ + 0x00,0x0c,0x18,0x30,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 131 */ + 0x00,0x10,0x38,0x6c,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 132 */ + 0x00,0x00,0xcc,0x00,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 133 */ + 0x00,0x60,0x30,0x18,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 134 */ + 0x00,0x38,0x6c,0x38,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 135 */ + 0x00,0x00,0x00,0x00,0x3c,0x66,0x60,0x60,0x66,0x3c,0x0c,0x06, + 0x3c,0x00,0x00,0x00, + /* character 136 */ + 0x00,0x10,0x38,0x6c,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 137 */ + 0x00,0x00,0xc6,0x00,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 138 */ + 0x00,0x60,0x30,0x18,0x00,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 139 */ + 0x00,0x00,0x66,0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c, + 0x00,0x00,0x00,0x00, + /* character 140 */ + 0x00,0x18,0x3c,0x66,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c, + 0x00,0x00,0x00,0x00, + /* character 141 */ + 0x00,0x60,0x30,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c, + 0x00,0x00,0x00,0x00, + /* character 142 */ + 0x00,0xc6,0x00,0x10,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6, + 0x00,0x00,0x00,0x00, + /* character 143 */ + 0x38,0x6c,0x38,0x00,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6, + 0x00,0x00,0x00,0x00, + /* character 144 */ + 0x18,0x30,0x60,0x00,0xfe,0x66,0x60,0x7c,0x60,0x60,0x66,0xfe, + 0x00,0x00,0x00,0x00, + /* character 145 */ + 0x00,0x00,0x00,0x00,0x6c,0xfe,0xb2,0x32,0x7e,0xd8,0xd8,0x6e, + 0x00,0x00,0x00,0x00, + /* character 146 */ + 0x00,0x00,0x3e,0x6c,0xcc,0xcc,0xfe,0xcc,0xcc,0xcc,0xcc,0xce, + 0x00,0x00,0x00,0x00, + /* character 147 */ + 0x00,0x10,0x38,0x6c,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 148 */ + 0x00,0x00,0xc6,0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 149 */ + 0x00,0x60,0x30,0x18,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 150 */ + 0x00,0x30,0x78,0xcc,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 151 */ + 0x00,0x60,0x30,0x18,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 152 */ + 0x00,0x00,0xc6,0x00,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7e, + 0x06,0x0c,0x78,0x00, + /* character 153 */ + 0x00,0xc6,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 154 */ + 0x00,0xc6,0x00,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 155 */ + 0x00,0x18,0x18,0x3c,0x66,0x60,0x60,0x60,0x66,0x3c,0x18,0x18, + 0x00,0x00,0x00,0x00, + /* character 156 */ + 0x00,0x38,0x6c,0x64,0x60,0xf0,0x60,0x60,0x60,0x60,0xe6,0xfc, + 0x00,0x00,0x00,0x00, + /* character 157 */ + 0x00,0x00,0x66,0x66,0x3c,0x18,0x7e,0x18,0x7e,0x18,0x18,0x18, + 0x00,0x00,0x00,0x00, + /* character 158 */ + 0x00,0xf8,0xcc,0xcc,0xf8,0xc4,0xcc,0xde,0xcc,0xcc,0xcc,0xc6, + 0x00,0x00,0x00,0x00, + /* character 159 */ + 0x00,0x0e,0x1b,0x18,0x18,0x18,0x7e,0x18,0x18,0x18,0x18,0x18, + 0xd8,0x70,0x00,0x00, + /* character 160 */ + 0x00,0x18,0x30,0x60,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 161 */ + 0x00,0x0c,0x18,0x30,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3c, + 0x00,0x00,0x00,0x00, + /* character 162 */ + 0x00,0x18,0x30,0x60,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 163 */ + 0x00,0x18,0x30,0x60,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76, + 0x00,0x00,0x00,0x00, + /* character 164 */ + 0x00,0x00,0x76,0xdc,0x00,0xdc,0x66,0x66,0x66,0x66,0x66,0x66, + 0x00,0x00,0x00,0x00, + /* character 165 */ + 0x76,0xdc,0x00,0xc6,0xe6,0xf6,0xfe,0xde,0xce,0xc6,0xc6,0xc6, + 0x00,0x00,0x00,0x00, + /* character 166 */ + 0x00,0x3c,0x6c,0x6c,0x3e,0x00,0x7e,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 167 */ + 0x00,0x38,0x6c,0x6c,0x38,0x00,0x7c,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 168 */ + 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60,0xc0,0xc6,0xc6,0x7c, + 0x00,0x00,0x00,0x00, + /* character 169 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xc0,0xc0,0xc0,0xc0,0x00, + 0x00,0x00,0x00,0x00, + /* character 170 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x06,0x06,0x06,0x06,0x00, + 0x00,0x00,0x00,0x00, + /* character 171 */ + 0x00,0xc0,0xc0,0xc2,0xc6,0xcc,0x18,0x30,0x60,0xdc,0x86,0x0c, + 0x18,0x3e,0x00,0x00, + /* character 172 */ + 0x00,0xc0,0xc0,0xc2,0xc6,0xcc,0x18,0x30,0x66,0xce,0x9e,0x3e, + 0x06,0x06,0x00,0x00, + /* character 173 */ + 0x00,0x00,0x18,0x18,0x00,0x18,0x18,0x18,0x3c,0x3c,0x3c,0x18, + 0x00,0x00,0x00,0x00, + /* character 174 */ + 0x00,0x00,0x00,0x00,0x00,0x36,0x6c,0xd8,0x6c,0x36,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 175 */ + 0x00,0x00,0x00,0x00,0x00,0xd8,0x6c,0x36,0x6c,0xd8,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 176 */ + 0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44, + 0x11,0x44,0x11,0x44, + /* character 177 */ + 0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa, + 0x55,0xaa,0x55,0xaa, + /* character 178 */ + 0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77, + 0xdd,0x77,0xdd,0x77, + /* character 179 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 180 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 181 */ + 0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 182 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xf6,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 183 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 184 */ + 0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0xf8,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 185 */ + 0x36,0x36,0x36,0x36,0x36,0xf6,0x06,0xf6,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 186 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 187 */ + 0x00,0x00,0x00,0x00,0x00,0xfe,0x06,0xf6,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 188 */ + 0x36,0x36,0x36,0x36,0x36,0xf6,0x06,0xfe,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 189 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xfe,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 190 */ + 0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 191 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 192 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 193 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 194 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 195 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 196 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 197 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xff,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 198 */ + 0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 199 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x37,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 200 */ + 0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x3f,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 201 */ + 0x00,0x00,0x00,0x00,0x00,0x3f,0x30,0x37,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 202 */ + 0x36,0x36,0x36,0x36,0x36,0xf7,0x00,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 203 */ + 0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xf7,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 204 */ + 0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x37,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 205 */ + 0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 206 */ + 0x36,0x36,0x36,0x36,0x36,0xf7,0x00,0xf7,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 207 */ + 0x18,0x18,0x18,0x18,0x18,0xff,0x00,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 208 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 209 */ + 0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 210 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 211 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x3f,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 212 */ + 0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 213 */ + 0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x1f,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 214 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 215 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xff,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x36, + /* character 216 */ + 0x18,0x18,0x18,0x18,0x18,0xff,0x18,0xff,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 217 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 218 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 219 */ + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + /* character 220 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + /* character 221 */ + 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, + 0xf0,0xf0,0xf0,0xf0, + /* character 222 */ + 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, + 0x0f,0x0f,0x0f,0x0f, + /* character 223 */ + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 224 */ + 0x00,0x00,0x00,0x00,0x00,0x76,0xdc,0xd8,0xd8,0xd8,0xdc,0x76, + 0x00,0x00,0x00,0x00, + /* character 225 */ + 0x00,0x00,0x78,0xcc,0xcc,0xcc,0xd8,0xcc,0xc6,0xc6,0xc6,0xcc, + 0x00,0x00,0x00,0x00, + /* character 226 */ + 0x00,0x00,0xfe,0xc6,0xc6,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0, + 0x00,0x00,0x00,0x00, + /* character 227 */ + 0x00,0x00,0x00,0x00,0xfe,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c, + 0x00,0x00,0x00,0x00, + /* character 228 */ + 0x00,0x00,0x00,0xfe,0xc6,0x60,0x30,0x18,0x30,0x60,0xc6,0xfe, + 0x00,0x00,0x00,0x00, + /* character 229 */ + 0x00,0x00,0x00,0x00,0x00,0x7e,0xd8,0xd8,0xd8,0xd8,0xd8,0x70, + 0x00,0x00,0x00,0x00, + /* character 230 */ + 0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x7c,0x60,0x60, + 0xc0,0x00,0x00,0x00, + /* character 231 */ + 0x00,0x00,0x00,0x00,0x76,0xdc,0x18,0x18,0x18,0x18,0x18,0x18, + 0x00,0x00,0x00,0x00, + /* character 232 */ + 0x00,0x00,0x00,0x7e,0x18,0x3c,0x66,0x66,0x66,0x3c,0x18,0x7e, + 0x00,0x00,0x00,0x00, + /* character 233 */ + 0x00,0x00,0x00,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0x6c,0x38, + 0x00,0x00,0x00,0x00, + /* character 234 */ + 0x00,0x00,0x38,0x6c,0xc6,0xc6,0xc6,0x6c,0x6c,0x6c,0x6c,0xee, + 0x00,0x00,0x00,0x00, + /* character 235 */ + 0x00,0x00,0x1e,0x30,0x18,0x0c,0x3e,0x66,0x66,0x66,0x66,0x3c, + 0x00,0x00,0x00,0x00, + /* character 236 */ + 0x00,0x00,0x00,0x00,0x00,0x7e,0xdb,0xdb,0xdb,0x7e,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 237 */ + 0x00,0x00,0x00,0x03,0x06,0x7e,0xdb,0xdb,0xf3,0x7e,0x60,0xc0, + 0x00,0x00,0x00,0x00, + /* character 238 */ + 0x00,0x00,0x1c,0x30,0x60,0x60,0x7c,0x60,0x60,0x60,0x30,0x1c, + 0x00,0x00,0x00,0x00, + /* character 239 */ + 0x00,0x00,0x00,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6, + 0x00,0x00,0x00,0x00, + /* character 240 */ + 0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0xfe,0x00,0x00,0xfe,0x00, + 0x00,0x00,0x00,0x00, + /* character 241 */ + 0x00,0x00,0x00,0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00,0xff, + 0x00,0x00,0x00,0x00, + /* character 242 */ + 0x00,0x00,0x00,0x30,0x18,0x0c,0x06,0x0c,0x18,0x30,0x00,0x7e, + 0x00,0x00,0x00,0x00, + /* character 243 */ + 0x00,0x00,0x00,0x0c,0x18,0x30,0x60,0x30,0x18,0x0c,0x00,0x7e, + 0x00,0x00,0x00,0x00, + /* character 244 */ + 0x00,0x00,0x0e,0x1b,0x1b,0x1b,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18, + /* character 245 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xd8,0xd8,0xd8,0x70, + 0x00,0x00,0x00,0x00, + /* character 246 */ + 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x7e,0x00,0x18,0x18,0x00, + 0x00,0x00,0x00,0x00, + /* character 247 */ + 0x00,0x00,0x00,0x00,0x00,0x76,0xdc,0x00,0x76,0xdc,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 248 */ + 0x00,0x38,0x6c,0x6c,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 249 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 250 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 251 */ + 0x00,0x0f,0x0c,0x0c,0x0c,0x0c,0x0c,0xec,0x6c,0x6c,0x3c,0x1c, + 0x00,0x00,0x00,0x00, + /* character 252 */ + 0x00,0xd8,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 253 */ + 0x00,0x70,0xd8,0x30,0x60,0xc8,0xf8,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + /* character 254 */ + 0x00,0x00,0x00,0x00,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x00, + 0x00,0x00,0x00,0x00, + /* character 255 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00 +}; + +struct { + GrFont theFont; + GrFontChrInfo rest[255]; +} GrFont_PC8x16 = { + { + { /* font header */ + "pc8x16", /* font name */ + "pc", /* font family name */ + 0, /* characters have varying width */ + 0, /* derived from a scalable font */ + 1, /* font permanently linked into program */ + GR_FONTCVT_NONE, /* 'tweaked' font (resized, etc..) */ + 8, /* width (average when proportional) */ + 16, /* font height */ + 11, /* baseline pixel pos (from top) */ + 15, /* underline pixel pos (from top) */ + 1, /* underline width */ + 0, /* lowest character code in font */ + 256 /* number of characters in font */ + }, + (char *)GrFont_PC8x16_bits, /* character bitmap array */ + 0, /* auxiliary bitmap */ + 8, /* width of narrowest character */ + 8, /* width of widest character */ + 0, /* allocated size of auxiliary bitmap */ + 0, /* free space in auxiliary bitmap */ + { 0 }, /* converted character bitmap offsets */ + {{ 8, 0 }} /* first character info */ + }, + { + { 8, 16 }, /* info for character 1 */ + { 8, 32 }, /* info for character 2 */ + { 8, 48 }, /* info for character 3 */ + { 8, 64 }, /* info for character 4 */ + { 8, 80 }, /* info for character 5 */ + { 8, 96 }, /* info for character 6 */ + { 8, 112 }, /* info for character 7 */ + { 8, 128 }, /* info for character 8 */ + { 8, 144 }, /* info for character 9 */ + { 8, 160 }, /* info for character 10 */ + { 8, 176 }, /* info for character 11 */ + { 8, 192 }, /* info for character 12 */ + { 8, 208 }, /* info for character 13 */ + { 8, 224 }, /* info for character 14 */ + { 8, 240 }, /* info for character 15 */ + { 8, 256 }, /* info for character 16 */ + { 8, 272 }, /* info for character 17 */ + { 8, 288 }, /* info for character 18 */ + { 8, 304 }, /* info for character 19 */ + { 8, 320 }, /* info for character 20 */ + { 8, 336 }, /* info for character 21 */ + { 8, 352 }, /* info for character 22 */ + { 8, 368 }, /* info for character 23 */ + { 8, 384 }, /* info for character 24 */ + { 8, 400 }, /* info for character 25 */ + { 8, 416 }, /* info for character 26 */ + { 8, 432 }, /* info for character 27 */ + { 8, 448 }, /* info for character 28 */ + { 8, 464 }, /* info for character 29 */ + { 8, 480 }, /* info for character 30 */ + { 8, 496 }, /* info for character 31 */ + { 8, 512 }, /* info for character 32 */ + { 8, 528 }, /* info for character 33 */ + { 8, 544 }, /* info for character 34 */ + { 8, 560 }, /* info for character 35 */ + { 8, 576 }, /* info for character 36 */ + { 8, 592 }, /* info for character 37 */ + { 8, 608 }, /* info for character 38 */ + { 8, 624 }, /* info for character 39 */ + { 8, 640 }, /* info for character 40 */ + { 8, 656 }, /* info for character 41 */ + { 8, 672 }, /* info for character 42 */ + { 8, 688 }, /* info for character 43 */ + { 8, 704 }, /* info for character 44 */ + { 8, 720 }, /* info for character 45 */ + { 8, 736 }, /* info for character 46 */ + { 8, 752 }, /* info for character 47 */ + { 8, 768 }, /* info for character 48 */ + { 8, 784 }, /* info for character 49 */ + { 8, 800 }, /* info for character 50 */ + { 8, 816 }, /* info for character 51 */ + { 8, 832 }, /* info for character 52 */ + { 8, 848 }, /* info for character 53 */ + { 8, 864 }, /* info for character 54 */ + { 8, 880 }, /* info for character 55 */ + { 8, 896 }, /* info for character 56 */ + { 8, 912 }, /* info for character 57 */ + { 8, 928 }, /* info for character 58 */ + { 8, 944 }, /* info for character 59 */ + { 8, 960 }, /* info for character 60 */ + { 8, 976 }, /* info for character 61 */ + { 8, 992 }, /* info for character 62 */ + { 8, 1008 }, /* info for character 63 */ + { 8, 1024 }, /* info for character 64 */ + { 8, 1040 }, /* info for character 65 */ + { 8, 1056 }, /* info for character 66 */ + { 8, 1072 }, /* info for character 67 */ + { 8, 1088 }, /* info for character 68 */ + { 8, 1104 }, /* info for character 69 */ + { 8, 1120 }, /* info for character 70 */ + { 8, 1136 }, /* info for character 71 */ + { 8, 1152 }, /* info for character 72 */ + { 8, 1168 }, /* info for character 73 */ + { 8, 1184 }, /* info for character 74 */ + { 8, 1200 }, /* info for character 75 */ + { 8, 1216 }, /* info for character 76 */ + { 8, 1232 }, /* info for character 77 */ + { 8, 1248 }, /* info for character 78 */ + { 8, 1264 }, /* info for character 79 */ + { 8, 1280 }, /* info for character 80 */ + { 8, 1296 }, /* info for character 81 */ + { 8, 1312 }, /* info for character 82 */ + { 8, 1328 }, /* info for character 83 */ + { 8, 1344 }, /* info for character 84 */ + { 8, 1360 }, /* info for character 85 */ + { 8, 1376 }, /* info for character 86 */ + { 8, 1392 }, /* info for character 87 */ + { 8, 1408 }, /* info for character 88 */ + { 8, 1424 }, /* info for character 89 */ + { 8, 1440 }, /* info for character 90 */ + { 8, 1456 }, /* info for character 91 */ + { 8, 1472 }, /* info for character 92 */ + { 8, 1488 }, /* info for character 93 */ + { 8, 1504 }, /* info for character 94 */ + { 8, 1520 }, /* info for character 95 */ + { 8, 1536 }, /* info for character 96 */ + { 8, 1552 }, /* info for character 97 */ + { 8, 1568 }, /* info for character 98 */ + { 8, 1584 }, /* info for character 99 */ + { 8, 1600 }, /* info for character 100 */ + { 8, 1616 }, /* info for character 101 */ + { 8, 1632 }, /* info for character 102 */ + { 8, 1648 }, /* info for character 103 */ + { 8, 1664 }, /* info for character 104 */ + { 8, 1680 }, /* info for character 105 */ + { 8, 1696 }, /* info for character 106 */ + { 8, 1712 }, /* info for character 107 */ + { 8, 1728 }, /* info for character 108 */ + { 8, 1744 }, /* info for character 109 */ + { 8, 1760 }, /* info for character 110 */ + { 8, 1776 }, /* info for character 111 */ + { 8, 1792 }, /* info for character 112 */ + { 8, 1808 }, /* info for character 113 */ + { 8, 1824 }, /* info for character 114 */ + { 8, 1840 }, /* info for character 115 */ + { 8, 1856 }, /* info for character 116 */ + { 8, 1872 }, /* info for character 117 */ + { 8, 1888 }, /* info for character 118 */ + { 8, 1904 }, /* info for character 119 */ + { 8, 1920 }, /* info for character 120 */ + { 8, 1936 }, /* info for character 121 */ + { 8, 1952 }, /* info for character 122 */ + { 8, 1968 }, /* info for character 123 */ + { 8, 1984 }, /* info for character 124 */ + { 8, 2000 }, /* info for character 125 */ + { 8, 2016 }, /* info for character 126 */ + { 8, 2032 }, /* info for character 127 */ + { 8, 2048 }, /* info for character 128 */ + { 8, 2064 }, /* info for character 129 */ + { 8, 2080 }, /* info for character 130 */ + { 8, 2096 }, /* info for character 131 */ + { 8, 2112 }, /* info for character 132 */ + { 8, 2128 }, /* info for character 133 */ + { 8, 2144 }, /* info for character 134 */ + { 8, 2160 }, /* info for character 135 */ + { 8, 2176 }, /* info for character 136 */ + { 8, 2192 }, /* info for character 137 */ + { 8, 2208 }, /* info for character 138 */ + { 8, 2224 }, /* info for character 139 */ + { 8, 2240 }, /* info for character 140 */ + { 8, 2256 }, /* info for character 141 */ + { 8, 2272 }, /* info for character 142 */ + { 8, 2288 }, /* info for character 143 */ + { 8, 2304 }, /* info for character 144 */ + { 8, 2320 }, /* info for character 145 */ + { 8, 2336 }, /* info for character 146 */ + { 8, 2352 }, /* info for character 147 */ + { 8, 2368 }, /* info for character 148 */ + { 8, 2384 }, /* info for character 149 */ + { 8, 2400 }, /* info for character 150 */ + { 8, 2416 }, /* info for character 151 */ + { 8, 2432 }, /* info for character 152 */ + { 8, 2448 }, /* info for character 153 */ + { 8, 2464 }, /* info for character 154 */ + { 8, 2480 }, /* info for character 155 */ + { 8, 2496 }, /* info for character 156 */ + { 8, 2512 }, /* info for character 157 */ + { 8, 2528 }, /* info for character 158 */ + { 8, 2544 }, /* info for character 159 */ + { 8, 2560 }, /* info for character 160 */ + { 8, 2576 }, /* info for character 161 */ + { 8, 2592 }, /* info for character 162 */ + { 8, 2608 }, /* info for character 163 */ + { 8, 2624 }, /* info for character 164 */ + { 8, 2640 }, /* info for character 165 */ + { 8, 2656 }, /* info for character 166 */ + { 8, 2672 }, /* info for character 167 */ + { 8, 2688 }, /* info for character 168 */ + { 8, 2704 }, /* info for character 169 */ + { 8, 2720 }, /* info for character 170 */ + { 8, 2736 }, /* info for character 171 */ + { 8, 2752 }, /* info for character 172 */ + { 8, 2768 }, /* info for character 173 */ + { 8, 2784 }, /* info for character 174 */ + { 8, 2800 }, /* info for character 175 */ + { 8, 2816 }, /* info for character 176 */ + { 8, 2832 }, /* info for character 177 */ + { 8, 2848 }, /* info for character 178 */ + { 8, 2864 }, /* info for character 179 */ + { 8, 2880 }, /* info for character 180 */ + { 8, 2896 }, /* info for character 181 */ + { 8, 2912 }, /* info for character 182 */ + { 8, 2928 }, /* info for character 183 */ + { 8, 2944 }, /* info for character 184 */ + { 8, 2960 }, /* info for character 185 */ + { 8, 2976 }, /* info for character 186 */ + { 8, 2992 }, /* info for character 187 */ + { 8, 3008 }, /* info for character 188 */ + { 8, 3024 }, /* info for character 189 */ + { 8, 3040 }, /* info for character 190 */ + { 8, 3056 }, /* info for character 191 */ + { 8, 3072 }, /* info for character 192 */ + { 8, 3088 }, /* info for character 193 */ + { 8, 3104 }, /* info for character 194 */ + { 8, 3120 }, /* info for character 195 */ + { 8, 3136 }, /* info for character 196 */ + { 8, 3152 }, /* info for character 197 */ + { 8, 3168 }, /* info for character 198 */ + { 8, 3184 }, /* info for character 199 */ + { 8, 3200 }, /* info for character 200 */ + { 8, 3216 }, /* info for character 201 */ + { 8, 3232 }, /* info for character 202 */ + { 8, 3248 }, /* info for character 203 */ + { 8, 3264 }, /* info for character 204 */ + { 8, 3280 }, /* info for character 205 */ + { 8, 3296 }, /* info for character 206 */ + { 8, 3312 }, /* info for character 207 */ + { 8, 3328 }, /* info for character 208 */ + { 8, 3344 }, /* info for character 209 */ + { 8, 3360 }, /* info for character 210 */ + { 8, 3376 }, /* info for character 211 */ + { 8, 3392 }, /* info for character 212 */ + { 8, 3408 }, /* info for character 213 */ + { 8, 3424 }, /* info for character 214 */ + { 8, 3440 }, /* info for character 215 */ + { 8, 3456 }, /* info for character 216 */ + { 8, 3472 }, /* info for character 217 */ + { 8, 3488 }, /* info for character 218 */ + { 8, 3504 }, /* info for character 219 */ + { 8, 3520 }, /* info for character 220 */ + { 8, 3536 }, /* info for character 221 */ + { 8, 3552 }, /* info for character 222 */ + { 8, 3568 }, /* info for character 223 */ + { 8, 3584 }, /* info for character 224 */ + { 8, 3600 }, /* info for character 225 */ + { 8, 3616 }, /* info for character 226 */ + { 8, 3632 }, /* info for character 227 */ + { 8, 3648 }, /* info for character 228 */ + { 8, 3664 }, /* info for character 229 */ + { 8, 3680 }, /* info for character 230 */ + { 8, 3696 }, /* info for character 231 */ + { 8, 3712 }, /* info for character 232 */ + { 8, 3728 }, /* info for character 233 */ + { 8, 3744 }, /* info for character 234 */ + { 8, 3760 }, /* info for character 235 */ + { 8, 3776 }, /* info for character 236 */ + { 8, 3792 }, /* info for character 237 */ + { 8, 3808 }, /* info for character 238 */ + { 8, 3824 }, /* info for character 239 */ + { 8, 3840 }, /* info for character 240 */ + { 8, 3856 }, /* info for character 241 */ + { 8, 3872 }, /* info for character 242 */ + { 8, 3888 }, /* info for character 243 */ + { 8, 3904 }, /* info for character 244 */ + { 8, 3920 }, /* info for character 245 */ + { 8, 3936 }, /* info for character 246 */ + { 8, 3952 }, /* info for character 247 */ + { 8, 3968 }, /* info for character 248 */ + { 8, 3984 }, /* info for character 249 */ + { 8, 4000 }, /* info for character 250 */ + { 8, 4016 }, /* info for character 251 */ + { 8, 4032 }, /* info for character 252 */ + { 8, 4048 }, /* info for character 253 */ + { 8, 4064 }, /* info for character 254 */ + { 8, 4080 } /* info for character 255 */ + } +}; + diff --git a/thirdparty/grx249/src/fonts/pc8x8.c b/thirdparty/grx249/src/fonts/pc8x8.c new file mode 100644 index 0000000..9356a31 --- /dev/null +++ b/thirdparty/grx249/src/fonts/pc8x8.c @@ -0,0 +1,810 @@ +/** + ** pc8x8.c ---- GRX 2.0 font converted to C by 'GrDumpFont()' + **/ + +#define GrFont_PC8x8 FONTNAME_TEMPORARY_REDIRECTION +#include "grx20.h" +#undef GrFont_PC8x8 + +static unsigned char far GrFont_PC8x8_bits[] = { + /* character 0 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + /* character 1 */ + 0x7e,0x81,0xa5,0x81,0xbd,0x99,0x81,0x7e, + /* character 2 */ + 0x7e,0xff,0xdb,0xff,0xc3,0xe7,0xff,0x7e, + /* character 3 */ + 0x6c,0xfe,0xfe,0xfe,0x7c,0x38,0x10,0x00, + /* character 4 */ + 0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x08,0x00, + /* character 5 */ + 0x1c,0x1c,0x1c,0x7f,0x7f,0x6b,0x08,0x1c, + /* character 6 */ + 0x10,0x10,0x38,0x7c,0xfe,0x7c,0x10,0x38, + /* character 7 */ + 0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00, + /* character 8 */ + 0xff,0xff,0xe7,0xc3,0xc3,0xe7,0xff,0xff, + /* character 9 */ + 0x00,0x3c,0x66,0x42,0x42,0x66,0x3c,0x00, + /* character 10 */ + 0xff,0xc3,0x99,0xbd,0xbd,0x99,0xc3,0xff, + /* character 11 */ + 0x0f,0x07,0x0f,0x7d,0xcc,0xcc,0xcc,0x78, + /* character 12 */ + 0x3c,0x66,0x66,0x66,0x3c,0x18,0x7e,0x18, + /* character 13 */ + 0x3f,0x33,0x3f,0x30,0x30,0x70,0xf0,0xe0, + /* character 14 */ + 0x7f,0x63,0x7f,0x63,0x63,0x67,0xe6,0xc0, + /* character 15 */ + 0x18,0xdb,0x3c,0xe7,0xe7,0x3c,0xdb,0x18, + /* character 16 */ + 0x80,0xe0,0xf8,0xfe,0xf8,0xe0,0x80,0x00, + /* character 17 */ + 0x02,0x0e,0x3e,0xfe,0x3e,0x0e,0x02,0x00, + /* character 18 */ + 0x18,0x3c,0x7e,0x18,0x18,0x7e,0x3c,0x18, + /* character 19 */ + 0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x00, + /* character 20 */ + 0x7f,0xdb,0xdb,0x7b,0x1b,0x1b,0x1b,0x00, + /* character 21 */ + 0x3e,0x63,0x38,0x6c,0x6c,0x38,0xcc,0x78, + /* character 22 */ + 0x00,0x00,0x00,0x00,0x7e,0x7e,0x7e,0x00, + /* character 23 */ + 0x18,0x3c,0x7e,0x18,0x7e,0x3c,0x18,0xff, + /* character 24 */ + 0x18,0x3c,0x7e,0x18,0x18,0x18,0x18,0x00, + /* character 25 */ + 0x18,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00, + /* character 26 */ + 0x00,0x18,0x0c,0xfe,0x0c,0x18,0x00,0x00, + /* character 27 */ + 0x00,0x30,0x60,0xfe,0x60,0x30,0x00,0x00, + /* character 28 */ + 0x00,0x00,0xc0,0xc0,0xc0,0xfe,0x00,0x00, + /* character 29 */ + 0x00,0x24,0x66,0xff,0x66,0x24,0x00,0x00, + /* character 30 */ + 0x00,0x18,0x3c,0x7e,0xff,0xff,0x00,0x00, + /* character 31 */ + 0x00,0xff,0xff,0x7e,0x3c,0x18,0x00,0x00, + /* character 32 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + /* character 33 */ + 0x30,0x78,0x78,0x30,0x30,0x00,0x30,0x00, + /* character 34 */ + 0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x00, + /* character 35 */ + 0x6c,0x6c,0xfe,0x6c,0xfe,0x6c,0x6c,0x00, + /* character 36 */ + 0x18,0x3e,0x60,0x3c,0x06,0x7c,0x18,0x00, + /* character 37 */ + 0x00,0x63,0x66,0x0c,0x18,0x33,0x63,0x00, + /* character 38 */ + 0x1c,0x36,0x1c,0x3b,0x6e,0x66,0x3b,0x00, + /* character 39 */ + 0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00, + /* character 40 */ + 0x0c,0x18,0x30,0x30,0x30,0x18,0x0c,0x00, + /* character 41 */ + 0x30,0x18,0x0c,0x0c,0x0c,0x18,0x30,0x00, + /* character 42 */ + 0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00, + /* character 43 */ + 0x00,0x30,0x30,0xfc,0x30,0x30,0x00,0x00, + /* character 44 */ + 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30, + /* character 45 */ + 0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00, + /* character 46 */ + 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00, + /* character 47 */ + 0x03,0x06,0x0c,0x18,0x30,0x60,0x40,0x00, + /* character 48 */ + 0x3e,0x63,0x67,0x6f,0x7b,0x73,0x3e,0x00, + /* character 49 */ + 0x18,0x38,0x58,0x18,0x18,0x18,0x7e,0x00, + /* character 50 */ + 0x3c,0x66,0x06,0x1c,0x30,0x66,0x7e,0x00, + /* character 51 */ + 0x3c,0x66,0x06,0x1c,0x06,0x66,0x3c,0x00, + /* character 52 */ + 0x0e,0x1e,0x36,0x66,0x7f,0x06,0x0f,0x00, + /* character 53 */ + 0x7e,0x60,0x7c,0x06,0x06,0x66,0x3c,0x00, + /* character 54 */ + 0x1c,0x30,0x60,0x7c,0x66,0x66,0x3c,0x00, + /* character 55 */ + 0x7e,0x66,0x06,0x0c,0x18,0x18,0x18,0x00, + /* character 56 */ + 0x3c,0x66,0x66,0x3c,0x66,0x66,0x3c,0x00, + /* character 57 */ + 0x3c,0x66,0x66,0x3e,0x06,0x0c,0x38,0x00, + /* character 58 */ + 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00, + /* character 59 */ + 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x30, + /* character 60 */ + 0x0c,0x18,0x30,0x60,0x30,0x18,0x0c,0x00, + /* character 61 */ + 0x00,0x00,0x7e,0x00,0x00,0x7e,0x00,0x00, + /* character 62 */ + 0x30,0x18,0x0c,0x06,0x0c,0x18,0x30,0x00, + /* character 63 */ + 0x3c,0x66,0x06,0x0c,0x18,0x00,0x18,0x00, + /* character 64 */ + 0x3e,0x63,0x6f,0x69,0x6f,0x60,0x3e,0x00, + /* character 65 */ + 0x18,0x3c,0x66,0x66,0x7e,0x66,0x66,0x00, + /* character 66 */ + 0x7e,0x33,0x33,0x3e,0x33,0x33,0x7e,0x00, + /* character 67 */ + 0x1e,0x33,0x60,0x60,0x60,0x33,0x1e,0x00, + /* character 68 */ + 0x7c,0x36,0x33,0x33,0x33,0x36,0x7c,0x00, + /* character 69 */ + 0x7f,0x31,0x34,0x3c,0x34,0x31,0x7f,0x00, + /* character 70 */ + 0x7f,0x31,0x34,0x3c,0x34,0x30,0x78,0x00, + /* character 71 */ + 0x1e,0x33,0x60,0x60,0x67,0x33,0x1f,0x00, + /* character 72 */ + 0x66,0x66,0x66,0x7e,0x66,0x66,0x66,0x00, + /* character 73 */ + 0x3c,0x18,0x18,0x18,0x18,0x18,0x3c,0x00, + /* character 74 */ + 0x0f,0x06,0x06,0x06,0x66,0x66,0x3c,0x00, + /* character 75 */ + 0x73,0x33,0x36,0x3c,0x36,0x33,0x73,0x00, + /* character 76 */ + 0x78,0x30,0x30,0x30,0x31,0x33,0x7f,0x00, + /* character 77 */ + 0x63,0x77,0x7f,0x7f,0x6b,0x63,0x63,0x00, + /* character 78 */ + 0x63,0x73,0x7b,0x6f,0x67,0x63,0x63,0x00, + /* character 79 */ + 0x3e,0x63,0x63,0x63,0x63,0x63,0x3e,0x00, + /* character 80 */ + 0x7e,0x33,0x33,0x3e,0x30,0x30,0x78,0x00, + /* character 81 */ + 0x3c,0x66,0x66,0x66,0x6e,0x3c,0x0e,0x00, + /* character 82 */ + 0x7e,0x33,0x33,0x3e,0x36,0x33,0x73,0x00, + /* character 83 */ + 0x3c,0x66,0x30,0x18,0x0c,0x66,0x3c,0x00, + /* character 84 */ + 0x7e,0x5a,0x18,0x18,0x18,0x18,0x3c,0x00, + /* character 85 */ + 0x66,0x66,0x66,0x66,0x66,0x66,0x7e,0x00, + /* character 86 */ + 0x66,0x66,0x66,0x66,0x66,0x3c,0x18,0x00, + /* character 87 */ + 0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x00, + /* character 88 */ + 0x63,0x63,0x36,0x1c,0x1c,0x36,0x63,0x00, + /* character 89 */ + 0x66,0x66,0x66,0x3c,0x18,0x18,0x3c,0x00, + /* character 90 */ + 0x7f,0x63,0x46,0x0c,0x19,0x33,0x7f,0x00, + /* character 91 */ + 0x3c,0x30,0x30,0x30,0x30,0x30,0x3c,0x00, + /* character 92 */ + 0x60,0x30,0x18,0x0c,0x06,0x03,0x01,0x00, + /* character 93 */ + 0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c,0x00, + /* character 94 */ + 0x08,0x1c,0x36,0x63,0x00,0x00,0x00,0x00, + /* character 95 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff, + /* character 96 */ + 0x18,0x18,0x0c,0x00,0x00,0x00,0x00,0x00, + /* character 97 */ + 0x00,0x00,0x3c,0x06,0x3e,0x66,0x3b,0x00, + /* character 98 */ + 0x70,0x30,0x30,0x3e,0x33,0x33,0x6e,0x00, + /* character 99 */ + 0x00,0x00,0x3c,0x66,0x60,0x66,0x3c,0x00, + /* character 100 */ + 0x0e,0x06,0x06,0x3e,0x66,0x66,0x3b,0x00, + /* character 101 */ + 0x00,0x00,0x3c,0x66,0x7e,0x60,0x3c,0x00, + /* character 102 */ + 0x1c,0x36,0x30,0x78,0x30,0x30,0x78,0x00, + /* character 103 */ + 0x00,0x00,0x3b,0x66,0x66,0x3e,0x06,0x7c, + /* character 104 */ + 0x70,0x30,0x36,0x3b,0x33,0x33,0x73,0x00, + /* character 105 */ + 0x18,0x00,0x38,0x18,0x18,0x18,0x3c,0x00, + /* character 106 */ + 0x06,0x00,0x06,0x06,0x06,0x66,0x66,0x3c, + /* character 107 */ + 0x70,0x30,0x33,0x36,0x3c,0x36,0x73,0x00, + /* character 108 */ + 0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x00, + /* character 109 */ + 0x00,0x00,0x66,0x7f,0x7f,0x6b,0x63,0x00, + /* character 110 */ + 0x00,0x00,0x7c,0x66,0x66,0x66,0x66,0x00, + /* character 111 */ + 0x00,0x00,0x3c,0x66,0x66,0x66,0x3c,0x00, + /* character 112 */ + 0x00,0x00,0x6e,0x33,0x33,0x3e,0x30,0x78, + /* character 113 */ + 0x00,0x00,0x3b,0x66,0x66,0x3e,0x06,0x0f, + /* character 114 */ + 0x00,0x00,0x6e,0x3b,0x33,0x30,0x78,0x00, + /* character 115 */ + 0x00,0x00,0x3e,0x60,0x3c,0x06,0x7c,0x00, + /* character 116 */ + 0x08,0x18,0x3e,0x18,0x18,0x1a,0x0c,0x00, + /* character 117 */ + 0x00,0x00,0x66,0x66,0x66,0x66,0x3b,0x00, + /* character 118 */ + 0x00,0x00,0x66,0x66,0x66,0x3c,0x18,0x00, + /* character 119 */ + 0x00,0x00,0x63,0x6b,0x7f,0x7f,0x36,0x00, + /* character 120 */ + 0x00,0x00,0x63,0x36,0x1c,0x36,0x63,0x00, + /* character 121 */ + 0x00,0x00,0x66,0x66,0x66,0x3e,0x06,0x7c, + /* character 122 */ + 0x00,0x00,0x7e,0x4c,0x18,0x32,0x7e,0x00, + /* character 123 */ + 0x0e,0x18,0x18,0x70,0x18,0x18,0x0e,0x00, + /* character 124 */ + 0x0c,0x0c,0x0c,0x00,0x0c,0x0c,0x0c,0x00, + /* character 125 */ + 0x70,0x18,0x18,0x0e,0x18,0x18,0x70,0x00, + /* character 126 */ + 0x3b,0x6e,0x00,0x00,0x00,0x00,0x00,0x00, + /* character 127 */ + 0x00,0x08,0x1c,0x36,0x63,0x63,0x7f,0x00, + /* character 128 */ + 0x3c,0x66,0x60,0x66,0x3c,0x0c,0x06,0x3c, + /* character 129 */ + 0x00,0x66,0x00,0x66,0x66,0x66,0x3f,0x00, + /* character 130 */ + 0x1c,0x00,0x78,0xcc,0xfc,0xc0,0x78,0x00, + /* character 131 */ + 0x7e,0xc3,0x3c,0x06,0x3e,0x66,0x3f,0x00, + /* character 132 */ + 0x66,0x00,0x3c,0x06,0x3e,0x66,0x3f,0x00, + /* character 133 */ + 0x70,0x00,0x3c,0x06,0x3e,0x66,0x3f,0x00, + /* character 134 */ + 0x18,0x18,0x3c,0x06,0x3e,0x66,0x3f,0x00, + /* character 135 */ + 0x00,0x00,0x3c,0x60,0x60,0x3c,0x06,0x1c, + /* character 136 */ + 0x7e,0xc3,0x3c,0x66,0x7e,0x60,0x3c,0x00, + /* character 137 */ + 0xcc,0x00,0x78,0xcc,0xfc,0xc0,0x78,0x00, + /* character 138 */ + 0x70,0x00,0x3c,0x66,0x7e,0x60,0x3c,0x00, + /* character 139 */ + 0x66,0x00,0x38,0x18,0x18,0x18,0x3c,0x00, + /* character 140 */ + 0x3e,0x63,0x1c,0x0c,0x0c,0x0c,0x1e,0x00, + /* character 141 */ + 0x70,0x00,0x38,0x18,0x18,0x18,0x3c,0x00, + /* character 142 */ + 0x63,0x1c,0x36,0x63,0x7f,0x63,0x63,0x00, + /* character 143 */ + 0x18,0x18,0x00,0x3c,0x66,0x7e,0x66,0x00, + /* character 144 */ + 0x1c,0x00,0xfc,0x60,0x78,0x60,0xfc,0x00, + /* character 145 */ + 0x00,0x00,0x7f,0x0c,0x7f,0xcc,0x7f,0x00, + /* character 146 */ + 0x1f,0x36,0x66,0x7f,0x66,0x66,0x67,0x00, + /* character 147 */ + 0x3c,0x66,0x00,0x3c,0x66,0x66,0x3c,0x00, + /* character 148 */ + 0x00,0x66,0x00,0x3c,0x66,0x66,0x3c,0x00, + /* character 149 */ + 0x00,0x70,0x00,0x3c,0x66,0x66,0x3c,0x00, + /* character 150 */ + 0x3c,0x66,0x00,0x66,0x66,0x66,0x3f,0x00, + /* character 151 */ + 0x00,0x70,0x00,0x66,0x66,0x66,0x3f,0x00, + /* character 152 */ + 0x00,0xcc,0x00,0xcc,0xcc,0x7c,0x0c,0xf8, + /* character 153 */ + 0xc3,0x18,0x3c,0x66,0x66,0x3c,0x18,0x00, + /* character 154 */ + 0x66,0x00,0x66,0x66,0x66,0x66,0x3c,0x00, + /* character 155 */ + 0x0c,0x0c,0x3f,0x60,0x60,0x3f,0x0c,0x0c, + /* character 156 */ + 0x1c,0x36,0x32,0x78,0x30,0x73,0x7e,0x00, + /* character 157 */ + 0x66,0x66,0x3c,0x7e,0x18,0x7e,0x18,0x18, + /* character 158 */ + 0xf8,0xcc,0xcc,0xfa,0xc6,0xcf,0xc6,0xc7, + /* character 159 */ + 0x0e,0x1b,0x18,0x3c,0x18,0x18,0xd8,0x70, + /* character 160 */ + 0x0e,0x00,0x3c,0x06,0x3e,0x66,0x3f,0x00, + /* character 161 */ + 0x1c,0x00,0x38,0x18,0x18,0x18,0x3c,0x00, + /* character 162 */ + 0x00,0x0e,0x00,0x3c,0x66,0x66,0x3c,0x00, + /* character 163 */ + 0x00,0x0e,0x00,0x66,0x66,0x66,0x3f,0x00, + /* character 164 */ + 0x00,0x7c,0x00,0x7c,0x66,0x66,0x66,0x00, + /* character 165 */ + 0x7e,0x00,0x66,0x76,0x7e,0x6e,0x66,0x00, + /* character 166 */ + 0x1e,0x36,0x36,0x1f,0x00,0x3f,0x00,0x00, + /* character 167 */ + 0x1c,0x36,0x36,0x1c,0x00,0x3e,0x00,0x00, + /* character 168 */ + 0x18,0x00,0x18,0x30,0x60,0x66,0x3c,0x00, + /* character 169 */ + 0x00,0x00,0x00,0x7e,0x60,0x60,0x00,0x00, + /* character 170 */ + 0x00,0x00,0x00,0xfc,0x0c,0x0c,0x00,0x00, + /* character 171 */ + 0xc3,0xc6,0xcc,0xde,0x33,0x66,0xcc,0x0f, + /* character 172 */ + 0xc3,0xc6,0xcc,0xdb,0x37,0x6f,0xcf,0x03, + /* character 173 */ + 0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00, + /* character 174 */ + 0x00,0x33,0x66,0xcc,0x66,0x33,0x00,0x00, + /* character 175 */ + 0x00,0xcc,0x66,0x33,0x66,0xcc,0x00,0x00, + /* character 176 */ + 0x22,0x88,0x22,0x88,0x22,0x88,0x22,0x88, + /* character 177 */ + 0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa, + /* character 178 */ + 0xdb,0x77,0xdb,0xee,0xdb,0x77,0xdb,0xee, + /* character 179 */ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + /* character 180 */ + 0x18,0x18,0x18,0x18,0xf8,0x18,0x18,0x18, + /* character 181 */ + 0x18,0x18,0xf8,0x18,0xf8,0x18,0x18,0x18, + /* character 182 */ + 0x36,0x36,0x36,0x36,0xf6,0x36,0x36,0x36, + /* character 183 */ + 0x00,0x00,0x00,0x00,0xfe,0x36,0x36,0x36, + /* character 184 */ + 0x00,0x00,0xf8,0x18,0xf8,0x18,0x18,0x18, + /* character 185 */ + 0x36,0x36,0xf6,0x06,0xf6,0x36,0x36,0x36, + /* character 186 */ + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, + /* character 187 */ + 0x00,0x00,0xfe,0x06,0xf6,0x36,0x36,0x36, + /* character 188 */ + 0x36,0x36,0xf6,0x06,0xfe,0x00,0x00,0x00, + /* character 189 */ + 0x36,0x36,0x36,0x36,0xfe,0x00,0x00,0x00, + /* character 190 */ + 0x18,0x18,0xf8,0x18,0xf8,0x00,0x00,0x00, + /* character 191 */ + 0x00,0x00,0x00,0x00,0xf8,0x18,0x18,0x18, + /* character 192 */ + 0x18,0x18,0x18,0x18,0x1f,0x00,0x00,0x00, + /* character 193 */ + 0x18,0x18,0x18,0x18,0xff,0x00,0x00,0x00, + /* character 194 */ + 0x00,0x00,0x00,0x00,0xff,0x18,0x18,0x18, + /* character 195 */ + 0x18,0x18,0x18,0x18,0x1f,0x18,0x18,0x18, + /* character 196 */ + 0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00, + /* character 197 */ + 0x18,0x18,0x18,0x18,0xff,0x18,0x18,0x18, + /* character 198 */ + 0x18,0x18,0x1f,0x18,0x1f,0x18,0x18,0x18, + /* character 199 */ + 0x36,0x36,0x36,0x36,0x37,0x36,0x36,0x36, + /* character 200 */ + 0x36,0x36,0x37,0x30,0x3f,0x00,0x00,0x00, + /* character 201 */ + 0x00,0x00,0x3f,0x30,0x37,0x36,0x36,0x36, + /* character 202 */ + 0x36,0x36,0xf7,0x00,0xff,0x00,0x00,0x00, + /* character 203 */ + 0x00,0x00,0xff,0x00,0xf7,0x36,0x36,0x36, + /* character 204 */ + 0x36,0x36,0x37,0x30,0x37,0x36,0x36,0x36, + /* character 205 */ + 0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00, + /* character 206 */ + 0x36,0x36,0xf7,0x00,0xf7,0x36,0x36,0x36, + /* character 207 */ + 0x18,0x18,0xff,0x00,0xff,0x00,0x00,0x00, + /* character 208 */ + 0x36,0x36,0x36,0x36,0xff,0x00,0x00,0x00, + /* character 209 */ + 0x00,0x00,0xff,0x00,0xff,0x18,0x18,0x18, + /* character 210 */ + 0x00,0x00,0x00,0x00,0xff,0x36,0x36,0x36, + /* character 211 */ + 0x36,0x36,0x36,0x36,0x3f,0x00,0x00,0x00, + /* character 212 */ + 0x18,0x18,0x1f,0x18,0x1f,0x00,0x00,0x00, + /* character 213 */ + 0x00,0x00,0x1f,0x18,0x1f,0x18,0x18,0x18, + /* character 214 */ + 0x00,0x00,0x00,0x00,0x3f,0x36,0x36,0x36, + /* character 215 */ + 0x36,0x36,0x36,0x36,0xff,0x36,0x36,0x36, + /* character 216 */ + 0x18,0x18,0xff,0x18,0xff,0x18,0x18,0x18, + /* character 217 */ + 0x18,0x18,0x18,0x18,0xf8,0x00,0x00,0x00, + /* character 218 */ + 0x00,0x00,0x00,0x00,0x1f,0x18,0x18,0x18, + /* character 219 */ + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + /* character 220 */ + 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff, + /* character 221 */ + 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, + /* character 222 */ + 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, + /* character 223 */ + 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, + /* character 224 */ + 0x00,0x00,0x3b,0x6e,0x64,0x6e,0x3b,0x00, + /* character 225 */ + 0x00,0x3c,0x66,0x7c,0x66,0x7c,0x60,0x60, + /* character 226 */ + 0x00,0x7e,0x66,0x60,0x60,0x60,0x60,0x00, + /* character 227 */ + 0x00,0x7f,0x36,0x36,0x36,0x36,0x36,0x00, + /* character 228 */ + 0x7e,0x66,0x30,0x18,0x30,0x66,0x7e,0x00, + /* character 229 */ + 0x00,0x00,0x3f,0x6c,0x6c,0x6c,0x38,0x00, + /* character 230 */ + 0x00,0x33,0x33,0x33,0x33,0x3e,0x30,0x60, + /* character 231 */ + 0x00,0x3b,0x6e,0x0c,0x0c,0x0c,0x0c,0x00, + /* character 232 */ + 0x7e,0x18,0x3c,0x66,0x66,0x3c,0x18,0x7e, + /* character 233 */ + 0x1c,0x36,0x63,0x7f,0x63,0x36,0x1c,0x00, + /* character 234 */ + 0x1c,0x36,0x63,0x63,0x36,0x36,0x77,0x00, + /* character 235 */ + 0x0e,0x18,0x0c,0x3e,0x66,0x66,0x3c,0x00, + /* character 236 */ + 0x00,0x00,0x7e,0xdb,0xdb,0x7e,0x00,0x00, + /* character 237 */ + 0x06,0x0c,0x7e,0xdb,0xdb,0x7e,0x60,0xc0, + /* character 238 */ + 0x1c,0x30,0x60,0x7c,0x60,0x30,0x1c,0x00, + /* character 239 */ + 0x3c,0x66,0x66,0x66,0x66,0x66,0x66,0x00, + /* character 240 */ + 0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x00, + /* character 241 */ + 0x18,0x18,0x7e,0x18,0x18,0x00,0x7e,0x00, + /* character 242 */ + 0x30,0x18,0x0c,0x18,0x30,0x00,0x7e,0x00, + /* character 243 */ + 0x0c,0x18,0x30,0x18,0x0c,0x00,0x7e,0x00, + /* character 244 */ + 0x0e,0x1b,0x1b,0x18,0x18,0x18,0x18,0x18, + /* character 245 */ + 0x18,0x18,0x18,0x18,0x18,0xd8,0xd8,0x70, + /* character 246 */ + 0x18,0x18,0x00,0x7e,0x00,0x18,0x18,0x00, + /* character 247 */ + 0x00,0x3b,0x6e,0x00,0x3b,0x6e,0x00,0x00, + /* character 248 */ + 0x1c,0x36,0x36,0x1c,0x00,0x00,0x00,0x00, + /* character 249 */ + 0x00,0x00,0x00,0x0c,0x0c,0x00,0x00,0x00, + /* character 250 */ + 0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00, + /* character 251 */ + 0x0f,0x0c,0x0c,0x0c,0xec,0x6c,0x3c,0x1c, + /* character 252 */ + 0x78,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x00, + /* character 253 */ + 0x70,0x18,0x30,0x60,0x78,0x00,0x00,0x00, + /* character 254 */ + 0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x00,0x00, + /* character 255 */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +}; + +struct { + GrFont theFont; + GrFontChrInfo rest[255]; +} GrFont_PC8x8 = { + { + { /* font header */ + "pc8x8", /* font name */ + "pc", /* font family name */ + 0, /* characters have varying width */ + 0, /* derived from a scalable font */ + 1, /* font permanently linked into program */ + GR_FONTCVT_NONE, /* 'tweaked' font (resized, etc..) */ + 8, /* width (average when proportional) */ + 8, /* font height */ + 6, /* baseline pixel pos (from top) */ + 7, /* underline pixel pos (from top) */ + 1, /* underline width */ + 0, /* lowest character code in font */ + 256 /* number of characters in font */ + }, + (char*)GrFont_PC8x8_bits, /* character bitmap array */ + 0, /* auxiliary bitmap */ + 8, /* width of narrowest character */ + 8, /* width of widest character */ + 0, /* allocated size of auxiliary bitmap */ + 0, /* free space in auxiliary bitmap */ + { 0 }, /* converted character bitmap offsets */ + {{ 8, 0 }} /* first character info */ + }, + { + { 8, 8 }, /* info for character 1 */ + { 8, 16 }, /* info for character 2 */ + { 8, 24 }, /* info for character 3 */ + { 8, 32 }, /* info for character 4 */ + { 8, 40 }, /* info for character 5 */ + { 8, 48 }, /* info for character 6 */ + { 8, 56 }, /* info for character 7 */ + { 8, 64 }, /* info for character 8 */ + { 8, 72 }, /* info for character 9 */ + { 8, 80 }, /* info for character 10 */ + { 8, 88 }, /* info for character 11 */ + { 8, 96 }, /* info for character 12 */ + { 8, 104 }, /* info for character 13 */ + { 8, 112 }, /* info for character 14 */ + { 8, 120 }, /* info for character 15 */ + { 8, 128 }, /* info for character 16 */ + { 8, 136 }, /* info for character 17 */ + { 8, 144 }, /* info for character 18 */ + { 8, 152 }, /* info for character 19 */ + { 8, 160 }, /* info for character 20 */ + { 8, 168 }, /* info for character 21 */ + { 8, 176 }, /* info for character 22 */ + { 8, 184 }, /* info for character 23 */ + { 8, 192 }, /* info for character 24 */ + { 8, 200 }, /* info for character 25 */ + { 8, 208 }, /* info for character 26 */ + { 8, 216 }, /* info for character 27 */ + { 8, 224 }, /* info for character 28 */ + { 8, 232 }, /* info for character 29 */ + { 8, 240 }, /* info for character 30 */ + { 8, 248 }, /* info for character 31 */ + { 8, 256 }, /* info for character 32 */ + { 8, 264 }, /* info for character 33 */ + { 8, 272 }, /* info for character 34 */ + { 8, 280 }, /* info for character 35 */ + { 8, 288 }, /* info for character 36 */ + { 8, 296 }, /* info for character 37 */ + { 8, 304 }, /* info for character 38 */ + { 8, 312 }, /* info for character 39 */ + { 8, 320 }, /* info for character 40 */ + { 8, 328 }, /* info for character 41 */ + { 8, 336 }, /* info for character 42 */ + { 8, 344 }, /* info for character 43 */ + { 8, 352 }, /* info for character 44 */ + { 8, 360 }, /* info for character 45 */ + { 8, 368 }, /* info for character 46 */ + { 8, 376 }, /* info for character 47 */ + { 8, 384 }, /* info for character 48 */ + { 8, 392 }, /* info for character 49 */ + { 8, 400 }, /* info for character 50 */ + { 8, 408 }, /* info for character 51 */ + { 8, 416 }, /* info for character 52 */ + { 8, 424 }, /* info for character 53 */ + { 8, 432 }, /* info for character 54 */ + { 8, 440 }, /* info for character 55 */ + { 8, 448 }, /* info for character 56 */ + { 8, 456 }, /* info for character 57 */ + { 8, 464 }, /* info for character 58 */ + { 8, 472 }, /* info for character 59 */ + { 8, 480 }, /* info for character 60 */ + { 8, 488 }, /* info for character 61 */ + { 8, 496 }, /* info for character 62 */ + { 8, 504 }, /* info for character 63 */ + { 8, 512 }, /* info for character 64 */ + { 8, 520 }, /* info for character 65 */ + { 8, 528 }, /* info for character 66 */ + { 8, 536 }, /* info for character 67 */ + { 8, 544 }, /* info for character 68 */ + { 8, 552 }, /* info for character 69 */ + { 8, 560 }, /* info for character 70 */ + { 8, 568 }, /* info for character 71 */ + { 8, 576 }, /* info for character 72 */ + { 8, 584 }, /* info for character 73 */ + { 8, 592 }, /* info for character 74 */ + { 8, 600 }, /* info for character 75 */ + { 8, 608 }, /* info for character 76 */ + { 8, 616 }, /* info for character 77 */ + { 8, 624 }, /* info for character 78 */ + { 8, 632 }, /* info for character 79 */ + { 8, 640 }, /* info for character 80 */ + { 8, 648 }, /* info for character 81 */ + { 8, 656 }, /* info for character 82 */ + { 8, 664 }, /* info for character 83 */ + { 8, 672 }, /* info for character 84 */ + { 8, 680 }, /* info for character 85 */ + { 8, 688 }, /* info for character 86 */ + { 8, 696 }, /* info for character 87 */ + { 8, 704 }, /* info for character 88 */ + { 8, 712 }, /* info for character 89 */ + { 8, 720 }, /* info for character 90 */ + { 8, 728 }, /* info for character 91 */ + { 8, 736 }, /* info for character 92 */ + { 8, 744 }, /* info for character 93 */ + { 8, 752 }, /* info for character 94 */ + { 8, 760 }, /* info for character 95 */ + { 8, 768 }, /* info for character 96 */ + { 8, 776 }, /* info for character 97 */ + { 8, 784 }, /* info for character 98 */ + { 8, 792 }, /* info for character 99 */ + { 8, 800 }, /* info for character 100 */ + { 8, 808 }, /* info for character 101 */ + { 8, 816 }, /* info for character 102 */ + { 8, 824 }, /* info for character 103 */ + { 8, 832 }, /* info for character 104 */ + { 8, 840 }, /* info for character 105 */ + { 8, 848 }, /* info for character 106 */ + { 8, 856 }, /* info for character 107 */ + { 8, 864 }, /* info for character 108 */ + { 8, 872 }, /* info for character 109 */ + { 8, 880 }, /* info for character 110 */ + { 8, 888 }, /* info for character 111 */ + { 8, 896 }, /* info for character 112 */ + { 8, 904 }, /* info for character 113 */ + { 8, 912 }, /* info for character 114 */ + { 8, 920 }, /* info for character 115 */ + { 8, 928 }, /* info for character 116 */ + { 8, 936 }, /* info for character 117 */ + { 8, 944 }, /* info for character 118 */ + { 8, 952 }, /* info for character 119 */ + { 8, 960 }, /* info for character 120 */ + { 8, 968 }, /* info for character 121 */ + { 8, 976 }, /* info for character 122 */ + { 8, 984 }, /* info for character 123 */ + { 8, 992 }, /* info for character 124 */ + { 8, 1000 }, /* info for character 125 */ + { 8, 1008 }, /* info for character 126 */ + { 8, 1016 }, /* info for character 127 */ + { 8, 1024 }, /* info for character 128 */ + { 8, 1032 }, /* info for character 129 */ + { 8, 1040 }, /* info for character 130 */ + { 8, 1048 }, /* info for character 131 */ + { 8, 1056 }, /* info for character 132 */ + { 8, 1064 }, /* info for character 133 */ + { 8, 1072 }, /* info for character 134 */ + { 8, 1080 }, /* info for character 135 */ + { 8, 1088 }, /* info for character 136 */ + { 8, 1096 }, /* info for character 137 */ + { 8, 1104 }, /* info for character 138 */ + { 8, 1112 }, /* info for character 139 */ + { 8, 1120 }, /* info for character 140 */ + { 8, 1128 }, /* info for character 141 */ + { 8, 1136 }, /* info for character 142 */ + { 8, 1144 }, /* info for character 143 */ + { 8, 1152 }, /* info for character 144 */ + { 8, 1160 }, /* info for character 145 */ + { 8, 1168 }, /* info for character 146 */ + { 8, 1176 }, /* info for character 147 */ + { 8, 1184 }, /* info for character 148 */ + { 8, 1192 }, /* info for character 149 */ + { 8, 1200 }, /* info for character 150 */ + { 8, 1208 }, /* info for character 151 */ + { 8, 1216 }, /* info for character 152 */ + { 8, 1224 }, /* info for character 153 */ + { 8, 1232 }, /* info for character 154 */ + { 8, 1240 }, /* info for character 155 */ + { 8, 1248 }, /* info for character 156 */ + { 8, 1256 }, /* info for character 157 */ + { 8, 1264 }, /* info for character 158 */ + { 8, 1272 }, /* info for character 159 */ + { 8, 1280 }, /* info for character 160 */ + { 8, 1288 }, /* info for character 161 */ + { 8, 1296 }, /* info for character 162 */ + { 8, 1304 }, /* info for character 163 */ + { 8, 1312 }, /* info for character 164 */ + { 8, 1320 }, /* info for character 165 */ + { 8, 1328 }, /* info for character 166 */ + { 8, 1336 }, /* info for character 167 */ + { 8, 1344 }, /* info for character 168 */ + { 8, 1352 }, /* info for character 169 */ + { 8, 1360 }, /* info for character 170 */ + { 8, 1368 }, /* info for character 171 */ + { 8, 1376 }, /* info for character 172 */ + { 8, 1384 }, /* info for character 173 */ + { 8, 1392 }, /* info for character 174 */ + { 8, 1400 }, /* info for character 175 */ + { 8, 1408 }, /* info for character 176 */ + { 8, 1416 }, /* info for character 177 */ + { 8, 1424 }, /* info for character 178 */ + { 8, 1432 }, /* info for character 179 */ + { 8, 1440 }, /* info for character 180 */ + { 8, 1448 }, /* info for character 181 */ + { 8, 1456 }, /* info for character 182 */ + { 8, 1464 }, /* info for character 183 */ + { 8, 1472 }, /* info for character 184 */ + { 8, 1480 }, /* info for character 185 */ + { 8, 1488 }, /* info for character 186 */ + { 8, 1496 }, /* info for character 187 */ + { 8, 1504 }, /* info for character 188 */ + { 8, 1512 }, /* info for character 189 */ + { 8, 1520 }, /* info for character 190 */ + { 8, 1528 }, /* info for character 191 */ + { 8, 1536 }, /* info for character 192 */ + { 8, 1544 }, /* info for character 193 */ + { 8, 1552 }, /* info for character 194 */ + { 8, 1560 }, /* info for character 195 */ + { 8, 1568 }, /* info for character 196 */ + { 8, 1576 }, /* info for character 197 */ + { 8, 1584 }, /* info for character 198 */ + { 8, 1592 }, /* info for character 199 */ + { 8, 1600 }, /* info for character 200 */ + { 8, 1608 }, /* info for character 201 */ + { 8, 1616 }, /* info for character 202 */ + { 8, 1624 }, /* info for character 203 */ + { 8, 1632 }, /* info for character 204 */ + { 8, 1640 }, /* info for character 205 */ + { 8, 1648 }, /* info for character 206 */ + { 8, 1656 }, /* info for character 207 */ + { 8, 1664 }, /* info for character 208 */ + { 8, 1672 }, /* info for character 209 */ + { 8, 1680 }, /* info for character 210 */ + { 8, 1688 }, /* info for character 211 */ + { 8, 1696 }, /* info for character 212 */ + { 8, 1704 }, /* info for character 213 */ + { 8, 1712 }, /* info for character 214 */ + { 8, 1720 }, /* info for character 215 */ + { 8, 1728 }, /* info for character 216 */ + { 8, 1736 }, /* info for character 217 */ + { 8, 1744 }, /* info for character 218 */ + { 8, 1752 }, /* info for character 219 */ + { 8, 1760 }, /* info for character 220 */ + { 8, 1768 }, /* info for character 221 */ + { 8, 1776 }, /* info for character 222 */ + { 8, 1784 }, /* info for character 223 */ + { 8, 1792 }, /* info for character 224 */ + { 8, 1800 }, /* info for character 225 */ + { 8, 1808 }, /* info for character 226 */ + { 8, 1816 }, /* info for character 227 */ + { 8, 1824 }, /* info for character 228 */ + { 8, 1832 }, /* info for character 229 */ + { 8, 1840 }, /* info for character 230 */ + { 8, 1848 }, /* info for character 231 */ + { 8, 1856 }, /* info for character 232 */ + { 8, 1864 }, /* info for character 233 */ + { 8, 1872 }, /* info for character 234 */ + { 8, 1880 }, /* info for character 235 */ + { 8, 1888 }, /* info for character 236 */ + { 8, 1896 }, /* info for character 237 */ + { 8, 1904 }, /* info for character 238 */ + { 8, 1912 }, /* info for character 239 */ + { 8, 1920 }, /* info for character 240 */ + { 8, 1928 }, /* info for character 241 */ + { 8, 1936 }, /* info for character 242 */ + { 8, 1944 }, /* info for character 243 */ + { 8, 1952 }, /* info for character 244 */ + { 8, 1960 }, /* info for character 245 */ + { 8, 1968 }, /* info for character 246 */ + { 8, 1976 }, /* info for character 247 */ + { 8, 1984 }, /* info for character 248 */ + { 8, 1992 }, /* info for character 249 */ + { 8, 2000 }, /* info for character 250 */ + { 8, 2008 }, /* info for character 251 */ + { 8, 2016 }, /* info for character 252 */ + { 8, 2024 }, /* info for character 253 */ + { 8, 2032 }, /* info for character 254 */ + { 8, 2040 } /* info for character 255 */ + } +}; diff --git a/thirdparty/grx249/src/gformats/ctx2jpg.c b/thirdparty/grx249/src/gformats/ctx2jpg.c new file mode 100644 index 0000000..c33d224 --- /dev/null +++ b/thirdparty/grx249/src/gformats/ctx2jpg.c @@ -0,0 +1,183 @@ +/** + ** ctx2jpg.c ---- saves a context to a JPEG file + ** + ** Copyright (C) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include +#include +#include "grx20.h" + +static int writejpeg( FILE *f, GrContext *grc, int quality, int grayscale ); + +/* +** GrSaveContextToJpeg - Dump a context in a JPEG file +** +** This routine works both in RGB and palette modes +** +** Arguments: +** grc: Context to be saved (NULL -> use current context) +** jpegfn: Name of jpeg file +** quality: quality scaling (1 to 100) the normal value is 75 +** +** Returns 0 on success +** -1 on error +*/ + +int GrSaveContextToJpeg( GrContext *grc, char *jpegfn, int quality ) +{ + GrContext grcaux; + FILE *f; + int r; + + f = fopen( jpegfn,"wb" ); + if( f == NULL ) return -1; + + GrSaveContext( &grcaux ); + if( grc != NULL ) GrSetContext( grc ); + r = writejpeg( f,grc,quality,0 ); + GrSetContext( &grcaux ); + + fclose( f ); + + return r; +} + +/* +** GrSaveContextToGrayJpeg - Dump a context in a Gray JPEG file +** +** This routine works both in RGB and palette modes +** +** Arguments: +** grc: Context to be saved (NULL -> use current context) +** jpegfn: Name of jpeg file +** quality: quality scaling (1 to 100) the normal value is 75 +** +** Returns 0 on success +** -1 on error +*/ + +int GrSaveContextToGrayJpeg( GrContext *grc, char *jpegfn, int quality ) +{ + GrContext grcaux; + FILE *f; + int r; + + f = fopen( jpegfn,"wb" ); + if( f == NULL ) return -1; + + GrSaveContext( &grcaux ); + if( grc != NULL ) GrSetContext( grc ); + r = writejpeg( f,grc,quality,1 ); + GrSetContext( &grcaux ); + + fclose( f ); + + return r; +} + +/**/ +/**/ + +struct my_error_mgr{ + struct jpeg_error_mgr pub; + jmp_buf setjmp_buffer; + }; + +typedef struct my_error_mgr *my_error_ptr; + +/**/ + +METHODDEF(void) my_error_exit( j_common_ptr cinfo ) +{ + my_error_ptr myerr = (my_error_ptr) cinfo->err; + + /*(*cinfo->err_>output_message)( cinfo );*/ + + longjmp( myerr->setjmp_buffer,1 ); +} + +/**/ + +static int writejpeg( FILE *f, GrContext *grc, int quality, int grayscale ) +{ + struct jpeg_compress_struct cinfo; + struct my_error_mgr jerr; + JSAMPROW row_pointer[1]; + static unsigned char *buffer = NULL; + unsigned char *pix_ptr; + const GrColor *pColors; + int row_stride; + int x, y, r, g, b; + + cinfo.err = jpeg_std_error( &jerr.pub ); + jerr.pub.error_exit = my_error_exit; + if( setjmp( jerr.setjmp_buffer ) ) { + if( buffer ) free( buffer ); + jpeg_destroy_compress( &cinfo ); + return -1; + } + + jpeg_create_compress( &cinfo ); + jpeg_stdio_dest( &cinfo,f ); + + cinfo.image_width = GrSizeX(); + cinfo.image_height = GrSizeY(); + if( grayscale ){ + cinfo.input_components = 1; + cinfo.in_color_space = JCS_GRAYSCALE; + } + else{ + cinfo.input_components = 3; + cinfo.in_color_space = JCS_RGB; + } + + jpeg_set_defaults( &cinfo ); + jpeg_set_quality( &cinfo,quality,TRUE ); + + jpeg_start_compress( &cinfo, TRUE ); + + row_stride = cinfo.image_width * 3; + buffer = malloc( row_stride ); + if( buffer == NULL ) longjmp( jerr.setjmp_buffer,1 ); + row_pointer[0] = buffer; + + for( y=0; y +#include +#include +#include "grx20.h" + +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#endif + +static int writepng( FILE *f, GrContext *grc ); + +/* +** GrSaveContextToPng - Dump a context in a PNG file +** +** This routine works both in RGB and palette modes +** +** Arguments: +** grc: Context to be saved (NULL -> use current context) +** pngfn: Name of png file +** +** Returns 0 on success +** -1 on error +*/ + +int GrSaveContextToPng( GrContext *grc, char *pngfn ) +{ + GrContext grcaux; + FILE *f; + int r; + + f = fopen( pngfn,"wb" ); + if( f == NULL ) return -1; + + GrSaveContext( &grcaux ); + if( grc != NULL ) GrSetContext( grc ); + r = writepng( f,grc ); + GrSetContext( &grcaux ); + + fclose( f ); + + return r; +} + +/**/ + +static int writepng( FILE *f, GrContext *grc ) +{ + png_structp png_ptr; + png_infop info_ptr; + png_uint_32 height; + png_uint_32 width; + png_byte *png_pixels = NULL; + png_byte **row_pointers = NULL; + png_byte *pix_ptr = NULL; + int x, y, r, g, b; + GrColor *pColors = NULL; + + /* Create and initialize the png_struct */ + png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL ); + if( png_ptr == NULL ) + return -1; + + /* Allocate/initialize the image information data */ + info_ptr = png_create_info_struct( png_ptr ); + if( info_ptr == NULL ){ + png_destroy_write_struct( &png_ptr,(png_infopp)NULL ); + return -1; + } + + /* Set error handling */ + if( setjmp( png_jmpbuf(png_ptr) ) ){ + /* If we get here, we had a problem reading the file */ + png_destroy_write_struct( &png_ptr,&info_ptr ); + return -1; + } + + /* set up the output control we are using standard C streams */ + png_init_io( png_ptr,f ); + + /* Set the image information */ + width = GrSizeX(); + height = GrSizeY(); + png_set_IHDR( png_ptr,info_ptr,width,height,8,PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE,PNG_COMPRESSION_TYPE_BASE, + PNG_FILTER_TYPE_BASE ); + + /* No gamma correction by now */ + /* png_set_gAMA(png_ptr, info_ptr, gamma); */ + + /* No comments by now */ + /* text_ptr[0].key = "Title"; + text_ptr[0].text = "Mona Lisa"; + text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr[1].key = "Author"; + text_ptr[1].text = "Leonardo DaVinci"; + text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr[2].key = "Description"; + text_ptr[2].text = ""; + text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; + png_set_text(png_ptr, info_ptr, text_ptr, 3); */ + + /* Write the file header information */ + png_write_info( png_ptr,info_ptr ); + + png_pixels = (png_byte *) malloc( width * 3 * sizeof(png_byte) ); + if( png_pixels == NULL ){ + png_destroy_write_struct( &png_ptr,&info_ptr ); + return -1; + } + + row_pointers = (png_byte **) malloc( 1 * sizeof(png_bytep) ); + if( row_pointers == NULL ){ + png_destroy_write_struct( &png_ptr,&info_ptr ); + free( png_pixels ); + return -1; + } + + pColors = malloc( width * sizeof(GrColor) ); + if( pColors == NULL ){ + png_destroy_write_struct( &png_ptr,&info_ptr ); + free( row_pointers ); + free( png_pixels ); + return -1; + } + + row_pointers[0] = png_pixels; + + for( y=0; y +#include +#include +#include "grx20.h" + +/* +** GrSaveContextToPbm - Dump a context in a PBM file (bitmap) +** +** This routine works both in RGB and palette modes +** If the pixel color isn't Black it asumes White +** +** Arguments: +** ctx: Context to be saved (NULL -> use current context) +** pbmfn: Name of pbm file +** docn: string saved like a comment in the pbm file (can be NULL) +** +** Returns 0 on success +** -1 on error +*/ + +int GrSaveContextToPbm( GrContext *grc, char *pbmfn, char *docn ) +{ + FILE *f; + GrContext grcaux; + char cab[81]; + int currentbyte = 0, currentbit = 7; + int x, y; + + if( (f = fopen( pbmfn,"wb" )) == NULL ) return -1; + + GrSaveContext( &grcaux ); + if( grc != NULL ) GrSetContext( grc ); + sprintf( cab,"P4\n#" ); + fwrite( cab,1,strlen( cab ),f ); + if( docn != NULL ) fwrite( docn,1,strlen( docn ), f ); + sprintf( cab,"\n%d %d\n",GrSizeX(),GrSizeY() ); + fwrite( cab,1,strlen( cab ),f ); + for( y=0; y use current context) +** pgmfn: Name of pgm file +** docn: string saved like a comment in the pgm file (can be NULL) +** +** Returns 0 on success +** -1 on error +*/ + +int GrSaveContextToPgm( GrContext *grc, char *pgmfn, char *docn ) +{ + FILE *f; + GrContext grcaux; + char cab[81]; + unsigned char grey; + int rgb[3]; + int x, y; + + if( (f = fopen( pgmfn,"wb" )) == NULL ) return -1; + + GrSaveContext( &grcaux ); + if( grc != NULL ) GrSetContext( grc ); + sprintf( cab,"P5\n#" ); + fwrite( cab,1,strlen( cab ),f ); + if( docn != NULL ) fwrite( docn,1,strlen( docn ), f ); + sprintf( cab,"\n%d %d\n255\n",GrSizeX(),GrSizeY() ); + fwrite( cab,1,strlen( cab ),f ); + for( y=0; y use current context) +** ppmfn: Name of ppm file +** docn: string saved like a comment in the ppm file (can be NULL) +** +** Returns 0 on success +** -1 on error +*/ + +int GrSaveContextToPpm( GrContext *grc, char *ppmfn, char *docn ) +{ + FILE *f; + GrContext grcaux; + char cab[81]; + unsigned char brgb[3]; + int x, y, r, g, b; + + if( (f = fopen( ppmfn,"wb" )) == NULL ) return -1; + + GrSaveContext( &grcaux ); + if( grc != NULL ) GrSetContext( grc ); + sprintf( cab,"P6\n#" ); + fwrite( cab,1,strlen( cab ),f ); + if( docn != NULL ) fwrite( docn,1,strlen( docn ), f ); + sprintf( cab,"\n%d %d\n255\n",GrSizeX(),GrSizeY() ); + fwrite( cab,1,strlen( cab ),f ); + for( y=0; y +#include +#include "grx20.h" + +/* +** GrJpegSupport - Returns false +*/ + +int GrJpegSupport( void ) +{ + return 0; +} + +/* +** GrSaveContextToJpeg - Returns error +*/ + +int GrSaveContextToJpeg( GrContext *grc, char *jpegfn, int quality ) +{ + return -1; +} + +/* +** GrSaveContextToGrayJpeg - Returns error +*/ + +int GrSaveContextToGrayJpeg( GrContext *grc, char *jpegfn, int quality ) +{ + return -1; +} + +/* +** GrLoadContextFromJpeg - Returns error +*/ + +int GrLoadContextFromJpeg( GrContext *grc, char *jpegfn, int scale ) +{ + return -1; +} + +/* +** GrQueryJpeg - Returns error +*/ + +int GrQueryJpeg( char *jpegfn, int *width, int *height ) +{ + return -1; +} diff --git a/thirdparty/grx249/src/gformats/dummypng.c b/thirdparty/grx249/src/gformats/dummypng.c new file mode 100644 index 0000000..071b628 --- /dev/null +++ b/thirdparty/grx249/src/gformats/dummypng.c @@ -0,0 +1,57 @@ +/** + ** dummypng.c ---- dummy png funtions if not PNG support in the library + ** + ** Copyright (C) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include "grx20.h" + +/* +** GrPngSupport - Returns false +*/ + +int GrPngSupport( void ) +{ + return 0; +} + +/* +** GrSaveContextToPng - Returns error +*/ + +int GrSaveContextToPng( GrContext *grc, char *pngfn ) +{ + return -1; +} + +/* +** GrLoadContextFromPng - Returns error +*/ + +int GrLoadContextFromPng( GrContext *grc, char *pngfn, int use_alpha ) +{ + return -1; +} + +/* +** GrQueryPnm - Returns error +*/ + +int GrQueryPng( char *pngfn, int *width, int *height ) +{ + return -1; +} diff --git a/thirdparty/grx249/src/gformats/jpg2ctx.c b/thirdparty/grx249/src/gformats/jpg2ctx.c new file mode 100644 index 0000000..cfba554 --- /dev/null +++ b/thirdparty/grx249/src/gformats/jpg2ctx.c @@ -0,0 +1,214 @@ +/** + ** jpg2ctx.c ---- loads a context from a JPEG file + ** + ** Copyright (C) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include +#include +#include "grx20.h" + +/* +** GrJpegSupport - Returns true +*/ + +int GrJpegSupport( void ) +{ + return 1; +} + +static int readjpeg( FILE *f, GrContext *grc, int scale ); +static int queryjpeg( FILE *f, int *w, int *h ); + +/* +** GrLoadContextFromJpeg - Load a context from a JPEG file +** +** If context dimensions are lesser than jpeg dimensions, +** the routine loads as much as it can +** +** If color mode is not in RGB mode, the routine allocates as +** much colors as it can +** +** Arguments: +** grc: Context to be loaded (NULL -> use current context) +** jpegfn: Name of jpeg file +** scale: scale the image to 1/scale, actually libjpeg support +** 1, 2, 4 and 8 noly +** +** Returns 0 on success +** -1 on error +*/ + +int GrLoadContextFromJpeg( GrContext *grc, char *jpegfn, int scale ) +{ + GrContext grcaux; + FILE *f; + int r; + + f = fopen( jpegfn,"rb" ); + if( f == NULL ) return -1; + + GrSaveContext( &grcaux ); + if( grc != NULL ) GrSetContext( grc ); + r = readjpeg( f,grc,scale ); + GrSetContext( &grcaux ); + + fclose( f ); + + return r; +} + +/* +** GrQueryJpeg - Query width and height data from a JPEG file +** +** Arguments: +** jpegfn: Name of jpeg file +** width: return pnm width +** height: return pnm height +** +** Returns 0 on success +** -1 on error +*/ + +int GrQueryJpeg( char *jpegfn, int *width, int *height ) +{ + FILE *f; + int r; + + f = fopen( jpegfn,"rb" ); + if( f == NULL ) return -1; + + r = queryjpeg( f,width,height ); + + fclose( f ); + + return r; +} + +/**/ + +struct my_error_mgr{ + struct jpeg_error_mgr pub; + jmp_buf setjmp_buffer; + }; + +typedef struct my_error_mgr *my_error_ptr; + +/**/ + +METHODDEF(void) my_error_exit( j_common_ptr cinfo ) +{ + my_error_ptr myerr = (my_error_ptr) cinfo->err; + + /*(*cinfo->err_>output_message)( cinfo );*/ + + longjmp( myerr->setjmp_buffer,1 ); +} + +/**/ + +static int readjpeg( FILE *f, GrContext *grc, int scale ) +{ + struct jpeg_decompress_struct cinfo; + struct my_error_mgr jerr; + JSAMPARRAY buffer; + int row_stride; + int maxwidth, maxheight; + static GrColor *pColors = NULL; + unsigned char *pix_ptr; + int x, y, r, g, b; + + cinfo.err = jpeg_std_error( &jerr.pub ); + jerr.pub.error_exit = my_error_exit; + if( setjmp( jerr.setjmp_buffer ) ) { + if( pColors) free( pColors ); + jpeg_destroy_decompress( &cinfo ); + return -1; + } + + jpeg_create_decompress( &cinfo ); + jpeg_stdio_src( &cinfo,f ); + jpeg_read_header( &cinfo,TRUE ); + + cinfo.scale_denom = scale; + + jpeg_start_decompress( &cinfo ); + + row_stride = cinfo.output_width * cinfo.output_components; + + buffer = (*cinfo.mem->alloc_sarray) + ( (j_common_ptr)&cinfo,JPOOL_IMAGE,row_stride,1 ); + + maxwidth = (cinfo.output_width > GrSizeX()) ? + GrSizeX() : cinfo.output_width; + maxheight = (cinfo.output_height > GrSizeY()) ? + GrSizeY() : cinfo.output_height; + pColors = malloc( maxwidth * sizeof(GrColor) ); + if( pColors == NULL ) longjmp( jerr.setjmp_buffer,1 ); + + for( y=0; y +#include +#include +#include "grx20.h" + +/* +** GrPngSupport - Returns true +*/ + +int GrPngSupport( void ) +{ + return 1; +} + +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#endif + +static int readpng( FILE *f, GrContext *grc, int use_alpha ); +static int querypng( FILE *f, int *w, int *h ); + +/* +** GrLoadContextFromPng - Load a context from a PNG file +** +** If context dimensions are lesser than png dimensions, +** the routine loads as much as it can +** +** If color mode is not in RGB mode, the routine allocates as +** much colors as it can +** +** Arguments: +** grc: Context to be loaded (NULL -> use current context) +** pngfn: Name of pnm file +** use_alpha: if true, use alpha channel if available +** +** Returns 0 on success +** -1 on error +*/ + +int GrLoadContextFromPng( GrContext *grc, char *pngfn, int use_alpha ) +{ + GrContext grcaux; + FILE *f; + int r; + + f = fopen( pngfn,"rb" ); + if( f == NULL ) return -1; + + GrSaveContext( &grcaux ); + if( grc != NULL ) GrSetContext( grc ); + r = readpng( f,grc,use_alpha ); + GrSetContext( &grcaux ); + + fclose( f ); + + return r; +} + +/* +** GrQueryPnm - Query width and height data from a PNG file +** +** Arguments: +** pngfn: Name of png file +** width: return pnm width +** height: return pnm height +** +** Returns 0 on success +** -1 on error +*/ + +int GrQueryPng( char *pngfn, int *width, int *height ) +{ + FILE *f; + int r; + + f = fopen( pngfn,"rb" ); + if( f == NULL ) return -1; + + r = querypng( f,width,height ); + + fclose( f ); + + return r; +} + +/**/ + +static int readpng( FILE *f, GrContext *grc, int use_alpha ) +{ + png_struct *png_ptr = NULL; + png_info *info_ptr = NULL; + png_byte buf[8]; + png_byte *png_pixels = NULL; + png_byte **row_pointers = NULL; + png_byte *pix_ptr = NULL; + png_uint_32 row_bytes; + png_uint_32 width; + png_uint_32 height; + int bit_depth; + int color_type; + int alpha_present; + int i, x, y, r, g, b; + int alpha = 0, ro, go, bo; + int maxwidth, maxheight; + GrColor *pColors = NULL; + + /* is it a PNG file? */ + if( fread( buf,1,8,f ) != 8 ) return -1; + if( ! png_check_sig( buf,8 ) ) return -1; + + png_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL); + if( !png_ptr ){ + return -1; + } + + info_ptr = png_create_info_struct( png_ptr ); + if( !info_ptr ){ + png_destroy_read_struct( &png_ptr,NULL,NULL ); + return -1; + } + + if( setjmp( png_jmpbuf(png_ptr) ) ){ + png_destroy_read_struct( &png_ptr,&info_ptr,NULL ); + return -1; + } + + png_init_io( png_ptr,f ); + png_set_sig_bytes( png_ptr,8 ); + png_read_info( png_ptr,info_ptr ); + + png_get_IHDR( png_ptr,info_ptr,&width,&height,&bit_depth, + &color_type,NULL,NULL,NULL); + + /* tell libpng to strip 16 bit/color files down to 8 bits/color */ + if( bit_depth == 16 ) + png_set_strip_16( png_ptr ); + /* expand paletted colors into true RGB triplets */ + if( color_type == PNG_COLOR_TYPE_PALETTE ) + png_set_expand( png_ptr ); + /* expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ + if( color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8 ) + png_set_expand( png_ptr ); + /* expand paletted or RGB images with transparency to full alpha channels + so the data will be available as RGBA quartets. */ + if( png_get_valid( png_ptr,info_ptr,PNG_INFO_tRNS ) ) + png_set_expand( png_ptr ); + /* transform grayscale images into rgb */ + if( color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA ) + png_set_gray_to_rgb( png_ptr ); + + /* we don't do gamma correction by now */ + + png_read_update_info( png_ptr,info_ptr ); + png_get_IHDR( png_ptr,info_ptr,&width,&height,&bit_depth, + &color_type,NULL,NULL,NULL); + + if( color_type == PNG_COLOR_TYPE_RGB ) + alpha_present = 0; + else if( color_type == PNG_COLOR_TYPE_RGB_ALPHA ) + alpha_present = 1; + else{ + png_destroy_read_struct( &png_ptr,&info_ptr,NULL ); + return -1; + } + + row_bytes = png_get_rowbytes( png_ptr,info_ptr ); + + png_pixels = (png_byte *) malloc( row_bytes * height * sizeof(png_byte) ); + if( png_pixels == NULL ){ + png_destroy_read_struct( &png_ptr,&info_ptr,NULL ); + return -1; + } + + row_pointers = (png_byte **) malloc( height * sizeof(png_bytep) ); + if( row_pointers == NULL ){ + png_destroy_read_struct( &png_ptr,&info_ptr,NULL ); + free( png_pixels ); + png_pixels = NULL; + return -1; + } + + for( i=0; i GrSizeX()) ? GrSizeX() : width; + maxheight = (height > GrSizeY()) ? GrSizeY() : height; + + pColors = malloc( maxwidth * sizeof(GrColor) ); + if( pColors == NULL ){ + free( row_pointers ); + row_pointers = NULL; + free( png_pixels ); + png_pixels = NULL; + return -1; + } + + for( y=0; y +#include +#include +#include "grx20.h" + +typedef struct{ + int method; /* 0=file, 1=buffer */ + FILE *file; + const char *buffer; + int bufferpointer; + } inputstruct; + +/**/ + +static size_t inputread( void *buffer, size_t size, size_t number, + inputstruct *is ) +{ + if( is->method == 0 ) + return fread( buffer,size,number,is->file ); + else{ + memcpy( buffer,&(is->buffer[is->bufferpointer]),size*number ); + is->bufferpointer += size * number; + return number; + } +} + +/**/ + +static int inputgetc( inputstruct *is ) +{ + if( is->method == 0 ) + return fgetc( is->file ); + else + return is->buffer[is->bufferpointer++]; +} + +/**/ + +int inputungetc( int c, inputstruct *is ) +{ + if( is->method == 0 ) + return ungetc( c,is->file ); + else{ + is->bufferpointer--; + return c; + } +} + +/**/ + +static int skipspaces( inputstruct *is ) +{ + int c; + + while( 1 ){ + if( (c = inputgetc( is )) == EOF ) return -1; + if( c == '#' ) // it's a comment + while( 1 ){ + if( (c = inputgetc( is )) == EOF ) return -1; + if( c == '\n' ) break; + } + if( c != ' ' && c != '\t' && c != '\n' && c != '\r' ){ + inputungetc( c,is ); + return 0; + } + } +} + +/**/ + +static int readnumber( inputstruct *is ) +{ + char buf[81]; + int count; + + count = 0; + while( 1 ){ + if( (buf[count] = inputgetc( is )) == EOF ) return -1; + if( buf[count] == ' ' || buf[count] == '\t' || buf[count] == '\n' ){ + inputungetc( buf[count],is ); + break; + } + if( count > 80 ) break; + count++; + } + buf[count] = '\0'; + return atoi( buf ); +} + +/**/ + +static int loaddata( inputstruct *is, int *width, int *height, int *maxval ) +{ + unsigned char buf[10]; + int r; + + if( inputread( buf,1,2,is ) != 2 ) return -1; + if( buf[0] != 'P' ) return -1; + r = buf[1] - '0'; + if( (r < PLAINPBMFORMAT) || (r > PPMFORMAT) ) return -1; + if( skipspaces( is ) != 0 ) return -1; + if( (*width = readnumber( is )) < 0 ) return -1; + if( skipspaces( is ) != 0 ) return -1; + if( (*height = readnumber( is )) < 0 ) return -1; + if( (r == PLAINPBMFORMAT) || (r == PBMFORMAT) ) + *maxval = 1; + else{ + if( skipspaces( is ) != 0 ) return -1; + if( (*maxval = readnumber( is )) < 0 ) return -1; + } + inputgetc( is ); // skip \n + return r; +} + +/**/ + +static int _GrLoadContextFromPbm( inputstruct *is, int width, int height ) +{ + int x, y; + int maxwidth, maxheight; + GrColor color; + int currentbyte, isbyteread = 0; + int currentbit = 0; + GrColor *pColors=NULL; + int res = 0; + + maxwidth = (width > GrSizeX()) ? GrSizeX() : width; + maxheight = (height > GrSizeY()) ? GrSizeY() : height; + + pColors = malloc( maxwidth * sizeof(GrColor) ); + if(pColors == NULL) { res = -1; goto salida; } + + for( y=0; y GrSizeX()) ? GrSizeX() : width; + maxheight = (height > GrSizeY()) ? GrSizeY() : height; + + if( maxval < 255 ){ + needcoloradjust = 1; + coloradjust = 255.0 / maxval; + } + + pData = NULL; + pColors = malloc( maxwidth * sizeof(GrColor) ); + if(pColors == NULL) { res = -1; goto salida; } + pData = malloc( width * sizeof(char) ); + if(pData == NULL) { res = -1; goto salida; } + + for( y=0; y GrSizeX()) ? GrSizeX() : width; + maxheight = (height > GrSizeY()) ? GrSizeY() : height; + + if( maxval < 255 ){ + needcoloradjust = 1; + coloradjust = 255.0 / maxval; + } + + pRGB = NULL; + pColors = malloc( maxwidth * sizeof(GrColor) ); + if(pColors == NULL) { res = -1; goto salida; } + pRGB = malloc( width * 3 * sizeof(char) ); + if(pRGB == NULL) { res = -1; goto salida; } + + for( y=0; y use current context) +** pnmfn: Name of pnm file +** +** Returns 0 on success +** -1 on error +*/ + +int GrLoadContextFromPnm( GrContext *grc, char *pnmfn ) +{ + inputstruct is = {0, NULL, NULL, 0}; + GrContext grcaux; + int r = -1; + int format, width, height, maxval; + + if( (is.file = fopen( pnmfn,"rb" )) == NULL ) return -1; + + GrSaveContext( &grcaux ); + if( grc != NULL ) GrSetContext( grc ); + + format = loaddata( &is,&width,&height,&maxval ); + if( maxval > 255 ) goto ENDFUNCTION; + if( (format < PBMFORMAT) || (format > PPMFORMAT) ) goto ENDFUNCTION; + + switch( format ){ + case PBMFORMAT: r = _GrLoadContextFromPbm( &is,width,height ); + break; + case PGMFORMAT: r = _GrLoadContextFromPgm( &is,width,height,maxval ); + break; + case PPMFORMAT: r = _GrLoadContextFromPpm( &is,width,height,maxval ); + break; + } + +ENDFUNCTION: + GrSetContext( &grcaux ); + fclose( is.file ); + + return r; +} + +/* +** GrQueryPnm - Query format, width and height data from a PNM file +** +** Arguments: +** pnmfn: Name of pnm file +** width: return pnm width +** height: return pnm height +** maxval: max color component value +** +** Returns 1 to 6 on success (PNM FORMAT) +** -1 on error +*/ + +int GrQueryPnm( char *pnmfn, int *width, int *height, int *maxval ) +{ + inputstruct is = {0, NULL, NULL, 0}; + int r; + + if( (is.file = fopen( pnmfn,"rb" )) == NULL ) return -1; + + r = loaddata( &is,width,height,maxval ); + + fclose( is.file ); + + return r; +} + +/* +** GrLoadContextFromPnmBuffer - Load a context from a PNM buffer +** +** Support only PBM, PGM and PPM binary buffers with maxval < 256 +** +** If context dimensions are lesser than pnm dimensions, +** the routine loads as much as it can +** +** If color mode is not in RGB mode, the routine allocates as +** much colors as it can +** +** Arguments: +** ctx: Context to be loaded (NULL -> use current context) +** pnmbuf: Buffer that holds data +** +** Returns 0 on success +** -1 on error +*/ + +int GrLoadContextFromPnmBuffer( GrContext *grc, const char *pnmbuf ) +{ + inputstruct is = {1, NULL, NULL, 0}; + GrContext grcaux; + int r = -1; + int format, width, height, maxval; + + is.buffer = pnmbuf; + + GrSaveContext( &grcaux ); + if( grc != NULL ) GrSetContext( grc ); + + format = loaddata( &is,&width,&height,&maxval ); + if( maxval > 255 ) goto ENDFUNCTION; + if( (format < PBMFORMAT) || (format > PPMFORMAT) ) goto ENDFUNCTION; + + switch( format ){ + case PBMFORMAT: r = _GrLoadContextFromPbm( &is,width,height ); + break; + case PGMFORMAT: r = _GrLoadContextFromPgm( &is,width,height,maxval ); + break; + case PPMFORMAT: r = _GrLoadContextFromPpm( &is,width,height,maxval ); + break; + } + +ENDFUNCTION: + GrSetContext( &grcaux ); + + return r; +} + +/* +** GrQueryPnmBuffer - Query format, width and height data from a PNM buffer +** +** Arguments: +** pnmbuf: Buffer that holds data +** width: return pnm width +** height: return pnm height +** maxval: max color component value +** +** Returns 1 to 6 on success (PNM FORMAT) +** -1 on error +*/ + +int GrQueryPnmBuffer( const char *pnmbuf, int *width, int *height, int *maxval ) +{ + inputstruct is = {1, NULL, NULL, 0}; + int r; + + is.buffer = pnmbuf; + + r = loaddata( &is,width,height,maxval ); + + return r; +} + diff --git a/thirdparty/grx249/src/image/ialloc.c b/thirdparty/grx249/src/image/ialloc.c new file mode 100644 index 0000000..c633c0b --- /dev/null +++ b/thirdparty/grx249/src/image/ialloc.c @@ -0,0 +1,57 @@ +/** + ** ialloc.c ---- Source Image Utility + ** + ** by Michal Stencl Copyright (c) 1998 + ** - [stenclpmd@ba.telecom.sk] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** modifications by Hartmut Schirmer Copyright (c) 1998 + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "image/image.h" + +int _GrImageTestSize(int wdt,int hgt) +{ + long total; + GRX_ENTER(); + total = GrContextSize(wdt,hgt); +# ifdef _MAXMEMPLANESIZE + if ( total > _MAXMEMPLANESIZE ) total = 0L; +# endif + GRX_RETURN(total); +} + +GrImage *_GrImageAllocate(GrContext *ctx, int nwidth,int nheight) +{ + GrImage *img; + + GRX_ENTER(); + img = NULL; + if ( _GrImageTestSize(nwidth, nheight) <= 0 ) goto done; + if (!GrCreateContext(nwidth, nheight, NULL, ctx)) goto done; + img = (GrImage *)malloc(sizeof(GrImage)); + if ( !img ) { + GrDestroyContext(ctx); + goto done; + } + img->pxp_ispixmap = 1; + img->pxp_width = nwidth; + img->pxp_height = nheight; + img->pxp_oper = 0; + img->pxp_source = ctx->gc_frame; + img->pxp_source.gf_memflags = 3;/* MY_CONTEXT & MY_MEMORY */ +done: + GRX_RETURN(img); +} diff --git a/thirdparty/grx249/src/image/ibuild.c b/thirdparty/grx249/src/image/ibuild.c new file mode 100644 index 0000000..81b5ce8 --- /dev/null +++ b/thirdparty/grx249/src/image/ibuild.c @@ -0,0 +1,51 @@ +/** + ** ibuild.c ---- Source Image Utility + ** + ** by Michal Stencl Copyright (c) 1998 + ** - [stenclpmd@ba.telecom.sk] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** modifications by Hartmut Schirmer (c) 1998 + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "mempeek.h" +#include "image/image.h" + +GrImage *GrImageBuild(const char *pixels,int w,int h,const GrColorTableP colors) +{ + GrImage *img; + GRX_ENTER(); + img = NULL; + if ( pixels ) do { + GrContext ctx, save; + GrColor col; + int yy=0, xx; + img = _GrImageAllocate(&ctx,w,h); + if ( !img ) break; + save = *CURC; + *CURC = ctx; + do { + xx = 0; + do { + col = peek_b(pixels); + ptrinc(pixels,1); + if ( colors ) col = GR_CTABLE_COLOR(colors,col); + (*CURC->gc_driver->drawpixel)(xx, yy, (col & C_COLOR)); + } while(++xx < w); + } while(++yy < h); + *CURC = save; + } while(0); + GRX_RETURN(img); +} diff --git a/thirdparty/grx249/src/image/ifbox.c b/thirdparty/grx249/src/image/ifbox.c new file mode 100644 index 0000000..a39690e --- /dev/null +++ b/thirdparty/grx249/src/image/ifbox.c @@ -0,0 +1,77 @@ +/** + ** ifbox.c ---- Source Image Utility + ** + ** by Michal Stencl Copyright (c) 1998 + ** - [stenclpmd@ba.telecom.sk] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** modifications by Hartmut Schirmer (c) 1998 + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "image/image.h" + +void GrImageFilledBoxAlign(int xo,int yo,int x1,int y1,int x2,int y2,GrImage *p) +{ + int iwdt, ihgt, xoff, yoff, yy, xx, copyh, copyw; + void (*bltfun)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor); + xo = min(xo, min(x1,x2)); + yo = min(yo, min(y1,y2)); + clip_box(CURC,x1,y1,x2,y2); + iwdt = p->pxp_width; + ihgt = p->pxp_height; + if ( (y2-y1) <= 0 || (x2-x1) <= 0 || iwdt <= 0 || ihgt <= 0) return; + if (CURC->gc_onscreen) bltfun = CURC->gc_driver->bltr2v; + else bltfun = CURC->gc_driver->bitblt; + while (xo > x1) xo -= iwdt; + while (yo > y1) yo -= ihgt; + yoff = (y1-yo)%ihgt; + yy = y1; + mouse_block(CURC,x1,y1,x2,y2); + x2++; + y2++; + do { + xx = x1; + copyh = min(y2-yy,ihgt-yoff); + xoff = (x1-xo)%iwdt; + do { + copyw = min(x2-xx,iwdt-xoff); + (*bltfun)( &CURC->gc_frame, xx + CURC->gc_xoffset, yy + CURC->gc_yoffset, + &p->pxp_source,xoff,yoff,copyw,copyh, + p->pxp_oper + ); + xx += iwdt-xoff; + xoff = 0; + } while ( xx < x2 ); + yy += ihgt-yoff; + yoff = 0; + } while ( yy < y2 ); + mouse_unblock(); +} + +void GrImageDisplay(int x,int y,GrImage *p) +{ + GRX_ENTER(); + GrImageFilledBoxAlign(x,y,x,y,x+p->pxp_width-1,y+p->pxp_height-1,p); + GRX_LEAVE(); +} + +void GrImageDisplayExt(int x1,int y1,int x2,int y2,GrImage* p) +{ + GRX_ENTER(); + GrImageFilledBoxAlign(x1,y1,x1,y1,x2,y2,p); + GRX_LEAVE(); +} + + diff --git a/thirdparty/grx249/src/image/ihline.c b/thirdparty/grx249/src/image/ihline.c new file mode 100644 index 0000000..f0bdd85 --- /dev/null +++ b/thirdparty/grx249/src/image/ihline.c @@ -0,0 +1,56 @@ +/** + ** ihline.c ---- Source Image Utility + ** + ** by Michal Stencl Copyright (c) 1998 + ** - [stenclpmd@ba.telecom.sk] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** modifications by Hartmut Schirmer (c) 1998 + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "image/image.h" + +void GrImageHLineAlign(int xo,int yo,int x,int y,int width,GrImage *p) +{ + int x2, widthimg, yimg, ximg, xdest, ydest, cpysize; + GrColor optype; + void (*bltfun)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor); + x2 = x+width; + xo = min(xo, min(x,x2)); + yo = min(yo, y); + clip_hline(CURC,x,x2,y); + width = x2 - x; + mouse_block(CURC,x,y,x2,y); + widthimg = p->pxp_width; + yimg = (y - yo) % p->pxp_height; + ximg = (x - xo) % widthimg; + xdest = x + CURC->gc_xoffset; + ydest = y + CURC->gc_yoffset; + cpysize = widthimg - ximg; + optype = p->pxp_oper; + if (CURC->gc_onscreen) bltfun = CURC->gc_driver->bltr2v; + else bltfun = CURC->gc_driver->bitblt; + while ( width > 0 ) { + if ( cpysize > width ) cpysize = width; + (*bltfun)(&CURC->gc_frame,xdest,ydest, + &p->pxp_source,ximg,yimg,cpysize,1, + optype); + width -= cpysize; + ximg = 0; + xdest += cpysize; + cpysize = widthimg; + }; + mouse_unblock(); +} diff --git a/thirdparty/grx249/src/image/iinverse.c b/thirdparty/grx249/src/image/iinverse.c new file mode 100644 index 0000000..a9ead77 --- /dev/null +++ b/thirdparty/grx249/src/image/iinverse.c @@ -0,0 +1,58 @@ +/** + ** iinverse.c ---- Source Image Utility + ** + ** by Michal Stencl Copyright (c) 1998 + ** - [stenclpmd@ba.telecom.sk] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** modifications by Hartmut Schirmer (c) 1998 + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "image/image.h" + +GrImage *GrImageInverse(GrImage *p,int flag) +{ + GrContext ctx, save; + GrColor col; + GrImage *img; + int yy, xx, sidex, sidey, width, height, xs, ys = 0; + width = p->pxp_width; + height = p->pxp_height; + img = _GrImageAllocate(&ctx,width,height); + if ( !img ) return(NULL); + save = *CURC; + *CURC = ctx; + sidex = ( flag & GR_IMAGE_INVERSE_LR ) ? -1 : 1; + sidey = ( flag & GR_IMAGE_INVERSE_TD ) ? -1 : 1; + yy = ( flag & GR_IMAGE_INVERSE_TD ) ? height-1 : 0; + do { + xx = ( flag & GR_IMAGE_INVERSE_LR ) ? width-1 : 0; + xs = 0; + do { + col = (*p->pxp_source.gf_driver->readpixel)(&p->pxp_source,xs,ys); + (*CURC->gc_driver->drawpixel)(xx, yy, col); + xx += sidex; + } while(++xs < width); + yy += sidey; + } while(++ys < height); + *CURC = save; + img->pxp_ispixmap = 1; + img->pxp_width = width; + img->pxp_height = height; + img->pxp_oper = 0; + img->pxp_source = ctx.gc_frame; + img->pxp_source.gf_memflags = 3;/* MY_CONTEXT & MY_MEMORY */ + return(img); +} diff --git a/thirdparty/grx249/src/image/image.h b/thirdparty/grx249/src/image/image.h new file mode 100644 index 0000000..625f5ee --- /dev/null +++ b/thirdparty/grx249/src/image/image.h @@ -0,0 +1,35 @@ +/** + ** image.h ---- Source Image Utility + ** + ** by Michal Stencl Copyright (c) 1998 + ** - [stenclpmd@ba.telecom.sk] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** modifications by Hartmut Schirmer (c) 1998 + ** + **/ + +#ifndef __IMAGE_H_INCLUDED__ +#define __IMAGE_H_INCLUDED__ + +#ifndef __LIBGRX_H_INCLUDED__ +#include "libgrx.h" +#endif + +#ifndef GrImage +#define GrImage GrPixmap +#endif + +int _GrImageTestSize(int wdt,int hgt); +GrImage *_GrImageAllocate(GrContext *ctx, int nwidth,int nheight); + +#endif diff --git a/thirdparty/grx249/src/image/imginlne.c b/thirdparty/grx249/src/image/imginlne.c new file mode 100644 index 0000000..e91707e --- /dev/null +++ b/thirdparty/grx249/src/image/imginlne.c @@ -0,0 +1,44 @@ +/** + ** imginlne.h ---- Image Utility + ** + ** by Michal Stencl Copyright (c) 1998 for GRX + ** - [stenclpmd@ba.telecom.sk] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "image/image.h" + +GrImage *(GrImageFromPattern)(GrPattern *p) { + return GrImageFromPattern(p); +} + +GrImage *(GrImageFromContext)(GrContext *c) { + return GrImageFromContext(c); +} + +GrPattern *(GrPatternFromImage)(GrImage *p) { + return GrPatternFromImage(p); +} + +GrImage *(GrImageBuildUsedAsPattern)(const char *pixels,int w,int h, + const GrColorTableP colors ) { + return GrImageBuildUsedAsPattern(pixels,w,h,colors); +} + +void (GrImageDestroy)(GrImage *i) { + GrImageDestroy(i); +} + + + diff --git a/thirdparty/grx249/src/image/iplot.c b/thirdparty/grx249/src/image/iplot.c new file mode 100644 index 0000000..3eed462 --- /dev/null +++ b/thirdparty/grx249/src/image/iplot.c @@ -0,0 +1,39 @@ +/** + ** iplot.c ---- Source Image Utility + ** + ** by Michal Stencl Copyright (c) 1998 + ** - [stenclpmd@ba.telecom.sk] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** modifications by Hartmut Schirmer (c) 1998 + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "image/image.h" + +void GrImagePlotAlign(int xo,int yo,int x,int y,GrImage *p) +{ + int xp, yp; + GrColor col; + + xo = min(xo, x); + yo = min(yo, y); + clip_dot(CURC,x,y); + xp = (x - xo) % p->pxp_width; + yp = (y - yo) % p->pxp_height; + mouse_block(CURC,x,y,x,y); + col = (*p->pxp_source.gf_driver->readpixel)(&p->pxp_source,xp,yp); + (*CURC->gc_driver->drawpixel)(x + CURC->gc_xoffset, y + CURC->gc_yoffset, col); + mouse_unblock(); +} diff --git a/thirdparty/grx249/src/image/istretch.c b/thirdparty/grx249/src/image/istretch.c new file mode 100644 index 0000000..d78be9b --- /dev/null +++ b/thirdparty/grx249/src/image/istretch.c @@ -0,0 +1,35 @@ +/** + ** istretch.c ---- Source Image Utility + ** + ** Copyright (c) 1998 by Michal Stencl and Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "clipping.h" +#include "image/image.h" + +GrImage *GrImageStretch(GrImage *p,int nwidth,int nheight) +{ + GrContext ctx; + GrImage *img; + + GRX_ENTER(); + img = _GrImageAllocate(&ctx,nwidth,nheight); + if ( img ) + _GrFrDrvGenericStretchBlt(&ctx.gc_frame,0,0,nwidth,nheight, + &p->pxp_source,0,0,p->pxp_width,p->pxp_height, + p->pxp_oper); + GRX_RETURN(img); +} diff --git a/thirdparty/grx249/src/include/access24.h b/thirdparty/grx249/src/include/access24.h new file mode 100644 index 0000000..7a460d2 --- /dev/null +++ b/thirdparty/grx249/src/include/access24.h @@ -0,0 +1,44 @@ +/** + ** access24.h ---- 16M color (24bit) access macros + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + **/ + +#ifndef __ACCESS24_H_INCLUDED__ +#define __ACCESS24_H_INCLUDED__ + +#ifndef __LIBGRX_H_INCLUDED__ +#include "libgrx.h" +#endif + +#ifndef __MEMPEEK_H_INCLUDED__ +#include "mempeek.h" +#endif + +#if BYTE_ORDER==LITTLE_ENDIAN +/* read color component from 32bit variable */ +#define RD24BYTE(p,idx) peek_b(((GR_int8u *)(&p))+idx) +/* write color componet to 32bit variable */ +#define WR24BYTE(p,idx,cc) poke_b(((GR_int8u *)(&p))+idx,cc) +#else +/* read color component from 32bit variable */ +#define RD24BYTE(p,idx) peek_b(((GR_int8u *)(&p))+idx+1) +/* write color componet to 32bit variable */ +#define WR24BYTE(p,idx,cc) poke_b(((GR_int8u *)(&p))+idx+1,cc) +#endif + +#endif diff --git a/thirdparty/grx249/src/include/allocate.h b/thirdparty/grx249/src/include/allocate.h new file mode 100644 index 0000000..edbaf8a --- /dev/null +++ b/thirdparty/grx249/src/include/allocate.h @@ -0,0 +1,83 @@ +/** + ** allocate.h ---- common ground for malloc & friends in 16 & 32 bit envs + ** stack based temporary memory allocation + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#if defined(__alpha__) || (GRX_VERSION==GRX_VERSION_GENERIC_X11) && !defined(_AIX) +# include +#elif defined(__TURBOC__) +# include +# include "bcc/allocate.h" +#elif defined(__WATCOMC__) +# include +#elif defined(_MSC_VER) && defined(_WIN32) +# include +#elif defined(__MINGW32__) && !defined(alloca) +# define alloca __builtin_alloca +#else +# include +#endif + +#if defined(_MSC_VER) && !defined(_WIN32) +#define farmalloc _fmalloc +#define farrealloc _frealloc +#define farcalloc _fcalloc +#define farfree _ffree +#elif !defined(__TURBOC__) +#define farmalloc malloc +#define farrealloc realloc +#define farcalloc calloc +#define farfree free +#endif + +#if 0 && defined(_MSC_VER) +#define setup_alloca() do { unsigned char _stack_dummy_var_ = '\001' +#define reset_alloca() } while (0) +#endif + + +#ifndef setup_alloca +#define setup_alloca() +#define reset_alloca() +#endif + +/* ALLOC / FREE : use alloca if possible */ +#ifdef SMALL_STACK +#define ALLOC(sze) malloc(sze) +#define FREE(p) free(p) +#define setup_ALLOC() +#define reset_ALLOC() +#elif defined(_MSC_VER) && !defined(_WIN32) +#define ALLOC(sze) _alloca(sze) +#define FREE(p) +#define setup_ALLOC setup_alloca +#define reset_ALLOC reset_alloca +#else +#define ALLOC(sze) alloca(sze) +#define FREE(p) +#define setup_ALLOC setup_alloca +#define reset_ALLOC reset_alloca +#endif + +/* temp buffer for blits etc. */ +extern void far *_GrTempBuffer; +extern unsigned _GrTempBufferBytes; +#define _GrTempBufferAlloc(b) ( \ + ((unsigned)(b) <= _GrTempBufferBytes) ? _GrTempBuffer \ + : _GrTempBufferAlloc_(b) ) +extern void far *_GrTempBufferAlloc_(size_t bytes); +extern void _GrTempBufferFree(void); diff --git a/thirdparty/grx249/src/include/arith.h b/thirdparty/grx249/src/include/arith.h new file mode 100644 index 0000000..77685a7 --- /dev/null +++ b/thirdparty/grx249/src/include/arith.h @@ -0,0 +1,237 @@ +/** + ** arith.h ---- some common integer arithmetic macros/inline functions + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Intel CPU specific support is provided for the Turbo C and GNU C. May + ** work with other compilers and CPU-s, but is not optimized for them. + ** + **/ + +#ifndef __ARITH_H_INCLUDED__ +#define __ARITH_H_INCLUDED__ + +#ifdef __GNUC__ +#include "gcc/arith.h" +#elif defined(__TURBOC__) +#include "bcc/arith.h" +#endif + +#ifdef _MSC_VER +#define __emit__(x) __asm{ __emit (x) } +#endif + +/* + * old standbys + */ +#ifndef min +#define min(x,y) (((x) < (y)) ? (x) : (y)) +#endif +#ifndef max +#define max(x,y) (((x) > (y)) ? (x) : (y)) +#endif +#ifndef __ABS +#define __ABS(x) (((x) < (0)) ? -(x) : (x)) +#endif +#ifndef abs +#define abs(x) __ABS(x) +#endif +#ifndef scale +#define scale(x,n,d) (((x) * (n)) / (d)) +#endif +#ifndef imin +#define imin(x,y) min((int)(x),(int)(y)) +#endif +#ifndef imax +#define imax(x,y) max((int)(x),(int)(y)) +#endif +#ifndef iabs +#define iabs(x) abs((int)(x)) +#endif +#ifndef umin +#define umin(x,y) min((unsigned int)(x),(unsigned int)(y)) +#endif +#ifndef umax +#define umax(x,y) max((unsigned int)(x),(unsigned int)(y)) +#endif +#ifndef lmin +#define lmin(x,y) min((long)(x),(long)(y)) +#endif +#ifndef lmax +#define lmax(x,y) max((long)(x),(long)(y)) +#endif +#ifndef labs +#define labs(x) __ABS((long)(x)) +#endif +#ifndef ulmin +#define ulmin(x,y) min((unsigned long)(x),(unsigned long)(y)) +#endif +#ifndef ulmax +#define ulmax(x,y) max((unsigned long)(x),(unsigned long)(y)) +#endif + +/* + * swap and sort stuff + */ +#define iswap(x,y) { \ + int _swap_tmpval_ = (x); \ + (x) = (y); \ + (y) = _swap_tmpval_; \ +} + +#define lswap(x,y) { \ + long _swap_tmpval_ = (x); \ + (x) = (y); \ + (y) = _swap_tmpval_; \ +} + +#define isort(x,y) { \ + if((int)(x) > (int)(y)) iswap(x,y) \ +} + +#define usort(x,y) { \ + if((unsigned int)(x) > (unsigned int)(y)) iswap(x,y) \ +} + +#define lsort(x,y) { \ + if((long)(x) > (long)(y)) lswap(x,y) \ +} + +#define ulsort(x,y) { \ + if((unsigned long)(x) > (unsigned long)(y)) lswap(x,y) \ +} + + +/* + * couple of 'sizeof'-like useful macros + */ +#ifndef bsizeof +#define bsizeof(s) (sizeof(s) / sizeof(char)) +#endif +#ifndef wsizeof +#define wsizeof(s) (sizeof(s) / sizeof(short)) +#endif +#ifndef lsizeof +#define lsizeof(s) (sizeof(s) / sizeof(long)) +#endif +#ifndef bitsof +#define bitsof(s) (sizeof(s) * 8) +#endif +#ifndef bytesof +#define bytesof(s) ((sizeof(s) + sizeof(char) - 1) / sizeof(char)) +#endif +#ifndef wordsof +#define wordsof(s) ((sizeof(s) + sizeof(short) - 1) / sizeof(short)) +#endif +#ifndef longsof +#define longsof(s) ((sizeof(s) + sizeof(long) - 1) / sizeof(long)) +#endif +#ifndef itemsof +#define itemsof(arr) (sizeof(arr) / sizeof((arr)[0])) +#endif +#ifndef offsetof +#define offsetof(structype,field) (int)( \ + (char *)(&((structype *)(0))->field) - \ + (char *)(0) \ +) +#endif + +/* + * [i|u]mul32(x,y) + * multiply two int-s for a long result + */ +#ifndef imul32 +#define imul32(X,Y) ((long)(X) * (long)(Y)) +#endif +#ifndef umul32 +#define umul32(X,Y) ((unsigned long)(X) * (unsigned long)(Y)) +#endif + + +/* + * umuladd32(x,y,z) + * multiply two unsigned-s for a long result and add an unsigned + */ +#ifndef umuladd32 +#define umuladd32(X,Y,Z) (umul32((X),(Y))+(Z)) +#endif + + +/* + * [i|u]scale(X,N,D) + * scale an integer with long intermediate result but without using long + * arithmetic all the way + */ +#ifndef iscale +#define iscale(X,N,D) (int)(imul32(X,N) / (long)(D)) +#endif +#ifndef uscale +#define uscale(X,N,D) (unsigned int)(umul32(X,N) / (unsigned long)(D)) +#endif +#ifndef irscale +#define irscale(X,N,D) (( \ + iscale(((int)(X) << 1),N,D) + \ + (((int)(X) ^ (int)(N) ^ (int)(D)) >> (bitsof(int) - 1)) + \ + 1 \ +) >> 1) +#endif +#ifndef urscale +#define urscale(X,N,D) ((uscale(((int)(X) << 1),N,D) + 1) >> 1) +#endif + +/* + * replicate_2(byte_or_word_value) + * copy the lower byte(s) of a byte or word into the upper byte(s) + */ +#define __INLINE_REPLICATE__(V,TFROM,TTO) ( \ + ((unsigned TTO)(unsigned TFROM)(V)) | \ + ((unsigned TTO)(unsigned TFROM)(V) << (sizeof(TFROM) * 8)) \ +) + +#ifndef replicate_b2b +#define replicate_b2b(BYTE) (BYTE) +#endif +#ifndef replicate_b2w +#define replicate_b2w(BYTE) __INLINE_REPLICATE__(BYTE,GR_int8,GR_int16) +#endif +#ifndef replicate_b2l +#define replicate_b2l(BYTE) replicate_w2l(replicate_b2w(BYTE)) +#endif +#ifndef replicate_b2h +#define replicate_b2h(BYTE) replicate_l2h(replicate_w2l(replicate_b2w(BYTE))) +#endif + +#ifndef replicate_w2w +#define replicate_w2w(WORD) (WORD) +#endif +#ifndef replicate_w2l +#define replicate_w2l(WORD) __INLINE_REPLICATE__(WORD,GR_int16,GR_int32) +#endif +#ifndef replicate_w2h +#define replicate_w2h(WORD) replicate_l2h(replicate_w2l(WORD)) +#endif + +#ifndef replicate_l2l +#define replicate_l2l(LONG) (LONG) +#endif +#ifndef replicate_l2h +#define replicate_l2h(LONG) __INLINE_REPLICATE__(LONG,GR_int32,GR_int64) +#endif + +#ifndef replicate_h2h +#define replicate_h2h(LLONG) (LLONG) +#endif + +#endif /* whole file */ + diff --git a/thirdparty/grx249/src/include/bcc/allocate.h b/thirdparty/grx249/src/include/bcc/allocate.h new file mode 100644 index 0000000..7d0b3fd --- /dev/null +++ b/thirdparty/grx249/src/include/bcc/allocate.h @@ -0,0 +1,42 @@ +/** + ** allocate.h ---- common ground for malloc & friends in 16 & 32 bit envs + ** stack based temporary memory allocation + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* + * I have TC++ 1.01 (quite old). It is possible that newer TC++ versions + * have a built-in alloca. + */ +#if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) +extern unsigned int __brklvl; +#define alloca(size) ( \ + ((_AX = _SP - (((unsigned int)(size) + 3) & ~3)) > __brklvl) ? \ + (void near *)(_SP = _AX) : \ + (void near *)(0) \ +) +#else +extern unsigned int _stklen; +#define alloca(size) ( \ + ((_AX = _SP - (((unsigned int)(size) + 3) & ~3)) < _stklen) ? \ + (void far *)((void _seg *)(_SS) + (void near *)(_SP = _AX)) : \ + (void far *)(0) \ +) +#endif + +#define setup_alloca() { unsigned int __saved_SP__ = _SP; +#define reset_alloca() _SP = __saved_SP__; } + diff --git a/thirdparty/grx249/src/include/bcc/arith.h b/thirdparty/grx249/src/include/bcc/arith.h new file mode 100644 index 0000000..334df21 --- /dev/null +++ b/thirdparty/grx249/src/include/bcc/arith.h @@ -0,0 +1,74 @@ +/** + ** arith.h ---- some common integer arithmetic macros/inline functions + ** Special Borland-C++ handling + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* + * arithmetic stuff + */ + +/* prototype for __emit__() */ +#include + +/* + * [i|u]mul32(x,y) + * multiply two int-s for a long result + */ +extern long _GR_imul32(int x, int y); +extern unsigned long _GR_umul32(int x, int y); +#define imul32(X,Y) _GR_imul32((X),(Y)) +#define umul32(X,Y) _GR_umul32((X),(Y)) + +/* + * umuladd32(x,y,z) + * multiply two unsigned-s for a long result and add an unsigned + */ +extern unsigned long _GR_umuladd32(unsigned x, unsigned y, unsigned z); +#define umuladd32(X,Y,Z) _GR_umuladd32((X),(Y),(Z)) + +/* + * [i|u]scale(X,N,D) + * scale an integer with long intermediate result but without using long + * arithmetic all the way + */ +extern int _GR_iscale(int x,int n,int d); +extern unsigned _GR_uscale(int x,int n,int d); +extern int _GR_irscale(int x, int n, int d); +#define iscale(X,N,D) _GR_iscale((X),(N),(D)) +#define uscale(X,N,D) _GR_uscale((X),(N),(D)) +#define irscale(X,N,D) _GR_irscale((X),(N),(D)) + +/* + * replicate_2(byte_or_word_value) + * copy the lower byte(s) of a byte or word into the upper byte(s) + */ +#define replicate_b2w(BYTE) ( \ + _AL = (char)(BYTE), \ + _AH = _AL, \ + (int)_AX \ +) +#define replicate_w2l(WORD) ( \ + _AX = (int)(WORD), \ + _DX = _AX, \ + (long)((void _seg *)_DX + (void near *)_AX) \ +) +#define replicate_b2l(BYTE) ( \ + _AL = (char)(BYTE), \ + _AH = _AL, \ + _DX = _AX, \ + (long)((void _seg *)_DX + (void near *)_AX) \ +) diff --git a/thirdparty/grx249/src/include/bcc/asmsupp.h b/thirdparty/grx249/src/include/bcc/asmsupp.h new file mode 100644 index 0000000..f6e7c38 --- /dev/null +++ b/thirdparty/grx249/src/include/bcc/asmsupp.h @@ -0,0 +1,39 @@ +/* + * Define assembler memonics for asm code creation + * and memonic extensions for different operand sizes + */ + +#ifndef __BCC_ASMSUPP_H_INCLUDED +#define __BCC_ASMSUPP_H_INCLUDED + +#define __EMIT__(x) __emit__((char)(x)) + +#define MOV_INS mov +#define XOR_INS xor +#define OR_INS or +#define AND_INS and + +/* for opcode generation using __emit__ */ +/* mov [...],al */ +#define OPCODE_mov_mem_b 0x88 +/* mov [...],ax */ +#define OPCODE_mov_mem_w 0x89 +/* xor [...],al */ +#define OPCODE_xor_mem_b 0x30 +/* xor [...],ax */ +#define OPCODE_xor_mem_w 0x31 +/* or [...],al */ +#define OPCODE_or_mem_b 0x08 +/* or [...],ax */ +#define OPCODE_or_mem_w 0x09 +/* and [...],al */ +#define OPCODE_and_mem_b 0x20 +/* and [...],ax */ +#define OPCODE_and_mem_w 0x21 + + +#define OP8b b +#define OP16b w +#define OP32b l + +#endif diff --git a/thirdparty/grx249/src/include/bcc/highlow.h b/thirdparty/grx249/src/include/bcc/highlow.h new file mode 100644 index 0000000..a05ed8b --- /dev/null +++ b/thirdparty/grx249/src/include/bcc/highlow.h @@ -0,0 +1,20 @@ +/** + ** highlow.h ---- combining two BYTES into one WORD -- Borland-C++ special + ** + ** Copyright (c) 1997 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* combine two bytes into one word: optimized x86 version */ +#define highlow(hi,lo) ( _AH = (hi), _AL = (lo), _AX ) + diff --git a/thirdparty/grx249/src/include/bcc/memcopy.h b/thirdparty/grx249/src/include/bcc/memcopy.h new file mode 100644 index 0000000..82d613f --- /dev/null +++ b/thirdparty/grx249/src/include/bcc/memcopy.h @@ -0,0 +1,232 @@ +/** + ** memcopy.h ---- inline assembly memory copy macros -- GNU-C code + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* bcc can't do 32bit copies -> use 16bit instead */ +#ifndef NO_32BIT_COPY +# define NO_32BIT_COPY +#endif + +#include "bcc/asmsupp.h" + +#define __INLINE_STD_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) do { \ + __EMIT__(0x1e); /* push ds */ \ + _ES = (unsigned)(void _seg *)(void far *)(S); \ + _SI = (unsigned)(void near *)(S); \ + __EMIT__(0x06); /* push es */ \ + _ES = (unsigned)(void _seg *)(void far *)(D); \ + _DI = (unsigned)(void near *)(D); \ + _CX = (int)(C); \ + __EMIT__(0x1f); /* pop ds */ \ + __EMIT__(0xfc); /* cld */ \ + __EMIT__(0xf3); /* rep */ \ + __EMIT__(0xa4 + sizeof(TYPE) - 1); /* movsB|W */ \ + __EMIT__(0x1f); /* pop ds */ \ + (unsigned)(void near *)(D) = _DI; \ + (unsigned)(void near *)(S) = _SI; \ +} while(0) + +/* -------------------------------------------------------------------------- */ + +#define __INLINE_BCC_OPRCOPY_b__(D,S,C,WROPCODE) do { \ + __EMIT__(0x1e); /* push ds */ \ + _ES = (unsigned)(void _seg *)(void far *)(S); \ + _SI = (unsigned)(void near *)(S); \ + __EMIT__(0x06); /* push es */ \ + _ES = (unsigned)(void _seg *)(void far *)(D); \ + _DI = (unsigned)(void near *)(D); \ + _CX = (int)(C); \ + __EMIT__(0x1f); /* pop ds */ \ + __EMIT__(0xfc); /* cld */ \ + /* loop: */ \ + __EMIT__(0xac); /* lodsb */ \ + __EMIT__(0x26); /* es: */ \ + __EMIT__(WROPCODE); /* xor/or/and/mov [..],al/ax */ \ + __EMIT__(0x05); /* di */ \ + __EMIT__(0x47); /* inc di */ \ + __EMIT__(0x49); /* dec cx */ \ + __EMIT__(0x75); /* jnz */ \ + __EMIT__(0xf8); /* loop*/ \ + __EMIT__(0x1f); /* pop ds */ \ + (unsigned)(void near *)(D) = _DI; \ + (unsigned)(void near *)(S) = _SI; \ +} while(0) + + +#define __INLINE_BCC_OPRCOPY_w__(D,S,C,WROPCODE) do { \ + __EMIT__(0x1e); /* push ds */ \ + _ES = (unsigned)(void _seg *)(void far *)(S); \ + _SI = (unsigned)(void near *)(S); \ + __EMIT__(0x06); /* push es */ \ + _ES = (unsigned)(void _seg *)(void far *)(D); \ + _DI = (unsigned)(void near *)(D); \ + _CX = (int)(C); \ + __EMIT__(0x1f); /* pop ds */ \ + __EMIT__(0xfc); /* cld */ \ + /* loop: */ \ + __EMIT__(0xad); /* lodsw */ \ + __EMIT__(0x26); /* es: */ \ + __EMIT__(WROPCODE); /* xor/or/and/mov [..],al/ax */ \ + __EMIT__(0x05); /* di */ \ + __EMIT__(0x47); /* inc di */ \ + __EMIT__(0x47); /* inc di */ \ + __EMIT__(0x49); /* dec cx */ \ + __EMIT__(0x75); /* jnz */ \ + __EMIT__(0xf7); /* loop*/ \ + __EMIT__(0x1f); /* pop ds */ \ + (unsigned)(void near *)(D) = _DI; \ + (unsigned)(void near *)(S) = _SI; \ +} while(0) + +/* need an additional indirection to resolve INS and SIZE */ +#define __INLINE_TMP_OPRCOPY__(D,S,C,INS,SIZE,TY) \ + __INLINE_BCC_OPRCOPY_##SIZE##__(D,S,C,OPCODE_##INS##_mem_##SIZE,TY) + +#define __INLINE_STD_OPRCOPY__(D,S,C,DM,SM,INS,SIZE,TY) \ + __INLINE_TMP_OPRCOPY__(D,S,C,INS,SIZE,TY) + +/* -------------------------------------------------------------------------- */ + +#define __INLINE_BCC_COLCOPY__(D,DS,S,SS,C,WROPCODE,TYPE) do { \ + volatile int _dskip_ = (int)(DS); \ + volatile int _sskip_ = (int)(SS); \ + volatile unsigned int _cnt_ = (unsigned int)(C); \ + __EMIT__(0x1e); /* push ds */ \ + _ES = (unsigned)(void _seg *)(void far *)(S); \ + _SI = (unsigned)(void near *)(S); \ + __EMIT__(0x06); /* push es */ \ + _ES = (unsigned)(void _seg *)(void far *)(D); \ + _DI = (unsigned)(void near *)(D); \ + _BX = (int)(_sskip_); \ + _CX = (int)(_cnt_); \ + _DX = (int)(_dskip_); \ + __EMIT__(0x1f); /* pop ds */ \ + __EMIT__(0xfc); /* cld */ \ + /* loop: */ \ + __EMIT__(0x8a+sizeof(TYPE)-1); /* mov al/ax,[si] */ \ + __EMIT__(0x04); \ + __EMIT__(0x26); /* es: */ \ + __EMIT__(WROPCODE); /* xor/or/and/mov [..],al/ax */ \ + __EMIT__(0x05); /* di */ \ + __EMIT__(0x01); /* add di,dx */ \ + __EMIT__(0xd7); \ + __EMIT__(0x01); /* add si,bx */ \ + __EMIT__(0xde); \ + __EMIT__(0x49); /* dec cx */ \ + __EMIT__(0x75); /* jnz */ \ + __EMIT__(0xf4); /* loop*/ \ + __EMIT__(0x1f); /* pop ds */ \ + (unsigned)(void near *)(D) = _DI; \ + (unsigned)(void near *)(S) = _SI; \ +} while(0) + +/* need an additional indirection to resolve INS and SIZE */ +#define __INLINE_STD_COLCOPY__(D,DSKP,S,SSKP,C,DM,SM,INS,SIZE,TYPE) \ + __INLINE_TMP1_COLCOPY__(D,DSKP,S,SSKP,C,INS,SIZE,TYPE) +#define __INLINE_TMP1_COLCOPY__(D,DS,S,SS,C,INS,SIZE,TY) \ + __INLINE_TMP2_COLCOPY__(D,DS,S,SS,C,OPCODE_##INS##_mem_##SIZE,TY) +#define __INLINE_TMP2_COLCOPY__(D,DS,S,SS,C,WOPC,TY) \ + __INLINE_BCC_COLCOPY__(D,DS,S,SS,C,WOPC,TY) + + +/* memory -> video copy */ +#define rowcopy_b_f_set rowcopy_b_set +#define rowcopy_w_f_set rowcopy_w_set +#define rowcopy_l_f_set rowcopy_l_set + +#define rowcopy_b_f_xor rowcopy_b_xor +#define rowcopy_w_f_xor rowcopy_w_xor +#define rowcopy_l_f_xor rowcopy_l_xor + +#define rowcopy_b_f_or rowcopy_b_or +#define rowcopy_w_f_or rowcopy_w_or +#define rowcopy_l_f_or rowcopy_l_or + +#define rowcopy_b_f_and rowcopy_b_and +#define rowcopy_w_f_and rowcopy_w_and +#define rowcopy_l_f_and rowcopy_l_and + +/* video -> memory copy */ +#define rowcopy_b_set_f rowcopy_b_set +#define rowcopy_w_set_f rowcopy_w_set +#define rowcopy_l_set_f rowcopy_l_set + +#define rowcopy_b_xor_f rowcopy_b_xor +#define rowcopy_w_xor_f rowcopy_w_xor +#define rowcopy_l_xor_f rowcopy_l_xor + +#define rowcopy_b_or_f rowcopy_b_or +#define rowcopy_w_or_f rowcopy_w_or +#define rowcopy_l_or_f rowcopy_l_or + +#define rowcopy_b_and_f rowcopy_b_and +#define rowcopy_w_and_f rowcopy_w_and +#define rowcopy_l_and_f rowcopy_l_and + +/* video -> video copy */ +#define rowcopy_b_f_set_f rowcopy_b_set +#define rowcopy_w_f_set_f rowcopy_w_set +#define rowcopy_l_f_set_f rowcopy_l_set + +#define rowcopy_b_f_xor_f rowcopy_b_xor +#define rowcopy_w_f_xor_f rowcopy_w_xor +#define rowcopy_l_f_xor_f rowcopy_l_xor + +#define rowcopy_b_f_or_f rowcopy_b_or +#define rowcopy_w_f_or_f rowcopy_w_or +#define rowcopy_l_f_or_f rowcopy_l_or + +#define rowcopy_b_f_and_f rowcopy_b_and +#define rowcopy_w_f_and_f rowcopy_w_and +#define rowcopy_l_f_and_f rowcopy_l_and + + +/* ------------------------------------------- optimal fills */ +extern void far *_GR_fwdcopy_set(void near *ap, void far *d, + void far *s, unsigned cnt); +extern void far *_GR_fwdcopy_xor(void near *ap, void far *d, + void far *s, unsigned cnt); +extern void far *_GR_fwdcopy_or( void near *ap, void far *d, + void far *s, unsigned cnt); +extern void far *_GR_fwdcopy_and(void near *ap, void far *d, + void far *s, unsigned cnt); + +#define __BCC_FWD_COPY__(OP,ap,d,s,c) do { \ + (d) = _GR_fwdcopy_##OP((void near *)(ap),(void far *)(d), \ + (void far *)(s), (unsigned)(c) ); \ + ((char far *)(s)) += (unsigned)(c); \ +} while (0) + +#define fwdcopy_set(ap,d,s,c) __BCC_FWD_COPY__(set,ap,d,s,c) +#define fwdcopy_f_set fwdcopy_set +#define fwdcopy_set_f fwdcopy_set +#define fwdcopy_f_set_f fwdcopy_set + +#define fwdcopy_xor(ap,d,s,c) __BCC_FWD_COPY__(xor,ap,d,s,c) +#define fwdcopy_f_xor fwdcopy_xor +#define fwdcopy_xor_f fwdcopy_xor +#define fwdcopy_f_xor_f fwdcopy_xor + +#define fwdcopy_or(ap,d,s,c) __BCC_FWD_COPY__(or,ap,d,s,c) +#define fwdcopy_f_or fwdcopy_or +#define fwdcopy_or_f fwdcopy_or +#define fwdcopy_f_or_f fwdcopy_or + +#define fwdcopy_and(ap,d,s,c) __BCC_FWD_COPY__(and,ap,d,s,c) +#define fwdcopy_f_and fwdcopy_and +#define fwdcopy_and_f fwdcopy_and +#define fwdcopy_f_and_f fwdcopy_and diff --git a/thirdparty/grx249/src/include/bcc/memfill.h b/thirdparty/grx249/src/include/bcc/memfill.h new file mode 100644 index 0000000..a57a092 --- /dev/null +++ b/thirdparty/grx249/src/include/bcc/memfill.h @@ -0,0 +1,114 @@ +/** + ** memfill.h ---- inline assembly memory fill macros + ** Borland-C++ special version + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Basic and optimized memory block fill operations in byte, word and + ** long sizes. The fills are available in WRITE, XOR, OR and AND modes. + **/ + +#include "bcc/asmsupp.h" + +#define __INLINE_STD_ROWFILL__(P,V,C,FMODE,SIZE,TYPE) do { \ + _ES = (unsigned)(void _seg *)(void far *)(P); \ + _DI = (unsigned)(void near *)(P); \ + _CX = (int)(C); \ + _AX = (int)(V); \ + __emit__((char)(0xfc)); /* cld */ \ + __emit__((char)(0xf3)); /* rep */ \ + __emit__((char)(0xaa + sizeof(TYPE) - 1)); /* stosB|W */ \ + (unsigned)(void near *)(P) = _DI; \ +} while(0) + +#define __INLINE_BCC_COLFILL__(P,V,C,SKIP,INS,SIZE) do { \ + (P) = _GR_colfill_##SIZE##_##INS((P),(SKIP),(V),(C)); \ +} while(0) + +#define __INLINE_STD_COLFILL__(P,V,C,SKIP,FMODE,INS,SIZE,TYPE) \ + __INLINE_BCC_COLFILL__(P,V,C,SKIP,INS,SIZE) + +#define __INLINE_FAR_ROWFILL__(P,V,C,FMODE,SIZE,TYPE) \ + __INLINE_STD_ROWFILL__(P,V,C,FMODE,SIZE,TYPE) + +#define __INLINE_B_REPFILL__(P,V,C,FMODE) rowfill_b##FMODE(P,V,C) +#define __INLINE_W_REPFILL__(P,V,C,FMODE) rowfill_w##FMODE(P,V,C) +#define __INLINE_L_REPFILL__(P,V,C,FMODE) rowfill_l##FMODE(P,V,C) + +void far *_GR_colfill_b_mov(void far *P, int O, unsigned char V, unsigned C); +void far *_GR_colfill_b_xor(void far *P, int O, unsigned char V, unsigned C); +void far *_GR_colfill_b_or( void far *P, int O, unsigned char V, unsigned C); +void far *_GR_colfill_b_and(void far *P, int O, unsigned char V, unsigned C); + +void far *_GR_colfill_w_mov(void far *P, int O, unsigned V, unsigned C); +void far *_GR_colfill_w_xor(void far *P, int O, unsigned V, unsigned C); +void far *_GR_colfill_w_or( void far *P, int O, unsigned V, unsigned C); +void far *_GR_colfill_w_and(void far *P, int O, unsigned V, unsigned C); + +void far *_GR_colfill_l_mov(void far *P, int O, unsigned long V, unsigned C); +void far *_GR_colfill_l_xor(void far *P, int O, unsigned long V, unsigned C); +void far *_GR_colfill_l_or( void far *P, int O, unsigned long V, unsigned C); +void far *_GR_colfill_l_and(void far *P, int O, unsigned long V, unsigned C); + +#define rowfill_l(p,v,c) do (p)=_GR_colfill_l_mov((p),4,(v),(c)); while(0) +#define rowfill_l_xor(p,v,c) do (p)=_GR_colfill_l_xor((p),4,(v),(c)); while(0) +#define rowfill_l_or(p,v,c) do (p)=_GR_colfill_l_or( (p),4,(v),(c)); while(0) +#define rowfill_l_and(p,v,c) do (p)=_GR_colfill_l_and((p),4,(v),(c)); while(0) + +#define rowfill_l_f(p,v,c) rowfill_l( (p),(v),(c)) +#define rowfill_l_f_xor(p,v,c) rowfill_l_xor((p),(v),(c)) +#define rowfill_l_f_or(p,v,c) rowfill_l_or( (p),(v),(c)) +#define rowfill_l_f_and(p,v,c) rowfill_l_and((p),(v),(c)) + + +void far *_GR_repfill_b( void far *P,unsigned int V, unsigned int C); +void far *_GR_repfill_b_xor(void far *P,unsigned int V, unsigned int C); +void far *_GR_repfill_b_or( void far *P,unsigned int V, unsigned int C); +void far *_GR_repfill_b_and(void far *P,unsigned int V, unsigned int C); + +#define repfill_b(p,v,c) do (p) = _GR_repfill_b( (p),(v),(c)); while(0) +#define repfill_b_xor(p,v,c) do (p) = _GR_repfill_b_xor((p),(v),(c)); while(0) +#define repfill_b_or(p,v,c) do (p) = _GR_repfill_b_or( (p),(v),(c)); while(0) +#define repfill_b_and(p,v,c) do (p) = _GR_repfill_b_and((p),(v),(c)); while(0) + +#define repfill_b_f(p,v,c) repfill_b( (p),(v),(c)) +#define repfill_b_f_xor(p,v,c) repfill_b_xor((p),(v),(c)) +#define repfill_b_f_or(p,v,c) repfill_b_or( (p),(v),(c)) +#define repfill_b_f_and(p,v,c) repfill_b_and((p),(v),(c)) + + +#define __INLINE_MEMFILL__(P,V,C,SIZE,TYPE,FMODE) do { \ + void far *_PTR = (void far *)(P); \ + register int _VAL = (int)(V); \ + register int _CNT = (int)(C); \ + rowfill_##SIZE##FMODE(_PTR,_VAL,_CNT); \ +} while(0) + + +void far *_GR_repfill_24_set(void far *P,unsigned long V, unsigned int B); +void far *_GR_repfill_24_xor(void far *P,unsigned long V, unsigned int B); +void far *_GR_repfill_24_or( void far *P,unsigned long V, unsigned int B); +void far *_GR_repfill_24_and(void far *P,unsigned long V, unsigned int B); + +#define GRX_HAVE_FAST_REPFILL24 + +#define repfill_24(p,v,b) do (p)=_GR_repfill_24_set((p),(v),(b)); while(0) +#define repfill_24_xor(p,v,b) do (p)=_GR_repfill_24_xor((p),(v),(b)); while(0) +#define repfill_24_or(p,v,b) do (p)=_GR_repfill_24_or( (p),(v),(b)); while(0) +#define repfill_24_and(p,v,b) do (p)=_GR_repfill_24_and((p),(v),(b)); while(0) + +#define repfill_24_f(p,v,b) repfill_24( (p),(v),(b)) +#define repfill_24_f_xor(p,v,b) repfill_24_xor((p),(v),(b)) +#define repfill_24_f_or(p,v,b) repfill_24_or( (p),(v),(b)) +#define repfill_24_f_and(p,v,b) repfill_24_and((p),(v),(b)) diff --git a/thirdparty/grx249/src/include/bcc/memmode.h b/thirdparty/grx249/src/include/bcc/memmode.h new file mode 100644 index 0000000..adddf97 --- /dev/null +++ b/thirdparty/grx249/src/include/bcc/memmode.h @@ -0,0 +1,25 @@ +/** + ** memmode.h ---- determine how to access video and system RAM + ** Borland-C++ code + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include + +#define DECLARE_XFER_BUFFER(size) char XFER_BUFFER[size] +#define DELETE_XFER_BUFFER +#define FP86_SEG(p) FP_SEG(p) +#define FP86_OFF(p) FP_OFF(p) diff --git a/thirdparty/grx249/src/include/bcc/mempeek.h b/thirdparty/grx249/src/include/bcc/mempeek.h new file mode 100644 index 0000000..d3528e3 --- /dev/null +++ b/thirdparty/grx249/src/include/bcc/mempeek.h @@ -0,0 +1,70 @@ +/** + ** mempeek.h ---- (far) memory read/write operations + ** Borland-C code + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Basic memory peek and poke operations in byte, word and long sizes. + ** The poke operations are available in WRITE, XOR, OR and AND versions. + ** + **/ + +/* There's actually nothing special except of far pointer usage */ +#define __INLINE_STD_PEEK__(P,S,T) (*(unsigned T far *)(P)) +#define __INLINE_STD_POKE__(P,V,OP,I,S,T) (*(unsigned T far *)(P) OP (V)) + +#define __INLINE_FAR_PEEK__(P,S,T) (*(volatile unsigned T far *)(P)) +#define __INLINE_FAR_POKE__(P,V,OP,I,S,T) (*(volatile unsigned T far *)(P) OP (V)) + + +/* optimized 24bpp access */ + +#include "access24.h" + +#define __INLINE_24_PEEK__(P) ( \ + _ES = (unsigned)(void _seg *)(void far *)(P), \ + _DI = (unsigned)(void near *)(P), \ + (__emit__(0x26),__emit__(0x8b),__emit__(0x05), /* mov ax,es:[di] */ \ + __emit__(0x26),__emit__(0x8a), /* mov dl,es:[di+2] */ \ + __emit__(0x55), __emit__(0x02), \ + __emit__(0x30), __emit__(0xf6) ), /* xor dh,dh */ \ + (long)((void _seg *)_DX + (void near *)_AX) \ +) +#define __INLINE_24_FAR_PEEK__ __INLINE_24_PEEK__ + + +#define __INLINE_24_BCC_POKE__(P,C,OPC_w,OPC_b) do { \ + _AX = (unsigned)(C); \ + _ES = (unsigned)(void _seg *)(void far *)(P); \ + _DI = (unsigned)(void near *)(P); \ + __emit__((char)(0x26)); /* es: */ \ + __emit__((char)(OPC_w)); /* xor/or/and/mov [..],ax */ \ + __emit__((char)(0x05)); /* di */ \ + __emit__((char)(0x47)); /* inc di */ \ + __emit__((char)(0x47)); /* inc di */ \ + _AL = RD24BYTE((C),2); \ + __emit__((char)(0x26)); /* es: */ \ + __emit__((char)(OPC_b)); /* xor/or/and/mov [..],al */ \ + __emit__((char)(0x05)); /* di */ \ +} while (0) + + +#define __INLINE_24_POKE__(P,C,OP,INS) \ + __INLINE_24_TMP1_POKE__(P,C,INS) +#define __INLINE_24_TMP1_POKE__(P,C,INS) \ + __INLINE_24_TMP2_POKE__(P,C,OPCODE_##INS##_mem_w,OPCODE_##INS##_mem_b) +#define __INLINE_24_TMP2_POKE__(P,C,OPCw,OPCb) \ + __INLINE_24_BCC_POKE__(P,C,OPCw,OPCb) + +#define __INLINE_24_FAR_POKE__ __INLINE_24_POKE__ diff --git a/thirdparty/grx249/src/include/clipping.h b/thirdparty/grx249/src/include/clipping.h new file mode 100644 index 0000000..b2a6079 --- /dev/null +++ b/thirdparty/grx249/src/include/clipping.h @@ -0,0 +1,239 @@ +/** + ** clipping.h ---- macros to clip pixels lines and boxes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __CLIPPING_H_INCLUDED__ +#define __CLIPPING_H_INCLUDED__ + +#ifndef __ARITH_H_INCLUDED__ +#include "arith.h" +#endif + +/* + * clip pixels and pixel ranges to the clip box + */ +#define clip_xdot_(c,x,when_out) { \ + if((x > c->gc_xcliphi) || (x < c->gc_xcliplo)) { when_out; } \ +} + +#define clip_ydot_(c,y,when_out) { \ + if((y > c->gc_ycliphi) || (y < c->gc_ycliplo)) { when_out; } \ +} + +#define clip_dot_(c,x,y,when_out) { \ + clip_xdot_(c,x,when_out); \ + clip_ydot_(c,y,when_out); \ +} + +#define clip_ordxrange_(c,x1,x2,when_out,when_clip) { \ + if(x1 > c->gc_xcliphi) { when_out; } \ + if(x2 < c->gc_xcliplo) { when_out; } \ + if(x1 < c->gc_xcliplo) { x1 = c->gc_xcliplo; when_clip; } \ + if(x2 > c->gc_xcliphi) { x2 = c->gc_xcliphi; when_clip; } \ +} + +#define clip_ordyrange_(c,y1,y2,when_out,when_clip) { \ + if(y1 > c->gc_ycliphi) { when_out; } \ + if(y2 < c->gc_ycliplo) { when_out; } \ + if(y1 < c->gc_ycliplo) { y1 = c->gc_ycliplo; when_clip; } \ + if(y2 > c->gc_ycliphi) { y2 = c->gc_ycliphi; when_clip; } \ +} + +#define clip_xrange_(c,x1,x2,when_out,when_clip) { \ + isort(x1,x2); \ + clip_ordxrange_(c,x1,x2,when_out,when_clip); \ +} + +#define clip_yrange_(c,y1,y2,when_out,when_clip) { \ + isort(y1,y2); \ + clip_ordyrange_(c,y1,y2,when_out,when_clip); \ +} + +#define clip_ordbox_(c,x1,y1,x2,y2,when_out,when_clip) { \ + clip_ordxrange_(c,x1,x2,when_out,when_clip); \ + clip_ordyrange_(c,y1,y2,when_out,when_clip); \ +} + +#define clip_box_(c,x1,y1,x2,y2,when_out,when_clip) { \ + clip_xrange_(c,x1,x2,when_out,when_clip); \ + clip_yrange_(c,y1,y2,when_out,when_clip); \ +} + +/* + * clip pixels and pixel ranges to the full context + */ +#define cxclip_xdot_(c,x,when_out) { \ + if((unsigned int)x > (unsigned int)c->gc_xmax) { when_out; } \ +} + +#define cxclip_ydot_(c,y,when_out) { \ + if((unsigned int)y > (unsigned int)c->gc_ymax) { when_out; } \ +} + +#define cxclip_dot_(c,x,y,when_out) { \ + cxclip_xdot_(c,x,when_out); \ + cxclip_ydot_(c,y,when_out); \ +} + +#define cxclip_ordxrange_(c,x1,x2,when_out,when_clip) { \ + if(x1 > c->gc_xmax) { when_out; } \ + if(x2 < 0) { when_out; } \ + if(x1 < 0) { x1 = 0; when_clip; } \ + if(x2 > c->gc_xmax) { x2 = c->gc_xmax; when_clip; } \ +} + +#define cxclip_ordyrange_(c,y1,y2,when_out,when_clip) { \ + if(y1 > c->gc_ymax) { when_out; } \ + if(y2 < 0) { when_out; } \ + if(y1 < 0) { y1 = 0; when_clip; } \ + if(y2 > c->gc_ymax) { y2 = c->gc_ymax; when_clip; } \ +} + +#define cxclip_xrange_(c,x1,x2,when_out,when_clip) { \ + isort(x1,x2); \ + cxclip_ordxrange_(c,x1,x2,when_out,when_clip); \ +} + +#define cxclip_yrange_(c,y1,y2,when_out,when_clip) { \ + isort(y1,y2); \ + cxclip_ordyrange_(c,y1,y2,when_out,when_clip); \ +} + +#define cxclip_ordbox_(c,x1,y1,x2,y2,when_out,when_clip) { \ + cxclip_ordxrange_(c,x1,x2,when_out,when_clip); \ + cxclip_ordyrange_(c,y1,y2,when_out,when_clip); \ +} + +#define cxclip_box_(c,x1,y1,x2,y2,when_out,when_clip) { \ + cxclip_xrange_(c,x1,x2,when_out,when_clip); \ + cxclip_yrange_(c,y1,y2,when_out,when_clip); \ +} + +/* + * clip lines to the clip box + */ +#define clip_hline_(c,x1,x2,y,when_out,when_clip) { \ + clip_ydot_(c,y,when_out); \ + clip_xrange_(c,x1,x2,when_out,when_clip); \ +} + +#define clip_vline_(c,x,y1,y2,when_out,when_clip) { \ + clip_xdot_(c,x,when_out); \ + clip_yrange_(c,y1,y2,when_out,when_clip); \ +} + +#define clip_line_xmin_(c,x1,y1,x2,y2,when_clip) { \ + if(x1 < c->gc_xcliplo) { \ + y1 += irscale((y2 - y1),(c->gc_xcliplo - x1),(x2 - x1)); \ + x1 = c->gc_xcliplo; \ + when_clip; \ + } \ +} + +#define clip_line_xmax_(c,x1,y1,x2,y2,when_clip) { \ + if(x2 > c->gc_xcliphi) { \ + y2 -= irscale((y2 - y1),(x2 - c->gc_xcliphi),(x2 - x1)); \ + x2 = c->gc_xcliphi; \ + when_clip; \ + } \ +} + +#define clip_line_ymin_(c,x1,y1,x2,y2,when_clip) { \ + if(y1 < c->gc_ycliplo) { \ + x1 += irscale((x2 - x1),(c->gc_ycliplo - y1),(y2 - y1)); \ + y1 = c->gc_ycliplo; \ + when_clip; \ + } \ +} + +#define clip_line_ymax_(c,x1,y1,x2,y2,when_clip) { \ + if(y2 > c->gc_ycliphi) { \ + x2 -= irscale((x2 - x1),(y2 - c->gc_ycliphi),(y2 - y1)); \ + y2 = c->gc_ycliphi; \ + when_clip; \ + } \ +} + +#define clip_line_(c,x1,y1,x2,y2,when_out,when_clip) { \ + if(x1 < x2) { \ + if(x2 < c->gc_xcliplo) { when_out; } \ + if(x1 > c->gc_xcliphi) { when_out; } \ + clip_line_xmin_(c,x1,y1,x2,y2,when_clip); \ + clip_line_xmax_(c,x1,y1,x2,y2,when_clip); \ + } \ + else { \ + if(x1 < c->gc_xcliplo) { when_out; } \ + if(x2 > c->gc_xcliphi) { when_out; } \ + clip_line_xmin_(c,x2,y2,x1,y1,when_clip); \ + clip_line_xmax_(c,x2,y2,x1,y1,when_clip); \ + } \ + if(y1 < y2) { \ + if(y2 < c->gc_ycliplo) { when_out; } \ + if(y1 > c->gc_ycliphi) { when_out; } \ + clip_line_ymin_(c,x1,y1,x2,y2,when_clip); \ + clip_line_ymax_(c,x1,y1,x2,y2,when_clip); \ + } \ + else { \ + if(y1 < c->gc_ycliplo) { when_out; } \ + if(y2 > c->gc_ycliphi) { when_out; } \ + clip_line_ymin_(c,x2,y2,x1,y1,when_clip); \ + clip_line_ymax_(c,x2,y2,x1,y1,when_clip); \ + } \ +} + +/* + * clipping with default actions: outside => return, clipped => nothing + */ +/* some systems have problems with emtpy macro args ... */ +#if defined(__GNUC__) || defined(__TURBOC__) +#define CLIP_EMPTY_MACRO_ARG +#endif + +#ifndef CLIP_EMPTY_MACRO_ARG +#define CLIP_EMPTY_MACRO_ARG do ; while(0) +#endif + +#define clip_xdot(c,x) clip_xdot_(c,x,return) +#define clip_ydot(c,x) clip_ydot_(c,y,return) +#define clip_dot(c,x,y) clip_dot_(c,x,y,return) +#define clip_ordxrange(c,x1,x2) clip_ordxrange_(c,x1,x2,return,CLIP_EMPTY_MACRO_ARG) +#define clip_ordyrange(c,y1,y2) clip_ordyrange_(c,y1,y2,return,CLIP_EMPTY_MACRO_ARG) +#define clip_xrange(c,x1,x2) clip_xrange_(c,x1,x2,return,CLIP_EMPTY_MACRO_ARG) +#define clip_yrange(c,y1,y2) clip_yrange_(c,y1,y2,return,CLIP_EMPTY_MACRO_ARG) +#define clip_ordbox(c,x1,y1,x2,y2) clip_ordbox_(c,x1,y1,x2,y2,return,CLIP_EMPTY_MACRO_ARG) +#define clip_box(c,x1,y1,x2,y2) clip_box_(c,x1,y1,x2,y2,return,CLIP_EMPTY_MACRO_ARG) + +#define cxclip_xdot(c,x) cxclip_xdot_(c,x,return) +#define cxclip_ydot(c,x) cxclip_ydot_(c,y,return) +#define cxclip_dot(c,x,y) cxclip_dot_(c,x,y,return) +#define cxclip_ordxrange(c,x1,x2) cxclip_ordxrange_(c,x1,x2,return,CLIP_EMPTY_MACRO_ARG) +#define cxclip_ordyrange(c,y1,y2) cxclip_ordyrange_(c,y1,y2,return,CLIP_EMPTY_MACRO_ARG) +#define cxclip_xrange(c,x1,x2) cxclip_xrange_(c,x1,x2,return,CLIP_EMPTY_MACRO_ARG) +#define cxclip_yrange(c,y1,y2) cxclip_yrange_(c,y1,y2,return,CLIP_EMPTY_MACRO_ARG) +#define cxclip_ordbox(c,x1,y1,x2,y2) cxclip_ordbox_(c,x1,y1,x2,y2,return,CLIP_EMPTY_MACRO_ARG) +#define cxclip_box(c,x1,y1,x2,y2) cxclip_box_(c,x1,y1,x2,y2,return,CLIP_EMPTY_MACRO_ARG) + +#define clip_hline(c,x1,x2,y) clip_hline_(c,x1,x2,y,return,CLIP_EMPTY_MACRO_ARG) +#define clip_vline(c,x,y1,y2) clip_vline_(c,x,y1,y2,return,CLIP_EMPTY_MACRO_ARG) +#define clip_line_xmin(c,x1,y1,x2,y2) clip_line_xmin_(c,x1,y1,x2,y2,CLIP_EMPTY_MACRO_ARG) +#define clip_line_xmax(c,x1,y1,x2,y2) clip_line_xmax_(c,x1,y1,x2,y2,CLIP_EMPTY_MACRO_ARG) +#define clip_line_ymin(c,x1,y1,x2,y2) clip_line_ymin_(c,x1,y1,x2,y2,CLIP_EMPTY_MACRO_ARG) +#define clip_line_ymax(c,x1,y1,x2,y2) clip_line_ymax_(c,x1,y1,x2,y2,CLIP_EMPTY_MACRO_ARG) +#define clip_line(c,x1,y1,x2,y2) clip_line_(c,x1,y1,x2,y2,return,CLIP_EMPTY_MACRO_ARG) + +#endif /* whole file */ + diff --git a/thirdparty/grx249/src/include/docolor.h b/thirdparty/grx249/src/include/docolor.h new file mode 100644 index 0000000..1c33ace --- /dev/null +++ b/thirdparty/grx249/src/include/docolor.h @@ -0,0 +1,25 @@ +/** + ** docolor.h ---- color mode operation check table + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +extern unsigned int _GrFDdotable8[]; + +#define DOCOLOR8(c,op) (_GrFDdotable8[(op)] ^ (unsigned int)(unsigned char)(c)) + diff --git a/thirdparty/grx249/src/include/gcc/arith.h b/thirdparty/grx249/src/include/gcc/arith.h new file mode 100644 index 0000000..6cdb969 --- /dev/null +++ b/thirdparty/grx249/src/include/gcc/arith.h @@ -0,0 +1,86 @@ +/** + ** arith.h ---- some common integer arithmetic macros/inline functions + ** Special GNU-C handling + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* + * [i|u]scale(X,N,D) + * scale an integer with long intermediate result but without using long + * arithmetic all the way + */ + +#define irscale(X,N,D) ({ \ + register int _SclVal_ = iscale(((int)(X) << 1),N,D); \ + (_SclVal_ + (_SclVal_ >> (bitsof(int) - 1)) + 1) >> 1; \ +}) + +/* ================================================================ */ +/* == 80386 FAMILY == */ +/* ================================================================ */ +#ifdef __i386__ +/* + * replicate_2(byte_or_word_value) + * copy the lower byte(s) of a byte or word into the upper byte(s) + */ + +#define replicate_b2w(BYTE) (__builtin_constant_p(BYTE) ? \ + (long)(0x00000101UL * (GR_int8u)(BYTE)) : \ + ({ \ + register long _repvalue; \ + __asm__( \ + "movzbl %b1,%0 " "\n\t" \ + "movb %b0,%h0 " \ + : "=q" (_repvalue) \ + : "0m" ((char)(BYTE)) \ + ); \ + _repvalue; \ + }) \ +) + +#define replicate_w2l(WORD) (__builtin_constant_p(WORD) ? \ + (long)(0x00010001UL * (GR_int16u)(WORD)) : \ + ({ \ + register long _repvalue; \ + __asm__( \ + "movw %w1,%w0 " "\n\t" \ + "shll $16,%0 " "\n\t" \ + "movw %w1,%w0 " \ + : "=&r" (_repvalue) \ + : "rm" ((GR_int16u)(WORD)) \ + ); \ + _repvalue; \ + }) \ +) + +#define replicate_b2l(BYTE) (__builtin_constant_p(BYTE) ? \ + (long)(0x01010101UL * (GR_int8u)(BYTE)) : \ + ({ \ + register long _repvalue; \ + __asm__( \ + "movb %b1,%b0 " "\n\t" \ + "movb %b0,%h0 " "\n\t" \ + "shll $16,%0 " "\n\t" \ + "movb %b1,%b0 " "\n\t" \ + "movb %b0,%h0 " \ + : "=&q" (_repvalue) \ + : "qm" ((char)(BYTE)) \ + ); \ + _repvalue; \ + }) \ +) + +#endif /* __i386__ */ diff --git a/thirdparty/grx249/src/include/gcc/asmsupp.h b/thirdparty/grx249/src/include/gcc/asmsupp.h new file mode 100644 index 0000000..139660c --- /dev/null +++ b/thirdparty/grx249/src/include/gcc/asmsupp.h @@ -0,0 +1,13 @@ +/* + * Define assembler memonics for asm code creation + * and memonic extensions for different operand sizes + */ + +#define MOV_INS mov +#define XOR_INS xor +#define OR_INS or +#define AND_INS and + +#define OP8b b +#define OP16b w +#define OP32b l diff --git a/thirdparty/grx249/src/include/gcc/highlow.h b/thirdparty/grx249/src/include/gcc/highlow.h new file mode 100644 index 0000000..573039d --- /dev/null +++ b/thirdparty/grx249/src/include/gcc/highlow.h @@ -0,0 +1,56 @@ +/** + ** highlow.h ---- combining two BYTES into one WORD -- GNU-C special + ** + ** Copyright (c) 1997 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* ================================================================ */ +/* == 80386 FAMILY == */ +/* ================================================================ */ +#ifdef __i386__ +#if __GNUC_MAJOR__==2 && __GNUC_MINOR__<=8 +/* should not be used for EGCS/GCC after v2.8.x */ + +/* combine two bytes into one word: optimized i386 version */ +#define highlow(hi,lo) ({ \ + register GR_int32u _res_; \ + if(__builtin_constant_p((hi))&& __builtin_constant_p((lo))) \ + _res_ = __highlow__((hi),(lo)); \ + else \ + if(__builtin_constant_p((hi))) \ + __asm__ volatile( " movb %b1,%b0" \ + : "=&q" (_res_) \ + : "qnm" ((GR_int8u)(lo)), "0" (((int)(hi))<<8) ); \ + else \ + __asm__ volatile( " movb %b1,%h0" \ + : "=&q" (_res_) \ + : "qnm" ((GR_int8u)(hi)), "0" ((int)(lo)) ); \ + _res_; \ +}) + + +/* high from *p / low from *(p+1) */ +#define highlowP(p) ({ \ + register GR_int32u _res_; \ + __asm__ volatile( "xorl %0,%0 \n\t" \ + "movw (%1),%w0 \n\t" \ + "exch %b0,%h0 " \ + : "=&q" (_res_) \ + : "r" ((GR_int8u *)(p)) \ + ); \ + _res_; \ +}) + +#endif /* __GNUC_MAJOR__==2 && __GNUC_MINOR__<=8 */ +#endif /* __i386__ */ diff --git a/thirdparty/grx249/src/include/gcc/memcopy.h b/thirdparty/grx249/src/include/gcc/memcopy.h new file mode 100644 index 0000000..95b27eb --- /dev/null +++ b/thirdparty/grx249/src/include/gcc/memcopy.h @@ -0,0 +1,243 @@ +/** + ** memcopy.h ---- inline assembly memory copy macros -- GNU-C code + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* ================================================================ */ +/* == 80386 FAMILY == */ +/* ================================================================ */ +#ifdef __i386__ + +#ifndef MOV_INS +#include "gcc/asmsupp.h" +#endif + +#define __INLINE_386_ROWCOPY__(D,S,C,SIZE) ({ \ + __asm__ volatile( \ + " cld \n" \ + " rep \n" \ + " movs"#SIZE \ + : "=D" ((void *)(D)), "=S" ((void *)(S)), "=c" ((int)(C)) \ + : "0" ((void *)(D)), "1" ((void *)(S)), "2" ((int)(C)) \ + : "memory" \ + ); \ +}) + +#define __INLINE_STD_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) \ + __INLINE_386_ROWCOPY__(D,S,C,SIZE) + +#define __INLINE_386_G_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL) ({ \ + register TYPE _scr_; \ + __asm__ volatile("" \ + " incl %2 \n" \ + " shrl $1,%2 \n" \ + " jnc 1f \n" \ + " jmp 0f \n" \ + " .align 4,0x90 \n" \ + "0: "#SIN""#SIZE" "#SSEL"(%1),%3 \n" \ + " addl %8,%1 \n" \ + " "#DIN""#SIZE" %3,"#DSEL"(%0) \n" \ + " addl %7,%0 \n" \ + "1: "#SIN""#SIZE" "#SSEL"(%1),%3 \n" \ + " addl %8,%1 \n" \ + " "#DIN""#SIZE" %3,"#DSEL"(%0) \n" \ + " addl %7,%0 \n" \ + " decl %2 \n" \ + " jne 0b" \ + : "=r" ((void *)(DP)),"=r" ((void *)(SP)),"=r" ((int)(C)), \ + "=&q" ((TYPE)_scr_) \ + : "0" ((void *)(DP)),"1" ((void *)(SP)), "2" ((int)(C)), \ + "gn" ((int)(DS)), "gn" ((int)(SS)) \ + : "memory" \ + ); \ +}) + +#define __INLINE_386_C_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,DINC,SINC) ({\ + register TYPE _scr_; \ + __asm__ volatile("" \ + " incl %2 \n" \ + " shrl $1,%2 \n" \ + " jnc 1f \n" \ + " jmp 0f \n" \ + " .align 4,0x90 \n" \ + "0: "#SIN""#SIZE" "#SSEL"(%1),%3 \n" \ + " " SINC " \n" \ + " "#DIN""#SIZE" %3,"#DSEL"(%0) \n" \ + " " DINC " \n" \ + "1: "#SIN""#SIZE" "#SSEL"(%1),%3 \n" \ + " " SINC " \n" \ + " "#DIN""#SIZE" %3,"#DSEL"(%0) \n" \ + " " DINC " \n" \ + " decl %2 \n" \ + " jne 0b" \ + : "=r" ((void *)(DP)),"=r" ((void *)(SP)),"=r" ((int)(C)), \ + "=&q" ((TYPE)_scr_) \ + : "0" ((void *)(DP)),"1" ((void *)(SP)), "2" ((int)(C)) \ + : "memory" \ + ); \ +}) + +#define __INLINE_386_C2_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,DINC) ({\ + if( (SS) == 1 ) \ + __INLINE_386_C_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,DINC,"incl %1");\ + else \ + if( (SS) == -1 ) \ + __INLINE_386_C_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,DINC,"decl %1");\ + else \ + if( (SS) == 2 ) \ + __INLINE_386_C_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,DINC,"leal 2(%1),%1");\ + else \ + if( (SS) == -2 ) \ + __INLINE_386_C_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,DINC,"leal -2(%1),%1");\ + else \ + if( (SS) == 4 ) \ + __INLINE_386_C_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,DINC,"leal 4(%1),%1");\ + else \ + if( (SS) == -4 ) \ + __INLINE_386_C_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,DINC,"leal -4(%1),%1");\ + else \ + __INLINE_386_G_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL); \ +}) + +#define __INLINE_386_C1_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL) ({ \ + if( (DS) == 1 ) \ + __INLINE_386_C2_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,"incl %0");\ + else \ + if( (DS) == -1 ) \ + __INLINE_386_C2_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,"decl %0");\ + else \ + if( (DS) == 2 ) \ + __INLINE_386_C2_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,"leal 2(%0),%0");\ + else \ + if( (DS) == -2 ) \ + __INLINE_386_C2_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,"leal -2(%0),%0");\ + else \ + if( (DS) == 4 ) \ + __INLINE_386_C2_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,"leal 4(%0),%0");\ + else \ + if( (DS) == -4 ) \ + __INLINE_386_C2_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL,"leal -4(%0),%0");\ + else \ + __INLINE_386_G_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL); \ +}) + + +#define __INLINE_386_COLCOPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL) ({ \ + if(__builtin_constant_p(DS) && __builtin_constant_p(SS) ) \ + __INLINE_386_C1_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL); \ + else \ + __INLINE_386_G_COPY__(DP,DS,SP,SS,C,DIN,SIN,SIZE,TYPE,DSEL,SSEL); \ +}) + +#define __INLINE_SEGSEG_ROWCOPY__(D,S,C,SZ,T,DS,SS) \ + __INLINE_386_COLCOPY__(D,CPSIZE_##SZ,S,CPSIZE_##SZ,C,mov,mov,SZ,T,DS,SS) + +/* memory -> memory copies */ +#define __INLINE_STD_COLCOPY__(D,DSKP,S,SSKP,C,DM,SM,INS,SIZE,TYPE) \ + __INLINE_386_COLCOPY__(D,DSKP,S,SSKP,C,INS,mov,SIZE,TYPE,,) +#ifdef I386_GCC_FAR_MEMORY +/* memory -> video copies */ +#define __INLINE_FAR_STD_COLCOPY__(DST,DSKP,SRC,SSKP,C,DM,SM,INS,SIZE,TYPE) \ + __INLINE_386_COLCOPY__(DST,DSKP,SRC,SSKP,C,INS,mov,SIZE,TYPE,%%fs:,) +#define __INLINE_FAR_STD_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) \ + __INLINE_SEGSEG_ROWCOPY__(D,S,C,SIZE,TYPE,%%fs:,) +/* video -> memory copies */ +#define __INLINE_STD_FAR_COLCOPY__(DST,DSKP,SRC,SSKP,C,DM,SM,INS,SIZE,TYPE) \ + __INLINE_386_COLCOPY__(DST,DSKP,SRC,SSKP,C,INS,mov,SIZE,TYPE,,%%fs:) +#define __INLINE_STD_FAR_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) \ + __INLINE_SEGSEG_ROWCOPY__(D,S,C,SIZE,TYPE,,%%fs:) +/* video -> video copies */ +#define __INLINE_FAR_FAR_COLCOPY__(DST,DSKP,SRC,SSKP,C,DM,SM,INS,SIZE,TYPE) \ + __INLINE_386_COLCOPY__(DST,DSKP,SRC,SSKP,C,INS,mov,SIZE,TYPE,%%fs:,%%fs:) +#define __INLINE_FAR_FAR_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) \ + __INLINE_SEGSEG_ROWCOPY__(D,S,C,SIZE,TYPE,%%fs:,%%fs:) +#else /* I386_GCC_FAR_MEMORY */ +#define __INLINE_FAR_STD_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) \ + __INLINE_STD_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) +#define __INLINE_STD_FAR_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) \ + __INLINE_STD_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) +#define __INLINE_FAR_FAR_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) \ + __INLINE_STD_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) +#endif /* I386_GCC_FAR_MEMORY */ + +#define fwdcopy_set(AP,D,S,C) do { \ + int _scr_; \ + if ((AP)==(D)) \ + __asm__ volatile("\n" \ + " cld \n" \ + " cmpl $4,%2 \n" \ + " jb 3f \n" \ + " testl $1,%0 \n" \ + " je 1f \n" \ + " movsb \n" \ + " decl %2 \n" \ + "1: testl $2,%0 \n" \ + " je 2f \n" \ + " movsw \n" \ + " decl %2 \n" \ + " decl %2 \n" \ + "2: movl %2,%3 \n" \ + " shrl $2,%3 \n" \ + " je 3f \n" \ + " rep \n" \ + " movsl \n" \ + "3: testl $2,%2 \n" \ + " je 4f \n" \ + " movsw \n" \ + "4: testl $1,%2 \n" \ + " je 5f \n" \ + " movsb \n" \ + "5: " \ + : "=D" ((void *)(D)),"=S" ((void *)(S)),"=r" ((int)(C)), \ + "=&c" ((int)_scr_) \ + : "0" ((void *)(D)), "1" ((void *)(S)), "2" ((int)(C)) \ + : "memory" \ + ); \ + else \ + __asm__ volatile("\n" \ + " cld \n" \ + " cmpl $4,%2 \n" \ + " jb 3f \n" \ + " testl $1,%1 \n" \ + " je 1f \n" \ + " movsb \n" \ + " decl %2 \n" \ + "1: testl $2,%1 \n" \ + " je 2f \n" \ + " movsw \n" \ + " decl %2 \n" \ + " decl %2 \n" \ + "2: movl %2,%3 \n" \ + " shrl $2,%3 \n" \ + " je 3f \n" \ + " rep \n" \ + " movsl \n" \ + "3: testl $2,%2 \n" \ + " je 4f \n" \ + " movsw \n" \ + "4: testl $1,%2 \n" \ + " je 5f \n" \ + " movsb \n" \ + "5: " \ + : "=D" ((void *)(D)),"=S" ((void *)(S)),"=r" ((int)(C)), \ + "=&c" ((int)_scr_) \ + : "0" ((void *)(D)), "1" ((void *)(S)), "2" ((int)(C)) \ + : "memory" \ + ); \ +} while (0) + +#endif /* __i386__ */ + diff --git a/thirdparty/grx249/src/include/gcc/memfill.h b/thirdparty/grx249/src/include/gcc/memfill.h new file mode 100644 index 0000000..f10cd1d --- /dev/null +++ b/thirdparty/grx249/src/include/gcc/memfill.h @@ -0,0 +1,274 @@ +/** + ** memfill.h ---- inline assembly memory fill macros -- GNU-C code + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* ================================================================ */ +/* == 80386 FAMILY == */ +/* ================================================================ */ +#ifdef __i386__ + +#ifndef MOV_INS +#include "gcc/asmsupp.h" +#endif + +/* + * Unoptimized row and column fills + */ +#define __INLINE_386_ROWFILL__(P,V,C,SIZE,TYPE) ({ \ + __asm__ volatile( \ + " cld \n" \ + " rep \n" \ + " stos"#SIZE \ + : "=D" ((void *)(P)), "=c" ((int)(C)) \ + : "0" ((void *)(P)), "1" ((int)(C)), \ + "a" ((TYPE)(V)) \ + : "memory" \ + ); \ +}) +#define __INLINE_STD_ROWFILL__(P,V,C,FMODE,SIZE,TYPE) \ + __INLINE_386_ROWFILL__(P,V,C,SIZE,TYPE) + +#define __INLINE_386_COLFILL__(P,V,C,SKIP,INS,SIZE,TYPE,SEL) ({ \ + if(__builtin_constant_p(SKIP) && ((SKIP) == 1)) \ + __asm__ volatile("" \ + " incl %1 \n" \ + " shrl $1,%1 \n" \ + " jnc 1f \n" \ + " jmp 0f \n" \ + " .align 4,0x90 \n" \ + "0: "#INS""#SIZE" %4,"#SEL"(%0) \n" \ + " incl %0 \n" \ + "1: "#INS""#SIZE" %4,"#SEL"(%0) \n" \ + " incl %0 \n" \ + " decl %1 \n" \ + " jne 0b" \ + : "=r" ((void *)(P)), "=r" ((int)(C)) \ + : "0" ((void *)(P)), "1" ((int)(C)), \ + "qn" ((TYPE)(V)) \ + : "memory" \ + ); \ + else \ + if(__builtin_constant_p(SKIP) && ((SKIP) == 2)) \ + __asm__ volatile("" \ + " incl %1 \n" \ + " shrl $1,%1 \n" \ + " jnc 1f \n" \ + " jmp 0f \n" \ + " .align 4,0x90 \n" \ + "0: "#INS""#SIZE" %4,"#SEL"(%0) \n" \ + " leal 2(%0),%0 \n" \ + "1: "#INS""#SIZE" %4,"#SEL"(%0) \n" \ + " leal 2(%0),%0 \n" \ + " decl %1 \n" \ + " jne 0b" \ + : "=r" ((void *)(P)), "=r" ((int)(C)) \ + : "0" ((void *)(P)), "1" ((int)(C)), \ + "qn" ((TYPE)(V)) \ + : "memory" \ + ); \ + else \ + if(__builtin_constant_p(SKIP) && ((SKIP) == 4)) \ + __asm__ volatile("" \ + " incl %1 \n" \ + " shrl $1,%1 \n" \ + " jnc 1f \n" \ + " jmp 0f \n" \ + " .align 4,0x90 \n" \ + "0: "#INS""#SIZE" %4,"#SEL"(%0) \n" \ + " leal 4(%0),%0 \n" \ + "1: "#INS""#SIZE" %4,"#SEL"(%0) \n" \ + " leal 4(%0),%0 \n" \ + " decl %1 \n" \ + " jne 0b" \ + : "=r" ((void *)(P)), "=r" ((int)(C)) \ + : "0" ((void *)(P)), "1" ((int)(C)), \ + "qn" ((TYPE)(V)) \ + : "memory" \ + ); \ + else \ + __asm__ volatile("" \ + " incl %1 \n" \ + " shrl $1,%1 \n" \ + " jnc 1f \n" \ + " jmp 0f \n" \ + " .align 4,0x90 \n" \ + "0: "#INS""#SIZE" %5,"#SEL"(%0) \n" \ + " addl %4,%0 \n" \ + "1: "#INS""#SIZE" %5,"#SEL"(%0) \n" \ + " addl %4,%0 \n" \ + " decl %1 \n" \ + " jne 0b" \ + : "=r" ((void *)(P)), "=r" ((int)(C)) \ + : "0" ((void *)(P)), "1" ((int)(C)), \ + "ng" ((int)(SKIP)), "qn" ((TYPE)(V)) \ + : "memory" \ + ); \ +}) +#define __INLINE_STD_COLFILL__(P,V,C,SKIP,FMODE,INS,SIZE,TYPE) \ + __INLINE_386_COLFILL__(P,V,C,SKIP,INS,SIZE,TYPE,) +#ifdef I386_GCC_FAR_MEMORY +#define __INLINE_FAR_COLFILL__(P,V,C,SKIP,FMODE,INS,SIZE,TYPE) \ + __INLINE_386_COLFILL__(P,V,C,SKIP,INS,SIZE,TYPE,%%fs:) +#else /* I386_GCC_FAR_MEMORY */ +#define __INLINE_FAR_ROWFILL__(P,V,C,FMODE,SIZE,TYPE) \ + __INLINE_STD_ROWFILL__(P,V,C,FMODE,SIZE,TYPE) +#endif /* I386_GCC_FAR_MEMORY */ + +/* ============================================ special optimized fills */ + +/* optimized byte based fill: +** if (c&(~3)) { (* c >= 4 *) +** if (p&1) write 8bit, p++, c--; +** if (p&2) write 16bit, p+=2, c-=2; +** if (c&(~3)) { (* c >= 4 *) +** c>>2 times: write 32bit, p+=4; +** } +** } +** if (c&2) write 16bit, p += 2; +** if (c&1) write 8bit, p++; +*/ +#define repfill_b(p,v,c) do { \ + asm volatile("" \ + " testl $-4,%%ecx \n" \ + " je 2f \n" \ + " testl $1,%%edi \n" \ + " je 0f \n" \ + " movb %%al,(%%edi) \n" \ + " incl %%edi \n" \ + " decl %%ecx \n" \ + "0: testl $2,%%edi \n" \ + " je 1f \n" \ + " movw %%ax,(%%edi) \n" \ + " leal -2(%%ecx),%%ecx \n" \ + " leal 2(%%edi),%%edi \n" \ + "1: testl $-4,%%ecx \n" \ + " je 2f \n" \ + " pushl %%ecx \n" \ + " shrl $2,%%ecx \n" \ + " cld \n" \ + " rep \n" \ + " stosl \n" \ + " popl %%ecx \n" \ + "2: testb $2,%%cl \n" \ + " je 3f \n" \ + " movw %%ax,(%%edi) \n" \ + " leal 2(%%edi),%%edi \n" \ + "3: testb $1,%%cl \n" \ + " je 4f \n" \ + " movb %%al,(%%edi) \n" \ + " incl %%edi \n" \ + "4: " \ + : "=c" ((unsigned int) (c)), \ + "=D" ((void *)(p)) \ + : "0" ((unsigned int) (c)), \ + "1" ((void *)(p)), \ + "a" ((GR_int32u)(v)) \ + : "memory" \ + ); \ +} while (0) + +#ifndef I386_GCC_FAR_MEMORY +/* Video memory is near: use optimized code */ +#define repfill_b_f(p,v,c) repfill_b((p),(v),(c)) +#endif + +/* ====================================================== 24bpp support */ + +#define __INLINE_386_REPFILL24__(p,c,b,INS,SEG) do { \ + int _dummy_; \ + __asm__ volatile ( "\n" \ + " testl $1,%0 \n" \ + " je 1f \n" \ + " "#INS"b %%dl,"#SEG"(%0) \n" \ + " incl %0 \n" \ + " decl %1 \n" \ + " shll $8,%%edx \n" \ + " movb %%dh,%%dl \n" \ + " rorl $16,%%edx \n" \ + "1: testl $2,%0 \n" \ + " je 2f \n" \ + " "#INS"w %%dx,"#SEG"(%0) \n" \ + " leal 2(%0),%0 \n" \ + " leal -2(%1),%1 \n" \ + " roll $16,%%edx \n" \ + " movb %%dl,%%dh \n" \ + " shrl $8,%%edx \n" \ + "2: cmpl $4,%1 \n" \ + " jb 7f \n" \ + " movl %%edx,%%eax \n" \ + " shl $8,%%eax \n" \ + " shldl $8,%%eax,%%edx \n" \ + " movl %%edx,%%ecx \n" \ + " shl $8,%%ecx \n" \ + " movb %%ah,%%al \n" \ + " rorl $8,%%eax \n" \ + " movb %%ah,%%cl \n" \ + /* now we have : eax=La, ecx=Lb, edx=Lc */ \ + " subl $12,%1 \n" \ + " jb 4f \n" \ + " jmp 3f \n" \ + " .align 4,0x90 \n" \ + "3: "#INS"l %%eax,"#SEG"(%0) \n" \ + " leal 4(%0),%0 \n" \ + " "#INS"l %%ecx,"#SEG"(%0) \n" \ + " leal 4(%0),%0 \n" \ + " "#INS"l %%edx,"#SEG"(%0) \n" \ + " leal 4(%0),%0 \n" \ + " subl $12,%1 \n" \ + " jnb 3b \n" \ + /* 0 .. 11 bytes left */ \ + "4: leal 12(%1),%1 \n" \ + " cmpl $4,%1 \n" \ + " jnb 5f \n" \ + " movl %%eax,%%edx \n" \ + " jmp 7f \n" \ + "5: "#INS"l %%eax,"#SEG"(%0) \n" \ + " leal -4(%1),%1 \n" \ + " leal 4(%0),%0 \n" \ + " cmpl $4,%1 \n" \ + " jnb 6f \n" \ + " movl %%ecx,%%edx \n" \ + " jmp 7f \n" \ + "6: "#INS"l %%ecx,"#SEG"(%0) \n" \ + " leal 4(%0),%0 \n" \ + /* 0 .. 3 bytes left */ \ + "7: testl $2,%1 \n" \ + " je 8f \n" \ + " "#INS"w %%dx,"#SEG"(%0) \n" \ + " leal 2(%0),%0 \n" \ + " shrl $16,%%edx \n" \ + "8: testl $1,%1 \n" \ + " je 9f \n" \ + " "#INS"b %%dl,"#SEG"(%0) \n" \ + " incl %0 \n" \ + "9: \n" \ + : "=r" ((void *)(p)), "=r" ((int)(b)), "=d" (_dummy_) \ + : "2" ((int)(c)), "0" ((void *)(p)), "1" ((int)(b)) \ + : "ax", "cx", "memory" \ + ); \ +} while (0) + +#define __INLINE_24_REPFILL__(P,C,B,FMODE,INS) \ + __INLINE_386_REPFILL24__(P,C,B,INS,) + +#define __INLINE_24_FAR_REPFILL__(P,C,B,FMODE,INS) \ + __INLINE_386_REPFILL24__(P,C,B,INS,%%fs:) + +#define GRX_HAVE_FAST_REPFILL24 + +#endif /* __i386__ */ + diff --git a/thirdparty/grx249/src/include/gcc/memmode.h b/thirdparty/grx249/src/include/gcc/memmode.h new file mode 100644 index 0000000..4c775f0 --- /dev/null +++ b/thirdparty/grx249/src/include/gcc/memmode.h @@ -0,0 +1,54 @@ +/** + ** memmode.h ---- determine how to access video and system RAM + ** GNU-C / DJGPP code + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifdef __i386__ +#ifdef __MSDOS__ + +#include + +#ifdef ECHILD + +#include +#define I386_GCC_FAR_MEMORY +#define LINP_PTR(p) (void *)((long)(p) & 0x00ffffffUL) +#define LINP_SEL(p) _go32_info_block.selector_for_linear_memory +#define XFER_BUFFER _go32_info_block.linear_address_of_transfer_buffer + +#else /* ECHILD */ + +#define LINP_PTR(p) (void *)(((long)(p) & 0x00ffffffUL) | 0xe0000000UL) +#define LINP_SEL(p) 0 +#define XFER_BUFFER __transfer_buffer +extern char *__transfer_buffer; + +#endif /* ECHILD */ +#endif /* __MSDOS__ */ + +#define MK_FP(s,o) (void *)( \ + ((long)(unsigned short)(s) << 4) + \ + (unsigned short)(o) \ +) +#define FP_SEG(p) (unsigned short)((long)(p) >> 4) +#define FP_OFF(p) (unsigned short)((int)(p) & 15) +#define FP86_SEG(p) (unsigned short)((long)(p) >> 16) +#define FP86_OFF(p) (unsigned short)((int)(p)) +#define DECLARE_XFER_BUFFER(size) +#define DELETE_XFER_BUFFER + +#endif /* __i386__ */ diff --git a/thirdparty/grx249/src/include/gcc/mempeek.h b/thirdparty/grx249/src/include/gcc/mempeek.h new file mode 100644 index 0000000..6f9bee1 --- /dev/null +++ b/thirdparty/grx249/src/include/gcc/mempeek.h @@ -0,0 +1,117 @@ +/** + ** mempeek.h ---- (far) memory read/write operations + ** GNU-C special assembler code + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Basic memory peek and poke operations in byte, word and long sizes. + ** The poke operations are available in WRITE, XOR, OR and AND versions. + ** + **/ + +/* ================================================================ */ +/* == 80386 FAMILY == */ +/* ================================================================ */ +#ifdef __i386__ + +/* the far selector peek / poke stuff is only used +** if far memory access is required (DJGPP v2) */ +#ifdef I386_GCC_FAR_MEMORY + +#ifndef MOV_INS +#include "gcc/asmsupp.h" +#endif + +#define __INLINE_386_PEEK__(P,SIZE,T,SEL) ({ \ + unsigned T _peekvalue; \ + if(sizeof(T) == 1) __asm__ volatile( \ + "mov"#SIZE" "#SEL"(%1),%0" \ + : "=q" (_peekvalue) \ + : "r" (((unsigned T *)(P))) \ + ); \ + else __asm__ volatile( \ + "mov"#SIZE" "#SEL"(%1),%0" \ + : "=r" (_peekvalue) \ + : "r" (((unsigned T *)(P))) \ + ); \ + _peekvalue; \ +}) +#define __INLINE_386_POKE__(P,V,INS,SIZE,T,SEL) ({ \ + if(sizeof(T) == 1) __asm__ volatile( \ + ""#INS""#SIZE" %1,"#SEL"%0" \ + : "=m" (*((unsigned T *)(P))) \ + : "qn" ((unsigned T)(V)) \ + ); \ + else __asm__ volatile( \ + ""#INS""#SIZE" %1,"#SEL"%0" \ + : "=m" (*((unsigned T *)(P))) \ + : "rn" ((unsigned T)(V)) \ + ); \ +}) + +#define __INLINE_STD_PEEK__(P,S,T) __INLINE_386_PEEK__(P,S,T,) +#define __INLINE_STD_POKE__(P,V,OP,I,S,T) __INLINE_386_POKE__(P,V,I,S,T,) + +#define I386_GCC_FAR_SELECTOR "%%fs:" +#define __INLINE_FAR_PEEK__(P,S,T) __INLINE_386_PEEK__(P,S,T,%%fs:) +#define __INLINE_FAR_POKE__(P,V,OP,I,S,T) __INLINE_386_POKE__(P,V,I,S,T,%%fs:) +#define setup_far_selector(S) ({ \ + __asm__ volatile( \ + "movw %0,%%fs" \ + : /* no outputs */ \ + : "r" ((unsigned short)(S)) \ + ); \ +}) +#endif /* I386_GCC_FAR_MEMORY */ + +#ifndef I386_GCC_FAR_SELECTOR +#define I386_GCC_FAR_SELECTOR "" +#endif /* I386_GCC_FAR_SELECTOR */ + +#define __INLINE_386_PEEK24__(P,SEL) ({ \ + register GR_int32u _pix_; \ + __asm__ volatile( "\n" \ + " xorl %%eax,%%eax \n" \ + " movb " SEL "2(%1),%%ah \n" \ + " sall $8,%%eax \n" \ + " movw " SEL "(%1),%%ax " \ + : "=&a" ((GR_int32u)_pix_) \ + : "r" ((void *)(P)) \ + ); \ + (GrColor)_pix_; \ +}) + +#define __INLINE_386_POKE24__(P,C,INS,SEL) do { \ + int _dummy_; \ + __asm__ volatile( "\n" \ + " "#INS"w %%ax," SEL "(%2) \n" \ + " shrl $8,%%eax \n" \ + " "#INS"b %%ah," SEL "2(%2) \n" \ + : "=a" (_dummy_) \ + : "0" (C), "r" ((void *)(P)) \ + ); \ +} while (0) + +#define __INLINE_24_PEEK__(p) \ + __INLINE_386_PEEK24__(p,) + +#define __INLINE_24_FAR_PEEK__(p) (peek_l_f(p) & 0xffffff) +#define PEEK_24_F_READS_ONE_MORE + +#define __INLINE_24_POKE__(p,c,op,INS) \ + __INLINE_386_POKE24__(p,c,INS,) +#define __INLINE_24_FAR_POKE__(p,c,op,INS) \ + __INLINE_386_POKE24__(p,c,INS,I386_GCC_FAR_SELECTOR) + +#endif /* __i386__ */ diff --git a/thirdparty/grx249/src/include/grxdebug.h b/thirdparty/grx249/src/include/grxdebug.h new file mode 100644 index 0000000..5c98c43 --- /dev/null +++ b/thirdparty/grx249/src/include/grxdebug.h @@ -0,0 +1,59 @@ +/** + ** grxdebug.h ---- GRX library debug support + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __GRXDEBUG_H_INCLUDED__ +#define __GRXDEBUG_H_INCLUDED__ + +#define DBG_ENTER 0x8000 +#define DBG_LEAVE DBG_ENTER +#define DBG_FONT 0x4000 +#define DBG_SETMD 0x2000 +#define DBG_DRIVER 0x1000 +#define DBG_COLOR 0x0800 +#define DBG_COPYFILL 0x0400 + +extern char *_GR_debug_file; +extern int _GR_debug_line; +extern int _GR_debug_flags; +extern void _GR_debug_printf(char *fmt,...); + +# ifdef __GNUC__ + extern char *_GR_debug_function; +# define DBGPRINTF(tst,x) do { \ + if ((tst)&_GR_debug_flags) { \ + _GR_debug_file = __FILE__; \ + _GR_debug_line = __LINE__; \ + _GR_debug_function = __FUNCTION__; \ + _GR_debug_printf x; \ + } \ + } while (0) +# else +# define DBGPRINTF(tst,x) do { \ + if ((tst)&_GR_debug_flags) { \ + _GR_debug_file = __FILE__; \ + _GR_debug_line = __LINE__; \ + _GR_debug_printf x ; \ + } \ + } while (0) +#endif + +#define GRX_ENTER() DBGPRINTF(DBG_ENTER,("FUNC ENTER\n")) +#define GRX_LEAVE() DBGPRINTF(DBG_LEAVE,("FUNC EXIT\n")) +#define GRX_RETURN(x) GRX_LEAVE(); return x; + +#endif /* whole file */ + diff --git a/thirdparty/grx249/src/include/highlow.h b/thirdparty/grx249/src/include/highlow.h new file mode 100644 index 0000000..8f9588c --- /dev/null +++ b/thirdparty/grx249/src/include/highlow.h @@ -0,0 +1,33 @@ +/** + ** highlow.h ---- combining two BYTES into one WORD + ** + ** Copyright (c) 1997 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* combine two bytes into one word: generic version */ +#define __highlow__(hi,lo) ((((GR_int16u)(hi))<<8)|((GR_int8u)(lo))) + +#ifdef __GNUC__ +#include "gcc/highlow.h" +#elif defined(__TURBOC__) +#include "bcc/highlow.h" +#endif + +#ifndef highlow +#define highlow(hi,lo) __highlow__((hi),(lo)) +#endif + +#ifndef highlowP +#define highlowP(p) highlow(*((GR_int8u *)(p)),*(((GR_int8u *)(p))+1)) +#endif diff --git a/thirdparty/grx249/src/include/int86.h b/thirdparty/grx249/src/include/int86.h new file mode 100644 index 0000000..76662ed --- /dev/null +++ b/thirdparty/grx249/src/include/int86.h @@ -0,0 +1,227 @@ +/** + ** int86.h ---- common ground for DOS/BIOS interrupts under TCC and DJGPP + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __INT86_H_INCLUDED__ +#define __INT86_H_INCLUDED__ + +#ifndef __MEMMODE_H_INCLUDED__ +#include "memmode.h" +#endif + +#if defined(MSDOS) && defined(_MSC_VER) + +#include + +typedef union _REGS Int86Regs; +#define int10(iregp) _int86(0x10,(iregp),(iregp)) +#define int11(iregp) _int86(0x11,(iregp),(iregp)) +#define int16(iregp) _int86(0x16,(iregp),(iregp)) +#define int33(iregp) _int86(0x33,(iregp),(iregp)) + +#define IREG_AX(iregs) ((iregs).x.ax) +#define IREG_BX(iregs) ((iregs).x.bx) +#define IREG_CX(iregs) ((iregs).x.cx) +#define IREG_DX(iregs) ((iregs).x.dx) +#define IREG_SI(iregs) ((iregs).x.si) +#define IREG_DI(iregs) ((iregs).x.di) +/* ==== IREG_BP() not implemented ==== */ +/* ==== IREG_DS() not implemented ==== */ +/* ==== IREG_ES() not implemented ==== */ + + +#define IREG_AL(iregs) ((iregs).h.al) +#define IREG_AH(iregs) ((iregs).h.ah) +#define IREG_BL(iregs) ((iregs).h.bl) +#define IREG_BH(iregs) ((iregs).h.bh) +#define IREG_CL(iregs) ((iregs).h.cl) +#define IREG_CH(iregs) ((iregs).h.ch) +#define IREG_DL(iregs) ((iregs).h.dl) +#define IREG_DH(iregs) ((iregs).h.dh) + +#endif /* _MSC_VER */ + +#ifdef __WATCOMC__ /* GS - WATCOM C++ 11.0 */ +/* Use the 386 enhanced interrupt for 32 bit DOS4GW. */ +#include +#include +#include +#if defined(__386__) && !defined(__WINDOWS_386__) +#define int86(a,b,c) int386(a,&(b->Normal),&(c->Normal)) + +struct ALLREGS +{ + union REGS Normal; + struct SREGS Extended; +}; +typedef struct ALLREGS Int86Regs; + +#define IREG_AX(iregs) ((iregs).Normal.w.ax) +#define IREG_BX(iregs) ((iregs).Normal.w.bx) +#define IREG_CX(iregs) ((iregs).Normal.w.cx) +#define IREG_DX(iregs) ((iregs).Normal.w.dx) +#define IREG_SI(iregs) ((iregs).Normal.w.si) +#define IREG_DI(iregs) ((iregs).Normal.w.di) +#define IREG_EDI(iregs) ((iregs).Normal.x.edi) +#define IREG_BP(iregs) ((iregs).Normal.w.bp) +#define IREG_DS(iregs) ((iregs).Extended.ds) +#define IREG_ES(iregs) ((iregs).Extended.es) + +#define IREG_AL(iregs) ((iregs).Normal.h.al) +#define IREG_AH(iregs) ((iregs).Normal.h.ah) +#define IREG_BL(iregs) ((iregs).Normal.h.bl) +#define IREG_BH(iregs) ((iregs).Normal.h.bh) +#define IREG_CL(iregs) ((iregs).Normal.h.cl) +#define IREG_CH(iregs) ((iregs).Normal.h.ch) +#define IREG_DL(iregs) ((iregs).Normal.h.dl) +#define IREG_DH(iregs) ((iregs).Normal.h.dh) + +/* all int10 calls using the XFER_BUFFER _must_ use int10x ! */ +extern void wc32_int10x(Int86Regs *regs, int seg); +#define int10x(r) wc32_int10x(r, int10_segment) + +#else + +typedef union REGS Int86Regs; + +#define IREG_AX(iregs) ((iregs).x.ax) +#define IREG_BX(iregs) ((iregs).x.bx) +#define IREG_CX(iregs) ((iregs).x.cx) +#define IREG_DX(iregs) ((iregs).x.dx) +#define IREG_SI(iregs) ((iregs).x.si) +#define IREG_DI(iregs) ((iregs).x.di) +#define IREG_BP(iregs) ((iregs).x.bp) +#define IREG_DS(iregs) ((iregs).x.ds) +/* #define IREG_ES(iregs) ((iregs).x.es) */ + +#define IREG_AL(iregs) ((iregs).h.al) +#define IREG_AH(iregs) ((iregs).h.ah) +#define IREG_BL(iregs) ((iregs).h.bl) +#define IREG_BH(iregs) ((iregs).h.bh) +#define IREG_CL(iregs) ((iregs).h.cl) +#define IREG_CH(iregs) ((iregs).h.ch) +#define IREG_DL(iregs) ((iregs).h.dl) +#define IREG_DH(iregs) ((iregs).h.dh) +#endif /* __386__ */ + +/*the standard interrupt macros*/ +#define int10(iregp) int86(0x10,(iregp),(iregp)) +#define int16(iregp) int86(0x16,(iregp),(iregp)) +#define int33(iregp) int86(0x33,(iregp),(iregp)) + +#endif /* __WATCOM__ */ + +#ifdef __MSDOS__ +#ifdef __TURBOC__ + +typedef struct REGPACK Int86Regs; +#define int10(iregp) intr(0x10,(iregp)) +#define int11(iregp) intr(0x11,(iregp)) +#define int16(iregp) intr(0x16,(iregp)) +#define int33(iregp) intr(0x33,(iregp)) + +#define IREG_AX(iregs) ((iregs).r_ax) +#define IREG_BX(iregs) ((iregs).r_bx) +#define IREG_CX(iregs) ((iregs).r_cx) +#define IREG_DX(iregs) ((iregs).r_dx) +#define IREG_SI(iregs) ((iregs).r_si) +#define IREG_DI(iregs) ((iregs).r_di) +#define IREG_BP(iregs) ((iregs).r_bp) +#define IREG_DS(iregs) ((iregs).r_ds) +#define IREG_ES(iregs) ((iregs).r_es) + +#define IREG_AL(iregs) (((unsigned char *)(&(iregs).r_ax))[0]) +#define IREG_AH(iregs) (((unsigned char *)(&(iregs).r_ax))[1]) +#define IREG_BL(iregs) (((unsigned char *)(&(iregs).r_bx))[0]) +#define IREG_BH(iregs) (((unsigned char *)(&(iregs).r_bx))[1]) +#define IREG_CL(iregs) (((unsigned char *)(&(iregs).r_cx))[0]) +#define IREG_CH(iregs) (((unsigned char *)(&(iregs).r_cx))[1]) +#define IREG_DL(iregs) (((unsigned char *)(&(iregs).r_dx))[0]) +#define IREG_DH(iregs) (((unsigned char *)(&(iregs).r_dx))[1]) + +#endif /* __TURBOC__ */ + +#ifdef __GNUC__ +#ifdef I386_GCC_FAR_MEMORY + +#include + +typedef _go32_dpmi_registers Int86Regs; +#define int10(iregp) _go32_dpmi_simulate_int(0x10,(iregp)) +#define int11(iregp) _go32_dpmi_simulate_int(0x11,(iregp)) +#define int16(iregp) _go32_dpmi_simulate_int(0x16,(iregp)) +#define int33(iregp) _go32_dpmi_simulate_int(0x33,(iregp)) + +#define IREG_AX(iregs) ((iregs).x.ax) +#define IREG_BX(iregs) ((iregs).x.bx) +#define IREG_CX(iregs) ((iregs).x.cx) +#define IREG_DX(iregs) ((iregs).x.dx) +#define IREG_SI(iregs) ((iregs).x.si) +#define IREG_DI(iregs) ((iregs).x.di) +#define IREG_BP(iregs) ((iregs).x.bp) +#define IREG_DS(iregs) ((iregs).x.ds) +#define IREG_ES(iregs) ((iregs).x.es) + +#define IREG_AL(iregs) ((iregs).h.al) +#define IREG_AH(iregs) ((iregs).h.ah) +#define IREG_BL(iregs) ((iregs).h.bl) +#define IREG_BH(iregs) ((iregs).h.bh) +#define IREG_CL(iregs) ((iregs).h.cl) +#define IREG_CH(iregs) ((iregs).h.ch) +#define IREG_DL(iregs) ((iregs).h.dl) +#define IREG_DH(iregs) ((iregs).h.dh) + +#else /* I386_GCC_FAR_MEMORY */ + +#include + +typedef union REGS Int86Regs; +#define int10(iregp) int86(0x10,(iregp),(iregp)) +#define int11(iregp) int86(0x11,(iregp),(iregp)) +#define int16(iregp) int86(0x16,(iregp),(iregp)) +#define int33(iregp) int86(0x33,(iregp),(iregp)) + +#define IREG_AX(iregs) ((iregs).x.ax) +#define IREG_BX(iregs) ((iregs).x.bx) +#define IREG_CX(iregs) ((iregs).x.cx) +#define IREG_DX(iregs) ((iregs).x.dx) +#define IREG_SI(iregs) ((iregs).x.si) +#define IREG_DI(iregs) ((iregs).x.di) +/* ==== IREG_BP() not implemented ==== */ +/* ==== IREG_DS() not implemented ==== */ +/* ==== IREG_ES() not implemented ==== */ + +#define IREG_AL(iregs) ((iregs).h.al) +#define IREG_AH(iregs) ((iregs).h.ah) +#define IREG_BL(iregs) ((iregs).h.bl) +#define IREG_BH(iregs) ((iregs).h.bh) +#define IREG_CL(iregs) ((iregs).h.cl) +#define IREG_CH(iregs) ((iregs).h.ch) +#define IREG_DL(iregs) ((iregs).h.dl) +#define IREG_DH(iregs) ((iregs).h.dh) + +#endif /* I386_GCC_FAR_MEMORY */ +#endif /* __GNUC__ */ +#endif /* __MSDOS__ */ + +/* all int10 calls using the XFER_BUFFER _must_ use int10x ! */ +#ifndef int10x +#define int10x(r) int10(r) +#endif + +#endif /* whole file */ + diff --git a/thirdparty/grx249/src/include/ioport.h b/thirdparty/grx249/src/include/ioport.h new file mode 100644 index 0000000..fb26771 --- /dev/null +++ b/thirdparty/grx249/src/include/ioport.h @@ -0,0 +1,342 @@ +/** + ** ioport.h ---- port input/output macros + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Intel CPU specific input/output instructions. This file + ** supports i386 GCC and Turbo C. + ** + **/ + +#ifndef __IOPORT_H_INCLUDED__ +#define __IOPORT_H_INCLUDED__ + +#ifdef __TURBOC__ +/* prototype for __emit__() */ +#include +#endif + +#ifdef _MSC_VER +/* prototype for _inp/_inpw/_outp/_outpw */ +#include +/* prototype _enable/_disable */ +#include +#endif + +#ifdef SLOW_DOWN_IO +#ifndef SLOW_DOWN_IO_PORT +#define SLOW_DOWN_IO_PORT 0x80 +#endif +#ifdef __GNUC__ +#ifdef __i386__ +#define __INLINE_SLOW_IO_ONCE__ ({ \ + __asm__ volatile( \ + "outb %%al,%0" \ + : /* no outputs */ \ + : "n" (SLOW_DOWN_IO_PORT) \ + ); \ +}) +#endif +#endif +#ifdef __TURBOC__ +#define __INLINE_SLOW_IO_ONCE__ ( \ + __emit__((char)(0xe6)), /* outb to const port */ \ + __emit__((char)(SLOW_DOWN_IO_PORT)) \ +) +#endif + +#ifdef _MSC_VER +#define __INLINE_SLOW_IO_ONCE__ outp(SLOW_DOWN_IO_PORT,0) +#endif + +#if (SLOW_DOWN_IO - 0) <= 1 +#define __INLINE_SLOW_DOWN_IO__ \ + __INLINE_SLOW_IO_ONCE__ +#elif (SLOW_DOWN_IO - 0) == 2 +#define __INLINE_SLOW_DOWN_IO__ \ + __INLINE_SLOW_IO_ONCE__, \ + __INLINE_SLOW_IO_ONCE__ +#elif (SLOW_DOWN_IO - 0) == 3 +#define __INLINE_SLOW_DOWN_IO__ \ + __INLINE_SLOW_IO_ONCE__, \ + __INLINE_SLOW_IO_ONCE__, \ + __INLINE_SLOW_IO_ONCE__ +#else +#define __INLINE_SLOW_DOWN_IO__ \ + __INLINE_SLOW_IO_ONCE__, \ + __INLINE_SLOW_IO_ONCE__, \ + __INLINE_SLOW_IO_ONCE__, \ + __INLINE_SLOW_IO_ONCE__ +#endif +#define __INLINE_SLOW_DWN_IOC__ __INLINE_SLOW_DOWN_IO__, +#else /* SLOW_DOWN_IO */ +#define __INLINE_SLOW_DOWN_IO__ +#define __INLINE_SLOW_DWN_IOC__ +#endif + +#ifdef __GNUC__ +#ifdef __i386__ +#define __INLINE_INPORT__(P,SIZE,T) ({ \ + register T _value; \ + __asm__ volatile( \ + "in"#SIZE" %w1,%0" \ + : "=a" (_value) \ + : "Nd" ((unsigned short)(P)) \ + ); \ + __INLINE_SLOW_DOWN_IO__; \ + _value; \ +}) +#define __INLINE_OUTPORT__(P,V,SIZE,T) ({ \ + __asm__ volatile( \ + "out"#SIZE" %"#SIZE"0,%w1" \ + : /* no outputs */ \ + : "a" ((unsigned T)(V)), \ + "Nd" ((unsigned short)(P)) \ + ); \ + __INLINE_SLOW_DOWN_IO__; \ +}) +#ifndef SLOW_DOWN_IO +#define __INLINE_INPORTS__(P,B,C,SIZE,T) ({ \ + register void *_inportptr = ((void *)(B)); \ + register int _inportcnt = ((int)(C)); \ + __asm__ volatile( \ + "cld; " \ + "rep; ins"#SIZE"" \ + : "=D" (_inportptr), "=c" (_inportcnt) \ + : "0" (_inportptr), "1" (_inportcnt), \ + "d" ((unsigned short)(P)) \ + ); \ +}) +#define __INLINE_OUTPORTS__(P,B,C,SIZE,T) ({ \ + register void *_outportptr = ((void *)(B)); \ + register int _outportcnt = ((int)(C)); \ + __asm__ volatile( \ + "cld; " \ + "rep; outs"#SIZE"" \ + : "=S" (_outportptr), "=c" (_outportcnt) \ + : "0" (_outportptr), "1" (_outportcnt), \ + "d" ((unsigned short)(P)) \ + ); \ +}) +#else /* SLOW_DOWN_IO */ +#define __INLINE_INPORTS__(P,B,C,SIZE,T) ({ \ + register T *_inportptr = ((T *)(B)); \ + register int _inportcnt = ((int)(C)); \ + register int _inportadr = ((int)(P)); \ + do *_inportptr++ = inport_##SIZE(_inportadr); \ + while(--_inportcnt); \ +}) +#define __INLINE_OUTPORTS__(P,B,C,SIZE,T) ({ \ + register T *_outportptr = ((T *)(B)); \ + register int _outportcnt = ((int)(C)); \ + register int _outportadr = ((int)(P)); \ + do outport_##SIZE(_outportadr,*_outportptr++); \ + while(--_outportcnt); \ +}) +#endif /* SLOW_DOWN_IO */ +#endif /* __i386__ */ +#endif /* __GNUC__ */ + +#ifdef __TURBOC__ +/* void __emit__(); */ +#define __INLINE_INPORT__(P,SIZE,T) ( \ + _DX = ((unsigned short)(P)), \ + __emit__((char)(0xec+sizeof(T)-1)), /* inB|W */ \ + __INLINE_SLOW_DWN_IOC__ \ + (unsigned T)_AX \ +) +#define __INLINE_OUTPORT__(P,V,SIZE,T) do { \ + _AX = ((unsigned short)(V)); \ + _DX = ((unsigned short)(P)); \ + __emit__((char)(0xee+sizeof(T)-1)); /* outB|W */ \ + __INLINE_SLOW_DOWN_IO__; \ +} while(0) +#ifndef SLOW_DOWN_IO +#define __INLINE_INPORTS__(P,B,C,SIZE,T) do { \ + _ES = (unsigned)(void _seg *)(void far *)(B); \ + _DI = (unsigned)(void near *)(B); \ + _CX = ((unsigned short)(C)); \ + _DX = ((unsigned short)(P)); \ + __emit__((char)(0xfc)); /* cld */ \ + __emit__((char)(0xf3)); /* rep */ \ + __emit__((char)(0x6c+sizeof(T)-1)); /* insB|W */ \ +} while(0) +#define __INLINE_OUTPORTS__(P,B,C,SIZE,T) do { \ + _ES = (unsigned)(void _seg *)(void far *)(B); \ + _SI = (unsigned)(void near *)(B); \ + _CX = ((unsigned short)(C)); \ + _DX = ((unsigned short)(P)); \ + __emit__((char)(0xfc)); /* cld */ \ + __emit__((char)(0x26)); /* seg es */ \ + __emit__((char)(0xf3)); /* rep */ \ + __emit__((char)(0x6e+sizeof(T)-1)); /* outsB|W */ \ +} while(0) +#else /* SLOW_DOWN_IO */ +#define __INLINE_INPORTS__(P,B,C,SIZE,T) do { \ + _ES = (unsigned)(void _seg *)(void far *)(B); \ + _BX = (unsigned)(void near *)(B); \ + _CX = ((unsigned short)(C)); \ + _DX = ((unsigned short)(P)); \ + do { \ + __emit__((char)(0xec+sizeof(T)-1)); /* inB|W */ \ + __INLINE_SLOW_DOWN_IO__; \ + *((T _seg *)_ES + (T near *)_BX) = (T)_AX; \ + _BX += sizeof(T); \ + _CX--; \ + } while(_CX); \ +} while(0) +#define __INLINE_OUTPORTS__(P,B,C,SIZE,T) do { \ + _ES = (unsigned)(void _seg *)(void far *)(B); \ + _BX = (unsigned)(void near *)(B); \ + _CX = ((unsigned short)(C)); \ + _DX = ((unsigned short)(P)); \ + do { \ + (T)_AX = *((T _seg *)_ES + (T near *)_BX); \ + __emit__((char)(0xee+sizeof(T)-1)); /* outB|W */ \ + __INLINE_SLOW_DOWN_IO__; \ + _BX += sizeof(T); \ + _CX--; \ + } while(_CX); \ +} while(0) +#endif /* SLOW_DOWN_IO */ +#endif /* __TURBOC__ */ + +#ifdef __WATCOMC__ /* GS - Watcom C++ 11.0 */ +#include +/* 8bit port access */ +#define inpb(a) inp(a) +#define outpb(a,b) outp(a,b) +/* 16bit port access */ +/* inpw(a) already defined */ +/* outpw(a,b) already defined */ +/* 32bit port access */ +#define inpl(a) inpd(a) +#define outpl(a,b) outpd(a,b) +#define __INLINE_INPORT__(P,SIZE,T) ( \ + (unsigned T) inp##SIZE (P) \ +) +#define __INLINE_OUTPORT__(P,V,SIZE,T) ( \ + (unsigned T) outp##SIZE (P,V) \ +) +#ifndef SLOW_DOWN_IO +#define __INLINE_INPORTS__(P,B,C,SIZE,T) do { \ + do { \ + *B = __INLINE_INPORT__(P,SIZE,T); \ + (T)B ++; \ + } while(C--); \ +} while(0) +#define __INLINE_OUTPORTS__(P,B,C,SIZE,T) do { \ + do{ \ + __INLINE_OUTPORTS__(P,*B,SIZE,T); \ + (T)B ++; \ + } while (C--); \ +} while(0) +#else /* SLOW_DOWN_IO */ +#define __INLINE_INPORTS__(P,B,C,SIZE,T) do { \ + do { \ + *B = __INLINE_INPORT__(P,SIZE,T); \ + (T)B ++; \ + } while(C--); \ +} while(0) +#define __INLINE_OUTPORTS__(P,B,C,SIZE,T) do { \ + do{ \ + __INLINE_OUTPORTS__(P,*B,SIZE,T); \ + (T)B ++; \ + } while (C--); \ +} while(0) +#endif /* SLOW_DOWN_IO */ +#endif /* __WATCOMC__ */ + +#ifdef _MSC_VER +#define inport_b(port) _inp((unsigned)(port)) +#define inport_w(port) _inpw((unsigned)(port)) +#define outport_b(port,val) _outp(((unsigned)(port)),((int)(val))) +#define outport_w(port,val) _outp(((unsigned)(port)),((unsigned)(val))) +#endif + +#ifndef inport_b +#define inport_b(port) __INLINE_INPORT__(port,b,char) +#endif +#ifndef inport_w +#define inport_w(port) __INLINE_INPORT__(port,w,short) +#endif +#ifndef inport_l +#define inport_l(port) __INLINE_INPORT__(port,l,long) +#endif + +#ifndef outport_b +#define outport_b(port,val) __INLINE_OUTPORT__(port,val,b,char) +#endif +#ifndef outport_w +#define outport_w(port,val) __INLINE_OUTPORT__(port,val,w,short) +#endif +#ifndef outport_l +#define outport_l(port,val) __INLINE_OUTPORT__(port,val,l,long) +#endif + +#ifndef inport_b_s +#define inport_b_s(port,buf,cnt) __INLINE_INPORTS__(port,buf,cnt,b,char) +#endif +#ifndef inport_w_s +#define inport_w_s(port,buf,cnt) __INLINE_INPORTS__(port,buf,cnt,w,short) +#endif +#ifndef inport_l_s +#define inport_l_s(port,buf,cnt) __INLINE_INPORTS__(port,buf,cnt,l,long) +#endif + +#ifndef outport_b_s +#define outport_b_s(port,buf,cnt) __INLINE_OUTPORTS__(port,buf,cnt,b,char) +#endif +#ifndef outport_w_s +#define outport_w_s(port,buf,cnt) __INLINE_OUTPORTS__(port,buf,cnt,w,short) +#endif +#ifndef outport_l_s +#define outport_l_s(port,buf,cnt) __INLINE_OUTPORTS__(port,buf,cnt,l,long) +#endif + +#ifdef __GNUC__ +#ifdef __i386__ +#ifdef __MSDOS__ +#define int_disable() ({ __asm__ volatile("cli"); }) +#define int_enable() ({ __asm__ volatile("sti"); }) +#else +#define int_disable() +#define int_enable() +#endif +#endif +#endif + +#ifdef __TURBOC__ +#define int_disable() __emit__((char)(0xfa)) +#define int_enable() __emit__((char)(0xfb)) +#endif + +#if defined(_MSC_VER) || defined(__WATCOMC__) /* GS - Watcom C++ 11.0 */ +#define int_disable() _disable() +#define int_enable() _enable() +#endif + + +#if defined(__TURBOC__) || defined(_MSC_VER) +/* + * These are not really here! + */ +#undef inport_l +#undef outport_l +#undef inport_l_s +#undef outport_l_s +#endif + +#endif /* whole file */ + diff --git a/thirdparty/grx249/src/include/libgrx.h b/thirdparty/grx249/src/include/libgrx.h new file mode 100644 index 0000000..70fefa2 --- /dev/null +++ b/thirdparty/grx249/src/include/libgrx.h @@ -0,0 +1,338 @@ +/** + ** libgrx.h ---- GRX library private include file + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __LIBGRX_H_INCLUDED__ +#define __LIBGRX_H_INCLUDED__ + +#define USE_GRX_INTERNAL_DEFINITIONS + +/* The LCC compiler on Linux requires this */ +#if defined(__LCC__) && defined(__linux__) +/* make alloca work ... */ +# define __USE_MISC +#endif + +#ifdef _AIX +#define _BIG_ENDIAN +#endif + +#include +#include +#include + +#ifndef __GRX20_H_INCLUDED__ +#include "grx20.h" +#endif + +#ifndef NULL +#define NULL ((void *)(0)) +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +/* +** identify the compiler / system +** and check for special restrictions +*/ +/* DEC alpha chips have special alignment +** restrictions. We'll have do care about them */ +#if !defined(__alpha__) && defined(__alpha) +#define __alpha__ __alpha +#endif + + +/* Casting a lvalue on the left side of an assignment +** causes error or warnings on several compilers: +** +** LCC v4.0 +** Watcom C++ v11.0 +** SUN cc v4.0 +** GCC v > 3 +*/ +#if !defined(NO_LEFTSIDE_LVALUE_CAST) && \ + ( defined(__LCC__) \ + || defined(__WATCOMC__) \ + || (defined(__GNUC__) && (__GNUC__>=3)) \ + || defined(__SUNPRO_C) ) +#define NO_LEFTSIDE_LVALUE_CAST +#endif +/* Casting a pointer on the left side of an assignment +** also cuses problems on several systems: +** +** LCC v4.0 +** Watcom C++ v11.0 +*/ +#if !defined(NO_LEFTSIDE_PTR_CAST) && \ + ( defined(__LCC__) \ + || defined(__WATCOMC__) ) +#define NO_LEFTSIDE_PTR_CAST +#endif + +/* some CPU allow misaligned access to non byte location */ +#if defined(__TURBOC__) \ + || defined(_MSC_VER) \ + || defined(__386__) \ + || defined(__i386__) \ + || defined(__i386) \ + || defined(__x86_64__) + /* x86 can write to misalgined 16bit locations */ +# define MISALIGNED_16bit_OK +#endif + +#if defined(__386__) \ + || defined(__i386__) \ + || defined(__i386) \ + || defined(__x86_64__) + /* x86 can write to misalgined 32bit locations */ +# define MISALIGNED_32bit_OK +#endif + + +/* need some n-bit types */ +/* char should always be 8bit and short 16bit ... */ +#define GR_int8 char +#define GR_int16 short +#if defined(__alpha__) || (defined(_MIPS_SZLONG) && _MIPS_SZLONG == 64) || defined(__x86_64__) +#define GR_int32 int +#define GR_int64 long +#define GR_PtrInt long +#else +#define GR_int32 long +#define GR_PtrInt int +#endif + +/* signed and unsigned variants of the above */ +typedef signed GR_int8 GR_int8s; +typedef signed GR_int16 GR_int16s; +typedef signed GR_int32 GR_int32s; +typedef unsigned GR_int8 GR_int8u; +typedef unsigned GR_int16 GR_int16u; +typedef unsigned GR_int32 GR_int32u; +#ifdef GR_int64 +typedef signed GR_int64 GR_int64s; +typedef unsigned GR_int64 GR_int64u; +#endif + + +/* +** get system endian +*/ +#if !defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) +# if defined(__TURBOC__) \ + || defined(__WATCOMC__) \ + || defined(_MSC_VER) \ + || defined(__alpha__) \ + || (defined(__LCC__) && defined(__i386__)) \ + || (defined(__GNUC__) && \ + (defined(__i386__) || defined(__x86_64__))) +# define _LITTLE_ENDIAN +# else +# include +# ifdef __LITTLE_ENDIAN +# define _LITTLE_ENDIAN +# endif +# ifdef __BIG_ENDIAN +# define _BIG_ENDIAN +# endif +# endif +#endif + +#if defined(__BYTE_ORDER__) && !defined(BYTE_ORDER) +# define BYTE_ORDER __BYTE_ORDER__ +# define LITTLE_ENDIAN __LITTLE_ENDIAN__ +# define BIG_ENDIAN __BIG_ENDIAN__ +#endif +#if !defined(BYTE_ORDER) && defined(_LITTLE_ENDIAN) +#define LITTLE_ENDIAN 0x1234 +#define BIG_ENDIAN 0x4321 +#define BYTE_ORDER LITTLE_ENDIAN +#endif +#if !defined(BYTE_ORDER) && defined(_BIG_ENDIAN) +#define LITTLE_ENDIAN 0x1234 +#define BIG_ENDIAN 0x4321 +#define BYTE_ORDER BIG_ENDIAN +#endif +#ifndef BYTE_ORDER +#error Unknown byte ordering ! +#endif + +#ifndef HARDWARE_BYTE_ORDER +#define HARDWARE_BYTE_ORDER BYTE_ORDER +#endif + +/* + * Debug support + */ +#if defined(DEBUG) && !defined(__GRXDEBUG_H_INCLUDED__) +# include "grxdebug.h" +#endif +#ifndef DBGPRINTF +# define DBGPRINTF(chk,x) +# define GRX_ENTER() +# define GRX_LEAVE() +# define GRX_RETURN(x) return x +#endif + +/* simple pointer arithmetic */ +#define ptrdiff(a,b) ( ((GR_int8 far *)(a)) - ((GR_int8 far *)(b)) ) +#define ptradd(P,SKIP) ( (void *)( ((GR_int8 *)(P))+(SKIP)) ) +#ifdef NO_LEFTSIDE_LVALUE_CAST +#define ptrinc(P,SKIP) do (P) = ptradd((P),(SKIP)); while (0) +#else +#define ptrinc(P,SKIP) do ((GR_int8 *)(P)) += (SKIP); while (0) +#endif + +/* + * function inline + */ +#ifdef __GNUC__ +#define INLINE __inline__ +#endif +#ifndef INLINE +#define INLINE +#endif + + +/* + * global library data structures + */ +extern struct _GR_driverInfo _GrDriverInfo; +extern struct _GR_contextInfo _GrContextInfo; +extern struct _GR_colorInfo _GrColorInfo; +extern struct _GR_mouseInfo _GrMouseInfo; + +#define GrDriverInfo (&_GrDriverInfo) +#define GrContextInfo (&_GrContextInfo) +#define GrColorInfo (&_GrColorInfo) +#define GrMouseInfo (&_GrMouseInfo) + +#define DRVINFO (&_GrDriverInfo) +#define CXTINFO (&_GrContextInfo) +#define CLRINFO (&_GrColorInfo) +#define MOUINFO (&_GrMouseInfo) + +#define CURC (&(CXTINFO->current)) +#define SCRN (&(CXTINFO->screen)) +#define FDRV (&(DRVINFO->fdriver)) +#define SDRV (&(DRVINFO->sdriver)) +#define VDRV ( (DRVINFO->vdriver)) + +/* + * banking stuff + */ +#ifndef BANKHOOK +#define BANKHOOK +#endif + +#ifndef RWBANKHOOK +#define RWBANKHOOK +#endif + +#ifdef __TURBOC__ +# define BANKPOS(offs) ((unsigned short)(offs)) +# define BANKNUM(offs) (((unsigned short *)(&(offs)))[1]) +# define BANKLFT(offs) (_AX = -(int)(BANKPOS(offs)),(_AX ? _AX : 0xffffU)) +#endif + +#ifndef BANKPOS +#define BANKPOS(offs) ((GR_int16u)(offs)) +#endif +#ifndef BANKNUM +#define BANKNUM(offs) ((int)((GR_int32u)(offs) >> 16)) +#endif +#ifndef BANKLFT +#define BANKLFT(offs) (0x10000 - BANKPOS(offs)) +#endif + +#define SETBANK(bk) do { \ + register int _bankval_ = (bk); \ + DRVINFO->curbank = _bankval_; \ + (*DRVINFO->setbank)(_bankval_); \ + BANKHOOK; \ +} while(0) + +#define SRWBANK(rb,wb) do { \ + DRVINFO->curbank = (-1); \ + (*DRVINFO->setrwbanks)((rb),(wb)); \ + RWBANKHOOK; \ +} while(0) + +#define CHKBANK(bk) do { \ + register int _bankval_ = (bk); \ + if(_bankval_ != DRVINFO->curbank) { \ + DRVINFO->curbank = _bankval_; \ + (*DRVINFO->setbank)(_bankval_); \ + BANKHOOK; \ + } \ +} while(0) + +/* + * color stuff + */ +extern int _GR_firstFreeColor; /* can't access all colors on all systems */ +extern int _GR_lastFreeColor; /* eg. X11 and other windowing systems */ +int _GrResetColors(void); /* like GrResetColors but return true on success */ + +#ifdef __TURBOC__ +# define C_OPER(color) (unsigned int)(((unsigned char *)(&(color)))[3] & 15) +#endif + +#ifndef C_OPER +#define C_OPER(color) (unsigned int)(((GrColor)(color) >> 24) & 15) +#endif +#define C_WRITE (int)(GrWRITE >> 24) +#define C_XOR (int)(GrXOR >> 24) +#define C_OR (int)(GrOR >> 24) +#define C_AND (int)(GrAND >> 24) +#define C_IMAGE (int)(GrIMAGE >> 24) +#define C_COLOR GrCVALUEMASK + +/* + * mouse stuff + */ +#define mouse_block(c,x1,y1,x2,y2) { \ + int __mouse_block_flag = 0; \ + mouse_addblock(c,x1,y1,x2,y2); +#define mouse_addblock(c,x1,y1,x2,y2) \ + if(MOUINFO->docheck && (c)->gc_onscreen) { \ + __mouse_block_flag |= (*MOUINFO->block)((c),(x1),(y1),(x2),(y2)); \ + } +#define mouse_unblock() \ + if(__mouse_block_flag) { \ + (*MOUINFO->unblock)(__mouse_block_flag); \ + } \ +} + +/* + * internal utility functions + */ +GrFrameDriver *_GrFindFrameDriver(GrFrameMode mode); +GrFrameDriver *_GrFindRAMframeDriver(GrFrameMode mode); + +void _GrCloseVideoDriver(void); +void _GrDummyFunction(void); + + +#endif /* whole file */ + diff --git a/thirdparty/grx249/src/include/libsdl.h b/thirdparty/grx249/src/include/libsdl.h new file mode 100644 index 0000000..6bdafc0 --- /dev/null +++ b/thirdparty/grx249/src/include/libsdl.h @@ -0,0 +1,53 @@ +/** + ** libsdl.h - GRX library SDL private include file + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef _LIBSDL_H_ + +#include + +#define KMOD_SCROLL ((SDLMod) 0x10) +#define KMOD_INSERT ((SDLMod) 0x20) + +extern SDL_Surface *_SGrScreen; +#if defined(__WIN32__) +extern void *_SGrBackup; +extern int _SGrLength; +extern int _SGrActive; +#endif + +extern int _GrIsKbdEnabled(void); +extern int _GrKeyPressed(void); + +/* _keyssdlpool used only when GrMouseEventEnable( 0,x ) is set */ + +#define _MAXKEYSSDLPOOL 16 +extern int _nkeyssdlpool; +extern int _keyssdlpool[_MAXKEYSSDLPOOL]; + +#if defined(__WIN32__) +#include +#include +#elif defined(__XWIN__) +#include +#include +#include +#include +#endif + +#define _LIBSDL_H_ 1 +#endif diff --git a/thirdparty/grx249/src/include/libwin32.h b/thirdparty/grx249/src/include/libwin32.h new file mode 100644 index 0000000..5cede92 --- /dev/null +++ b/thirdparty/grx249/src/include/libwin32.h @@ -0,0 +1,54 @@ +/** + ** libwin32.h - GRX library Win32-API private include file + ** + ** Author: Gernot Graeff + ** E-mail: gernot.graeff@t-online.de + ** Date: 13.11.98 + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef _LIBWIN32_H_ +#define _LIBWIN32_H_ + +#include +#include "grx20.h" + +typedef struct _W32Event { + UINT uMsg; + WPARAM wParam; + LPARAM lParam; + int kbstat; +} W32Event; + +extern CRITICAL_SECTION _csEventQueue; +extern W32Event *_W32EventQueue; +extern volatile int _W32EventQueueSize; +extern volatile int _W32EventQueueRead; +extern volatile int _W32EventQueueWrite; +extern volatile int _W32EventQueueLength; + +extern HWND hGRXWnd; +extern HDC hDCMem; +extern HANDLE windowThread; + +extern int _GrIsKbdEnabled(void); +extern int _GrKeyPressed(void); +extern int _GrKeyStat(void); + +/* _keysw32pool used only when GrMouseEventEnable( 0,x ) is set */ + +#define _MAXKEYSW32POOL 16 +extern int _nkeysw32pool; +extern int _keysw32pool[_MAXKEYSW32POOL]; + +#endif diff --git a/thirdparty/grx249/src/include/libxwin.h b/thirdparty/grx249/src/include/libxwin.h new file mode 100644 index 0000000..ccd8925 --- /dev/null +++ b/thirdparty/grx249/src/include/libxwin.h @@ -0,0 +1,93 @@ +/** + ** libxwin.h - GRX library X Windows private include file + ** + ** Author: Ulrich Leodolter + ** E-mail: ulrich@lab1.psy.univie.ac.at + ** Date: Thu Sep 28 09:46:21 1995 + ** RCSId: $Id$ + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: + ** 070505 M.Alvarez, Using a Pixmap for BackingStore + ** + **/ + +#ifndef _LIBXWIN_H_ +#define _LIBXWIN_H_ + +#include +#include +#include +#include +#include + +#define USE_PIXMAP_FOR_BS 1 // 1 = use a pixmap for backing store + +#if defined(XF86DGA_DRIVER) +#include +extern int _XGrWindowedMode; +#else +#define _XGrWindowedMode 1 +#endif + +/* + Invoke pre-X11R6 ICCCM routines if XlibSpecificationRelease is not 6. +*/ +#if XlibSpecificationRelease-0 < 6 +#define PRE_R6_ICCCM +#endif +/* + Invoke pre-X11R5 ICCCM routines if XlibSpecificationRelease is not defined. +*/ +#if !defined(XlibSpecificationRelease) +#define PRE_R5_ICCCM +#endif +/* + Invoke pre-X11R4 ICCCM routines if PWinGravity is not defined. +*/ +#if !defined(PWinGravity) +#define PRE_R4_ICCCM +#endif + +#define Export +#include "prex11r6.h" + +extern Display * _XGrDisplay; +extern int _XGrScreen; +extern Colormap _XGrColormap; +extern Window _XGrWindow; +extern Pixmap _XGrBitmap; +extern Pixmap _XGrPattern; +extern Pixmap _XGrBStore; +extern GC _XGrGC; +extern GC _XGrBitmapGC; +extern GC _XGrPatternGC; +extern unsigned long _XGrForeColor; +extern unsigned long _XGrBackColor; +extern unsigned int _XGrColorOper; +extern unsigned int _XGrDepth; +extern unsigned int _XGrBitsPerPixel; +extern int _XGrBStoreInited; + +extern unsigned long _XGrColorPlanes[8]; +extern unsigned int _XGrColorNumPlanes; +extern unsigned long _XGrColorPixels[2]; +extern unsigned int _XGrColorNumPixels; +extern char * _XGrClassNames[6]; + +extern void _XGrCopyBStore(int x, int y, int width, int lenght); + +extern int _XGrKeyboardHit(void); +extern int _XGrKeyboardGetKey(void); +extern int _XGrKeyboardGetState(void); + +#endif diff --git a/thirdparty/grx249/src/include/memcopy.h b/thirdparty/grx249/src/include/memcopy.h new file mode 100644 index 0000000..2e5eb48 --- /dev/null +++ b/thirdparty/grx249/src/include/memcopy.h @@ -0,0 +1,1417 @@ +/** + ** memcopy.h ---- inline assembly memory copy macros + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Basic and optimized memory block copy operations in byte, word and + ** long sizes. The copys are available in WRITE, XOR, OR and AND modes. + ** + **/ + +#ifndef __MEMCOPY_H_INCLUDED__ +#define __MEMCOPY_H_INCLUDED__ + +#ifndef __MEMMODE_H_INCLUDED__ +#include "memmode.h" +#endif +#ifndef __MEMPEEK_H_INCLUDED__ +#include "mempeek.h" +#endif +#ifndef __ARITH_H_INCLUDED__ +#include "arith.h" +#endif + +#if !defined(CPSIZE_b) && defined(GR_int8) +#define CPSIZE_b sizeof(GR_int8) +#endif +#if !defined(CPSIZE_w) && defined(GR_int16) +#define CPSIZE_w sizeof(GR_int16) +#endif +#if !defined(CPSIZE_l) && defined(GR_int32) +#define CPSIZE_l sizeof(GR_int32) +#endif +#if !defined(CPSIZE_h) && defined(GR_int64) +#define CPSIZE_h sizeof(GR_int64) +#endif + +#ifdef __GNUC__ +# include "gcc/memcopy.h" +#elif defined(__TURBOC__) +# include "bcc/memcopy.h" +#elif defined(__WATCOMC__) +# include "watcom/memcopy.h" +#endif + +#if !defined(GR_int64) && !defined(NO_64BIT_COPY) +#define NO_64BIT_COPY +#endif +#if !defined(GR_int32) && !defined(NO_32BIT_COPY) +#define NO_32BIT_COPY +#endif +#if !defined(GR_int16) && !defined(NO_16BIT_COPY) +#define NO_16BIT_COPY +#endif + +/* Note: +** These functions alter the destination and source pointers and the +** counter. Destination and source pointer _must_ point to next copy +** location at return +*/ + +/* memory -> memory copies */ +#ifndef __INLINE_STD_COLCOPY__ +#define __INLINE_STD_COLCOPY__(D,DSKP,S,SSKP,C,DM,SM,INS,SIZE,TYPE) do { \ + poke##DM((D),peek##SM(S)); \ + ptrinc((D),(DSKP)); ptrinc((S),(SSKP)); \ +} while(--(C)) +#endif + +#ifndef __INLINE_STD_OPRCOPY__ +#define __INLINE_STD_OPRCOPY__(D,S,C,DM,SM,INS,SIZE,TY) \ + __INLINE_STD_COLCOPY__(D,sizeof(TY),S,sizeof(TY),C,DM,SM,INS,SIZE,TY) +#endif + +#ifndef __INLINE_STD_ROWCOPY__ +#define __INLINE_STD_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) \ + __INLINE_STD_OPRCOPY__(D,S,C,DM,SM,MOV_INS,SIZE,TYPE) +#endif + +/* video -> memory copies */ +#ifndef __INLINE_STD_FAR_COLCOPY__ +#define __INLINE_STD_FAR_COLCOPY__(D,DSK,S,SSK,C,DM,SM,INS,SIZE,TYPE) \ + __INLINE_STD_COLCOPY__(D,DSK,S,SSK,C,DM,SM,INS,SIZE,TYPE) +#endif + +#ifndef __INLINE_STD_FAR_OPRCOPY__ +#define __INLINE_STD_FAR_OPRCOPY__(D,S,C,DM,SM,INS,SIZE,TY) \ + __INLINE_STD_FAR_COLCOPY__(D,sizeof(TY),S,sizeof(TY),C,DM,SM,INS,SIZE,TY) +#endif + +#ifndef __INLINE_STD_FAR_ROWCOPY__ +#define __INLINE_STD_FAR_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) \ + __INLINE_STD_FAR_OPRCOPY__(D,S,C,DM,SM,MOV_INS,SIZE,TYPE) +#endif + +/* memory -> video copies */ +#ifndef __INLINE_FAR_STD_COLCOPY__ +#define __INLINE_FAR_STD_COLCOPY__(D,DSK,S,SSK,C,DM,SM,INS,SIZE,TYPE) \ + __INLINE_STD_COLCOPY__(D,DSK,S,SSK,C,DM,SM,INS,SIZE,TYPE) +#endif + +#ifndef __INLINE_FAR_STD_OPRCOPY__ +#define __INLINE_FAR_STD_OPRCOPY__(D,S,C,DM,SM,INS,SIZE,TY) \ + __INLINE_FAR_STD_COLCOPY__(D,sizeof(TY),S,sizeof(TY),C,DM,SM,INS,SIZE,TY) +#endif + +#ifndef __INLINE_FAR_STD_ROWCOPY__ +#define __INLINE_FAR_STD_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) \ + __INLINE_FAR_STD_OPRCOPY__(D,S,C,DM,SM,MOV_INS,SIZE,TYPE) +#endif + +/* video -> video copies */ +#ifndef __INLINE_FAR_FAR_COLCOPY__ +#define __INLINE_FAR_FAR_COLCOPY__(D,DSK,S,SSK,C,DM,SM,INS,SIZE,TYPE) \ + __INLINE_STD_COLCOPY__(D,DSK,S,SSK,C,DM,SM,INS,SIZE,TYPE) +#endif + +#ifndef __INLINE_FAR_FAR_OPRCOPY__ +#define __INLINE_FAR_FAR_OPRCOPY__(D,S,C,DM,SM,INS,SIZE,TY) \ + __INLINE_FAR_FAR_COLCOPY__(D,sizeof(TY),S,sizeof(TY),C,DM,SM,INS,SIZE,TY) +#endif + +#ifndef __INLINE_FAR_FAR_ROWCOPY__ +#define __INLINE_FAR_FAR_ROWCOPY__(D,S,C,DM,SM,SIZE,TYPE) \ + __INLINE_FAR_FAR_OPRCOPY__(D,S,C,DM,SM,MOV_INS,SIZE,TYPE) +#endif + +/* + * rowcopy_[_][_][_](dst,src,count) + * ^-^-^-dst-^-^-^ ^src^ + */ +/* memory -> memory copy */ +#ifndef rowcopy_b_set +#define rowcopy_b_set(d,s,c) \ + __INLINE_STD_ROWCOPY__(d,s,c,_b,_b,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_set +# ifdef NO_16BIT_COPY +# define rowcopy_w_set(d,s,c) rowcopy_b_set(d,s,(c)<<1) +# else +# define rowcopy_w_set(d,s,c) __INLINE_STD_ROWCOPY__(d,s,c,_w,_w,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_set +# ifdef NO_32BIT_COPY +# define rowcopy_l_set(d,s,c) rowcopy_w_set(d,s,(c)<<1) +# else +# define rowcopy_l_set(d,s,c) __INLINE_STD_ROWCOPY__(d,s,c,_l,_l,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_set) +# ifdef NO_64BIT_COPY +# define rowcopy_h_set(d,s,c) rowcopy_l_set(d,s,(c)<<1) +# else +# define rowcopy_h_set(d,s,c) __INLINE_STD_ROWCOPY__(d,s,c,_h,_h,OP64b,GR_int64) +# endif +#endif + +#define rowcopy_b rowcopy_b_set +#define rowcopy_w rowcopy_w_set +#define rowcopy_l rowcopy_l_set +#ifdef rowcopy_h_set +#define rowcopy_h rowcopy_h_set +#endif + +#ifndef rowcopy_b_xor +#define rowcopy_b_xor(d,s,c) \ + __INLINE_STD_OPRCOPY__(d,s,c,_b_xor,_b,XOR_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_xor +# ifdef NO_16BIT_COPY +# define rowcopy_w_xor(d,s,c) rowcopy_b_xor(d,s,(c)<<1) +# else +# define rowcopy_w_xor(d,s,c) __INLINE_STD_OPRCOPY__(d,s,c,_w_xor,_w,XOR_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_xor +# ifdef NO_32BIT_COPY +# define rowcopy_l_xor(d,s,c) rowcopy_w_xor(d,s,(c)<<1) +# else +# define rowcopy_l_xor(d,s,c) __INLINE_STD_OPRCOPY__(d,s,c,_l_xor,_l,XOR_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_xor) +# ifdef NO_64BIT_COPY +# define rowcopy_h_xor(d,s,c) rowcopy_l_xor(d,s,(c)<<1) +# else +# define rowcopy_h_xor(d,s,c) __INLINE_STD_OPRCOPY__(d,s,c,_h_xor,_h,XOR_INS,OP64b,GR_int64) +# endif +#endif + +#ifndef rowcopy_b_or +#define rowcopy_b_or(d,s,c) \ + __INLINE_STD_OPRCOPY__(d,s,c,_b_or,_b,OR_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_or +# ifdef NO_16BIT_COPY +# define rowcopy_w_or(d,s,c) rowcopy_b_or(d,s,(c)<<1) +# else +# define rowcopy_w_or(d,s,c) __INLINE_STD_OPRCOPY__(d,s,c,_w_or,_w,OR_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_or +# ifdef NO_32BIT_COPY +# define rowcopy_l_or(d,s,c) rowcopy_w_or(d,s,(c)<<1) +# else +# define rowcopy_l_or(d,s,c) __INLINE_STD_OPRCOPY__(d,s,c,_l_or,_l,OR_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_or) +# ifdef NO_64BIT_COPY +# define rowcopy_h_or(d,s,c) rowcopy_l_or(d,s,(c)<<1) +# else +# define rowcopy_h_or(d,s,c) __INLINE_STD_OPRCOPY__(d,s,c,_h_or,_h,OR_INS,OP64b,GR_int64) +# endif +#endif + +#ifndef rowcopy_b_and +#define rowcopy_b_and(d,s,c) \ + __INLINE_STD_OPRCOPY__(d,s,c,_b_and,_b,AND_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_and +# ifdef NO_16BIT_COPY +# define rowcopy_w_and(d,s,c) rowcopy_b_and(d,s,(c)<<1) +# else +# define rowcopy_w_and(d,s,c) __INLINE_STD_OPRCOPY__(d,s,c,_w_and,_w,AND_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_and +# ifdef NO_32BIT_COPY +# define rowcopy_l_and(d,s,c) rowcopy_w_and(d,s,(c)<<1) +# else +# define rowcopy_l_and(d,s,c) __INLINE_STD_OPRCOPY__(d,s,c,_l_and,_l,AND_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_and) +# ifdef NO_64BIT_COPY +# define rowcopy_h_and(d,s,c) rowcopy_l_and(d,s,(c)<<1) +# else +# define rowcopy_h_and(d,s,c) __INLINE_STD_OPRCOPY__(d,s,c,_h_and,_h,AND_INS,OP64b,GR_int64) +# endif +#endif + +#define rowcopy_b_n_set_n rowcopy_b_set +#define rowcopy_b_n_xor_n rowcopy_b_xor +#define rowcopy_b_n_or_n rowcopy_b_or +#define rowcopy_b_n_and_n rowcopy_b_and +#define rowcopy_w_n_set_n rowcopy_w_set +#define rowcopy_w_n_xor_n rowcopy_w_xor +#define rowcopy_w_n_or_n rowcopy_w_or +#define rowcopy_w_n_and_n rowcopy_w_and +#define rowcopy_l_n_set_n rowcopy_l_set +#define rowcopy_l_n_xor_n rowcopy_l_xor +#define rowcopy_l_n_or_n rowcopy_l_or +#define rowcopy_l_n_and_n rowcopy_l_and +#ifdef rowcopy_l_set +#define rowcopy_h_n_set_n rowcopy_h_set +#define rowcopy_h_n_xor_n rowcopy_h_xor +#define rowcopy_h_n_or_n rowcopy_h_or +#define rowcopy_h_n_and_n rowcopy_h_and +#endif + +/* memory -> video copy */ +#ifndef rowcopy_b_f_set +#define rowcopy_b_f_set(d,s,c) \ + __INLINE_FAR_STD_ROWCOPY__(d,s,c,_b_f,_b,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_f_set +# ifdef NO_16BIT_COPY +# define rowcopy_w_f_set(d,s,c) rowcopy_b_f_set(d,s,(c)<<1) +# else +# define rowcopy_w_f_set(d,s,c) \ + __INLINE_FAR_STD_ROWCOPY__(d,s,c,_w_f,_w,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_f_set +# ifdef NO_32BIT_COPY +# define rowcopy_l_f_set(d,s,c) rowcopy_w_f_set(d,s,(c)<<1) +# else +# define rowcopy_l_f_set(d,s,c) \ + __INLINE_FAR_STD_ROWCOPY__(d,s,c,_l_f,_l,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_f_set) +# ifdef NO_64BIT_COPY +# define rowcopy_h_f_set(d,s,c) rowcopy_l_f_set(d,s,(c)<<1) +# else +# define rowcopy_h_f_set(d,s,c) \ + __INLINE_FAR_STD_ROWCOPY__(d,s,c,_h_f,_h,OP64b,GR_int64) +# endif +#endif + +#ifndef rowcopy_b_f_xor +#define rowcopy_b_f_xor(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_b_f_xor,_b,XOR_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_f_xor +# ifdef NO_16BIT_COPY +# define rowcopy_w_f_xor(d,s,c) rowcopy_b_f_xor(d,s,(c)<<1) +# else +# define rowcopy_w_f_xor(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_w_f_xor,_w,XOR_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_f_xor +# ifdef NO_32BIT_COPY +# define rowcopy_l_f_xor(d,s,c) rowcopy_w_f_xor(d,s,(c)<<1) +# else +# define rowcopy_l_f_xor(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_l_f_xor,_l,XOR_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_f_xor) +# ifdef NO_64BIT_COPY +# define rowcopy_h_f_xor(d,s,c) rowcopy_l_f_xor(d,s,(c)<<1) +# else +# define rowcopy_h_f_xor(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_h_f_xor,_h,XOR_INS,OP64b,GR_int64) +# endif +#endif + +#ifndef rowcopy_b_f_or +#define rowcopy_b_f_or(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_b_f_or,_b,OR_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_f_or +# ifdef NO_16BIT_COPY +# define rowcopy_w_f_or(d,s,c) rowcopy_b_f_or(d,s,(c)<<1) +# else +# define rowcopy_w_f_or(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_w_f_or,_w,OR_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_f_or +# ifdef NO_32BIT_COPY +# define rowcopy_l_f_or(d,s,c) rowcopy_w_f_or(d,s,(c)<<1) +# else +# define rowcopy_l_f_or(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_l_f_or,_l,OR_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_f_or) +# ifdef NO_64BIT_COPY +# define rowcopy_h_f_or(d,s,c) rowcopy_l_f_or(d,s,(c)<<1) +# else +# define rowcopy_h_f_or(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_h_f_or,_h,OR_INS,OP64b,GR_int64) +# endif +#endif + +#ifndef rowcopy_b_f_and +#define rowcopy_b_f_and(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_b_f_and,_b,AND_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_f_and +# ifdef NO_16BIT_COPY +# define rowcopy_w_f_and(d,s,c) rowcopy_b_f_and(d,s,(c)<<1) +# else +# define rowcopy_w_f_and(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_w_f_and,_w,AND_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_f_and +# ifdef NO_16BIT_COPY +# define rowcopy_l_f_and(d,s,c) rowcopy_w_f_and(d,s,(c)<<1) +# else +# define rowcopy_l_f_and(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_l_f_and,_l,AND_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_f_and) +# ifdef NO_16BIT_COPY +# define rowcopy_h_f_and(d,s,c) rowcopy_l_f_and(d,s,(c)<<1) +# else +# define rowcopy_h_f_and(d,s,c) \ + __INLINE_FAR_STD_OPRCOPY__(d,s,c,_h_f_and,_h,AND_INS,OP64b,GR_int64) +# endif +#endif + +#define rowcopy_b_f_set_n rowcopy_b_f_set +#define rowcopy_b_f_xor_n rowcopy_b_f_xor +#define rowcopy_b_f_or_n rowcopy_b_f_or +#define rowcopy_b_f_and_n rowcopy_b_f_and +#define rowcopy_w_f_set_n rowcopy_w_f_set +#define rowcopy_w_f_xor_n rowcopy_w_f_xor +#define rowcopy_w_f_or_n rowcopy_w_f_or +#define rowcopy_w_f_and_n rowcopy_w_f_and +#define rowcopy_l_f_set_n rowcopy_l_f_set +#define rowcopy_l_f_xor_n rowcopy_l_f_xor +#define rowcopy_l_f_or_n rowcopy_l_f_or +#define rowcopy_l_f_and_n rowcopy_l_f_and +#ifdef rowcopy_h_f_set +#define rowcopy_h_f_set_n rowcopy_h_f_set +#define rowcopy_h_f_xor_n rowcopy_h_f_xor +#define rowcopy_h_f_or_n rowcopy_h_f_or +#define rowcopy_h_f_and_n rowcopy_h_f_and +#endif + + +/* video -> memory copy */ +#ifndef rowcopy_b_set_f +#define rowcopy_b_set_f(d,s,c) \ + __INLINE_STD_FAR_ROWCOPY__(d,s,c,_b,_b_f,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_set_f +# ifdef NO_16BIT_COPY +# define rowcopy_w_set_f(d,s,c) rowcopy_b_set_f(d,s,(c)<<1) +# else +# define rowcopy_w_set_f(d,s,c) \ + __INLINE_STD_FAR_ROWCOPY__(d,s,c,_w,_w_f,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_set_f +# ifdef NO_32BIT_COPY +# define rowcopy_l_set_f(d,s,c) rowcopy_w_set_f(d,s,(c)<<1) +# else +# define rowcopy_l_set_f(d,s,c) \ + __INLINE_STD_FAR_ROWCOPY__(d,s,c,_l,_l_f,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_set_f) +# ifdef NO_64BIT_COPY +# define rowcopy_h_set_f(d,s,c) rowcopy_l_set_f(d,s,(c)<<1) +# else +# define rowcopy_h_set_f(d,s,c) \ + __INLINE_STD_FAR_ROWCOPY__(d,s,c,_h,_h_f,OP64b,GR_int64) +# endif +#endif + +#ifndef rowcopy_b_xor_f +#define rowcopy_b_xor_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_b_xor,_b_f,XOR_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_xor_f +# ifdef NO_16BIT_COPY +# define rowcopy_w_xor_f(d,s,c) rowcopy_b_xor_f(d,s,(c)<<1) +# else +# define rowcopy_w_xor_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_w_xor,_w_f,XOR_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_xor_f +# ifdef NO_32BIT_COPY +# define rowcopy_l_xor_f(d,s,c) rowcopy_w_xor_f(d,s,(c)<<1) +# else +# define rowcopy_l_xor_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_l_xor,_l_f,XOR_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_xor_f) +# ifdef NO_64BIT_COPY +# define rowcopy_h_xor_f(d,s,c) rowcopy_l_xor_f(d,s,(c)<<1) +# else +# define rowcopy_h_xor_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_h_xor,_h_f,XOR_INS,OP64b,GR_int64) +# endif +#endif + +#ifndef rowcopy_b_or_f +#define rowcopy_b_or_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_b_or,_b_f,OR_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_or_f +# ifdef NO_16BIT_COPY +# define rowcopy_w_or_f(d,s,c) rowcopy_b_or_f(d,s,(c)<<1) +# else +# define rowcopy_w_or_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_w_or,_w_f,OR_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_or_f +# ifdef NO_32BIT_COPY +# define rowcopy_l_or_f(d,s,c) rowcopy_w_or_f(d,s,(c)<<1) +# else +# define rowcopy_l_or_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_l_or,_l_f,OR_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_or_f) +# ifdef NO_64BIT_COPY +# define rowcopy_h_or_f(d,s,c) rowcopy_l_or_f(d,s,(c)<<1) +# else +# define rowcopy_h_or_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_h_or,_h_f,OR_INS,OP64b,GR_int64) +# endif +#endif + +#ifndef rowcopy_b_and_f +#define rowcopy_b_and_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_b_and,_b_f,AND_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_and_f +# ifdef NO_16BIT_COPY +# define rowcopy_w_and_f(d,s,c) rowcopy_b_and_f(d,s,(c)<<1) +# else +# define rowcopy_w_and_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_w_and,_w_f,AND_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_and_f +# ifdef NO_32BIT_COPY +# define rowcopy_l_and_f(d,s,c) rowcopy_w_and_f(d,s,(c)<<1) +# else +# define rowcopy_l_and_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_l_and,_l_f,AND_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_and_f) +# ifdef NO_64BIT_COPY +# define rowcopy_h_and_f(d,s,c) rowcopy_l_and_f(d,s,(c)<<1) +# else +# define rowcopy_h_and_f(d,s,c) \ + __INLINE_STD_FAR_OPRCOPY__(d,s,c,_h_and,_h_f,AND_INS,OP64b,GR_int64) +# endif +#endif + +#define rowcopy_b_n_set_f rowcopy_b_set_f +#define rowcopy_b_n_xor_f rowcopy_b_xor_f +#define rowcopy_b_n_or_f rowcopy_b_or_f +#define rowcopy_b_n_and_f rowcopy_b_and_f +#define rowcopy_w_n_set_f rowcopy_w_set_f +#define rowcopy_w_n_xor_f rowcopy_w_xor_f +#define rowcopy_w_n_or_f rowcopy_w_or_f +#define rowcopy_w_n_and_f rowcopy_w_and_f +#define rowcopy_l_n_set_f rowcopy_l_set_f +#define rowcopy_l_n_xor_f rowcopy_l_xor_f +#define rowcopy_l_n_or_f rowcopy_l_or_f +#define rowcopy_l_n_and_f rowcopy_l_and_f +#ifdef rowcopy_h_set_f +#define rowcopy_h_n_set_f rowcopy_h_set_f +#define rowcopy_h_n_xor_f rowcopy_h_xor_f +#define rowcopy_h_n_or_f rowcopy_h_or_f +#define rowcopy_h_n_and_f rowcopy_h_and_f +#endif + + +/* video -> video copy */ +#ifndef rowcopy_b_f_set_f +#define rowcopy_b_f_set_f(d,s,c) \ + __INLINE_FAR_FAR_ROWCOPY__(d,s,c,_b_f,_b_f,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_f_set_f +# ifdef NO_16BIT_COPY +# define rowcopy_w_f_set_f(d,s,c) rowcopy_b_f_set_f(d,s,(c)<<1) +# else +# define rowcopy_w_f_set_f(d,s,c) \ + __INLINE_FAR_FAR_ROWCOPY__(d,s,c,_w_f,_w_f,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_f_set_f +# ifdef NO_32BIT_COPY +# define rowcopy_l_f_set_f(d,s,c) rowcopy_w_f_set_f(d,s,(c)<<1) +# else +# define rowcopy_l_f_set_f(d,s,c) \ + __INLINE_FAR_FAR_ROWCOPY__(d,s,c,_l_f,_l_f,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_f_set_f) +# ifdef NO_64BIT_COPY +# define rowcopy_h_f_set_f(d,s,c) rowcopy_l_f_set_f(d,s,(c)<<1) +# else +# define rowcopy_h_f_set_f(d,s,c) \ + __INLINE_FAR_FAR_ROWCOPY__(d,s,c,_h_f,_h_f,OP64b,GR_int64) +# endif +#endif + +#ifndef rowcopy_b_f_xor_f +#define rowcopy_b_f_xor_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_b_f_xor,_b_f,XOR_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_f_xor_f +# ifdef NO_16BIT_COPY +# define rowcopy_w_f_xor_f(d,s,c) rowcopy_b_f_xor_f(d,s,(c)<<1) +# else +# define rowcopy_w_f_xor_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_w_f_xor,_w_f,XOR_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_f_xor_f +# ifdef NO_32BIT_COPY +# define rowcopy_l_f_xor_f(d,s,c) rowcopy_w_f_xor_f(d,s,(c)<<1) +# else +# define rowcopy_l_f_xor_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_l_f_xor,_l_f,XOR_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_f_xor_f) +# ifdef NO_64BIT_COPY +# define rowcopy_h_f_xor_f(d,s,c) rowcopy_l_f_xor_f(d,s,(c)<<1) +# else +# define rowcopy_h_f_xor_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_h_f_xor,_h_f,XOR_INS,OP64b,GR_int64) +# endif +#endif + +#ifndef rowcopy_b_f_or_f +#define rowcopy_b_f_or_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_b_f_or,_b_f,OR_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_f_or_f +# ifdef NO_16BIT_COPY +# define rowcopy_w_f_or_f(d,s,c) rowcopy_b_f_or_f(d,s,(c)<<1) +# else +# define rowcopy_w_f_or_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_w_f_or,_w_f,OR_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_f_or_f +# ifdef NO_32BIT_COPY +# define rowcopy_l_f_or_f(d,s,c) rowcopy_w_f_or_f(d,s,(c)<<1) +# else +# define rowcopy_l_f_or_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_l_f_or,_l_f,OR_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_f_or_f) +# ifdef NO_64BIT_COPY +# define rowcopy_h_f_or_f(d,s,c) rowcopy_l_f_or_f(d,s,(c)<<1) +# else +# define rowcopy_h_f_or_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_h_f_or,_h_f,OR_INS,OP64b,GR_int64) +# endif +#endif + +#ifndef rowcopy_b_f_and_f +#define rowcopy_b_f_and_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_b_f_and,_b_f,AND_INS,OP8b,GR_int8) +#endif +#ifndef rowcopy_w_f_and_f +# ifdef NO_16BIT_COPY +# define rowcopy_w_f_and_f(d,s,c) rowcopy_b_f_and_f(d,s,(c)<<1) +# else +# define rowcopy_w_f_and_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_w_f_and,_w_f,AND_INS,OP16b,GR_int16) +# endif +#endif +#ifndef rowcopy_l_f_and_f +# ifdef NO_32BIT_COPY +# define rowcopy_l_f_and_f(d,s,c) rowcopy_w_f_and_f(d,s,(c)<<1) +# else +# define rowcopy_l_f_and_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_l_f_and,_l_f,AND_INS,OP32b,GR_int32) +# endif +#endif +#if defined(GR_int64) && !defined(rowcopy_h_f_and_f) +# ifdef NO_64BIT_COPY +# define rowcopy_h_f_and_f(d,s,c) rowcopy_l_f_and_f(d,s,(c)<<1) +# else +# define rowcopy_h_f_and_f(d,s,c) \ + __INLINE_FAR_FAR_OPRCOPY__(d,s,c,_h_f_and,_h_f,AND_INS,OP64b,GR_int64) +# endif +#endif + + + +/* + * colcopy_[_][_][_](dst,doffs,src,srcoffs,count) + * ^-^-^-dst-^-^-^ ^src^ + */ +/* memory -> memory copy */ +#ifndef colcopy_b_set +#define colcopy_b_set(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_b,_b,MOV_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_set +#define colcopy_w_set(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_w,_w,MOV_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_set) +#define colcopy_l_set(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_l,_l,MOV_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_set) +#define colcopy_h_set(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_h,_h,MOV_INS,OP64b,GR_int64) +#endif + +#define colcopy_b colcopy_b_set +#define colcopy_w colcopy_w_set +#define colcopy_l colcopy_l_set +#ifdef colcopy_h_set +#define colcopy_h colcopy_h_set +#endif + + +#ifndef colcopy_b_xor +#define colcopy_b_xor(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_b_xor,_b,XOR_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_xor +#define colcopy_w_xor(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_w_xor,_w,XOR_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_xor) +#define colcopy_l_xor(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_l_xor,_l,XOR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_xor) +#define colcopy_h_xor(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_h_xor,_h,XOR_INS,OP64b,GR_int64) +#endif + +#ifndef colcopy_b_or +#define colcopy_b_or(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_b_or,_b,OR_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_or +#define colcopy_w_or(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_w_or,_w,OR_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_or) +#define colcopy_l_or(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_l_or,_l,OR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_or) +#define colcopy_h_or(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_h_or,_h,OR_INS,OP64b,GR_int64) +#endif + +#ifndef colcopy_b_and +#define colcopy_b_and(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_b_and,_b,AND_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_and +#define colcopy_w_and(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_w_and,_w,AND_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_and) +#define colcopy_l_and(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_l_and,_l,AND_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_and) +#define colcopy_h_and(d,dof,s,sof,c) \ + __INLINE_STD_COLCOPY__(d,dof,s,sof,c,_h_and,_h,AND_INS,OP64b,GR_int64) +#endif + +#define colcopy_b_n_set_n colcopy_b_set +#define colcopy_b_n_xor_n colcopy_b_xor +#define colcopy_b_n_or_n colcopy_b_or +#define colcopy_b_n_and_n colcopy_b_and +#define colcopy_w_n_set_n colcopy_w_set +#define colcopy_w_n_xor_n colcopy_w_xor +#define colcopy_w_n_or_n colcopy_w_or +#define colcopy_w_n_and_n colcopy_w_and +#define colcopy_l_n_set_n colcopy_l_set +#define colcopy_l_n_xor_n colcopy_l_xor +#define colcopy_l_n_or_n colcopy_l_or +#define colcopy_l_n_and_n colcopy_l_and +#ifdef colcopy_h_set +#define colcopy_h_n_set_n colcopy_h_set +#define colcopy_h_n_xor_n colcopy_h_xor +#define colcopy_h_n_or_n colcopy_h_or +#define colcopy_h_n_and_n colcopy_h_and +#endif + + +/* memory -> video copy */ +#ifndef colcopy_b_f_set +#define colcopy_b_f_set(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_b_f,_b,MOV_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_f_set +#define colcopy_w_f_set(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_w_f,_w,MOV_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_f_set) +#define colcopy_l_f_set(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_l_f,_l,MOV_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_f_set) +#define colcopy_h_f_set(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_h_f,_h,MOV_INS,OP64b,GR_int64) +#endif + +#ifndef colcopy_b_f_xor +#define colcopy_b_f_xor(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_b_f_xor,_b,XOR_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_f_xor +#define colcopy_w_f_xor(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_w_f_xor,_w,XOR_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_f_xor) +#define colcopy_l_f_xor(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_l_f_xor,_l,XOR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_f_xor) +#define colcopy_h_f_xor(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_h_f_xor,_h,XOR_INS,OP64b,GR_int64) +#endif + +#ifndef colcopy_b_f_or +#define colcopy_b_f_or(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_b_f_or,_b,OR_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_f_or +#define colcopy_w_f_or(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_w_f_or,_w,OR_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_f_or) +#define colcopy_l_f_or(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_l_f_or,_l,OR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_f_or) +#define colcopy_h_f_or(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_h_f_or,_h,OR_INS,OP64b,GR_int64) +#endif + +#ifndef colcopy_b_f_and +#define colcopy_b_f_and(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_b_f_and,_b,AND_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_f_and +#define colcopy_w_f_and(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_w_f_and,_w,AND_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_f_and) +#define colcopy_l_f_and(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_l_f_and,_l,AND_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_f_and) +#define colcopy_h_f_and(d,dof,s,sof,c) \ + __INLINE_FAR_STD_COLCOPY__(d,dof,s,sof,c,_h_f_and,_h,AND_INS,OP64b,GR_int64) +#endif + +#define colcopy_b_f_set_n colcopy_b_f_set +#define colcopy_b_f_xor_n colcopy_b_f_xor +#define colcopy_b_f_or_n colcopy_b_f_or +#define colcopy_b_f_and_n colcopy_b_f_and +#define colcopy_w_f_set_n colcopy_w_f_set +#define colcopy_w_f_xor_n colcopy_w_f_xor +#define colcopy_w_f_or_n colcopy_w_f_or +#define colcopy_w_f_and_n colcopy_w_f_and +#define colcopy_l_f_set_n colcopy_l_f_set +#define colcopy_l_f_xor_n colcopy_l_f_xor +#define colcopy_l_f_or_n colcopy_l_f_or +#define colcopy_l_f_and_n colcopy_l_f_and +#ifdef colcopy_h_f_set +#define colcopy_h_f_set_n colcopy_h_f_set +#define colcopy_h_f_xor_n colcopy_h_f_xor +#define colcopy_h_f_or_n colcopy_h_f_or +#define colcopy_h_f_and_n colcopy_h_f_and +#endif + + +/* video -> memory copy */ +#ifndef colcopy_b_set_f +#define colcopy_b_set_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_b,_b_f,MOV_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_set_f +#define colcopy_w_set_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_w,_w_f,MOV_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_set_f) +#define colcopy_l_set_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_l,_l_f,MOV_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_set_f) +#define colcopy_h_set_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_h,_h_f,MOV_INS,OP64b,GR_int64) +#endif + +#ifndef colcopy_b_xor_f +#define colcopy_b_xor_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_b_xor,_b_f,XOR_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_xor_f +#define colcopy_w_xor_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_w_xor,_w_f,XOR_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_xor_f) +#define colcopy_l_xor_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_l_xor,_l_f,XOR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_xor_f) +#define colcopy_h_xor_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_h_xor,_h_f,XOR_INS,OP64b,GR_int64) +#endif + +#ifndef colcopy_b_or_f +#define colcopy_b_or_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_b_or,_b_f,OR_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_or_f +#define colcopy_w_or_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_w_or,_w_f,OR_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_or_f) +#define colcopy_l_or_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_l_or,_l_f,OR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_or_f) +#define colcopy_h_or_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_h_or,_h_f,OR_INS,OP64b,GR_int64) +#endif + +#ifndef colcopy_b_and_f +#define colcopy_b_and_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_b_and,_b_f,AND_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_and_f +#define colcopy_w_and_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_w_and,_w_f,AND_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_and_f) +#define colcopy_l_and_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_l_and,_l_f,AND_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_and_f) +#define colcopy_h_and_f(d,dof,s,sof,c) \ + __INLINE_STD_FAR_COLCOPY__(d,dof,s,sof,c,_h_and,_h_f,AND_INS,OP64b,GR_int64) +#endif + +#define colcopy_b_n_set_f colcopy_b_set_f +#define colcopy_b_n_xor_f colcopy_b_xor_f +#define colcopy_b_n_or_f colcopy_b_or_f +#define colcopy_b_n_and_f colcopy_b_and_f +#define colcopy_w_n_set_f colcopy_w_set_f +#define colcopy_w_n_xor_f colcopy_w_xor_f +#define colcopy_w_n_or_f colcopy_w_or_f +#define colcopy_w_n_and_f colcopy_w_and_f +#define colcopy_l_n_set_f colcopy_l_set_f +#define colcopy_l_n_xor_f colcopy_l_xor_f +#define colcopy_l_n_or_f colcopy_l_or_f +#define colcopy_l_n_and_f colcopy_l_and_f +#ifdef colcopy_h_set_f +#define colcopy_h_n_set_f colcopy_h_set_f +#define colcopy_h_n_xor_f colcopy_h_xor_f +#define colcopy_h_n_or_f colcopy_h_or_f +#define colcopy_h_n_and_f colcopy_h_and_f +#endif + + +/* video -> video copy */ +#ifndef colcopy_b_f_set_f +#define colcopy_b_f_set_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_b_f,_b_f,MOV_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_f_set_f +#define colcopy_w_f_set_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_w_f,_w_f,MOV_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_f_set_f) +#define colcopy_l_f_set_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_l_f,_l_f,MOV_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_f_set_f) +#define colcopy_h_f_set_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_h_f,_h_f,MOV_INS,OP64b,GR_int64) +#endif + +#ifndef colcopy_b_f_xor_f +#define colcopy_b_f_xor_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_b_f_xor,_b_f,XOR_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_f_xor_f +#define colcopy_w_f_xor_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_w_f_xor,_w_f,XOR_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_f_xor_f) +#define colcopy_l_f_xor_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_l_f_xor,_l_f,XOR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_f_xor_f) +#define colcopy_h_f_xor_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_h_f_xor,_h_f,XOR_INS,OP64b,GR_int64) +#endif + +#ifndef colcopy_b_f_or_f +#define colcopy_b_f_or_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_b_f_or,_b_f,OR_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_f_or_f +#define colcopy_w_f_or_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_w_f_or,_w_f,OR_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_f_or_f) +#define colcopy_l_f_or_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_l_f_or,_l_f,OR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_f_or_f) +#define colcopy_h_f_or_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_h_f_or,_h_f,OR_INS,OP64b,GR_int64) +#endif + +#ifndef colcopy_b_f_and_f +#define colcopy_b_f_and_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_b_f_and,_b_f,AND_INS,OP8b,GR_int8) +#endif +#ifndef colcopy_w_f_and_f +#define colcopy_w_f_and_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_w_f_and,_w_f,AND_INS,OP16b,GR_int16) +#endif +#if defined(GR_int32) && !defined(colcopy_l_f_and_f) +#define colcopy_l_f_and_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_l_f_and,_l_f,AND_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(colcopy_h_f_and_f) +#define colcopy_h_f_and_f(d,dof,s,sof,c) \ + __INLINE_FAR_FAR_COLCOPY__(d,dof,s,sof,c,_h_f_and,_h_f,AND_INS,OP64b,GR_int64) +#endif + + +/* + * fwdcopy[_]_[_](alp,dst,src,cnt) + * revcopy[_]_[_](alp,dst,src,count) + * ^-^-^-dst-^-^-^ ^src^ + * + * optimized copy - will use fastest available copy + * alp: alignment pointer will be moved to an aligned + * boundary by small size copy ops before bulk copy is + * done using max. data width. Must equal dst or src + * dst: destination pointer, on return points to first address + * following the copy area + * src: source pointer, on return points to first address + * following the copy area + * cnt: number of bytes to be copied. Changed. + */ + +/* generic single element copy */ +#ifndef __INLINE_1_COPY__ +#define __INLINE_1_COPY__(D,S,SZ,WOP,SF,INC) do { \ + poke_##SZ##WOP((D),peek_##SZ##SF(S)); \ + ptrinc((D),(INC)); ptrinc((S),(INC)); \ +} while (0) +#endif + +/* generic optimized forward copy (meets NO alignment resriction :( */ +#ifndef __INLINE_STD_FWD_COPY__ +#define __INLINE_STD_FWD_COPY__(SZ,WOP,SF,ALP,DST,SRC,CNT) do { \ + if ((GR_PtrInt)(CNT) >= 2*CPSIZE_##SZ-1 ) { \ + GR_PtrInt _c_ = (-((GR_PtrInt)(ALP))) & (CPSIZE_##SZ-1); \ + if (_c_) { \ + (CNT) -= _c_; \ + rowcopy_b##WOP##SF(DST,SRC,_c_); \ + } \ + _c_ = ((GR_PtrInt)(CNT)) / CPSIZE_##SZ; \ + rowcopy_##SZ##WOP##SF(DST,SRC,_c_); \ + (CNT) &= (CPSIZE_##SZ-1); \ + } \ + if ( (GR_PtrInt)(CNT) ) \ + rowcopy_b##WOP##SF(DST,SRC,CNT)); \ +} while(0) +#endif + +/* generic optimized reverse copy (meets NO alignment resrictions :( */ +#ifndef __INLINE_STD_REV_COPY__ +#define __INLINE_STD_REV_COPY__(SZ,WOP,SF,ALP,DST,SRC,CNT) do { \ + if ((GR_PtrInt)(CNT) >= 2*CPSIZE_##SZ-1 ) { \ + GR_PtrInt _c_ = ((GR_PtrInt)(ALP)+1) & (CPSIZE_##SZ-1); \ + if (_c_) { \ + (CNT) -= _c_; \ + colcopy_b##WOP##SF(DST,(-1),SRC,(-1),_c_); \ + } \ + _c_ = ((GR_PtrInt)(CNT)) / CPSIZE_##SZ; \ + ptrinc(DST,-(CPSIZE_##SZ)+1); \ + ptrinc(SRC,-(CPSIZE_##SZ)+1); \ + colcopy_##SZ##WOP##SF(DST,-(CPSIZE_##SZ),SRC,-(CPSIZE_##SZ),_c_); \ + ptrinc(DST,(CPSIZE_##SZ)-1); \ + ptrinc(SRC,(CPSIZE_##SZ)-1); \ + (CNT) &= (CPSIZE_##SZ-1); \ + } \ + if ( (GR_PtrInt)(CNT) ) \ + colcopy_b##WOP##SF(DST,(-1),SRC,(-1),CNT); \ +} while(0) +#endif + +/* forward copy: copy and step to next higher alignment boundary */ +#ifndef __INLINE_FWD_ALIGN__ +#define __INLINE_FWD_ALIGN__(SZ,WOP,SF,AP,D,S,C) \ + if ( ((GR_PtrInt)(AP)) & CPSIZE_##SZ ) { \ + __INLINE_1_COPY__(D,S,SZ,WOP,SF,CPSIZE_##SZ); \ + (C) -= CPSIZE_##SZ; \ + if ( ! ((GR_PtrInt)(C)) ) break; \ + } +#endif + +/* forward copy: copy one remaining element */ +#ifndef __INLINE_FWD_TAIL__ +#define __INLINE_FWD_TAIL__(SZ,WOP,SF,D,S,C) do \ + if ( ((GR_PtrInt)(C)) & CPSIZE_##SZ ) \ + __INLINE_1_COPY__(D,S,SZ,WOP,SF,CPSIZE_##SZ); \ +while (0) +#endif + +/* ------------------- check for system alignment requirements ------------- */ +#if defined(MISALIGNED_64bit_OK) && !defined(NO_64BIT_COPY) && \ + defined(MISALIGNED_32bit_OK) && defined(MISALIGNED_16bit_OK) +/* 8,16,32,64bit misaligned ok */ +#ifndef __INLINE_FWD_COPY__ +#define __INLINE_FWD_COPY__(WOP,SF,AP,D,S,C) do { \ + if ( ((GR_PtrInt)(C)) >= 7 ) { \ + __INLINE_FWD_ALIGN__(b,WOP,SF,AP,D,S,C); \ + __INLINE_FWD_ALIGN__(w,WOP,SF,AP,D,S,C); \ + __INLINE_FWD_ALIGN__(l,WOP,SF,AP,D,S,C); \ + { GR_PtrInt _c_ = ((GR_PtrInt)(C)) >> 3; \ + if (_c_) rowcopy_h##WOP##SF(D,S,_c_); } \ + } \ + __INLINE_FWD_TAIL__(l,WOP,SF,D,S,C); \ + __INLINE_FWD_TAIL__(w,WOP,SF,D,S,C); \ + __INLINE_FWD_TAIL__(b,WOP,SF,D,S,C); \ +} while (0) +#endif +#ifndef __INLINE_REV_COPY__ +#define __INLINE_REV_COPY__(WOP,SF,AP,D,S,C) do { \ + if (((GR_PtrInt)(C)) >= 7) { \ + if ( ! ( ((GR_PtrInt)(AP)) & 1) ) { \ + __INLINE_1_COPY__(D,S,b,WOP,SF,-1); \ + (C)--; \ + } \ + if ( ! ( ((GR_PtrInt)(AP)) & 2) ) { \ + ptrinc((D),-1); \ + ptrinc((S),-1); \ + __INLINE_1_COPY__(D,S,w,WOP,SF,-1); \ + (C) -= 2; \ + } \ + if ( ! ( ((GR_PtrInt)(AP)) & 4) ) { \ + ptrinc((D),-3); \ + ptrinc((S),-3); \ + __INLINE_1_COPY__(D,S,l,WOP,SF,-1); \ + (C) -= 4; \ + } \ + { GR_PtrInt _rch_ = ((GR_PtrInt)(C)) >> 3; \ + if (_rch_) { \ + ptrinc((D),-7); \ + ptrinc((S),-7); \ + colcopy_h##WOP##SF(D,-8,S,-8,_rch_); \ + ptrinc((D),+7); \ + ptrinc((S),+7); \ + } \ + } \ + } \ + if ( ((GR_PtrInt)(C)) & 4 ) { \ + ptrinc((D),-3); \ + ptrinc((S),-3); \ + __INLINE_1_COPY__(D,S,l,WOP,SF,-1); \ + } \ + if ( ((GR_PtrInt)(C)) & 2 ) { \ + ptrinc((D),-1); \ + ptrinc((S),-1); \ + __INLINE_1_COPY__(D,S,w,WOP,SF,-1); \ + } \ + if ( ((GR_PtrInt)(C)) & 1 ) \ + __INLINE_1_COPY__(D,S,b,WOP,SF,-1); \ +} while (0) +#endif + +#elif defined(MISALIGNED_64bit_OK) && !defined(NO_64BIT_COPY) +/* 8,64bit misaligned ok -> standard code */ +#ifndef __INLINE_FWD_COPY__ +#define __INLINE_FWD_COPY__(WOP,SF,AP,D,S,C) \ + __INLINE_STD_FWD_COPY__(h,WOP,SF,AP,D,S,C) +#endif +#ifndef __INLINE_REV_COPY__ +#define __INLINE_REV_COPY__(WOP,SF,AP,D,S,C) \ + __INLINE_STD_REV_COPY__(h,WOP,SF,AP,D,S,C) +#endif + +#elif defined(MISALIGNED_32bit_OK) && !defined(NO_32BIT_COPY) && \ + defined(MISALIGNED_16bit_OK) +/* 8,16,32bit misaligned ok */ +#ifndef __INLINE_FWD_COPY__ +#define __INLINE_FWD_COPY__(WOP,SF,AP,D,S,C) do { \ + if ( ((GR_PtrInt)(C)) >= 3 ) { \ + GR_PtrInt _fcl_; \ + __INLINE_FWD_ALIGN__(b,WOP,SF,AP,D,S,C); \ + __INLINE_FWD_ALIGN__(w,WOP,SF,AP,D,S,C); \ + if ( (_fcl_ = ((GR_PtrInt)(C)) >> 2) != 0) rowcopy_l##WOP##SF(D,S,_fcl_); \ + } \ + __INLINE_FWD_TAIL__(w,WOP,SF,D,S,C); \ + __INLINE_FWD_TAIL__(b,WOP,SF,D,S,C); \ +} while (0) +#endif +#ifndef __INLINE_REV_COPY__ +#define __INLINE_REV_COPY__(WOP,SF,AP,D,S,C) do { \ + if (((GR_PtrInt)(C)) >= 3) { \ + if ( ! ( ((GR_PtrInt)(AP)) & 1) ) { \ + __INLINE_1_COPY__(D,S,b,WOP,SF,-1); \ + (C)--; \ + } \ + if ( ! ( ((GR_PtrInt)(AP)) & 2) ) { \ + ptrinc((D),-1); \ + ptrinc((S),-1); \ + __INLINE_1_COPY__(D,S,w,WOP,SF,-1); \ + (C) -= 2; \ + } \ + { GR_PtrInt _rcl_ = ((GR_PtrInt)(C)) >> 2; \ + if (_rcl_) { \ + ptrinc((D),-3); \ + ptrinc((S),-3); \ + colcopy_l##WOP##SF(D,-4,S,-4,_rcl_); \ + ptrinc((D),+3); \ + ptrinc((S),+3); \ + } \ + } \ + } \ + if ( ((GR_PtrInt)(C)) & 2 ) { \ + ptrinc((D),-1); \ + ptrinc((S),-1); \ + __INLINE_1_COPY__(D,S,w,WOP,SF,-1); \ + } \ + if ( ((GR_PtrInt)(C)) & 1 ) \ + __INLINE_1_COPY__(D,S,b,WOP,SF,-1); \ +} while(0) +#endif + +#elif defined(MISALIGNED_32bit_OK) && !defined(NO_32BIT_COPY) +/* 8,32bit misaligned ok -> standard code */ +#ifndef __INLINE_FWD_COPY__ +#define __INLINE_FWD_COPY__(WOP,SF,AP,D,S,C) \ + __INLINE_STD_FWD_COPY__(l,WOP,SF,AP,D,S,C) +#endif +#ifndef __INLINE_REV_COPY__ +#define __INLINE_REV_COPY__(WOP,SF,AP,D,S,C) \ + __INLINE_STD_REV_COPY__(l,WOP,SF,AP,D,S,C) +#endif + +#elif defined(MISALIGNED_16bit_OK) && !defined(NO_16BIT_COPY) +/* 8,16bit misaligned ok */ +#ifndef __INLINE_FWD_COPY__ +#define __INLINE_FWD_COPY__(WOP,SF,AP,D,S,C) do if ((GR_PtrInt)(C)) { \ + __INLINE_FWD_ALIGN__(b,WOP,SF,AP,D,S,C); \ + { GR_PtrInt _fcw_ = ((GR_PtrInt)(C)) >> 1; \ + if (_fcw_) rowcopy_w##WOP##SF(D,S,_fcw_); } \ + __INLINE_FWD_TAIL__(b,WOP,SF,D,S,C); \ +} while (0) +#endif +#ifndef __INLINE_REV_COPY__ +#define __INLINE_REV_COPY__(WOP,SF,AP,D,S,C) do if ((GR_PtrInt)(C)) { \ + if ( ! ( ((GR_PtrInt)(AP)) & 1) ) { \ + __INLINE_1_COPY__(D,S,b,WOP,SF,-1); \ + (C)--; \ + if ( ! ((GR_PtrInt)(C)) ) break; \ + } \ + { GR_PtrInt _rcw_ = ((GR_PtrInt)(C)) >> 1; \ + if (_rcw_) { \ + ptrinc((D),-1); \ + ptrinc((S),-1); \ + colcopy_w##WOP##SF(D,-2,S,-2,_rcw_); \ + ptrinc((D),+1); \ + ptrinc((S),+1); \ + } \ + } \ + if ( ((GR_PtrInt)(C)) & 1 ) \ + __INLINE_1_COPY__(D,S,b,WOP,SF,-1); \ +} while (0) +#endif + +#endif + +/* ---------------------------------------- fall back to byte copy */ +#ifndef __INLINE_FWD_COPY__ +#define __INLINE_FWD_COPY__(WOP,SF,AP,D,S,C) rowcopy_b##WOP##SF(D,S,C) +#endif +#ifndef __INLINE_REV_COPY__ +#define __INLINE_REV_COPY__(WOP,SF,AP,D,S,C) colcopy_b##WOP##SF(D,-1,S,-1,C) +#endif + +/* memory -> memory copy */ +#ifndef fwdcopy_set +#define fwdcopy_set(ap,d,s,c) __INLINE_FWD_COPY__(_n_set,_n,ap,d,s,c) +#endif +#ifndef fwdcopy_xor +#define fwdcopy_xor(ap,d,s,c) __INLINE_FWD_COPY__(_n_xor,_n,ap,d,s,c) +#endif +#ifndef fwdcopy_or +#define fwdcopy_or(ap,d,s,c) __INLINE_FWD_COPY__(_n_or,_n,ap,d,s,c) +#endif +#ifndef fwdcopy_and +#define fwdcopy_and(ap,d,s,c) __INLINE_FWD_COPY__(_n_and,_n,ap,d,s,c) +#endif +#ifndef revcopy_set +#define revcopy_set(ap,d,s,c) __INLINE_REV_COPY__(_n_set,_n,ap,d,s,c) +#endif +#ifndef revcopy_xor +#define revcopy_xor(ap,d,s,c) __INLINE_REV_COPY__(_n_xor,_n,ap,d,s,c) +#endif +#ifndef revcopy_or +#define revcopy_or(ap,d,s,c) __INLINE_REV_COPY__(_n_or,_n,ap,d,s,c) +#endif +#ifndef revcopy_and +#define revcopy_and(ap,d,s,c) __INLINE_REV_COPY__(_n_and,_n,ap,d,s,c) +#endif + +#define fwdcopy_n_set_n fwdcopy_set +#define fwdcopy_n_xor_n fwdcopy_xor +#define fwdcopy_n_or_n fwdcopy_or +#define fwdcopy_n_and_n fwdcopy_and +#define revcopy_n_set_n revcopy_set +#define revcopy_n_xor_n revcopy_xor +#define revcopy_n_or_n revcopy_or +#define revcopy_n_and_n revcopy_and + + +/* memory -> video copy */ +#ifndef fwdcopy_f_set +#define fwdcopy_f_set(ap,d,s,c) __INLINE_FWD_COPY__(_f_set,_n,ap,d,s,c) +#endif +#ifndef fwdcopy_f_xor +#define fwdcopy_f_xor(ap,d,s,c) __INLINE_FWD_COPY__(_f_xor,_n,ap,d,s,c) +#endif +#ifndef fwdcopy_f_or +#define fwdcopy_f_or(ap,d,s,c) __INLINE_FWD_COPY__(_f_or,_n,ap,d,s,c) +#endif +#ifndef fwdcopy_f_and +#define fwdcopy_f_and(ap,d,s,c) __INLINE_FWD_COPY__(_f_and,_n,ap,d,s,c) +#endif +#ifndef revcopy_f_set +#define revcopy_f_set(ap,d,s,c) __INLINE_REV_COPY__(_f_set,_n,ap,d,s,c) +#endif +#ifndef revcopy_f_xor +#define revcopy_f_xor(ap,d,s,c) __INLINE_REV_COPY__(_f_xor,_n,ap,d,s,c) +#endif +#ifndef revcopy_f_or +#define revcopy_f_or(ap,d,s,c) __INLINE_REV_COPY__(_f_or,_n,ap,d,s,c) +#endif +#ifndef revcopy_f_and +#define revcopy_f_and(ap,d,s,c) __INLINE_REV_COPY__(_f_and,_n,ap,d,s,c) +#endif + +#define fwdcopy_f_set_n fwdcopy_f_set +#define fwdcopy_f_xor_n fwdcopy_f_xor +#define fwdcopy_f_or_n fwdcopy_f_or +#define fwdcopy_f_and_n fwdcopy_f_and +#define revcopy_f_set_n revcopy_f_set +#define revcopy_f_xor_n revcopy_f_xor +#define revcopy_f_or_n revcopy_f_or +#define revcopy_f_and_n revcopy_f_and + + +/* video -> memory copy */ +#ifndef fwdcopy_set_f +#define fwdcopy_set_f(ap,d,s,c) __INLINE_FWD_COPY__(_n_set,_f,ap,d,s,c) +#endif +#ifndef fwdcopy_xor_f +#define fwdcopy_xor_f(ap,d,s,c) __INLINE_FWD_COPY__(_n_xor,_f,ap,d,s,c) +#endif +#ifndef fwdcopy_or_f +#define fwdcopy_or_f(ap,d,s,c) __INLINE_FWD_COPY__(_n_or,_f,ap,d,s,c) +#endif +#ifndef fwdcopy_and_f +#define fwdcopy_and_f(ap,d,s,c) __INLINE_FWD_COPY__(_n_and,_f,ap,d,s,c) +#endif +#ifndef revcopy_set_f +#define revcopy_set_f(ap,d,s,c) __INLINE_REV_COPY__(_n_set,_f,ap,d,s,c) +#endif +#ifndef revcopy_xor_f +#define revcopy_xor_f(ap,d,s,c) __INLINE_REV_COPY__(_n_xor,_f,ap,d,s,c) +#endif +#ifndef revcopy_or_f +#define revcopy_or_f(ap,d,s,c) __INLINE_REV_COPY__(_n_or,_f,ap,d,s,c) +#endif +#ifndef revcopy_and_f +#define revcopy_and_f(ap,d,s,c) __INLINE_REV_COPY__(_n_and,_f,ap,d,s,c) +#endif + +#define fwdcopy_n_set_f fwdcopy_set_f +#define fwdcopy_n_xor_f fwdcopy_xor_f +#define fwdcopy_n_or_f fwdcopy_or_f +#define fwdcopy_n_and_f fwdcopy_and_f +#define revcopy_n_set_f revcopy_set_f +#define revcopy_n_xor_f revcopy_xor_f +#define revcopy_n_or_f revcopy_or_f +#define revcopy_n_and_f revcopy_and_f + + +/* video -> video copy */ +#ifndef fwdcopy_f_set_f +#define fwdcopy_f_set_f(ap,d,s,c) __INLINE_FWD_COPY__(_f_set,_f,ap,d,s,c) +#endif +#ifndef fwdcopy_f_xor_f +#define fwdcopy_f_xor_f(ap,d,s,c) __INLINE_FWD_COPY__(_f_xor,_f,ap,d,s,c) +#endif +#ifndef fwdcopy_f_or_f +#define fwdcopy_f_or_f(ap,d,s,c) __INLINE_FWD_COPY__(_f_or,_f,ap,d,s,c) +#endif +#ifndef fwdcopy_f_and_f +#define fwdcopy_f_and_f(ap,d,s,c) __INLINE_FWD_COPY__(_f_and,_f,ap,d,s,c) +#endif +#ifndef revcopy_f_set_f +#define revcopy_f_set_f(ap,d,s,c) __INLINE_REV_COPY__(_f_set,_f,ap,d,s,c) +#endif +#ifndef revcopy_f_xor_f +#define revcopy_f_xor_f(ap,d,s,c) __INLINE_REV_COPY__(_f_xor,_f,ap,d,s,c) +#endif +#ifndef revcopy_f_or_f +#define revcopy_f_or_f(ap,d,s,c) __INLINE_REV_COPY__(_f_or,_f,ap,d,s,c) +#endif +#ifndef revcopy_f_and_f +#define revcopy_f_and_f(ap,d,s,c) __INLINE_REV_COPY__(_f_and,_f,ap,d,s,c) +#endif + +/* + * stuff to copy arrays, structures + */ +#define memcopy(d,s,sze) do { \ + register void far *_CD = (void far *)(d); \ + register void far *_CS = (void far *)(s); \ + register unsigned GR_PtrInt _CC = (unsigned GR_PtrInt)(sze); \ + DBGPRINTF(DBG_COPYFILL,("memcopy size=%u\n",_CC)); \ + fwdcopy_set(_CD,_CD,_CS,_CC); \ +} while(0) +#define sttcopy(dstp,srcp) memcopy((dstp),(srcp),sizeof(*(srcp))) + + + +#endif /* whole file */ diff --git a/thirdparty/grx249/src/include/memfill.h b/thirdparty/grx249/src/include/memfill.h new file mode 100644 index 0000000..5f70a17 --- /dev/null +++ b/thirdparty/grx249/src/include/memfill.h @@ -0,0 +1,944 @@ +/** + ** memfill.h ---- inline assembly memory fill macros + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Basic and optimized memory block fill operations in byte, word and + ** long sizes. The fills are available in WRITE, XOR, OR and AND modes. + ** + **/ + +#ifndef __MEMFILL_H_INCLUDED__ +#define __MEMFILL_H_INCLUDED__ + +#ifndef __MEMMODE_H_INCLUDED__ +#include "memmode.h" +#endif +#ifndef __MEMPEEK_H_INCLUDED__ +#include "mempeek.h" +#endif +#ifndef __ARITH_H_INCLUDED__ +#include "arith.h" +#endif + +#ifdef __GNUC__ +# include "gcc/memfill.h" +#elif defined(__TURBOC__) +# include "bcc/memfill.h" +#elif defined(__WATCOMC__) +# include "watcom/memfill.h" +#endif + +#if !defined(GR_int64) && !defined(NO_64BIT_FILL) +#define NO_64BIT_FILL +#endif +#if !defined(GR_int32) && !defined(NO_32BIT_FILL) +#define NO_32BIT_FILL +#endif +#if !defined(GR_int16) && !defined(NO_16BIT_FILL) +#define NO_16BIT_FILL +#endif + +#if !defined(CPSIZE_b) && defined(GR_int8) +#define CPSIZE_b sizeof(GR_int8) +#endif +#if !defined(CPSIZE_w) && defined(GR_int16) +#define CPSIZE_w sizeof(GR_int16) +#endif +#if !defined(CPSIZE_l) && defined(GR_int32) +#define CPSIZE_l sizeof(GR_int32) +#endif +#if !defined(CPSIZE_h) && defined(GR_int64) +#define CPSIZE_h sizeof(GR_int64) +#endif + +#ifndef __INLINE_STD_COLFILL__ +#define __INLINE_STD_COLFILL__(P,V,C,SKIP,FMODE,INS,SIZE,TYPE) do { \ + poke##FMODE((P),(V)); \ + ptrinc((P),(SKIP)); \ +} while(--(C)) +#endif + +#ifndef __INLINE_STD_OPRFILL__ +#define __INLINE_STD_OPRFILL__(P,V,C,FMODE,INS,SIZE,TYPE) \ + __INLINE_STD_COLFILL__(P,V,C,sizeof(TYPE),FMODE,INS,SIZE,TYPE) +#endif + +#ifndef __INLINE_STD_ROWFILL__ +#define __INLINE_STD_ROWFILL__(P,V,C,FMODE,SIZE,TYPE) \ + __INLINE_STD_OPRFILL__(P,V,C,FMODE,MOV_INS,SIZE,TYPE) +#endif + +#ifndef __INLINE_FAR_COLFILL__ +#define __INLINE_FAR_COLFILL__(P,V,C,SKIP,FMODE,INS,SIZE,TYPE) \ + __INLINE_STD_COLFILL__(P,V,C,SKIP,FMODE,INS,SIZE,TYPE) +#endif + +#ifndef __INLINE_FAR_OPRFILL__ +#define __INLINE_FAR_OPRFILL__(P,V,C,FMODE,INS,SIZE,TYPE) \ + __INLINE_FAR_COLFILL__(P,V,C,sizeof(TYPE),FMODE,INS,SIZE,TYPE) +#endif + +#ifndef __INLINE_FAR_ROWFILL__ +#define __INLINE_FAR_ROWFILL__(P,V,C,FMODE,SIZE,TYPE) \ + __INLINE_FAR_OPRFILL__(P,V,C,FMODE,MOV_INS,SIZE,TYPE) +#endif + +/* + * rowfill_[_][_](pointer,value,count) + */ +#ifndef rowfill_b +#define rowfill_b(p,v,c) \ + __INLINE_STD_ROWFILL__(p,v,c,_b,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(rowfill_w) +#define rowfill_w(p,v,c) \ + __INLINE_STD_ROWFILL__(p,v,c,_w,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(rowfill_l) +#define rowfill_l(p,v,c) \ + __INLINE_STD_ROWFILL__(p,v,c,_l,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(rowfill_h) +#define rowfill_h(p,v,c) \ + __INLINE_STD_ROWFILL__(p,v,c,_h,OP64b,GR_int64) +#endif + +#ifndef rowfill_b_xor +#define rowfill_b_xor(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_b_xor,XOR_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(rowfill_w_xor) +#define rowfill_w_xor(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_w_xor,XOR_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(rowfill_l_xor) +#define rowfill_l_xor(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_l_xor,XOR_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(rowfill_h_xor) +#define rowfill_h_xor(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_h_xor,XOR_INS,OP64b,GR_int64) +#endif + +#ifndef rowfill_b_or +#define rowfill_b_or(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_b_or,OR_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(rowfill_w_or) +#define rowfill_w_or(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_w_or,OR_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(rowfill_l_or) +#define rowfill_l_or(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_l_or,OR_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(rowfill_h_or) +#define rowfill_h_or(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_h_or,OR_INS,OP64b,GR_int64) +#endif + +#ifndef rowfill_b_and +#define rowfill_b_and(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_b_and,AND_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(rowfill_w_and) +#define rowfill_w_and(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_w_and,AND_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(rowfill_l_and) +#define rowfill_l_and(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_l_and,AND_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(rowfill_h_and) +#define rowfill_h_and(p,v,c) \ + __INLINE_STD_OPRFILL__(p,v,c,_h_and,AND_INS,OP64b,GR_int64) +#endif + +#define rowfill_b_n rowfill_b +#define rowfill_w_n rowfill_w +#define rowfill_l_n rowfill_l +#define rowfill_h_n rowfill_h +#define rowfill_b_xor_n rowfill_b_xor +#define rowfill_w_xor_n rowfill_w_xor +#define rowfill_l_xor_n rowfill_l_xor +#define rowfill_h_xor_n rowfill_h_xor +#define rowfill_b_or_n rowfill_b_or +#define rowfill_w_or_n rowfill_w_or +#define rowfill_l_or_n rowfill_l_or +#define rowfill_h_or_n rowfill_h_or +#define rowfill_b_and_n rowfill_b_and +#define rowfill_w_and_n rowfill_w_and +#define rowfill_l_and_n rowfill_l_and +#define rowfill_h_and_n rowfill_h_and + + + +#ifndef rowfill_b_f +#define rowfill_b_f(p,v,c) \ + __INLINE_FAR_ROWFILL__(p,v,c,_b_f,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(rowfill_w_f) +#define rowfill_w_f(p,v,c) \ + __INLINE_FAR_ROWFILL__(p,v,c,_w_f,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(rowfill_l_f) +#define rowfill_l_f(p,v,c) \ + __INLINE_FAR_ROWFILL__(p,v,c,_l_f,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(rowfill_h_f) +#define rowfill_h_f(p,v,c) \ + __INLINE_FAR_ROWFILL__(p,v,c,_h_f,OP64b,GR_int64) +#endif + +#ifndef rowfill_b_f_xor +#define rowfill_b_f_xor(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_b_f_xor,XOR_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(rowfill_w_f_xor) +#define rowfill_w_f_xor(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_w_f_xor,XOR_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(rowfill_l_f_xor) +#define rowfill_l_f_xor(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_l_f_xor,XOR_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(rowfill_h_f_xor) +#define rowfill_h_f_xor(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_h_f_xor,XOR_INS,OP64b,GR_int64) +#endif + +#ifndef rowfill_b_f_or +#define rowfill_b_f_or(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_b_f_or,OR_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(rowfill_w_f_or) +#define rowfill_w_f_or(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_w_f_or,OR_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(rowfill_l_f_or) +#define rowfill_l_f_or(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_l_f_or,OR_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(rowfill_h_f_or) +#define rowfill_h_f_or(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_h_f_or,OR_INS,OP64b,GR_int64) +#endif + +#ifndef rowfill_b_f_and +#define rowfill_b_f_and(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_b_f_and,AND_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(rowfill_w_f_and) +#define rowfill_w_f_and(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_w_f_and,AND_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(rowfill_l_f_and) +#define rowfill_l_f_and(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_l_f_and,AND_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(rowfill_h_f_and) +#define rowfill_h_f_and(p,v,c) \ + __INLINE_FAR_OPRFILL__(p,v,c,_h_f_and,AND_INS,OP64b,GR_int64) +#endif + +/* + * colfill_[_][_](pointer,offset,value,count) + */ +#ifndef colfill_b +#define colfill_b(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_b,MOV_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(colfill_w) +#define colfill_w(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_w,MOV_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(colfill_l) +#define colfill_l(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_l,MOV_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(colfill_h) +#define colfill_h(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_h,MOV_INS,OP64b,GR_int64) +#endif + +#ifndef colfill_b_xor +#define colfill_b_xor(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_b_xor,XOR_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(colfill_w_xor) +#define colfill_w_xor(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_w_xor,XOR_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(colfill_l_xor) +#define colfill_l_xor(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_l_xor,XOR_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(colfill_h_xor) +#define colfill_h_xor(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_h_xor,XOR_INS,OP64b,GR_int64) +#endif + +#ifndef colfill_b_or +#define colfill_b_or(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_b_or,OR_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(colfill_w_or) +#define colfill_w_or(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_w_or,OR_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(colfill_l_or) +#define colfill_l_or(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_l_or,OR_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(colfill_h_or) +#define colfill_h_or(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_h_or,OR_INS,OP64b,GR_int64) +#endif + +#ifndef colfill_b_and +#define colfill_b_and(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_b_and,AND_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(colfill_w_and) +#define colfill_w_and(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_w_and,AND_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(colfill_l_and) +#define colfill_l_and(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_l_and,AND_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(colfill_h_and) +#define colfill_h_and(p,o,v,c) \ + __INLINE_STD_COLFILL__(p,v,c,o,_h_and,AND_INS,OP64b,GR_int64) +#endif + +#ifndef colfill_b_f +#define colfill_b_f(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_b_f,MOV_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(colfill_w_f) +#define colfill_w_f(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_w_f,MOV_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(colfill_l_f) +#define colfill_l_f(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_l_f,MOV_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(colfill_h_f) +#define colfill_h_f(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_h_f,MOV_INS,OP64b,GR_int64) +#endif + +#ifndef colfill_b_f_xor +#define colfill_b_f_xor(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_b_f_xor,XOR_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(colfill_w_f_xor) +#define colfill_w_f_xor(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_w_f_xor,XOR_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(colfill_l_f_xor) +#define colfill_l_f_xor(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_l_f_xor,XOR_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(colfill_h_f_xor) +#define colfill_h_f_xor(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_h_f_xor,XOR_INS,OP64b,GR_int64) +#endif + +#ifndef colfill_b_f_or +#define colfill_b_f_or(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_b_f_or,OR_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(colfill_w_f_or) +#define colfill_w_f_or(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_w_f_or,OR_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(colfill_l_f_or) +#define colfill_l_f_or(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_l_f_or,OR_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(colfill_h_f_or) +#define colfill_h_f_or(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_h_f_or,OR_INS,OP64b,GR_int64) +#endif + +#ifndef colfill_b_f_and +#define colfill_b_f_and(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_b_f_and,AND_INS,OP8b,GR_int8) +#endif +#if !defined(NO_16BIT_FILL) && !defined(colfill_w_f_and) +#define colfill_w_f_and(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_w_f_and,AND_INS,OP16b,GR_int16) +#endif +#if !defined(NO_32BIT_FILL) && !defined(colfill_l_f_and) +#define colfill_l_f_and(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_l_f_and,AND_INS,OP32b,GR_int32) +#endif +#if !defined(NO_64BIT_FILL) && !defined(colfill_h_f_and) +#define colfill_h_f_and(p,o,v,c) \ + __INLINE_FAR_COLFILL__(p,v,c,o,_h_f_and,AND_INS,OP64b,GR_int64) +#endif + +/* + * Optimized row fill operations in byte, word and long sizes. + * The idea is that the bulk of the fill operation is done using + * aligned long fills with a few possible shorter alignment and/or pad + * fills at start and/or end. The smaller size routines (byte, word) + * still assume a long fill argument with the fill value replicated + * in the upper bytes. + */ + +/* generic single element fill */ +#ifndef __INLINE_1_FILL__ +#define __INLINE_1_FILL__(P,V,WOP,SZ) do { \ + poke_##SZ##WOP((P),(V)); \ + ptrinc((P),(CPSIZE_##SZ)); \ +} while (0) +#endif + +/* fill and step to next higher alignment boundary */ +#ifndef __INLINE_ALIGN_FILL__ +#define __INLINE_ALIGN_FILL__(P,V,C,WOP,SZ,BASE) \ + if ( ((GR_PtrInt)(P)) & CPSIZE_##SZ ) { \ + __INLINE_1_FILL__(P,V,WOP,SZ); \ + (C) -= (CPSIZE_##SZ/CPSIZE_##BASE); \ + if ( ! ((GR_PtrInt)(C)) ) break; \ + } +#endif + +/* fill && step remaining bytes after otimal fill */ +#ifndef __INLINE_TAIL_FILL__ +#define __INLINE_TAIL_FILL__(P,V,C,WOP,SZ,BASE) do { \ + if ( ((GR_PtrInt)(C)) & (CPSIZE_##SZ/CPSIZE_##BASE) ) \ + __INLINE_1_FILL__(P,V,WOP,SZ); \ +} while (0) +#endif + +#ifndef __INLINE_STD_OPT_FILL__ +#define __INLINE_STD_OPT_FILL__(P,V,C,WOP,SZ,BASE) do { \ + if ((unsigned GR_PtrInt)(C) >= 2*(CPSIZE_##SZ/CPSIZE_##BASE)-1 ) { \ + unsigned GR_PtrInt _c_ = (-((GR_PtrInt)(P))) & ((CPSIZE_##SZ/CPSIZE_##BASE)-1); \ + if (_c_) { \ + (C) -= _c_; \ + rowfill_##BASE##WOP(P,V,_c_); \ + } \ + _c_ = ((unsigned GR_PtrInt)(C)) / (CPSIZE_##SZ/CPSIZE_##BASE); \ + rowfill_##SZ##WOP(P,V,_c_); \ + (C) &= ((CPSIZE_##SZ/CPSIZE_##BASE)-1); \ + } \ + if ( (GR_PtrInt)(C) ) \ + rowfill_b##WOP(P,V,C); \ +} while(0) +#endif + + +#ifndef __INLINE_B_REPFILL__ +# if !defined(NO_64BIT_FILL) +# if defined(MISALIGNED_32bit_OK) && defined(MISALIGNED_16bit_OK) +# define __INLINE_B_REPFILL__(P,V,C,FMODE) do { \ + if ((unsigned GR_PtrInt)(C) >= 7 ) { \ + __INLINE_ALIGN_FILL__(P,V,C,FMODE,b,b); \ + __INLINE_ALIGN_FILL__(P,V,C,FMODE,w,b); \ + __INLINE_ALIGN_FILL__(P,V,C,FMODE,l,b); \ + { unsigned GR_PtrInt _c64_ = ((unsigned GR_PtrInt)(C)) >> 3; \ + if (_c64_) rowfill_h##FMODE(P,V,_c64_); } \ + } \ + __INLINE_TAIL_FILL__(P,V,C,FMODE,l,b); \ + __INLINE_TAIL_FILL__(P,V,C,FMODE,w,b); \ + __INLINE_TAIL_FILL__(P,V,C,FMODE,b,b); \ + } while (0) +# else +# define __INLINE_B_REPFILL__(P,V,C,FMODE) \ + __INLINE_STD_OPT_FILL__(P,V,C,FMODE,h,b) +# endif +# elif !defined(NO_32BIT_FILL) +# if defined(MISALIGNED_16bit_OK) +# define __INLINE_B_REPFILL__(P,V,C,FMODE) do { \ + if ((unsigned GR_PtrInt)(C) >= 3 ) { \ + __INLINE_ALIGN_FILL__(P,V,C,FMODE,b,b); \ + __INLINE_ALIGN_FILL__(P,V,C,FMODE,w,b); \ + { unsigned GR_PtrInt _c32_ = ((unsigned GR_PtrInt)(C)) >> 2; \ + if (_c32_) rowfill_l##FMODE(P,V,_c32_); } \ + } \ + __INLINE_TAIL_FILL__(P,V,C,FMODE,w,b); \ + __INLINE_TAIL_FILL__(P,V,C,FMODE,b,b); \ + } while (0) +# else +# define __INLINE_B_REPFILL__(P,V,C,FMODE) \ + __INLINE_STD_OPT_FILL__(P,V,C,FMODE,l,b) +# endif +# elif !defined(NO_16BIT_FILL) +# define __INLINE_B_REPFILL__(P,V,C,FMODE) do { \ + __INLINE_ALIGN_FILL__(P,V,C,FMODE,b,b); \ + { unsigned GR_PtrInt _c16_ = ((unsigned GR_PtrInt)(C)) >> 1; \ + if (_c16_) rowfill_w##FMODE(P,V,_c16_); } \ + __INLINE_TAIL_FILL__(P,V,C,FMODE,b,b); \ + } while (0) +# else +# define __INLINE_B_REPFILL__(P,V,C,FMODE) \ + rowfill_b##FMODE(P,V,C) +# endif +#endif /* !__INLINE_B_REPFILL__ */ + +#if !defined(NO_16BIT_FILL) && !defined(__INLINE_W_REPFILL__) +# if !defined(NO_64BIT_FILL) +# if defined(MISALIGNED_32bit_OK) +# define __INLINE_W_REPFILL__(P,V,C,FMODE) do { \ + if ((unsigned GR_PtrInt)(C) >= 3 ) { \ + __INLINE_ALIGN_FILL__(P,V,C,FMODE,w,w); \ + __INLINE_ALIGN_FILL__(P,V,C,FMODE,l,w); \ + { unsigned GR_PtrInt _c64_ = ((unsigned GR_PtrInt)(C)) >> 2; \ + if (_c64_) rowfill_h##FMODE(P,V,_c64_); } \ + } \ + __INLINE_TAIL_FILL__(P,V,C,FMODE,l,w); \ + __INLINE_TAIL_FILL__(P,V,C,FMODE,w,w); \ + } while (0) +# else +# define __INLINE_W_REPFILL__(P,V,C,FMODE) \ + __INLINE_STD_OPT_FILL__(P,V,C,FMODE,h,w) +# endif +# elif !defined(NO_32BIT_FILL) +# define __INLINE_W_REPFILL__(P,V,C,FMODE) do { \ + __INLINE_ALIGN_FILL__(P,V,C,FMODE,w,w); \ + { unsigned GR_PtrInt _c32_ = ((unsigned GR_PtrInt)(C)) >> 1; \ + if (_c32_) rowfill_l##FMODE(P,V,_c32_); } \ + __INLINE_TAIL_FILL__(P,V,C,FMODE,w,w); \ + } while (0) +# else +# define __INLINE_W_REPFILL__(P,V,C,FMODE) \ + rowfill_w##FMODE(P,V,C) +# endif +#endif /* !__INLINE_W_REPFILL__ */ + +#if !defined(NO_32BIT_FILL) && !defined(__INLINE_L_REPFILL__) +# if !defined(NO_64BIT_FILL) +# define __INLINE_L_REPFILL__(P,V,C,FMODE) do { \ + __INLINE_ALIGN_FILL__(P,V,C,FMODE,l,l); \ + { unsigned GR_PtrInt _c64_ = ((unsigned GR_PtrInt)(C)) >> 1; \ + if (_c64_) rowfill_h##FMODE(P,V,_c64_); } \ + __INLINE_TAIL_FILL__(P,V,C,FMODE,l,l); \ + } while (0) +# else +# define __INLINE_L_REPFILL__(P,V,C,FMODE) \ + rowfill_l##FMODE(P,V,C) +# endif +#endif /* !__INLINE_L_REPFILL__ */ + +#if !defined(NO_64BIT_FILL) && !defined(__INLINE_H_REPFILL__) +#define __INLINE_H_REPFILL__(P,V,C,FMODE) do { \ + rowfill_h##FMODE((P),(V),(C)); \ +} while(0) +#endif /* !__INLINE_H_REPFILL__ */ + +/* + * repfill_[_][_](pointer,value,count) + */ +#ifndef repfill_b +#define repfill_b(p,v,c) __INLINE_B_REPFILL__(p,v,c,_n) +#endif +#if defined(__INLINE_W_REPFILL__) && !defined(repfill_w) +#define repfill_w(p,v,c) __INLINE_W_REPFILL__(p,v,c,_n) +#endif +#if defined(__INLINE_L_REPFILL__) && !defined(repfill_l) +#define repfill_l(p,v,c) __INLINE_L_REPFILL__(p,v,c,_n) +#endif +#if defined(__INLINE_H_REPFILL__) && !defined(repfill_h) +#define repfill_h(p,v,c) __INLINE_H_REPFILL__(p,v,c,_n) +#endif + +#ifndef repfill_b_xor +#define repfill_b_xor(p,v,c) __INLINE_B_REPFILL__(p,v,c,_xor) +#endif +#if defined(__INLINE_W_REPFILL__) && !defined(repfill_w_xor) +#define repfill_w_xor(p,v,c) __INLINE_W_REPFILL__(p,v,c,_xor) +#endif +#if defined(__INLINE_L_REPFILL__) && !defined(repfill_l_xor) +#define repfill_l_xor(p,v,c) __INLINE_L_REPFILL__(p,v,c,_xor) +#endif +#if defined(__INLINE_H_REPFILL__) && !defined(repfill_h_xor) +#define repfill_h_xor(p,v,c) __INLINE_H_REPFILL__(p,v,c,_xor) +#endif + +#ifndef repfill_b_or +#define repfill_b_or(p,v,c) __INLINE_B_REPFILL__(p,v,c,_or) +#endif +#if defined(__INLINE_W_REPFILL__) && !defined(repfill_w_or) +#define repfill_w_or(p,v,c) __INLINE_W_REPFILL__(p,v,c,_or) +#endif +#if defined(__INLINE_L_REPFILL__) && !defined(repfill_l_or) +#define repfill_l_or(p,v,c) __INLINE_L_REPFILL__(p,v,c,_or) +#endif +#if defined(__INLINE_H_REPFILL__) && !defined(repfill_h_or) +#define repfill_h_or(p,v,c) __INLINE_H_REPFILL__(p,v,c,_or) +#endif + +#ifndef repfill_b_and +#define repfill_b_and(p,v,c) __INLINE_B_REPFILL__(p,v,c,_and) +#endif +#if defined(__INLINE_W_REPFILL__) && !defined(repfill_w_and) +#define repfill_w_and(p,v,c) __INLINE_W_REPFILL__(p,v,c,_and) +#endif +#if defined(__INLINE_L_REPFILL__) && !defined(repfill_l_and) +#define repfill_l_and(p,v,c) __INLINE_L_REPFILL__(p,v,c,_and) +#endif +#if defined(__INLINE_H_REPFILL__) && !defined(repfill_h_and) +#define repfill_h_and(p,v,c) __INLINE_H_REPFILL__(p,v,c,_and) +#endif + +#ifndef repfill_b_f +#define repfill_b_f(p,v,c) __INLINE_B_REPFILL__(p,v,c,_f) +#endif +#if defined(__INLINE_W_REPFILL__) && !defined(repfill_w_f) +#define repfill_w_f(p,v,c) __INLINE_W_REPFILL__(p,v,c,_f) +#endif +#if defined(__INLINE_L_REPFILL__) && !defined(repfill_l_f) +#define repfill_l_f(p,v,c) __INLINE_L_REPFILL__(p,v,c,_f) +#endif +#if defined(__INLINE_H_REPFILL__) && !defined(repfill_h_f) +#define repfill_h_f(p,v,c) __INLINE_H_REPFILL__(p,v,c,_f) +#endif + +#ifndef repfill_b_f_xor +#define repfill_b_f_xor(p,v,c) __INLINE_B_REPFILL__(p,v,c,_f_xor) +#endif +#if defined(__INLINE_W_REPFILL__) && !defined(repfill_w_f_xor) +#define repfill_w_f_xor(p,v,c) __INLINE_W_REPFILL__(p,v,c,_f_xor) +#endif +#if defined(__INLINE_L_REPFILL__) && !defined(repfill_l_f_xor) +#define repfill_l_f_xor(p,v,c) __INLINE_L_REPFILL__(p,v,c,_f_xor) +#endif +#if defined(__INLINE_H_REPFILL__) && !defined(repfill_h_f_xor) +#define repfill_h_f_xor(p,v,c) __INLINE_H_REPFILL__(p,v,c,_f_xor) +#endif + +#ifndef repfill_b_f_or +#define repfill_b_f_or(p,v,c) __INLINE_B_REPFILL__(p,v,c,_f_or) +#endif +#if defined(__INLINE_W_REPFILL__) && !defined(repfill_w_f_or) +#define repfill_w_f_or(p,v,c) __INLINE_W_REPFILL__(p,v,c,_f_or) +#endif +#if defined(__INLINE_L_REPFILL__) && !defined(repfill_l_f_or) +#define repfill_l_f_or(p,v,c) __INLINE_L_REPFILL__(p,v,c,_f_or) +#endif +#if defined(__INLINE_H_REPFILL__) && !defined(repfill_h_f_or) +#define repfill_h_f_or(p,v,c) __INLINE_H_REPFILL__(p,v,c,_f_or) +#endif + +#ifndef repfill_b_f_and +#define repfill_b_f_and(p,v,c) __INLINE_B_REPFILL__(p,v,c,_f_and) +#endif +#if defined(__INLINE_W_REPFILL__) && !defined(repfill_w_f_and) +#define repfill_w_f_and(p,v,c) __INLINE_W_REPFILL__(p,v,c,_f_and) +#endif +#if defined(__INLINE_L_REPFILL__) && !defined(repfill_l_f_and) +#define repfill_l_f_and(p,v,c) __INLINE_L_REPFILL__(p,v,c,_f_and) +#endif +#if defined(__INLINE_H_REPFILL__) && !defined(repfill_h_f_and) +#define repfill_h_f_and(p,v,c) __INLINE_H_REPFILL__(p,v,c,_f_and) +#endif + +#define repfill_b_n repfill_b +#define repfill_w_n repfill_w +#define repfill_l_n repfill_l +#define repfill_h_n repfill_h +#define repfill_b_xor_n repfill_b_xor +#define repfill_w_xor_n repfill_w_xor +#define repfill_l_xor_n repfill_l_xor +#define repfill_h_xor_n repfill_h_xor +#define repfill_b_or_n repfill_b_or +#define repfill_w_or_n repfill_w_or +#define repfill_l_or_n repfill_l_or +#define repfill_h_or_n repfill_h_or +#define repfill_b_and_n repfill_b_and +#define repfill_w_and_n repfill_w_and +#define repfill_l_and_n repfill_l_and +#define repfill_h_and_n repfill_h_and + + +/* + * Another set of optimized fills which also do the replication. + */ +#if !defined(NO_64BIT_FILL) +#define GR_repl GR_int64u +#define freplicate_b(V) replicate_b2h(V) +#define freplicate_w(V) replicate_w2h(V) +#define freplicate_l(V) replicate_l2h(V) +#elif !defined(NO_32BIT_FILL) +#define GR_repl GR_int32u +#define freplicate_b(V) replicate_b2l(V) +#define freplicate_w(V) replicate_w2l(V) +#define freplicate_l(V) (V) +#elif !defined(NO_16BIT_FILL) +#define GR_repl GR_int16u +#define freplicate_b(V) replicate_b2w(V) +#define freplicate_w(V) (V) +#else +#define GR_repl GR_int8u +#define freplicate_b(V) (V) +#endif + +/* + * optfill_[_][_](pointer,value,count) + */ +#define optfill_b(p,v,c) repfill_b(p,freplicate_b(v),c) +#define optfill_w(p,v,c) repfill_w(p,freplicate_w(v),c) +#define optfill_l(p,v,c) repfill_l(p,freplicate_l(v),c) + +#define optfill_b_xor(p,v,c) repfill_b_xor(p,freplicate_b(v),c) +#define optfill_w_xor(p,v,c) repfill_w_xor(p,freplicate_w(v),c) +#define optfill_l_xor(p,v,c) repfill_l_xor(p,freplicate_l(v),c) + +#define optfill_b_or(p,v,c) repfill_b_or(p,freplicate_b(v),c) +#define optfill_w_or(p,v,c) repfill_w_or(p,freplicate_w(v),c) +#define optfill_l_or(p,v,c) repfill_l_or(p,freplicate_l(v),c) + +#define optfill_b_and(p,v,c) repfill_b_and(p,freplicate_b(v),c) +#define optfill_w_and(p,v,c) repfill_w_and(p,freplicate_w(v),c) +#define optfill_l_and(p,v,c) repfill_l_and(p,freplicate_l(v),c) + +#define optfill_b_f(p,v,c) repfill_b_f(p,freplicate_b(v),c) +#define optfill_w_f(p,v,c) repfill_w_f(p,freplicate_w(v),c) +#define optfill_l_f(p,v,c) repfill_l_f(p,freplicate_l(v),c) + +#define optfill_b_f_xor(p,v,c) repfill_b_f_xor(p,freplicate_b(v),c) +#define optfill_w_f_xor(p,v,c) repfill_w_f_xor(p,freplicate_w(v),c) +#define optfill_l_f_xor(p,v,c) repfill_l_f_xor(p,freplicate_l(v),c) + +#define optfill_b_f_or(p,v,c) repfill_b_f_or(p,freplicate_b(v),c) +#define optfill_w_f_or(p,v,c) repfill_w_f_or(p,freplicate_w(v),c) +#define optfill_l_f_or(p,v,c) repfill_l_f_or(p,freplicate_l(v),c) + +#define optfill_b_f_and(p,v,c) repfill_b_f_and(p,freplicate_b(v),c) +#define optfill_w_f_and(p,v,c) repfill_w_f_and(p,freplicate_w(v),c) +#define optfill_l_f_and(p,v,c) repfill_l_f_and(p,freplicate_l(v),c) + +/* + * A set of optimized fills which preserves the address and count arguments + * and performs small constant sized fills unrolled if the compiler supports + * this (e.g. GCC) + */ + +#ifndef __INLINE_MEMFILL__ +#define __INLINE_MEMFILL__(P,V,C,SIZE,TYPE,FMODE) do { \ + register void *_FP = (void *)(P); \ + register GR_repl _FV = freplicate_##SIZE((TYPE)(V)); \ + register GR_PtrInt _FC = (GR_PtrInt)(C); \ + repfill_##SIZE##FMODE(_FP,_FV,_FC); \ +} while(0) +#endif + +/* + * memfill_[_][_](pointer,value,count) + */ +#define memfill_b(p,v,c) __INLINE_MEMFILL__(p,v,c,b,GR_int8,_n) +#define memfill_w(p,v,c) __INLINE_MEMFILL__(p,v,c,w,GR_int16,_n) +#define memfill_l(p,v,c) __INLINE_MEMFILL__(p,v,c,l,GR_int32,_n) + +#define memfill_b_xor(p,v,c) __INLINE_MEMFILL__(p,v,c,b,GR_int8,_xor) +#define memfill_w_xor(p,v,c) __INLINE_MEMFILL__(p,v,c,w,GR_int16,_xor) +#define memfill_l_xor(p,v,c) __INLINE_MEMFILL__(p,v,c,l,GR_int32,_xor) + +#define memfill_b_or(p,v,c) __INLINE_MEMFILL__(p,v,c,b,GR_int8,_or) +#define memfill_w_or(p,v,c) __INLINE_MEMFILL__(p,v,c,w,GR_int16,_or) +#define memfill_l_or(p,v,c) __INLINE_MEMFILL__(p,v,c,l,GR_int32,_or) + +#define memfill_b_and(p,v,c) __INLINE_MEMFILL__(p,v,c,b,GR_int8,_and) +#define memfill_w_and(p,v,c) __INLINE_MEMFILL__(p,v,c,w,GR_int16,_and) +#define memfill_l_and(p,v,c) __INLINE_MEMFILL__(p,v,c,l,GR_int32,_and) + +#define memfill_b_f(p,v,c) __INLINE_MEMFILL__(p,v,c,b,GR_int8,_f) +#define memfill_w_f(p,v,c) __INLINE_MEMFILL__(p,v,c,w,GR_int16,_f) +#define memfill_l_f(p,v,c) __INLINE_MEMFILL__(p,v,c,l,GR_int32,_f) + +#define memfill_b_f_xor(p,v,c) __INLINE_MEMFILL__(p,v,c,b,GR_int8,_f_xor) +#define memfill_w_f_xor(p,v,c) __INLINE_MEMFILL__(p,v,c,w,GR_int16,_f_xor) +#define memfill_l_f_xor(p,v,c) __INLINE_MEMFILL__(p,v,c,l,GR_int32,_f_xor) + +#define memfill_b_f_or(p,v,c) __INLINE_MEMFILL__(p,v,c,b,GR_int8,_f_or) +#define memfill_w_f_or(p,v,c) __INLINE_MEMFILL__(p,v,c,w,GR_int16,_f_or) +#define memfill_l_f_or(p,v,c) __INLINE_MEMFILL__(p,v,c,l,GR_int32,_f_or) + +#define memfill_b_f_and(p,v,c) __INLINE_MEMFILL__(p,v,c,b,GR_int8,_f_and) +#define memfill_w_f_and(p,v,c) __INLINE_MEMFILL__(p,v,c,w,GR_int16,_f_and) +#define memfill_l_f_and(p,v,c) __INLINE_MEMFILL__(p,v,c,l,GR_int32,_f_and) + +/* + * 24bpp special support functions + */ + +#ifndef __INLINE_24_REPFILL__ +#define __INLINE_24_REPFILL__(P,C,B,FMODE,INS) do { \ + GR_int32u _cl24_ = (GR_int32u)(C); \ + GR_PtrInt _b24_ = (GR_PtrInt)(B); \ + while ( _b24_ >= 3) { \ + poke_24##FMODE((P), _cl24_); \ + ptrinc((P),3); \ + _b24_ -= 3; \ + } \ + /* B = 0..2 */ \ + if (! _b24_ ) break; \ + poke_b##FMODE((P), (GR_int8u)_cl24_); \ + ptrinc((P),1); \ + if (! --_b24_ ) break; \ + poke_b##FMODE((P), (GR_int8u)(_cl24_>>8)); \ + ptrinc((P),1); \ +} while (0) +#endif + +#ifndef __INLINE_24_FAR_REPFILL__ +#define __INLINE_24_FAR_REPFILL__(P,C,B,FMODE,INS) \ + __INLINE_24_REPFILL__(P,C,B,FMODE,INS) +#endif + +#ifndef repfill_24_set +#define repfill_24_set(p,c,b) __INLINE_24_REPFILL__(p,c,b,_set,MOV_INS) +#endif +#ifndef repfill_24_xor +#define repfill_24_xor(p,c,b) __INLINE_24_REPFILL__(p,c,b,_xor,XOR_INS) +#endif +#ifndef repfill_24_or +#define repfill_24_or(p,c,b) __INLINE_24_REPFILL__(p,c,b,_or,OR_INS) +#endif +#ifndef repfill_24_and +#define repfill_24_and(p,c,b) __INLINE_24_REPFILL__(p,c,b,_and,AND_INS) +#endif + +#ifndef repfill_24_f_set +#define repfill_24_f_set(p,c,b) __INLINE_24_FAR_REPFILL__(p,c,b,_f_set,MOV_INS) +#endif +#ifndef repfill_24_f_xor +#define repfill_24_f_xor(p,c,b) __INLINE_24_FAR_REPFILL__(p,c,b,_f_xor,XOR_INS) +#endif +#ifndef repfill_24_f_or +#define repfill_24_f_or(p,c,b) __INLINE_24_FAR_REPFILL__(p,c,b,_f_or,OR_INS) +#endif +#ifndef repfill_24_f_and +#define repfill_24_f_and(p,c,b) __INLINE_24_FAR_REPFILL__(p,c,b,_f_and,AND_INS) +#endif + +#ifndef __INLINE_24_MEMFILL +#define __INLINE_24_MEMFILL__(p,c,b,FMODE) do { \ + void *_p24 = (p); \ + unsigned long _c24 = (c); \ + unsigned _b24 = (b); \ + repfill_24##FMODE(_p24,_c24,_b24); \ +} while (0) +#endif + +#ifndef memfill_24_set +#define memfill_24_set(p,c,b) __INLINE_24_MEMFILL__(p,c,b,_set) +#endif +#ifndef memfill_24_xor +#define memfill_24_xor(p,c,b) __INLINE_24_MEMFILL__(p,c,b,_xor) +#endif +#ifndef memfill_24_or +#define memfill_24_or(p,c,b) __INLINE_24_MEMFILL__(p,c,b,_or) +#endif +#ifndef memfill_24_and +#define memfill_24_and(p,c,b) __INLINE_24_MEMFILL__(p,c,b,_and) +#endif + +#ifndef memfill_24_set_f +#define memfill_24_set_f(p,c,b) __INLINE_24_MEMFILL__(p,c,b,_set_f) +#endif +#ifndef memfill_24_xor_f +#define memfill_24_xor_f(p,c,b) __INLINE_24_MEMFILL__(p,c,b,_xor_f) +#endif +#ifndef memfill_24_or_f +#define memfill_24_or_f(p,c,b) __INLINE_24_MEMFILL__(p,c,b,_or_f) +#endif +#ifndef memfill_24_and_f +#define memfill_24_and_f(p,c,b) __INLINE_24_MEMFILL__(p,c,b,_and_f) +#endif + +#define memfill_24 memfill_24_set +#define memfill_24_f memfill_24_set_f + + +/* + * stuff to clear arrays, structures + */ +/* +#ifdef __TURBOC__ +#define memzero(p,s) memfill_w((p),0,((s) >> 1)) +#endif +#ifndef memzero +#define memzero(p,s) memfill_l((p),0,((s) >> 2)) +#endif +*/ +#define memzero(p,s) do { \ + register void far *_FP = (void far *)(p); \ + register GR_repl _FV = 0; \ + register unsigned _FC = (unsigned)(s); \ + DBGPRINTF(DBG_COPYFILL,("memzero size=%u\n",_FC)); \ + repfill_b(_FP,_FV,_FC); \ +} while(0) + + +#define sttzero(p) memzero((p),sizeof(*(p))) + +#if (defined(__WATCOMC__) && !defined(__386__)) +/* + * These are not really here! + */ +#undef rowfill_l +#undef rowfill_l_xor +#undef rowfill_l_or +#undef rowfill_l_and +#undef rowfill_l_f +#undef rowfill_l_f_xor +#undef rowfill_l_f_or +#undef rowfill_l_f_and + +#undef repfill_l +#undef repfill_l_xor +#undef repfill_l_or +#undef repfill_l_and +#undef repfill_l_f +#undef repfill_l_f_xor +#undef repfill_l_f_or +#undef repfill_l_f_and + +#undef optfill_l +#undef optfill_l_xor +#undef optfill_l_or +#undef optfill_l_and +#undef optfill_l_f +#undef optfill_l_f_xor +#undef optfill_l_f_or +#undef optfill_l_f_and + +#undef memfill_l +#undef memfill_l_xor +#undef memfill_l_or +#undef memfill_l_and +#undef memfill_l_f +#undef memfill_l_f_xor +#undef memfill_l_f_or +#undef memfill_l_f_and + +#undef colfill_l +#undef colfill_l_xor +#undef colfill_l_or +#undef colfill_l_and +#undef colfill_l_f +#undef colfill_l_f_xor +#undef colfill_l_f_or +#undef colfill_l_f_and + +#endif + +#endif /* whole file */ diff --git a/thirdparty/grx249/src/include/memmode.h b/thirdparty/grx249/src/include/memmode.h new file mode 100644 index 0000000..8456a18 --- /dev/null +++ b/thirdparty/grx249/src/include/memmode.h @@ -0,0 +1,45 @@ +/** + ** memmode.h ---- determine how to access video and system RAM + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __MEMMODE_H_INCLUDED__ +#define __MEMMODE_H_INCLUDED__ + +#ifdef __GNUC__ +#include "gcc/memmode.h" +#elif defined(__TURBOC__) +#include "bcc/memmode.h" +#elif defined(__WATCOMC__) +#include "watcom/memmode.h" +#endif + +#ifndef LINP_PTR +#define LINP_PTR(p) (p) +#endif +#ifndef LINP_SEL +#define LINP_SEL(p) 0 +#endif + +#ifndef MK_FP +#define MK_FP(s,o) (void *)( \ + ((GR_int32u)(GR_int16u)(s) << 4) + \ + (GR_int16u)(o) \ +) +#endif + +#endif /* whole file */ + diff --git a/thirdparty/grx249/src/include/mempeek.h b/thirdparty/grx249/src/include/mempeek.h new file mode 100644 index 0000000..8a4ba91 --- /dev/null +++ b/thirdparty/grx249/src/include/mempeek.h @@ -0,0 +1,352 @@ +/** + ** mempeek.h ---- (far) memory read/write operations + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Basic memory peek and poke operations in byte, word and long sizes. + ** The poke operations are available in WRITE, XOR, OR and AND versions. + ** Intel CPU specific support is provided for the Turbo C and GNU C + ** compilers. The i386 GCC version supports segment overrides. May + ** work with other compilers and CPU-s, but is not optimized for them. + ** + **/ + +#ifndef __MEMPEEK_H_INCLUDED__ +#define __MEMPEEK_H_INCLUDED__ + +#ifndef __MEMMODE_H_INCLUDED__ +#include "memmode.h" +#endif + +#ifdef __GNUC__ +#include "gcc/mempeek.h" +#elif defined(__TURBOC__) +#include "bcc/mempeek.h" +#elif defined(__WATCOMC__) +#include "watcom/mempeek.h" +#endif + +#ifndef __INLINE_STD_PEEK__ +#define __INLINE_STD_PEEK__(P,S,T) (*(unsigned T *)(P)) +#endif + +#ifndef __INLINE_STD_POKE__ +# ifdef NO_LEFTSIDE_PTR_CAST +# define __INLINE_STD_POKE__(P,V,OP,I,S,T) do { \ + register unsigned T *_ISPptr = (void *)(P); \ + *_ISPptr OP (unsigned T)(V); \ + } while (0) +# else +# define __INLINE_STD_POKE__(P,V,OP,I,S,T) (*(unsigned T *)(P) OP (unsigned T)(V)) +# endif +#endif + +/* the volatile modifier ensures the video ram access is really done */ +#ifndef __INLINE_FAR_PEEK__ +#define __INLINE_FAR_PEEK__(P,S,T) (*(volatile unsigned T *)(P)) +#endif + +#ifndef __INLINE_FAR_POKE__ +# ifdef NO_LEFTSIDE_PTR_CAST +# define __INLINE_FAR_POKE__(P,V,OP,I,S,T) do { \ + register unsigned T *_ISPptr = (void *)(P); \ + *_ISPptr OP (V); \ + } while (0) +# else +# define __INLINE_FAR_POKE__(P,V,OP,I,S,T) (*(volatile unsigned T *)(P) OP (V)) +# endif +#endif + + +/* + * setup_far_selector(segment_selector) + */ +#ifndef setup_far_selector +#define setup_far_selector(S) +#endif + +/* + * peek_... (pointer) + * poke_... (pointer,value) + */ + +/* some processors (eg. DEC alpha) need special handling for word access */ +#ifndef MISALIGNED_16bit_OK +#define peek_w(p) ( ((GR_int16u)(*((GR_int8u *)(p) )) ) \ + | ((GR_int16u)(*((GR_int8u *)(p)+1))<<8) ) +#define __SPLIT_16_POKE__(P,V,OP) ( (*((GR_int8u *)(P) ) OP ((V) )), \ + (*((GR_int8u *)(P)+1) OP ((V)>>8)) ) +#define poke_w(p,v) __SPLIT_16_POKE__(p,v,=) +#define poke_w_xor(p,v) __SPLIT_16_POKE__(p,v,^=) +#define poke_w_or(p,v) __SPLIT_16_POKE__(p,v,|=) +#define poke_w_and(p,v) __SPLIT_16_POKE__(p,v,&=) +#define peek_w_f(p) peek_w(p) +#define poke_w_f(p,v) poke_w((p),(v)) +#define poke_w_f_xor(p,v) poke_w_xor((p),(v)) +#define poke_w_f_or(p,v) poke_w_or((p),(v)) +#define poke_w_f_and(p,v) poke_w_and((p),(v)) +#endif + + +/* ------------------------------------- near memory (RAM) access */ +#ifndef peek_b +#define peek_b(p) __INLINE_STD_PEEK__(p,OP8b,GR_int8) +#endif +#ifndef peek_w +#define peek_w(p) __INLINE_STD_PEEK__(p,OP16b,GR_int16) +#endif +#ifndef peek_l +#define peek_l(p) __INLINE_STD_PEEK__(p,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(peek_h) +#define peek_h(p) __INLINE_STD_PEEK__(p,OP64b,GR_int64) +#endif + +#ifndef poke_b +#define poke_b(p,v) __INLINE_STD_POKE__(p,v,=,MOV_INS,OP8b,GR_int8) +#endif +#ifndef poke_w +#define poke_w(p,v) __INLINE_STD_POKE__(p,v,=,MOV_INS,OP16b,GR_int16) +#endif +#ifndef poke_l +#define poke_l(p,v) __INLINE_STD_POKE__(p,v,=,MOV_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(poke_h) +#define poke_h(p,v) __INLINE_STD_POKE__(p,v,=,MOV_INS,OP64b,GR_int64) +#endif + +#define poke_b_set poke_b +#define poke_w_set poke_w +#define poke_l_set poke_l +#ifdef poke_h +#define poke_h_set poke_h +#endif + +#ifndef poke_b_xor +#define poke_b_xor(p,v) __INLINE_STD_POKE__(p,v,^=,XOR_INS,OP8b,GR_int8) +#endif +#ifndef poke_w_xor +#define poke_w_xor(p,v) __INLINE_STD_POKE__(p,v,^=,XOR_INS,OP16b,GR_int16) +#endif +#ifndef poke_l_xor +#define poke_l_xor(p,v) __INLINE_STD_POKE__(p,v,^=,XOR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(poke_h_xor) +#define poke_h_xor(p,v) __INLINE_STD_POKE__(p,v,^=,XOR_INS,OP64b,GR_int64) +#endif + +#ifndef poke_b_or +#define poke_b_or(p,v) __INLINE_STD_POKE__(p,v,|=,OR_INS,OP8b,GR_int8) +#endif +#ifndef poke_w_or +#define poke_w_or(p,v) __INLINE_STD_POKE__(p,v,|=,OR_INS,OP16b,GR_int16) +#endif +#ifndef poke_l_or +#define poke_l_or(p,v) __INLINE_STD_POKE__(p,v,|=,OR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(poke_h_or) +#define poke_h_or(p,v) __INLINE_STD_POKE__(p,v,|=,OR_INS,OP64b,GR_int64) +#endif + +#ifndef poke_b_and +#define poke_b_and(p,v) __INLINE_STD_POKE__(p,v,&=,AND_INS,OP8b,GR_int8) +#endif +#ifndef poke_w_and +#define poke_w_and(p,v) __INLINE_STD_POKE__(p,v,&=,AND_INS,OP16b,GR_int16) +#endif +#ifndef poke_l_and +#define poke_l_and(p,v) __INLINE_STD_POKE__(p,v,&=,AND_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(poke_h_and) +#define poke_h_and(p,v) __INLINE_STD_POKE__(p,v,&=,AND_INS,OP64b,GR_int64) +#endif + +/* ------------------------------------- far memory (video) access */ +#ifndef peek_b_f +#define peek_b_f(p) __INLINE_FAR_PEEK__(p,OP8b,GR_int8) +#endif +#ifndef peek_w_f +#define peek_w_f(p) __INLINE_FAR_PEEK__(p,OP16b,GR_int16) +#endif +#ifndef peek_l_f +#define peek_l_f(p) __INLINE_FAR_PEEK__(p,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(peek_h_f) +#define peek_h_f(p) __INLINE_FAR_PEEK__(p,OP64b,GR_int64) +#endif + +#ifndef poke_b_f +#define poke_b_f(p,v) __INLINE_FAR_POKE__(p,v,=,MOV_INS,OP8b,GR_int8) +#endif +#ifndef poke_w_f +#define poke_w_f(p,v) __INLINE_FAR_POKE__(p,v,=,MOV_INS,OP16b,GR_int16) +#endif +#ifndef poke_l_f +#define poke_l_f(p,v) __INLINE_FAR_POKE__(p,v,=,MOV_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(poke_h_f) +#define poke_h_f(p,v) __INLINE_FAR_POKE__(p,v,=,MOV_INS,OP64b,GR_int64) +#endif + +#define poke_b_f_set poke_b_f +#define poke_w_f_set poke_w_f +#define poke_l_f_set poke_l_f +#ifdef poke_h_f +#define poke_h_f_set poke_h_f +#endif + +#ifndef poke_b_f_xor +#define poke_b_f_xor(p,v) __INLINE_FAR_POKE__(p,v,^=,XOR_INS,OP8b,GR_int8) +#endif +#ifndef poke_w_f_xor +#define poke_w_f_xor(p,v) __INLINE_FAR_POKE__(p,v,^=,XOR_INS,OP16b,GR_int16) +#endif +#ifndef poke_l_f_xor +#define poke_l_f_xor(p,v) __INLINE_FAR_POKE__(p,v,^=,XOR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(poke_h_f_xor) +#define poke_h_f_xor(p,v) __INLINE_FAR_POKE__(p,v,^=,XOR_INS,OP64b,GR_int64) +#endif + +#ifndef poke_b_f_or +#define poke_b_f_or(p,v) __INLINE_FAR_POKE__(p,v,|=,OR_INS,OP8b,GR_int8) +#endif +#ifndef poke_w_f_or +#define poke_w_f_or(p,v) __INLINE_FAR_POKE__(p,v,|=,OR_INS,OP16b,GR_int16) +#endif +#ifndef poke_l_f_or +#define poke_l_f_or(p,v) __INLINE_FAR_POKE__(p,v,|=,OR_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(poke_h_f_or) +#define poke_h_f_or(p,v) __INLINE_FAR_POKE__(p,v,|=,OR_INS,OP64b,GR_int64) +#endif + +#ifndef poke_b_f_and +#define poke_b_f_and(p,v) __INLINE_FAR_POKE__(p,v,&=,AND_INS,OP8b,GR_int8) +#endif +#ifndef poke_w_f_and +#define poke_w_f_and(p,v) __INLINE_FAR_POKE__(p,v,&=,AND_INS,OP16b,GR_int16) +#endif +#ifndef poke_l_f_and +#define poke_l_f_and(p,v) __INLINE_FAR_POKE__(p,v,&=,AND_INS,OP32b,GR_int32) +#endif +#if defined(GR_int64) && !defined(poke_h_f_and) +#define poke_h_f_and(p,v) __INLINE_FAR_POKE__(p,v,&=,AND_INS,OP64b,GR_int64) +#endif + +/* ------------------------------------------- special 24bpp handling --- */ + +#define __INTERN_24_PEEK__(P,F) \ + ( peek_b##F(P) \ + | ((GR_int16u)peek_b##F(((GR_int8 *)(P))+1)<<8) \ + | ((GR_int32u)peek_b##F(((GR_int8 *)(P))+2)<<16)) + +#define __INTERN_24_POKE__(P,C,F,OP) do { \ + poke_b##F##OP((P),(GR_int8)(C)); \ + poke_b##F##OP(((GR_int8 *)(P))+1,(GR_int8)((C)>>8)); \ + poke_b##F##OP(((GR_int8 *)(P))+2,(GR_int8)((C)>>16)); \ + } while (0) + +#ifndef __INLINE_24_PEEK__ +#define __INLINE_24_PEEK__(p) \ + __INTERN_24_PEEK__(p,_n) +#endif +#ifndef __INLINE_24_FAR_PEEK__ +#define __INLINE_24_FAR_PEEK__(p) \ + __INTERN_24_PEEK__(p,_f) +#endif + +#ifndef __INLINE_24_POKE__ +#define __INLINE_24_POKE__(p,c,op,INS) \ + __INTERN_24_POKE__(p,c,_n,op) +#endif + +#ifndef __INLINE_24_FAR_POKE__ +#define __INLINE_24_FAR_POKE__(p,c,op,INS) \ + __INTERN_24_POKE__(p,c,_f,op) +#endif + +#ifndef peek_24 +#define peek_24(p) __INLINE_24_PEEK__(p) +#endif +#ifndef peek_24_f +#define peek_24_f(p) __INLINE_24_FAR_PEEK__(p) +#endif + +#ifndef poke_24_set +#define poke_24_set(p,c) __INLINE_24_POKE__(p,c,_set,MOV_INS) +#endif +#ifndef poke_24_xor +#define poke_24_xor(p,c) __INLINE_24_POKE__(p,c,_xor,XOR_INS) +#endif +#ifndef poke_24_or +#define poke_24_or(p,c) __INLINE_24_POKE__(p,c,_or,OR_INS) +#endif +#ifndef poke_24_and +#define poke_24_and(p,c) __INLINE_24_POKE__(p,c,_and,AND_INS) +#endif +#define poke_24 poke_24_set + +#ifndef poke_24_f_set +#define poke_24_f_set(p,c) __INLINE_24_FAR_POKE__(p,c,_set,MOV_INS) +#endif +#ifndef poke_24_f_xor +#define poke_24_f_xor(p,c) __INLINE_24_FAR_POKE__(p,c,_xor,XOR_INS) +#endif +#ifndef poke_24_f_or +#define poke_24_f_or(p,c) __INLINE_24_FAR_POKE__(p,c,_or,OR_INS) +#endif +#ifndef poke_24_f_and +#define poke_24_f_and(p,c) __INLINE_24_FAR_POKE__(p,c,_and,AND_INS) +#endif +#define poke_24_f poke_24_f_set + +/* ..._n is used in some makros to keep the preprocessor happy. +** Mapped to standard near memory commands : */ +#define peek_b_n peek_b +#define peek_w_n peek_w +#define peek_l_n peek_l +#define poke_b_n poke_b +#define poke_w_n poke_w +#define poke_l_n poke_l +#define poke_b_n_set poke_b +#define poke_w_n_set poke_w +#define poke_l_n_set poke_l +#define poke_b_n_xor poke_b_xor +#define poke_w_n_xor poke_w_xor +#define poke_l_n_xor poke_l_xor +#define poke_b_n_or poke_b_or +#define poke_w_n_or poke_w_or +#define poke_l_n_or poke_l_or +#define poke_b_n_and poke_b_and +#define poke_w_n_and poke_w_and +#define poke_l_n_and poke_l_and +#ifdef poke_h +#define peek_h_n peek_h +#define poke_h_n poke_h +#define poke_h_n_set poke_h +#define poke_h_n_xor poke_h_xor +#define poke_h_n_or poke_h_or +#define poke_h_n_and poke_h_and +#endif + +#define peek_24_n peek_24 +#define poke_24_n poke_24_set +#define poke_24_n_set poke_24_set +#define poke_24_n_xor poke_24_xor +#define poke_24_n_or poke_24_or +#define poke_24_n_and poke_24_and + +#endif /* whole file */ + diff --git a/thirdparty/grx249/src/include/ordswap.h b/thirdparty/grx249/src/include/ordswap.h new file mode 100644 index 0000000..ad7370c --- /dev/null +++ b/thirdparty/grx249/src/include/ordswap.h @@ -0,0 +1,30 @@ +/** + ** ordswap.h ---- definitions for multibyte value order swaping + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +extern void _GR_swap16(GR_int16 far *w); +extern void _GR_swap32(GR_int32 far *l); + +#define _GR_swap16s(w) _GR_swap16((GR_int16 far *)(w)) +#define _GR_swap16u(w) _GR_swap16((GR_int16 far *)(w)) +#define _GR_swap32s(l) _GR_swap32((GR_int32 far *)(l)) +#define _GR_swap32u(l) _GR_swap32((GR_int32 far *)(l)) + +#ifdef GR_int64 +extern void _GR_swap64(GR_int64 far *h); +#define _GR_swap64s(h) _GR_swap64((GR_int64 far *)(h)) +#define _GR_swap64u(h) _GR_swap64((GR_int64 far *)(h)) +#endif diff --git a/thirdparty/grx249/src/include/pblit.h b/thirdparty/grx249/src/include/pblit.h new file mode 100644 index 0000000..d93b910 --- /dev/null +++ b/thirdparty/grx249/src/include/pblit.h @@ -0,0 +1,78 @@ +/** + ** pblit.h ---- video->video; video->ram; ram->video blit support macros + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#ifndef __PBLIT_H_INCLUDED__ +#define __PBLIT_H_INCLUDED__ + +#ifndef __MEMCOPY_H_INCLUDED__ +#include "memcopy.h" +#endif + +/* +** single element (SIZE=b: 8bit, w:16bit, l:32bit) copy command. +** Source is 'sptr', destination 'dptr'. Read operation memory +** reference F is empty for standard memory access (near pointer) +** and '_f' for far pointer access. OP is the write command +** specifier: use _xor, _and, _or, _set and _image for near +** pointer writes and _f_xor, ... for far pointer destination. +** +** DO1COPY_FW: forward copy, pointers are incremented after +** copy operation +** DO1COPY_RV: reverse copy, pointers are decremented before +** copy operation +*/ +#define DO1COPY_FW(SIZE,OP,F) do { \ + poke_##SIZE##OP((dptr),peek_##SIZE##F(sptr)); \ + (dptr) += CPSIZE_##SIZE; \ + (sptr) += CPSIZE_##SIZE; \ + } while(0) + +#define DO1COPY_RV(SIZE,OP,F) do { \ + poke_##SIZE##OP((dptr),peek_##SIZE##F(sptr)); \ + (dptr) -= CPSIZE_##SIZE; \ + (sptr) -= CPSIZE_##SIZE; \ + } while(0) + + +/* special handling for image blits */ +#define poke_b_image(p,v) do { \ + GR_int8u val = (v); \ + if(val != cval) poke_b(p,val); \ + } while (0) + +#define poke_b_f_image(p,v) do { \ + GR_int8u val = (v); \ + if(val != cval) poke_b_f(p,val); \ + } while (0) + +#define poke_b_n_image poke_b_image + +#define __DOICOPY__(INC,WF,RF) do { \ + poke_b##WF##_image((dptr),peek_b##RF(sptr)); \ + (dptr) INC CPSIZE_b; \ + (sptr) INC CPSIZE_b; \ + } while(0) + +#define __DOICOPY_FW__(WF,RF) __DOICOPY__(+=,WF,RF) +#define __DOICOPY_RV__(WF,RF) __DOICOPY__(-=,WF,RF) +#define DOIMGCOPY(DIR,WF,RF,W) do __DOICOPY_##DIR##__(WF,RF); while(--(W) != 0) + +#endif /* whole file */ diff --git a/thirdparty/grx249/src/include/prex11r6.h b/thirdparty/grx249/src/include/prex11r6.h new file mode 100644 index 0000000..57984a1 --- /dev/null +++ b/thirdparty/grx249/src/include/prex11r6.h @@ -0,0 +1,40 @@ +#if defined(PRE_R6_ICCCM) +/* + Compatability defines for pre X11R6 ICCCM. +*/ +#define XK_KP_Home 0xFF95 +#define XK_KP_Left 0xFF96 +#define XK_KP_Up 0xFF97 +#define XK_KP_Right 0xFF98 +#define XK_KP_Down 0xFF99 +#define XK_KP_Prior 0xFF9A +#define XK_KP_Page_Up 0xFF9A +#define XK_KP_Next 0xFF9B +#define XK_KP_Page_Down 0xFF9B +#define XK_KP_End 0xFF9C +#define XK_KP_Delete 0xFF9F +/* +XK_ISO_Left_Tab +XK_KP_Add +XK_KP_Begin 0xffd8 +XK_KP_Divide +XK_KP_End +XK_KP_Enter +XK_KP_Insert +XK_KP_Multiply +XK_KP_Subtract +*/ + +#endif + +#if defined(PRE_R5_ICCCM) +/* + Compatability defines for pre X11R5 ICCCM. +*/ +#endif + +#if defined(PRE_R4_ICCCM) +/* + Compatability defines for pre X11R4 ICCCM. +*/ +#endif diff --git a/thirdparty/grx249/src/include/shapes.h b/thirdparty/grx249/src/include/shapes.h new file mode 100644 index 0000000..9143bb1 --- /dev/null +++ b/thirdparty/grx249/src/include/shapes.h @@ -0,0 +1,75 @@ +/** + ** shapes.h ---- declarations and global data for generating complex shapes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __SHAPES_H_INCLUDED__ +#define __SHAPES_H_INCLUDED__ + +#define USE_FDR_DRAWPATTERN 1 + +typedef union _GR_fillArg { + GrColor color; + struct _GR_bitmap *bmp; + struct _GR_pixmap *pxp; + GrPattern *p; +} GrFillArg; + +typedef void (*PixelFillFunc)(int x,int y,GrFillArg fval); +typedef void (*LineFillFunc)(int x,int y,int dx,int dy,GrFillArg fval); +typedef void (*ScanFillFunc)(int x,int y,int w,GrFillArg fval); + +typedef struct _GR_filler { + PixelFillFunc pixel; + LineFillFunc line; + ScanFillFunc scan; +} GrFiller; + +extern GrFiller _GrSolidFiller; +extern GrFiller _GrPatternFiller; +/* +extern GrFiller _GrBitmapFiller; +extern GrFiller _GrPixmapFiller; +*/ + +void _GrDrawPolygon(int n,int pt[][2],GrFiller *f,GrFillArg c,int doClose); +void _GrDrawCustomPolygon(int n,int pt[][2],const GrLineOption *lp,GrFiller *f,GrFillArg c,int doClose,int circle); +void _GrScanConvexPoly(int n,int pt[][2],GrFiller *f,GrFillArg c); +void _GrScanPolygon(int n,int pt[][2],GrFiller *f,GrFillArg c); +void _GrScanEllipse(int xc,int yc,int xa,int ya,GrFiller *f,GrFillArg c,int filled); + +/* --- */ +#define _GrDrawPatternedPixel ((PixelFillFunc)_GrPatternFilledPlot) +#define _GrDrawPatternedLine ((LineFillFunc)_GrPatternFilledLine) +void _GrFillPatternedScanLine(int x,int y,int w,GrFillArg arg); + +/* --- */ +void _GrFloodFill(int x,int y,GrColor border,GrFiller *f,GrFillArg fa); + +/* -- */ +void _GrFillPattern(int x,int y,int width,GrPattern *p); +void _GrFillPatternExt(int x,int y,int sx, int sy,int width,GrPattern *p); +void _GrPatternFilledLine(int x1,int y1,int dx,int dy,GrPattern *p); +void _GrPatternFilledPlot(int x,int y,GrPattern *p); + +void _GrFillBitmapPattern(int x,int y,int w,int h, + char far *bmp,int pitch,int start, + GrPattern* p,GrColor bg); +void _GrFillBitmapPatternExt(int x,int y,int w,int h, int sx, int sy, + char far *bmp,int pitch,int start, + GrPattern* p,GrColor bg); + +#endif diff --git a/thirdparty/grx249/src/include/usercord.h b/thirdparty/grx249/src/include/usercord.h new file mode 100644 index 0000000..f45cbc3 --- /dev/null +++ b/thirdparty/grx249/src/include/usercord.h @@ -0,0 +1,35 @@ +/** + ** usercord.h + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "usrscale.h" + +#define U2SX(x,c) \ + SCALE(x,((x) - (c)->gc_usrxbase),(c)->gc_xmax,(c)->gc_usrwidth) +#define U2SY(y,c) \ + SCALE(y,((y) - (c)->gc_usrybase),(c)->gc_ymax,(c)->gc_usrheight) + +#define S2UX(x,c) do { \ + SCALE(x,x,(c)->gc_usrwidth,(c)->gc_xmax); \ + (x) += (c)->gc_usrxbase; \ +} while(0) + +#define S2UY(y,c) do { \ + SCALE(y,y,(c)->gc_usrheight,(c)->gc_ymax); \ + (y) += (c)->gc_usrybase; \ +} while(0) diff --git a/thirdparty/grx249/src/include/usrscale.h b/thirdparty/grx249/src/include/usrscale.h new file mode 100644 index 0000000..6dbaafc --- /dev/null +++ b/thirdparty/grx249/src/include/usrscale.h @@ -0,0 +1,33 @@ +/** + ** usrscale.h + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef _SCALE_H_ +#define _SCALE_H_ + +#include "arith.h" + +#define SCALE(var,arg,nom,den) do { \ + (var) = iscale((arg),(nom),(den)); \ +} while(0) + +# define USCALE(var,arg,nom,den) do { \ + (var) = uscale((arg),(nom),(den)); \ +} while(0) + +#endif /* whole file */ diff --git a/thirdparty/grx249/src/include/vesa.h b/thirdparty/grx249/src/include/vesa.h new file mode 100644 index 0000000..2879042 --- /dev/null +++ b/thirdparty/grx249/src/include/vesa.h @@ -0,0 +1,185 @@ +/** + ** vesa.h ---- VESA BIOS extensions function codes, structures and return codes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#ifndef _VESA_H_included +#define _VESA_H_included + +#define VESA_FUNC 0x4f00 +#define VESA_SUCCESS 0x004f + +#define VESA_VERSION(major,minor) ((((major) & 0xff) << 8) | ((minor) & 0xff)) +#define VESA_VERSION_MAJOR(vers) (((vers) >> 8) & 0xff) +#define VESA_VERSION_MINOR(vers) ((vers) & 0xff) + +/* + * VESA BIOS sub-function numbers + */ +#define VESA_VGA_INFO 0 /* get VGA adapter info */ +#define VESA_MODE_INFO 1 /* get SVGA mode info */ +#define VESA_SET_MODE 2 /* set video mode */ +#define VESA_GET_MODE 3 /* get current video mode */ +#define VESA_VGA_STATE 4 /* save/restore VGA state */ +#define VESA_PAGE_CTL 5 /* memory control */ +/* VESA 1.1 +++ */ +#define VESA_SCAN_LNLEN 6 /* set/get scan line length */ +#define VESA_DISP_START 7 /* set/get display start address */ +/* VESA 1.2 +++ */ +#define VESA_PAL_CNTRL 8 /* DAC palette control */ +/* VESA 2.0 +++ */ +#define VESA_PAL_GETSET 9 /* get/set DAC palette entries */ +#define VESA_PM_INTERF 10 /* VBE protected mode interface */ + +#ifdef __GNUC__ +#define PACK __attribute__((packed)) +#else +#define PACK +#endif + +#ifdef __WATCOMC__ /* GS - WATCOM C++ 11.0 */ +#pragma pack ( 0 ); +#define PACKTYPEMOD _Packed +#else +#define PACKTYPEMOD +#endif + +/* + * The VGA info structure (without padding) + */ +typedef PACKTYPEMOD struct { + char VESAsignature[4] PACK; /* should be "VESA" */ + short VESAversion PACK; /* VESA version number */ + char far *OEMstringPtr PACK; /* Pointer to OEM string */ + long Capabilities PACK; /* capabilities of the video env */ + short far *VideoModePtr PACK; /* ptr to supported Super VGA modes */ + /* ==== VESA 1.2 and later ==== */ + short MemorySize PACK; /* # of 64K pages */ + /* ==== VESA 2.0 and later ==== */ + short OEMversion PACK; /* OEM software revision number */ + char far *VendorNamePtr PACK; /* Pointer to vendor name */ + char far *ProductNamePtr PACK; /* Pointer to product name */ + char far *RevisionStrPtr PACK; /* Pointer to product revision string */ +} VESAvgaInfoBlock; + +/* + * Capabilities flags + */ +#define CAP_DAC_WIDTH 1 /* set if DAC width can be changed */ +/* ==== VESA 2.0 and later ==== */ +#define CAP_NON_VGA 2 /* set if non VGA controller */ +#define CAP_DAC_BLANK 4 /* set if programmed DAC with blank bit */ + +/* + * The mode information structure (without padding) + */ +typedef PACKTYPEMOD struct { + short ModeAttributes PACK; /* mode attributes */ + char WinAAttributes PACK; /* Window A attributes */ + char WinBAttributes PACK; /* Window B attributes */ + short WinGranularity PACK; /* window granularity */ + short WinSize PACK; /* window size */ + short WinASegment PACK; /* Window A start segment */ + short WinBSegment PACK; /* Window B start segment */ + void far (*WinFuncPtr)() PACK; /* pointer to window function */ + short BytesPerScanLine PACK; /* bytes per scan line */ + /* ==== extended and optional information ==== */ + short XResolution PACK; /* horizontal resolution */ + short YResolution PACK; /* vertical resolution */ + char XCharSize PACK; /* character cell width */ + char YCharSize PACK; /* character cell height */ + char NumberOfPlanes PACK; /* number of memory planes */ + char BitsPerPixel PACK; /* bits per pixel */ + char NumberOfBanks PACK; /* number of banks */ + char MemoryModel PACK; /* memory model type */ + char BankSize PACK; /* bank size in K */ + char NumImagePages PACK; /* number of image pages */ + char reserved[1] PACK; + /* ==== VESA 1.2 and later ==== */ + char RedMaskSize PACK; /* number of bits in red mask */ + char RedMaskPos PACK; /* starting bit for red mask */ + char GreenMaskSize PACK; + char GreenMaskPos PACK; + char BlueMaskSize PACK; + char BlueMaskPos PACK; + char ReservedMaskSize PACK; /* reserved bits in pixel */ + char ReservedMaskPos PACK; + char DirectScreenMode PACK; + /* ==== VESA 2.0 and later ==== */ + unsigned long LinearFrameBuffer PACK; /* physical address of linear frame buf */ + unsigned long StartOffScreenMem PACK; /* physical addr.: start of off screen mem */ + short OffScreenMemSize PACK; /* off screen mem size in kb */ +} VESAmodeInfoBlock; + +/* + * The protected mode info structure (VBE2+) + */ +typedef PACKTYPEMOD struct { + unsigned short RealMode_SEG PACK; /* RealMode physical base addr */ + unsigned short RealMode_OFF PACK; /* of the following data table */ + unsigned short PhysicalLength PACK; /* length of original table */ + /* Original table starts here */ + unsigned short SetWindow_off PACK; /* ofs to PM Set Windows func */ + unsigned short DisplStart_off PACK; /* ofs to PM Set Display Start func */ + unsigned short PPalette_off PACK; /* ofs to PM Set Primary Palette func */ + unsigned short SubTable_off PACK; /* ofs to PM resource sub table */ +} VESApmInfoBlock; +#define VESApmInfoBlock_BASEOFF (3*sizeof(unsigned short)) + +#undef PACK +#undef PACKTYPEMOD + +/* + * MODE attribute bits + */ +#define MODE_SUPPORTED 1 /* Mode supported in hardware */ +#define MODE_EXTINFO 2 /* Extended information available */ +#define MODE_SUPBIOS 4 /* Text output supported by BIOS */ +#define MODE_ISCOLOR 8 /* Monochrome/color mode */ +#define MODE_ISGRAPHICS 16 /* Mode type (0: text, 1:graphics) */ +/* ==== VESA 2.0 and later ==== */ +#define MODE_NON_VGA 32 /* set if not a VGA mode */ +#define MODE_NO_BANKING 64 /* set if non banking mode */ +#define MODE_LIN_FRAME 128 /* set if linear frame buffer available */ + +/* + * Window attribute bits + */ +#define WIN_SUPPORTED 1 /* Window supported */ +#define WIN_READABLE 2 /* Window readable */ +#define WIN_WRITABLE 4 /* Window writable */ + +/* + * MemoryModel values + */ +#define MODEL_TEXT 0 /* 00h = Text mode */ +#define MODEL_CGA 1 /* 01h = CGA graphics */ +#define MODEL_HERC 2 /* 02h = Hercules graphics */ +#define MODEL_4PLANE 3 /* 03h = 4-plane planar */ +#define MODEL_PACKED 4 /* 04h = Packed pixel */ +#define MODEL_256_NC 5 /* 05h = Non-chain 4, 256 color */ +#define MODEL_DIRECT 6 /* 06h = direct color mode */ +/* 07h-0Fh = Reserved, to be defined by VESA */ +/* 10h-FFh = To be defined by OEM */ + +int _GrViDrvVESAgetVGAinfo(VESAvgaInfoBlock *ib); +int _GrViDrvVESAgetModeInfo(int mode,VESAmodeInfoBlock *ib); +VESApmInfoBlock * _GrViDrvVESAgetPMinfo(void); + +#endif diff --git a/thirdparty/grx249/src/include/vgaregs.h b/thirdparty/grx249/src/include/vgaregs.h new file mode 100644 index 0000000..0219088 --- /dev/null +++ b/thirdparty/grx249/src/include/vgaregs.h @@ -0,0 +1,50 @@ +/** + ** vgaregs.h ---- EGA/VGA register declarations + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* + * color plane operations + */ +#define VGA_FUNC_SET 0 +#define VGA_FUNC_AND 8 +#define VGA_FUNC_OR 16 +#define VGA_FUNC_XOR 24 + +/* + * Sequencer port and frequently used register indices + */ +#define VGA_SEQUENCER_PORT 0x3c4 +#define VGA_SEQUENCER_DATA 0x3c5 + +#define VGA_WRT_PLANE_ENB_REG 2 + +/* + * Graphics controller port and frequently used registers + */ +#define VGA_GR_CTRL_PORT 0x3ce +#define VGA_GR_CTRL_DATA 0x3cf + +#define VGA_SET_RESET_REG 0 +#define VGA_SET_RESET_ENB_REG 1 +#define VGA_COLOR_COMP_REG 2 +#define VGA_ROT_FN_SEL_REG 3 +#define VGA_RD_PLANE_SEL_REG 4 +#define VGA_MODE_REG 5 +#define VGA_MISC_REG 6 +#define VGA_COLOR_DONTC_REG 7 +#define VGA_BIT_MASK_REG 8 + diff --git a/thirdparty/grx249/src/include/watcom/memcopy.h b/thirdparty/grx249/src/include/watcom/memcopy.h new file mode 100644 index 0000000..f938c00 --- /dev/null +++ b/thirdparty/grx249/src/include/watcom/memcopy.h @@ -0,0 +1,5 @@ +/** + ** memcopy.h ---- inline assembly memory copy macros -- WATCOM-C++ code + **/ + +/* this is a good candidate for optimized assembler code */ diff --git a/thirdparty/grx249/src/include/watcom/memfill.h b/thirdparty/grx249/src/include/watcom/memfill.h new file mode 100644 index 0000000..dab777c --- /dev/null +++ b/thirdparty/grx249/src/include/watcom/memfill.h @@ -0,0 +1,321 @@ +/** + ** memfill.h ---- inline assembly memory fill macros + ** Watcom special version + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#if defined(USE_WATCOM386_ASM) && defined(__386__) + +/* ------------------------------------------------------------------------ */ + +extern void *_GR_rowfill_b_set(void *P, GR_int8u V, unsigned C); +extern void *_GR_rowfill_w_set(void *P, GR_int16u V, unsigned C); +extern void *_GR_rowfill_l_set(void *P, GR_int32u V, unsigned C); + +#pragma aux _GR_rowfill_b_set = \ + "cld" \ + "rep stosb" \ + parm [edi]/*=P*/ [al]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +#pragma aux _GR_rowfill_w_set = \ + "cld" \ + "rep stosw" \ + parm [edi]/*=P*/ [ax]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +#pragma aux _GR_rowfill_l_set = \ + "cld" \ + "rep stosd" \ + parm [edi]/*=P*/ [eax]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +/* ------------------------------------------------------------------------ */ + +extern void *_GR_colfill_b_set(void *P, unsigned SKIP, GR_int8u V, unsigned C); +extern void *_GR_colfill_w_set(void *P, unsigned SKIP, GR_int16u V, unsigned C); +extern void *_GR_colfill_l_set(void *P, unsigned SKIP, GR_int32u V, unsigned C); + +#pragma aux _GR_colfill_b_set = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: mov byte ptr [edi],al" \ + "add edi,ebx" \ + "odd: mov byte ptr [edi],al" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [al]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +#pragma aux _GR_colfill_w_set = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: mov word ptr [edi],ax" \ + "add edi,ebx" \ + "odd: mov word ptr [edi],ax" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [ax]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +#pragma aux _GR_colfill_l_set = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: mov dword ptr [edi],eax" \ + "add edi,ebx" \ + "odd: mov dword ptr [edi],eax" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [eax]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +/* ------------------------------------------------------------------------ */ + +extern void *_GR_colfill_b_xor(void *P, unsigned SKIP, GR_int8u V, unsigned C); +extern void *_GR_colfill_w_xor(void *P, unsigned SKIP, GR_int16u V, unsigned C); +extern void *_GR_colfill_l_xor(void *P, unsigned SKIP, GR_int32u V, unsigned C); + +#pragma aux _GR_colfill_b_xor = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: xor byte ptr [edi],al" \ + "add edi,ebx" \ + "odd: xor byte ptr [edi],al" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [al]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +#pragma aux _GR_colfill_w_xor = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: xor word ptr [edi],ax" \ + "add edi,ebx" \ + "odd: xor word ptr [edi],ax" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [ax]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +#pragma aux _GR_colfill_l_xor = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: xor dword ptr [edi],eax" \ + "add edi,ebx" \ + "odd: xor dword ptr [edi],eax" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [eax]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +/* ------------------------------------------------------------------------ */ + +extern void *_GR_colfill_b_or(void *P, unsigned SKIP, GR_int8u V, unsigned C); +extern void *_GR_colfill_w_or(void *P, unsigned SKIP, GR_int16u V, unsigned C); +extern void *_GR_colfill_l_or(void *P, unsigned SKIP, GR_int32u V, unsigned C); + +#pragma aux _GR_colfill_b_or = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: or byte ptr [edi],al" \ + "add edi,ebx" \ + "odd: or byte ptr [edi],al" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [al]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +#pragma aux _GR_colfill_w_or = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: or word ptr [edi],ax" \ + "add edi,ebx" \ + "odd: or word ptr [edi],ax" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [ax]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +#pragma aux _GR_colfill_l_or = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: or dword ptr [edi],eax" \ + "add edi,ebx" \ + "odd: or dword ptr [edi],eax" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [eax]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +/* ------------------------------------------------------------------------ */ + +extern void *_GR_colfill_b_and(void *P, unsigned SKIP, GR_int8u V, unsigned C); +extern void *_GR_colfill_w_and(void *P, unsigned SKIP, GR_int16u V, unsigned C); +extern void *_GR_colfill_l_and(void *P, unsigned SKIP, GR_int32u V, unsigned C); + +#pragma aux _GR_colfill_b_and = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: and byte ptr [edi],al" \ + "add edi,ebx" \ + "odd: and byte ptr [edi],al" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [al]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +#pragma aux _GR_colfill_w_and = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: and word ptr [edi],ax" \ + "add edi,ebx" \ + "odd: and word ptr [edi],ax" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [ax]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +#pragma aux _GR_colfill_l_and = \ + "inc ecx" \ + "shr ecx,1" \ + "jnc short odd" \ + "jmp short lop1" \ + /* align to 16byte boundary here */ \ + "lop1: and dword ptr [edi],eax" \ + "add edi,ebx" \ + "odd: and dword ptr [edi],eax" \ + "add edi,ebx" \ + "dec ecx" \ + "jnz short lop1" \ + parm [edi]/*=P*/ [ebx]/*=SKIP*/ [eax]/*=V*/ [ecx]/*=C*/ \ + value [edi]; + +/* ------------------------------------------------------------------------ */ + +#define colfill_b(P,S,V,C) do (P)=_GR_colfill_b_set(P,S,V,C); while (0) +#define colfill_w(P,S,V,C) do (P)=_GR_colfill_w_set(P,S,V,C); while (0) +#define colfill_l(P,S,V,C) do (P)=_GR_colfill_l_set(P,S,V,C); while (0) + +#define colfill_b_xor(P,S,V,C) do (P)=_GR_colfill_b_xor(P,S,V,C); while (0) +#define colfill_w_xor(P,S,V,C) do (P)=_GR_colfill_w_xor(P,S,V,C); while (0) +#define colfill_l_xor(P,S,V,C) do (P)=_GR_colfill_l_xor(P,S,V,C); while (0) + +#define colfill_b_or(P,S,V,C) do (P)=_GR_colfill_b_or(P,S,V,C); while (0) +#define colfill_w_or(P,S,V,C) do (P)=_GR_colfill_w_or(P,S,V,C); while (0) +#define colfill_l_or(P,S,V,C) do (P)=_GR_colfill_l_or(P,S,V,C); while (0) + +#define colfill_b_and(P,S,V,C) do (P)=_GR_colfill_b_and(P,S,V,C); while (0) +#define colfill_w_and(P,S,V,C) do (P)=_GR_colfill_w_and(P,S,V,C); while (0) +#define colfill_l_and(P,S,V,C) do (P)=_GR_colfill_l_and(P,S,V,C); while (0) + +/* ------------------------------------------------------------------------ */ + +#define rowfill_b(P,V,C) do (P)=_GR_rowfill_b_set(P,V,C); while (0) +#define rowfill_w(P,V,C) do (P)=_GR_rowfill_w_set(P,V,C); while (0) +#define rowfill_l(P,V,C) do (P)=_GR_rowfill_l_set(P,V,C); while (0) + +#define rowfill_b_xor(P,V,C) colfill_b_xor(P,1,V,C) +#define rowfill_w_xor(P,V,C) colfill_w_xor(P,2,V,C) +#define rowfill_l_xor(P,V,C) colfill_l_xor(P,4,V,C) + +#define rowfill_b_or(P,V,C) colfill_b_or(P,1,V,C) +#define rowfill_w_or(P,V,C) colfill_w_or(P,2,V,C) +#define rowfill_l_or(P,V,C) colfill_l_or(P,4,V,C) + +#define rowfill_b_and(P,V,C) colfill_b_and(P,1,V,C) +#define rowfill_w_and(P,V,C) colfill_w_and(P,2,V,C) +#define rowfill_l_and(P,V,C) colfill_l_and(P,4,V,C) + +/* ------------------------------------------------------------------------ */ + +#define colfill_b_f colfill_b +#define colfill_w_f colfill_w +#define colfill_l_f colfill_l + +#define colfill_b_f_xor colfill_b_xor +#define colfill_w_f_xor colfill_w_xor +#define colfill_l_f_xor colfill_l_xor + +#define colfill_b_f_or colfill_b_or +#define colfill_w_f_or colfill_w_or +#define colfill_l_f_or colfill_l_or + +#define colfill_b_f_and colfill_b_and +#define colfill_w_f_and colfill_w_and +#define colfill_l_f_and colfill_l_and + +/* ------------------------------------------------------------------------ */ + +#define rowfill_b_f rowfill_b +#define rowfill_w_f rowfill_w +#define rowfill_l_f rowfill_l + +#define rowfill_b_f_xor rowfill_b_xor +#define rowfill_w_f_xor rowfill_w_xor +#define rowfill_l_f_xor rowfill_l_xor + +#define rowfill_b_f_or rowfill_b_or +#define rowfill_w_f_or rowfill_w_or +#define rowfill_l_f_or rowfill_l_or + +#define rowfill_b_f_and rowfill_b_and +#define rowfill_w_f_and rowfill_w_and +#define rowfill_l_f_and rowfill_l_and + +#endif /* USE_WATCOM386_ASM && __386__ */ diff --git a/thirdparty/grx249/src/include/watcom/memmode.h b/thirdparty/grx249/src/include/watcom/memmode.h new file mode 100644 index 0000000..be089b3 --- /dev/null +++ b/thirdparty/grx249/src/include/watcom/memmode.h @@ -0,0 +1,81 @@ +/** + ** memmode.h ---- determine how to access video and system RAM + ** Watcom-C++ code + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "int86.h" +#undef MK_FP + +#ifdef __386__ +/* WATCOM DOS4GW protected mode */ +#define MK_FP(s,o) (void *)( \ + ( ( ( (long)(unsigned short)(s) ) << 4 ) + \ + (unsigned short)(o)) \ +) +#define MK_DOS_ADDR(s,o) (void *)((s):>(o)) +#else +#define MK_FP(s,o) (void far *)( \ + ( ( ( (long)(unsigned short)(s) ) << 4 ) + \ + (unsigned short)(o)) \ +) +#define MK_DOS_ADDR(s,o) (void far *)((s):>(o)) + +#endif /* __386__ */ + +#define LINP_PTR(p) (p) +#define LINP_SEL(p) 0 +#define FP86_SEG(p) ((unsigned short)((unsigned long)(p)>>16)) +#define FP86_OFF(p) ((unsigned short)((int)(p))) + +/* +The DECLARE_XFER_BUFFER macro allocates a DOS memory block. +Used by the int10x macro. +*/ +#ifdef __386__ +/* WATCOM DOS4GW protected mode */ +#pragma off (unreferenced); +static short int10_segment = 0; /*this is not nice! - hack to load real segment for int10*/ +/* allocate a real mode segment so we can return info from VESA int10 */ +#define DECLARE_XFER_BUFFER(size) \ + void _far * xfer_ptr; \ + Int86Regs BuffRegs; \ + do { \ + sttzero((&BuffRegs)); \ + IREG_AX(BuffRegs) = 0x100; \ + IREG_BX(BuffRegs) = 64; \ + int386 ( 0x31, &(BuffRegs.Normal), &(BuffRegs.Normal) ); \ + int10_segment = IREG_AX(BuffRegs); \ + xfer_ptr = IREG_DX(BuffRegs) :> (void near *)0; \ + _fmemset ( xfer_ptr, 0xaa, 256 ); \ + } while (0) +/* access the real mode segment */ +#define XFER_BUFFER xfer_ptr +/* clean up the DOS memory allocated by DOS4GW DPMI macro above */ +#define DELETE_XFER_BUFFER \ + do { \ + sttzero((&BuffRegs)); \ + IREG_AX(BuffRegs) = 0x101; \ + IREG_DX(BuffRegs) = FP_SEG(xfer_ptr); \ + int386x(0x31,&(BuffRegs.Normal),&(BuffRegs.Normal),&(BuffRegs.Extended) ); \ + } while (0) +#else /* __386__ */ +/* WATCOM 16 Bit DOS - hey we're in real mode! */ +#define DECLARE_XFER_BUFFER(size) char XFER_BUFFER[size] +#define DELETE_XFER_BUFFER +#endif /* !__386__ */ + diff --git a/thirdparty/grx249/src/include/watcom/mempeek.h b/thirdparty/grx249/src/include/watcom/mempeek.h new file mode 100644 index 0000000..66b374f --- /dev/null +++ b/thirdparty/grx249/src/include/watcom/mempeek.h @@ -0,0 +1,28 @@ +/** + ** mempeek.h ---- (far) memory read/write operations + ** Watcom-C++ code + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Basic memory peek and poke operations in byte, word and long sizes. + ** The poke operations are available in WRITE, XOR, OR and AND versions. + ** + **/ + +/* candidate for speed ups */ +#define __INLINE_STD_PEEK__(P,S,T) (*((unsigned T *)(P))) +#define __INLINE_STD_POKE__(P,V,OP,I,S,T) ((*((unsigned T *)(P))) OP (V)) + +#define __INLINE_FAR_PEEK__(P,S,T) (*((volatile unsigned T *)(P))) +#define __INLINE_FAR_POKE__(P,V,OP,I,S,T) ((*((volatile unsigned T *)(P))) OP (V)) diff --git a/thirdparty/grx249/src/makefile.bcc b/thirdparty/grx249/src/makefile.bcc new file mode 100644 index 0000000..541c496 --- /dev/null +++ b/thirdparty/grx249/src/makefile.bcc @@ -0,0 +1,205 @@ +# +# GRX 2.0 Library Makefile for Turbo C. +# Uses Turbo C Make (v3.7 worked for me) +# Make sure your shell is command.com ! +# +.AUTODEPEND + +!include "../makedefs.bcc" + +# The library may get too complex ... +#LIBPAGE=/P32 + +# -w-sig : Don't warn "conversion may lose significant digits" +# -DGRX_USE_RAM3x8 : Use planed ram driver for TrueColor modes (24/32bpp) +ADDOPT = -w-sig -DGRX_USE_RAM3x8 + +!ifdef DEBUG +ADDOPT = -DDEBUG=$(DEBUG) $(ADDOPT) +!endif + +# SMALL_STACK: Turbo-C / Borland-C++ have only a small stack. +# It's usually better to get memory from heap +# instead of alloca()-ing it from stack. +ADDOPT = -DSMALL_STACK $(ADDOPT) + +GRX20ST = ..\lib\$(GRX_LIB_SUBDIR)\grx20$(MODEL).lib +# Borland make fails on long lines, build lib in stages +GRX20STa= ..\lib\$(GRX_LIB_SUBDIR)\temp1.lib +GRX20STb= ..\lib\$(GRX_LIB_SUBDIR)\temp2.lib +GRX20STc= ..\lib\$(GRX_LIB_SUBDIR)\temp3.lib +GRX20STd= ..\lib\$(GRX_LIB_SUBDIR)\temp4.lib +GRX20STe= ..\lib\$(GRX_LIB_SUBDIR)\temp5.lib +TEMP_LIB= ..\lib\$(GRX_LIB_SUBDIR)\temp?.lib + +INCDIR= -I. -I./include -I../include -I$(BCCROOT)/include\ + -I./vdrivers -I./bgi +LIBDIR= -L$(BCCROOT)/lib + +OP=+ +OX=.obj + +!include "./stdobjs.mak" + +!ifdef DEBUG +DBG_O = +utils\dbgprint.obj +!else +DBG_O = +!endif + +BCCOBJ= +fdrivers\egavga1.obj \ + +fdrivers\ega4.obj \ + +fdrivers\herc1.obj \ + +fdrivers\ram3x8.obj \ + +fdrivers\svga16.obj \ + +fdrivers\svga24.obj \ + +fdrivers\svga32h.obj \ + +fdrivers\svga32l.obj \ + +fdrivers\svga4.obj \ + +fdrivers\svga8.obj \ + +fdrivers\vga8x.obj \ + +mouse\dosinput.obj \ + +mouse\doskeys.obj \ + +misc\dosmisc.obj \ + +utils\bccarith.obj \ + +utils\bcccopy.obj \ + +utils\bccfil08.obj \ + +utils\bccfil16.obj \ + +utils\bccfil24.obj \ + +utils\bccfil32.obj \ + +vdrivers\ati28800.obj \ + +vdrivers\cl5426.obj \ + +vdrivers\et4000.obj \ + +vdrivers\herc.obj \ + +vdrivers\mach64.obj \ + +vdrivers\s3.obj \ + +vdrivers\stdega.obj \ + +vdrivers\stdvga.obj \ + +vdrivers\u_egavga.obj \ + +vdrivers\u_vesa.obj \ + +vdrivers\u_vsvirt.obj \ + +vdrivers\vesa.obj + + +# Borland make and librarian don't like very long lines ... +LOBJ1=$(STD_1:/=\) $(STD_2:/=\) $(STD_3:/=\) $(STD_4:/=\) +LOBJ2=$(STD_5:/=\) $(STD_6:/=\) $(STD_7:/=\) $(STD_8:/=\) +LOBJ3=$(STD_9:/=\) $(STD_10:/=\) +LOBJ4=$(BGI_1:/=\) $(BGI_2:/=\) $(BGI_3:/=\) +LOBJ5=$(BGI_4:/=\) $(BGI_5:/=\) $(BGI_6:/=\) +LOBJ6=$(STD_11:/=\) $(BCCOBJ) $(DBG_O) + +UTILP = \ + ..\bin\vesaif16.exe \ + ..\bin\fnt2c16.exe \ + ..\bin\modtst16.exe \ + ..\bin\bin2c16.exe + +all: config.bcc $(GRX20ST) $(UTILP) + +clean: + if exist bgi\*.obj del bgi\*.obj + if exist draw\*.obj del draw\*.obj + if exist fdrivers\*.obj del fdrivers\*.obj + if exist fonts\*.obj del fonts\*.obj + if exist gformats\*.obj del gformats\*.obj + if exist image\*.obj del image\*.obj + if exist misc\*.obj del misc\*.obj + if exist mouse\*.obj del mouse\*.obj + if exist pattern\*.obj del pattern\*.obj + if exist setup\*.obj del setup\*.obj + if exist shape\*.obj del shape\*.obj + if exist text\*.obj del text\*.obj + if exist user\*.obj del user\*.obj + if exist utils\*.obj del utils\*.obj + if exist vdrivers\*.obj del vdrivers\*.obj + if exist wideline\*.obj del wideline\*.obj + if exist ..\addons\*.obj del ..\addons\*.obj + if exist ..\addons\print\*.obj del ..\addons\print\*.obj + if exist ..\addons\bmp\*.obj del ..\addons\bmp\*.obj + if exist config.bcc del config.bcc + if exist *.asm del *.asm + if exist *.obj del *.obj + if exist $(TEMP_LIB) del $(TEMP_LIB) + +cleanall: clean + if exist $(GRX20ST) del $(GRX20ST) + if exist ..\bin\*.exe del ..\bin\*.exe + +# the & tells TLIB to continue on next line +$(GRX20ST): $(GRX20STa) $(GRX20STb) $(GRX20STc) $(GRX20STd) $(GRX20STe) $(LOBJ6:+=) + if exist $(GRX20ST) del $(GRX20ST) + $(TLIB) $(LIBPAGE) /C $(GRX20ST) @&&! + +$(GRX20STa) & + +$(GRX20STb) & + +$(GRX20STc) & + +$(GRX20STd) & + +$(GRX20STe) & + $(LOBJ6) +! + +$(GRX20STa): $(LOBJ1:+=) + if exist $(GRX20STa) del $(GRX20STa) + $(TLIB) $(LIBPAGE) /C $(GRX20STa) @&&! + $(LOBJ1) +! + +$(GRX20STb): $(LOBJ2:+=) + if exist $(GRX20STb) del $(GRX20STb) + $(TLIB) $(LIBPAGE) /C $(GRX20STb) @&&! + $(LOBJ2) +! + +$(GRX20STc): $(LOBJ3:+=) + if exist $(GRX20STc) del $(GRX20STc) + $(TLIB) $(LIBPAGE) /C $(GRX20STc) @&&! + $(LOBJ3) +! + +$(GRX20STd): $(LOBJ4:+=) + if exist $(GRX20STd) del $(GRX20STd) + $(TLIB) $(LIBPAGE) /C $(GRX20STd) @&&! + $(LOBJ4) +! + +$(GRX20STe): $(LOBJ5:+=) + if exist $(GRX20STe) del $(GRX20STe) + $(TLIB) $(LIBPAGE) /C $(GRX20STe) @&&! + $(LOBJ5) +! + +..\bin\vesaif16.exe: utilprog\vesainfo.c $(GRX20ST) config.bcc + $(BCC) +config.bcc -e..\bin\vesaif16 @&&! + utilprog\vesainfo.c $(GRX20ST) +! + +..\bin\fnt2c16.exe: utilprog\fnt2c.c $(GRX20ST) config.bcc + $(BCC) +config.bcc -e..\bin\fnt2c16 @&&! + utilprog\fnt2c.c $(GRX20ST) +! + +..\bin\modtst16.exe: utilprog\modetest.c $(GRX20ST) config.bcc + $(BCC) +config.bcc -I..\test -e..\bin\modtst16 @&&! + utilprog\modetest.c $(GRX20ST) +! + +..\bin\bin2c16.exe: utilprog\bin2c.c $(GRX20ST) config.bcc + $(BCC) +config.bcc -e..\bin\bin2c16 @&&! + utilprog\bin2c.c $(GRX20ST) +! + +.c.obj: + $(BCC) +config.bcc -c -o$*.obj $*.c + +.c.asm: + $(BCC) +config.bcc -S -o$*.asm $*.c + + +config.bcc: makefile.bcc ../makedefs.bcc + copy &&! + $(CCOPT) $(ADDOPT) + $(INCDIR) + $(LIBDIR) +! config.bcc + +#!include "depend.bcc" diff --git a/thirdparty/grx249/src/makefile.dj2 b/thirdparty/grx249/src/makefile.dj2 new file mode 100644 index 0000000..e56ef19 --- /dev/null +++ b/thirdparty/grx249/src/makefile.dj2 @@ -0,0 +1,343 @@ +# +# GRX Library Makefile for DJGPP v2. Needs GNU Make. +# Make sure your shell is command.com ! +# +.PHONY : clean cleanall install uninstall \ + install-bin uninstall-bin install-fonts uninstall-fonts \ + install-info uninstall-info + +GRXVDJ2=y + +include ../makedefs.grx + +INCDIR= -I. -I./include -I../include + +ifdef GRX_DEFAULT_FONT_PATH +CCOPT += -DGRX_DEFAULT_FONT_PATH=\"$(GRX_DEFAULT_FONT_PATH)\" +endif + +TAG = $(DOS_DJGPP_V2) + +GRX20ln = libgrx20.a +GRX20ST = ../lib/$(GRX_LIB_SUBDIR)/$(GRX20ln) +ifeq ($(HAVE_UNIX_TOOLS),n) +GRX20STdos = $(subst /,\,$(GRX20ST)) +DESTDIRdos = $(subst /,\,$(DESTDIR)) +libdirdos = $(subst /,\,$(libdir)) +includedirdos = $(subst /,\,$(includedir)) +unitsdirdos = $(subst /,\,$(unitsdir)) +infodirdos = $(subst /,\,$(infodir)) +endif + +OX=.o +OP= + +include ./stdobjs.mak + +# Keep things a little smaller when building the lib ... +STD_Oa= $(STD_1) $(STD_2) $(STD_3) $(STD_4) $(STD_5) $(STD_6) +STD_Ob= $(STD_7) $(STD_8) $(STD_9) $(STD_10) $(STD_11) $(STD_12) +BGI_Oa= $(BGI_1) $(BGI_2) $(BGI_3) +BGI_Ob= $(BGI_4) $(BGI_5) $(BGI_6) + +ADDON_O= +ifdef DEBUG + ADDON_O += $(DBG_1) +endif + +ifeq ($(HAVE_LIBTIFF),y) + ADDON_O += $(TIF_1) +endif + +ifeq ($(HAVE_LIBJPEG),y) + ADDON_O += $(JPG_1) +else + ADDON_O += $(NOJPG_1) +endif + +ifeq ($(HAVE_LIBPNG),y) + ADDON_O += $(PNG_1) +else + ADDON_O += $(NOPNG_1) +endif + +ifeq ($(INCLUDE_PRINTING_CODE),y) + ADDON_O += $(PRN_1) + INCDIR += -I../addons/print +ifeq ($(INCLUDE_BGI_SUPPORT),y) + BGI_Ob += $(PRNBGI_1) +endif +endif + +ifeq ($(INCLUDE_BMP_CODE),y) + ADDON_O += $(BMP_1) + INCDIR += -I../addons/bmp +endif + +DJ_O= $(ADDON_O) \ + fdrivers/egavga1.o \ + fdrivers/ega4.o \ + fdrivers/herc1.o \ + fdrivers/lfb16.o \ + fdrivers/lfb24.o \ + fdrivers/lfb32h.o \ + fdrivers/lfb32l.o \ + fdrivers/lfb8.o \ + fdrivers/lfbbltrv.o \ + fdrivers/lfbbltvr.o \ + fdrivers/lfbbltvv.o \ + fdrivers/ram24.o \ + fdrivers/ram32l.o \ + fdrivers/ram32h.o \ + fdrivers/svga16.o \ + fdrivers/svga24.o \ + fdrivers/svga32h.o \ + fdrivers/svga32l.o \ + fdrivers/svga4.o \ + fdrivers/svga8.o \ + fdrivers/vga8x.o \ + mouse/dosinput.o \ + mouse/doskeys.o \ + misc/dosmisc.o \ + vdrivers/ati28800.o \ + vdrivers/cl5426.o \ + vdrivers/et4000.o \ + vdrivers/herc.o \ + vdrivers/mach64.o \ + vdrivers/s3.o \ + vdrivers/stdega.o \ + vdrivers/stdvga.o \ + vdrivers/u_egavga.o \ + vdrivers/u_vesa.o \ + vdrivers/u_vsvirt.o \ + vdrivers/vesa.o + +ALL_O = $(STD_Oa) $(STD_Ob) $(DJ_O) + +ifeq ($(INCLUDE_BGI_SUPPORT),y) + ALL_O += $(BGI_Oa) $(BGI_Ob) +endif + +UTILP = ../bin/bin2c.exe \ + ../bin/fnt2c.exe \ + ../bin/vesainfo.exe \ + ../bin/modetest.exe + +all: $(GRX20ST) $(UTILP) + +clean: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f */*.o ../addons/*.o ../addons/*/*.o $(TAG) +else + if exist bgi\*.o del bgi\*.o + if exist draw\*.o del draw\*.o + if exist fdrivers\*.o del fdrivers\*.o + if exist fonts\*.o del fonts\*.o + if exist image\*.o del image\*.o + if exist gformats\*.o del gformats\*.o + if exist mouse\*.o del mouse\*.o + if exist misc\*.o del misc\*.o + if exist pattern\*.o del pattern\*.o + if exist setup\*.o del setup\*.o + if exist shape\*.o del shape\*.o + if exist text\*.o del text\*.o + if exist user\*.o del user\*.o + if exist utilprog\*.o del utilprog\*.o + if exist utils\*.o del utils\*.o + if exist vdrivers\*.o del vdrivers\*.o + if exist wideline\*.o del wideline\*.o + if exist ..\addons\*.o del ..\addons\*.o + if exist ..\addons\print\*.o del ..\addons\print\*.o + if exist ..\addons\bmp\*.o del ..\addons\bmp\*.o + if exist $(TAG) del $(TAG) +endif + +cleanall: clean +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f $(GRX20ST) ../bin/*.exe +else + if exist $(GRX20STdos) del $(GRX20STdos) + if exist ..\bin\*.exe del ..\bin\*.exe +endif + +install: $(GRX20ST) +ifeq ($(HAVE_UNIX_TOOLS),y) + mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(includedir) + cp $(GRX20ST) $(DESTDIR)$(libdir) + cp ../include/grx20.h ../include/grxkeys.h \ + ../include/libbcc.h $(DESTDIR)$(includedir) +ifeq ($(INCLUDE_PRINTING_CODE),y) + cp ../addons/print/grxprint.h $(DESTDIR)$(includedir) +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + mkdir -p $(DESTDIR)$(unitsdir) + cp ../pascal/grx.pas ../pascal/bgi/graph.pas $(DESTDIR)$(unitsdir) +endif +else + if not exist $(DESTDIRdos)\nul mkdir $(DESTDIRdos) + if not exist $(DESTDIRdos)$(libdirdos)\nul mkdir $(DESTDIRdos)$(libdirdos) + if not exist $(DESTDIRdos)$(includedirdos)\nul mkdir $(DESTDIRdos)$(includedirdos) + copy $(GRX20STdos) $(DESTDIRdos)$(libdirdos) + copy ..\include\grx20.h $(DESTDIRdos)$(includedirdos) + copy ..\include\grxkeys.h $(DESTDIRdos)$(includedirdos) + copy ..\include\libbcc.h $(DESTDIRdos)$(includedirdos) +ifeq ($(INCLUDE_PRINTING_CODE),y) + copy ..\addons\print\grxprint.h $(DESTDIRdos)$(includedirdos) +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + if not exist $(DESTDIRdos)$(unitsdirdos)\nul mkdir $(DESTDIRdos)$(unitsdirdos) + copy ..\pascal\grx.pas $(DESTDIRdos)$(unitsdirdos) + copy ..\pascal\bgi\graph.pas $(DESTDIRdos)$(unitsdirdos) +endif +endif + +uninstall: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f $(DESTDIR)$(libdir)/$(GRX20ln) $(DESTDIR)$(includedir)/grx20.h \ + $(DESTDIR)$(includedir)/grxkeys.h $(DESTDIR)$(includedir)/libbcc.h +ifeq ($(INCLUDE_PRINTING_CODE),y) + rm -f $(DESTDIR)$(includedir)/grxprint.h +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + rm -f $(DESTDIR)$(unitsdir)/grx.pas $(DESTDIR)$(unitsdir)/graph.pas +endif +else + if exist $(DESTDIRdos)$(libdirdos)\$(GRX20ln) del $(DESTDIRdos)$(libdirdos)\$(GRX20ln) + if exist $(DESTDIRdos)$(includedirdos)\grx20.h del $(DESTDIRdos)$(includedirdos)\grx20.h + if exist $(DESTDIRdos)$(includedirdos)\grxkeys.h del $(DESTDIRdos)$(includedirdos)\grxkeys.h + if exist $(DESTDIRdos)$(includedirdos)\libbcc.h del $(DESTDIRdos)$(includedirdos)\libbcc.h +ifeq ($(INCLUDE_PRINTING_CODE),y) + if exist $(DESTDIRdos)$(includedirdos)\grxprint.h del $(DESTDIRdos)$(includedirdos)\grxprint.h +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + if exist $(DESTDIRdos)$(unitsdirdos)\grx.pas del $(DESTDIRdos)$(unitsdirdos)\grx.pas + if exist $(DESTDIRdos)$(unitsdirdos)\graph.pas del $(DESTDIRdos)$(unitsdirdos)\graph.pas +endif +endif + +install-info: +ifeq ($(HAVE_UNIX_TOOLS),y) + mkdir -p $(DESTDIR)$(infodir) + cp ../doc/grx*um.inf $(DESTDIR)$(infodir)/grx.inf + install-info $(DESTDIR)$(infodir)/grx.inf $(DESTDIR)$(infodir)/dir +else + if not exist $(DESTDIRdos)$(infodirdos)\nul mkdir $(DESTDIRdos)$(infodirdos) + copy ..\doc\grx*um.inf $(DESTDIRdos)$(infodirdos)\grx.inf + install-info $(DESTDIRdos)$(infodirdos)\grx.inf $(DESTDIRdos)$(infodirdos)\dir +endif + +uninstall-info: +ifeq ($(HAVE_UNIX_TOOLS),y) + install-info -r $(DESTDIR)$(infodir)/grx.inf $(DESTDIR)$(infodir)/dir + rm -f $(DESTDIR)$(infodir)/grx.inf +else + install-info -r $(DESTDIRdos)$(infodirdos)\grx.inf $(DESTDIRdos)$(infodirdos)\dir + if exist $(DESTDIRdos)$(infodirdos)\grx.inf del $(DESTDIRdos)$(infodirdos)\grx.inf +endif + +install-bin: $(UTILP) +ifeq ($(HAVE_UNIX_TOOLS),y) + mkdir -p $(DESTDIR)$(bindir) + cp ../bin/bin2c.exe ../bin/fnt2c.exe ../bin/vesainfo.exe \ + ../bin/modetest.exe $(DESTDIR)$(bindir) +else + if not exist $(DESTDIRdos)$(bindirdos)\nul mkdir $(DESTDIRdos)$(bindirdos) + copy ..\bin\bin2c.exe $(DESTDIRdos)$(bindirdos) + copy ..\bin\fnt2c.exe $(DESTDIRdos)$(bindirdos) + copy ..\bin\vesainfo.exe $(DESTDIRdos)$(bindirdos) + copy ..\bin\modetest.exe $(DESTDIRdos)$(bindirdos) +endif + +uninstall-bin: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f $(DESTDIR)$(bindir)/bin2c.exe $(DESTDIR)$(bindir)/fnt2c.exe \ + $(DESTDIR)$(bindir)/vesainfo.exe $(DESTDIR)$(bindir)/modetest.exe +else + if exist $(DESTDIRdos)$(bindirdos)\bin2c.exe del $(DESTDIRdos)$(bindirdos)\bin2c.exe + if exist $(DESTDIRdos)$(bindirdos)\fnt2c.exe del $(DESTDIRdos)$(bindirdos)\fnt2c.exe + if exist $(DESTDIRdos)$(bindirdos)\vesainfo.exe del $(DESTDIRdos)$(bindirdos)\vesainfo.exe + if exist $(DESTDIRdos)$(bindirdos)\modetest.exe del $(DESTDIRdos)$(bindirdos)\modetest.exe +endif + +ifdef GRX_DEFAULT_FONT_PATH +ifeq ($(HAVE_UNIX_TOOLS),n) +FONTPATHdos = $(subst /,\,$(GRX_DEFAULT_FONT_PATH)) +endif +install-fonts: +ifeq ($(HAVE_UNIX_TOOLS),y) + mkdir -p $(DESTDIR)$(GRX_DEFAULT_FONT_PATH) + cp ../fonts/* $(DESTDIR)$(GRX_DEFAULT_FONT_PATH) +else + if not exist $(DESTDIRdos)$(FONTPATHdos)\nul mkdir $(DESTDIRdos)$(FONTPATHdos) + copy ..\fonts\*.* $(DESTDIRdos)$(FONTPATHdos) +endif +uninstall-fonts: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f $(DESTDIR)$(GRX_DEFAULT_FONT_PATH)/* +else + del $(DESTDIRdos)$(FONTPATHdos)\*.* +endif +endif + +dep: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f depend.tmp +else + if exist depend.tmp del depend.tmp +endif + $(CC) -MM $(CCOPT) $(INCDIR) $(ALL_O:.o=.c) >depend.tmp + sed 's#^.*: \(.*\)\.c#\1.o: \1.c#g' depend.dj2 +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f depend.tmp +else + if exist depend.tmp del depend.tmp +endif + +depend.b: depend.new + sed "s#\.o:#.obj:#g" depend.b + sed "s#\.o:#.asm:#g" >depend.b + +$(GRX20ST): $(TAG) $(ALL_O) +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f $(GRX20ST) +else + if exist $(GRX20STdos) del $(GRX20STdos) +endif + $(AR) -r $(GRX20ST) $(STD_Oa) + $(AR) -r $(GRX20ST) $(STD_Ob) +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(AR) -r $(GRX20ST) $(BGI_Oa) + $(AR) -r $(GRX20ST) $(BGI_Ob) +endif + $(AR) -r $(GRX20ST) $(DJ_O) + $(RANLIB) $(GRX20ST) + +$(UTILP): ../bin/%.exe : utilprog/%.o $(GRX20ST) + $(CC) $(LDOPT) -o $@ utilprog/$*.o $(GRX20ST) + $(EXE_COMPRESS) $@ + +$(DOS_DJGPP_V2): + $(MAKE) -f makefile.dj2 clean +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f $(SYSTEM_TAG_PREFIX).* +else + if exist $(SYSTEM_TAG_PREFIX).* del $(SYSTEM_TAG_PREFIX).* +endif + echo DOS_DJGPP_V2_TARGET > $(DOS_DJGPP_V2) + +$(ALL_O): $(TAG) + +$(ALL_O:.o=.i) : %.i : %.c + $(CC) -E $(CCOPT) $(INCDIR) $*.c > $*.i + +$(ALL_O:.o=.dm) : %.dm : %.c + $(CC) -dM -E $(CCOPT) $(INCDIR) $*.c > $*.dm + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c -o $*.s + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +include depend.dj2 diff --git a/thirdparty/grx249/src/makefile.lnx b/thirdparty/grx249/src/makefile.lnx new file mode 100644 index 0000000..7a02842 --- /dev/null +++ b/thirdparty/grx249/src/makefile.lnx @@ -0,0 +1,284 @@ +# +# GRX Library Makefile for LINUX/console. Uses GNU Make. +# +.PHONY : libst libsh clean cleanall install uninstall setsuid \ + install-bin uninstall-bin install-fonts uninstall-fonts \ + install-info uninstall-info + +GRXVLNX=y + +include ../makedefs.grx + +INCDIR= -I. -I./include -I../include +CCOPT += -DLFB_BY_NEAR_POINTER -pipe +ADDON_LIBS = + +ifdef GRX_DEFAULT_FONT_PATH +CCOPT += -DGRX_DEFAULT_FONT_PATH=\"$(GRX_DEFAULT_FONT_PATH)\" +endif + +ifeq ($(USE_SVGALIB_DRIVER),y) +CCOPT += -DSVGALIB_DRIVER +ADDON_LIBS += -lvga +endif + +ifeq ($(USE_FRAMEBUFFER_DRIVER),y) +CCOPT += -DFRAMEBUFFER_DRIVER +endif + +ifeq ($(USE_INOUTP_FRAMEDRIVERS),y) +CCOPT += -DINOUTP_FRAMEDRIVERS +endif + +ifeq ($(SET_SUIDROOT),y) +EXECBITS = 4755 +else +EXECBITS = 0755 +endif + +GRX20ST = ../lib/$(GRX_LIB_SUBDIR)/libgrx20.a + +GRX20SH = ../lib/$(GRX_LIB_SUBDIR)/libgrx20.so +GRX20SHli = $(GRX20SH).$(word 1,$(subst ., ,$(GRX_VERSION))) +GRX20SHna = $(GRX20SH).$(GRX_VERSION) +SHCCOPT = -fPIC -D__SHARED__ + +OX=.o +OP= + +include ./stdobjs.mak + +STD_O= $(STD_1) $(STD_2) $(STD_3) $(STD_4) \ + $(STD_5) $(STD_6) $(STD_7) $(STD_8) \ + $(STD_9) $(STD_10) $(STD_11) $(STD_12) + +BGI_O= $(BGI_1) $(BGI_2) $(BGI_3) $(BGI_4) \ + $(BGI_5) $(BGI_6) + +ADDON_O= + +ifdef DEBUG + ADDON_O += $(DBG_1) +endif + +ifeq ($(HAVE_LIBTIFF),y) + ADDON_O += $(TIF_1) +endif + +ifeq ($(HAVE_LIBJPEG),y) + ADDON_O += $(JPG_1) +else + ADDON_O += $(NOJPG_1) +endif + +ifeq ($(HAVE_LIBPNG),y) + ADDON_O += $(PNG_1) +else + ADDON_O += $(NOPNG_1) +endif + +ifeq ($(INCLUDE_PRINTING_CODE),y) + ADDON_O += $(PRN_1) + INCDIR += -I../addons/print +ifeq ($(INCLUDE_BGI_SUPPORT),y) + BGI_O += $(PRNBGI_1) +endif +endif + +O= $(STD_O) \ + $(ADDON_O) \ + fdrivers/ram24.o \ + fdrivers/ram32l.o \ + fdrivers/ram32h.o \ + fdrivers/svga16.o \ + fdrivers/svga24.o \ + fdrivers/svga32h.o \ + fdrivers/svga32l.o \ + fdrivers/svga8.o \ + mouse/lnxkeys.o \ + misc/lnxmisc.o + +ifeq ($(BUILD_X86_64),n) + O += fdrivers/egavga1.o \ + fdrivers/ega4.o \ + fdrivers/svga4.o \ + fdrivers/vga8x.o +endif + +ifeq ($(INCLUDE_BGI_SUPPORT),y) + O += $(BGI_O) +endif + +ifeq ($(USE_SVGALIB_DRIVER),y) + O += vdrivers/svgalib.o +endif + +ifeq ($(USE_FRAMEBUFFER_DRIVER),y) + O += vdrivers/vd_lnxfb.o +endif + +ifeq ($(USE_DIRECT_MOUSE_DRIVER),y) + O += mouse/lnxinpu2.o +else + O += mouse/lnxinput.o +endif + +LO = $(subst $(OX),.lo,$(O)) + +UTILP = ../bin/bin2c \ + ../bin/fnt2c \ + ../bin/lfbinfo + +UTILPS= ../bin/modetest + +all: libst libsh $(UTILP) $(UTILPS) + +libst: $(GRX20ST) + +$(GRX20ST): $(LINUX_i386_CONSOLE) $(O) + -rm -f $(GRX20ST) + $(AR) -r $(GRX20ST) $(O) + $(RANLIB) $(GRX20ST) + +ifeq ($(INCLUDE_SHARED_SUPPORT),y) +libsh: $(GRX20SHna) +else +libsh: +endif + +$(GRX20SHna): $(LINUX_i386_CONSOLE) $(LO) + -rm -f $(GRX20SHna) + $(CC) $(LDOPT) -shared -Wl,-soname,$(notdir $(GRX20SHli)) -o $(GRX20SHna) $(LO) + ln -sf $(notdir $(GRX20SHna)) $(GRX20SHli) + +$(UTILP): ../bin/% : utilprog/%.o $(GRX20ST) + $(CC) $(LDOPT) -o $@ utilprog/$*.o $(GRX20ST) + $(STRIP) $@ + +$(UTILPS): ../bin/% : utilprog/%.o $(GRX20ST) + $(CC) $(LDOPT) -o $@ utilprog/$*.o $(GRX20ST) $(ADDON_LIBS) -lm + $(STRIP) $@ + chmod $(EXECBITS) $@ + +$(O): $(LINUX_i386_CONSOLE) + +$(LO): $(LINUX_i386_CONSOLE) + +$(LINUX_i386_CONSOLE): + if [ ! -r $(LINUX_i386_CONSOLE) ]; then \ + rm -f $(SYSTEM_TAG_PREFIX).* $(O) $(LO) utilprog/*.o; fi + touch $(LINUX_i386_CONSOLE) + +clean: + rm -f $(O) $(O:.o=.s) $(LO) $(LINUX_i386_CONSOLE) + rm -f utilprog/*.o + +cleanall: clean +ifeq ($(INCLUDE_SHARED_SUPPORT),y) + rm -f $(GRX20SHna) $(GRX20SHli) +endif + rm -f $(GRX20ST) + rm -f $(UTILP) $(UTILPS) + +install: libst libsh + install -m 0755 -d $(DESTDIR)$(libdir) + install -m 0755 -d $(DESTDIR)$(includedir) + install -m 0644 $(GRX20ST) $(DESTDIR)$(libdir) +ifeq ($(INCLUDE_SHARED_SUPPORT),y) + install -m 0755 $(GRX20SHna) $(DESTDIR)$(libdir) + ln -sf $(notdir $(GRX20SHna)) $(DESTDIR)$(libdir)/$(notdir $(GRX20SHli)) + ln -sf $(notdir $(GRX20SHli)) $(DESTDIR)$(libdir)/$(notdir $(GRX20SH)) +endif + install -m 0644 ../include/grx20.h $(DESTDIR)$(includedir) + install -m 0644 ../include/grxkeys.h $(DESTDIR)$(includedir) + install -m 0644 ../include/libbcc.h $(DESTDIR)$(includedir) +ifeq ($(INCLUDE_PRINTING_CODE),y) + install -m 0644 ../addons/print/grxprint.h $(DESTDIR)$(includedir) +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + install -m 0755 -d $(DESTDIR)$(unitsdir) + install -m 0644 ../pascal/grx.pas $(DESTDIR)$(unitsdir) + install -m 0644 ../pascal/bgi/graph.pas $(DESTDIR)$(unitsdir) +endif + +uninstall: + rm -f $(DESTDIR)$(libdir)/$(notdir $(GRX20ST)) +ifeq ($(INCLUDE_SHARED_SUPPORT),y) + rm -f $(DESTDIR)$(libdir)/$(notdir $(GRX20SH)) + rm -f $(DESTDIR)$(libdir)/$(notdir $(GRX20SHli)) + rm -f $(DESTDIR)$(libdir)/$(notdir $(GRX20SHna)) +endif + rm -f $(DESTDIR)$(includedir)/grx20.h + rm -f $(DESTDIR)$(includedir)/grxkeys.h + rm -f $(DESTDIR)$(includedir)/libbcc.h +ifeq ($(INCLUDE_PRINTING_CODE),y) + rm -f $(DESTDIR)$(includedir)/grxprint.h +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + rm -f $(DESTDIR)$(unitsdir)/grx.pas + rm -f $(DESTDIR)$(unitsdir)/graph.pas +endif + +setsuid: $(UTILPS) +ifeq ($(SET_SUIDROOT),y) + chown root ../bin/modetest + chmod $(EXECBITS) ../bin/modetest +else + @echo "Nothing to do, SET_SUIDROOT is not set to 'y' in makedefs.grx" +endif + +install-info: + install -m 0755 -d $(DESTDIR)$(infodir) + install -m 0644 ../doc/grx*um.inf $(DESTDIR)$(infodir)/grx.info + for info_dir_file in $(DESTDIR)$(infodir)/dir /etc/info-dir; do \ + if [ -w $info_dir_file ]; then \ + install-info --dir-file=$info_dir_file $(DESTDIR)$(infodir)/grx.info; \ + fi; \ + done + +uninstall-info: + for info_dir_file in $(DESTDIR)$(infodir)/dir /etc/info-dir; do \ + if [ -w $info_dir_file ]; then \ + install-info --dir-file=$info_dir_file -r grx; \ + fi; \ + done + rm -f $(DESTDIR)$(infodir)/grx.info + +install-bin: $(UTILP) $(UTILPS) + install -m 0755 -d $(DESTDIR)$(bindir) + install -m 0755 ../bin/bin2c $(DESTDIR)$(bindir) + install -m 0755 ../bin/fnt2c $(DESTDIR)$(bindir) + install -m 0755 ../bin/lfbinfo $(DESTDIR)$(bindir) + install -m $(EXECBITS) ../bin/modetest $(DESTDIR)$(bindir) + +uninstall-bin: + rm -f $(DESTDIR)$(bindir)/bin2c + rm -f $(DESTDIR)$(bindir)/fnt2c + rm -f $(DESTDIR)$(bindir)/lfbinfo + rm -f $(DESTDIR)$(bindir)/modetest + +ifdef GRX_DEFAULT_FONT_PATH +install-fonts: + install -m 0755 -d $(DESTDIR)$(GRX_DEFAULT_FONT_PATH) + install -m 0644 ../fonts/* $(DESTDIR)$(GRX_DEFAULT_FONT_PATH) +uninstall-fonts: + rm -f $(GRX_DEFAULT_FONT_PATH)/* +endif + +dep: + $(CC) -MM $(CCOPT) $(INCDIR) $(O:.o=.c) \ + | sed 's#^.*: \(.*\)\.c#\1.o: \1.c#g' >depend.lnx + +$(O): %.o : %.c + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +$(LO): %.lo : %.c + $(CC) -c $(CCOPT) $(SHCCOPT) $(INCDIR) $*.c -o $*.lo + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c -o $*.s + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +include depend.lnx diff --git a/thirdparty/grx249/src/makefile.sdl b/thirdparty/grx249/src/makefile.sdl new file mode 100644 index 0000000..0e87cad --- /dev/null +++ b/thirdparty/grx249/src/makefile.sdl @@ -0,0 +1,223 @@ +# +# GRX Library Makefile for SDL +# +.PHONY : clean cleanall install uninstall \ + install-bin uninstall-bin install-fonts uninstall-fonts + +GRXVSDL=y + +include ../makedefs.grx + +INCDIR= -I. -I./include -I../include + +ifeq ($(EP),x) + INCDIR += $(X11INCS) + SDLDEFS = -D__XWIN__ -D__SDL__ + LIBS = $(X11LIBS) + SDLLIBS = -lSDL -lpthread +else + EX = .exe + SDLDEFS = -D__SDL__ + LIBS = + SDLLIBS = -lSDL +endif + +CCOPT += $(SDLDEFS) + +ifdef GRX_DEFAULT_FONT_PATH +CCOPT += -DGRX_DEFAULT_FONT_PATH=\"$(GRX_DEFAULT_FONT_PATH)\" +endif + +TAG = $(ANY_GCC_SDL_STATIC) + +GRX20ST = ../lib/$(GRX_LIB_SUBDIR)/libgrx20S.a + +OX=.o +OP= + +include ./stdobjs.mak + +# Keep things a little smaller when building the lib ... +STD_Oa= $(STD_1) $(STD_2) $(STD_3) +STD_Ob= $(STD_4) $(STD_5) $(STD_6) +STD_Oc= $(STD_7) $(STD_8) $(STD_9) +STD_Od= $(STD_10) $(STD_11) $(STD_12) +BGI_Oa= $(BGI_1) $(BGI_2) $(BGI_3) +BGI_Ob= $(BGI_4) $(BGI_5) $(BGI_6) + +ADDON_O= +ifdef DEBUG + ADDON_O += $(DBG_1) +endif + +ifeq ($(HAVE_LIBTIFF),y) + ADDON_O += $(TIF_1) +endif + +ifeq ($(HAVE_LIBJPEG),y) + ADDON_O += $(JPG_1) +else + ADDON_O += $(NOJPG_1) +endif + +ifeq ($(HAVE_LIBPNG),y) + ADDON_O += $(PNG_1) +else + ADDON_O += $(NOPNG_1) +endif + +ifeq ($(INCLUDE_PRINTING_CODE),y) + ADDON_O += $(PRN_1) + INCDIR += -I../addons/print +ifeq ($(INCLUDE_BGI_SUPPORT),y) + BGI_Ob += $(PRNBGI_1) +endif +endif + +ifeq ($(INCLUDE_BMP_CODE),y) + ADDON_O += $(BMP_1) + INCDIR += -I../addons/bmp +endif + +SDL_O = $(ADDON_O) \ + fdrivers/sdl8.o \ + fdrivers/sdl16.o \ + fdrivers/sdl24.o \ + fdrivers/sdl32l.o \ + fdrivers/sdl32h.o \ + fdrivers/lfbbltrv.o \ + fdrivers/lfbbltvr.o \ + fdrivers/lfbbltvv.o \ + fdrivers/ram24.o \ + fdrivers/ram32l.o \ + fdrivers/ram32h.o \ + mouse/sdlinp.o \ + mouse/sdlkeys.o \ + misc/sdlmisc.o \ + vdrivers/vd_sdl.o + +ifneq ($(EX),.exe) + SDL_O += fonts/fdv_xwin.o +endif + +ALL_O = $(STD_Oa) $(STD_Ob) $(STD_Oc) $(STD_Od) $(SDL_O) + +ifeq ($(INCLUDE_BGI_SUPPORT),y) + ALL_O += $(BGI_Oa) $(BGI_Ob) +endif + +UTILPC= ../bin/bin2c$(EX) \ + ../bin/fnt2c$(EX) \ + +UTILPS= ../bin/$(EP)modetest$(EX) + +all: $(GRX20ST) $(UTILPC) $(UTILPS) + +clean: + rm -f bgi/*.o draw/*.o fdrivers/*.o fonts/*.o image/*.o gformats/*.o + rm -f mouse/*.o misc/*.o pattern/*.o setup/*.o shape/*.o text/*.o + rm -f user/*.o utils/*.o utilprog/*.o vdrivers/*.o wideline/*.o + rm -f ../addons/*.o ../addons/print/*.o ../addons/bmp/*.o $(TAG) + +cleanall: clean + rm -f $(GRX20ST) $(UTILPC) $(UTILPS) + +install: $(GRX20ST) + mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(includedir) + cp $(GRX20ST) $(DESTDIR)$(libdir) + cp ../include/grx20.h ../include/grxkeys.h \ + ../include/libbcc.h $(DESTDIR)$(includedir) +ifeq ($(INCLUDE_PRINTING_CODE),y) + cp ../addons/print/grxprint.h $(DESTDIR)$(includedir) +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + mkdir -p $(DESTDIR)$(unitsdir) + cp ../pascal/grx.pas ../pascal/bgi/graph.pas $(DESTDIR)$(unitsdir) +endif + +uninstall: + rm -f $(DESTDIR)$(libdir)/$(notdir $(GRX20ST)) $(DESTDIR)$(includedir)/grx20.h \ + $(DESTDIR)$(includedir)/grxkeys.h $(DESTDIR)$(includedir)/libbcc.h +ifeq ($(INCLUDE_PRINTING_CODE),y) + rm -f $(DESTDIR)$(includedir)/grxprint.h +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + rm -f $(DESTDIR)$(unitsdir)/grx.pas $(DESTDIR)$(unitsdir)/graph.pas +endif + +install-bin: $(UTILPC) $(UTILPW) + mkdir -p $(DESTDIR)$(bindir) + cp ../bin/bin2c$(EX) ../bin/fnt2c$(EX) \ + ../bin/$(EP)modetest$(EX) $(DESTDIR)$(bindir) + +uninstall-bin: + rm -f $(DESTDIR)$(bindir)/bin2c$(EX) $(DESTDIR)$(bindir)/fnt2c$(EX) \ + $(DESTDIR)$(bindir)/$(EP)modetest$(EX) + +ifdef GRX_DEFAULT_FONT_PATH +install-fonts: + mkdir -p $(DESTDIR)$(GRX_DEFAULT_FONT_PATH) + cp ../fonts/* $(DESTDIR)$(GRX_DEFAULT_FONT_PATH) + +uninstall-fonts: + rm -f $(DESTDIR)$(GRX_DEFAULT_FONT_PATH)/* +endif + +dep: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f depend.tmp +else + if exist depend.tmp del depend.tmp +endif + gcc -MM $(CCOPT) $(INCDIR) $(ALL_O:.o=.c) >depend.tmp + sed 's#^.*: \(.*\)\.c#\1.o: \1.c#g' depend.sdl +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f depend.tmp +else + if exist depend.tmp del depend.tmp +endif + +depend.b: depend.new + sed "s#\.o:#.obj:#g" depend.b + sed "s#\.o:#.asm:#g" >depend.b + +$(GRX20ST): $(TAG) $(ALL_O) + rm -f $(GRX20ST) + $(AR) -r $(GRX20ST) $(STD_Oa) + $(AR) -r $(GRX20ST) $(STD_Ob) + $(AR) -r $(GRX20ST) $(STD_Oc) + $(AR) -r $(GRX20ST) $(STD_Od) +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(AR) -r $(GRX20ST) $(BGI_Oa) + $(AR) -r $(GRX20ST) $(BGI_Ob) +endif + $(AR) -r $(GRX20ST) $(SDL_O) + $(RANLIB) $(GRX20ST) + +$(UTILPC): ../bin/%$(EX) : utilprog/%.o $(GRX20ST) + $(CC) $(LDOPT) -o $@ utilprog/$*.o $(GRX20ST) $(LIBS) + +$(UTILPS): ../bin/$(EP)%$(EX) : utilprog/%.o $(GRX20ST) + $(CC) $(LDOPT) -o $@ utilprog/$*.o $(GRX20ST) $(SDLLIBS) $(LIBS) + +$(ANY_GCC_SDL_STATIC): + $(MAKE) -f makefile.sdl clean + rm -f $(SYSTEM_TAG_PREFIX).* + echo ANY_GCC_SDL_STATIC_TARGET > $(ANY_GCC_SDL_STATIC) + +$(ALL_O): $(TAG) + +$(ALL_O:.o=.i) : %.i : %.c + $(CC) -E $(CCOPT) $(INCDIR) $*.c > $*.i + +$(ALL_O:.o=.dm) : %.dm : %.c + $(CC) -dM -E $(CCOPT) $(INCDIR) $*.c > $*.dm + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c -o $*.s + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +#include depend.sdl diff --git a/thirdparty/grx249/src/makefile.w32 b/thirdparty/grx249/src/makefile.w32 new file mode 100644 index 0000000..642c310 --- /dev/null +++ b/thirdparty/grx249/src/makefile.w32 @@ -0,0 +1,303 @@ +# +# GRX Library Makefile for Mingw +# Make sure your shell is command.com ! +# +.PHONY : clean cleanall install uninstall \ + install-bin uninstall-bin install-fonts uninstall-fonts + +GRXVW32=y + +include ../makedefs.grx + +INCDIR= -I. -I./include -I../include + +ifdef GRX_DEFAULT_FONT_PATH +CCOPT += -DGRX_DEFAULT_FONT_PATH=\"$(GRX_DEFAULT_FONT_PATH)\" +endif + +TAG = $(WIN32_GCC_i386_STATIC) + +GRX20ln = libgrx20.a +GRX20ST = ../lib/$(GRX_LIB_SUBDIR)/$(GRX20ln) +ifeq ($(HAVE_UNIX_TOOLS),n) +GRX20STdos = $(subst /,\,$(GRX20ST)) +DESTDIRdos = $(subst /,\,$(DESTDIR)) +libdirdos = $(subst /,\,$(libdir)) +includedirdos = $(subst /,\,$(includedir)) +unitsdirdos = $(subst /,\,$(unitsdir)) +infodirdos = $(subst /,\,$(infodir)) +endif + +OX=.o +OP= + +include ./stdobjs.mak + +# Keep things a little smaller when building the lib ... +STD_Oa= $(STD_1) $(STD_2) $(STD_3) +STD_Ob= $(STD_4) $(STD_5) $(STD_6) +STD_Oc= $(STD_7) $(STD_8) $(STD_9) +STD_Od= $(STD_10) $(STD_11) $(STD_12) +BGI_Oa= $(BGI_1) $(BGI_2) $(BGI_3) +BGI_Ob= $(BGI_4) $(BGI_5) $(BGI_6) + +ADDON_O= +ifdef DEBUG + ADDON_O += $(DBG_1) +endif + +ifeq ($(HAVE_LIBTIFF),y) + ADDON_O += $(TIF_1) +endif + +ifeq ($(HAVE_LIBJPEG),y) + ADDON_O += $(JPG_1) +else + ADDON_O += $(NOJPG_1) +endif + +ifeq ($(HAVE_LIBPNG),y) + ADDON_O += $(PNG_1) +else + ADDON_O += $(NOPNG_1) +endif + +ifeq ($(INCLUDE_PRINTING_CODE),y) + ADDON_O += $(PRN_1) + INCDIR += -I../addons/print +ifeq ($(INCLUDE_BGI_SUPPORT),y) + BGI_Ob += $(PRNBGI_1) +endif +endif + +ifeq ($(INCLUDE_BMP_CODE),y) + ADDON_O += $(BMP_1) + INCDIR += -I../addons/bmp +endif + +W32_O = $(ADDON_O) \ + fdrivers/fdw32_24.o \ + fdrivers/fdw32_8.o \ + fdrivers/lfbbltrv.o \ + fdrivers/lfbbltvr.o \ + fdrivers/lfbbltvv.o \ + fdrivers/ram24.o \ + fdrivers/ram32l.o \ + fdrivers/ram32h.o \ + mouse/w32inp.o \ + mouse/w32keys.o \ + misc/w32misc.o \ + vdrivers/vd_win32.o + +ALL_O = $(STD_Oa) $(STD_Ob) $(STD_Oc) $(STD_Od) $(W32_O) + +ifeq ($(INCLUDE_BGI_SUPPORT),y) + ALL_O += $(BGI_Oa) $(BGI_Ob) +endif + +UTILPC= ../bin/bin2c.exe \ + ../bin/fnt2c.exe \ + +UTILPW= ../bin/modetest.exe + +all: $(GRX20ST) $(UTILPC) $(UTILPW) + +clean: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f */*.o ../addons/*.o ../addons/*/*.o $(TAG) +else + if exist bgi\*.o del bgi\*.o + if exist draw\*.o del draw\*.o + if exist fdrivers\*.o del fdrivers\*.o + if exist fonts\*.o del fonts\*.o + if exist image\*.o del image\*.o + if exist gformats\*.o del gformats\*.o + if exist mouse\*.o del mouse\*.o + if exist misc\*.o del misc\*.o + if exist pattern\*.o del pattern\*.o + if exist setup\*.o del setup\*.o + if exist shape\*.o del shape\*.o + if exist text\*.o del text\*.o + if exist user\*.o del user\*.o + if exist utils\*.o del utils\*.o + if exist utilprog\*.o del utilprog\*.o + if exist vdrivers\*.o del vdrivers\*.o + if exist wideline\*.o del wideline\*.o + if exist ..\addons\*.o del ..\addons\*.o + if exist ..\addons\print\*.o del ..\addons\print\*.o + if exist ..\addons\bmp\*.o del ..\addons\bmp\*.o + if exist $(TAG) del $(TAG) +endif + +cleanall: clean +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f $(GRX20STdos) ../bin/*.exe +else + if exist $(GRX20STdos) del $(GRX20STdos) + if exist ..\bin\*.exe del ..\bin\*.exe +endif + +install: $(GRX20ST) +ifeq ($(HAVE_UNIX_TOOLS),y) + mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(includedir) + cp $(GRX20ST) $(DESTDIR)$(libdir) + cp ../include/grx20.h ../include/grxkeys.h \ + ../include/libbcc.h $(DESTDIR)$(includedir) +ifeq ($(INCLUDE_PRINTING_CODE),y) + cp ../addons/print/grxprint.h $(DESTDIR)$(includedir) +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + mkdir -p $(DESTDIR)$(unitsdir) + cp ../pascal/grx.pas ../pascal/bgi/graph.pas $(DESTDIR)$(unitsdir) +endif +else + if not exist $(DESTDIRdos)\nul mkdir $(DESTDIRdos) + if not exist $(DESTDIRdos)$(libdirdos)\nul mkdir $(DESTDIRdos)$(libdirdos) + if not exist $(DESTDIRdos)$(includedirdos)\nul mkdir $(DESTDIRdos)$(includedirdos) + copy $(GRX20STdos) $(DESTDIRdos)$(libdirdos) + copy ..\include\grx20.h $(DESTDIRdos)$(includedirdos) + copy ..\include\grxkeys.h $(DESTDIRdos)$(includedirdos) + copy ..\include\libbcc.h $(DESTDIRdos)$(includedirdos) +ifeq ($(INCLUDE_PRINTING_CODE),y) + copy ..\addons\print\grxprint.h $(DESTDIRdos)$(includedirdos) +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + if not exist $(DESTDIRdos)$(unitsdirdos)\nul mkdir $(DESTDIRdos)$(unitsdirdos) + copy ..\pascal\grx.pas $(DESTDIRdos)$(unitsdirdos) + copy ..\pascal\bgi\graph.pas $(DESTDIRdos)$(unitsdirdos) +endif +endif + +uninstall: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f $(DESTDIR)$(libdir)/$(GRX20ln) $(DESTDIR)$(includedir)/grx20.h \ + $(DESTDIR)$(includedir)/grxkeys.h $(DESTDIR)$(includedir)/libbcc.h +ifeq ($(INCLUDE_PRINTING_CODE),y) + rm -f $(DESTDIR)$(includedir)/grxprint.h +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + rm -f $(DESTDIR)$(unitsdir)/grx.pas $(DESTDIR)$(unitsdir)/graph.pas +endif +else + if exist $(DESTDIRdos)$(libdirdos)\$(GRX20ln) del $(DESTDIRdos)$(libdirdos)\$(GRX20ln) + if exist $(DESTDIRdos)$(includedirdos)\grx20.h del $(DESTDIRdos)$(includedirdos)\grx20.h + if exist $(DESTDIRdos)$(includedirdos)\grxkeys.h del $(DESTDIRdos)$(includedirdos)\grxkeys.h + if exist $(DESTDIRdos)$(includedirdos)\libbcc.h del $(DESTDIRdos)$(includedirdos)\libbcc.h +ifeq ($(INCLUDE_PRINTING_CODE),y) + if exist $(DESTDIRdos)$(includedirdos)\grxprint.h del $(DESTDIRdos)$(includedirdos)\grxprint.h +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + if exist $(DESTDIRdos)$(unitsdirdos)\grx.pas del $(DESTDIRdos)$(unitsdirdos)\grx.pas + if exist $(DESTDIRdos)$(unitsdirdos)\graph.pas del $(DESTDIRdos)$(unitsdirdos)\graph.pas +endif +endif + +install-bin: $(UTILP) +ifeq ($(HAVE_UNIX_TOOLS),y) + mkdir -p $(DESTDIR)$(bindir) + cp ../bin/bin2c.exe ../bin/fnt2c.exe \ + ../bin/modetest.exe $(DESTDIR)$(bindir) +else + if not exist $(DESTDIRdos)$(bindirdos)\nul mkdir $(DESTDIRdos)$(bindirdos) + copy ..\bin\bin2c.exe $(DESTDIRdos)$(bindirdos) + copy ..\bin\fnt2c.exe $(DESTDIRdos)$(bindirdos) + copy ..\bin\modetest.exe $(DESTDIRdos)$(bindirdos) +endif + +uninstall-bin: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f $(DESTDIR)$(bindir)/bin2c.exe $(DESTDIR)$(bindir)/fnt2c.exe \ + $(DESTDIR)$(bindir)/modetest.exe +else + if exist $(DESTDIRdos)$(bindirdos)\bin2c.exe del $(DESTDIRdos)$(bindirdos)\bin2c.exe + if exist $(DESTDIRdos)$(bindirdos)\fnt2c.exe del $(DESTDIRdos)$(bindirdos)\fnt2c.exe + if exist $(DESTDIRdos)$(bindirdos)\modetest.exe del $(DESTDIRdos)$(bindirdos)\modetest.exe +endif + +ifdef GRX_DEFAULT_FONT_PATH +ifeq ($(HAVE_UNIX_TOOLS),n) +FONTPATHdos = $(subst /,\,$(GRX_DEFAULT_FONT_PATH)) +endif +install-fonts: +ifeq ($(HAVE_UNIX_TOOLS),y) + mkdir -p $(DESTDIR)$(GRX_DEFAULT_FONT_PATH) + cp ../fonts/* $(DESTDIR)$(GRX_DEFAULT_FONT_PATH) +else + if not exist $(DESTDIRdos)$(FONTPATHdos)\nul mkdir $(DESTDIRdos)$(FONTPATHdos) + copy ..\fonts\*.* $(DESTDIRdos)$(FONTPATHdos) +endif +uninstall-fonts: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f $(DESTDIR)$(GRX_DEFAULT_FONT_PATH)/* +else + del $(DESTDIRdos)$(FONTPATHdos)\*.* +endif +endif + +dep: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f depend.tmp +else + if exist depend.tmp del depend.tmp +endif + $(CC) -MM $(CCOPT) $(INCDIR) $(ALL_O:.o=.c) >depend.tmp + sed 's#^.*: \(.*\)\.c#\1.o: \1.c#g' depend.w32 +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f depend.tmp +else + if exist depend.tmp del depend.tmp +endif + +depend.b: depend.new + sed "s#\.o:#.obj:#g" depend.b + sed "s#\.o:#.asm:#g" >depend.b + +$(GRX20ST): $(TAG) $(ALL_O) +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f $(GRX20ST) +else + if exist $(GRX20STdos) del $(GRX20STdos) +endif + $(AR) -r $(GRX20ST) $(STD_Oa) + $(AR) -r $(GRX20ST) $(STD_Ob) + $(AR) -r $(GRX20ST) $(STD_Oc) + $(AR) -r $(GRX20ST) $(STD_Od) +ifeq ($(INCLUDE_BGI_SUPPORT),y) + $(AR) -r $(GRX20ST) $(BGI_Oa) + $(AR) -r $(GRX20ST) $(BGI_Ob) +endif + $(AR) -r $(GRX20ST) $(W32_O) + $(RANLIB) $(GRX20ST) + +$(UTILPC): ../bin/%.exe : utilprog/%.o $(GRX20ST) + $(CC) $(LDOPT) -o $@ utilprog/$*.o $(GRX20ST) + +$(UTILPW): ../bin/%.exe : utilprog/%.o $(GRX20ST) + $(CC) $(LDOPT) -o $@ utilprog/$*.o $(GRX20ST) -mwindows -mconsole + +$(WIN32_GCC_i386_STATIC): + $(MAKE) -f makefile.w32 clean +ifeq ($(HAVE_UNIX_TOOLS),y) + if [ ! -r $(WIN32_GCC_i386_STATIC) ]; then \ + rm -f $(SYSTEM_TAG_PREFIX).*; fi +else + if not exist $(WIN32_GCC_i386_STATIC) del $(SYSTEM_TAG_PREFIX).* +endif + echo WIN32_GCC_i386_STATIC_TARGET > $(WIN32_GCC_i386_STATIC) + +$(ALL_O): $(TAG) + +$(ALL_O:.o=.i) : %.i : %.c + $(CC) -E $(CCOPT) $(INCDIR) $*.c > $*.i + +$(ALL_O:.o=.dm) : %.dm : %.c + $(CC) -dM -E $(CCOPT) $(INCDIR) $*.c > $*.dm + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c -o $*.s + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +#include depend.w32 diff --git a/thirdparty/grx249/src/makefile.wat b/thirdparty/grx249/src/makefile.wat new file mode 100644 index 0000000..e0b8db4 --- /dev/null +++ b/thirdparty/grx249/src/makefile.wat @@ -0,0 +1,1188 @@ +!define BLANK "" + +## Object Files +OBJS = .\bmp.obj .\grxprint.obj .\prndata.obj .\bitblt.obj .\bitbltnc.obj & + .\box.obj .\boxnc.obj .\clearclp.obj .\clearctx.obj .\clearscr.obj & + .\drwinlne.obj .\fillbox.obj .\fillboxn.obj .\frambox.obj .\framboxn.obj & + .\getscl.obj .\line.obj .\linenc.obj .\majorln1.obj .\majorln2.obj & + .\majorln3.obj .\majorln4.obj .\pixel.obj .\pixelc.obj .\plot.obj & + .\putscl.obj .\dotab8.obj .\ega4.obj .\egavga1.obj .\ftable.obj & + .\genblit.obj .\gengiscl.obj .\genptscl.obj .\genstrch.obj .\herc1.obj & + .\lfb16.obj .\lfb24.obj .\lfb32h.obj .\lfb32l.obj .\lfb8.obj & + .\lfbbltrv.obj .\lfbbltvr.obj .\lfbbltvv.obj .\pblitr2r.obj .\pblitr2v.obj & + .\pblitv2r.obj .\pblitv2v.obj .\ram1.obj .\ram16.obj .\ram24.obj & + .\ram32h.obj .\ram32l.obj .\ram4.obj .\ram8.obj .\rblit_14.obj & + .\svga16.obj .\svga24.obj .\svga32h.obj .\svga32l.obj .\svga4.obj & + .\svga8.obj .\vga8x.obj .\fdtable.obj .\fdv_bgi.obj .\fdv_grx.obj & + .\pc6x8.obj .\pc8x14.obj .\pc8x16.obj .\pc8x8.obj .\ialloc.obj & + .\ibuild.obj .\ifbox.obj .\ihline.obj .\iinverse.obj .\imginlne.obj & + .\iplot.obj .\istretch.obj .\bldcurs.obj .\dosinput.obj .\doskeys.obj & + .\drawcurs.obj .\mouinfo.obj .\mouinlne.obj .\mscursor.obj .\fillpatt.obj & + .\makepat.obj .\patfbits.obj .\patfbox.obj .\patfcvxp.obj .\patfline.obj & + .\patfplot.obj .\patfpoly.obj .\patternf.obj .\pattfldf.obj .\pattline.obj & + .\pattpoly.obj .\pfcirc.obj .\pfcirca.obj .\pfelli.obj .\pfellia.obj & + .\ptcirc.obj .\ptcirca.obj .\ptelli.obj .\ptellia.obj .\clip.obj & + .\clrinfo.obj .\clrinlne.obj .\colorbw.obj .\colorega.obj .\colors.obj & + .\context.obj .\cxtinfo.obj .\cxtinlne.obj .\drvinfo.obj .\drvinlne.obj & + .\fframe.obj .\fgeom.obj .\hooks.obj .\modewalk.obj .\setdrvr.obj & + .\setmode.obj .\version.obj .\viewport.obj .\circle1.obj .\circle2.obj & + .\circle3.obj .\circle4.obj .\drawpoly.obj .\fillcir1.obj .\fillcir2.obj & + .\fillcnvx.obj .\fillell1.obj .\fillell2.obj .\fillpoly.obj .\flood.obj & + .\floodfil.obj .\genellip.obj .\polygon.obj .\polyline.obj .\scancnvx.obj & + .\scanellp.obj .\scanpoly.obj .\solidfil.obj .\buildaux.obj .\buildfnt.obj & + .\convfont.obj .\drawstrg.obj .\drawtext.obj .\drwstrg.obj .\dumpfont.obj & + .\dumptext.obj .\epatstrg.obj .\fntinlne.obj .\fontinfo.obj .\fontpath.obj & + .\loadfont.obj .\pattstrg.obj .\propwdt.obj .\unloadfn.obj .\ubox.obj & + .\ucbox.obj .\uccirc.obj .\uccirca.obj .\ucelli.obj .\ucellia.obj & + .\ucirc.obj .\ucirca.obj .\ucircf.obj .\ucircfa.obj .\ucline.obj & + .\ucpolyg.obj .\ucpolyl.obj .\udrwchar.obj .\udrwstrg.obj .\uelli.obj & + .\uellia.obj .\uellif.obj .\uellifa.obj .\ufcpolyg.obj .\ufillbox.obj & + .\uflood.obj .\ufpolyg.obj .\uframbox.obj .\ugetwin.obj .\uhline.obj & + .\uline.obj .\upbox.obj .\upcirc.obj .\upcirca.obj .\upelli.obj & + .\upellia.obj .\upfbox.obj .\upfcirc.obj .\upfcirca.obj .\upfcpoly.obj & + .\upfelli.obj .\upfellia.obj .\upfflood.obj .\upfline.obj .\upfplot.obj & + .\upfpolyg.obj .\upixel.obj .\upixelc.obj .\upline.obj .\uplot.obj & + .\upolygon.obj .\upolylin.obj .\uppolyg.obj .\uppolyl.obj .\usercord.obj & + .\usetwin.obj .\utextxy.obj .\uvline.obj .\ordswap.obj .\resize.obj & + .\shiftscl.obj .\strmatch.obj .\tmpbuff.obj .\watcom32.obj .\ati28800.obj & + .\cl5426.obj .\et4000.obj .\herc.obj .\mach64.obj .\s3.obj .\stdega.obj & + .\stdvga.obj .\u_egavga.obj .\u_vesa.obj .\u_vsvirt.obj .\vd_mem.obj & + .\vesa.obj .\vtable.obj .\ccirc.obj .\ccirca.obj .\celli.obj .\cellia.obj & + .\custbox.obj .\custline.obj .\custplne.obj .\custpoly.obj .\drwcpoly.obj + +OBJS += .\arc.obj .\aspectra.obj .\bar.obj .\bar3d.obj .\bccgrx.obj & + .\bgimode.obj .\circle.obj .\clearvp.obj .\closegra.obj & + .\clrdev.obj .\detectg.obj .\drvname.obj .\egacolor.obj .\ellipse.obj & + .\errmsg.obj .\fellipse.obj .\fillpatt.obj .\fillpoly.obj .\fillstyl.obj & + .\fldfill.obj .\getbkcol.obj .\getcol.obj .\getdefpa.obj .\getfillp.obj & + .\getfills.obj .\getgramo.obj .\getimage.obj .\getmaxmo.obj .\getmoran.obj & + .\getpixel.obj .\getviewp.obj .\getx.obj .\gety.obj .\gmaxcol.obj & + .\gmmaxcol.obj .\gmmaxx.obj .\gmmaxy.obj .\gpalsize.obj .\graphres.obj & + .\imagesze.obj .\instbgid.obj .\line.obj .\linerel.obj .\lineto.obj & + .\lnestyle.obj .\modename.obj .\moverel.obj .\moveto.obj .\page1.obj & + .\page2.obj .\page3.obj .\page4.obj .\page5.obj .\page6.obj .\palette.obj & + .\pieslice.obj .\polygon.obj .\putimage.obj .\putpixel.obj .\rectang.obj & + .\regbgidr.obj .\rgbpal_g.obj .\rgbpal_s.obj .\rstcrtmd.obj .\sector.obj & + .\setbgiwh.obj .\setbkcol.obj .\setbusze.obj .\setcolor.obj .\setrgbc.obj & + .\setviewp.obj .\setwrmod.obj .\text.obj .\text1.obj .\text2.obj & + .\text3.obj .\text4.obj .\text5.obj .\text6.obj .\text7.obj .\text8.obj & + .\text9.obj .\texta.obj .\textb.obj .\textc.obj .\textd.obj .\txtlnest.obj & + .\bgiext01.obj .\bgiext01.obj + +!ifdef DEBUG +OBJS += .\dbgprint.obj +!endif +OBJS += .AUTODEPEND + +## implicit rules do not seem to work with wmake - it complains about +## no default action??? +.c.obj: + $(CC) $[@ $(CC_OPTS) + +## Rules +.\bmp.obj : .\addons\bmp\bmp.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\grxprint.obj : .\addons\print\grxprint.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\prndata.obj : .\addons\print\prndata.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bitblt.obj : .\src\draw\bitblt.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bitbltnc.obj : .\src\draw\bitbltnc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\box.obj : .\src\draw\box.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\boxnc.obj : .\src\draw\boxnc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\clearclp.obj : .\src\draw\clearclp.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\clearctx.obj : .\src\draw\clearctx.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\clearscr.obj : .\src\draw\clearscr.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\drwinlne.obj : .\src\draw\drwinlne.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillbox.obj : .\src\draw\fillbox.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillboxn.obj : .\src\draw\fillboxn.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\frambox.obj : .\src\draw\frambox.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\framboxn.obj : .\src\draw\framboxn.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getscl.obj : .\src\draw\getscl.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\line.obj : .\src\draw\line.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\linenc.obj : .\src\draw\linenc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\majorln1.obj : .\src\draw\majorln1.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\majorln2.obj : .\src\draw\majorln2.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\majorln3.obj : .\src\draw\majorln3.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\majorln4.obj : .\src\draw\majorln4.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pixel.obj : .\src\draw\pixel.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pixelc.obj : .\src\draw\pixelc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\plot.obj : .\src\draw\plot.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\putscl.obj : .\src\draw\putscl.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\dotab8.obj : .\src\fdrivers\dotab8.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ega4.obj : .\src\fdrivers\ega4.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\egavga1.obj : .\src\fdrivers\egavga1.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ftable.obj : .\src\fdrivers\ftable.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\genblit.obj : .\src\fdrivers\genblit.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\gengiscl.obj : .\src\fdrivers\gengiscl.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\genptscl.obj : .\src\fdrivers\genptscl.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\genstrch.obj : .\src\fdrivers\genstrch.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\herc1.obj : .\src\fdrivers\herc1.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\lfb16.obj : .\src\fdrivers\lfb16.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\lfb24.obj : .\src\fdrivers\lfb24.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\lfb32h.obj : .\src\fdrivers\lfb32h.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\lfb32l.obj : .\src\fdrivers\lfb32l.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\lfb8.obj : .\src\fdrivers\lfb8.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\lfbbltrv.obj : .\src\fdrivers\lfbbltrv.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\lfbbltvr.obj : .\src\fdrivers\lfbbltvr.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\lfbbltvv.obj : .\src\fdrivers\lfbbltvv.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pblitr2r.obj : .\src\fdrivers\pblitr2r.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pblitr2v.obj : .\src\fdrivers\pblitr2v.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pblitv2r.obj : .\src\fdrivers\pblitv2r.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pblitv2v.obj : .\src\fdrivers\pblitv2v.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ram1.obj : .\src\fdrivers\ram1.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ram16.obj : .\src\fdrivers\ram16.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ram24.obj : .\src\fdrivers\ram24.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ram32h.obj : .\src\fdrivers\ram32h.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ram32l.obj : .\src\fdrivers\ram32l.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ram4.obj : .\src\fdrivers\ram4.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ram8.obj : .\src\fdrivers\ram8.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\rblit_14.obj : .\src\fdrivers\rblit_14.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\svga16.obj : .\src\fdrivers\svga16.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\svga24.obj : .\src\fdrivers\svga24.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\svga32h.obj : .\src\fdrivers\svga32h.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\svga32l.obj : .\src\fdrivers\svga32l.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\svga4.obj : .\src\fdrivers\svga4.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\svga8.obj : .\src\fdrivers\svga8.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\vga8x.obj : .\src\fdrivers\vga8x.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fdtable.obj : .\src\fonts\fdtable.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fdv_bgi.obj : .\src\fonts\fdv_bgi.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fdv_grx.obj : .\src\fonts\fdv_grx.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pc6x8.obj : .\src\fonts\pc6x8.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pc8x14.obj : .\src\fonts\pc8x14.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pc8x16.obj : .\src\fonts\pc8x16.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pc8x8.obj : .\src\fonts\pc8x8.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ialloc.obj : .\src\image\ialloc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ibuild.obj : .\src\image\ibuild.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ifbox.obj : .\src\image\ifbox.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ihline.obj : .\src\image\ihline.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\iinverse.obj : .\src\image\iinverse.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\imginlne.obj : .\src\image\imginlne.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\iplot.obj : .\src\image\iplot.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\istretch.obj : .\src\image\istretch.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bldcurs.obj : .\src\mouse\bldcurs.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\dosinput.obj : .\src\mouse\dosinput.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\doskeys.obj : .\src\mouse\doskeys.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\drawcurs.obj : .\src\mouse\drawcurs.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\mouinfo.obj : .\src\mouse\mouinfo.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\mouinlne.obj : .\src\mouse\mouinlne.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\mscursor.obj : .\src\mouse\mscursor.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillpatt.obj : .\src\pattern\fillpatt.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\makepat.obj : .\src\pattern\makepat.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\patfbits.obj : .\src\pattern\patfbits.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\patfbox.obj : .\src\pattern\patfbox.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\patfcvxp.obj : .\src\pattern\patfcvxp.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\patfline.obj : .\src\pattern\patfline.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\patfplot.obj : .\src\pattern\patfplot.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\patfpoly.obj : .\src\pattern\patfpoly.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\patternf.obj : .\src\pattern\patternf.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pattfldf.obj : .\src\pattern\pattfldf.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pattline.obj : .\src\pattern\pattline.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pattpoly.obj : .\src\pattern\pattpoly.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pfcirc.obj : .\src\pattern\pfcirc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pfcirca.obj : .\src\pattern\pfcirca.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pfelli.obj : .\src\pattern\pfelli.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pfellia.obj : .\src\pattern\pfellia.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ptcirc.obj : .\src\pattern\ptcirc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ptcirca.obj : .\src\pattern\ptcirca.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ptelli.obj : .\src\pattern\ptelli.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ptellia.obj : .\src\pattern\ptellia.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\clip.obj : .\src\setup\clip.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\clrinfo.obj : .\src\setup\clrinfo.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\clrinlne.obj : .\src\setup\clrinlne.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\colorbw.obj : .\src\setup\colorbw.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\colorega.obj : .\src\setup\colorega.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\colors.obj : .\src\setup\colors.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\context.obj : .\src\setup\context.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\cxtinfo.obj : .\src\setup\cxtinfo.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\cxtinlne.obj : .\src\setup\cxtinlne.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\drvinfo.obj : .\src\setup\drvinfo.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\drvinlne.obj : .\src\setup\drvinlne.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fframe.obj : .\src\setup\fframe.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fgeom.obj : .\src\setup\fgeom.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\hooks.obj : .\src\setup\hooks.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\modewalk.obj : .\src\setup\modewalk.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\setdrvr.obj : .\src\setup\setdrvr.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\setmode.obj : .\src\setup\setmode.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\version.obj : .\src\setup\version.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\viewport.obj : .\src\setup\viewport.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\circle1.obj : .\src\shape\circle1.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\circle2.obj : .\src\shape\circle2.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\circle3.obj : .\src\shape\circle3.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\circle4.obj : .\src\shape\circle4.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\drawpoly.obj : .\src\shape\drawpoly.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillcir1.obj : .\src\shape\fillcir1.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillcir2.obj : .\src\shape\fillcir2.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillcnvx.obj : .\src\shape\fillcnvx.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillell1.obj : .\src\shape\fillell1.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillell2.obj : .\src\shape\fillell2.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillpoly.obj : .\src\shape\fillpoly.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\flood.obj : .\src\shape\flood.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\floodfil.obj : .\src\shape\floodfil.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\genellip.obj : .\src\shape\genellip.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\polygon.obj : .\src\shape\polygon.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\polyline.obj : .\src\shape\polyline.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\scancnvx.obj : .\src\shape\scancnvx.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\scanellp.obj : .\src\shape\scanellp.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\scanpoly.obj : .\src\shape\scanpoly.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\solidfil.obj : .\src\shape\solidfil.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\buildaux.obj : .\src\text\buildaux.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\buildfnt.obj : .\src\text\buildfnt.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\convfont.obj : .\src\text\convfont.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\drawstrg.obj : .\src\text\drawstrg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\drawtext.obj : .\src\text\drawtext.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\drwstrg.obj : .\src\text\drwstrg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\dumpfont.obj : .\src\text\dumpfont.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\dumptext.obj : .\src\text\dumptext.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\epatstrg.obj : .\src\text\epatstrg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fntinlne.obj : .\src\text\fntinlne.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fontinfo.obj : .\src\text\fontinfo.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fontpath.obj : .\src\text\fontpath.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\loadfont.obj : .\src\text\loadfont.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pattstrg.obj : .\src\text\pattstrg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\propwdt.obj : .\src\text\propwdt.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\unloadfn.obj : .\src\text\unloadfn.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ubox.obj : .\src\user\ubox.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ucbox.obj : .\src\user\ucbox.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uccirc.obj : .\src\user\uccirc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uccirca.obj : .\src\user\uccirca.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ucelli.obj : .\src\user\ucelli.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ucellia.obj : .\src\user\ucellia.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ucirc.obj : .\src\user\ucirc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ucirca.obj : .\src\user\ucirca.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ucircf.obj : .\src\user\ucircf.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ucircfa.obj : .\src\user\ucircfa.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ucline.obj : .\src\user\ucline.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ucpolyg.obj : .\src\user\ucpolyg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ucpolyl.obj : .\src\user\ucpolyl.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\udrwchar.obj : .\src\user\udrwchar.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\udrwstrg.obj : .\src\user\udrwstrg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uelli.obj : .\src\user\uelli.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uellia.obj : .\src\user\uellia.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uellif.obj : .\src\user\uellif.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uellifa.obj : .\src\user\uellifa.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ufcpolyg.obj : .\src\user\ufcpolyg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ufillbox.obj : .\src\user\ufillbox.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uflood.obj : .\src\user\uflood.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ufpolyg.obj : .\src\user\ufpolyg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uframbox.obj : .\src\user\uframbox.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ugetwin.obj : .\src\user\ugetwin.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uhline.obj : .\src\user\uhline.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uline.obj : .\src\user\uline.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upbox.obj : .\src\user\upbox.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upcirc.obj : .\src\user\upcirc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upcirca.obj : .\src\user\upcirca.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upelli.obj : .\src\user\upelli.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upellia.obj : .\src\user\upellia.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upfbox.obj : .\src\user\upfbox.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upfcirc.obj : .\src\user\upfcirc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upfcirca.obj : .\src\user\upfcirca.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upfcpoly.obj : .\src\user\upfcpoly.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upfelli.obj : .\src\user\upfelli.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upfellia.obj : .\src\user\upfellia.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upfflood.obj : .\src\user\upfflood.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upfline.obj : .\src\user\upfline.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upfplot.obj : .\src\user\upfplot.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upfpolyg.obj : .\src\user\upfpolyg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upixel.obj : .\src\user\upixel.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upixelc.obj : .\src\user\upixelc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upline.obj : .\src\user\upline.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uplot.obj : .\src\user\uplot.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upolygon.obj : .\src\user\upolygon.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\upolylin.obj : .\src\user\upolylin.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uppolyg.obj : .\src\user\uppolyg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uppolyl.obj : .\src\user\uppolyl.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\usercord.obj : .\src\user\usercord.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\usetwin.obj : .\src\user\usetwin.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\utextxy.obj : .\src\user\utextxy.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\uvline.obj : .\src\user\uvline.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ordswap.obj : .\src\utils\ordswap.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\resize.obj : .\src\utils\resize.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\shiftscl.obj : .\src\utils\shiftscl.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\strmatch.obj : .\src\utils\strmatch.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\tmpbuff.obj : .\src\utils\tmpbuff.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\watcom32.obj : .\src\utils\watcom32.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ati28800.obj : .\src\vdrivers\ati28800.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\cl5426.obj : .\src\vdrivers\cl5426.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\et4000.obj : .\src\vdrivers\et4000.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\herc.obj : .\src\vdrivers\herc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\mach64.obj : .\src\vdrivers\mach64.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\s3.obj : .\src\vdrivers\s3.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\stdega.obj : .\src\vdrivers\stdega.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\stdvga.obj : .\src\vdrivers\stdvga.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\u_egavga.obj : .\src\vdrivers\u_egavga.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\u_vesa.obj : .\src\vdrivers\u_vesa.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\u_vsvirt.obj : .\src\vdrivers\u_vsvirt.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\vd_mem.obj : .\src\vdrivers\vd_mem.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\vesa.obj : .\src\vdrivers\vesa.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\vtable.obj : .\src\vdrivers\vtable.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ccirc.obj : .\src\wideline\ccirc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ccirca.obj : .\src\wideline\ccirca.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\celli.obj : .\src\wideline\celli.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\cellia.obj : .\src\wideline\cellia.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\custbox.obj : .\src\wideline\custbox.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\custline.obj : .\src\wideline\custline.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\custplne.obj : .\src\wideline\custplne.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\custpoly.obj : .\src\wideline\custpoly.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\drwcpoly.obj : .\src\wideline\drwcpoly.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\dbgprint.obj : .\src\utils\dbgprint.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\arc.obj : .\src\bgi\arc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\aspectra.obj : .\src\bgi\aspectra.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bar.obj : .\src\bgi\bar.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bar3d.obj : .\src\bgi\bar3d.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bccgrx.obj : .\src\bgi\bccgrx.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bgimode.obj : .\src\bgi\bgimode.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\circle.obj : .\src\bgi\circle.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\clearvp.obj : .\src\bgi\clearvp.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\closegra.obj : .\src\bgi\closegra.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\clrdev.obj : .\src\bgi\clrdev.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\detectg.obj : .\src\bgi\detectg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\drvname.obj : .\src\bgi\drvname.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\egacolor.obj : .\src\bgi\egacolor.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ellipse.obj : .\src\bgi\ellipse.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\errmsg.obj : .\src\bgi\errmsg.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fellipse.obj : .\src\bgi\fellipse.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillpatt.obj : .\src\bgi\fillpatt.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillpoly.obj : .\src\bgi\fillpoly.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fillstyl.obj : .\src\bgi\fillstyl.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fldfill.obj : .\src\bgi\fldfill.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getbkcol.obj : .\src\bgi\getbkcol.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getcol.obj : .\src\bgi\getcol.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getdefpa.obj : .\src\bgi\getdefpa.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getfillp.obj : .\src\bgi\getfillp.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getfills.obj : .\src\bgi\getfills.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getgramo.obj : .\src\bgi\getgramo.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getimage.obj : .\src\bgi\getimage.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getmaxmo.obj : .\src\bgi\getmaxmo.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getmoran.obj : .\src\bgi\getmoran.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getpixel.obj : .\src\bgi\getpixel.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getviewp.obj : .\src\bgi\getviewp.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\getx.obj : .\src\bgi\getx.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\gety.obj : .\src\bgi\gety.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\gmaxcol.obj : .\src\bgi\gmaxcol.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\gmmaxcol.obj : .\src\bgi\gmmaxcol.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\gmmaxx.obj : .\src\bgi\gmmaxx.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\gmmaxy.obj : .\src\bgi\gmmaxy.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\gpalsize.obj : .\src\bgi\gpalsize.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\graphres.obj : .\src\bgi\graphres.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\imagesze.obj : .\src\bgi\imagesze.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\instbgid.obj : .\src\bgi\instbgid.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\line.obj : .\src\bgi\line.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\linerel.obj : .\src\bgi\linerel.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\lineto.obj : .\src\bgi\lineto.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\lnestyle.obj : .\src\bgi\lnestyle.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\modename.obj : .\src\bgi\modename.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\moverel.obj : .\src\bgi\moverel.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\moveto.obj : .\src\bgi\moveto.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\page1.obj : .\src\bgi\page1.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\page2.obj : .\src\bgi\page2.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\page3.obj : .\src\bgi\page3.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\page4.obj : .\src\bgi\page4.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\page5.obj : .\src\bgi\page5.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\page6.obj : .\src\bgi\page6.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\palette.obj : .\src\bgi\palette.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pieslice.obj : .\src\bgi\pieslice.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\polygon.obj : .\src\bgi\polygon.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\putimage.obj : .\src\bgi\putimage.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\putpixel.obj : .\src\bgi\putpixel.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\rectang.obj : .\src\bgi\rectang.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\regbgidr.obj : .\src\bgi\regbgidr.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\rgbpal_g.obj : .\src\bgi\rgbpal_g.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\rgbpal_s.obj : .\src\bgi\rgbpal_s.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\rstcrtmd.obj : .\src\bgi\rstcrtmd.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\sector.obj : .\src\bgi\sector.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\setbgiwh.obj : .\src\bgi\setbgiwh.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\setbkcol.obj : .\src\bgi\setbkcol.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\setbusze.obj : .\src\bgi\setbusze.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\setcolor.obj : .\src\bgi\setcolor.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\setrgbc.obj : .\src\bgi\setrgbc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\setviewp.obj : .\src\bgi\setviewp.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\setwrmod.obj : .\src\bgi\setwrmod.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\text.obj : .\src\bgi\text.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\text1.obj : .\src\bgi\text1.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\text2.obj : .\src\bgi\text2.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\text3.obj : .\src\bgi\text3.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\text4.obj : .\src\bgi\text4.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\text5.obj : .\src\bgi\text5.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\text6.obj : .\src\bgi\text6.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\text7.obj : .\src\bgi\text7.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\text8.obj : .\src\bgi\text8.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\text9.obj : .\src\bgi\text9.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\texta.obj : .\src\bgi\texta.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\textb.obj : .\src\bgi\textb.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\textc.obj : .\src\bgi\textc.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\textd.obj : .\src\bgi\textd.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\txtlnest.obj : .\src\bgi\txtlnest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bgiext01.obj : .\src\bgi\bgiext01.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bgiext02.obj : .\src\bgi\bgiext02.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +## wat32mak.lb1 is a text file with the names of all the object files +## this gets around DOS command line length limit + +$(GRXLIB) : $(OBJS) + %create wat32mak.lb1 +!ifneq BLANK "bmp.obj grxprint.obj prndata.obj bitblt.obj bitbltnc.obj & +box.obj boxnc.obj clearclp.obj clearctx.obj clearscr.obj drwinlne.obj & +fillbox.obj fillboxn.obj frambox.obj framboxn.obj getscl.obj line.obj & +linenc.obj majorln1.obj majorln2.obj majorln3.obj majorln4.obj pixel.obj & +pixelc.obj plot.obj putscl.obj dotab8.obj ega4.obj egavga1.obj ftable.obj & +genblit.obj gengiscl.obj genptscl.obj genstrch.obj herc1.obj lfb16.obj & +lfb24.obj lfb32h.obj lfb32l.obj lfb8.obj lfbbltrv.obj lfbbltvr.obj & +lfbbltvv.obj pblitr2r.obj pblitr2v.obj pblitv2r.obj pblitv2v.obj ram1.obj & +ram16.obj ram24.obj ram32h.obj ram32l.obj ram4.obj ram8.obj rblit_14.obj & +svga16.obj svga24.obj svga32h.obj svga32l.obj svga4.obj svga8.obj vga8x.obj & +fdtable.obj fdv_bgi.obj fdv_grx.obj pc6x8.obj pc8x14.obj pc8x16.obj & +pc8x8.obj ialloc.obj ibuild.obj ifbox.obj ihline.obj iinverse.obj & +imginlne.obj iplot.obj istretch.obj bldcurs.obj dosinput.obj doskeys.obj & +drawcurs.obj mouinfo.obj mouinlne.obj mscursor.obj fillpatt.obj makepat.obj & +patfbits.obj patfbox.obj patfcvxp.obj patfline.obj patfplot.obj & +patfpoly.obj patternf.obj pattfldf.obj pattline.obj pattpoly.obj pfcirc.obj & +pfcirca.obj pfelli.obj pfellia.obj ptcirc.obj ptcirca.obj ptelli.obj & +ptellia.obj clip.obj clrinfo.obj clrinlne.obj colorbw.obj colorega.obj & +colors.obj context.obj cxtinfo.obj cxtinlne.obj drvinfo.obj drvinlne.obj & +fframe.obj fgeom.obj hooks.obj modewalk.obj setdrvr.obj setmode.obj & +version.obj viewport.obj circle1.obj circle2.obj circle3.obj circle4.obj & +drawpoly.obj fillcir1.obj fillcir2.obj fillcnvx.obj fillell1.obj & +fillell2.obj fillpoly.obj flood.obj floodfil.obj genellip.obj polygon.obj & +polyline.obj scancnvx.obj scanellp.obj scanpoly.obj solidfil.obj & +buildaux.obj buildfnt.obj convfont.obj drawstrg.obj drawtext.obj & +drwstrg.obj dumpfont.obj dumptext.obj epatstrg.obj fntinlne.obj & +fontinfo.obj fontpath.obj loadfont.obj pattstrg.obj propwdt.obj & +unloadfn.obj ubox.obj ucbox.obj uccirc.obj uccirca.obj ucelli.obj & +ucellia.obj ucirc.obj ucirca.obj ucircf.obj ucircfa.obj ucline.obj & +ucpolyg.obj ucpolyl.obj udrwchar.obj udrwstrg.obj uelli.obj uellia.obj & +uellif.obj uellifa.obj ufcpolyg.obj ufillbox.obj uflood.obj ufpolyg.obj & +uframbox.obj ugetwin.obj uhline.obj uline.obj upbox.obj upcirc.obj & +upcirca.obj upelli.obj upellia.obj upfbox.obj upfcirc.obj upfcirca.obj & +upfcpoly.obj upfelli.obj upfellia.obj upfflood.obj upfline.obj upfplot.obj & +upfpolyg.obj upixel.obj upixelc.obj upline.obj uplot.obj upolygon.obj & +upolylin.obj uppolyg.obj uppolyl.obj usercord.obj usetwin.obj utextxy.obj & +uvline.obj ordswap.obj resize.obj shiftscl.obj strmatch.obj tmpbuff.obj & +watcom32.obj ati28800.obj cl5426.obj et4000.obj herc.obj mach64.obj s3.obj & +stdega.obj stdvga.obj u_egavga.obj u_vesa.obj u_vsvirt.obj vd_mem.obj & +vesa.obj vtable.obj ccirc.obj ccirca.obj celli.obj cellia.obj custbox.obj & +custline.obj custplne.obj custpoly.obj drwcpoly.obj" + @for %i in (bmp.obj grxprint.obj prndata.obj bitblt.obj bitbltnc.obj & +box.obj boxnc.obj clearclp.obj clearctx.obj clearscr.obj drwinlne.obj & +fillbox.obj fillboxn.obj frambox.obj framboxn.obj getscl.obj line.obj & +linenc.obj majorln1.obj majorln2.obj majorln3.obj majorln4.obj pixel.obj & +pixelc.obj plot.obj putscl.obj dotab8.obj ega4.obj egavga1.obj ftable.obj & +genblit.obj gengiscl.obj genptscl.obj genstrch.obj herc1.obj lfb16.obj & +lfb24.obj lfb32h.obj lfb32l.obj lfb8.obj lfbbltrv.obj lfbbltvr.obj & +lfbbltvv.obj pblitr2r.obj pblitr2v.obj pblitv2r.obj pblitv2v.obj ram1.obj & +ram16.obj ram24.obj ram32h.obj ram32l.obj ram4.obj ram8.obj rblit_14.obj & +svga16.obj svga24.obj svga32h.obj svga32l.obj svga4.obj svga8.obj vga8x.obj & +fdtable.obj fdv_bgi.obj fdv_grx.obj pc6x8.obj pc8x14.obj pc8x16.obj & +pc8x8.obj ialloc.obj ibuild.obj ifbox.obj ihline.obj iinverse.obj & +imginlne.obj iplot.obj istretch.obj bldcurs.obj dosinput.obj doskeys.obj & +drawcurs.obj mouinfo.obj mouinlne.obj mscursor.obj fillpatt.obj makepat.obj & +patfbits.obj patfbox.obj patfcvxp.obj patfline.obj patfplot.obj & +patfpoly.obj patternf.obj pattfldf.obj pattline.obj pattpoly.obj pfcirc.obj & +pfcirca.obj pfelli.obj pfellia.obj ptcirc.obj ptcirca.obj ptelli.obj & +ptellia.obj clip.obj clrinfo.obj clrinlne.obj colorbw.obj colorega.obj & +colors.obj context.obj cxtinfo.obj cxtinlne.obj drvinfo.obj drvinlne.obj & +fframe.obj fgeom.obj hooks.obj modewalk.obj setdrvr.obj setmode.obj & +version.obj viewport.obj circle1.obj circle2.obj circle3.obj circle4.obj & +drawpoly.obj fillcir1.obj fillcir2.obj fillcnvx.obj fillell1.obj & +fillell2.obj fillpoly.obj flood.obj floodfil.obj genellip.obj polygon.obj & +polyline.obj scancnvx.obj scanellp.obj scanpoly.obj solidfil.obj & +buildaux.obj buildfnt.obj convfont.obj drawstrg.obj drawtext.obj & +drwstrg.obj dumpfont.obj dumptext.obj epatstrg.obj fntinlne.obj & +fontinfo.obj fontpath.obj loadfont.obj pattstrg.obj propwdt.obj & +unloadfn.obj ubox.obj ucbox.obj uccirc.obj uccirca.obj ucelli.obj & +ucellia.obj ucirc.obj ucirca.obj ucircf.obj ucircfa.obj ucline.obj & +ucpolyg.obj ucpolyl.obj udrwchar.obj udrwstrg.obj uelli.obj uellia.obj & +uellif.obj uellifa.obj ufcpolyg.obj ufillbox.obj uflood.obj ufpolyg.obj & +uframbox.obj ugetwin.obj uhline.obj uline.obj upbox.obj upcirc.obj & +upcirca.obj upelli.obj upellia.obj upfbox.obj upfcirc.obj upfcirca.obj & +upfcpoly.obj upfelli.obj upfellia.obj upfflood.obj upfline.obj upfplot.obj & +upfpolyg.obj upixel.obj upixelc.obj upline.obj uplot.obj upolygon.obj & +upolylin.obj uppolyg.obj uppolyl.obj usercord.obj usetwin.obj utextxy.obj & +uvline.obj ordswap.obj resize.obj shiftscl.obj strmatch.obj tmpbuff.obj & +watcom32.obj ati28800.obj cl5426.obj et4000.obj herc.obj mach64.obj s3.obj & +stdega.obj stdvga.obj u_egavga.obj u_vesa.obj u_vsvirt.obj vd_mem.obj & +vesa.obj vtable.obj ccirc.obj ccirca.obj celli.obj cellia.obj custbox.obj & +arc.obj aspectra.obj bar.obj bar3d.obj bccgrx.obj bgimode.obj circle.obj & +clearvp.obj closegra.obj clrdev.obj detectg.obj drvname.obj egacolor.obj & +ellipse.obj errmsg.obj fellipse.obj fillpatt.obj fillpoly.obj fillstyl.obj & +fldfill.obj getbkcol.obj getcol.obj getdefpa.obj getfillp.obj getfills.obj & +getgramo.obj getimage.obj getmaxmo.obj getmoran.obj getpixel.obj & +getviewp.obj getx.obj gety.obj gmaxcol.obj gmmaxcol.obj gmmaxx.obj & +gmmaxy.obj gpalsize.obj graphres.obj imagesze.obj instbgid.obj line.obj & +linerel.obj lineto.obj lnestyle.obj modename.obj moverel.obj moveto.obj & +page1.obj page2.obj page3.obj page4.obj page5.obj page6.obj palette.obj & +pieslice.obj polygon.obj putimage.obj putpixel.obj rectang.obj regbgidr.obj & +rgbpal_g.obj rgbpal_s.obj rstcrtmd.obj sector.obj \setbgiwh.obj setbkcol.obj & +setbusze.obj setcolor.obj setrgbc.obj setviewp.obj setwrmod.obj text.obj & +text1.obj text2.obj text3.obj text4.obj text5.obj text6.obj text7.obj & +text8.obj text9.obj texta.obj textb.obj textc.obj textd.obj txtlnest.obj & +bgiext01.obj bgiext02.obj custline.obj custplne.obj custpoly.obj drwcpoly.obj& +) do @%append wat32mak.lb1 +'%i' +!endif +!ifdef DEBUG + @for %i in (dbgprint.obj) do @%append wat32mak.lb1 +'%i' +!endif +!ifneq BLANK "" + @for %i in () do @%append wat32mak.lb1 +'%i' +!endif + $(LIB) $(LIB_OPTS) $(GRXLIB) @wat32mak.lb1 diff --git a/thirdparty/grx249/src/makefile.x11 b/thirdparty/grx249/src/makefile.x11 new file mode 100644 index 0000000..7fbcebc --- /dev/null +++ b/thirdparty/grx249/src/makefile.x11 @@ -0,0 +1,277 @@ +# +# Library Makefile for LINUX/X11. Uses GNU Make. +# +# set up for GCC / Linux +# +.PHONY : libst libsh clean cleanall install uninstall setsuid \ + install-bin uninstall-bin install-fonts uninstall-fonts \ + install-info uninstall-info + +GRXVX11=y + +include ../makedefs.grx + +INCDIR= -I. -I./include -I../include $(X11INCS) + +ifdef GRX_DEFAULT_FONT_PATH +CCOPT += -DGRX_DEFAULT_FONT_PATH=\"$(GRX_DEFAULT_FONT_PATH)\" +endif + +ifeq ($(USE_XF86DGA_DRIVER),y) +CCOPT += -DXF86DGA_DRIVER +endif + +ifeq ($(USE_XF86DGA_FRAMEBUFFER),y) +CCOPT += -DXF86DGA_FRAMEBUFFER +endif + +ifeq ($(SET_XSUIDROOT),y) +EXECBITS = 4755 +else +EXECBITS = 0755 +endif + +ADDON_LIBS = + +ifeq ($(USE_XF86DGA_DRIVER),y) + ADDON_LIBS += -lXxf86dga -lXext +endif + +GRX20ST = ../lib/$(GRX_LIB_SUBDIR)/libgrx20X.a + +GRX20SH = ../lib/$(GRX_LIB_SUBDIR)/libgrx20X.so +GRX20SHli = $(GRX20SH).$(word 1,$(subst ., ,$(GRX_VERSION))) +GRX20SHna = $(GRX20SH).$(GRX_VERSION) +SHCCOPT = -fPIC -D__SHARED__ + +OX=.o +OP= + +include ./stdobjs.mak + +STD_O= $(STD_1) $(STD_2) $(STD_3) $(STD_4) \ + $(STD_5) $(STD_6) $(STD_7) $(STD_8) \ + $(STD_9) $(STD_10) $(STD_11) $(STD_12)\ + +BGI_O= $(BGI_1) $(BGI_2) $(BGI_3) $(BGI_4) \ + $(BGI_5) $(BGI_6) + +ADDON_O= + +ifdef DEBUG + ADDON_O += $(DBG_1) +endif + +ifeq ($(HAVE_LIBTIFF),y) + ADDON_O += $(TIF_1) +endif + +ifeq ($(HAVE_LIBJPEG),y) + ADDON_O += $(JPG_1) +else + ADDON_O += $(NOJPG_1) +endif + +ifeq ($(HAVE_LIBPNG),y) + ADDON_O += $(PNG_1) +else + ADDON_O += $(NOPNG_1) +endif + +ifeq ($(INCLUDE_PRINTING_CODE),y) + ADDON_O += $(PRN_1) + INCDIR += -I../addons/print +ifeq ($(INCLUDE_BGI_SUPPORT),y) + BGI_O += $(PRNBGI_1) +endif +endif + +ifeq ($(INCLUDE_BMP_CODE),y) + ADDON_O += $(BMP_1) + INCDIR += -I../addons/bmp +endif + +O= $(STD_O) \ + $(ADDON_O) \ + fdrivers/fd_xwin.o \ + fdrivers/ram24.o \ + fdrivers/ram32l.o \ + fdrivers/ram32h.o \ + fonts/fdv_xwin.o \ + mouse/xwininp.o \ + mouse/xwinkeys.o \ + misc/x11misc.o \ + vdrivers/vd_xwin.o + +ifeq ($(USE_XF86DGA_DRIVER),y) +O+= fdrivers/lfb16.o \ + fdrivers/lfb24.o \ + fdrivers/lfb32h.o \ + fdrivers/lfb32l.o \ + fdrivers/lfb8.o \ + fdrivers/lfbbltrv.o \ + fdrivers/lfbbltvr.o \ + fdrivers/lfbbltvv.o \ + vdrivers/vd_xfdga.o +endif + +ifeq ($(INCLUDE_BGI_SUPPORT),y) + O += $(BGI_O) +endif + +LO = $(subst $(OX),.lo,$(O)) + +UTILP = ../bin/bin2c \ + ../bin/fnt2c + +UTILPX= ../bin/xmodetest + +all: libst libsh $(UTILP) $(UTILPX) + +libst: $(GRX20ST) + +$(GRX20ST): $(LINUX_i386_X11) $(O) + -rm -f $(GRX20ST) + $(AR) -r $(GRX20ST) $(O) + $(RANLIB) $(GRX20ST) + +ifeq ($(INCLUDE_SHARED_SUPPORT),y) +libsh: $(GRX20SHna) +else +libsh: +endif + +$(GRX20SHna): $(LINUX_i386_X11) $(LO) + -rm -f $(GRX20SHna) + $(CC) $(LDOPT) -shared -Wl,-soname,$(notdir $(GRX20SHli)) -o $(GRX20SHna) $(LO) + ln -sf $(notdir $(GRX20SHna)) $(GRX20SHli) + +$(UTILP): ../bin/% : utilprog/%.o $(GRX20ST) + $(CC) $(LDOPT) -o $@ utilprog/$*.o $(GRX20ST) $(X11LIBS) + $(STRIP) $@ + +$(UTILPX): ../bin/x% : utilprog/%.o $(GRX20ST) + $(CC) $(LDOPT) -o $@ utilprog/$*.o $(GRX20ST) $(ADDON_LIBS) $(X11LIBS) + $(STRIP) $@ + chmod $(EXECBITS) $@ + +$(O): $(LINUX_i386_X11) + +$(LO): $(LINUX_i386_X11) + +$(LINUX_i386_X11): + -if [ ! -r $(LINUX_i386_X11) ]; then \ + rm -f $(SYSTEM_TAG_PREFIX).* $(O) $(LO) utilprog/*.o; fi + touch $(LINUX_i386_X11) + +clean: + rm -f $(O) $(LO) $(LINUX_i386_X11) + rm -f utilprog/*.o + +cleanall: clean +ifeq ($(INCLUDE_SHARED_SUPPORT),y) + rm -f $(GRX20SHna) $(GRX20SHli) +endif + rm -f $(GRX20ST) + rm -f $(UTILP) $(UTILPX) + +install: libst libsh + install -m 0755 -d $(DESTDIR)$(libdir) + install -m 0755 -d $(DESTDIR)$(includedir) + install -m 0644 $(GRX20ST) $(DESTDIR)$(libdir) +ifeq ($(INCLUDE_SHARED_SUPPORT),y) + install -m 0755 $(GRX20SHna) $(DESTDIR)$(libdir) + ln -sf $(notdir $(GRX20SHna)) $(DESTDIR)$(libdir)/$(notdir $(GRX20SHli)) + ln -sf $(notdir $(GRX20SHli)) $(DESTDIR)$(libdir)/$(notdir $(GRX20SH)) +endif + install -m 0644 ../include/grx20.h $(DESTDIR)$(includedir) + install -m 0644 ../include/grxkeys.h $(DESTDIR)$(includedir) + install -m 0644 ../include/libbcc.h $(DESTDIR)$(includedir) +ifeq ($(INCLUDE_PRINTING_CODE),y) + install -m 0644 ../addons/print/grxprint.h $(DESTDIR)$(includedir) +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + install -m 0755 -d $(DESTDIR)$(unitsdir) + install -m 0644 ../pascal/grx.pas $(DESTDIR)$(unitsdir) + install -m 0644 ../pascal/bgi/graph.pas $(DESTDIR)$(unitsdir) +endif + +uninstall: + rm -f $(DESTDIR)$(libdir)/$(notdir $(GRX20ST)) +ifeq ($(INCLUDE_SHARED_SUPPORT),y) + rm -f $(DESTDIR)$(libdir)/$(notdir $(GRX20SH)) + rm -f $(DESTDIR)$(libdir)/$(notdir $(GRX20SHli)) + rm -f $(DESTDIR)$(libdir)/$(notdir $(GRX20SHna)) +endif + rm -f $(DESTDIR)$(includedir)/grx20.h + rm -f $(DESTDIR)$(includedir)/grxkeys.h + rm -f $(DESTDIR)$(includedir)/libbcc.h +ifeq ($(INCLUDE_PRINTING_CODE),y) + rm -f $(DESTDIR)$(includedir)/grxprint.h +endif +ifeq ($(INCLUDE_GPC_SUPPORT),y) + rm -f $(DESTDIR)$(unitsdir)/grx.pas + rm -f $(DESTDIR)$(unitsdir)/graph.pas +endif + +setsuid: $(UTILPX) +ifeq ($(SET_XSUIDROOT),y) + chown root ../bin/modetest + chmod $(EXECBITS) ../bin/modetest +else + @echo "Nothing to do, SET_XSUIDROOT is not set to 'y' in makedefs.grx" +endif + +install-info: + install -m 0755 -d $(DESTDIR)$(infodir) + install -m 0644 ../doc/grx*um.inf $(DESTDIR)$(infodir)/grx.info + for info_dir_file in $(DESTDIR)$(infodir)/dir /etc/info-dir; do \ + if [ -w $$info_dir_file ]; then \ + install-info --dir-file=$$info_dir_file $(DESTDIR)$(infodir)/grx.info; \ + fi; \ + done + +uninstall-info: + for info_dir_file in $(DESTDIR)$(infodir)/dir /etc/info-dir; do \ + if [ -w $$info_dir_file ]; then \ + install-info --dir-file=$$info_dir_file -r grx; \ + fi; \ + done + rm -f $(DESTDIR)$(infodir)/grx.info + +install-bin: $(UTILP) $(UTILPX) + install -m 0755 -d $(DESTDIR)$(bindir) + install -m 0755 ../bin/bin2c $(DESTDIR)$(bindir) + install -m 0755 ../bin/fnt2c $(DESTDIR)$(bindir) + install -m $(EXECBITS) ../bin/xmodetest $(DESTDIR)$(bindir) + +uninstall-bin: + rm -f $(DESTDIR)$(bindir)/bin2c + rm -f $(DESTDIR)$(bindir)/fnt2c + rm -f $(DESTDIR)$(bindir)/xmodetest + +ifdef GRX_DEFAULT_FONT_PATH +install-fonts: + install -m 0755 -d $(DESTDIR)$(GRX_DEFAULT_FONT_PATH) + install -m 0644 ../fonts/* $(DESTDIR)$(GRX_DEFAULT_FONT_PATH) +uninstall-fonts: + rm -f $(DESTDIR)$(GRX_DEFAULT_FONT_PATH)/* +endif + +dep: + $(CC) -MM $(CCOPT) $(INCDIR) $(O:.o=.c) \ + | sed 's#^.*: \(.*\)\.c#\1.o: \1.c#g' >depend.x11 + +$(O): %.o : %.c + $(CC) -c $(CCOPT) -D__XWIN__ $(INCDIR) $*.c -o $*.o + +$(LO): %.lo : %.c + $(CC) -c $(CCOPT) $(SHCCOPT) -D__XWIN__ $(INCDIR) $*.c -o $*.lo + +.c.s: + $(CC) -S $(CCOPT) -D__XWIN__ $(INCDIR) $*.c -o $*.s + +.c.o: + $(CC) -c $(CCOPT) -D__XWIN__ $(INCDIR) $*.c -o $*.o + +include depend.x11 diff --git a/thirdparty/grx249/src/misc/dosmisc.c b/thirdparty/grx249/src/misc/dosmisc.c new file mode 100644 index 0000000..bb4ec1a --- /dev/null +++ b/thirdparty/grx249/src/misc/dosmisc.c @@ -0,0 +1,33 @@ +/** + ** dosmisc.c - miscellaneous functions for DOS + ** + ** Copyright (C) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "libgrx.h" + +void GrSetWindowTitle( char *title ) +{ +} + +void GrSleep( int msec ) +{ + delay( msec ); +} + +void GrFlush( void) +{ +} diff --git a/thirdparty/grx249/src/misc/lnxmisc.c b/thirdparty/grx249/src/misc/lnxmisc.c new file mode 100644 index 0000000..5172f8c --- /dev/null +++ b/thirdparty/grx249/src/misc/lnxmisc.c @@ -0,0 +1,33 @@ +/** + ** lnxmisc.c - miscellaneous functions for Linux console + ** + ** Copyright (C) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "libgrx.h" + +void GrSetWindowTitle( char *title ) +{ +} + +void GrSleep( int msec ) +{ + usleep( msec*1000L ); +} + +void GrFlush( void) +{ +} diff --git a/thirdparty/grx249/src/misc/sdlmisc.c b/thirdparty/grx249/src/misc/sdlmisc.c new file mode 100644 index 0000000..ef48602 --- /dev/null +++ b/thirdparty/grx249/src/misc/sdlmisc.c @@ -0,0 +1,34 @@ +/** + ** sdlmisc.c - miscellaneous functions for SDL + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include + +void GrSetWindowTitle(char *title) +{ + SDL_WM_SetCaption(title, NULL); +} + +void GrSleep(int msec) +{ + SDL_Delay(msec); +} + +void GrFlush( void) +{ +} diff --git a/thirdparty/grx249/src/misc/w32misc.c b/thirdparty/grx249/src/misc/w32misc.c new file mode 100644 index 0000000..ae7ef8e --- /dev/null +++ b/thirdparty/grx249/src/misc/w32misc.c @@ -0,0 +1,35 @@ +/** + ** w32misc.c - miscellaneous functions for Win32 + ** + ** Copyright (C) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "libwin32.h" + +void GrSetWindowTitle( char *title ) +{ + SetWindowText( hGRXWnd,title ); +} + +void GrSleep( int msec ) +{ + Sleep( msec ); +} + +void GrFlush( void) +{ +} + diff --git a/thirdparty/grx249/src/misc/x11misc.c b/thirdparty/grx249/src/misc/x11misc.c new file mode 100644 index 0000000..00f08f2 --- /dev/null +++ b/thirdparty/grx249/src/misc/x11misc.c @@ -0,0 +1,39 @@ +/** + ** x11misc.c - miscellaneous functions for X11 + ** + ** Copyright (C) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "libgrx.h" +#include "libxwin.h" +#include "mouse/input.h" + +void GrSetWindowTitle( char *title ) +{ + XStoreName( _XGrDisplay,_XGrWindow,title ); + XSetIconName( _XGrDisplay,_XGrWindow,title ); +} + +void GrSleep( int msec ) +{ + usleep( msec*1000L ); +} + +void GrFlush( void ) +{ + _GrUpdateInputs(); + XFlush(_XGrDisplay); +} diff --git a/thirdparty/grx249/src/mouse/bldcurs.c b/thirdparty/grx249/src/mouse/bldcurs.c new file mode 100644 index 0000000..44001a2 --- /dev/null +++ b/thirdparty/grx249/src/mouse/bldcurs.c @@ -0,0 +1,65 @@ +/** + ** bldcurs.c ---- create and destroy cursor data structures + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "memfill.h" + +GrCursor *GrBuildCursor(char far *pixels,int pitch,int w,int h,int xo,int yo,const GrColorTableP C) +{ + GrCursor *curs; + GrContext save; + int wrkw2 = (w + 7) & ~7; + int workw = wrkw2 << 1; + int workh = ((h + 7) & ~7) << 1; + int xx,yy; + curs = malloc(sizeof(GrCursor)); + if(!curs) return(NULL); + sttzero(curs); + if(!GrCreateContext(workw,((workh << 1) + h),NULL,&curs->work)) { + free(curs); + return(NULL); + } + curs->xsize = w; + curs->ysize = h; + curs->xoffs = xo; + curs->yoffs = yo; + curs->xwork = workw; + curs->ywork = workh; + GrSaveContext(&save); + GrSetContext(&curs->work); + GrFilledBoxNC(0,0,(workw - 1),(h - 1),0L); + for(yy = 0; yy < h; yy++) { + unsigned char far *p = (unsigned char far *)pixels + (yy * pitch); + for(xx = 0; xx < w; xx++,p++) { + if(*p) GrPlotNC(xx,yy,GrColorValue(GR_CTABLE_COLOR(C,(*p - 1)))); + else GrPlotNC((xx + wrkw2),yy,GrColorValue(-1L)); + } + } + GrSetContext(&save); + return(curs); +} + +void GrDestroyCursor(GrCursor *cursor) +{ + if(cursor && (cursor != MOUINFO->cursor)) { + GrEraseCursor(cursor); + GrDestroyContext(&cursor->work); + free(cursor); + } +} diff --git a/thirdparty/grx249/src/mouse/dosinput.c b/thirdparty/grx249/src/mouse/dosinput.c new file mode 100644 index 0000000..3022bb8 --- /dev/null +++ b/thirdparty/grx249/src/mouse/dosinput.c @@ -0,0 +1,212 @@ +/** + ** dosinput.c ---- polled mode mouse and keyboard interface for DOS + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include + +#if defined(__TURBOC__) || defined(__WATCOMC__) /* GS - Watcom C++ 11.0 */ +#include +#endif + +#ifdef __DJGPP__ +#include +#endif + +#include "libgrx.h" +#include "grxkeys.h" +#include "allocate.h" +#include "arith.h" +#include "int86.h" +#include "memcopy.h" +#include "memfill.h" +#include "mouse/input.h" + +static int kbd_enabled = TRUE; +static int mou_enabled = TRUE; +static int mou_buttons = 0; +static long evt_lasttime; + +static void uninit(void) +{ + if(MOUINFO->msstatus > 1) MOUINFO->msstatus = 1; +} + +int GrMouseDetect(void) +{ + Int86Regs r; + if(MOUINFO->msstatus == 0) { + MOUINFO->msstatus = (-1); /* assume missing */ + sttzero(&r); + int33(&r); + if(IREG_AX(r) != 0) { + atexit(uninit); + MOUINFO->msstatus = 1; /* present, but not initted */ + } + } + return((MOUINFO->msstatus > 0) ? TRUE : FALSE); +} + +void GrMouseInitN(int queue_size) +{ + uninit(); + queue_size = umax(4,umin(256,queue_size)); + init_queue(queue_size); + if(GrMouseDetect()) { + GrMouseSetSpeed(1,1); + GrMouseSetAccel(100,1); + GrMouseSetLimits(0,0,SCRN->gc_xmax,SCRN->gc_ymax); + GrMouseWarp((SCRN->gc_xmax >> 1),(SCRN->gc_ymax >> 1)); + _GrInitMouseCursor(); + MOUINFO->msstatus = 2; + mou_buttons = 0; + } + GrMouseEventEnable(TRUE,TRUE); + real_time(evt_lasttime); + MOUINFO->uninit = uninit; +} + +void GrMouseSetSpeed(int spmult,int spdiv) +{ + MOUINFO->spmult = umin(16,umax(1,spmult)); + MOUINFO->spdiv = umin(16,umax(1,spdiv)); +} + +void GrMouseSetAccel(int thresh,int accel) +{ + MOUINFO->thresh = umin(64,umax(1,thresh)); + MOUINFO->accel = umin(16,umax(1,accel)); +} + +void GrMouseSetLimits(int x1,int y1,int x2,int y2) +{ + isort(x1,x2); + isort(y1,y2); + MOUINFO->xmin = imax(0,imin(x1,SCRN->gc_xmax)); + MOUINFO->ymin = imax(0,imin(y1,SCRN->gc_ymax)); + MOUINFO->xmax = imax(0,imin(x2,SCRN->gc_xmax)); + MOUINFO->ymax = imax(0,imin(y2,SCRN->gc_ymax)); +} + +void GrMouseWarp(int x,int y) +{ + MOUINFO->xpos = imax(MOUINFO->xmin,imin(MOUINFO->xmax,x)); + MOUINFO->ypos = imax(MOUINFO->ymin,imin(MOUINFO->ymax,y)); + GrMouseUpdateCursor(); +} + +void GrMouseEventEnable(int enable_kb,int enable_ms) +{ + kbd_enabled = enable_kb; + mou_enabled = enable_ms; +} + +void _GrUpdateInputs(void) +{ + for( ; ; ) { + Int86Regs r; + GrMouseEvent ev; + int gotevt = FALSE; + if(mou_enabled && (MOUINFO->msstatus == 2)) { + int mick,btn; + sttzero(&r); + IREG_AX(r) = 11; /* read mickey counters */ + int33(&r); + if((mick = (short)IREG_CX(r)) != 0) { + update_coord(x,mick); + } + if((mick = (short)IREG_DX(r)) != 0) { + update_coord(y,mick); + } + IREG_AX(r) = 3; /* read button state */ + int33(&r); + btn = IREG_BX(r); + if(btn != mou_buttons) { + fill_mouse_ev( + ev, + mou_buttons,btn, + GR_M_LEFT, + GR_M_MIDDLE, + GR_M_RIGHT, + GR_M_P4, + GR_M_P5, + GrKeyStat() + ); + real_dtime(ev.dtime,evt_lasttime); + enqueue_event(ev); + MOUINFO->moved = FALSE; + mou_buttons = btn; + gotevt = TRUE; + } + } + if(kbd_enabled && GrKeyPressed()) { + fill_keybd_ev(ev,GrKeyRead(),GrKeyStat()); + real_dtime(ev.dtime,evt_lasttime); + enqueue_event(ev); + MOUINFO->moved = FALSE; + gotevt = TRUE; + } + if(!gotevt) break; + } +} + +void GrMouseGetEventT(int flags,GrMouseEvent *ev,long tout) +{ + int msdraw; + long prevtime; + if(MOUINFO->msstatus == 0) GrMouseInit(); + msdraw = !MOUINFO->displayed && !(flags & GR_M_NOPAINT); + if(msdraw) GrMouseDisplayCursor(); + real_time(prevtime); + for( ; ; ) { + _GrUpdateInputs(); + GrMouseUpdateCursor(); + while(MOUINFO->qlength > 0) { + dequeue_event((*ev)); + if(ev->flags & flags) { + if(msdraw) GrMouseEraseCursor(); + return; + } + } + if((flags & GR_M_POLL) || + (tout == 0L) || + (MOUINFO->moved && (flags & GR_M_MOTION))) { + fill_mouse_ev( + (*ev), + mou_buttons,mou_buttons, + GR_M_LEFT, + GR_M_MIDDLE, + GR_M_RIGHT, + GR_M_P4, + GR_M_P5, + GrKeyStat() + ); + if ( ev->flags ) /* something happend */ + real_dtime(ev->dtime,evt_lasttime); + else + ev->dtime = -1; /* special time if nothing happend */ + MOUINFO->moved = FALSE; + if(msdraw) GrMouseEraseCursor(); + return; + } + if(tout > 0L) { + long dtime; + real_dtime(dtime,prevtime); + if((tout -= dtime) < 0L) tout = 0L; + } + } +} + diff --git a/thirdparty/grx249/src/mouse/doskeys.c b/thirdparty/grx249/src/mouse/doskeys.c new file mode 100644 index 0000000..b390d47 --- /dev/null +++ b/thirdparty/grx249/src/mouse/doskeys.c @@ -0,0 +1,121 @@ +/** + ** doskeys.c ---- auxiliary DOS keyboard input functions + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#include "libgrx.h" +#include "grxkeys.h" +#include "int86.h" +#include "memfill.h" + +#ifdef __DJGPP__ +#include +#endif + +#if defined(__WATCOMC__) || defined(__TURBOC__) +#include +#endif + +#define USE_AT_BIOS + +#ifdef USE_AT_BIOS +#define KBD_BIOS_BASE 0x10 +#else +#define KBD_BIOS_BASE 0 +#endif + +#if defined(__TURBOC__) || defined(__WATCOMC__) /* GS - Watcom C++ 11.0 */ + +int getkey(void) +{ + Int86Regs r; + sttzero(&r); + IREG_AX(r) = (KBD_BIOS_BASE + 0) << 8; + int16(&r); + switch(IREG_AL(r)) { +#ifdef USE_AT_BIOS + case 0xe0: +#endif + case 0x00: + return(IREG_AH(r) + 0x100); + default: + return(IREG_AL(r)); + } +} + +int getxkey(void) +{ + Int86Regs r; + sttzero(&r); + IREG_AX(r) = (KBD_BIOS_BASE + 0) << 8; + int16(&r); + switch(IREG_AL(r)) { +#ifdef USE_AT_BIOS + case 0xe0: + return(IREG_AH(r) + 0x200); +#endif + case 0x00: + return(IREG_AH(r) + 0x100); + default: + return(IREG_AL(r)); + } +} + +#endif + +int getkbstat(void) +{ + Int86Regs r; + sttzero(&r); + IREG_AX(r) = (KBD_BIOS_BASE + 2) << 8; + int16(&r); + return(IREG_AL(r)); +} + + +/* +** new functions to replace the old style +** kbhit / getch / getkey / getxkey / getkbstat +** keyboard interface +*/ +int GrKeyPressed(void) { + return kbhit(); +} + +GrKeyType GrKeyRead(void) { + int key = getkey(); + + switch (key) { + case 0x197: key = GrKey_Alt_Home; break; + case 0x198: key = GrKey_Alt_Up; break; + case 0x199: key = GrKey_Alt_PageUp; break; + case 0x19b: key = GrKey_Alt_Left; break; + case 0x19d: key = GrKey_Alt_Right; break; + case 0x19f: key = GrKey_Alt_End; break; + case 0x1a0: key = GrKey_Alt_Down; break; + case 0x1a1: key = GrKey_Alt_PageDown; break; + case 0x1a2: key = GrKey_Alt_Insert; break; + case 0x1a3: key = GrKey_Alt_Delete; break; + } + return (GrKeyType) key; +} + +int GrKeyStat(void) { + return getkbstat(); +} diff --git a/thirdparty/grx249/src/mouse/drawcurs.c b/thirdparty/grx249/src/mouse/drawcurs.c new file mode 100644 index 0000000..5a3bbb0 --- /dev/null +++ b/thirdparty/grx249/src/mouse/drawcurs.c @@ -0,0 +1,156 @@ +/** + ** DRAWCURS.C ---- display, erase and move graphics cursors + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "mouse/input.h" +#include "libgrx.h" + +#define XORMASK(c,x,y) &(c)->work.gc_frame,(x),(y) +#define ANDMASK(c,x,y) &(c)->work.gc_frame,((x) + ((c)->xwork >> 1)),(y) +#define SAVECXT(c,x,y) &(c)->work.gc_frame,(x),((y) + (c)->ysize) +#define WORKCXT(c,x,y) &(c)->work.gc_frame,(x),((y) + (c)->ysize + (c)->ywork) + +void GrDisplayCursor(GrCursor *C) +{ + int xpos,ypos; + int xwrk,ywrk; + int xsiz,ysiz; + if(!C || !COMPATIBLE(C) || C->displayed) return; + C->displayed = TRUE; + xpos = C->xcord - C->xoffs; + ypos = C->ycord - C->yoffs; + xsiz = C->xwork; + ysiz = C->ywork; + xwrk = xpos & ~7; + ywrk = ypos & ~7; + if(xwrk < 0) xwrk = 0; + if(ywrk < 0) ywrk = 0; + if(xwrk > (GrVirtualX() - xsiz)) xwrk = GrVirtualX() - xsiz; + if(ywrk > (GrVirtualY() - ysiz)) ywrk = GrVirtualY() - ysiz; + C->xwpos = xwrk; + C->ywpos = ywrk; + mouse_block(SCRN,xwrk,ywrk,(xwrk + xsiz - 1),(ywrk + ysiz - 1)); + (*SDRV->bltv2r)( + SAVECXT(C,0,0), + &SCRN->gc_frame,xwrk,ywrk, + xsiz,ysiz, + GrWRITE + ); + (*C->work.gc_driver->bitblt)( + WORKCXT(C,0,0), + SAVECXT(C,0,0), + xsiz,ysiz, + GrWRITE + ); + xpos -= xwrk; + ypos -= ywrk; + xsiz = C->xsize; + ysiz = C->ysize; + xwrk = ywrk = 0; + if(xpos < 0) { xwrk -= xpos; xsiz += xpos; xpos = 0; } + if(ypos < 0) { ywrk -= ypos; ysiz += ypos; ypos = 0; } + if(xsiz > (C->xwork - xpos)) xsiz = C->xwork - xpos; + if(ysiz > (C->ywork - ypos)) ysiz = C->ywork - ypos; + if((xsiz <= 0) || (ysiz <= 0)) return; + (*C->work.gc_driver->bitblt)( + WORKCXT(C,xpos,ypos), + ANDMASK(C,xwrk,ywrk), + xsiz,ysiz, + GrAND + ); + (*C->work.gc_driver->bitblt)( + WORKCXT(C,xpos,ypos), + XORMASK(C,xwrk,ywrk), + xsiz,ysiz, + GrXOR + ); + (*SDRV->bltr2v)( + &SCRN->gc_frame,C->xwpos,C->ywpos, + WORKCXT(C,0,0), + C->xwork,C->ywork, + GrWRITE + ); + mouse_unblock(); +} + +void GrEraseCursor(GrCursor *C) +{ + if(C && COMPATIBLE(C) && C->displayed) { + mouse_block(SCRN, + C->xwpos, C->ywpos, + (C->xwpos + C->xwork - 1),(C->ywpos + C->ywork - 1) + ); + (*SDRV->bltr2v)( + &SCRN->gc_frame,C->xwpos,C->ywpos, + SAVECXT(C,0,0), + C->xwork,C->ywork, + GrWRITE + ); + C->displayed = FALSE; + mouse_unblock(); + } +} + +void GrMoveCursor(GrCursor *C,int x,int y) +{ + int xpos,ypos; + int xsiz,ysiz; + if(!C || ((C->xcord == x) && (C->ycord == y))) return; + C->xcord = x; + C->ycord = y; + if(!C->displayed || !COMPATIBLE(C)) return; + xpos = x - C->xoffs - C->xwpos; + ypos = y - C->yoffs - C->ywpos; + xsiz = C->xsize; + ysiz = C->ysize; + if((xpos >= 0) && ((xpos + xsiz) <= C->xwork) && + (ypos >= 0) && ((ypos + ysiz) <= C->ywork)) { + mouse_block(SCRN, + C->xwpos, C->ywpos, + (C->xwpos + C->xwork - 1),(C->ywpos + C->ywork - 1) + ); + (*C->work.gc_driver->bitblt)( + WORKCXT(C,0,0), + SAVECXT(C,0,0), + C->xwork,C->ywork, + GrWRITE + ); + (*C->work.gc_driver->bitblt)( + WORKCXT(C,xpos,ypos), + ANDMASK(C,0,0), + xsiz,ysiz, + GrAND + ); + (*C->work.gc_driver->bitblt)( + WORKCXT(C,xpos,ypos), + XORMASK(C,0,0), + xsiz,ysiz, + GrXOR + ); + (*SDRV->bltr2v)( + &SCRN->gc_frame,C->xwpos,C->ywpos, + WORKCXT(C,0,0), + C->xwork,C->ywork, + GrWRITE + ); + mouse_unblock(); + return; + } + GrEraseCursor(C); + GrDisplayCursor(C); +} + diff --git a/thirdparty/grx249/src/mouse/input.h b/thirdparty/grx249/src/mouse/input.h new file mode 100644 index 0000000..0fe5a45 --- /dev/null +++ b/thirdparty/grx249/src/mouse/input.h @@ -0,0 +1,181 @@ +/** + ** input.h ---- declarations and code pieces for input processing + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#define update_coord(WHICH,MICKEYS) do { \ + static int fract = 0; \ + int delta,ddelta,pos; \ + delta = (MICKEYS) * MOUINFO->spmult; \ + ddelta = (delta + fract) / MOUINFO->spdiv; \ + fract = (delta + fract) % MOUINFO->spdiv; \ + if(iabs(ddelta) >= MOUINFO->thresh) ddelta *= MOUINFO->accel; \ + pos = MOUINFO->WHICH##pos + ddelta; \ + if(pos < MOUINFO->WHICH##min) pos = MOUINFO->WHICH##min; \ + if(pos > MOUINFO->WHICH##max) pos = MOUINFO->WHICH##max; \ + if(pos != MOUINFO->WHICH##pos) { \ + MOUINFO->WHICH##pos = pos; \ + MOUINFO->moved = TRUE; \ + } \ +} while(0) + +#define fill_mouse_ev(EV,OLDBT,NEWBT,LB,MB,RB,P4,P5,KBSTAT) do { \ + int bdown = NEWBT & (~OLDBT); \ + int btnup = OLDBT & (~NEWBT); \ + EV.flags = MOUINFO->moved ? GR_M_MOTION : 0; \ + EV.x = MOUINFO->xpos; \ + EV.y = MOUINFO->ypos; \ + EV.kbstat = KBSTAT; \ + EV.key = 0; \ + EV.buttons = 0; \ + if(NEWBT & LB) EV.buttons |= GR_M_LEFT; \ + if(NEWBT & MB) EV.buttons |= GR_M_MIDDLE; \ + if(NEWBT & RB) EV.buttons |= GR_M_RIGHT; \ + if(NEWBT & P4) EV.buttons |= GR_M_P4; \ + if(NEWBT & P5) EV.buttons |= GR_M_P5; \ + if(bdown & LB) EV.flags |= GR_M_LEFT_DOWN; \ + if(bdown & MB) EV.flags |= GR_M_MIDDLE_DOWN; \ + if(bdown & RB) EV.flags |= GR_M_RIGHT_DOWN; \ + if(bdown & P4) EV.flags |= GR_M_P4_DOWN; \ + if(bdown & P5) EV.flags |= GR_M_P5_DOWN; \ + if(btnup & LB) EV.flags |= GR_M_LEFT_UP; \ + if(btnup & MB) EV.flags |= GR_M_MIDDLE_UP; \ + if(btnup & RB) EV.flags |= GR_M_RIGHT_UP; \ + if(btnup & P4) EV.flags |= GR_M_P4_UP; \ + if(btnup & P5) EV.flags |= GR_M_P5_UP; \ +} while(0) + +#define fill_keybd_ev(EV,KEY,KBSTAT) do { \ + EV.flags = GR_M_KEYPRESS | (MOUINFO->moved ? GR_M_MOTION : 0); \ + EV.x = MOUINFO->xpos; \ + EV.y = MOUINFO->ypos; \ + EV.key = KEY; \ + EV.kbstat = KBSTAT; \ + EV.buttons = 0; \ +} while(0) + +#define fill_cmd_ev(EV,CMD,KBSTAT) do { \ + EV.flags = GR_COMMAND | (MOUINFO->moved ? GR_M_MOTION : 0); \ + EV.x = MOUINFO->xpos; \ + EV.y = MOUINFO->ypos; \ + EV.key = CMD; \ + EV.kbstat = KBSTAT; \ + EV.buttons = 0; \ +} while(0) + +#define enqueue_event(EV) do { \ + sttcopy(&MOUINFO->queue[MOUINFO->qwrite],&EV); \ + if(++MOUINFO->qwrite == MOUINFO->qsize) MOUINFO->qwrite = 0; \ + if(++MOUINFO->qlength > MOUINFO->qsize) { \ + MOUINFO->qlength--; \ + if(++MOUINFO->qread == MOUINFO->qsize) MOUINFO->qread = 0; \ + } \ +} while(0) + +#define dequeue_event(EV) do { \ + if(MOUINFO->qlength > 0) { \ + sttcopy(&EV,&MOUINFO->queue[MOUINFO->qread]); \ + if(++MOUINFO->qread == MOUINFO->qsize) MOUINFO->qread = 0; \ + MOUINFO->qlength--; \ + } \ +} while(0) + +#define init_queue(N) do { \ + if(MOUINFO->qsize != N) { \ + if(MOUINFO->queue != NULL) free(MOUINFO->queue); \ + MOUINFO->queue = malloc(sizeof(MOUINFO->queue[0]) * N); \ + MOUINFO->qsize = MOUINFO->queue ? N : 0; \ + } \ + MOUINFO->qread = 0; \ + MOUINFO->qwrite = 0; \ + MOUINFO->qlength = 0; \ +} while(0); + + +#if defined(__TURBOC__) || defined(__WATCOMC__) /* GS - Watcom C++ 11.0 */ +#define real_time(tv) do { \ + (tv) = *(long far *)(MK_FP(0x40,0x6c)); \ +} while(0) +#define MS_PER_TICK 55 +#endif + +#ifdef __DJGPP__ +#ifdef NO_REPROGRAM_TIMER +#define real_time(tv) do { \ + setup_far_selector(LINP_SEL(0x0000046c)); \ + (tv) = peek_l_f(LINP_PTR(0x0000046c)); \ +} while(0) +#define MS_PER_TICK 55 +#else +#include +#define real_time(tv) do { \ + (tv) = uclock()/(UCLOCKS_PER_SEC/1000); \ +} while(0) +#define MS_PER_TICK 1 +#endif +#endif + +#ifdef __WIN32__ +#include +#define real_time(tv) do { \ + (tv) = clock(); \ +} while(0) +#define MS_PER_TICK (1000L / CLOCKS_PER_SEC) +#endif + +#if !defined(real_time) && defined(unix) +#include +#include +#define real_time(tv) do { \ + (tv) = times(NULL); \ +} while(0) +#define MS_PER_TICK (1000L / sysconf(_SC_CLK_TCK)) +#endif + +#define real_dtime(dt,oldtime) do { \ + long newtime; \ + real_time(newtime); \ + (dt) = (newtime - oldtime) * MS_PER_TICK; \ + oldtime = newtime; \ +} while(0) + +#ifdef __MSDOS__ +#define test_unblock(flag) do { \ + static long lastcheck = 0L; \ + long checktime; \ + real_time(checktime); \ + flag = (int)(checktime - lastcheck); \ + lastcheck = checktime; \ +} while(0) +#else +#define test_unblock(flag) do { \ + static int checkcnt = 1000; \ + (flag) = FALSE; \ + if(--checkcnt <= 0) { \ + checkcnt = 1000; \ + flag = (TRUE); \ + } \ +} while(0) +#endif + +#define COMPATIBLE(c) ((c)->work.gc_driver->mode == SDRV->rmode) + +void _GrUpdateInputs(void); +void _GrInitMouseCursor(void); +#ifndef __MSDOS__ +int _GrCheckKeyboardHit(void); +int _GrReadCharFromKeyboard(void); +#endif diff --git a/thirdparty/grx249/src/mouse/lnxinpu2.c b/thirdparty/grx249/src/mouse/lnxinpu2.c new file mode 100644 index 0000000..fd195ae --- /dev/null +++ b/thirdparty/grx249/src/mouse/lnxinpu2.c @@ -0,0 +1,600 @@ +/** + ** lnxinpu2.c ---- alternate mouse and keyboard interface for Linux + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Mauro Condarelli (mc5686@mclink.it) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andris Pavenis (pavenis@acad.latnet.lv) + ** + ** This version of lnxinput.c handles the mouse directly, not using + ** the svgalib. Changes: + ** + ** New mouse code. Try to open /dev/psaux. Only works with PS2 mice + ** (M.Alvarez 07/02/2002). + ** + ** Now works with PS2 and IMPS2 mice (the wheel is not used) + ** (M.Alvarez 29/12/2002). + ** + ** Now calls _LnxfbSwitchConsoleAndWait if _lnxfb_waiting_to_switch_console + ** is true (M.Alvarez 1/3/2003). + **/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libgrx.h" +#include "input.h" +#include "arith.h" +#include "memcopy.h" +#include "memfill.h" + +#include "grxkeys.h" + +extern int _lnxfb_waiting_to_switch_console; +extern void _LnxfbSwitchConsoleAndWait(void); + +/* + * keyboard stuff + */ +static struct termio kbd_setup; +static struct termio kbd_reset; +static int kbd_initted = FALSE; +static int kbd_enabled = TRUE; +static int kbd_isatty; +static int kbd_lastchr; +static int kbd_filedsc; +static enum { normal, test, wait } kbd_mode; + +static void kbd_restore(void) +{ + if (kbd_initted && kbd_isatty && (kbd_mode != normal)) { + ioctl(kbd_filedsc, TCSETA, &kbd_reset); + kbd_mode = normal; + } +} + +static void kbd_init(void) +{ + if (!kbd_initted) { + kbd_initted = TRUE; + kbd_lastchr = EOF; + kbd_filedsc = fileno(stdin); + kbd_isatty = isatty(kbd_filedsc); + if (kbd_isatty) { + ioctl(kbd_filedsc, TCGETA, &kbd_setup); + ioctl(kbd_filedsc, TCGETA, &kbd_reset); + kbd_setup.c_lflag &= ~(ICANON | ECHO); + kbd_setup.c_iflag &= ~(INLCR | ICRNL); + atexit(kbd_restore); + kbd_mode = normal; + } + } +} + +static int n = 0; +static int getByte(int remove) +{ + static unsigned char keybuf[10]; + int ch, f; + + if (n < 0) + n = 0; + if (n <= 0) { + f = read(kbd_filedsc, keybuf + n, 10 - n); + if (f > 0) { + n += f; + } + } + if (n <= 0) + return EOF; + ch = keybuf[0]; + if (remove) { + --n; + memmove(&keybuf[0], &keybuf[1], n * sizeof(unsigned char)); + } + return ch; +} + +static const GrKeyType fnk[] = { + GrKey_F6, GrKey_F7, GrKey_F8, GrKey_F9, GrKey_F10, GrKey_Escape, + /* shift F1 == F11, shift F2 == F12 What code should be returned ?? */ + GrKey_Shift_F1, GrKey_Shift_F2, + GrKey_Shift_F3, GrKey_Shift_F4, + GrKey_Escape, GrKey_Shift_F5, GrKey_Shift_F6, GrKey_Escape, + GrKey_Shift_F7, GrKey_Shift_F8, GrKey_Shift_F9, GrKey_Shift_F10 +}; + +static const GrKeyType alt[] = { + GrKey_Escape, GrKey_Alt_Escape, + 0x7f, GrKey_Alt_Backspace, + 'q', GrKey_Alt_Q, + 'w', GrKey_Alt_W, + 'e', GrKey_Alt_E, + 'r', GrKey_Alt_R, + 't', GrKey_Alt_T, + 'y', GrKey_Alt_Y, + 'u', GrKey_Alt_U, + 'i', GrKey_Alt_I, + 'o', GrKey_Alt_O, + 'p', GrKey_Alt_P, + '[', GrKey_Alt_LBracket, + ']', GrKey_Alt_RBracket, + GrKey_Return, GrKey_Alt_Return, + 'a', GrKey_Alt_A, + 's', GrKey_Alt_S, + 'd', GrKey_Alt_D, + 'f', GrKey_Alt_F, + 'g', GrKey_Alt_G, + 'h', GrKey_Alt_H, + 'j', GrKey_Alt_J, + 'k', GrKey_Alt_K, + 'l', GrKey_Alt_L, + ';', GrKey_Alt_Semicolon, + '\'', GrKey_Alt_Quote, + '\x60', GrKey_Alt_Backquote, + '\\', GrKey_Alt_Backslash, + 'z', GrKey_Alt_Z, + 'x', GrKey_Alt_X, + 'c', GrKey_Alt_C, + 'v', GrKey_Alt_V, + 'b', GrKey_Alt_B, + 'n', GrKey_Alt_N, + 'm', GrKey_Alt_M, + ',', GrKey_Alt_Comma, + '.', GrKey_Alt_Period, + '/', GrKey_Alt_Slash, +/* GrKey_Alt_F1 */ +/* GrKey_Alt_F2 */ +/* GrKey_Alt_F3 */ +/* GrKey_Alt_F4 */ +/* GrKey_Alt_F5 */ +/* GrKey_Alt_F6 */ +/* GrKey_Alt_F7 */ +/* GrKey_Alt_F8 */ +/* GrKey_Alt_F9 */ +/* GrKey_Alt_F10 */ + '1', GrKey_Alt_1, + '2', GrKey_Alt_2, + '3', GrKey_Alt_3, + '4', GrKey_Alt_4, + '5', GrKey_Alt_5, + '6', GrKey_Alt_6, + '7', GrKey_Alt_7, + '8', GrKey_Alt_8, + '9', GrKey_Alt_9, + '0', GrKey_Alt_0, + '-', GrKey_Alt_Dash, + '=', GrKey_Alt_Equals, +/* GrKey_Alt_F11 */ +/* GrKey_Alt_F12 */ +/* GrKey_Alt_KPSlash */ + GrKey_Tab, GrKey_Alt_Tab, +/* GrKey_Alt_Enter */ + '<', GrKey_Alt_LAngle, + '>', GrKey_Alt_RAngle, + '@', GrKey_Alt_At, + '{', GrKey_Alt_LBrace, + '|', GrKey_Alt_Pipe, + '}', GrKey_Alt_RBrace, + 0x0000, GrKey_NoKey +}; + +static GrKeyType keytrans(GrKeyType k, const GrKeyType * t) +{ + while (t[0] != 0x0000 && t[1] != GrKey_NoKey) { + if (k == t[0]) + return t[1]; + t += 2; + } + return GrKey_OutsideValidRange; +} + +static int inkey(void) +{ + int Key, Key2; + + Restart: + Key = getByte(1); + if (Key != GrKey_Escape) { + if (Key == 0x7f) + return (GrKey_BackSpace); + return (Key); + } + if (n == 0) + return (GrKey_Escape); + /* We have ^[ and something more after that */ + + Key = getByte(1); + if (Key == EOF) + return (GrKey_Escape); + if (Key != '[') + return (keytrans(Key, alt)); /* Check for Alt+Key */ + + /* We have ^[[ */ + if (n == 0) + return (GrKey_Alt_LBracket); + + Key = getByte(1); + if (Key == EOF) + return (GrKey_Alt_LBracket);; + switch (Key) { + case 'A': + return (GrKey_Up); + case 'B': + return (GrKey_Down); + case 'C': + return (GrKey_Right); + case 'D': + return (GrKey_Left); + case 'G': + return (GrKey_Center); + case '[': + Key = getByte(1); + switch (Key) { + case 'A': + return (GrKey_F1); + case 'B': + return (GrKey_F2); + case 'C': + return (GrKey_F3); + case 'D': + return (GrKey_F4); + case 'E': + return (GrKey_F5); + default: + goto Restart; + } + default: + if (Key >= '1' && Key <= '6') { + Key2 = getByte(1); + if (Key2 == '~') + switch (Key) { + case '1': + return (GrKey_Home); + case '2': + return (GrKey_Insert); + case '3': + return (GrKey_Delete); + case '4': + return (GrKey_End); + case '5': + return (GrKey_PageUp); + case '6': + return (GrKey_PageDown); + } else if (Key2 >= '0' && Key2 <= '9') { + int index = 10 * (Key - '0') + (Key2 - '0'); + if (getByte(1) != '~') + goto Restart; + if (17 <= index && index <= 34) + return (fnk[index - 17]); + goto Restart; + } + } + goto Restart; + } +} + +static int validKey(int key, int valid) +{ + if (key < 0 || key > GrKey_LastDefinedKeycode || key == EOF) + return valid; + return key; +} + +int _GrCheckKeyboardHit(void) +{ + if (_lnxfb_waiting_to_switch_console) + _LnxfbSwitchConsoleAndWait(); + + if (!kbd_initted) { + kbd_init(); + } + if (!kbd_isatty) { + return (TRUE); + } + if (kbd_lastchr != EOF) { + return (TRUE); + } + if (kbd_mode != test) { + kbd_setup.c_cc[VMIN] = 0; + kbd_setup.c_cc[VTIME] = 0; + if (ioctl(kbd_filedsc, TCSETAW, &kbd_setup) == EOF) + return (FALSE); + kbd_mode = test; + } + kbd_lastchr = validKey(inkey(), EOF); + return (kbd_lastchr != EOF); +} + +int _GrReadCharFromKeyboard(void) +{ + int key = EOF; + + if (!kbd_initted) { + kbd_init(); + } + if (!kbd_isatty) { + return (getc(stdin)); + } + do { + if (_lnxfb_waiting_to_switch_console) + _LnxfbSwitchConsoleAndWait(); + + if (kbd_lastchr != EOF) { + key = kbd_lastchr; + kbd_lastchr = EOF; + break; + } + if (kbd_mode == test) { + /* we're in test mode. Look for key without mode switch ... */ + _GrCheckKeyboardHit(); + if (kbd_lastchr != EOF) { + key = kbd_lastchr; + kbd_lastchr = EOF; + break; + } + } + /* no key till now. Wait of it ... */ + if (kbd_mode != wait) { + kbd_setup.c_cc[VMIN] = 0; + kbd_setup.c_cc[VTIME] = 1; + if (ioctl(kbd_filedsc, TCSETAW, &kbd_setup) == EOF) + return (EOF); + kbd_mode = wait; + } + if ((key = inkey()) != EOF) break; + } while (1); + return validKey(key, GrKey_OutsideValidRange); +} + +/* + * Mouse stuff + */ + +#define PS2_LEFTBUTTON 1 +#define PS2_MIDDLEBUTTON 4 +#define PS2_RIGHTBUTTON 2 +#define PS2_FOURTHBUTTON 8 +#define PS2_FIFTHBUTTON 16 + +static int mou_filedsc; +static int mou_buttons; +static int mou_enabled = TRUE; +static long evt_lasttime; + +static void uninit(void) +{ + if (MOUINFO->msstatus > 1) + MOUINFO->msstatus = 1; +} + +int GrMouseDetect(void) +{ + if (MOUINFO->msstatus == 0) { + MOUINFO->msstatus = (-1); /* assume missing */ + mou_filedsc = open("/dev/psaux", O_RDONLY | O_NDELAY); + if (mou_filedsc >= 0) { + MOUINFO->msstatus = 1; /* present, but not initted */ + atexit(uninit); + } + } + return ((MOUINFO->msstatus > 0) ? TRUE : FALSE); +} + +void GrMouseInitN(int queue_size) +{ + uninit(); + queue_size = umax(4, umin(256, queue_size)); + init_queue(queue_size); + kbd_init(); + if (GrMouseDetect()) { + GrMouseSetSpeed(1, 1); + GrMouseSetAccel(100, 1); + GrMouseSetLimits(0, 0, SCRN->gc_xmax, SCRN->gc_ymax); + GrMouseWarp((SCRN->gc_xmax >> 1), (SCRN->gc_ymax >> 1)); + _GrInitMouseCursor(); + MOUINFO->msstatus = 2; + mou_buttons = 0; + } + GrMouseEventEnable(TRUE, TRUE); + real_time(evt_lasttime); + MOUINFO->uninit = uninit; +} + +void GrMouseSetSpeed(int spmult, int spdiv) +{ + MOUINFO->spmult = umin(16, umax(1, spmult)); + MOUINFO->spdiv = umin(16, umax(1, spdiv)); +} + +void GrMouseSetAccel(int thresh, int accel) +{ + MOUINFO->thresh = umin(64, umax(1, thresh)); + MOUINFO->accel = umin(16, umax(1, accel)); +} + +void GrMouseSetLimits(int x1, int y1, int x2, int y2) +{ + isort(x1, x2); + isort(y1, y2); + MOUINFO->xmin = imax(0, imin(x1, SCRN->gc_xmax)); + MOUINFO->ymin = imax(0, imin(y1, SCRN->gc_ymax)); + MOUINFO->xmax = imax(0, imin(x2, SCRN->gc_xmax)); + MOUINFO->ymax = imax(0, imin(y2, SCRN->gc_ymax)); +} + +void GrMouseWarp(int x, int y) +{ + MOUINFO->xpos = imax(MOUINFO->xmin, imin(MOUINFO->xmax, x)); + MOUINFO->ypos = imax(MOUINFO->ymin, imin(MOUINFO->ymax, y)); + GrMouseUpdateCursor(); +} + +void GrMouseEventEnable(int enable_kb, int enable_ms) +{ + kbd_enabled = enable_kb; + mou_enabled = enable_ms; +} + +/* works with PS2 and IMPS2 mice, but the wheel is not used */ +static int _GrReadPS2MouseData(int *mb, int *mx, int *my) +{ + static int imps2 = 0; + static int count_to_imps2 = 0; + static int last_packed_ok = 0; + unsigned char buf[4]; + int evr = 0; + + *mx = *my = 0; + do { + if (read(mou_filedsc, buf, 1) < 1) + return evr; + if (!(buf[0] & 0x08)) { /* sync lost */ + if (!imps2) { + if (last_packed_ok) { /* an IMPS2 mouse? */ + count_to_imps2++; + if (count_to_imps2 > 20) + imps2 = 1; + } else + count_to_imps2 = 0; + last_packed_ok = 0; + } + return evr; + } + while (read(mou_filedsc, buf + 1, 1) != 1); + while (read(mou_filedsc, buf + 2, 1) != 1); + if (imps2) /* the IMPS2 protocol is 4 bytes wide */ + while (read(mou_filedsc, buf + 3, 1) != 1); + *mb = buf[0] & 0x7; + *mx += (buf[0] & 0x10) ? buf[1] - 256 : buf[1]; + *my += (buf[0] & 0x20) ? -(buf[2] - 256) : -buf[2]; + last_packed_ok = 1; + evr = 1; + } while (*mb == mou_buttons); + return evr; +} + +void _GrUpdateInputs(void) +{ + GrMouseEvent ev; + int mb, mx, my, gotevt; + + for (;;) { + gotevt = FALSE; + if (_lnxfb_waiting_to_switch_console) + _LnxfbSwitchConsoleAndWait(); + if (mou_enabled && (MOUINFO->msstatus == 2)) { + if (_GrReadPS2MouseData(&mb, &mx, &my)) { + update_coord(x, mx); + update_coord(y, my); + if (mb != mou_buttons) { + fill_mouse_ev(ev, + mou_buttons, mb, + PS2_LEFTBUTTON, + PS2_MIDDLEBUTTON, PS2_RIGHTBUTTON, + PS2_FOURTHBUTTON, PS2_FIFTHBUTTON, 0); + real_dtime(ev.dtime, evt_lasttime); + enqueue_event(ev); + MOUINFO->moved = FALSE; + mou_buttons = mb; + gotevt = TRUE; + } + } + } + if (kbd_enabled && kbd_isatty && _GrCheckKeyboardHit()) { + int key = _GrReadCharFromKeyboard(); + fill_keybd_ev(ev, key, 0); + real_dtime(ev.dtime, evt_lasttime); + enqueue_event(ev); + MOUINFO->moved = FALSE; + gotevt = TRUE; + } + if (!gotevt) + break; + } +} + +void GrMouseGetEventT(int flags, GrMouseEvent * ev, long tout) +{ + int msdraw; + if (MOUINFO->msstatus == 0) + GrMouseInit(); + msdraw = !MOUINFO->displayed && !(flags & GR_M_NOPAINT); + if (msdraw) + GrMouseDisplayCursor(); + for (;;) { + fd_set readfds; + struct timeval wtime; + int N; + _GrUpdateInputs(); + GrMouseUpdateCursor(); + while (MOUINFO->qlength > 0) { + dequeue_event((*ev)); + if (ev->flags & flags) { + if (msdraw) + GrMouseEraseCursor(); + return; + } + } + if ((flags & GR_M_POLL) || + (tout == 0) || (MOUINFO->moved && (flags & GR_M_MOTION))) { + fill_mouse_ev((*ev), + mou_buttons, mou_buttons, + PS2_LEFTBUTTON, + PS2_MIDDLEBUTTON, PS2_RIGHTBUTTON, + PS2_FOURTHBUTTON, PS2_FIFTHBUTTON, 0); + if (ev->flags) /* something happend */ + real_dtime(ev->dtime, evt_lasttime); + else + ev->dtime = -1; /* special time is nothing happend */ + MOUINFO->moved = FALSE; + if (msdraw) + GrMouseEraseCursor(); + return; + } + FD_ZERO(&readfds); + N = 0; + if (kbd_enabled && kbd_isatty) { + FD_SET(kbd_filedsc, &readfds); + N = kbd_filedsc + 1; + } + if (mou_enabled && (MOUINFO->msstatus == 2)) { + FD_SET(mou_filedsc, &readfds); + N = umax(N, (mou_filedsc + 1)); + } + if (N == 0) { + if (tout > 0) + usleep(tout * 1000); + tout = 0; + continue; + } + if (tout > 0) { + wtime.tv_sec = (tout / 1000); + wtime.tv_usec = (tout % 1000) * 1000; + if (select(N, &readfds, NULL, NULL, &wtime) < 1) + tout = 0; + continue; + } + select(N, &readfds, NULL, NULL, NULL); + } +} diff --git a/thirdparty/grx249/src/mouse/lnxinput.c b/thirdparty/grx249/src/mouse/lnxinput.c new file mode 100644 index 0000000..b18cefa --- /dev/null +++ b/thirdparty/grx249/src/mouse/lnxinput.c @@ -0,0 +1,526 @@ +/** + ** lnxinput.c ---- mouse and keyboard interface for Linux + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Mauro Condarelli (mc5686@mclink.it) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andris Pavenis (pavenis@acad.latnet.lv) + ** + **/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libgrx.h" +#include "input.h" +#include "arith.h" +#include "memcopy.h" +#include "memfill.h" + +#include "grxkeys.h" + +/* + * keyboard stuff + */ +static struct termio kbd_setup; +static struct termio kbd_reset; +static int kbd_initted = FALSE; +static int kbd_enabled = TRUE; +static int kbd_isatty; +static int kbd_lastchr; +static int kbd_filedsc; +static enum { normal, test, wait } kbd_mode; + +static void kbd_restore(void) +{ + if(kbd_initted && kbd_isatty && (kbd_mode != normal)) { + ioctl(kbd_filedsc,TCSETA,&kbd_reset); + kbd_mode = normal; + } +} + +static void kbd_init(void) +{ + if(!kbd_initted) { + kbd_initted = TRUE; + kbd_lastchr = EOF; + kbd_filedsc = fileno(stdin); + kbd_isatty = isatty(kbd_filedsc); + if(kbd_isatty) { + ioctl(kbd_filedsc,TCGETA,&kbd_setup); + ioctl(kbd_filedsc,TCGETA,&kbd_reset); + kbd_setup.c_lflag &= ~(ICANON | ECHO ); + kbd_setup.c_iflag &= ~(INLCR | ICRNL); + atexit(kbd_restore); + kbd_mode = normal; + } + } +} + +static int n = 0; +static int getByte(int remove) + { + static unsigned char keybuf[10]; + int ch, f; + + if (n < 0) n = 0; + if (n<=0) { + f = read(kbd_filedsc, keybuf+n, 10-n); + if (f>0) n += f; + } + if (n<=0) return EOF; + ch = keybuf[0]; + if (remove) { + --n; + memmove(&keybuf[0],&keybuf[1], n*sizeof(unsigned char)); + } + return ch; + } + + +static const GrKeyType fnk[] = { + GrKey_F6, GrKey_F7, GrKey_F8, GrKey_F9, GrKey_F10, GrKey_Escape, + /* shift F1 == F11, shift F2 == F12 What code should be returned ?? */ + GrKey_Shift_F1, GrKey_Shift_F2, + GrKey_Shift_F3, GrKey_Shift_F4, + GrKey_Escape, GrKey_Shift_F5, GrKey_Shift_F6, GrKey_Escape, + GrKey_Shift_F7, GrKey_Shift_F8, GrKey_Shift_F9, GrKey_Shift_F10 }; + +static const GrKeyType alt[] = { + GrKey_Escape, GrKey_Alt_Escape, + 0x7f, GrKey_Alt_Backspace, + 'q', GrKey_Alt_Q, + 'w', GrKey_Alt_W, + 'e', GrKey_Alt_E, + 'r', GrKey_Alt_R, + 't', GrKey_Alt_T, + 'y', GrKey_Alt_Y, + 'u', GrKey_Alt_U, + 'i', GrKey_Alt_I, + 'o', GrKey_Alt_O, + 'p', GrKey_Alt_P, + '[', GrKey_Alt_LBracket, + ']', GrKey_Alt_RBracket, + GrKey_Return, GrKey_Alt_Return, + 'a', GrKey_Alt_A, + 's', GrKey_Alt_S, + 'd', GrKey_Alt_D, + 'f', GrKey_Alt_F, + 'g', GrKey_Alt_G, + 'h', GrKey_Alt_H, + 'j', GrKey_Alt_J, + 'k', GrKey_Alt_K, + 'l', GrKey_Alt_L, + ';', GrKey_Alt_Semicolon, + '\'', GrKey_Alt_Quote, + '\x60', GrKey_Alt_Backquote, + '\\', GrKey_Alt_Backslash, + 'z', GrKey_Alt_Z, + 'x', GrKey_Alt_X, + 'c', GrKey_Alt_C, + 'v', GrKey_Alt_V, + 'b', GrKey_Alt_B, + 'n', GrKey_Alt_N, + 'm', GrKey_Alt_M, + ',', GrKey_Alt_Comma, + '.', GrKey_Alt_Period, + '/', GrKey_Alt_Slash, +/* GrKey_Alt_F1 */ +/* GrKey_Alt_F2 */ +/* GrKey_Alt_F3 */ +/* GrKey_Alt_F4 */ +/* GrKey_Alt_F5 */ +/* GrKey_Alt_F6 */ +/* GrKey_Alt_F7 */ +/* GrKey_Alt_F8 */ +/* GrKey_Alt_F9 */ +/* GrKey_Alt_F10 */ + '1', GrKey_Alt_1, + '2', GrKey_Alt_2, + '3', GrKey_Alt_3, + '4', GrKey_Alt_4, + '5', GrKey_Alt_5, + '6', GrKey_Alt_6, + '7', GrKey_Alt_7, + '8', GrKey_Alt_8, + '9', GrKey_Alt_9, + '0', GrKey_Alt_0, + '-', GrKey_Alt_Dash, + '=', GrKey_Alt_Equals, +/* GrKey_Alt_F11 */ +/* GrKey_Alt_F12 */ +/* GrKey_Alt_KPSlash */ + GrKey_Tab, GrKey_Alt_Tab, +/* GrKey_Alt_Enter */ + '<', GrKey_Alt_LAngle, + '>', GrKey_Alt_RAngle, + '@', GrKey_Alt_At, + '{', GrKey_Alt_LBrace, + '|', GrKey_Alt_Pipe, + '}', GrKey_Alt_RBrace, + 0x0000, GrKey_NoKey +}; + +static GrKeyType keytrans(GrKeyType k, const GrKeyType *t) { + while (t[0] != 0x0000 && t[1] != GrKey_NoKey) { + if (k == t[0]) return t[1]; + t += 2; + } + return GrKey_OutsideValidRange; +} + +static +int inkey(void) { + int Key, Key2; + +Restart: + Key = getByte(1); + if (Key!=GrKey_Escape) { + if (Key == 0x7f) return(GrKey_BackSpace); + return(Key); + } + if (n==0) return(GrKey_Escape); + /* We have ^[ and something more after that */ + + Key = getByte(1); + if (Key == EOF) return(GrKey_Escape); + if (Key!='[') return(keytrans(Key,alt)); /* Check for Alt+Key */ + + /* We have ^[[ */ + if (n==0) return(GrKey_Alt_LBracket); + + Key = getByte(1); + if (Key == EOF) return(GrKey_Alt_LBracket);; + switch (Key) + { + case 'A': return(GrKey_Up); + case 'B': return(GrKey_Down); + case 'C': return(GrKey_Right); + case 'D': return(GrKey_Left); + case 'G': return(GrKey_Center); + case '[': Key = getByte(1); + switch (Key) + { + case 'A': return(GrKey_F1); + case 'B': return(GrKey_F2); + case 'C': return(GrKey_F3); + case 'D': return(GrKey_F4); + case 'E': return(GrKey_F5); + default: goto Restart; + } + default: if (Key>='1' && Key<='6') + { + Key2 = getByte(1); + if (Key2=='~') switch (Key) + { + case '1': return(GrKey_Home); + case '2': return(GrKey_Insert); + case '3': return(GrKey_Delete); + case '4': return(GrKey_End); + case '5': return(GrKey_PageUp); + case '6': return(GrKey_PageDown); + } + else if (Key2>='0' && Key2<='9') + { + int index = 10*(Key-'0') + (Key2 - '0'); + if (getByte(1)!='~') goto Restart; + if (17 <= index && index <= 34) + return(fnk[index-17]); + goto Restart; + } + } + goto Restart; + } +} + +static int validKey(int key, int valid) { + if (key < 0 || key > GrKey_LastDefinedKeycode || key == EOF) + return valid; + return key; +} + +int _GrCheckKeyboardHit(void) +{ + if(!kbd_initted) { + kbd_init(); + } + if(!kbd_isatty) { + return(TRUE); + } + if(kbd_lastchr != EOF) { + return(TRUE); + } + if(kbd_mode != test) { + kbd_setup.c_cc[VMIN] = 0; + kbd_setup.c_cc[VTIME] = 0; + if(ioctl(kbd_filedsc,TCSETAW,&kbd_setup) == EOF) return(FALSE); + kbd_mode = test; + } + kbd_lastchr = validKey(inkey(), EOF); + return (kbd_lastchr != EOF); +} + +int _GrReadCharFromKeyboard(void) +{ + int key = EOF; + + if(!kbd_initted) { + kbd_init(); + } + if(!kbd_isatty) { + return(getc(stdin)); + } + do { + if(kbd_lastchr != EOF) { + key = kbd_lastchr; + kbd_lastchr = EOF; + break; + } + if(kbd_mode == test) { + /* we're in test mode. Look for key without mode switch ... */ + _GrCheckKeyboardHit(); + if(kbd_lastchr != EOF) { + key = kbd_lastchr; + kbd_lastchr = EOF; + break; + } + } + /* no key till now. Wait of it ... */ + if(kbd_mode != wait) { + kbd_setup.c_cc[VMIN] = 1; + kbd_setup.c_cc[VTIME] = 0; + if(ioctl(kbd_filedsc,TCSETAW,&kbd_setup) == EOF) return(EOF); + kbd_mode = wait; + } + key = inkey(); + } while (0); + return validKey(key, GrKey_OutsideValidRange); +} + +/* + * Mouse stuff + */ + +static int mou_filedsc; +static int mou_lastxpos; +static int mou_lastypos; +static int mou_buttons; +static int mou_enabled = TRUE; +static long evt_lasttime; + +int GrMouseDetect(void) +{ + if(MOUINFO->msstatus == 0) { + MOUINFO->msstatus = (-1); /* assume missing */ + mou_filedsc = mouse_init_return_fd( + "/dev/mouse", + vga_getmousetype(), + MOUSE_DEFAULTSAMPLERATE + ); + if(mou_filedsc >= 0) { + MOUINFO->msstatus = 1; /* present, but not initted */ + atexit(mouse_close); + mouse_setxrange(0,32767); + mouse_setyrange(0,32767); + mouse_setwrap(MOUSE_NOWRAP); + mouse_setscale(16); + } + } + return((MOUINFO->msstatus > 0) ? TRUE : FALSE); +} + +static void uninit(void) +{ + if(MOUINFO->msstatus > 1) MOUINFO->msstatus = 1; + kbd_restore(); +} + +void GrMouseInitN(int queue_size) +{ + uninit(); + queue_size = umax(4,umin(256,queue_size)); + init_queue(queue_size); + kbd_init(); + if(GrMouseDetect()) { + GrMouseSetSpeed(1,1); + GrMouseSetAccel(100,1); + GrMouseSetLimits(0,0,SCRN->gc_xmax,SCRN->gc_ymax); + GrMouseWarp((SCRN->gc_xmax >> 1),(SCRN->gc_ymax >> 1)); + _GrInitMouseCursor(); + MOUINFO->msstatus = 2; + } + GrMouseEventEnable(TRUE,TRUE); + real_time(evt_lasttime); + MOUINFO->uninit = uninit; +} + +void GrMouseSetSpeed(int spmult,int spdiv) +{ + MOUINFO->spmult = umin(16,umax(1,spmult)); + MOUINFO->spdiv = umin(16,umax(1,spdiv)); +} + +void GrMouseSetAccel(int thresh,int accel) +{ + MOUINFO->thresh = umin(64,umax(1,thresh)); + MOUINFO->accel = umin(16,umax(1,accel)); +} + +void GrMouseSetLimits(int x1,int y1,int x2,int y2) +{ + isort(x1,x2); + isort(y1,y2); + MOUINFO->xmin = imax(0,imin(x1,SCRN->gc_xmax)); + MOUINFO->ymin = imax(0,imin(y1,SCRN->gc_ymax)); + MOUINFO->xmax = imax(0,imin(x2,SCRN->gc_xmax)); + MOUINFO->ymax = imax(0,imin(y2,SCRN->gc_ymax)); +} + +void GrMouseWarp(int x,int y) +{ + MOUINFO->xpos = imax(MOUINFO->xmin,imin(MOUINFO->xmax,x)); + MOUINFO->ypos = imax(MOUINFO->ymin,imin(MOUINFO->ymax,y)); + mou_lastxpos = 16384; + mou_lastypos = 16384; + mouse_setposition(16384,16384); + GrMouseUpdateCursor(); +} + +void GrMouseEventEnable(int enable_kb,int enable_ms) +{ + if(!enable_kb) kbd_restore(); + kbd_enabled = enable_kb; + mou_enabled = enable_ms; +} + +void _GrUpdateInputs(void) +{ + for( ; ; ) { + GrMouseEvent ev; + int gotevt = FALSE; + if(mou_enabled && (MOUINFO->msstatus == 2) && mouse_update()) { + int mx = mouse_getx(); + int my = mouse_gety(); + int mb = mouse_getbutton(); + update_coord(x,(mx - mou_lastxpos)); + update_coord(y,(my - mou_lastypos)); + mou_lastxpos = mx; + mou_lastypos = my; + if(mb != mou_buttons) { + fill_mouse_ev( + ev, + mou_buttons,mb, + MOUSE_LEFTBUTTON, + MOUSE_MIDDLEBUTTON, + MOUSE_RIGHTBUTTON, + MOUSE_FOURTHBUTTON, + MOUSE_FIFTHBUTTON, + 0 + ); + real_dtime(ev.dtime,evt_lasttime); + enqueue_event(ev); + MOUINFO->moved = FALSE; + mou_buttons = mb; + } + gotevt = TRUE; + } + if(kbd_enabled && kbd_isatty && _GrCheckKeyboardHit()) { + int key = _GrReadCharFromKeyboard(); + fill_keybd_ev(ev,key,0); + real_dtime(ev.dtime,evt_lasttime); + enqueue_event(ev); + MOUINFO->moved = FALSE; + gotevt = TRUE; + } + if(!gotevt) break; + } +} + +void GrMouseGetEventT(int flags,GrMouseEvent *ev,long tout) +{ + int msdraw; + if(MOUINFO->msstatus == 0) GrMouseInit(); + msdraw = !MOUINFO->displayed && !(flags & GR_M_NOPAINT); + if(msdraw) GrMouseDisplayCursor(); + for( ; ; ) { + fd_set readfds; + struct timeval wtime; + int N; + _GrUpdateInputs(); + GrMouseUpdateCursor(); + while(MOUINFO->qlength > 0) { + dequeue_event((*ev)); + if(ev->flags & flags) { + if(msdraw) GrMouseEraseCursor(); + return; + } + } + if((flags & GR_M_POLL) || + (tout == 0) || + (MOUINFO->moved && (flags & GR_M_MOTION))) { + fill_mouse_ev( + (*ev), + mou_buttons,mou_buttons, + MOUSE_LEFTBUTTON, + MOUSE_MIDDLEBUTTON, + MOUSE_RIGHTBUTTON, + MOUSE_FOURTHBUTTON, + MOUSE_FIFTHBUTTON, + 0 + ); + if ( ev->flags ) /* something happend */ + real_dtime(ev->dtime,evt_lasttime); + else + ev->dtime = -1; /* special time is nothing happend */ + MOUINFO->moved = FALSE; + if(msdraw) GrMouseEraseCursor(); + return; + } + FD_ZERO(&readfds); + N = 0; + if(kbd_enabled && kbd_isatty) { + FD_SET(kbd_filedsc,&readfds); + N = kbd_filedsc + 1; + } + if(mou_enabled && (MOUINFO->msstatus == 2)) { + FD_SET(mou_filedsc,&readfds); + N = umax(N,(mou_filedsc + 1)); + } + if(N == 0) { + if(tout > 0) usleep(tout * 1000); + tout = 0; + continue; + } + if(tout > 0) { + wtime.tv_sec = (tout / 1000); + wtime.tv_usec = (tout % 1000) * 1000; + if(select(N,&readfds,NULL,NULL,&wtime) < 1) + tout = 0; + continue; + } + select(N,&readfds,NULL,NULL,NULL); + } +} + diff --git a/thirdparty/grx249/src/mouse/lnxkeys.c b/thirdparty/grx249/src/mouse/lnxkeys.c new file mode 100644 index 0000000..bbb270f --- /dev/null +++ b/thirdparty/grx249/src/mouse/lnxkeys.c @@ -0,0 +1,63 @@ +/** + ** lnxkeys.c ---- DOS (TCC/BCC/DJGPP: "conio.h") style keyboard utilities + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#include "libgrx.h" +#include "input.h" + +#include "grxkeys.h" + +int kbhit(void) +{ + return(_GrCheckKeyboardHit()); +} + +int getch(void) +{ + return(_GrReadCharFromKeyboard()); +} + +int getkey(void) +{ + return(_GrReadCharFromKeyboard()); +} + +int getkbstat(void) +{ + return(0); +} + + +/* +** new functions to replace the old style +** kbhit / getch / getkey / getxkey / getkbstat +** keyboard interface +*/ +int GrKeyPressed(void) { + return(_GrCheckKeyboardHit()); +} + +GrKeyType GrKeyRead(void) { + return (GrKeyType)_GrReadCharFromKeyboard(); +} + +int GrKeyStat(void) { + return(0); +} diff --git a/thirdparty/grx249/src/mouse/mouinfo.c b/thirdparty/grx249/src/mouse/mouinfo.c new file mode 100644 index 0000000..0d61a1f --- /dev/null +++ b/thirdparty/grx249/src/mouse/mouinfo.c @@ -0,0 +1,24 @@ +/** + ** mouinfo.c ---- the mouse info data structure + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#undef GrMouseInfo + +const +struct _GR_mouseInfo * const GrMouseInfo = &_GrMouseInfo; +struct _GR_mouseInfo _GrMouseInfo = { 0 }; diff --git a/thirdparty/grx249/src/mouse/mouinlne.c b/thirdparty/grx249/src/mouse/mouinlne.c new file mode 100644 index 0000000..ba33270 --- /dev/null +++ b/thirdparty/grx249/src/mouse/mouinlne.c @@ -0,0 +1,70 @@ +/** + ** mouinlne.c ---- the mouse inline functions + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +void (GrMouseEventMode)(int dummy) +{ + GrMouseEventMode(dummy); +} + +void (GrMouseInit)(void) +{ + GrMouseInit(); +} + +void (GrMouseUnInit)(void) +{ + GrMouseUnInit(); +} + +void (GrMouseGetEvent)(int flags,GrMouseEvent *event) +{ + GrMouseGetEvent(flags,event); +} + +int (GrMousePendingEvent)(void) +{ + return(GrMousePendingEvent()); +} + +GrCursor *(GrMouseGetCursor)(void) +{ + return(GrMouseGetCursor()); +} + +int (GrMouseCursorIsDisplayed)(void) +{ + return(GrMouseCursorIsDisplayed()); +} + +void (GrMouseGetLimits)(int *x1,int *y1,int *x2,int *y2) +{ + GrMouseGetLimits(x1,y1,x2,y2); +} + +int (GrMouseBlock)(GrContext *c,int x1,int y1,int x2,int y2) +{ + return(GrMouseBlock(c,x1,y1,x2,y2)); +} + +void (GrMouseUnBlock)(int flags) +{ + GrMouseUnBlock(flags); +} + diff --git a/thirdparty/grx249/src/mouse/mscursor.c b/thirdparty/grx249/src/mouse/mscursor.c new file mode 100644 index 0000000..152aafa --- /dev/null +++ b/thirdparty/grx249/src/mouse/mscursor.c @@ -0,0 +1,289 @@ +/** + ** mscursor.c ---- the mouse cursor related stuff + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include + +#include "mouse/input.h" +#include "libgrx.h" +#include "clipping.h" +#include "mempeek.h" + +#define MSCURSOR (MOUINFO->cursor) +#define CURSORMODE (MOUINFO->cursmode) +#define SPECIALMODE (MOUINFO->cursmode != GR_M_CUR_NORMAL) +#define BLOCKED 1 +#define ERASED 2 + +static void draw_special(void) +{ + int xpos = MSCURSOR->xcord; + int ypos = MSCURSOR->ycord; + int check = MOUINFO->docheck; + GrContext csave; + MOUINFO->docheck = FALSE; + GrSaveContext(&csave); + GrSetContext(SCRN); + switch(CURSORMODE) { + case GR_M_CUR_RUBBER: + GrBox(xpos,ypos,MOUINFO->x1,MOUINFO->y1,MOUINFO->curscolor); + break; + case GR_M_CUR_LINE: + GrLine(xpos,ypos,MOUINFO->x1,MOUINFO->y1,MOUINFO->curscolor); + break; + case GR_M_CUR_BOX: + GrBox( + (xpos + MOUINFO->x1),(ypos + MOUINFO->y1), + (xpos + MOUINFO->x2),(ypos + MOUINFO->y2), + MOUINFO->curscolor + ); + break; + } + GrSetContext(&csave); + MOUINFO->docheck = check; +} + +static void move_mouse(void) +{ + if((MOUINFO->xpos != MSCURSOR->xcord) || + (MOUINFO->ypos != MSCURSOR->ycord)) { + int check = MOUINFO->docheck; + int dospec = SPECIALMODE && MSCURSOR->displayed; + MOUINFO->docheck = FALSE; + if(dospec) draw_special(); + GrMoveCursor(MSCURSOR,MOUINFO->xpos,MOUINFO->ypos); + if(dospec) draw_special(); + MOUINFO->docheck = check; + } +} + +static void draw_mouse(void) +{ + int check = MOUINFO->docheck; + MOUINFO->docheck = FALSE; + GrDisplayCursor(MSCURSOR); + if(SPECIALMODE) draw_special(); + MOUINFO->docheck = check; +} + +static void erase_mouse(void) +{ + int check = MOUINFO->docheck; + MOUINFO->docheck = FALSE; + if(SPECIALMODE) draw_special(); + GrEraseCursor(MSCURSOR); + MOUINFO->docheck = check; +} + +void GrMouseDisplayCursor(void) +{ + if(MOUINFO->msstatus != 2) GrMouseInit(); + if(MOUINFO->msstatus != 2) return; + if(MOUINFO->cursor == NULL) return; + if(MOUINFO->displayed != FALSE) return; + move_mouse(); + draw_mouse(); + MOUINFO->displayed = TRUE; + MOUINFO->docheck = TRUE; + MOUINFO->blockflag = 0; +} + +void GrMouseEraseCursor(void) +{ + if(MOUINFO->msstatus != 2) return; + if(MOUINFO->cursor == NULL) return; + if(MOUINFO->displayed == FALSE) return; + if(MOUINFO->blockflag != 0) return; + MOUINFO->displayed = FALSE; + MOUINFO->docheck = FALSE; + erase_mouse(); +} + +void GrMouseSetCursor(GrCursor *C) +{ + if(!MOUINFO->displayed && C && (C != MSCURSOR) && COMPATIBLE(C)) { + GrCursor *oldcursor = MSCURSOR; + if(C->displayed) GrEraseCursor(C); + MOUINFO->cursor = C; + if(MOUINFO->owncursor) GrDestroyCursor(oldcursor); + MOUINFO->owncursor = FALSE; + } +} + +void GrMouseSetColors(GrColor fg,GrColor bg) +{ + static char ptr12x16bits[] = { + 0,1,0,0,0,0,0,0,0,0,0,0, + 1,2,1,0,0,0,0,0,0,0,0,0, + 1,2,2,1,0,0,0,0,0,0,0,0, + 1,2,2,2,1,0,0,0,0,0,0,0, + 1,2,2,2,2,1,0,0,0,0,0,0, + 1,2,2,2,2,2,1,0,0,0,0,0, + 1,2,2,2,2,2,2,1,0,0,0,0, + 1,2,2,2,2,2,2,2,1,0,0,0, + 1,2,2,2,2,2,2,2,2,1,0,0, + 1,2,2,2,2,2,2,2,2,2,1,0, + 1,2,2,2,2,2,2,2,2,2,2,1, + 1,2,2,2,2,1,1,1,1,1,1,0, + 1,2,2,2,1,0,0,0,0,0,0,0, + 1,2,2,1,0,0,0,0,0,0,0,0, + 1,2,1,0,0,0,0,0,0,0,0,0, + 0,1,0,0,0,0,0,0,0,0,0,0, + }; + GrCursor *newc; + GrColor cols[3]; + if(MOUINFO->displayed) return; + cols[0] = 2; + cols[1] = bg; + cols[2] = fg; + newc = GrBuildCursor(ptr12x16bits,12,12,16,1,1,cols); + if(!newc) return; + GrMouseSetCursor(newc); + MOUINFO->owncursor = TRUE; +} + +void GrMouseSetCursorMode(int mode,...) +{ + va_list ap; + if(MOUINFO->displayed) return; + va_start(ap,mode); + switch(mode) { + case GR_M_CUR_BOX: + MOUINFO->x2 = va_arg(ap,int); + MOUINFO->y2 = va_arg(ap,int); + case GR_M_CUR_RUBBER: + case GR_M_CUR_LINE: + MOUINFO->cursmode = mode; + MOUINFO->x1 = va_arg(ap,int); + MOUINFO->y1 = va_arg(ap,int); + MOUINFO->curscolor = GrXorModeColor(va_arg(ap,GrColor)); + break; + default: + MOUINFO->cursmode = GR_M_CUR_NORMAL; + break; + } + va_end(ap); +} + +static int block(GrContext *c,int x1,int y1,int x2,int y2) +{ + int mx1,my1,mx2,my2,oldblock = MOUINFO->blockflag; + if(!c) c = CURC; + if(!MOUINFO->displayed) return(0); + if(!MOUINFO->docheck) return(0); + if(!c->gc_onscreen) return(0); + if(oldblock & ERASED) return(0); + MOUINFO->blockflag = BLOCKED; + isort(x1,x2); x1 += c->gc_xoffset; x2 += c->gc_xoffset; + isort(y1,y2); y1 += c->gc_yoffset; y2 += c->gc_yoffset; + mx1 = MSCURSOR->xwpos; + my1 = MSCURSOR->ywpos; + mx2 = MSCURSOR->xwork + mx1 - 1; + my2 = MSCURSOR->ywork + my1 - 1; + if(SPECIALMODE) { + int cx1,cy1,cx2,cy2; + switch(CURSORMODE) { + case GR_M_CUR_RUBBER: + case GR_M_CUR_LINE: + cx1 = MSCURSOR->xcord; + cy1 = MSCURSOR->ycord; + cx2 = MOUINFO->x1; + cy2 = MOUINFO->y1; + break; + case GR_M_CUR_BOX: + cx1 = MSCURSOR->xcord + MOUINFO->x1; + cy1 = MSCURSOR->ycord + MOUINFO->y1; + cx2 = MSCURSOR->xcord + MOUINFO->x2; + cy2 = MSCURSOR->ycord + MOUINFO->y2; + break; + default: + return(0); + } + isort(cx1,cx2); mx1 = imin(cx1,mx1); mx2 = imax(mx2,cx2); + isort(cy1,cy2); my1 = imin(cy1,my1); my2 = imax(my2,cy2); + } + x1 = imax(x1,mx1); y1 = imax(y1,my1); + x2 = imin(x2,mx2); y2 = imin(y2,my2); + if((x1 <= x2) && (y1 <= y2)) { + MOUINFO->blockflag = oldblock | ERASED; + MOUINFO->docheck = FALSE; + erase_mouse(); + return(ERASED); + } + return((oldblock & BLOCKED) ? 0 : BLOCKED); +} + +static void unblock(int flags) +{ + if(!MOUINFO->displayed) return; + if(flags & MOUINFO->blockflag & ERASED) { + if(!(MOUINFO->blockflag & BLOCKED) || (flags & BLOCKED)) { + _GrUpdateInputs(); + move_mouse(); + MOUINFO->blockflag &= ~BLOCKED; + } + draw_mouse(); + MOUINFO->blockflag &= ~ERASED; + MOUINFO->docheck = TRUE; + return; + } + if(flags & MOUINFO->blockflag & BLOCKED) { + if(!(MOUINFO->blockflag & ERASED)) { + int updflag; + test_unblock(updflag); + if(updflag) { + _GrUpdateInputs(); + move_mouse(); + } + } + MOUINFO->blockflag &= ~BLOCKED; + } +} + +void GrMouseUpdateCursor(void) +{ + if(MOUINFO->displayed && !MOUINFO->blockflag) { + _GrUpdateInputs(); + move_mouse(); + } +} + +void _GrInitMouseCursor(void) +{ + if(MSCURSOR && !COMPATIBLE(MSCURSOR)) { + if(MOUINFO->owncursor) { + GrCursor *obsolete = MSCURSOR; + MOUINFO->cursor = NULL; + MOUINFO->owncursor = FALSE; + GrDestroyCursor(obsolete); + } + MOUINFO->cursor = NULL; + } + if(MSCURSOR == NULL) { + GrMouseSetColors(GrAllocColor(255,0,0),GrBlack()); + } + if(MSCURSOR && MSCURSOR->displayed) { + GrEraseCursor(MSCURSOR); + } + MOUINFO->cursmode = GR_M_CUR_NORMAL; + MOUINFO->displayed = FALSE; + MOUINFO->blockflag = 0; + MOUINFO->docheck = FALSE; + MOUINFO->block = block; + MOUINFO->unblock = unblock; +} + diff --git a/thirdparty/grx249/src/mouse/mstime.c b/thirdparty/grx249/src/mouse/mstime.c new file mode 100644 index 0000000..c76ea52 --- /dev/null +++ b/thirdparty/grx249/src/mouse/mstime.c @@ -0,0 +1,27 @@ +/** + ** mstime.c ---- millisecond time + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "mouse/input.h" + +long GrMsecTime( void ) +{ + long tv; + real_time(tv); + return (tv * MS_PER_TICK); +} diff --git a/thirdparty/grx249/src/mouse/sdlinp.c b/thirdparty/grx249/src/mouse/sdlinp.c new file mode 100644 index 0000000..cbdaf4d --- /dev/null +++ b/thirdparty/grx249/src/mouse/sdlinp.c @@ -0,0 +1,324 @@ +/** + ** sdlinp.c ---- mouse and keyboard interface for SDL + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** FIXME: sdlinp/xwininp: the i18n (cyrillic etc.) keys don't work. + ** FIXME: win32: Alt-Tab-Alt-Shift-Tab nails the Alt state to unset. + ** + **/ + +#include "libsdl.h" +#include "libgrx.h" +#include "grxkeys.h" +#include "input.h" +#include "arith.h" +#include "memcopy.h" +#include "sdlinput.h" + +int _nkeyssdlpool = 0; +int _keyssdlpool[_MAXKEYSSDLPOOL]; + +static int kbd_enabled = TRUE; +static int kbd_hitcount = 0; +static int mou_enabled = TRUE; +static int mou_buttons = 0; +static long evt_lasttime; + +int _GrIsKbdEnabled(void) +{ + return kbd_enabled; +} + +int _GrKeyPressed(void) +{ + _GrUpdateInputs(); + if (kbd_enabled) + return (kbd_hitcount > 0); + else + return (_nkeyssdlpool > 0); +} + +static void uninit(void) +{ + if (MOUINFO->msstatus > 1) { + MOUINFO->msstatus = 1; + } +} + +int GrMouseDetect(void) +{ +#if defined(__WIN32__) + return(GetSystemMetrics(SM_MOUSEPRESENT)); +#else + return TRUE; +#endif +} + +void GrMouseInitN(int queue_size) +{ + uninit(); + queue_size = umax(4, umin(256, queue_size)); + init_queue(queue_size); + kbd_hitcount = 0; + if (GrMouseDetect()) { + GrMouseSetSpeed(1, 1); + GrMouseSetAccel(100, 1); + GrMouseSetLimits(0, 0, SCRN->gc_xmax, SCRN->gc_ymax); + GrMouseWarp((SCRN->gc_xmax >> 1), (SCRN->gc_ymax >> 1)); + _GrInitMouseCursor(); + MOUINFO->msstatus = 2; + mou_buttons = 0; + } + GrMouseEventEnable(TRUE, TRUE); + real_time(evt_lasttime); + MOUINFO->uninit = uninit; +} + +void GrMouseSetSpeed(int spmult, int spdiv) +{ + MOUINFO->spmult = umin(16, umax(1, spmult)); + MOUINFO->spdiv = umin(16, umax(1, spdiv)); +} + +void GrMouseSetAccel(int thresh, int accel) +{ + MOUINFO->thresh = umin(64, umax(1, thresh)); + MOUINFO->accel = umin(16, umax(1, accel)); +} + +void GrMouseSetLimits(int x1, int y1, int x2, int y2) +{ + isort(x1, x2); + isort(y1, y2); + MOUINFO->xmin = imax(0, imin(x1, SCRN->gc_xmax)); + MOUINFO->ymin = imax(0, imin(y1, SCRN->gc_ymax)); + MOUINFO->xmax = imax(0, imin(x2, SCRN->gc_xmax)); + MOUINFO->ymax = imax(0, imin(y2, SCRN->gc_ymax)); +} + +void GrMouseWarp(int x, int y) +{ + MOUINFO->xpos = imax(MOUINFO->xmin, imin(MOUINFO->xmax, x)); + MOUINFO->ypos = imax(MOUINFO->ymin, imin(MOUINFO->ymax, y)); + GrMouseUpdateCursor(); + SDL_WarpMouse(MOUINFO->xpos, MOUINFO->ypos); +} + +void GrMouseEventEnable(int enable_kb, int enable_ms) +{ + kbd_enabled = enable_kb; + mou_enabled = enable_ms; +} + +void GrMouseGetEventT(int flags, GrMouseEvent * ev, long tout) +{ + int msdraw; + + if (MOUINFO->msstatus == 0) GrMouseInit(); + + msdraw = !MOUINFO->displayed && !(flags & GR_M_NOPAINT); + if (msdraw) GrMouseDisplayCursor(); + + if (tout <= 0L) tout = 1L; + + for (;;) { + _GrUpdateInputs(); + GrMouseUpdateCursor(); + while (MOUINFO->qlength > 0) { + dequeue_event((*ev)); + if (ev->flags & GR_M_KEYPRESS) kbd_hitcount--; + if (ev->flags & flags) { + if (msdraw) GrMouseEraseCursor(); + return; + } + } + if ((flags & GR_M_POLL) || + (tout == 0L) || (MOUINFO->moved && (flags & GR_M_MOTION))) { + fill_mouse_ev((*ev), + mou_buttons, mou_buttons, + GR_M_LEFT, GR_M_MIDDLE, GR_M_RIGHT, GR_M_P4, GR_M_P5, GrKeyStat()); + if (ev->flags) /* something happend */ + real_dtime(ev->dtime, evt_lasttime); + else + ev->dtime = -1; /* special time if nothing happend */ + MOUINFO->moved = FALSE; + if (msdraw) { + GrMouseEraseCursor(); + } + return; + } + if (tout > 0L) { + SDL_Delay(10); + if ((tout -= 10) < 0L) tout = 0L; + } + } +} + +#if defined(__XWIN__) +#define DSC 0x08 +#else +#define DSC 0x00 +#endif + +static GrKeyType StdKeyTranslate(SDL_keysym *keysym) +{ + keytrans *k; + int i; + + /*printf("scancode = %x, unicode = %d , sym = %d, mod = %x\n", + keysym->scancode, keysym->unicode, keysym->sym, keysym->mod);*/ + + if (keysym->mod & KMOD_ALT) { + if(keysym->scancode >= 0x10+DSC && keysym->scancode <= 0x35+DSC) + return(keysym->scancode + 0x100-DSC); + if(keysym->scancode >= 0x02+DSC && keysym->scancode <= 0x0d+DSC) + return(keysym->scancode + 0x176-DSC); + k = altstdkeys; + } + else if (keysym->mod & KMOD_CTRL) k = controlstdkeys; + else if (keysym->mod & KMOD_SHIFT) k = shiftstdkeys; + else k = stdkeys; + + if(keysym->sym >= SDLK_KP0 && keysym->sym <= SDLK_KP_PERIOD) { + if(k == stdkeys && (keysym->mod & KMOD_NUM)) + return(numchars[keysym->sym - SDLK_KP0]); + keysym->sym = numkeys[keysym->sym - SDLK_KP0]; + } + + for (i = 0; i < NSTDKEYS; i++) + if (keysym->sym == k[i].sdlkey) return k[i].grkey; + + return(keysym->unicode & 0xFF); +} + +static int DequeueSDLEvent(GrMouseEvent *ev) +{ + SDL_Event event; + GrKeyType key; + int buttons; + static int quit = FALSE; + +#if defined(__WIN32__) + if(!_SGrActive) { + do SDL_WaitEvent(&event); while(!_SGrActive); + if(_SGrBackup != NULL) { + if(!SDL_LockSurface(_SGrScreen)) { + memcpy(_SGrScreen->pixels, _SGrBackup, _SGrLength); + SDL_UnlockSurface(_SGrScreen); + } + free(_SGrBackup); + _SGrBackup = NULL; + } + } +#endif + + if(SDL_PollEvent(&event) == 0) + return(0); + + switch(event.type) { + + case SDL_KEYDOWN : + if((key = StdKeyTranslate(&event.key.keysym)) != 0) { + fill_keybd_ev((*ev), key, event.key.keysym.mod); + return(1); + } + return(-1); + + case SDL_MOUSEBUTTONDOWN : + switch(event.button.button) { + case SDL_BUTTON_LEFT : buttons = GR_M_LEFT | mou_buttons; break; + case SDL_BUTTON_RIGHT : buttons = GR_M_RIGHT | mou_buttons; break; + case SDL_BUTTON_MIDDLE : buttons = GR_M_MIDDLE | mou_buttons; break; + case SDL_BUTTON_WHEELUP: buttons = GR_M_P4 | mou_buttons; break; + case SDL_BUTTON_WHEELDOWN : buttons = GR_M_P5 | mou_buttons; break; + default : return(-1); + } + fill_mouse_ev((*ev), mou_buttons, buttons, GR_M_LEFT, + GR_M_MIDDLE, GR_M_RIGHT, GR_M_P4, GR_M_P5, GrKeyStat()); + mou_buttons = buttons; + MOUINFO->moved = FALSE; + return(1); + + case SDL_MOUSEBUTTONUP : + switch(event.button.button) { + case SDL_BUTTON_LEFT : buttons = ~GR_M_LEFT & mou_buttons; break; + case SDL_BUTTON_RIGHT : buttons = ~GR_M_RIGHT & mou_buttons; break; + case SDL_BUTTON_MIDDLE : buttons = ~GR_M_MIDDLE & mou_buttons; break; + case SDL_BUTTON_WHEELUP: buttons = ~GR_M_P4 & mou_buttons; break; + case SDL_BUTTON_WHEELDOWN : buttons = ~GR_M_P5 & mou_buttons; break; + default : return(-1); + } + fill_mouse_ev((*ev), mou_buttons, buttons, GR_M_LEFT, + GR_M_MIDDLE, GR_M_RIGHT, GR_M_P4, GR_M_P5, GrKeyStat()); + mou_buttons = buttons; + MOUINFO->moved = FALSE; + return(1); + + case SDL_MOUSEMOTION : + MOUINFO->xpos = event.motion.x; + MOUINFO->ypos = event.motion.y; + MOUINFO->moved = TRUE; + return(-1); + + case SDL_QUIT : +#if defined(__WIN32__) + if((_SGrScreen->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { + if(!quit) { + MessageBeep(0xFFFFFFFF); + quit = TRUE; + return(-1); + } + } + else if(MessageBox(NULL, "Abort the program?", "GRX", MB_APPLMODAL | + MB_ICONQUESTION | MB_YESNO) != IDYES) return(-1); +#elif defined(__XWIN__) + if(!quit) { + if(isatty(fileno(stderr))) + fputs("GRX: request quit again to abort the program.\a\n", + stderr); + quit = TRUE; + return(-1); + } +#endif + exit(1); + + default : + return(-1); + + } +} + +void _GrUpdateInputs(void) +{ + GrMouseEvent ev; + int r; + + if(SDL_MUSTLOCK(_SGrScreen)) SDL_UnlockSurface(_SGrScreen); + while ((r = DequeueSDLEvent(&ev)) != 0) { + if (r > 0) { + if (ev.flags & GR_M_KEYPRESS && !kbd_enabled){ + if (_nkeyssdlpool < _MAXKEYSSDLPOOL) + _keyssdlpool[_nkeyssdlpool++] = ev.key; + } + else{ + real_dtime(ev.dtime, evt_lasttime); + enqueue_event(ev); + if (ev.flags & GR_M_KEYPRESS) kbd_hitcount++; + } + } + } + if(SDL_MUSTLOCK(_SGrScreen)) SDL_LockSurface(_SGrScreen); +} + diff --git a/thirdparty/grx249/src/mouse/sdlinput.h b/thirdparty/grx249/src/mouse/sdlinput.h new file mode 100644 index 0000000..216c9e6 --- /dev/null +++ b/thirdparty/grx249/src/mouse/sdlinput.h @@ -0,0 +1,189 @@ +/** + ** sdlinput.h ---- SDL to GRX keys conversion tables + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef _SDLINPUT_H_ +#define _SDLINPUT_H_ + +typedef struct { + SDLKey sdlkey; + GrKeyType grkey; +} keytrans; + +#define NSTDKEYS 33 + +static keytrans stdkeys[NSTDKEYS] = { + { SDLK_PAGEUP, GrKey_PageUp }, + { SDLK_PAGEDOWN, GrKey_PageDown }, + { SDLK_END, GrKey_End }, + { SDLK_HOME, GrKey_Home }, + { SDLK_LEFT, GrKey_Left }, + { SDLK_UP, GrKey_Up }, + { SDLK_RIGHT, GrKey_Right }, + { SDLK_DOWN, GrKey_Down }, + { SDLK_INSERT, GrKey_Insert }, + { SDLK_DELETE, GrKey_Delete }, + { SDLK_F1, GrKey_F1 }, + { SDLK_F2, GrKey_F2 }, + { SDLK_F3, GrKey_F3 }, + { SDLK_F4, GrKey_F4 }, + { SDLK_F5, GrKey_F5 }, + { SDLK_F6, GrKey_F6 }, + { SDLK_F7, GrKey_F7 }, + { SDLK_F8, GrKey_F8 }, + { SDLK_F9, GrKey_F9 }, + { SDLK_F10, GrKey_F10 }, + { SDLK_F11, GrKey_F11 }, + { SDLK_F12, GrKey_F12 }, + { SDLK_KP5, GrKey_Center }, + { SDLK_KP_DIVIDE, GrKey_Slash }, + { SDLK_KP_MULTIPLY, GrKey_Star }, + { SDLK_KP_MINUS, GrKey_Dash }, + { SDLK_KP_PLUS, GrKey_Plus }, + { SDLK_KP_ENTER, GrKey_Return }, + { SDLK_KP_EQUALS, GrKey_Equals }, + { SDLK_BACKSPACE, GrKey_BackSpace }, + { SDLK_TAB, GrKey_Tab }, + { SDLK_RETURN, GrKey_Return }, + { SDLK_ESCAPE, GrKey_Escape } +}; + +static keytrans altstdkeys[NSTDKEYS] = { + { SDLK_PAGEUP, GrKey_Alt_PageUp }, + { SDLK_PAGEDOWN, GrKey_Alt_PageDown }, + { SDLK_END, GrKey_Alt_End }, + { SDLK_HOME, GrKey_Alt_Home }, + { SDLK_LEFT, GrKey_Alt_Left }, + { SDLK_UP, GrKey_Alt_Up }, + { SDLK_RIGHT, GrKey_Alt_Right }, + { SDLK_DOWN, GrKey_Alt_Down }, + { SDLK_INSERT, GrKey_Alt_Insert }, + { SDLK_DELETE, GrKey_Alt_Delete }, + { SDLK_F1, GrKey_Alt_F1 }, + { SDLK_F2, GrKey_Alt_F2 }, + { SDLK_F3, GrKey_Alt_F3 }, + { SDLK_F4, GrKey_Alt_F4 }, + { SDLK_F5, GrKey_Alt_F5 }, + { SDLK_F6, GrKey_Alt_F6 }, + { SDLK_F7, GrKey_Alt_F7 }, + { SDLK_F8, GrKey_Alt_F8 }, + { SDLK_F9, GrKey_Alt_F9 }, + { SDLK_F10, GrKey_Alt_F10 }, + { SDLK_F11, GrKey_Alt_F11 }, + { SDLK_F12, GrKey_Alt_F12 }, + { SDLK_KP5, GrKey_Alt_Center }, + { SDLK_KP_DIVIDE, GrKey_Alt_KPSlash }, + { SDLK_KP_MULTIPLY, GrKey_Alt_KPStar }, + { SDLK_KP_MINUS, GrKey_Alt_KPMinus }, + { SDLK_KP_PLUS, GrKey_Alt_KPPlus }, + { SDLK_KP_ENTER, GrKey_Alt_Enter }, + { SDLK_KP_EQUALS, GrKey_Alt_Equals }, + { SDLK_BACKSPACE, GrKey_Alt_Backspace }, + { SDLK_TAB, GrKey_Alt_Tab }, + { SDLK_RETURN, GrKey_Alt_Return }, + { SDLK_ESCAPE, GrKey_Alt_Escape } +}; + +static keytrans controlstdkeys[NSTDKEYS] = { + { SDLK_PAGEUP, GrKey_Control_PageUp }, + { SDLK_PAGEDOWN, GrKey_Control_PageDown }, + { SDLK_END, GrKey_Control_End }, + { SDLK_HOME, GrKey_Control_Home }, + { SDLK_LEFT, GrKey_Control_Left }, + { SDLK_UP, GrKey_Control_Up }, + { SDLK_RIGHT, GrKey_Control_Right }, + { SDLK_DOWN, GrKey_Control_Down }, + { SDLK_INSERT, GrKey_Control_Insert }, + { SDLK_DELETE, GrKey_Control_Delete }, + { SDLK_F1, GrKey_Control_F1 }, + { SDLK_F2, GrKey_Control_F2 }, + { SDLK_F3, GrKey_Control_F3 }, + { SDLK_F4, GrKey_Control_F4 }, + { SDLK_F5, GrKey_Control_F5 }, + { SDLK_F6, GrKey_Control_F6 }, + { SDLK_F7, GrKey_Control_F7 }, + { SDLK_F8, GrKey_Control_F8 }, + { SDLK_F9, GrKey_Control_F9 }, + { SDLK_F10, GrKey_Control_F10 }, + { SDLK_F11, GrKey_Control_F11 }, + { SDLK_F12, GrKey_Control_F12 }, + { SDLK_KP5, GrKey_Control_Center }, + { SDLK_KP_DIVIDE, GrKey_Control_KPSlash }, + { SDLK_KP_MULTIPLY, GrKey_Control_KPStar }, + { SDLK_KP_MINUS, GrKey_Control_KPDash }, + { SDLK_KP_PLUS, GrKey_Control_KPPlus }, + { SDLK_KP_ENTER, GrKey_LineFeed }, + { SDLK_KP_EQUALS, GrKey_NoKey }, + { SDLK_BACKSPACE, GrKey_Control_Backspace }, + { SDLK_TAB, GrKey_Control_Tab }, + { SDLK_RETURN, GrKey_LineFeed }, + { SDLK_ESCAPE, GrKey_NoKey } +}; + +static keytrans shiftstdkeys[NSTDKEYS] = { + { SDLK_PAGEUP, GrKey_Shift_PageUp }, + { SDLK_PAGEDOWN, GrKey_Shift_PageDown }, + { SDLK_END, GrKey_Shift_End }, + { SDLK_HOME, GrKey_Shift_Home }, + { SDLK_LEFT, GrKey_Shift_Left }, + { SDLK_UP, GrKey_Shift_Up }, + { SDLK_RIGHT, GrKey_Shift_Right }, + { SDLK_DOWN, GrKey_Shift_Down }, + { SDLK_INSERT, GrKey_Shift_Insert }, + { SDLK_DELETE, GrKey_NoKey }, + { SDLK_F1, GrKey_Shift_F1 }, + { SDLK_F2, GrKey_Shift_F2 }, + { SDLK_F3, GrKey_Shift_F3 }, + { SDLK_F4, GrKey_Shift_F4 }, + { SDLK_F5, GrKey_Shift_F5 }, + { SDLK_F6, GrKey_Shift_F6 }, + { SDLK_F7, GrKey_Shift_F7 }, + { SDLK_F8, GrKey_Shift_F8 }, + { SDLK_F9, GrKey_Shift_F9 }, + { SDLK_F10, GrKey_Shift_F10 }, + { SDLK_F11, GrKey_Shift_F11 }, + { SDLK_F12, GrKey_Shift_F12 }, + { SDLK_KP5, GrKey_NoKey }, + { SDLK_KP_DIVIDE, GrKey_Slash }, + { SDLK_KP_MULTIPLY, GrKey_Star }, + { SDLK_KP_MINUS, GrKey_Dash }, + { SDLK_KP_PLUS, GrKey_Plus }, + { SDLK_KP_ENTER, GrKey_Return }, + { SDLK_KP_EQUALS, GrKey_Equals }, + { SDLK_BACKSPACE, GrKey_BackSpace }, + { SDLK_TAB, GrKey_BackTab }, + { SDLK_RETURN, GrKey_Return }, + { SDLK_ESCAPE, GrKey_Escape } +}; + +static char *numchars = "0123456789."; + +static GrKeyType numkeys[] = { + SDLK_INSERT, + SDLK_END, + SDLK_DOWN, + SDLK_PAGEDOWN, + SDLK_LEFT, + SDLK_KP5, + SDLK_RIGHT, + SDLK_HOME, + SDLK_UP, + SDLK_PAGEUP, + SDLK_DELETE +}; + +#endif diff --git a/thirdparty/grx249/src/mouse/sdlkeys.c b/thirdparty/grx249/src/mouse/sdlkeys.c new file mode 100644 index 0000000..2975493 --- /dev/null +++ b/thirdparty/grx249/src/mouse/sdlkeys.c @@ -0,0 +1,109 @@ +/** + ** sdlkeys.c ---- DOS (TCC/BCC/DJGPP: "conio.h") style keyboard utilities + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libsdl.h" +#include "libgrx.h" +#include "input.h" +#include "grxkeys.h" + +int GrKeyPressed(void) +{ + if (MOUINFO->msstatus < 2) { + GrMouseInit(); + GrMouseEventEnable(1, 0); + } + return _GrKeyPressed(); +} + +GrKeyType GrKeyRead(void) +{ + GrMouseEvent ev; + int i, key; + + if (!_GrIsKbdEnabled()) { + while (_nkeyssdlpool < 1) + _GrUpdateInputs(); + key = _keyssdlpool[0]; + for (i = 0; i < _nkeyssdlpool; i++) + _keyssdlpool[i] = _keyssdlpool[i + 1]; + _nkeyssdlpool--; + return key; + } + + if (MOUINFO->msstatus < 2) { + GrMouseInit(); + GrMouseEventEnable(1, 0); + } + for (;;) { + GrMouseGetEvent((GR_M_EVENT | GR_M_NOPAINT), &ev); + if (ev.flags & GR_M_KEYPRESS) { + return (ev.key); + } + } +} + +int GrKeyStat(void) +{ + static SDLMod trans[8] = { + KMOD_RSHIFT, KMOD_LSHIFT, KMOD_CTRL, KMOD_ALT, + KMOD_SCROLL, KMOD_NUM, KMOD_CAPS, KMOD_INSERT + }; + + SDLMod mod = SDL_GetModState(); + int i, state = 0; + + for(i = 0; i < 8; i++) + if (mod & trans[i]) state |= 1 << i; + + return(state); +} + +int kbhit(void) +{ + return GrKeyPressed(); +} + +int getkey(void) +{ + return (int)GrKeyRead(); +} + +int getch(void) +{ + static int lastkey = (-1); + int key; + + if (lastkey != (-1)) { + key = lastkey; + lastkey = (-1); + return (key); + } + key = getkey(); + if (key < 0x100) { + return (key); + } + lastkey = key & 0xff; + + return (0); +} + +int getkbstat(void) +{ + return GrKeyStat(); +} + diff --git a/thirdparty/grx249/src/mouse/w32inp.c b/thirdparty/grx249/src/mouse/w32inp.c new file mode 100644 index 0000000..07e0263 --- /dev/null +++ b/thirdparty/grx249/src/mouse/w32inp.c @@ -0,0 +1,391 @@ +/** + ** w32inp.c ---- DOS (TCC/BCC/DJGPP: "conio.h") style keyboard utilities + ** + ** Author: Gernot Graeff + ** E-mail: gernot.graeff@t-online.de + ** Date: 02-11-99 + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by M.Alvarez (malfer@teleline.es) 18/11/2001 + ** - Better keys handling using translation tables (w32input.h). + ** + ** Contributions by M.Alvarez (malfer@teleline.es) 02/02/2002 + ** - The w32 imput queue implemented as a circular queue. + ** - All the input related code moved here from vd_win32.c + ** + ** Contribution by M. Lombardi 05/08/2007 + ** Do not treat WM_PAINT messages here. They are delt with in vd_win32.c. + ** This produced saturation of GRX event queue and gobbling of + ** keyboard/mouse events there (compare behavior of test/mousetst) + ** + ** Contribution by Richard Sanders (richard@dogcreek.ca) 02/04/2009 + ** Synchronisation of windows and grx mouse cursors + **/ + +#include "libwin32.h" +#include "libgrx.h" +#include "grxkeys.h" +#include "input.h" +#include "arith.h" +#include "memcopy.h" +#include "w32input.h" + +int _nkeysw32pool = 0; +int _keysw32pool[_MAXKEYSW32POOL]; + +static int kbd_enabled = TRUE; +static int kbd_lastmod = 0; +static int kbd_hitcount = 0; +static int mou_enabled = TRUE; +static int mou_buttons = 0; +static long evt_lasttime; + +int _GrIsKbdEnabled(void) +{ + return kbd_enabled; +} + +int _GrKeyPressed(void) +{ + _GrUpdateInputs(); + if (kbd_enabled) + return (kbd_hitcount > 0); + else + return (_nkeysw32pool > 0); +} + +int _GrKeyStat(void) +{ + return kbd_lastmod; +} + +static void uninit(void) +{ + if (MOUINFO->msstatus > 1) { + MOUINFO->msstatus = 1; + } +} + +int GrMouseDetect(void) +{ + return GetSystemMetrics(SM_MOUSEPRESENT); +} + +static void init_w32queue(int queue_size) +{ + EnterCriticalSection(&_csEventQueue); + if (_W32EventQueueSize != queue_size) { + if (_W32EventQueue != NULL) + free(_W32EventQueue); + _W32EventQueue = (W32Event *)malloc(sizeof(W32Event) * queue_size); + _W32EventQueueSize = _W32EventQueue ? queue_size : 0; + } + _W32EventQueueRead = 0; + _W32EventQueueWrite = 0; + _W32EventQueueLength = 0; + LeaveCriticalSection(&_csEventQueue); +} + +void GrMouseInitN(int queue_size) +{ + uninit(); + queue_size = umax(4, umin(256, queue_size)); + init_queue(queue_size); + init_w32queue(queue_size); + kbd_hitcount = 0; + if (GrMouseDetect()) { + GrMouseSetSpeed(1, 1); + GrMouseSetAccel(100, 1); + GrMouseSetLimits(0, 0, SCRN->gc_xmax, SCRN->gc_ymax); + GrMouseWarp((SCRN->gc_xmax >> 1), (SCRN->gc_ymax >> 1)); + _GrInitMouseCursor(); + MOUINFO->msstatus = 2; + mou_buttons = 0; + } + GrMouseEventEnable(TRUE, TRUE); + real_time(evt_lasttime); + MOUINFO->uninit = uninit; +} + +void GrMouseSetSpeed(int spmult, int spdiv) +{ + MOUINFO->spmult = umin(16, umax(1, spmult)); + MOUINFO->spdiv = umin(16, umax(1, spdiv)); +} + +void GrMouseSetAccel(int thresh, int accel) +{ + MOUINFO->thresh = umin(64, umax(1, thresh)); + MOUINFO->accel = umin(16, umax(1, accel)); +} + +void GrMouseSetLimits(int x1, int y1, int x2, int y2) +{ + isort(x1, x2); + isort(y1, y2); + MOUINFO->xmin = imax(0, imin(x1, SCRN->gc_xmax)); + MOUINFO->ymin = imax(0, imin(y1, SCRN->gc_ymax)); + MOUINFO->xmax = imax(0, imin(x2, SCRN->gc_xmax)); + MOUINFO->ymax = imax(0, imin(y2, SCRN->gc_ymax)); +} + +void GrMouseWarp(int x, int y) +{ + POINT point; + + MOUINFO->xpos = imax(MOUINFO->xmin, imin(MOUINFO->xmax, x)); + MOUINFO->ypos = imax(MOUINFO->ymin, imin(MOUINFO->ymax, y)); + GrMouseUpdateCursor(); + point.x = MOUINFO->xpos; + point.y = MOUINFO->ypos; + ClientToScreen(hGRXWnd, &point); + SetCursorPos(point.x, point.y); +} + +void GrMouseEventEnable(int enable_kb, int enable_ms) +{ + kbd_enabled = enable_kb; + mou_enabled = enable_ms; +} + +void GrMouseGetEventT(int flags, GrMouseEvent * ev, long tout) +{ + int msdraw; + + if (MOUINFO->msstatus == 0) GrMouseInit(); + + msdraw = !MOUINFO->displayed && !(flags & GR_M_NOPAINT); + if (msdraw) GrMouseDisplayCursor(); + + if (tout <= 0L) tout = 1L; + + for (;;) { + _GrUpdateInputs(); + GrMouseUpdateCursor(); + while (MOUINFO->qlength > 0) { + dequeue_event((*ev)); + if (ev->flags & GR_M_KEYPRESS) kbd_hitcount--; + if (ev->flags & flags) { + if (msdraw) GrMouseEraseCursor(); + return; + } + } + if ((flags & GR_M_POLL) || + (tout == 0L) || (MOUINFO->moved && (flags & GR_M_MOTION))) { + fill_mouse_ev((*ev), + mou_buttons, mou_buttons, + GR_M_LEFT, GR_M_MIDDLE, GR_M_RIGHT, GR_M_P4, GR_M_P5, kbd_lastmod); + if (ev->flags) /* something happend */ + real_dtime(ev->dtime, evt_lasttime); + else + ev->dtime = -1; /* special time if nothing happend */ + MOUINFO->moved = FALSE; + if (msdraw) { + GrMouseEraseCursor(); + } + return; + } + if (tout > 0L) { + Sleep(10); + if ((tout -= 10) < 0L) tout = 0L; + } + } +} + +static GrKeyType StdKeyTranslate(int winkey, int fkbState) +{ + keytrans *k; + int i; + + if (fkbState & GR_KB_ALT) + k = altstdkeys; + else if (fkbState & GR_KB_CTRL) + k = controlstdkeys; + else if (fkbState & GR_KB_SHIFT) + k = shiftstdkeys; + else + k = stdkeys; + + for (i = 0; i < NSTDKEYS; i++) { + if (winkey == k[i].winkey) + return k[i].grkey; + } + + return 0; +} + +static int DequeueW32Event(GrMouseEvent * ev) +{ + W32Event evaux; + int key; + int buttons; + + if (_W32EventQueueLength < 1){ + Sleep(1); /* yield */ + return 0; + } + + EnterCriticalSection(&_csEventQueue); +// if (!TryEnterCriticalSection(&_csEventQueue)) +// return 0; + + evaux = _W32EventQueue[_W32EventQueueRead]; + if (++_W32EventQueueRead == _W32EventQueueSize) + _W32EventQueueRead = 0; + _W32EventQueueLength--; + LeaveCriticalSection(&_csEventQueue); + + switch (evaux.uMsg) { + + case WM_CHAR: + fill_keybd_ev((*ev), evaux.wParam, evaux.kbstat); + kbd_lastmod = evaux.kbstat; + return 1; + + case WM_SYSCHAR: + key = 0; + if (evaux.wParam >= 'a' && evaux.wParam <= 'z') + key = altletters[evaux.wParam - 'a']; + if (evaux.wParam >= 'A' && evaux.wParam <= 'Z') + key = altletters[evaux.wParam - 'A']; + if (evaux.wParam >= '0' && evaux.wParam <= '9') + key = altnumbers[evaux.wParam - '0']; + if (key == 0) + return -1; + fill_keybd_ev((*ev), key, evaux.kbstat); + kbd_lastmod = evaux.kbstat; + return 1; + + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + key = StdKeyTranslate(evaux.wParam, evaux.kbstat); + if (key == 0) + return -1; + fill_keybd_ev((*ev), key, evaux.kbstat); + kbd_lastmod = evaux.kbstat; + return 1; + + case WM_COMMAND: + fill_cmd_ev((*ev), evaux.wParam, evaux.kbstat); + return 1; + + case WM_LBUTTONDOWN: + buttons = GR_M_LEFT | mou_buttons; + MOUINFO->xpos = LOWORD(evaux.lParam); + MOUINFO->ypos = HIWORD(evaux.lParam); + fill_mouse_ev((*ev), mou_buttons, buttons, GR_M_LEFT, + GR_M_MIDDLE, GR_M_RIGHT, GR_M_P4, GR_M_P5, evaux.kbstat); + mou_buttons = buttons; + MOUINFO->moved = FALSE; + kbd_lastmod = evaux.kbstat; + return 1; + + case WM_MBUTTONDOWN: + buttons = GR_M_MIDDLE | mou_buttons; + MOUINFO->xpos = LOWORD(evaux.lParam); + MOUINFO->ypos = HIWORD(evaux.lParam); + fill_mouse_ev((*ev), mou_buttons, buttons, GR_M_LEFT, + GR_M_MIDDLE, GR_M_RIGHT, GR_M_P4, GR_M_P5, evaux.kbstat); + mou_buttons = buttons; + MOUINFO->moved = FALSE; + kbd_lastmod = evaux.kbstat; + return 1; + + case WM_RBUTTONDOWN: + buttons = GR_M_RIGHT | mou_buttons; + MOUINFO->xpos = LOWORD(evaux.lParam); + MOUINFO->ypos = HIWORD(evaux.lParam); + fill_mouse_ev((*ev), mou_buttons, buttons, GR_M_LEFT, + GR_M_MIDDLE, GR_M_RIGHT, GR_M_P4, GR_M_P5, evaux.kbstat); + mou_buttons = buttons; + MOUINFO->moved = FALSE; + kbd_lastmod = evaux.kbstat; + return 1; + + case WM_LBUTTONUP: + buttons = ~GR_M_LEFT & mou_buttons; + MOUINFO->xpos = LOWORD(evaux.lParam); + MOUINFO->ypos = HIWORD(evaux.lParam); + fill_mouse_ev((*ev), mou_buttons, buttons, GR_M_LEFT, + GR_M_MIDDLE, GR_M_RIGHT, GR_M_P4, GR_M_P5, evaux.kbstat); + mou_buttons = buttons; + MOUINFO->moved = FALSE; + kbd_lastmod = evaux.kbstat; + return 1; + + case WM_MBUTTONUP: + buttons = ~GR_M_MIDDLE & mou_buttons; + MOUINFO->xpos = LOWORD(evaux.lParam); + MOUINFO->ypos = HIWORD(evaux.lParam); + fill_mouse_ev((*ev), mou_buttons, buttons, GR_M_LEFT, + GR_M_MIDDLE, GR_M_RIGHT, GR_M_P4, GR_M_P5, evaux.kbstat); + mou_buttons = buttons; + MOUINFO->moved = FALSE; + kbd_lastmod = evaux.kbstat; + return 1; + + case WM_RBUTTONUP: + buttons = ~GR_M_RIGHT & mou_buttons; + MOUINFO->xpos = LOWORD(evaux.lParam); + MOUINFO->ypos = HIWORD(evaux.lParam); + fill_mouse_ev((*ev), mou_buttons, buttons, GR_M_LEFT, + GR_M_MIDDLE, GR_M_RIGHT, GR_M_P4, GR_M_P5, evaux.kbstat); + mou_buttons = buttons; + MOUINFO->moved = FALSE; + kbd_lastmod = evaux.kbstat; + return 1; + + case WM_MOUSEWHEEL: + buttons = mou_buttons ^ (((short)HIWORD(evaux.wParam) > 0) ? + GR_M_P4 : GR_M_P5); + MOUINFO->xpos = LOWORD(evaux.lParam); + MOUINFO->ypos = HIWORD(evaux.lParam); + fill_mouse_ev((*ev), mou_buttons, buttons, GR_M_LEFT, + GR_M_MIDDLE, GR_M_RIGHT, GR_M_P4, GR_M_P5, evaux.kbstat); + mou_buttons = buttons; + MOUINFO->moved = FALSE; + kbd_lastmod = evaux.kbstat; + return 1; + + case WM_MOUSEMOVE: + MOUINFO->xpos = LOWORD(evaux.lParam); + MOUINFO->ypos = HIWORD(evaux.lParam); + MOUINFO->moved = TRUE; + ev->kbstat = evaux.kbstat; + kbd_lastmod = evaux.kbstat; + return -1; + + default: + return -1; + + } +} + +void _GrUpdateInputs(void) +{ + GrMouseEvent ev; + int r; + + while ((r = DequeueW32Event(&ev)) != 0) { + if (r > 0) { + if (ev.flags & GR_M_KEYPRESS && !kbd_enabled){ + if (_nkeysw32pool < _MAXKEYSW32POOL) + _keysw32pool[_nkeysw32pool++] = ev.key; + } + else{ + real_dtime(ev.dtime, evt_lasttime); + enqueue_event(ev); + if (ev.flags & GR_M_KEYPRESS) kbd_hitcount++; + } + } + } +} diff --git a/thirdparty/grx249/src/mouse/w32input.h b/thirdparty/grx249/src/mouse/w32input.h new file mode 100644 index 0000000..41eabfe --- /dev/null +++ b/thirdparty/grx249/src/mouse/w32input.h @@ -0,0 +1,171 @@ +/** + ** w32input.h ---- Win32 to GRX keys conversion tables + ** + ** Copyright (C) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef _W32INPUT_H_ +#define _W32INPUT_H_ + +typedef struct { + int winkey; + GrKeyType grkey; +} keytrans; + +#define NSTDKEYS 22 + +static keytrans stdkeys[NSTDKEYS] = { + {VK_PRIOR, GrKey_PageUp}, + {VK_NEXT, GrKey_PageDown}, + {VK_END, GrKey_End}, + {VK_HOME, GrKey_Home}, + {VK_LEFT, GrKey_Left}, + {VK_UP, GrKey_Up}, + {VK_RIGHT, GrKey_Right}, + {VK_DOWN, GrKey_Down}, + {VK_INSERT, GrKey_Insert}, + {VK_DELETE, GrKey_Delete}, + {VK_F1, GrKey_F1}, + {VK_F2, GrKey_F2}, + {VK_F3, GrKey_F3}, + {VK_F4, GrKey_F4}, + {VK_F5, GrKey_F5}, + {VK_F6, GrKey_F6}, + {VK_F7, GrKey_F7}, + {VK_F8, GrKey_F8}, + {VK_F9, GrKey_F9}, + {VK_F10, GrKey_F10}, + {VK_F11, GrKey_F11}, + {VK_F12, GrKey_F12} +}; + +static keytrans altstdkeys[NSTDKEYS] = { + {VK_PRIOR, GrKey_Alt_PageUp}, + {VK_NEXT, GrKey_Alt_PageDown}, + {VK_END, GrKey_Alt_End}, + {VK_HOME, GrKey_Alt_Home}, + {VK_LEFT, GrKey_Alt_Left}, + {VK_UP, GrKey_Alt_Up}, + {VK_RIGHT, GrKey_Alt_Right}, + {VK_DOWN, GrKey_Alt_Down}, + {VK_INSERT, GrKey_Alt_Insert}, + {VK_DELETE, GrKey_Alt_Delete}, + {VK_F1, GrKey_Alt_F1}, + {VK_F2, GrKey_Alt_F2}, + {VK_F3, GrKey_Alt_F3}, + {VK_F4, GrKey_Alt_F4}, + {VK_F5, GrKey_Alt_F5}, + {VK_F6, GrKey_Alt_F6}, + {VK_F7, GrKey_Alt_F7}, + {VK_F8, GrKey_Alt_F8}, + {VK_F9, GrKey_Alt_F9}, + {VK_F10, GrKey_Alt_F10}, + {VK_F11, GrKey_Alt_F11}, + {VK_F12, GrKey_Alt_F12} +}; + +static keytrans controlstdkeys[NSTDKEYS] = { + {VK_PRIOR, GrKey_Control_PageUp}, + {VK_NEXT, GrKey_Control_PageDown}, + {VK_END, GrKey_Control_End}, + {VK_HOME, GrKey_Control_Home}, + {VK_LEFT, GrKey_Control_Left}, + {VK_UP, GrKey_Control_Up}, + {VK_RIGHT, GrKey_Control_Right}, + {VK_DOWN, GrKey_Control_Down}, + {VK_INSERT, GrKey_Control_Insert}, + {VK_DELETE, GrKey_Control_Delete}, + {VK_F1, GrKey_Control_F1}, + {VK_F2, GrKey_Control_F2}, + {VK_F3, GrKey_Control_F3}, + {VK_F4, GrKey_Control_F4}, + {VK_F5, GrKey_Control_F5}, + {VK_F6, GrKey_Control_F6}, + {VK_F7, GrKey_Control_F7}, + {VK_F8, GrKey_Control_F8}, + {VK_F9, GrKey_Control_F9}, + {VK_F10, GrKey_Control_F10}, + {VK_F11, GrKey_Control_F11}, + {VK_F12, GrKey_Control_F12} +}; + +static keytrans shiftstdkeys[NSTDKEYS] = { + {VK_PRIOR, GrKey_Shift_PageUp}, + {VK_NEXT, GrKey_Shift_PageDown}, + {VK_END, GrKey_Shift_End}, + {VK_HOME, GrKey_Shift_Home}, + {VK_LEFT, GrKey_Shift_Left}, + {VK_UP, GrKey_Shift_Up}, + {VK_RIGHT, GrKey_Shift_Right}, + {VK_DOWN, GrKey_Shift_Down}, + {VK_INSERT, GrKey_Shift_Insert}, + {VK_DELETE, 0}, + {VK_F1, GrKey_Shift_F1}, + {VK_F2, GrKey_Shift_F2}, + {VK_F3, GrKey_Shift_F3}, + {VK_F4, GrKey_Shift_F4}, + {VK_F5, GrKey_Shift_F5}, + {VK_F6, GrKey_Shift_F6}, + {VK_F7, GrKey_Shift_F7}, + {VK_F8, GrKey_Shift_F8}, + {VK_F9, GrKey_Shift_F9}, + {VK_F10, GrKey_Shift_F10}, + {VK_F11, GrKey_Shift_F11}, + {VK_F12, GrKey_Shift_F12} +}; + +static GrKeyType altletters[] = { + GrKey_Alt_A, + GrKey_Alt_B, + GrKey_Alt_C, + GrKey_Alt_D, + GrKey_Alt_E, + GrKey_Alt_F, + GrKey_Alt_G, + GrKey_Alt_H, + GrKey_Alt_I, + GrKey_Alt_J, + GrKey_Alt_K, + GrKey_Alt_L, + GrKey_Alt_M, + GrKey_Alt_N, + GrKey_Alt_O, + GrKey_Alt_P, + GrKey_Alt_Q, + GrKey_Alt_R, + GrKey_Alt_S, + GrKey_Alt_T, + GrKey_Alt_U, + GrKey_Alt_V, + GrKey_Alt_W, + GrKey_Alt_X, + GrKey_Alt_Y, + GrKey_Alt_Z +}; + +static GrKeyType altnumbers[] = { + GrKey_Alt_0, + GrKey_Alt_1, + GrKey_Alt_2, + GrKey_Alt_3, + GrKey_Alt_4, + GrKey_Alt_5, + GrKey_Alt_6, + GrKey_Alt_7, + GrKey_Alt_8, + GrKey_Alt_9 +}; + +#endif diff --git a/thirdparty/grx249/src/mouse/w32keys.c b/thirdparty/grx249/src/mouse/w32keys.c new file mode 100644 index 0000000..55ab4ee --- /dev/null +++ b/thirdparty/grx249/src/mouse/w32keys.c @@ -0,0 +1,99 @@ +/** + ** w32keys.c ---- DOS (TCC/BCC/DJGPP: "conio.h") style keyboard utilities + ** + ** Author: Gernot Graeff + ** E-mail: gernot.graeff@t-online.de + ** Date: 02-11-99 + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libwin32.h" +#include "libgrx.h" +#include "input.h" +#include "grxkeys.h" + +int GrKeyPressed(void) +{ + if (MOUINFO->msstatus < 2) { + GrMouseInit(); + GrMouseEventEnable(1, 0); + } + return _GrKeyPressed(); +} + +GrKeyType GrKeyRead(void) +{ + GrMouseEvent ev; + int i, key; + + if (!_GrIsKbdEnabled()) { + while (_nkeysw32pool < 1) + _GrUpdateInputs(); + key = _keysw32pool[0]; + for (i = 0; i < _nkeysw32pool; i++) + _keysw32pool[i] = _keysw32pool[i + 1]; + _nkeysw32pool--; + return key; + } + + if (MOUINFO->msstatus < 2) { + GrMouseInit(); + GrMouseEventEnable(1, 0); + } + for (;;) { + GrMouseGetEvent((GR_M_EVENT | GR_M_NOPAINT), &ev); + if (ev.flags & GR_M_KEYPRESS) { + return (ev.key); + } + } +} + +int GrKeyStat(void) +{ + return _GrKeyStat(); +} + +int kbhit(void) +{ + return GrKeyPressed(); +} + +int getkey(void) +{ + return (int)GrKeyRead(); +} + +int getch(void) +{ + static int lastkey = (-1); + int key; + + if (lastkey != (-1)) { + key = lastkey; + lastkey = (-1); + return (key); + } + key = getkey(); + if (key < 0x100) { + return (key); + } + lastkey = key & 0xff; + + return (0); +} + +int getkbstat(void) +{ + return _GrKeyStat(); +} + diff --git a/thirdparty/grx249/src/mouse/xwininp.c b/thirdparty/grx249/src/mouse/xwininp.c new file mode 100644 index 0000000..19dadff --- /dev/null +++ b/thirdparty/grx249/src/mouse/xwininp.c @@ -0,0 +1,791 @@ +/** + ** xwininp.c ---- mouse and keyboard interface for X Windows + ** + ** Author: Ulrich Leodolter + ** E-mail: ulrich@lab1.psy.univie.ac.at + ** Date: Thu Sep 28 20:22:16 1995 + ** Comment: Implements the same GRX functions as dosinput.c + ** RCSId: $Id: xwininput.c 1.2 1995/11/19 19:32:30 ulrich Exp $ + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Small changes by Dimitar Zhekov to work in fullscreen mode (DGA2). + ** + ** Contributions by: + ** 070505 M.Alvarez, Using a Pixmap for BackingStore. + ** + **/ + +#include +#include /* for select() */ + +#include "libgrx.h" +#include "libxwin.h" +#include +#include "grxkeys.h" +#include "allocate.h" +#include "arith.h" +#include "memcopy.h" +#include "memfill.h" +#include "mouse/input.h" + +#ifdef _AIX +#include +#endif + +static int kbd_enabled = TRUE; +static int kbd_lastmod = 0; +static int mou_enabled = TRUE; +static int mou_buttons = 0; +static Time MouseMoveTime = 0; +static Time evt_lasttime; +static int evt_lasttime_ok = FALSE; + +#if 0 +long volatile _XGrTickValue = -1; +static void _XGrTickHandler (int signum) +{ + signal (signum, _XGrTickHandler); + _XGrTickValue++; +} +#endif + +static void uninit(void) +{ + if(MOUINFO->msstatus > 1) MOUINFO->msstatus = 1; +} + +int GrMouseDetect(void) +{ + if(MOUINFO->msstatus == 0) { + if (_XGrDisplay) MOUINFO->msstatus = 1; /* present, but not initted */ + } + return((MOUINFO->msstatus > 0) ? TRUE : FALSE); +} + +void GrMouseInitN(int queue_size) +{ + uninit(); + queue_size = umax(4,umin(256,queue_size)); + init_queue(queue_size); + if(GrMouseDetect()) { + GrMouseSetSpeed(1,1); + GrMouseSetAccel(100,1); + GrMouseSetLimits(0,0,SCRN->gc_xmax,SCRN->gc_ymax); + GrMouseWarp((SCRN->gc_xmax >> 1),(SCRN->gc_ymax >> 1)); + _GrInitMouseCursor(); + MOUINFO->msstatus = 2; + mou_buttons = 0; + /* + * Define an invisible X cursor for _XGrWindow + */ + if(_XGrWindowedMode) { + static char cbits[8] = { 0,0,0,0,0,0,0,0, }; + Pixmap csource, cmask; + XColor cfore, cback; + Cursor curs; + + csource = cmask = XCreateBitmapFromData (_XGrDisplay, + _XGrWindow, + cbits, + 8, + 8 + ); + cfore.red = cfore.green = cfore.blue = 0; + cback.red = cback.green = cback.blue = 0; + curs = XCreatePixmapCursor (_XGrDisplay, + csource, + cmask, + &cfore, + &cback, + 0, + 0 + ); + XDefineCursor (_XGrDisplay, _XGrWindow, curs); + } + } + GrMouseEventEnable(TRUE,TRUE); + evt_lasttime_ok = FALSE; + MouseMoveTime = 0; + MOUINFO->uninit = uninit; +} + +void GrMouseSetSpeed(int spmult,int spdiv) +{ + MOUINFO->spmult = umin(16,umax(1,spmult)); + MOUINFO->spdiv = umin(16,umax(1,spdiv)); +} + +void GrMouseSetAccel(int thresh,int accel) +{ + MOUINFO->thresh = umin(64,umax(1,thresh)); + MOUINFO->accel = umin(16,umax(1,accel)); +} + +void GrMouseSetLimits(int x1,int y1,int x2,int y2) +{ + isort(x1,x2); + isort(y1,y2); + MOUINFO->xmin = imax(0,imin(x1,SCRN->gc_xmax)); + MOUINFO->ymin = imax(0,imin(y1,SCRN->gc_ymax)); + MOUINFO->xmax = imax(0,imin(x2,SCRN->gc_xmax)); + MOUINFO->ymax = imax(0,imin(y2,SCRN->gc_ymax)); +} + +void GrMouseWarp(int x,int y) +{ + MOUINFO->xpos = imax(MOUINFO->xmin,imin(MOUINFO->xmax,x)); + MOUINFO->ypos = imax(MOUINFO->ymin,imin(MOUINFO->ymax,y)); + if (_XGrDisplay) { + GrMouseUpdateCursor(); + /* + * Move the X cursor only if inside _XGrWindow + */ + XWarpPointer (_XGrDisplay, + _XGrWindow, + _XGrWindow, + 0, + 0, + GrScreenX(), + GrScreenY(), + MOUINFO->xpos, + MOUINFO->ypos); + } +} + +void GrMouseEventEnable(int enable_kb,int enable_ms) +{ + kbd_enabled = enable_kb; + mou_enabled = enable_ms; +} + +/* Keyboard Translation Table */ + +typedef struct { + GrKeyType key; + unsigned short state; + KeySym keysym; +} KeyEntry; + +static KeyEntry _KeyTable[] = { + { GrKey_Alt_0 , Mod1Mask, XK_0 }, + { GrKey_Alt_1 , Mod1Mask, XK_1 }, + { GrKey_Alt_2 , Mod1Mask, XK_2 }, + { GrKey_Alt_3 , Mod1Mask, XK_3 }, + { GrKey_Alt_4 , Mod1Mask, XK_4 }, + { GrKey_Alt_5 , Mod1Mask, XK_5 }, + { GrKey_Alt_6 , Mod1Mask, XK_6 }, + { GrKey_Alt_7 , Mod1Mask, XK_7 }, + { GrKey_Alt_8 , Mod1Mask, XK_8 }, + { GrKey_Alt_9 , Mod1Mask, XK_9 }, + { GrKey_Alt_A , Mod1Mask, XK_a }, + { GrKey_Alt_At , Mod1Mask, XK_at }, + { GrKey_Alt_B , Mod1Mask, XK_b }, + { GrKey_Alt_Backquote , Mod1Mask, XK_quoteright }, + { GrKey_Alt_Backslash , Mod1Mask, XK_backslash }, + { GrKey_Alt_Backspace , Mod1Mask, XK_BackSpace }, + { GrKey_Alt_C , Mod1Mask, XK_c }, +#ifdef XK_KP_Begin + { GrKey_Alt_Center , Mod1Mask, XK_KP_Begin }, +#endif + { GrKey_Alt_Comma , Mod1Mask, XK_comma }, + { GrKey_Alt_D , Mod1Mask, XK_d }, + { GrKey_Alt_Dash , Mod1Mask, XK_minus }, +#ifdef XK_KP_Delete + { GrKey_Alt_Delete , Mod1Mask, XK_KP_Delete }, +#endif + { GrKey_Alt_Down , Mod1Mask, XK_Down }, +#ifdef XK_KP_Down + { GrKey_Alt_Down , Mod1Mask, XK_KP_Down }, +#endif + { GrKey_Alt_E , Mod1Mask, XK_e }, +#ifdef XK_KP_End + { GrKey_Alt_End , Mod1Mask, XK_KP_End }, +#endif +#ifdef XK_KP_Enter + { GrKey_Alt_Enter , Mod1Mask, XK_KP_Enter }, +#endif + { GrKey_Alt_Equals , Mod1Mask, XK_equal }, + { GrKey_Alt_Escape , Mod1Mask, XK_Escape }, + { GrKey_Alt_F , Mod1Mask, XK_f }, + { GrKey_Alt_F1 , Mod1Mask, XK_F1 }, + { GrKey_Alt_F2 , Mod1Mask, XK_F2 }, + { GrKey_Alt_F3 , Mod1Mask, XK_F3 }, + { GrKey_Alt_F4 , Mod1Mask, XK_F4 }, + { GrKey_Alt_F5 , Mod1Mask, XK_F5 }, + { GrKey_Alt_F6 , Mod1Mask, XK_F6 }, + { GrKey_Alt_F7 , Mod1Mask, XK_F7 }, + { GrKey_Alt_F8 , Mod1Mask, XK_F8 }, + { GrKey_Alt_F9 , Mod1Mask, XK_F9 }, + { GrKey_Alt_F10 , Mod1Mask, XK_F10 }, + { GrKey_Alt_F11 , Mod1Mask, XK_F11 }, + { GrKey_Alt_F12 , Mod1Mask, XK_F12 }, + { GrKey_Alt_G , Mod1Mask, XK_g }, + { GrKey_Alt_H , Mod1Mask, XK_h }, +#ifdef XK_KP_Home + { GrKey_Alt_Home , Mod1Mask, XK_KP_Home }, +#endif + { GrKey_Alt_I , Mod1Mask, XK_i }, +#ifdef XK_KP_Insert + { GrKey_Alt_Insert , Mod1Mask, XK_KP_Insert }, +#endif + { GrKey_Alt_J , Mod1Mask, XK_j }, + { GrKey_Alt_K , Mod1Mask, XK_k }, +#ifdef XK_KP_Subtract + { GrKey_Alt_KPMinus , Mod1Mask, XK_KP_Subtract }, +#endif +#ifdef XK_KP_Add + { GrKey_Alt_KPPlus , Mod1Mask, XK_KP_Add }, +#endif +#ifdef XK_KP_Divide + { GrKey_Alt_KPSlash , Mod1Mask, XK_KP_Divide }, +#endif +#ifdef XK_KP_Multiply + { GrKey_Alt_KPStar , Mod1Mask, XK_KP_Multiply }, +#endif + { GrKey_Alt_KPStar , Mod1Mask, XK_multiply }, + { GrKey_Alt_L , Mod1Mask, XK_l }, + { GrKey_Alt_LAngle , Mod1Mask, XK_less }, + { GrKey_Alt_LBrace , Mod1Mask, XK_braceleft }, + { GrKey_Alt_LBracket , Mod1Mask, XK_bracketleft }, +#ifdef XK_KP_Left + { GrKey_Alt_Left , Mod1Mask, XK_KP_Left }, +#endif + { GrKey_Alt_Left , Mod1Mask, XK_Left }, + { GrKey_Alt_M , Mod1Mask, XK_m }, + { GrKey_Alt_N , Mod1Mask, XK_n }, + { GrKey_Alt_O , Mod1Mask, XK_o }, + { GrKey_Alt_P , Mod1Mask, XK_p }, +#ifdef XK_KP_Next + { GrKey_Alt_PageDown , Mod1Mask, XK_KP_Next }, +#endif +#ifdef XK_KP_Page_Down + { GrKey_Alt_PageDown , Mod1Mask, XK_KP_Page_Down }, +#endif +#ifdef XK_KP_Page_Up + { GrKey_Alt_PageUp , Mod1Mask, XK_KP_Page_Up }, +#endif +#ifdef XK_KP_Prior + { GrKey_Alt_PageUp , Mod1Mask, XK_KP_Prior }, +#endif + { GrKey_Alt_Period , Mod1Mask, XK_period }, + { GrKey_Alt_Pipe , Mod1Mask, XK_bar }, + { GrKey_Alt_Q , Mod1Mask, XK_q }, + { GrKey_Alt_Quote , Mod1Mask, XK_quoteleft }, + { GrKey_Alt_R , Mod1Mask, XK_r }, + { GrKey_Alt_RAngle , Mod1Mask, XK_greater }, + { GrKey_Alt_RBrace , Mod1Mask, XK_braceright }, + { GrKey_Alt_RBracket , Mod1Mask, XK_bracketright }, + { GrKey_Alt_Return , Mod1Mask, XK_Return }, +#ifdef XK_KP_Right + { GrKey_Alt_Right , Mod1Mask, XK_KP_Right }, +#endif + { GrKey_Alt_Right , Mod1Mask, XK_Right }, + { GrKey_Alt_S , Mod1Mask, XK_s }, + { GrKey_Alt_Semicolon , Mod1Mask, XK_semicolon }, + { GrKey_Alt_Slash , Mod1Mask, XK_slash }, + { GrKey_Alt_T , Mod1Mask, XK_t }, + { GrKey_Alt_Tab , Mod1Mask, XK_Tab }, + { GrKey_Alt_U , Mod1Mask, XK_u }, +#ifdef XK_KP_Up + { GrKey_Alt_Up , Mod1Mask, XK_KP_Up }, +#endif + { GrKey_Alt_Up , Mod1Mask, XK_Up }, + { GrKey_Alt_V , Mod1Mask, XK_v }, + { GrKey_Alt_W , Mod1Mask, XK_w }, + { GrKey_Alt_X , Mod1Mask, XK_x }, + { GrKey_Alt_Y , Mod1Mask, XK_y }, + { GrKey_Alt_Z , Mod1Mask, XK_z }, +#ifdef XK_ISO_Left_Tab + { GrKey_BackTab , ShiftMask, XK_ISO_Left_Tab }, +#endif + { GrKey_Center , 0, XK_5 }, +#ifdef XK_KP_Begin + { GrKey_Center , 0, XK_KP_Begin }, +#endif + { GrKey_Control_At , ControlMask, XK_at }, + { GrKey_Control_Center , ControlMask, XK_5 }, +#ifdef XK_KP_Begin + { GrKey_Control_Center , ControlMask, XK_KP_Begin }, +#endif + { GrKey_Control_Delete , ControlMask, XK_Delete }, +#ifdef XK_KP_Delete + { GrKey_Control_Delete , ControlMask, XK_KP_Delete }, +#endif + { GrKey_Control_Down , ControlMask, XK_Down }, +#ifdef XK_KP_Down + { GrKey_Control_Down , ControlMask, XK_KP_Down }, +#endif + { GrKey_Control_End , ControlMask, XK_End }, +#ifdef XK_KP_End + { GrKey_Control_End , ControlMask, XK_KP_End }, +#endif + { GrKey_Control_F1 , ControlMask, XK_F1 }, + { GrKey_Control_F2 , ControlMask, XK_F2 }, + { GrKey_Control_F3 , ControlMask, XK_F3 }, + { GrKey_Control_F4 , ControlMask, XK_F4 }, + { GrKey_Control_F5 , ControlMask, XK_F5 }, + { GrKey_Control_F6 , ControlMask, XK_F6 }, + { GrKey_Control_F7 , ControlMask, XK_F7 }, + { GrKey_Control_F8 , ControlMask, XK_F8 }, + { GrKey_Control_F9 , ControlMask, XK_F9 }, + { GrKey_Control_F10 , ControlMask, XK_F10 }, + { GrKey_Control_F11 , ControlMask, XK_F11 }, + { GrKey_Control_F12 , ControlMask, XK_F12 }, + { GrKey_Control_Home , ControlMask, XK_Home }, +#ifdef XK_KP_Home + { GrKey_Control_Home , ControlMask, XK_KP_Home }, +#endif + { GrKey_Control_Insert , ControlMask, XK_Insert }, +#ifdef XK_KP_Insert + { GrKey_Control_Insert , ControlMask, XK_KP_Insert }, +#endif +#ifdef XK_KP_Subtract + { GrKey_Control_KPDash , ControlMask, XK_KP_Subtract }, +#endif +#ifdef XK_KP_Add + { GrKey_Control_KPPlus , ControlMask, XK_KP_Add }, +#endif + { GrKey_Control_KPSlash , ControlMask, XK_slash }, + { GrKey_Control_KPStar , ControlMask, XK_multiply }, + { GrKey_Control_Left , ControlMask, XK_Left }, +#ifdef XK_KP_Left + { GrKey_Control_Left , ControlMask, XK_KP_Left }, +#endif + { GrKey_Control_PageDown , ControlMask, XK_Next }, +#ifdef XK_KP_Next + { GrKey_Control_PageDown , ControlMask, XK_KP_Next }, +#endif + { GrKey_Control_PageUp , ControlMask, XK_Prior }, +#ifdef XK_KP_Prior + { GrKey_Control_PageUp , ControlMask, XK_KP_Prior }, +#endif + { GrKey_Control_Right , ControlMask, XK_Right }, +#ifdef XK_KP_Right + { GrKey_Control_Right , ControlMask, XK_KP_Right }, +#endif + { GrKey_Control_Up , ControlMask, XK_Up }, +#ifdef XK_KP_Up + { GrKey_Control_Up , ControlMask, XK_KP_Up }, +#endif +#ifdef XK_KP_Subtract + { GrKey_Dash , 0, XK_KP_Subtract }, +#endif + { GrKey_Delete , 0, XK_Delete }, +#ifdef XK_KP_Delete + { GrKey_Delete , 0, XK_KP_Delete }, +#endif + { GrKey_Down , 0, XK_Down }, +#ifdef XK_KP_Down + { GrKey_Down , 0, XK_KP_Down }, +#endif + { GrKey_End , 0, XK_End }, +#ifdef XK_KP_End + { GrKey_End , 0, XK_KP_End }, +#endif + { GrKey_F1 , 0, XK_F1 }, + { GrKey_F2 , 0, XK_F2 }, + { GrKey_F3 , 0, XK_F3 }, + { GrKey_F4 , 0, XK_F4 }, + { GrKey_F5 , 0, XK_F5 }, + { GrKey_F6 , 0, XK_F6 }, + { GrKey_F7 , 0, XK_F7 }, + { GrKey_F8 , 0, XK_F8 }, + { GrKey_F9 , 0, XK_F9 }, + { GrKey_F10 , 0, XK_F10 }, + { GrKey_F11 , 0, XK_F11 }, + { GrKey_F12 , 0, XK_F12 }, + { GrKey_Home , 0, XK_Home }, +#ifdef XK_KP_Home + { GrKey_Home , 0, XK_KP_Home }, +#endif + { GrKey_Insert , 0, XK_Insert }, +#ifdef XK_KP_Insert + { GrKey_Insert , 0, XK_KP_Insert }, +#endif + { GrKey_Left , 0, XK_Left }, +#ifdef XK_KP_Left + { GrKey_Left , 0, XK_KP_Left }, +#endif + { GrKey_PageDown , 0, XK_Next }, +#ifdef XK_KP_Next + { GrKey_PageDown , 0, XK_KP_Next }, +#endif + { GrKey_PageUp , 0, XK_Prior }, +#ifdef XK_KP_Prior + { GrKey_PageUp , 0, XK_KP_Prior }, +#endif +#ifdef XK_KP_Add + { GrKey_Plus , 0, XK_KP_Add }, +#endif + { GrKey_Print , 0, XK_Print }, + { GrKey_Right , 0, XK_Right }, +#ifdef XK_KP_Right + { GrKey_Right , 0, XK_KP_Right }, +#endif + { GrKey_Shift_Down , ShiftMask, XK_Down }, + { GrKey_Shift_End , ShiftMask, XK_End }, + { GrKey_Shift_F1 , ShiftMask, XK_F1 }, + { GrKey_Shift_F2 , ShiftMask, XK_F2 }, + { GrKey_Shift_F3 , ShiftMask, XK_F3 }, + { GrKey_Shift_F4 , ShiftMask, XK_F4 }, + { GrKey_Shift_F5 , ShiftMask, XK_F5 }, + { GrKey_Shift_F6 , ShiftMask, XK_F6 }, + { GrKey_Shift_F7 , ShiftMask, XK_F7 }, + { GrKey_Shift_F8 , ShiftMask, XK_F8 }, + { GrKey_Shift_F9 , ShiftMask, XK_F9 }, + { GrKey_Shift_F10 , ShiftMask, XK_F10 }, + { GrKey_Shift_F11 , ShiftMask, XK_F11 }, + { GrKey_Shift_F12 , ShiftMask, XK_F12 }, + { GrKey_Shift_Home , ShiftMask, XK_Home }, + { GrKey_Shift_Insert , ShiftMask, XK_Insert }, + { GrKey_Shift_Left , ShiftMask, XK_Left }, + { GrKey_Shift_PageDown , ShiftMask, XK_Next }, + { GrKey_Shift_PageUp , ShiftMask, XK_Prior }, + { GrKey_Shift_Right , ShiftMask, XK_Right }, + { GrKey_Shift_Up , ShiftMask, XK_Up }, + { GrKey_Up , 0, XK_Up }, +#ifdef XK_KP_Up + { GrKey_Up , 0, XK_KP_Up }, +#endif +}; + +static int _XKeyEventToGrKey (XKeyEvent *xkey) +{ + KeyEntry *kp; + unsigned int state; + char buffer[20]; + KeySym keysym; + int count; + + state = xkey->state & (ShiftMask | ControlMask | Mod1Mask); + count = XLookupString (xkey, + buffer, + sizeof(buffer), + &keysym, (XComposeStatus *) NULL); + + if ((count == 1) && ((state & Mod1Mask) == 0)) + return (unsigned char) buffer[0]; + + for (kp = _KeyTable; + kp < &_KeyTable[sizeof(_KeyTable)/sizeof(_KeyTable[0])]; + kp = kp + 1) + { + if (keysym == kp->keysym && state == kp->state) + return kp->key; + } + /* printf("Unknown: 0x%x\n", (unsigned) keysym); */ + return EOF; +} + +static INLINE +unsigned int _XButtonEventToGrButton (XButtonEvent *event) +{ + unsigned int state = event->state; + unsigned int mask = 0; + + switch (event->button) { + case Button1: mask = Button1Mask; break; + case Button2: mask = Button2Mask; break; + case Button3: mask = Button3Mask; break; + case Button4: mask = Button4Mask; break; + case Button5: mask = Button5Mask; break; + } + switch (event->type) { + case ButtonPress: state |= mask; break; + case ButtonRelease: state &= ~mask; break; + } + return ( ((state & Button1Mask) ? GR_M_LEFT : 0) + | ((state & Button2Mask) ? GR_M_MIDDLE : 0) + | ((state & Button3Mask) ? GR_M_RIGHT : 0) + | ((state & Button4Mask) ? GR_M_P4 : 0) + | ((state & Button5Mask) ? GR_M_P5 : 0)); +} + +static INLINE +unsigned int _XGrModifierKey (KeySym keysym, int type) +{ + if (type == KeyPress) { + switch (keysym) { + case XK_Shift_L: kbd_lastmod |= GR_KB_LEFTSHIFT; break; + case XK_Shift_R: kbd_lastmod |= GR_KB_RIGHTSHIFT; break; + case XK_Control_L: + case XK_Control_R: kbd_lastmod |= GR_KB_CTRL; break; + case XK_Alt_L: + case XK_Alt_R: + case XK_Meta_L: + case XK_Meta_R: kbd_lastmod |= GR_KB_ALT; break; + case XK_Num_Lock: kbd_lastmod |= GR_KB_NUMLOCK; break; + case XK_Caps_Lock: kbd_lastmod |= GR_KB_CAPSLOCK; break; + case XK_Insert: kbd_lastmod |= GR_KB_INSERT; break; + } + } + if (type == KeyRelease) { + switch (keysym) { + case XK_Shift_L: kbd_lastmod &= ~GR_KB_LEFTSHIFT; break; + case XK_Shift_R: kbd_lastmod &= ~GR_KB_RIGHTSHIFT; break; + case XK_Control_L: + case XK_Control_R: kbd_lastmod &= ~GR_KB_CTRL; break; + case XK_Alt_L: + case XK_Alt_R: + case XK_Meta_L: + case XK_Meta_R: kbd_lastmod &= ~GR_KB_ALT; break; + case XK_Num_Lock: kbd_lastmod &= ~GR_KB_NUMLOCK; break; + case XK_Caps_Lock: kbd_lastmod &= ~GR_KB_CAPSLOCK; break; + case XK_Insert: kbd_lastmod &= ~GR_KB_INSERT; break; + } + } + return kbd_lastmod; +} + +void _GrUpdateInputs(void) +{ + int count; + +#if 0 + if (_XGrTickValue == -1) { + struct itimerval it; + + _XGrTickHandler (SIGALRM); + it.it_interval.tv_sec = 0; + it.it_interval.tv_usec = MS_PER_TICK * 1000L; + it.it_value.tv_sec = 0; + it.it_value.tv_usec = MS_PER_TICK * 1000L; + setitimer (ITIMER_REAL, &it, NULL); + } +#endif + + if (_XGrDisplay) { + count = XEventsQueued (_XGrDisplay, QueuedAfterReading); + if (count <= 0) { + XFlush (_XGrDisplay); + return; + } + while (--count >= 0) { + GrMouseEvent ev; + XEvent xev; + KeySym keysym; + int btn; + + XNextEvent (_XGrDisplay, &xev); + switch (xev.type) { + case Expose: + _XGrCopyBStore(xev.xexpose.x, xev.xexpose.y, + xev.xexpose.width, xev.xexpose.height); + break; + + case MotionNotify: + if (mou_enabled && (MOUINFO->msstatus == 2)) { + if (_XGrWindowedMode) { + MOUINFO->xpos = xev.xmotion.x; + MOUINFO->ypos = xev.xmotion.y; + } + else { + MOUINFO->xpos += xev.xmotion.x; + MOUINFO->ypos += xev.xmotion.y; + } + MOUINFO->moved = TRUE; + MouseMoveTime = xev.xmotion.time; + } + break; + + case ButtonPress: + case ButtonRelease: + if (mou_enabled && (MOUINFO->msstatus == 2)) { + btn = _XButtonEventToGrButton (&xev.xbutton); + if(btn != mou_buttons) { + fill_mouse_ev( + ev, + mou_buttons,btn, + GR_M_LEFT, + GR_M_MIDDLE, + GR_M_RIGHT, + GR_M_P4, + GR_M_P5, + kbd_lastmod + ); + if (evt_lasttime_ok) + ev.dtime = xev.xbutton.time - evt_lasttime; + else { + ev.dtime = 1; + evt_lasttime_ok = TRUE; + } + evt_lasttime = xev.xbutton.time; + enqueue_event(ev); + MOUINFO->moved = FALSE; + mou_buttons = btn; + } + } + break; + + case KeyPress: + keysym = XKeycodeToKeysym (_XGrDisplay, xev.xkey.keycode, 0); + if (IsModifierKey (keysym)) { + _XGrModifierKey (keysym, xev.type); + } + else if (kbd_enabled) { + fill_keybd_ev( + ev, + _XKeyEventToGrKey (&xev.xkey), + kbd_lastmod + ); + if (evt_lasttime_ok) + ev.dtime = xev.xkey.time - evt_lasttime; + else { + ev.dtime = 1; + evt_lasttime_ok = TRUE; + } + evt_lasttime = xev.xkey.time; + enqueue_event(ev); + MOUINFO->moved = FALSE; + } + break; + + case KeyRelease: + keysym = XKeycodeToKeysym (_XGrDisplay, xev.xkey.keycode, 0); + if (IsModifierKey (keysym)) { + _XGrModifierKey (keysym, xev.type); + } + break; + } + } + } +} + +void GrMouseGetEventT(int flags,GrMouseEvent *ev,long tout) +{ + int msdraw; + ev->flags = 0; + if (MOUINFO->msstatus == 0) GrMouseInit(); + if (MOUINFO->msstatus == 0) return; + msdraw = !MOUINFO->displayed && !(flags & GR_M_NOPAINT); + if (msdraw) GrMouseDisplayCursor(); + /* Note: avoid zero timeout for select */ + /* I don't agree. Zero timeout is still needed when I want to display soft */ + /* real time data while looking for some keypress at the same time (A.Pavenis) */ + /* if (tout <= 0L) tout = 1L; */ + if (tout < 0L) tout = 0L; + for( ; _XGrDisplay ; ) { + struct timeval tval; + fd_set readfds; + int fd; + /* + * Note: The select call with nonzero timeout avoids CPU usage + * of nearly 100% + */ + fd = ConnectionNumber(_XGrDisplay); + FD_ZERO(&readfds); + FD_SET(fd, &readfds); + tval.tv_sec = tout / 1000L; + tval.tv_usec = (tout % 1000) * 1000L; + select (fd + 1, + &readfds, + (fd_set *) 0, + (fd_set *) 0, + &tval); + tout = tval.tv_sec * 1000L + tval.tv_usec / 1000L; + + _GrUpdateInputs(); + GrMouseUpdateCursor(); + while (MOUINFO->qlength > 0) { + dequeue_event((*ev)); + if (ev->flags & flags) { + if (msdraw) GrMouseEraseCursor(); + return; + } + } + if ((flags & GR_M_POLL) || + (tout == 0L) || + (MOUINFO->moved && (flags & GR_M_MOTION))) { + fill_mouse_ev( + (*ev), + mou_buttons,mou_buttons, + GR_M_LEFT, + GR_M_MIDDLE, + GR_M_RIGHT, + GR_M_P4, + GR_M_P5, + kbd_lastmod + ); + if ( ev->flags ) { + /* something happend */ + if (MOUINFO->moved) { + if (evt_lasttime_ok && MouseMoveTime) { + ev->dtime = MouseMoveTime - evt_lasttime; + evt_lasttime = MouseMoveTime; + } else + ev->dtime = 1; + } + /* otherwise the ev->dtime is ok */ + } else + ev->dtime = -1; /* special time if nothing happend */ + MOUINFO->moved = FALSE; + MouseMoveTime = 0; + if (msdraw) GrMouseEraseCursor(); + return; + } + /* Make sure we don't use all the CPU */ + /* Is this the right way, Andris? */ + if (tout == 0L) tout = 1L; + } +} + + +int _XGrKeyboardHit (void) +{ + XEvent xev; + KeySym keysym; + + if (_XGrDisplay) { + if (XEventsQueued (_XGrDisplay, QueuedAfterReading) <= 0) { + XFlush (_XGrDisplay); + return FALSE; + } + while (XCheckMaskEvent (_XGrDisplay, KeyPressMask|KeyReleaseMask, &xev)) { + keysym = XKeycodeToKeysym (_XGrDisplay, xev.xkey.keycode, 0); + if (IsModifierKey (keysym)) { + _XGrModifierKey (keysym, xev.type); + continue; + } + if (xev.type == KeyPress) { + XPutBackEvent (_XGrDisplay, &xev); + return TRUE; + } + } + } + return FALSE; +} + +int _XGrKeyboardGetKey (void) +{ + XEvent xev; + KeySym keysym; + + if (_XGrDisplay) { + while (XMaskEvent (_XGrDisplay, KeyPressMask|KeyReleaseMask, &xev)) { + keysym = XKeycodeToKeysym (_XGrDisplay, xev.xkey.keycode, 0); + if (IsModifierKey (keysym)) { + _XGrModifierKey (keysym, xev.type); + continue; + } + if (xev.type == KeyPress) { + return _XKeyEventToGrKey (&xev.xkey); + } + } + } + return 0; +} + +int _XGrKeyboardGetState (void) +{ + return kbd_lastmod; +} + diff --git a/thirdparty/grx249/src/mouse/xwinkeys.c b/thirdparty/grx249/src/mouse/xwinkeys.c new file mode 100644 index 0000000..ff92788 --- /dev/null +++ b/thirdparty/grx249/src/mouse/xwinkeys.c @@ -0,0 +1,134 @@ +/** + ** xwinkeys.c ---- DOS (TCC/BCC/DJGPP: "conio.h") style keyboard utilities + ** + ** Author: Ulrich Leodolter + ** E-mail: ulrich@lab1.psy.univie.ac.at + ** Date: Sun Oct 1 08:10:30 1995 + ** RCSId: $Id: xwinkeys.c 1.1 1995/11/19 16:34:52 ulrich Exp $ + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "libxwin.h" +#include "input.h" +#include "grxkeys.h" + +#define _NOKEY_ (-1) +static int lastkey = _NOKEY_; +static int lastgetchkey = _NOKEY_; + +static int getkey_w (int delay) +{ + GrMouseEvent ev; + if(MOUINFO->msstatus < 2) { + GrMouseInit(); + GrMouseEventEnable(1,0); + } + GrMouseGetEventT((GR_M_EVENT | GR_M_NOPAINT),&ev,delay); + if(ev.flags & GR_M_KEYPRESS) + return(ev.key); + return _NOKEY_; +} + +int getkey(void) +{ + int key; + lastgetchkey = _NOKEY_; + if (lastkey != _NOKEY_) { + key = lastkey; + lastkey = _NOKEY_; + } + else do { + key = getkey_w (1L); + } while (key == _NOKEY_); + return key; +} + +int getch(void) +{ + int key; + if (lastgetchkey != _NOKEY_) { + key = lastgetchkey; + lastgetchkey = _NOKEY_; + return(key); + } + if (lastkey != _NOKEY_) { + key = lastkey; + lastkey = _NOKEY_; + } + else + key = getkey(); + if(key < 0x100) { + return(key); + } + lastgetchkey = key & 0xff; + return(0); +} + +int kbhit(void) +{ + int key; + if (lastkey != _NOKEY_ || lastgetchkey != _NOKEY_) + return TRUE; + key = getkey_w (0); + if (key != _NOKEY_) { + lastkey = key; + return TRUE; + } + return FALSE; +} + +int getkbstat(void) +{ + if(MOUINFO->msstatus < 2) { + GrMouseInit(); + GrMouseEventEnable(1,0); + } + return(_XGrKeyboardGetState()); +} + +/* +** new functions to replace the old style +** kbhit / getch / getkey / getxkey / getkbstat +** keyboard interface +*/ + +int GrKeyPressed(void) +{ + int key; + if (lastkey != _NOKEY_) + return TRUE; + key = getkey_w (0); + if (key==_NOKEY_) + return FALSE; + lastkey = key; + return TRUE; +} + +GrKeyType GrKeyRead(void) +{ + int key; + if (lastkey != _NOKEY_){ + key = lastkey; + lastkey = _NOKEY_; + return (GrKeyType) key; + } + do { + key = getkey_w (1); + } while (key == _NOKEY_); + return key; +} + +int GrKeyStat(void) { + return getkbstat(); +} diff --git a/thirdparty/grx249/src/pattern/fillpatt.c b/thirdparty/grx249/src/pattern/fillpatt.c new file mode 100644 index 0000000..68a9ee7 --- /dev/null +++ b/thirdparty/grx249/src/pattern/fillpatt.c @@ -0,0 +1,94 @@ +/** + ** fillpatt.c ---- draw a pattern filled horizontal line + ** + ** Copyright (C) 1997, Michael Goffioul + ** [e-mail : goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + **/ + +#include "libgrx.h" +#include "arith.h" +#include "shapes.h" + +void _GrFillPatternExt(int x, int y, int sx, int sy, int width, GrPattern *p) +{ + GRX_ENTER(); + if (p->gp_ispixmap) { + void (*bltfun)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor); + int pattwdt = p->gp_pxp_width; + int xdest = x; + int ydest = y; + int ypatt = (y-sy) % p->gp_pxp_height; + int xpatt = (x-sx) % pattwdt; + int cpysize = pattwdt - xpatt; + GrColor optype = p->gp_pxp_oper; + + if (CURC->gc_onscreen) bltfun = CURC->gc_driver->bltr2v; + else bltfun = CURC->gc_driver->bitblt; + while (width > 0) { + if (cpysize > width) cpysize = width; + (*bltfun)( + &CURC->gc_frame,xdest,ydest, + &p->gp_pxp_source,xpatt,ypatt,cpysize,1, + optype + ); + width -= cpysize; + xpatt = 0; + xdest += cpysize; + cpysize = pattwdt; + } + } + else { + + char bits = p->gp_bmp_data[y % p->gp_bmp_height]; + if (bits == 0) + (*CURC->gc_driver->drawhline)(x,y,width,p->gp_bmp_bgcolor); + else if ((GR_int8u)bits == 0xff) + (*CURC->gc_driver->drawhline)(x,y,width,p->gp_bmp_fgcolor); + else { + GrColor fg = p->gp_bmp_fgcolor; + GrColor bg = p->gp_bmp_bgcolor; + int xoffs = x & 7; +# if USE_FDR_DRAWPATTERN-0 + GR_int8u pp = replicate_b2w(bits) >> (8-xoffs); + (*CURC->gc_driver->drawpattern)(x,y,width,pp,fg,bg); +# else + unsigned char mask = 0x80; + mask >>= xoffs; + width += x; + do { + (*CURC->gc_driver->drawpixel)(x,y,(bits & mask) ? fg : bg); + if((mask >>= 1) == 0) mask = 0x80; + } while(++x != width); +# endif + } + } + GRX_LEAVE(); +} + +void _GrFillPattern(int x, int y, int width, GrPattern *p) +{ + GRX_ENTER(); + _GrFillPatternExt(x,y,0,0,width,p); + GRX_LEAVE(); +} + +void _GrFillPatternedScanLine(int x,int y,int w,GrFillArg arg) +{ + GRX_ENTER(); + _GrFillPatternExt(x,y,0,0,w,arg.p); + GRX_LEAVE(); +} diff --git a/thirdparty/grx249/src/pattern/makepat.c b/thirdparty/grx249/src/pattern/makepat.c new file mode 100644 index 0000000..c4fe7a8 --- /dev/null +++ b/thirdparty/grx249/src/pattern/makepat.c @@ -0,0 +1,170 @@ +/** + ** makepat.c + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" + +#define BEST_MAX_LINE 128 +#define BEST_MAX_CONTEXT 2048L + +#define GCM_MYMEMORY 1 /* set if my context memory */ +#define GCM_MYCONTEXT 2 /* set if my context structure */ + +/* + * try to replicate a pixmap for faster bitblt-s + * in bitplane modes it is especially desirable to replicate until + * the width is a multiple of 8 + */ +static int _GrBestPixmapWidth(int wdt,int hgt) +{ + long total = GrContextSize(wdt,hgt); + int linelen = GrLineOffset(wdt); + int factor = 1; + int test; + + if(total == 0L) return(0); +#ifdef _MAXMEMPLANESIZE + if(total > _MAXMEMPLANESIZE) return(0); +#endif + if((test = (int)(BEST_MAX_CONTEXT / total)) > factor) + factor = test; + if((test = (BEST_MAX_LINE / linelen)) < factor) + factor = test; + while((factor >>= 1) != 0) + wdt <<= 1; + return(wdt); +} + +GrPattern *GrBuildPixmap(const char *pixels,int w,int h,const GrColorTableP ct) +{ + GrContext csave,cwork; + GrPixmap *result; + unsigned char *src; + int wdt,wdt2,fullw; + int hgt; + GrColor color; + + if((fullw = _GrBestPixmapWidth(w,h)) <= 0) return(NULL); + result = (GrPixmap *)malloc(sizeof(GrPixmap)); + if (result == NULL) return(NULL); + + if (!GrCreateContext(fullw,h,NULL,&cwork)) { + free(result); + return NULL; + } + csave = *CURC; + *CURC = cwork; + for(hgt = 0; hgt < h; hgt++) { + for(wdt2 = fullw; (wdt2 -= w) >= 0; ) { + src = (unsigned char *)pixels; + for(wdt = 0; wdt < w; wdt++) { + color = *src++; + if(ct != NULL) color = GR_CTABLE_COLOR(ct,color); + (*CURC->gc_driver->drawpixel)(wdt2+wdt,hgt,(color & C_COLOR)); + } + } + pixels += w; + } + *CURC = csave; + result->pxp_source = cwork.gc_frame; + result->pxp_source.gf_memflags = (GCM_MYCONTEXT | GCM_MYMEMORY); + result->pxp_ispixmap = TRUE; + result->pxp_width = fullw; + result->pxp_height = h; + result->pxp_oper = 0; + return((GrPattern *)result); +} + +GrPattern *GrBuildPixmapFromBits(const char *bits,int w,int h,GrColor fgc,GrColor bgc) +{ + GrContext csave,cwork; + GrPixmap *result; + unsigned char *src; + int wdt,wdt2,fullw; + int hgt,mask,byte; + + if((fullw = _GrBestPixmapWidth(w,h)) <= 0) return(NULL); + result = (GrPixmap *)malloc(sizeof(GrPixmap)); + if(result == NULL) return(NULL); + + if (!GrCreateContext(fullw,h,NULL,&cwork)) { + free(result); + return NULL; + } + csave = *CURC; + *CURC = cwork; + fgc &= C_COLOR; + bgc &= C_COLOR; + for(hgt = 0; hgt < h; hgt++) { + for(wdt2 = fullw; (wdt2 -= w) >= 0; ) { + src = (unsigned char *)bits; + mask = byte = 0; + for(wdt = w; --wdt >= 0; ) { + if((mask >>= 1) == 0) { mask = 0x80; byte = *src++; } + (*CURC->gc_driver->drawpixel)(wdt2+wdt,hgt,((byte & mask) ? fgc : bgc)); + } + } + bits += (w + 7) >> 3; + } + *CURC = csave; + result->pxp_source = cwork.gc_frame; + result->pxp_source.gf_memflags = (GCM_MYCONTEXT | GCM_MYMEMORY); + result->pxp_ispixmap = TRUE; + result->pxp_width = fullw; + result->pxp_height = h; + result->pxp_oper = 0; + return((GrPattern *)result); +} + +GrPattern *GrConvertToPixmap(GrContext *src) +{ + GrPixmap *result; + + if(src->gc_onscreen) return(NULL); + result = malloc(sizeof(GrPixmap)); + if(result == NULL) return(NULL); + result->pxp_source = src->gc_frame; + result->pxp_source.gf_memflags = GCM_MYCONTEXT; + result->pxp_ispixmap = TRUE; + result->pxp_width = src->gc_xmax + 1; + result->pxp_height = src->gc_ymax + 1; + result->pxp_oper = 0; + return((GrPattern *)result); +} + + +void GrDestroyPattern(GrPattern *p) +{ + if (!p) return; + if (p->gp_ispixmap) { + if ( p->gp_pxp_source.gf_memflags & GCM_MYMEMORY) { + int ii; + for ( ii = p->gp_pxp_source.gf_driver->num_planes; ii > 0; ii-- ) + farfree(p->gp_pxp_source.gf_baseaddr[ii - 1]); + } + if ( p->gp_pxp_source.gf_memflags & GCM_MYCONTEXT ) + free(p); + return; + } + if ( p->gp_bitmap.bmp_memflags ) free(p); +} + diff --git a/thirdparty/grx249/src/pattern/patfbits.c b/thirdparty/grx249/src/pattern/patfbits.c new file mode 100644 index 0000000..ddfacd7 --- /dev/null +++ b/thirdparty/grx249/src/pattern/patfbits.c @@ -0,0 +1,99 @@ +/** + ** patfbits.c + ** + ** Author unknow + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "shapes.h" + +void _GrFillBitmapPatternExt(int x,int y,int w,int h, int sx, int sy, + char far *bmp,int pitch,int start, + GrPattern* p,GrColor bg) +{ + GR_int8u far *bits, *dptr; + GR_int8u mask; + int xx, width, oldx; + GRX_ENTER(); + bits = (GR_int8u far *)bmp + ((unsigned int)start >> 3); + if ( bg == GrNOCOLOR ) + { + w += x; + h += y; + do { + mask = 0x80; + dptr = bits; + oldx = xx = x; + width = 0; + do { + if ( *dptr & mask ) { + if ( width == 0 ) oldx = xx; + width++; + } + else if ( width ) { + _GrFillPatternExt(oldx, y, sx, sy, width, p); + width = 0; + } + if((mask >>= 1) == 0) { mask = 0x80; ++dptr; } + } while ( ++xx < w ); + if ( width ) _GrFillPatternExt(oldx, y, sx, sy, width, p); + bits += pitch; + } while ( ++y < h ); + } + else { + int widthbg; + w += x; h += y; + do { + mask = 0x80; + dptr = bits; + oldx = xx = x; + widthbg = width = 0; + do { + if ( *dptr & mask ) { + if ( widthbg ) + { + (*FDRV->drawhline)(oldx, y, widthbg, bg); + widthbg = 0; + oldx = xx; + } + width++; + } + else + { + if ( width ) + { + _GrFillPatternExt(oldx, y, sx, sy, width, p); + width = 0; + oldx = xx; + } + widthbg++; + } + if((mask >>= 1) == 0) { mask = 0x80; ++dptr; } + } while ( ++xx < w ); + if ( width ) _GrFillPatternExt(oldx, y, sx, sy, width, p); else + if ( widthbg ) (*FDRV->drawhline)(oldx, y, widthbg, bg); + bits += pitch; + } while ( ++y < h ); + } + GRX_LEAVE(); +} + +void _GrFillBitmapPattern(int x,int y,int w,int h,char far *bmp,int pitch,int start,GrPattern* p,GrColor bg) +{ + GRX_ENTER(); + _GrFillBitmapPatternExt(x, y, w, h, 0, 0, bmp, pitch, start, p, bg); + GRX_LEAVE(); +} + diff --git a/thirdparty/grx249/src/pattern/patfbox.c b/thirdparty/grx249/src/pattern/patfbox.c new file mode 100644 index 0000000..4d3353d --- /dev/null +++ b/thirdparty/grx249/src/pattern/patfbox.c @@ -0,0 +1,68 @@ +/** + ** patfbox.c + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "arith.h" +#include "clipping.h" +#include "shapes.h" + +void GrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p) +{ + int width,height; + + clip_box(CURC,x1,y1,x2,y2); + mouse_block(CURC,x1,y1,x2,y2); + width = x2 - x1 + 1; + height = y2 - y1 + 1; + x1 += CURC->gc_xoffset; + y1 += CURC->gc_yoffset; + if(!p->gp_ispixmap) + while(--height >= 0) _GrFillPattern(x1,y1++,width,p); + else { + void (*bltfun)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor); + int pwdt = p->gp_pxp_width; + int phgt = p->gp_pxp_height; + int xoff = x1 % pwdt; + int ypos = y1; + int yoff = ypos % phgt; + if (CURC->gc_onscreen) bltfun = CURC->gc_driver->bltr2v; + else bltfun = CURC->gc_driver->bitblt; + while(height > 0) { + int fillh = min(height,(phgt - yoff)); + int linewdt = width; + int xpos = x1; + int xcuroff = xoff; + while(linewdt > 0) { + int fillw = min(linewdt,(pwdt - xcuroff)); + (*bltfun)( + &CURC->gc_frame,xpos,ypos, + &p->gp_pxp_source,xcuroff,yoff,fillw,fillh, + p->gp_pxp_oper + ); + linewdt -= fillw; + xpos += fillw; + xcuroff = 0; + } + height -= fillh; + ypos += fillh; + yoff = 0; + } + } + mouse_unblock(); +} + diff --git a/thirdparty/grx249/src/pattern/patfcvxp.c b/thirdparty/grx249/src/pattern/patfcvxp.c new file mode 100644 index 0000000..a36462c --- /dev/null +++ b/thirdparty/grx249/src/pattern/patfcvxp.c @@ -0,0 +1,33 @@ +/** + ** patfcvxp.c + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrPatternFilledConvexPolygon(int n,int pt[][2],GrPattern *p) +{ + GrFillArg fa; + + fa.p = p; + _GrScanConvexPoly(n,pt,&_GrPatternFiller,fa); +} + diff --git a/thirdparty/grx249/src/pattern/patfline.c b/thirdparty/grx249/src/pattern/patfline.c new file mode 100644 index 0000000..25ed021 --- /dev/null +++ b/thirdparty/grx249/src/pattern/patfline.c @@ -0,0 +1,107 @@ +/** + ** patfline.c + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "shapes.h" + +void _GrPatternFilledLine(int x1,int y1,int dx,int dy,GrPattern *p) +{ + union { GrFrame *c; unsigned char *b; } src; + int sy,ymajor; + int pw,ph,px,py; + int ispixmap; + GrColor fgc = 0, bgc = 0; + int points,error; + + if (dx < 0) { + x1 += dx; dx = -dx; + y1 += dy; dy = -dy; + } + if(dy==0) { +/*int check_if_offsets_correct;*/ + _GrFillPattern(x1,y1,dx+1,p); + return; + } + if(dy >= 0) { + sy = 1; + } + else { + dy = (-dy); + sy = (-1); + } + if((ispixmap = p->gp_ispixmap) != FALSE) { + pw = p->gp_pxp_width; + ph = p->gp_pxp_height; + px = x1 % pw; + py = y1 % ph; + src.c = &p->gp_pxp_source; + } + else { + pw = 8; + ph = p->gp_bmp_height; + px = x1 & 7; + py = y1 % ph; + src.b = (unsigned char *) p->gp_bmp_data; + fgc = p->gp_bmp_fgcolor; + bgc = p->gp_bmp_bgcolor; + } + if(dy > dx) { + points = dy + 1; + error = dy >> 1; + ymajor = TRUE; + } + else { + points = dx + 1; + error = dx >> 1; + ymajor = FALSE; + } + while(--points >= 0) { + (*CURC->gc_driver->drawpixel)( + x1,y1, + ispixmap ? + (*src.c->gf_driver->readpixel)(src.c,px,py) : + (src.b[py] & (0x80U >> px)) ? fgc : bgc + ); + if(ymajor) { + if((error -= dx) < 0) error += dy,x1++,px++; + y1 += sy,py += sy; + } + else { + if((error -= dy) < 0) error += dx,y1 += sy,py += sy; + x1++,px++; + } + if((unsigned)py >= (unsigned)ph) { + if(py < 0) py += ph; + else py -= ph; + } + if(px >= pw) px = 0; + } +} + +void GrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p) +{ + clip_line(CURC,x1,y1,x2,y2); + mouse_block(CURC,x1,y1,x2,y2); + _GrPatternFilledLine(x1+CURC->gc_xoffset,y1+CURC->gc_xoffset,x2-x1,y2-y1,p); + mouse_unblock(); +} diff --git a/thirdparty/grx249/src/pattern/patfplot.c b/thirdparty/grx249/src/pattern/patfplot.c new file mode 100644 index 0000000..098b28c --- /dev/null +++ b/thirdparty/grx249/src/pattern/patfplot.c @@ -0,0 +1,53 @@ +/** + ** patfplot.c + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void _GrPatternFilledPlot(int x,int y,GrPattern *p) +{ + int xp,yp; + + if(p->gp_ispixmap) { + xp = x % p->gp_pxp_width; + yp = y % p->gp_pxp_height; + (*CURC->gc_driver->drawpixel)(x,y, + (*p->gp_pxp_source.gf_driver->readpixel)(&p->gp_pxp_source,xp,yp) + ); + } + else { + xp = x & 7; + yp = y % p->gp_bmp_height; + (*CURC->gc_driver->drawpixel)(x,y, + (p->gp_bmp_data[yp] & (0x80U >> xp)) ? p->gp_bmp_fgcolor : p->gp_bmp_bgcolor + ); + } +} + +void GrPatternFilledPlot(int x,int y,GrPattern *p) +{ + clip_dot(CURC,x,y); + mouse_block(CURC,x,y,x,y); + _GrPatternFilledPlot(x+CURC->gc_xoffset,y+CURC->gc_yoffset, p); + mouse_unblock(); +} + diff --git a/thirdparty/grx249/src/pattern/patfpoly.c b/thirdparty/grx249/src/pattern/patfpoly.c new file mode 100644 index 0000000..f7bbd07 --- /dev/null +++ b/thirdparty/grx249/src/pattern/patfpoly.c @@ -0,0 +1,34 @@ +/** + ** patfpoly.c + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrPatternFilledPolygon(int n,int pt[][2],GrPattern *p) +{ + GrFillArg fa; + + fa.p = p; + if(n <= 3) _GrScanConvexPoly(n,pt,&_GrPatternFiller,fa); + else _GrScanPolygon( n,pt,&_GrPatternFiller,fa); +} + diff --git a/thirdparty/grx249/src/pattern/patternf.c b/thirdparty/grx249/src/pattern/patternf.c new file mode 100644 index 0000000..cbcb499 --- /dev/null +++ b/thirdparty/grx249/src/pattern/patternf.c @@ -0,0 +1,25 @@ +/** + ** patternf.c ---- data structure for standard pattern filler + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +GrFiller _GrPatternFiller = { + _GrDrawPatternedPixel, + _GrDrawPatternedLine, + _GrFillPatternedScanLine +}; diff --git a/thirdparty/grx249/src/pattern/pattfldf.c b/thirdparty/grx249/src/pattern/pattfldf.c new file mode 100644 index 0000000..acd497c --- /dev/null +++ b/thirdparty/grx249/src/pattern/pattfldf.c @@ -0,0 +1,29 @@ +/** + ** pattfldf.c ---- fill an arbitrary area with a pattern + ** + ** Copyright (c) 1997 Hartmut Schirmer + ** [e-mail: hsc@techfak.uni-kiel.de] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "shapes.h" + +void GrPatternFloodFill(int x, int y, GrColor border, GrPattern *p) +{ + GrFillArg fval; + + fval.p = p; + _GrFloodFill(x,y,border,&_GrPatternFiller,fval); +} diff --git a/thirdparty/grx249/src/pattern/pattline.c b/thirdparty/grx249/src/pattern/pattline.c new file mode 100644 index 0000000..b282e79 --- /dev/null +++ b/thirdparty/grx249/src/pattern/pattline.c @@ -0,0 +1,40 @@ +/** + ** pattline.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [e-mail : goffioul@emic.ucl.ac.be] + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp) +{ + GrFillArg fval; + int points[2][2]; + + points[0][0] = x1; + points[0][1] = y1; + points[1][0] = x2; + points[1][1] = y2; + fval.p = lp->lnp_pattern; + _GrDrawCustomPolygon(2,points,lp->lnp_option,&_GrPatternFiller,fval,FALSE,FALSE); +} diff --git a/thirdparty/grx249/src/pattern/pattpoly.c b/thirdparty/grx249/src/pattern/pattpoly.c new file mode 100644 index 0000000..95d709e --- /dev/null +++ b/thirdparty/grx249/src/pattern/pattpoly.c @@ -0,0 +1,59 @@ +/** + ** pattpoly.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [e-mail : goffioul@emic.ucl.ac.be] + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp) +{ + GrFillArg fval; + + fval.p = lp->lnp_pattern; + _GrDrawCustomPolygon(numpts,points,lp->lnp_option, + &_GrPatternFiller,fval,FALSE,FALSE); +} + +void GrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp) +{ + GrFillArg fval; + + fval.p = lp->lnp_pattern; + _GrDrawCustomPolygon(numpts,points,lp->lnp_option, + &_GrPatternFiller,fval,TRUE,FALSE); +} + +void GrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp) +{ + GrFillArg fval; + int points[4][2]; + + points[0][0] = x1; points[0][1] = y1; + points[1][0] = x1; points[1][1] = y2; + points[2][0] = x2; points[2][1] = y2; + points[3][0] = x2; points[3][1] = y1; + fval.p = lp->lnp_pattern; + _GrDrawCustomPolygon(4,points,lp->lnp_option, + &_GrPatternFiller,fval,TRUE,FALSE); +} diff --git a/thirdparty/grx249/src/pattern/pfcirc.c b/thirdparty/grx249/src/pattern/pfcirc.c new file mode 100644 index 0000000..0ff85ed --- /dev/null +++ b/thirdparty/grx249/src/pattern/pfcirc.c @@ -0,0 +1,28 @@ +/** + ** pfcirc.c + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +void GrPatternFilledCircle(int xc,int yc,int r,GrPattern *p) +{ + GrPatternFilledEllipse(xc,yc,r,r,p); +} diff --git a/thirdparty/grx249/src/pattern/pfcirca.c b/thirdparty/grx249/src/pattern/pfcirca.c new file mode 100644 index 0000000..623f2dc --- /dev/null +++ b/thirdparty/grx249/src/pattern/pfcirca.c @@ -0,0 +1,29 @@ +/** + ** pfcirca.c + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +void GrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrPattern *p) +{ + GrPatternFilledEllipseArc(xc,yc,r,r,start,end,style,p); +} + diff --git a/thirdparty/grx249/src/pattern/pfelli.c b/thirdparty/grx249/src/pattern/pfelli.c new file mode 100644 index 0000000..f0deec4 --- /dev/null +++ b/thirdparty/grx249/src/pattern/pfelli.c @@ -0,0 +1,32 @@ +/** + ** pfelli.c + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p) +{ + GrFillArg fa; + + fa.p = p; + _GrScanEllipse(xc,yc,xa,ya,&_GrPatternFiller,fa,TRUE); +} diff --git a/thirdparty/grx249/src/pattern/pfellia.c b/thirdparty/grx249/src/pattern/pfellia.c new file mode 100644 index 0000000..121a9bf --- /dev/null +++ b/thirdparty/grx249/src/pattern/pfellia.c @@ -0,0 +1,48 @@ +/** + ** pfellia.c + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "shapes.h" + +void GrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrPattern *p) +{ + int (*points)[2]; + setup_ALLOC(); + points = ALLOC(sizeof(int) * 2 * (GR_MAX_ELLIPSE_POINTS + 1)); + if (points != NULL) + { + int numpts = GrGenerateEllipseArc(xc,yc,xa,ya,start,end,points); + GrFillArg fa; + + if (style == GR_ARC_STYLE_CLOSE2) { + points[numpts][0] = xc; + points[numpts][1] = yc; + numpts++; + } + fa.p = p; + if(numpts < 0) _GrScanConvexPoly((-numpts),points,&_GrPatternFiller,fa); + else _GrScanPolygon( numpts, points,&_GrPatternFiller,fa); + FREE(points); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/pattern/ptcirc.c b/thirdparty/grx249/src/pattern/ptcirc.c new file mode 100644 index 0000000..f16666b --- /dev/null +++ b/thirdparty/grx249/src/pattern/ptcirc.c @@ -0,0 +1,31 @@ +/** + ** ptcirc.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [e-mail : goffioul@emic.ucl.ac.be] + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +void GrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp) +{ + GrPatternedEllipse(xc,yc,r,r,lp); +} diff --git a/thirdparty/grx249/src/pattern/ptcirca.c b/thirdparty/grx249/src/pattern/ptcirca.c new file mode 100644 index 0000000..b7d91fa --- /dev/null +++ b/thirdparty/grx249/src/pattern/ptcirca.c @@ -0,0 +1,32 @@ +/** + ** ptcirca.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [e-mail : goffioul@emic.ucl.ac.be] + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +void GrPatternedCircleArc(int xc,int yc,int r,int start,int end,int style,GrLinePattern *lp) +{ + GrPatternedEllipseArc(xc,yc,r,r,start,end,style,lp); +} + diff --git a/thirdparty/grx249/src/pattern/ptelli.c b/thirdparty/grx249/src/pattern/ptelli.c new file mode 100644 index 0000000..227e332 --- /dev/null +++ b/thirdparty/grx249/src/pattern/ptelli.c @@ -0,0 +1,45 @@ +/** + ** ptelli.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [e-mail : goffioul@emic.ucl.ac.be] + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "shapes.h" + +void GrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp) { + int (*points)[2]; + setup_ALLOC(); + points = ALLOC(sizeof(int) * 2 * GR_MAX_ELLIPSE_POINTS); + if (points != NULL) + { + int numpts = GrGenerateEllipse(xc,yc,xa,ya,points); + GrFillArg fval; + + fval.p = lp->lnp_pattern; + _GrDrawCustomPolygon(numpts,points,lp->lnp_option, + &_GrPatternFiller,fval,TRUE,TRUE); + FREE(points); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/pattern/ptellia.c b/thirdparty/grx249/src/pattern/ptellia.c new file mode 100644 index 0000000..3d046f5 --- /dev/null +++ b/thirdparty/grx249/src/pattern/ptellia.c @@ -0,0 +1,63 @@ +/** + ** ptellia.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [e-mail : goffioul@emic.ucl.ac.be] + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "shapes.h" + +void GrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrLinePattern *lp) +{ + int (*points)[2]; + setup_ALLOC(); + points = ALLOC(sizeof(int) * 2 * (GR_MAX_ELLIPSE_POINTS + 2)); + if (points != NULL) + { + int numpts = GrGenerateEllipseArc(xc,yc,xa,ya,start,end,points); + GrFillArg fval; + int close; + + close = FALSE; + if (style == GR_ARC_STYLE_CLOSE2) { + points[numpts][0] = xc; + points[numpts][1] = yc; + numpts++; + points[numpts][0] = points[0][0]; + points[numpts][1] = points[0][1]; + numpts++; + close = TRUE; + } + if (style == GR_ARC_STYLE_CLOSE1) { + points[numpts][0] = points[0][0]; + points[numpts][1] = points[0][1]; + numpts++; + close = TRUE; + } + fval.p = lp->lnp_pattern; + _GrDrawCustomPolygon(numpts,points,lp->lnp_option, + &_GrPatternFiller,fval,close,TRUE); + FREE(points); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/setup/clip.c b/thirdparty/grx249/src/setup/clip.c new file mode 100644 index 0000000..f4098ca --- /dev/null +++ b/thirdparty/grx249/src/setup/clip.c @@ -0,0 +1,55 @@ +/** + ** clip.c ---- clip box setting utilities + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" + +void GrSetClipBox(int x1,int y1,int x2,int y2) +{ + cxclip_box(CURC,x1,y1,x2,y2); + CURC->gc_xcliplo = x1; + CURC->gc_ycliplo = y1; + CURC->gc_xcliphi = x2; + CURC->gc_ycliphi = y2; +} + +void GrSetClipBoxC(GrContext *c,int x1,int y1,int x2,int y2) +{ + cxclip_box(c,x1,y1,x2,y2); + c->gc_xcliplo = x1; + c->gc_ycliplo = y1; + c->gc_xcliphi = x2; + c->gc_ycliphi = y2; +} + +void GrResetClipBox(void) +{ + CURC->gc_xcliplo = 0; + CURC->gc_ycliplo = 0; + CURC->gc_xcliphi = CURC->gc_xmax; + CURC->gc_ycliphi = CURC->gc_ymax; +} + +void GrResetClipBoxC(GrContext *c) +{ + c->gc_xcliplo = 0; + c->gc_ycliplo = 0; + c->gc_xcliphi = c->gc_xmax; + c->gc_ycliphi = c->gc_ymax; +} + diff --git a/thirdparty/grx249/src/setup/clrinfo.c b/thirdparty/grx249/src/setup/clrinfo.c new file mode 100644 index 0000000..7f284a2 --- /dev/null +++ b/thirdparty/grx249/src/setup/clrinfo.c @@ -0,0 +1,55 @@ +/** + ** clrinfo.c ---- the color info data structure + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#undef GrColorInfo + +const +struct _GR_colorInfo * const GrColorInfo = &_GrColorInfo; +struct _GR_colorInfo _GrColorInfo = { + 16, /* ncolors: initted for 16 color VGA modes */ + 0, /* nfree */ + 0, /* black */ + 15, /* white */ + FALSE, /* RBG */ + { 6, 6, 6 }, /* precision */ + { 5, 5, 5 }, /* bit position */ + { 0xfc, 0xfc, 0xfc }, /* mask */ + { 2, 2, 2 }, /* round */ + { 2, 2, 2 }, /* shift */ + 2, /* normalization */ + { /* first 16 EGA/VGA colors */ + { 0, 0, 0 }, /* black */ + { 0, 0, 170 }, /* blue */ + { 0, 170, 0 }, /* green */ + { 0, 170, 170 }, /* cyan */ + { 170, 0, 0 }, /* red */ + { 170, 0, 170 }, /* magenta */ + { 170, 85, 0 }, /* brown */ + { 170, 170, 170 }, /* light gray */ + { 85, 85, 85 }, /* dark gray */ + { 85, 85, 255 }, /* light blue */ + { 85, 255, 85 }, /* light green */ + { 85, 255, 255 }, /* light cyan */ + { 255, 85, 85 }, /* light red */ + { 255, 85, 255 }, /* light magenta */ + { 255, 255, 85 }, /* yellow */ + { 255, 255, 255 } /* white */ + } +}; + diff --git a/thirdparty/grx249/src/setup/clrinlne.c b/thirdparty/grx249/src/setup/clrinlne.c new file mode 100644 index 0000000..9f2766c --- /dev/null +++ b/thirdparty/grx249/src/setup/clrinlne.c @@ -0,0 +1,114 @@ +/** + ** clrinlne.c ---- the color inline functions + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +GrColor (GrColorValue)(GrColor c) +{ + return(GrColorValue(c)); +} + +GrColor (GrColorMode)(GrColor c) +{ + return(GrColorMode(c)); +} + +GrColor (GrWriteModeColor)(GrColor c) +{ + return(GrWriteModeColor(c)); +} + +GrColor (GrXorModeColor)(GrColor c) +{ + return(GrXorModeColor(c)); +} + +GrColor (GrOrModeColor)(GrColor c) +{ + return(GrOrModeColor(c)); +} +GrColor (GrAndModeColor)(GrColor c) +{ + return(GrAndModeColor(c)); +} + +GrColor (GrImageModeColor)(GrColor c) +{ + return(GrImageModeColor(c)); +} + +GrColor (GrNumColors)(void) +{ + return(GrNumColors()); +} + +GrColor (GrNumFreeColors)(void) +{ + return(GrNumFreeColors()); +} + +GrColor (GrBuildRGBcolorT)(int r,int g,int b) +{ + return(GrBuildRGBcolorT(r,g,b)); +} + +GrColor (GrBuildRGBcolorR)(int r,int g,int b) +{ + return(GrBuildRGBcolorR(r,g,b)); +} + +int (GrRGBcolorRed)(GrColor c) +{ + return(GrRGBcolorRed(c)); +} + +int (GrRGBcolorGreen)(GrColor c) +{ + return(GrRGBcolorGreen(c)); +} + +int (GrRGBcolorBlue)(GrColor c) +{ + return(GrRGBcolorBlue(c)); +} + +GrColor (GrAllocColorID)(int r,int g,int b) +{ + return(GrAllocColorID(r,g,b)); +} + +GrColor (GrAllocColor2)(long hcolor) +{ + return(GrAllocColor2(hcolor)); +} + +GrColor (GrAllocColor2ID)(long hcolor) +{ + return(GrAllocColor2ID(hcolor)); +} + +void (GrQueryColorID)(GrColor c,int *r,int *g,int *b) +{ + GrQueryColorID(c,r,g,b); +} + +void (GrQueryColor2ID)(GrColor c,long *hcolor) +{ + GrQueryColor2ID(c,hcolor); +} + diff --git a/thirdparty/grx249/src/setup/colorbw.c b/thirdparty/grx249/src/setup/colorbw.c new file mode 100644 index 0000000..671c4ca --- /dev/null +++ b/thirdparty/grx249/src/setup/colorbw.c @@ -0,0 +1,41 @@ +/** + ** colorbw.c ---- standard colors: black and white + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +#ifdef GrBlack +#undef GrBlack +#endif +GrColor GrBlack(void) +{ + GRX_ENTER(); + if(CLRINFO->black == GrNOCOLOR) CLRINFO->black = GrAllocColor(0,0,0); + GRX_RETURN(CLRINFO->black); +} + +#ifdef GrWhite +#undef GrWhite +#endif +GrColor GrWhite(void) +{ + GRX_ENTER(); + if(CLRINFO->white == GrNOCOLOR) CLRINFO->white = GrAllocColor(255,255,255); + GRX_RETURN(CLRINFO->white); +} + diff --git a/thirdparty/grx249/src/setup/colorega.c b/thirdparty/grx249/src/setup/colorega.c new file mode 100644 index 0000000..34ac7fc --- /dev/null +++ b/thirdparty/grx249/src/setup/colorega.c @@ -0,0 +1,48 @@ +/** + ** colorega.c ---- Alloc the standard EGA palette + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +static struct { + GR_int8u r, g, b; +} EGArgb[16] = { + { 0, 0, 0 }, /* black */ + { 0, 0, 170 }, /* blue */ + { 0, 170, 0 }, /* green */ + { 0, 170, 170 }, /* cyan */ + { 170, 0, 0 }, /* red */ + { 170, 0, 170 }, /* magenta */ + { 170, 85, 0 }, /* brown */ + { 170, 170, 170 }, /* light gray */ + { 85, 85, 85 }, /* dark gray */ + { 85, 85, 255 }, /* light blue */ + { 85, 255, 85 }, /* light green */ + { 85, 255, 255 }, /* light cyan */ + { 255, 85, 85 }, /* light red */ + { 255, 85, 255 }, /* light magenta */ + { 255, 255, 85 }, /* yellow */ + { 255, 255, 255 } /* white */ +}; + +GrColor *GrAllocEgaColors(void) { + static GrColor egapal[16]; + int i; + for (i=0; i < 16; ++i) + egapal[i] = GrAllocColor(EGArgb[i].r,EGArgb[i].g,EGArgb[i].b); + return egapal; +} + diff --git a/thirdparty/grx249/src/setup/colors.c b/thirdparty/grx249/src/setup/colors.c new file mode 100644 index 0000000..00ee80b --- /dev/null +++ b/thirdparty/grx249/src/setup/colors.c @@ -0,0 +1,368 @@ +/** + ** colors.c ---- color management functions + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "memcopy.h" +#include "memfill.h" + +static void (*DACload)(int c,int r,int g,int b) = NULL; + +static void loadcolor(int c,int r,int g,int b) +{ + CLRINFO->ctable[c].r = (r &= CLRINFO->mask[0]); + CLRINFO->ctable[c].g = (g &= CLRINFO->mask[1]); + CLRINFO->ctable[c].b = (b &= CLRINFO->mask[2]); + if(DACload) (*DACload)(c,r,g,b); +} + +static void setbits(char *prec,char *pos) +{ + int i,tmp; + CLRINFO->norm = 0; + for(i = 0; i < 3; i++,prec++,pos++) { + CLRINFO->prec[i] = *prec; + CLRINFO->pos[i] = *prec + *pos - 1; + CLRINFO->mask[i] = (tmp = 0xff ^ (0xff >> *prec)); + CLRINFO->round[i] = (tmp >> 1) & ~tmp; + CLRINFO->shift[i] = (tmp = CLRINFO->pos[i] - 7); + CLRINFO->norm = imax(CLRINFO->norm,(-tmp)); + } + CLRINFO->shift[0] += CLRINFO->norm; + CLRINFO->shift[1] += CLRINFO->norm; + CLRINFO->shift[2] += CLRINFO->norm; +} + +void GrRefreshColors(void) +{ + int i; + for(i = 0; i < (int)CLRINFO->ncolors; i++) { + if(CLRINFO->ctable[i].defined) loadcolor( + (int)(i), + CLRINFO->ctable[i].r, + CLRINFO->ctable[i].g, + CLRINFO->ctable[i].b + ); + } +} + +/* _GR_firstFreeColor is normally zero but some systems may protect some +** colors for other programs (eg. X11). In this case we don't touch them. +** These variables are only used in palette modes +*/ +#ifdef __XWIN__ +int _GR_firstFreeColor = 0; +int _GR_lastFreeColor = -1; +#else +#define _GR_firstFreeColor 0 +#endif + +int _GrResetColors(void) +{ +# define NSAVED 16 + static char *infosave = NULL; + static int firsttime = TRUE; + int i; + if(firsttime) { + infosave = malloc(offsetof(struct _GR_colorInfo,ctable[NSAVED])); + if ( infosave ) { + memcpy(infosave,CLRINFO,offsetof(struct _GR_colorInfo,ctable[NSAVED])); + } + firsttime = FALSE; + } + sttzero(CLRINFO); + if(DRVINFO->actmode.extinfo->mode == GR_frameText) { + if ( infosave ) { + memcpy(CLRINFO,infosave,sizeof(infosave)); + return TRUE; + } + return FALSE; + } + DACload = DRVINFO->actmode.extinfo->loadcolor; + CLRINFO->black = GrNOCOLOR; + CLRINFO->white = GrNOCOLOR; + CLRINFO->ncolors = DRVINFO->actmode.bpp>=32 ? 0 : (1L << DRVINFO->actmode.bpp); + if ( ((CLRINFO->ncolors-1)&GrCVALUEMASK) != (CLRINFO->ncolors-1) ) { + /* can happen on 32bpp systems. */ + int cbpp = 0; + for(i=0; i < 3; ++i) + cbpp += DRVINFO->actmode.extinfo->cprec[i]; + CLRINFO->ncolors = 1L << cbpp; + } + setbits( + DRVINFO->actmode.extinfo->cprec, + DRVINFO->actmode.extinfo->cpos + ); + switch(DRVINFO->actmode.bpp) { + case 4: + case 8: +#ifdef __XWIN__ + if (_GR_lastFreeColor >= _GR_firstFreeColor) + CLRINFO->nfree = _GR_lastFreeColor - _GR_firstFreeColor + 1; + else +#endif + CLRINFO->nfree = CLRINFO->ncolors - _GR_firstFreeColor; + if ( infosave ) { + for(i = 0; i < NSAVED; i++) { + loadcolor( + (i + _GR_firstFreeColor), + ((struct _GR_colorInfo *)(infosave))->ctable[i].r, + ((struct _GR_colorInfo *)(infosave))->ctable[i].g, + ((struct _GR_colorInfo *)(infosave))->ctable[i].b + ); + CLRINFO->ctable[i].defined = TRUE; + } + } + break; + default: + CLRINFO->RGBmode = TRUE; + break; + } + return ((CLRINFO->ncolors-1)&GrCVALUEMASK) == CLRINFO->ncolors-1; +} + +void GrResetColors(void) +{ + _GrResetColors(); +} + +void GrSetRGBcolorMode(void) +{ + if(!CLRINFO->RGBmode) { + GrColor c; + switch(CLRINFO->ncolors) { + case 16L: setbits("\1\2\1","\3\1\0"); break; + case 256L: setbits("\3\3\2","\5\2\0"); break; + default: return; + } + CLRINFO->RGBmode = TRUE; + CLRINFO->nfree = 0L; + CLRINFO->black = 0L; + CLRINFO->white = CLRINFO->ncolors - 1L; + for(c = 0; c < CLRINFO->ncolors; c++) loadcolor( + (int)(c), + (int)GrRGBcolorRed(c), + (int)GrRGBcolorGreen(c), + (int)GrRGBcolorBlue(c) + ); + } +} + +#define ROUNDCOLORCOMP(x,n) ( \ + ((unsigned int)(x) >= CLRINFO->mask[n]) ? \ + CLRINFO->mask[n] : \ + (((x) + CLRINFO->round[n]) & CLRINFO->mask[n]) \ +) + +GrColor GrAllocColor(int r,int g,int b) +{ + GrColor res; + + GRX_ENTER(); + res = GrNOCOLOR; + r = ROUNDCOLORCOMP(r,0); + g = ROUNDCOLORCOMP(g,1); + b = ROUNDCOLORCOMP(b,2); + if(CLRINFO->RGBmode) { + res = GrBuildRGBcolorT(r,g,b); + } + else { + GR_int32u minerr = 1000; + int i; + int free_ = (-1),allfree = (-1),best = (-1); + int ndef = (int)CLRINFO->ncolors - (int)CLRINFO->nfree; + DBGPRINTF(DBG_COLOR,("Allocating color: r=%d, g=%d, b=%d\n",r,g,b)); + for(i = 0; i < (int)CLRINFO->ncolors; i++) { + if(CLRINFO->ctable[i].defined) { + if(!CLRINFO->ctable[i].writable) { + GR_int32u err = 0; + GR_int16u colerr; + colerr = iabs(r - CLRINFO->ctable[i].r); + colerr = colerr * colerr; + err += colerr; + colerr = iabs(g - CLRINFO->ctable[i].g); + colerr = colerr * colerr; + err += colerr; + colerr = iabs(b - CLRINFO->ctable[i].b); + colerr = colerr * colerr; + err += colerr; + if(err < minerr) { + DBGPRINTF(DBG_COLOR,("New best color %d (err=%ld): r=%d, g=%d, b=%d\n", i, err, \ + (int)CLRINFO->ctable[i].r,(int)CLRINFO->ctable[i].g,(int)CLRINFO->ctable[i].b)); + best = i; + if((minerr = err) == 0) goto foundbest; + } + if((free_ <= 0) && !CLRINFO->ctable[i].nused) { + DBGPRINTF(DBG_COLOR,("First free color: r=%d\n", i)); + free_ = i; + } + } + if(CLRINFO->ctable[i].nused) ndef--; + } + else { + if(allfree < 0) allfree = i; + } + if((allfree >= 0) && (ndef <= 0)) { + DBGPRINTF(DBG_COLOR,("Found a usable color: allfree = %d, ndef = %d\n", allfree, ndef)); + break; + } + } + if(allfree >= 0) { + DBGPRINTF(DBG_COLOR,("Using %d as free color (free=%d)\n", allfree, free_)); + free_ = allfree; + } + if(free_ >= 0) { + DBGPRINTF(DBG_COLOR,("Allocating %d\n", free_)); + CLRINFO->ctable[free_].defined = TRUE; + CLRINFO->ctable[free_].writable = FALSE; + CLRINFO->ctable[free_].nused = 1; + CLRINFO->nfree--; + loadcolor(free_,r,g,b); + res = free_; + goto done; + } + foundbest: + if(best >= 0) { + DBGPRINTF(DBG_COLOR,("Using best %d\n", best)); + if(!CLRINFO->ctable[best].nused) CLRINFO->nfree--; + CLRINFO->ctable[best].nused++; + res = best; + goto done; + } + } +done: GRX_RETURN(res); +} + +GrColor GrAllocCell(void) +{ + if(!CLRINFO->RGBmode && CLRINFO->nfree) { + int i,free_ = (-1); + for(i = 0; i < (int)CLRINFO->ncolors; i++) { + if(!CLRINFO->ctable[i].defined) { + free_ = i; + break; + } + if(!CLRINFO->ctable[i].nused) { + if(free_ < 0) free_ = i; + } + } + if(free_ >= 0) { + CLRINFO->ctable[free_].defined = TRUE; + CLRINFO->ctable[free_].writable = TRUE; + CLRINFO->ctable[free_].nused = 1; + CLRINFO->nfree--; + loadcolor(free_,0,0,0); + return((GrColor)(free_)); + } + } + return(GrNOCOLOR); +} + +void GrFreeColor(GrColor c) +{ + if(!CLRINFO->RGBmode && ((GrColor)(c) < CLRINFO->ncolors) && + !CLRINFO->ctable[(int)(c)].writable && + CLRINFO->ctable[(int)(c)].defined && + (--CLRINFO->ctable[(int)(c)].nused == 0)) { + CLRINFO->nfree++; + CLRINFO->ctable[(int)(c)].defined = FALSE; + CLRINFO->ctable[(int)(c)].writable = FALSE; + CLRINFO->ctable[(int)(c)].nused = 0; + } +} + +void GrFreeCell(GrColor c) +{ + GRX_ENTER(); + if(!CLRINFO->RGBmode && ((GrColor)(c) < CLRINFO->ncolors)) { + if(CLRINFO->ctable[(int)(c)].writable) { + CLRINFO->nfree++; + CLRINFO->ctable[(int)(c)].defined = FALSE; + CLRINFO->ctable[(int)(c)].writable = FALSE; + CLRINFO->ctable[(int)(c)].nused = 0; + } + } + GRX_LEAVE(); +} + +void GrSetColor(GrColor c,int r,int g,int b) +{ + GRX_ENTER(); + if(!CLRINFO->RGBmode && ((GrColor)(c) < CLRINFO->ncolors)) { + if(!CLRINFO->ctable[(int)(c)].defined) { + CLRINFO->ctable[(int)(c)].defined = TRUE; + CLRINFO->ctable[(int)(c)].nused = 0; + } + if(!CLRINFO->ctable[(int)(c)].nused) { + CLRINFO->ctable[(int)(c)].writable = TRUE; + CLRINFO->ctable[(int)(c)].nused = 1; + CLRINFO->nfree--; + } + if(CLRINFO->ctable[(int)(c)].writable) loadcolor( + (int)(c), + (int)ROUNDCOLORCOMP(r,0), + (int)ROUNDCOLORCOMP(g,1), + (int)ROUNDCOLORCOMP(b,2) + ); + } + GRX_LEAVE(); +} + +void GrQueryColor(GrColor c,int *r,int *g,int *b) +{ + GRX_ENTER(); + GrQueryColorID(c,r,g,b); + GRX_LEAVE(); +} + +void GrQueryColor2(GrColor c,long *hcolor) +{ + GRX_ENTER(); + GrQueryColor2ID(c,hcolor); + GRX_LEAVE(); +} + +#define CSAVE_MAGIC 0x7abf5698UL + +typedef struct { + GrColor magic; + GrColor nc; + struct _GR_colorInfo info; +} colorsave; + +int GrColorSaveBufferSize(void) +{ + return(sizeof(colorsave)); +} + +void GrSaveColors(void *buffer) +{ + colorsave *cp = (colorsave *)buffer; + cp->magic = CSAVE_MAGIC; + cp->nc = GrNumColors(); + sttcopy(&cp->info,CLRINFO); +} + +void GrRestoreColors(void *buffer) +{ + colorsave *cp = (colorsave *)buffer; + if((cp->magic == CSAVE_MAGIC) && (cp->nc == GrNumColors())) { + sttcopy(CLRINFO,&cp->info); + GrRefreshColors(); + } +} + diff --git a/thirdparty/grx249/src/setup/context.c b/thirdparty/grx249/src/setup/context.c new file mode 100644 index 0000000..010481b --- /dev/null +++ b/thirdparty/grx249/src/setup/context.c @@ -0,0 +1,156 @@ +/** + ** context.c ----- context creation and manipulation functions + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include + +#include "libgrx.h" +#include "allocate.h" +#include "clipping.h" +#include "memcopy.h" +#include "memfill.h" + +#define MYCONTEXT 1 +#define MYFRAME 2 + +GrContext *GrCreateFrameContext(GrFrameMode md,int w,int h,char far *memory[4],GrContext *where) +{ + GrFrameDriver *fd = _GrFindRAMframeDriver(md); + int ii,offset,flags = 0; + char far *mymem[4]; + long psize; + + if(!fd) return(NULL); + offset = GrFrameLineOffset(md,w); + psize = GrFramePlaneSize(md,w,h); + if(psize <= 0L) return(NULL); + if(psize > fd->max_plane_size) return(NULL); + if(!where) { + where = malloc(sizeof(GrContext)); + if(!where) return(NULL); + flags = MYCONTEXT; + } + sttzero(where); + if(!memory) { + for(ii = 0; ii < fd->num_planes; ii++) { + mymem[ii] = farmalloc((size_t)psize); + if(!mymem[ii]) { + while(--ii >= 0) farfree(mymem[ii]); + if(flags) free(where); + return(NULL); + } + } + while(ii < 4) mymem[ii++] = NULL; + memory = mymem; + flags |= MYFRAME; + } + where->gc_driver = fd; + where->gc_baseaddr[0] = memory[0]; + where->gc_baseaddr[1] = memory[1]; + where->gc_baseaddr[2] = memory[2]; + where->gc_baseaddr[3] = memory[3]; + where->gc_lineoffset = offset; + where->gc_memflags = flags; + where->gc_xcliphi = where->gc_xmax = w - 1; + where->gc_ycliphi = where->gc_ymax = h - 1; + return(where); +} + +GrContext *GrCreateSubContext( + int x1,int y1,int x2,int y2, + const GrContext *parent, + GrContext *where +){ + int flags = 0; + + if(!parent) parent = SCRN; + if(parent->gc_root) { + x1 += parent->gc_xoffset; + y1 += parent->gc_yoffset; + x2 += parent->gc_xoffset; + y2 += parent->gc_yoffset; + parent = parent->gc_root; + } + cxclip_box_(parent,x1,y1,x2,y2,return(NULL),CLIP_EMPTY_MACRO_ARG); + if(!where) { + where = malloc(sizeof(GrContext)); + if(!where) return(NULL); + flags = MYCONTEXT; + } + sttzero(where); + sttcopy(&where->gc_frame,&parent->gc_frame); + where->gc_memflags = flags; + where->gc_xoffset = x1; + where->gc_yoffset = y1; + where->gc_xcliphi = where->gc_xmax = x2 - x1; + where->gc_ycliphi = where->gc_ymax = y2 - y1; + where->gc_root = (GrContext *)parent; + return(where); +} + +void GrResizeSubContext(GrContext *context,int x1,int y1,int x2,int y2) +{ + GrContext *parent = context->gc_root; + + if((parent = context->gc_root) == NULL) return; +/* + x1 += context->gc_xoffset; + y1 += context->gc_yoffset; + x2 += context->gc_xoffset; + y2 += context->gc_yoffset; +*/ + cxclip_box(parent,x1,y1,x2,y2); + context->gc_xoffset = x1; + context->gc_yoffset = y1; + context->gc_xcliphi = context->gc_xmax = x2 - x1; + context->gc_ycliphi = context->gc_ymax = y2 - y1; + context->gc_xcliplo = 0; + context->gc_ycliplo = 0; +} + +void GrDestroyContext(GrContext *cxt) +{ + if(cxt && (cxt != CURC) && (cxt != SCRN)) { + if(cxt->gc_memflags & MYFRAME) { + int ii = cxt->gc_driver->num_planes; + while(--ii >= 0) farfree(cxt->gc_baseaddr[ii]); + } + if(cxt->gc_memflags & MYCONTEXT) free(cxt); + } +} + +void GrSetContext(const GrContext *context) +{ + if(!context) context = SCRN; + sttcopy(CURC,context); + sttcopy(FDRV,context->gc_driver); +} + +GrContext *GrSaveContext(GrContext *where) +{ + int flags = 0; + + if(!where) { + where = malloc(sizeof(GrContext)); + if(!where) return(NULL); + flags = MYCONTEXT; + } + sttcopy(where,CURC); + where->gc_memflags = flags; + return(where); +} + diff --git a/thirdparty/grx249/src/setup/cxtinfo.c b/thirdparty/grx249/src/setup/cxtinfo.c new file mode 100644 index 0000000..6d8b506 --- /dev/null +++ b/thirdparty/grx249/src/setup/cxtinfo.c @@ -0,0 +1,68 @@ +/** + ** cxtinfo.c ---- the context info data structure + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "memmode.h" +#undef GrContextInfo + +const +struct _GR_contextInfo * const GrContextInfo = &_GrContextInfo; +struct _GR_contextInfo _GrContextInfo = { + { /* the current context */ + { /* frame */ + { /* frame start addresses */ +#ifdef __MSDOS__ + LINP_PTR(MK_FP(0xb800,0)), + LINP_PTR(MK_FP(0xb800,0)), + LINP_PTR(MK_FP(0xb800,0)), + LINP_PTR(MK_FP(0xb800,0)) +#else + NULL,NULL,NULL,NULL +#endif + }, + 0, /* selector */ + TRUE, /* onscreen */ + 0, /* memflags */ + 0, /* lineoffset */ + &DRVINFO->tdriver /* frame driver */ + }, + NULL /* root */ + }, + { /* the screen context */ + { /* frame */ + { /* frame start addresses */ +#ifdef __MSDOS__ + LINP_PTR(MK_FP(0xb800,0)), + LINP_PTR(MK_FP(0xb800,0)), + LINP_PTR(MK_FP(0xb800,0)), + LINP_PTR(MK_FP(0xb800,0)) +#else + NULL,NULL,NULL,NULL +#endif + }, + 0, /* selector */ + TRUE, /* onscreen */ + 0, /* memflags */ + 0, /* lineoffset */ + &DRVINFO->tdriver /* frame driver */ + }, + NULL /* root */ + } +}; + + diff --git a/thirdparty/grx249/src/setup/cxtinlne.c b/thirdparty/grx249/src/setup/cxtinlne.c new file mode 100644 index 0000000..ecea6db --- /dev/null +++ b/thirdparty/grx249/src/setup/cxtinlne.c @@ -0,0 +1,85 @@ +/** + ** ctcinlne.c ---- the context inline functions + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +GrContext *(GrCreateContext)(int w,int h,char far *memory[4],GrContext *where) +{ + return(GrCreateContext(w,h,memory,where)); +} + +GrContext *(GrCurrentContext)(void) +{ + return(GrCurrentContext()); +} + +GrContext *(GrScreenContext)(void) +{ + return(GrScreenContext()); +} + +void (GrGetClipBox)(int *x1p,int *y1p,int *x2p,int *y2p) +{ + GrGetClipBox(x1p,y1p,x2p,y2p); +} + +void (GrGetClipBoxC)(const GrContext *c,int *x1p,int *y1p,int *x2p,int *y2p) +{ + GrGetClipBoxC(c,x1p,y1p,x2p,y2p); +} + +int (GrMaxX)(void) +{ + return(GrMaxX()); +} + +int (GrMaxY)(void) +{ + return(GrMaxY()); +} + +int (GrSizeX)(void) +{ + return(GrSizeX()); +} + +int (GrSizeY)(void) +{ + return(GrSizeY()); +} + +int (GrLowX)(void) +{ + return(GrLowX()); +} + +int (GrLowY)(void) +{ + return(GrLowY()); +} + +int (GrHighX)(void) +{ + return(GrHighX()); +} + +int (GrHighY)(void) +{ + return(GrHighY()); +} + diff --git a/thirdparty/grx249/src/setup/drvinfo.c b/thirdparty/grx249/src/setup/drvinfo.c new file mode 100644 index 0000000..40a9788 --- /dev/null +++ b/thirdparty/grx249/src/setup/drvinfo.c @@ -0,0 +1,138 @@ +/** + ** drvinfo.c ---- the driver info data structure + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" + +#undef GrDriverInfo + +static GrColor dummyframefn(void); + +const +struct _GR_driverInfo * const GrDriverInfo = &_GrDriverInfo; +struct _GR_driverInfo _GrDriverInfo = { + NULL, /* video driver */ + &DRVINFO->actmode, /* current video mode pointer */ + { /* current video mode struct */ + FALSE, /* present */ + 4, /* bpp */ + 80,25, /* geometry */ + 3, /* BIOS mode */ + 160, /* lineoffset */ + 0, /* private */ +#ifdef __MSDOS__ + &_GrViDrvEGAVGAtextModeExt /* extended info */ +#else + NULL +#endif + }, + { /* current frame driver */ + GR_frameUndef, /* frame mode */ + GR_frameUndef, /* compatible RAM frame mode */ + FALSE, /* onscreen */ + 1, /* line width alignment */ + 1, /* number of planes */ + 0, /* bits per pixel */ + 0L, /* max plane size the code can handle */ + NULL, + (GrColor (*)(GrFrame*,int,int)) dummyframefn, + (void (*)(int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,int,char*,int,int,GrColor,GrColor)) dummyframefn, + (void (*)(int,int,int,char,GrColor,GrColor)) dummyframefn, + (void (*)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor)) dummyframefn, + (void (*)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor)) dummyframefn, + (void (*)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor)) dummyframefn + }, + { /* screen frame driver */ + GR_frameUndef, /* frame mode */ + GR_frameUndef, /* compatible RAM frame mode */ + FALSE, /* onscreen */ + 1, /* line width alignment */ + 1, /* number of planes */ + 0, /* bits per pixel */ + 0L, /* max plane size the code can handle */ + NULL, + (GrColor (*)(GrFrame*,int,int)) dummyframefn, + (void (*)(int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,int,char*,int,int,GrColor,GrColor)) dummyframefn, + (void (*)(int,int,int,char,GrColor,GrColor)) dummyframefn, + (void (*)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor)) dummyframefn, + (void (*)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor)) dummyframefn, + (void (*)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor)) dummyframefn + }, + { /* dummy text mode frame driver */ + GR_frameText, /* frame mode */ + GR_frameUndef, /* compatible RAM frame mode */ + TRUE, /* onscreen */ + 1, /* line width alignment */ + 1, /* number of planes */ + 16, /* bits per pixel */ + 0L, /* max plane size the code can handle */ + NULL, + (GrColor (*)(GrFrame*,int,int)) dummyframefn, + (void (*)(int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,int,GrColor)) dummyframefn, + (void (*)(int,int,int,int,char*,int,int,GrColor,GrColor)) dummyframefn, + (void (*)(int,int,int,char,GrColor,GrColor)) dummyframefn, + (void (*)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor)) dummyframefn, + (void (*)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor)) dummyframefn, + (void (*)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor)) dummyframefn + }, + GR_default_text, /* current mode code */ + 80,25, /* default text size */ + 640,480, /* default graphics size */ + 16L,16L, /* default txt and gr colors */ + 0,0, /* virtual position */ + TRUE, /* exit upon errors */ + TRUE, /* restore startup mode */ + FALSE, /* split banks */ + (-1), /* current bank */ + NULL, /* mode set hook */ + (void (*)(int) )_GrDummyFunction, /* banking func */ + (void (*)(int,int))_GrDummyFunction /* split banking func */ +}; + +static GrColor dummyframefn(void) +{ + if(DRVINFO->errsfatal) { + _GrCloseVideoDriver(); + fprintf(stderr, + "GRX Error: graphics operation attempted %s\n", + (DRVINFO->fdriver.mode == GR_frameText) ? "in text mode" : "before mode set" + ); + exit(1); + } + return(GrNOCOLOR); +} + +void _GrDummyFunction(void) +{ + return; +} + diff --git a/thirdparty/grx249/src/setup/drvinlne.c b/thirdparty/grx249/src/setup/drvinlne.c new file mode 100644 index 0000000..edeccc8 --- /dev/null +++ b/thirdparty/grx249/src/setup/drvinlne.c @@ -0,0 +1,125 @@ +/** + ** drvinlne.c ---- inline functions related to drivers + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +GrGraphicsMode (GrCurrentMode)(void) +{ + return(GrCurrentMode()); +} + +GrVideoAdapter (GrAdapterType)(void) +{ + return(GrAdapterType()); +} + +GrFrameMode (GrCurrentFrameMode)(void) +{ + return(GrCurrentFrameMode()); +} + +GrFrameMode (GrScreenFrameMode)(void) +{ + return(GrScreenFrameMode()); +} + +GrFrameMode (GrCoreFrameMode)(void) +{ + return(GrCoreFrameMode()); +} + +const GrVideoDriver *(GrCurrentVideoDriver)(void) +{ + return(GrCurrentVideoDriver()); +} + +const GrVideoMode *(GrCurrentVideoMode)(void) +{ + return(GrCurrentVideoMode()); +} + +const GrVideoMode *(GrVirtualVideoMode)(void) +{ + return(GrVirtualVideoMode()); +} + +const GrFrameDriver *(GrCurrentFrameDriver)(void) +{ + return(GrCurrentFrameDriver()); +} + +const GrFrameDriver *(GrScreenFrameDriver)(void) +{ + return(GrScreenFrameDriver()); +} + +int (GrScreenX)(void) +{ + return(GrScreenX()); +} + +int (GrScreenY)(void) +{ + return(GrScreenY()); +} + +int (GrVirtualX)(void) +{ + return(GrVirtualX()); +} + +int (GrVirtualY)(void) +{ + return(GrVirtualY()); +} + +int (GrViewportX)(void) +{ + return(GrViewportX()); +} + +int (GrViewportY)(void) +{ + return(GrViewportY()); +} + +int (GrScreenIsVirtual)(void) +{ + return(GrScreenIsVirtual()); +} + +int (GrNumPlanes)(void) +{ + return(GrNumPlanes()); +} + +int (GrLineOffset)(int width) +{ + return(GrLineOffset(width)); +} + +long (GrPlaneSize)(int w,int h) +{ + return(GrPlaneSize(w,h)); +} + +long (GrContextSize)(int w,int h) +{ + return(GrContextSize(w,h)); +} + diff --git a/thirdparty/grx249/src/setup/fframe.c b/thirdparty/grx249/src/setup/fframe.c new file mode 100644 index 0000000..d4d2ff8 --- /dev/null +++ b/thirdparty/grx249/src/setup/fframe.c @@ -0,0 +1,37 @@ +/** + ** fframe.c ---- frame driver lookup functions + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" + +GrFrameDriver *_GrFindFrameDriver(GrFrameMode mode) +{ + int ii = 0; + while(_GrFrameDriverTable[ii] != NULL) { + if(_GrFrameDriverTable[ii]->mode == mode) break; + ii++; + } + return(_GrFrameDriverTable[ii]); +} + +GrFrameDriver *_GrFindRAMframeDriver(GrFrameMode mode) +{ + GrFrameDriver *dp = _GrFindFrameDriver(mode); + return((dp && dp->is_video) ? _GrFindFrameDriver(dp->rmode) : dp); +} + diff --git a/thirdparty/grx249/src/setup/fgeom.c b/thirdparty/grx249/src/setup/fgeom.c new file mode 100644 index 0000000..f5b40e7 --- /dev/null +++ b/thirdparty/grx249/src/setup/fgeom.c @@ -0,0 +1,50 @@ +/** + ** fgeom.c ---- frame geometry and memory allocation utilities + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "arith.h" + +int GrFrameNumPlanes(GrFrameMode md) +{ + GrFrameDriver *dp = _GrFindRAMframeDriver(md); + return(dp ? dp->num_planes : 0); +} + +int GrFrameLineOffset(GrFrameMode md,int width) +{ + GrFrameDriver *dp = _GrFindRAMframeDriver(md); + if(dp) { + unsigned int w = (unsigned int)width + * (dp->bits_per_pixel / dp->num_planes); + w = ((w + 7) >> 3); + w = ((w + dp->row_align - 1) / dp->row_align) * dp->row_align; + return(w); + } + return(0); +} + +long GrFramePlaneSize(GrFrameMode md,int w,int h) +{ + return(umul32(GrFrameLineOffset(md,w),h)); +} + +long GrFrameContextSize(GrFrameMode md,int w,int h) +{ + return(umul32(GrFrameLineOffset(md,w),(GrFrameNumPlanes(md) * h))); +} + diff --git a/thirdparty/grx249/src/setup/hooks.c b/thirdparty/grx249/src/setup/hooks.c new file mode 100644 index 0000000..e6b9374 --- /dev/null +++ b/thirdparty/grx249/src/setup/hooks.c @@ -0,0 +1,35 @@ +/** + ** hooks.c ---- functions to set up some hooks and control flags + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +void GrSetModeRestore(int restoreFlag) +{ + DRVINFO->moderestore = restoreFlag; +} + +void GrSetErrorHandling(int exitIfError) +{ + DRVINFO->errsfatal = exitIfError; +} + +void GrSetModeHook(void (*hookfunc)(void)) +{ + DRVINFO->mdsethook = hookfunc; +} + diff --git a/thirdparty/grx249/src/setup/modewalk.c b/thirdparty/grx249/src/setup/modewalk.c new file mode 100644 index 0000000..f286462 --- /dev/null +++ b/thirdparty/grx249/src/setup/modewalk.c @@ -0,0 +1,64 @@ +/** + ** modewalk.c ---- utilities to iterate over the available video modes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "grdriver.h" +#include "libgrx.h" + +static GrVideoMode *modewalk(GrVideoMode *pm,GrVideoMode *dup,GrFrameMode md) +{ + GrVideoDriver *vd; + GrVideoMode *vm; + int n,seen = TRUE; + if(pm && pm->extinfo) { + md = pm->extinfo->mode; + seen = FALSE; + } + for(vd = VDRV; vd != NULL; vd = vd->inherit) { + for(n = vd->nmodes,vm = vd->modes; --n >= 0; vm++) { + if(vm->present == FALSE) continue; + if(vm->extinfo == NULL) continue; + if(vm->extinfo->mode != md) continue; + if(dup) { + if(vm == dup) return(NULL); + if(vm->width != dup->width) continue; + if(vm->height != dup->height) continue; + if(vm->bpp != dup->bpp) continue; + return(vm); + } + if(seen) { + if(!modewalk(NULL,vm,md)) return(vm); + continue; + } + if(pm == vm) { + seen = TRUE; + } + } + } + return(NULL); +} + +const GrVideoMode *GrFirstVideoMode(GrFrameMode fmode) +{ + return(modewalk(NULL,NULL,fmode)); +} + +const GrVideoMode *GrNextVideoMode(const GrVideoMode *prev) +{ + return(modewalk((GrVideoMode *)prev,NULL,GR_frameUndef)); +} + diff --git a/thirdparty/grx249/src/setup/setdrvr.c b/thirdparty/grx249/src/setup/setdrvr.c new file mode 100644 index 0000000..6fab2d7 --- /dev/null +++ b/thirdparty/grx249/src/setup/setdrvr.c @@ -0,0 +1,133 @@ +/** + ** setdrvr.c ---- video driver setup + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "memcopy.h" +#include "memfill.h" + +static char *near nxtoken(char *p,char *token) +{ + while(*p == ' ') p++; + while(*p && (*p != ' ')) *token++ = *p++; + *token = '\0'; + return(p); +} + +int GrSetDriver(char *drvspec) +{ + static int firsttime = TRUE; + GrVideoDriver *drv = NULL; + char options[100]; + if(!drvspec) drvspec = getenv("GRX20DRV"); + options[0] = '\0'; + if(drvspec) { + char t[100],name[100],*p = drvspec; + name[0] = '\0'; + while(p = nxtoken(p,t),t[0] != '\0') { + if(strlen(t) == 2) { +# define CH16(c1,c2) (((c1) << 8) | (c2)) + void *oaddr = NULL; + int cf = FALSE; + switch(CH16(tolower(t[0]),tolower(t[1]))) { + case CH16('n','c'): + case CH16('g','c'): oaddr = &DRVINFO->defgc; cf = TRUE; break; + case CH16('t','c'): oaddr = &DRVINFO->deftc; cf = TRUE; break; + case CH16('g','w'): oaddr = &DRVINFO->defgw; break; + case CH16('t','w'): oaddr = &DRVINFO->deftw; break; + case CH16('g','h'): oaddr = &DRVINFO->defgh; break; + case CH16('t','h'): oaddr = &DRVINFO->defth; break; + } + if(oaddr) { + long optval; + p = nxtoken(p,t); + if(sscanf(t,"%ld",&optval) > 0) { + if(cf) { + switch(toupper(t[strlen(t) - 1])) { + case 'K': optval <<= 10; break; + case 'M': optval <<= 20; break; + } + *((long *)oaddr) = optval; + continue; + } + *((int *)oaddr) = (int)optval; + } + continue; + } + } + strcpy(name,t); + } + for(p = name; (p = strchr(p,':')) != NULL; p++) { + if(p[1] == ':') { + strcpy(options,&p[2]); + *p = '\0'; + break; + } + } + if(name[0] != '\0') { + int ii = 0,found = FALSE; + while(!found && ((drv = _GrVideoDriverTable[ii++]) != NULL)) { + char *n = name; + for(p = drv->name; ; p++,n++) { + if(tolower(*p) != tolower(*n)) break; + if(*p == '\0') { found = TRUE; break; } + } + } + if(!found) return(FALSE); + } + } + if(!drv) { + GrVideoDriver *dp; + int ii,maxmodes = 0; + for(ii = 0; (dp = _GrVideoDriverTable[ii]) != NULL; ii++) { + if(dp->detect && (*dp->detect)()) { + int nm = 0; + for( ; dp; dp = dp->inherit) nm += dp->nmodes; + if(nm > maxmodes) { + drv = _GrVideoDriverTable[ii]; + maxmodes = nm; + } + } + } + if(!drv) return(FALSE); + } + _GrCloseVideoDriver(); + if(firsttime) { + atexit(_GrCloseVideoDriver); + firsttime = FALSE; + } + if(!drv->init || drv->init(options)) { + DRVINFO->vdriver = drv; + return(TRUE); + } + return(FALSE); +} + +void _GrCloseVideoDriver(void) +{ + sttcopy(&DRVINFO->fdriver,&DRVINFO->tdriver); + if(DRVINFO->vdriver != NULL) { + if(DRVINFO->vdriver->reset) (*DRVINFO->vdriver->reset)(); + DRVINFO->vdriver = NULL; + } +} + diff --git a/thirdparty/grx249/src/setup/setmode.c b/thirdparty/grx249/src/setup/setmode.c new file mode 100644 index 0000000..bb71b5a --- /dev/null +++ b/thirdparty/grx249/src/setup/setmode.c @@ -0,0 +1,444 @@ +/** + ** setmode.c ---- video mode setup + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include + +#include "libgrx.h" +#include "arith.h" +#include "memfill.h" +#include "memcopy.h" +#include "grdriver.h" + +GrVideoMode * _gr_selectmode(GrVideoDriver *drv,int w,int h,int bpp, + int txt,unsigned int *ep) +{ +# define ERROR(des,act) ((des > act) ? ((des - act) + 20000) : (act - des)) + int n; + unsigned int cerr,serr,err[2]; + GrVideoMode *best,*mp; + GRX_ENTER(); + best = NULL; + mp = drv->modes; + for(n = drv->nmodes; --n >= 0; mp++) { + if(!mp->present) continue; + if(!mp->extinfo) continue; + if((mp->extinfo->mode != GR_frameText) ? txt : !txt) continue; + cerr = ERROR(bpp,mp->bpp); + serr = ERROR(w,mp->width) + ERROR(h,mp->height); + if(((ep) ? FALSE : ((ep = err),TRUE)) || + ((cerr < ep[0])) || + ((cerr == ep[0]) && (serr < ep[1]))) { + best = mp; + if (!cerr && !serr) break; + ep[0] = cerr; + ep[1] = serr; + } + } + if(drv->inherit) { + mp = (drv->inherit->selectmode) (drv->inherit,w,h,bpp,txt,ep); + if(mp) best = mp; + } + GRX_RETURN(best); +} + +static int buildframedriver(GrVideoMode *mp,GrFrameDriver *drv) +{ + GrFrameDriver *d1, *d2; + int res = TRUE; + GRX_ENTER(); + res = TRUE; + d1 = _GrFindFrameDriver(mp->extinfo->mode); + d2 = mp->extinfo->drv; + if(d1) sttcopy(drv,d1); + if(d2) { + int compl = TRUE; +# define MERGE(F) if(d2->F) drv->F = d2->F; else compl = FALSE; + MERGE(readpixel); + MERGE(drawpixel); + MERGE(drawhline); + MERGE(drawvline); + MERGE(drawblock); + MERGE(drawline); + MERGE(drawbitmap); + MERGE(drawpattern); + MERGE(bitblt); + MERGE(bltv2r); + MERGE(bltr2v); + MERGE(getindexedscanline); + MERGE(putscanline); + if(compl) { + memcpy(drv,d2,offsetof(GrFrameDriver,readpixel)); + goto done; /* TRUE */ + } + if(!d1) { res = FALSE; goto done; } + if((d2->mode == d1->mode) && + (d2->rmode == d1->rmode) && + (d1->is_video ? d2->is_video : !d2->is_video) && + (d2->row_align <= d1->row_align) && !(d1->row_align % d2->row_align) && + (d2->num_planes == d1->num_planes) && + (d2->max_plane_size >= d1->max_plane_size) && + (d2->bits_per_pixel == d1->bits_per_pixel)) { + drv->init = d2->init ? d2->init : d1->init; + goto done; /* TRUE */ + } + } + if(!d1) { res = FALSE; goto done; } + sttcopy(drv,d1); +done: GRX_RETURN(res); +} + +static int buildcontext(GrVideoMode *mp,GrFrameDriver *fdp,GrContext *cxt) +{ + long plsize; + int res; + GRX_ENTER(); + res = FALSE; + plsize = umul32(mp->lineoffset,mp->height); + DBGPRINTF(DBG_SETMD,("buildcontext - Mode Frame buffer = 0x%x\n",mp->extinfo->frame)); + DBGPRINTF(DBG_SETMD,("buildcontext - Mode Frame selector = 0x%x\n",mp->extinfo->LFB_Selector)); + sttzero(cxt); +#if !defined(__TURBOC__) \ + && !(defined(__WATCOMC__) && !defined(__386__)) \ + && !(defined(__XWIN__) && !defined(XF86DGA_FRAMEBUFFER) && !defined(__SDL__)) + if(mp->extinfo->flags&GR_VMODEF_LINEAR) + { + DBGPRINTF(DBG_SETMD,("buildcontext - Linear Mode\n")); + cxt->gc_baseaddr[0] = + cxt->gc_baseaddr[1] = + cxt->gc_baseaddr[2] = + cxt->gc_baseaddr[3] = LINP_PTR(mp->extinfo->frame); + cxt->gc_selector = mp->extinfo->LFB_Selector; + } else +#endif /* !__TURBOC__ && !( __WATCOMC__ && !__386__) && !(__XWIN__ && !XF86DGA_FRAMEBUFFER && !__SDL__) */ + if (mp->extinfo->flags&GR_VMODEF_MEMORY) + { + DBGPRINTF(DBG_SETMD,("buildcontext - Memory Mode\n")); + if(plsize > fdp->max_plane_size) goto done; /* FALSE */ + if(mp->lineoffset % fdp->row_align) goto done; /* FALSE */ + DBGPRINTF(DBG_SETMD,("buildcontext - mp->present = %d\n",mp->present)); + DBGPRINTF(DBG_SETMD,("buildcontext - mp->bpp = %d\n",mp->bpp)); + DBGPRINTF(DBG_SETMD,("buildcontext - mp->width = %d\n",mp->width)); + DBGPRINTF(DBG_SETMD,("buildcontext - mp->height = %d\n",mp->height)); + DBGPRINTF(DBG_SETMD,("buildcontext - mp->mode = %d\n",mp->mode)); + DBGPRINTF(DBG_SETMD,("buildcontext - mp->lineoffset = %d\n",mp->lineoffset)); + DBGPRINTF(DBG_SETMD,("buildcontext - mp->ext->mode = %d\n",mp->extinfo->mode)); + DBGPRINTF(DBG_SETMD,("buildcontext - mp->ext->flags = %x\n",mp->extinfo->flags)); +#ifdef GRX_USE_RAM3x8 + if (mp->bpp==24) + { + int m_incr = mp->lineoffset*mp->height; + cxt->gc_baseaddr[0] = mp->extinfo->frame; + cxt->gc_baseaddr[1] = cxt->gc_baseaddr[0] + m_incr; + cxt->gc_baseaddr[2] = cxt->gc_baseaddr[1] + m_incr; + cxt->gc_baseaddr[3] = NULL; + } + else +#endif + if (mp->bpp==4) + { + int m_incr = mp->lineoffset*mp->height; + cxt->gc_baseaddr[0] = mp->extinfo->frame; + cxt->gc_baseaddr[1] = cxt->gc_baseaddr[0] + m_incr; + cxt->gc_baseaddr[2] = cxt->gc_baseaddr[1] + m_incr; + cxt->gc_baseaddr[3] = cxt->gc_baseaddr[2] + m_incr; + } + else + { + cxt->gc_baseaddr[0] = + cxt->gc_baseaddr[1] = + cxt->gc_baseaddr[2] = + cxt->gc_baseaddr[3] = mp->extinfo->frame; + } +#if defined(__TURBOC__) || (defined(__WATCOMC__) && !defined(__386__)) + cxt->gc_selector = LINP_SEL(mp->extinfo->frame); +#endif + } + else + { + if(plsize > fdp->max_plane_size) goto done; /* FALSE */ + if(!mp->extinfo->setbank && (plsize > 0x10000L)) goto done; /* FALSE */ + if(mp->lineoffset % fdp->row_align) goto done; /* FALSE */ + cxt->gc_baseaddr[0] = + cxt->gc_baseaddr[1] = + cxt->gc_baseaddr[2] = + cxt->gc_baseaddr[3] = LINP_PTR(mp->extinfo->frame); + cxt->gc_selector = LINP_SEL(mp->extinfo->frame); + } + cxt->gc_onscreen = !(mp->extinfo->flags&GR_VMODEF_MEMORY); + /* Why do we default to screen driver ?? */ + cxt->gc_onscreen = TRUE; + cxt->gc_lineoffset = mp->lineoffset; + cxt->gc_xcliphi = cxt->gc_xmax = mp->width - 1; + cxt->gc_ycliphi = cxt->gc_ymax = mp->height - 1; + cxt->gc_driver = &DRVINFO->sdriver; + + res = TRUE; + + DBGPRINTF(DBG_SETMD,("buildcontext - context buffer 0 = 0x%x\n",cxt->gc_baseaddr[0])); + DBGPRINTF(DBG_SETMD,("buildcontext - context buffer 1 = 0x%x\n",cxt->gc_baseaddr[1])); + DBGPRINTF(DBG_SETMD,("buildcontext - context buffer 2 = 0x%x\n",cxt->gc_baseaddr[2])); + DBGPRINTF(DBG_SETMD,("buildcontext - context buffer 3 = 0x%x\n",cxt->gc_baseaddr[3])); +done: + GRX_RETURN(res); +} + +static int errhdlr(char *msg) +{ + if(DRVINFO->errsfatal) { + DRVINFO->moderestore = TRUE; + _GrCloseVideoDriver(); + fprintf(stderr,"GrSetMode: %s\n",msg); + exit(1); + } + return(FALSE); +} + +int GrSetMode(GrGraphicsMode which,...) +{ + int w,h,pl,vw,vh; + int t,noclear,res; + GrColor c; + va_list ap; + GRX_ENTER(); + pl = 0; + vw = 0; + vh = 0; + t = FALSE; + noclear = FALSE; + c = 0; + res = FALSE; + DBGPRINTF(DBG_SETMD,("Mode: %d\n",(int)which)); + if(DRVINFO->vdriver == NULL) { + GrSetDriver(NULL); + if(DRVINFO->vdriver == NULL) { + res = errhdlr("could not find suitable video driver"); + goto done; + } + } + va_start(ap,which); + switch(which) { + case GR_NC_80_25_text: + noclear = TRUE; + case GR_80_25_text: + w = 80; + h = 25; + c = DRVINFO->deftc; + t = TRUE; + break; + case GR_NC_default_text: + noclear = TRUE; + case GR_default_text: + w = DRVINFO->deftw; + h = DRVINFO->defth; + c = DRVINFO->deftc; + t = TRUE; + break; + case GR_NC_width_height_text: + noclear = TRUE; + case GR_width_height_text: + w = va_arg(ap,int); + h = va_arg(ap,int); + c = DRVINFO->deftc; + t = TRUE; + break; + case GR_NC_biggest_text: + noclear = TRUE; + case GR_biggest_text: + w = 200; + h = 80; + c = DRVINFO->deftc; + t = TRUE; + break; + case GR_NC_width_height_color_text: + noclear = TRUE; + case GR_width_height_color_text: + w = va_arg(ap,int); + h = va_arg(ap,int); + c = va_arg(ap,GrColor); + t = TRUE; + break; + case GR_NC_width_height_bpp_text: + noclear = TRUE; + case GR_width_height_bpp_text: + w = va_arg(ap,int); + h = va_arg(ap,int); + pl = va_arg(ap,int); + t = TRUE; + break; + case GR_NC_320_200_graphics: + noclear = TRUE; + case GR_320_200_graphics: + w = 320; + h = 200; + c = DRVINFO->defgc; + break; + case GR_NC_default_graphics: + noclear = TRUE; + case GR_default_graphics: + w = DRVINFO->defgw; + h = DRVINFO->defgh; + c = DRVINFO->defgc; + break; + case GR_NC_width_height_graphics: + noclear = TRUE; + case GR_width_height_graphics: + w = va_arg(ap,int); + h = va_arg(ap,int); + c = DRVINFO->defgc; + break; + case GR_NC_biggest_noninterlaced_graphics: + noclear = TRUE; + case GR_biggest_noninterlaced_graphics: + w = 800; + h = 600; + c = DRVINFO->defgc; + break; + case GR_NC_biggest_graphics: + noclear = TRUE; + case GR_biggest_graphics: + w = 4096; + h = 4096; + c = DRVINFO->defgc; + break; + case GR_NC_width_height_color_graphics: + noclear = TRUE; + case GR_width_height_color_graphics: + w = va_arg(ap,int); + h = va_arg(ap,int); + c = va_arg(ap,GrColor); + break; + case GR_NC_width_height_bpp_graphics: + noclear = TRUE; + case GR_width_height_bpp_graphics: + w = va_arg(ap,int); + h = va_arg(ap,int); + pl = va_arg(ap,int); + break; + case GR_NC_custom_graphics: + noclear = TRUE; + case GR_custom_graphics: + w = va_arg(ap,int); + h = va_arg(ap,int); + c = va_arg(ap,GrColor); + vw = va_arg(ap,int); + vh = va_arg(ap,int); + break; + case GR_NC_custom_bpp_graphics: + noclear = TRUE; + case GR_custom_bpp_graphics: + w = va_arg(ap,int); + h = va_arg(ap,int); + pl = va_arg(ap,int); + vw = va_arg(ap,int); + vh = va_arg(ap,int); + break; + default: + va_end(ap); + res = errhdlr("unknown video mode"); + goto done; + } + va_end(ap); + if (c) + for(pl = 1; (pl < 32) && ((1UL << pl) < (GrColor)c); pl++) ; + for( ; ; ) { + GrContext cxt; + GrFrameDriver fdr; + GrVideoMode *mdp,vmd; + mdp = (DRVINFO->vdriver->selectmode)(DRVINFO->vdriver,w,h,pl,t,NULL); + if(!mdp) { + res = errhdlr("could not find suitable video mode"); + goto done; + } + sttcopy(&vmd,mdp); + if((t || buildframedriver(&vmd,&fdr)) && + (*vmd.extinfo->setup)(&vmd,noclear) && + (t || buildcontext(&vmd,&fdr,&cxt))) { + if((!t) && + ((vw > vmd.width) || (vh > vmd.height)) && + (vmd.extinfo->setvsize != NULL) && + (vmd.extinfo->scroll != NULL)) { + int ww = vmd.width = imax(vw,vmd.width); + int hh = vmd.height = imax(vh,vmd.height); + if(!(*vmd.extinfo->setvsize)(&vmd,ww,hh,&vmd) || + !buildcontext(&vmd,&fdr,&cxt)) { + sttcopy(&vmd,mdp); + buildcontext(&vmd,&fdr,&cxt); + (*vmd.extinfo->setup)(&vmd,noclear); + } + } + DBGPRINTF(DBG_SETMD,("GrMouseUnInit ...\n")); + GrMouseUnInit(); + DBGPRINTF(DBG_SETMD,("GrMouseUnInit done\n")); + DRVINFO->setbank = (void (*)(int ))_GrDummyFunction; + DRVINFO->setrwbanks = (void (*)(int,int))_GrDummyFunction; + DRVINFO->curbank = (-1); + DRVINFO->splitbanks = FALSE; + if(!t) { + if(vmd.extinfo->setbank) { + DRVINFO->setbank = vmd.extinfo->setbank; + } + if(vmd.extinfo->setrwbanks) { + DRVINFO->setrwbanks = vmd.extinfo->setrwbanks; + DRVINFO->splitbanks = TRUE; + } + if(umul32(vmd.lineoffset,vmd.height) <= 0x10000L) { + DRVINFO->splitbanks = TRUE; + } + } + else { + sttzero(&cxt); + sttcopy(&fdr,&DRVINFO->tdriver); + cxt.gc_driver = &DRVINFO->tdriver; + } + sttcopy(&CXTINFO->current,&cxt); + sttcopy(&CXTINFO->screen, &cxt); + sttcopy(&DRVINFO->fdriver,&fdr); + sttcopy(&DRVINFO->sdriver,&fdr); + sttcopy(&DRVINFO->actmode,&vmd); + DRVINFO->curmode = mdp; + DRVINFO->mcode = which; + DRVINFO->vposx = 0; + DRVINFO->vposy = 0; + DBGPRINTF(DBG_SETMD,("GrResetColors ...\n")); + if ( !_GrResetColors() ) { + res = errhdlr("could not set color mode"); + goto done; + } + DBGPRINTF(DBG_SETMD,("GrResetColors done\n")); + if(fdr.init) { + DBGPRINTF(DBG_SETMD,("fdr.init ...\n")); + (*fdr.init)(&DRVINFO->actmode); + DBGPRINTF(DBG_SETMD,("fdr.init done\n")); + } + if(DRVINFO->mdsethook) { + DBGPRINTF(DBG_SETMD,("mdsethook ...\n")); + (*DRVINFO->mdsethook)(); + DBGPRINTF(DBG_SETMD,("mdsethook done\n")); + } + DBGPRINTF(DBG_SETMD,("GrSetMode complete\n")); + res = TRUE; + goto done; + } + mdp->present = FALSE; + } +done: GRX_RETURN(res); +} + diff --git a/thirdparty/grx249/src/setup/version.c b/thirdparty/grx249/src/setup/version.c new file mode 100644 index 0000000..bfbff30 --- /dev/null +++ b/thirdparty/grx249/src/setup/version.c @@ -0,0 +1,26 @@ +/** + ** version.c ---- return GRX library version + ** + ** Copyright (c) 1997 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +unsigned GrGetLibraryVersion(void) { + return (unsigned)GRX_VERSION_API; +} + +unsigned GrGetLibrarySystem(void) { + return (unsigned)GRX_VERSION; +} diff --git a/thirdparty/grx249/src/setup/viewport.c b/thirdparty/grx249/src/setup/viewport.c new file mode 100644 index 0000000..922b81e --- /dev/null +++ b/thirdparty/grx249/src/setup/viewport.c @@ -0,0 +1,40 @@ +/** + ** viewport.c ---- set display start address for virtual screen + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "arith.h" + +int GrSetViewport(int x,int y) +{ + int res[2]; + if(!GrScreenIsVirtual()) return(FALSE); + if(!DRVINFO->actmode.extinfo->scroll) return(FALSE); + x = imax(0,imin((GrVirtualX() - GrScreenX()),x)); + y = imax(0,imin((GrVirtualY() - GrScreenY()),y)); + if((x == GrViewportX()) && (y == GrViewportY())) return(TRUE); + if((*DRVINFO->actmode.extinfo->scroll)(&DRVINFO->actmode,x,y,res)) { + DRVINFO->vposx = res[0]; + DRVINFO->vposy = res[1]; + return(TRUE); + } + return(FALSE); +} + + + + diff --git a/thirdparty/grx249/src/shape/circle1.c b/thirdparty/grx249/src/shape/circle1.c new file mode 100644 index 0000000..9e484e1 --- /dev/null +++ b/thirdparty/grx249/src/shape/circle1.c @@ -0,0 +1,27 @@ +/** + ** circle1.c ---- draw ellipse + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrEllipse(int xc,int yc,int xa,int ya,GrColor c) +{ + GrFillArg fval; + fval.color = c; + _GrScanEllipse(xc,yc,xa,ya,&_GrSolidFiller,fval,FALSE); +} diff --git a/thirdparty/grx249/src/shape/circle2.c b/thirdparty/grx249/src/shape/circle2.c new file mode 100644 index 0000000..12a1284 --- /dev/null +++ b/thirdparty/grx249/src/shape/circle2.c @@ -0,0 +1,47 @@ +/** + ** circle2.c ---- draw ellipse arc + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "shapes.h" + +void GrEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrColor c) +{ + int (*pnts)[2]; + setup_ALLOC(); + pnts = ALLOC(sizeof(int) * 2 * (GR_MAX_ELLIPSE_POINTS + 1)); + if (pnts != NULL) + { + GrFillArg fval; + int npts = GrGenerateEllipseArc(xc,yc,xa,ya,start,end,pnts); + int close = FALSE; + switch(style) { + case GR_ARC_STYLE_CLOSE2: + pnts[npts][0] = xc; + pnts[npts][1] = yc; + npts++; + case GR_ARC_STYLE_CLOSE1: + close = TRUE; + break; + } + fval.color = c; + _GrDrawPolygon(npts,pnts,&_GrSolidFiller,fval,close); + FREE(pnts); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/shape/circle3.c b/thirdparty/grx249/src/shape/circle3.c new file mode 100644 index 0000000..27ae0d7 --- /dev/null +++ b/thirdparty/grx249/src/shape/circle3.c @@ -0,0 +1,25 @@ +/** + ** circle3.c ---- draw circle + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrCircle(int xc,int yc,int r,GrColor c) +{ + GrEllipse(xc,yc,r,r,c); +} diff --git a/thirdparty/grx249/src/shape/circle4.c b/thirdparty/grx249/src/shape/circle4.c new file mode 100644 index 0000000..cb92a15 --- /dev/null +++ b/thirdparty/grx249/src/shape/circle4.c @@ -0,0 +1,26 @@ +/** + ** circle4.c ---- draw circle arc + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c) +{ + GrEllipseArc(xc,yc,r,r,start,end,style,c); +} + diff --git a/thirdparty/grx249/src/shape/drawpoly.c b/thirdparty/grx249/src/shape/drawpoly.c new file mode 100644 index 0000000..f4d4bbe --- /dev/null +++ b/thirdparty/grx249/src/shape/drawpoly.c @@ -0,0 +1,64 @@ +/** + ** drawpoly.c ---- draw the outline of a polygon + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" +#include "clipping.h" +#include "arith.h" + +void _GrDrawPolygon(int n,int pt[][2],GrFiller *f,GrFillArg c,int doClose) +{ + int i,px,py,x1,y1,x2,y2; + if(n <= 0) return; + if(n == 1) doClose = TRUE; + x1 = x2 = pt[0][0]; + y1 = y2 = pt[0][1]; + for(i = 1; i < n; i++) { + int *ppt = pt[i]; + if(x1 > ppt[0]) x1 = ppt[0]; + if(x2 < ppt[0]) x2 = ppt[0]; + if(y1 > ppt[1]) y1 = ppt[1]; + if(y2 < ppt[1]) y2 = ppt[1]; + } + clip_ordbox(CURC,x1,y1,x2,y2); + mouse_block(CURC,x1,y1,x2,y2); + px = pt[n - 1][0]; + py = pt[n - 1][1]; + for(i = 0; i < n; i++) { + x1 = px; + y1 = py; + x2 = px = pt[i][0]; + y2 = py = pt[i][1]; + if(i | doClose) { + if(y1 > y2) { + iswap(x1,x2); + iswap(y1,y2); + } + clip_line_(CURC,x1,y1,x2,y2,continue,CLIP_EMPTY_MACRO_ARG); + (*f->line)( + (x1 + CURC->gc_xoffset), + (y1 + CURC->gc_yoffset), + (x2 - x1), + (y2 - y1), + c + ); + } + } + mouse_unblock(); +} + diff --git a/thirdparty/grx249/src/shape/fillcir1.c b/thirdparty/grx249/src/shape/fillcir1.c new file mode 100644 index 0000000..82f6721 --- /dev/null +++ b/thirdparty/grx249/src/shape/fillcir1.c @@ -0,0 +1,25 @@ +/** + ** fillcir1.c ---- filled circle + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrFilledCircle(int xc,int yc,int r,GrColor c) +{ + GrFilledEllipse(xc,yc,r,r,c); +} diff --git a/thirdparty/grx249/src/shape/fillcir2.c b/thirdparty/grx249/src/shape/fillcir2.c new file mode 100644 index 0000000..3b2e89d --- /dev/null +++ b/thirdparty/grx249/src/shape/fillcir2.c @@ -0,0 +1,26 @@ +/** + ** fillcir2.c ---- filled circle arc + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c) +{ + GrFilledEllipseArc(xc,yc,r,r,start,end,style,c); +} + diff --git a/thirdparty/grx249/src/shape/fillcnvx.c b/thirdparty/grx249/src/shape/fillcnvx.c new file mode 100644 index 0000000..0b87a96 --- /dev/null +++ b/thirdparty/grx249/src/shape/fillcnvx.c @@ -0,0 +1,27 @@ +/** + ** fillcnvx.c ---- fill a convex polygon with a solid color + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrFilledConvexPolygon(int n,int pt[][2],GrColor c) +{ + GrFillArg fval; + fval.color = c; + _GrScanConvexPoly(n,pt,&_GrSolidFiller,fval); +} diff --git a/thirdparty/grx249/src/shape/fillell1.c b/thirdparty/grx249/src/shape/fillell1.c new file mode 100644 index 0000000..7b11403 --- /dev/null +++ b/thirdparty/grx249/src/shape/fillell1.c @@ -0,0 +1,27 @@ +/** + ** fillell1.c ---- filled ellipse + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c) +{ + GrFillArg fval; + fval.color = c; + _GrScanEllipse(xc,yc,xa,ya,&_GrSolidFiller,fval,TRUE); +} diff --git a/thirdparty/grx249/src/shape/fillell2.c b/thirdparty/grx249/src/shape/fillell2.c new file mode 100644 index 0000000..3ce041d --- /dev/null +++ b/thirdparty/grx249/src/shape/fillell2.c @@ -0,0 +1,42 @@ +/** + ** fillell2.c ---- filled ellipse arc + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "shapes.h" + +void GrFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrColor c) +{ + int (*pnts)[2]; + setup_ALLOC(); + pnts = ALLOC(sizeof(int) * 2 * (GR_MAX_ELLIPSE_POINTS + 1)); + if (pnts != NULL) + { + GrFillArg fval; + int npts = GrGenerateEllipseArc(xc,yc,xa,ya,start,end,pnts); + if(style == GR_ARC_STYLE_CLOSE2) { + pnts[npts][0] = xc; + pnts[npts][1] = yc; + npts++; + } + fval.color = c; + _GrScanPolygon(npts,pnts,&_GrSolidFiller,fval); + FREE(pnts); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/shape/fillpoly.c b/thirdparty/grx249/src/shape/fillpoly.c new file mode 100644 index 0000000..cd6d06c --- /dev/null +++ b/thirdparty/grx249/src/shape/fillpoly.c @@ -0,0 +1,27 @@ +/** + ** fillpoly.c ---- fill an arbitrary polygon with a solid color + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrFilledPolygon(int n,int pt[][2],GrColor c) +{ + GrFillArg fval; + fval.color = c; + _GrScanPolygon(n,pt,&_GrSolidFiller,fval); +} diff --git a/thirdparty/grx249/src/shape/flood.c b/thirdparty/grx249/src/shape/flood.c new file mode 100644 index 0000000..c8eafe7 --- /dev/null +++ b/thirdparty/grx249/src/shape/flood.c @@ -0,0 +1,251 @@ +/** + ** flood.c ---- fill an arbitrary area + ** + ** Copyright (c) 1997 Hartmut Schirmer + ** [e-mail: hsc@techfak.uni-kiel.de] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include + +#include "libgrx.h" +#include "memfill.h" +#include "shapes.h" + +static ScanFillFunc _filler; +static GrFillArg _fa; +static int lx, ly, mx, my, lxo, lyo; +static GrColor _border; +static jmp_buf error; + +typedef unsigned char element; /* for 1bit/pixel images */ +typedef unsigned short line_index; /* start index table */ +static element **done = NULL; /* bitmap of already processed pixel */ +static element **start = NULL; /* pixel that need to be processed */ +static unsigned elements; /* no. bytes in each bitmap line */ +static line_index *start_flg = NULL; /* !=0: index+1 of first start element !=0 */ + /* ==0: nothing to do */ + +#define bits_per_element (sizeof(element)*8) +#define offset_div (bits_per_element) +#define calc_bit(x) ( ((element)1) << ((x)&(bits_per_element-1))) +#define calc_high_bits(x) ( (~((element)0)) << ((x)&(bits_per_element-1))) +#define calc_ofs(x) ((x) / offset_div) + +/* -------- internal line buffer functions +** +** (x,y) scaled to (0..mx,0..my) +*/ + +static INLINE +element *generate_line(element **buf, int y) { + if (buf[y] == NULL) + if ( (buf[y] = calloc(sizeof(element),elements)) == NULL) + longjmp(error,1); + return buf[y]; +} + +static INLINE +void mark_line( element **buf, int x1, int x2, int y) { + element *l = generate_line(buf,y); + element *anf, *ende; + int start_bit, stop_bit; + + anf = &l[calc_ofs(x1)]; + ende = &l[calc_ofs(x2)]; + start_bit = calc_high_bits(x1); + if (anf != ende) { + *(anf++) |= start_bit; + if (anf != ende) { + GR_repl cv = ~((GR_repl)0); + unsigned w = (ende-anf)*sizeof(element); + repfill_b(anf,cv,w); + } + start_bit = ~0; + } + /* start_bit rejects all invalid low bits, let stop_bit discard + all invalid high bits, but make sure stop_bit won't get zero */ + stop_bit = ~calc_high_bits(x2+1); + if (stop_bit) start_bit &= stop_bit; + *ende |= start_bit; +} + +static INLINE +void set_pix(element **buf, int x, int y) { + element *l = generate_line(buf,y); + l[calc_ofs(x)] |= calc_bit(x); +} + +static INLINE +int test_pix(element **buf, int x, int y) { + element *l = buf[y]; + if (l != NULL) + return (l[calc_ofs(x)] & calc_bit(x)) != 0; + return FALSE; +} + +static INLINE +int test_screen(int x, int y) { + return (GrPixelNC(x+lx,y+ly) == _border); +} + +static INLINE +int test_pixel(int x, int y) { + if (test_pix(done,x,y)) return TRUE; + if (test_screen(x,y)) { + set_pix(done,x,y); + return TRUE; + } + return FALSE; +} + +static INLINE +void SetStartFlag(int x, int y) { + int _x = calc_ofs(x); + if ( !start_flg[y] + || _x 0 && !test_pixel(sx-1,y)) + --sx; + while ( x < mx && !test_pixel(x+1,y)) + ++x; + (*_filler)(sx+lxo,y+lyo,x-sx+1,_fa); + mark_line( done, sx, x, y); + if (y>0) { mark_line( start, sx, x, y-1); + SetStartFlag(sx,y-1); } + if (y 1 here */ + s += i; d += i; + for ( ; i < elements ; ++i) + *(s++) &= ~*(d++); + s = start[top]; + } + i=start_flg[top]-1; start_flg[top] = 0; + for ( s += i; i < elements ; ++i, ++s) + if (*s) { + element b = 1; + int x = i*offset_div; + do { + while ( !(*s&b)) { ++x; b <<= 1; } + if (test_screen(x,top)) { + set_pix(done,x,top); + *s ^= b; + } else { + SetStartFlag(x,top); + fill(x,top); + rescan = 1; + goto ThisLine; + } + } while (*s); + } + } + top += dir; + } + dir = -dir; + top += dir; + } while (rescan); +} + +void _GrFloodFill(int x,int y,GrColor border,GrFiller *f,GrFillArg fa) { + int _x, _y; + + lx = CURC->gc_xcliplo; + mx = CURC->gc_xcliphi; + ly = CURC->gc_ycliplo; + my = CURC->gc_ycliphi; + lxo = lx + CURC->gc_xoffset; + lyo = ly + CURC->gc_yoffset; + + if ( x < lx || y < ly || x > mx || y > my || GrPixelNC(x,y) == border) + return; + + _border = border; + _filler = f->scan; + _fa = fa; + mx -= lx; _x = x - lx; + my -= ly; _y = y - ly; + done = calloc(sizeof(element *), (size_t)(my+1)); + start = calloc(sizeof(element *), (size_t)(my+1)); + start_flg = calloc(sizeof(line_index), (size_t)(my+1)); + if (done==NULL || start==NULL || start_flg==NULL) { +/* ERR = grNoFloodMem; */ + goto FreeMem; + } + + if (setjmp(error) == 0) { + elements = calc_ofs(mx + bits_per_element) + 1; + + mouse_block(CURC,lx,ly,mx,my); + set_pix(start, _x, _y); + SetStartFlag(_x,_y); + work(); + mouse_unblock(); + } else { + /* generate_line() called longjmp() : out of memory error */ +/* ERR = grNoFloodMem; */ + } + +FreeMem: + if (done != NULL) { + int i; + for (i=my; i >= 0; --i) + if (done[i] != NULL) + free(done[i]); + free(done); + done = NULL; + } + if (start != NULL) { + int i; + for (i=my; i >= 0; --i) + if (start[i] != NULL) + free(start[i]); + free(start); + start = NULL; + } + if (start_flg != NULL) { + free(start_flg); + start_flg = NULL; + } +} diff --git a/thirdparty/grx249/src/shape/floodfil.c b/thirdparty/grx249/src/shape/floodfil.c new file mode 100644 index 0000000..dfa45e8 --- /dev/null +++ b/thirdparty/grx249/src/shape/floodfil.c @@ -0,0 +1,27 @@ +/** + ** floodfil.c ---- fill an arbitrary area with a solid color + ** + ** Copyright (c) 1997 Hartmut Schirmer + ** [e-mail: hsc@techfak.uni-kiel.de] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrFloodFill(int x, int y, GrColor border, GrColor c) +{ + GrFillArg fval; + fval.color = c; + _GrFloodFill(x,y,border,&_GrSolidFiller,fval); +} diff --git a/thirdparty/grx249/src/shape/genellip.c b/thirdparty/grx249/src/shape/genellip.c new file mode 100644 index 0000000..8b93863 --- /dev/null +++ b/thirdparty/grx249/src/shape/genellip.c @@ -0,0 +1,152 @@ +/** + ** genellip.c ---- generate points for an ellipse or ellipse arc + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "arith.h" + +#define MAXPTS (GR_MAX_ELLIPSE_POINTS & (~15)) +#define SEGLEN 5 /* preferred lenght of line segments on arc */ +#define TRIGMGN 16384 /* scale factor for sine table */ +#define PERIOD 1024 /* number of points in sine table */ +#define PHALF (PERIOD / 2) +#define PQUART (PERIOD / 4) + +static int sintab[PQUART + 1] = { + 0, 101, 201, 302, 402, 503, 603, 704, + 804, 904, 1005, 1105, 1205, 1306, 1406, 1506, + 1606, 1706, 1806, 1906, 2006, 2105, 2205, 2305, + 2404, 2503, 2603, 2702, 2801, 2900, 2999, 3098, + 3196, 3295, 3393, 3492, 3590, 3688, 3786, 3883, + 3981, 4078, 4176, 4273, 4370, 4467, 4563, 4660, + 4756, 4852, 4948, 5044, 5139, 5235, 5330, 5425, + 5520, 5614, 5708, 5803, 5897, 5990, 6084, 6177, + 6270, 6363, 6455, 6547, 6639, 6731, 6823, 6914, + 7005, 7096, 7186, 7276, 7366, 7456, 7545, 7635, + 7723, 7812, 7900, 7988, 8076, 8163, 8250, 8337, + 8423, 8509, 8595, 8680, 8765, 8850, 8935, 9019, + 9102, 9186, 9269, 9352, 9434, 9516, 9598, 9679, + 9760, 9841, 9921, 10001, 10080, 10159, 10238, 10316, + 10394, 10471, 10549, 10625, 10702, 10778, 10853, 10928, + 11003, 11077, 11151, 11224, 11297, 11370, 11442, 11514, + 11585, 11656, 11727, 11797, 11866, 11935, 12004, 12072, + 12140, 12207, 12274, 12340, 12406, 12472, 12537, 12601, + 12665, 12729, 12792, 12854, 12916, 12978, 13039, 13100, + 13160, 13219, 13279, 13337, 13395, 13453, 13510, 13567, + 13623, 13678, 13733, 13788, 13842, 13896, 13949, 14001, + 14053, 14104, 14155, 14206, 14256, 14305, 14354, 14402, + 14449, 14497, 14543, 14589, 14635, 14680, 14724, 14768, + 14811, 14854, 14896, 14937, 14978, 15019, 15059, 15098, + 15137, 15175, 15213, 15250, 15286, 15322, 15357, 15392, + 15426, 15460, 15493, 15525, 15557, 15588, 15619, 15649, + 15679, 15707, 15736, 15763, 15791, 15817, 15843, 15868, + 15893, 15917, 15941, 15964, 15986, 16008, 16029, 16049, + 16069, 16088, 16107, 16125, 16143, 16160, 16176, 16192, + 16207, 16221, 16235, 16248, 16261, 16273, 16284, 16295, + 16305, 16315, 16324, 16332, 16340, 16347, 16353, 16359, + 16364, 16369, 16373, 16376, 16379, 16381, 16383, 16384, + 16384 +}; + +static int last_xs = 0,last_ys = 0; +static int last_xe = 0,last_ye = 0; +static int last_xc = 0,last_yc = 0; + +static void GrSinCos(int n,int cx,int cy,int rx,int ry,int *pt) +{ + int cval,sval; + switch((n &= (PERIOD - 1)) / PQUART) { + case 0: + sval = sintab[n]; + cval = sintab[PQUART - n]; + break; + case 1: + sval = sintab[PHALF - n]; + cval = -sintab[n - PQUART]; + break; + case 2: + sval = -sintab[n - PHALF]; + cval = -sintab[PERIOD - PQUART - n]; + break; + default: /* must be 3 */ + sval = -sintab[PERIOD - n]; + cval = sintab[n - PERIOD + PQUART]; + break; + } + pt[0] = cx; pt[0] += irscale(rx,cval,TRIGMGN); + pt[1] = cy; pt[1] -= irscale(ry,sval,TRIGMGN); +} + +int GrGenerateEllipseArc(int cx,int cy,int rx,int ry,int start,int end,int pt[][2]) +{ + int npts = urscale((iabs(rx) + iabs(ry)),314,(SEGLEN * 100)); + int step,closed; + start = irscale(start,PERIOD,GR_MAX_ANGLE_VALUE) & (PERIOD - 1); + end = irscale(end, PERIOD,GR_MAX_ANGLE_VALUE) & (PERIOD - 1); + if(start == end) { + closed = TRUE; + end += PERIOD; + } + else { + if(start > end) end += PERIOD; + closed = FALSE; + } + npts = urscale(npts,(end - start),PERIOD); + npts = umax(npts,16); + npts = umin(npts,MAXPTS); + if(closed) { + for(step = 1; (PERIOD / step) > npts; step <<= 1); + end -= step; + npts = 0; + } + else { + int start2 = end - start - 1; + step = umax(1,((end - start) / npts)); + while(((start2 + step) / step) >= MAXPTS) step++; + start2 = end - (((end - start) / step) * step); + npts = 0; + if(start2 > start) { + GrSinCos(start,cx,cy,rx,ry,pt[0]); + start = start2; + npts++; + } + } + while(start <= end) { + GrSinCos(start,cx,cy,rx,ry,pt[npts]); + start += step; + npts++; + } + last_xc = cx; + last_yc = cy; + last_xs = pt[0][0]; + last_ys = pt[0][1]; + last_xe = pt[npts - 1][0]; + last_ye = pt[npts - 1][1]; + return(npts); +} + +int GrGenerateEllipse(int xc,int yc,int rx,int ry,int pt[][2]) +{ + return(GrGenerateEllipseArc(xc,yc,rx,ry,0,0,pt)); +} + +void GrLastArcCoords(int *xs,int *ys,int *xe,int *ye,int *xc,int *yc) +{ + *xs = last_xs; *ys = last_ys; + *xe = last_xe; *ye = last_ye; + *xc = last_xc; *yc = last_yc; +} diff --git a/thirdparty/grx249/src/shape/polyedge.h b/thirdparty/grx249/src/shape/polyedge.h new file mode 100644 index 0000000..90e0267 --- /dev/null +++ b/thirdparty/grx249/src/shape/polyedge.h @@ -0,0 +1,62 @@ +/** + ** polyedge.h ---- polygon edge structures for scan routines + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +typedef struct { + int x,xlast; /* current and final X coordinates */ + int y,ylast; /* current and final Y coordinates */ + int dx,dy; /* line diagonals */ + int xmajor; /* flag for X major lines */ + int xstep; /* direction of X scan */ + int error; /* Bresenham error term */ +} polyedge; + +#define setup_edge(ep) { \ + (ep)->dy = (ep)->ylast - (ep)->y; \ + (ep)->dx = (ep)->xlast - (ep)->x; \ + if((ep)->dx < 0) { \ + (ep)->xstep = (-1); \ + (ep)->dx = (-(ep)->dx); \ + } \ + else { \ + (ep)->xstep = 1; \ + } \ + if((ep)->dx > (ep)->dy) { \ + (ep)->xmajor = TRUE; \ + (ep)->error = (ep)->dx >> 1; \ + } \ + else { \ + (ep)->xmajor = FALSE; \ + (ep)->error = ((ep)->dy - ((1 - (ep)->xstep) >> 1)) >> 1; \ + } \ +} + +#define xstep_edge(ep) for( ; ; ) { \ + (ep)->x += (ep)->xstep; \ + if(((ep)->error -= (ep)->dy) < 0) { \ + (ep)->error += (ep)->dx; \ + break; \ + } \ +} + +#define ystep_edge(ep) { \ + if(((ep)->error -= (ep)->dx) < 0) { \ + (ep)->x += (ep)->xstep; \ + (ep)->error += (ep)->dy; \ + } \ +} + diff --git a/thirdparty/grx249/src/shape/polygon.c b/thirdparty/grx249/src/shape/polygon.c new file mode 100644 index 0000000..ce19d56 --- /dev/null +++ b/thirdparty/grx249/src/shape/polygon.c @@ -0,0 +1,16 @@ +/** + ** POLYGON.C ---- draw a closed polygon + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] See "doc/copying.cb" for details. + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrPolygon(int n,int pt[][2],GrColor c) +{ + GrFillArg fval; + fval.color = c; + _GrDrawPolygon(n,pt,&_GrSolidFiller,fval,TRUE); +} diff --git a/thirdparty/grx249/src/shape/polyline.c b/thirdparty/grx249/src/shape/polyline.c new file mode 100644 index 0000000..b439aa5 --- /dev/null +++ b/thirdparty/grx249/src/shape/polyline.c @@ -0,0 +1,16 @@ +/** + ** POLYLINE.C ---- draw an open ended polygon + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] See "doc/copying.cb" for details. + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrPolyLine(int n,int pt[][2],GrColor c) +{ + GrFillArg fval; + fval.color = c; + _GrDrawPolygon(n,pt,&_GrSolidFiller,fval,FALSE); +} diff --git a/thirdparty/grx249/src/shape/scancnvx.c b/thirdparty/grx249/src/shape/scancnvx.c new file mode 100644 index 0000000..2d1a771 --- /dev/null +++ b/thirdparty/grx249/src/shape/scancnvx.c @@ -0,0 +1,147 @@ +/** + ** scancnvx.c ---- scan fill a convex polygon + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" +#include "clipping.h" +#include "arith.h" +#include "shape/polyedge.h" + +typedef struct { + unsigned int dir; /* which direction to go for next point */ + unsigned int index; /* index of the current point */ + polyedge e; +} edge; + +#define next_edge(ed,n,pt) { \ + ed.index = (ed.index + ed.dir) % (unsigned int)n; \ + ed.e.x = ed.e.xlast; \ + ed.e.y = ed.e.ylast; \ + ed.e.xlast = pt[ed.index][0]; \ + ed.e.ylast = pt[ed.index][1]; \ +} + +void _GrScanConvexPoly(int n,int pt[][2],GrFiller *f,GrFillArg c) +{ + edge L,R; + int xmin,xmax; + int ymin,ymax; + int ypos,i; + if((n > 1) && + (pt[0][0] == pt[n - 1][0]) && + (pt[0][1] == pt[n - 1][1])) { + n--; + } + if(n < 1) { + return; + } + xmin = xmax = pt[0][0]; + ymin = ymax = pt[0][1]; + ypos = 0; + for(i = 1; i < n; i++) { + int *ppt = pt[i]; + if(ymin > ppt[1]) ymin = ppt[1],ypos = i; + if(ymax < ppt[1]) ymax = ppt[1]; + if(xmin > ppt[0]) xmin = ppt[0]; + if(xmax < ppt[0]) xmax = ppt[0]; + } + clip_ordbox(CURC,xmin,ymin,xmax,ymax); + mouse_block(CURC,xmin,ymin,xmax,ymax); + L.dir = 1; + R.dir = n - 1; + L.index = R.index = ypos; + L.e.xlast = R.e.xlast = pt[ypos][0]; + L.e.ylast = R.e.ylast = pt[ypos][1]; + for( ; ; ) { + next_edge(L,n,pt); + if(L.e.ylast >= ymin) { + clip_line_ymin(CURC,L.e.x,L.e.y,L.e.xlast,L.e.ylast); + setup_edge(&L.e); + break; + } + } + for( ; ; ) { + next_edge(R,n,pt); + if(R.e.ylast >= ymin) { + clip_line_ymin(CURC,R.e.x,R.e.y,R.e.xlast,R.e.ylast); + setup_edge(&R.e); + break; + } + } + for(ypos = ymin; ypos <= ymax; ypos++) { + xmin = L.e.x; + xmax = L.e.x; + if(ypos == L.e.ylast) { + xmin = imin(xmin,L.e.xlast); + xmax = imax(xmax,L.e.xlast); + if(ypos < ymax) for( ; ; ) { + next_edge(L,n,pt); + if(L.e.ylast > ypos) { + setup_edge(&L.e); + break; + } + xmin = imin(xmin,L.e.xlast); + xmax = imax(xmax,L.e.xlast); + } + } + if(ypos != ymax) { + if(L.e.xmajor) { + xstep_edge(&L.e); + xmin = imin(xmin,(L.e.x - L.e.xstep)); + xmax = imax(xmax,(L.e.x - L.e.xstep)); + } + else { + ystep_edge(&L.e); + } + } + xmin = imin(xmin,R.e.x); + xmax = imax(xmax,R.e.x); + if(ypos == R.e.ylast) { + xmin = imin(xmin,R.e.xlast); + xmax = imax(xmax,R.e.xlast); + if(ypos < ymax) for( ; ; ) { + next_edge(R,n,pt); + if(R.e.ylast > ypos) { + setup_edge(&R.e); + break; + } + xmin = imin(xmin,R.e.xlast); + xmax = imax(xmax,R.e.xlast); + } + } + if(ypos != ymax) { + if(R.e.xmajor) { + xstep_edge(&R.e); + xmin = imin(xmin,(R.e.x - R.e.xstep)); + xmax = imax(xmax,(R.e.x - R.e.xstep)); + } + else { + ystep_edge(&R.e); + } + } + clip_ordxrange_(CURC,xmin,xmax,continue,CLIP_EMPTY_MACRO_ARG); + (*f->scan)( + (xmin + CURC->gc_xoffset), + (ypos + CURC->gc_yoffset), + (xmax - xmin + 1), + c + ); + } + mouse_unblock(); +} + diff --git a/thirdparty/grx249/src/shape/scanellp.c b/thirdparty/grx249/src/shape/scanellp.c new file mode 100644 index 0000000..7dd1e6d --- /dev/null +++ b/thirdparty/grx249/src/shape/scanellp.c @@ -0,0 +1,125 @@ +/** + ** scanellp.c ---- draw the outline or scan fill an ellipse + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "arith.h" +#include "clipping.h" +#include "shapes.h" + +#define MAXR 120 /* max radius for which Bresenham works */ + +void _GrScanEllipse(int xc,int yc,int xa,int ya,GrFiller *f,GrFillArg c,int filled) +{ + int x1,x2,y1,y2; + if(xa < 0) xa = (-xa); + if(ya < 0) ya = (-ya); + x1 = xc - xa; y1 = yc - ya; + x2 = xc + xa; y2 = yc + ya; + clip_ordbox(CURC,x1,y1,x2,y2); + mouse_block(CURC,x1,y1,x2,y2); + setup_ALLOC(); + if((xa == 0) || (ya == 0)) (*f->line)( + (x1 + CURC->gc_xoffset), + (y1 + CURC->gc_yoffset), + (x2 - x1), + (y2 - y1), + c + ); + else if((xa > MAXR) || (ya > MAXR)) { /* Bresenham would overflow !! */ + int (*points)[2] = ALLOC(sizeof(int) * 2 * GR_MAX_ELLIPSE_POINTS); + if(points != NULL) { + int count = GrGenerateEllipse(xc,yc,xa,ya,points); + if(filled) _GrScanConvexPoly(count,points,f,c); + else _GrDrawPolygon(count,points,f,c,TRUE); + FREE(points); + } + } + else { + int *scans = ALLOC(sizeof(int) * (ya + 1)); + int row = ya; + int col = 0; + if(scans != NULL) { + long yasq = umul32(ya,ya); + long xasq = umul32(xa,xa); + long xasq2 = xasq + xasq; + long yasq2 = yasq + yasq; + long xasq4 = xasq2 + xasq2; + long yasq4 = yasq2 + yasq2; + long error = (xasq2 * (row - 1) * row) + + (yasq2 * (1 - xasq)) + + xasq; + while((xasq * row) > (yasq * col)) { + if(error >= 0) { + scans[row] = col; + row--; + error -= xasq4 * row; + } + error += yasq2 * (3 + (col << 1)); + col++; + } + error = (yasq2 * (col + 1) * col) + + (xasq2 * ((row * (row - 2)) + 1)) + + (yasq * (1 - xasq2)); + while(row >= 0) { + scans[row] = col; + if(error <= 0) { + col++; + error += yasq4 * col; + } + row--; + error += xasq2 * (2 - (row << 1)); + } + for(row = y1; row <= y2; row++) { + col = iabs(yc - row); + if(!filled && (col < ya)) { + x1 = xc - scans[col]; + x2 = xc - scans[col + 1]; + if(x1 < x2) x2--; + do { + clip_ordxrange_(CURC,x1,x2,break,CLIP_EMPTY_MACRO_ARG); + (*f->scan)( + (x1 + CURC->gc_xoffset), + (row + CURC->gc_yoffset), + (x2 - x1 + 1), + c + ); + } while (0); + x1 = xc + scans[col + 1]; + x2 = xc + scans[col]; + if(x1 < x2) x1++; + } + else { + x1 = xc - scans[col]; + x2 = xc + scans[col]; + } + clip_ordxrange_(CURC,x1,x2,continue,CLIP_EMPTY_MACRO_ARG); + (*f->scan)( + (x1 + CURC->gc_xoffset), + (row + CURC->gc_yoffset), + (x2 - x1 + 1), + c + ); + } + FREE(scans); + } + } + reset_ALLOC(); + mouse_unblock(); +} + diff --git a/thirdparty/grx249/src/shape/scanpoly.c b/thirdparty/grx249/src/shape/scanpoly.c new file mode 100644 index 0000000..15deae8 --- /dev/null +++ b/thirdparty/grx249/src/shape/scanpoly.c @@ -0,0 +1,223 @@ +/** + ** scanpoly.c ---- scan fill an arbitrary polygon + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" +#include "allocate.h" +#include "clipping.h" +#include "arith.h" +#include "shape/polyedge.h" + +typedef enum { + inactive, /* not reached yet */ + active, /* currently contributes point */ + passed /* above current scan line */ +} edgestat; + +typedef struct { + edgestat status; /* status of this edge */ + polyedge e; /* the edge data */ +} edge; + +typedef struct _scan { + struct _scan *next; /* next segment/point in the list */ + int x1,x2; /* endpoints of this filled segment */ +} scan; + +#define add_scanpoint(List,Scp,X1,X2) { \ + scan *prev = NULL; \ + scan *work = List; \ + while(work != NULL) { \ + if(work->x1 > X1) break; \ + prev = work; \ + work = work->next; \ + } \ + Scp->x1 = X1; \ + Scp->x2 = X2; \ + Scp->next = work; \ + if(prev) prev->next = Scp; \ + else List = Scp; \ +} + +#define add_scansegment(List,Scp,X1,X2) { \ + scan *prev = NULL; \ + scan *work = List; \ + int overlap = FALSE; \ + while(work != NULL) { \ + if((work->x1 <= X2) && (X1 <= work->x2)) { \ + overlap = TRUE; \ + if(X1 < work->x1) work->x1 = X1; \ + if(X2 > work->x2) { \ + prev = work; \ + while((work = work->next) != NULL) { \ + if(work->x1 > X2) break; \ + if(work->x2 > X2) X2 = work->x2; \ + } \ + prev->x2 = X2; \ + prev->next = work; \ + } \ + break; \ + } \ + if(work->x1 > X2) break; \ + prev = work; \ + work = work->next; \ + } \ + if(!overlap) { \ + Scp->x1 = X1; \ + Scp->x2 = X2; \ + Scp->next = work; \ + if(prev) prev->next = Scp; \ + else List = Scp; \ + } \ +} + +void _GrScanPolygon(int n,int pt[][2],GrFiller *f,GrFillArg c) +{ + edge *edges,*ep; + scan *scans,*sp,*points,*segments; + int xmin,xmax,ymin,ymax; + int ypos,nedges; + if((n > 1) && + (pt[0][0] == pt[n-1][0]) && + (pt[0][1] == pt[n-1][1])) { + n--; + } + if(n < 1) { + return; + } + setup_ALLOC(); + edges = (edge *)ALLOC(sizeof(edge) * (n + 2)); + scans = (scan *)ALLOC(sizeof(scan) * (n + 8)); + if(edges && scans) { + /* + * Build the edge table. Store only those edges which are in the + * valid Y region. Clip them in Y if necessary. Store them with + * the endpoints ordered by Y in the edge table. + */ + int prevx = xmin = xmax = pt[0][0]; + int prevy = ymin = ymax = pt[0][1]; + nedges = 0; + ep = edges; + while(--n >= 0) { + if(pt[n][1] >= prevy) { + ep->e.x = prevx; + ep->e.y = prevy; + ep->e.xlast = prevx = pt[n][0]; + ep->e.ylast = prevy = pt[n][1]; + } + else { + ep->e.xlast = prevx; + ep->e.ylast = prevy; + ep->e.x = prevx = pt[n][0]; + ep->e.y = prevy = pt[n][1]; + } + if((ep->e.y > GrHighY()) || (ep->e.ylast < GrLowY())) continue; + clip_line_ymin(CURC,ep->e.x,ep->e.y,ep->e.xlast,ep->e.ylast); + if(ymin > ep->e.y) ymin = ep->e.y; + if(ymax < ep->e.ylast) ymax = ep->e.ylast; + if(xmin > ep->e.x) xmin = ep->e.x; + if(xmax < ep->e.xlast) xmax = ep->e.xlast; + setup_edge(&ep->e); + ep->status = inactive; + nedges++; + ep++; + } + if((nedges > 0) && (xmin <= GrHighX()) && (xmax >= GrLowX())) { + if(xmin < GrLowX()) xmin = GrLowX(); + if(ymin < GrLowY()) ymin = GrLowY(); + if(xmax > GrHighX()) xmax = GrHighX(); + if(ymax > GrHighY()) ymax = GrHighY(); + mouse_block(CURC,xmin,ymin,xmax,ymax); + /* + * Scan for every row between ymin and ymax. + * Build a linked list of disjoint segments to fill. Rules: + * (1) a horizontal edge in the row contributes a segment + * (2) any other edge crossing the row contributes a point + * (3) every segment between even and odd points is filled + */ + for(ypos = ymin; ypos <= ymax; ypos++) { + sp = scans; + points = NULL; + segments = NULL; + for(n = nedges,ep = edges; --n >= 0; ep++) { + switch(ep->status) { + case inactive: + if(ep->e.y != ypos) break; + if(ep->e.dy == 0) { + ep->status = passed; + xmin = ep->e.x; + xmax = ep->e.xlast; + isort(xmin,xmax); + add_scansegment(segments,sp,xmin,xmax); + sp++; + break; + } + ep->status = active; + case active: + xmin = xmax = ep->e.x; + if(ep->e.ylast == ypos) { + ep->status = passed; + xmax = ep->e.xlast; + isort(xmin,xmax); + add_scanpoint(points,sp,xmin,xmax); + sp++; + } + else if(ep->e.xmajor) { + xstep_edge(&ep->e); + xmax = ep->e.x - ep->e.xstep; + isort(xmin,xmax); + } + else { + ystep_edge(&ep->e); + } + add_scanpoint(points,sp,xmin,xmax); + sp++; + break; + default: + break; + } + } + while(points != NULL) { + scan *nextpt = points->next; + if(!nextpt) break; + xmin = points->x1; + xmax = nextpt->x2; + points = nextpt->next; + add_scansegment(segments,nextpt,xmin,xmax); + } + while(segments != NULL) { + xmin = segments->x1; + xmax = segments->x2; + segments = segments->next; + clip_ordxrange_(CURC,xmin,xmax,continue,CLIP_EMPTY_MACRO_ARG); + (*f->scan)( + (xmin + CURC->gc_xoffset), + (ypos + CURC->gc_yoffset), + (xmax - xmin + 1), + c + ); + } + } + mouse_unblock(); + } + } + if (edges) FREE(edges); + if (scans) FREE(scans); + reset_ALLOC(); +} + diff --git a/thirdparty/grx249/src/shape/solidfil.c b/thirdparty/grx249/src/shape/solidfil.c new file mode 100644 index 0000000..ef14ef6 --- /dev/null +++ b/thirdparty/grx249/src/shape/solidfil.c @@ -0,0 +1,42 @@ +/** + ** solidfil.c ---- wrapper for solid filling + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + */ + +#include "libgrx.h" +#include "shapes.h" + +static void pixel(int x,int y,GrFillArg fval) { + GRX_ENTER(); + FDRV->drawpixel(x,y,fval.color); + GRX_LEAVE(); +} + +static void line(int x,int y,int dx,int dy,GrFillArg fval) { + GRX_ENTER(); + FDRV->drawline(x,y,dx,dy,fval.color); + GRX_LEAVE(); +} + +static void scan(int x,int y,int w,GrFillArg fval) { + GRX_ENTER(); + FDRV->drawhline(x,y,w,fval.color); + GRX_LEAVE(); +} + +GrFiller _GrSolidFiller = { + pixel, line, scan +}; + diff --git a/thirdparty/grx249/src/stdobjs.mak b/thirdparty/grx249/src/stdobjs.mak new file mode 100644 index 0000000..85d7ae4 --- /dev/null +++ b/thirdparty/grx249/src/stdobjs.mak @@ -0,0 +1,341 @@ +# Standard object files + +STD_1 = $(OP)draw/bitblt$(OX) \ + $(OP)draw/bitbltnc$(OX) \ + $(OP)draw/bitblt1b$(OX) \ + $(OP)draw/box$(OX) \ + $(OP)draw/boxnc$(OX) \ + $(OP)draw/clearclp$(OX) \ + $(OP)draw/clearctx$(OX) \ + $(OP)draw/clearscr$(OX) \ + $(OP)draw/drwinlne$(OX) \ + $(OP)draw/fillbox$(OX) \ + $(OP)draw/fillboxn$(OX) \ + $(OP)draw/frambox$(OX) \ + $(OP)draw/framboxn$(OX) \ + $(OP)draw/getscl$(OX) \ + $(OP)draw/line$(OX) \ + $(OP)draw/linenc$(OX) \ + $(OP)draw/majorln1$(OX) \ + $(OP)draw/majorln2$(OX) \ + $(OP)draw/majorln3$(OX) \ + $(OP)draw/majorln4$(OX) \ + $(OP)draw/pixel$(OX) \ + $(OP)draw/pixelc$(OX) \ + $(OP)draw/plot$(OX) \ + $(OP)draw/putscl$(OX) \ + $(OP)draw/flodspil$(OX) + +STD_2 = $(OP)fdrivers/dotab8$(OX) \ + $(OP)fdrivers/ftable$(OX) \ + $(OP)fdrivers/genblit$(OX) \ + $(OP)fdrivers/gengiscl$(OX) \ + $(OP)fdrivers/genptscl$(OX) \ + $(OP)fdrivers/genstrch$(OX) \ + $(OP)fdrivers/pblitr2r$(OX) \ + $(OP)fdrivers/pblitr2v$(OX) \ + $(OP)fdrivers/pblitv2r$(OX) \ + $(OP)fdrivers/pblitv2v$(OX) \ + $(OP)fdrivers/ram1$(OX) \ + $(OP)fdrivers/ram16$(OX) \ + $(OP)fdrivers/ram4$(OX) \ + $(OP)fdrivers/ram8$(OX) \ + $(OP)fdrivers/rblit_14$(OX) + +STD_3 = $(OP)fonts/fdv_bgi$(OX) \ + $(OP)fonts/fdv_grx$(OX) \ + $(OP)fonts/fdv_raw$(OX) \ + $(OP)fonts/fdv_fna$(OX) \ + $(OP)fonts/fdv_win$(OX) \ + $(OP)fonts/fdtable$(OX) \ + $(OP)fonts/pc6x8$(OX) \ + $(OP)fonts/pc8x8$(OX) \ + $(OP)fonts/pc8x14$(OX) \ + $(OP)fonts/pc8x16$(OX) \ + $(OP)image/ialloc$(OX) \ + $(OP)image/ibuild$(OX) \ + $(OP)image/ifbox$(OX) \ + $(OP)image/ihline$(OX) \ + $(OP)image/iinverse$(OX) \ + $(OP)image/imginlne$(OX) \ + $(OP)image/iplot$(OX) \ + $(OP)image/istretch$(OX) \ + $(OP)gformats/ctx2pnm$(OX) \ + $(OP)gformats/pnm2ctx$(OX) + +STD_4 = $(OP)mouse/bldcurs$(OX) \ + $(OP)mouse/drawcurs$(OX) \ + $(OP)mouse/mouinfo$(OX) \ + $(OP)mouse/mouinlne$(OX) \ + $(OP)mouse/mscursor$(OX) \ + $(OP)mouse/mstime$(OX) + +STD_5 = $(OP)pattern/fillpatt$(OX) \ + $(OP)pattern/makepat$(OX) \ + $(OP)pattern/patfbits$(OX) \ + $(OP)pattern/patfbox$(OX) \ + $(OP)pattern/patfcvxp$(OX) \ + $(OP)pattern/patfline$(OX) \ + $(OP)pattern/patfplot$(OX) \ + $(OP)pattern/patfpoly$(OX) \ + $(OP)pattern/patternf$(OX) \ + $(OP)pattern/pattfldf$(OX) \ + $(OP)pattern/pattline$(OX) \ + $(OP)pattern/pattpoly$(OX) \ + $(OP)pattern/pfcirc$(OX) \ + $(OP)pattern/pfcirca$(OX) \ + $(OP)pattern/pfelli$(OX) \ + $(OP)pattern/pfellia$(OX) \ + $(OP)pattern/ptcirc$(OX) \ + $(OP)pattern/ptcirca$(OX) \ + $(OP)pattern/ptelli$(OX) \ + $(OP)pattern/ptellia$(OX) + +STD_6 = $(OP)setup/clip$(OX) \ + $(OP)setup/clrinfo$(OX) \ + $(OP)setup/clrinlne$(OX) \ + $(OP)setup/colorbw$(OX) \ + $(OP)setup/colorega$(OX) \ + $(OP)setup/colors$(OX) \ + $(OP)setup/context$(OX) \ + $(OP)setup/cxtinfo$(OX) \ + $(OP)setup/cxtinlne$(OX) \ + $(OP)setup/drvinfo$(OX) \ + $(OP)setup/drvinlne$(OX) \ + $(OP)setup/fframe$(OX) \ + $(OP)setup/fgeom$(OX) \ + $(OP)setup/hooks$(OX) \ + $(OP)setup/modewalk$(OX) \ + $(OP)setup/setdrvr$(OX) \ + $(OP)setup/setmode$(OX) \ + $(OP)setup/version$(OX) \ + $(OP)setup/viewport$(OX) \ + $(OP)shape/circle1$(OX) + +STD_7 = $(OP)shape/circle2$(OX) \ + $(OP)shape/circle3$(OX) \ + $(OP)shape/circle4$(OX) \ + $(OP)shape/drawpoly$(OX) \ + $(OP)shape/fillcir1$(OX) \ + $(OP)shape/fillcir2$(OX) \ + $(OP)shape/fillcnvx$(OX) \ + $(OP)shape/fillell1$(OX) \ + $(OP)shape/fillell2$(OX) \ + $(OP)shape/fillpoly$(OX) \ + $(OP)shape/flood$(OX) \ + $(OP)shape/floodfil$(OX) \ + $(OP)shape/genellip$(OX) \ + $(OP)shape/polygon$(OX) \ + $(OP)shape/polyline$(OX) \ + $(OP)shape/scancnvx$(OX) \ + $(OP)shape/scanellp$(OX) \ + $(OP)shape/scanpoly$(OX) \ + $(OP)shape/solidfil$(OX) + +STD_8 = $(OP)text/buildaux$(OX) \ + $(OP)text/buildfnt$(OX) \ + $(OP)text/convfont$(OX) \ + $(OP)text/drawstrg$(OX) \ + $(OP)text/drawtext$(OX) \ + $(OP)text/drwstrg$(OX) \ + $(OP)text/dumpfna$(OX) \ + $(OP)text/dumpfont$(OX) \ + $(OP)text/dumptext$(OX) \ + $(OP)text/epatstrg$(OX) \ + $(OP)text/fntinlne$(OX) \ + $(OP)text/fontinfo$(OX) \ + $(OP)text/fontpath$(OX) \ + $(OP)text/loadfont$(OX) \ + $(OP)text/pattstrg$(OX) \ + $(OP)text/propwdt$(OX) \ + $(OP)text/unloadfn$(OX) + +STD_9 = $(OP)user/ubox$(OX) \ + $(OP)user/ucbox$(OX) \ + $(OP)user/uccirc$(OX) \ + $(OP)user/uccirca$(OX) \ + $(OP)user/ucelli$(OX) \ + $(OP)user/ucellia$(OX) \ + $(OP)user/ucirc$(OX) \ + $(OP)user/ucirca$(OX) \ + $(OP)user/ucircf$(OX) \ + $(OP)user/ucircfa$(OX) \ + $(OP)user/ucline$(OX) \ + $(OP)user/ucpolyg$(OX) \ + $(OP)user/ucpolyl$(OX) \ + $(OP)user/udrwchar$(OX) \ + $(OP)user/udrwstrg$(OX) \ + $(OP)user/uelli$(OX) \ + $(OP)user/uellia$(OX) \ + $(OP)user/uellif$(OX) \ + $(OP)user/uellifa$(OX) \ + $(OP)user/ufcpolyg$(OX) \ + $(OP)user/ufillbox$(OX) \ + $(OP)user/uflood$(OX) \ + $(OP)user/ufpolyg$(OX) \ + $(OP)user/uframbox$(OX) \ + $(OP)user/ugetwin$(OX) \ + $(OP)user/uhline$(OX) \ + $(OP)user/uline$(OX) \ + $(OP)user/upbox$(OX) \ + $(OP)user/upcirc$(OX) + +STD_10= $(OP)user/upcirca$(OX) \ + $(OP)user/upelli$(OX) \ + $(OP)user/upellia$(OX) \ + $(OP)user/upfbox$(OX) \ + $(OP)user/upfcirc$(OX) \ + $(OP)user/upfcirca$(OX) \ + $(OP)user/upfcpoly$(OX) \ + $(OP)user/upfelli$(OX) \ + $(OP)user/upfellia$(OX) \ + $(OP)user/upfflood$(OX) \ + $(OP)user/upfline$(OX) \ + $(OP)user/upfplot$(OX) \ + $(OP)user/upfpolyg$(OX) \ + $(OP)user/upixel$(OX) \ + $(OP)user/upixelc$(OX) \ + $(OP)user/upline$(OX) \ + $(OP)user/uplot$(OX) \ + $(OP)user/upolygon$(OX) \ + $(OP)user/upolylin$(OX) \ + $(OP)user/uppolyg$(OX) \ + $(OP)user/uppolyl$(OX) \ + $(OP)user/usercord$(OX) \ + $(OP)user/usetwin$(OX) \ + $(OP)user/utextxy$(OX) \ + $(OP)user/uvline$(OX) + +STD_11= $(OP)utils/resize$(OX) \ + $(OP)utils/ordswap$(OX) \ + $(OP)utils/shiftscl$(OX) \ + $(OP)utils/strmatch$(OX) \ + $(OP)utils/tmpbuff$(OX) \ + $(OP)vdrivers/vd_mem$(OX) \ + $(OP)vdrivers/vtable$(OX) \ + $(OP)wideline/ccirc$(OX) \ + $(OP)wideline/ccirca$(OX) \ + $(OP)wideline/celli$(OX) \ + $(OP)wideline/cellia$(OX) \ + $(OP)wideline/custbox$(OX) \ + $(OP)wideline/custline$(OX) \ + $(OP)wideline/custplne$(OX) \ + $(OP)wideline/custpoly$(OX) \ + $(OP)wideline/drwcpoly$(OX) + +BGI_1 = $(OP)bgi/arc$(OX) \ + $(OP)bgi/aspectra$(OX) \ + $(OP)bgi/bar$(OX) \ + $(OP)bgi/bar3d$(OX) \ + $(OP)bgi/bccgrx$(OX) \ + $(OP)bgi/bgimode$(OX) \ + $(OP)bgi/circle$(OX) \ + $(OP)bgi/clearvp$(OX) \ + $(OP)bgi/closegra$(OX) \ + $(OP)bgi/clrdev$(OX) \ + $(OP)bgi/detectg$(OX) \ + $(OP)bgi/drvname$(OX) \ + $(OP)bgi/egacolor$(OX) \ + $(OP)bgi/ellipse$(OX) \ + $(OP)bgi/errmsg$(OX) + +BGI_2 = $(OP)bgi/fellipse$(OX) \ + $(OP)bgi/fillpatb$(OX) \ + $(OP)bgi/fillpolb$(OX) \ + $(OP)bgi/fillstyl$(OX) \ + $(OP)bgi/fldfill$(OX) \ + $(OP)bgi/getbkcol$(OX) \ + $(OP)bgi/getcol$(OX) \ + $(OP)bgi/getdefpa$(OX) \ + $(OP)bgi/getfillp$(OX) \ + $(OP)bgi/getfills$(OX) \ + $(OP)bgi/getgramo$(OX) \ + $(OP)bgi/getimage$(OX) \ + $(OP)bgi/getmaxmo$(OX) \ + $(OP)bgi/getmoran$(OX) \ + $(OP)bgi/getpixel$(OX) \ + $(OP)bgi/getviewp$(OX) + +BGI_3 = $(OP)bgi/getx$(OX) \ + $(OP)bgi/gety$(OX) \ + $(OP)bgi/gmaxcol$(OX) \ + $(OP)bgi/gmmaxcol$(OX) \ + $(OP)bgi/gmmaxx$(OX) \ + $(OP)bgi/gmmaxy$(OX) \ + $(OP)bgi/gpalsize$(OX) \ + $(OP)bgi/graphres$(OX) \ + $(OP)bgi/imagesze$(OX) \ + $(OP)bgi/instbgid$(OX) \ + $(OP)bgi/lineb$(OX) \ + $(OP)bgi/linerel$(OX) \ + $(OP)bgi/lineto$(OX) \ + $(OP)bgi/lnestyle$(OX) + +BGI_4 = $(OP)bgi/modename$(OX) \ + $(OP)bgi/moverel$(OX) \ + $(OP)bgi/moveto$(OX) \ + $(OP)bgi/page1$(OX) \ + $(OP)bgi/page2$(OX) \ + $(OP)bgi/page3$(OX) \ + $(OP)bgi/page4$(OX) \ + $(OP)bgi/page5$(OX) \ + $(OP)bgi/page6$(OX) \ + $(OP)bgi/palette$(OX) \ + $(OP)bgi/pieslice$(OX) \ + $(OP)bgi/polygonb$(OX) \ + $(OP)bgi/putimage$(OX) \ + $(OP)bgi/putpixel$(OX) \ + $(OP)bgi/rectang$(OX) \ + $(OP)bgi/regbgidr$(OX) + +BGI_5 = $(OP)bgi/rgbpal_g$(OX) \ + $(OP)bgi/rgbpal_s$(OX) \ + $(OP)bgi/rstcrtmd$(OX) \ + $(OP)bgi/sector$(OX) \ + $(OP)bgi/setbgiwh$(OX) \ + $(OP)bgi/setbkcol$(OX) \ + $(OP)bgi/setbusze$(OX) \ + $(OP)bgi/setcolor$(OX) \ + $(OP)bgi/setrgbc$(OX) \ + $(OP)bgi/setviewp$(OX) \ + $(OP)bgi/setwrmod$(OX) \ + $(OP)bgi/text$(OX) \ + $(OP)bgi/text1$(OX) \ + $(OP)bgi/text2$(OX) \ + $(OP)bgi/text3$(OX) + +BGI_6 = $(OP)bgi/text4$(OX) \ + $(OP)bgi/text5$(OX) \ + $(OP)bgi/text6$(OX) \ + $(OP)bgi/text7$(OX) \ + $(OP)bgi/text8$(OX) \ + $(OP)bgi/text9$(OX) \ + $(OP)bgi/texta$(OX) \ + $(OP)bgi/textb$(OX) \ + $(OP)bgi/textc$(OX) \ + $(OP)bgi/textd$(OX) \ + $(OP)bgi/txtlnest$(OX) \ + $(OP)bgi/bgiext01$(OX) \ + $(OP)bgi/bgiext02$(OX) + +DBG_1 = $(OP)utils/dbgprint$(OX) + +JPG_1 = $(OP)gformats/ctx2jpg$(OX) \ + $(OP)gformats/jpg2ctx$(OX) + +NOJPG_1 = $(OP)gformats/dummyjpg$(OX) + +BMP_1 = $(OP)../addons/bmp/bmp$(OX) + +TIF_1 = $(OP)../addons/ctx2tiff$(OX) + +PNG_1 = $(OP)gformats/ctx2png$(OX) \ + $(OP)gformats/png2ctx$(OX) + +NOPNG_1 = $(OP)gformats/dummypng$(OX) + +PRN_1 = $(OP)../addons/print/grxprint$(OX) \ + $(OP)../addons/print/prndata$(OX) + +PRNBGI_1 = $(OP)bgi/bgiprint$(OX) + diff --git a/thirdparty/grx249/src/text/buildaux.c b/thirdparty/grx249/src/text/buildaux.c new file mode 100644 index 0000000..24823ef --- /dev/null +++ b/thirdparty/grx249/src/text/buildaux.c @@ -0,0 +1,112 @@ +/** + ** buildaux.c ---- generate and store a rotated character for a font + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "arith.h" +#include "memfill.h" + +char far *GrBuildAuxiliaryBitmap(GrFont *f,int chr,int dir,int ul) +{ + unsigned int idx = (unsigned int)chr - f->h.minchar; + unsigned int bpos,rbpos,size,rsize,w,h; + int boff,rboff,rbinc; + char far *stdmap,far *cvtmap; + if(idx >= f->h.numchars) return(NULL); + stdmap = &f->bitmap[f->chrinfo[idx].offset]; + dir = (dir & 3) + ((ul && (f->h.ulheight > 0)) ? 4 : 0); + if(dir == GR_TEXT_RIGHT) return(stdmap); + if(f->auxoffs[--dir] != NULL) { + unsigned int offs = f->auxoffs[dir][idx]; + if(offs > 0) return(&f->auxmap[offs - 1]); + } + else { + size = sizeof(f->auxoffs[0][0]) * f->h.numchars; + f->auxoffs[dir] = farmalloc(size); + if(f->auxoffs[dir] == NULL) return(NULL); + memzero(f->auxoffs[dir],size); + } + h = f->h.height; + w = f->chrinfo[idx].width; + size = h * (boff = (w + 7) & ~7); + rsize = w * (rboff = (h + 7) & ~7); + switch(dir) { + case (GR_TEXT_RIGHT - 1 + 4): + rboff = boff; + rsize = size; + rbpos = 0; + rbinc = 1; + break; + case (GR_TEXT_DOWN - 1): /* downward */ + case (GR_TEXT_DOWN - 1 + 4): + rbpos = h - 1; + rbinc = rboff; + rboff = -1; + break; + case (GR_TEXT_LEFT - 1): /* upside down, right to left */ + case (GR_TEXT_LEFT - 1 + 4): + rboff = boff; + rsize = size; + rbpos = rsize - rboff + w - 1; + rbinc = -1; + rboff = -rboff; + break; + case (GR_TEXT_UP - 1): /* upward */ + case (GR_TEXT_UP - 1 + 4): + rbpos = rsize - rboff; + rbinc = -rboff; + rboff = 1; + break; + default: + return(NULL); + } + if((rsize >>= 3) == 0) return(NULL); + if(rsize > (f->auxsize - f->auxnext)) { + /* add space for 32 (average) characters */ + unsigned int newsize = (((f->h.width + 7) >> 3) * f->h.height) << 6; + newsize = umax(newsize,(rsize << 2)); + newsize = umin(newsize,((unsigned int)(-4) - f->auxsize)); + newsize += f->auxsize; + if(rsize > (newsize - f->auxnext)) return(NULL); + cvtmap = farmalloc(newsize); + if(cvtmap == NULL) return(NULL); + if(f->auxsize > 0) { + memcpy(cvtmap,f->auxmap,f->auxsize); + farfree(f->auxmap); + } + f->auxmap = cvtmap; + f->auxsize = newsize; + } + cvtmap = &f->auxmap[f->auxnext]; + f->auxoffs[dir][idx] = f->auxnext + 1; + f->auxnext += rsize; + memfill_b(cvtmap,0,rsize); + for(h = bpos = 0; bpos < size; bpos += boff,rbpos += rboff,h++) { + unsigned int bp = bpos; + unsigned int bptop = bpos + w; + unsigned int rbp = rbpos; + unsigned int ulrow = ul && ((h - f->h.ulpos) < f->h.ulheight); + for( ; bp < bptop; bp++,rbp += rbinc) { + if(stdmap[bp >> 3] & (0x80 >> (bp & 7)) || ulrow) { + cvtmap[rbp >> 3] |= (0x80 >> (rbp & 7)); + } + } + } + return(cvtmap); +} + diff --git a/thirdparty/grx249/src/text/buildfnt.c b/thirdparty/grx249/src/text/buildfnt.c new file mode 100644 index 0000000..83ed4ec --- /dev/null +++ b/thirdparty/grx249/src/text/buildfnt.c @@ -0,0 +1,352 @@ +/** + ** buildfnt.c ---- allocate and fill a font descriptor + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include + +#include "libgrx.h" +#include "grfontdv.h" +#include "allocate.h" +#include "arith.h" +#include "memfill.h" + +/* + * amounts for various font conversions + */ +#define BOLDWDT(width) (((width) + 3) / 10) +#define ITALWDT(height) (((height) + 1) / 7) +#define PROPGAP(width) (((width) / 6) ? ((width) / 6) : 1) + +/* + * Font conversion option structure + */ +typedef struct { + int oldhgt; /* height of the source font */ + int newhgt; /* height of the created font */ + int boldwdt; /* shift and OR in X dir by this much */ + int italwdt; /* tilt font by this much */ + int dofix; /* convert to fixed width */ + int fixwdt; /* width of the fixed cvt font */ + int doprop; /* convert to proportional width */ + int propgap; /* zero edge pixels for prop cvt */ +} conv; + +#ifdef DEBUG +static void bdump(char *hd,unsigned char *bmp,int w,int h,int pitch) +{ + char *s; + DBGPRINTF(DBG_FONT, ("%s (%dx%d):\n",hd,w,h)); + setup_ALLOC(); + s = ALLOC((size_t) (w + 1)); + if(s == NULL) DBGPRINTF(DBG_FONT, ("no memory to show the char\n")); + else { + while(--h >= 0) { + int x; + for(x = 0; x < w; x++) s[x] = bmp[x] ? '#' : '.'; + s[x] = '\0'; + DBGPRINTF(DBG_FONT, ("%s\n", s)); + bmp += pitch; + } + FREE(s); + } + reset_ALLOC(); +} +#define BDUMP(hd,bmp,w,h,pitch) bdump(hd,bmp,w,h,pitch) +#else +#define BDUMP(hd,bmp,w,h,pitch) +#endif + +static int cvtbitmap(int oldw,int neww,conv *c,char *bmp) +{ + int wofs,i,j,x,y,w,h; + unsigned char *work_base; + setup_ALLOC(); + wofs = umax(oldw,neww) + c->boldwdt + c->italwdt + c->propgap; + wofs = umax(wofs,c->fixwdt); + wofs = (wofs + 15) & ~3; + i = wofs * (umax(c->newhgt,c->oldhgt) + 2); + work_base = ALLOC((size_t)i); + if(work_base) { + unsigned char *work = work_base; + memzero(work,i); + work += wofs; + w = neww - c->boldwdt - c->italwdt; + h = c->newhgt; + if((w == oldw) && (h == c->oldhgt)) { + /* No resizing is needed */ + for(y = 0; y < h; y++) { + i = ((w + 7) & ~7) * y; + j = wofs * y; + for(x = 0; x < w; x++,i++,j++) { + work[j] = bmp[i >> 3] & (0x80 >> (i & 7)); + } + } + BDUMP("after unpacking",work,w,h,wofs); + } + else { + /* Resize the bitmap */ + /* The algorithm first looks for rectangles of '1' pixels */ + /* and then maps these onto the coordinate space of the */ + /* resized bitmap. This seems to work better than simple */ + /* pixel sampling. (No feature loss) */ + for(y = 0; y < c->oldhgt; y++) { + unsigned int pos = 0,ones = 0; + i = ((oldw + 7) & ~7) * y; + for(x = 0; x < oldw; x++,i++) { + if(bmp[i >> 3] & (0x80 >> (i & 7))) { + if(!ones) pos = x; + ones++; + if(x != (oldw - 1)) continue; + } + if(ones > 0) { + unsigned int x1 = urscale(pos,w,oldw); + unsigned int x2 = urscale((pos + ones),w,oldw); + unsigned int y1 = urscale(y,h,c->oldhgt); + unsigned int y2 = urscale((y + 1),h,c->oldhgt); + do { + unsigned int xx = x1; + j = (y1 * wofs) + xx; + do { + work[j++] = 1; + } while(++xx < x2); + } while(++y1 < y2); + ones = 0; + } + } + } + BDUMP("after resize",work,w,h,wofs); + } + /* bold conversion */ + if(c->boldwdt > 0) { + for(y = 0; y < h; y++) { + unsigned char *row = &work[wofs * y]; + unsigned char *p1 = &row[w]; + unsigned char *p2 = &row[w + c->boldwdt]; + while(p1 > row) *--p2 |= *--p1; + } + w += c->boldwdt; + BDUMP("after boldify",work,w,h,wofs); + } + /* italic conversion */ + if(c->italwdt > 0) { + int ymax = h - 1; + int yrnd = ymax >> 1; + for(y = 0; y < h; y++) { + int tilt = ((c->italwdt * (ymax - y)) + yrnd) / ymax; + unsigned char *row = &work[wofs * y]; + unsigned char *p1 = &row[w]; + unsigned char *p2 = &row[w + tilt]; + while(p1 > row) *--p2 = *--p1; + while(p2 > row) *--p2 = 0; + } + w += c->italwdt; + BDUMP("after italicize",work,w,h,wofs); + } + x = 0; + /* proportional or fixed width adjustment */ + if(c->dofix || c->doprop) { + int minx = w; + int maxx = 0; + for(y = 0; y < h; y++) { + i = y * wofs; + for(j = 0; j < w; j++,i++) { + if(work[i] && (j < minx)) minx = j; + if(work[i] && (j > maxx)) maxx = j; + } + } + if(minx > maxx) { + minx = 0; + maxx = w - 1; + } + if(c->dofix) { + neww = c->fixwdt; + w = maxx - minx + 1; + x = (neww - w) >> 1; + } + if(c->doprop) { + w = maxx - minx + 1; + x = minx - (c->propgap >> 1); + neww = w + c->propgap; + } + } + for(y = 0,i = (neww + 7) >> 3; y < h; y++) { + char *bp = &bmp[y * i]; + unsigned char *wp = &work[y * wofs]; + int xpos = x; + memfill_b(bp,0,i); + for(j = 0; j < neww; j++,xpos++) { + if(wp[xpos]) bp[j >> 3] |= (0x80 >> (j & 7)); + } + } + FREE(work_base); + } + reset_ALLOC(); + return(neww); +} + +GrFont *_GrBuildFont( + const GrFontHeader *h, + int cvt, + int wdt, + int hgt, + int cmin, + int cmax, + int (*charwdt)(int chr), + int (*bitmap)(int chr,int w,int h,char *buffer), + int scaled +){ + GrFont *f = NULL; + unsigned int fprop = h->proportional; + unsigned int chrcv = GR_FONTCVT_NONE; + unsigned int bmpcv = GR_FONTCVT_NONE; + unsigned long totwdt = 0L; + unsigned long bmplen = 0L; + unsigned int bmpofs = 0; + unsigned int numch,i,chr; + char *bmp = NULL; + conv cv; + setup_ALLOC(); + sttzero(&cv); + if(cvt & GR_FONTCVT_SKIPCHARS) { + unsigned int lastfntchr = h->minchar + h->numchars - 1; + cmin = umin(umax(cmin,h->minchar),lastfntchr); + cmax = umin(umax(cmax,h->minchar),lastfntchr); + if(cmin > cmax) goto error; + if((unsigned int)cmin > h->minchar) chrcv = GR_FONTCVT_SKIPCHARS; + if((unsigned int)cmax < lastfntchr) chrcv = GR_FONTCVT_SKIPCHARS; + } + else { + cmin = h->minchar; + cmax = h->minchar + h->numchars - 1; + } + if(cvt & GR_FONTCVT_RESIZE) { + if((unsigned int)(wdt = imax(2,wdt)) != h->width) bmpcv=GR_FONTCVT_RESIZE; + if((unsigned int)(hgt = imax(2,hgt)) != h->height) bmpcv=GR_FONTCVT_RESIZE; + } + else { + wdt = h->width; + hgt = h->height; + } + numch = cmax - cmin + 1; + i = sizeof(GrFont) + ((numch - 1) * sizeof(GrFontChrInfo)); + f = malloc(i); + if(!f) goto error; + memzero(f,i); + f->h.name = malloc(strlen(h->name) + 1); + f->h.family = malloc(strlen(h->family) + 1); + if(!f->h.name || !f->h.family) goto error; + strcpy(f->h.name ,h->name); + strcpy(f->h.family,h->family); + f->minwidth = 0x7fff; + f->maxwidth = 0; + for(chr = cmin,i = 0; i < numch; chr++,i++) { + int oldw = (*charwdt)(chr); + unsigned int neww = urscale(oldw,wdt,h->width); + if(oldw < 0) goto error; + if(f->minwidth > neww) f->minwidth = neww; + if(f->maxwidth < neww) f->maxwidth = neww; + f->chrinfo[i].width = oldw; + bmplen += ((neww + 7) >> 3) * hgt; + } + cv.oldhgt = scaled ? hgt : h->height; + cv.newhgt = hgt; + if(cvt & GR_FONTCVT_BOLDIFY) { + cv.boldwdt = BOLDWDT(wdt); + cv.boldwdt = imin(cv.boldwdt,(f->minwidth - 1)); + cv.boldwdt = imax(cv.boldwdt,0); + if(cv.boldwdt > 0) bmpcv |= GR_FONTCVT_BOLDIFY; + } + if(cvt & GR_FONTCVT_ITALICIZE) { + cv.italwdt = ITALWDT(hgt); + cv.italwdt = imin(cv.italwdt,(f->minwidth - cv.boldwdt - 1)); + cv.italwdt = imax(cv.italwdt,0); + if(cv.italwdt > 0) bmpcv |= GR_FONTCVT_ITALICIZE; + } + if((cvt & GR_FONTCVT_FIXIFY) && fprop) { + bmpcv |= GR_FONTCVT_FIXIFY; + cv.fixwdt = f->maxwidth; + bmplen = umul32((hgt * ((cv.fixwdt + 7) >> 3)),numch); + cv.dofix = TRUE; + fprop = FALSE; + } + if((cvt & GR_FONTCVT_PROPORTION) && !fprop) { + bmpcv |= GR_FONTCVT_PROPORTION; + cv.propgap = imax(0,(PROPGAP(wdt) - cv.italwdt)); + bmplen = umul32((hgt * ((wdt + cv.propgap + 7) >> 3)),numch); + cv.doprop = TRUE; + fprop = TRUE; + } + if((unsigned long)(unsigned int)bmplen != bmplen) goto error; + f->bitmap = farmalloc(bmplen); + if(!f->bitmap) goto error; + memzero(f->bitmap,(unsigned int)bmplen); + i = f->maxwidth; + if(h->width > (unsigned int)wdt) i = urscale(i,h->width,wdt); + i = ((i + 31) >> 3) * umax(hgt,h->height); + bmp = ALLOC((size_t)i); + if(!bmp) goto error; + f->minwidth = 0x7fff; + f->maxwidth = 0; + for(chr = cmin,i = 0; i < numch; chr++,i++) { + unsigned int oldw = f->chrinfo[i].width; + unsigned int neww = imax(urscale(oldw,wdt,h->width),1); + unsigned int size; + if(scaled) { + unsigned int raww = neww - cv.boldwdt - cv.italwdt; + if(!(*bitmap)(chr,raww,hgt,bmp)) goto error; + if(bmpcv & ~GR_FONTCVT_RESIZE) neww = cvtbitmap(oldw,raww,&cv,bmp); + } + else { + if(!(*bitmap)(chr,oldw,h->height,bmp)) goto error; + if(bmpcv) neww = cvtbitmap(oldw,neww,&cv,bmp); + } + if(f->minwidth > neww) f->minwidth = neww; + if(f->maxwidth < neww) f->maxwidth = neww; + size = ((neww + 7) >> 3) * hgt; + memcpy(&f->bitmap[bmpofs],bmp,size); + f->chrinfo[i].width = neww; + f->chrinfo[i].offset = bmpofs; + bmpofs += size; + totwdt += neww; + } + f->h.proportional = fprop; + f->h.scalable = h->scalable; + f->h.preloaded = FALSE; + f->h.modified = h->modified | chrcv | bmpcv; + f->h.minchar = cmin; + f->h.numchars = numch; + f->h.width = (cv.dofix || cv.doprop) ? (unsigned int)(totwdt / numch) : wdt; + f->h.height = hgt; + f->h.baseline = urscale(h->baseline,hgt,h->height); + f->h.ulpos = urscale(h->ulpos, hgt,h->height); + f->h.ulheight = urscale(h->ulheight,hgt,h->height); + goto done; + error: + if(f) { + if(f->h.name) free(f->h.name); + if(f->h.family) free(f->h.family); + if(f->bitmap) farfree(f->bitmap); + free(f); + f = NULL; + } + done: + if (bmp) FREE(bmp); + reset_ALLOC(); + return(f); +} + diff --git a/thirdparty/grx249/src/text/convfont.c b/thirdparty/grx249/src/text/convfont.c new file mode 100644 index 0000000..cc36e48 --- /dev/null +++ b/thirdparty/grx249/src/text/convfont.c @@ -0,0 +1,52 @@ +/** + ** convfont.c ---- build a converted font from an already loaded (linked) one + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grfontdv.h" +#include "arith.h" + +static const GrFont *cvfont; + +static int charwdt(int chr) +{ + chr -= cvfont->h.minchar; + if((unsigned int)chr >= cvfont->h.numchars) return(-1); + return(cvfont->chrinfo[chr].width); +} + +static int bitmap(int chr,int w,int h,char *buffer) +{ + chr -= cvfont->h.minchar; + if((unsigned int)chr >= cvfont->h.numchars) return(FALSE); + if((unsigned int)w != cvfont->chrinfo[chr].width) return(FALSE); + if((unsigned int)h != cvfont->h.height) return(FALSE); + memcpy( + buffer, + &cvfont->bitmap[cvfont->chrinfo[chr].offset], + ((w + 7) >> 3) * h + ); + return(TRUE); +} + +GrFont *GrBuildConvertedFont(const GrFont *from,int cvt,int w,int h,int minch,int maxch) +{ + cvfont = from; + if(!cvfont) return(NULL); + return(_GrBuildFont(&from->h,cvt,w,h,minch,maxch,charwdt,bitmap,FALSE)); +} + diff --git a/thirdparty/grx249/src/text/drawstrg.c b/thirdparty/grx249/src/text/drawstrg.c new file mode 100644 index 0000000..153eef7 --- /dev/null +++ b/thirdparty/grx249/src/text/drawstrg.c @@ -0,0 +1,135 @@ +/** + ** drawstrg.c ---- low level character string output + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "text/text.h" + +int _GR_textattrintensevideo = 0; + +void _GrDrawString(const void *text,int length,int x,int y, + const GrTextOption *opt, GrPattern *p, TextDrawBitmapFunc dbm) +{ + GrFont *f; + int x1; + GRX_ENTER(); + + if ( ((f = opt->txo_font) != NULL) + && (x1= GrFontStringWidth(f,text,length,opt->txo_chrtype))!=0 ) { + GrColorTableP fgcp = opt->txo_fgcolor.p; + GrColorTableP bgcp = opt->txo_bgcolor.p; + GrColor fgcv = opt->txo_fgcolor.v; + GrColor bgcv = opt->txo_bgcolor.v; + int undl = (fgcv & GR_UNDERLINE_TEXT) ? 1 : 0; + int rotat = GR_TEXT_IS_VERTICAL(opt->txo_direct) ? ~0 : 0; + int dxpre = 0; + int dypre = 0; + int dxpost= 0; + int dypost= 0; + int oldx = x; + int oldy = y; + int y1 = f->h.height; + int ww = (x1 & ~rotat) | (y1 & rotat); + int hh = (x1 & rotat) | (y1 & ~rotat); + int type, step, x2, y2; + switch(opt->txo_xalign) { + case GR_ALIGN_RIGHT: + x -= ww - 1; + break; + case GR_ALIGN_CENTER: + x -= (ww >> 1); + break; + } + switch(opt->txo_yalign) { + case GR_ALIGN_BASELINE: + if(opt->txo_direct == GR_TEXT_DEFAULT) y -= f->h.baseline; + break; + case GR_ALIGN_BOTTOM: + y -= hh - 1; + break; + case GR_ALIGN_CENTER: + y -= (hh >> 1); + break; + } + mouse_block(CURC,x,y,(x + ww - 1),(y + hh - 1)); + switch(opt->txo_direct) { + case GR_TEXT_DOWN: + dypost = ~0; + break; + case GR_TEXT_LEFT: + dxpre = ~0; + x += ww; + break; + case GR_TEXT_UP: + dypre = ~0; + y += hh; + break; + default: + dxpost = ~0; + break; + } + type = opt->txo_chrtype; + step = GR_TEXTCHR_SIZE(type); + while(--length >= 0) { + int chr = GR_TEXTSTR_CODE(text,type); + int attr,xx,yy,cw,ch; + char far *bmp; + if(type == GR_ATTR_TEXT) { + attr = GR_TEXTSTR_ATTR(text,GR_ATTR_TEXT); + fgcv = GR_CTABLE_COLOR(fgcp,GR_ATTR_FGCOLOR(attr)); + bgcv = GR_CTABLE_COLOR(bgcp,GR_ATTR_BGCOLOR(attr)); + undl = GR_ATTR_UNDERLINE(attr); + } + text = (void *)((char *)(text) + step); + x1 = GrFontCharWidth(f,chr); + y1 = f->h.height; + cw = (x1 & ~rotat) | (y1 & rotat); + ch = (x1 & rotat) | (y1 & ~rotat); + x1 = (x -= (cw & dxpre)); + y1 = (y -= (ch & dypre)); + x2 = (xx = x1) + cw - 1; + y2 = (yy = y1) + ch - 1; + x += (cw & dxpost); + y += (ch & dypost); + clip_ordbox_(CURC,x1,y1,x2,y2,continue,CLIP_EMPTY_MACRO_ARG); + bmp = GrFontCharAuxBmp(f,chr,opt->txo_direct,undl); + if(bmp) (*dbm)( + (x1 + CURC->gc_xoffset), + (y1 + CURC->gc_yoffset), + (x2 - x1 + 1), + (y2 - y1 + 1), + oldx, oldy, + bmp, + ((cw + 7) >> 3), + ((x1 - xx) + ((y1 - yy) * ((cw + 7) & ~7))), + fgcv,bgcv, + p + ); + else (*FDRV->drawblock)( + (x1 + CURC->gc_xoffset), + (y1 + CURC->gc_yoffset), + (x2 - x1 + 1), + (y2 - y1 + 1), + bgcv + ); + } + mouse_unblock(); + } + GRX_LEAVE(); +} diff --git a/thirdparty/grx249/src/text/drawtext.c b/thirdparty/grx249/src/text/drawtext.c new file mode 100644 index 0000000..0125146 --- /dev/null +++ b/thirdparty/grx249/src/text/drawtext.c @@ -0,0 +1,34 @@ +/** + ** drawtext.c ---- draw a character string with the default font + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "libgrx.h" + +void GrTextXY(int x,int y,char *text,GrColor fg,GrColor bg) +{ + GrTextOption opt; + opt.txo_font = &GrDefaultFont; + opt.txo_fgcolor.v = fg; + opt.txo_bgcolor.v = bg; + opt.txo_chrtype = GR_BYTE_TEXT; + opt.txo_direct = GR_TEXT_RIGHT; + opt.txo_xalign = GR_ALIGN_LEFT; + opt.txo_yalign = GR_ALIGN_TOP; + GrDrawString(text,(int)strlen(text),x,y,&opt); +} + diff --git a/thirdparty/grx249/src/text/drwstrg.c b/thirdparty/grx249/src/text/drwstrg.c new file mode 100644 index 0000000..f857391 --- /dev/null +++ b/thirdparty/grx249/src/text/drwstrg.c @@ -0,0 +1,57 @@ +/** + ** drwstrg.c ---- draw a character string + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "text/text.h" + +static void FdrvDrawBitmap(int x,int y,int w,int h,int ox, int oy, + char far *bmp,int pitch,int start, + GrColor fg,GrColor bg,GrPattern *p) +{ + GRX_ENTER(); + (*FDRV->drawbitmap)(x,y,w,h,bmp,pitch,start,fg,bg); + GRX_LEAVE(); +} + +void GrDrawString(void *text,int length,int x,int y,const GrTextOption *opt) +{ + GRX_ENTER(); + _GrDrawString(text,length,x,y,opt,NULL,FdrvDrawBitmap); + GRX_LEAVE(); +} + +void GrDrawChar(int chr,int x,int y,const GrTextOption *opt) +{ + char cbuff[2]; + short sbuff[2]; + + GRX_ENTER(); + switch(opt->txo_chrtype) { + case GR_WORD_TEXT: + case GR_ATTR_TEXT: + sbuff[0] = chr; + GrDrawString(sbuff,1,x,y,opt); + break; + default: + cbuff[0] = chr; + GrDrawString(cbuff,1,x,y,opt); + break; + } + GRX_LEAVE(); +} diff --git a/thirdparty/grx249/src/text/dumpfna.c b/thirdparty/grx249/src/text/dumpfna.c new file mode 100644 index 0000000..5fcc194 --- /dev/null +++ b/thirdparty/grx249/src/text/dumpfna.c @@ -0,0 +1,64 @@ +/** + ** dumpfna.c ---- write an ascii font file from a font in memory + ** + ** Copyright (C) 2002 Dimitar Zhekov + ** E-Mail: jimmy@is-vn.bg + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include + +#include "libgrx.h" + +void GrDumpFnaFont(const GrFont *f, char *fileName) +{ + int chr; + int x, y, width, bytes; + char *buffer; + FILE *fp = fopen(fileName, "w"); + if(!fp) return; + /* write header */ + fprintf(fp, "name %s\n", f->h.name); + fprintf(fp, "family %s\n", f->h.family); + fprintf(fp, "isfixed %d\n", !f->h.proportional); + if(f->h.proportional) { + fprintf(fp, "minwidth %d\n", f->minwidth); + fprintf(fp, "maxwidth %d\n", f->maxwidth); + fprintf(fp, "avg"); + } + fprintf(fp, "width %d\n", f->h.width); + fprintf(fp, "height %d\n", f->h.height); + fprintf(fp, "minchar %d\n", f->h.minchar); + fprintf(fp, "maxchar %d\n", f->h.minchar + f->h.numchars - 1); + fprintf(fp, "baseline %d\n", f->h.baseline); + fprintf(fp, "undwidth %d\n", f->h.ulheight); + /* write characters */ + for(chr = f->h.minchar; chr < f->h.minchar + f->h.numchars; chr++) { + width = GrFontCharWidth(f, chr); + bytes = (width - 1) / 8 + 1; + buffer = GrFontCharBitmap(f, chr); + /* write character header */ + fprintf(fp, "\n; character %d", chr); + if(isgraph(chr)) fprintf(fp, " (%c)", chr); + fprintf(fp, " width = %d\n", width); + /* write character data */ + for(y = 0; y < f->h.height; y++) { + for(x = 0; x < width; x++) + putc(buffer[x >> 3] & (1 << (7 - (x & 7))) ? '#' : '.', fp); + putc('\n', fp); + buffer += bytes; + } + } + fclose(fp); +} diff --git a/thirdparty/grx249/src/text/dumpfont.c b/thirdparty/grx249/src/text/dumpfont.c new file mode 100644 index 0000000..6feee77 --- /dev/null +++ b/thirdparty/grx249/src/text/dumpfont.c @@ -0,0 +1,167 @@ +/** + ** dumpfont.c ---- write a C source file from a font in memory + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include + +#include "libgrx.h" + +/* ----------------------------------------------------------------------- */ +static char bitmaphdr[] = + +"/**\n" +" ** %s ---- GRX 2.0 font converted to C by 'GrDumpFont()'\n" +" **/\n" +"\n" +"#define %s FONTNAME_TEMPORARY_REDIRECTION\n" +"#include \"grx20.h\"\n" +"#undef %s\n" +"\n" +"static unsigned char far %s[] = {\n"; + +/* ----------------------------------------------------------------------- */ +static char fonthdr[] = + +"};\n" +"\n" +"struct {\n" +" GrFont theFont;\n" +" GrFontChrInfo rest[%d];\n" +"} %s = {\n" +" {\n" +" { /* font header */\n" +" %-24s" "/* font name */\n" +" %-24s" "/* font family name */\n" +" %d, \t\t " "/* characters have varying width */\n" +" 0, /* derived from a scalable font */\n" +" 1, /* font permanently linked into program */\n" +" GR_FONTCVT_NONE, /* 'tweaked' font (resized, etc..) */\n" +" %d, \t\t " "/* width (average when proportional) */\n" +" %d, \t\t " "/* font height */\n" +" %d, \t\t " "/* baseline pixel pos (from top) */\n" +" %d, \t\t " "/* underline pixel pos (from top) */\n" +" %d, \t\t " "/* underline width */\n" +" %d, \t\t " "/* lowest character code in font */\n" +" %d \t\t " "/* number of characters in font */\n" +" },\n" +" (char *)%-20s" "/* character bitmap array */\n" +" 0, /* auxiliary bitmap */\n" +" %d,\t\t\t " "/* width of narrowest character */\n" +" %d,\t\t\t " "/* width of widest character */\n" +" 0, /* allocated size of auxiliary bitmap */\n" +" 0, /* free space in auxiliary bitmap */\n" +" { 0\t\t" "}, /* converted character bitmap offsets */\n" +" {{ %d,\t0\t" "}} /* first character info */\n" +" },\n" +" {\n"; + +/* ----------------------------------------------------------------------- */ +static char charinfo[] = + +" { %d,\t%d\t" "}%c /* info for character %-3d */\n"; + +/* ----------------------------------------------------------------------- */ +static char fontend[] = + +" }\n" +"};\n\n"; + +/* ----------------------------------------------------------------------- */ + +void GrDumpFont(const GrFont *f,char *CsymbolName,char *fileName) +{ + unsigned int i; + int offset; + char filname[200]; + char fntname[200]; + char famname[200]; + char bitname[200]; + char *p; + FILE *fp = fopen(fileName,"w"); + if(!fp) return; + strcpy(filname,fileName); + for(p = filname; *p; p++) *p = toupper(*p); + sprintf(fntname,"\"%s",f->h.name); + if((p = strrchr(fntname,'.')) != 0) *p = '\0'; + strcat(fntname,"\","); + sprintf(famname,"\"%s\",",f->h.family); + sprintf(bitname,"%s_bits",CsymbolName); + fprintf( + fp, + bitmaphdr, + filname, + CsymbolName, + CsymbolName, + bitname + ); + for(i = 0; i < f->h.numchars; i++) { + int chr = i + f->h.minchar; + int len = GrFontCharBitmapSize(f,chr); + int pos = 0,j; + char far *bmp = GrFontCharBitmap(f,chr); + fprintf(fp,"\t/* character %d */\n\t",chr); + for(j = 0; j < len; j++) { + fprintf(fp,"0x%02x",(bmp[j] & 0xff)); + if((j + 1) != len) { + putc(',',fp); + if(++pos != 12) continue; + fputs("\n\t",fp); + pos = 0; + } + } + if((i + 1) != f->h.numchars) { + fputs(",\n",fp); + } + } + fprintf(fp, + fonthdr, + f->h.numchars - 1, + CsymbolName, + fntname, + famname, + f->h.proportional, + f->h.width, + f->h.height, + f->h.baseline, + f->h.ulpos, + f->h.ulheight, + f->h.minchar, + f->h.numchars, + (strcat(bitname,","),bitname), + f->minwidth, + f->maxwidth, + GrFontCharWidth(f,f->h.minchar) + ); + offset = GrFontCharBitmapSize(f,f->h.minchar); + for(i = 1; i < f->h.numchars; i++) { + int chr = i + f->h.minchar; + fprintf( + fp, + charinfo, + GrFontCharWidth(f,chr), + offset, + ((i == (f->h.numchars - 1)) ? ' ' : ','), + chr + ); + offset += GrFontCharBitmapSize(f,chr); + } + fputs(fontend,fp); + fclose(fp); +} + diff --git a/thirdparty/grx249/src/text/dumptext.c b/thirdparty/grx249/src/text/dumptext.c new file mode 100644 index 0000000..5ec7990 --- /dev/null +++ b/thirdparty/grx249/src/text/dumptext.c @@ -0,0 +1,156 @@ +/** + ** dumptext.c ---- optimized fixed font text drawing + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "arith.h" + +void GrDumpText(int col,int row,int wdt,int hgt,const GrTextRegion *r) +{ + GrColorTableP fgcp = r->txr_fgcolor.p; + GrColorTableP bgcp = r->txr_bgcolor.p; + GrColor fgcv = r->txr_fgcolor.v; + GrColor bgcv = r->txr_bgcolor.v; + int undl = (fgcv & GR_UNDERLINE_TEXT) ? 1 : 0; + GrFont *f = r->txr_font; + char *ptr = r->txr_buffer; + char *bpt = r->txr_backup; + int cofs = GR_TEXTCHR_SIZE(r->txr_chrtype); + int offs = r->txr_lineoffset; + int fast = bpt ? TRUE : FALSE; + int chrw,chrh,bmpw; + int xpos,ypos; + if((f == NULL) || f->h.proportional) return; + if((unsigned int)col >= (unsigned int)r->txr_width) return; + if((unsigned int)row >= (unsigned int)r->txr_height) return; + wdt = umin(wdt,(r->txr_width - col)); + hgt = umin(hgt,(r->txr_height - row)); + if((wdt <= 0) || (hgt <= 0)) return; + chrw = f->h.width; + chrh = f->h.height; + bmpw = (chrw + 7) >> 3; + xpos = r->txr_xpos + (chrw * col); + ypos = r->txr_ypos + (chrh * row); + if(xpos < GrLowX()) { + int clip = (GrLowX() - xpos + chrw - 1) / chrw; + if((wdt -= clip) <= 0) return; + col += clip; + } + if(ypos < GrLowY()) { + int clip = (GrLowY() - ypos + chrh - 1) / chrh; + if((hgt -= clip) <= 0) return; + row += clip; + } + xpos = r->txr_xpos + (chrw * (col + wdt)) - 1; + ypos = r->txr_ypos + (chrh * (row + hgt)) - 1; + if(xpos > GrHighX()) { + int clip = (xpos - GrHighX() + chrw - 1) / chrw; + if((wdt -= clip) <= 0) return; + } + if(ypos > GrHighY()) { + int clip = (ypos - GrHighY() + chrh - 1) / chrh; + if((hgt -= clip) <= 0) return; + } + ptr += (row * offs) + (col * cofs); + bpt += (row * offs) + (col * cofs); + xpos = r->txr_xpos + (col * chrw); + ypos = r->txr_ypos + (row * chrh); + mouse_block( + CURC, + xpos,ypos, + (xpos + (wdt * chrw) - 1), + (ypos + (hgt * chrh) - 1) + ); + for( ; --hgt >= 0; ptr += offs,bpt += offs,ypos += chrh) { + char *pt2 = ptr; + char *bp2 = bpt; + int wd2 = wdt; + int xp2 = xpos; + for( ; --wd2 >= 0; pt2 += cofs,bp2 += cofs,xp2 += chrw) { + int chr,attr; + char far *bmp; + switch(r->txr_chrtype) { + case GR_WORD_TEXT: + chr = *((unsigned short *)(pt2)); + if(fast) { + if(*((unsigned short *)(bp2)) == chr) continue; + *((unsigned short *)(bp2)) = chr; + } + break; + case GR_ATTR_TEXT: + chr = *((unsigned short *)(pt2)); + if(fast) { + if(*((unsigned short *)(bp2)) == chr) continue; + *((unsigned short *)(bp2)) = chr; + } + attr = GR_TEXTCHR_ATTR(chr,GR_ATTR_TEXT); + chr = GR_TEXTCHR_CODE(chr,GR_ATTR_TEXT); + fgcv = GR_CTABLE_COLOR(fgcp,GR_ATTR_FGCOLOR(attr)); + bgcv = GR_CTABLE_COLOR(bgcp,GR_ATTR_BGCOLOR(attr)); + undl = GR_ATTR_UNDERLINE(attr); + break; + default: + chr = *((unsigned char *)(pt2)); + if(fast) { + if(*((unsigned char *)(bp2)) == chr) continue; + *((unsigned char *)(bp2)) = chr; + } + break; + } + bmp = GrFontCharAuxBmp(f,chr,GR_TEXT_RIGHT,undl); + if(bmp) (*FDRV->drawbitmap)( + (xp2 + CURC->gc_xoffset), + (ypos + CURC->gc_yoffset), + chrw,chrh, + bmp,bmpw,0, + fgcv,bgcv + ); + else (*FDRV->drawblock)( + (xp2 + CURC->gc_xoffset), + (ypos + CURC->gc_yoffset), + chrw,chrh, + bgcv + ); + } + } + mouse_unblock(); +} + +void GrDumpTextRegion(const GrTextRegion *r) +{ + GrDumpText(0,0,r->txr_width,r->txr_height,r); +} + +void GrDumpChar(int chr,int col,int row,const GrTextRegion *r) +{ + int offs; + if((unsigned int)col >= (unsigned int)r->txr_width) return; + if((unsigned int)row >= (unsigned int)r->txr_height) return; + switch(r->txr_chrtype) { + case GR_WORD_TEXT: + case GR_ATTR_TEXT: + offs = (row * r->txr_lineoffset) + (col * sizeof(short)); + *((short *)((char *)r->txr_buffer + offs)) = chr; + break; + default: + offs = (row * r->txr_lineoffset) + (col * sizeof(char)); + *((char *)((char *)r->txr_buffer + offs)) = chr; + break; + } + GrDumpText(col,row,1,1,r); +} + diff --git a/thirdparty/grx249/src/text/epatstrg.c b/thirdparty/grx249/src/text/epatstrg.c new file mode 100644 index 0000000..9c25436 --- /dev/null +++ b/thirdparty/grx249/src/text/epatstrg.c @@ -0,0 +1,40 @@ +/** + ** epatstrg.c ---- extended patterned draw character string + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "shapes.h" +#include "text/text.h" + +static void ExtPatternFilledBmp(int x,int y,int w,int h,int ox, int oy, + char far *bmp,int pitch,int start, + GrColor fg,GrColor bg,GrPattern *p) +{ + GRX_ENTER(); + _GrFillBitmapPatternExt(x,y,w,h,ox,oy,bmp,pitch,start,p,bg); + GRX_LEAVE(); +} + +void GrPatternDrawStringExt(void *text,int length,int x,int y, + const GrTextOption *opt,GrPattern *p) +{ + GRX_ENTER(); + _GrDrawString(text,length,x,y,opt,p,ExtPatternFilledBmp); + GRX_LEAVE(); +} diff --git a/thirdparty/grx249/src/text/fntinlne.c b/thirdparty/grx249/src/text/fntinlne.c new file mode 100644 index 0000000..c42fb1e --- /dev/null +++ b/thirdparty/grx249/src/text/fntinlne.c @@ -0,0 +1,95 @@ +/** + ** fntinlne.c ---- the font inline functions + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +int (GrFontCharPresent)(const GrFont *font,int chr) +{ + return(GrFontCharPresent(font,chr)); +} + +int (GrFontCharWidth)(const GrFont *font,int chr) +{ + return(GrFontCharWidth(font,chr)); +} + +int (GrFontCharHeight)(const GrFont *font,int chr) +{ + return(GrFontCharHeight(font,chr)); +} + +int (GrFontCharBmpRowSize)(const GrFont *font,int chr) +{ + return(GrFontCharBmpRowSize(font,chr)); +} + +int (GrFontCharBitmapSize)(const GrFont *font,int chr) +{ + return(GrFontCharBitmapSize(font,chr)); +} + +int (GrFontStringWidth)(const GrFont *font,void *text,int len,int type) +{ + return(GrFontStringWidth(font,text,len,type)); +} + +int (GrFontStringHeight)(const GrFont *font,void *text,int len,int type) +{ + return(GrFontStringHeight(font,text,len,type)); +} + +char far *(GrFontCharBitmap)(const GrFont *font,int chr) +{ + return(GrFontCharBitmap(font,chr)); +} + +char far *(GrFontCharAuxBmp)(GrFont *font,int chr,int dir,int ul) +{ + return(GrFontCharAuxBmp(font,chr,dir,ul)); +} + +int (GrCharWidth)(int chr,const GrTextOption *opt) +{ + return(GrCharWidth(chr,opt)); +} + +int (GrCharHeight)(int chr,const GrTextOption *opt) +{ + return(GrCharHeight(chr,opt)); +} + +void (GrCharSize)(int chr,const GrTextOption *opt,int *w,int *h) +{ + GrCharSize(chr,opt,w,h); +} + +int (GrStringWidth)(void *text,int length,const GrTextOption *opt) +{ + return(GrStringWidth(text,length,opt)); +} + +int (GrStringHeight)(void *text,int length,const GrTextOption *opt) +{ + return(GrStringHeight(text,length,opt)); +} + +void (GrStringSize)(void *text,int length,const GrTextOption *opt,int *w,int *h) +{ + GrStringSize(text,length,opt,w,h); +} + diff --git a/thirdparty/grx249/src/text/fontinfo.c b/thirdparty/grx249/src/text/fontinfo.c new file mode 100644 index 0000000..a0bb888 --- /dev/null +++ b/thirdparty/grx249/src/text/fontinfo.c @@ -0,0 +1,26 @@ +/** + ** fontinfo.c ---- font path global data + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grfontdv.h" + +struct _GR_fontFileInfo _GrFontFileInfo = { + (-1), /* number of path entries */ + NULL /* the path entries */ +}; + diff --git a/thirdparty/grx249/src/text/fontpath.c b/thirdparty/grx249/src/text/fontpath.c new file mode 100644 index 0000000..5882d3f --- /dev/null +++ b/thirdparty/grx249/src/text/fontpath.c @@ -0,0 +1,107 @@ +/** + ** fontpath.c ---- set up the font search path + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ +#include +#include + +#include "libgrx.h" +#include "grfontdv.h" +#include "allocate.h" +#include "arith.h" + +void GrSetFontPath(char *p) +{ + int chr,totlen = 0,npath,plen = 0,dc = TRUE; + char path[200],*plist[100]; + if(!p || (*p == '\0')) return; + for (npath = 0; npath < itemsof(plist); ++npath) + plist[npath] = NULL; + npath = 0; + setup_ALLOC(); + path[0] = '\0'; + while(((chr = *p++) != '\0') || (plen > 0)) { + int pathchr = TRUE; + switch(chr) { + case ':': +#if defined(__MSDOS__) || defined(__WIN32__) + if((plen == 1) && isalpha(path[0])) break; +#endif + case ';': + pathchr = FALSE; + break; + case '\0': + p--; + pathchr = FALSE; + break; +#if defined(__MSDOS__) || defined(__WIN32__) + case '\\': + chr = '/'; + case '/': + dc = TRUE; + break; +#endif + default: +#ifdef __DJGPP__ + /* allow syntax /dev/env/DJDIR */ + if ((plen == 9) && (strncmp(path,"/dev/env/",9)==0)) + dc = FALSE; + if (dc) +#endif +#if defined(__MSDOS__) || defined(__WIN32__) + chr = tolower(chr); +#endif + if(isspace(chr)) pathchr = FALSE; + break; + } + if(pathchr) { + path[plen++] = chr; + continue; + } + if(plen > 0) { + if(path[plen - 1] != '/') path[plen++] = '/'; + path[plen++] = '\0'; + plist[npath] = ALLOC((size_t)plen); + if(plist[npath] == NULL) goto error; + strcpy(plist[npath],path); + totlen += plen; + plen = 0; + if(++npath == itemsof(plist)) break; + } + } + if(_GrFontFileInfo.path != NULL) free(_GrFontFileInfo.path); + _GrFontFileInfo.path = NULL; + _GrFontFileInfo.npath = npath; + if(npath > 0) { + _GrFontFileInfo.path = malloc((sizeof(char *) * npath) + totlen); + if(_GrFontFileInfo.path == NULL) goto error; + p = (char *)(&_GrFontFileInfo.path[npath]); + for(plen = 0; plen < npath; plen++) { + _GrFontFileInfo.path[plen] = p; + strcpy(p,plist[plen]); + p += strlen(p) + 1; + } + } + goto done; + error: + if(_GrFontFileInfo.path != NULL) free(_GrFontFileInfo.path); + _GrFontFileInfo.path = NULL; + _GrFontFileInfo.npath = 0; + done: + for (npath = 0; npath < itemsof(plist); ++npath) + FREE(plist[npath]); + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/text/loadfont.c b/thirdparty/grx249/src/text/loadfont.c new file mode 100644 index 0000000..e90c35c --- /dev/null +++ b/thirdparty/grx249/src/text/loadfont.c @@ -0,0 +1,138 @@ +/** + ** loadfont.c ---- load a font from a disk file + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include + +#include "libgrx.h" +#include "grfontdv.h" + +static GrFont *doit(char *fname,char *path,int cvt,int w,int h,int lo,int hi) +{ + GrFontDriver **fd; + GrFontHeader hdr; + GrFont *f, *res; + char pathname[200]; + char tempstring[200]; + int plen; + GRX_ENTER(); + res = NULL; + strcpy(pathname,path); + strcat(pathname,fname); + DBGPRINTF(DBG_FONT,("searching font %s\n", pathname)); + plen = strlen(pathname); + hdr.name = &tempstring[0]; + hdr.family = &tempstring[100]; + for(fd = _GrFontDriverTable; (*fd) != NULL; fd++) { + DBGPRINTF(DBG_FONT,("Driver \"%s\", extension \"%s\"\n", (*fd)->name, (*fd)->ext)); + pathname[plen] = '\0'; + if(!((*fd)->openfile)(pathname)) { + strcpy(&pathname[plen],(*fd)->ext); + if(!((*fd)->openfile)(pathname)) continue; + } + if(!((*fd)->header)(&hdr)) { + DBGPRINTF(DBG_FONT,("fd->header failed for %s\n", pathname)); + (*fd)->cleanup(); + continue; + } + f = _GrBuildFont( + &hdr, + cvt, + w,h, + lo,hi, + (*fd)->charwdt, + (*fd)->bitmap, + (*fd)->scalable + ); + if(!f) { + DBGPRINTF(DBG_FONT,("_GrBuildFont failed for %s\n", pathname)); + (*fd)->cleanup(); + continue; + } + (*fd)->cleanup(); + res = f; + break; + } + GRX_RETURN(res); +} + +GrFont *GrLoadConvertedFont(char *name,int cvt,int w,int h,int minc,int maxc) +{ + GrFont *f; + int chr,len,abspath,dc; + char fname[200]; + GRX_ENTER(); + len = 0; + abspath = FALSE; + dc = TRUE; + while((chr = *name++) != '\0') { + switch(chr) { +#if defined(__MSDOS__) || defined(__WIN32__) + case ':': + abspath = TRUE; + break; + case '\\': + chr = '/'; +#endif + case '/': + dc = TRUE; + if(len == 0) abspath = TRUE; + break; + default: + if(isspace(chr)) { + if(len == 0) continue; + name = ""; + chr = '\0'; + } +#ifdef __DJGPP__ + /* allow syntax /dev/env/DJDIR */ + if ((len == 9) && (strncmp(fname,"/dev/env/",9)==0)) + dc = FALSE; + if (dc) +#endif +#if defined(__MSDOS__) || defined(__WIN32__) + chr = tolower(chr); +#endif + break; + } + fname[len++] = chr; + } + fname[len] = '\0'; + f = doit(fname,"",cvt,w,h,minc,maxc); + if((f == NULL) && !abspath) { + if(_GrFontFileInfo.npath < 0) { + char *fPath = getenv("GRXFONT"); +#ifdef GRX_DEFAULT_FONT_PATH + if (!fPath) fPath = GRX_DEFAULT_FONT_PATH; +#endif + GrSetFontPath(fPath); + } + for(len = 0; len < _GrFontFileInfo.npath; len++) { + f = doit(fname,_GrFontFileInfo.path[len],cvt,w,h,minc,maxc); + if(f != NULL) break; + } + } + GRX_RETURN(f); +} + +GrFont *GrLoadFont(char *name) +{ + return(GrLoadConvertedFont(name,GR_FONTCVT_NONE,0,0,0,0)); +} + diff --git a/thirdparty/grx249/src/text/pattstrg.c b/thirdparty/grx249/src/text/pattstrg.c new file mode 100644 index 0000000..4053d2c --- /dev/null +++ b/thirdparty/grx249/src/text/pattstrg.c @@ -0,0 +1,62 @@ +/** + ** pattstrg.c ---- patterned character string output + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "clipping.h" +#include "shapes.h" +#include "text/text.h" + +static void PatternFilledBmp(int x,int y,int w,int h,int ox, int oy, + char far *bmp,int pitch,int start, + GrColor fg,GrColor bg,GrPattern *p) +{ + GRX_ENTER(); + _GrFillBitmapPattern(x,y,w,h,bmp,pitch,start,p,bg); + GRX_LEAVE(); +} + +void GrPatternDrawString(void *text,int length,int x,int y, + const GrTextOption *opt,GrPattern *p) +{ + GRX_ENTER(); + _GrDrawString(text,length,x,y,opt,p,PatternFilledBmp); + GRX_LEAVE(); +} + +void GrPatternDrawChar(int chr,int x,int y,const GrTextOption *opt,GrPattern *p) +{ + char cbuff[2]; + short sbuff[2]; + + GRX_ENTER(); + switch(opt->txo_chrtype) { + case GR_WORD_TEXT: + case GR_ATTR_TEXT: + sbuff[0] = chr; + GrPatternDrawString(sbuff,1,x,y,opt,p); + break; + default: + cbuff[0] = chr; + GrPatternDrawString(cbuff,1,x,y,opt,p); + break; + } + GRX_LEAVE(); +} + + diff --git a/thirdparty/grx249/src/text/propwdt.c b/thirdparty/grx249/src/text/propwdt.c new file mode 100644 index 0000000..728f0ff --- /dev/null +++ b/thirdparty/grx249/src/text/propwdt.c @@ -0,0 +1,34 @@ +/** + ** propwdt.c ---- calculate the width of a string using a proportional font + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +int GrProportionalTextWidth(const GrFont *font,const void *text,int len,int type) +{ + char *txp = (char *)text; + int wdt = 0; + while(--len >= 0) { + wdt += GrFontCharWidth(font,GR_TEXTSTR_CODE(txp,type)); + txp += GR_TEXTCHR_SIZE(type); + } + return(wdt); +} + + + + diff --git a/thirdparty/grx249/src/text/text.h b/thirdparty/grx249/src/text/text.h new file mode 100644 index 0000000..74fc26a --- /dev/null +++ b/thirdparty/grx249/src/text/text.h @@ -0,0 +1,23 @@ +/** + ** text.h ---- some shared definitions + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + */ + +typedef void (*TextDrawBitmapFunc)(int x,int y,int w,int h,int ox, int oy, + char far *bmp,int pitch,int start, + GrColor fg,GrColor bg,GrPattern *p); + +void _GrDrawString(const void *text,int length,int x,int y, + const GrTextOption *opt, GrPattern *p, TextDrawBitmapFunc dbm); diff --git a/thirdparty/grx249/src/text/unloadfn.c b/thirdparty/grx249/src/text/unloadfn.c new file mode 100644 index 0000000..72d31f5 --- /dev/null +++ b/thirdparty/grx249/src/text/unloadfn.c @@ -0,0 +1,37 @@ +/** + ** unloadfn.c ---- remove a font from memory + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "arith.h" + +void GrUnloadFont(GrFont *f) +{ + if((f != NULL) && !f->h.preloaded) { + unsigned int i; + free(f->h.name); + free(f->h.family); + farfree(f->bitmap); + if(f->auxmap) farfree(f->auxmap); + for(i = 0; i < itemsof(f->auxoffs); i++) { + if(f->auxoffs[i]) free(f->auxoffs[i]); + } + free(f); + } +} + diff --git a/thirdparty/grx249/src/user/ubox.c b/thirdparty/grx249/src/user/ubox.c new file mode 100644 index 0000000..8a59a58 --- /dev/null +++ b/thirdparty/grx249/src/user/ubox.c @@ -0,0 +1,30 @@ +/** + ** ubox.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrBox(int x1,int y1,int x2,int y2,GrColor c) +{ + U2SX(x1,CURC); + U2SY(y1,CURC); + U2SX(x2,CURC); + U2SY(y2,CURC); + GrBox(x1,y1,x2,y2,c); +} diff --git a/thirdparty/grx249/src/user/ucbox.c b/thirdparty/grx249/src/user/ucbox.c new file mode 100644 index 0000000..186269c --- /dev/null +++ b/thirdparty/grx249/src/user/ucbox.c @@ -0,0 +1,30 @@ +/** + ** ucbox.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + + +void GrUsrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *lo) +{ + U2SX(x1,CURC); + U2SX(x2,CURC); + U2SY(y1,CURC); + U2SY(y2,CURC); + GrCustomBox(x1,y1,x2,y2,lo); +} diff --git a/thirdparty/grx249/src/user/uccirc.c b/thirdparty/grx249/src/user/uccirc.c new file mode 100644 index 0000000..d83f37d --- /dev/null +++ b/thirdparty/grx249/src/user/uccirc.c @@ -0,0 +1,35 @@ +/** + ** uccirc.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle + ** looks like a circle on the screen + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrCustomCircle(int xc,int yc,int r,const GrLineOption *lo) +{ +#ifdef USR_KEEP_SHAPE + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(r,r,CURC->gc_xmax,CURC->gc_usrwidth); + GrCustomCircle(xc,yc,r,lo); +#else + GrUsrCustomEllipse(xc,yc,r,r,lo); +#endif /* USR_KEEP_SHAPE */ +} diff --git a/thirdparty/grx249/src/user/uccirca.c b/thirdparty/grx249/src/user/uccirca.c new file mode 100644 index 0000000..142b7b8 --- /dev/null +++ b/thirdparty/grx249/src/user/uccirca.c @@ -0,0 +1,35 @@ +/** + ** uccirca.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle + ** looks like a circle on the screen + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrCustomCircleArc(int xc,int yc,int r,int start,int end,int style,const GrLineOption *lo) +{ +#ifdef USR_KEEP_SHAPE + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(r,r,CURC->gc_xmax,CURC->gc_usrwidth); + GrCustomCircleArc(xc,yc,r,start,end,style,lo); +#else + GrUsrCustomEllipseArc(xc,yc,r,r,start,end,style,lo); +#endif /* USR_KEEP_SHAPE */ +} diff --git a/thirdparty/grx249/src/user/ucelli.c b/thirdparty/grx249/src/user/ucelli.c new file mode 100644 index 0000000..79a5cb3 --- /dev/null +++ b/thirdparty/grx249/src/user/ucelli.c @@ -0,0 +1,30 @@ +/** + ** ucelli.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *lo) +{ + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(xa,xa,CURC->gc_xmax,CURC->gc_usrwidth); + SCALE(ya,ya,CURC->gc_ymax,CURC->gc_usrheight); + GrCustomEllipse(xc,yc,xa,ya,lo); +} + diff --git a/thirdparty/grx249/src/user/ucellia.c b/thirdparty/grx249/src/user/ucellia.c new file mode 100644 index 0000000..2137694 --- /dev/null +++ b/thirdparty/grx249/src/user/ucellia.c @@ -0,0 +1,29 @@ +/** + ** ucellia.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrCustomEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,const GrLineOption *lo) +{ + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(xa,xa,CURC->gc_xmax,CURC->gc_usrwidth); + SCALE(ya,ya,CURC->gc_ymax,CURC->gc_usrheight); + GrCustomEllipseArc(xc,yc,xa,ya,start,end,style,lo); +} diff --git a/thirdparty/grx249/src/user/ucirc.c b/thirdparty/grx249/src/user/ucirc.c new file mode 100644 index 0000000..da5adbf --- /dev/null +++ b/thirdparty/grx249/src/user/ucirc.c @@ -0,0 +1,39 @@ +/** + ** ucirc.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle + ** looks like a circle on the screen + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrCircle(int xc,int yc,int r,GrColor c) +{ +#ifdef USR_KEEP_SHAPE + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(r,r,CURC->gc_xmax,CURC->gc_usrwidth); + GrCircle(xc,yc,r,c); +#else + GrUsrEllipse(xc,yc,r,r,c); +#endif +} diff --git a/thirdparty/grx249/src/user/ucirca.c b/thirdparty/grx249/src/user/ucirca.c new file mode 100644 index 0000000..b0fbe41 --- /dev/null +++ b/thirdparty/grx249/src/user/ucirca.c @@ -0,0 +1,34 @@ +/** + ** ucirca.c + ** + ** Copyright (C), Michael Goffioul + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle + ** looks like a circle on the screen + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c) +{ +#ifdef USR_KEEP_SHAPE + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(r,r,CURC->gc_xmax,CURC->gc_usrwidth); + GrCircleArc(xc,yc,r,start,end,style,c); +#else + GrUsrEllipseArc(xc,yc,r,r,start,end,style,c); +#endif /* USR_KEEP_SHAPE */ +} diff --git a/thirdparty/grx249/src/user/ucircf.c b/thirdparty/grx249/src/user/ucircf.c new file mode 100644 index 0000000..9c309ff --- /dev/null +++ b/thirdparty/grx249/src/user/ucircf.c @@ -0,0 +1,46 @@ +/** + ** UCIRCF.C + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is distributed under the terms listed in the document + ** "copying.cb", available from the author at the address above. + ** A copy of "copying.cb" should accompany this file; if not, a copy + ** should be available from where this file was obtained. This file + ** may not be distributed without a verbatim copy of "copying.cb". + ** You should also have received a copy of the GNU General Public + ** License along with this program (it is in the file "copying"); + ** if not, write to the Free Software Foundation, Inc., 675 Mass Ave, + ** Cambridge, MA 02139, USA. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** + ** Copyright (C) 1997, Michael Goffioul + ** + ** goffioul@emic.ucl.ac.be + ** + ** + ** Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle + ** looks like a circle on the screen + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrFilledCircle(int xc,int yc,int r,GrColor c) +{ +#ifdef USR_KEEP_SHAPE + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(r,r,CURC->gc_xmax,CURC->gc_usrwidth); + GrFilledCircle(xc,yc,r,c); +#else + GrUsrFilledEllipse(xc,yc,r,r,c); +#endif +} diff --git a/thirdparty/grx249/src/user/ucircfa.c b/thirdparty/grx249/src/user/ucircfa.c new file mode 100644 index 0000000..96ced85 --- /dev/null +++ b/thirdparty/grx249/src/user/ucircfa.c @@ -0,0 +1,35 @@ +/** + ** ucircfa.c + ** + ** Copyright (C), Michael Goffioul + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle + ** looks like a circle on the screen + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c) +{ +#ifdef USR_KEEP_SHAPE + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(r,r,CURC->gc_xmax,CURC->gc_usrwidth); + GrFilledCircleArc(xc,yc,r,start,end,style,c); +#else + GrUsrFilledEllipseArc(xc,yc,r,r,start,end,style,c); +#endif /* USR_KEEP_SHAPE */ +} + diff --git a/thirdparty/grx249/src/user/ucline.c b/thirdparty/grx249/src/user/ucline.c new file mode 100644 index 0000000..8d9825a --- /dev/null +++ b/thirdparty/grx249/src/user/ucline.c @@ -0,0 +1,30 @@ +/** + ** ucline.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + + +void GrUsrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *lo) +{ + U2SX(x1,CURC); + U2SX(x2,CURC); + U2SY(y1,CURC); + U2SY(y2,CURC); + GrCustomLine(x1,y1,x2,y2,lo); +} diff --git a/thirdparty/grx249/src/user/ucpolyg.c b/thirdparty/grx249/src/user/ucpolyg.c new file mode 100644 index 0000000..1d43152 --- /dev/null +++ b/thirdparty/grx249/src/user/ucpolyg.c @@ -0,0 +1,41 @@ +/** + ** ucpolyg.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "usercord.h" + +void GrUsrCustomPolygon(int numpts,int points[][2],const GrLineOption *lo) +{ + int pt; + int (*tmp)[2]; + setup_ALLOC(); + tmp = ALLOC(sizeof(int) * 2 * numpts); + + if (tmp != NULL) { + for ( pt = 0;pt < numpts;pt++) { + tmp[pt][0] = points[pt][0]; + tmp[pt][1] = points[pt][1]; + U2SX(tmp[pt][0],CURC); + U2SY(tmp[pt][1],CURC); + } + GrCustomPolygon(numpts,tmp,lo); + FREE(tmp); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/user/ucpolyl.c b/thirdparty/grx249/src/user/ucpolyl.c new file mode 100644 index 0000000..01cb76a --- /dev/null +++ b/thirdparty/grx249/src/user/ucpolyl.c @@ -0,0 +1,41 @@ +/** + ** ucpolyl.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "usercord.h" + +void GrUsrCustomPolyLine(int numpts,int points[][2],const GrLineOption *lo) +{ + int pt; + int (*tmp)[2]; + setup_ALLOC(); + tmp = ALLOC(sizeof(int) * 2 * numpts); + + if (tmp != NULL) { + for ( pt = 0;pt < numpts;pt++) { + tmp[pt][0] = points[pt][0]; + tmp[pt][1] = points[pt][1]; + U2SX(tmp[pt][0],CURC); + U2SY(tmp[pt][1],CURC); + } + GrCustomPolyLine(numpts,tmp,lo); + FREE(tmp); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/user/udrwchar.c b/thirdparty/grx249/src/user/udrwchar.c new file mode 100644 index 0000000..821e8c4 --- /dev/null +++ b/thirdparty/grx249/src/user/udrwchar.c @@ -0,0 +1,29 @@ +/** + ** udrwchar.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrDrawChar(int chr,int x,int y,const GrTextOption *opt) +{ + U2SX(x,CURC); + U2SY(y,CURC); + GrDrawChar(chr,x,y,opt); +} + diff --git a/thirdparty/grx249/src/user/udrwstrg.c b/thirdparty/grx249/src/user/udrwstrg.c new file mode 100644 index 0000000..8ad25e4 --- /dev/null +++ b/thirdparty/grx249/src/user/udrwstrg.c @@ -0,0 +1,28 @@ +/** + ** udrwstrg.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrDrawString(char *text,int length,int x,int y,const GrTextOption *opt) +{ + U2SX(x,CURC); + U2SY(y,CURC); + GrDrawString(text,length,x,y,opt); +} diff --git a/thirdparty/grx249/src/user/uelli.c b/thirdparty/grx249/src/user/uelli.c new file mode 100644 index 0000000..6099c81 --- /dev/null +++ b/thirdparty/grx249/src/user/uelli.c @@ -0,0 +1,33 @@ +/** + ** uelli.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrEllipse(int xc,int yc,int xa,int ya,GrColor c) +{ + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(xa,xa,CURC->gc_xmax,CURC->gc_usrwidth); + SCALE(ya,ya,CURC->gc_ymax,CURC->gc_usrheight); + GrEllipse(xc,yc,xa,ya,c); +} diff --git a/thirdparty/grx249/src/user/uellia.c b/thirdparty/grx249/src/user/uellia.c new file mode 100644 index 0000000..b2bd07a --- /dev/null +++ b/thirdparty/grx249/src/user/uellia.c @@ -0,0 +1,29 @@ +/** + ** uellia.c + ** + ** Copyright (C), Michael Goffioul + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrColor c) +{ + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(xa,xa,CURC->gc_xmax,CURC->gc_usrwidth); + SCALE(ya,ya,CURC->gc_ymax,CURC->gc_usrheight); + GrEllipseArc(xc,yc,xa,ya,start,end,style,c); +} + diff --git a/thirdparty/grx249/src/user/uellif.c b/thirdparty/grx249/src/user/uellif.c new file mode 100644 index 0000000..34d634c --- /dev/null +++ b/thirdparty/grx249/src/user/uellif.c @@ -0,0 +1,33 @@ +/** + ** uellif.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c) +{ + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(xa,xa,CURC->gc_xmax,CURC->gc_usrwidth); + SCALE(ya,ya,CURC->gc_ymax,CURC->gc_usrheight); + GrFilledEllipse(xc,yc,xa,ya,c); +} diff --git a/thirdparty/grx249/src/user/uellifa.c b/thirdparty/grx249/src/user/uellifa.c new file mode 100644 index 0000000..51be194 --- /dev/null +++ b/thirdparty/grx249/src/user/uellifa.c @@ -0,0 +1,29 @@ +/** + ** uellifa.c + ** + ** Copyright (C), Michael Goffioul + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrColor c) +{ + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(xa,xa,CURC->gc_xmax,CURC->gc_usrwidth); + SCALE(ya,ya,CURC->gc_ymax,CURC->gc_usrheight); + GrFilledEllipseArc(xc,yc,xa,ya,start,end,style,c); +} + diff --git a/thirdparty/grx249/src/user/ufcpolyg.c b/thirdparty/grx249/src/user/ufcpolyg.c new file mode 100644 index 0000000..603ee64 --- /dev/null +++ b/thirdparty/grx249/src/user/ufcpolyg.c @@ -0,0 +1,41 @@ +/** + ** ufcpolyg.c + ** + ** Copyright (C), Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "usercord.h" + +void GrUsrFilledConvexPolygon(int numpts,int points[][2],GrColor c) +{ + int pt; + int (*tmp)[2]; + setup_ALLOC(); + tmp = ALLOC(sizeof(int) * 2 * numpts); + + if (tmp != NULL) { + for ( pt = 0; pt < numpts; pt++) { + tmp[pt][0] = points[pt][0]; + tmp[pt][1] = points[pt][1]; + U2SX(tmp[pt][0],CURC); + U2SY(tmp[pt][1],CURC); + } + GrFilledConvexPolygon(numpts,tmp,c); + FREE(tmp); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/user/ufillbox.c b/thirdparty/grx249/src/user/ufillbox.c new file mode 100644 index 0000000..f6cc641 --- /dev/null +++ b/thirdparty/grx249/src/user/ufillbox.c @@ -0,0 +1,30 @@ +/** + ** ufillbox.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrFilledBox(int x1,int y1,int x2,int y2,GrColor c) +{ + U2SX(x1,CURC); + U2SY(y1,CURC); + U2SX(x2,CURC); + U2SY(y2,CURC); + GrFilledBox(x1,y1,x2,y2,c); +} diff --git a/thirdparty/grx249/src/user/uflood.c b/thirdparty/grx249/src/user/uflood.c new file mode 100644 index 0000000..4d89ab9 --- /dev/null +++ b/thirdparty/grx249/src/user/uflood.c @@ -0,0 +1,27 @@ +/** + ** uflood.c ---- fill an arbitrary area in user coordinates + ** + ** Copyright (c) 1997 Hartmut Schirmer + ** [e-mail: hsc@techfak.uni-kiel.de] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrFloodFill(int x, int y, GrColor border, GrColor c) +{ + U2SX(x,CURC); + U2SY(y,CURC); + GrFloodFill(x,y,border,c); +} diff --git a/thirdparty/grx249/src/user/ufpolyg.c b/thirdparty/grx249/src/user/ufpolyg.c new file mode 100644 index 0000000..1249862 --- /dev/null +++ b/thirdparty/grx249/src/user/ufpolyg.c @@ -0,0 +1,41 @@ +/** + ** ufpolyg.c + ** + ** Copyright (C), Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "usercord.h" + +void GrUsrFilledPolygon(int numpts,int points[][2],GrColor c) +{ + int pt; + int (*tmp)[2]; + setup_ALLOC(); + tmp = ALLOC(sizeof(int) * 2 * numpts); + + if (tmp != NULL) { + for ( pt = 0; pt < numpts; pt++) { + tmp[pt][0] = points[pt][0]; + tmp[pt][1] = points[pt][1]; + U2SX(tmp[pt][0],CURC); + U2SY(tmp[pt][1],CURC); + } + GrFilledPolygon(numpts,tmp,c); + FREE(tmp); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/user/uframbox.c b/thirdparty/grx249/src/user/uframbox.c new file mode 100644 index 0000000..93eb0bf --- /dev/null +++ b/thirdparty/grx249/src/user/uframbox.c @@ -0,0 +1,38 @@ +/** + ** uframbox.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "arith.h" +#include "usercord.h" + +void GrUsrFramedBox(int x1,int y1,int x2,int y2,int wdt,GrFBoxColors *c) +{ + int w1,w2; + + U2SX(x1,CURC); + U2SY(y1,CURC); + U2SX(x2,CURC); + U2SY(y2,CURC); + SCALE(w1,wdt,CURC->gc_xmax,CURC->gc_usrwidth); + SCALE(w2,wdt,CURC->gc_ymax,CURC->gc_usrheight); + wdt = (iabs((int)w1) + iabs((int)w2)) >> 1; + if(wdt == 0) + GrFilledBox(x1,y1,x2,y2,c->fbx_intcolor); + else GrFramedBox(x1,y1,x2,y2,wdt,c); +} diff --git a/thirdparty/grx249/src/user/ugetwin.c b/thirdparty/grx249/src/user/ugetwin.c new file mode 100644 index 0000000..d52b38a --- /dev/null +++ b/thirdparty/grx249/src/user/ugetwin.c @@ -0,0 +1,28 @@ +/** + ** ugetwin.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +void GrGetUserWindow(int *x1,int *y1,int *x2,int *y2) +{ + *x1 = CURC->gc_usrxbase; + *y1 = CURC->gc_usrybase; + *x2 = CURC->gc_usrxbase + CURC->gc_usrwidth; + *y2 = CURC->gc_usrybase + CURC->gc_usrheight; +} diff --git a/thirdparty/grx249/src/user/uhline.c b/thirdparty/grx249/src/user/uhline.c new file mode 100644 index 0000000..390634e --- /dev/null +++ b/thirdparty/grx249/src/user/uhline.c @@ -0,0 +1,29 @@ +/** + ** uhline.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrHLine(int x1,int x2,int y,GrColor c) +{ + U2SX(x1,CURC); + U2SX(x2,CURC); + U2SY(y,CURC); + GrHLine(x1,x2,y,c); +} diff --git a/thirdparty/grx249/src/user/uline.c b/thirdparty/grx249/src/user/uline.c new file mode 100644 index 0000000..77b0b84 --- /dev/null +++ b/thirdparty/grx249/src/user/uline.c @@ -0,0 +1,30 @@ +/** + ** uline.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrLine(int x1,int y1,int x2,int y2,GrColor c) +{ + U2SX(x1,CURC); + U2SY(y1,CURC); + U2SX(x2,CURC); + U2SY(y2,CURC); + GrLine(x1,y1,x2,y2,c); +} diff --git a/thirdparty/grx249/src/user/upbox.c b/thirdparty/grx249/src/user/upbox.c new file mode 100644 index 0000000..34a4569 --- /dev/null +++ b/thirdparty/grx249/src/user/upbox.c @@ -0,0 +1,29 @@ +/** + ** upbox.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp) +{ + U2SX(x1,CURC); + U2SX(x2,CURC); + U2SY(y1,CURC); + U2SY(y2,CURC); + GrPatternedBox(x1,y1,x2,y2,lp); +} diff --git a/thirdparty/grx249/src/user/upcirc.c b/thirdparty/grx249/src/user/upcirc.c new file mode 100644 index 0000000..e2cb621 --- /dev/null +++ b/thirdparty/grx249/src/user/upcirc.c @@ -0,0 +1,35 @@ +/** + ** upcirc.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle + ** looks like a circle on the screen + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp) +{ +#ifdef USR_KEEP_SHAPE + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(r,r,CURC->gc_xmax,CURC->gc_usrwidth); + GrPatternedCircle(xc,yc,r,lp); +#else + GrUsrPatternedEllipse(xc,yc,r,r,lp); +#endif /* USR_KEEP_SHAPE */ +} diff --git a/thirdparty/grx249/src/user/upcirca.c b/thirdparty/grx249/src/user/upcirca.c new file mode 100644 index 0000000..8d0ab82 --- /dev/null +++ b/thirdparty/grx249/src/user/upcirca.c @@ -0,0 +1,36 @@ +/** + ** upcirca.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle + ** looks like a circle on the screen + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternedCircleArc(int xc,int yc,int r,int start,int end,int style,GrLinePattern *lp) +{ +#ifdef USR_KEEP_SHAPE + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(r,r,CURC->gc_xmax,CURC->gc_usrwidth); + GrPatternedCircleArc(xc,yc,r,start,end,style,lp); +#else + GrUsrPatternedEllipseArc(xc,yc,r,r,start,end,style,lp); +#endif /* USR_KEEP_SHAPE */ +} + diff --git a/thirdparty/grx249/src/user/upelli.c b/thirdparty/grx249/src/user/upelli.c new file mode 100644 index 0000000..c16dbed --- /dev/null +++ b/thirdparty/grx249/src/user/upelli.c @@ -0,0 +1,29 @@ +/** + ** upelli.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp) +{ + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(xa,xa,CURC->gc_xmax,CURC->gc_usrwidth); + SCALE(ya,ya,CURC->gc_ymax,CURC->gc_usrheight); + GrPatternedEllipse(xc,yc,xa,ya,lp); +} diff --git a/thirdparty/grx249/src/user/upellia.c b/thirdparty/grx249/src/user/upellia.c new file mode 100644 index 0000000..1d57ee5 --- /dev/null +++ b/thirdparty/grx249/src/user/upellia.c @@ -0,0 +1,30 @@ +/** + ** upellia.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + + +void GrUsrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrLinePattern *lp) +{ + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(xa,xa,CURC->gc_xmax,CURC->gc_usrwidth); + SCALE(ya,ya,CURC->gc_ymax,CURC->gc_usrheight); + GrPatternedEllipseArc(xc,yc,xa,ya,start,end,style,lp); +} diff --git a/thirdparty/grx249/src/user/upfbox.c b/thirdparty/grx249/src/user/upfbox.c new file mode 100644 index 0000000..ad720d0 --- /dev/null +++ b/thirdparty/grx249/src/user/upfbox.c @@ -0,0 +1,29 @@ +/** + ** upfbox.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p) +{ + U2SX(x1,CURC); + U2SX(x2,CURC); + U2SY(y1,CURC); + U2SY(y2,CURC); + GrPatternFilledBox(x1,y1,x2,y2,p); +} diff --git a/thirdparty/grx249/src/user/upfcirc.c b/thirdparty/grx249/src/user/upfcirc.c new file mode 100644 index 0000000..6039116 --- /dev/null +++ b/thirdparty/grx249/src/user/upfcirc.c @@ -0,0 +1,36 @@ +/** + ** upfcirc.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle + ** looks like a circle on the screen + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternFilledCircle(int xc,int yc,int r,GrPattern *p) +{ +#ifdef USR_KEEP_SHAPE + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(r,r,CURC->gc_xmax,CURC->gc_usrwidth); + GrPatternFilledCircle(xc,yc,r,p); +#else + GrUsrPatternFilledEllipse(xc,yc,r,r,p); +#endif /* USR_KEEP_SHAPE */ +} + diff --git a/thirdparty/grx249/src/user/upfcirca.c b/thirdparty/grx249/src/user/upfcirca.c new file mode 100644 index 0000000..2ac9df9 --- /dev/null +++ b/thirdparty/grx249/src/user/upfcirca.c @@ -0,0 +1,35 @@ +/** + ** upfcirca.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle + ** looks like a circle on the screen + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrPattern *p) +{ +#ifdef USR_KEEP_SHAPE + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(r,r,CURC->gc_xmax,CURC->gc_usrwidth); + GrPatternFilledCircleArc(xc,yc,r,start,end,style,p); +#else + GrUsrPatternFilledEllipseArc(xc,yc,r,r,start,end,style,p); +#endif /* USR_KEEP_SHAPE */ +} diff --git a/thirdparty/grx249/src/user/upfcpoly.c b/thirdparty/grx249/src/user/upfcpoly.c new file mode 100644 index 0000000..eb90a45 --- /dev/null +++ b/thirdparty/grx249/src/user/upfcpoly.c @@ -0,0 +1,41 @@ +/** + ** upfcpoly.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "usercord.h" + +void GrUsrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p) +{ + int pt; + int (*tmp)[2]; + setup_ALLOC(); + tmp = ALLOC(sizeof(int) * 2 * numpts); + + if (tmp != NULL) { + for ( pt = 0;pt < numpts;pt++) { + tmp[pt][0] = points[pt][0]; + tmp[pt][1] = points[pt][1]; + U2SX(tmp[pt][0],CURC); + U2SY(tmp[pt][1],CURC); + } + GrPatternFilledConvexPolygon(numpts,tmp,p); + FREE(tmp); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/user/upfelli.c b/thirdparty/grx249/src/user/upfelli.c new file mode 100644 index 0000000..8023f3d --- /dev/null +++ b/thirdparty/grx249/src/user/upfelli.c @@ -0,0 +1,19 @@ +/** + ** upfelli.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p) +{ + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(xa,xa,CURC->gc_xmax,CURC->gc_usrwidth); + SCALE(ya,ya,CURC->gc_ymax,CURC->gc_usrheight); + GrPatternFilledEllipse(xc,yc,xa,ya,p); +} diff --git a/thirdparty/grx249/src/user/upfellia.c b/thirdparty/grx249/src/user/upfellia.c new file mode 100644 index 0000000..d635601 --- /dev/null +++ b/thirdparty/grx249/src/user/upfellia.c @@ -0,0 +1,29 @@ +/** + ** upfellia.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrPattern *p) +{ + U2SX(xc,CURC); + U2SY(yc,CURC); + SCALE(xa,xa,CURC->gc_xmax,CURC->gc_usrwidth); + SCALE(ya,ya,CURC->gc_ymax,CURC->gc_usrheight); + GrPatternFilledEllipseArc(xc,yc,xa,ya,start,end,style,p); +} diff --git a/thirdparty/grx249/src/user/upfflood.c b/thirdparty/grx249/src/user/upfflood.c new file mode 100644 index 0000000..b67d117 --- /dev/null +++ b/thirdparty/grx249/src/user/upfflood.c @@ -0,0 +1,27 @@ +/** + ** upfflood.c ---- pattern fill an arbitrary area in user coordinates + ** + ** Copyright (c) 1997 Hartmut Schirmer + ** [e-mail: hsc@techfak.uni-kiel.de] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternFloodFill(int x, int y, GrColor border, GrPattern *p) +{ + U2SX(x,CURC); + U2SY(y,CURC); + GrPatternFloodFill(x,y,border,p); +} diff --git a/thirdparty/grx249/src/user/upfline.c b/thirdparty/grx249/src/user/upfline.c new file mode 100644 index 0000000..7780e06 --- /dev/null +++ b/thirdparty/grx249/src/user/upfline.c @@ -0,0 +1,29 @@ +/** + ** upfline.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p) +{ + U2SX(x1,CURC); + U2SX(x2,CURC); + U2SY(y1,CURC); + U2SY(y2,CURC); + GrPatternFilledLine(x1,y1,x2,y2,p); +} diff --git a/thirdparty/grx249/src/user/upfplot.c b/thirdparty/grx249/src/user/upfplot.c new file mode 100644 index 0000000..d6046de --- /dev/null +++ b/thirdparty/grx249/src/user/upfplot.c @@ -0,0 +1,27 @@ +/** + ** upfplot.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternFilledPlot(int x,int y,GrPattern *p) +{ + U2SX(x,CURC); + U2SY(y,CURC); + GrPatternFilledPlot(x,y,p); +} diff --git a/thirdparty/grx249/src/user/upfpolyg.c b/thirdparty/grx249/src/user/upfpolyg.c new file mode 100644 index 0000000..e894358 --- /dev/null +++ b/thirdparty/grx249/src/user/upfpolyg.c @@ -0,0 +1,41 @@ +/** + ** upfpolyg.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "usercord.h" + +void GrUsrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p) +{ + int pt; + int (*tmp)[2]; + setup_ALLOC(); + tmp = ALLOC(sizeof(int) * 2 * numpts); + + if (tmp != NULL) { + for ( pt = 0;pt < numpts;pt++) { + tmp[pt][0] = points[pt][0]; + tmp[pt][1] = points[pt][1]; + U2SX(tmp[pt][0],CURC); + U2SY(tmp[pt][1],CURC); + } + GrPatternFilledPolygon(numpts,tmp,p); + FREE(tmp); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/user/upixel.c b/thirdparty/grx249/src/user/upixel.c new file mode 100644 index 0000000..fb58396 --- /dev/null +++ b/thirdparty/grx249/src/user/upixel.c @@ -0,0 +1,28 @@ +/** + ** upixel.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +GrColor GrUsrPixel(int x,int y) +{ + U2SX(x,CURC); + U2SY(y,CURC); + return(GrPixel(x,y)); +} diff --git a/thirdparty/grx249/src/user/upixelc.c b/thirdparty/grx249/src/user/upixelc.c new file mode 100644 index 0000000..5e4e79c --- /dev/null +++ b/thirdparty/grx249/src/user/upixelc.c @@ -0,0 +1,28 @@ +/** + ** upixelc.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +GrColor GrUsrPixelC(GrContext *c,int x,int y) +{ + U2SX(x,c); + U2SY(y,c); + return(GrPixelC(c,x,y)); +} diff --git a/thirdparty/grx249/src/user/upline.c b/thirdparty/grx249/src/user/upline.c new file mode 100644 index 0000000..0f04d35 --- /dev/null +++ b/thirdparty/grx249/src/user/upline.c @@ -0,0 +1,29 @@ +/** + ** upline.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp) +{ + U2SX(x1,CURC); + U2SX(x2,CURC); + U2SY(y1,CURC); + U2SY(y2,CURC); + GrPatternedLine(x1,y1,x2,y2,lp); +} diff --git a/thirdparty/grx249/src/user/uplot.c b/thirdparty/grx249/src/user/uplot.c new file mode 100644 index 0000000..8c19345 --- /dev/null +++ b/thirdparty/grx249/src/user/uplot.c @@ -0,0 +1,28 @@ +/** + ** uplot.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrPlot(int x,int y,GrColor c) +{ + U2SX(x,CURC); + U2SY(y,CURC); + GrPlot(x,y,c); +} diff --git a/thirdparty/grx249/src/user/upolygon.c b/thirdparty/grx249/src/user/upolygon.c new file mode 100644 index 0000000..90d1ec7 --- /dev/null +++ b/thirdparty/grx249/src/user/upolygon.c @@ -0,0 +1,41 @@ +/** + ** upolygon.c + ** + ** Copyright (C), Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "usercord.h" + +void GrUsrPolygon(int numpts,int points[][2],GrColor c) +{ + int pt; + int (*tmp)[2]; + setup_ALLOC(); + tmp = ALLOC(sizeof(int) * 2 * numpts); + + if (tmp != NULL) { + for ( pt = 0; pt < numpts; pt++) { + tmp[pt][0] = points[pt][0]; + tmp[pt][1] = points[pt][1]; + U2SX(tmp[pt][0],CURC); + U2SY(tmp[pt][1],CURC); + } + GrPolygon(numpts,tmp,c); + FREE(tmp); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/user/upolylin.c b/thirdparty/grx249/src/user/upolylin.c new file mode 100644 index 0000000..1369d47 --- /dev/null +++ b/thirdparty/grx249/src/user/upolylin.c @@ -0,0 +1,41 @@ +/** + ** upolylin.c + ** + ** Copyright (C), Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "usercord.h" + +void GrUsrPolyLine(int numpts,int points[][2],GrColor c) +{ + int pt; + int (*tmp)[2]; + setup_ALLOC(); + tmp = ALLOC(sizeof(int) * 2 * numpts); + + if (tmp != NULL) { + for ( pt = 0; pt < numpts; pt++) { + tmp[pt][0] = points[pt][0]; + tmp[pt][1] = points[pt][1]; + U2SX(tmp[pt][0],CURC); + U2SY(tmp[pt][1],CURC); + } + GrPolyLine(numpts,tmp,c); + FREE(tmp); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/user/uppolyg.c b/thirdparty/grx249/src/user/uppolyg.c new file mode 100644 index 0000000..ed256b2 --- /dev/null +++ b/thirdparty/grx249/src/user/uppolyg.c @@ -0,0 +1,41 @@ +/** + ** uppolyg.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "usercord.h" + +void GrUsrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp) +{ + int pt; + int (*tmp)[2]; + setup_ALLOC(); + tmp = ALLOC(sizeof(int) * 2 * numpts); + + if (tmp != NULL) { + for ( pt = 0;pt < numpts;pt++) { + tmp[pt][0] = points[pt][0]; + tmp[pt][1] = points[pt][1]; + U2SX(tmp[pt][0],CURC); + U2SY(tmp[pt][1],CURC); + } + GrPatternedPolygon(numpts,tmp,lp); + FREE(tmp); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/user/uppolyl.c b/thirdparty/grx249/src/user/uppolyl.c new file mode 100644 index 0000000..ffae856 --- /dev/null +++ b/thirdparty/grx249/src/user/uppolyl.c @@ -0,0 +1,42 @@ +/** + ** uppolyl.c + ** + ** Copyright (C) 1997, Michael Goffioul + ** [goffioul@emic.ucl.ac.be] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "usercord.h" + +void GrUsrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp) +{ + int pt; + int (*tmp)[2]; + setup_ALLOC(); + tmp = ALLOC(sizeof(int) * 2 * numpts); + + if (tmp != NULL) { + for ( pt = 0;pt < numpts;pt++) { + tmp[pt][0] = points[pt][0]; + tmp[pt][1] = points[pt][1]; + U2SX(tmp[pt][0],CURC); + U2SY(tmp[pt][1],CURC); + } + GrPatternedPolyLine(numpts,tmp,lp); + FREE(tmp); + } + reset_ALLOC(); +} + diff --git a/thirdparty/grx249/src/user/usercord.c b/thirdparty/grx249/src/user/usercord.c new file mode 100644 index 0000000..89f1d6e --- /dev/null +++ b/thirdparty/grx249/src/user/usercord.c @@ -0,0 +1,33 @@ +/** + ** usercord.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrGetScreenCoord(int *x,int *y) +{ + U2SX(*x,CURC); + U2SY(*y,CURC); +} + +void GrGetUserCoord(int *x,int *y) +{ + S2UX(*x,CURC); + S2UY(*y,CURC); +} diff --git a/thirdparty/grx249/src/user/usetwin.c b/thirdparty/grx249/src/user/usetwin.c new file mode 100644 index 0000000..8a9c33d --- /dev/null +++ b/thirdparty/grx249/src/user/usetwin.c @@ -0,0 +1,28 @@ +/** + ** usetwin.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" + +void GrSetUserWindow(int x1,int y1,int x2,int y2) +{ + CURC->gc_usrxbase = x1; + CURC->gc_usrybase = y1; + CURC->gc_usrwidth = x2 - x1; + CURC->gc_usrheight = y2 - y1; +} diff --git a/thirdparty/grx249/src/user/utextxy.c b/thirdparty/grx249/src/user/utextxy.c new file mode 100644 index 0000000..964aa62 --- /dev/null +++ b/thirdparty/grx249/src/user/utextxy.c @@ -0,0 +1,28 @@ +/** + ** utextxy.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrTextXY(int x,int y,char *text,GrColor fg,GrColor bg) +{ + U2SX(x,CURC); + U2SY(y,CURC); + GrTextXY(x,y,text,fg,bg); +} diff --git a/thirdparty/grx249/src/user/uvline.c b/thirdparty/grx249/src/user/uvline.c new file mode 100644 index 0000000..d9c8c3e --- /dev/null +++ b/thirdparty/grx249/src/user/uvline.c @@ -0,0 +1,29 @@ +/** + ** uvline.c + ** + ** Copyright (C) 1992, Csaba Biegl + ** 820 Stirrup Dr, Nashville, TN, 37221 + ** csaba@vuse.vanderbilt.edu + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "usercord.h" + +void GrUsrVLine(int x,int y1,int y2,GrColor c) +{ + U2SX(x,CURC); + U2SY(y1,CURC); + U2SY(y2,CURC); + GrVLine(x,y1,y2,c); +} diff --git a/thirdparty/grx249/src/utilprog/bin2c.c b/thirdparty/grx249/src/utilprog/bin2c.c new file mode 100644 index 0000000..6b7fd55 --- /dev/null +++ b/thirdparty/grx249/src/utilprog/bin2c.c @@ -0,0 +1,110 @@ +/** + ** BCC2GRX - Interfacing Borland based graphics programs to LIBGRX + ** Copyright (C) 1993-97 by Hartmut Schirmer + ** + ** + ** Contact : Hartmut Schirmer + ** Feldstrasse 118 + ** D-24105 Kiel + ** Germany + ** + ** e-mail : hsc@techfak.uni-kiel.de + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include +#include +#include + +#define TRUE (1==1) +#define FALSE (!TRUE) + +void usage(char *err) +{ + puts("bin2c -- convert binary files into C source\n"); + puts("Usage:\n"); + puts(" bin2c []"); + if (err != NULL) + printf("\n\nError: %s\n", err); + exit(1); +} + +char *timestr(void) +{ + struct tm *lt; + time_t t; + + t = time(NULL); + lt = localtime(&t); + return asctime(lt); +} + +long filesize(FILE *f) +{ + long posi, res; + + posi = ftell(f); + fseek(f, 0, SEEK_END); + res = ftell(f); + fseek(f, posi, SEEK_SET); + return res; +} + +int main(int argc, char *argv[]) +{ + FILE *inp, *outp; + char name[1000]; + long length, count; + int linec; + unsigned char *buffer, *komma; + + if (argc < 3 || argc > 4) usage("Incorrect command line"); + + strcpy(name,"binary_data_field"); + inp = fopen( argv[1], "rb"); + if (inp == NULL) usage("Couldn't opem input file"); + + strcpy( name, argv[2]); + if (argc > 3) { + outp = fopen(argv[3], "w"); + if (outp == NULL) usage("Couldn't open output file"); + } else + outp = stdout; + + length = filesize(inp); + buffer = (unsigned char *)malloc( length); + if (buffer == NULL) usage("Out of memory"); + if (fread( buffer, length, 1, inp) != 1) usage("read error"); + fclose(inp); + + fprintf(outp, "unsigned char %s[] = {\n", name); + count = 0; + linec = 0; + komma = " "; + while (count != length) { + linec += fprintf(outp, "%s", komma); + if (linec > 75) { + fprintf(outp, "\n "); + linec = 1; + } + linec += fprintf(outp, "%d", *buffer); + komma = ","; + ++count; + ++buffer; + } + fprintf(outp, "\n};\n"); + fclose( outp); + return 0; +} diff --git a/thirdparty/grx249/src/utilprog/fnt2c.c b/thirdparty/grx249/src/utilprog/fnt2c.c new file mode 100644 index 0000000..1c03a8b --- /dev/null +++ b/thirdparty/grx249/src/utilprog/fnt2c.c @@ -0,0 +1,47 @@ +/** + ** font2c.c ---- convert a font to C source code + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "grx20.h" + +int main(int argc,char **argv) +{ + GrFont *f; + if(argc < 4) { + fprintf( + stderr, + "%s: too few arguments\n" + "usage: font2c fontFile outputFile CfontSymbolName\n", + argv[0] + ); + return(1); + } + f = GrLoadFont(argv[1]); + if(!f) { + fprintf( + stderr, + "%s: could not load font \"%s\"\n", + argv[0], + argv[1] + ); + return(1); + } + GrDumpFont(f,argv[3],argv[2]); + return(0); +} + diff --git a/thirdparty/grx249/src/utilprog/fnt2text.c b/thirdparty/grx249/src/utilprog/fnt2text.c new file mode 100644 index 0000000..3faee87 --- /dev/null +++ b/thirdparty/grx249/src/utilprog/fnt2text.c @@ -0,0 +1,56 @@ +/** + ** font2txt.c ---- make an ASCII dump of a font + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "grx20.h" + +void dumpf(GrFont *f) +{ + int chr,wdt,hgt,xpos,ypos; + char far *bmp; + hgt = f->h.height; + for(chr = f->h.minchar; chr < (f->h.minchar + f->h.numchars); chr++) { + wdt = GrFontCharWidth(f,chr); + bmp = GrFontCharBitmap(f,chr); + printf("char '%c', code = 0x%04x\n",chr,chr); + for(ypos = 0; ypos < hgt; ypos++) { + for(xpos = 0; xpos < wdt; xpos++) { + putchar((bmp[xpos >> 3] & (0x80 >> (xpos & 7))) ? '#' : '.'); + } + putchar('\n'); + bmp += ((wdt + 7) >> 3); + } + putchar('\n'); + } +} + +int main() +{ + dumpf(GrLoadFont("pc8x16")); + dumpf(GrBuildConvertedFont( + &GrDefaultFont, + (GR_FONTCVT_SKIPCHARS | GR_FONTCVT_RESIZE | GR_FONTCVT_PROPORTION), + 10, + 20, + ' ', + 'z' + )); + return(0); +} + diff --git a/thirdparty/grx249/src/utilprog/lfbinfo.c b/thirdparty/grx249/src/utilprog/lfbinfo.c new file mode 100644 index 0000000..4a655dc --- /dev/null +++ b/thirdparty/grx249/src/utilprog/lfbinfo.c @@ -0,0 +1,76 @@ +/** + ** lfbinfo.c ---- print linux framebuffer information + ** + ** Copyright (c) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include +#include +#include + +int main() +{ + struct fb_fix_screeninfo refix; + struct fb_var_screeninfo resul; + int fd; + char *fbname; + char *default_fbname = "/dev/fb0"; + + fbname = getenv( "FRAMEBUFFER" ); + if( fbname == NULL ) fbname = default_fbname; + fd = open( fbname,O_RDWR ); + if( fd == -1 ){ + printf( "can't open %s\n",fbname ); + return 1; + } + + printf( "Device file: %s\n",fbname ); + + printf( "Fixed data\n" ); + printf( "----------\n" ); + ioctl( fd,FBIOGET_FSCREENINFO,&refix ); + printf( "smem_start: %d\n",(int)refix.smem_start ); + printf( "smem_len: %d\n",(int)refix.smem_len ); + printf( "type: %d\n",(int)refix.type ); + printf( "type_aux: %d\n",(int)refix.type_aux ); + printf( "visual: %d\n",(int)refix.visual ); + printf( "xpanstep: %d ypanstep: %d ywrapstep: %d \n", + refix.xpanstep,refix.ypanstep,refix.ywrapstep ); + printf( "line_length: %d\n",(int)refix.line_length ); + printf( "mmio_start: %d\n",(int)refix.mmio_start ); + printf( "mmio_len: %d\n",(int)refix.mmio_len ); + printf( "accel: %d\n",(int)refix.accel ); + ioctl( fd,FBIOGET_VSCREENINFO,&resul ); + printf( "Variable data\n" ); + printf( "-------------\n" ); + printf( "xres: %d\n",(int)resul.xres ); + printf( "yres: %d\n",(int)resul.yres ); + printf( "xres_virtual: %d\n",(int)resul.xres_virtual ); + printf( "yres_virtual: %d\n",(int)resul.yres_virtual ); + printf( "xoffset: %d\n",(int)resul.xoffset ); + printf( "yoffset: %d\n",(int)resul.yoffset ); + printf( "bpp: %d\n",(int)resul.bits_per_pixel ); + printf( "red offset: %d length: %d msb_right: %d\n", + resul.red.offset,resul.red.length,resul.red.msb_right ); + printf( "green offset: %d length: %d msb_right: %d\n", + resul.green.offset,resul.green.length,resul.green.msb_right ); + printf( "blue offset: %d length: %d msb_right: %d\n", + resul.blue.offset,resul.blue.length,resul.blue.msb_right ); + printf( "transp offset: %d length: %d msb_right: %d\n", + resul.transp.offset,resul.transp.length,resul.transp.msb_right ); + return 0; +} diff --git a/thirdparty/grx249/src/utilprog/modetest.c b/thirdparty/grx249/src/utilprog/modetest.c new file mode 100644 index 0000000..0056722 --- /dev/null +++ b/thirdparty/grx249/src/utilprog/modetest.c @@ -0,0 +1,235 @@ +/** + ** modetest.c ---- test all available graphics modes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include +#include + +#include "grx20.h" +#include "grxkeys.h" + +#include "../../test/drawing.h" + +static void PrintInfo(void) +{ + char aux[81]; + int x, y; + + sprintf(aux, " Mode: %dx%d %d bpp ", GrCurrentVideoMode()->width, + GrCurrentVideoMode()->height, GrCurrentVideoMode()->bpp); + x = (GrMaxX() - + GrFontStringWidth(&GrDefaultFont, aux, strlen(aux), GR_BYTE_TEXT)) / 2; + y = (GrMaxY() - + GrFontStringHeight(&GrDefaultFont, aux, strlen(aux), GR_BYTE_TEXT)) / 2; + GrTextXY(x, y, aux, GrWhite(), GrBlack()); +} + +typedef struct { + int w,h,bpp; +} gvmode; + +gvmode grmodes[200]; +int nmodes = 0; + +gvmode *collectmodes(const GrVideoDriver *drv,gvmode *gp) +{ + GrFrameMode fm; + const GrVideoMode *mp; + for(fm =GR_firstGraphicsFrameMode; + fm <= GR_lastGraphicsFrameMode; fm++) { + for(mp = GrFirstVideoMode(fm); mp; mp = GrNextVideoMode(mp)) { + gp->w = mp->width; + gp->h = mp->height; + gp->bpp = mp->bpp; + gp++; + } + } + return(gp); +} + +int vmcmp(const void *m1,const void *m2) +{ + gvmode *md1 = (gvmode *)m1; + gvmode *md2 = (gvmode *)m2; + if(md1->bpp != md2->bpp) return(md1->bpp - md2->bpp); + if(md1->w != md2->w ) return(md1->w - md2->w ); + if(md1->h != md2->h ) return(md1->h - md2->h ); + return(0); +} + +#define LINES 18 +#define COLUMNS 80 +void ModeText(int i, int shrt,char *mdtxt) { + switch (shrt) { + case 2 : sprintf(mdtxt,"%2d) %dx%d ", i+1, grmodes[i].w, grmodes[i].h); + break; + case 1 : sprintf(mdtxt,"%2d) %4dx%-4d ", i+1, grmodes[i].w, grmodes[i].h); + break; + default: sprintf(mdtxt," %2d) %4dx%-4d ", i+1, grmodes[i].w, grmodes[i].h); + break; + } + mdtxt += strlen(mdtxt); + + if (grmodes[i].bpp > 20) + sprintf(mdtxt, "%ldM", 1L << (grmodes[i].bpp-20)); + else if (grmodes[i].bpp > 10) + sprintf(mdtxt, "%ldk", 1L << (grmodes[i].bpp-10)); + else + sprintf(mdtxt, "%ld", 1L << grmodes[i].bpp); + switch (shrt) { + case 2 : break; + case 1 : strcat(mdtxt, " col"); break; + default: strcat(mdtxt, " colors"); break; + } +} + +int ColsCheck(int cols, int ml, int sep) { + int len; + + len = ml * cols + (cols-1) * sep + 1; + return len <= COLUMNS; +} + +void PrintModes(void) { + char mdtxt[100]; + unsigned int maxlen; + int i, n, shrt, c, cols; + + cols = (nmodes+LINES-1) / LINES; + do { + for (shrt = 0; shrt <= 2; ++shrt) { + maxlen = 0; + for (i = 0; i < nmodes; ++i) { + ModeText(i,shrt,mdtxt); + if (strlen(mdtxt) > maxlen) maxlen = strlen(mdtxt); + } + n = 2; + if (cols>1 || shrt<2) { + if (!ColsCheck(cols, maxlen, n)) continue; + while (ColsCheck(cols, maxlen, n+1) && n < 4) ++n; + } + c = 0; + for (i = 0; i < nmodes; ++i) { + if (++c == cols) c = 0; + ModeText(i,shrt,mdtxt); + printf("%*s%s", (c ? -((int)(maxlen+n)) : -((int)maxlen)), mdtxt, (c ? "" : "\n") ); + } + if (!c) printf("\n"); + return; + } + --cols; + } while (1); +} + +int main(void) +{ + static int firstgr = 1; + GrSetDriver(NULL); + if(GrCurrentVideoDriver() == NULL) { + printf("No graphics driver found\n"); + exit(1); + } + for( ; ; ) { + int i,w,h,px,py; + char m1[41]; + nmodes = (int)(collectmodes(GrCurrentVideoDriver(),grmodes) - grmodes); + GrSetMode(GR_default_text); + if(nmodes == 0) { + printf("No graphics modes found\n"); + exit(1); + } + qsort(grmodes,nmodes,sizeof(grmodes[0]),vmcmp); + printf( + "Graphics driver: \"%s\"\n" + " graphics defaults: %dx%d %ld colors\n" + " text defaults: %dx%d %ld colors\n\n", + GrCurrentVideoDriver()->name, + GrDriverInfo->defgw, + GrDriverInfo->defgh, + (long)GrDriverInfo->defgc, + GrDriverInfo->deftw, + GrDriverInfo->defth, + (long)GrDriverInfo->deftc + ); + PrintModes(); + printf("\nEnter choice #, or anything else to quit> "); + fflush(stdout); + if(!fgets(m1,40,stdin) || + (sscanf(m1,"%d",&i) != 1) || (i < 1) || (i > nmodes)) { + exit(0); + } + if(firstgr) { + printf( + "When in graphics mode, press any key to return to menu.\n" + "Now press to continue..." + ); + fflush(stdout); + fgets(m1,40,stdin); + firstgr = 0; + } + i--; + GrSetMode( + GR_width_height_bpp_graphics, + grmodes[i].w, + grmodes[i].h, + grmodes[i].bpp + ); + if(grmodes[i].bpp<15) { + w = GrScreenX() >> 1; + h = GrScreenY() >> 1; + px = w + 5; + py = h + 5; + w -= 10; + h -= 10; + drawing( + 5,5,w,h, + GrBlack(), + GrWhite() + ); + drawing( + px,5,w,h, + GrAllocColor(255,0,0), + GrAllocColor(0,255,0) + ); + drawing( + 5,py,w,h, + GrAllocColor(0,0,255), + GrAllocColor(255,255,0) + ); + drawing( + px,py,w,h, + GrAllocColor(255,0,255), + GrAllocColor(0,255,255) + ); + } else { + int y,sx; + sx=GrScreenX()>>2; + for(y=0;ybit != 0) { + if(value & def->bit) { + if(prev) printf(" | "); + printf(def->name); + prev = 1; + } + def++; + } + if(!prev) printf("0"); + printf("\n"); +} + +void printinfo(VESAvgaInfoBlock *vgainfo) +{ + char far *sp = vgainfo->OEMstringPtr; + short far *mp = vgainfo->VideoModePtr; + + printf("VESASignature:\t\"%c%c%c%c\"\n", + vgainfo->VESAsignature[0], + vgainfo->VESAsignature[1], + vgainfo->VESAsignature[2], + vgainfo->VESAsignature[3] + ); + printf("VESAVersion:\t%d.%d\n", + VESA_VERSION_MAJOR(vgainfo->VESAversion), + VESA_VERSION_MINOR(vgainfo->VESAversion) + ); + printf("OEMStringPtr:\t\""); + while(*sp != '\0') putchar(*sp++); + printf("\"\nCapabilities:\t"), + printbits((int)vgainfo->Capabilities,capabilitiesbits); + printf("VideoModePtr:\t0x%08lx\n",(long)mp); + printf("Video Modes:\t"); + while(*mp != (short)(-1)) printf("0x%x ",(unsigned short)(*mp++)); + printf("\n"); + if(vgainfo->VESAversion >= VESA_VERSION(1,2)) { + printf("Memory Size:\t%d*64KBytes\n",vgainfo->MemorySize); + } + printf("\n"); + +} + +char *getmodelname(int model) +{ + static char temp[50]; + + if(model < 0) return(sprintf(temp,"Invalid model [%d]",model),temp); + if(model <= MODEL_DIRECT) return(memorymodels[model].name); + if(model <= 15) return(sprintf(temp,"VESA model [0x%02x]",model),temp); + return(sprintf(temp,"OEM model [%0x2x]",model),temp); +} + +void printmodeinfo(int mode,int version,VESAmodeInfoBlock *modeinfo) +{ + printf("Mode 0x%x is supported\n",mode); + printf(" ModeAttributes: "); + printbits(modeinfo->ModeAttributes,modeattrbits); + printf(" WinAAttributes: "); + printbits(modeinfo->WinAAttributes,winattrbits); + printf(" WinBAttributes: "); + printbits(modeinfo->WinBAttributes,winattrbits); + printf(" WinGranularity: %d\n",modeinfo->WinGranularity); + printf(" WinSize: %d\n",modeinfo->WinSize); + printf(" WinASegment: 0x%04x\n",(unsigned short)modeinfo->WinASegment); + printf(" WinBSegment: 0x%04x\n",(unsigned short)modeinfo->WinBSegment); + printf(" WinFuncPtr: 0x%08lx\n",(long)modeinfo->WinFuncPtr); + printf(" BytesPerScanLine: %d\n",modeinfo->BytesPerScanLine); + if(!(modeinfo->ModeAttributes & MODE_EXTINFO)) return; + printf(" XResolution: %d\n",modeinfo->XResolution); + printf(" YResolution: %d\n",modeinfo->YResolution); + printf(" XCharSize: %d\n",modeinfo->XCharSize); + printf(" YCharSize: %d\n",modeinfo->YCharSize); + printf(" NumberOfPlanes: %d\n",modeinfo->NumberOfPlanes); + printf(" BitsPerPixel: %d\n",modeinfo->BitsPerPixel); + printf(" NumberOfBanks: %d\n",modeinfo->NumberOfBanks); + printf(" MemoryModel: %d (%s)\n",modeinfo->MemoryModel,getmodelname(modeinfo->MemoryModel)); + printf(" BankSize: %d\n",modeinfo->BankSize); + printf(" NumImagePages %d\n",modeinfo->NumImagePages); + if(version < VESA_VERSION(1,2)) return; + printf(" RedMaskSize: %d\n",modeinfo->RedMaskSize); + printf(" RedMaskPos: %d\n",modeinfo->RedMaskPos); + printf(" GreenMaskSize: %d\n",modeinfo->GreenMaskSize); + printf(" GreenMaskPos: %d\n",modeinfo->GreenMaskPos); + printf(" BlueMaskSize: %d\n",modeinfo->BlueMaskSize); + printf(" BlueMaskPos: %d\n",modeinfo->BlueMaskPos); + printf(" ReservedMaskSize: %d\n",modeinfo->ReservedMaskSize); + printf(" ReservedMaskPos: %d\n",modeinfo->ReservedMaskPos); + printf(" DirectScreenMode: %d\n",modeinfo->DirectScreenMode); + if(version < VESA_VERSION(2,0)) return; + printf(" LinearFrameBuffer:0x%08lx\n", modeinfo->LinearFrameBuffer); + printf(" StartOffScreenMem:0x%08lx\n", modeinfo->StartOffScreenMem); + printf(" OffScreenMemSize: %d kb\n", modeinfo->OffScreenMemSize); +} + +#define PTR_ADD(p,o) ((void *) ((char*)(p)+(o)) ) + +void printpminfo(VESApmInfoBlock *pb) { + unsigned short *st = (unsigned short *) PTR_ADD(pb,pb->SubTable_off+VESApmInfoBlock_BASEOFF); + + printf("VESA bios includes protected mode support:\n"); + printf(" PM info table start:\t\t%04x:%04x\n", pb->RealMode_SEG, pb->RealMode_OFF); + printf(" PM info table length:\t\t0x%04x\n", pb->PhysicalLength); + printf(" set window offset:\t\t%04x (%04x:%04x)\n", pb->SetWindow_off, pb->RealMode_SEG, pb->RealMode_OFF+pb->SetWindow_off); + printf(" set display start offset:\t%04x (%04x:%04x)\n", pb->DisplStart_off, pb->RealMode_SEG, pb->RealMode_OFF+pb->DisplStart_off); + printf(" set primary palette offset:\t%04x (%04x:%04x)\n", pb->PPalette_off, pb->RealMode_SEG, pb->RealMode_OFF+pb->PPalette_off); + printf(" resource table offset:\t%04x (%04x:%04x)\n", pb->SubTable_off, pb->RealMode_SEG, pb->RealMode_OFF+pb->SubTable_off); + if (pb->SubTable_off != 0) { + int first; + printf(" required ports:\t\t"); + first = 1; + while (*st != 0xffff) { + printf("%s%04x", (first?"":", "), *st); + ++st; + } + printf("\n required memory areas:\t"); + first = 1; + while (*st != 0xffff) { + unsigned long start = *st++; + unsigned long end = *st++; + start <<= 4; + end += start; + printf("%s%06lx-%06lx", (first?"":", "), start, end-1); + } + printf("\n"); + } + printf("\n"); +} + +int main(void) +{ + VESApmInfoBlock *pb; + VESAvgaInfoBlock vb; + VESAmodeInfoBlock mb; + if(_GrViDrvVESAgetVGAinfo(&vb)) { + short far *mp = vb.VideoModePtr; + printinfo(&vb); + if((pb=_GrViDrvVESAgetPMinfo()) != NULL) + printpminfo(pb); + while(*mp != (short)(-1)) { + if(_GrViDrvVESAgetModeInfo(*mp,&mb)) { + printmodeinfo(*mp,vb.VESAversion,&mb); + } + else { + printf("Mode 0x%x IS NOT SUPPORTED!\n",*mp); + } + mp++; + } + } + else printf("VESA BIOS extensions not found\n"); + return 0; +} + + diff --git a/thirdparty/grx249/src/utils/bccarith.c b/thirdparty/grx249/src/utils/bccarith.c new file mode 100644 index 0000000..850af82 --- /dev/null +++ b/thirdparty/grx249/src/utils/bccarith.c @@ -0,0 +1,189 @@ +/** + ** bccarith.c ---- some common integer arithmetic functions + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Intel CPU specific support is provided for the Turbo C and GNU C. May + ** work with other compilers and CPU-s, but is not optimized for them. + ** + **/ + +#include "libgrx.h" +#include "arith.h" + +#ifdef __TURBOC__ +/* prototype for __emit__() */ +#include +#endif + +#ifdef _MSC_VER +#define __emit__(x) __asm{ __emit (x) } +#endif + +/* + * [i|u]mul32(x,y) + * multiply two int-s for a long result + */ +long _GR_imul32(int x, int y) { + _DX = (int)(x); + _AX = (int)(y); + __emit__((char)(0xf7)); /* imul dx */ + __emit__((char)(0xea)); + return (long)((void _seg *)_DX + (void near *)_AX); +} + +unsigned long _GR_umul32(int x, int y) { + _DX = (int)(x); + _AX = (int)(y); + __emit__((char)(0xf7)); /* mul dx */ + __emit__((char)(0xe2)); + return (unsigned long)((void _seg *)_DX + (void near *)_AX); +} + +/* + * umuladd32(x,y,z) + * multiply two int-s for a long result and add + */ +unsigned long _GR_umuladd32(unsigned x, unsigned y, unsigned z) { + _DX = x; + _AX = y; + _BX = z; + __emit__((char)(0xf7)); /* mul dx */ + __emit__((char)(0xe2)); + + __emit__((char)(0x01)); /* add ax,bx */ + __emit__((char)(0xd8)); + + __emit__((char)(0x83)); /* adc dx,0 */ + __emit__((char)(0xd2)); + __emit__((char)(0x00)); + return (unsigned long)((void _seg *)_DX + (void near *)_AX); +} + +/* + * [i|u]scale(X,N,D) + * scale an integer with long intermediate result but without using long + * arithmetic all the way + */ +int _GR_iscale(int x,int n,int d) { + _CX = (int)(d); + _DX = (int)(n); + _AX = (int)(x); + __emit__((char)(0xf7)); /* imul dx */ + __emit__((char)(0xea)); + __emit__((char)(0xf7)); /* idiv cx */ + __emit__((char)(0xf9)); + return (int)_AX; +} + +unsigned int _GR_uscale(int x,int n,int d) { + _CX = (int)(d); + _DX = (int)(n); + _AX = (int)(x); + __emit__((char)(0xf7)); /* mul dx */ + __emit__((char)(0xe2)); + __emit__((char)(0xf7)); /* div cx */ + __emit__((char)(0xf1)); + return (unsigned int)_AX; +} + +int _GR_irscale(int x, int n, int d) { + _AX = (int)(x<<1); + _CX = (int)(d); + _DX = (int)(n); + __emit__((char)(0xf7)); /* imul dx */ + __emit__((char)(0xea)); + __emit__((char)(0xf7)); /* idiv cx */ + __emit__((char)(0xf9)); + + _DX = _AX; + __emit__((char)(0x03)); /* add dx,dx */ + __emit__((char)(0xd2)); + __emit__((char)(0x1d)); /* sbc ax,0xffff */ + __emit__((char)(-1)); + __emit__((char)(-1)); + __emit__((char)(0xd1)); /* sar ax,1 */ + __emit__((char)(0xf8)); + + return (int)_AX; +} + +#if 0 +These are Csaba's inline macros. +The _?X register loading fails in some cases. + +#define imul32(X,Y) ( \ + _AX = (int)(X), \ + __emit__((char)(0x50)), /* push ax */ \ + _AX = (int)(Y), \ + __emit__((char)(0x5a)), /* pop dx */ \ + __emit__((char)(0xf7)), /* imul dx */ \ + __emit__((char)(0xea)), \ + _BX = _AX, \ + _CX = _DX, \ + (long)((void _seg *)_CX + (void near *)_BX) \ +) +#define umul32(X,Y) ( \ + _AX = (int)(X), \ + __emit__((char)(0x50)), /* push ax */ \ + _AX = (int)(Y), \ + __emit__((char)(0x5a)), /* pop dx */ \ + __emit__((char)(0xf7)), /* mul dx */ \ + __emit__((char)(0xe2)), \ + _BX = _AX, \ + _CX = _DX, \ + (unsigned long)((void _seg *)_CX + (void near *)_BX) \ +) + +#define iscale(X,N,D) ( \ + _AX = (int)(D), \ + __emit__((char)(0x50)), /* push ax */ \ + _AX = (int)(N), \ + __emit__((char)(0x50)), /* push ax */ \ + _AX = (int)(X), \ + __emit__((char)(0x5a)), /* pop dx */ \ + __emit__((char)(0x59)), /* pop cx */ \ + __emit__((char)(0xf7)), /* imul dx */ \ + __emit__((char)(0xea)), \ + __emit__((char)(0xf7)), /* idiv cx */ \ + __emit__((char)(0xf9)), \ + (int)_AX \ +) +#define uscale(X,N,D) ( \ + _AX = (int)(D), \ + __emit__((char)(0x50)), /* push ax */ \ + _AX = (int)(N), \ + __emit__((char)(0x50)), /* push ax */ \ + _AX = (int)(X), \ + __emit__((char)(0x5a)), /* pop dx */ \ + __emit__((char)(0x59)), /* pop cx */ \ + __emit__((char)(0xf7)), /* mul dx */ \ + __emit__((char)(0xe2)), \ + __emit__((char)(0xf7)), /* div cx */ \ + __emit__((char)(0xf1)), \ + (unsigned int)_AX \ +) +#define irscale(X,N,D) ( \ + _DX = iscale(((int)(X) << 1),N,D), \ + __emit__((char)(0x03)), /* add dx,dx */ \ + __emit__((char)(0xd2)), \ + __emit__((char)(0x1d)), /* sbc ax,0xffff */ \ + __emit__((char)(-1)), \ + __emit__((char)(-1)), \ + __emit__((char)(0xd1)), /* sar ax,1 */ \ + __emit__((char)(0xf8)), \ + (int)_AX \ +) + +#endif diff --git a/thirdparty/grx249/src/utils/bcccopy.c b/thirdparty/grx249/src/utils/bcccopy.c new file mode 100644 index 0000000..c41c948 --- /dev/null +++ b/thirdparty/grx249/src/utils/bcccopy.c @@ -0,0 +1,103 @@ +/** + ** bcccopy.c ---- optimized BCC memory copy operations + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "mempeek.h" +#include "memcopy.h" + +#pragma inline +#pragma warn -rvl + +void far *_GR_fwdcopy_set(void near *ap, void far *d, void far *s, unsigned cnt) +{ + asm push ds + asm mov cx, cnt + asm mov ax, ap + asm les di, d + asm lds si, s + asm or cx,cx + asm jz short done + asm cld + asm test al,1 + asm jz short noalign + asm movsb + asm dec cx + asm jz short done + noalign: + asm shr cx, 1 + asm jz short noword + asm rep movsw + noword: + asm jnc short done + asm movsb + done: + asm mov dx, es + asm mov ax, di + asm pop ds +} + +#define COPYOPR(FN,INS) \ + void far * FN (void near *ap, void far *d, void far *s, unsigned cnt) \ + { \ + asm push ds ; \ + asm mov cx, cnt ; \ + asm mov ax, ap ; \ + asm les di, d ; \ + asm lds si, s ; \ + asm or cx,cx ; \ + asm jz short done ; \ + asm cld ; \ + asm test al,1 ; \ + asm jz short noalign ; \ + asm lodsb ; \ + asm INS es:[di], al ; \ + asm inc di ; \ + asm dec cx ; \ + asm jz short done ; \ + noalign: \ + asm shr cx, 1 ; \ + asm jz short noword ; \ + asm pushf ; \ + asm mov bx,2 ; \ + asm inc cx ; \ + asm shr cx, 1 ; \ + asm jnc short odd ; \ + loop: \ + asm lodsw ; \ + asm INS es:[di], ax ; \ + asm add di, bx ; \ + odd: \ + asm lodsw ; \ + asm INS es:[di], ax ; \ + asm add di, bx ; \ + asm dec cx ; \ + asm jnz short loop ; \ + asm popf ; \ + noword: \ + asm jnc short done ; \ + asm lodsb ; \ + asm INS es:[di], al ; \ + asm inc di ; \ + done: \ + asm mov dx, es ; \ + asm mov ax, di ; \ + asm pop ds ; \ + } + +COPYOPR(_GR_fwdcopy_xor,xor) +COPYOPR(_GR_fwdcopy_or,or) +COPYOPR(_GR_fwdcopy_and,and) diff --git a/thirdparty/grx249/src/utils/bccfil08.c b/thirdparty/grx249/src/utils/bccfil08.c new file mode 100644 index 0000000..321e719 --- /dev/null +++ b/thirdparty/grx249/src/utils/bccfil08.c @@ -0,0 +1,126 @@ +/** + ** bccfil08.c ---- optimized BCC memory fill operations (8bit) + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "mempeek.h" +#include "memfill.h" + +#pragma inline +#pragma warn -rvl + +#define COLFL(FN,INS) \ + void far * FN (void far *P, int O, unsigned char V, unsigned C) { \ + asm les di, P ; \ + asm mov cx, C ; \ + asm or cx,cx ; \ + asm jz short _##FN##3 ; \ + asm mov bx, O ; \ + asm mov al, V ; \ + asm inc cx ; \ + asm shr cx,1 ; \ + asm jnc short _##FN##2 ; \ + _##FN##1: \ + asm INS es:[di],al ; \ + asm add di,bx ; \ + _##FN##2: \ + asm INS es:[di],al ; \ + asm add di,bx ; \ + asm dec cx ; \ + asm jnz short _##FN##1 ; \ + _##FN##3: \ + asm mov dx,es ; \ + asm mov ax,di ; \ + } + +COLFL(_GR_colfill_b_mov,MOV_INS) +COLFL(_GR_colfill_b_xor,XOR_INS) +COLFL(_GR_colfill_b_or,OR_INS) +COLFL(_GR_colfill_b_and,AND_INS) + + +void far *_GR_repfill_b(void far *P,unsigned int V, unsigned int C) { + asm les di, P + asm mov cx, C + asm or cx,cx + asm jz short _rpfb3 + asm cld + asm mov ax, V + asm test di,1 + asm jz short _rpfb1 + asm stosb + asm dec cx + _rpfb1: + asm shr cx,1 + asm jz _rpfb2 + asm pushf + asm cld + asm rep stosw + asm popf + _rpfb2: + asm jnc _rpfb3 + asm stosb + _rpfb3: + asm mov dx,es + asm mov ax,di +} + +#define REPFB_OP(FN,INS) \ + void far * FN (void far *P,unsigned int V, unsigned int C) { \ + asm mov cx, C ; \ + asm push ds ; \ + asm lds di, P ; \ + asm or cx,cx ; \ + asm jz short _##FN##4 ; \ + asm cld ; \ + asm mov ax, V ; \ + asm test di,1 ; \ + asm jz short _##FN##1 ; \ + asm INS [di],al ; \ + asm inc di ; \ + asm dec cx ; \ + _##FN##1: \ + asm shr cx,1 ; \ + asm jz short _##FN##3 ; \ + asm pushf ; \ + asm inc cx ; \ + asm shr cx,1 ; \ + asm jnc short _##FN##5 ; \ + _##FN##2: \ + asm INS [di],ax ; \ + asm inc di ; \ + asm inc di ; \ + _##FN##5: \ + asm INS [di],ax ; \ + asm inc di ; \ + asm inc di ; \ + asm dec cx ; \ + asm jnz short _##FN##2 ; \ + asm popf ; \ + _##FN##3: \ + asm jnc _##FN##4 ; \ + asm INS [di],al ; \ + asm inc di ; \ + _##FN##4: \ + asm mov dx,ds ; \ + asm mov ax,di ; \ + asm pop ds ; \ + } + +REPFB_OP(_GR_repfill_b_xor,XOR_INS) +REPFB_OP(_GR_repfill_b_or,OR_INS) +REPFB_OP(_GR_repfill_b_and,AND_INS) + diff --git a/thirdparty/grx249/src/utils/bccfil16.c b/thirdparty/grx249/src/utils/bccfil16.c new file mode 100644 index 0000000..b4e8005 --- /dev/null +++ b/thirdparty/grx249/src/utils/bccfil16.c @@ -0,0 +1,52 @@ +/** + ** bccfil16.c ---- BCC memory fill operations (16bit) + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "mempeek.h" +#include "memfill.h" + +#pragma inline +#pragma warn -rvl + +#define COLFL(FN,INS) \ + void far * FN (void far *P,int O, unsigned V, unsigned C) { \ + asm les di, P ; \ + asm mov cx, C ; \ + asm or cx,cx ; \ + asm jz short _##FN##3 ; \ + asm mov bx, O ; \ + asm mov ax, V ; \ + asm inc cx ; \ + asm shr cx,1 ; \ + asm jnc short _##FN##2 ; \ + _##FN##1: \ + asm INS es:[di],ax ; \ + asm add di,bx ; \ + _##FN##2: \ + asm INS es:[di],ax ; \ + asm add di,bx ; \ + asm dec cx ; \ + asm jnz short _##FN##1 ; \ + _##FN##3: \ + asm mov dx,es ; \ + asm mov ax,di ; \ + } + +COLFL(_GR_colfill_w_mov,MOV_INS) +COLFL(_GR_colfill_w_xor,XOR_INS) +COLFL(_GR_colfill_w_or,OR_INS) +COLFL(_GR_colfill_w_and,AND_INS) diff --git a/thirdparty/grx249/src/utils/bccfil24.c b/thirdparty/grx249/src/utils/bccfil24.c new file mode 100644 index 0000000..0d4757c --- /dev/null +++ b/thirdparty/grx249/src/utils/bccfil24.c @@ -0,0 +1,89 @@ +/** + ** bccfil24.c ---- optimized BCC memory fill operations for 24bpp + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "mempeek.h" +#include "memfill.h" +#include "access24.h" + +#pragma inline +#pragma warn -rvl + +#define REPF24_OP(FN,INS) \ + void far * FN (void far *P,unsigned long V, unsigned int B) { \ + _CX = (unsigned)B; \ + _AX = (unsigned)(V); \ + _DL = RD24BYTE(V,2); \ + /* least sig byte: al, mid byte : ah, most sig byte : dl */ \ + asm push ds ; \ + asm lds di, P ; \ + asm or cx,cx ; \ + asm jz short _##FN##done ; \ + asm test di,1 ; \ + asm jz short _##FN##1 ; \ + asm INS [di],al ; \ + asm inc di ; \ + asm dec cx ; \ + asm xchg ah,al /* rotate dl/ah/al */ ; \ + asm xchg dl,ah ; \ + _##FN##1: \ + asm mov dh,al /* ax/dx/bx: 2 pix */ ; \ + asm mov bl,ah ; \ + asm mov bh,dl ; \ + asm mov si,6 ; \ + asm sub cx,si ; \ + asm jb short _##FN##3 ; \ + _##FN##2: \ + asm INS [di],ax ; \ + asm INS [di+2],dx ; \ + asm INS [di+4],bx ; \ + asm add di,si ; \ + asm sub cx,si ; \ + asm jnb short _##FN##2 ; \ + _##FN##3: \ + asm add cx,si ; \ + asm je short _##FN##done ; \ + /* 1..5 bytes left */ \ + asm INS [di],al ; \ + asm inc di ; \ + asm dec cx ; \ + asm je short _##FN##done ; \ + asm INS [di],ah ; \ + asm inc di ; \ + asm dec cx ; \ + asm je short _##FN##done ; \ + asm INS [di],dl ; \ + asm inc di ; \ + asm dec cx ; \ + asm je short _##FN##done ; \ + asm INS [di],dh ; \ + asm inc di ; \ + asm dec cx ; \ + asm je short _##FN##done ; \ + asm INS [di],bl ; \ + asm inc di ; \ + _##FN##done: \ + asm mov dx, ds ; \ + asm mov ax, di ; \ + asm pop ds ; \ + } + +REPF24_OP(_GR_repfill_24_set,MOV_INS) +REPF24_OP(_GR_repfill_24_xor,XOR_INS) +REPF24_OP(_GR_repfill_24_or,OR_INS) +REPF24_OP(_GR_repfill_24_and,AND_INS) + diff --git a/thirdparty/grx249/src/utils/bccfil32.c b/thirdparty/grx249/src/utils/bccfil32.c new file mode 100644 index 0000000..8560f0c --- /dev/null +++ b/thirdparty/grx249/src/utils/bccfil32.c @@ -0,0 +1,55 @@ +/** + ** bccfil32.c ---- optimized BCC memory fill operations (32bit) + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "mempeek.h" +#include "memfill.h" + +#pragma inline +#pragma warn -rvl + +#define COLFL(FN,INS) \ + void far * FN (void far *P,int O, unsigned long V, unsigned C) { \ + asm les di, P ; \ + asm mov cx, C ; \ + asm or cx,cx ; \ + asm jz short _##FN##3 ; \ + asm mov bx, O ; \ + _DX = ((GR_int16u *)&V)[1]; \ + _AX = ((GR_int16u *)&V)[0]; \ + asm inc cx ; \ + asm shr cx,1 ; \ + asm jnc short _##FN##2 ; \ + _##FN##1: \ + asm INS es:[di],ax ; \ + asm INS es:[di+2],dx ; \ + asm add di,bx ; \ + _##FN##2: \ + asm INS es:[di],ax ; \ + asm INS es:[di+2],dx ; \ + asm add di,bx ; \ + asm dec cx ; \ + asm jnz short _##FN##1 ; \ + _##FN##3: \ + asm mov dx,es ; \ + asm mov ax,di ; \ + } + +COLFL(_GR_colfill_l_mov,MOV_INS) +COLFL(_GR_colfill_l_xor,XOR_INS) +COLFL(_GR_colfill_l_or,OR_INS) +COLFL(_GR_colfill_l_and,AND_INS) diff --git a/thirdparty/grx249/src/utils/dbgprint.c b/thirdparty/grx249/src/utils/dbgprint.c new file mode 100644 index 0000000..6d28d39 --- /dev/null +++ b/thirdparty/grx249/src/utils/dbgprint.c @@ -0,0 +1,54 @@ +/** + ** dbgprint.c ---- GRX debug support + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifdef DEBUG +#include +#include +#include + +#include "grxdebug.h" + +#ifndef DBG_LOGFILE +#define DBG_LOGFILE "grxdebug.log" +#endif + +char *_GR_debug_file; +int _GR_debug_line; +#ifdef __GNUC__ +char *_GR_debug_function; +# endif +int _GR_debug_flags = DEBUG-0; + +void _GR_debug_printf(char *fmt,...) +{ + FILE *dfp = NULL; + va_list ap; + dfp = fopen(DBG_LOGFILE,"at"); + if(!dfp) return; +#ifdef __GNUC__ + fprintf(dfp,"%s|%s|%d: ", + _GR_debug_file, _GR_debug_function, _GR_debug_line); +#else + fprintf(dfp,"%s/%d: ", _GR_debug_file, _GR_debug_line); +#endif + va_start(ap,fmt); + vfprintf(dfp,fmt,ap); + va_end(ap); + fclose(dfp); +} + +#endif diff --git a/thirdparty/grx249/src/utils/ordswap.c b/thirdparty/grx249/src/utils/ordswap.c new file mode 100644 index 0000000..14bf26a --- /dev/null +++ b/thirdparty/grx249/src/utils/ordswap.c @@ -0,0 +1,101 @@ +/** + ** ordswap.c ---- multibyte value order swaping + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + + +#include "libgrx.h" +#include "mempeek.h" +#include "ordswap.h" + +#if 1 +#define SWAPBYTE(ty,mb,src,dst) (((ty)((GR_int8u)((mb) >> (8*(src)))) << (8*(dst)))) + +void _GR_swap16(GR_int16 far *w) { + GR_int16 res; + GRX_ENTER(); + res = SWAPBYTE(GR_int16,*w,1,0); + res |= SWAPBYTE(GR_int16,*w,0,1); + *w = res; + GRX_LEAVE(); +} + +void _GR_swap32(GR_int32 far *l) { + GR_int32 res; + GRX_ENTER(); + res = SWAPBYTE(GR_int32,*l,3,0); + res |= SWAPBYTE(GR_int16,*l,0,3); + res |= SWAPBYTE(GR_int16,*l,2,1); + res |= SWAPBYTE(GR_int16,*l,1,2); + *l = res; + GRX_LEAVE(); +} + +#ifdef GR_int64 + +void _GR_swap64(GR_int64 far *h) { + GR_int64 res; + GRX_ENTER(); + res = SWAPBYTE(GR_int64,*h,7,0); + res |= SWAPBYTE(GR_int64,*h,0,7); + res |= SWAPBYTE(GR_int64,*h,6,1); + res |= SWAPBYTE(GR_int64,*h,1,6); + res |= SWAPBYTE(GR_int64,*h,5,2); + res |= SWAPBYTE(GR_int64,*h,2,5); + res |= SWAPBYTE(GR_int64,*h,4,3); + res |= SWAPBYTE(GR_int64,*h,3,4); + *h = res; + GRX_LEAVE(); +} +#endif + +#else +static void swapbytes(GR_int8 far *b1, GR_int8 far *b2) { + GR_int8 b; + GRX_ENTER(); + b = peek_b(b1); + poke_b(b1, peek_b(b2)); + poke_b(b2, b); + GRX_LEAVE(); +} + +void _GR_swap16(GR_int16 far *w) { + GRX_ENTER(); + swapbytes((GR_int8 far *)w, ((GR_int8 far *)w)+1); + GRX_LEAVE(); +} + +void _GR_swap32(GR_int32 far *l) { + GRX_ENTER(); + swapbytes(((GR_int8 far *)l) , ((GR_int8 far *)l)+3); + swapbytes(((GR_int8 far *)l)+1, ((GR_int8 far *)l)+2); + GRX_LEAVE(); +} + +#ifdef GR_int64 + +void _GR_swap64(GR_int64 far *h) { + GRX_ENTER(); + swapbytes(((GR_int8 far *)h) , ((GR_int8 far *)h)+7); + swapbytes(((GR_int8 far *)h)+1, ((GR_int8 far *)h)+6); + swapbytes(((GR_int8 far *)h)+2, ((GR_int8 far *)h)+5); + swapbytes(((GR_int8 far *)h)+3, ((GR_int8 far *)h)+4); + GRX_LEAVE(); +} + +#endif + + +#endif diff --git a/thirdparty/grx249/src/utils/resize.c b/thirdparty/grx249/src/utils/resize.c new file mode 100644 index 0000000..5cff00e --- /dev/null +++ b/thirdparty/grx249/src/utils/resize.c @@ -0,0 +1,110 @@ +/** + ** resize.c ---- function to resize a two-D map of gray (0..255) pixels + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include + +#include "libgrx.h" + +static void near shrink(unsigned char far *ptr,int pitch,unsigned int oldlen,unsigned int newlen) +{ + register unsigned char far *dst = ptr; + register unsigned char far *src = ptr; + int count = newlen; + unsigned int weight = newlen; + do { + unsigned int collect = oldlen; + unsigned int pixsum = 0; + do { + unsigned int factor; + if(weight == 0) weight = newlen,src += pitch; + if((factor = weight) > collect) factor = collect; + pixsum += factor * (*src); + weight -= factor; + collect -= factor; + } while(collect > 0); + *dst = pixsum / oldlen; + dst += pitch; + } while(--count > 0); +#ifdef DEBUG + if(dst != (ptr + (newlen * pitch))) { + fprintf(stderr,"resize: dst error (shrink)\n"); + exit(1); + } + if(src != (ptr + ((oldlen - 1) * pitch))) { + fprintf(stderr,"resize: src error (shrink)\n"); + exit(1); + } +#endif +} + +static void grow(unsigned char far *ptr,int pitch,unsigned int oldlen,unsigned int newlen) +{ + register unsigned char far *dst = ptr + (--newlen * pitch); + register unsigned char far *src = ptr + (--oldlen * pitch); + unsigned int rpix = *src; + unsigned int lpix = rpix; + int count = newlen; + int scale = oldlen; + do { + if((scale -= oldlen) < 0) { + rpix = lpix; + lpix = *(src -= pitch); + scale += newlen; + } + *dst = ((lpix * (newlen - scale)) + (rpix * scale)) / newlen; + dst -= pitch; + } while(--count >= 0); +#ifdef DEBUG + if(dst != (ptr - pitch)) { + fprintf(stderr,"resize: dst error (grow)\n"); + exit(1); + } + if(src != ptr) { + fprintf(stderr,"resize: src error (grow)\n"); + exit(1); + } +#endif +} + +void GrResizeGrayMap(unsigned char far *map,int pitch,int ow,int oh,int nw,int nh) +{ + if(ow != nw) { + unsigned char far *ptr = map; + int cnt = oh; + if((unsigned int)ow > (unsigned int)nw) do { + shrink(ptr,1,ow,nw); + ptr += pitch; + } while(--cnt > 0); + else do { + grow(ptr,1,ow,nw); + ptr += pitch; + } while(--cnt > 0); + } + if(oh != nh) { + int cnt = nw; + if((unsigned int)oh > (unsigned int)nh) do { + shrink(map,pitch,oh,nh); + map++; + } while(--cnt > 0); + else do { + grow(map,pitch,oh,nh); + map++; + } while(--cnt > 0); + } +} diff --git a/thirdparty/grx249/src/utils/shiftscl.c b/thirdparty/grx249/src/utils/shiftscl.c new file mode 100644 index 0000000..f5224ed --- /dev/null +++ b/thirdparty/grx249/src/utils/shiftscl.c @@ -0,0 +1,142 @@ +/** + ** shiftscl.c ---- shift and copy an array (scanline) + ** for 1bpp and 4bpp frame driver blit operations + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "highlow.h" + +#ifdef __TURBOC__ +#pragma inline +#endif + +void _GR_shift_scanline(GR_int8u far **dst, + GR_int8u far **src, + int ws, int shift, int planes) { + int plane; + + GRX_ENTER(); + if (shift <= 0) { + shift = -shift; + for (plane = 0; plane < planes; ++plane) { + GR_int8u far *s = *(src++) + ws; + GR_int8u far *d = *(dst++) + ws; +# if defined(__GNUC__) && defined(__i386__) + int _dummy_, w = ws; + /* sad but true: the x86 bytesex forces this inefficient code :( */ + asm volatile ("\n" + " movb (%0),%%ch \n" + " jmp 1f \n" + " .align 4,0x90 \n" + "1: decl %0 \n" + " movb %%ch,%%al \n" + " movb (%0),%%ah \n" + " movb %%ah,%%ch \n" + " shrl %%cl,%%eax \n" + " movb %%al,(%1) \n" + " decl %1 \n" + " decl %2 \n" + " jne 1b \n" + " shrb %%cl,%%ch \n" + " movb %%ch,(%1) " + : "=r" ((void *)s), "=r" ((void *)d), "=r" ((int)w), "=c" (_dummy_) + : "0" ((void *)s), "1" ((void *)d), "2" ((int)w), "3" ((int)shift) + : "ax" + ); +# elif defined(__TURBOC__) + asm push ds ; + asm mov bx, ws ; + asm mov cl, shift ; + asm les di, d ; + asm lds si, s ; + asm mov ch,[si] ; + asm std ; + looprv: + asm dec si ; + asm mov al, ch ; + asm mov ah, [si] ; + asm mov ch, ah ; + asm shr ax, cl ; + asm stosb ; + asm dec bx ; + asm jnz short looprv ; + asm mov al, ch ; + asm shr al, cl ; + asm stosb ; + asm pop ds ; +# else + int w = ws; + do { + --s; + *(d--) = highlowP(s)>>shift; + } while (--w); + *d = *s >> shift; +# endif + } + } else { + shift = 8-shift; + for (plane = 0; plane < planes; ++plane) { + GR_int8u far *s = *(src++); + GR_int8u far *d = *(dst++); +# if defined(__GNUC__) && defined(__i386__) + int _dummy_, w = ws; + asm volatile ("\n" + " movb (%0),%%ch \n" + " jmp 1f \n" + " .align 4,0x90 \n" + "1: incl %0 \n" + " movb %%ch,%%ah \n" + " movb (%0),%%al \n" + " movb %%al,%%ch \n" + " shrl %%cl,%%eax \n" + " movb %%al,(%1) \n" + " incl %1 \n" + " decl %2 \n" + " jne 1b " + : "=r" ((void *)s), "=r" ((void *)d), "=r" ((int)w), "=c" (_dummy_) + : "0" ((void *)s), "1" ((void *)d), "2" ((int)w), "3" ((int)shift) + : "ax" + ); +# elif defined(__TURBOC__) + asm push ds ; + asm mov bx, ws ; + asm mov cl, shift ; + asm les di, d ; + asm lds si, s ; + asm mov ch,[si] ; + asm cld ; + loopfw: + asm inc si ; + asm mov ah, ch ; + asm mov al, [si] ; + asm mov ch, al ; + asm shr ax, cl ; + asm stosb ; + asm dec bx ; + asm jnz short loopfw ; + asm pop ds ; +# else + int w = ws; + do { + *(d++) = highlowP(s)>>shift /* sh */; + s++; + } while (--w); +# endif + } + } + GRX_LEAVE(); +} + diff --git a/thirdparty/grx249/src/utils/strmatch.c b/thirdparty/grx249/src/utils/strmatch.c new file mode 100644 index 0000000..8b6337b --- /dev/null +++ b/thirdparty/grx249/src/utils/strmatch.c @@ -0,0 +1,131 @@ +/** + ** strmatch.c ---- a string matcher. Similar to UNIX filename matching + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "libgrx.h" + +int GrMatchString(const char *pat,const char *str) +{ + int i,n,escape = FALSE; + union { + struct { const char *s; int l; } str[20]; + struct { unsigned char loc; unsigned char hic; } chr[50]; + } m; + for( ; ; ) { + if(*pat == '\0') { + return((*str == '\0') ? TRUE : FALSE); + } + if(!escape) switch(*pat) { + case '\\': + escape = TRUE; + pat++; + continue; + case '?': + if(*str == '\0') return(FALSE); + pat++; + str++; + continue; + case '*': + if(*(++pat) == '\0') { + return(TRUE); + } + while(*str != '\0') { + if(GrMatchString(pat,str)) return(TRUE); + str++; + } + return(FALSE); + case '[': + for(i = FALSE, n = 0; ; ) { + switch(*(++pat)) { + case '\0': + return(FALSE); + case '\\': + escape = TRUE; + continue; + case ']': + if(!escape) { + pat++; + break; + } + case '-': + if(!escape) { + i = TRUE; + continue; + } + default: + if(i && (n > 0)) { + m.chr[n - 1].hic = *pat; + } + else { + m.chr[n].loc = m.chr[n].hic = *pat; + n++; + } + i = escape = FALSE; + continue; + } + break; + } + for(i = 0; ; i++) { + if(i == n) return(FALSE); + if((unsigned char)(*str) < m.chr[i].loc) continue; + if((unsigned char)(*str) > m.chr[i].hic) continue; + str++; + break; + } + continue; + case '{': + for(m.str[n = i = 0].s = pat + 1; ; ) { + switch(*(++pat)) { + case '\0': + return(FALSE); + case '\\': + escape = TRUE; + continue; + case '}': + if(!escape) { + m.str[n++].l = i; + pat++; + break; + } + case ',': + if(!escape) { + m.str[n++].l = i; + m.str[n ].s = pat + 1; + i = 0; + continue; + } + default: + i++; + continue; + } + break; + } + for(i = 0; i < n; i++) { + if(strncmp(str,m.str[i].s,(size_t)m.str[i].l)!=0) continue; + if(GrMatchString(pat,&str[m.str[i].l]) == 0) continue; + return(TRUE); + } + return(FALSE); + } + if(*pat != *str) return(FALSE); + escape = FALSE; + pat++; + str++; + } +} + diff --git a/thirdparty/grx249/src/utils/tmpbuff.c b/thirdparty/grx249/src/utils/tmpbuff.c new file mode 100644 index 0000000..0d99ad3 --- /dev/null +++ b/thirdparty/grx249/src/utils/tmpbuff.c @@ -0,0 +1,41 @@ +/** + ** tmpbuff.c ---- temporary buffer support + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" + +void far *_GrTempBuffer = NULL; +unsigned _GrTempBufferBytes = 0; + +void far *_GrTempBufferAlloc_(size_t bytes) { + GRX_ENTER(); + if (bytes > _GrTempBufferBytes || _GrTempBuffer == NULL) { + void far *neu = farrealloc(_GrTempBuffer, bytes); + if (neu) { + _GrTempBuffer = neu; + _GrTempBufferBytes = bytes; + } + } + GRX_RETURN( (bytes<=_GrTempBufferBytes && _GrTempBuffer) + ? _GrTempBuffer : NULL); +} + +void _GrTempBufferFree(void) { + if (_GrTempBuffer) farfree(_GrTempBuffer); + _GrTempBuffer = NULL; + _GrTempBufferBytes = 0; +} diff --git a/thirdparty/grx249/src/utils/watcom32.c b/thirdparty/grx249/src/utils/watcom32.c new file mode 100644 index 0000000..9308f51 --- /dev/null +++ b/thirdparty/grx249/src/utils/watcom32.c @@ -0,0 +1,62 @@ +/** + ** watcom32.c ---- Watcom32 support functions + ** + ** Copyright (c) 1998 Hartmut Schirmer & Gary Sands + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "int86.h" +#include "memfill.h" + +void wc32_int10x(Int86Regs *iregp, int nSeg) { + static struct rminfo { + long EDI; + long ESI; + long EBP; + long reserved_by_system; + long EBX; + long EDX; + long ECX; + long EAX; + short flags; + short ES,DS,FS,GS,IP,CS,SP,SS; + } RMI; + _fmemset ( &RMI,0,sizeof(RMI) ); + RMI.EDI = IREG_DI(*iregp); + RMI.ESI = IREG_SI(*iregp); + RMI.EBX = IREG_BX(*iregp); + RMI.EDX = IREG_DX(*iregp); + RMI.ECX = IREG_CX(*iregp); + RMI.EAX = IREG_AX(*iregp); + /* RMI.ES = IREG_ES(iregp); */ + RMI.ES = nSeg; + RMI.DS = IREG_DS(*iregp); + sttzero(iregp); + IREG_AX(*iregp) = 0x300; + IREG_BL(*iregp) = 0x10; + IREG_BH(*iregp) = 0; + IREG_CX(*iregp) = 0; + IREG_ES(*iregp) = FP_SEG(&RMI); + IREG_EDI(*iregp) = FP_OFF(&RMI); + int386x( 0x31, &(iregp->Normal), &(iregp->Normal), &(iregp->Extended) ); + sttzero(iregp); + IREG_DI(*iregp) = RMI.EDI; + IREG_SI(*iregp) = RMI.ESI; + IREG_BX(*iregp) = RMI.EBX; + IREG_DX(*iregp) = RMI.EDX; + IREG_CX(*iregp) = RMI.ECX; + IREG_AX(*iregp) = RMI.EAX; + IREG_ES(*iregp) = RMI.ES; + IREG_DS(*iregp) = RMI.DS; +} diff --git a/thirdparty/grx249/src/utils/watmake.c b/thirdparty/grx249/src/utils/watmake.c new file mode 100644 index 0000000..771f438 --- /dev/null +++ b/thirdparty/grx249/src/utils/watmake.c @@ -0,0 +1,246 @@ +/** + ** watmake.c ---- generates makefile.wat from depend.dj2 + ** + ** Copyright (c) 1998 Hartmut Schirmer & Gary Sands + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* +** NOTE: The src/depend.dj2 file in the GRX v2.3 archive is +** a dummy file -- If you want to use this utility, run +** +** ...\SRC> make -f makefile.dj2 dep +** +** to create a real dependency file for DJGPP v2 +*/ + + +#include +#include +#include +#include + +#define DJGPP_DEP "depend.dj2" +#define WATC_MAKE "makefile.wat" + +#define DBGPRINT "dbgprint.obj" + +typedef struct _objs { + char *name; + struct _objs *next; +} OBJLIST; + +char *WatcomFiles[] = { + "utils\\watcom32", + NULL +}; + +char *IgnoredFiles[] = { + NULL +}; + +OBJLIST *objs = NULL; + +char *strgsave(char *s) { + int len = strlen(s); + char *ns = malloc(sizeof(char)*(len+1)); + assert(ns != NULL); + strcpy(ns,s); + return ns; +} + +void double_entry(char *name) { + fprintf(stderr, "object file %s multiple defined !\n", name); + exit(1); +} + +void add2objlist(OBJLIST **root, char *ns, char **ignore) { + OBJLIST *p, *q, *neu = NULL; + int scmp; + + if (ignore) { + while (*ignore) { + if (strcmp(*ignore, ns) == 0) return; + ++ignore; + } + } + neu = malloc(sizeof(OBJLIST)); + assert(neu != NULL); + neu->name = strgsave(ns); + neu->next = NULL; + if (*root == NULL) { + *root = neu; + return; + } else + scmp = strcmp(ns, (*root)->name); + if (scmp < 0) { + neu ->next = *root; + *root = neu; + return; + } + if (scmp == 0) double_entry(ns); + p = *root; + q = p->next; + while (q) { + scmp = strcmp(ns, q->name); + if (scmp < 0) { + neu->next = q; + p->next = neu; + return; + } + if (scmp == 0) double_entry(ns); + p = q; + q = q->next; + } + p->next = neu; +} + +void print_rule(FILE *makefile, char *n) { + char *cp; + + cp = strrchr(n, '\\'); + if (!cp) cp = n; else ++cp; + fprintf(makefile, ".\\%s.obj : .\\",cp); + cp = n; + if (strncmp("..\\",cp,3) == 0) { + cp += 3; + } else { + fprintf(makefile, "src\\"); + } + fprintf(makefile, "%s.c .AUTODEPEND\n", cp); + fprintf(makefile, "\t$(CC) $[@ $(CC_OPTS)\n\n"); +} + +int main(void) { + FILE *makefile, *depend; + OBJLIST *olp; + char *cp, **cpp; + int len, first, nlen; + + cpp = WatcomFiles; + while (*cpp) { + add2objlist(&objs, *cpp, NULL); + cpp++; + } + + depend = fopen(DJGPP_DEP, "rt"); + assert(depend != NULL); + while (!feof(depend)) { + char line[150]; + if (fgets(line, 150-4, depend) != line) break; + cp = strchr(line, ':'); + if (cp) { + *cp = '\0'; + cp = strrchr(line, '.'); + if (cp) + *cp = '\0'; + cp = strchr(line, '/'); + while (cp) { + *cp = '\\'; + cp = strchr(cp, '/'); + } + add2objlist(&objs, line, IgnoredFiles); + } + } + fclose(depend); + makefile = fopen(WATC_MAKE, "wt"); + assert(makefile != NULL); + fprintf(makefile, "!define BLANK \"\"\n\n" + "## Object Files\n"); + len = fprintf(makefile, "OBJS ="); + olp = objs; + while (olp != NULL) { + cp = strrchr(olp->name, '\\'); + if (!cp) cp = olp->name; else ++cp; + nlen = 3 + strlen(cp) + 4; + if (nlen+len > 75) { + fprintf(makefile, " &\n"); + len = 0; + } + len += fprintf(makefile, " .\\%s.obj", cp); + olp = olp->next; + } + fprintf(makefile, "\n"); + fprintf(makefile, "!ifdef DEBUG\n" + "OBJS += .\\" DBGPRINT "\n" + "!endif\n" + "OBJS += .AUTODEPEND\n\n"); + fprintf(makefile, "## implicit rules do not seem to work with wmake - it complains about\n"); + fprintf(makefile, "## no default action???\n"); + fprintf(makefile, ".c.obj:\n"); + fprintf(makefile, "\t$(CC) $[@ $(CC_OPTS)\n\n"); + fprintf(makefile, "## Rules\n"); + olp = objs; + while (olp != NULL) { + print_rule(makefile, olp->name); + olp = olp->next; + } + print_rule(makefile, DBGPRINT); + + fprintf(makefile, "## wat32mak.lb1 is a text file with the names of all the object files\n"); + fprintf(makefile, "## this gets around DOS command line length limit\n\n"); + fprintf(makefile, "$(GRXLIB) : $(OBJS)\n" + " %%create wat32mak.lb1\n"); + len = fprintf(makefile, "!ifneq BLANK \""); + olp = objs; + first = 1; + while (olp != NULL) { + cp = strrchr(olp->name, '\\'); + if (!cp) cp = olp->name; else ++cp; + if (!first) { + fprintf(makefile, " "); + ++len; + } + first = 0; + nlen = strlen(cp) + 4; + if (len+nlen > 75) { + fprintf(makefile, "&\n"); + len = 0; + } + len += fprintf(makefile, "%s.obj", cp); + olp = olp->next; + } + fprintf(makefile, "\"\n"); + len = fprintf(makefile, " @for %%i in ("); + olp = objs; + first = 1; + while (olp != NULL) { + cp = strrchr(olp->name, '\\'); + if (!cp) cp = olp->name; else ++cp; + if (!first) { + fprintf(makefile, " "); + ++len; + } + first = 0; + nlen = strlen(cp) + 4; + if (len+nlen > 75) { + fprintf(makefile, "&\n"); + len = 0; + } + len += fprintf(makefile, "%s.obj", cp); + olp = olp->next; + } + if (len > 40) fprintf(makefile, "&\n"); + fprintf(makefile, ") do @%%append wat32mak.lb1 +'%%i'\n"); + fprintf(makefile, "!endif\n"); + fprintf(makefile, "!ifdef DEBUG\n"); + fprintf(makefile, "@for %%i in (" DBGPRINT ") do @%%append wat32mak.lb1 +'%%i'\n"); + fprintf(makefile, "!endif\n"); + fprintf(makefile, "!ifneq BLANK \"\"\n"); + fprintf(makefile, " @for %%i in () do @%%append wat32mak.lb1 +'%%i'\n"); + fprintf(makefile, "!endif\n"); + fprintf(makefile, " $(LIB) $(LIB_OPTS) $(GRXLIB) @wat32mak.lb1\n"); + + fclose(makefile); + return 0; +} diff --git a/thirdparty/grx249/src/vdrivers/ati28800.c b/thirdparty/grx249/src/vdrivers/ati28800.c new file mode 100644 index 0000000..b753f99 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/ati28800.c @@ -0,0 +1,89 @@ +/** + ** ati2880.c ---- ATI 28800 VGA (The SVGA part on MACH8, etc..) driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "ioport.h" +#include "memmode.h" + +static void setbank(int bk) +{ + outport_w(0x1ce,(((bk & 7) << 13) | ((bk & 7) << 9) | 0xb2)); +} + +static void setrwbanks(int rb,int wb) +{ + outport_w(0x1ce,(((rb & 7) << 13) | ((wb & 7) << 9) | 0xb2)); +} + +static GrVideoModeExt gr4ext = { + GR_frameSVGA4, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + _GrViDrvLoadColorVGA4 /* color loader */ +}; + +static GrVideoModeExt gr8ext = { + GR_frameSVGA8, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + GR_VMODEF_FAST_SVGA8, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + _GrViDrvLoadColorVGA8 /* color loader */ +}; + +static GrVideoMode modes[] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + { TRUE, 4, 132, 25, 0x23, 264, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 132, 28, 0x23, 264, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 132, 44, 0x33, 264, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 132, 50, 0x23, 264, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 800, 600, 0x54, 100, 0, &gr4ext }, + { TRUE, 4, 1024, 768, 0x55, 128, 0, &gr4ext }, + { TRUE, 8, 640, 480, 0x62, 640, 0, &gr8ext }, + { TRUE, 8, 800, 600, 0x63, 800, 0, &gr8ext } +}; + +GrVideoDriver _GrVideoDriverATI28800 = { + "ati28800", /* name */ + GR_VGA, /* adapter type */ + &_GrVideoDriverSTDVGA, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + NULL, /* detection routine */ + _GrViDrvInitEGAVGA, /* initialization routine */ + _GrViDrvResetEGAVGA, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/cl5426.c b/thirdparty/grx249/src/vdrivers/cl5426.c new file mode 100644 index 0000000..4fb894b --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/cl5426.c @@ -0,0 +1,136 @@ +/** + ** cl5426.c ---- Cirrus 5426 (or higher) driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "ioport.h" +#include "memmode.h" + +static void setbank(int bk) +{ + outport_w(0x3ce,((bk << 12) | 9)); +} + +static GrVideoModeExt gr4ext = { + GR_frameSVGA4, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + NULL, /* double bank set function */ + _GrViDrvLoadColorVGA4 /* color loader */ +}; + +static GrVideoModeExt gr8ext = { + GR_frameSVGA8, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + GR_VMODEF_FAST_SVGA8, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + NULL, /* double bank set function */ + _GrViDrvLoadColorVGA8 /* color loader */ +}; + +static GrVideoModeExt gr15ext = { + GR_frameSVGA16, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 5, 5, 5 }, /* color precisions */ + { 10, 5, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoModeExt gr16ext = { + GR_frameSVGA16, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 5, 6, 5 }, /* color precisions */ + { 11, 5, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoModeExt gr24ext = { + GR_frameSVGA24, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 8, 8, 8 }, /* color precisions */ + { 16, 8, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoMode modes[] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + { TRUE, 4, 132, 25, 0x14, 264, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 132, 28, 0x14, 264, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 132, 43, 0x54, 264, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 132, 50, 0x14, 264, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 800, 600, 0x102, 100, 0, &gr4ext }, + { TRUE, 4, 1024, 768, 0x104, 128, 0, &gr4ext }, + { TRUE, 4, 1280, 1024, 0x6c, 160, 0, &gr4ext /* ????? */ }, + { TRUE, 8, 640, 480, 0x101, 640, 0, &gr8ext }, + { TRUE, 8, 800, 600, 0x103, 800, 0, &gr8ext }, + { TRUE, 8, 1024, 768, 0x105, 1024, 0, &gr8ext }, + { TRUE, 15, 640, 480, 0x110, 1280, 0, &gr15ext }, + { TRUE, 15, 800, 600, 0x113, 1600, 0, &gr15ext }, + { TRUE, 16, 640, 480, 0x111, 1280, 0, &gr16ext }, + { TRUE, 16, 800, 600, 0x114, 1600, 0, &gr16ext }, + { TRUE, 24, 640, 480, 0x112, 2048, 0, &gr24ext } +}; + +GrVideoDriver _GrVideoDriverCL5426 = { + "cl5426", /* name */ + GR_VGA, /* adapter type */ + &_GrVideoDriverSTDVGA, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + NULL, /* detection routine */ + _GrViDrvInitEGAVGA, /* initialization routine */ + _GrViDrvResetEGAVGA, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/et4000.c b/thirdparty/grx249/src/vdrivers/et4000.c new file mode 100644 index 0000000..c8c382e --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/et4000.c @@ -0,0 +1,222 @@ +/** + ** et400.cC ---- Tseng ET4000 video driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Christian Domp (alma.student.uni-kl.de) + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "int86.h" +#include "ioport.h" +#include "memfill.h" + +static void setbank(int bk) +{ + outport_b(0x3cd,((bk & 15) | ((bk & 15) << 4))); +} + +static void setrwbanks(int rb,int wb) +{ + outport_b(0x3cd,((wb & 15) | ((rb & 15) << 4))); +} + +static GrVideoModeExt gr4ext = { + GR_frameSVGA4, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + _GrViDrvLoadColorVGA4 /* color loader */ +}; + +static GrVideoModeExt gr8ext = { + GR_frameSVGA8, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + GR_VMODEF_FAST_SVGA8, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + _GrViDrvLoadColorVGA8 /* color loader */ +}; + +static int setmode15(GrVideoMode *mp,int noclear) +{ + if(_GrViDrvSetEGAVGAmode(mp,noclear)) { + Int86Regs r; + sttzero(&r); + IREG_AX(r) = 0x10f0; + IREG_BX(r) = mp->mode; + int10(&r); + if(IREG_AX(r) == 0x10) return(TRUE); + } + return(FALSE); +} + +static GrVideoModeExt gr15ext = { + GR_frameSVGA16, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 5, 5, 5 }, /* color precisions */ + { 10, 5, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + setmode15, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + NULL /* color loader */ +}; + +static int setmode16(GrVideoMode *mp,int noclear) +{ + if(setmode15(mp,noclear)) { /* set 15-bit mode */ + Int86Regs r; + sttzero(&r); + IREG_AX(r) = 0x10f2; + IREG_BX(r) = 2; + int10(&r); /* switch to 16-bit mode */ + if(IREG_AX(r) == 0x10) return(TRUE); + } + return(FALSE); +} + +static GrVideoModeExt gr16ext = { + GR_frameSVGA16, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 5, 6, 5 }, /* color precisions */ + { 11, 5, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + setmode16, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + NULL /* color loader */ +}; + +static int setmode24(GrVideoMode *mp,int noclear) +{ + if(_GrViDrvSetEGAVGAmode(mp,noclear)) { + Int86Regs r; + sttzero(&r); + IREG_AX(r) = 0x10f0; + IREG_BX(r) = (mp->mode<<8)|0xff; + int10(&r); + if(IREG_AX(r) == 0x10) return(TRUE); + } + return(FALSE); +} + +static GrVideoModeExt gr24ext = { + GR_frameSVGA24, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 8, 8, 8 }, /* color precisions */ + { 16, 8, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + setmode24, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoMode modes[] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + { TRUE, 4, 80, 60, 0x26, 160, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 100, 40, 0x2a, 200, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 132, 25, 0x23, 264, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 132, 28, 0x24, 264, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 132, 44, 0x22, 264, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 132, 50, 0x61, 264, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 132, 60, 0x21, 264, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 800, 600, 0x29, 100, 0, &gr4ext }, + { TRUE, 4, 1024, 768, 0x37, 128, 0, &gr4ext }, + { TRUE, 4, 1280, 1024, 0x3d, 160, 0, &gr4ext }, + { TRUE, 8, 640, 350, 0x2d, 640, 0, &gr8ext }, + { TRUE, 8, 640, 400, 0x2f, 640, 0, &gr8ext }, + { TRUE, 8, 640, 480, 0x2e, 640, 0, &gr8ext }, + { TRUE, 8, 800, 600, 0x30, 800, 0, &gr8ext }, + { TRUE, 8, 1024, 768, 0x38, 1024, 0, &gr8ext }, + { FALSE, 15, 320, 200, 0x13, 640, 0, &gr15ext }, + { FALSE, 15, 640, 350, 0x2d, 1280, 0, &gr15ext }, + { FALSE, 15, 640, 400, 0x2f, 1280, 0, &gr15ext }, + { FALSE, 15, 640, 480, 0x2e, 1280, 0, &gr15ext }, + { FALSE, 15, 800, 600, 0x30, 1600, 0, &gr15ext }, + { FALSE, 16, 320, 200, 0x13, 640, 0, &gr16ext }, + { FALSE, 16, 640, 350, 0x2d, 1280, 0, &gr16ext }, + { FALSE, 16, 640, 400, 0x2f, 1280, 0, &gr16ext }, + { FALSE, 16, 640, 480, 0x2e, 1280, 0, &gr16ext }, + { FALSE, 16, 800, 600, 0x30, 1600, 0, &gr16ext }, + { FALSE, 24, 640, 350, 0x2d, 1920, 0, &gr24ext }, + { FALSE, 24, 640, 400, 0x2f, 1920, 0, &gr24ext }, + { FALSE, 24, 640, 480, 0x2e, 1920, 0, &gr24ext } +}; + +static int init(char *options) +{ + if(_GrViDrvInitEGAVGA(options)) { + Int86Regs r; + sttzero(&r); + IREG_AX(r) = 0x10f1; + int10(&r); + if((IREG_AX(r) == 0x10) && (IREG_BX(r) >= 1)) { + GrVideoMode *mp = &modes[itemsof(modes)]; + while(--mp >= modes) { + switch(mp->bpp) { + case 24: + if(IREG_BX(r) < 3) break; + case 16: + if(IREG_BX(r) < 2) break; + case 15: + mp->present = TRUE; + } + } + } + return(TRUE); + } + return(FALSE); +} + +GrVideoDriver _GrVideoDriverET4000 = { + "et4000", /* name */ + GR_VGA, /* adapter type */ + &_GrVideoDriverSTDVGA, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + NULL, /* detection routine */ + init, /* initialization routine */ + _GrViDrvResetEGAVGA, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/herc.c b/thirdparty/grx249/src/vdrivers/herc.c new file mode 100644 index 0000000..da8e9c0 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/herc.c @@ -0,0 +1,194 @@ +/** + ** herc.c ---- Hercules video driver + ** + ** Author: Ulrich Leodolter + ** E-mail: ulrich@lab1.psy.univie.ac.at + ** Date: Tue Nov 14 15:55:56 1995 + ** Comment: Driver code partly from X11R6/XFree86 (see below) + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/mono/drivers/hercules/hercules.c,v 3.2 1994/09/23 10:18:52 dawes Exp $ */ +/* + * MONO: Driver family for interlaced and banked monochrome video adaptors + * Pascal Haible 8/93, 3/94, 4/94 haible@IZFM.Uni-Stuttgart.DE + * + * mono/drivers/hercules + * + * original: + * hga2/drivers/hga6845.c + * + * Author: Davor Matic, dmatic@athena.mit.edu + * + * heavily edited for R6 by + * Pascal Haible 4/94 haible@IZFM.Uni-Stuttgart.DE + * + */ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "int86.h" +#include "ioport.h" +#include "memfill.h" + +/* + * Define the generic HGA I/O Ports + */ +#define HGA_INDEX 0x3B4 +#define HGA_DATA 0x3B5 +#define HGA_MODE 0x3B8 +#define HGA_STATUS 0x3BA +#define HGA_CONFIG 0x3BF + +/* + * Since the conf and mode registers are write only, we need to keep + * a local copy of the state here. The initial state is assumed to be: + * conf: enable setting of graphics mode, and disable page one + * (allows coexistence with a color graphics board) + * mode: text, deactivate screen, enable text blink, and page zero at 0xB0000 + */ +static unsigned char static_config = 0x01; +static unsigned char static_mode = 0x20; + +/* + * Since the table of 6845 registers is write only, we need to keep + * a local copy of the state here. The initial state is assumed to + * be 80x25 text mode. + */ +static unsigned char + static_tbl[] = {0x61, 0x50, 0x52, 0x0F, 0x19, 0x06, 0x19, 0x19, + 0x02, 0x0D, 0x0B, 0x0C, 0x00, 0x00, 0x00, 0x28}; + +static unsigned char init_config = 0x03; +static unsigned char init_mode = 0x0A; +static unsigned char /* 720x348 graphics mode parameters */ + init_tbl[] = {0x35, 0x2D, 0x2E, 0x07, 0x5B, 0x02, 0x57, 0x57, + 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A}; +/* + * Video ram size in Kbytes + */ +static int videoRam = 64; + +static int setmode(GrVideoMode *mp,int noclear) +{ + int i; + + if (noclear == FALSE) { + long far *p; + long far *q; + + p = (long far *)LINP_PTR(mp->extinfo->frame); + q = p + (videoRam * 1024) / sizeof(*p); + setup_far_selector (LINP_SEL(mp->extinfo->frame)); + for (; p < q; p++) poke_l_f(p,0L); + } + outport_b (HGA_CONFIG, static_config = init_config); + outport_b (HGA_MODE, static_mode = init_mode); + for (i = 0; i < 16; i++) { + outport_b (HGA_INDEX, i); + outport_b (HGA_DATA, static_tbl[i] = init_tbl[i]); + } + return(TRUE); +} + +static void setbank(int bk) +{ +} + +static void setrwbanks(int rb,int wb) +{ +} + +static void loadcolor (int c,int r,int g,int b) +{ +} + +static GrVideoModeExt grherc1ext = { + GR_frameHERC1, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xb000,0), /* frame buffer address */ + { 1, 1, 1 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + loadcolor, /* color loader */ +}; + +static GrVideoMode modes[] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + { TRUE, 1, 80, 25, 0x07, 160, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 1, 720, 348, 0x00, 92, 0, &grherc1ext } +}; + +static int detect (void) +{ +#define DSP_VSYNC_MASK 0x80 +#define DSP_ID_MASK 0x70 + unsigned char dsp, dsp_old; + int i, cnt; + + /* + * Checks if there is a HGA 6845 based bard in the system. + * The following loop tries to see if the Hercules display + * status port register is counting vertical syncs (50Hz). + */ + cnt = 0; + dsp_old = inport_b(HGA_STATUS) & DSP_VSYNC_MASK; + for (i = 0; i < 0x100; i++) { + int j; + for(j = 0; j < 0x100; j++) { + dsp = inport_b(HGA_STATUS) & DSP_VSYNC_MASK; + if (dsp != dsp_old) + cnt++; + dsp_old = dsp; + } + } + + /* If there are active sync changes, we found a Hercules board. */ + if (cnt) { + videoRam = 64; + + /* The Plus and InColor versions have an ID code as well. */ + dsp = inport_b(HGA_STATUS) & DSP_ID_MASK; + switch(dsp) { + case 0x10: /* Plus */ + videoRam = 64; + break; + case 0x50: /* InColor */ + videoRam = 256; + break; + } + } else { /* there is no hga card */ + return(FALSE); + } + return(TRUE); +} + +GrVideoDriver _GrVideoDriverHERC = { + "herc", /* name */ + GR_HERC, /* adapter type */ + NULL, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + detect, /* detection routine */ + NULL, /* initialization routine */ + _GrViDrvResetEGAVGA, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/mach64.c b/thirdparty/grx249/src/vdrivers/mach64.c new file mode 100644 index 0000000..3e947e2 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/mach64.c @@ -0,0 +1,172 @@ +/** + ** mach64.c ---- ATI MACH64 driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "highlow.h" +#include "ioport.h" +#include "memmode.h" + +static void setbank(int bk) +{ + register unsigned b1; + if(inport_b(0x6aec) & 4) { + bk <<= 1; + b1 = bk+1; + outport_b(0x56ec,bk); + outport_b(0x56ee,b1); + outport_b(0x5aec,bk); + outport_b(0x5aee,b1); + } else { + b1 = (GR_int16u)(bk&7); + b1 = ( ((b1<<4)+b1) << 9) + 0xb2; + outport_w(0x1ce,b1); + } +} + +static void setrwbanks(int rb,int wb) +{ + if(inport_b(0x6aec) & 4) { + wb <<= 1; + outport_b(0x56ec,(wb + 0)); + outport_b(0x56ee,(wb + 1)); + rb <<= 1; + outport_b(0x5aec,(rb + 0)); + outport_b(0x5aee,(rb + 1)); + } else { + register unsigned b = ((((rb&7) << 4) + (wb&7)) << 9) + 0xb2; + outport_w(0x1ce,b); + } +} + +static GrVideoModeExt gr4ext = { + GR_frameSVGA4, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + _GrViDrvLoadColorVGA4 /* color loader */ +}; + +static GrVideoModeExt gr8ext = { + GR_frameSVGA8, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + GR_VMODEF_FAST_SVGA8, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + _GrViDrvLoadColorVGA8 /* color loader */ +}; + +static GrVideoModeExt gr15ext = { + GR_frameSVGA16, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 5, 5, 5 }, /* color precisions */ + { 10, 5, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoModeExt gr16ext = { + GR_frameSVGA16, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 5, 6, 5 }, /* color precisions */ + { 11, 5, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoModeExt gr24ext = { + GR_frameSVGA24, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 8, 8, 8 }, /* color precisions */ + { 16, 8, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoMode modes[] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + { TRUE, 4, 100, 25, 0x21, 200, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 100, 28, 0x21, 200, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 100, 30, 0x22, 200, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 100, 34, 0x22, 200, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 100, 50, 0x21, 200, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 132, 25, 0x23, 264, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 132, 28, 0x23, 264, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 132, 44, 0x33, 264, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 132, 50, 0x23, 264, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 800, 600, 0x102, 100, 0, &gr4ext }, + { TRUE, 4, 1024, 768, 0x104, 128, 0, &gr4ext }, + { TRUE, 8, 640, 480, 0x101, 640, 0, &gr8ext }, + { TRUE, 8, 800, 600, 0x103, 800, 0, &gr8ext }, + { TRUE, 8, 1024, 768, 0x105, 1024, 0, &gr8ext }, + { TRUE, 8, 1280, 1024, 0x107, 1280, 0, &gr8ext }, + { TRUE, 15, 640, 480, 0x110, 1280, 0, &gr15ext }, + { TRUE, 15, 800, 600, 0x113, 1600, 0, &gr15ext }, + { TRUE, 15, 1024, 768, 0x116, 2048, 0, &gr15ext }, + { TRUE, 16, 640, 480, 0x111, 1280, 0, &gr16ext }, + { TRUE, 16, 800, 600, 0x114, 1600, 0, &gr16ext }, + { TRUE, 16, 1024, 768, 0x117, 2048, 0, &gr16ext }, + { TRUE, 24, 640, 480, 0x112, 1920, 0, &gr24ext }, + { TRUE, 24, 800, 600, 0x115, 2400, 0, &gr24ext } +}; + +GrVideoDriver _GrVideoDriverMACH64 = { + "mach64", /* name */ + GR_VGA, /* adapter type */ + &_GrVideoDriverSTDVGA, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + NULL, /* detection routine */ + _GrViDrvInitEGAVGA, /* initialization routine */ + _GrViDrvResetEGAVGA, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/s3.c b/thirdparty/grx249/src/vdrivers/s3.c new file mode 100644 index 0000000..5c1407c --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/s3.c @@ -0,0 +1,197 @@ +/** + ** s3.c ---- the GRX 2.0 S3 driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + **/ + +#include + +#include "libgrx.h" +#include "grdriver.h" +#include "memcopy.h" +#include "ioport.h" +#include "highlow.h" + +extern int _GrVidDrvVESAbanksft; + +/* -------------------------------------------------------------------- */ +/* direct register access banking. Adopted from code written by Finn */ +/* Thoegersen (finth@datashopper.dk) and taken from whatvga v2.20 */ + +#define CRTC 0x3d4 + +#define WriteIndexed(pt,inx,val) outport_w((pt),highlow((val),(inx))) + +#ifdef __GNUC__ +/* read register PT index INX */ +#define ReadIndexed(pt,inx) ({ \ + outport_b((pt),(inx)); \ + (unsigned char) inport_b((pt)+1); \ +}) +#else +static INLINE +unsigned char ReadIndexed(unsigned short pt, unsigned char inx) { + /* read register PT index INX */ + outport_b(pt,inx); + return (unsigned char) inport_b(pt+1); +} +#endif + +/* In register PT index INX sets the bits set in VAL */ +#define SetIndexed(pt,inx,val) do { \ + register unsigned char _temp_val_ = ReadIndexed((pt),(inx)); \ + _temp_val_ |= (val); \ + WriteIndexed((pt), (inx), _temp_val_); \ + } while (0) + +/* In register PT index INX sets +** the bits in MASK as in NWV the other are left unchanged */ +#define ModifyIndexed(pt,inx,mask,nwv) do { \ + register unsigned char _temp_val_ = ReadIndexed((pt),(inx)); \ + _temp_val_ = (_temp_val_ & ~(mask)) | ( (nwv) & (mask) ); \ + WriteIndexed((pt), (inx), _temp_val_); \ + } while (0) + +static int TestIndexed(unsigned short pt, unsigned char rg, unsigned char msk) +{ /* Returns TRUE if the bits in MSK of register PT index RG are read/writable */ + unsigned char old,nw1,nw2; + + old = ReadIndexed(pt,rg); + WriteIndexed(pt,rg,old & ~msk); + nw1 = ReadIndexed(pt,rg) & msk; + WriteIndexed(pt,rg,old | msk); + nw2 = ReadIndexed(pt,rg) & msk; + WriteIndexed(pt,rg,old); + return (nw1==0) && (nw2==msk); +} + +static unsigned char s3_revision(void) { + unsigned char res = 0; + WriteIndexed(CRTC,0x38,0); + if (!TestIndexed(CRTC,0x35,0x0F)) { + WriteIndexed(CRTC,0x38,0x48); + if (TestIndexed(CRTC,0x35,0x0F)) { + res = ReadIndexed(CRTC,0x30); + } + } + return res; +} + +typedef void (*BANKINGFUNC)(int bk); + +/* no shift required */ +static void setbank_864_0(int bk) { + WriteIndexed(CRTC,0x39,0xA5); + WriteIndexed(CRTC,0x6A, bk); + WriteIndexed(CRTC,0x39,0x5A); +} +/* general bank shift */ +static void setbank_864(int bk) { + WriteIndexed(CRTC,0x39,0xA5); + bk <<= _GrVidDrvVESAbanksft; + WriteIndexed(CRTC,0x6A, bk); + WriteIndexed(CRTC,0x39,0x5A); +} + +static void setbank_801_0(int bk) { + WriteIndexed(CRTC,0x39,0xA5); + WriteIndexed(CRTC,0x38,0x48); + /* SetIndexed(CRTC,0x31,9); memory interface should be set by bios */ + ModifyIndexed(CRTC,0x35,0x0F,bk); + ModifyIndexed(CRTC,0x51,0x0C,bk>>2); + WriteIndexed(CRTC,0x38,0); + WriteIndexed(CRTC,0x39,0x5A); +} +static void setbank_801(int bk) { + WriteIndexed(CRTC,0x39,0xA5); + WriteIndexed(CRTC,0x38,0x48); + /* SetIndexed(CRTC,0x31,9); memory interface should be set by bios */ + bk <<= _GrVidDrvVESAbanksft; + ModifyIndexed(CRTC,0x35,0x0F,bk); + ModifyIndexed(CRTC,0x51,0x0C,bk>>2); + WriteIndexed(CRTC,0x38,0); + WriteIndexed(CRTC,0x39,0x5A); +} + +static void setbank_911_0(int bk) { + WriteIndexed(CRTC,0x39,0xA5); + WriteIndexed(CRTC,0x38,0x48); + /* SetIndexed(CRTC,0x31,9); memory interface should be set by bios */ + bk <<= _GrVidDrvVESAbanksft; + ModifyIndexed(CRTC,0x35,0x0F, bk); + WriteIndexed(CRTC,0x38,0); + WriteIndexed(CRTC,0x39,0x5A); +} +static void setbank_911(int bk) { + WriteIndexed(CRTC,0x39,0xA5); + WriteIndexed(CRTC,0x38,0x48); + /* SetIndexed(CRTC,0x31,9); memory interface should be set by bios */ + bk <<= _GrVidDrvVESAbanksft; + ModifyIndexed(CRTC,0x35,0x0F, bk); + WriteIndexed(CRTC,0x38,0); + WriteIndexed(CRTC,0x39,0x5A); +} + +static BANKINGFUNC banktab[6] = { + /* _GrVidDrvVESAbanksft == 0 */ /* _GrVidDrvVESAbanksft != 0*/ + setbank_864_0, setbank_864, + setbank_801_0, setbank_801, + setbank_911_0, setbank_911 +}; + +static int init(char *options) { + int res, s3, i, bf; + + res = _GrVideoDriverVESA.init(options); + _GrVideoDriverS3.modes = _GrVideoDriverVESA.modes; + _GrVideoDriverS3.nmodes = _GrVideoDriverVESA.nmodes; + s3 = s3_revision(); + if (s3 >= 0xc0) bf = 0; /* 864 or newer */ else + if (s3 >= 0x90) bf = 2; /* 801 or newer */ else + if (s3 >= 0x80) bf = 4; /* 911 or newer */ else { + sttcopy(&_GrVideoDriverS3, &_GrVideoDriverVESA); + return res; + } + if (_GrVidDrvVESAbanksft) ++bf; + + /* step through all modes and select S3 banking */ + for (i=0; i < _GrVideoDriverS3.nmodes; ++i) { + GrVideoMode *mp = &_GrVideoDriverS3.modes[i]; + if (mp->bpp >= 8 && mp->extinfo) { + mp->extinfo->setbank = banktab[bf]; + mp->extinfo->setrwbanks = NULL; + } + } + return res; +} + +static void reset(void) { + _GrVideoDriverVESA.reset(); +} + +GrVideoDriver _GrVideoDriverS3 = { + "S3", /* name */ + GR_VGA, /* adapter type */ + &_GrVideoDriverSTDVGA, /* inherit modes from this driver */ + NULL, /* mode table */ + 0, /* # of modes */ + NULL, /* detection routine */ + init, /* initialization routine */ + reset, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; diff --git a/thirdparty/grx249/src/vdrivers/stdega.c b/thirdparty/grx249/src/vdrivers/stdega.c new file mode 100644 index 0000000..9a9949c --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/stdega.c @@ -0,0 +1,94 @@ +/** + ** stdega.c ---- the standard EGA driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "int86.h" +#include "memfill.h" + +void _GrViDrvLoadColorEGA4(int c,int r,int g,int b) +{ + Int86Regs rg; + sttzero(&rg); + IREG_AX(rg) = 0x1000; + IREG_BX(rg) = c & 0x0f; + IREG_BX(rg) |= ((r & 0x40) << 7) | ((r & 0x80) << 3); + IREG_BX(rg) |= ((g & 0x40) << 6) | ((g & 0x80) << 2); + IREG_BX(rg) |= ((b & 0x40) << 5) | ((b & 0x80) << 1); + int10(&rg); +} + +static GrVideoModeExt gr1ext = { + GR_frameEGAVGA1, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 1, 1, 1 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + _GrViDrvLoadColorEGA4 /* color loader */ +}; + +static GrVideoModeExt gr4ext = { + GR_frameEGA4, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 2, 2, 2 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + _GrViDrvLoadColorEGA4 /* color loader */ +}; + +static GrVideoMode modes[] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + { TRUE, 1, 80, 25, 0x07, 160, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 1, 80, 43, 0x07, 160, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 40, 25, 0x01, 80, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 80, 25, 0x03, 160, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 80, 43, 0x03, 160, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 1, 320, 200, 0x0d, 40, 0, &gr1ext }, + { TRUE, 1, 640, 200, 0x0e, 80, 0, &gr1ext }, + { TRUE, 1, 640, 350, 0x10, 80, 0, &gr1ext }, + { TRUE, 4, 320, 200, 0x0d, 40, 0, &gr4ext }, + { TRUE, 4, 640, 200, 0x0e, 80, 0, &gr4ext }, + { TRUE, 4, 640, 350, 0x10, 80, 0, &gr4ext } +}; + +GrVideoDriver _GrVideoDriverSTDEGA = { + "stdega", /* name */ + GR_EGA, /* adapter type */ + NULL, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + _GrViDrvDetectEGA, /* detection routine */ + _GrViDrvInitEGAVGA, /* initialization routine */ + _GrViDrvResetEGAVGA, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/stdvga.c b/thirdparty/grx249/src/vdrivers/stdvga.c new file mode 100644 index 0000000..cebd336 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/stdvga.c @@ -0,0 +1,350 @@ +/** + ** stdvga.c ---- the standard VGA driver + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Christian Domp (alma.student.uni-kl.de) + **/ + +#include + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "int86.h" +#include "memfill.h" +#include "mempeek.h" +#include "ioport.h" + +/* so that GCC in its infinite wisdom does not optimize things away.. */ +static volatile unsigned char junk; + +static int DACshift = 2; + +void _GrViDrvSetDACshift(int shift) { + GRX_ENTER(); + DACshift = shift; + GRX_LEAVE(); +} + +void _GrViDrvLoadColorVGA8(int c,int r,int g,int b) { + GRX_ENTER(); + int_disable(); + outport_b(0x3c8,c); + junk += inport_b(0x80); + outport_b(0x3c9,((unsigned char)r >> DACshift)); + junk += inport_b(0x80); + outport_b(0x3c9,((unsigned char)g >> DACshift)); + junk += inport_b(0x80); + outport_b(0x3c9,((unsigned char)b >> DACshift)); + int_enable(); + GRX_LEAVE(); +} + +void _GrViDrvLoadColorVGA4(int c,int r,int g,int b) +{ + Int86Regs rg; + GRX_ENTER(); + sttzero(&rg); + IREG_AX(rg) = 0x1000; + IREG_BX(rg) = (c & 0x0f) | ((c & 0x0f) << 8); + int10(&rg); + _GrViDrvLoadColorVGA8(c,r,g,b); + GRX_LEAVE(); +} + +static GrVideoModeExt gr1ext = { + GR_frameEGAVGA1, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 1, 1, 1 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + _GrViDrvLoadColorVGA4 /* color loader */ +}; + +static GrVideoModeExt gr4ext = { + GR_frameSVGA4, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + _GrViDrvLoadColorVGA4 /* color loader */ +}; + +static GrVideoModeExt gr8ext = { + GR_frameSVGA8, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + _GrViDrvVESAsetVirtualSize, /* virtual size set */ + _GrViDrvVESAvirtualScroll, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + _GrViDrvLoadColorVGA8 /* color loader */ +}; + +/* ==== tweaked planar 256 color graphics modes (MODE X) ==== */ + +static struct xtweakdef { + unsigned char miscreg; + unsigned char crtc_regs[24]; +} xtweaks[] = { + { /* 320x240 */ + 0xe3, + { + 0x5f, 0x4f, 0x50, 0x82, + 0x54, 0x80, 0x0d, 0x3e, + 0x00, 0x41, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0xea, 0xac, 0xdf, 0x28, + 0x00, 0xe7, 0x06, 0xe3 + } + }, + { /* 320x400 */ + 0, /* don't need to set it */ + { + 0x5f, 0x4f, 0x50, 0x82, + 0x54, 0x80, 0xbf, 0x1f, + 0x00, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x9c, 0x8e, 0x8f, 0x28, + 0x00, 0x96, 0xb9, 0xe3 + } + }, + { /* 360x480 */ + 0xe7, + { + 0x6b, 0x59, 0x5a, 0x8e, + 0x5e, 0x8a, 0x0d, 0x3e, + 0x00, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x31, + 0xea, 0xac, 0xdf, 0x2d, + 0x00, 0xe7, 0x06, 0xe3 + } + } +}; + +static int setmodex(GrVideoMode *mp,int noclear) +{ + int res = FALSE; + GRX_ENTER(); + if(((unsigned int)mp->privdata < itemsof(xtweaks)) && + (_GrViDrvSetEGAVGAmode(mp,noclear) != FALSE)) { + struct xtweakdef *tp = &xtweaks[mp->privdata]; + unsigned int i; + /* turn off chain4 */ + outport_w(0x3c4,0x604); + if(!noclear) { + char far *ptr = LINP_PTR(mp->extinfo->frame); + int size = 0x8000U; + /* enable all planes */ + outport_w(0x3c4,((0x0f << 8) | 2)); + setup_far_selector(LINP_SEL(mp->extinfo->frame)); + rowfill_w_f(ptr,0,size); + } + /* wait for vertical retrace */ + while((inport_b(0x3da) & 8) != 0); + while((inport_b(0x3da) & 8) == 0); + int_disable(); + if(tp->miscreg) { + outport_w(0x3c4,0x100); + outport_b(0x3c2,tp->miscreg); + outport_w(0x3c4,0x300); + } + outport_w(0x3d4,(((tp->crtc_regs[17] & 0x7f) << 8) | 17)); + for(i = 0; i < itemsof(tp->crtc_regs); i++) { + outport_w(0x3d4,((tp->crtc_regs[i] << 8) | i)); + } + int_enable(); + res = TRUE; + } + GRX_LEAVE(); + return(res); +} + +static GrVideoModeExt gr8xext = { + GR_frameVGA8X, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xa000,0), /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + setmodex, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + _GrViDrvLoadColorVGA8 /* color loader */ +}; + +/* ==== tweaked text modes: 90x30, 90x34, 94x30, 94x34 ==== */ + +static unsigned short ttweaks[][16] = { + { /* 90x30 */ + 0x0c11,0x6d00,0x5901,0x5a02,0x9003,0x6004,0x8b05,0x0b06, + 0x3e07,0x4f09,0xea10,0x8c11,0xdf12,0x2d13,0xe715,0x0416 + }, + { /* 90x34 */ + 0x0c11,0x6d00,0x5901,0x5a02,0x9003,0x6004,0x8b05,0x0b06, + 0x3e07,0x4d09,0xea10,0x8c11,0xdf12,0x2d13,0xe715,0x0416 + }, + { /* 94x30 */ + 0x0c11,0x6c00,0x5d01,0x5e02,0x8f03,0x6204,0x8e05,0x0b06, + 0x3e07,0x4f09,0xea10,0x8c11,0xdf12,0x2f13,0xe715,0x0416 + }, + { /* 94x34 */ + 0x0c11,0x6c00,0x5d01,0x5e02,0x8f03,0x6204,0x8e05,0x0b06, + 0x3e07,0x4d09,0xea10,0x8c11,0xdf12,0x2f13,0xe715,0x0416 + } +}; + +static int set_tweaked_text(GrVideoMode *mp,int noclear) +{ + int res = FALSE; + GRX_ENTER(); + if(((unsigned int)mp->privdata < itemsof(ttweaks)) && + (_GrViDrvSetEGAVGAmode(mp,noclear) != FALSE)) { + unsigned int i; + /* load 8x14 font for 34 line modes */ + if(mp->height == 34) { + Int86Regs r; + sttzero(&r); + IREG_AX(r) = 0x1111; + int10(&r); + } + /* wait for vertical retrace */ + while((inport_b(0x3da) & 8) != 0); + while((inport_b(0x3da) & 8) == 0); + int_disable(); + outport_b(0x3c2,0xe7); + /* set sequencer clocking mode */ + outport_w(0x3c4,0x101); + /* reset data flip-flop to address mode */ + junk = inport_w(0x3da); + outport_b(0x3c0,0x30); + /* set mode control register */ + outport_b(0x3c0,0x04); + outport_b(0x3c0,0x33); + /* set horizontal pixel pan */ + outport_b(0x3c0,0x00); + for(i = 0; i < itemsof(ttweaks[0]); i++) { + outport_w(0x3d4,ttweaks[mp->privdata][i]); + } + setup_far_selector(LINP_SEL(0)); + /* update BIOS data area */ + poke_w_f(0x44a,mp->width); + poke_b_f(0x484,(mp->height - 1)); + poke_w_f(0x44c,(mp->width * mp->height * 2)); + int_enable(); + res = TRUE; + } + GRX_LEAVE(); + return res; +} + +static GrVideoModeExt twtext = { + GR_frameText, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xb800,0), /* frame buffer address */ + { 0, 0, 0 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + set_tweaked_text, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoMode modes[] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + { TRUE, 1, 80, 25, 0x07, 160, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 1, 80, 28, 0x07, 160, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 1, 80, 50, 0x07, 160, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 40, 25, 0x01, 80, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 80, 25, 0x03, 160, 0, &_GrViDrvEGAVGAtextModeExt }, + { TRUE, 4, 80, 28, 0x03, 160, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 80, 50, 0x03, 160, 0, &_GrViDrvEGAVGAcustomTextModeExt }, + { TRUE, 4, 90, 30, 0x03, 180, 0, &twtext }, + { TRUE, 4, 90, 34, 0x03, 180, 1, &twtext }, + { TRUE, 4, 94, 30, 0x03, 188, 2, &twtext }, + { TRUE, 4, 94, 34, 0x03, 188, 3, &twtext }, + { TRUE, 1, 320, 200, 0x0d, 40, 0, &gr1ext }, + { TRUE, 1, 640, 200, 0x0e, 80, 0, &gr1ext }, + { TRUE, 1, 640, 350, 0x10, 80, 0, &gr1ext }, + { TRUE, 1, 640, 480, 0x12, 80, 0, &gr1ext }, + { FALSE, 1, 800, 600, 0x6a, 100, 0, &gr1ext }, + { TRUE, 4, 320, 200, 0x0d, 40, 0, &gr4ext }, + { TRUE, 4, 640, 200, 0x0e, 80, 0, &gr4ext }, + { TRUE, 4, 640, 350, 0x10, 80, 0, &gr4ext }, + { TRUE, 4, 640, 480, 0x12, 80, 0, &gr4ext }, + { FALSE, 4, 800, 600, 0x6a, 100, 0, &gr4ext }, + { TRUE, 8, 320, 200, 0x13, 320, 0, &gr8ext }, + { TRUE, 8, 320, 240, 0x13, 80, 0, &gr8xext }, + { TRUE, 8, 320, 400, 0x13, 80, 1, &gr8xext }, + { TRUE, 8, 360, 480, 0x13, 90, 2, &gr8xext } +}; + +static int init(char *options) +{ + int res = FALSE; + GRX_ENTER(); + if(_GrViDrvInitEGAVGA(options)) { + if(options && (strncmp(options,"svga",4) == 0)) { + int svgamode; + GrVideoMode *mp; + if(sscanf(options,"svga=%x",&svgamode) != 1) svgamode = 0; + for(mp = modes; mp < &modes[itemsof(modes)]; mp++) { + if(mp->width == 800) { + mp->present = TRUE; + mp->mode = ((svgamode > 0x13) && (svgamode <= 0x110)) ? svgamode : 0x6a; + } + } + } + res = TRUE; + } + GRX_LEAVE(); + return res; +} + +GrVideoDriver _GrVideoDriverSTDVGA = { + "stdvga", /* name */ + GR_VGA, /* adapter type */ + NULL, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + _GrViDrvDetectVGA, /* detection routine */ + init, /* initialization routine */ + _GrViDrvResetEGAVGA, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/svgalib.c b/thirdparty/grx249/src/vdrivers/svgalib.c new file mode 100644 index 0000000..0fb61a3 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/svgalib.c @@ -0,0 +1,295 @@ +/** + ** svgalib.c ---- Linux driver, i.e. an interface to SVGALIB + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "memcopy.h" +#include "memfill.h" + +#define NUM_MODES 80 /* max # of supported modes */ +#define NUM_EXTS 15 /* max # of mode extensions */ + +static int initted = (-1); +static int initmode = 0; +static int isEGA; + +static int detect(void) +{ + if(initted < 0) { +#if 0 + /* make sure VGA will map to 64K boundary ... */ + long endmem = (long)(sbrk(0)); + if((endmem & 0xffffL) != 0) { + brk((void *)((endmem + 0xffffL) & ~0xffffL)); + } +#endif + if(vga_init() >= 0) { + initted = 1; + isEGA = (vga_getcurrentchipset() == EGA); + initmode = vga_getcurrentmode(); + } + else initted = 0; + } + return((initted > 0) ? TRUE : FALSE); +} + +static void reset(void) +{ + if(initted > 0 && vga_getcurrentmode() != initmode) + vga_setmode(initmode); +} + +static void setrwbanks(int rb,int wb) +{ + vga_setreadpage(rb); + vga_setwritepage(wb); +} + +static void loadcolor(int c,int r,int g,int b) +{ + vga_setpalette(c,(r >> 2),(g >> 2),(b >> 2)); +} + +static int setmode(GrVideoMode *mp,int noclear) +{ + vga_setmode(mp->mode); + if (mp->extinfo->flags & GR_VMODEF_LINEAR) { + if (vga_setlinearaddressing() == -1) + return(FALSE); + } + mp->extinfo->frame = (char *)vga_getgraphmem(); + return(TRUE); +} + +static int settext(GrVideoMode *mp,int noclear) +{ + vga_setmode(mp->mode); + return(TRUE); +} + +GrVideoModeExt _GrViDrvEGAVGAtextModeExt = { + GR_frameText, /* frame driver */ + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + { 6, 6, 6 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + settext, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL, /* color loader */ +}; + +static GrVideoModeExt exts[NUM_EXTS]; +static GrVideoMode modes[NUM_MODES] = { + /* pres. bpp wdt hgt mode scan priv. &ext */ + { TRUE, 4, 80, 25, TEXT, 160, 0, &_GrViDrvEGAVGAtextModeExt }, + { 0 } +}; + +static int build_video_mode( + vga_modeinfo *ip, + GrVideoMode *mp, + GrVideoModeExt *ep +){ + mp->present = TRUE; + mp->width = ip->width; + mp->height = ip->height; + mp->lineoffset = ip->linewidth; + mp->extinfo = NULL; + mp->privdata = 0; + ep->drv = NULL; + ep->frame = NULL; /* filled in after mode set */ + ep->flags = 0; + ep->setup = setmode; + ep->setvsize = NULL; /* tbd */ + ep->scroll = NULL; /* tbd */ + ep->setbank = isEGA ? NULL : vga_setpage; + ep->setrwbanks = (ip->flags & HAVE_RWPAGE) ? setrwbanks : NULL; + ep->loadcolor = NULL; + switch(ip->colors) { +#ifdef INOUTP_FRAMEDRIVERS + case 2: + mp->bpp = 1; + ep->mode = GR_frameEGAVGA1; + ep->cprec[0] = + ep->cprec[1] = + ep->cprec[2] = 1; + ep->cpos[0] = + ep->cpos[1] = + ep->cpos[2] = 0; + break; + case 16: + mp->bpp = 4; + ep->mode = isEGA ? GR_frameEGA4 : GR_frameSVGA4; + ep->cprec[0] = + ep->cprec[1] = + ep->cprec[2] = isEGA ? 2 : 6; + ep->cpos[0] = + ep->cpos[1] = + ep->cpos[2] = 0; + ep->loadcolor = loadcolor; + break; +#endif + case 256: + mp->bpp = 8; + if (ip->flags & IS_MODEX) +#ifdef INOUTP_FRAMEDRIVERS + ep->mode = GR_frameVGA8X; +#else + return(FALSE); +#endif + else + if (ip->flags & CAPABLE_LINEAR) { + ep->mode = GR_frameSVGA8_LFB; + ep->flags|= GR_VMODEF_LINEAR; + } else + ep->mode = GR_frameSVGA8; + ep->cprec[0] = + ep->cprec[1] = + ep->cprec[2] = 6; + ep->cpos[0] = + ep->cpos[1] = + ep->cpos[2] = 0; + ep->loadcolor = loadcolor; + break; + case 32*1024: + mp->bpp = 15; + if (ip->flags & CAPABLE_LINEAR) { + ep->mode = GR_frameSVGA16_LFB; + ep->flags|= GR_VMODEF_LINEAR; + } else + ep->mode = GR_frameSVGA16; + ep->cprec[0] = + ep->cprec[1] = + ep->cprec[2] = 5; + ep->cpos[0] = 10; + ep->cpos[1] = 5; + ep->cpos[2] = 0; + break; + case 64*1024: + mp->bpp = 16; + if (ip->flags & CAPABLE_LINEAR) { + ep->mode = GR_frameSVGA16_LFB; + ep->flags|= GR_VMODEF_LINEAR; + } else + ep->mode = GR_frameSVGA16; + ep->cprec[0] = 5; + ep->cprec[1] = 6; + ep->cprec[2] = 5; + ep->cpos[0] = 11; + ep->cpos[1] = 5; + ep->cpos[2] = 0; + break; + case 16*1024*1024: + mp->bpp = 24; + if (ip->flags & CAPABLE_LINEAR) { + ep->mode = GR_frameSVGA24_LFB; + ep->flags|= GR_VMODEF_LINEAR; + } else + ep->mode = GR_frameSVGA24; + ep->cprec[0] = + ep->cprec[1] = + ep->cprec[2] = 8; + ep->cpos[0] = 16; + ep->cpos[1] = 8; + ep->cpos[2] = 0; + if(ip->bytesperpixel == 3) break; + mp->bpp = 32; + ep->mode = (ip->flags & CAPABLE_LINEAR) ? GR_frameSVGA32L_LFB + : GR_frameSVGA32L; + if(!(ip->flags & RGB_MISORDERED)) break; + ep->cpos[0] = 24; + ep->cpos[1] = 16; + ep->cpos[2] = 8; + ep->mode = (ip->flags & CAPABLE_LINEAR) ? GR_frameSVGA32H_LFB + : GR_frameSVGA32H; + break; + default: + return(FALSE); + } + return(TRUE); +} + +static void add_video_mode( + GrVideoMode *mp, GrVideoModeExt *ep, + GrVideoMode **mpp,GrVideoModeExt **epp +){ + if(*mpp < &modes[NUM_MODES]) { + if(!mp->extinfo) { + GrVideoModeExt *etp = &exts[0]; + while(etp < *epp) { + if(memcmp(etp,ep,sizeof(GrVideoModeExt)) == 0) { + mp->extinfo = etp; + break; + } + etp++; + } + if(!mp->extinfo) { + if(etp >= &exts[NUM_EXTS]) return; + sttcopy(etp,ep); + mp->extinfo = etp; + *epp = ++etp; + } + } + sttcopy(*mpp,mp); + (*mpp)++; + } +} + +static int init(char *options) +{ + if(detect()) { + vga_modeinfo *mdinfo; + GrVideoMode mode,*modep = &modes[1]; + GrVideoModeExt ext, *extp = &exts[0]; + int mindex; + memzero(modep,(sizeof(modes) - sizeof(modes[0]))); + for(mindex = G320x200x16; mindex <= GLASTMODE; mindex++) { + if(!(vga_hasmode(mindex))) continue; + if(!(mdinfo = vga_getmodeinfo(mindex))) continue; + if(!(build_video_mode(mdinfo,&mode,&ext))) continue; + mode.mode = mindex; + add_video_mode(&mode,&ext,&modep,&extp); + } + _GrVideoDriverSVGALIB.adapter = isEGA ? GR_EGA : GR_VGA; + return(TRUE); + } + return(FALSE); +} + +GrVideoDriver _GrVideoDriverSVGALIB = { + "svgalib", /* name */ + GR_VGA, /* adapter type */ + NULL, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + detect, /* detection routine */ + init, /* initialization routine */ + reset, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/u_egavga.c b/thirdparty/grx249/src/vdrivers/u_egavga.c new file mode 100644 index 0000000..3c8df25 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/u_egavga.c @@ -0,0 +1,153 @@ +/** + ** u_egavga.c ---- common EGA/VGA utilities for video drivers + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "int86.h" +#include "vesa.h" +#include "memfill.h" + +int _GrViDrvDetectEGAVGA(void) +{ + Int86Regs r; + sttzero(&r); + /* check for EGA/VGA by trying to read a palette register */ + IREG_AX(r) = 0x1007; + IREG_BX(r) = 0xff00; + int10(&r); + return ( (unsigned char)IREG_BH(r) != (unsigned char)0xff ); +} + +static int detectvga(void) +{ + Int86Regs r; + sttzero(&r); + /* check for VGA by trying to read a DAC register */ + IREG_AX(r) = 0x1015; + IREG_BX(r) = 0; + IREG_CX(r) = 0xffff; + IREG_DX(r) = 0xffff; + int10(&r); + return( ( (unsigned short)(IREG_CX(r) & IREG_DX(r)) + != (unsigned short)0xffff ) ? TRUE : FALSE); +} + +int _GrViDrvDetectEGA(void) +{ + return((_GrViDrvDetectEGAVGA() && !detectvga()) ? TRUE : FALSE); +} + +int _GrViDrvDetectVGA(void) +{ + return((_GrViDrvDetectEGAVGA() && detectvga()) ? TRUE : FALSE); +} + +int _GrViDrvGetCurrentEGAVGAmode(void) +{ + Int86Regs r; + sttzero(&r); + IREG_AX(r) = VESA_FUNC + VESA_GET_MODE; + int10(&r); + if(IREG_AX(r) == VESA_SUCCESS) { + int mode = IREG_BX(r) & 0x7fff; + if(mode > 0x13) return(mode); + } + IREG_AX(r) = 0x0f00; + int10(&r); + return(IREG_AL(r) & 0x7f); +} + +static int setmode(int mode,int noclear) +{ + Int86Regs r; + sttzero(&r); + IREG_AX(r) = VESA_FUNC + VESA_SET_MODE; + IREG_BX(r) = (mode & 0x7fff) | (noclear ? 0x8000U : 0); + int10(&r); + if(IREG_AX(r) == VESA_SUCCESS) return(TRUE); + IREG_AX(r) = (mode & 0x7f) | (noclear ? 0x80U : 0); + int10(&r); + return((_GrViDrvGetCurrentEGAVGAmode() == mode) ? TRUE : FALSE); +} + +int _GrViDrvSetEGAVGAmode(GrVideoMode *mp,int noclear) +{ + return(setmode(mp->mode,noclear)); +} + +int _GrViDrvSetEGAVGAcustomTextMode(GrVideoMode *mp,int noclear) +{ + if(_GrViDrvSetEGAVGAmode(mp,noclear)) { + Int86Regs r; + sttzero(&r); + /* load 8x8 or 8x14 font */ + IREG_AX(r) = (mp->height >= 50) ? 0x1112 : 0x1111; + int10(&r); + return(TRUE); + } + return(FALSE); +} + +static int origmode = (-1); + +int _GrViDrvInitEGAVGA(char *options) +{ + if(_GrViDrvDetectEGAVGA()) { + origmode = _GrViDrvGetCurrentEGAVGAmode(); + return(TRUE); + } + return(FALSE); +} + +void _GrViDrvResetEGAVGA(void) +{ + if((origmode != (-1)) && DRVINFO->moderestore) { + setmode(origmode,FALSE); + } +} + +GrVideoModeExt _GrViDrvEGAVGAtextModeExt = { + GR_frameText, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xb800,0), /* frame buffer address */ + { 0, 0, 0 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +GrVideoModeExt _GrViDrvEGAVGAcustomTextModeExt = { + GR_frameText, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xb800,0), /* frame buffer address */ + { 0, 0, 0 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + _GrViDrvSetEGAVGAcustomTextMode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/u_vesa.c b/thirdparty/grx249/src/vdrivers/u_vesa.c new file mode 100644 index 0000000..38ef50b --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/u_vesa.c @@ -0,0 +1,225 @@ +/** + ** u_vesa.c ---- interface utility functions to VESA BIOS inquiry calls + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@xaphod.techfak.uni-kiel.d400.de) + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "vesa.h" +#include "mempeek.h" +#include "memfill.h" +#include "int86.h" + +#ifndef IREG_AX + +int _GrViDrvVESAgetVGAinfo(VESAvgaInfoBlock *ib) +{ + return(FALSE); +} +int _GrViDrvVESAgetModeInfo(int mode,VESAmodeInfoBlock *ib) +{ + return(FALSE); +} + +VESApmInfoBlock * _GrViDrvVESAgetPMinfo(void) +{ + return(NULL); +} + +#else + +#if defined(__WATCOMC__) && defined(__386__) +#define FAR _far +#else +#define FAR far +#endif /* __WATCOMC__ && __386__*/ + +int _GrViDrvVESAgetVGAinfo(VESAvgaInfoBlock *ib) +{ + static char *nmcopy = NULL; + static short *mdcopy = NULL; + Int86Regs regs; + short FAR *mp; + short *modes; + char FAR *p1; + char *p2; + int ii; + DECLARE_XFER_BUFFER(1000); + /* + * copy VBE 2.0 tag into XFER buffer + */ + setup_far_selector(LINP_SEL(XFER_BUFFER)); + p1 = (char FAR *)LINP_PTR(XFER_BUFFER); + poke_b_f(p1,'V'); ++p1; + poke_b_f(p1,'B'); ++p1; + poke_b_f(p1,'E'); ++p1; + poke_b_f(p1,'2'); ++p1; + /* + * set up registers and call interrupt + */ + sttzero(®s); + IREG_AX(regs) = VESA_FUNC + VESA_VGA_INFO; + IREG_ES(regs) = FP_SEG(XFER_BUFFER); + IREG_DI(regs) = FP_OFF(XFER_BUFFER); + int10x(®s); + if(IREG_AX(regs) != VESA_SUCCESS) { + DELETE_XFER_BUFFER; + return(FALSE); + } + /* + * copy VESA info block into accessible memory + */ + setup_far_selector(LINP_SEL(XFER_BUFFER)); + p1 = (char FAR *)LINP_PTR(XFER_BUFFER); + p2 = (char *)ib; + for(ii = sizeof(*ib); --ii >= 0; p1++,p2++) *p2 = peek_b_f(p1); + + if ( ib->VESAsignature[0] != 'V' || + ib->VESAsignature[1] != 'E' || + ib->VESAsignature[2] != 'S' || + ib->VESAsignature[3] != 'A' ) { + DELETE_XFER_BUFFER; + return(FALSE); + } + /* + * allocate space and copy mode list into accessible memory + */ + mp = LINP_PTR(MK_FP(FP86_SEG(ib->VideoModePtr),FP86_OFF(ib->VideoModePtr))); + p1 = (char FAR *)mp; + for(ii = 1; (short)peek_w_f(mp) != (short)(-1); mp++,ii++); + modes = mdcopy = realloc(mdcopy,ii * sizeof(short)); + if(!modes) { DELETE_XFER_BUFFER; return(FALSE); } + ib->VideoModePtr = modes; + mp = (short far *)p1; + for( ; --ii >= 0; mp++,modes++) *modes = peek_w_f(mp); + /* + * allocate space and copy ID string into accessible memory + */ + p1 = LINP_PTR(MK_FP(FP86_SEG(ib->OEMstringPtr),FP86_OFF(ib->OEMstringPtr))); + mp = (short FAR *)p1; + for(ii = 1; (char)peek_b_f(p1) != (char)(0); p1++,ii++); + p2 = nmcopy = realloc(nmcopy,ii * sizeof(char)); + if(!p2) { DELETE_XFER_BUFFER; return(FALSE); } + ib->OEMstringPtr = p2; + p1 = (char FAR *)mp; + for( ; --ii >= 0; p1++,p2++) *p2 = peek_b_f(p1); + DELETE_XFER_BUFFER; + return(TRUE); +} + +VESApmInfoBlock * _GrViDrvVESAgetPMinfo(void) { + Int86Regs r; + static VESApmInfoBlock *ib = NULL; + unsigned Length, ii; + char FAR *p1; + char *p2; + + sttzero(&r); + IREG_AX(r) = VESA_FUNC + VESA_PM_INTERF; + IREG_BX(r) = 0x0000; + DBGPRINTF(DBG_DRIVER,("Getting protected mode interface\n")); + int10x(&r); + if(IREG_AX(r) != VESA_SUCCESS) + return(NULL); + /* Now we have : CX = length of table and routines (bytes) + ES:DI = pointer to table + ES_DI+00: offset PM set window routine + +02: offset PM set display start + +04: offset PM set primary palette + +06: offset PM description table */ + Length = (unsigned)IREG_CX(r); + if( Length == 0) return(NULL); + ib = realloc(ib, Length + VESApmInfoBlock_BASEOFF); + if (ib == NULL) return(NULL); + + ib->RealMode_SEG = IREG_ES(r); + ib->RealMode_OFF = IREG_DI(r); + ib->PhysicalLength = IREG_CX(r); + + setup_far_selector(LINP_SEL(MK_FP( IREG_ES(r),IREG_DI(r)))); + p1 = LINP_PTR( MK_FP( IREG_ES(r),IREG_DI(r) ) ); + p2 = (char *) &(ib->SetWindow_off); + for(ii = 0; ii < Length; p1++,ii++) *(p2++) = peek_b_f(p1); + DBGPRINTF(DBG_DRIVER,("Protected Mode Interface :-\n" )); + DBGPRINTF(DBG_DRIVER,(" Real mode address = 0x%04x:0x%04x\n",ib->RealMode_SEG,ib->RealMode_OFF)); + DBGPRINTF(DBG_DRIVER,(" Length = 0x%08x\n",ib->PhysicalLength)); + DBGPRINTF(DBG_DRIVER,(" SetWindow function offset = 0x%08x\n",ib->SetWindow_off)); + DBGPRINTF(DBG_DRIVER,(" SetDisplayStart function offset = 0x%08x\n",ib->DisplStart_off)); + DBGPRINTF(DBG_DRIVER,(" Primary Palette function offset = 0x%08x\n",ib->PPalette_off)); + DBGPRINTF(DBG_DRIVER,(" Resource Sub-Table offset = 0x%08x\n",ib->SubTable_off)); +#ifdef DUMP_PM_TABLE + { + static int once = 0; + if (!once) { + int len; + FILE *dump = fopen("vesapm.s", "wt"); + once = 1; + if (dump) { + p2 = (char *) &(ib->SetWindow_off); + fprintf(dump, ".text\n_vesa_pm_table:\n"); + for (len=0; len < Length; ++len) { + fprintf(dump, "\t.byte %u\n", *(unsigned char *)p2); + ++p2; + } + fclose(dump); + } + dump = fopen("vesapm.dmp", "wb"); + if (dump) { + p2 = (char *) &(ib->SetWindow_off); + fwrite(p2,Length,1,dump); + fclose(dump); + } + } + } +#endif + return(ib); +} + +int _GrViDrvVESAgetModeInfo(int mode,VESAmodeInfoBlock *ib) +{ + Int86Regs regs; + char FAR *p1; + char *p2; + int ii; + DECLARE_XFER_BUFFER(1000); + /* + * set up registers and call interrupt + */ + sttzero(®s); + IREG_AX(regs) = VESA_FUNC + VESA_MODE_INFO; + IREG_CX(regs) = mode; + IREG_ES(regs) = FP_SEG(XFER_BUFFER); + IREG_DI(regs) = FP_OFF(XFER_BUFFER); + int10x(®s); + if(IREG_AX(regs) != VESA_SUCCESS) { + DELETE_XFER_BUFFER; + return(FALSE); + } + /* + * copy VESA info block into accessible memory + */ + setup_far_selector(LINP_SEL(XFER_BUFFER)); + p1 = (char FAR *)LINP_PTR(XFER_BUFFER); + p2 = (char *)ib; + for(ii = sizeof(*ib); --ii >= 0; p1++,p2++) *p2 = peek_b_f(p1); + DELETE_XFER_BUFFER; + return((ib->ModeAttributes & MODE_SUPPORTED) ? TRUE : FALSE); +} + +#endif + diff --git a/thirdparty/grx249/src/vdrivers/u_vsvirt.c b/thirdparty/grx249/src/vdrivers/u_vsvirt.c new file mode 100644 index 0000000..e242ae4 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/u_vsvirt.c @@ -0,0 +1,80 @@ +/** + ** u_vsvirt.c ---- virtual screen utility functions using VESA BIOS calls + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" +#include "vesa.h" +#include "arith.h" +#include "mempeek.h" +#include "memfill.h" +#include "int86.h" + +int _GrViDrvVESAsetVirtualSize(GrVideoMode *md,int w,int h,GrVideoMode *result) +{ + Int86Regs r; + sttzero(&r); + IREG_AX(r) = VESA_FUNC + VESA_SCAN_LNLEN; + IREG_BX(r) = 0; + IREG_CX(r) = w; +#ifdef __WATCOMC__ + int10x(&r); +#else + int10(&r); +#endif + if(IREG_AX(r) == VESA_SUCCESS) { + result->lineoffset = IREG_BX(r); + result->width = IREG_CX(r); + result->height = umin(IREG_DX(r),h); + return(TRUE); + } + return(FALSE); +} + +/* +** VESA 2.0 has a PM function for VESA_DISP_START +** Bad news: register values are incompatible with +** real mode function. PM adaption should be done +*/ +int _GrViDrvVESAvirtualScroll(GrVideoMode *md,int x,int y,int result[2]) +{ + Int86Regs r; + sttzero(&r); + IREG_AX(r) = VESA_FUNC + VESA_DISP_START; + IREG_BX(r) = 0; + IREG_CX(r) = x; + IREG_DX(r) = y; +#ifdef __WATCOMC__ + int10x(&r); +#else + int10(&r); +#endif + if(IREG_AX(r) == VESA_SUCCESS) { + IREG_AX(r) = VESA_FUNC + VESA_DISP_START; + IREG_BX(r) = 1; +#ifdef __WATCOMC__ + int10x(&r); +#else + int10(&r); +#endif + result[0] = IREG_CX(r); + result[1] = IREG_DX(r); + return(TRUE); + } + return(FALSE); +} + diff --git a/thirdparty/grx249/src/vdrivers/vd_lnxfb.c b/thirdparty/grx249/src/vdrivers/vd_lnxfb.c new file mode 100644 index 0000000..35c5792 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/vd_lnxfb.c @@ -0,0 +1,389 @@ +/** + ** vd_lnxfb.c ---- Linux framebuffer driver + ** + ** Copyright (c) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@telefonica.net] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by Josu Onandia (jonandia@fagorautomation.es) 13/12/2002 + ** - Added the 8bpp paletted mode. + ** Modifications by Mariano Alvarez Fernandez 21/12/2002 + ** - Added function to change virtual terminals, _SwitchConsoleLnxfbDriver + ** to be called from the input driver. + ** - Some cleanups, now the text screen shows ok on exit. + ** Modifications by Mariano Alvarez Fernandez 1/3/2002 + ** - Added code to catch a signal when user wants to change virtual + ** terminals. The driver sets _lnxfb_waiting_to_switch_console and the + ** input driver must calls _LnxfbSwitchConsoleAndWait then. + ** - _SwitchConsoleLnxfbDriver renamed to _LnxfbSwitchConsoleVt, not used, + ** is here only for possible future use. + **/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "memcopy.h" +#include "memfill.h" + +#define NUM_MODES 80 /* max # of supported modes */ +#define NUM_EXTS 15 /* max # of mode extensions */ + +static int initted = -1; +static int fbfd = -1; +static int ttyfd = -1; +static struct fb_fix_screeninfo fbfix; +static struct fb_var_screeninfo fbvar; +static char *fbuffer = NULL; +static int ingraphicsmode = 0; + +int _lnxfb_waiting_to_switch_console = 0; + +static int detect(void) +{ + char *fbname; + char *default_fbname = "/dev/fb0"; + + if (initted < 0) { + initted = 0; + fbname = getenv("FRAMEBUFFER"); + if (fbname == NULL) + fbname = default_fbname; + fbfd = open(fbname, O_RDWR); + if (fbfd == -1) + return FALSE; + ioctl(fbfd, FBIOGET_FSCREENINFO, &fbfix); + ioctl(fbfd, FBIOGET_VSCREENINFO, &fbvar); + if (fbfix.type != FB_TYPE_PACKED_PIXELS) + return FALSE; + ttyfd = open("/dev/tty", O_RDONLY); + initted = 1; + } + return ((initted > 0) ? TRUE : FALSE); +} + +static void reset(void) +{ + struct vt_mode vtm; + + if (fbuffer) { + memzero(fbuffer, fbvar.yres * fbfix.line_length); + munmap(fbuffer, fbfix.smem_len); + fbuffer = NULL; + } + if (fbfd != -1) { + close(fbfd); + fbfd = -1; + } + if (ttyfd > -1) { + ioctl(ttyfd, KDSETMODE, KD_TEXT); + vtm.mode = VT_AUTO; + vtm.relsig = 0; + vtm.acqsig = 0; + ioctl(ttyfd, VT_SETMODE, &vtm); + signal(SIGUSR1, SIG_IGN); + close(ttyfd); + ttyfd = -1; + ingraphicsmode = 0; + } + initted = -1; +} + +void _LnxfbSwitchToConsoleVt(unsigned short vt) +{ + struct vt_stat vtst; + unsigned short myvt; + GrContext *grc; + + if (!ingraphicsmode) return; + if (ttyfd < 0) return; + if (ioctl(ttyfd, VT_GETSTATE, &vtst) < 0) return; + myvt = vtst.v_active; + if (vt == myvt) return; + + grc = GrCreateContext(GrScreenX(), GrScreenY(), NULL, NULL); + if (grc != NULL) { + GrBitBlt(grc, 0, 0, GrScreenContext(), 0, 0, + GrScreenX()-1, GrScreenY()-1, GrWRITE); + } + ioctl(ttyfd, KDSETMODE, KD_TEXT); + if (ioctl(ttyfd, VT_ACTIVATE, vt) == 0) { + ioctl(ttyfd, VT_WAITACTIVE, vt); + ioctl(ttyfd, VT_WAITACTIVE, myvt); + } + ioctl(ttyfd, KDSETMODE, KD_GRAPHICS); + if (grc != NULL) { + GrBitBlt(GrScreenContext(), 0, 0, grc, 0, 0, + GrScreenX()-1, GrScreenY()-1, GrWRITE); + GrDestroyContext(grc); + } +} + +void _LnxfbSwitchConsoleAndWait(void) +{ + struct vt_stat vtst; + unsigned short myvt; + GrContext *grc; + + _lnxfb_waiting_to_switch_console = 0; + if (!ingraphicsmode) return; + if (ttyfd < 0) return; + if (ioctl(ttyfd, VT_GETSTATE, &vtst) < 0) return; + myvt = vtst.v_active; + + grc = GrCreateContext(GrScreenX(), GrScreenY(), NULL, NULL); + if (grc != NULL) { + GrBitBlt(grc, 0, 0, GrScreenContext(), 0, 0, + GrScreenX()-1, GrScreenY()-1, GrWRITE); + } + + ioctl(ttyfd, KDSETMODE, KD_TEXT); + + ioctl(ttyfd, VT_RELDISP, 1); + ioctl(ttyfd, VT_WAITACTIVE, myvt); + + ioctl(ttyfd, KDSETMODE, KD_GRAPHICS); + + if (grc != NULL) { + GrBitBlt(GrScreenContext(), 0, 0, grc, 0, 0, + GrScreenX()-1, GrScreenY()-1, GrWRITE); + GrDestroyContext(grc); + } +} + +void _LnxfbRelsigHandle(int sig) +{ + _lnxfb_waiting_to_switch_console = 1; + signal(SIGUSR1, _LnxfbRelsigHandle); +} + +static void loadcolor(int c, int r, int g, int b) +{ + __u16 red, green, blue, transp; + struct fb_cmap cmap; + + red = (r << 8); + green = (g << 8); + blue = (b << 8); + transp = 0; + cmap.start = c; + cmap.len = 1; + cmap.red = &red; + cmap.green = &green; + cmap.blue = &blue; + cmap.transp = &transp; + ioctl(fbfd, FBIOPUTCMAP, &cmap); +} + +static int setmode(GrVideoMode * mp, int noclear) +{ + struct vt_mode vtm; + + fbuffer = mp->extinfo->frame = mmap(0, + fbfix.smem_len, + PROT_READ | PROT_WRITE, + MAP_SHARED, fbfd, 0); + if (mp->extinfo->frame && ttyfd > -1) { + ioctl(ttyfd, KDSETMODE, KD_GRAPHICS); + vtm.mode = VT_PROCESS; + vtm.relsig = SIGUSR1; + vtm.acqsig = 0; + ioctl(ttyfd, VT_SETMODE, &vtm); + signal(SIGUSR1, _LnxfbRelsigHandle); + ingraphicsmode = 1; + } + if (mp->extinfo->frame && !noclear) + memzero(mp->extinfo->frame, fbvar.yres * fbfix.line_length); + return ((mp->extinfo->frame) ? TRUE : FALSE); +} + +static int settext(GrVideoMode * mp, int noclear) +{ + struct vt_mode vtm; + + if (fbuffer) { + memzero(fbuffer, fbvar.yres * fbfix.line_length); + munmap(fbuffer, fbfix.smem_len); + fbuffer = NULL; + } + if (ttyfd > -1) { + ioctl(ttyfd, KDSETMODE, KD_TEXT); + vtm.mode = VT_AUTO; + vtm.relsig = 0; + vtm.acqsig = 0; + ioctl(ttyfd, VT_SETMODE, &vtm); + signal(SIGUSR1, SIG_IGN); + ingraphicsmode = 0; + } + return TRUE; +} + +GrVideoModeExt grtextextfb = { + GR_frameText, /* frame driver */ + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + {6, 6, 6}, /* color precisions */ + {0, 0, 0}, /* color component bit positions */ + 0, /* mode flag bits */ + settext, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL, /* color loader */ +}; + +static GrVideoModeExt exts[NUM_EXTS]; +static GrVideoMode modes[NUM_MODES] = { + /* pres. bpp wdt hgt mode scan priv. &ext */ + {TRUE, 4, 80, 25, 0, 160, 0, &grtextextfb}, + {0} +}; + +static int build_video_mode(GrVideoMode * mp, GrVideoModeExt * ep) +{ + mp->present = TRUE; + mp->width = fbvar.xres; + mp->height = fbvar.yres; + mp->lineoffset = fbfix.line_length; + mp->extinfo = NULL; + mp->privdata = 0; + ep->drv = NULL; + ep->frame = NULL; /* filled in after mode set */ + ep->flags = 0; + ep->setup = setmode; + ep->setvsize = NULL; /* tbd */ + ep->scroll = NULL; /* tbd */ + ep->setbank = NULL; + ep->setrwbanks = NULL; + ep->loadcolor = NULL; + switch (fbvar.bits_per_pixel) { + case 8: + if (fbfix.visual != FB_VISUAL_PSEUDOCOLOR) + return FALSE; + mp->bpp = 8; + ep->mode = GR_frameSVGA8_LFB; + ep->flags |= GR_VMODEF_LINEAR; + ep->cprec[0] = fbvar.red.length; + ep->cprec[1] = fbvar.green.length; + ep->cprec[2] = fbvar.blue.length; + ep->cpos[0] = fbvar.red.offset; + ep->cpos[1] = fbvar.green.offset; + ep->cpos[2] = fbvar.blue.offset; + ep->loadcolor = loadcolor; + break; + case 15: + if (fbfix.visual != FB_VISUAL_TRUECOLOR) + return FALSE; + mp->bpp = 15; + ep->mode = GR_frameSVGA16_LFB; + ep->flags |= GR_VMODEF_LINEAR; + ep->cprec[0] = fbvar.red.length; + ep->cprec[1] = fbvar.green.length; + ep->cprec[2] = fbvar.blue.length; + ep->cpos[0] = fbvar.red.offset; + ep->cpos[1] = fbvar.green.offset; + ep->cpos[2] = fbvar.blue.offset; + break; + case 16: + if (fbfix.visual != FB_VISUAL_TRUECOLOR) + return FALSE; + mp->bpp = 16; + ep->mode = GR_frameSVGA16_LFB; + ep->flags |= GR_VMODEF_LINEAR; + ep->cprec[0] = fbvar.red.length; + ep->cprec[1] = fbvar.green.length; + ep->cprec[2] = fbvar.blue.length; + ep->cpos[0] = fbvar.red.offset; + ep->cpos[1] = fbvar.green.offset; + ep->cpos[2] = fbvar.blue.offset; + break; + case 24: + if (fbfix.visual != FB_VISUAL_TRUECOLOR) + return FALSE; + mp->bpp = 24; + ep->mode = GR_frameSVGA24_LFB; + ep->flags |= GR_VMODEF_LINEAR; + ep->cprec[0] = fbvar.red.length; + ep->cprec[1] = fbvar.green.length; + ep->cprec[2] = fbvar.blue.length; + ep->cpos[0] = fbvar.red.offset; + ep->cpos[1] = fbvar.green.offset; + ep->cpos[2] = fbvar.blue.offset; + break; + default: + return (FALSE); + } + return (TRUE); +} + +static void add_video_mode(GrVideoMode * mp, GrVideoModeExt * ep, + GrVideoMode ** mpp, GrVideoModeExt ** epp) +{ + if (*mpp < &modes[NUM_MODES]) { + if (!mp->extinfo) { + GrVideoModeExt *etp = &exts[0]; + while (etp < *epp) { + if (memcmp(etp, ep, sizeof(GrVideoModeExt)) == 0) { + mp->extinfo = etp; + break; + } + etp++; + } + if (!mp->extinfo) { + if (etp >= &exts[NUM_EXTS]) + return; + sttcopy(etp, ep); + mp->extinfo = etp; + *epp = ++etp; + } + } + sttcopy(*mpp, mp); + (*mpp)++; + } +} + +static int init(char *options) +{ + if (detect()) { + GrVideoMode mode, *modep = &modes[1]; + GrVideoModeExt ext, *extp = &exts[0]; + memzero(modep, (sizeof(modes) - sizeof(modes[0]))); + if ((build_video_mode(&mode, &ext))) { + add_video_mode(&mode, &ext, &modep, &extp); + } + return (TRUE); + } + return (FALSE); +} + +GrVideoDriver _GrVideoDriverLINUXFB = { + "linuxfb", /* name */ + GR_LNXFB, /* adapter type */ + NULL, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + detect, /* detection routine */ + init, /* initialization routine */ + reset, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; diff --git a/thirdparty/grx249/src/vdrivers/vd_mem.c b/thirdparty/grx249/src/vdrivers/vd_mem.c new file mode 100644 index 0000000..61d4845 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/vd_mem.c @@ -0,0 +1,252 @@ +/** + ** vd_mem.c ---- driver for creating image in memory for later exporting + ** + ** Author: Andris Pavenis + ** [e-mail: pavenis@acad.latnet.lv] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include + +#include "libgrx.h" +#include "grdriver.h" +#include "allocate.h" +#include "arith.h" +#include "int86.h" +#include "memfill.h" + + +static char far * MemBuf = NULL; +static unsigned long MemBufSze = 0; + +static void FreeMemBuf(void) { + if (MemBuf) farfree(MemBuf); + MemBuf = NULL; + MemBufSze = 0; +} + +static int AllocMemBuf(unsigned long sze) { + int clear = 1; + if (!MemBuf) { + MemBuf = farcalloc(1,(size_t)sze); + if (!MemBuf) return 0; + MemBufSze = sze; + clear = 0; + } + if (MemBufSze < sze) { + MemBuf = farrealloc(MemBuf,(size_t)sze); + if (!MemBuf) return 0; + MemBufSze = sze; + } + if (clear) memzero(MemBuf,sze); + return 1; +} + +static int mem_setmode (GrVideoMode *mp,int noclear); + + +static GrVideoModeExt gr1ext = { + GR_frameRAM1, /* frame driver */ + NULL, /* frame driver override */ + 0, /* frame buffer address */ + { 1, 1, 1 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + GR_VMODEF_MEMORY, /* mode flag bits */ + mem_setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoModeExt gr4ext = { + GR_frameRAM4, /* frame driver */ + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + { 8, 8, 8 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + GR_VMODEF_MEMORY, /* mode flag bits */ + mem_setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoModeExt gr8ext = { + GR_frameRAM8, /* frame driver */ + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + { 8, 8, 8 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + GR_VMODEF_MEMORY, /* mode flag bits */ + mem_setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoModeExt gr24ext = { +#ifdef GRX_USE_RAM3x8 + GR_frameRAM3x8, /* frame driver */ +#else + GR_frameRAM24, /* frame driver */ +#endif + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + { 8, 8, 8 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + GR_VMODEF_MEMORY, /* mode flag bits */ + mem_setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + + +static int dummymode (GrVideoMode * mp , int noclear ) +{ + FreeMemBuf(); + return TRUE; +} + + +GrVideoModeExt dummyExt = { + GR_frameText, /* frame driver */ + NULL, /* frame driver override */ + MK_FP(0xb800,0), /* frame buffer address */ + { 0, 0, 0 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + dummymode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + + + + +static GrVideoMode modes[] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + { TRUE, 1, 640, 480, 0x00, 80, 0, &gr1ext }, + { TRUE, 4, 640, 480, 0x00, 320, 0, &gr4ext }, + { TRUE, 8, 640, 480, 0x00, 640, 0, &gr8ext }, + { TRUE, 24, 640, 480, 0x00, 1920, 0, &gr24ext }, + { TRUE, 1, 80, 25, 0x00, 160, 0, &dummyExt } +}; + + + +static int mem_setmode (GrVideoMode *mp,int noclear) +{ + return MemBuf ? TRUE : FALSE; +} + + + +static GrVideoMode * mem_selectmode ( GrVideoDriver * drv, int w, int h, + int bpp, int txt, unsigned int * ep ) +{ + int index; + unsigned long size; + int LineOffset; + + if (txt) return _gr_selectmode (drv,w,h,bpp,txt,ep); +/* why ??? + if (w<320) w=320; + if (h<240) h=240; +*/ + if (w < 1 || h < 1) return NULL; + + switch (bpp) + { + case 1: index = 0; + LineOffset = (w + 7) >> 3; + size = h; + break; + case 4: index = 1; + LineOffset = (w + 7) >> 3; + size = 4*h; + break; + case 8: index = 2; + LineOffset = w; + size = h; + break; + case 24: index = 3; +#ifdef GRX_USE_RAM3x8 + LineOffset = w; + size = 3*h; +#else + LineOffset = 3*w; + size = h; +#endif + break; + default: return NULL; + } + + LineOffset = (LineOffset+7) & (~7); /* align rows to 64bit boundary */ + size *= LineOffset; + + if (((size_t)size) != size) return NULL; + + /* why ??? */ + modes[index].width = /* w<320 ? 320 : */ w; + modes[index].height = /* h<200 ? 200 : */ h; + modes[index].bpp = bpp; + modes[index].lineoffset = LineOffset; + + if ( AllocMemBuf(size) ) { + modes[index].extinfo->frame = MemBuf; + return _gr_selectmode (drv,w,h,bpp,txt,ep); + } + return FALSE; +} + + +/* +static int detect (void) +{ + return TRUE; +} +*/ + +static void mem_reset (void) +{ + if(DRVINFO->moderestore) { + FreeMemBuf(); + } +} + + +GrVideoDriver _GrDriverMEM = { + "memory", /* name */ + GR_MEM, /* adapter type */ + NULL, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + NULL, /* detect, */ /* detection routine */ + NULL, /* initialization routine */ + mem_reset, /* reset routine */ + mem_selectmode, /* special mode select routine */ + GR_DRIVERF_USER_RESOLUTION /* arbitrary resolution possible */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/vd_sdl.c b/thirdparty/grx249/src/vdrivers/vd_sdl.c new file mode 100644 index 0000000..72e38ae --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/vd_sdl.c @@ -0,0 +1,468 @@ +/** + ** vd_sdl.c -- SDL driver (interface to SDL) + ** + ** Copyright (C) 2004 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Passing SDL_SWSURFACE or SDL_HWSURFACE is a good wish only, the + ** real value is only available in the flags of a surface returned + ** from SDL_SetVideoMode(). + ** + ** We assume that any SDL_FULLSCREEN | SDL_HWSURFACE screen surface + ** has pixels pointing to the screen and a dummy SDL_UpdateRect(). + ** This is true for WIN32 and DGA2. + ** + ** We also assume that such pixels value, once locked, will remain + ** valid after any number of subsequent unlocks-&-locks (sdlinp.c). + ** FIXME: update frame after unlock? + ** + **/ + +#include "libsdl.h" +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "memcopy.h" +#include "memfill.h" + +SDL_Surface *_SGrScreen = NULL; +#if defined(__WIN32__) +void *_SGrBackup = NULL; +int _SGrLength; +int _SGrActive = TRUE; +static HWND window; +static WNDPROC wndproc; +static int fullscreen = TRUE; +#else +static int fullscreen = FALSE; +#endif + +#if defined(__WIN32__) +static int MaxWidth, MaxHeight; +#elif defined(__XWIN__) +static int MaxWidth, MaxHeight; +#else +#define MaxWidth 9600 +#define MaxHeight 7200 +#endif + +static void reset(void); +static int detect(void); +static void loadcolor(int c, int r, int g, int b); + +static int filter(const SDL_Event *event) +{ + if(event->type == SDL_KEYDOWN) { + if(event->key.keysym.sym == SDLK_SCROLLOCK) + SDL_SetModState(SDL_GetModState() ^ KMOD_SCROLL); + else if(event->key.keysym.sym == SDLK_INSERT) + SDL_SetModState(SDL_GetModState() ^ KMOD_INSERT); + } + + if((event->type == SDL_KEYDOWN || event->type == SDL_KEYUP) + && event->key.keysym.sym >= SDLK_NUMLOCK) return(0); + + return(1); +} + +#if defined(__WIN32__) +LONG CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_KILLFOCUS : + SDL_EnableKeyRepeat(0, 0); + _SGrActive = FALSE; + break; + case WM_SYSCOMMAND : if (wParam != SC_RESTORE) break; + case WM_SETFOCUS : + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, + SDL_DEFAULT_REPEAT_INTERVAL); + _SGrActive = TRUE; + break; + case WM_ACTIVATEAPP : + if(_SGrActive && !SDL_LockSurface(_SGrScreen)) { + if(_SGrBackup != NULL) free(_SGrBackup); + _SGrLength = _SGrScreen->pitch * _SGrScreen->h; + _SGrBackup = malloc(_SGrLength); + if(_SGrBackup != NULL) + memcpy(_SGrBackup, _SGrScreen->pixels, _SGrLength); + SDL_UnlockSurface(_SGrScreen); + } + } + + return (CallWindowProc(wndproc, hwnd, msg, wParam, lParam)); +} +#endif + +static int setmode(GrVideoMode *mp,int noclear) +{ + int res; + GrVideoModeExt *ep = mp->extinfo; + int fullscreen = mp->privdata & SDL_FULLSCREEN; +#if defined (__WIN32__) + SDL_SysWMinfo info; +#endif + SDL_PixelFormat *vfmt; + GRX_ENTER(); + res = FALSE; + if(mp->mode != 0) { + if(!detect()) { + DBGPRINTF(DBG_DRIVER, ("SDL re-detect() failed\n")); + goto done; + } + + _SGrScreen = SDL_SetVideoMode(mp->width, mp->height, mp->bpp, + mp->privdata); + if(_SGrScreen == NULL) { + DBGPRINTF(DBG_DRIVER, ("SDL_SetVideoMode() failed\n")); + goto done; + } + if((_SGrScreen->flags & SDL_FULLSCREEN) != fullscreen) { + DBGPRINTF(DBG_DRIVER, ("SDL_FULLSCREEN mismatch\n")); + goto done; + } + + SDL_ShowCursor(SDL_DISABLE); + SDL_EnableUNICODE(1); + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, + SDL_DEFAULT_REPEAT_INTERVAL); + SDL_SetEventFilter(filter); + + if(SDL_MUSTLOCK(_SGrScreen)) { + if(!fullscreen) { + DBGPRINTF(DBG_DRIVER, ("hardware windows not supported\n")); + goto done; + } + if(SDL_LockSurface(_SGrScreen)) { + DBGPRINTF(DBG_DRIVER, ("SDL_LockSurface() failed\n")); + goto done; + } +#if defined(__WIN32__) + SDL_VERSION(&info.version); + if(!SDL_GetWMInfo(&info)) { + DBGPRINTF(DBG_DRIVER, ("SDL_GetWMInfo() failed\n")); + goto done; + } + window = info.window; + wndproc = (WNDPROC)GetWindowLong(window, GWL_WNDPROC); + SetWindowLong(window, GWL_WNDPROC, (LONG) WndProc); + _SGrActive = TRUE; +#endif + } + + mp->lineoffset = _SGrScreen->pitch; + ep->frame = _SGrScreen->pixels; + + if(mp->bpp >= 15 && fullscreen) { + vfmt = _SGrScreen->format; + ep->cprec[0] = 8 - vfmt->Rloss; + ep->cprec[1] = 8 - vfmt->Gloss; + ep->cprec[2] = 8 - vfmt->Bloss; + ep->cpos[0] = vfmt->Rshift; + ep->cpos[1] = vfmt->Gshift; + ep->cpos[2] = vfmt->Bshift; + if(mp->bpp == 32 && vfmt->Rshift == 24) + ep->mode = GR_frameSVGA32H_LFB; + } + + if(!noclear) { + if(mp->bpp == 8) loadcolor(0, 0, 0, 0); + SDL_FillRect(_SGrScreen, NULL, 0); + SDL_UpdateRect(_SGrScreen, 0, 0, 0, 0); + } + + res = TRUE; + } +done: if (res != TRUE) { + reset(); + res = mp->mode == 0; + } + GRX_RETURN(res); +} + +static void reset(void) +{ + GRX_ENTER(); +#if defined(__WIN32__) + _SGrActive = TRUE; + if(_SGrBackup != NULL) free(_SGrBackup); + _SGrBackup = NULL; +#endif + if(_SGrScreen != NULL) + if(SDL_MUSTLOCK(_SGrScreen)) SDL_UnlockSurface(_SGrScreen); + if(SDL_WasInit(SDL_INIT_VIDEO)) SDL_Quit(); + _SGrScreen = NULL; + GRX_LEAVE(); +} + +static int detect(void) +{ + int res; + GRX_ENTER(); + res = SDL_WasInit(SDL_INIT_VIDEO) || SDL_Init(SDL_INIT_VIDEO) == 0; + GRX_RETURN(res); +} + +static void loadcolor(int c, int r, int g, int b) +{ + SDL_Color color; + + if(_SGrScreen != NULL) { + color.r = r; + color.g = g; + color.b = b; + SDL_SetPalette(_SGrScreen, SDL_PHYSPAL, &color, c, 1); + } +} + +static int build_video_mode(int mode, int flags, SDL_Rect *rect, + SDL_PixelFormat *vfmt, GrVideoMode *mp, + GrVideoModeExt *ep) +{ + mp->present = TRUE; + mp->bpp = vfmt->BitsPerPixel; + mp->width = rect->w; + mp->height = rect->h; + mp->mode = mode; + mp->lineoffset = 0; + mp->privdata = flags | SDL_HWPALETTE; + mp->extinfo = NULL; + + ep->drv = NULL; + ep->frame = NULL; + ep->flags = GR_VMODEF_LINEAR; + ep->setup = setmode; + ep->setvsize = NULL; + ep->scroll = NULL; + ep->setbank = NULL; + ep->setrwbanks = NULL; + ep->loadcolor = NULL; + + switch(mp->bpp) { + case 8 : + ep->cprec[0] = + ep->cprec[1] = + ep->cprec[2] = 6; + ep->cpos[0] = + ep->cpos[1] = + ep->cpos[2] = 0; + ep->mode = GR_frameSDL8; + ep->loadcolor = loadcolor; + break; + case 15 : + case 16 : ep->mode = GR_frameSDL16; break; + case 24 : ep->mode = GR_frameSDL24; break; + case 32 : ep->mode = GR_frameSDL32L; break; + default : return(FALSE); + } + + if(mp->width == MaxWidth && mp->height == MaxHeight) + mp->privdata |= SDL_NOFRAME; + + if(mp->bpp >= 15) { + if(flags & SDL_FULLSCREEN) { + ep->cprec[0] = + ep->cprec[1] = + ep->cprec[2] = 0; + ep->cpos[0] = + ep->cpos[1] = + ep->cpos[2] = 0; + } + else { + ep->cprec[0] = 8 - vfmt->Rloss; + ep->cprec[1] = 8 - vfmt->Gloss; + ep->cprec[2] = 8 - vfmt->Bloss; + ep->cpos[0] = vfmt->Rshift; + ep->cpos[1] = vfmt->Gshift; + ep->cpos[2] = vfmt->Bshift; + if(mp->bpp == 32 && vfmt->Rshift == 24) + ep->mode = GR_frameSDL32H; + } + } + + return(TRUE); +} + +GrVideoModeExt grtextextsdl = { + GR_frameText, /* frame driver */ + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + { 0, 0, 0 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +#define NUM_MODES 200 /* max # of supported modes */ +#define NUM_EXTS 10 /* max # of mode extensions */ + +static GrVideoModeExt exts[NUM_EXTS]; +static GrVideoMode modes[NUM_MODES] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + { TRUE, 8, 80, 25, 0x00, 80, 1, &grtextextsdl }, + { 0 } +}; + +/* from svgalib.c, unmodified */ +static void add_video_mode( + GrVideoMode *mp, GrVideoModeExt *ep, + GrVideoMode **mpp,GrVideoModeExt **epp +) { + if(*mpp < &modes[NUM_MODES]) { + if(!mp->extinfo) { + GrVideoModeExt *etp = &exts[0]; + while(etp < *epp) { + if(memcmp(etp,ep,sizeof(GrVideoModeExt)) == 0) { + mp->extinfo = etp; + break; + } + etp++; + } + if(!mp->extinfo) { + if(etp >= &exts[NUM_EXTS]) return; + sttcopy(etp,ep); + mp->extinfo = etp; + *epp = ++etp; + } + } + sttcopy(*mpp,mp); + (*mpp)++; + } +} + +#define NUM_RESOS 7 + +struct { + int w, h; +} +resos[NUM_RESOS] = { + { 320, 240 }, + { 640, 480 }, + { 800, 600 }, + { 1024, 768 }, + { 1280, 1024 }, + { 1600, 1200 }, + { 9999, 9999 } +}; + +static int init(char *options) +{ + int res; + SDL_Rect **rects; + int *bpp, n; + int bpps[] = { 8, 15, 16, 24, 32, 0 }; + SDL_PixelFormat fmt; + const SDL_VideoInfo *vi; +#if defined(__XWIN__) + Display *dsp; +#endif + SDL_Rect rect = { 0, 0, 0, 0 }; + int i; + GrVideoMode mode, *modep = &modes[1]; + GrVideoModeExt ext, *extp = &exts[0]; + GRX_ENTER(); + res = FALSE; + if(detect()) { + if(options) { + if(!strncmp(options, "fs", 2)) fullscreen = TRUE; + else if(!strncmp(options, "ww", 2)) fullscreen = FALSE; + } + memzero(modep,(sizeof(modes) - sizeof(modes[0]))); + if(fullscreen) { + memzero(&fmt, sizeof fmt); + for(bpp = bpps; *bpp; bpp++) { + fmt.BitsPerPixel = *bpp; + rects = SDL_ListModes(&fmt, SDL_HWSURFACE|SDL_FULLSCREEN); + if(rects != NULL && rects != (SDL_Rect **) -1) { + for(n = 0; rects[n] != NULL; n++); + for(i = n - 1; i >= 0; i--) { + if(!build_video_mode(n-i, + SDL_HWSURFACE|SDL_FULLSCREEN, + rects[i], &fmt, &mode, &ext)) + continue; + add_video_mode(&mode,&ext,&modep,&extp); + } + } + } + } + if(modep == &modes[1]) { + if((vi = SDL_GetVideoInfo()) == NULL) { + DBGPRINTF(DBG_DRIVER, ("SDL_GetVideoInfo() failed\n")); + goto done; + } +#if defined(__WIN32__) + MaxWidth = GetSystemMetrics(SM_CXSCREEN); + MaxHeight = GetSystemMetrics(SM_CYSCREEN); +#elif defined(__XWIN__) + if((dsp = XOpenDisplay("")) != NULL) { + MaxWidth = DisplayWidth(dsp, DefaultScreen(dsp)); + MaxHeight = DisplayHeight(dsp, DefaultScreen(dsp)); + XCloseDisplay(dsp); + } + else { + MaxWidth = 9600; + MaxHeight = 7200; + } +#endif + for(i = 0; i < NUM_RESOS; i++) { + rect.w = resos[i].w; + rect.h = resos[i].h; + if(!build_video_mode(i+1, SDL_SWSURFACE, &rect, vi->vfmt, + &mode, &ext)) + continue; + mode.present = rect.w <= MaxWidth && rect.h <= MaxHeight; + add_video_mode(&mode,&ext,&modep,&extp); + } + } + res = TRUE; + } +done: if(!res) reset(); + GRX_RETURN(res); +} + +static GrVideoMode *selectmode(GrVideoDriver *drv, int w, int h, + int bpp, int txt, unsigned int *ep) +{ + int i; + + if(!txt && !(modes[1].privdata & SDL_FULLSCREEN)) { + for(i = 1; i < NUM_RESOS; i++) + if(modes[i].width == w && modes[i].height == h) goto done; + if(w <= MaxWidth && h <= MaxHeight) { + modes[i].present = TRUE; + modes[i].width = w; + modes[i].height = h; + } + else modes[i].present = FALSE; + } +done: return(_gr_selectmode(drv, w, h, bpp, txt, ep)); +} + +GrVideoDriver _GrVideoDriverSDL = { + "sdl", /* name */ + GR_SDL, /* adapter type */ + NULL, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + detect, /* detection routine */ + init, /* initialization routine */ + reset, /* reset routine */ + selectmode, /* special mode select routine */ + 0 /* no additional capabilities */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/vd_win32.c b/thirdparty/grx249/src/vdrivers/vd_win32.c new file mode 100644 index 0000000..905e768 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/vd_win32.c @@ -0,0 +1,713 @@ +/** + ** vd_win32.c ---- the standard Win32-API driver + ** + ** Author: Gernot Graeff + ** E-mail: gernot.graeff@t-online.de + ** Date: 13.11.98 + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Changes by Josu Onandia (jonandia@fagorautomation.es) 21/02/2001 + ** - The colors loaded in the ColorList are guaranteed to be actually used + ** by Windows (GetNearestColor), for the GR_frameWin32 to work. + ** - When the window is created, it gets the maximum size allowed by the + ** current mode. Indeed this size is stored (maxWindowWidth/ + ** maxWindowHeight). + ** When the window is going to be resized (WM_GETMINMAXINFO) it's not + ** allowed to grow bigger than this maximum size (it makes nosense). + ** - Added some modes for 24bpp colors. + ** - When changed to text-mode, the graphics window is hidden. If the + ** application has a console (linked with -mconsole) it can use + ** printf/scanf and the like. + ** When changed again into graphics mode, the window reappears. + ** - Inter-task synchronization. In some cases the two threads are + ** manipulating at the same time the main window, and the on-memory + ** bitmap. I guess this is causing trouble, so in some cases the main + ** thread suspends the worker thread, make its operation, and then + ** resumes it. + ** - The window title is selectable with a define, at compile time. + ** If not defined, it defaults to "GRX". + ** + ** Changes by M.Alvarez (malfer@telefonica.net) 02/01/2002 + ** - Go to full screen if the framemode dimensions are equal to + ** the screen dimensions (setting the client start area at 0,0). + ** + ** Changes by M.Alvarez (malfer@telefonica.net) 02/02/2002 + ** - The w32 imput queue implemented as a circular queue. + ** - All the input related code moved to w32inp.c + ** - The main window is created in WinMain, so the grx program + ** can use other videodrivers like the memory one. + ** + ** Changes by M.Alvarez (malfer@telefonica.net) 11/02/2002 + ** - Now the GRX window is properly closed, so the previous app + ** gets the focus. + ** + ** Changes by M.Alvarez (malfer@telefonica.net) 31/03/2002 + ** - Accepts arbitrary (user defined) resolution. + ** + ** Changes by Thomas Demmer (TDemmer@krafteurope.com) + ** - Instead of begin with WinMain and start a thread with the main + ** GRX program, do it backward: begin in main and start a thread to + ** handle the Windows window. With this change we get rid of the + ** awful GRXMain special entry point. + ** + ** Changes by M.Alvarez (malfer@telefonica.net) 12/02/2003 + ** - Sanitize the Thomas changes. + ** + ** Changes by Thomas Demmer (TDemmer@krafteurope.com) 18/03/2003 + ** - Use a DIB for the hDCMem. + ** + ** Changes by Josu Onandia (jonandia@fagorautomation.es) 19/03/2003 + ** - With the Thomas idea of using a DIB, we can now use the DIB like + ** a linear frame buffer, so the new win32 framedrivers can take + ** advantage of the standard GRX frame drivers. + ** + ** Changes by Peter Gerwinski 19/06/2004 + ** - more W32 events handling + ** + ** Changes by Maurice Lombardi 21/08/2007 + ** - Corrections to WM_PAINT + ** 1 - revert the previous change: was saturating GrMouseInfo->queue + ** for fast paintings + ** 2 - GetUpdateRect() gave wrong UpdateRect !!! + ** + ** Changes by Peter Schauer 12/05/2008 + ** - vdrivers/vd_win32.c has a race condition with the loadcolor + ** SetDIBColorTable function call, which happens sometimes on + ** fast multiprocessor machines. This affects only 8 bpp modes, + ** as loadcolor is not called in 32 bpp modes. + ** If the WndThread is currently executing its BitBlt during WM_PAINT + ** processing and the GRX user thread is calling GrAllocColor, the + ** SetDIBColorTable function call fails, as the DC is locked by the BitBlt. + ** This results in the color not being set, which could also happen + ** during the initial setting of the VGA colors in _GrResetColors. + ** My proposed fix delays the SetDIBColorTable call and moves it to + ** the WM_PAINT processing, making it synchronous with the BitBlt call. + ** + ** Changes by M.Alvarez (malfer@telefonica.net) 01/12/2007 + ** - Added videomodes for wide monitors + ** + **/ + +#include "libwin32.h" +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" + +#ifndef GRXWINDOW_TITLE +#define GRXWINDOW_TITLE "GRX" +#endif + +HWND hGRXWnd = NULL; +HWND hPrvWnd = NULL; +HDC hDCMem = NULL; + +CRITICAL_SECTION _csEventQueue; +W32Event *_W32EventQueue = NULL; +volatile int _W32EventQueueSize = 0; +volatile int _W32EventQueueRead = 0; +volatile int _W32EventQueueWrite = 0; +volatile int _W32EventQueueLength = 0; + +static HBITMAP hBmpDIB = NULL; + +static int maxScreenWidth, maxScreenHeight; +static int maxWindowWidth, maxWindowHeight; + +HANDLE windowThread = INVALID_HANDLE_VALUE; +static HANDLE mainThread = INVALID_HANDLE_VALUE; + +static volatile int isWindowThreadRunning = 0; +static volatile int isMainWaitingTermination = 0; + +struct _GR_modifiedColors { + int modified; + RGBQUAD color; +}; +static struct _GR_modifiedColors modifiedColors[256]; +static volatile int isColorModified = 0; + +static DWORD WINAPI WndThread(void *param); +static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, + LPARAM lParam); + +static void loadcolor(int c, int r, int g, int b) +{ + RGBQUAD color; + color.rgbBlue = b; + color.rgbGreen = g; + color.rgbRed = r; + color.rgbReserved = 0; + if (c >= 0 && c <= 256) { + modifiedColors[c].color = color; + modifiedColors[c].modified = 1; + isColorModified = 1; + InvalidateRect(hGRXWnd, NULL, FALSE); + } +} + +static HBITMAP CreateDIB8(HDC hdc, int w, int h, char **pBits) +{ + BITMAPINFO *pbmInfo; + HBITMAP hBmp; + + pbmInfo = malloc(sizeof(BITMAPINFO) +256*sizeof(RGBQUAD)); + pbmInfo->bmiHeader.biSize = sizeof (BITMAPINFOHEADER); + pbmInfo->bmiHeader.biWidth = w; + pbmInfo->bmiHeader.biHeight = -h; + pbmInfo->bmiHeader.biPlanes = 1; + pbmInfo->bmiHeader.biBitCount = 8; + pbmInfo->bmiHeader.biCompression = BI_RGB; + pbmInfo->bmiHeader.biSizeImage = 0; + pbmInfo->bmiHeader.biXPelsPerMeter = 0; + pbmInfo->bmiHeader.biYPelsPerMeter = 0; + pbmInfo->bmiHeader.biClrUsed = 0; + pbmInfo->bmiHeader.biClrImportant = 0; + hBmp = CreateDIBSection(0, pbmInfo, DIB_RGB_COLORS, (void*)pBits, 0, 0); + free(pbmInfo); + return(hBmp); +} + +static HBITMAP CreateDIB24(HDC hdc, int w, int h, char **pBits) +{ + BITMAPINFO *pbmInfo; + HBITMAP hBmp; + + pbmInfo = malloc(sizeof(BITMAPINFO)); + pbmInfo->bmiHeader.biSize = sizeof (BITMAPINFOHEADER); + pbmInfo->bmiHeader.biWidth = w; + pbmInfo->bmiHeader.biHeight = -h; + pbmInfo->bmiHeader.biPlanes = 1; + pbmInfo->bmiHeader.biBitCount = 24; + pbmInfo->bmiHeader.biCompression = BI_RGB; + pbmInfo->bmiHeader.biSizeImage = 0; + pbmInfo->bmiHeader.biXPelsPerMeter = 0; + pbmInfo->bmiHeader.biYPelsPerMeter = 0; + pbmInfo->bmiHeader.biClrUsed = 0; + pbmInfo->bmiHeader.biClrImportant = 0; + hBmp = CreateDIBSection(0, pbmInfo, DIB_RGB_COLORS, (void*)pBits, 0, 0); + free(pbmInfo); + return(hBmp); +} + +static int setmode(GrVideoMode * mp, int noclear) +{ + RECT Rect; + HDC hDC; + HBRUSH hBrush; + RGBQUAD color; + int inipos; + + if (mp->extinfo->mode != GR_frameText) { + inipos = 50; + if (mp->width == maxScreenWidth && mp->height == maxScreenHeight) + inipos = 0; + Rect.left = inipos; + Rect.top = inipos; + Rect.right = mp->width + inipos; + Rect.bottom = mp->height + inipos; + AdjustWindowRect(&Rect, WS_OVERLAPPEDWINDOW, FALSE); + maxWindowWidth = Rect.right - Rect.left; + maxWindowHeight = Rect.bottom - Rect.top; + SetWindowPos(hGRXWnd, NULL, + Rect.left, Rect.top, + maxWindowWidth, maxWindowHeight, + SWP_DRAWFRAME | SWP_NOZORDER | SWP_SHOWWINDOW); + + if (hBmpDIB != NULL) { + DeleteObject(hBmpDIB); + hBmpDIB = NULL; + } + hDC = GetDC(hGRXWnd); + if (hDCMem == NULL) + hDCMem = CreateCompatibleDC(hDC); + if (mp->bpp == 8) { + hBmpDIB = CreateDIB8(hDC, mp->width, mp->height, + &mp->extinfo->frame); + } else { + hBmpDIB = CreateDIB24(hDC, mp->width, mp->height, + &mp->extinfo->frame); + } + SelectObject(hDCMem, hBmpDIB); + if (mp->bpp == 8) { + color.rgbBlue = color.rgbGreen = color.rgbRed = + color.rgbReserved = 0; + SetDIBColorTable(hDCMem, 0, 1, &color); + } + SetRect(&Rect, 0, 0, mp->width, mp->height); + hBrush = CreateSolidBrush(0); + FillRect(hDCMem, &Rect, hBrush); + if (mp->bpp == 8) + BitBlt(hDC, 0, 0, mp->width, mp->height, hDCMem, 0, 0, SRCCOPY); + else + FillRect(hDC, &Rect, hBrush); + ReleaseDC(hGRXWnd, hDC); + DeleteObject(hBrush); + UpdateWindow(hGRXWnd); + SetForegroundWindow(hGRXWnd); + } else { + /* If changing to text-mode, hide the graphics window. */ + if (hGRXWnd != NULL) { + ShowWindow(hGRXWnd, SW_HIDE); + SetForegroundWindow(hPrvWnd); + } + } + return (TRUE); +} + +static void setbank_dummy(int bk) +{ + bk = bk; +} + +GrVideoModeExt grtextext = { + GR_frameText, /* frame driver */ + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + {0, 0, 0}, /* color precisions */ + {0, 0, 0}, /* color component bit positions */ + 0, /* mode flag bits */ + setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoModeExt grxwinext8 = { + GR_frameWIN32_8, /* frame driver */ + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + {8, 8, 8}, /* color precisions */ + {0, 8, 16}, /* color component bit positions */ + 0, /* mode flag bits */ + setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + setbank_dummy, /* bank set function */ + NULL, /* double bank set function */ + loadcolor /* color loader */ +}; + +static GrVideoModeExt grxwinext24 = { + GR_frameWIN32_24, /* frame driver */ + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + {8, 8, 8}, /* color precisions */ + {16, 8, 0}, /* color component bit positions */ + 0, /* mode flag bits */ + setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + setbank_dummy, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoMode modes[] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + {TRUE, 8, 80, 25, 0x00, 80, 1, &grtextext}, + + {TRUE, 8, 320, 240, 0x00, 320, 0, &grxwinext8}, + {TRUE, 8, 640, 480, 0x00, 640, 0, &grxwinext8}, + {TRUE, 8, 800, 600, 0x00, 800, 0, &grxwinext8}, + {TRUE, 8, 1024, 768, 0x00, 1024, 0, &grxwinext8}, + {TRUE, 8, 1280, 1024, 0x00, 1280, 0, &grxwinext8}, + {TRUE, 8, 1600, 1200, 0x00, 1600, 0, &grxwinext8}, + {TRUE, 8, 1440, 900, 0x00, 1440, 0, &grxwinext8}, + {TRUE, 8, 1680, 1050, 0x00, 1680, 0, &grxwinext8}, + {TRUE, 8, 1920, 1200, 0x00, 1920, 0, &grxwinext8}, + {TRUE, 8, 2560, 1600, 0x00, 2560, 0, &grxwinext8}, + + {TRUE, 24, 320, 240, 0x00, 960, 0, &grxwinext24}, + {TRUE, 24, 640, 480, 0x00, 1920, 0, &grxwinext24}, + {TRUE, 24, 800, 600, 0x00, 2400, 0, &grxwinext24}, + {TRUE, 24, 1024, 768, 0x00, 3072, 0, &grxwinext24}, + {TRUE, 24, 1280, 1024, 0x00, 3840, 0, &grxwinext24}, + {TRUE, 24, 1600, 1200, 0x00, 4800, 0, &grxwinext24}, + {TRUE, 24, 1440, 900, 0x00, 4320, 0, &grxwinext24}, + {TRUE, 24, 1680, 1050, 0x00, 5040, 0, &grxwinext24}, + {TRUE, 24, 1920, 1200, 0x00, 5760, 0, &grxwinext24}, + {TRUE, 24, 2560, 1600, 0x00, 7680, 0, &grxwinext24}, + + {FALSE, 0, 9999, 9999, 0x00, 0, 0, NULL} +}; + +static int detect(void) +{ + static int inited = 0; + WNDCLASSEX wndclass; + + if (!inited) { + wndclass.cbSize = sizeof(wndclass); + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = WndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = GetModuleHandle(NULL); + wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = "GRXCLASS"; + wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + if (RegisterClassEx(&wndclass)== 0) return FALSE; + inited = 1; + } + + return TRUE; +} + +static int init(char *options) +{ + int i; + DWORD thread_id; + + if (!detect()) return FALSE; + + /* WARNING: mainThread can not be used in the windowThread */ + mainThread = GetCurrentThread(); + + hPrvWnd = GetForegroundWindow(); + + InitializeCriticalSection(&_csEventQueue); + + /* The modes not compatible width the configuration */ + /* of Windows are made 'non-present' */ + maxScreenWidth = GetSystemMetrics(SM_CXSCREEN); + for (i = 1; i < itemsof(modes); i++) { + if (modes[i].width > maxScreenWidth) + modes[i].present = FALSE; + } + maxScreenHeight = GetSystemMetrics(SM_CYSCREEN); + for (i = 1; i < itemsof(modes); i++) { + if (modes[i].height > maxScreenHeight) + modes[i].present = FALSE; + } + + windowThread = CreateThread(NULL, 0, WndThread, NULL, 0, &thread_id); + + /* Wait for thread creating the window. This is a busy */ + /* waiting loop (bad), but we Sleep to yield (good) */ + while (isWindowThreadRunning == 0) + Sleep(1); + + return TRUE; +} + +static void reset(void) +{ + isMainWaitingTermination = 1; + PostMessage(hGRXWnd, WM_CLOSE, 0, 0); + + while (isWindowThreadRunning == 1) + Sleep(1); + + isMainWaitingTermination = 0; + DeleteCriticalSection(&_csEventQueue); + + if(hBmpDIB != NULL) + { + DeleteObject(hBmpDIB); + hBmpDIB = NULL; + } + if (hDCMem != NULL) { + DeleteDC(hDCMem); + hDCMem = NULL; + } +} + +static GrVideoMode * _w32_selectmode(GrVideoDriver * drv, int w, int h, + int bpp, int txt, unsigned int * ep) +{ + GrVideoMode *mp, *res; + long resto; + + if (txt) { + res = _gr_selectmode(drv, w, h, bpp, txt, ep); + goto done; + } + for (mp = &modes[1]; mp < &modes[itemsof(modes)-1]; mp++) { + if (mp->present && mp->width == w && mp->height == h) { + res = _gr_selectmode(drv, w, h, bpp, txt, ep); + goto done; + } + } + /* no predefined mode found. Create a new mode if we can*/ + if (w <= maxScreenWidth && h <= maxScreenHeight) { + mp->present = TRUE; + mp->width = w; + mp->height = h; + if (bpp <= 8) { + mp->bpp = 8; + mp->extinfo = &grxwinext8; + resto = mp->width % 4; + if (resto) resto = 4 - resto; + mp->lineoffset = mp->width + resto; + } + else { + mp->bpp = 24; + mp->extinfo = &grxwinext24; + resto = (mp->width * 3) % 4; + if (resto) resto = 4 - resto; + mp->lineoffset = mp->width * 3 + resto; + } + } + res = _gr_selectmode(drv, w, h, bpp, txt, ep); +done: + return res; +} + +GrVideoDriver _GrVideoDriverWIN32 = { + "win32", /* name */ + GR_WIN32, /* adapter type */ + NULL, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + detect, /* detection routine */ + init, /* initialization routine */ + reset, /* reset routine */ + _w32_selectmode, /* special mode select routine */ + GR_DRIVERF_USER_RESOLUTION /* arbitrary resolution possible */ +}; + +static DWORD WINAPI WndThread(void *param) +{ + MSG msg; + + hGRXWnd = CreateWindow("GRXCLASS", GRXWINDOW_TITLE, + WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU + | WS_THICKFRAME | WS_MINIMIZEBOX, 0, 0, + CW_USEDEFAULT, CW_USEDEFAULT, NULL, + NULL, GetModuleHandle(NULL), NULL); + ShowWindow(hGRXWnd, SW_HIDE); + + isWindowThreadRunning = 1; + + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + isWindowThreadRunning = 0; + + ExitThread(0); + return 0; +} + +static int convertwin32keystate(void) +{ + int fkbState = 0; + + if (GetKeyState(VK_SHIFT) < 0) + fkbState |= GR_KB_SHIFT; + if (GetKeyState(VK_CONTROL) < 0) + fkbState |= GR_KB_CTRL; + if (GetKeyState(VK_MENU) < 0) + fkbState |= GR_KB_ALT; + if (GetKeyState(VK_SCROLL) < 0) + fkbState |= GR_KB_SCROLLOCK; + if (GetKeyState(VK_NUMLOCK) < 0) + fkbState |= GR_KB_NUMLOCK; + if (GetKeyState(VK_CAPITAL) < 0) + fkbState |= GR_KB_CAPSLOCK; + if (GetKeyState(VK_INSERT) < 0) + fkbState |= GR_KB_INSERT; + return fkbState; +} + +static void EnqueueW32Event(UINT uMsg, WPARAM wParam, LPARAM lParam, + int kbstat) +{ + if (_W32EventQueue == NULL) + return; + + EnterCriticalSection(&_csEventQueue); + _W32EventQueue[_W32EventQueueWrite].uMsg = uMsg; + _W32EventQueue[_W32EventQueueWrite].wParam = wParam; + _W32EventQueue[_W32EventQueueWrite].lParam = lParam; + _W32EventQueue[_W32EventQueueWrite].kbstat = kbstat; + if (++_W32EventQueueWrite == _W32EventQueueSize) + _W32EventQueueWrite = 0; + if (++_W32EventQueueLength > _W32EventQueueSize) { + _W32EventQueueLength--; + if (++_W32EventQueueRead == _W32EventQueueSize) + _W32EventQueueRead = 0; + } + LeaveCriticalSection(&_csEventQueue); +} + +static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, + LPARAM lParam) +{ + static int cursorOn = 1; + int kbstat; + BOOL fInsert; + + switch (uMsg) { + + case WM_NCHITTEST: + { + LRESULT res = DefWindowProc(hWnd, uMsg, wParam, lParam); + if (res == HTCLIENT) { + if (cursorOn) { + ShowCursor(FALSE); + cursorOn = 0; + } + } else { + if (!cursorOn) { + ShowCursor(TRUE); + cursorOn = 1; + } + } + return res; + } + + case WM_CLOSE: + if (!isMainWaitingTermination && MessageBox(hWnd, + "This will abort the program\nare you sure?", "Abort", + MB_APPLMODAL | MB_ICONQUESTION | MB_YESNO ) != IDYES) + return 0; + DestroyWindow(hWnd); + if (!isMainWaitingTermination) + { + isWindowThreadRunning = 0; + ExitProcess(1); + } + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + case WM_GETMINMAXINFO: + { + LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam; + + lpmmi->ptMaxSize.x = lpmmi->ptMaxTrackSize.x = maxWindowWidth; + lpmmi->ptMaxSize.y = lpmmi->ptMaxTrackSize.y = maxWindowHeight; + } + return 0; + + case WM_SYSCHAR: + fInsert = FALSE; + kbstat = convertwin32keystate(); + if (kbstat & GR_KB_ALT) { + if (wParam >= 'a' && wParam <= 'z') + fInsert = TRUE; + if (wParam >= 'A' && wParam <= 'Z') + fInsert = TRUE; + if (wParam >= '0' && wParam <= '9') + fInsert = TRUE; + } + if (!fInsert) + break; + EnqueueW32Event(uMsg, wParam, lParam, kbstat); + return 0; + + case WM_COMMAND: + case WM_CHAR: + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + case WM_LBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_LBUTTONUP: + case WM_MBUTTONUP: + case WM_RBUTTONUP: + case WM_MOUSEMOVE: + { + kbstat = convertwin32keystate(); + EnqueueW32Event(uMsg, wParam, lParam, kbstat); + } + return 0; + + case WM_MOUSEWHEEL: + { + kbstat = convertwin32keystate(); + /* twice to simulate down up */ + EnqueueW32Event(uMsg, wParam, lParam, kbstat); + EnqueueW32Event(uMsg, wParam, lParam, kbstat); + } + return 0; + + + case WM_PAINT: + { + HDC hDC; + PAINTSTRUCT ps; + + if (isColorModified) { + int c; + + isColorModified = 0; + for (c = 0; c < 256; c++) { + if (modifiedColors[c].modified) { + int res; + + modifiedColors[c].modified = 0; + if ((res = SetDIBColorTable(hDCMem, c, 1, &modifiedColors[c].color)) != 1) + DBGPRINTF(DBG_DRIVER,("SetDIBColorTable returned %d (%ld) color %d\n", res, GetLastError(), c)); + } + } + } + + hDC = BeginPaint(hWnd, &ps); + BitBlt(hDC, + ps.rcPaint.left, ps.rcPaint.top, + ps.rcPaint.right - ps.rcPaint.left + 1, + ps.rcPaint.bottom - ps.rcPaint.top + 1, + hDCMem, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); + EndPaint(hWnd, &ps); + } + return 0; + + case WM_SYSCOMMAND: + case WM_NCCREATE: + case WM_NCPAINT: + case WM_NCMOUSEMOVE: + case WM_PALETTEISCHANGING: + case WM_ACTIVATEAPP: + case WM_NCCALCSIZE: + case WM_ACTIVATE: + case WM_NCACTIVATE: + case WM_SHOWWINDOW: + case WM_WINDOWPOSCHANGING: + case WM_GETTEXT: + case WM_SETFOCUS: + case WM_KILLFOCUS: + case WM_GETICON: + case WM_ERASEBKGND: + case WM_QUERYNEWPALETTE: + case WM_WINDOWPOSCHANGED: + case WM_GETDLGCODE: + case WM_MOVE: + case WM_SIZE: + case WM_SETCURSOR: + case WM_HELP: + case WM_KEYUP: + case WM_SYSKEYUP: + break; + + default: +/* + char szMsg[255]; + sprintf(szMsg, "Msg %x, wParam %d, lParam %d", + uMsg, wParam, lParam); + MessageBox(NULL, szMsg, "Msg", MB_OK); +*/ + break; + + } + + return DefWindowProc(hWnd, uMsg, wParam, lParam); +} diff --git a/thirdparty/grx249/src/vdrivers/vd_xfdga.c b/thirdparty/grx249/src/vdrivers/vd_xfdga.c new file mode 100644 index 0000000..cb272ce --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/vd_xfdga.c @@ -0,0 +1,396 @@ +/** + ** vd_xfdga.c -- DGA2 driver (interface to X11 DGA2) + ** + ** Copyright (C) 2003 Dimitar Zhekov + ** [e-mail: jimmy@is-vn.bg] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Changes by Dimitar Zhekov (jimmy@is-vn.bg) Aug 27 2003 + ** - use Xlib for rendering unless defined XF86DGA_FRAMEBUFFER + ** + **/ + +#include "libgrx.h" +#include "libxwin.h" +#include "grdriver.h" +#include "arith.h" +#include "memcopy.h" +#include "memfill.h" + +int _XGrWindowedMode = 1; + +static int setmode(GrVideoMode *mp,int noclear) +{ + int res; + XDGADevice *dev; + GRX_ENTER(); + res = FALSE; + DBGPRINTF(DBG_DRIVER, ("attempting to set DGA mode %d\n", mp->mode)); +#ifndef XF86DGA_FRAMEBUFFER + if(_XGrPatternGC != None) XFreeGC(_XGrDisplay, _XGrPatternGC); + if(_XGrPattern != None) XFreePixmap(_XGrDisplay, _XGrPattern); + if(_XGrBitmapGC != None) XFreeGC(_XGrDisplay, _XGrBitmapGC); + if(_XGrBitmap != None) XFreePixmap(_XGrDisplay, _XGrBitmap); + if(_XGrGC != None) XFreeGC(_XGrDisplay, _XGrGC); + _XGrGC = _XGrBitmapGC = _XGrPatternGC = None; + _XGrBitmap = _XGrPattern = None; +#endif + XUngrabPointer(_XGrDisplay, CurrentTime); + XUngrabKeyboard(_XGrDisplay, CurrentTime); + dev = XDGASetMode(_XGrDisplay, _XGrScreen, mp->mode); + if(mp->mode != 0) { + if(dev == NULL) { + DBGPRINTF(DBG_DRIVER, ("can't set DGA mode\n")); + goto done; + } +#ifdef XF86DGA_FRAMEBUFFER + mp->extinfo->frame = dev->data; +#else + mp->extinfo->frame = (char *) dev->pixmap; +#endif + XDGASync(_XGrDisplay, _XGrScreen); + XDGASetViewport(_XGrDisplay, _XGrScreen, 0, 0, XDGAFlipRetrace); + XGrabKeyboard(_XGrDisplay, _XGrWindow, True, GrabModeAsync, + GrabModeAsync, CurrentTime); + XGrabPointer(_XGrDisplay, _XGrWindow, True, StructureNotifyMask | + ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | PointerMotionMask, GrabModeAsync, + GrabModeAsync, None, None, CurrentTime); + if(mp->bpp == 8) { + if(_XGrColormap == None) { + /* one colormap for all modes, XFreeColormap() problems */ + _XGrColormap = XDGACreateColormap(_XGrDisplay, _XGrScreen, + dev, AllocAll); + } + if(_XGrColormap != None) { + XDGAInstallColormap(_XGrDisplay, _XGrScreen, _XGrColormap); + _GR_lastFreeColor = 255; + } + } +#ifdef XF86DGA_FRAMEBUFFER + if(!noclear) memzero(dev->data, mp->lineoffset * mp->height); +#else + _XGrDepth = _XGrBitsPerPixel = mp->bpp; + if(_XGrDepth == 32) _XGrDepth = 24; + _XGrForeColor = GrNOCOLOR; /* force XSetForeground */ + _XGrBackColor = GrNOCOLOR; /* force XSetBackground */ + _XGrColorOper = C_WRITE; + _XGrGC = XCreateGC(_XGrDisplay, dev->pixmap, 0L, NULL); + _XGrBitmap = XCreatePixmap(_XGrDisplay, dev->pixmap, 128, 128, 1); + _XGrBitmapGC = XCreateGC(_XGrDisplay, _XGrBitmap, 0L, NULL); + _XGrPattern = XCreatePixmap(_XGrDisplay, dev->pixmap, 8, 1, 1); + _XGrPatternGC = XCreateGC(_XGrDisplay, _XGrPattern, 0L, NULL); + if(!noclear) { + XSetForeground(_XGrDisplay, _XGrGC, 0); + XSetFunction(_XGrDisplay, _XGrGC, GXcopy); + XFillRectangle(_XGrDisplay, dev->pixmap, _XGrGC, 0, 0, + mp->width, mp->height); + } +#endif + } + res = TRUE; +done: if(dev != NULL) XFree(dev); + GRX_RETURN(res); +} + +static void reset(void) +{ + XDGADevice *dev; + GRX_ENTER(); + if(_XGrDisplay != NULL) { + XUngrabPointer(_XGrDisplay, CurrentTime); + XUngrabKeyboard(_XGrDisplay, CurrentTime); +#ifdef XF86DGA_FRAMEBUFFER + XDGACloseFramebuffer(_XGrDisplay, _XGrScreen); +#endif + dev = XDGASetMode(_XGrDisplay, _XGrScreen, 0); + if(dev != NULL) XFree(dev); + XCloseDisplay(_XGrDisplay); + } + _XGrDisplay = NULL; + _XGrColormap = None; + _GR_firstFreeColor = 0; + _GR_lastFreeColor = -1; + GRX_LEAVE(); +} + +static int detect(void) +{ + int res; + int event, error; + int major, minor; + GRX_ENTER(); + if(_XGrDisplay == NULL) { + res = FALSE; +#ifdef XF86DGA_FRAMEBUFFER + if(geteuid()) { + DBGPRINTF(DBG_DRIVER, ("root priviledges required\n")); + goto done; + } +#endif + if((_XGrDisplay = XOpenDisplay("")) == NULL) { + DBGPRINTF(DBG_DRIVER, ("can't connect to X server\n")); + goto done; + } + if(!XDGAQueryExtension(_XGrDisplay, &event, &error)) { + DBGPRINTF(DBG_DRIVER, ("can't query DGA extension\n")); + goto done; + } + if(!XDGAQueryVersion(_XGrDisplay, &major, &minor)) { + DBGPRINTF(DBG_DRIVER, ("can't query DGA version\n")); + goto done; + } + if(major < 2) { + DBGPRINTF(DBG_DRIVER, + ("required DGA version 2.0, detected %d.%d\n", + major, minor)); + goto done; + } + } + res = TRUE; +done: if(!res) reset(); + GRX_RETURN(res); +} + +#ifndef XF86DGA_FRAMEBUFFER +static void setbank(int bk) +{} + +static void setrwbanks(int rb,int wb) +{} +#endif + +static void loadcolor(int c,int r,int g,int b) +{ + XColor xcolor; + + if(_XGrColormap != None) { + xcolor.pixel = c; + xcolor.red = r * 257; + xcolor.green = g * 257; + xcolor.blue = b * 257; + xcolor.flags = DoRed | DoGreen | DoBlue; + XStoreColor(_XGrDisplay, _XGrColormap, &xcolor); + } +} + +#ifdef XF86DGA_FRAMEBUFFER +#define GRFRAMEDRIVER(bpp) GR_frameSVGA##bpp##_LFB +#else +#define GRFRAMEDRIVER(bpp) GR_frameXWIN##bpp +#endif + +static int build_video_mode(XDGAMode *ip, GrVideoMode *mp, GrVideoModeExt *ep) +{ + mp->present = TRUE; + mp->bpp = ip->depth; + mp->width = ip->viewportWidth; + mp->height = ip->viewportHeight; + mp->mode = ip->num; + mp->lineoffset = ip->bytesPerScanline; + mp->privdata = 0; + mp->extinfo = NULL; + + ep->drv = NULL; + ep->frame = NULL; +#ifdef XF86DGA_FRAMEBUFFER + ep->flags = GR_VMODEF_LINEAR; +#else + ep->flags = 0; +#endif + ep->setup = setmode; + ep->setvsize = NULL; + ep->scroll = NULL; +#ifdef XF86DGA_FRAMEBUFFER + ep->setbank = NULL; + ep->setrwbanks = NULL; +#else + ep->setbank = setbank; + ep->setrwbanks = setrwbanks; +#endif + ep->loadcolor = NULL; + + if(ip->visualClass != (mp->bpp == 8 ? PseudoColor : TrueColor)) { + DBGPRINTF(DBG_DRIVER, ("%d: visual class %s depth %d unsupported\n", + ip->num, _XGrClassNames[ip->visualClass], + mp->bpp)); + return(FALSE); + } + +#ifndef XF86DGA_FRAMEBUFFER + if(!(ip->flags & XDGAPixmap)) { + DBGPRINTF(DBG_DRIVER, ("%d: rendering with XLib impossible\n", + ip->num)); + return(FALSE); + } +#endif + + switch(mp->bpp) { + case 8 : + ep->mode = GRFRAMEDRIVER(8); + ep->cprec[0] = + ep->cprec[1] = + ep->cprec[2] = 6; + ep->cpos[0] = + ep->cpos[1] = + ep->cpos[2] = 0; + ep->loadcolor = loadcolor; + break; + case 15 : + ep->mode = GRFRAMEDRIVER(16); + ep->cprec[0] = + ep->cprec[1] = + ep->cprec[2] = 5; + ep->cpos[0] = 10; + ep->cpos[1] = 5; + ep->cpos[2] = 0; + break; + case 16 : + ep->mode = GRFRAMEDRIVER(16); + ep->cprec[0] = 5; + ep->cprec[1] = 6; + ep->cprec[2] = 5; + ep->cpos[0] = 11; + ep->cpos[1] = 5; + ep->cpos[2] = 0; + break; + case 24 : + ep->cprec[0] = + ep->cprec[1] = + ep->cprec[2] = 8; + ep->cpos[0] = 16; + ep->cpos[1] = 8; + ep->cpos[2] = 0; + ep->mode = GRFRAMEDRIVER(24); + if(ip->bitsPerPixel == 32) { + mp->bpp = 32; + ep->mode = GRFRAMEDRIVER(32L); + if(ip->redMask == 0xFF000000) { + ep->cpos[0] = 24; + ep->cpos[1] = 16; + ep->cpos[2] = 8; + ep->mode = GRFRAMEDRIVER(32H); + } + } + break; + default: + return(FALSE); + } + + return(TRUE); +} + +GrVideoModeExt grtextextdga = { + GR_frameText, /* frame driver */ + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + { 0, 0, 0 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +#define NUM_MODES 200 /* max # of supported modes */ +#define NUM_EXTS 10 /* max # of mode extensions */ + +static GrVideoModeExt exts[NUM_EXTS]; +static GrVideoMode modes[NUM_MODES] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + { TRUE, 8, 80, 25, 0x00, 80, 1, &grtextextdga }, + { 0 } +}; + +/* from svgalib.c, unmodified */ +static void add_video_mode( + GrVideoMode *mp, GrVideoModeExt *ep, + GrVideoMode **mpp,GrVideoModeExt **epp +) { + if(*mpp < &modes[NUM_MODES]) { + if(!mp->extinfo) { + GrVideoModeExt *etp = &exts[0]; + while(etp < *epp) { + if(memcmp(etp,ep,sizeof(GrVideoModeExt)) == 0) { + mp->extinfo = etp; + break; + } + etp++; + } + if(!mp->extinfo) { + if(etp >= &exts[NUM_EXTS]) return; + sttcopy(etp,ep); + mp->extinfo = etp; + *epp = ++etp; + } + } + sttcopy(*mpp,mp); + (*mpp)++; + } +} + +static int init(char *options) +{ + int res; + XDGAMode *modev = NULL; + int modec, mindex; + GrVideoMode mode, *modep = &modes[1]; + GrVideoModeExt ext, *extp = &exts[0]; + GRX_ENTER(); + res = FALSE; + if(detect()) { + _XGrScreen = DefaultScreen(_XGrDisplay); + _XGrWindow = DefaultRootWindow(_XGrDisplay); +#ifdef XF86DGA_FRAMEBUFFER + if(!XDGAOpenFramebuffer(_XGrDisplay, _XGrScreen)) { + DBGPRINTF(DBG_DRIVER, ("can't open framebuffer\n")); + goto done; + } +#endif + modev = XDGAQueryModes(_XGrDisplay, _XGrScreen, &modec); + if(modev == NULL) { + DBGPRINTF(DBG_DRIVER, ("can't query DGA modes")); + goto done; + } + memzero(modep,(sizeof(modes) - sizeof(modes[0]))); + for(mindex = 0; mindex < modec; mindex++) { + if(!build_video_mode(&modev[mindex], &mode, &ext)) continue; + add_video_mode(&mode,&ext,&modep,&extp); + } + _XGrWindowedMode = 0; + _XGrColormap = None; +#ifndef XF86DGA_FRAMEBUFFER + _XGrColorNumPixels = 0; +#endif + res = TRUE; + } +done: if(modev != NULL) XFree(modev); + if(!res) reset(); + GRX_RETURN(res); +} + +GrVideoDriver _GrVideoDriverXF86DGA = { + "xf86dga", /* name */ + GR_XWIN, /* adapter type */ + NULL, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + detect, /* detection routine */ + init, /* initialization routine */ + reset, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/vd_xwin.c b/thirdparty/grx249/src/vdrivers/vd_xwin.c new file mode 100644 index 0000000..f73652e --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/vd_xwin.c @@ -0,0 +1,547 @@ +/** + ** vd_xwin.c ---- the standard X Window driver + ** + ** Author: Ulrich Leodolter + ** E-mail: ulrich@lab1.psy.univie.ac.at + ** Date: Thu Sep 28 09:29:26 1995 + ** RCSId: $Id: vd_xwin.c 1.2 1995/11/19 19:28:12 ulrich Exp $ + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: + ** 070505 M.Alvarez, Using a Pixmap for BackingStore + ** 071201 M.Alvarez, Added videomodes for wide monitors + ** 071201 M.Alvarez, The modes higher than the X resolution + ** are made 'non-present' + ** 071201 M.Alvarez, go to fullscreen if w,h == X resolution + ** GR_biggest_graphics is honored + **/ + +#include "libgrx.h" +#include "libxwin.h" +#include "grdriver.h" +#include "arith.h" + +Display * _XGrDisplay; +int _XGrScreen; +Window _XGrWindow; +Pixmap _XGrBitmap; +Pixmap _XGrPattern; +Pixmap _XGrBStore; +Colormap _XGrColormap; +GC _XGrGC; +GC _XGrBitmapGC; +GC _XGrPatternGC; +XIM _XGrXim = NULL; +XIC _XGrXic = NULL; +unsigned long _XGrForeColor; +unsigned long _XGrBackColor; +unsigned int _XGrColorOper; +unsigned int _XGrDepth; +unsigned int _XGrBitsPerPixel; +unsigned int _XGrScanlinePad; +unsigned int _XGrMaxWidth; +unsigned int _XGrMaxHeight; +int _XGrBStoreInited = 0; +int _XGrFullScreen = 0; + +unsigned long _XGrColorPlanes[8]; +unsigned int _XGrColorNumPlanes; +unsigned long _XGrColorPixels[2]; +unsigned int _XGrColorNumPixels; + +char *_XGrClassNames[6] = { + "StaticGray", + "GrayScale", + "StaticColor", + "PseudoColor", + "TrueColor", + "DirectColor" +}; + +static void setbank(int bk); +static void setrwbanks(int rb,int wb); +static void loadcolor(int c,int r,int g,int b); +static int setmode(GrVideoMode *mp,int noclear); + +GrVideoModeExt grtextext = { + GR_frameText, /* frame driver */ + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + { 0, 0, 0 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + NULL, /* bank set function */ + NULL, /* double bank set function */ + NULL /* color loader */ +}; + +static GrVideoModeExt grxwinext = { + GR_frameUndef, /* frame driver */ + NULL, /* frame driver override */ + NULL, /* frame buffer address */ + { 0, 0, 0 }, /* color precisions */ + { 0, 0, 0 }, /* color component bit positions */ + 0, /* mode flag bits */ + setmode, /* mode set */ + NULL, /* virtual size set */ + NULL, /* virtual scroll */ + setbank, /* bank set function */ + setrwbanks, /* double bank set */ + loadcolor /* color loader */ +}; + +static GrVideoMode modes[] = { + /* pres. bpp wdt hgt BIOS scan priv. &ext */ + { TRUE, 8, 80, 25, 0x00, 80, 1, &grtextext }, + { FALSE, 0, 320, 240, 0x00, 0, 0, &grxwinext }, + { FALSE, 0, 640, 480, 0x00, 0, 0, &grxwinext }, + { FALSE, 0, 800, 600, 0x00, 0, 0, &grxwinext }, + { FALSE, 0, 1024, 768, 0x00, 0, 0, &grxwinext }, + { FALSE, 0, 1280, 1024, 0x00, 0, 0, &grxwinext }, + { FALSE, 0, 1600, 1200, 0x00, 0, 0, &grxwinext }, + { FALSE, 0, 1440, 900, 0x00, 0, 0, &grxwinext }, + { FALSE, 0, 1680, 1050, 0x00, 0, 0, &grxwinext }, + { FALSE, 0, 1920, 1200, 0x00, 0, 0, &grxwinext }, + { FALSE, 0, 2560, 1600, 0x00, 0, 0, &grxwinext }, + { FALSE, 0, 9999, 9999, 0x00, 0, 0, &grxwinext } +}; + +static void goto_fullscreen(Display *dsp, Window win) +{ + XEvent xev; + Atom wm_state = XInternAtom(dsp, "_NET_WM_STATE", False); + Atom fullscreen = XInternAtom(dsp, "_NET_WM_STATE_FULLSCREEN", False); + memset(&xev, 0, sizeof(xev)); + xev.type = ClientMessage; + xev.xclient.window = win; + xev.xclient.message_type = wm_state; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD + xev.xclient.data.l[1] = fullscreen; + xev.xclient.data.l[2] = 0; + XSendEvent(dsp, DefaultRootWindow(dsp), False, + SubstructureNotifyMask, &xev); +} + +static void returnfrom_fullscreen(Display *dsp, Window win) +{ + XEvent xev; + Atom wm_state = XInternAtom(dsp, "_NET_WM_STATE", False); + Atom fullscreen = XInternAtom(dsp, "_NET_WM_STATE_FULLSCREEN", False); + memset(&xev, 0, sizeof(xev)); + xev.type = ClientMessage; + xev.xclient.window = win; + xev.xclient.message_type = wm_state; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 0; // _NET_WM_STATE_REMOVE + xev.xclient.data.l[1] = fullscreen; + xev.xclient.data.l[2] = 0; + XSendEvent(dsp, DefaultRootWindow(dsp), False, + SubstructureNotifyMask, &xev); +} + +static void setbank(int bk) +{} + +static void setrwbanks(int rb,int wb) +{} + +static void loadcolor(int c,int r,int g,int b) +{ + GRX_ENTER(); + if ( _XGrDisplay != NULL + && _XGrColormap != None + && ! ( _XGrColorNumPixels == 1 + && (c < _XGrColorPixels[0] || c > _XGrColorPixels[1])) ) { + XColor xcolor; + + DBGPRINTF(DBG_DRIVER,("Setting X11 color %d to r=%d, g=%d, b=%d\n",c,r,g,b)); + xcolor.pixel = c; + xcolor.red = r * 257; + xcolor.green = g * 257; + xcolor.blue = b * 257; + xcolor.flags = DoRed|DoGreen|DoBlue; + XStoreColor (_XGrDisplay, _XGrColormap, &xcolor); + } + GRX_LEAVE(); +} + +static int setmode(GrVideoMode *mp,int noclear) +{ + char name[100], *window_name, *icon_name; + int res; + + GRX_ENTER(); + res = FALSE; + if (_XGrWindow != None) { + + if (_XGrFullScreen) { + returnfrom_fullscreen(_XGrDisplay, _XGrWindow); + _XGrFullScreen = 0; + } + XUnmapWindow (_XGrDisplay, _XGrWindow); + if (_XGrBStoreInited) { + XFreePixmap(_XGrDisplay, _XGrBStore); + XFreeGC(_XGrDisplay, _XGrGC); + _XGrBStoreInited = 0; + } + + if (mp->extinfo->mode != GR_frameText) { + XSizeHints hints; + + XResizeWindow (_XGrDisplay, _XGrWindow, mp->width, mp->height); + if (USE_PIXMAP_FOR_BS ) { + _XGrBStore = XCreatePixmap (_XGrDisplay, _XGrWindow, mp->width, mp->height, _XGrDepth); + _XGrGC = XCreateGC (_XGrDisplay, _XGrBStore, 0L, NULL); + _XGrBStoreInited = 1; + XFillRectangle (_XGrDisplay, _XGrBStore, _XGrGC, 0, 0, mp->width, mp->height); + grxwinext.frame = (char *) _XGrBStore; + } + + sprintf (name, "grx %dx%dx%d", mp->width, mp->height, mp->bpp); + window_name = name; + icon_name = name; + + hints.min_width = mp->width; + hints.max_width = mp->width; + hints.min_height = mp->height; + hints.max_height = mp->height; + hints.flags = PMaxSize | PMinSize; + + XSetStandardProperties (_XGrDisplay, /* display */ + _XGrWindow, /* w */ + window_name, /* window_name */ + icon_name, /* icon_name */ + None, /* icon_pixmap */ + NULL, /* argv */ + 0, /* argc */ + &hints); /* hints */ + + XMapRaised (_XGrDisplay, _XGrWindow); + + /* Wait until window appears on screen */ + { + XEvent xevent; + + while (1) { + XNextEvent (_XGrDisplay, &xevent); + if (xevent.type == MapNotify) + break; + } + } + + /* Go to fullscreen if w,h == X resolution */ + if ((mp->width == _XGrMaxWidth) && (mp->height == _XGrMaxHeight)) { + goto_fullscreen(_XGrDisplay, _XGrWindow); + _XGrFullScreen = 1; + } + } + res = TRUE; + } + GRX_RETURN(res); +} + +static int (*previous_error_handler) (Display *dpy, XErrorEvent *ev); + +static int error_handler (Display *dpy, XErrorEvent *ev) +{ + char buffer[200]; + + /* + * This error is triggerd in fd_xwin.c:bltv2r() if the source rectangle + * is not fully contained in the root window + */ + if (ev->request_code == X_GetImage && ev->error_code == BadMatch) + return 0; + + if (previous_error_handler) + return (*previous_error_handler) (dpy, ev); + + XGetErrorText (dpy, ev->error_code, buffer, sizeof(buffer)), + fprintf (stderr, "GRX: XError: %s XID=%ld request_code=%d serial=%lu\n", + buffer, + ev->resourceid, + ev->request_code, + ev->serial); + return 0; +} + +static GrVideoMode * _xw_selectmode ( GrVideoDriver * drv, int w, int h, int bpp, + int txt, unsigned int * ep ) +{ + GrVideoMode *mp, *res; + GRX_ENTER(); + if (txt) { + res = _gr_selectmode(drv,w,h,bpp,txt,ep); + goto done; + } + for (mp = &modes[1]; mp < &modes[itemsof(modes)-1]; mp++) { + if ( mp->present && mp->width == w && mp->height == h) { + res = _gr_selectmode (drv,w,h,bpp,txt,ep); + goto done; + } + } + /* no predefined mode found. Create a new mode */ + mp->present = TRUE; + mp->width = (w > _XGrMaxWidth) ? _XGrMaxWidth : w; + mp->height = (h > _XGrMaxHeight) ? _XGrMaxHeight : h; + mp->lineoffset = (mp->width * mp->bpp) / 8; + res = _gr_selectmode (drv,w,h,bpp,txt,ep); +done: + GRX_RETURN(res); +} + +static int detect(void) +{ + int res; + GRX_ENTER(); + res = (getenv("DISPLAY") ? TRUE : FALSE); + GRX_RETURN(res); +} + +static int init(char *options) +{ + Window root; + XSetWindowAttributes attr; + unsigned long mask; + Visual *visual; + XPixmapFormatValues *pfmt; + int pfmt_count; + GrVideoMode *mp; + unsigned int depth, bpp, pad; + int private_colormap; + int i, j, res; + + + GRX_ENTER(); + res = FALSE; + private_colormap = FALSE; + _XGrDisplay = XOpenDisplay (""); + if (_XGrDisplay == NULL) + goto done; /* FALSE */ + + previous_error_handler = XSetErrorHandler (error_handler); + + _XGrScreen = DefaultScreen (_XGrDisplay); + _XGrDepth = depth = DefaultDepth (_XGrDisplay, _XGrScreen); + _XGrMaxWidth = DisplayWidth(_XGrDisplay, _XGrScreen); + _XGrMaxHeight = DisplayHeight(_XGrDisplay, _XGrScreen); + + visual = DefaultVisual (_XGrDisplay, _XGrScreen); + root = RootWindow (_XGrDisplay, _XGrScreen); + + if (options && (strncmp ("privcmap", options, 8) == 0)) { + private_colormap = TRUE; + } + + _XGrColorNumPlanes = 0; + _XGrColorNumPixels = 0; + + if (visual->class == PseudoColor + && (depth == 4 || depth == 8)) { + if (! private_colormap) { + /* + * Allocate at least 4 planes (= 16 colors) of writable cells + */ + _XGrColormap = DefaultColormap (_XGrDisplay, _XGrScreen); + for (i = depth - 1; i >= 4; i--) { + if (XAllocColorCells (_XGrDisplay, + _XGrColormap, + True, /* contiguous */ + _XGrColorPlanes, + i, + _XGrColorPixels, + 1)) { + _XGrColorNumPlanes = i; + _XGrColorNumPixels = 1; + _GR_firstFreeColor = _XGrColorPixels[0]; + _XGrColorPixels[1] = _XGrColorPixels[0]; + for (j = 0; j < _XGrColorNumPlanes; j++) { + _XGrColorPixels[1] |= _XGrColorPlanes[j]; + } + _GR_lastFreeColor = _XGrColorPixels[1]-1; + break; + } + } + if (_XGrColorNumPlanes == 0) + private_colormap = TRUE; + } + if (private_colormap) { + _XGrColormap = XCreateColormap (_XGrDisplay, root, visual, AllocAll); + } + grxwinext.cprec[0] = visual->bits_per_rgb; + grxwinext.cprec[1] = visual->bits_per_rgb; + grxwinext.cprec[2] = visual->bits_per_rgb; + grxwinext.cpos[0] = 0; + grxwinext.cpos[1] = 0; + grxwinext.cpos[2] = 0; + /* loadcolor (0, 0, 0, 0); */ /* load black */ + } + else if (visual->class == TrueColor + && (depth == 8 || depth == 15 || depth == 16 || depth == 24)) { + int i, pos, prec; + unsigned long mask[3]; + + _XGrColormap = (Colormap) 0; + mask[0] = visual->red_mask; + mask[1] = visual->green_mask; + mask[2] = visual->blue_mask; + for (i = 0; i < 3; i++) { + for (pos = 0; !(mask[i] & 1); pos++, mask[i]>>=1); + for (prec = 0; (mask[i] & 1); prec++, mask[i]>>=1); + grxwinext.cprec[i] = prec; + grxwinext.cpos[i] = pos; + } + } + else { + XCloseDisplay (_XGrDisplay); + fprintf (stderr, "GRX init: Visual class=%s depth=%d not supported\n", + _XGrClassNames[visual->class], depth); + exit (1); + } + _XGrForeColor = GrNOCOLOR; /* force XSetForeground */ + _XGrBackColor = GrNOCOLOR; /* force XSetBackground */ + _XGrColorOper = C_WRITE; + + mask = 0L; + attr.backing_store = NotUseful; + mask |= CWBackingStore; + if (_XGrColormap) { + attr.colormap = _XGrColormap; + mask |= CWColormap; + } + attr.background_pixel = 0L; + mask |= CWBackPixel; + attr.border_pixel = 0L; + mask |= CWBorderPixel; + attr.event_mask = (StructureNotifyMask + | KeyPressMask + | KeyReleaseMask + | ButtonPressMask + | ButtonReleaseMask + | ButtonMotionMask + | ExposureMask + | PointerMotionMask); + mask |= CWEventMask; + _XGrWindow = XCreateWindow (_XGrDisplay, + root, /* parent */ + 0, /* x */ + 0, /* y */ + 1, /* width */ + 1, /* height */ + 0, /* border_width */ + depth, /* depth */ + InputOutput, /* class */ + visual, /* visual */ + mask, /* valuemask */ + &attr); /* attributes */ + _XGrBitmap = XCreatePixmap (_XGrDisplay, root, 128, 128, 1); + _XGrBitmapGC = XCreateGC (_XGrDisplay, _XGrBitmap, 0L, NULL); + _XGrPattern = XCreatePixmap (_XGrDisplay, root, 8, 1, 1); + _XGrPatternGC = XCreateGC (_XGrDisplay, _XGrPattern, 0L, NULL); + + if (!USE_PIXMAP_FOR_BS) { + _XGrGC = XCreateGC (_XGrDisplay, _XGrWindow, 0L, NULL); + grxwinext.frame = (char *) _XGrWindow; + } + + /* is this required ?? */ + if (_XGrColormap) { + XInstallColormap(_XGrDisplay, _XGrColormap); + XSetWindowColormap(_XGrDisplay, _XGrWindow, _XGrColormap); + } + + pfmt = XListPixmapFormats (_XGrDisplay, &pfmt_count); + if (!pfmt || pfmt_count <= 0) { + XCloseDisplay (_XGrDisplay); + fprintf (stderr, "GRX init: cannot list pixmap formats\n"); + exit (1); + } + + bpp = 0; + pad = 0; + for (i = 0; i < pfmt_count; i++) { + if (pfmt[i].depth == depth) + { + bpp = pfmt[i].bits_per_pixel; + pad = pfmt[i].scanline_pad; + break; + } + } + XFree (pfmt); + if (!bpp) { + XCloseDisplay (_XGrDisplay); + fprintf (stderr, "GRX init: cannot find pixmap format\n"); + exit (1); + } + + switch (depth) { + case 1: grxwinext.mode = GR_frameXWIN1; break; + case 4: grxwinext.mode = GR_frameXWIN4; break; + case 8: grxwinext.mode = GR_frameXWIN8; break; + case 15: + case 16: grxwinext.mode = GR_frameXWIN16; break; + case 24: + switch (bpp) { + case 24: grxwinext.mode = GR_frameXWIN24; break; + case 32: grxwinext.mode = + (visual->red_mask & 0xff000000) ? GR_frameXWIN32H : GR_frameXWIN32L; break; + } + break; + } + + _XGrBitsPerPixel = bpp; + _XGrScanlinePad = pad; + + /* fixed size modes */ + for (mp = &modes[1]; mp < &modes[itemsof(modes)-1]; mp++) { + mp->present = TRUE; + mp->bpp = bpp; + mp->lineoffset = (mp->width * bpp) / 8; + if (mp->width > _XGrMaxWidth) mp->present = FALSE; + if (mp->height > _XGrMaxHeight) mp->present = FALSE; + } + /* this is the variable size mode */ + mp->present = FALSE; + mp->bpp = bpp; + mp->lineoffset = 0; + res = TRUE; +done: + GRX_RETURN( res ); +} + +static void reset(void) +{ + GRX_ENTER(); + if (_XGrDisplay) XCloseDisplay (_XGrDisplay); + _XGrDisplay = NULL; + _GR_firstFreeColor = 0; + _GR_lastFreeColor = -1; + GRX_LEAVE(); +} + +GrVideoDriver _GrVideoDriverXWIN = { + "xwin", /* name */ + GR_XWIN, /* adapter type */ + NULL, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + detect, /* detection routine */ + init, /* initialization routine */ + reset, /* reset routine */ + _xw_selectmode, /* special mode select routine */ + GR_DRIVERF_USER_RESOLUTION /* arbitrary resolution possible */ +}; + diff --git a/thirdparty/grx249/src/vdrivers/vesa.c b/thirdparty/grx249/src/vdrivers/vesa.c new file mode 100644 index 0000000..c0c4252 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/vesa.c @@ -0,0 +1,458 @@ +/** + ** vesa.c ---- the GRX 2.0 VESA BIOS interface + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + **/ + +#include + +#include "libgrx.h" +#include "grdriver.h" +#include "arith.h" +#include "int86.h" +#include "ioport.h" +#include "memcopy.h" +#include "memfill.h" +#include "vesa.h" + +#if defined(__GNUC__) || (defined(__WATCOMC__) && defined(__386__)) +#define NUM_MODES 100 /* max # of supported modes */ +#define NUM_EXTS 25 /* max # of mode extensions */ +#else +#define NUM_MODES 40 /* max # of supported modes */ +#define NUM_EXTS 12 /* max # of mode extensions */ +#endif + +static GrVideoMode modes[NUM_MODES]; +static GrVideoModeExt exts[NUM_EXTS]; + +static unsigned char _GrVidDrvVESAflags = 0; +#define HICOLOR32K 0x01 +#define PROTBANKING 0x02 +#define USE_REALMODE 0x04 +#define NOT_LINEAR 0x08 +#define NO_8BIT_DAC 0x10 + +static char fast256 = 0; +static char varDAC = FALSE; +static unsigned long VRAMsize = 0; +static int VESAversion; +static int nexts; + +/* VESA driver (and others) need this information for paging */ +int _GrVidDrvVESAbanksft = (-1); +int _GrVidDrvVESArdbank; +int _GrVidDrvVESAwrbank; + +/* these variables hold the correct paging functions: +** +** Turbo-C : normal bios access or direct function call +** GNU-C : normal real mode bios access or protected mode banking +*/ +static void (*_SETRWBANKS)(int rb, int wb); +static void (*_SETBANK)(int bk); + + +/* get the real mode stuff ... */ +#include "vesa_rm.c" + +#if (defined(__WATCOMC__) && defined (__386__)) \ + || (defined(DJGPP) && defined(DJGPP_MINOR)) +#define HAVE_VBE2 +/* get the VBE2 protected mode stuff ... */ +#include "vesa_pm.c" + +# define MC(a,b) a##b +# define MODE(md) ((ep->flags & GR_VMODEF_LINEAR) ? MC(md,_LFB) : md) + +#else /* no protected mode support */ +# define _SETUP _GrViDrvSetEGAVGAmode +# define reset _GrViDrvResetEGAVGA +# define MODE(md) (md) +#endif + + +static int detect(void) +{ + if(_GrViDrvDetectVGA()) { + VESAvgaInfoBlock blk; + if(_GrViDrvVESAgetVGAinfo(&blk)) return(TRUE); + } + return(FALSE); +} + + +/* special setup: check for 8bit DAC in palette modes */ +static int setup48(GrVideoMode *mp,int noclear) { + int res = _SETUP(mp, noclear); + DBGPRINTF(DBG_DRIVER,("setup48 called\n")); + if (res) { + mp->extinfo->cprec[0] = + mp->extinfo->cprec[1] = + mp->extinfo->cprec[2] = 6; + _GrViDrvSetDACshift(8-6); + if (varDAC) { + /* have variable DAC, try setting 8bit per color component */ + Int86Regs r; + sttzero(&r); + IREG_AX(r) = VESA_FUNC + VESA_PAL_CNTRL; + IREG_BX(r) = 0x0800; /* BL = 0 -> set DAC width, BH=8 -> req. width */ + DBGPRINTF(DBG_DRIVER,("Variable DAC\n")); +#ifdef __WATCOMC__ + int10x(&r); +#else + int10(&r); +#endif + if(IREG_AX(r) == VESA_SUCCESS) { + DBGPRINTF(DBG_DRIVER,("Variable DAC initialised\n")); + _GrViDrvSetDACshift(8-IREG_BH(r)); + mp->extinfo->cprec[0] = + mp->extinfo->cprec[1] = + mp->extinfo->cprec[2] = IREG_BH(r); + } + } + } + DBGPRINTF(DBG_DRIVER,("setup48 complete\n")); + return res; +} + + +static int build_video_mode( VESAmodeInfoBlock *ip, + GrVideoMode *mp, GrVideoModeExt *ep) +{ + int banksft = 0; + int rdbank = (-1); + int wrbank = (-1); + mp->present = TRUE; + mp->width = ip->XResolution; + mp->height = ip->YResolution; + mp->bpp = ip->BitsPerPixel; + mp->lineoffset = ip->BytesPerScanLine; + mp->extinfo = NULL; + mp->privdata = 0; + if(!(ip->ModeAttributes & MODE_ISGRAPHICS)) { + mp->extinfo = &_GrViDrvEGAVGAtextModeExt; + return(TRUE); + } + if(ip->WinSize != 64) return(FALSE); + while((ip->WinGranularity << banksft) < 64) banksft++; + if((ip->WinGranularity << banksft) != 64) return(FALSE); + if(ip->WinAAttributes & WIN_SUPPORTED) { + if(ip->WinAAttributes & WIN_WRITABLE) wrbank = 0; + if(ip->WinAAttributes & WIN_READABLE) rdbank = 0; + } + if(ip->WinBAttributes & WIN_SUPPORTED) { + if(ip->WinBAttributes & WIN_WRITABLE) wrbank = 1; + if(ip->WinBAttributes & WIN_READABLE) rdbank = 1; + } + if(wrbank < 0) return(FALSE); + if(rdbank >= 0) { + if(rdbank == wrbank) rdbank = (-1); + if(ip->WinASegment != ip->WinBSegment) rdbank = (-1); + } + if(_GrVidDrvVESAbanksft >= 0) { + if(banksft != _GrVidDrvVESAbanksft) return(FALSE); + if(wrbank != _GrVidDrvVESAwrbank) return(FALSE); + if(rdbank != _GrVidDrvVESArdbank) return(FALSE); + } + _GrVidDrvVESAbanksft = banksft; + _GrVidDrvVESAwrbank = wrbank; + _GrVidDrvVESArdbank = rdbank; + + ep->mode = GR_frameUndef; + ep->drv = NULL; + ep->frame = MK_FP((wrbank ? ip->WinBSegment : ip->WinASegment),0); + ep->flags = 0; + ep->cprec[0] = ep->cprec[1] = ep->cprec[2] = 6; + ep->cpos[0] = ep->cpos[1] = ep->cpos[2] = 0; + +#ifdef __TURBOC__ + if ( _GrVidDrvVESAflags & PROTBANKING) { + if(VESAbankfn && (VESAbankfn != ip->WinFuncPtr)) { + _GrVidDrvVESAflags &= ~PROTBANKING; + _SETRWBANKS = RM_setrwbanks; + _SETBANK = RM_setbank; + } else { + VESAbankfn = ip->WinFuncPtr; + _SETRWBANKS = RM_protsetrwbanks; + _SETBANK = RM_protsetbank; + } + } +#endif +#ifdef HAVE_VBE2 + if(!(_GrVidDrvVESAflags&NOT_LINEAR) && VESAversion>=VESA_VERSION(2,0)) { + /* check for linear frame buffer */ + if (ip->ModeAttributes&MODE_LIN_FRAME) { + DBGPRINTF(DBG_DRIVER,("Linear mode at 0x%08x\n", ip->LinearFrameBuffer)); + map_linear(ip->LinearFrameBuffer,VRAMsize, + &LFB_Selector, &LFB_LinearAddress); + DBGPRINTF(DBG_DRIVER,("Linear mode mapped to selector 0x%08x, linear address 0x%08x\n", LFB_Selector, LFB_LinearAddress)); + ep->LFB_Selector=LFB_Selector; + if (LFB_Selector >= 0 && LFB_LinearAddress) { + /* every thing went well: allow linear frame buffer access */ + ep->flags |= GR_VMODEF_LINEAR; + ep->frame = LFB_virtualAddr(); + } + } + } +#endif + ep->setup = _SETUP; + ep->setvsize = _GrViDrvVESAsetVirtualSize; + ep->scroll = _GrViDrvVESAvirtualScroll; + ep->setbank = _SETBANK; + ep->setrwbanks = (rdbank >= 0) ? _SETRWBANKS : NULL; + ep->loadcolor = NULL; + switch(ip->BitsPerPixel) { + case 4: + if(ip->MemoryModel != MODEL_4PLANE) return(FALSE); + if(ip->NumberOfPlanes != 4) return(FALSE); + ep->mode = GR_frameSVGA4; + ep->loadcolor = _GrViDrvLoadColorVGA4; + ep->flags = 0; /* no LFB with 4bit modes */ + ep->setup = setup48; + break; + case 8: + if(ip->MemoryModel != MODEL_PACKED) return(FALSE); + if(ip->NumberOfPlanes != 1) return(FALSE); + ep->mode = MODE(GR_frameSVGA8); + ep->loadcolor = _GrViDrvLoadColorVGA8; + ep->flags |= fast256; + ep->setup = setup48; + break; + case 15: + case 16: + case 24: + case 32: + if((ip->MemoryModel != MODEL_PACKED) && + (ip->MemoryModel != MODEL_DIRECT)) return(FALSE); + if(ip->NumberOfPlanes != 1) return(FALSE); + mp->bpp = ip->BitsPerPixel; + switch (ip->BitsPerPixel) { + case 32: if(VESAversion < VESA_VERSION(1,2)) + return(FALSE); + if (ip->ReservedMaskSize != 8) + return(FALSE); + switch (ip->ReservedMaskPos) { + case 24: ep->mode = MODE(GR_frameSVGA32L); + break; + case 0: ep->mode = MODE(GR_frameSVGA32H); + break; + default: return(FALSE); + } + mp->bpp = 24; + break; + case 24: ep->mode = MODE(GR_frameSVGA24); + break; + case 16: if (ip->ReservedMaskSize == 1) mp->bpp = 15; + goto Default; + default: + Default: ep->mode = MODE(GR_frameSVGA16); + break; + } + if(VESAversion < VESA_VERSION(1,2)) { + if(ip->BitsPerPixel == 24 || ip->BitsPerPixel == 32) { + ep->cprec[0] = 8; ep->cpos[0] = 16; + ep->cprec[1] = 8; ep->cpos[1] = 8; + ep->cprec[2] = 8; ep->cpos[2] = 0; + break; + } + if((ip->BitsPerPixel==15) || (_GrVidDrvVESAflags&HICOLOR32K)) { + mp->bpp = 15; + ep->cprec[0] = 5; ep->cpos[0] = 10; + ep->cprec[1] = 5; ep->cpos[1] = 5; + ep->cprec[2] = 5; ep->cpos[2] = 0; + break; + } + mp->bpp = 16; + ep->cprec[0] = 5; ep->cpos[0] = 11; + ep->cprec[1] = 6; ep->cpos[1] = 5; + ep->cprec[2] = 5; ep->cpos[2] = 0; + break; + } + ep->cprec[0] = ip->RedMaskSize; ep->cpos[0] = ip->RedMaskPos; + ep->cprec[1] = ip->GreenMaskSize; ep->cpos[1] = ip->GreenMaskPos; + ep->cprec[2] = ip->BlueMaskSize; ep->cpos[2] = ip->BlueMaskPos; + break; + default: + return(FALSE); + } + DBGPRINTF(DBG_DRIVER,("build_video_mode complete\n" )); + return(TRUE); +} + +static void add_video_mode( + GrVideoMode *mp, GrVideoModeExt *ep, + GrVideoMode **mpp,GrVideoModeExt **epp +){ + if(*mpp < &modes[NUM_MODES]) { + if(!mp->extinfo) { + GrVideoModeExt *etp = &exts[0]; + while(etp < *epp) { + if(memcmp(etp,ep,sizeof(GrVideoModeExt)) == 0) { + mp->extinfo = etp; + break; + } + etp++; + } + if(!mp->extinfo) { + if(etp >= &exts[NUM_EXTS]) return; + sttcopy(etp,ep); + mp->extinfo = etp; + *epp = ++etp; + } + } + sttcopy(*mpp,mp); + (*mpp)++; + } +} + +static int get_tweaked_text_mode(GrVideoMode *mp,GrVideoMode *etable) +{ + if(etable < &modes[NUM_MODES]) { + GrVideoMode *m1,*m2; + for(m1 = modes; m1 < etable; m1++) { + if((m1->present) && + (m1->extinfo) && + (m1->extinfo->mode == GR_frameText) && + (m1->height == 25) && + (m1->width > 80)) { + VESAmodeInfoBlock mdinfo; + if((_GrViDrvVESAgetModeInfo(m1->mode,&mdinfo)) && + (mdinfo.ModeAttributes & MODE_EXTINFO) && + (mdinfo.YCharSize == 16)) { + int h,exists = FALSE; + for(h = 28; h <= 50; h += (50 - 28)) { + for(m2 = modes; m2 < etable; m2++) { + if((m2->present) && + (m2->extinfo) && + (m2->extinfo->mode == GR_frameText) && + (m2->height == h) && + (m2->width == m1->width) && + (m2->bpp == m1->bpp)) { + exists = TRUE; + break; + } + } + if(!exists) { + sttcopy(mp,m1); + mp->height = h; + mp->extinfo = &_GrViDrvEGAVGAcustomTextModeExt; + return(TRUE); + } + } + } + } + } + } + return(FALSE); +} + +/* This code will fail if the controller is not VGA compatible. +** One should get the VESA info first and check the Capability +** flags for VGA base controller. If not VGA based all functions +** must use BIOS calls (eg. DAC programming), no tweaked modes, +** don't inherit EGA/VGA modes +** Don't know if (and how) this should be done (hsc 970710) */ +static int init(char *options) +{ + DBGPRINTF(DBG_DRIVER,("options: \"%s\"\n",options)); + if(_GrViDrvInitEGAVGA(options)) { + VESAvgaInfoBlock blk; + memzero(modes,sizeof(modes)); + memzero(exts,sizeof(exts)); + nexts = 0; + if(_GrViDrvVESAgetVGAinfo(&blk)) { + VESAmodeInfoBlock mdinfo; + GrVideoMode mode,*modep = &modes[0]; + GrVideoModeExt ext, *extp = &exts[0]; + short far *mp; + VRAMsize = blk.MemorySize; + VRAMsize <<= 16; + _GrVidDrvVESAflags = 0; + _GrVidDrvVESAbanksft = (-1); + VESAversion = blk.VESAversion; + DBGPRINTF(DBG_DRIVER,("VESAversion = %d.%d\n", + VESA_VERSION_MAJOR(VESAversion), + VESA_VERSION_MINOR(VESAversion) )); + DBGPRINTF(DBG_DRIVER,("VRAMsize = %lu bytes\n", VRAMsize)); + if(options) while(*options != '\0') { + switch(*options) { + case '5': + _GrVidDrvVESAflags |= HICOLOR32K; + DBGPRINTF(DBG_DRIVER,("option '5': setting HICOLOR32K\n")); + break; + case 'p': + case 'P': + DBGPRINTF(DBG_DRIVER,("option 'p': setting PROTBANKING\n")); + _GrVidDrvVESAflags |= PROTBANKING; + break; + case 'f': + case 'F': + fast256 = GR_VMODEF_FAST_SVGA8; + break; + case 'r': + case 'R': + _GrVidDrvVESAflags |= USE_REALMODE; + break; + case 'b': + case 'B': + _GrVidDrvVESAflags |= NOT_LINEAR; + break; + } + options++; + } + /* set up default banking function */ + _SETRWBANKS = RM_setrwbanks; + _SETBANK = RM_setbank; +#ifdef HAVE_VBE2 + /* Check out and set up VBE 2+ portected mode banking */ + if ( !(_GrVidDrvVESAflags & USE_REALMODE) ) + VBE2ProtMode(); +#endif + /* Check for variable width DAC */ + varDAC = (_GrVidDrvVESAflags & NO_8BIT_DAC) == 0 + && (blk.Capabilities & CAP_DAC_WIDTH) != 0; + for(mp = blk.VideoModePtr; *mp != (-1); mp++) { + mode.mode = *mp; + if(!_GrViDrvVESAgetModeInfo(*mp,&mdinfo)) continue; + if(!(mdinfo.ModeAttributes & MODE_EXTINFO)) continue; + if(!build_video_mode(&mdinfo,&mode,&ext)) continue; + add_video_mode(&mode,&ext,&modep,&extp); + } + while(get_tweaked_text_mode(&mode,modep)) { + add_video_mode(&mode,&ext,&modep,&extp); + } + nexts = (int)(extp-exts); + } + return(TRUE); + } + return(FALSE); +} + +GrVideoDriver _GrVideoDriverVESA = { + "VESA", /* name */ + GR_VGA, /* adapter type */ + &_GrVideoDriverSTDVGA, /* inherit modes from this driver */ + modes, /* mode table */ + itemsof(modes), /* # of modes */ + detect, /* detection routine */ + init, /* initialization routine */ + reset, /* reset routine */ + _gr_selectmode, /* standard mode select routine */ + 0 /* no additional capabilities */ +}; diff --git a/thirdparty/grx249/src/vdrivers/vesa.txt b/thirdparty/grx249/src/vdrivers/vesa.txt new file mode 100644 index 0000000..db3e5ee --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/vesa.txt @@ -0,0 +1,336 @@ +This is from VGADOC 4b + +I changed the 104F0A description hsc@techfak.uni-kiel.de +******************************************************** + +The VESA BIOS interface is a software interface for detection capabilities, +setting modes and setting the bank register. + +VESA 1.0 VESA Standard #VS891001 +VESA 1.1 VESA Standard #VS900602 +VESA 1.2 VESA Standard #VS911022 +VESA 2.0 VESA Standard + +----------104F00----------------------------- +INT 10 - VESA SuperVGA BIOS - GET SuperVGA INFORMATION + AX = 4F00h + ES:DI -> 256-byte buffer for SuperVGA information (see below) +Return: AL = 4Fh function supported + AH = status + 00h successful + 01h failed + 02h (VBE 2) function not supported by current hardware config + 03h (VBE 2) function invalid in current mode + +Format of SuperVGA information: +Offset Size Description + 00h 4 BYTEs Signature ('VESA'). For VBE 2.0 this field must be set to + "VBE2" before the call to fill in the version 2.0 fields + 04h WORD VESA version number + 06h DWORD pointer to OEM name + 0Ah 4 BYTEs capabilities. + Bit 0 Set if the DAC can switch width, clear if it is + fixed 6bits per primary color + 1 (VBE2) non-VGA controller + 2 (VBE2) Programmed DAC with blank bit + 0Eh DWORD pointer to list of supported VESA and OEM video modes + Terminated with 0FFFFh. + 12h WORD Video memory in 64k blocks +--- VBE v2.0 --- + 14h WORD OEM software version + 16h DWORD Pointer to vendor name + 1Ah DWORD Pointer to product name + 1Eh DWORD Pointer to product revision string +100h 256 BYTEs OEM scratchpad +The buffer is defined as 256bytes for version 1.0 & 1.2, 262 bytes for version + 1.1 and 512 bytes for version 2.0. Note: Some VESA drivers have been known to + write beoynd the end of the official buffer. +----------104F01----------------------------- +INT 10 - VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION + AX = 4F01h + CX = SuperVGA video mode + ES:DI -> 256-byte buffer mode information (see below) +Return: AL = 4Fh function supported + AH = status + 00h successful + 01h failed + +Format of mode information: +Offset Size Description + 00h WORD mode attributes + bit 0: mode supported if set + 1: optional information available if set + 2: BIOS output supported if set + 3: set if color, clear if monochrome + 4: set if graphics mode, clear if text mode + 5: (VBE2) non-VGA mode + 6: (VBE2) No bank swiotching supported + 7: (VBE2) Linear framebuffer mode supported + 02h BYTE window A attributes + bit 0: exists if set + 1: readable if set + 2: writable if set + bits 3-7 reserved + 03h BYTE window B attributes (as for window A) + 04h WORD window granularity in K + 06h WORD window size in K + 08h WORD start segment of window A + 0Ah WORD start segment of window B + 0Ch DWORD -> FAR window positioning function (equivalent to AX=4F05h) + 10h WORD bytes per scan line +---remainder is optional for VESA modes, needed for OEM modes--- + 12h WORD width in pixels + 14h WORD height in pixels + 16h BYTE width of character cell in pixels + 17h BYTE height of character cell in pixels + 18h BYTE number of memory planes + 19h BYTE number of bits per pixel + 1Ah BYTE number of banks + 1Bh BYTE memory model type + 0 Text + 1 CGA graphics + 2 Hercules Graphics + 3 EGA 16 color + 4 Packed pixels + 5 Non chain 4 256 color modes + 6 Direct 15/16/24 bit + 7 YUV (luminance-chrominance, alos called YIQ) + 8-0Fh Reserved for VESA + 10h-0FFh Reserved for OEM + 1Ch BYTE size of bank in K + 1Dh BYTE number of image pages + 1Eh BYTE reserved(1) +------VBE v1.2+ -------------------------- + 1Fh BYTE Red mask size + 20h BYTE Red mask position + 21h BYTE Green mask size + 22h BYTE Green mask position + 23h BYTE Blue mask size + 24h BYTE Blue mask position + 25h BYTE Reserved mask size + 26h BYTE Reserved mask position + 27h BYTE Direct Screen mode info + Bit 0 If set the color ramp is programmable, if clear fixed + 1 If set the reserved field (as defined by Bytes 25-26h) + can be used by the application, if clear the field is + truly reserved. +--- VBE v2.0 --- + 28h DWORD Physical address of linear video buffer + 2Ch DWORD Pointer to start of offscreen memory + 30h WORD Offscreen memory in Kbytes +The buffer is defined as 256bytes +----------104F02----------------------------- +INT 10 - VESA SuperVGA BIOS - SET SuperVGA VIDEO MODE + AX = 4F02h + BX = mode + bit 15 set means don't clear video memory + bit 14 (VBE2) set to enable linear framebuffer mode +Return: AL = 4Fh function supported + AH = status + 00h successful + 01h failed + +Values for VESA video mode: + 00h-FFh OEM video modes (see AH=00h) + 100h 640x400x256 + 101h 640x480x256 + 102h 800x600x16 + 103h 800x600x256 + 104h 1024x768x16 + 105h 1024x768x256 + 106h 1280x1024x16 + 107h 1280x1024x256 + 108h 80x60 text + 109h 132x25 text + 10Ah 132x43 text + 10Bh 132x50 text + 10Ch 132x60 text + ------------ VBE v1.2+ ------------------ + 10Dh 320x200 32k + 10Eh 320x200 64k + 10Fh 320x200 16M + 110h 640x480 32k + 111h 640x480 64k + 112h 640x480 16M + 113h 800x600 32k + 114h 800x600 64k + 115h 800x600 16M + 116h 1024x768 32k + 117h 1024x768 64k + 118h 1024x768 16M + 119h 1280x1024 32k + 11Ah 1280x1024 64k + 11Bh 1280x1024 16M + ------------ VBE 2.0 -------------------- +81FFh Special full-memory access mode + Mode 81FFh preserves the contents of video memory and gives access to + the entire video memory. It is recommanded that mode 81FFh should be a + packed pixel mode. + +----------104F03----------------------------- +INT 10 - VESA SuperVGA BIOS - GET CURRENT VIDEO MODE + AX = 4F03h +Return: AL = 4Fh function supported + AH = status + 00h successful + 01h failed + BX = video mode (see AX=4F02h) +----------104F04----------------------------- +INT 10 - VESA SuperVGA BIOS - SAVE/RESTORE SuperVGA VIDEO STATE + AX = 4F04h + DL = subfunction + 00h get state buffer size + Return: BX = number of 64-byte blocks needed + 01h save video states + ES:BX -> buffer + 02h restore video states + ES:BX -> buffer + CX = flags for states to save/restore + bit 0: video hardware state + bit 1: video BIOS data state + bit 2: video DAC state + bit 3: SuperVGA state +Return: AL = 4Fh function supported + AH = status + 00h successful + 01h failed +----------104F05----------------------------- +INT 10 - VESA SuperVGA BIOS - CPU VIDEO MEMORY CONTROL + AX = 4F05h + BH = subfunction + 00h select video memory window + DX = window address in video memory (in granularity units) + 01h get video memory window + Return: DX = window address in video memory (in gran. units) + BL = window number + 00h window A + 01h window B +Return: AL = 4Fh function supported + AH = status + 00h successful + 01h failed +----------104F06----------------------------- +INT 10 - VESA SuperVGA BIOS 1.1+ - GET/SET LOGICAL SCAN LINE LENGTH + AX = 4F06h + BL = function + 00h set scan line length + CX = desired width in pixels + 01h get scan line length + 02h (VBE 2) set scan line length + CX = desired width in bytes + 03h (VBE 2) get maximum scan line length +Return: AL = 4Fh if function supported + AH = status + 00h successful + 01h failed + BX = bytes per scan line + Maximum bytes per scan line for function 03h + CX = number of pixels per scan line + Maximum pixels per scan line for function 03h + DX = maximum number of scan lines + Unchaqnged for function 03h +Notes: if the desired width is not achievable, the next larger width will be + set. The scan line may be wider than the visible area of the screen + this function is valid in text modes, provided that values are + multiplied by the character cell width/height +----------104F07BH00------------------------- +INT 10 - VESA SuperVGA BIOS 1.1+ - GET/SET DISPLAY START + AX = 4F07h + BH = 00h (reserved) + BL = 00h (or 80h) set display start + CX = leftmost displayed pixel in scan line + DX = first displayed scan line + = 01h get display start + Return: BH = 00h + CX = leftmost displayed pixel in scan line + DX = first displayed scan line +Return: AL = 4Fh if function supported + AH = status + 00h successful + 01h failed +Note: this function is valid in text modes, provided that values are + multiplied by the character cell width/height +----------104F08----------------------------- +INT 10 - VESA SuperVGA BIOS v1.2+ - GET/SET DAC PALETTE CONTROL + AX = 4F08h + BL = function + 00h Set DAC palette width + BH = desired number of bits per primary color. + 01h Get DAC palette width +Return: AL = 4Fh if function supported + AH = status + BH = Current number of bits per primary color (6 = Standard VGA) +----------104F09----------------------------- +INT 10 - VESA SuperVGA BIOS v2.0+ - GET/SET PALETTE ENTRIES + AX = 4F09h + BL = function + 00h set palette + 01h get palette + 02h set secondary palette data + 03h get secondary palette data + 80h set palette during vertical retrace + CX = number of entries to change + DX = starting palette index + ES:DI -> palette buffer (array of 4 bytes per entry) + Offset Size Description + 00h BYTE Red byte + 01h BYTE Green byte + 02h BYTE Blue byte + 03h BYTE Alpha or alignment byte +Return: AL = 4Fh if function supported + AH = status + 00h successful + 01h failed +----------104F0A----------------------------- +INT 10 - VESA SuperVGA BIOS v2.0+ - GET PROTECTED-MODE CODE + AX = 4F0Ah + BX = subfunction code + 0000h Return protected mode table + +Return: AL = 4Fh if function supported + AH = status + 00h successful + BX=0000h + CX = total number of bytes in table + ES:DI -> base address of PM info table : + +00 word off. to PM set window func, see 104F05 + +02 word off. to PM set display start func, see 104F07 + +04 word off. to PM set primary palette func, see 104F09 + +06 word off. to PM resource table (word,word,...): + ,...,<0xFFFF>, + ,,...,<0xFFFF> + 01h failed +----------104F10----------------------------- +INT 10 - VESA DPMS - Display Power Management Extensions + AX = 4F10h + BL = 00h Report VBE/PM Capabilities + ES:DI = 0000h:0000h + Return: BH = Power saving state signals supported: + Bit 0 STAND BY supported if set + 1 SUSPEND supported if set + 2 OFF supported if set + 3 REDUCED On supported if set + (Not supported in DPMS 1.0) + BL = VBE/PM Version number: + Bit 0-3 Minor version + 4-7 Major version + 01h Set Display Power State + BH = Requested Power State: + 00h ON + 01h STAND BY + 02h SUSPEND + 04h OFF + 08h REDUCED ON (for flat screens) + 02h Get Display Power State + Return: BH = Display Power State + 00h ON + 01h STAND BY + 02h SUSPEND + 04h OFF + 08h REDUCED ON (for flat screens) +Return: AL = 4Fh if function supported + AH = status +----------104FFF----------------------------- +INT 10 - VESA SuperVGA BIOS - Everex - TURN VESA ON/OFF + AX = 4FFFh + DL = new state (00h off, 01h on) diff --git a/thirdparty/grx249/src/vdrivers/vesa_pm.c b/thirdparty/grx249/src/vdrivers/vesa_pm.c new file mode 100644 index 0000000..d1a4129 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/vesa_pm.c @@ -0,0 +1,548 @@ +/** + ** vesa_pm.c ---- the GRX 2.0 VBE2 BIOS interface: protected mode stuff + ** + ** Watcom C++ 11.0 DOS4GW by Gary Sands [gsands@stbni.co.uk] + ** DJGPP v2 by Andrzej Lawa [FidoNet: Andrzej Lawa 2:480/19.77] + ** and Hartmut Schirmer (hsc@techfak.uni-kiel.de) + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +/* memory information for linear frame buffer access */ +static int LFB_Selector = -1; +static unsigned long LFB_LinearAddress = 0; + +/* memory information for protected mode ** +** (VESA 2.0) banking with memory mapped i/o */ +int MEM_IO_sel = -1; +unsigned long MEM_IO_la = 0; + +/* memory for portected mode banking, virtual ** +** screen handling and palette manipulation */ +static void *PM_base = NULL; +static int PM_base_len = 0; +static void *PM_banking_ptr = NULL; +/* +static void *PM_dstart_ptr = NULL; +static void *PM_palette_ptr = NULL; +*/ + +/* ----------------------------------------------------------- DPMI stuff -- */ + +#ifdef __DJGPP__ +#define WHO_AM_I "DJGPP" +#include + +/* we do selector based video access with DJGPP. ** +** The selector gives access to full video ram ** +** starting at offset 0 */ +#define LFB_virtualAddr() ((void *) 0) + +#endif + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +#if defined(__WATCOMC__) && defined(__386__) + +#define WHO_AM_I "WATCOM" + +#ifndef MAKELONG +#define MAKELONG(a, b) ((long) (((unsigned short) (a)) \ + | ((unsigned long) ((unsigned short) (b))) << 16)) +#endif + +#ifndef LOWORD +#define LOWORD(l) ((unsigned short) (l & 0xffff)) +#endif + +#ifndef HIWORD +#define HIWORD(l) ((unsigned short) (((unsigned long) (l) >> 16) & 0xffff)) +#endif + +/* DPMI structures */ +typedef struct { + unsigned long handle; /* 0, 2 */ + unsigned long size; /* or count */ /* 4, 6 */ + unsigned long address; /* 8, 10 */ +} __dpmi_meminfo; + + +/* DPMI functions */ +unsigned short __dpmi_error; + +int __dpmi_allocate_ldt_descriptors( int _count ) +{ + /* variables */ + auto Int86Regs DpmiRegs; + /* code */ + DBGPRINTF(DBG_DRIVER, ("WATCOM __dpmi_allocate_ldt_descriptors\n")); + sttzero((&DpmiRegs)); + IREG_AX(DpmiRegs) = 0x0; /*function code*/ + IREG_CX(DpmiRegs) = _count; + int386 ( 0x31, &(DpmiRegs.Normal), &(DpmiRegs.Normal) ); + if ( DpmiRegs.Normal.w.cflag ) + { + __dpmi_error = IREG_AX(DpmiRegs); + return -1; + } + return IREG_AX(DpmiRegs); +} + +int __dpmi_free_ldt_descriptor ( int _descriptor ) +{ + /* variables */ + auto Int86Regs DpmiRegs; + /* code */ + DBGPRINTF(DBG_DRIVER, ("WATCOM __dpmi_free_ldt_descriptors\n")); + sttzero((&DpmiRegs)); + IREG_AX(DpmiRegs) = 0x1; /*function code*/ + IREG_BX(DpmiRegs) = _descriptor; + int386 ( 0x31, &(DpmiRegs.Normal), &(DpmiRegs.Normal) ); + if ( DpmiRegs.Normal.w.cflag ) + { + __dpmi_error = IREG_AX(DpmiRegs); + return -1; + } + return 0; +} + +int __dpmi_get_segment_base_address ( int _selector, unsigned long *_addr ) +{ + /* variables */ + auto Int86Regs DpmiRegs; + /* code */ + DBGPRINTF(DBG_DRIVER, ("WATCOM __dpmi_get_segment_base_address\n")); + sttzero((&DpmiRegs)); + IREG_AX(DpmiRegs) = 0x6; /* function code */ + IREG_BX(DpmiRegs) = _selector; + int386 ( 0x31, &(DpmiRegs.Normal), &(DpmiRegs.Normal) ); + if ( DpmiRegs.Normal.w.cflag ) + { + __dpmi_error = IREG_AX(DpmiRegs); + return -1; + } + *_addr = MAKELONG( IREG_DX(DpmiRegs), IREG_CX(DpmiRegs) ); + return 0; +} + +int __dpmi_set_segment_base_address ( int _selector, unsigned long _address ) +{ + /* variables */ + auto Int86Regs DpmiRegs; + /* code */ + DBGPRINTF(DBG_DRIVER, ("WATCOM __dpmi_set_segment_base_address\n")); + sttzero((&DpmiRegs)); + IREG_AX(DpmiRegs) = 0x7; /*function code*/ + IREG_BX(DpmiRegs) = _selector; + IREG_CX(DpmiRegs) = HIWORD(_address); + IREG_DX(DpmiRegs) = LOWORD(_address); + int386 ( 0x31, &(DpmiRegs.Normal), &(DpmiRegs.Normal) ); + if ( DpmiRegs.Normal.w.cflag ) + { + __dpmi_error = IREG_AX(DpmiRegs); + return -1; + } + return 0; +} + +int __dpmi_set_segment_limit ( int _selector, unsigned long _limit ) +{ + /* variables */ + auto Int86Regs DpmiRegs; + /* code */ + DBGPRINTF(DBG_DRIVER, ("WATCOM __dpmi_set_segment_limit\n")); + sttzero((&DpmiRegs)); + IREG_AX(DpmiRegs) = 0x9; /*function code*/ + IREG_BX(DpmiRegs) = _selector; + IREG_CX(DpmiRegs) = HIWORD(_limit); + IREG_DX(DpmiRegs) = LOWORD(_limit); + int386 ( 0x31, &(DpmiRegs.Normal), &(DpmiRegs.Normal) ); + if ( DpmiRegs.Normal.w.cflag ) + { + __dpmi_error = IREG_AX(DpmiRegs); + return -1; + } + return 0; +} + +int __dpmi_lock_linear_region ( __dpmi_meminfo *_info ) +{ + /* variables */ + auto Int86Regs DpmiRegs; + /* code */ + DBGPRINTF(DBG_DRIVER, ("WATCOM __dpmi_lock_linear_region\n")); + sttzero((&DpmiRegs)); + IREG_AX(DpmiRegs) = 0x600; /*function code*/ + IREG_BX(DpmiRegs) = HIWORD(_info->address); + IREG_CX(DpmiRegs) = LOWORD(_info->address); + IREG_SI(DpmiRegs) = HIWORD(_info->size); + IREG_DI(DpmiRegs) = LOWORD(_info->size); + int386 ( 0x31, &(DpmiRegs.Normal), &(DpmiRegs.Normal) ); + if ( DpmiRegs.Normal.w.cflag ) + { + __dpmi_error = IREG_AX(DpmiRegs); + return -1; + } + return 0; +} + +int __dpmi_unlock_linear_region ( __dpmi_meminfo *_info ) +{ + /* variables */ + auto Int86Regs DpmiRegs; + /* code */ + DBGPRINTF(DBG_DRIVER, ("WATCOM __dpmi_unlock_linear_region\n")); + sttzero((&DpmiRegs)); + IREG_AX(DpmiRegs) = 0x601; /*function code*/ + IREG_BX(DpmiRegs) = HIWORD(_info->address); + IREG_CX(DpmiRegs) = LOWORD(_info->address); + IREG_SI(DpmiRegs) = HIWORD(_info->size); + IREG_DI(DpmiRegs) = LOWORD(_info->size); + int386 ( 0x31, &(DpmiRegs.Normal), &(DpmiRegs.Normal) ); + if ( DpmiRegs.Normal.w.cflag ) + { + __dpmi_error = IREG_AX(DpmiRegs); + return -1; + } + return 0; +} + +int __dpmi_physical_address_mapping ( __dpmi_meminfo *_info ) +{ + /* variables */ + auto Int86Regs DpmiRegs; + /* code */ + DBGPRINTF(DBG_DRIVER, ("WATCOM __dpmi_physical_address_mapping\n")); + sttzero((&DpmiRegs)); + IREG_AX(DpmiRegs) = 0x800; /*function code*/ + IREG_BX(DpmiRegs) = HIWORD(_info->address); + IREG_CX(DpmiRegs) = LOWORD(_info->address); + IREG_SI(DpmiRegs) = HIWORD(_info->size); + IREG_DI(DpmiRegs) = LOWORD(_info->size); + int386 ( 0x31, &(DpmiRegs.Normal), &(DpmiRegs.Normal) ); + if ( DpmiRegs.Normal.w.cflag ) + { + __dpmi_error = IREG_AX(DpmiRegs); + return -1; + } + _info->address = MAKELONG( IREG_CX(DpmiRegs), IREG_BX(DpmiRegs) ); + return 0; +} + +int __dpmi_free_physical_address_mapping ( __dpmi_meminfo *_info ) +{ + /* variables */ + auto Int86Regs DpmiRegs; + /* code */ + DBGPRINTF(DBG_DRIVER, ("WATCOM __dpmi_free_physical_address_mapping\n")); + sttzero((&DpmiRegs)); + IREG_AX(DpmiRegs) = 0x801; /*function code*/ + IREG_BX(DpmiRegs) = HIWORD(_info->address); + IREG_CX(DpmiRegs) = LOWORD(_info->address); + int386 ( 0x31, &(DpmiRegs.Normal), &(DpmiRegs.Normal) ); + if ( DpmiRegs.Normal.w.cflag ) + { + __dpmi_error = IREG_AX(DpmiRegs); + return -1; + } + return 0; +} + +int _go32_dpmi_lock_data ( void *_lockaddr, unsigned long _locksize ) +{ + /* variables */ + auto __dpmi_meminfo _lockme; + /* code */ + DBGPRINTF(DBG_DRIVER, ("WATCOM _go32_dpmi_lock_data\n")); + _lockme.address = (unsigned long)_lockaddr; + _lockme.size = _locksize; + return __dpmi_lock_linear_region ( &_lockme ); +} + +int _go32_my_ds ( void ) +{ + /* variables */ + short my_ds = 0; + /* code */ + DBGPRINTF(DBG_DRIVER, ("WATCOM _go32_my_ds\n")); + _asm + { + mov my_ds, ds + } + return ( (int)my_ds ); +} + +/* Watcom C++ maps the physical video memory to a ** +** virtual address in linear address space */ +#define LFB_virtualAddr() ((void *) LFB_LinearAddress) + +#endif /* __WATCOMC__ && __386__ */ + +/* ------------------------------------------------------------- */ +/* memory access helper functions */ +static int map_linear(unsigned long adr, unsigned long len, + int *sel, unsigned long *la ) { + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " map_linear\n")); + if(*sel<0) { + *sel = __dpmi_allocate_ldt_descriptors(1); + if (*sel<0) return FALSE; + } + if(!*la) { + __dpmi_meminfo meminfo; + meminfo.address = adr; + meminfo.size = len; + if(__dpmi_physical_address_mapping(&meminfo)==-1) { + return FALSE; + } + if(__dpmi_set_segment_base_address(*sel,meminfo.address)==-1) { + return FALSE; + } + if(__dpmi_set_segment_limit(*sel,len-1)==-1) { + return FALSE; + } + *la=meminfo.address; + } + return TRUE; +} + +static void free_linear(int *sel, unsigned long *la) { + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " free_linear\n")); + if(*la) { + __dpmi_meminfo meminfo; + meminfo.address = *la; + __dpmi_free_physical_address_mapping(&meminfo); + *la = 0; + } + if(*sel >= 0) { + __dpmi_free_ldt_descriptor(*sel); + *sel = -1; + } +} + +/* ------------------------------------------------------------- */ + +static void PM_free(void) { + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " PM_free\n")); + free_linear(&MEM_IO_sel, &MEM_IO_la); + if (PM_base != NULL) { + unsigned long baseaddr; + __dpmi_meminfo mem; + __dpmi_get_segment_base_address(_go32_my_ds(), &baseaddr); + mem.address = baseaddr + (unsigned long)PM_base; + mem.size = PM_base_len; + __dpmi_unlock_linear_region(&mem); + free(PM_base); + } + PM_base = NULL; +} + +static int PM_alloc(int len) { + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " PM_alloc\n")); + PM_base_len = len; + PM_base = malloc(PM_base_len); + if (PM_base == NULL) return 0; + _go32_dpmi_lock_data(PM_base, PM_base_len); + return 1; +} + +/* ------------------------------------------------------------- */ +/* protected mode banking */ + +#if defined(__GNUC__) && defined(__i386__) +static INLINE void PM_banking(short BX, short DX) { + __asm__ volatile ( + " pushal \n" + " call *%3 \n" + " popal " + : /* no output */ + : "a" (0x4F05), "b" (BX), "d" (DX), + "r" (PM_banking_ptr) + ); +} + +static INLINE void PM_es_banking(short es, short BX, short DX) { + __asm__ volatile ( + " pushal \n" + " movw %%ax, %%es \n" + " movw $0x4f05, %%ax \n" + " call *%3 \n" + " popal " + : /* no output */ + : "a" (es), "b" (BX), "d" (DX), + "r" (PM_banking_ptr) + ); +} +#endif /* __GNUC__ && __i386__ */ + +#if defined(__WATCOMC__) && defined(__386__) +static void PM_banking(short myBX, short myDX) { + _asm + { + pusha + mov ax, 4f05h + mov bx, myBX + mov dx, myDX + call PM_banking_ptr + popa + } +} + +static void PM_es_banking(short myES, short myBX, short myDX) { + _asm + { + pusha + mov ax, myES + mov es, ax + mov ax, 4f05h + mov bx, myBX + mov dx, myDX + call PM_banking_ptr + popa + } +} +#endif /* __WATCOMC__ && __386__ */ + +static void PM_setrwbanks(int rb,int wb) { + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " PM_setrwbanks\n")); + PM_banking( _GrVidDrvVESAwrbank, wb << _GrVidDrvVESAbanksft); + PM_banking( _GrVidDrvVESArdbank, rb << _GrVidDrvVESAbanksft); + setup_far_selector(SCRN->gc_selector); +} + +static void PM_setbank(int bk) { + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " PM_setbank\n")); + PM_banking( _GrVidDrvVESAwrbank, bk << _GrVidDrvVESAbanksft); + if(_GrVidDrvVESArdbank >= 0) + PM_banking( _GrVidDrvVESArdbank, bk << _GrVidDrvVESAbanksft); + setup_far_selector(SCRN->gc_selector); +} + + +static void PM_es_setrwbanks(int rb,int wb) { + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " PM_es_setrwbanks\n")); + PM_es_banking(MEM_IO_sel, _GrVidDrvVESAwrbank, wb << _GrVidDrvVESAbanksft); + PM_es_banking(MEM_IO_sel, _GrVidDrvVESArdbank, rb << _GrVidDrvVESAbanksft); + setup_far_selector(SCRN->gc_selector); +} + +static void PM_es_setbank(int bk) { + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " PM_es_setbank\n")); + PM_es_banking(MEM_IO_sel, _GrVidDrvVESAwrbank, bk << _GrVidDrvVESAbanksft); + if(_GrVidDrvVESArdbank >= 0) + PM_es_banking(MEM_IO_sel, _GrVidDrvVESArdbank, bk << _GrVidDrvVESAbanksft); + setup_far_selector(SCRN->gc_selector); +} + + +static void VBE2ProtMode(void) { + /* VBE 2.0+ may provide protected mode banking functions */ + VESApmInfoBlock *PMinfo; + unsigned long MS_ptr = 0; + unsigned short MS_len = 0; + + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " VBE2ProtMode\n")); + if (PM_base != NULL) return; + + /* Default: INT 10H based bank switching */ + _SETRWBANKS = RM_setrwbanks; + _SETBANK = RM_setbank; + + if ( (PMinfo=_GrViDrvVESAgetPMinfo()) == NULL) return; + if (PMinfo->SubTable_off != 0x0000) { + GR_int16u *subtab = ptradd(&PMinfo->SetWindow_off,PMinfo->SubTable_off); + long bytes_left = (long)PMinfo->PhysicalLength + - (long)PMinfo->SubTable_off; + /* Skip over port info but don't leave VBE2PM data */ + while (bytes_left >= 2 && peek_w(subtab) != 0xffff) { + ptrinc(subtab,2); + bytes_left -= 2; + } + /* skip 0xffff end marker */ + ptrinc(subtab,2); + bytes_left -= 2; + /* check for memory mapped IO: ** + ** 4 bytes for memory mapped IO base ** + ** 2 bytes for memory mapped IO length */ + if (bytes_left >= 4+2 && peek_w(subtab) != 0xffff) { + /* The memory location area isn't empty. The VESA bios + * bios requires an additional memory selector set up in ES */ + MS_ptr = peek_l(subtab); + ptrinc(subtab,4); + MS_len = peek_w(subtab); + /* MS_ptr == 0 -> no mem area */ + } + } + if (!PM_alloc(PMinfo->PhysicalLength)) return; + memcpy(PM_base, &PMinfo->SetWindow_off, PMinfo->PhysicalLength); + PM_banking_ptr = ptradd(PM_base, PMinfo->SetWindow_off); +/* + PM_dstart_ptr = ptradd(PM_base, PMinfo->DisplStart_off); + PM_palette_ptr = ptradd(PM_base, PMinfo->PPalette_off); +*/ + if (MS_ptr && MS_len) { + if (!map_linear(MS_ptr, MS_len, &MEM_IO_sel, &MEM_IO_la)) return; + _SETRWBANKS = PM_es_setrwbanks; + _SETBANK = PM_es_setbank; + } else { + _SETRWBANKS = PM_setrwbanks; + _SETBANK = PM_setbank; + } +} + + +static int _SETUP(GrVideoMode *mp,int noclear) { + int res = 0; + + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " _SETUP\n")); + if ( mp->extinfo->flags&GR_VMODEF_LINEAR && + mp->extinfo->mode != GR_frameText ) { + Int86Regs r; + sttzero(&r); + IREG_AX(r) = VESA_FUNC + VESA_SET_MODE; + IREG_BX(r) = (mp->mode & 0x7fff) + | (noclear ? 0x8000U : 0) + | 0x4000U; + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " _SETUP calling int10\n")); +# if defined(__WATCOMC__) + int10x(&r); +# else + int10(&r); +# endif + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " _SETUP int10 called\n")); + res = IREG_AX(r) == VESA_SUCCESS; + } else + res = _GrViDrvSetEGAVGAmode(mp,noclear); + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " _SETUP finished\n")); + return res; +} + +static void reset(void) { + int i; + + _SETRWBANKS = RM_setrwbanks; + _SETBANK = RM_setbank; + + DBGPRINTF(DBG_DRIVER, (WHO_AM_I " reset\n")); + for (i=0; i < nexts; ++i) { + exts[i].setbank = NULL; + exts[i].setrwbanks = NULL; + } + + PM_free(); + PM_banking_ptr = NULL; +/* + PM_dstart_ptr = NULL; + PM_palette_ptr = NULL; +*/ + free_linear(&LFB_Selector, &LFB_LinearAddress); + _GrViDrvResetEGAVGA(); +} diff --git a/thirdparty/grx249/src/vdrivers/vesa_rm.c b/thirdparty/grx249/src/vdrivers/vesa_rm.c new file mode 100644 index 0000000..c42a5e6 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/vesa_rm.c @@ -0,0 +1,85 @@ +/** + ** vesa_rm.c ---- the GRX 2.0 VESA BIOS interface: real mode banking code + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Contributions by: (See "doc/credits.doc" for details) + ** Hartmut Schirmer (hsc@techfak.uni-kiel.de) + **/ + +static void RM_setbank(int bk) +{ + Int86Regs r; + + sttzero(&r); + IREG_AX(r) = VESA_FUNC + VESA_PAGE_CTL; + IREG_BX(r) = _GrVidDrvVESAwrbank; + IREG_DX(r) = bk << _GrVidDrvVESAbanksft; + int10(&r); + if(_GrVidDrvVESArdbank >= 0) { + IREG_AX(r) = VESA_FUNC + VESA_PAGE_CTL; + IREG_BX(r) = _GrVidDrvVESArdbank; + IREG_DX(r) = bk << _GrVidDrvVESAbanksft; + int10(&r); + } + setup_far_selector(SCRN->gc_selector); +} + +static void RM_setrwbanks(int rb,int wb) +{ + Int86Regs r; + + sttzero(&r); + IREG_AX(r) = VESA_FUNC + VESA_PAGE_CTL; + IREG_BX(r) = _GrVidDrvVESAwrbank; + IREG_DX(r) = wb << _GrVidDrvVESAbanksft; + int10(&r); + IREG_AX(r) = VESA_FUNC + VESA_PAGE_CTL; + IREG_BX(r) = _GrVidDrvVESArdbank; + IREG_DX(r) = rb << _GrVidDrvVESAbanksft; + int10(&r); + setup_far_selector(SCRN->gc_selector); +} + +#ifdef __TURBOC__ + +static void far (*VESAbankfn)(void); + +static void RM_protsetbank(int bk) +{ + _DX = bk << _GrVidDrvVESAbanksft; + _BX = _GrVidDrvVESAwrbank; + _AX = VESA_FUNC + VESA_PAGE_CTL; + (*VESAbankfn)(); + if(_GrVidDrvVESArdbank >= 0) { + _DX = bk << _GrVidDrvVESAbanksft; + _BX = _GrVidDrvVESArdbank; + _AX = VESA_FUNC + VESA_PAGE_CTL; + (*VESAbankfn)(); + } +} + +static void RM_protsetrwbanks(int rb,int wb) +{ + _DX = wb << _GrVidDrvVESAbanksft; + _BX = _GrVidDrvVESAwrbank; + _AX = VESA_FUNC + VESA_PAGE_CTL; + (*VESAbankfn)(); + _DX = rb << _GrVidDrvVESAbanksft; + _BX = _GrVidDrvVESArdbank; + _AX = VESA_FUNC + VESA_PAGE_CTL; + (*VESAbankfn)(); +} + +#endif diff --git a/thirdparty/grx249/src/vdrivers/vtable.c b/thirdparty/grx249/src/vdrivers/vtable.c new file mode 100644 index 0000000..76aabe0 --- /dev/null +++ b/thirdparty/grx249/src/vdrivers/vtable.c @@ -0,0 +1,57 @@ +/** + ** vtable.c ---- a table of available video drivers + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "grdriver.h" + +GrVideoDriver *_GrVideoDriverTable[] = { +#if defined(__MSDOS__) + &_GrVideoDriverHERC, + &_GrVideoDriverSTDEGA, + &_GrVideoDriverSTDVGA, + &_GrVideoDriverVESA, + &_GrVideoDriverATI28800, + &_GrVideoDriverET4000, + &_GrVideoDriverCL5426, + &_GrVideoDriverMACH64, + &_GrVideoDriverS3, +#endif +#if defined(__XWIN__) && !defined(__SDL__) +#if defined(XF86DGA_DRIVER) + &_GrVideoDriverXF86DGA, +#endif + &_GrVideoDriverXWIN, +#endif +#if defined(__linux__) && !defined(__XWIN__) && !defined(__SDL__) +#ifdef SVGALIB_DRIVER + &_GrVideoDriverSVGALIB, +#endif +#ifdef FRAMEBUFFER_DRIVER + &_GrVideoDriverLINUXFB, +#endif +#endif +#if defined(__WIN32__) && !defined(__SDL__) + &_GrVideoDriverWIN32, +#endif +#if defined(__SDL__) + &_GrVideoDriverSDL, +#endif + &_GrDriverMEM, + NULL +}; + diff --git a/thirdparty/grx249/src/wideline/ccirc.c b/thirdparty/grx249/src/wideline/ccirc.c new file mode 100644 index 0000000..d3cdd4b --- /dev/null +++ b/thirdparty/grx249/src/wideline/ccirc.c @@ -0,0 +1,25 @@ +/** + ** ccirc.c ---- draw dashed and/or wide circles + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrCustomCircle(int xc,int yc,int r,const GrLineOption *o) +{ + GrCustomEllipse(xc,yc,r,r,o); +} diff --git a/thirdparty/grx249/src/wideline/ccirca.c b/thirdparty/grx249/src/wideline/ccirca.c new file mode 100644 index 0000000..d7caae6 --- /dev/null +++ b/thirdparty/grx249/src/wideline/ccirca.c @@ -0,0 +1,26 @@ +/** + ** ccirca.c ---- draw dashed and/or wide circle arcs + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrCustomCircleArc(int xc,int yc,int r,int start,int end,int style,const GrLineOption *o) +{ + GrCustomEllipseArc(xc,yc,r,r,start,end,style,o); +} + diff --git a/thirdparty/grx249/src/wideline/celli.c b/thirdparty/grx249/src/wideline/celli.c new file mode 100644 index 0000000..ce5241f --- /dev/null +++ b/thirdparty/grx249/src/wideline/celli.c @@ -0,0 +1,37 @@ +/** + ** celli.c ---- draw dashed and/or wide ellipses + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "shapes.h" + +void GrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o) +{ + int (*pnts)[2]; + setup_ALLOC(); + pnts = ALLOC(sizeof(int) * 2 * GR_MAX_ELLIPSE_POINTS); + if (pnts != NULL) + { + GrFillArg fval; + int npts = GrGenerateEllipse(xc,yc,xa,ya,pnts); + fval.color = o->lno_color; + _GrDrawCustomPolygon(npts,pnts,o,&_GrSolidFiller,fval,TRUE,TRUE); + FREE(pnts); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/wideline/cellia.c b/thirdparty/grx249/src/wideline/cellia.c new file mode 100644 index 0000000..4f5fff6 --- /dev/null +++ b/thirdparty/grx249/src/wideline/cellia.c @@ -0,0 +1,47 @@ +/** + ** cellia.c ---- draw dashed and/or wide ellipse arcs + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "allocate.h" +#include "shapes.h" + +void GrCustomEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,const GrLineOption *o) +{ + int (*pnts)[2]; + setup_ALLOC(); + pnts = ALLOC(sizeof(int) * 2 * (GR_MAX_ELLIPSE_POINTS+1)); + if (pnts != NULL) + { + GrFillArg fval; + int npts = GrGenerateEllipseArc(xc,yc,xa,ya,start,end,pnts); + int close = FALSE; + switch(style) { + case GR_ARC_STYLE_CLOSE2: + pnts[npts][0] = xc; + pnts[npts][1] = yc; + npts++; + case GR_ARC_STYLE_CLOSE1: + close = TRUE; + break; + } + fval.color = o->lno_color; + _GrDrawCustomPolygon(npts,pnts,o,&_GrSolidFiller,fval,close,TRUE); + FREE(pnts); + } + reset_ALLOC(); +} diff --git a/thirdparty/grx249/src/wideline/custbox.c b/thirdparty/grx249/src/wideline/custbox.c new file mode 100644 index 0000000..0006526 --- /dev/null +++ b/thirdparty/grx249/src/wideline/custbox.c @@ -0,0 +1,33 @@ +/** + ** custbox.c ---- wide and/or dashed box outline + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o) +{ + GrFillArg fval; + int pt[4][2]; + pt[0][0] = x1; pt[0][1] = y1; + pt[1][0] = x2; pt[1][1] = y1; + pt[2][0] = x2; pt[2][1] = y2; + pt[3][0] = x1; pt[3][1] = y2; + fval.color = o->lno_color; + _GrDrawCustomPolygon(4,pt,o,&_GrSolidFiller,fval,TRUE,FALSE); +} + diff --git a/thirdparty/grx249/src/wideline/custline.c b/thirdparty/grx249/src/wideline/custline.c new file mode 100644 index 0000000..3a9b088 --- /dev/null +++ b/thirdparty/grx249/src/wideline/custline.c @@ -0,0 +1,31 @@ +/** + ** custline.c ---- wide and/or dashed line + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o) +{ + GrFillArg fval; + int pt[2][2]; + pt[0][0] = x1; pt[0][1] = y1; + pt[1][0] = x2; pt[1][1] = y2; + fval.color = o->lno_color; + _GrDrawCustomPolygon(2,pt,o,&_GrSolidFiller,fval,FALSE,FALSE); +} + diff --git a/thirdparty/grx249/src/wideline/custplne.c b/thirdparty/grx249/src/wideline/custplne.c new file mode 100644 index 0000000..daefdfb --- /dev/null +++ b/thirdparty/grx249/src/wideline/custplne.c @@ -0,0 +1,27 @@ +/** + ** custplne.c ---- draw an open ended dashed and/or wide polygon + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrCustomPolyLine(int n,int pt[][2],const GrLineOption *o) +{ + GrFillArg fval; + fval.color = o->lno_color; + _GrDrawCustomPolygon(n,pt,o,&_GrSolidFiller,fval,FALSE,FALSE); +} diff --git a/thirdparty/grx249/src/wideline/custpoly.c b/thirdparty/grx249/src/wideline/custpoly.c new file mode 100644 index 0000000..36275dc --- /dev/null +++ b/thirdparty/grx249/src/wideline/custpoly.c @@ -0,0 +1,27 @@ +/** + ** custpoly.c ---- draw a closed dashed and/or wide polygon + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" + +void GrCustomPolygon(int n,int pt[][2],const GrLineOption *o) +{ + GrFillArg fval; + fval.color = o->lno_color; + _GrDrawCustomPolygon(n,pt,o,&_GrSolidFiller,fval,TRUE,FALSE); +} diff --git a/thirdparty/grx249/src/wideline/drwcpoly.c b/thirdparty/grx249/src/wideline/drwcpoly.c new file mode 100644 index 0000000..7cd55ca --- /dev/null +++ b/thirdparty/grx249/src/wideline/drwcpoly.c @@ -0,0 +1,437 @@ +/** + ** drwcpoly.c ---- draw the outline of a custom (wide and/or dashed) polygon + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This file is part of the GRX graphics library. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "libgrx.h" +#include "shapes.h" +#include "clipping.h" +#include "arith.h" +#include "memcopy.h" + +/* + * update the end point of line #1 and the starting point of line #2 + * so that they intersect + */ +static void intersect(int l1s[2],int l1e[2],int l2s[2],int l2e[2]) +{ +# define x11 l1s[0] +# define y11 l1s[1] +# define x12 l1e[0] +# define y12 l1e[1] +# define x21 l2s[0] +# define y21 l2s[1] +# define x22 l2e[0] +# define y22 l2e[1] + if(x12 != x21 || y12 != y21) { + int dx1 = x12 - x11; + int dy1 = y12 - y11; + int dx2 = x22 - x21; + int dy2 = y22 - y21; + long det = imul32(dx2,dy1) - imul32(dx1,dy2); + if( det != 0 ) { + /* Compute t for the parametric equation of line #2 */ + /* then: x = x21 + dx2 * t2, and y = y21 + dy2 * t2 */ + /* but do this with integer arithmetic */ + /* and do rounding instead of truncation */ + long det_t2 = imul32(dx1,(y21 - y11)) - imul32(dy1,(x21 - x11)); + long ldet = labs(det); + /* make sure we're still near old start point of line #2 */ + if( labs(det_t2) < (((ldet<<1) + ldet)>>1) ) { + int xdif2 = (int)(((long)(dx2 << 1) * det_t2) / det); + int ydif2 = (int)(((long)(dy2 << 1) * det_t2) / det); + if(xdif2 > 0) xdif2++; + if(ydif2 > 0) ydif2++; + xdif2 = x21 + (xdif2 >> 1); + ydif2 = y21 + (ydif2 >> 1); + /* don't create triangles */ + if ( xdif2 != x11 && xdif2 != x22 && + ydif2 != y11 && ydif2 != y22 ) { + l1e[0] = l2s[0] = xdif2; + l1e[1] = l2s[1] = ydif2; + return; + } + } + } + { /* + ** no good intersection point till now + ** Check mean point and its eight neighbours for + ** best compromise intersection point + ** + ** y-y11 y12-y11 y-y21 y22-y21 + ** ----- - ------- = 0 and ----- - ------- = 0 + ** x-x11 x12-x11 x-x21 x22-x21 + ** + ** should hold for intersection point (x,y) + ** Measuring the errors for both lines: + ** + ** e1 = (x12-x11)(y-y11)-(x-x11)(y12-y11) = dx1(y-y11)-(x-x11)dy1 + ** e2 = (x22-x21)(y-y21)-(x-x21)(y22-y21) = dx2(y-y21)-(x-x21)dy2 + ** + ** search minimal err = |e1| + |e2| + */ + static int xr[9] = { 0, -1, 0, 1, 0, -1, 1, 1, -1}; + static int yr[9] = { 0, 0, 1, 0, -1, 1, 1, -1, -1}; + int xc = (x12+x21) >> 1; + int yc = (y12+y21) >> 1; + int xb = 0, yb = 0; + int i; + long minerr=0, err; + for (i = 0; i < 9; ++i) { + int x = xc+xr[i]; + int y = yc+yr[i]; + long e1 = imul32(dx1,(y-y11)) - imul32(dy1,(x-x11)); + long e2 = imul32(dx2,(y-y21)) - imul32(dy2,(x-x21)); + err = labs(e1) + labs(e2); + if ( i==0 || err < minerr) { + minerr = err; + xb = xr[i]; yb = yr[i]; + if (minerr == 0) break; + } + } + l1e[0] = l2s[0] = xc + xb; + l1e[1] = l2s[1] = yc + yb; + } + } +# undef x11 +# undef y11 +# undef x12 +# undef y12 +# undef x21 +# undef y21 +# undef x22 +# undef y22 +} + +/* + * generate the four corner points of a wide line segment + * + * p1 end : rect[0] rect[1] + * p2 end : rect[2] rect[3] + * + */ +static void genrect(int p1[2],int p2[2],int w,int rect[4][2]) +{ + int dx = p2[0] - p1[0]; + int dy = p2[1] - p1[1]; + int wx,wy,wx1,wy1,wx2,wy2; + + if(dx == 0) { + wx = w; + wy = 0; + } + else if (dy == 0) { + wx = 0; + wy = w; + } + else { + unsigned long minerr,error = ~0UL,w2 = imul32(w,w); + int mindelta = umin(iabs(dx),iabs(dy)); + int maxdelta = umax(iabs(dx),iabs(dy)); + wx1 = w/2; + if (wx1 <= 0) wx1 = 1; + if (wx1+wx1 < w) ++wx1; + wy1 = 0; + do { + wx = wx1++; + wy = wy1; + wy1 = urscale(wx1,mindelta,maxdelta); + minerr = error; + error = imul32(wx1,wx1) + imul32(wy1,wy1) - w2; + error = labs(error); + } while(error <= minerr); + if(iabs(dx) > iabs(dy)) iswap(wx,wy); + } + if(dx < 0) wy = (-wy); + if(dy >= 0) wx = (-wx); + wx1 = -(wx >> 1); + wy1 = -(wy >> 1); + wx2 = wx + wx1; + wy2 = wy + wy1; + if((wx1 + wx2) < 0) wx1++,wx2++; + if((wy1 + wy2) < 0) wy1++,wy2++; + rect[0][0] = p1[0] + wx1; + rect[0][1] = p1[1] + wy1; + rect[1][0] = p1[0] + wx2; + rect[1][1] = p1[1] + wy2; + rect[2][0] = p2[0] + wx2; + rect[2][1] = p2[1] + wy2; + rect[3][0] = p2[0] + wx1; + rect[3][1] = p2[1] + wy1; +} + +/* + * working version of the line pattern and fill argument structures + */ +typedef struct { + int w; /* line width */ + int psegs; /* number of pattern segments */ + int plength; /* total length of pattern in pixels */ + int ppos; /* current pattern position (modulo plength) */ + int on; /* is the pattern currently on ? */ + unsigned char *patt; /* the pattern bits */ + GrFiller *f; /* the filler functions */ + GrFillArg c; /* the filler argument */ +} linepatt; + +static void solidsegment1( + int p1[2], int p2[2], + int prev[2],int next[2], + linepatt *p +){ + int x1 = p1[0], y1 = p1[1]; + int x2 = p2[0], y2 = p2[1]; + (*p->f->line)( + (x1 + CURC->gc_xoffset), + (y1 + CURC->gc_yoffset), + (x2 - x1), + (y2 - y1), + p->c + ); +} + +static void solidsegmentw( + int p1[2], int p2[2], + int prev[2],int next[2], + linepatt *p +){ + int rect[4][2], prect[4][2], nrect[4][2]; + genrect(p1,p2,p->w,rect); + if(prev) genrect(prev,p1,p->w,prect); + if(next) genrect(p2,next,p->w,nrect); + if(prev && next) { + int points[2]; + points[0] = rect[1][0]; points[1] = rect[1][1]; + intersect(prect[1],prect[2],rect[1],rect[2]); + intersect(points,rect[2],nrect[1],nrect[2]); + points[0] = rect[0][0]; points[1] = rect[0][1]; + intersect(prect[0],prect[3],rect[0],rect[3]); + intersect(points,rect[3],nrect[0],nrect[3]); + } else + if(prev) { + intersect(prect[1],prect[2],rect[1],rect[2]); + intersect(prect[0],prect[3],rect[0],rect[3]); + } else + if(next) { + intersect(rect[1],rect[2],nrect[1],nrect[2]); + intersect(rect[0],rect[3],nrect[0],nrect[3]); + } + _GrScanConvexPoly(4,rect,p->f,p->c); +} + +static void dashedsegment( + int p1[2], int p2[2], + int prev[2],int next[2], + linepatt *p, + void (*doseg)(int[2],int[2],int[2],int[2],linepatt*) +){ + int on,pos,len,seg; + int x,y,dx,dy; + int error,erradd,errsub,count; + int xinc1,xinc2,yinc1,yinc2; + int start[2],end[2], se_init; + + /* find the current starting segment for the pattern */ + pos = (p->ppos %= p->plength); + for(on = 1,seg = 0; ; ) { + len = p->patt[seg]; + if(pos < len) { len -= pos; break; } + if(++seg >= p->psegs) seg = 0; + on ^= 1; + pos -= len; + } + /* Can't have a zero length element here */ + + /* set up line drawing */ + x = p1[0]; dx = p2[0] - x; + y = p1[1]; dy = p2[1] - y; + if(dx >= 0) { xinc2 = 1; } + else { xinc2 = -1; dx = -dx; } + if(dy >= 0) { yinc2 = 1; } + else { yinc2 = -1; dy = -dy; } + if(dx >= dy) { + count = dx + 1; + error = dx >> 1; + errsub = dy; + erradd = dx; + xinc1 = xinc2; + yinc1 = 0; + } + else { + count = dy + 1; + error = dy >> 1; + errsub = dx; + erradd = dy; + yinc1 = yinc2; + xinc1 = 0; + } + se_init = 0; + if(on) { + start[0] = x; + start[1] = y; + se_init = 1; + } + else { + prev = NULL; + } + /* go */ + while(--count >= 0) { + if(on) { + end[0] = x; + end[1] = y; + se_init |= 2; + } + if((error -= errsub) < 0) { + error += erradd; + x += xinc2; + y += yinc2; + } + else { + x += xinc1; + y += yinc1; + } + if(--len <= 0) { + /* end of current segment */ + int old_state = on; + do { + if(++seg >= p->psegs) seg = 0; + len = p->patt[seg]; + on ^= 1; + } while (len == 0); + if ( !old_state && on && count > 0) { + start[0] = x; + start[1] = y; + se_init = 1; + } else + if ( old_state && !on) { + (*doseg)(start,end,prev,NULL,p); + prev = NULL; + se_init = 0; + } + /* else: zero length element(s), continue current segment */ + } + } + if(on && se_init==3) { + (*doseg)(start,end,prev,next,p); + } + p->on = on; +} + +static void dashedsegment1( + int p1[2], int p2[2], + int prev[2],int next[2], + linepatt *p +){ + dashedsegment(p1,p2,prev,next,p,solidsegment1); +} + +static void dashedsegmentw( + int p1[2], int p2[2], + int prev[2],int next[2], + linepatt *p +){ + dashedsegment(p1,p2,prev,next,p,solidsegmentw); +} + +void _GrDrawCustomPolygon( + int n,int pt[][2], + const GrLineOption *lp, + GrFiller *f,GrFillArg c, + int doClose,int circle +){ +# define x1 start[0] +# define y1 start[1] +# define x2 end[0] +# define y2 end[1] + int i,start[2],end[2]; + void (*doseg)(int[2],int[2],int[2],int[2],linepatt*); + linepatt p; + GrContext preclip; + if(n < 2) return; + /* set up working pattern */ + p.f = f; + p.c = c; + p.w = imax((lp->lno_width - 1),0); + p.ppos = 0; + p.patt = lp->lno_dashpat; + p.psegs = p.patt ? imax(lp->lno_pattlen,0) : 0; + p.plength = 0; + for(i = 0; i < p.psegs; i++) { +/* if(!p.patt[i]) { p.plength = 0; break; } */ + p.plength += p.patt[i]; + } + if(p.plength) + doseg = p.w ? dashedsegmentw : dashedsegment1; + else { + if (p.psegs && p.patt[0]==0 ) return; /* nothing to do */ + doseg = p.w ? solidsegmentw : solidsegment1; + } + /* preclip */ + x1 = x2 = pt[0][0]; + y1 = y2 = pt[0][1]; + for(i = 1; i < n; i++) { + int *ppt = pt[i]; + if(x1 > ppt[0]) x1 = ppt[0]; + if(x2 < ppt[0]) x2 = ppt[0]; + if(y1 > ppt[1]) y1 = ppt[1]; + if(y2 < ppt[1]) y2 = ppt[1]; + } + sttcopy(&preclip,CURC); + preclip.gc_xcliplo -= p.w; preclip.gc_ycliplo -= p.w; + preclip.gc_xcliphi += p.w; preclip.gc_ycliphi += p.w; + clip_ordbox((&preclip),x1,y1,x2,y2); + mouse_block(CURC,x1,y1,x2,y2); + /* do the polygon segments */ + if(doClose) { + int *p1 = pt[0], *p2 = pt[n - 1]; + if((n > 1) && (p1[0] == p2[0]) && (p1[1] == p2[1])) n--; + if(n < 3) doClose = FALSE; + } + for(i = 0; i < n; i++) { + int clipped,xmajor,length; + int *p1,*p2,*prev,*next; + if(!(i + doClose)) continue; + p1 = pt[(i + n - 1) % n]; + p2 = pt[i]; + prev = ((i > 1) || doClose) ? pt[(i + n - 2) % n] : NULL; + next = ((i < (n - 1)) || doClose) ? pt[(i + 1) % n] : NULL; + x1 = p1[0]; + y1 = p1[1]; + x2 = p2[0]; + y2 = p2[1]; + clipped = 0; + xmajor = iabs(x1 - x2); + length = iabs(y1 - y2); + if(xmajor > length) { length = xmajor; xmajor = 1; } + else xmajor = 0; + clip_line_((&preclip),x1,y1,x2,y2,goto outside,clipped = p.plength); + if(clipped) { + clipped = xmajor ? iabs(p1[0] - x1) : iabs(p1[1] - y1); + p.ppos += clipped; + length -= clipped; + } + (*doseg)(start,end,prev,next,&p); + outside: + p.ppos += length; + } + mouse_unblock(); +# undef x1 +# undef y1 +# undef x2 +# undef y2 +} + + diff --git a/thirdparty/grx249/test/arctest.c b/thirdparty/grx249/test/arctest.c new file mode 100644 index 0000000..7c6b772 --- /dev/null +++ b/thirdparty/grx249/test/arctest.c @@ -0,0 +1,61 @@ +/** + ** arctest.c ---- test arc outline and filled arc drawing + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "test.h" + +TESTFUNC(arctest) +{ + char buff[300]; + int xc,yc,xa,ya,start,end; + FILE *fp; + GrColor red = GrAllocColor(255,0,0); + GrColor green = GrAllocColor(0,255,0); + GrColor blue = GrAllocColor(0,0,255); + + fp = fopen("arctest.dat","r"); + if(fp == NULL) return; + while(fgets(buff,299,fp) != NULL) { + int len = strlen(buff); + while(--len >= 0) { + if(buff[len] == '\n') { buff[len] = '\0'; continue; } + if(buff[len] == '\r') { buff[len] = '\0'; continue; } + break; + } + if(sscanf(buff, + "arc xc=%d yc=%d xa=%d ya=%d start=%d end=%d", + &xc,&yc,&xa,&ya,&start,&end) == 6) { + GrClearScreen(GrBlack()); + GrEllipse(xc,yc,xa,ya,red); + GrFilledEllipse(xc,yc,xa,ya,blue); + GrEllipseArc(xc,yc,xa,ya,start,end,GR_ARC_STYLE_CLOSE2,GrWhite()); + GrTextXY(0,0,buff,GrWhite(),GrNOCOLOR); + GrTextXY(0,20,"press any key to continue",GrWhite(),GrNOCOLOR); + GrKeyRead(); + GrClearScreen(GrBlack()); + GrEllipseArc(xc,yc,xa,ya,start,end,GR_ARC_STYLE_CLOSE2,red); + GrFilledEllipseArc(xc,yc,xa,ya,start,end,GR_ARC_STYLE_CLOSE2,green); + GrTextXY(0,0,buff,GrWhite(),GrNOCOLOR); + GrTextXY(0,20,"press any key to continue",GrWhite(),GrNOCOLOR); + GrKeyRead(); + } + } + fclose(fp); +} + diff --git a/thirdparty/grx249/test/arctest.dat b/thirdparty/grx249/test/arctest.dat new file mode 100644 index 0000000..6e0b2fb --- /dev/null +++ b/thirdparty/grx249/test/arctest.dat @@ -0,0 +1,9 @@ +arc xc=300 yc=200 xa=50 ya=50 start=10 end=40 +arc xc=300 yc=200 xa=250 ya=150 start=10 end=200 +arc xc=300 yc=200 xa=250 ya=150 start=10 end=2000 +arc xc=300 yc=200 xa=250 ya=150 start=1000 end=200 +arc xc=300 yc=200 xa=25 ya=15 start=3500 end=800 +arc xc=300 yc=200 xa=25 ya=15 start=10 end=100 +arc xc=300 yc=200 xa=25 ya=15 start=3500 end=10 +arc xc=300 yc=200 xa=25 ya=15 start=0 end=900 + diff --git a/thirdparty/grx249/test/bb1test.c b/thirdparty/grx249/test/bb1test.c new file mode 100644 index 0000000..7ffe8af --- /dev/null +++ b/thirdparty/grx249/test/bb1test.c @@ -0,0 +1,84 @@ +/** + ** bb1test.c ---- test the GrBitBlt1bpp routine + ** + ** Copyright (c) 2001 Josu Onandia + ** [e-mail: jonandia@fagorautomation.es]. + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + **/ + +#include +#include "grx20.h" +#include "grxkeys.h" + +int main(void) +{ + GrContext *pContext; + int sizex = 40; + int sizey = 40; + int x = 0; + int y = 40; + GrColor fcolor, bcolor; + GrKeyType k; + + GrSetMode( GR_default_graphics ); + /* Create a 1bpp bitmap */ + pContext = GrCreateFrameContext(GR_frameRAM1, sizex, sizey, NULL, NULL); + /* draw something (black and white) into the bitmap */ + GrSetContext(pContext); + GrClearContext( GrBlack() ); + GrLine(0, 0, sizex-1, sizey-1, GrWhite()); + GrLine(0, sizey-1, sizex-1, 0, GrWhite()); + + GrSetContext(NULL); + fcolor = GrAllocColor( 255,0,0 ); + bcolor = GrAllocColor( 0,0,255 ); + GrTextXY(0,0,"Type u d l r U D L R to move, 1 2 to change color, q to quit", + GrWhite(),GrNOCOLOR); + GrSetClipBox(0, 40, GrScreenX(), GrScreenY()); + + /* Put the bitmap into the screen */ + GrBitBlt1bpp(NULL,x,y,pContext,0,0,sizex-1,sizey-1,fcolor,bcolor); + + while( 1 ){ + k = GrKeyRead(); + if( k == 'q' ) break; + switch( k ) { + case 'u': y--; break; + case 'd': y++; break; + case 'l': x--; break; + case 'r': x++; break; + case 'U': y -= 10; break; + case 'D': y += 10; break; + case 'L': x -= 10; break; + case 'R': x += 10; break; + case '1': fcolor = GrAllocColor( 255,0,0 ); + bcolor = GrAllocColor( 0,0,255 ); + break; + case '2': fcolor = GrAllocColor( 0,255,255 ); + bcolor = GrAllocColor( 255,255,0 ); + break; + default: continue; + } + if(x < -40) x = -40; + if(x > GrScreenX()) x = GrScreenX(); + if(y < 0) y = 0; + if(y > GrScreenY()) y = GrScreenY(); + GrBitBlt1bpp(NULL,x,y,pContext,0,0,sizex-1,sizey-1,fcolor,bcolor); + } + + /* Destroy */ + GrDestroyContext(pContext); + + GrSetMode(GR_default_text); + return 0; +} diff --git a/thirdparty/grx249/test/bgi/bccbgi.c b/thirdparty/grx249/test/bgi/bccbgi.c new file mode 100644 index 0000000..86eaf45 --- /dev/null +++ b/thirdparty/grx249/test/bgi/bccbgi.c @@ -0,0 +1,2214 @@ +/* + GRAPHICS DEMO FOR Borland C++ + + Copyright (c) 1987,88,91 Borland International. All rights reserved. +*/ + +/* Partially copyrighted (c) 1993-97 by Hartmut Schirmer */ + +#ifdef __TINY__ +#error BGIDEMO will not run in the tiny model. +#endif + +#include +#include +#include +#include +#include +#include "libbcc.h" +#include "bgiext.h" +#include "stdfun.h" + +#include "../rand.h" +#define Random(r) ((unsigned) (((RND() % (r)) + 1))) +#define Seed(s) SRND(s) + +#if defined(__MSDOS__) || defined(__WIN32__) +#define BGI_PATH "..\\..\\chr" +#else +#define BGI_PATH "../../chr" +#endif + +#define itoa(value,str,radix) sprintf((str),"%d",(value)) +#define getch() getkey() + +#define ESC 0x1b /* Define the escape key */ +#ifndef TRUE +# define TRUE 1 /* Define some handy constants */ +#endif +#ifndef FALSE +# define FALSE 0 /* Define some handy constants */ +#endif +#ifndef PI +# define PI 3.14159 /* Define a value for PI */ +#endif +#define ON 1 /* Define some handy constants */ +#define OFF 0 /* Define some handy constants */ + +#define NFONTS 11 + +char *Fonts[] = { + "DefaultFont", "TriplexFont", "SmallFont", + "SansSerifFont", "GothicFont", "ScriptFont", "SimplexFont", "TriplexScriptFont", + "ComplexFont", "EuropeanFont", "BoldFont" +}; + +char *LineStyles[] = { + "SolidLn", "DottedLn", "CenterLn", "DashedLn", "UserBitLn" +}; + +char *FillStyles[] = { + "EmptyFill", "SolidFill", "LineFill", "LtSlashFill", + "SlashFill", "BkSlashFill", "LtBkSlashFill", "HatchFill", + "XHatchFill", "InterleaveFill", "WideDotFill", "CloseDotFill" +}; + +char *TextDirect[] = { + "HorizDir", "VertDir" +}; + +char *HorizJust[] = { + "LeftText", "CenterText", "RightText" +}; + +char *VertJust[] = { + "BottomText", "CenterText", "TopText" +}; + +struct PTS { + int x, y; +}; /* Structure to hold vertex points */ + +int GraphDriver; /* The Graphics device driver */ +int GraphMode; /* The Graphics mode value */ +double AspectRatio; /* Aspect ratio of a pixel on the screen*/ +int MaxX, MaxY; /* The maximum resolution of the screen */ +int MaxColors; /* The maximum # of colors available */ +int ErrorCode; /* Reports any graphics errors */ +struct palettetype palette; /* Used to read palette info */ +static char PauseMsg[] = "Esc aborts or press a key..."; +static char StopMsg[] = "ESC Aborts - Press a Key to stop"; + +/* */ +/* GPRINTF: Used like PRINTF except the output is sent to the */ +/* screen in graphics mode at the specified co-ordinate. */ +/* */ + +int gprintf( int *xloc, int *yloc, char *fmt, ... ) +{ + va_list argptr; /* Argument list pointer */ + char str[140]; /* Buffer to build sting into */ + int cnt; /* Result of SPRINTF for return */ + + va_start( argptr, fmt ); /* Initialize va_ functions */ + + cnt = vsprintf( str, fmt, argptr ); /* prints string to buffer */ + outtextxy( *xloc, *yloc, str ); /* Send string in graphics mode */ + *yloc += textheight( "H" ) + 2; /* Advance to next line */ + + va_end( argptr ); /* Close va_ functions */ + + return( cnt ); /* Return the conversion count */ + +} + +/* */ +/* CHANGETEXTSTYLE: similar to settextstyle, but checks for */ +/* errors that might occur whil loading the font file. */ +/* */ + +void changetextstyle(int font, int direction, int charsize) +{ + int ErrorCode; + + graphresult(); /* clear error code */ + settextstyle(font, direction, charsize); + ErrorCode = graphresult(); /* check result */ + if( ErrorCode != grOk ){ /* if error occured */ +#if 0 + closegraph(); + printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) ); + exit( 1 ); +#else + settextstyle(DEFAULT_FONT, direction, charsize); +#endif + } +} + +/* */ +/* DRAWBORDER: Draw a solid single line around the current */ +/* viewport. */ +/* */ + +void DrawBorder(int color) +{ + struct viewporttype vp; + + setcolor( color); + + setlinestyle( SOLID_LINE, 0, NORM_WIDTH ); + + getviewsettings( &vp ); + rectangle( 0, 0, vp.right-vp.left, vp.bottom-vp.top); + +} + +/* */ +/* STATUSLINE: Display a status line at the bottom of the screen. */ +/* */ + +void StatusLineColor( char *msg, int color ) +{ + int height; + + setviewport( 0, 0, MaxX, MaxY, 1 ); /* Open port to full screen */ + setcolor( color); /* Set requested color */ + + changetextstyle( DEFAULT_FONT, HORIZ_DIR, 1 ); + settextjustify( CENTER_TEXT, TOP_TEXT ); + setlinestyle( SOLID_LINE, 0, NORM_WIDTH ); + setfillstyle( EMPTY_FILL, 0 ); + + height = textheight( "H" ); /* Detemine current height */ + bar( 0, MaxY-(height+4), MaxX, MaxY ); + rectangle( 0, MaxY-(height+4), MaxX, MaxY ); + outtextxy( MaxX/2, MaxY-(height+2), msg ); + setviewport( 1, height+5, MaxX-1, MaxY-(height+5), 1 ); +} + +void StatusLine( char *msg ) +{ + StatusLineColor(msg, WHITE); +} + +/* */ +/* MAINWINDOW: Establish the main window for the demo and set */ +/* a viewport for the demo code. */ +/* */ + +void DisplayTitle(char *header, int color) { + struct viewporttype vp; + + getviewsettings( &vp ); + setcolor( color); /* Set current requested color */ + setviewport( 0, 0, MaxX, MaxY, 1 ); /* Open port to full screen */ + changetextstyle( DEFAULT_FONT, HORIZ_DIR, 1 ); + settextjustify( CENTER_TEXT, TOP_TEXT ); + outtextxy( MaxX/2, 2, header ); + setviewport(vp.left, vp.top, vp.right, vp.bottom, vp.clip); +} + +void MainWindowColor( char *header, int color) +{ + int height; + + cleardevice(); /* Clear graphics screen */ + setcolor( color); /* Set current requested color */ + setviewport( 0, 0, MaxX, MaxY, 1 ); /* Open port to full screen */ + + height = textheight( "H" ); /* Get basic text height */ + + DisplayTitle(header, color); + setviewport( 0, height+4, MaxX, MaxY-(height+4), 1 ); + DrawBorder(color); + setviewport( 1, height+5, MaxX-1, MaxY-(height+5), 1 ); + +} + +void MainWindow( char *header ) +{ + MainWindowColor( header, WHITE); +} + +/* */ +/* PAUSE: Pause until the user enters a keystroke. If the */ +/* key is an ESC, then exit program, else simply return. */ +/* */ + + +void NewPause(int clear) +{ + int c; + + StatusLine( PauseMsg ); /* Put msg at bottom of screen */ + + c = getch(); /* Read a character from kbd */ + + if( ESC == c ){ /* Does user wish to leave? */ + closegraph(); /* Change to text mode */ + exit( 1 ); /* Return to OS */ + } + + if( 0 == c ){ /* Did use hit a non-ASCII key? */ + c = getch(); /* Read scan code for keyboard */ + } + + if (clear) + cleardevice(); /* Clear the screen */ +} + +#define Pause() NewPause(TRUE) + +/* */ +/* INITIALIZE: Initializes the graphics system and reports */ +/* any errors which occured. */ +/* */ + +void Initialize(void) +{ + int xasp, yasp; + + GraphDriver = DETECT; /* Request auto-detection */ +#ifdef __GNUC__ +/* set_BGI_mode_whc(&GraphDriver, &GraphMode, 640, 480, 16); */ + set_BGI_mode_pages(2); +#endif + initgraph( &GraphDriver, &GraphMode, BGI_PATH ); + ErrorCode = graphresult(); /* Read result of initialization*/ + if( ErrorCode != grOk ){ /* Error occured during init */ + printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) ); + exit( 1 ); + } + + getpalette( &palette ); /* Read the palette from board */ + MaxColors = getmaxcolor() + 1; /* Read maximum number of colors*/ + if (MaxColors == 256) + setrgbdefaults(); + + MaxX = getmaxx(); + MaxY = getmaxy(); /* Read size of screen */ + + getaspectratio( &xasp, &yasp ); /* read the hardware aspect */ + AspectRatio = (double)xasp / (double)yasp; /* Get correction factor */ + +} + + +/* */ +/* REPORTSTATUS: Report the current configuration of the system */ +/* after the auto-detect initialization. */ +/* */ + +void ReportStatus(void) +{ + struct viewporttype viewinfo; /* Params for inquiry procedures*/ + struct linesettingstype lineinfo; + struct fillsettingstype fillinfo; + struct textsettingstype textinfo; + struct palettetype palette; + + char *driver, *mode, *fmt; /* Strings for driver and mode */ + int x, y, mno; + + getviewsettings( &viewinfo ); + getlinesettings( &lineinfo ); + getfillsettings( &fillinfo ); + gettextsettings( &textinfo ); + getpalette( &palette ); + + x = 5; + y = 4; + + MainWindow( "Status report after InitGraph" ); + settextjustify( LEFT_TEXT, TOP_TEXT ); + + driver = getdrivername(); + mode = getmodename(GraphMode); /* get current setting */ + + gprintf( &x, &y, "Graphics device : %-20s (%d)", driver, GraphDriver ); + gprintf( &x, &y, "Graphics mode : %-20s (%d)", mode, GraphMode ); +#ifdef __GNUC__ + gprintf( &x, &y, "Available pages : %d", get_BGI_mode_pages() ); +#endif + gprintf( &x, &y, "Screen resolution : ( 0, 0, %d, %d )", getmaxx(), getmaxy() ); + gprintf( &x, &y, "Current view port : ( %d, %d, %d, %d )", + viewinfo.left, viewinfo.top, viewinfo.right, viewinfo.bottom ); + gprintf( &x, &y, "Clipping : %s", viewinfo.clip ? "ON" : "OFF" ); + + gprintf( &x, &y, "Current position : ( %d, %d )", getx(), gety() ); + gprintf( &x, &y, "Colors available : %d", MaxColors ); + gprintf( &x, &y, "Current color : %d", getcolor() ); + + gprintf( &x, &y, "Line style : %s", LineStyles[ lineinfo.linestyle ] ); + gprintf( &x, &y, "Line thickness : %d", lineinfo.thickness ); + + gprintf( &x, &y, "Current fill style : %s", FillStyles[ fillinfo.pattern ] ); + gprintf( &x, &y, "Current fill color : %d", fillinfo.color ); + + gprintf( &x, &y, "Current font : %s", Fonts[ textinfo.font ] ); + gprintf( &x, &y, "Text direction : %s", TextDirect[ textinfo.direction ] ); + gprintf( &x, &y, "Character size : %d", textinfo.charsize ); + gprintf( &x, &y, "Horizontal justify : %s", HorizJust[ textinfo.horiz ] ); + gprintf( &x, &y, "Vertical justify : %s", VertJust[ textinfo.vert ] ); + + gprintf( &x, &y, "Aspect ratio : %lf", AspectRatio); + + getviewsettings( &viewinfo ); + { + int ybase; + setfillstyle(SOLID_FILL, BLACK); + if (MaxY<350-1) { + x = 400; + y = 4; + fmt = "#%-3d: %s"; + } else { + y += 5; + fmt = " Mode #%-3d : %s"; + } + gprintf( &x, &y, "Available modes :"); + y += 5; + ybase = y; + for (mno = 0; mno <= getmaxmode(); ++mno) { + char sp[100]; + sprintf(sp, fmt, mno, getmodename(mno)); + bar(x-4, y + textheight(sp), x+textwidth(sp)+4, y); + gprintf( &x, &y, "%s", sp); + if (y+viewinfo.top>viewinfo.bottom-8) { + y = ybase; + x += (viewinfo.right-viewinfo.left) / 2; + } + } + } + + Pause(); /* Pause for user to read screen*/ + +} + +/* */ +/* TEXTDUMP: Display the all the characters in each of the */ +/* available fonts. */ +/* */ + +void TextDump(void) +{ + static int CGASizes[] = { + 1, 3, 7, 3, 3, 2, 2, 2, 2, 2, 2 }; + static int NormSizes[] = { + 1, 4, 7, 4, 4, 2, 2, 2, 2, 2, 2 }; + + char buffer[80]; + int font, ch, wwidth, lwidth, size; + struct viewporttype vp; + + for( font=0 ; font wwidth-3) + moveto( 5, gety() + textheight("H") + 3 ); + outtext( buffer ); /* send string to screen */ + ++ch; /* Goto the next character */ + } + } + else{ + + size = (MaxY < 200) ? CGASizes[font] : NormSizes[font]; + changetextstyle( font, HORIZ_DIR, size ); + + ch = '!'; /* Begin at 1st printable */ + while( ch < 256 ){ /* For each printable character */ + buffer[0] = ch; /* Put character into a string */ + lwidth = textwidth( buffer); /* Get letter width */ + if( (lwidth+getx()) > wwidth-3) /* Are we still in window? */ + moveto( 5, gety()+textheight("H")+3 ); + outtext( buffer ); /* send string to screen */ + ++ch; /* Goto the next character */ + } + + } + + Pause(); /* Pause until user acks */ + + } /* End of FONT loop */ + +} + +/* */ +/* BAR3DDEMO: Display a 3-D bar chart on the screen. */ +/* */ + +void Bar3DDemo(void) +{ + static int barheight[] = { + 1, 3, 5, 4, 3, 2, 1, 5, 4, 2, 3 }; + struct viewporttype vp; + int xstep, ystep, deepth; + int i, j, h, color, bheight; + char buffer[10]; + + MainWindow( "Bar 3-D / Rectangle Demonstration" ); + + h = 3 * textheight( "H" ); + getviewsettings( &vp ); + settextjustify( CENTER_TEXT, TOP_TEXT ); + changetextstyle( TRIPLEX_FONT, HORIZ_DIR, 4 ); + outtextxy( MaxX/2, 6, "These are 3-D Bars" ); + changetextstyle( DEFAULT_FONT, HORIZ_DIR, 1 ); + setviewport( vp.left+50, vp.top+40, vp.right-50, vp.bottom-10, 1 ); + getviewsettings( &vp ); + + line( h, h, h, vp.bottom-vp.top-h ); + line( h, (vp.bottom-vp.top)-h, (vp.right-vp.left)-h, (vp.bottom-vp.top)-h ); + xstep = ((vp.right-vp.left) - (2*h)) / 10; + ystep = ((vp.bottom-vp.top) - (2*h)) / 5; + j = (vp.bottom-vp.top) - h; + deepth = (getmaxx() <= 400) ? 7 : 15; + settextjustify( LEFT_TEXT, CENTER_TEXT ); + + for( i=0 ; i<6 ; ++i ){ + line( h/2, j, h, j ); + itoa( i, buffer, 10 ); + outtextxy( 0, j, buffer ); + j -= ystep; + } + + j = h; + settextjustify( CENTER_TEXT, TOP_TEXT ); + + for( i=0 ; i<11 ; ++i ){ + color = Random( MaxColors-1 ) + 1; + setfillstyle( i+1, color ); + line( j, (vp.bottom-vp.top)-h, j, (vp.bottom-vp.top-3)-(h/2) ); + itoa( i, buffer, 10 ); + outtextxy( j, (vp.bottom-vp.top)-(h/2), buffer ); + if( i != 10 ){ + bheight = (vp.bottom-vp.top) - h - 1; + bar3d( j, (vp.bottom-vp.top-h)-(barheight[i]*ystep), j+xstep-deepth, bheight, deepth, 1 ); + } + j += xstep; + } + + Pause(); /* Pause for user's response */ + +} + +/* */ +/* RandomBARS: Display random bars */ +/* */ + +void RandomBars(void) +{ + int color; + + MainWindow( "Random Bars" ); + StatusLine( PauseMsg ); /* Put msg at bottom of screen */ + while( !kbhit() ){ /* Until user enters a key... */ + color = Random( MaxColors-1 )+1; + setcolor( color ); + setfillstyle( Random(11)+1, color ); + bar3d( Random( getmaxx() ), Random( getmaxy() ), + Random( getmaxx() ), Random( getmaxy() ), 0, OFF); + } + + Pause(); /* Pause for user's response */ + +} + + +/* */ +/* TEXTDEMO: Show each font in several sizes to the user. */ +/* */ + +void TextDemo(void) +{ + int charsize[] = { + 1, 3, 7, 3, 4, 2, 2, 2, 2, 2, 2 }; + int font, size; + int h, x, y, i; + struct viewporttype vp; + char buffer[80]; + + for( font=0 ; font= 1.0) + radius = (int)(radius / AspectRatio); + while( (AspectRatio*radius) < piesize ) ++radius; + + lradius = radius + ( radius / 5 ); /* Labels placed 20% farther */ + + changetextstyle( TRIPLEX_FONT, HORIZ_DIR, 4 ); + settextjustify( CENTER_TEXT, TOP_TEXT ); + outtextxy( MaxX/2, 6, "This is a Pie Chart" ); + changetextstyle( TRIPLEX_FONT, HORIZ_DIR, 1 ); + settextjustify( CENTER_TEXT, TOP_TEXT ); + + setfillstyle( SOLID_FILL, _ega_color(RED) ); + pieslice( xcenter+10, ycenter-adjasp(10), 0, 90, radius ); + radians = torad( 45 ); + x = xcenter + (int)( cos( radians ) * (double)lradius ); + y = ycenter - (int)( sin( radians ) * (double)lradius * AspectRatio ); + settextjustify( LEFT_TEXT, BOTTOM_TEXT ); + outtextxy( x, y, "25 %" ); + + setfillstyle( WIDE_DOT_FILL, _ega_color(GREEN) ); + pieslice( xcenter, ycenter, 90, 135, radius ); + radians = torad( 113 ); + x = xcenter + (int)( cos( radians ) * (double)lradius ); + y = ycenter - (int)( sin( radians ) * (double)lradius * AspectRatio ); + settextjustify( RIGHT_TEXT, BOTTOM_TEXT ); + outtextxy( x, y, "12.5 %" ); + + setfillstyle( INTERLEAVE_FILL, _ega_color(YELLOW) ); + settextjustify( RIGHT_TEXT, CENTER_TEXT ); + pieslice( xcenter-10, ycenter, 135, 225, radius ); + radians = torad( 180 ); + x = xcenter + (int)( cos( radians ) * (double)lradius ); + y = ycenter - (int)( sin( radians ) * (double)lradius * AspectRatio ); + settextjustify( RIGHT_TEXT, CENTER_TEXT ); + outtextxy( x, y, "25 %" ); + + setfillstyle( HATCH_FILL, _ega_color(BLUE) ); + pieslice( xcenter, ycenter, 225, 360, radius ); + radians = torad( 293 ); + x = xcenter + (int)( cos( radians ) * (double)lradius ); + y = ycenter - (int)( sin( radians ) * (double)lradius * AspectRatio ); + settextjustify( LEFT_TEXT, TOP_TEXT ); + outtextxy( x, y, "37.5 %" ); + + Pause(); /* Pause for user's response */ + +} + +/* */ +/* BARDEMO: Draw a 2-D bar chart using Bar and Rectangle. */ +/* */ + +void BarDemo(void) +{ + int barheight[] = { + 1, 3, 5, 2, 4 }; + int styles[] = { + 1, 3, 10, 5, 9, 1 }; + int xstep, ystep; + int sheight, swidth; + int i, j, h; + struct viewporttype vp; + char buffer[40]; + + MainWindow( "Bar / Rectangle demonstration" ); + h = 3 * textheight( "H" ); + getviewsettings( &vp ); + settextjustify( CENTER_TEXT, TOP_TEXT ); + changetextstyle( TRIPLEX_FONT, HORIZ_DIR, 4 ); + outtextxy( MaxX /2, 6, "These are 2-D Bars" ); + changetextstyle( DEFAULT_FONT, HORIZ_DIR, 1 ); + setviewport( vp.left+50, vp.top+30, vp.right-50, vp.bottom-10, 1 ); + + getviewsettings( &vp ); + sheight = vp.bottom - vp.top; + swidth = vp.right - vp.left; + + line( h, h, h, sheight-h ); + line( h, sheight-h, sheight-h, sheight-h ); + ystep = (sheight - (2*h) ) / 5; + xstep = (swidth - (2*h) ) / 5; + j = sheight - h; + settextjustify( LEFT_TEXT, CENTER_TEXT ); + + for( i=0 ; i<6 ; ++i ){ + line( h/2, j, h, j ); + itoa( i, buffer, 10 ); + outtextxy( 0, j, buffer ); + j -= ystep; + } + + j = h; + settextjustify( CENTER_TEXT, TOP_TEXT ); + for( i=0 ; i<6 ; ++i ){ + setfillstyle( styles[i], Random(MaxColors-1)+1 ); + line( j, sheight - h, j, sheight- 3 - (h/2) ); + itoa( i, buffer, 10 ); + outtextxy( j, sheight - (h/2), buffer ); + if( i != 5 ){ + bar( j, (sheight-h)-(barheight[i] * ystep), j+xstep, sheight-h-1 ); + rectangle( j, (sheight-h)-(barheight[i] * ystep), j+xstep, sheight-h); + } + j += xstep; + } + + Pause(); + +} + +/* */ +/* LINERELDEMO: Display pattern using moverel and linerel cmds. */ +/* */ + +void LineRelDemo(void) +{ + struct viewporttype vp; + int h, w, dx, dy, cx, cy; + struct PTS outs[7]; + + + MainWindow( "MoveRel / LineRel Demonstration" ); + StatusLine( StopMsg); + + getviewsettings( &vp ); + cx = (vp.right - vp.left) / 2; /* Center of the screen coords */ + cy = (vp.bottom - vp.top ) / 2; + + h = (vp.bottom - vp.top ) / 8; + w = (vp.right - vp.left) / 9; + + dx = 2 * w; + dy = 2 * h; + + setcolor( BLACK ); + + setfillstyle( SOLID_FILL, _ega_color(BLUE) ); + bar( 0, 0, vp.right-vp.left, vp.bottom-vp.top ); /* Draw backgnd */ + + outs[0].x = cx - dx; + outs[0].y = cy - dy; + outs[1].x = cx - (dx-w); + outs[1].y = cy - (dy+h); + outs[2].x = cx + dx; + outs[2].y = cy - (dy+h); + outs[3].x = cx + dx; + outs[3].y = cy + dy; + outs[4].x = cx + (dx-w); + outs[4].y = cy + (dy+h); + outs[5].x = cx - dx; + outs[5].y = cy + (dy+h); + outs[6].x = cx - dx; + outs[6].y = cy - dy; + + setfillstyle( SOLID_FILL, WHITE ); + fillpoly( 7, (int far *)outs ); + + outs[0].x = cx - (w/2); + outs[0].y = cy + h; + outs[1].x = cx + (w/2); + outs[1].y = cy + h; + outs[2].x = cx + (w/2); + outs[2].y = cy - h; + outs[3].x = cx - (w/2); + outs[3].y = cy - h; + outs[4].x = cx - (w/2); + outs[4].y = cy + h; + + setfillstyle( SOLID_FILL, _ega_color(BLUE) ); + fillpoly( 5, (int far *)outs ); + + /* Draw a Tesseract object on the screen using the LineRel and */ + /* MoveRel drawing commands. */ + + moveto( cx-dx, cy-dy ); + linerel( w, -h ); + linerel( 3*w, 0 ); + linerel( 0, 5*h ); + linerel( -w, h ); + linerel( -3*w, 0 ); + linerel( 0, -5*h ); + + moverel( w, -h ); + linerel( 0, 5*h ); + linerel( w+(w/2), 0 ); + linerel( 0, -3*h ); + linerel( w/2, -h ); + linerel( 0, 5*h ); + + moverel( 0, -5*h ); + linerel( -(w+(w/2)), 0 ); + linerel( 0, 3*h ); + linerel( -w/2, h ); + + moverel( w/2, -h ); + linerel( w, 0 ); + + moverel( 0, -2*h ); + linerel( -w, 0 ); + + Pause(); /* Wait for user's response */ + +} + +/* */ +/* PUTPIXELDEMO: Display a pattern of random dots on the screen */ +/* and pick them back up again. */ +/* */ + +void PutPixelDemo(void) +{ + int seed = 1958; + int i, x, y, h, w, color; + struct viewporttype vp; + + MainWindow( "PutPixel / GetPixel Demonstration" ); + StatusLine( PauseMsg); /* Put msg at bottom of screen */ + + getviewsettings( &vp ); + h = vp.bottom - vp.top; + w = vp.right - vp.left; + + do { + Seed( seed ); /* Restart random # function */ + + for( i=0 ; i<5000 ; ++i ){ /* Put 5000 pixels on screen */ + x = 1 + Random( w - 1 ); /* Generate a random location */ + y = 1 + Random( h - 1 ); + color = Random( MaxColors-1 ) + 1; + putpixel( x, y, color ); + } + + Seed( seed ); /* Restart random # at same # */ + for( i=0 ; i<5000 ; ++i ){ /* Take the 5000 pixels off */ + x = 1 + Random( w - 1 ); /* Generate a random location */ + y = 1 + Random( h - 1 ); + color = getpixel( x, y ); /* Read the color pixel */ + if( color==Random(MaxColors-1)+1 ) /* Used to keep random in sync */ + putpixel( x, y, BLACK ); /* Write pixel to BLACK */ + } + if (!kbhit()) + delay(400); + } while ( !kbhit()); + + Pause(); /* Wait for user's response */ + +} + +/* */ +/* PUTIMAGEDEMO */ +/* */ +#define PAUSETIME 20 +#define PID_r 20 +#define StartX 100 +#define StartY 50 +#define MAXXSTEP (2*PID_r/3) +#define MAXYSTEP (PID_r/2) +#define PID_STEPS 250 + +int SaucerMoveX(int *dx, int x) { +// *dx += (Random( 2*MAXXSTEP+1) - MAXXSTEP + (MAXXSTEP*(MaxX/2-x))/MaxX) / 10; + *dx += Random( 2*MAXXSTEP) - MAXXSTEP; + if ( *dx > MAXXSTEP) *dx = MAXXSTEP; else + if ( *dx < -MAXXSTEP) *dx = -MAXXSTEP; + return *dx; +} +int SaucerMoveY(int *dy, int y) { +// *dy += (Random( 2*MAXYSTEP+1) - MAXYSTEP + (MAXYSTEP*(MaxY/2-y))/MaxY) / 10; + *dy += Random( 2*MAXYSTEP) - MAXYSTEP; + if ( *dy > MAXYSTEP) *dy = MAXYSTEP; else + if ( *dy < -MAXYSTEP) *dy = -MAXYSTEP; + return *dy; +} + +#define SaucerLimitX() do { \ + if (vp.left + nx + width - 1 > vp.right) \ + nx = vp.right-vp.left-width + 1; \ + else \ + if (nx < 0) \ + nx = 0; \ +} while (0) + +#define SaucerLimitY() do { \ + if (vp.top + ny + height - 1 > vp.bottom) \ + ny = vp.bottom-vp.top-height + 1; \ + else \ + if (ny < 0) \ + ny = 0; \ +} while (0) + +void PutImageDemo(void) +{ + struct viewporttype vp; + int x, y, ulx, uly, lrx, lry, size, i, width, height; + int nx, ny, dx, dy; + void *Saucer; + int old_xasp, old_yasp; + + MainWindow("GetImage / PutImage Demonstration"); + getviewsettings( &vp ); + + /* DrawSaucer */ + getaspectratio(&old_xasp, &old_yasp); + setaspectratio(1, 1); + ellipse(StartX, StartY, 0, 360, PID_r, PID_r / 3 + 2); + ellipse(StartX, StartY - 4, 190, 357, PID_r, PID_r / 3); + line(StartX + 7, StartY - 6, StartX + 10, StartY - 12); + circle(StartX + 10, StartY - 12, 2); + line(StartX - 7, StartY - 6, StartX - 10, StartY - 12); + circle(StartX - 10, StartY - 12, 2); + setfillstyle(SOLID_FILL, WHITE); + floodfill(StartX + 1, StartY + 4, getcolor()); + setaspectratio(old_xasp, old_yasp); + + /* Read saucer image */ + ulx = StartX-(PID_r+1); + uly = StartY-14; + lrx = StartX+(PID_r+1); + lry = StartY+(PID_r/3)+3; + width = lrx - ulx + 1; + height = lry - uly + 1; + size = imagesize(ulx, uly, lrx, lry); + Saucer = malloc( size ); + if (Saucer == NULL) return; + getimage(ulx, uly, lrx, lry, Saucer); + putimage(ulx, uly, Saucer, XOR_PUT); + + /* Plot some "stars" */ + for ( i=0 ; i<1000; ++i ) + putpixel(Random(MaxX), Random(MaxY), Random( MaxColors-1 )+1); + x = MaxX / 2; + y = MaxY / 2; + dx = 1; + dy = 0; + + StatusLine( PauseMsg); /* Put msg at bottom of screen */ + + /* until a key is hit */ + while ( !kbhit() ) { + + /* Draw the Saucer */ + if (dx != 0 || dy != 0) + putimage(x, y, Saucer, XOR_PUT); /* draw image */ + delay(PAUSETIME); + nx = x + SaucerMoveX(&dx,x); + ny = y + SaucerMoveY(&dy,y); + SaucerLimitX(); + SaucerLimitY(); + dx = nx-x; + dy = ny-y; + if (dx != 0 || dy != 0) + putimage(x, y, Saucer, XOR_PUT); /* erase image */ + x = nx; + y = ny; + } + +#ifdef __GNUC__ + if (get_BGI_mode_pages()>1) { + int ActPage = 0; + void *Screen = NULL; + + size = imagesize(0, 0, MaxX, MaxY); + Screen = malloc( size ); + if (Screen != NULL) { + if ( getch() == ESC) { + closegraph(); + exit(1); + } + setviewport(0, 0, MaxX, MaxY, 1); + getimage(0, 0, MaxX, MaxY, Screen); + while ( !kbhit() ) { + ActPage = (ActPage+1)&1; + setactivepage(ActPage); + putimage(0, 0, Screen, COPY_PUT); + putimage(vp.left+x, vp.top+y, Saucer, XOR_PUT ); + setvisualpage(ActPage); + nx = x + SaucerMoveX(&dx, x); + ny = y + SaucerMoveY(&dy, y); + SaucerLimitX(); + SaucerLimitY(); + dx = nx-x; + dy = ny-y; + x = nx; + y = ny; + } + setactivepage(0); + putimage(0, 0, Screen, COPY_PUT); + setvisualpage(0); + setactivepage(1); + cleardevice(); + setactivepage(0); + setviewport(vp.left, vp.top, vp.right, vp.bottom, vp.clip); + free(Screen); + } + } +#endif + + free( Saucer ); + Pause(); +} +#undef PAUSETIME +#undef PID_r +#undef StartX +#undef StartY +#undef MAXXSTEP +#undef MAXYSTEP +#undef PID_STEPS + +/* */ +/* LINETODEMO: Display a pattern using moveto and lineto commands. */ +/* */ + +#define MAXPTS 15 + +void LineToDemo(void) +{ + struct viewporttype vp; + struct PTS points[MAXPTS]; + int i, j, h, w, xcenter, ycenter; + int radius, angle, step; + double rads; + + MainWindow( "MoveTo / LineTo Demonstration" ); + + getviewsettings( &vp ); + h = vp.bottom - vp.top; + w = vp.right - vp.left; + + xcenter = w / 2; /* Determine the center of circle */ + ycenter = h / 2; + radius = (int)( (h-30) / (AspectRatio*2) ); + step = 360 / MAXPTS; /* Determine # of increments */ + + angle = 0; /* Begin at zero degrees */ + for( i=0 ; i to go back to graphics..." ); + fflush(stdout); + fgets(m,40,stdin); + + setgraphmode( mode ); + MainWindow( "SetGraphMode / RestoreCRTMode demo" ); + settextjustify( CENTER_TEXT, CENTER_TEXT ); + outtextxy( (vp.right-vp.left)/2, (vp.bottom-vp.top)/2, + "Back in Graphics Mode..." ); + + Pause(); /* Wait for user's response */ + +} + +/* */ +/* USERLINESTYLEDEMO: Display line styles showing the user */ +/* defined line style functions. */ +/* */ + +void UserLineStyleDemo(void) +{ + static unsigned msk_or[3] = { 0x0000, 0x0000, 0x8001 }; + static unsigned msk_and[3] = { 0xFFFF, 0x7FFE, 0xFFFF }; + int x, y, i, h, flag; + unsigned int style, msk_cnt; + struct viewporttype vp; + + MainWindow( "User defined line styles" ); + + getviewsettings( &vp ); + h = vp.bottom - vp.top; + + x = 4; + y = 10; + style = 0; + msk_cnt = 0; + i = 0; + + settextjustify( CENTER_TEXT, TOP_TEXT ); + flag = TRUE; /* Set the bits in this pass */ + + while( x < vp.right-2 ){ /* Draw lines across the screen */ + + if( flag ) /* If flag, set bits... */ + style |= (1 << i); /* Set the Ith bit in word */ + else /* If no flag, clear bits */ + style &= ~(1<= 3) msk_cnt = 0; + } + } + } + + settextjustify( LEFT_TEXT, TOP_TEXT ); + + Pause(); /* Wait for user's response */ + +} + +/* */ +/* FILLSTYLEDEMO: Display the standard fill patterns available. */ +/* */ + +void FillStyleDemo(void) +{ + int h, w, style; + int i, j, x, y; + struct viewporttype vp; + char buffer[40]; + + MainWindow( "Pre-defined Fill Styles" ); + + getviewsettings( &vp ); + w = 2 * ((vp.right + 1) / 13); + h = 2 * ((vp.bottom - 10) / 10); + + x = w / 2; + y = h / 2; /* Leave 1/2 blk margin */ + style = 0; + + for( j=0 ; j<3 ; ++j ){ /* Three rows of boxes */ + for( i=0 ; i<4 ; ++i ){ /* Four column of boxes */ + setfillstyle(style, WHITE); /* Set the fill style and WHITE */ + bar( x, y, x+w, y+h ); /* Draw the actual box */ + rectangle( x, y, x+w, y+h ); /* Outline the box */ + itoa( style, buffer, 10 ); /* Convert style 3 to ASCII */ + outtextxy( x+(w / 2), y+h+4, buffer ); + ++style; /* Go on to next style # */ + x += (w / 2) * 3; /* Go to next column */ + } /* End of coulmn loop */ + x = w / 2; /* Put base back to 1st column */ + y += (h / 2) * 3; /* Advance to next row */ + } /* End of Row loop */ + + settextjustify( LEFT_TEXT, TOP_TEXT ); + + Pause(); /* Wait for user's response */ + +} + +/* */ +/* FILLPATTERNDEMO: Demonstrate how to use the user definable */ +/* fill patterns. */ +/* */ + +void FillPatternDemo(void) +{ + int style; + int h, w; + int x, y, i, j; + char buffer[40]; + struct viewporttype vp; + static char patterns[][8] = { + { 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55 }, + { 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC }, + { 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F }, + { 0x00, 0x10, 0x28, 0x44, 0x28, 0x10, 0x00, 0x00 }, + { 0x00, 0x70, 0x20, 0x27, 0x24, 0x24, 0x07, 0x00 }, + { 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00 }, + { 0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x00 }, + { 0x00, 0x00, 0x22, 0x08, 0x00, 0x22, 0x1C, 0x00 }, + { 0xFF, 0x7E, 0x3C, 0x18, 0x18, 0x3C, 0x7E, 0xFF }, + { 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00 }, + { 0x00, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x00 } + }; + + MainWindow( "User Defined Fill Styles" ); + + getviewsettings( &vp ); + w = 2 * ((vp.right + 1) / 13); + h = 2 * ((vp.bottom - 10) / 10); + + x = w / 2; + y = h / 2; /* Leave 1/2 blk margin */ + style = 0; + + for( j=0 ; j<3 ; ++j ){ /* Three rows of boxes */ + for( i=0 ; i<4 ; ++i ){ /* Four column of boxes */ + setfillpattern( &patterns[style][0], WHITE); + bar( x, y, x+w, y+h ); /* Draw the actual box */ + rectangle( x, y, x+w, y+h ); /* Outline the box */ + itoa( style, buffer, 10 ); /* Convert style 3 to ASCII */ + outtextxy( x+(w / 2), y+h+4, buffer ); + ++style; /* Go on to next style # */ + x += (w / 2) * 3; /* Go to next column */ + } /* End of coulmn loop */ + x = w / 2; /* Put base back to 1st column */ + y += (h / 2) * 3; /* Advance to next row */ + } /* End of Row loop */ + + settextjustify( LEFT_TEXT, TOP_TEXT ); + + Pause(); /* Wait for user's response */ + +} + +/* */ +/* POLYDEMO: Display a random pattern of polygons on the screen */ +/* until the user says enough. */ +/* */ +void PaletteDemo(void) +{ + int i, j, x, y, color, cols; + struct viewporttype vp; + int height, width; + + if (MaxColors > 16) + return; + MainWindow( "Palette Demonstration" ); + StatusLine( StopMsg); + + getviewsettings( &vp ); + width = (vp.right - vp.left) / 15; /* get width of the box */ + height = (vp.bottom - vp.top) / 10; /* Get the height of the box */ + + x = y = 0; /* Start in upper corner */ + color = 1; /* Begin at 1st color */ + cols = 16; + if (MaxColors < cols) cols = MaxColors; + + for( j=0 ; j<10 ; ++j ){ /* For 10 rows of boxes */ + for( i=0 ; i<15 ; ++i ){ /* For 15 columns of boxes */ + setfillstyle( SOLID_FILL, color++ ); /* Set the color of box */ + bar( x, y, x+width, y+height ); /* Draw the box */ + x += width + 1; /* Advance to next col */ + color = 1 + (color % (cols- 2)); /* Set new color */ + } /* End of COLUMN loop */ + x = 0; /* Goto 1st column */ + y += height + 1; /* Goto next row */ + } /* End of ROW loop */ + + while( !kbhit() ){ /* Until user enters a key... */ + setpalette( 1+Random(cols - 2), Random(64) ); + } + + setallpalette( &palette ); + + Pause(); /* Wait for user's response */ + +} + +/* */ +/* POLYDEMO: Display a random pattern of polygons on the screen */ +/* until the user says enough. */ +/* */ + +#define MaxPts 6 /* Maximum # of pts in polygon */ + +void PolyDemo(void) +{ + struct PTS poly[ MaxPts ]; /* Space to hold datapoints */ + int color; /* Current drawing color */ + int i; + + MainWindow( "DrawPoly / FillPoly Demonstration" ); + StatusLine( StopMsg); + + while( !kbhit() ){ /* Repeat until a key is hit */ + + color = 1 + Random( MaxColors-1 ); /* Get a random color # (no blk)*/ + setfillstyle( Random(10), color ); /* Set a random line style */ + setcolor( color ); /* Set the desired color */ + + for( i=0 ; i<(MaxPts-1) ; i++ ){ /* Determine a random polygon */ + poly[i].x = Random( MaxX ); /* Set the x coord of point */ + poly[i].y = Random( MaxY ); /* Set the y coord of point */ + } + + poly[i].x = poly[0].x; /* last point = first point */ + poly[i].y = poly[1].y; + + fillpoly( MaxPts, (int far *)poly ); /* Draw the actual polygon */ + } /* End of WHILE not KBHIT */ + + Pause(); /* Wait for user's response */ + +} + + +/* */ +/* SAYGOODBYE: Give a closing screen to the user before leaving. */ +/* */ + +void SayGoodbye(void) +{ + struct viewporttype viewinfo; /* Structure to read viewport */ + int h, w; + + MainWindow( "== Finale ==" ); + + getviewsettings( &viewinfo ); /* Read viewport settings */ + changetextstyle( TRIPLEX_FONT, HORIZ_DIR, 4 ); + settextjustify( CENTER_TEXT, CENTER_TEXT ); + + h = viewinfo.bottom - viewinfo.top; + w = viewinfo.right - viewinfo.left; + outtextxy( w/2, h/2, "That's all, folks!" ); + + StatusLine( "Press any key to EXIT" ); + getch(); + + cleardevice(); /* Clear the graphics screen */ + +} + +/* ------------------------------------------------------------------- */ +/* ---- New demo routines ---- */ +/* ------------------------------------------------------------------- */ + +#ifdef __GNUC__ +#define rgb2col(r,g,b) setrgbcolor((r),(g),(b)) +#else +unsigned long rgb2color_15(int r, int g, int b) { + return ((r&0xf8)<<7) + | ((g&0xf8)<<2) + | ((b&0xf8)>>3); +} +unsigned long rgb2color_16(int r, int g, int b) { + return ((r&0xf8)<<8) + | ((g&0xfc)<<3) + | ((b&0xf8)>>3); +} +unsigned long rgb2color_24(int r, int g, int b) { + return ((r&0xff)<<16) + | ((g&0xff)<< 8) + | ((b&0xff) ); +} +#endif + +void BigColorDemo(void) { + struct viewporttype vp; + unsigned long tc; + int color, height, width; + int x, y; + +#ifdef __GNUC__ + MainWindow("High Color/True Color demonstration"); + + getviewsettings( &vp ); /* Get the current window size */ + height = (vp.bottom-vp.top)/4 - 1; + width = vp.right-vp.left; + if (width < 1) width = 1; + + y = 1; + for (x=width-1; x > 0; --x) { + color = (x-1)*256/(width-1); + /* red */ + tc = rgb2col(color,0,0); + setcolor((int)tc); + line(x,y,x,y+height-1); + /* green */ + tc = rgb2col(0,color,0); + setcolor((int)tc); + line(x,y+height,x,y+2*height-1); + /* blue */ + tc = rgb2col(0,0,color); + setcolor((int)tc); + line(x,y+2*height,x,y+3*height-1); + /* gray */ + tc = rgb2col(color,color,color); + setcolor((int)tc); + line(x,y+3*height,x,y+4*height-1); + } + setcolor(WHITE); + + Pause(); /* Pause for user's response */ +#endif +} + +int _max(int a, int b) +{ + return ( a>b ? a : b ); +} + +int _min(int a, int b) +{ + return ( a=1;l--) { + pal[l][0]=pal[l-1][0]; + pal[l][1]=pal[l-1][1]; + pal[l][2]=pal[l-1][2]; + } + pal[1][0]=r; + pal[1][1]=g; + pal[1][2]=b; + } + for (k=0;k<=255;k++) + setrgbpalette(k,pal[k][0],pal[k][1],pal[k][2]); +} + +void PlayRGBpalette(void) +/* This is partially copyrighted by COPYRIGHT(C) 1990 by H+BEDV */ +{ + typedef char _PAL[256][3]; + + int x,c, m, maxx, maxy, radius, height, ycenter; + double pc; + _PAL cpal; + struct viewporttype viewinfo; + + if ( getmaxcolor() != 255) return; + + for (c=1;c<=254;c++) { + m= (c*3)>>1; + if ((m<64)) { + cpal[c][0]=63; + cpal[c][1]=m; + cpal[c][2]=0; + } + if ((m>63) && (m<128)) { + cpal[c][0]=127-m; + cpal[c][1]=63; + cpal[c][2]=0; + } + if ((m>127) && (m<192)) { + cpal[c][0]=0; + cpal[c][1]=63; + cpal[c][2]=m-128; + } + if ((m>191) && (m<256)) { + cpal[c][0]=0; + cpal[c][1]=255-m; + cpal[c][2]=63; + } + if ((m>255) && (m<320)) { + cpal[c][0]=m-256; + cpal[c][1]=0; + cpal[c][2]=63; + } + if ((m>319)) { + cpal[c][0]=63; + cpal[c][1]=0; + cpal[c][2]=383-m; + } + } + cpal[0][0]=0; + cpal[0][1]=0; + cpal[0][2]=0; + cpal[255][0]=63; + cpal[255][1]=63; + cpal[255][2]=63; + ShiftDac( cpal); + + MainWindowColor( "Play RGB palette", 255); + getviewsettings( &viewinfo ); + maxx = abs(viewinfo.right-viewinfo.left)-1; + maxy = abs(viewinfo.top-viewinfo.bottom)-1; + setcolor(255); + + height = maxy/8; + c=1; + for (x=5; x <= maxx+1-5; ++x) { + setcolor(c); + if (++c > 254) c = 1; + line(x,maxy-5,x,maxy-5-height); + } + + pc=1.0; + ycenter = (maxy-5-height) / 2; + radius = _min((int)((maxy-5-height)/AspectRatio), maxx)*9/20; + for (x=0;x<=356;x++) { + setcolor((int)pc); + setfillstyle(SOLID_FILL,(int)pc); + pieslice(maxx/2,ycenter,x,x+4,radius); + pc=pc+254.0/360.0; + } + + StatusLineColor( StopMsg, 255); + + do { + ShiftDac(cpal); + } while (!(kbhit())); + if ( getch() == ESC) { + closegraph(); + exit(1); + } + for (c=1; c < 255; ++c) { + cpal[c][0] = _dac_g256[c][0]; + cpal[c][1] = _dac_g256[c][1]; + cpal[c][2] = _dac_g256[c][2]; + } + + StatusLineColor( PauseMsg, 255); + do { + ShiftDac(cpal); + } while (!(kbhit())); + + setbkcolor(BLACK); + clearviewport(); + setrgbdefaults(); + Pause(); /* Pause for user to read screen*/ +} + +/* The Sierpinski demo was mainly taken from + N. Wirth: Algorithmen und Datenstrukturen */ +#define SIRP_N 4 +#define SIRP_H0 320 + +static int SIRP_x, SIRP_y, h; + +static void SIRP_a(int i); +static void SIRP_b(int i); +static void SIRP_c(int i); +static void SIRP_d(int i); + +static void SIRP_a(int i) +{ + if (i>0) { + SIRP_a(i-1); SIRP_x += h; SIRP_y -= h; lineto( SIRP_x, SIRP_y); + SIRP_b(i-1); SIRP_x += 2*h; lineto( SIRP_x, SIRP_y); + SIRP_d(i-1); SIRP_x += h; SIRP_y += h; lineto( SIRP_x, SIRP_y); + SIRP_a(i-1); + } +} + +static void SIRP_b(int i) +{ + if (i>0) { + SIRP_b(i-1); SIRP_x -= h; SIRP_y -= h; lineto( SIRP_x, SIRP_y); + SIRP_c(i-1); SIRP_y -= 2*h; lineto( SIRP_x, SIRP_y); + SIRP_a(i-1); SIRP_x += h; SIRP_y -= h; lineto( SIRP_x, SIRP_y); + SIRP_b(i-1); + } +} + +static void SIRP_c(int i) +{ + if (i>0) { + SIRP_c(i-1); SIRP_x -= h; SIRP_y += h; lineto( SIRP_x, SIRP_y); + SIRP_d(i-1); SIRP_x -= 2*h; lineto( SIRP_x, SIRP_y); + SIRP_b(i-1); SIRP_x -= h; SIRP_y -= h; lineto( SIRP_x, SIRP_y); + SIRP_c(i-1); + } +} + +static void SIRP_d(int i) +{ + if (i>0) { + SIRP_d(i-1); SIRP_x += h; SIRP_y += h; lineto( SIRP_x, SIRP_y); + SIRP_a(i-1); SIRP_y += 2*h; lineto( SIRP_x, SIRP_y); + SIRP_c(i-1); SIRP_x -= h; SIRP_y += h; lineto( SIRP_x, SIRP_y); + SIRP_d(i-1); + } +} + +void sierpinski(void) +{ + int i, h0, x0, y0, bx, by; + int color, border; + struct viewporttype vp; + struct fillsettingstype fs; + + if (MaxColors < 16) + return; + + MainWindow( "Floodfill demo"); + StatusLine(PauseMsg); + getviewsettings( &vp); + getfillsettings( &fs); + + setviewport( (bx=_max((getmaxx() - SIRP_H0) / 2, vp.left)), + (by=_max((getmaxy() - SIRP_H0) / 2, vp.top)), + _min((getmaxx() + SIRP_H0) / 2 + 5, vp.right), + _min((getmaxy() + SIRP_H0) / 2 + 5, vp.bottom), + TRUE ); + + border = _ega_color(YELLOW); + setcolor( border); + h0 = SIRP_H0; + h = h0 / 4; + x0 = 2*h; + y0 = 3*h; + for (i=1; i <= SIRP_N; ++i) { + x0 -= h; + h /= 2; + y0 += h; + SIRP_x = x0; SIRP_y = y0; + moveto( SIRP_x, SIRP_y); + SIRP_a(i); SIRP_x += h; SIRP_y -= h; lineto(SIRP_x,SIRP_y); + SIRP_b(i); SIRP_x -= h; SIRP_y -= h; lineto(SIRP_x,SIRP_y); + SIRP_c(i); SIRP_x -= h; SIRP_y += h; lineto(SIRP_x,SIRP_y); + SIRP_d(i); SIRP_x += h; SIRP_y += h; lineto(SIRP_x,SIRP_y); + } + setviewport( vp.left, vp.top, vp.right, vp.bottom, vp.clip); + bx += h0/2 - vp.left; + by += h0/2 - vp.top; + color = BLUE-1; + do { + if (++color >= YELLOW) color = BLUE; + setfillstyle(Random(USER_FILL-1)+1, _ega_color(color)); + floodfill( bx, by, border); + if (kbhit()) break; + floodfill( 1, 1, border); + } while ( !kbhit()); + setfillstyle( fs.pattern, fs.color); + + Pause(); /* Pause for user to read screen*/ +} + +#ifdef __GNUC__ +/* Borland C died frequently on this demo */ +void snake(void) +{ + int i, x0, y0, x1, y1, x, y; + int color, border; + struct viewporttype vp; + struct fillsettingstype fs; + int dx, dy; + + if (MaxColors < 16) + return; + + MainWindow( "Floodfill demo 2"); + StatusLine(PauseMsg); + getviewsettings( &vp); + getfillsettings( &fs); + + x0 = 0; y0 = 0; + x1 = getmaxx(); y1 = getmaxy(); + if (x1-x0 < y1-y0) { + dx = (x1-x0) / 24; + dy = (int)(dx*AspectRatio + 0.5); + } else { + dy = (y1-y0) / 24; + dx = (int)(dy/AspectRatio + 0.5); + } + + border = _ega_color(YELLOW); + setcolor( border); + + moveto(x=(x1-x0)/2, y=(y1-y0)/2); + i = 0; + while (x0= YELLOW) color = BLUE; + setfillstyle(Random(USER_FILL-1)+1, _ega_color(color)); + floodfill( x, y, border); + delay(500); + } while ( !kbhit()); + setfillstyle( fs.pattern, fs.color); + + Pause(); /* Pause for user to read screen*/ +} +#endif + +void RandomSolidBars(void) +{ + int color; + + MainWindow( "Random Solid/Line Bars" ); + StatusLine( PauseMsg ); /* Put msg at bottom of screen */ + while( !kbhit() ){ /* Until user enters a key... */ + color = Random( MaxColors-1 )+1; + setcolor( color ); + /* SOLID_FILL && LINE_FILL are much faster */ + setfillstyle( SOLID_FILL+Random(2), color ); + bar3d( Random( getmaxx() ), Random( getmaxy() ), + Random( getmaxx() ), Random( getmaxy() ), 0, OFF); + } + + Pause(); /* Pause for user's response */ + +} + +#define Memory 100 +#define Windows 4 + +typedef int ColorList[Windows]; + + +typedef struct _REC_Line { + int LX1, LY1, LX2, LY2; + ColorList LColor; +} _REC_Line; + +/* Local variables for LinePlay: */ +struct LOC_LinePlay { + int ViewXmax, ViewYmax; + _REC_Line Line[Memory]; + int X1, X2, Y1, Y2, CurrentLine, ColorCount, IncrementCount, DeltaX1, + DeltaY1, DeltaX2, DeltaY2; + ColorList Colors; + int MaxDelta; +} ; + +void AdjustX(int *X, int *DeltaX, struct LOC_LinePlay *LINK) +{ + int TestX; + + TestX = *X + *DeltaX; + if (TestX < 1 || TestX > LINK->ViewXmax) { + TestX = *X; + *DeltaX = -*DeltaX; + } + *X = TestX; +} + +void AdjustY(int *Y, int *DeltaY, struct LOC_LinePlay *LINK) +{ + int TestY; + + TestY = *Y + *DeltaY; + if (TestY < 1 || TestY > LINK->ViewYmax) { + TestY = *Y; + *DeltaY = -*DeltaY; + } + *Y = TestY; +} + +int RandColor(void) +{ + return Random(MaxColors-1) + 1; +} + +void SelectNewColors(struct LOC_LinePlay *LINK) +{ + LINK->Colors[0] = RandColor(); + LINK->Colors[1] = RandColor(); + LINK->Colors[2] = RandColor(); + LINK->Colors[3] = RandColor(); + LINK->ColorCount = (Random(5) + 1) * 3; +} + +void SelectNewDeltaValues(struct LOC_LinePlay *LINK) +{ + LINK->DeltaX1 = Random(LINK->MaxDelta) - LINK->MaxDelta / 2; + LINK->DeltaX2 = Random(LINK->MaxDelta) - LINK->MaxDelta / 2; + LINK->DeltaY1 = Random(LINK->MaxDelta) - LINK->MaxDelta / 2; + LINK->DeltaY2 = Random(LINK->MaxDelta) - LINK->MaxDelta / 2; + LINK->IncrementCount = (Random(4) + 1) * 2; +} + +void SaveCurrentLine(int *CurrentColors, struct LOC_LinePlay *LINK) +{ + _REC_Line *WITH; + + WITH = &LINK->Line[LINK->CurrentLine - 1]; + WITH->LX1 = LINK->X1; + WITH->LY1 = LINK->Y1; + WITH->LX2 = LINK->X2; + WITH->LY2 = LINK->Y2; + memcpy(WITH->LColor, CurrentColors, sizeof(ColorList)); +} + +void Draw(unsigned short x1, unsigned short y1, unsigned short x2, + unsigned short y2, unsigned short color) +{ + setcolor(color); + line(x1, y1, x2, y2); +} + +void Updateline(struct LOC_LinePlay *LINK) +{ + LINK->CurrentLine++; + if (LINK->CurrentLine > Memory) + LINK->CurrentLine = 1; + LINK->ColorCount--; + LINK->IncrementCount--; +} + +void DrawCurrentLine(struct LOC_LinePlay *LINK) +{ + Draw(LINK->X1, LINK->Y1, LINK->X2, LINK->Y2, LINK->Colors[0]); + Draw(LINK->ViewXmax - LINK->X1, LINK->Y1, LINK->ViewXmax - LINK->X2, + LINK->Y2, LINK->Colors[1]); + Draw(LINK->X1, LINK->ViewYmax - LINK->Y1, LINK->X2, + LINK->ViewYmax - LINK->Y2, LINK->Colors[2]); + Draw(LINK->ViewXmax - LINK->X1, LINK->ViewYmax - LINK->Y1, + LINK->ViewXmax - LINK->X2, LINK->ViewYmax - LINK->Y2, LINK->Colors[3]); + SaveCurrentLine(LINK->Colors, LINK); +} + +void EraseCurrentLine(struct LOC_LinePlay *LINK) +{ + _REC_Line *WITH; + + WITH = &LINK->Line[LINK->CurrentLine - 1]; + Draw(WITH->LX1, WITH->LY1, WITH->LX2, WITH->LY2, 0); + Draw(LINK->ViewXmax - WITH->LX1, WITH->LY1, LINK->ViewXmax - WITH->LX2, + WITH->LY2, 0); + Draw(WITH->LX1, LINK->ViewYmax - WITH->LY1, WITH->LX2, + LINK->ViewYmax - WITH->LY2, 0); + Draw(LINK->ViewXmax - WITH->LX1, LINK->ViewYmax - WITH->LY1, + LINK->ViewXmax - WITH->LX2, LINK->ViewYmax - WITH->LY2, 0); +} + +void DoArt(struct LOC_LinePlay *LINK) +{ + SelectNewColors(LINK); + do { + EraseCurrentLine(LINK); + if (LINK->ColorCount == 0) + SelectNewColors(LINK); + if (LINK->IncrementCount == 0) + SelectNewDeltaValues(LINK); + AdjustX(&LINK->X1, &LINK->DeltaX1, LINK); + AdjustX(&LINK->X2, &LINK->DeltaX2, LINK); + AdjustY(&LINK->Y1, &LINK->DeltaY1, LINK); + AdjustY(&LINK->Y2, &LINK->DeltaY2, LINK); + if (Random(5) == 3) { + LINK->X1 = (LINK->X1 + LINK->X2) / 2; /* shorten the lines */ + LINK->Y2 = (LINK->Y1 + LINK->Y2) / 2; + } + DrawCurrentLine(LINK); + Updateline(LINK); + } while (!kbhit()); +} + + +void LinePlay(void) +{ + struct LOC_LinePlay V; + struct viewporttype ViewInfo; + int StartX, StartY, I; + _REC_Line *WITH; + + MainWindow("Line demonstration"); + StatusLine("Esc aborts or press a key ..."); + getviewsettings(&ViewInfo); + V.CurrentLine = 1; + V.ColorCount = 0; + V.IncrementCount = 0; + V.MaxDelta = 16; + V.ViewXmax = ViewInfo.right - 1; + V.ViewYmax = ViewInfo.bottom - 3; + StartX = ViewInfo.right / 2; + StartY = ViewInfo.bottom / 2; + for (I = 0; I < Memory; I++) { + WITH = &V.Line[I]; + WITH->LX1 = StartX; + WITH->LX2 = StartX; + WITH->LY1 = StartY; + WITH->LY2 = StartY; + } + V.X1 = StartX; + V.X2 = StartX; + V.Y1 = StartY; + V.Y2 = StartY; + DoArt(&V); + Pause(); +} + +#undef Memory +#undef Windows + +/* Local variables for ColorPlay: */ +struct LOC_ColorPlay { + unsigned short Color, Width, Height; + struct viewporttype ViewInfo; +} ; + +char *Int2Str(char *Result, long L) +{ + /* Converts an integer to a string for use with OutText, OutTextXY */ + char S[256]; + + sprintf(S, "%ld", L); + return strcpy(Result, S); +} /* Int2Str */ + + +void DrawBox__(unsigned short X, unsigned short Y, + struct LOC_ColorPlay *LINK) +{ + int bottom; + char STR1[256]; + + setfillstyle(SOLID_FILL, LINK->Color); + setcolor(LINK->Color); + if (LINK->Height / 2 >= textheight("M") + 4) + bottom = Y + LINK->Height; + else + bottom = Y + LINK->Height / 2 * 3 - textheight("M") - 5; + bar(X, Y, X + LINK->Width, bottom); + rectangle(X, Y, X + LINK->Width, bottom); + LINK->Color = getcolor(); + if (LINK->Color == 0) { + setcolor(MaxColors); + rectangle(X, Y, X + LINK->Width, bottom); + } + setcolor(WHITE); + outtextxy(X + LINK->Width / 2, bottom + 3, Int2Str(STR1, LINK->Color)); + LINK->Color = (LINK->Color + 1) % (MaxColors + 1); +} /* DrawBox */ + + +void ColorPlay(void) +{ + /* Display all of the colors available for the current driver and mode */ + struct LOC_ColorPlay V; + unsigned short X, Y, I, J; + + if (MaxColors != 256) { + ColorDemo(); + if (MaxColors < 256) + return; + } + if (MaxColors > 256) { + BigColorDemo(); + return; + } + MainWindow("Color demonstration"); + V.Color = 1; + getviewsettings(&V.ViewInfo); + V.Width = (V.ViewInfo.right + 1) / 53 * 2; + V.Height = (V.ViewInfo.bottom - 10) / 47 * 2; + if (V.Height < textheight("M") + 4) + V.Height = textheight("M") + 4; + if (V.Width < textwidth("M") * 2) + V.Width = textwidth("M") * 2; + X = V.Width / 2; + Y = V.Height / 2; + for (J = 1; J <= 15; J++) { + for (I = 1; I <= 17; I++) { + if (!kbhit()) + DrawBox__(X, Y, &V); + X += V.Width / 2 * 3; + } + X = V.Width / 2; + Y += V.Height / 2 * 3; + } + Pause(); +} /* ColorPlay */ + + + + +/* */ +/* Begin main function */ +/* */ + +int main(void) +{ + +#if 0 && defined(__GNUC__) + registerbgifont( &_bold_font); + registerbgifont( &_euro_font); + registerbgifont( &_goth_font); + registerbgifont( &_lcom_font); + registerbgifont( &_litt_font); + registerbgifont( &_sans_font); + registerbgifont( &_scri_font); + registerbgifont( &_simp_font); + registerbgifont( &_trip_font); + registerbgifont( &_tscr_font); +#endif + Initialize(); /* Set system into Graphics mode */ + ReportStatus(); /* Report results of the initialization */ + ColorPlay(); /* Begin actual demonstration */ + if( GraphDriver==EGA || GraphDriver==EGA64 || GraphDriver==VGA ) + PaletteDemo(); + PutPixelDemo(); + PutImageDemo(); + Bar3DDemo(); + BarDemo(); + RandomBars(); + RandomSolidBars(); + sierpinski(); +#ifdef __GNUC__ + snake(); +#endif + ArcDemo(); + CircleDemo(); + PieDemo(); + PlayRGBpalette(); + LinePlay(); + LineRelDemo(); + LineToDemo(); + LineStyleDemo(); + UserLineStyleDemo(); + TextDump(); + TextDemo(); + CRTModeDemo(); + FillStyleDemo(); + FillPatternDemo(); + PolyDemo(); + SayGoodbye(); /* Give user the closing screen */ + closegraph(); /* Return the system to text mode */ + return(0); +} + diff --git a/thirdparty/grx249/test/bgi/bgilink.c b/thirdparty/grx249/test/bgi/bgilink.c new file mode 100644 index 0000000..696da28 --- /dev/null +++ b/thirdparty/grx249/test/bgi/bgilink.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 1993-97 by Hartmut Schirmer + */ + +#include /* NULL, exit() */ +#include +#include "libbcc.h" + +static void check_linked( void *ptr ) +{ + if ( ptr == NULL ) + { + exit(1); + } +} + +int main(void) +{ + check_linked(restorecrtmode); + check_linked(closegraph); + check_linked(getgraphmode); + check_linked(getmaxmode); + check_linked(getmoderange); + check_linked(graphresult); + check_linked(getx); + check_linked(gety); + check_linked(moveto); + check_linked(moverel); + check_linked(getbkcolor); + check_linked(getcolor); + check_linked(cleardevice); + check_linked(setbkcolor); + check_linked(setcolor); + check_linked(line); + check_linked(linerel); + check_linked(lineto); + check_linked(drawpoly); + check_linked(bar); + check_linked(circle); + check_linked(ellipse); + check_linked(arc); + check_linked(getaspectratio); + check_linked(setaspectratio); + check_linked(getfillsettings); + check_linked(getfillpattern); + check_linked(sector); + check_linked(pieslice); + check_linked(setgraphbufsize); + check_linked(getdefaultpalette); + check_linked(installbgidriver); + check_linked(registerfarbgidriver); + check_linked(registerfarbgifont); + check_linked(textlinestyle); + check_linked(setpalette); + check_linked(set_BGI_mode_whc); + check_linked(set_BGI_mode_pages); + check_linked(get_BGI_mode_pages); + check_linked(getmodemaxcolor); + check_linked(getmodemaxx); + check_linked(getmodemaxy); + check_linked(setrgbcolor); + check_linked(setactivepage); + check_linked(getactivepage); + check_linked(setvisualpage); + check_linked(getvisualpage); + return 0; +} diff --git a/thirdparty/grx249/test/bgi/colortst.c b/thirdparty/grx249/test/bgi/colortst.c new file mode 100644 index 0000000..c5f1ba0 --- /dev/null +++ b/thirdparty/grx249/test/bgi/colortst.c @@ -0,0 +1,124 @@ +/* From VGAlib, changed for svgalib */ +/* partially copyrighted (C) 1993,1995 by Hartmut Schirmer */ + + +#include +#include +#include "libbcc.h" +#include "stdfun.h" + +static void testmode(int mode) { + int xmax, ymax; + int i, oldmode; + int x, y, yw; + int c; + + if (graphresult() == grNoInitGraph) + return; +#ifdef __GNUC__ + if (getmodemaxcolor(mode)+1 < 256) + return; +#endif + oldmode = getgraphmode(); + if (mode != oldmode) { + graphresult(); + setgraphmode(mode); + if (graphresult() != grOk) + return; + } + if (getmaxcolor() < 255) { + if (oldmode != mode) + setgraphmode(oldmode); + return; + } + xmax = getmaxx(); + ymax = getmaxy(); + + yw = (ymax - 0) / 4; + switch (getmaxcolor()+1) { + case 256: + #define std_c (16) + #define free_c (256-std_c) + #define avail (free_c / 4) + #define nrval (256/4) + for (i = 0; i < avail; ++i) { + c = (i * nrval) / avail; + setrgbpalette(i + std_c + (0 * avail), c, c, c); + setrgbpalette(i + std_c + (1 * avail), c, 0, 0); + setrgbpalette(i + std_c + (2 * avail), 0, c, 0); + setrgbpalette(i + std_c + (3 * avail), 0, 0, c); + } + for (x = 2; x < xmax - 1; ++x) { + c = (((x-2)*avail) / (xmax-3)) + std_c; + for (i=0; i < 4; ++i) { + setcolor(c+(avail*i)); + line( x, i*yw, x, (i+1)*yw); + } + } + break; +#ifdef __GNUC__ + case 1 << 15: + case 1 << 16: + case 1 << 24: + for (x = 2; x < xmax - 1; ++x) { + c = ((x - 2) * 256) / (xmax - 3); + y = 0; + setrgbcolor(c, c, c); + line(x, y, x, y + yw - 1); + y += yw; + setrgbcolor(c, 0, 0); + line(x, y, x, y + yw - 1); + y += yw; + setrgbcolor(0, c, 0); + line(x, y, x, y + yw - 1); + y += yw; + setrgbcolor(0, 0, c); + line(x, y, x, y + yw - 1); + } + break; +#endif + default: + if (oldmode != mode) + setgraphmode(oldmode); + return; + } + { + char *mn = getmodename(mode); + setcolor(WHITE); + settextjustify( CENTER_TEXT, BOTTOM_TEXT ); + outtextxy(getmaxx()/2, getmaxy(), mn); + } + getch(); + + if (oldmode != mode) + setgraphmode(oldmode); +} + +int main(void) +{ + int gd, gm; + int err; + int lomode, himode; + + gd = DETECT; +#if defined(__MSDOS__) || defined(__WIN32__) + initgraph(&gd,&gm,"..\\..\\chr"); +#else + initgraph(&gd,&gm,"../../chr"); +#endif + err = graphresult(); + if (err != grOk) { + fprintf(stderr, "Couldn't initialize graphics\n"); + return 1; + } + getmoderange(gd, &lomode, &himode); + gm = lomode; +#ifdef __GNUC__ + if (gm < __FIRST_DRIVER_SPECIFIC_MODE) + gm = __FIRST_DRIVER_SPECIFIC_MODE; +#endif + for ( ; gm <= himode; ++gm) + testmode(gm); + closegraph(); + return 0; +} diff --git a/thirdparty/grx249/test/bgi/fontplay.c b/thirdparty/grx249/test/bgi/fontplay.c new file mode 100644 index 0000000..453994f --- /dev/null +++ b/thirdparty/grx249/test/bgi/fontplay.c @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include +#include "stdfun.h" + +#ifdef __GNUC__ +# define getch() getkey() +#else +# error fontplay requires DJGPP/GRX based compiler +#endif + + +long long Time(void) { + struct timeval tm; + + gettimeofday(&tm,NULL); + return ((long long)tm.tv_sec)*1000+(tm.tv_usec/1000); +} + +int main(int argc, char *argv[]) +{ + int gd, gm, i, font; + int err; + long long start, stop; + +#if defined(__MSDOS__) || defined(__WIN32__) + initgraph(&gd,&gm,"..\\..\\chr"); +#else + initgraph(&gd,&gm,"../../chr"); +#endif + err = graphresult(); + if (err != grOk) { + fprintf(stderr, "Couldn't initialize graphics\n"); + exit(1); + } + +#if 0 + registerbgifont( &_bold_font); + registerbgifont( &_euro_font); + registerbgifont( &_goth_font); + registerbgifont( &_lcom_font); + registerbgifont( &_litt_font); + registerbgifont( &_sans_font); + registerbgifont( &_scri_font); + registerbgifont( &_simp_font); + registerbgifont( &_trip_font); + registerbgifont( &_tscr_font); +#endif + + start = Time(); + for (i=0; i < 2500; ++i) { + setcolor(i&15); + for (font=TRIPLEX_FONT; font <= BOLD_FONT; ++font) { + settextstyle(font, HORIZ_DIR, 1); + outtextxy( 10, 10, "M"); + } + } + stop = Time(); + closegraph(); + printf("Time : %1.3fs\n", (stop-start)/1000.0); + return 0; +} + diff --git a/thirdparty/grx249/test/bgi/makefile.bcc b/thirdparty/grx249/test/bgi/makefile.bcc new file mode 100644 index 0000000..f160191 --- /dev/null +++ b/thirdparty/grx249/test/bgi/makefile.bcc @@ -0,0 +1,35 @@ +# +# GRX 2.0 test programs makefile for Turbo C. Uses Turbo C make. +# +.AUTODEPEND + +!include "../../makedefs.bcc" + +INCDIR= -I../../include -I$(BCCROOT)\include +LIBDIR= -L$(BCCROOT)/lib + +GRX20ST = ../../lib/$(GRX_LIB_SUBDIR)/grx20$(MODEL).lib + +PROGS= \ + bgilink.exe \ + bccbgi.exe \ + colortst.exe \ + small.exe \ + tellipse.exe \ + tfill.exe \ + tmodes.exe \ + tpoly.exe \ + ttext.exe + +all: $(PROGS) + +clean: + if exist *.obj del *.obj + if exist *.exe del *.exe + +.obj.exe: + $(BCC) $(LIBDIR) $(LDOPT) -n. -e$* $*.obj $(GRX20ST) + +.c.obj: + $(BCC) -c $(CCOPT) $(INCDIR) -o$*.obj $*.c + diff --git a/thirdparty/grx249/test/bgi/makefile.dj2 b/thirdparty/grx249/test/bgi/makefile.dj2 new file mode 100644 index 0000000..9b7501a --- /dev/null +++ b/thirdparty/grx249/test/bgi/makefile.dj2 @@ -0,0 +1,65 @@ +# +# GRX test programs makefile for DJGPP v2. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean install uninstall + +GRXVDJ2=y + +include ../../makedefs.grx + +INCDIR= -I../../include +GRX20 = ../../lib/$(GRX_LIB_SUBDIR)/libgrx20.a + +ADDON_LIBS=-lpc + +#ifeq ($(HAVE_LIBTIFF),y) +# ADDON_LIBS += -ltiff +#endif +# +#ifeq ($(HAVE_LIBJPEG),y) +# ADDON_LIBS += -ljpeg +#endif +# +#ifeq ($(NEED_ZLIB),y) +# ADDON_LIBS += -lz +#endif + +LIBS= $(GRX20) $(ADDON_LIBS) + +PROGS= \ + bgilink.exe \ + bccbgi.exe \ + colortst.exe \ + fontplay.exe \ + small.exe \ + tellipse.exe \ + tfill.exe \ + tmodes.exe \ + tpoly.exe \ + ttext.exe + +all: $(PROGS) + +$(PROGS): %.exe : %.o $(GRX20) + $(CC) $(LDOPT) -o $*.exe $*.o $(LIBS) -lm + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c + +clean: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f *.o *.exe +else + if exist *.o del *.o + if exist *.exe del *.exe +endif + +depend.new: + $(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:.exe=.c) >depend.new + +#include depend.gnu diff --git a/thirdparty/grx249/test/bgi/makefile.lnx b/thirdparty/grx249/test/bgi/makefile.lnx new file mode 100644 index 0000000..38ab5b7 --- /dev/null +++ b/thirdparty/grx249/test/bgi/makefile.lnx @@ -0,0 +1,87 @@ +# +# GRX test programs makefile for LINUX/console. Uses GNU make. +# +.PHONY : clean setsuid + +GRXVLNX=y + +include ../../makedefs.grx + +INCDIR= -I../../include + +CCOPT += -pipe + +# Enable this line for static linked test progs (default) +GRX20 = ../../lib/$(GRX_LIB_SUBDIR)/libgrx20.a +# or this if you've already installed the shared libs +#GRX20 = -L../../lib/$(GRX_LIB_SUBDIR) -lgrx20 + +ifeq ($(USE_SVGALIB_DRIVER),y) + ADDON_LIBS= -lvga +endif + +#ifeq ($(HAVE_LIBTIFF),y) +# ADDON_LIBS += -ltiff +#endif +# +#ifeq ($(HAVE_LIBJPEG),y) +# ADDON_LIBS += -ljpeg +#endif +# +#ifeq ($(NEED_ZLIB),y) +# ADDON_LIBS += -lz +#endif + +ifeq ($(SET_SUIDROOT),y) +EXECBITS = 4755 +else +EXECBITS = 0755 +endif + +LIBS= $(GRX20) $(ADDON_LIBS) -lm + +PROGS= \ + bgilink \ + bccbgi \ + colortst \ + fontplay \ + small \ + tellipse \ + tfill \ + tmodes \ + tpoly \ + ttext + +all: $(PROGS) + +$(PROGS): % : %.o $(GRX20) + +clean: + rm -f *.o $(PROGS) + +setsuid: $(PROGS) +ifeq ($(SET_SUIDROOT),y) + chown root $(PROGS) + chmod $(EXECBITS) $(PROGS) +else + @echo "Nothing to do, SET_SUIDROOT is not set to 'y' in makedefs.grx" +endif + +.o: + $(CC) $(LDOPT) -o $* $*.o $(LIBS) + chmod $(EXECBITS) $* + +.oo: + $(CC) $(LDOPT) -o $* $*.o $(LIBS) + $(STRIP) $* + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c + +depend.new: + $(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:=.c) >depend.new + +#include depend.gnu diff --git a/thirdparty/grx249/test/bgi/makefile.sdl b/thirdparty/grx249/test/bgi/makefile.sdl new file mode 100644 index 0000000..8122252 --- /dev/null +++ b/thirdparty/grx249/test/bgi/makefile.sdl @@ -0,0 +1,73 @@ +# +# GRX test programs makefile for SDL. Uses GNU make. +# +.PHONY : clean + +GRXVSDL=y + +include ../../makedefs.grx + +INCDIR= -I. -I../../include + +GRX20ST = ../../lib/$(GRX_LIB_SUBDIR)/libgrx20S.a + +ifeq ($(EP),x) + INCDIR += $(X11INCS) + SDLDEFS = -D__XWIN__ + SDLLIBS = -lSDL -lpthread $(X11LIBS) +else + EX = .exe + SDLDEFS = + SDLLIBS = -lSDL +endif + +#ifeq ($(HAVE_LIBTIFF),y) +# ADDON_LIBS += -ltiff +#endif + +#ifeq ($(HAVE_LIBJPEG),y) +# ADDON_LIBS += -ljpeg +#endif + +#ifeq ($(HAVE_LIBPNG),y) +# ADDON_LIBS += -lpng +#endif + +#ifeq ($(NEED_ZLIB),y) +# ADDON_LIBS += -lz +#endif + +LIBS= $(GRX20ST) $(ADDON_LIBS) $(SDLLIBS) -lm + +CCOPT += $(SDLDEFS) + +PROGS= \ + $(EP)bgilink$(EX) \ + $(EP)bccbgi$(EX) \ + $(EP)colortst$(EX) \ + $(EP)fontplay$(EX) \ + $(EP)small$(EX) \ + $(EP)tellipse$(EX) \ + $(EP)tfill$(EX) \ + $(EP)tmodes$(EX) \ + $(EP)tpoly$(EX) \ + $(EP)ttext$(EX) + +all: $(PROGS) + +$(PROGS): $(EP)%$(EX) : %.o $(GRX20ST) + $(CC) $(LDOPT) -o $@ $*.o $(LIBS) + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c + +clean: + rm -f *.o $(PROGS) + +depend.new: + $(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:$(EP)%$(EX)=%.c) > depend.new + +#include depend.gnu diff --git a/thirdparty/grx249/test/bgi/makefile.w32 b/thirdparty/grx249/test/bgi/makefile.w32 new file mode 100644 index 0000000..3bb3097 --- /dev/null +++ b/thirdparty/grx249/test/bgi/makefile.w32 @@ -0,0 +1,63 @@ +# +# GRX test programs makefile for Mingw +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean install uninstall + +GRXVW32=y + +include ../../makedefs.grx + +INCDIR= -I../../include +GRX20 = ../../lib/$(GRX_LIB_SUBDIR)/libgrx20.a + +#ifeq ($(HAVE_LIBTIFF),y) +# ADDON_LIBS += -ltiff +#endif + +#ifeq ($(HAVE_LIBJPEG),y) +# ADDON_LIBS += -ljpeg +#endif + +#ifeq ($(NEED_ZLIB),y) +# ADDON_LIBS += -lz +#endif + +LIBS= $(GRX20) $(ADDON_LIBS) + +PROGS= \ + bgilink.exe \ + bccbgi.exe \ + colortst.exe \ + fontplay.exe \ + small.exe \ + tellipse.exe \ + tfill.exe \ + tmodes.exe \ + tpoly.exe \ + ttext.exe + +all: $(PROGS) \ + +$(PROGS): %.exe : %.o $(GRX20) + $(CC) $(LDOPT) -o $*.exe $*.o $(LIBS) -lm -mwindows -mconsole + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c + +clean: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f *.o *.exe +else + if exist *.o del *.o + if exist *.exe del *.exe +endif + +#depend.new: +# $(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:.exe=.c) >depend.new + +#include depend.gnu diff --git a/thirdparty/grx249/test/bgi/makefile.wat b/thirdparty/grx249/test/bgi/makefile.wat new file mode 100644 index 0000000..51f8a61 --- /dev/null +++ b/thirdparty/grx249/test/bgi/makefile.wat @@ -0,0 +1,87 @@ +!define BLANK "" + +############## +# Object Files + +.\bgilink.obj : .\test\bgilink.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bccbgi.obj : .\test\bccbgi.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\colortst.obj : .\test\colortst.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fontplay.obj : .\test\fontplay.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\small.obj : .\test\small.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\tellipse.obj : .\test\tellipse.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\tfill.obj : .\test\tfill.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\tmodes.obj : .\test\tmodes.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\tpoly.obj : .\test\tpoly.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ttext.obj : .\test\ttext.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +############## +# Executables + +$(GRX_BIN_SUBDIR)\bccbgi.exe : .\bccbgi.obj $(GRXLIB) .AUTODEPEND + @%write bccbgi.lk1 FIL bccbgi.obj + @%append bccbgi.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\bccbgi $(LINK_OPTS) @bccbgi.lk1 + +$(GRX_BIN_SUBDIR)\colortst.exe : .\colortst.obj $(GRXLIB) .AUTODEPEND + @%write colortst.lk1 FIL colortst.obj + @%append colortst.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\ $(LINK_OPTS) @colortst.lk1 + +$(GRX_BIN_SUBDIR)\fontplay.exe : .\fontplay.obj $(GRXLIB) .AUTODEPEND + @%write fontplay.lk1 FIL fontplay.obj + @%append fontplay.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\ $(LINK_OPTS) @fontplay.lk1 + +$(GRX_BIN_SUBDIR)\small.exe : .\small.obj $(GRXLIB) .AUTODEPEND + @%write small.lk1 FIL small.obj + @%append .lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\small $(LINK_OPTS) @small.lk1 + +$(GRX_BIN_SUBDIR)\tellipse.exe : .\tellipse.obj $(GRXLIB) .AUTODEPEND + @%write tellipse.lk1 FIL tellipse.obj + @%append tellipse.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\tellipse $(LINK_OPTS) @tellipse.lk1 + +$(GRX_BIN_SUBDIR)\tfill.exe : .\tfill.obj $(GRXLIB) .AUTODEPEND + @%write tfill.lk1 FIL tfill.obj + @%append tfill.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\tfill $(LINK_OPTS) @tfill.lk1 + +$(GRX_BIN_SUBDIR)\tmodes.exe : .\tmodes.obj $(GRXLIB) .AUTODEPEND + @%write tmodes.lk1 FIL tmodes.obj + @%append tmodes.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\tmodes $(LINK_OPTS) @tmodes.lk1 + +$(GRX_BIN_SUBDIR)\tpoly.exe : .\tpoly.obj $(GRXLIB) .AUTODEPEND + @%write tpoly.lk1 FIL tpoly.obj + @%append tpoly.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\tpoly $(LINK_OPTS) @.tpolylk1 + +$(GRX_BIN_SUBDIR)\ttext.exe : .\ttext.obj $(GRXLIB) .AUTODEPEND + @%write ttext.lk1 FIL ttext.obj + @%append ttext.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\ttext $(LINK_OPTS) @ttext.lk1 + +$(GRX_BIN_SUBDIR)\bgilink.exe : .\bgilink.obj $(GRXLIB) .AUTODEPEND + @%write bgilink.lk1 FIL bgilink.obj + @%append bgilink.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\bgilink $(LINK_OPTS) @bgilink.lk1 diff --git a/thirdparty/grx249/test/bgi/makefile.x11 b/thirdparty/grx249/test/bgi/makefile.x11 new file mode 100644 index 0000000..22866aa --- /dev/null +++ b/thirdparty/grx249/test/bgi/makefile.x11 @@ -0,0 +1,81 @@ +# +# GRX test programs makefile for LINUX/X11. Uses GNU make. +# +.PHONY : clean setsuid + +GRXVX11=y + +include ../../makedefs.grx + +INCDIR= -I../../include + +# Enable this line for static linked test progs (default) +GRX20X = ../../lib/$(GRX_LIB_SUBDIR)/libgrx20X.a +# or this if you've already installed the shared libs +#GRX20X = -L./../lib/$(GRX_LIB_SUBDIR) -lgrx20X + +ifeq ($(SET_XSUIDROOT),y) +EXECBITS = 4755 +else +EXECBITS = 0755 +endif + +ADDON_LIBS= + +ifeq ($(USE_XF86DGA_DRIVER),y) + ADDON_LIBS += -lXxf86dga -lXext +endif + +#ifeq ($(HAVE_LIBTIFF),y) +# ADDON_LIBS += -ltiff +#endif +# +#ifeq ($(HAVE_LIBJPEG),y) +# ADDON_LIBS += -ljpeg +#endif +# +#ifeq ($(NEED_ZLIB),y) +# ADDON_LIBS += -lz +#endif + +LIBS= $(GRX20X) $(ADDON_LIBS) $(X11LIBS) -lm + +PROGS= \ + xbgilink \ + xbccbgi \ + xcolortst \ + xfontplay \ + xsmall \ + xtellipse \ + xtfill \ + xtmodes \ + xtpoly \ + xttext + +all: $(PROGS) + +$(PROGS): x%: %.o $(GRX20X) + $(CC) $(LDOPT) -o $@ $*.o $(LIBS) + chmod $(EXECBITS) $@ + +$(PROGS:x%=%.o): %.o : %.c + $(CC) -c $(CCOPT) -D__XWIN__ $(INCDIR) $*.c -o $*.o + +setsuid: $(PROGS) +ifeq ($(SET_XSUIDROOT),y) + chown root $(PROGS) + chmod $(EXECBITS) $(PROGS) +else + @echo "Nothing to do, SET_XSUIDROOT is not set to 'y' in makedefs.grx" +endif + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c + +clean: + rm -f *.o $(PROGS) + +depend.new: + $(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:x%=%.c) > depend.new + +#include depend.gnu diff --git a/thirdparty/grx249/test/bgi/small.c b/thirdparty/grx249/test/bgi/small.c new file mode 100644 index 0000000..e721f48 --- /dev/null +++ b/thirdparty/grx249/test/bgi/small.c @@ -0,0 +1,16 @@ +#include + +int main(void) +{ + int gd, gm, err; + + gd = DETECT; +#if defined(__MSDOS__) || defined(__WIN32__) + initgraph(&gd,&gm,"..\\..\\chr"); +#else + initgraph(&gd,&gm,"../../chr"); +#endif + err = graphresult(); + closegraph(); + return 0; +} diff --git a/thirdparty/grx249/test/bgi/stdfun.h b/thirdparty/grx249/test/bgi/stdfun.h new file mode 100644 index 0000000..927c887 --- /dev/null +++ b/thirdparty/grx249/test/bgi/stdfun.h @@ -0,0 +1,19 @@ +/* +** Delay +*/ + +#if defined(__MSDOS__) +# include /* for delay() */ +#else + extern void GrSleep(int msec); +# define delay(ms) GrSleep(ms) +#endif + +/* +** Versions of getch, getkey and kbhit are defined in +** the libgrx for Linux X11 and Win32 +*/ + +extern int getch(void); +extern int getkey(void); +extern int kbhit(void); diff --git a/thirdparty/grx249/test/bgi/tellipse.c b/thirdparty/grx249/test/bgi/tellipse.c new file mode 100644 index 0000000..06b9ec8 --- /dev/null +++ b/thirdparty/grx249/test/bgi/tellipse.c @@ -0,0 +1,41 @@ +#include +#include +#include + +#include +#include "stdfun.h" + +int main(void) +{ + int gd, gm; + int err; + int x, y, xr, i; + + gd = DETECT; +#if defined(__MSDOS__) || defined(__WIN32__) + initgraph(&gd,&gm,"..\\..\\chr"); +#else + initgraph(&gd,&gm,"../../chr"); +#endif + err = graphresult(); + if (err != grOk) { + fprintf(stderr, "Couldn't initialize graphics\n"); + exit(1); + } + x = getmaxx()/2; + y = getmaxy()/2; + for (i=-10; i <= 10; i+=2) { + cleardevice(); + for (xr=1; xr <= x && xr < y ; xr += x/16) + ellipse(x,y,0,360+i,xr,xr*y/x); + getch(); + } + for (i=1; i <= 10; i++) { + cleardevice(); + for (xr=1; xr <= x && xr < y ; xr += x/16) + ellipse(x,y,0,360*i,xr,xr*y/x); + getch(); + } + closegraph(); + return 0; +} diff --git a/thirdparty/grx249/test/bgi/tfill.c b/thirdparty/grx249/test/bgi/tfill.c new file mode 100644 index 0000000..9774edd --- /dev/null +++ b/thirdparty/grx249/test/bgi/tfill.c @@ -0,0 +1,33 @@ +#include +#include + +#include +#include "stdfun.h" + +int main(void) +{ + int gd, gm; + int err; + + gd = DETECT; +#if defined(__MSDOS__) || defined(__WIN32__) + initgraph(&gd,&gm,"..\\..\\chr"); +#else + initgraph(&gd,&gm,"../../chr"); +#endif + err = graphresult(); + if (err != grOk) { + fprintf(stderr, "Couldn't initialize graphics\n"); + exit(1); + } + setviewport( 100, 100, 200, 200, 1); + floodfill( 10, 10, WHITE); + getch(); + setfillstyle( SOLID_FILL, DARKGRAY); + cleardevice(); + setviewport( 100, 100, 200, 200, 0); + floodfill( 10, 10, WHITE); + getch(); + closegraph(); + return 0; +} diff --git a/thirdparty/grx249/test/bgi/tmodes.c b/thirdparty/grx249/test/bgi/tmodes.c new file mode 100644 index 0000000..826f648 --- /dev/null +++ b/thirdparty/grx249/test/bgi/tmodes.c @@ -0,0 +1,102 @@ +#include +#include + +void test(char *dn, char *mn, int gd, int gm) +{ + int ogd = gd; + int ogm = gm; + + __gr_Result = grOk; + set_BGI_mode(&gd, &gm); + printf("%-12s %-12s : ", dn, mn); + if (__gr_Result == grOk) { + printf("%4dx%4dx%3d", __gr_BGI_w, __gr_BGI_h, __gr_BGI_c); + if (gd != ogd || gm != ogm) + printf( " gd: %2d -> %2d, gm: %2d -> %2d", ogd, gd, ogm, gm); + } else + printf("No translation available !"); + printf("\n"); +} + +#define TEST(drv,mode) test(#drv,#mode,drv,mode) +#define ETEST(drv,drvn,mode) test(drvn,#mode,drv,mode) +#define extended(drv) ETEST(drv,#drv,RES640x350); \ + ETEST(drv,#drv,RES640x480); \ + ETEST(drv,#drv,RES800x600); \ + ETEST(drv,#drv,RES1024x768); \ + ETEST(drv,#drv,RES1280x1024) + +int main(void) +{ + int i; + + printf( "Available modes :\n"); + for (i = 0; i <= getmaxmode(); ++i) + printf( "\tgraphics mode %2d : %s\n" , i, getmodename(i)); + printf("\n"); + + TEST(VGA , VGALO ); + TEST(VGA , VGAMED ); + TEST(VGA , VGAHI ); + TEST(IBM8514 , IBM8514LO ); + TEST(IBM8514 , IBM8514HI ); + TEST(HERCMONO, HERCMONOHI); + TEST(CGA , CGAC0 ); + TEST(CGA , CGAC1 ); + TEST(CGA , CGAC2 ); + TEST(CGA , CGAC3 ); + TEST(CGA , CGAHI ); + TEST(MCGA , MCGAC0 ); + TEST(MCGA , MCGAC1 ); + TEST(MCGA , MCGAC2 ); + TEST(MCGA , MCGAC3 ); + TEST(MCGA , MCGAMED ); + TEST(MCGA , MCGAHI ); + TEST(ATT400 , ATT400C0 ); + TEST(ATT400 , ATT400C1 ); + TEST(ATT400 , ATT400C2 ); + TEST(ATT400 , ATT400C3 ); + TEST(ATT400 , ATT400MED ); + TEST(ATT400 , ATT400HI ); + TEST(EGA64 , EGA64LO ); + TEST(EGA64 , EGA64HI ); + TEST(EGA , EGALO ); + TEST(EGA , EGAHI ); + TEST(EGAMONO , EGAMONOHI ); + TEST(PC3270 , PC3270HI ); + /* Extended modes from BC++ 4.5 */ + extended(VGA256); + extended(ATTDEB); + extended(TOSHIBA); + extended(SVGA16); + extended(SVGA256); + extended(SVGA32K); + extended(SVGA64K); + extended(VESA16); + extended(VESA256); + extended(VESA32K); + extended(VESA64K); + extended(VESA16M); + extended(ATI16); + extended(ATI256); + extended(ATI32K); + extended(COMPAQ); + extended(TSENG316); + extended(TSENG3256); + extended(TSENG416); + extended(TSENG4256); + extended(TSENG432K); + extended(GENOA5); + extended(GENOA6); + extended(OAK); + extended(PARADIS16); + extended(PARADIS256); + extended(TECMAR); + extended(TRIDENT16); + extended(TRIDENT256); + extended(VIDEO7); + extended(VIDEO7II); + extended(S3); + extended(ATIGUP); + return 0; +} diff --git a/thirdparty/grx249/test/bgi/tpoly.c b/thirdparty/grx249/test/bgi/tpoly.c new file mode 100644 index 0000000..10c1648 --- /dev/null +++ b/thirdparty/grx249/test/bgi/tpoly.c @@ -0,0 +1,49 @@ +#include +#include + +#include +#include "stdfun.h" + +int main(void) +{ + int gd, gm; + int err; + int poly[50]; + + gd = DETECT; +#if defined(__MSDOS__) || defined(__WIN32__) + initgraph(&gd,&gm,"..\\..\\chr"); +#else + initgraph(&gd,&gm,"../../chr"); +#endif + err = graphresult(); + if (err != grOk) { + fprintf(stderr, "Couldn't initialize graphics\n"); + exit(1); + } + setfillstyle( SOLID_FILL, GREEN); + poly[ 0] = 10; poly[ 1] = 10; + poly[ 2] = 20; poly[ 3] = 20; + poly[ 4] = 20; poly[ 5] = getmaxy()-20; + poly[ 6] = getmaxx()-20; poly[ 7] = getmaxy()-20; + poly[ 8] = getmaxx()-20; poly[ 9] = 20; + poly[10] = 20; poly[11] = 20; + poly[12] = 75; poly[13] = 35; + poly[14] = 75; poly[15] = getmaxy()-50; + poly[16] = getmaxx()-60; poly[17] = getmaxy()-50; + poly[18] = getmaxx()-60; poly[19] = 35; + poly[20] = 75; poly[21] = 35; + drawpoly( 11, poly); + getch(); + cleardevice(); + fillpoly( 11, poly); + getch(); + cleardevice(); + drawpoly( 10, &poly[2]); + getch(); + cleardevice(); + fillpoly( 10, &poly[2]); + getch(); + closegraph(); + return 0; +} diff --git a/thirdparty/grx249/test/bgi/ttext.c b/thirdparty/grx249/test/bgi/ttext.c new file mode 100644 index 0000000..3c10736 --- /dev/null +++ b/thirdparty/grx249/test/bgi/ttext.c @@ -0,0 +1,148 @@ +#include +#include + +#include +#include "stdfun.h" + +void play_font(char *name, char *file, int *x, int *y) +{ + int font; + + if (*file != '\0') + font = installuserfont(file); + else { + font = DEFAULT_FONT; + file = "DEFAULT_FONT"; + } + if (font >= 0) { + settextstyle(font, HORIZ_DIR, 1); + outtextxy( *x, *y, file); + outtextxy( *x+textwidth(file), *y, ": "); + outtextxy( *x+textwidth(file)+textwidth(": "), *y, name); + } else { + settextstyle(DEFAULT_FONT, HORIZ_DIR, 1); + outtextxy( *x, *y, "Couldn't install "); + outtextxy( *x+textwidth("Couldn't install "), *y, file); + } + *y += textheight( "M"); +} + +int Max(int a, int b) { + if (a>b) return a; + return b; +} + +void user_test(char *txt, int mx, int dx, int my, int dy) { + graphresult(); + setusercharsize(mx, dx, my, dy); +/* if (graphresult() == grOk) */{ + moveto(0, gety()+Max(textheight(txt), 8)+8); + outtext( txt); + } +} + +void user_info(int fnt, int sze) { + char info[20]; + int w = textwidth("H"); + int h = textheight("H"); +int x = getx(); int y = gety(); + settextstyle(DEFAULT_FONT, HORIZ_DIR, 1); + sprintf(info, " H:%dx%d", w, h); + outtextxy(x,y, info); + settextstyle(fnt, HORIZ_DIR, sze); +} + +void all_user_tests(int fnt, int sze) { + graphresult(); + settextstyle(fnt, HORIZ_DIR, sze); + settextjustify(LEFT_TEXT, BOTTOM_TEXT); + if (graphresult() != grOk) + return; + user_test("Norm", 1, 1, 1, 1); + user_info(fnt, sze); + user_test("Short", 1, 2, 1, 1); + user_info(fnt, sze); + user_test("Wide", 2, 1, 1, 1); + user_info(fnt, sze); + user_test("no width", 0, 1, 1, 1); + user_info(fnt, sze); + user_test("no height", 1, 1, 0, 1); + user_info(fnt, sze); + user_test("neg x", -1, 1, 1, 1); + user_info(fnt, sze); + user_test("neg y", 1, 1,-1, 1); + user_info(fnt, sze); +} + +int main(void) +{ + int gd, gm, x, y; + int err; + char ch[2]; + + gd = DETECT; +#if defined(__MSDOS__) || defined(__WIN32__) + initgraph(&gd,&gm,"..\\..\\chr"); +#else + initgraph(&gd,&gm,"../../chr"); +#endif + err = graphresult(); + if (err != grOk) { + fprintf(stderr, "Couldn't initialize graphics\n"); + exit(1); + } + setviewport( 50, 100, 150, 200, 1); + rectangle( 0, 0, 100, 100); + outtextxy( -20, 20, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + outtextxy( -15, 40, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + outtextxy( -10, 60, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + outtextxy( -05, 80, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + setviewport( getmaxx()-150, 100, getmaxx()-50, 200, 1); + settextstyle(DEFAULT_FONT, VERT_DIR, 1); + rectangle( 0, 0, 100, 100); + outtextxy( 5, -5, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + outtextxy( 15, 5, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + outtextxy( 95, -5, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + outtextxy(105, 5, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + x = 50; y = 105; + ch[0] = 'A'; ch[1] = '\0'; + while (y > 0) { + outtextxy(x,y,ch); + y -= textwidth(ch); + ++ch[0]; + } + settextstyle(DEFAULT_FONT, HORIZ_DIR, 1); + setviewport( 0, 0, getmaxx(), getmaxy(), 1); +#ifdef __TURBOC__ + outtextxy( 10, 10, "Turbo-C cuts text"); +#else + outtextxy( 10, 10, "BCC2GRX clips text"); +#endif +#ifdef __GNUC__ + setviewport( 100, 250, getmaxx()-100, getmaxy(), 1); + rectangle( 0, 0, getmaxx()-200, getmaxy()-250); + x = 5; y = 5; + play_font( "8x8 bit mapped characters", "", &x, &y); + play_font( "8x14 bit mapped characters", "pc8x14.fnt", &x, &y); + play_font( "8x14 bit mapped characters thin", "pc8x14t.fnt", &x, &y); + play_font( "8x16 bit mapped characters", "pc8x16.fnt", &x, &y); + play_font( "courier 16 pixel high", "cour16.fnt", &x, &y); + play_font( "helvetica 17 pixel high italic", "helv17i.fnt", &x, &y); + play_font( "helvetica 29 pixel bold italic", "helv29bi.fnt", &x, &y); + setviewport( 0, 0, getmaxx(), getmaxy(), 1); +#endif + getch(); + cleardevice(); + +#if 0 && defined(__GNUC__) + registerbgifont(&_sans_font); +#endif + + moveto(0, 0); + all_user_tests(SANS_SERIF_FONT, 4); + all_user_tests(DEFAULT_FONT, 1); + + getch(); + closegraph(); + return 0; +} diff --git a/thirdparty/grx249/test/blittest.c b/thirdparty/grx249/test/blittest.c new file mode 100644 index 0000000..b476b93 --- /dev/null +++ b/thirdparty/grx249/test/blittest.c @@ -0,0 +1,293 @@ +/** + ** blittest.c ---- test various bitblt-s + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include + +#include "test.h" + +#define BHH (GrScreenY() / 10) +int BWW = 83; + +void drbox(GrContext *src,int x,int y) +{ + GrColor c1 = GrAllocColor(0,0,255); + GrColor c2 = GrAllocColor(255,0,0); + int xx; + + GrClearScreen(c1); + GrSetContext(src); + GrSetClipBox(x-10,y-10,x+BWW-1+10,y+BHH-1+10); + GrClearClipBox(c2); + GrSetClipBox(x,y,x+BWW-1,y+BHH-1); + GrClearClipBox(GrBlack()); + GrBox(x,y,x+BWW-1,y+BHH-1,GrWhite()); + for(xx = x; xx < x+BWW; xx += 5) { + GrLine(xx,y,xx+BHH,y+BHH,GrWhite()); + GrLine(xx,y,xx-BHH,y+BHH,GrWhite()); + } + GrSetContext(NULL); + GrResetClipBox(); +} + +void doblits(GrContext *src,int x,int y) +{ + int xx = (GrSizeX() - BWW)/ 2; + int yy = 2; + int ii; + + for(ii = 0; ii < 8; ii++) { + GrBitBlt(NULL,xx,yy,src,x,y,x+BWW-1,y+BHH-1,GrWRITE); + xx++; + yy += (BHH + 2); + } +/* + { + GrColor xc = GrAllocColor(255,255,255) | GrXOR; + GrKeyRead(); + xx = (GrSizeX() - BWW)/ 2; + yy = 2; + for(ii = 0; ii < 8; ii++) { + GrFilledBox(xx,yy,xx+BWW-1,yy+BHH-1,xc); + xx++; + yy += (BHH + 2); + } + } +*/ +} + +void bltest(GrContext *src,int x,int y) +{ + int ii; + + for(ii = 0; ii < 8; ii++) { + drbox(src,x,y); + doblits(src,x,y); + GrKeyRead(); + x++; + } +} + +void blxtest(void) +{ + GrContext memc; + int cw = (BWW + 28) & ~7; + int ch = BHH + 20; + + bltest(NULL,GrScreenX()-BWW-8,GrScreenY()-BHH); + bltest(NULL,0,0); + GrCreateContext(cw,ch,NULL,&memc); + bltest(&memc,cw-BWW-8,ch-BHH); +} + +TESTFUNC(blittest) +{ + GrFBoxColors bcolors,ocolors,icolors; + GrColor c,bg; + int x = GrSizeX(); + int y = GrSizeY(); + int ww = (x * 2) / 3; + int wh = (y * 2) / 3; + int ii,jj; + int wdt = ww / 150; + int bw = x / 17; + int bh = y / 17; + int bx,by; + int cnt; + + GrContext *save = GrCreateSubContext(0,0,GrMaxX(),GrMaxY(),NULL,NULL); + GrContext *tile = GrCreateContext(bw,bh,NULL,NULL); + + blxtest(); + GrKeyRead(); + + BWW = 3; + blxtest(); + GrKeyRead(); + + bcolors.fbx_intcolor = GrAllocColor(160,100,30); + bcolors.fbx_topcolor = GrAllocColor(240,150,45); + bcolors.fbx_leftcolor = GrAllocColor(240,150,45); + bcolors.fbx_rightcolor = GrAllocColor(80,50,15); + bcolors.fbx_bottomcolor = GrAllocColor(80,50,15); + + ocolors.fbx_intcolor = GrAllocColor(0,120,100); + ocolors.fbx_topcolor = GrAllocColor(0,180,150); + ocolors.fbx_leftcolor = GrAllocColor(0,180,150); + ocolors.fbx_rightcolor = GrAllocColor(0,90,60); + ocolors.fbx_bottomcolor = GrAllocColor(0,90,60); + + icolors.fbx_intcolor = bg = GrAllocColor(30,30,30); + icolors.fbx_bottomcolor = GrAllocColor(0,180,150); + icolors.fbx_rightcolor = GrAllocColor(0,180,150); + icolors.fbx_leftcolor = GrAllocColor(0,90,60); + icolors.fbx_topcolor = GrAllocColor(0,90,60); + + c = GrAllocColor(250,250,0); + + for(ii = 0,by = -(bh/3); ii < 19; ii++) { + for(jj = 0,bx = -(bw/2); jj < 19; jj++) { + GrFramedBox(bx+2*wdt,by+2*wdt,bx+bw-2*wdt-1,by+bh-2*wdt-1,2*wdt,&bcolors); + bx += bw; + } + by += bh; + } + + GrFramedBox(ww/4-5*wdt-1,wh/4-5*wdt-1,ww/4+5*wdt+ww+1,wh/4+5*wdt+wh+1,wdt,&ocolors); + GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors); + + GrSetClipBox(ww/4,wh/4,ww/4+ww,wh/4+wh); + drawing(ww/4,wh/4,ww,wh,c,bg); + GrKeyRead(); + + GrClearScreen(0); + GrSetContext(save); + + bx = -(bw/2) + 15*bw; + by = -(bh/3) + 15*bh; + + GrFramedBox(bx+2*wdt,by+2*wdt,bx+bw-2*wdt-1,by+bh-2*wdt-1,2*wdt,&bcolors); + + for (cnt=0; cnt<3; cnt++) { + for(ii = 0,by = -(bh/3); ii < 19; ii++) { + for(jj = 0,bx = -(bw/2); jj < 19; jj++) { + if((ii != 15) || (jj != 15)) { + GrBitBlt(save, + bx,by, + save, + -(bw/2) + 15*bw, + -(bh/3) + 15*bh, + -(bw/2) + 15*bw + bw - 1, + -(bh/3) + 15*bh + bh - 1, + cnt==1 ? GrXOR : GrWRITE + ); + } + bx += bw; + } + by += bh; + } + } + + GrFramedBox(ww/4-5*wdt-1,wh/4-5*wdt-1,ww/4+5*wdt+ww+1,wh/4+5*wdt+wh+1,wdt,&ocolors); + GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors); + + GrSetClipBox(ww/4,wh/4,ww/4+ww,wh/4+wh); + drawing(ww/4,wh/4,ww,wh,c,bg); + GrKeyRead(); + + + GrBitBlt(tile, + 0,0, + save, + -(bw/2) + 15*bw, + -(bh/3) + 15*bh, + -(bw/2) + 15*bw + bw - 1, + -(bh/3) + 15*bh + bh - 1, + GrWRITE + ); + GrSetContext(tile); + GrFramedBox(2*wdt,2*wdt,bw-2*wdt-1,bh-2*wdt-1,2*wdt,&bcolors); + + GrClearScreen(0); + GrSetContext(save); + + for(ii = 0,by = -(bh/3); ii < 19; ii++) { + for(jj = 0,bx = -(bw/2); jj < 19; jj++) { + GrBitBlt(save, + bx,by, + tile, + 0,0, + bw-1,bh-1, + GrWRITE + ); + bx += bw; + } + by += bh; + } + + GrFramedBox(ww/4-5*wdt-1,wh/4-5*wdt-1,ww/4+5*wdt+ww+1,wh/4+5*wdt+wh+1,wdt,&ocolors); + GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors); + + GrSetClipBox(ww/4,wh/4,ww/4+ww,wh/4+wh); + drawing(ww/4,wh/4,ww,wh,c,bg); + + GrKeyRead(); + GrResetClipBox(); + GrBitBlt(NULL, + 60,60, + NULL, + 20,20, + GrSizeX() - 40, + GrSizeY() - 40, + GrWRITE + ); + + GrKeyRead(); + + GrBitBlt(NULL, + 10,10, + NULL, + 60,60, + GrSizeX() - 40, + GrSizeY() - 40, + GrWRITE + ); + + GrKeyRead(); + + GrSetContext(tile); + GrClearContext(0); + + GrBitBlt(tile, + 0,0, + save, + -(bw/2), + -(bh/3), + -(bw/2) + 15*bw + bw - 1, + -(bh/3) + 15*bh + bh - 1, + GrWRITE + ); + + GrSetContext(save); + GrClearScreen(0); + + for(ii = 0,by = -(bh/3); ii < 18; ii++) { + for(jj = 0,bx = -(bw/2); jj < 18; jj++) { + GrBitBlt(save, + bx,by, + tile, + 0,0, + bw-1,bh-1, + GrWRITE + ); + bx += bw; + } + by += bh; + } + + GrFramedBox(ww/4-5*wdt-1,wh/4-5*wdt-1,ww/4+5*wdt+ww+1,wh/4+5*wdt+wh+1,wdt,&ocolors); + GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors); + + GrSetClipBox(ww/4,wh/4,ww/4+ww,wh/4+wh); + drawing(ww/4,wh/4,ww,wh,c,bg); + + GrKeyRead(); + +} + diff --git a/thirdparty/grx249/test/circtest.c b/thirdparty/grx249/test/circtest.c new file mode 100644 index 0000000..9430664 --- /dev/null +++ b/thirdparty/grx249/test/circtest.c @@ -0,0 +1,93 @@ +/** + ** circtest.c ---- test circle and ellipse rendering + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" +#include + +void drawellip(int xc,int yc,int xa,int ya,GrColor c1,GrColor c2,GrColor c3) +{ + double ddx = (double)xa; + double ddy = (double)ya; + double R2 = ddx*ddx*ddy*ddy; + double SQ; + int x1,x2,y1,y2; + int dx,dy; + + GrFilledBox(xc-xa,yc-ya,xc+xa,yc+ya,c1); + dx = xa; + dy = 0; + GrPlot(xc-dx,yc,c3); + GrPlot(xc+dx,yc,c3); + while(++dy <= ya) { + SQ = R2 - (double)dy * (double)dy * ddx * ddx; + dx = (int)(sqrt(SQ)/ddy + 0.5); + x1 = xc - dx; + x2 = xc + dx; + y1 = yc - dy; + y2 = yc + dy; + GrPlot(x1,y1,c3); + GrPlot(x2,y1,c3); + GrPlot(x1,y2,c3); + GrPlot(x2,y2,c3); + } + GrEllipse(xc,yc,xa,ya,c2); +} + +TESTFUNC(circtest) +{ + int xc,yc; + int xr,yr; + GrColor c1,c2,c3; + + c1 = GrAllocColor(64,64,255); + c2 = GrAllocColor(255,255,64); + c3 = GrAllocColor(255,64,64); + xc = GrSizeX() / 2; + yc = GrSizeY() / 2; + xr = 1; + yr = 1; + while((xr < 1000) || (yr < 1000)) { + drawellip(xc,yc,xr,yr,c1,c2,c3); + xr += xr/4+1; + yr += yr/4+1; + GrSleep(200); + } + c1 = GrAllocColor(64,64,128); + xr = 4; + yr = 1; + while((xr < 1000) || (yr < 1000)) { + drawellip(xc,yc,xr,yr,c1,c2,c3); + yr += yr/4+1; + xr = yr * 4; + GrSleep(200); + } + c1 = GrAllocColor(64,64,64); + xr = 1; + yr = 4; + while((xr < 1000) || (yr < 1000)) { + drawellip(xc,yc,xr,yr,c1,c2,c3); + xr += xr/4+1; + yr = xr * 4; + GrSleep(200); + } + + GrTextXY(0,0,"press any key to continue",GrWhite(),GrBlack()); + GrKeyRead(); +} + diff --git a/thirdparty/grx249/test/cliptest.c b/thirdparty/grx249/test/cliptest.c new file mode 100644 index 0000000..d305582 --- /dev/null +++ b/thirdparty/grx249/test/cliptest.c @@ -0,0 +1,52 @@ +/** + ** cliptest.c ---- test clipping + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" +#include "rand.h" + +TESTFUNC(cliptest) +{ + long delay; + int x = GrSizeX(); + int y = GrSizeY(); + int ww = (x * 2) / 3; + int wh = (y * 2) / 3; + GrColor c; + + c = GrAllocColor(200,100,100); + GrBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,GrWhite()); + GrSetClipBox(ww/4,wh/4,ww/4+ww,wh/4+wh); + + drawing(0,0,ww,wh,c,GrBlack()); + GrKeyRead(); + + while(!GrKeyPressed()) { + GrFilledBox(0,0,x,y,GrBlack()); + drawing(-(RND()%(2*ww))+ww/2, + -(RND()%(2*wh))+wh/2, + RND()%(3*ww)+10, + RND()%(3*wh)+10, + c, + GrNOCOLOR + ); + for(delay = 200000L; delay > 0L; delay--); + } + GrKeyRead(); +} + diff --git a/thirdparty/grx249/test/colorops.c b/thirdparty/grx249/test/colorops.c new file mode 100644 index 0000000..a4a032e --- /dev/null +++ b/thirdparty/grx249/test/colorops.c @@ -0,0 +1,124 @@ +/** + ** colorops.c ---- test WRITE, XOR, OR, and AND draw modes + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" +#include "rand.h" + +TESTFUNC(colorops) +{ + GrFBoxColors bcolors,ocolors,icolors; + GrColor bg,c; + int x = GrSizeX(); + int y = GrSizeY(); + int ww = (x * 2) / 3; + int wh = (y * 2) / 3; + int ii,jj; + int wdt = ww / 150; + int bw = x / 16; + int bh = y / 16; + int bx,by; + + /* This won't work very well under X11 in pseudocolor + ** mode (256 colors or less) if not using a private + ** color map. The missing colors break RGB mode */ + GrSetRGBcolorMode(); + + bcolors.fbx_intcolor = GrAllocColor(160,100,30); + bcolors.fbx_topcolor = GrAllocColor(240,150,45); + bcolors.fbx_leftcolor = GrAllocColor(240,150,45); + bcolors.fbx_rightcolor = GrAllocColor(80,50,15); + bcolors.fbx_bottomcolor = GrAllocColor(80,50,15); + + ocolors.fbx_intcolor = GrAllocColor(0,120,100); + ocolors.fbx_topcolor = GrAllocColor(0,180,150); + ocolors.fbx_leftcolor = GrAllocColor(0,180,150); + ocolors.fbx_rightcolor = GrAllocColor(0,90,60); + ocolors.fbx_bottomcolor = GrAllocColor(0,90,60); + + icolors.fbx_intcolor = GrAllocColor(30,30,30); + icolors.fbx_bottomcolor = GrAllocColor(0,180,150); + icolors.fbx_rightcolor = GrAllocColor(0,180,150); + icolors.fbx_leftcolor = GrAllocColor(0,90,60); + icolors.fbx_topcolor = GrAllocColor(0,90,60); + + c = GrAllocColor(250,250,0); + bg = GrNOCOLOR; + + for(ii = 0,by = -(bh / 3); ii < 17; ii++) { + for(jj = 0,bx = (-bw / 2); jj < 17; jj++) { + GrFramedBox(bx+2*wdt,by+2*wdt,bx+bw-2*wdt-1,by+bh-2*wdt-1,2*wdt,&bcolors); + bx += bw; + } + by += bh; + } + + GrFramedBox(ww/4-5*wdt-1,wh/4-5*wdt-1,ww/4+5*wdt+ww+1,wh/4+5*wdt+wh+1,wdt,&ocolors); + GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors); + + GrSetClipBox(ww/4,wh/4,ww/4+ww,wh/4+wh); + + drawing(ww/4,wh/4,ww,wh,c,bg); + while(!GrKeyPressed()) { + drawing(ww/4+(RND()%100), + wh/4+(RND()%100), + ww, + wh, + ((RND() / 16) & (GrNumColors() - 1)), + bg + ); + } + GrKeyRead(); + GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors); + drawing(ww/4,wh/4,ww,wh,c,bg); + while(!GrKeyPressed()) { + drawing(ww/4+(RND()%100), + wh/4+(RND()%100), + ww, + wh, + ((RND() / 16) & (GrNumColors() - 1)) | GrXOR, + bg + ); + } + GrKeyRead(); + GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors); + drawing(ww/4,wh/4,ww,wh,c,bg); + while(!GrKeyPressed()) { + drawing(ww/4+(RND()%100), + wh/4+(RND()%100), + ww, + wh, + ((RND() / 16) & (GrNumColors() - 1)) | GrOR, + bg + ); + } + GrKeyRead(); + GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors); + drawing(ww/4,wh/4,ww,wh,c,bg); + while(!GrKeyPressed()) { + drawing(ww/4+(RND()%100), + wh/4+(RND()%100), + ww, + wh, + ((RND() / 16) & (GrNumColors() - 1)) | GrAND, + bg + ); + } + GrKeyRead(); +} + diff --git a/thirdparty/grx249/test/curstest.c b/thirdparty/grx249/test/curstest.c new file mode 100644 index 0000000..8463d91 --- /dev/null +++ b/thirdparty/grx249/test/curstest.c @@ -0,0 +1,106 @@ +/** + ** curstest.c ---- test cursors + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" + +char p16d[] = { + 0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0, + 1,2,1,0,0,0,0,0,0,0,0,1,2,2,1,0, + 1,2,2,1,0,0,0,0,0,0,1,2,0,0,2,1, + 1,2,2,2,1,0,0,0,0,0,1,2,0,0,2,1, + 1,2,2,2,2,1,0,0,0,0,0,1,2,2,1,0, + 1,2,2,2,2,2,1,0,0,0,0,0,1,1,0,0, + 1,2,2,2,2,2,2,1,0,0,0,0,0,0,0,0, + 1,2,2,2,2,2,2,2,1,0,0,0,0,0,0,0, + 1,2,2,2,2,2,2,2,2,1,0,0,0,0,0,0, + 1,2,2,2,2,2,2,2,2,2,1,0,0,0,0,0, + 1,2,2,2,2,2,2,2,2,2,2,1,0,0,0,0, + 1,2,2,2,2,1,1,1,1,1,1,0,0,0,0,0, + 1,2,2,2,1,0,0,0,0,0,0,0,0,0,0,0, + 1,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0, + 1,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +TESTFUNC(cursortest) +{ + GrColor bgc = GrAllocColor(0,0,128); + GrColor fgc = GrAllocColor(255,255,0); + GrColor msc[3]; + GrCursor *cur; + int x,y; + + msc[0] = 2; + msc[1] = GrWhite(); + msc[2] = GrAllocColor(255,0,0); + cur = GrBuildCursor(p16d,16,16,16,1,1,msc); + x = GrScreenX() / 2; + y = GrScreenY() / 2; + GrMoveCursor(cur,x,y); + GrClearScreen(bgc); + GrSetColor((GrNumColors() - 1),255,255,255); + drawing(0,0,GrSizeX(),GrSizeY(),fgc,GrNOCOLOR); + GrFilledBox(0,0,320,120,GrAllocColor(0,255,255)); + GrTextXY( 10,90,"ANDmask",GrBlack(),GrNOCOLOR); + GrTextXY( 90,90,"ORmask", GrBlack(),GrNOCOLOR); + GrTextXY(170,90,"Save", GrBlack(),GrNOCOLOR); + GrTextXY(250,90,"Work", GrBlack(),GrNOCOLOR); + GrDisplayCursor(cur); + for( ; ; ) { + GrBitBlt( + NULL,10,10, + &cur->work,cur->xwork/2,0,cur->xwork/2+cur->xsize-1,cur->ysize-1, + GrWRITE + ); + GrBitBlt( + NULL,90,10, + &cur->work,0,0,cur->xsize-1,cur->ysize-1, + GrWRITE + ); + GrBitBlt( + NULL,170,10, + &cur->work,0,cur->ysize,cur->xwork-1,cur->ysize+cur->ywork-1, + GrWRITE + ); + GrBitBlt( + NULL,250,10, + &cur->work,0,cur->ysize+cur->ywork,cur->xwork-1,cur->ysize+2*cur->ywork-1, + GrWRITE + ); + GrTextXY(0,GrMaxY()-20,"Type u d l r U D L R or q to quit",GrWhite(),GrNOCOLOR); + switch(GrKeyRead()) { + case 'u': y--; break; + case 'd': y++; break; + case 'l': x--; break; + case 'r': x++; break; + case 'U': y -= 10; break; + case 'D': y += 10; break; + case 'L': x -= 10; break; + case 'R': x += 10; break; + case 'q': return; + default: continue; + } + if(x < 0) x = 0; + if(x > GrScreenX()) x = GrScreenX(); + if(y < 100) y = 100; + if(y > GrScreenY()) y = GrScreenY(); + GrMoveCursor(cur,x,y); + } +} + diff --git a/thirdparty/grx249/test/demogrx.c b/thirdparty/grx249/test/demogrx.c new file mode 100644 index 0000000..3228170 --- /dev/null +++ b/thirdparty/grx249/test/demogrx.c @@ -0,0 +1,524 @@ +/** + ** demogrx.c ---- GRX Test programs launcher + ** + ** Copyright (C) 2000,2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include +#include "grx20.h" +#include "grxkeys.h" +#include "gfaz.h" +#include "drawing.h" + +/* default mode */ + +static int gwidth = 640; +static int gheight = 480; +static int gbpp = 16; + +char *wintitle = + "GRX 2.4.9, the graphics library"; + +char *animatedtext = + "GRX 2.4.9, the graphics library for DJGPPv2, Linux, X11 and Win32"; + +#define NDEMOS 33 + +#define ID_ARCTEST 1 +#define ID_BB1TEST 2 +#define ID_BLITTEST 3 +#define ID_CIRCTEST 4 +#define ID_CLIPTEST 5 +#define ID_COLOROPS 6 +#define ID_CURSTEST 7 +#define ID_FONTTEST 8 +#define ID_IMGTEST 9 +#define ID_JPGTEST 10 +#define ID_KEYS 11 +#define ID_LIFE 12 +#define ID_LINETEST 13 +#define ID_MOUSETST 14 +#define ID_PCIRCTST 15 +#define ID_PNMTEST 16 +#define ID_PNGTEST 17 +#define ID_POLYTEST 18 +#define ID_RGBTEST 19 +#define ID_SCROLTST 20 +#define ID_SBCTEST 21 +#define ID_SPEEDTST 22 +#define ID_TEXTPATT 23 +#define ID_WINCLIP 24 +#define ID_WINTEST 25 +#define ID_FNTDEMO1 26 +#define ID_FNTDEMO2 27 +#define ID_FNTDEMO3 28 +#define ID_FNTDEMO4 29 +#define ID_MODETEST 50 +#define ID_PAGE1 81 +#define ID_PAGE2 82 +#define ID_EXIT 99 + +typedef struct { + int cid; + char *prog; + char *text; +} ProgTable; + +static ProgTable ptable[NDEMOS] = { + {ID_ARCTEST, "arctest", "arctest.c -> test arc outline and filled arc drawing"}, + {ID_BB1TEST, "bb1test", "bb1test.c -> test GrBitBlt1bpp routine"}, + {ID_BLITTEST, "blittest", "blittest.c -> test various bitblt-s"}, + {ID_CIRCTEST, "circtest", "circtest.c -> test circle and ellipse rendering"}, + {ID_CLIPTEST, "cliptest", "cliptest.c -> test clipping"}, + {ID_COLOROPS, "colorops", "colorops.c -> test WRITE, XOR, OR, and AND draw modes"}, + {ID_CURSTEST, "curstest", "curstest.c -> test cursors"}, + {ID_FONTTEST, "fonttest", "fonttest.c -> test text drawing"}, + {ID_IMGTEST, "imgtest", "imgtest.c -> test image functions mapping"}, + {ID_JPGTEST, "jpgtest", "jpgtext.c -> text context to jpeg functions"}, + {ID_KEYS, "keys", "keys.c -> test keyboard input"}, + {ID_LIFE, "life", "life.c -> Conway's life program"}, + {ID_LINETEST, "linetest", "linetest.c -> test wide and patterned lines"}, + {ID_MOUSETST, "mousetst", "mousetst.c -> test mouse cursor and mouse/keyboard input"}, + {ID_PCIRCTST, "pcirctst", "pcirctst.c -> test custom circle and ellipse rendering"}, + {ID_PNMTEST, "pnmtest", "pnmtext.c -> text context to pnm functions"}, + {ID_PNGTEST, "pngtest", "pngtext.c -> text context to png functions"}, + {ID_POLYTEST, "polytest", "polytest.c -> test polygon rendering"}, + {ID_RGBTEST, "rgbtest", "rgbtest.c -> show 256 color RGB palette"}, + {ID_SBCTEST, "sbctest", "sbctest.c -> test subcontext operations"}, + {ID_SCROLTST, "scroltst", "scroltst.c -> test virtual screen set/scroll"}, + {ID_SPEEDTST, "speedtst", "speedtst.c -> check all available frame drivers speed"}, + {ID_TEXTPATT, "textpatt", "textpatt.c -> test patterned text"}, + {ID_WINCLIP, "winclip", "winclip.c -> clip a drawing to various windows (contexts)"}, + {ID_WINTEST, "wintest", "wintest.c -> test window (context) mapping"}, + {ID_FNTDEMO1, "fontdemo ncen22b.fnt", "fontdemo ncen22b.fnt -> test a GRX font"}, + {ID_FNTDEMO2, "fontdemo ter-114b.res", "fontdemo ter-114b.res -> test a RES font"}, + {ID_FNTDEMO3, "fontdemo ter-114n.fna", "fontdemo ter-114n.fna -> test a FNA font"}, + {ID_FNTDEMO4, "fontdemo ter-114v.psf", "fontdemo ter-114v.psf -> test a PSF font"}, + {ID_MODETEST, "modetest", "modetest.c -> test all available graphics modes"}, + {ID_PAGE1, "", "Change to page 1"}, + {ID_PAGE2, "", "Change to page 2"}, + {ID_EXIT, "", "Exit GRX test programs launcher"} +}; + +#define PX0 10 +#define PX1 115 +#define PX2 220 +#define PY0 10 +#define PY1 54 +#define PY2 98 +#define PY3 142 +#define PY4 186 +#define PY5 230 +#define PY6 274 +#define PY7 318 +#define PY8 362 + +#define NBUTTONSP1 26 + +static Button bp1[NBUTTONSP1] = { + {PX0, PY0, 100, 40, IND_BLUE, IND_YELLOW, "ArcTest", BSTATUS_SELECTED, ID_ARCTEST}, + {PX0, PY1, 100, 40, IND_BLUE, IND_YELLOW, "Bb1Test", 0, ID_BB1TEST}, + {PX0, PY2, 100, 40, IND_BLUE, IND_YELLOW, "BlitTest", 0, ID_BLITTEST}, + {PX0, PY3, 100, 40, IND_BLUE, IND_YELLOW, "CircTest", 0, ID_CIRCTEST}, + {PX0, PY4, 100, 40, IND_BLUE, IND_YELLOW, "ClipTest", 0, ID_CLIPTEST}, + {PX0, PY5, 100, 40, IND_BLUE, IND_YELLOW, "Colorops", 0, ID_COLOROPS}, + {PX0, PY6, 100, 40, IND_BLUE, IND_YELLOW, "CursTest", 0, ID_CURSTEST}, + {PX0, PY7, 100, 40, IND_BLUE, IND_YELLOW, "ImgTest", 0, ID_IMGTEST}, + {PX0, PY8, 100, 40, IND_BLUE, IND_YELLOW, "JpgTest", 0, ID_JPGTEST}, + {PX1, PY0, 100, 40, IND_BLUE, IND_YELLOW, "Keys", 0, ID_KEYS}, + {PX1, PY1, 100, 40, IND_BLUE, IND_YELLOW, "Life", 0, ID_LIFE}, + {PX1, PY2, 100, 40, IND_BLUE, IND_YELLOW, "LineTest", 0, ID_LINETEST}, + {PX1, PY3, 100, 40, IND_BLUE, IND_YELLOW, "MouseTst", 0, ID_MOUSETST}, + {PX1, PY4, 100, 40, IND_BLUE, IND_YELLOW, "PcircTst", 0, ID_PCIRCTST}, + {PX1, PY5, 100, 40, IND_BLUE, IND_YELLOW, "PnmTest", 0, ID_PNMTEST}, + {PX1, PY6, 100, 40, IND_BLUE, IND_YELLOW, "PngTest", 0, ID_PNGTEST}, + {PX1, PY7, 100, 40, IND_BLUE, IND_YELLOW, "PolyTest", 0, ID_POLYTEST}, + {PX1, PY8, 100, 40, IND_BLUE, IND_YELLOW, "RgbTest", 0, ID_RGBTEST}, + {PX2, PY0, 100, 40, IND_BLUE, IND_YELLOW, "SbcTest", 0, ID_SBCTEST}, + {PX2, PY1, 100, 40, IND_BLUE, IND_YELLOW, "ScrolTst", 0, ID_SCROLTST}, + {PX2, PY2, 100, 40, IND_BLUE, IND_YELLOW, "SpeedTst", 0, ID_SPEEDTST}, + {PX2, PY3, 100, 40, IND_BLUE, IND_YELLOW, "WinClip", 0, ID_WINCLIP}, + {PX2, PY4, 100, 40, IND_BLUE, IND_YELLOW, "WinTest", 0, ID_WINTEST}, + {PX2, PY6, 100, 40, IND_GREEN, IND_WHITE, "Page 2", 0, ID_PAGE2}, + {PX2, PY7, 100, 40, IND_BROWN, IND_WHITE, "ModeTest", 0, ID_MODETEST}, + {PX2, PY8, 100, 40, IND_RED, IND_WHITE, "Exit", 0, ID_EXIT} +}; + +#define NBUTTONSP2 9 + +static Button bp2[NBUTTONSP2] = { + {PX0, PY0, 100, 40, IND_BLUE, IND_YELLOW, "FontTest", BSTATUS_SELECTED, ID_FONTTEST}, + {PX0, PY1, 100, 40, IND_BLUE, IND_YELLOW, "TextPatt", 0, ID_TEXTPATT}, + {PX0, PY2, 100, 40, IND_BLUE, IND_YELLOW, "FontDemo1", 0, ID_FNTDEMO1}, + {PX0, PY3, 100, 40, IND_BLUE, IND_YELLOW, "FontDemo2", 0, ID_FNTDEMO2}, + {PX0, PY4, 100, 40, IND_BLUE, IND_YELLOW, "FontDemo3", 0, ID_FNTDEMO3}, + {PX0, PY5, 100, 40, IND_BLUE, IND_YELLOW, "FontDemo4", 0, ID_FNTDEMO4}, + {PX2, PY6, 100, 40, IND_GREEN, IND_WHITE, "Page 1", 0, ID_PAGE1}, + {PX2, PY7, 100, 40, IND_BROWN, IND_WHITE, "ModeTest", 0, ID_MODETEST}, + {PX2, PY8, 100, 40, IND_RED, IND_WHITE, "Exit", 0, ID_EXIT} +}; + +static Button_Group bgp1 = { 20, 30, bp1, NBUTTONSP1, 0, 0 }; +static Button_Group bgp2 = { 20, 30, bp2, NBUTTONSP2, 0, 0 }; +static Button_Group *bgact = &bgp1; + +static Board brd = + { 0, 0, 640, 480, IND_BLACK, IND_CYAN, IND_DARKGRAY, 1 }; +static Board brdimg = + { 384, 46, 235, 157, IND_BLACK, IND_CYAN, IND_DARKGRAY, 1 }; + +static GrFont *grf_std; +static GrFont *grf_big; +GrTextOption grt_centered; +GrTextOption grt_left; + +static GrContext *grcglob = NULL; +static int worg = 0, horg = 0; + +/* Internal routines */ + +static void ini_graphics(void); +static void ini_objects(void); +static void paint_screen(void); +static void the_title(int x, int y); +static void the_info(int x, int y); +static int pev_command(Event * ev); +static int pev_select(Event * ev); +static void paint_foot(char *s); +static void paint_animation(void); +static void disaster(char *s); + +/************************************************************************/ + +int main(int argc, char **argv) +{ + Event ev; + char buffer[100]; + + if (argc >= 4) { + gwidth = atoi(argv[1]); + gheight = atoi(argv[2]); + gbpp = atoi(argv[3]); + } + + ini_graphics(); + GrSetWindowTitle(wintitle); + ini_objects(); + paint_screen(); + + while (1) { + event_read(&ev); + if (ev.type == EV_MOUSE) { + ev.p2 -= worg; + ev.p3 -= horg; + } + if (ev.type == EV_END) + break; + if ((ev.type == EV_KEY) && (ev.p1 == GrKey_Escape)) + break; + if ((ev.type == EV_KEY) && (ev.p1 == 's')) { + GrSaveContextToPpm(NULL, "demogrx.ppm", "DemoGRX"); + continue; + } + if (pev_button_group(&ev, bgact)) + continue; + if (pev_command(&ev)) + continue; + if (pev_select(&ev)) + continue; + if (ev.type == EV_MOUSE) { + if (ev.p1 == MOUSE_LB_PRESSED) { + sprintf(buffer, "%ld %ld over a button, please",ev.p2,ev.p3); + paint_foot(buffer); + } + else if (ev.p1 == MOUSE_LB_RELEASED) + paint_foot("Hold down left mouse buttom to see a comment"); + } + if (ev.type == EV_NULL) + paint_animation(); + } + + gfaz_fin(); + return 0; +} + +/************************************************************************/ + +static void ini_graphics(void) +{ + gfaz_ini(gwidth, gheight, gbpp); + gwidth = GrScreenX(); + gheight = GrScreenY(); + grcglob = NULL; + if (gwidth > 640 || gheight > 480) { + GrClearScreen(GrAllocColor(120, 90, 60)); + worg = (gwidth - 640) / 2; + horg = (gheight - 480) / 2; + grcglob = GrCreateSubContext(worg, horg, worg + 639, horg + 479, + NULL, NULL); + GrSetContext(grcglob); + } +} + +/************************************************************************/ + +static void ini_objects(void) +{ + grf_std = GrLoadFont("lucb21.fnt"); + if (grf_std == NULL) { +#if defined(__MSDOS__) || defined(__WIN32__) + grf_std = GrLoadFont("..\\fonts\\lucb21.fnt"); +#else + grf_std = GrLoadFont("../fonts/lucb21.fnt"); +#endif + if (grf_std == NULL) + disaster("lucb21.fnt not found"); + } + + grf_big = GrLoadFont("lucb40b.fnt"); + if (grf_big == NULL) { +#if defined(__MSDOS__) || defined(__WIN32__) + grf_big = GrLoadFont("..\\fonts\\lucb40b.fnt"); +#else + grf_big = GrLoadFont("../fonts/lucb40b.fnt"); +#endif + if (grf_big == NULL) + disaster("lucb40b.fnt not found"); + } + + grt_centered.txo_bgcolor.v = GrNOCOLOR; + grt_centered.txo_direct = GR_TEXT_RIGHT; + grt_centered.txo_xalign = GR_ALIGN_CENTER; + grt_centered.txo_yalign = GR_ALIGN_CENTER; + grt_centered.txo_chrtype = GR_BYTE_TEXT; + + grt_left.txo_bgcolor.v = GrNOCOLOR; + grt_left.txo_direct = GR_TEXT_RIGHT; + grt_left.txo_xalign = GR_ALIGN_LEFT; + grt_left.txo_yalign = GR_ALIGN_CENTER; + grt_left.txo_chrtype = GR_BYTE_TEXT; +} + +/************************************************************************/ + +static void paint_screen(void) +{ + GrContext *grc; + + paint_board(&brd); + paint_button_group(bgact); + paint_board(&brdimg); + grc = GrCreateSubContext(brdimg.x + 4, brdimg.y + 4, + brdimg.x + brdimg.wide - 5, + brdimg.y + brdimg.high - 5, grcglob, NULL); + if (bgact == &bgp1) + GrLoadContextFromPnm(grc, "pnmtest.ppm"); + else + GrLoadContextFromPnm(grc, "pnmtest2.ppm"); + GrDestroyContext(grc); + the_info(500, 215); + drawing(400, 280, 200, 150, BROWN, DARKGRAY); + the_title(500, 330); + paint_foot("Hold down left mouse buttom to see a comment"); +} + +/************************************************************************/ + +static void the_title(int x, int y) +{ + char *t1 = "GRX 2.4.9"; + char *t2 = "test programs launcher"; + + grt_centered.txo_fgcolor.v = LIGHTGREEN; + + grt_centered.txo_font = grf_big; + GrDrawString(t1, strlen(t1), 0 + x, 0 + y, &grt_centered); + + grt_centered.txo_font = grf_std; + GrDrawString(t2, strlen(t2), 0 + x, 40 + y, &grt_centered); +} + +/************************************************************************/ + +static void the_info(int x, int y) +{ + char aux[81], sys[4] = "?"; + int nsys; + + grt_centered.txo_fgcolor.v = CYAN; + grt_centered.txo_font = grf_std; + + nsys = GrGetLibrarySystem(); + if (nsys == GRX_VERSION_TCC_8086_DOS) + strcpy(sys, "TCC"); + if (nsys == GRX_VERSION_GCC_386_DJGPP) + strcpy(sys, "DJ2"); + if (nsys == GRX_VERSION_GCC_386_LINUX) + strcpy(sys, "LNX"); + if (nsys == GRX_VERSION_GCC_386_X11) + strcpy(sys, "X11"); + if (nsys == GRX_VERSION_GCC_X86_64_LINUX) + strcpy(sys, "L64"); + if (nsys == GRX_VERSION_GCC_X86_64_X11) + strcpy(sys, "X64"); + if (nsys == GRX_VERSION_GENERIC_X11) + strcpy(sys, "X11"); + if (nsys == GRX_VERSION_WATCOM_DOS4GW) + strcpy(sys, "WAT"); + if (nsys == GRX_VERSION_GCC_386_WIN32) + strcpy(sys, "W32"); + + sprintf(aux, "Version:%x System:%s", GrGetLibraryVersion(), sys); + GrDrawString(aux, strlen(aux), 0 + x, 0 + y, &grt_centered); + + sprintf(aux, "VideoDriver: %s", GrCurrentVideoDriver()->name); + GrDrawString(aux, strlen(aux), 0 + x, 25 + y, &grt_centered); + + sprintf(aux, "Mode: %dx%d %d bpp", GrCurrentVideoMode()->width, + GrCurrentVideoMode()->height, GrCurrentVideoMode()->bpp); + GrDrawString(aux, strlen(aux), 0 + x, 50 + y, &grt_centered); +} + +/************************************************************************/ + +static int pev_command(Event * ev) +{ + int i; + char nprog[81]; + + if (ev->type == EV_COMMAND) { + if (ev->p1 == ID_EXIT) { + par_event_queue(EV_END, 0, 0, 0); + return 1; + } + if (ev->p1 == ID_PAGE1) { + bgact = &bgp1; + paint_screen(); + return 1; + } + if (ev->p1 == ID_PAGE2) { + bgact = &bgp2; + paint_screen(); + return 1; + } + for (i = 0; i < NDEMOS; i++) { + if (ev->p1 == ptable[i].cid) { + gfaz_fin(); +#if defined(__MSDOS__) || defined(__WIN32__) + if (ev->p1 == ID_MODETEST) + strcpy(nprog, "..\\bin\\"); + else + strcpy(nprog, ".\\"); +#else + if (ev->p1 == ID_MODETEST) + strcpy(nprog, "../bin/"); + else + strcpy(nprog, "./"); +#endif +#if defined(__XWIN__) + strcat(nprog, "x"); +#endif + strcat(nprog, ptable[i].prog); + system(nprog); + ini_graphics(); + GrSetWindowTitle(wintitle); + paint_screen(); + return 1; + } + } + } + return 0; +} + +/************************************************************************/ + +static int pev_select(Event * ev) +{ + int i; + + if (ev->type == EV_SELECT) { + for (i = 0; i < NDEMOS; i++) { + if (ev->p1 == ptable[i].cid) { + paint_foot(ptable[i].text); + return 1; + } + } + } + return 0; +} + +/************************************************************************/ + +static void paint_foot(char *s) +{ + grt_centered.txo_fgcolor.v = LIGHTGREEN; + grt_centered.txo_font = grf_std; + + GrSetClipBox(10, 440, 630, 470); + GrClearClipBox(CYAN); + GrDrawString(s, strlen(s), 320, 455, &grt_centered); + GrResetClipBox(); +} + +/************************************************************************/ + +static void paint_animation(void) +{ + static int pos = 620; + static int ini = 0; + static GrContext *grc; + int ltext, wtext; + + if (!ini) { + grc = GrCreateContext(620, 30, NULL, NULL); + if (grc == NULL) + return; + ini = 1; + } + + grt_left.txo_fgcolor.v = CYAN; + grt_left.txo_font = grf_std; + ltext = strlen(animatedtext); + wtext = GrStringWidth(animatedtext, ltext, &grt_left); + + GrSetContext(grc); + GrClearContext(DARKGRAY); + GrDrawString(animatedtext, ltext, pos, 15, &grt_left); + GrSetContext(grcglob); + GrBitBlt(NULL, 10, 8, grc, 0, 0, 629, 29, GrWRITE); + + pos -= 1; + if (pos <= -wtext) + pos = 620; +} + +/************************************************************************/ + +static void disaster(char *s) +{ + void _GrCloseVideoDriver(void); + + char aux[81]; + + gfaz_fin(); + _GrCloseVideoDriver(); + printf("DemoGRX: %s\n", s); + printf("press Return to continue\n"); + fgets(aux, 80, stdin); + exit(1); +} diff --git a/thirdparty/grx249/test/depend.gnu b/thirdparty/grx249/test/depend.gnu new file mode 100644 index 0000000..2814d96 --- /dev/null +++ b/thirdparty/grx249/test/depend.gnu @@ -0,0 +1,22 @@ +arctest.o: arctest.c test.h ../include/grx20.h drawing.h rand.h +blittest.o: blittest.c test.h ../include/grx20.h drawing.h rand.h +circtest.o: circtest.c test.h ../include/grx20.h drawing.h rand.h +cliptest.o: cliptest.c test.h ../include/grx20.h drawing.h rand.h +colorops.o: colorops.c test.h ../include/grx20.h drawing.h rand.h +curstest.o: curstest.c test.h ../include/grx20.h drawing.h rand.h +fnt2c.o: fnt2c.c ../include/grx20.h +fonttest.o: fonttest.c test.h ../include/grx20.h drawing.h rand.h +imgtest.o: imgtest.c test.h ../include/grx20.h drawing.h rand.h +keys.o: keys.c ../include/grx20.h ../include/grxkeys.h +life.o: life.c test.h ../include/grx20.h drawing.h rand.h +linetest.o: linetest.c test.h ../include/grx20.h drawing.h rand.h +modetest.o: modetest.c ../include/grx20.h drawing.h rand.h +mousetst.o: mousetst.c test.h ../include/grx20.h drawing.h rand.h +pcirctst.o: pcirctst.c test.h ../include/grx20.h drawing.h rand.h +polytest.o: polytest.c test.h ../include/grx20.h drawing.h rand.h +rgbtest.o: rgbtest.c test.h ../include/grx20.h drawing.h rand.h +scroltst.o: scroltst.c test.h ../include/grx20.h drawing.h rand.h +speedtst.o: speedtst.c rand.h ../include/grx20.h +textpatt.o: textpatt.c ../include/grx20.h ../include/grxkeys.h +winclip.o: winclip.c test.h ../include/grx20.h drawing.h rand.h +wintest.o: wintest.c test.h ../include/grx20.h drawing.h rand.h diff --git a/thirdparty/grx249/test/drawing.h b/thirdparty/grx249/test/drawing.h new file mode 100644 index 0000000..c6ac1cf --- /dev/null +++ b/thirdparty/grx249/test/drawing.h @@ -0,0 +1,36 @@ +/** + ** DRAWING.H ---- a stupid little drawing used all over in test programs + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] See "doc/copying.cb" for details. + **/ + +#include "rand.h" + +void drawing(int xpos,int ypos,int xsize,int ysize,long fg,long bg) +{ +# define XP(x) (int)((((long)(x) * (long)xsize) / 100L) + xpos) +# define YP(y) (int)((((long)(y) * (long)ysize) / 100L) + ypos) + int ii; + if(bg != GrNOCOLOR) { + GrFilledBox(xpos,ypos,xpos+xsize-1,ypos+ysize-1,bg); + } + GrLine(XP(10),YP(10),XP(40),YP(40),fg); + GrLine(XP(40),YP(10),XP(10),YP(40),fg); + GrLine(XP(35),YP(10),XP(65),YP(40),fg); + GrLine(XP(35),YP(40),XP(65),YP(10),fg); + GrLine(XP(70),YP(10),XP(90),YP(40),fg); + GrLine(XP(70),YP(40),XP(90),YP(10),fg); + for(ii = 0; ii < 5; ii++) { + GrBox(XP(70+2*ii),YP(10+3*ii),XP(90-2*ii),YP(40-3*ii),fg); + } + GrFilledBox(XP(10),YP(50),XP(60),YP(90),fg); + GrBox(XP(70),YP(50),XP(90),YP(90),fg); + for(ii = 0; ii < 100; ii++) { + GrPlot(XP((RND() % 20U) + 70),YP((RND() % 40U) + 50),fg); + } +} + +#undef XP +#undef YP + diff --git a/thirdparty/grx249/test/fontdemo.c b/thirdparty/grx249/test/fontdemo.c new file mode 100644 index 0000000..6d0a0b6 --- /dev/null +++ b/thirdparty/grx249/test/fontdemo.c @@ -0,0 +1,223 @@ +/** + ** fontdemo.c ---- demonstrate a font + ** + ** Copyright (C) 2002 Dimitar Zhekov + ** E-Mail: jimmy@is-vn.bg + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include + +#include "grx20.h" +#include "grxkeys.h" + +static GrTextOption opt; +static int curx = 0, cury = 0; +/* deltax and deltay are the additional columns/lines between characters */ +static int deltax = 0, deltay = 0; + +static void gnewl(void) +{ + cury += GrCharHeight('A', &opt) + deltay; + curx = 0; + if(cury + GrCharHeight('A', &opt) > GrSizeY() + deltay) { + if(GrKeyRead() == GrKey_F10) { + GrUnloadFont(opt.txo_font); + exit(0); + } + GrClearScreen(opt.txo_bgcolor.v); + cury = 0; + } +} + +/* all control characters are displayed 1:1 */ +static void gputc(int c) +{ + if(curx + GrCharWidth(c, &opt) + deltax > GrSizeX()) gnewl(); + GrDrawChar(c, curx, cury, &opt); + curx += GrCharWidth(c, &opt) + deltax; +} + +static void gputs(const char *s) +{ + while(*s != '\0') gputc((unsigned char) *s++); + gnewl(); +} + +static void revert(void) +{ + GrColor color; + + color = opt.txo_fgcolor.v; + opt.txo_fgcolor.v = opt.txo_bgcolor.v | (color & GR_UNDERLINE_TEXT); + opt.txo_bgcolor.v = color & ~GR_UNDERLINE_TEXT; + GrClearScreen(color); + curx = cury = 0; +} + +int main(int argc, char **argv) +{ + int i, n; + char *s; + char *bad = NULL; + int c; + + int width = 0, height = 0, bpp = 8, gray = 192, attributes = 0; + + char *name, *testname; + GrFontHeader *hdr; + FILE *f; + char buffer[0x20]; + GrKeyType key; + + /* unfortunately not all systems support getopt() */ + for(i = 1; i < argc; i++) { + s = argv[i]; + if(*s != '-' || ((c = *++s) == '\0') || *++s != '\0') break; + if(c == '-') { + i++; + break; + } + if(++i == argc) { + fprintf(stderr, "-%c: argument required\n", c); + return(1); + } + if(sscanf(argv[i], "%d", &n) != 1 || n < 0) { + fprintf(stderr, "%s: invalid argument\n", argv[i]); + exit(1); + } + switch(c) { + case 'x' : width = n; break; + case 'y' : height = n; break; + case 'b' : if((bpp = n) < 2 || bpp > 32) bad = "bpp"; break; + case 'g' : if((gray = n) > 255) bad = "gray"; break; + case 'X' : if((deltax = n) > 31) bad = "deltax"; break; + case 'Y' : if((deltay = n) > 31) bad = "deltay"; break; + case 'a' : if((attributes = n) > 3) bad = "attributes"; break; + default : { + fprintf(stderr, "-%c: invalid option\n", c); + return(1); + } + } + if(bad) { + fprintf(stderr, "%d: %s out of range\n", n, bad); + return(1); + } + } + + if(i == argc) { + printf( + "usage:\tfontdemo [-x WIDTH] [-y HEIGHT] [-b BPP] [-g COMPONENT]\n" + "\t[-X DELTAX] [-Y DELTAY] [-a ATTRIBUTES] FONT [FILE...]\n" + ); + return(0); + } + + name = argv[i++]; + opt.txo_font = GrLoadFont(name); + if(opt.txo_font == NULL && (testname = malloc(strlen(name) + 10)) != NULL) { + /* try again, this is a test and the path can not been set yet */ +#if defined(__MSDOS__) || defined(__WIN32__) + sprintf( testname,"..\\fonts\\%s",name ); +#else + sprintf( testname,"../fonts/%s",name ); +#endif + opt.txo_font = GrLoadFont(testname); + free(testname); + } + if(opt.txo_font == NULL) { + fprintf(stderr, "%s: load error\n", name); + return(1); + } + hdr = &opt.txo_font->h; + + if(height == 0) { + if(width == 0) { + switch(hdr->height) { + case 8 : + case 14 : height = 400; break; + case 24 : height = 768; break; + default : height = hdr->height * 30; + } + } + else height = width * 3 / 4; + } + if(width == 0) width = height == 400 ? 640 : height * 4 / 3; + + GrSetMode(GR_width_height_bpp_graphics, width, height, bpp); + if(!gray || (opt.txo_fgcolor.v = GrAllocColor(gray, gray, gray)) == GrNOCOLOR) opt.txo_fgcolor.v = GrWhite(); + if(attributes & 0x02) opt.txo_fgcolor.v |= GR_UNDERLINE_TEXT; + opt.txo_bgcolor.v = GrBlack(); + if(attributes & 0x01) revert(); + opt.txo_chrtype = GR_BYTE_TEXT; + opt.txo_direct = GR_TEXT_RIGHT; + opt.txo_xalign = GR_ALIGN_LEFT; + opt.txo_yalign = GR_ALIGN_TOP; + + sprintf(buffer, "%s %dx%d", hdr->name, GrCharWidth('A', &opt), GrCharHeight('A', &opt)); + gputs(buffer); + sprintf(buffer, "%dx%d@%lu", GrSizeX(), GrSizeY(), (unsigned long) GrNumColors()); + gputs(buffer); + gnewl(); + + gputs("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"); + gputs("the quick brown fox jumps over the lazy dog"); + gnewl(); + + if(hdr->minchar <= 0xC0 && hdr->minchar + hdr->numchars >= 0x100) { + gputs("ÁÚÐÇÀÒÀ ÊÀÔßÂÀ ËÈÑÈÖÀ ÏÐÅÑÊÀ×À ËÅÍÈÂÎÒÎ ÊÓ×Å"); + gputs("áúðçàòà êàôÿâà ëèñèöà ïðåñêà÷à ëåíèâîòî êó÷å"); + gnewl(); + } + + /* ascii table, or to be precise, a full table of the current font */ + opt.txo_chrtype = GR_WORD_TEXT; + for(c = 0; c < hdr->numchars; c++) { + gputc(hdr->minchar + c); + if(c % 0x20 == 0x1F) gnewl(); + } + gnewl(); + if(c % 0x20 != 0) gnewl(); + opt.txo_chrtype = GR_BYTE_TEXT; + + while(i < argc) { + name = argv[i++]; + if((f = fopen(name, "r")) == NULL) { + perror(name); + return(1); + } + while((c = getc(f)) != EOF) if(c != '\n') gputc(c); else gnewl(); + if(ferror(f) != 0 || fclose(f) != 0) { + perror(name); + return(1); + } + } + + /* enter and esc are < 0x100 and displayed 1:1 */ + gputs("F1-new line F5-toggle reverse F7-toggle underline F10-exit"); + gnewl(); + + while((key = GrKeyRead()) != GrKey_F10) { + if(key == GrKey_F1) gnewl(); + else if(key == GrKey_F5) revert(); + else if(key == GrKey_F7) opt.txo_fgcolor.v ^= GR_UNDERLINE_TEXT; + else if(key < 0x100) gputc(key); + } + + GrUnloadFont(opt.txo_font); + + return(0); +} diff --git a/thirdparty/grx249/test/fonttest.c b/thirdparty/grx249/test/fonttest.c new file mode 100644 index 0000000..cadf7b1 --- /dev/null +++ b/thirdparty/grx249/test/fonttest.c @@ -0,0 +1,192 @@ +/** + ** fonttest.c ---- test text drawing + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "test.h" + +int cx; +int cy; +GrColor c1; +GrColor c2; +GrColor c3; +GrColor c4; + +char test_text[] = { + "QUICK BROWN FOX JUMPS OVER THE LAZY DOG, " + "quick brown fox jumps over the lazy dog !@#$%^&*()1234567890" +}; + +void displayfont(GrFont *font,char *text,int len) +{ + GrTextOption opt; + int ww,hh; + int bx,by; + int bw,bh; + + memset(&opt,0,sizeof(opt)); + opt.txo_font = font; + opt.txo_xalign = GR_ALIGN_LEFT; + opt.txo_yalign = GR_ALIGN_TOP; + GrFilledBox(0,0,GrSizeX(),GrSizeY(),GrBlack()); + opt.txo_direct = GR_TEXT_RIGHT; + opt.txo_fgcolor.v = GrBlack(); + opt.txo_bgcolor.v = c1; + ww = GrStringWidth(text,len,&opt); + hh = GrStringHeight(text,len,&opt); + bw = ww+2*hh; + bh = ww; + bx = cx - bw/2; + by = cy - bh/2; + GrDrawString(text,len,bx+hh,by,&opt); + opt.txo_direct = GR_TEXT_DOWN; + opt.txo_bgcolor.v = c2; + GrDrawString(text,len,bx+bw-hh,by,&opt); + opt.txo_direct = GR_TEXT_LEFT; + opt.txo_bgcolor.v = c3; + GrDrawString(text,len,bx+bw-ww-hh,by+bh-hh,&opt); + opt.txo_direct = GR_TEXT_UP; + opt.txo_bgcolor.v = c4; + GrDrawString(text,len,bx,by+bh-ww,&opt); + GrKeyRead(); + GrClearClipBox(GrBlack()); + opt.txo_direct = GR_TEXT_RIGHT; + opt.txo_fgcolor.v = c1; + opt.txo_bgcolor.v = GrBlack(); + bx = GrSizeX() / 16; + by = GrSizeY() / 16; + bx = (bx + 7) & ~7; + while(by < GrSizeY()) { + GrDrawString(test_text,strlen(test_text),bx,by,&opt); + opt.txo_fgcolor.v ^= GR_UNDERLINE_TEXT; + by += hh; + } + GrKeyRead(); +} + +TESTFUNC(fonttest) +{ + GrFont *f; + int i; + char buff[100]; + cx = GrSizeX() / 2; + cy = GrSizeY() / 2; + c1 = GrAllocColor(100,200,100); + c2 = GrAllocColor(150,150,100); + c3 = GrAllocColor(100,100,200); + c4 = GrAllocColor(100,180,180); + GrBox(GrSizeX()/16 - 2, + GrSizeY()/16 - 2, + GrSizeX() - GrSizeX()/16 + 1, + GrSizeY() - GrSizeY()/16 + 1, + GrAllocColor(250,100,100) + ); + GrSetClipBox(GrSizeX()/16, + GrSizeY()/16, + GrSizeX() - GrSizeX()/16 - 1, + GrSizeY() - GrSizeY()/16 - 1 + ); + strcpy(buff,"Default GRX font"); + displayfont(&GrDefaultFont,buff,strlen(buff)); + strcpy(buff,"Default font scaled to 6x10"); + displayfont( + GrBuildConvertedFont( + &GrDefaultFont, + (GR_FONTCVT_SKIPCHARS | GR_FONTCVT_RESIZE), + 6, + 10, + ' ', + 'z' + ), + buff, + strlen(buff) + ); + strcpy(buff,"Default font scaled to 12x24"); + displayfont( + GrBuildConvertedFont( + &GrDefaultFont, + (GR_FONTCVT_SKIPCHARS | GR_FONTCVT_RESIZE), + 12, + 24, + ' ', + 'z' + ), + buff, + strlen(buff) + ); + strcpy(buff,"Default font scaled to 18x36"); + displayfont( + GrBuildConvertedFont( + &GrDefaultFont, + (GR_FONTCVT_SKIPCHARS | GR_FONTCVT_RESIZE), + 18, + 36, + ' ', + 'z' + ), + buff, + strlen(buff) + ); + strcpy(buff,"Default font scaled to 10x20 proportional"); + displayfont( + GrBuildConvertedFont( + &GrDefaultFont, + (GR_FONTCVT_SKIPCHARS | GR_FONTCVT_RESIZE | GR_FONTCVT_PROPORTION), + 10, + 20, + ' ', + 'z' + ), + buff, + strlen(buff) + ); + strcpy(buff,"Default font scaled to 10x20 bold"); + displayfont( + GrBuildConvertedFont( + &GrDefaultFont, + (GR_FONTCVT_SKIPCHARS | GR_FONTCVT_RESIZE | GR_FONTCVT_BOLDIFY), + 10, + 20, + ' ', + 'z' + ), + buff, + strlen(buff) + ); + strcpy(buff,"Default font scaled to 10x20 italic"); + displayfont( + GrBuildConvertedFont( + &GrDefaultFont, + (GR_FONTCVT_SKIPCHARS | GR_FONTCVT_RESIZE | GR_FONTCVT_ITALICIZE), + 10, + 20, + ' ', + 'z' + ), + buff, + strlen(buff) + ); + for(i = 0; i < Argc; i++) { + f = GrLoadFont(Argv[i]); + if(f) { + sprintf(buff,"This is font %s",Argv[i]); + displayfont(f,buff,strlen(buff)); + } + } +} + diff --git a/thirdparty/grx249/test/fswwtest.c b/thirdparty/grx249/test/fswwtest.c new file mode 100644 index 0000000..0264d65 --- /dev/null +++ b/thirdparty/grx249/test/fswwtest.c @@ -0,0 +1,75 @@ +/** + ** fswwtest.c ---- test programmed switching + ** between full screen and windowed modes + ** for the sdl driver + ** + ** Copyright (C) 2007 Maurice Lombardi + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "grx20.h" +#include "grxkeys.h" +#include "drawing.h" + +int main() +{ + int x, y, ww, wh, i = 0; + GrColor c; + GrContext *w1, *w2, *w3, *w4; + + do { + + if( i ) GrSetDriver( "sdl::ww gw 600 gh 600 nc 256" ); + else GrSetDriver( "sdl::fs gw 600 gh 600 nc 256" ); + i = ! i; + + GrSetMode( GR_default_graphics ); + + x = GrSizeX(); + y = GrSizeY(); + ww = (x / 2) - 10; + wh = (y / 2) - 10; + w1 = GrCreateSubContext(5,5,ww+4,wh+4,NULL,NULL); + w2 = GrCreateSubContext(15+ww,5,ww+ww+14,wh+4,NULL,NULL); + w3 = GrCreateSubContext(5,15+wh,ww+4,wh+wh+14,NULL,NULL); + w4 = GrCreateSubContext(15+ww,15+wh,ww+ww+14,wh+wh+14,NULL,NULL); + + GrSetContext(w1); + c = GrAllocColor(200,100,100); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w2); + c = GrAllocColor(100,200,200); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w3); + c = GrAllocColor(200,200,0); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w4); + c = GrAllocColor(0,100,200); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext( NULL ); + + GrTextXY(10,wh,"press any key to toggle full screen / windowed modes, escape to end",GrWhite(),GrBlack()); + + } while ( GrKeyRead() != GrKey_Escape ); + return 0; +} diff --git a/thirdparty/grx249/test/gfaz.c b/thirdparty/grx249/test/gfaz.c new file mode 100644 index 0000000..7e1f3cb --- /dev/null +++ b/thirdparty/grx249/test/gfaz.c @@ -0,0 +1,398 @@ +/** + ** gfaz.c ---- Mini GUI for GRX + ** + ** Copyright (C) 2000,2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include +#include +#include "gfaz.h" + +GrColor *egacolors; + +static int mouse_found = 0; +static int mouse_count = 0; + +#define MAX_EVQUEUE 10 + +static Event evqueue[MAX_EVQUEUE]; +static int num_evqueue = 0; + +static void (*hook_input_event)( Event * ) = NULL; + +/* Internal routines */ + +static int read_input( void ); +static void input_event_queue( Event *ev ); +static int coord_into( int x, int y, int xo, int yo, int xl, int yl ); + +/**************************************************************************/ + +int gfaz_ini( int width, int height, int bpp ) +{ +/* __djgpp_set_ctrl_c( 0 );*/ +/* _go32_want_ctrl_break( 1 );*/ +/* GrSetMode( GR_default_graphics );*/ + + GrSetMode( GR_width_height_bpp_graphics,width,height,bpp ); + + egacolors = GrAllocEgaColors(); + + if( GrMouseDetect() ){ + mouse_found = 1; + GrMouseInit(); + GrMouseSetColors( GrWhite(),GrBlack() ); + show_mouse(); + } + GrMouseEventEnable( 1,mouse_found ); + + return 0; +} + +/**************************************************************************/ + +int gfaz_fin( void ) +{ + if( mouse_found ){ + hide_mouse(); + GrMouseUnInit(); + } + + GrSetMode( GR_default_text ); + + return 0; +} + +/**************************************************************************/ + +void event_read( Event *ev ) +{ + while( 1 ){ + if( num_evqueue > 0 ){ + num_evqueue--; + *ev = evqueue[num_evqueue]; + return; + } + if( read_input() ){ + continue; + } + ev->type = EV_NULL; + ev->p1 = 0; + ev->p2 = 0; + ev->p3 = 0; + return; + } +} + +/**************************************************************************/ + +void event_wait( Event *ev ) +{ + while( 1 ){ + event_read( ev ); + if( ev->type != EV_NULL ) + return; + } +} + +/**************************************************************************/ + +void event_queue( Event *ev ) +{ + if( num_evqueue < MAX_EVQUEUE ) + evqueue[num_evqueue++] = *ev; +} + +/**************************************************************************/ + +void par_event_queue( int type, long p1, long p2, long p3 ) +{ + Event ev; + + ev.type = type; + ev.p1 = p1; + ev.p2 = p2; + ev.p3 = p3; + event_queue( &ev ); +} + +/**************************************************************************/ + +void set_hook_input_event( void (*fn)( Event * ) ) +{ + hook_input_event = fn; +} + +/**************************************************************************/ + +static void input_event_queue( Event *ev ) +{ + if( hook_input_event != NULL ) + hook_input_event( ev ); + else + event_queue( ev ); +} + +/************************************************************************/ + +static int read_input( void ) +{ + GrMouseEvent evt; + Event evaux; + + GrMouseGetEventT( GR_M_EVENT,&evt,10L ); + if( evt.dtime == -1 ) return 0; + + if( evt.flags & GR_M_KEYPRESS ){ + evaux.type = EV_KEY; + evaux.p1 = evt.key; + evaux.p2 = 0; + evaux.p3 = 0; + input_event_queue( &evaux ); + } + evaux.type = EV_MOUSE; + evaux.p2 = evt.x; + evaux.p3 = evt.y; + if( evt.flags & GR_M_LEFT_DOWN ){ + evaux.p1 = MOUSE_LB_PRESSED; + input_event_queue( &evaux ); + } + if( evt.flags & GR_M_RIGHT_DOWN ){ + evaux.p1 = MOUSE_RB_PRESSED; + input_event_queue( &evaux ); + } + if( evt.flags & GR_M_LEFT_UP ){ + evaux.p1 = MOUSE_LB_RELEASED; + input_event_queue( &evaux ); + } + if( evt.flags & GR_M_RIGHT_UP ){ + evaux.p1 = MOUSE_RB_RELEASED; + input_event_queue( &evaux ); + } + return 1; +} + +/**************************************************************************/ + +void show_mouse( void ) +{ + if( (mouse_count == 0) && mouse_found ) + GrMouseDisplayCursor(); + + mouse_count++; +} + +/************************************************************************/ + +void hide_mouse( void ) +{ + mouse_count--; + + if( (mouse_count == 0) && mouse_found ) + GrMouseEraseCursor(); +} + +/**************************************************************************/ + +void dboton( int x, int y, int an, int al, + GrColor c, GrColor ct, char * s, int t ) + +// x, y posici¢n de la esquina izquierda +// an, al ancho y alto +// c, ct color del fondo y del texto +// t, tipo bit 0 0=normal, 1=apretado +// bit 1 0=no selec, 1=seleccionado + +{ + int pol[7][2], prof, pulsd, selec, despl; + GrTextOption grt; + GrLineOption glo; + int mouseblock; + + prof = (t & 0x1) ? 2 : 4; + pulsd = (t & 0x1) ? 1 : 0; + selec = (t & 0x2) ? 1 : 0; + despl = (t & 0x1) ? 1 : 0; + + mouseblock = GrMouseBlock( NULL,x,y,x+an-1,y+al-1 ); + GrBox( x,y,x+an-1,y+al-1,BLACK ); + x = x + 1; y = y + 1; + an = an - 2; al = al - 2; + + pol[0][0] = x; pol[0][1] = y; + pol[1][0] = x + an - 1; pol[1][1] = y; + pol[2][0] = x + an - 2 - prof; pol[2][1] = y + 1 + prof; + pol[3][0] = x + 1 + prof; pol[3][1] = y + 1 + prof; + pol[4][0] = x + 1 + prof; pol[4][1] = y + al - 2 - prof; + pol[5][0] = x; pol[5][1] = y + al - 1; + pol[6][0] = pol[0][0]; pol[6][1] = pol[0][1]; + GrFilledPolygon( 7,pol,pulsd ? DARKGRAY : LIGHTGRAY ); + GrPolygon( 7,pol,BLACK ); + GrLine( pol[0][0],pol[0][1],pol[3][0],pol[3][1],BLACK ); + pol[0][0] = x + an - 1; pol[0][1] = y + al - 1; + pol[3][0] = x + an - 2 - prof; pol[3][1] = y + al - 2 - prof; + pol[6][0] = pol[0][0]; pol[6][1] = pol[0][1]; + GrFilledPolygon( 7,pol,pulsd ? LIGHTGRAY : DARKGRAY ); + GrPolygon( 7,pol,BLACK ); + GrLine( pol[0][0],pol[0][1],pol[3][0],pol[3][1],BLACK ); + GrFilledBox( x+2+prof,y+2+prof,x+an-3-prof,y+al-3-prof,c ); + + grt.txo_font = &GrFont_PC8x14; + grt.txo_fgcolor.v = ct; + grt.txo_bgcolor.v = GrNOCOLOR; + grt.txo_direct = GR_TEXT_RIGHT; + grt.txo_xalign = GR_ALIGN_CENTER; + grt.txo_yalign = GR_ALIGN_CENTER; + grt.txo_chrtype = GR_BYTE_TEXT; + if( despl ) + GrDrawString( s,strlen( s ),x+an/2+1,y+al/2+1,&grt ); + else + GrDrawString( s,strlen( s ),x+an/2,y+al/2,&grt ); + + if( selec ){ + glo.lno_color = ct; + glo.lno_width = 1; + glo.lno_pattlen = 2; + glo.lno_dashpat = "\2\1"; + GrCustomBox( x+8,y+al/2-6,x+an-8,y+al/2+5,&glo ); + } + + GrMouseUnBlock( mouseblock ); +} + +/**************************************************************************/ + +void paint_button( int x, int y, Button *b ) +{ + dboton( x+b->x,y+b->y,b->wide,b->high, + egacolors[b->tbcolor],egacolors[b->tfcolor], + b->text,b->status ); +} + +/**************************************************************************/ + +void paint_button_group( Button_Group *bg ) +{ + int i; + + for( i=0; inb; i++ ) + paint_button( bg->x,bg->y,&(bg->b[i]) ); +} + +/**************************************************************************/ + +int pev_button_group( Event *ev, Button_Group *bg ) +{ + int i; + + if( ev->type == EV_MOUSE ){ + if( ev->p1 == MOUSE_LB_PRESSED ){ + for( i=0; inb; i++ ) + if( coord_into( ev->p2,ev->p3, + bg->x+bg->b[i].x,bg->y+bg->b[i].y, + bg->b[i].wide,bg->b[i].high ) ){ + bg->b[bg->pb].status &= ~BSTATUS_SELECTED; + paint_button( bg->x,bg->y,&(bg->b[bg->pb]) ); + bg->b[i].status |= BSTATUS_PRESSED | BSTATUS_SELECTED; + paint_button( bg->x,bg->y,&(bg->b[i]) ); + bg->pb = i; + bg->abp = 1; + par_event_queue( EV_SELECT,bg->b[i].bid,0,0 ); + return 1; + } + } + if( ev->p1 == MOUSE_LB_RELEASED ){ + if( bg->abp ){ + i = bg->pb; + bg->b[i].status &= ~BSTATUS_PRESSED; + paint_button( bg->x,bg->y,&(bg->b[i]) ); + bg->abp = 0; + if( coord_into( ev->p2,ev->p3, + bg->x+bg->b[i].x,bg->y+bg->b[i].y, + bg->b[i].wide,bg->b[i].high ) ){ + par_event_queue( EV_COMMAND,bg->b[i].bid,0,0 ); + } + return 1; + } + } + } + else if( ev->type == EV_KEY ){ + if( ev->p1 == GrKey_Right || + ev->p1 == GrKey_Down || + ev->p1 == GrKey_Tab ){ + if( bg->pb < bg->nb-1 ){ + bg->b[bg->pb].status &= ~BSTATUS_SELECTED; + paint_button( bg->x,bg->y,&(bg->b[bg->pb]) ); + bg->pb++; + bg->b[bg->pb].status |= BSTATUS_SELECTED; + paint_button( bg->x,bg->y,&(bg->b[bg->pb]) ); + par_event_queue( EV_SELECT,bg->b[bg->pb].bid,0,0 ); + } + return 1; + } + else if( ev->p1 == GrKey_Left || + ev->p1 == GrKey_Up || + ev->p1 == GrKey_BackTab ){ + if( bg->pb > 0 ){ + bg->b[bg->pb].status &= ~BSTATUS_SELECTED; + paint_button( bg->x,bg->y,&(bg->b[bg->pb]) ); + bg->pb--; + bg->b[bg->pb].status |= BSTATUS_SELECTED; + paint_button( bg->x,bg->y,&(bg->b[bg->pb]) ); + par_event_queue( EV_SELECT,bg->b[bg->pb].bid,0,0 ); + } + return 1; + } + else if( ev->p1 == GrKey_Return ){ + par_event_queue( EV_COMMAND,bg->b[bg->pb].bid,0,0 ); + return 1; + } + } + + return 0; +} + +/**************************************************************************/ + +static int coord_into( int x, int y, int xo, int yo, int xl, int yl ) +{ + if( x < xo ) return 0; + if( x >= xo+xl ) return 0; + if( y < yo ) return 0; + if( y >= yo+yl ) return 0; + return 1; +} + +/**************************************************************************/ + +void paint_board( Board *b ) +{ + int x1, y1, x2, y2; + + x1 = b->x; + y1 = b->y; + x2 = b->x + b->wide - 1; + y2 = b->y + b->high - 1; + + GrBox( x1,y1,x2,y2,egacolors[b->lcolor] ); + GrBox( x1+1,y1+1,x2-1,y2-1,egacolors[b->bcolor] ); + GrBox( x1+2,y1+2,x2-2,y2-2,egacolors[b->bcolor] ); + GrBox( x1+3,y1+3,x2-3,y2-3,egacolors[b->lcolor] ); + GrFilledBox( x1+4,y1+4,x2-4,y2-4,egacolors[b->color] ); +} + diff --git a/thirdparty/grx249/test/gfaz.h b/thirdparty/grx249/test/gfaz.h new file mode 100644 index 0000000..4bffa8c --- /dev/null +++ b/thirdparty/grx249/test/gfaz.h @@ -0,0 +1,137 @@ +/** + ** gfaz.h ---- gfaz headers + ** + ** Copyright (C) 2000,2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +extern GrColor *egacolors; + +#define BLACK egacolors[0] +#define BLUE egacolors[1] +#define GREEN egacolors[2] +#define CYAN egacolors[3] +#define RED egacolors[4] +#define MAGENTA egacolors[5] +#define BROWN egacolors[6] +#define LIGHTGRAY egacolors[7] +#define DARKGRAY egacolors[8] +#define LIGHTBLUE egacolors[9] +#define LIGHTGREEN egacolors[10] +#define LIGHTCYAN egacolors[11] +#define LIGHTRED egacolors[12] +#define LIGHTMAGENTA egacolors[13] +#define YELLOW egacolors[14] +#define WHITE egacolors[15] + +#define IND_BLACK 0 +#define IND_BLUE 1 +#define IND_GREEN 2 +#define IND_CYAN 3 +#define IND_RED 4 +#define IND_MAGENTA 5 +#define IND_BROWN 6 +#define IND_LIGHTGRAY 7 +#define IND_DARKGRAY 8 +#define IND_LIGHTBLUE 9 +#define IND_LIGHTGREEN 10 +#define IND_LIGHTCYAN 11 +#define IND_LIGHTRED 12 +#define IND_LIGHTMAGENTA 13 +#define IND_YELLOW 14 +#define IND_WHITE 15 + +#define EV_NULL 0 +#define EV_KEY 1 +#define EV_MOUSE 2 +#define EV_COMMAND 3 +#define EV_SELECT 4 +#define EV_END 5 + +#define MOUSE_LB_PRESSED 1 +#define MOUSE_RB_PRESSED 2 +#define MOUSE_LB_RELEASED 3 +#define MOUSE_RB_RELEASED 4 + +typedef struct{ + int type; + long p1; + long p2; + long p3; + } Event; + +int gfaz_ini( int width, int height, int bpp ); +int gfaz_fin( void ); + +void event_read( Event *ev ); +void event_wait( Event *ev ); +void event_queue( Event *ev ); +void par_event_queue( int type, long p1, long p2, long p3 ); +void set_hook_input_event( void (*fn)( Event * ) ); + +void show_mouse( void ); +void hide_mouse( void ); + +#define BSTATUS_PRESSED 1 +#define BSTATUS_SELECTED 2 + +typedef struct{ + int x, y; // left upper coordinates + int wide, high; // what do you mean + int tbcolor, tfcolor; // text background, foreground, ind colors + char *text; // the text + int status; // see BSTATUS defs + int bid; // button id + } Button; + +void paint_button( int x, int y, Button *b ); + +typedef struct{ + int x, y; // left upper coordinates + Button *b; // button array + int nb; // button number + int pb; // point actual button + int abp; // actual button pressed + } Button_Group; + +void paint_button_group( Button_Group *bg ); +int pev_button_group( Event *ev, Button_Group *bg ); + +typedef struct{ + int x, y; // left upper coordinates + int wide, high; // what do you mean + int aid; // area id + int divx, divy; // x, y divisors + int inip1, inip2; // par1, par2 initial values + int incrp1, incrp2; // par1, par2 increments + int invert; // x,y -> par1,par2 or inverted if 1 + } Area; + +typedef struct{ + int x, y; // left upper coordinates + Area *a; // area array + } Area_Group; + +int pev_area_group( Event *ev, Area_Group *ag ); + +typedef struct{ + int x, y; // left upper coordinates + int wide, high; // what do you mean + int lcolor, bcolor, color; // line, border, normal ind color + int border; // + } Board; + +void paint_board( Board *b ); + diff --git a/thirdparty/grx249/test/imgtest.c b/thirdparty/grx249/test/imgtest.c new file mode 100644 index 0000000..6b62bf5 --- /dev/null +++ b/thirdparty/grx249/test/imgtest.c @@ -0,0 +1,85 @@ +/** + ** imgtest.c ---- test image functions mapping + ** + ** Copyright (c) 1998 Hartmut Schirmer + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" + +#define PARTS 4 + +TESTFUNC(imgtest) +{ + int x = GrSizeX(); + int y = GrSizeY(); + int ww = (x / PARTS)-1; + int wh = (y / PARTS)-1; + int m1, m2, d1, d2; + GrColor c1, c2, c3; + GrContext ctx; + GrImage *img1; + GrImage *img2; + if (! GrCreateContext(ww,wh,NULL,&ctx)) return; + + GrSetContext(&ctx); + c1 = GrAllocColor(255,100,0); + c2 = GrAllocColor(0,0,(GrNumColors() >= 16 ? 180 : 63)); + c3 = GrAllocColor(0,255,0); + drawing(0,0,ww,wh,c1,c2); + GrBox(0,0,ww-1,wh-1,c1); + + GrSetContext(NULL); + + img1 = GrImageFromContext(&ctx); + if (!img1) return; + + GrFilledBox(0,0,ww+1,wh+1,c3); + GrFilledBox(ww+15,0,2*ww+16,wh+1,c3); + + GrBitBlt(NULL,1,1,&ctx,0,0,ww-1,wh-1,0); + GrImageDisplay(ww+16,1,img1); + GrImageDisplayExt(0,wh+4,x-1,y-1, img1); + + GrKeyRead(); + + for (m1=1; m1 <= PARTS ; m1<<=1) { + for (d1=1; d1 <= PARTS; d1 <<= 1) { + for (m2=1; m2 <= PARTS ; m2<<=1) { + for (d2=1; d2 <= PARTS; d2 <<= 1) { + img2 = GrImageStretch(img1,(m1*ww)/d1, (m2*wh)/d2); + if (img2) { + GrImageDisplayExt(0,0,x-1,y-1,img2); + GrImageDestroy(img2); + } + } + } + } + } + GrKeyRead(); + + /* let's finish with some GrGetScanline / GrPutScanline tests */ + for (d1 = 1; d1 < 32; ++d1) { + for (m1 = wh; m1 < y-wh-d1-1; ++m1) { + const GrColor *cp; + cp = GrGetScanline(ww+1,x-ww-d1,m1+1); + if (cp) { + GrPutScanline(ww,x-ww-d1-1,m1,cp,GrIMAGE|c2); + } + } + } + + GrKeyRead(); +} + diff --git a/thirdparty/grx249/test/jpeg1.jpg b/thirdparty/grx249/test/jpeg1.jpg new file mode 100644 index 0000000..1037977 --- /dev/null +++ b/thirdparty/grx249/test/jpeg1.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea8f8daade06a65a95bf353af0abc97014a07168a9701ed1d9dcf8097b629a2d +size 95770 diff --git a/thirdparty/grx249/test/jpeg2.jpg b/thirdparty/grx249/test/jpeg2.jpg new file mode 100644 index 0000000..ceb3839 --- /dev/null +++ b/thirdparty/grx249/test/jpeg2.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5269a62b392a89191a85770af18d7243c6b4098c6485ce1d74e3f3fc9ae78e6d +size 62576 diff --git a/thirdparty/grx249/test/jpgtest.c b/thirdparty/grx249/test/jpgtest.c new file mode 100644 index 0000000..16b8074 --- /dev/null +++ b/thirdparty/grx249/test/jpgtest.c @@ -0,0 +1,118 @@ +/** + ** jpgtest.c ---- test the ctx2jpeg routines + ** + ** Copyright (c) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + **/ + +#include +#include +#include "grx20.h" +#include "grxkeys.h" + +void imagen( char *nf, int scale ) +{ + GrContext *grc; + int wide, high; + char s[81]; + int w, h; + + GrQueryJpeg( nf,&w,&h ); + sprintf( s,"%s %dx%d scale 1/%d",nf,w,h,scale ); + wide = (w/scale > 600) ? 600 : w/scale; + high = (h/scale > 400) ? 400 : h/scale; + GrClearScreen( GrAllocColor( 0,0,200 ) ); + + GrBox( 10,40,10+wide+1,40+high+1,GrWhite() ); + grc = GrCreateSubContext( 11,41,11+wide-1,41+high-1,NULL,NULL ); + GrLoadContextFromJpeg( grc,nf,scale ); + GrDestroyContext( grc ); + + GrTextXY( 10,10,s,GrBlack(),GrWhite() ); + GrTextXY( 10,50+high,"Press any key to continue",GrBlack(),GrWhite() ); + GrKeyRead(); +} + +void nojpegsupport( void ) +{ + char *s[6] = { + "Warning!", + "You need libjpeg (http://www.ijg.org) and enable", + "jpeg support in the GRX lib (edit makedefs.grx)", + "to run this demo", + " ", + "Press any key to continue..." }; + int i; + + GrClearScreen( GrAllocColor( 0,0,100 ) ); + for( i=0; i<6; i++ ) + GrTextXY( 90,160+i*18,s[i],GrWhite(),GrNOCOLOR ); + GrKeyRead(); +} + +int main() +{ + GrContext *grc; + + GrSetMode( GR_width_height_bpp_graphics,640,480,24 ); + + if( !GrJpegSupport() ){ + nojpegsupport(); + GrSetMode(GR_default_text); + exit( 1 ); + } + + imagen( "jpeg1.jpg",1 ); + imagen( "jpeg1.jpg",2 ); + imagen( "jpeg1.jpg",4 ); + imagen( "jpeg1.jpg",8 ); + imagen( "jpeg2.jpg",1 ); + imagen( "jpeg2.jpg",2 ); + imagen( "jpeg2.jpg",4 ); + imagen( "jpeg2.jpg",8 ); + + GrClearScreen( GrAllocColor( 0,100,0 ) ); + grc = GrCreateSubContext( 10,40,10+400-1,40+300-1,NULL,NULL ); + GrLoadContextFromJpeg( grc,"jpeg1.jpg",2 ); + GrDestroyContext( grc ); + grc = GrCreateSubContext( 210,150,210+400-1,150+300-1,NULL,NULL ); + GrLoadContextFromJpeg( grc,"jpeg2.jpg",2 ); + GrDestroyContext( grc ); + + GrTextXY( 10,10,"Press any key to save color and gray screen", + GrBlack(),GrWhite() ); + GrKeyRead(); + + GrSaveContextToJpeg( NULL,"p.jpg",75 ); + GrSaveContextToGrayJpeg( NULL,"pgray.jpg",75 ); + + GrClearScreen( GrBlack() ); + GrTextXY( 10,10,"Press any key to reload color screen ", + GrBlack(),GrWhite() ); + GrKeyRead(); + GrLoadContextFromJpeg( NULL,"p.jpg",1 ); + + GrTextXY( 10,10,"Press any key to reload gray screen ", + GrBlack(),GrWhite() ); + GrKeyRead(); + GrClearScreen( GrBlack() ); + GrLoadContextFromJpeg( NULL,"pgray.jpg",1 ); + + GrTextXY( 10,10,"Press any key to end ", + GrBlack(),GrWhite() ); + GrKeyRead(); + + GrSetMode(GR_default_text); + return 0; +} diff --git a/thirdparty/grx249/test/keys.c b/thirdparty/grx249/test/keys.c new file mode 100644 index 0000000..a6167da --- /dev/null +++ b/thirdparty/grx249/test/keys.c @@ -0,0 +1,465 @@ +/** + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** Changes by D.Zhekov (jimmy@is-vn.bg) 16/02/2004 + ** - converted to a standard test program [GRX I/O only]. + ** + **/ + +#include +#include +#include +#include +#include "test.h" +#include "grxkeys.h" + +#if defined(PENTIUM_CLOCK) && (!defined(__GNUC__) || !defined(__i386__)) +#undef PENTIUM_CLOCK +#endif + +#ifdef PENTIUM_CLOCK +/****************************************************************************** +** This is modified version of keys.c that checks also work of GrKeyPressed() +** and measures time spent in this procedure (at first set divider to clock +** frequency of Your CPU (I have 90MHz): gcc -DPENTIUM_CLOCK=90. +** A.Pavenis (pavenis@acad.latnet.lv) +******************* Some time measurements stuff *************************** +** Macrodefinition RDTSC reads Pentium CPU timestamp counter. It is counting +** CPU clocks. Attempt to use it under 386 or 486 will cause an invalid +** instruction +*/ +#define RDTSC(h,l) __asm__ ("rdtsc" : "=a"(l) , "=d"(h)) +inline long rdtsc(void) { long h,l; RDTSC(h,l); return l; } +/* ***************************************************************************/ +#endif /* PENTIUM_CLOCK */ + +#ifdef __DJGPP__ +#include +#include +#else +extern int getch(void); +extern int getkey(void); +extern int kbhit(void); +#endif + +#define ISPRINT(k) (((unsigned int)(k)) <= 255 && isprint(k)) + +typedef struct { GrKeyType key; + char *name; } KeyEntry; + +static KeyEntry Keys[] = { + { GrKey_NoKey , "GrKey_NoKey" }, + { GrKey_OutsideValidRange , "GrKey_OutsideValidRange" }, + { GrKey_Control_A , "GrKey_Control_A" }, + { GrKey_Control_B , "GrKey_Control_B" }, + { GrKey_Control_C , "GrKey_Control_C" }, + { GrKey_Control_D , "GrKey_Control_D" }, + { GrKey_Control_E , "GrKey_Control_E" }, + { GrKey_Control_F , "GrKey_Control_F" }, + { GrKey_Control_G , "GrKey_Control_G" }, + { GrKey_Control_H , "GrKey_Control_H" }, + { GrKey_Control_I , "GrKey_Control_I" }, + { GrKey_Control_J , "GrKey_Control_J" }, + { GrKey_Control_K , "GrKey_Control_K" }, + { GrKey_Control_L , "GrKey_Control_L" }, + { GrKey_Control_M , "GrKey_Control_M" }, + { GrKey_Control_N , "GrKey_Control_N" }, + { GrKey_Control_O , "GrKey_Control_O" }, + { GrKey_Control_P , "GrKey_Control_P" }, + { GrKey_Control_Q , "GrKey_Control_Q" }, + { GrKey_Control_R , "GrKey_Control_R" }, + { GrKey_Control_S , "GrKey_Control_S" }, + { GrKey_Control_T , "GrKey_Control_T" }, + { GrKey_Control_U , "GrKey_Control_U" }, + { GrKey_Control_V , "GrKey_Control_V" }, + { GrKey_Control_W , "GrKey_Control_W" }, + { GrKey_Control_X , "GrKey_Control_X" }, + { GrKey_Control_Y , "GrKey_Control_Y" }, + { GrKey_Control_Z , "GrKey_Control_Z" }, + { GrKey_Control_LBracket , "GrKey_Control_LBracket" }, + { GrKey_Control_BackSlash , "GrKey_Control_BackSlash" }, + { GrKey_Control_RBracket , "GrKey_Control_RBracket" }, + { GrKey_Control_Caret , "GrKey_Control_Caret" }, + { GrKey_Control_Underscore , "GrKey_Control_Underscore" }, + { GrKey_Space , "GrKey_Space" }, + { GrKey_ExclamationPoint , "GrKey_ExclamationPoint" }, + { GrKey_DoubleQuote , "GrKey_DoubleQuote" }, + { GrKey_Hash , "GrKey_Hash" }, + { GrKey_Dollar , "GrKey_Dollar" }, + { GrKey_Percent , "GrKey_Percent" }, + { GrKey_Ampersand , "GrKey_Ampersand" }, + { GrKey_Quote , "GrKey_Quote" }, + { GrKey_LParen , "GrKey_LParen" }, + { GrKey_RParen , "GrKey_RParen" }, + { GrKey_Star , "GrKey_Star" }, + { GrKey_Plus , "GrKey_Plus" }, + { GrKey_Comma , "GrKey_Comma" }, + { GrKey_Dash , "GrKey_Dash" }, + { GrKey_Period , "GrKey_Period" }, + { GrKey_Slash , "GrKey_Slash" }, + { GrKey_0 , "GrKey_0" }, + { GrKey_1 , "GrKey_1" }, + { GrKey_2 , "GrKey_2" }, + { GrKey_3 , "GrKey_3" }, + { GrKey_4 , "GrKey_4" }, + { GrKey_5 , "GrKey_5" }, + { GrKey_6 , "GrKey_6" }, + { GrKey_7 , "GrKey_7" }, + { GrKey_8 , "GrKey_8" }, + { GrKey_9 , "GrKey_9" }, + { GrKey_Colon , "GrKey_Colon" }, + { GrKey_SemiColon , "GrKey_SemiColon" }, + { GrKey_LAngle , "GrKey_LAngle" }, + { GrKey_Equals , "GrKey_Equals" }, + { GrKey_RAngle , "GrKey_RAngle" }, + { GrKey_QuestionMark , "GrKey_QuestionMark" }, + { GrKey_At , "GrKey_At" }, + { GrKey_A , "GrKey_A" }, + { GrKey_B , "GrKey_B" }, + { GrKey_C , "GrKey_C" }, + { GrKey_D , "GrKey_D" }, + { GrKey_E , "GrKey_E" }, + { GrKey_F , "GrKey_F" }, + { GrKey_G , "GrKey_G" }, + { GrKey_H , "GrKey_H" }, + { GrKey_I , "GrKey_I" }, + { GrKey_J , "GrKey_J" }, + { GrKey_K , "GrKey_K" }, + { GrKey_L , "GrKey_L" }, + { GrKey_M , "GrKey_M" }, + { GrKey_N , "GrKey_N" }, + { GrKey_O , "GrKey_O" }, + { GrKey_P , "GrKey_P" }, + { GrKey_Q , "GrKey_Q" }, + { GrKey_R , "GrKey_R" }, + { GrKey_S , "GrKey_S" }, + { GrKey_T , "GrKey_T" }, + { GrKey_U , "GrKey_U" }, + { GrKey_V , "GrKey_V" }, + { GrKey_W , "GrKey_W" }, + { GrKey_X , "GrKey_X" }, + { GrKey_Y , "GrKey_Y" }, + { GrKey_Z , "GrKey_Z" }, + { GrKey_LBracket , "GrKey_LBracket" }, + { GrKey_BackSlash , "GrKey_BackSlash" }, + { GrKey_RBracket , "GrKey_RBracket" }, + { GrKey_Caret , "GrKey_Caret" }, + { GrKey_UnderScore , "GrKey_UnderScore" }, + { GrKey_BackQuote , "GrKey_BackQuote" }, + { GrKey_a , "GrKey_a" }, + { GrKey_b , "GrKey_b" }, + { GrKey_c , "GrKey_c" }, + { GrKey_d , "GrKey_d" }, + { GrKey_e , "GrKey_e" }, + { GrKey_f , "GrKey_f" }, + { GrKey_g , "GrKey_g" }, + { GrKey_h , "GrKey_h" }, + { GrKey_i , "GrKey_i" }, + { GrKey_j , "GrKey_j" }, + { GrKey_k , "GrKey_k" }, + { GrKey_l , "GrKey_l" }, + { GrKey_m , "GrKey_m" }, + { GrKey_n , "GrKey_n" }, + { GrKey_o , "GrKey_o" }, + { GrKey_p , "GrKey_p" }, + { GrKey_q , "GrKey_q" }, + { GrKey_r , "GrKey_r" }, + { GrKey_s , "GrKey_s" }, + { GrKey_t , "GrKey_t" }, + { GrKey_u , "GrKey_u" }, + { GrKey_v , "GrKey_v" }, + { GrKey_w , "GrKey_w" }, + { GrKey_x , "GrKey_x" }, + { GrKey_y , "GrKey_y" }, + { GrKey_z , "GrKey_z" }, + { GrKey_LBrace , "GrKey_LBrace" }, + { GrKey_Pipe , "GrKey_Pipe" }, + { GrKey_RBrace , "GrKey_RBrace" }, + { GrKey_Tilde , "GrKey_Tilde" }, + { GrKey_Control_Backspace , "GrKey_Control_Backspace" }, + { GrKey_Alt_Escape , "GrKey_Alt_Escape" }, + { GrKey_Control_At , "GrKey_Control_At" }, + { GrKey_Alt_Backspace , "GrKey_Alt_Backspace" }, + { GrKey_BackTab , "GrKey_BackTab" }, + { GrKey_Alt_Q , "GrKey_Alt_Q" }, + { GrKey_Alt_W , "GrKey_Alt_W" }, + { GrKey_Alt_E , "GrKey_Alt_E" }, + { GrKey_Alt_R , "GrKey_Alt_R" }, + { GrKey_Alt_T , "GrKey_Alt_T" }, + { GrKey_Alt_Y , "GrKey_Alt_Y" }, + { GrKey_Alt_U , "GrKey_Alt_U" }, + { GrKey_Alt_I , "GrKey_Alt_I" }, + { GrKey_Alt_O , "GrKey_Alt_O" }, + { GrKey_Alt_P , "GrKey_Alt_P" }, + { GrKey_Alt_LBracket , "GrKey_Alt_LBracket" }, + { GrKey_Alt_RBracket , "GrKey_Alt_RBracket" }, + { GrKey_Alt_Return , "GrKey_Alt_Return" }, + { GrKey_Alt_A , "GrKey_Alt_A" }, + { GrKey_Alt_S , "GrKey_Alt_S" }, + { GrKey_Alt_D , "GrKey_Alt_D" }, + { GrKey_Alt_F , "GrKey_Alt_F" }, + { GrKey_Alt_G , "GrKey_Alt_G" }, + { GrKey_Alt_H , "GrKey_Alt_H" }, + { GrKey_Alt_J , "GrKey_Alt_J" }, + { GrKey_Alt_K , "GrKey_Alt_K" }, + { GrKey_Alt_L , "GrKey_Alt_L" }, + { GrKey_Alt_Semicolon , "GrKey_Alt_Semicolon" }, + { GrKey_Alt_Quote , "GrKey_Alt_Quote" }, + { GrKey_Alt_Backquote , "GrKey_Alt_Backquote" }, + { GrKey_Alt_Backslash , "GrKey_Alt_Backslash" }, + { GrKey_Alt_Z , "GrKey_Alt_Z" }, + { GrKey_Alt_X , "GrKey_Alt_X" }, + { GrKey_Alt_C , "GrKey_Alt_C" }, + { GrKey_Alt_V , "GrKey_Alt_V" }, + { GrKey_Alt_B , "GrKey_Alt_B" }, + { GrKey_Alt_N , "GrKey_Alt_N" }, + { GrKey_Alt_M , "GrKey_Alt_M" }, + { GrKey_Alt_Comma , "GrKey_Alt_Comma" }, + { GrKey_Alt_Period , "GrKey_Alt_Period" }, + { GrKey_Alt_Slash , "GrKey_Alt_Slash" }, + { GrKey_Alt_KPStar , "GrKey_Alt_KPStar" }, + { GrKey_F1 , "GrKey_F1" }, + { GrKey_F2 , "GrKey_F2" }, + { GrKey_F3 , "GrKey_F3" }, + { GrKey_F4 , "GrKey_F4" }, + { GrKey_F5 , "GrKey_F5" }, + { GrKey_F6 , "GrKey_F6" }, + { GrKey_F7 , "GrKey_F7" }, + { GrKey_F8 , "GrKey_F8" }, + { GrKey_F9 , "GrKey_F9" }, + { GrKey_F10 , "GrKey_F10" }, + { GrKey_Home , "GrKey_Home" }, + { GrKey_Up , "GrKey_Up" }, + { GrKey_PageUp , "GrKey_PageUp" }, + { GrKey_Alt_KPMinus , "GrKey_Alt_KPMinus" }, + { GrKey_Left , "GrKey_Left" }, + { GrKey_Center , "GrKey_Center" }, + { GrKey_Right , "GrKey_Right" }, + { GrKey_Alt_KPPlus , "GrKey_Alt_KPPlus" }, + { GrKey_End , "GrKey_End" }, + { GrKey_Down , "GrKey_Down" }, + { GrKey_PageDown , "GrKey_PageDown" }, + { GrKey_Insert , "GrKey_Insert" }, + { GrKey_Delete , "GrKey_Delete" }, + { GrKey_Shift_F1 , "GrKey_Shift_F1" }, + { GrKey_Shift_F2 , "GrKey_Shift_F2" }, + { GrKey_Shift_F3 , "GrKey_Shift_F3" }, + { GrKey_Shift_F4 , "GrKey_Shift_F4" }, + { GrKey_Shift_F5 , "GrKey_Shift_F5" }, + { GrKey_Shift_F6 , "GrKey_Shift_F6" }, + { GrKey_Shift_F7 , "GrKey_Shift_F7" }, + { GrKey_Shift_F8 , "GrKey_Shift_F8" }, + { GrKey_Shift_F9 , "GrKey_Shift_F9" }, + { GrKey_Shift_F10 , "GrKey_Shift_F10" }, + { GrKey_Control_F1 , "GrKey_Control_F1" }, + { GrKey_Control_F2 , "GrKey_Control_F2" }, + { GrKey_Control_F3 , "GrKey_Control_F3" }, + { GrKey_Control_F4 , "GrKey_Control_F4" }, + { GrKey_Control_F5 , "GrKey_Control_F5" }, + { GrKey_Control_F6 , "GrKey_Control_F6" }, + { GrKey_Control_F7 , "GrKey_Control_F7" }, + { GrKey_Control_F8 , "GrKey_Control_F8" }, + { GrKey_Control_F9 , "GrKey_Control_F9" }, + { GrKey_Control_F10 , "GrKey_Control_F10" }, + { GrKey_Alt_F1 , "GrKey_Alt_F1" }, + { GrKey_Alt_F2 , "GrKey_Alt_F2" }, + { GrKey_Alt_F3 , "GrKey_Alt_F3" }, + { GrKey_Alt_F4 , "GrKey_Alt_F4" }, + { GrKey_Alt_F5 , "GrKey_Alt_F5" }, + { GrKey_Alt_F6 , "GrKey_Alt_F6" }, + { GrKey_Alt_F7 , "GrKey_Alt_F7" }, + { GrKey_Alt_F8 , "GrKey_Alt_F8" }, + { GrKey_Alt_F9 , "GrKey_Alt_F9" }, + { GrKey_Alt_F10 , "GrKey_Alt_F10" }, + { GrKey_Control_Print , "GrKey_Control_Print" }, + { GrKey_Control_Left , "GrKey_Control_Left" }, + { GrKey_Control_Right , "GrKey_Control_Right" }, + { GrKey_Control_End , "GrKey_Control_End" }, + { GrKey_Control_PageDown , "GrKey_Control_PageDown" }, + { GrKey_Control_Home , "GrKey_Control_Home" }, + { GrKey_Alt_1 , "GrKey_Alt_1" }, + { GrKey_Alt_2 , "GrKey_Alt_2" }, + { GrKey_Alt_3 , "GrKey_Alt_3" }, + { GrKey_Alt_4 , "GrKey_Alt_4" }, + { GrKey_Alt_5 , "GrKey_Alt_5" }, + { GrKey_Alt_6 , "GrKey_Alt_6" }, + { GrKey_Alt_7 , "GrKey_Alt_7" }, + { GrKey_Alt_8 , "GrKey_Alt_8" }, + { GrKey_Alt_9 , "GrKey_Alt_9" }, + { GrKey_Alt_0 , "GrKey_Alt_0" }, + { GrKey_Alt_Dash , "GrKey_Alt_Dash" }, + { GrKey_Alt_Equals , "GrKey_Alt_Equals" }, + { GrKey_Control_PageUp , "GrKey_Control_PageUp" }, + { GrKey_F11 , "GrKey_F11" }, + { GrKey_F12 , "GrKey_F12" }, + { GrKey_Shift_F11 , "GrKey_Shift_F11" }, + { GrKey_Shift_F12 , "GrKey_Shift_F12" }, + { GrKey_Control_F11 , "GrKey_Control_F11" }, + { GrKey_Control_F12 , "GrKey_Control_F12" }, + { GrKey_Alt_F11 , "GrKey_Alt_F11" }, + { GrKey_Alt_F12 , "GrKey_Alt_F12" }, + { GrKey_Control_Up , "GrKey_Control_Up" }, + { GrKey_Control_KPDash , "GrKey_Control_KPDash" }, + { GrKey_Control_Center , "GrKey_Control_Center" }, + { GrKey_Control_KPPlus , "GrKey_Control_KPPlus" }, + { GrKey_Control_Down , "GrKey_Control_Down" }, + { GrKey_Control_Insert , "GrKey_Control_Insert" }, + { GrKey_Control_Delete , "GrKey_Control_Delete" }, + { GrKey_Control_Tab , "GrKey_Control_Tab" }, + { GrKey_Control_KPSlash , "GrKey_Control_KPSlash" }, + { GrKey_Control_KPStar , "GrKey_Control_KPStar" }, + { GrKey_Alt_KPSlash , "GrKey_Alt_KPSlash" }, + { GrKey_Alt_Tab , "GrKey_Alt_Tab" }, + { GrKey_Alt_Enter , "GrKey_Alt_Enter" }, + { GrKey_Alt_LAngle , "GrKey_Alt_LAngle" }, + { GrKey_Alt_RAngle , "GrKey_Alt_RAngle" }, + { GrKey_Alt_At , "GrKey_Alt_At" }, + { GrKey_Alt_LBrace , "GrKey_Alt_LBrace" }, + { GrKey_Alt_Pipe , "GrKey_Alt_Pipe" }, + { GrKey_Alt_RBrace , "GrKey_Alt_RBrace" }, + { GrKey_Print , "GrKey_Print" }, + { GrKey_Shift_Insert , "GrKey_Shift_Insert" }, + { GrKey_Shift_Home , "GrKey_Shift_Home" }, + { GrKey_Shift_End , "GrKey_Shift_End" }, + { GrKey_Shift_PageUp , "GrKey_Shift_PageUp" }, + { GrKey_Shift_PageDown , "GrKey_Shift_PageDown" }, + { GrKey_Alt_Up , "GrKey_Alt_Up" }, + { GrKey_Alt_Left , "GrKey_Alt_Left" }, + { GrKey_Alt_Center , "GrKey_Alt_Center" }, + { GrKey_Alt_Right , "GrKey_Alt_Right" }, + { GrKey_Alt_Down , "GrKey_Alt_Down" }, + { GrKey_Alt_Insert , "GrKey_Alt_Insert" }, + { GrKey_Alt_Delete , "GrKey_Alt_Delete" }, + { GrKey_Alt_Home , "GrKey_Alt_Home" }, + { GrKey_Alt_End , "GrKey_Alt_End" }, + { GrKey_Alt_PageUp , "GrKey_Alt_PageUp" }, + { GrKey_Alt_PageDown , "GrKey_Alt_PageDown" }, + { GrKey_Shift_Up , "GrKey_Shift_Up" }, + { GrKey_Shift_Down , "GrKey_Shift_Down" }, + { GrKey_Shift_Right , "GrKey_Shift_Right" }, + { GrKey_Shift_Left , "GrKey_Shift_Left" } +}; + +#define KEYS (sizeof(Keys)/sizeof(Keys[0])) + +static GrTextOption opt; +static int curx = 0, cury = 0; + +static void gputc(int c) +{ + if(c == '\n' || curx + GrCharWidth(c, &opt) > GrSizeX()) { + cury += GrCharHeight('A', &opt); + curx = 0; + if(cury + GrCharHeight('A', &opt) > GrSizeY()) { + GrClearScreen(opt.txo_bgcolor.v); + cury = 0; + } + } + + if(c != '\n') { + GrDrawChar(c, curx, cury, &opt); + curx += GrCharWidth(c, &opt); + } +} + +static void gprintf(const char *format, ...) +{ + va_list ap; + char buffer[0x100], *s; + + va_start(ap, format); + vsprintf(buffer, format, ap); + va_end(ap); + + for(s = buffer; *s; s++) gputc(*s); +} + +TESTFUNC(keys) { + int spaces_count = 0; + KeyEntry *kp; + GrKeyType k; + int ok; + + opt.txo_font = &GrFont_PC8x16; + opt.txo_fgcolor.v = GrWhite(); + opt.txo_bgcolor.v = GrBlack(); + opt.txo_chrtype = GR_BYTE_TEXT; + opt.txo_direct = GR_TEXT_RIGHT; + opt.txo_xalign = GR_ALIGN_LEFT; + opt.txo_yalign = GR_ALIGN_TOP; + + gprintf("\n\n Checking GrKey... style interface" + "\n Type 3 spaces to quit the test\n\n"); + while (spaces_count < 3) { +#ifdef PENTIUM_CLOCK + int keyPressed=0; + do + { + static double old_tm = -1.0; + double tm; + unsigned s,e; + s = rdtsc(); + keyPressed = GrKeyPressed(); + e = rdtsc(); + tm = ((double) (e-s))/(1000.0*PENTIUM_CLOCK); + if (fabs(tm-old_tm) > 0.01) { + gprintf ("%5.2f ",tm); + fflush (stdout); + old_tm = tm; + } + } while (!keyPressed); +#endif /* PENTIUM_CLOCK */ + k = GrKeyRead(); + if (k == ' ') ++spaces_count; else spaces_count = 0; + + ok = 0; + for ( kp = Keys; kp < &Keys[KEYS]; ++kp ) { + if (k == kp->key) { + gprintf("code 0x%04x symbol %s\n", (unsigned)k, kp->name); + ok = 1; + break; + } + } + if (!ok) + gprintf("code 0x%04x symbol UNKNOWN\n", (unsigned)k); + } + + gprintf("\n\n Now checking getch()" + "\n Type 3 spaces to quit the test\n\n"); + spaces_count = 0; + while (spaces_count < 3) { + k = getch(); + if (k == ' ') ++spaces_count; else spaces_count = 0; + + gprintf("code 0x%02x char ", (unsigned)k); + if (ISPRINT(k)) + gprintf("'%c'\n", (char)k); + else + gprintf("not printable\n"); + + } + + gprintf("\n\n Now checking getkey()" + "\n Type 3 spaces to quit the test\n\n"); + spaces_count = 0; + while (spaces_count < 3) { + k = getkey(); + if (k == ' ') ++spaces_count; else spaces_count = 0; + + gprintf("code 0x%04x char ", (unsigned)k); + if (ISPRINT(k)) + gprintf("'%c'\n", (char)k); + else + gprintf("not printable\n"); + } +} diff --git a/thirdparty/grx249/test/life.c b/thirdparty/grx249/test/life.c new file mode 100644 index 0000000..95feca5 --- /dev/null +++ b/thirdparty/grx249/test/life.c @@ -0,0 +1,112 @@ +/** + ** life.c ---- Conway's life program + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" +#include "rand.h" + +#include +#include +#include + +TESTFUNC(life) +{ + int W = GrSizeX(); + int H = GrSizeY(); + char **map[2],**old,**cur; + int *xp,*xn,*yp,*yn; + int which,x,y,gen; + GrColor c[2]; + long thresh; + for(which = 0; which < 2; which++) { + cur = malloc(H * sizeof(char *)); + if(!cur) return; + map[which] = cur; + for(y = 0; y < H; y++) { + cur[y] = malloc(W); + if(!cur[y]) return; + } + } + xp = malloc(W * sizeof(int)); + xn = malloc(W * sizeof(int)); + yp = malloc(H * sizeof(int)); + yn = malloc(H * sizeof(int)); + if(!xp || !xn || !yp || !yn) return; + for(x = 0; x < W; x++) { + xp[x] = (x + W - 1) % W; + xn[x] = (x + W + 1) % W; + } + for(y = 0; y < H; y++) { + yp[y] = (y + H - 1) % H; + yn[y] = (y + H + 1) % H; + } + c[0] = GrBlack(); + c[1] = GrWhite(); + which = 0; + old = map[which]; + cur = map[1 - which]; + SRND((int)time(NULL)); + for(y = 0; y < H; y++) { + for(x = 0; x < W; x++) { + int ii = RND() % 53; + while(--ii >= 0) RND(); + old[y][x] = (((RND() % 131) > 107) ? 1 : 0); + GrPlotNC(x,y,c[(int)old[y][x]]); + } + } + thresh = (((unsigned long)RND() << 16) + RND()) % 1003567UL; + gen = (Argc > 0) ? 1 : 0; + do { + for(y = 0; y < H; y++) { + char *prow = old[yp[y]]; + char *crow = old[y]; + char *nrow = old[yn[y]]; + char *curr = cur[y]; + for(x = 0; x < W; x++) { + int xprev = xp[x]; + int xnext = xn[x]; + char live = prow[xprev] + + prow[x] + + prow[xnext] + + crow[xprev] + + crow[xnext] + + nrow[xprev] + + nrow[x] + + nrow[xnext]; + live = ((live | crow[x]) == 3) ? 1 : 0; + if(--thresh <= 0) { + live ^= gen; + thresh = (((unsigned long)RND() << 16) + RND()) % 1483567UL; + } + curr[x] = live; + } + } + for(y = 0; y < H; y++) { + char *curr = cur[y]; + char *oldr = old[y]; + for(x = 0; x < W; x++) { + if(curr[x] != oldr[x]) GrPlotNC(x,y,c[(int)curr[x]]); + } + } + which = 1 - which; + old = map[which]; + cur = map[1 - which]; + } while(!GrKeyPressed()); + while(GrKeyPressed()) GrKeyRead(); +} + diff --git a/thirdparty/grx249/test/linetest.c b/thirdparty/grx249/test/linetest.c new file mode 100644 index 0000000..c32b4d7 --- /dev/null +++ b/thirdparty/grx249/test/linetest.c @@ -0,0 +1,67 @@ +/** + ** linetest.c ---- test wide and patterned lines + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" + +TESTFUNC(test1) +{ + GrLineOption o1,o2,o3,o4; + int i; + for(i = 0; i < 2; i++) { + o1.lno_color = GrAllocColor(255,0,0); + o1.lno_width = 1; + o1.lno_pattlen = 4 * i; + o1.lno_dashpat = "\5\5\24\24"; + o2.lno_color = GrAllocColor(255,255,0); + o2.lno_width = 2; + o2.lno_pattlen = 6 * i; + o2.lno_dashpat = "\5\5\24\24\2\2"; + o3.lno_color = GrAllocColor(0,255,255); + o3.lno_width = 30; + o3.lno_pattlen = 8 * i; + o3.lno_dashpat = "\5\5\24\24\2\2\40\40"; + o4.lno_color = GrAllocColor(255,0,255); + o4.lno_width = 4; + o4.lno_pattlen = 6 * i; + o4.lno_dashpat = "\2\2\2\2\10\10"; + GrClearScreen(GrBlack()); + GrCustomLine(10,10,100,100,&o1); + GrCustomLine(10,50,100,140,&o1); + GrCustomLine(10,90,100,180,&o1); + GrCustomLine(110,10,200,100,&o2); + GrCustomLine(110,50,200,140,&o2); + GrCustomLine(110,90,200,180,&o2); + GrCustomLine(210,10,300,100,&o3); + GrCustomLine(210,50,300,140,&o3); + GrCustomLine(210,90,300,180,&o3); + GrCustomLine(20,300,600,300,&o4); + GrCustomLine(20,320,600,340,&o4); + GrCustomLine(20,380,600,360,&o4); + GrCustomLine(400,100,400,300,&o4); + GrCustomLine(420,100,440,300,&o4); + GrCustomLine(480,100,460,300,&o4); + GrCustomLine(600,200,500,300,&o4); + GrKeyRead(); + GrClearScreen(GrBlack()); + GrCustomBox(50,50,550,350,&o3); + GrCustomCircle(300,200,50,&o2); + GrKeyRead(); + } +} + diff --git a/thirdparty/grx249/test/makefile.bcc b/thirdparty/grx249/test/makefile.bcc new file mode 100644 index 0000000..5df14c4 --- /dev/null +++ b/thirdparty/grx249/test/makefile.bcc @@ -0,0 +1,51 @@ +# +# GRX 2.0 test programs makefile for Turbo C. Uses Turbo C make. +# +.AUTODEPEND + +!include "../makedefs.bcc" + +INCDIR= -I../include -I$(BCCROOT)\include +LIBDIR= -L$(BCCROOT)/lib + +GRX20ST = ../lib/$(GRX_LIB_SUBDIR)/grx20$(MODEL).lib + +PROGS= \ + arctest.exe \ + blittest.exe \ + circtest.exe \ + cliptest.exe \ + colorops.exe \ + curstest.exe \ + fontdemo.exe \ + fonttest.exe \ + imgtest.exe \ + life.exe \ + linetest.exe \ + mousetst.exe \ + pcirctst.exe \ + pnmtest.exe \ + polytest.exe \ + rgbtest.exe \ + sbctest.exe \ + scroltst.exe \ + spdtst16.exe \ + textpatt.exe \ + winclip.exe \ + wintest.exe + +all: $(PROGS) + +clean: + if exist *.obj del *.obj + if exist *.exe del *.exe + +spdtst16.exe: speedtst.obj + $(BCC) $(LIBDIR) $(LDOPT) -n. -espdtst16 speedtst.obj $(GRX20ST) + +.obj.exe: + $(BCC) $(LIBDIR) $(LDOPT) -n. -e$* $*.obj $(GRX20ST) + +.c.obj: + $(BCC) -c $(CCOPT) $(INCDIR) -o$*.obj $*.c + diff --git a/thirdparty/grx249/test/makefile.dj2 b/thirdparty/grx249/test/makefile.dj2 new file mode 100644 index 0000000..5a35e04 --- /dev/null +++ b/thirdparty/grx249/test/makefile.dj2 @@ -0,0 +1,87 @@ +# +# GRX test programs makefile for DJGPP v2. +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean install uninstall + +GRXVDJ2=y + +include ../makedefs.grx + +INCDIR= -I../include +GRX20 = ../lib/$(GRX_LIB_SUBDIR)/libgrx20.a + +ADDON_LIBS=-lpc +ifeq ($(HAVE_LIBTIFF),y) + ADDON_LIBS += -ltiff +endif + +ifeq ($(HAVE_LIBJPEG),y) + ADDON_LIBS += -ljpeg +endif + +ifeq ($(HAVE_LIBPNG),y) + ADDON_LIBS += -lpng +endif + +ifeq ($(NEED_ZLIB),y) + ADDON_LIBS += -lz +endif + +LIBS= $(GRX20) $(ADDON_LIBS) + +PROGS= arctest.exe \ + bb1test.exe \ + blittest.exe \ + circtest.exe \ + cliptest.exe \ + colorops.exe \ + curstest.exe \ + fontdemo.exe \ + fonttest.exe \ + imgtest.exe \ + jpgtest.exe \ + keys.exe \ + life.exe \ + linetest.exe \ + memtest.exe \ + mousetst.exe \ + pcirctst.exe \ + pnmtest.exe \ + pngtest.exe \ + polytest.exe \ + rgbtest.exe \ + sbctest.exe \ + scroltst.exe \ + speedtst.exe \ + textpatt.exe \ + winclip.exe \ + wintest.exe + +all: $(PROGS) demogrx.exe + +demogrx.exe: demogrx.o gfaz.o $(GRX20) + $(CC) $(LDOPT) -o demogrx.exe demogrx.o gfaz.o $(LIBS) -lm + +$(PROGS): %.exe : %.o $(GRX20) + $(CC) $(LDOPT) -o $*.exe $*.o $(LIBS) -lm + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c + +clean: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f *.o *.exe +else + if exist *.o del *.o + if exist *.exe del *.exe +endif + +depend.new: + $(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:.exe=.c) >depend.new + +include depend.gnu diff --git a/thirdparty/grx249/test/makefile.lnx b/thirdparty/grx249/test/makefile.lnx new file mode 100644 index 0000000..edcd46f --- /dev/null +++ b/thirdparty/grx249/test/makefile.lnx @@ -0,0 +1,113 @@ +# +# GRX test programs makefile for LINUX/console. Uses GNU make. +# +.PHONY : clean setsuid + +GRXVLNX=y + +include ../makedefs.grx + +INCDIR= -I../include + +CCOPT += -pipe + +# Enable this line for static linked test progs (default) +GRX20 = ../lib/$(GRX_LIB_SUBDIR)/libgrx20.a +# or this if you've already installed the shared libs +#GRX20 = -L../lib/$(GRX_LIB_SUBDIR) -lgrx20 + +ifeq ($(SET_SUIDROOT),y) +EXECBITS = 4755 +else +EXECBITS = 0755 +endif + +ADDON_LIBS = + +ifeq ($(USE_SVGALIB_DRIVER),y) + ADDON_LIBS += -lvga +endif + +ifeq ($(HAVE_LIBTIFF),y) + ADDON_LIBS += -ltiff +endif + +ifeq ($(HAVE_LIBJPEG),y) + ADDON_LIBS += -ljpeg +endif + +ifeq ($(HAVE_LIBPNG),y) + ADDON_LIBS += -lpng +endif + +ifeq ($(NEED_ZLIB),y) + ADDON_LIBS += -lz +endif + +LIBS= $(GRX20) $(ADDON_LIBS) -lm + +PROGS= arctest \ + bb1test \ + blittest \ + circtest \ + cliptest \ + colorops \ + curstest \ + fontdemo \ + fonttest \ + imgtest \ + jpgtest \ + keys \ + life \ + linetest \ + memtest \ + mousetst \ + pcirctst \ + pnmtest \ + pngtest \ + polytest \ + rgbtest \ + sbctest \ + scroltst \ + speedtst \ + textpatt \ + winclip \ + wintest + +all: $(PROGS) demogrx + +demogrx: demogrx.o gfaz.o $(GRX20) + $(CC) $(LDOPT) -o demogrx demogrx.o gfaz.o $(LIBS) + chmod $(EXECBITS) demogrx + +$(PROGS): % : %.o $(GRX20) + +clean: + rm -f *.o $(PROGS) demogrx + +setsuid: $(PROGS) demogrx +ifeq ($(SET_SUIDROOT),y) + chown root $(PROGS) demogrx + chmod $(EXECBITS) $(PROGS) demogrx +else + @echo "Nothing to do, SET_SUIDROOT is not set to 'y' in makedefs.grx" +endif + +.o: + $(CC) $(LDOPT) -o $* $*.o $(LIBS) + chmod $(EXECBITS) $* + +.oo: + $(CC) $(LDOPT) -o $* $*.o $(LIBS) + $(STRIP) $* + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c + +depend.new: + $(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:=.c) >depend.new + +include depend.gnu diff --git a/thirdparty/grx249/test/makefile.sdl b/thirdparty/grx249/test/makefile.sdl new file mode 100644 index 0000000..108c9ea --- /dev/null +++ b/thirdparty/grx249/test/makefile.sdl @@ -0,0 +1,96 @@ +# +# GRX test programs makefile for SDL. Uses GNU make. +# +.PHONY : clean + +GRXVSDL=y + +include ../makedefs.grx + +INCDIR= -I. -I../include + +GRX20ST = ../lib/$(GRX_LIB_SUBDIR)/libgrx20S.a + +ifeq ($(EP),x) + INCDIR += $(X11INCS) + SDLDEFS = -D__XWIN__ + SDLLIBS = -lSDL -lpthread $(X11LIBS) +else + EX = .exe + SDLDEFS = + SDLLIBS = -lSDL +endif + +ifeq ($(HAVE_LIBTIFF),y) + ADDON_LIBS += -ltiff +endif + +ifeq ($(HAVE_LIBJPEG),y) + ADDON_LIBS += -ljpeg +endif + +ifeq ($(HAVE_LIBPNG),y) + ADDON_LIBS += -lpng +endif + +ifeq ($(NEED_ZLIB),y) + ADDON_LIBS += -lz +endif + +LIBS= $(GRX20ST) $(ADDON_LIBS) $(SDLLIBS) -lm + +CCOPT += $(SDLDEFS) + +PROGS= $(EP)arctest$(EX) \ + $(EP)bb1test$(EX) \ + $(EP)blittest$(EX) \ + $(EP)circtest$(EX) \ + $(EP)cliptest$(EX) \ + $(EP)colorops$(EX) \ + $(EP)curstest$(EX) \ + $(EP)fontdemo$(EX) \ + $(EP)fonttest$(EX) \ + $(EP)imgtest$(EX) \ + $(EP)jpgtest$(EX) \ + $(EP)keys$(EX) \ + $(EP)linetest$(EX) \ + $(EP)mousetst$(EX) \ + $(EP)pcirctst$(EX) \ + $(EP)pnmtest$(EX) \ + $(EP)pngtest$(EX) \ + $(EP)polytest$(EX) \ + $(EP)rgbtest$(EX) \ + $(EP)sbctest$(EX) \ + $(EP)scroltst$(EX) \ + $(EP)textpatt$(EX) \ + $(EP)winclip$(EX) \ + $(EP)wintest$(EX) \ + $(EP)fswwtest$(EX) + +all: $(PROGS) $(EP)demogrx$(EX) $(EP)speedtst$(EX) $(EP)memtest$(EX) + +$(EP)demogrx$(EX): demogrx.o gfaz.o $(GRX20ST) + $(CC) $(LDOPT) -o $(EP)demogrx$(EX) demogrx.o gfaz.o $(LIBS) + +$(EP)speedtst$(EX): speedtst.o $(GRX20ST) + $(CC) $(LDOPT) -o $(EP)speedtst$(EX) speedtst.o $(LIBS) + +$(EP)memtest$(EX): memtest.o $(GRX20ST) + $(CC) $(LDOPT) -o $(EP)memtest$(EX) memtest.o $(LIBS) + +$(PROGS): $(EP)%$(EX) : %.o $(GRX20ST) + $(CC) $(LDOPT) -o $@ $*.o $(LIBS) + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c + +clean: + rm -f *.o $(PROGS) $(EP)demogrx$(EX) $(EP)speedtst$(EX) $(EP)memtest$(EX) + +depend.new: + $(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:$(EP)%$(EX)=%.c) >depend.new + +include depend.gnu diff --git a/thirdparty/grx249/test/makefile.w32 b/thirdparty/grx249/test/makefile.w32 new file mode 100644 index 0000000..044953d --- /dev/null +++ b/thirdparty/grx249/test/makefile.w32 @@ -0,0 +1,97 @@ +# +# GRX test programs makefile for Mingw +# Uses GNU make. +# +.SUFFIXES: .exe +.PHONY: clean install uninstall + +GRXVW32=y + +include ../makedefs.grx + +INCDIR= -I../include +GRX20 = ../lib/$(GRX_LIB_SUBDIR)/libgrx20.a + +ifeq ($(HAVE_LIBTIFF),y) + ADDON_LIBS += -ltiff +endif + +ifeq ($(HAVE_LIBJPEG),y) + ADDON_LIBS += -ljpeg +endif + +ifeq ($(HAVE_LIBPNG),y) + ADDON_LIBS += -lpng +endif + +ifeq ($(NEED_ZLIB),y) + ADDON_LIBS += -lz +endif + +LIBS= $(GRX20) $(ADDON_LIBS) + +PROGS= arctest.exe \ + bb1test.exe \ + blittest.exe \ + circtest.exe \ + cliptest.exe \ + colorops.exe \ + curstest.exe \ + fontdemo.exe \ + fonttest.exe \ + imgtest.exe \ + jpgtest.exe \ + keys.exe \ + life.exe \ + linetest.exe \ + mousetst.exe \ + pcirctst.exe \ + pnmtest.exe \ + pngtest.exe \ + rgbtest.exe \ + sbctest.exe \ + scroltst.exe \ + textpatt.exe \ + winclip.exe \ + wintest.exe + +all: $(PROGS) \ + demogrx.exe \ + speedtst.exe \ + polytest.exe \ + memtest.exe + + +demogrx.exe: demogrx.o gfaz.o $(GRX20) + $(CC) $(LDOPT) -o demogrx.exe demogrx.o gfaz.o $(LIBS) -lm -mwindows + +speedtst.exe: speedtst.o $(GRX20) + $(CC) $(LDOPT) -o speedtst.exe speedtst.o $(LIBS) -lm -mwindows -mconsole + +memtest.exe: memtest.o $(GRX20) + $(CC) $(LDOPT) -o memtest.exe memtest.o $(LIBS) -lm -mwindows -mconsole + +polytest.exe: polytest.o $(GRX20) + $(CC) $(LDOPT) -o polytest.exe polytest.o $(LIBS) -lm -mwindows -mconsole + +$(PROGS): %.exe : %.o $(GRX20) + $(CC) $(LDOPT) -o $*.exe $*.o $(LIBS) -lm -mwindows + +.c.o: + $(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c + +clean: +ifeq ($(HAVE_UNIX_TOOLS),y) + rm -f *.o *.exe +else + if exist *.o del *.o + if exist *.exe del *.exe +endif + +depend.new: + $(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:.exe=.c) >depend.new + +include depend.gnu diff --git a/thirdparty/grx249/test/makefile.wat b/thirdparty/grx249/test/makefile.wat new file mode 100644 index 0000000..a73f7e2 --- /dev/null +++ b/thirdparty/grx249/test/makefile.wat @@ -0,0 +1,288 @@ +!define BLANK "" + +############## +# Object Files + +.\life.obj : .\test\life.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bgilink.obj : .\test\bgilink.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\blittest.obj : .\test\blittest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\circtest.obj : .\test\circtest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\cliptest.obj : .\test\cliptest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\colorops.obj : .\test\colorops.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\curstest.obj : .\test\curstest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fnt2c.obj : .\test\fnt2c.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fnt2text.obj : .\test\fnt2text.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fonttest.obj : .\test\fonttest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\imgtest.obj : .\test\imgtest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\keys.obj : .\test\keys.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\arctest.obj : .\test\arctest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\linetest.obj : .\test\linetest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\modetest.obj : .\test\modetest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\mousetst.obj : .\test\mousetst.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\pcirctst.obj : .\test\pcirctst.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\polytest.obj : .\test\polytest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\rgbtest.obj : .\test\rgbtest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\speedtst.obj : .\test\speedtst.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\textpatt.obj : .\test\textpatt.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\winclip.obj : .\test\winclip.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\wintest.obj : .\test\wintest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\scroltst.obj : .\test\scroltst.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\sbctest.obj : .\test\sbctest.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\bccbgi.obj : .\test\bccbgi.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\colortst.obj : .\test\colortst.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\fontplay.obj : .\test\fontplay.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\small.obj : .\test\small.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\tellipse.obj : .\test\tellipse.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\tfill.obj : .\test\tfill.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\tmodes.obj : .\test\tmodes.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\tpoly.obj : .\test\tpoly.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +.\ttext.obj : .\test\ttext.c .AUTODEPEND + $(CC) $[@ $(CC_OPTS) + +############## +# Executables + +$(GRX_BIN_SUBDIR)\bccbgi.exe : .\bccbgi.obj $(GRXLIB) .AUTODEPEND + @%write bccbgi.lk1 FIL bccbgi.obj + @%append bccbgi.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\bccbgi $(LINK_OPTS) @bccbgi.lk1 + +$(GRX_BIN_SUBDIR)\colortst.exe : .\colortst.obj $(GRXLIB) .AUTODEPEND + @%write colortst.lk1 FIL colortst.obj + @%append colortst.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\ $(LINK_OPTS) @colortst.lk1 + +$(GRX_BIN_SUBDIR)\fontplay.exe : .\fontplay.obj $(GRXLIB) .AUTODEPEND + @%write fontplay.lk1 FIL fontplay.obj + @%append fontplay.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\ $(LINK_OPTS) @fontplay.lk1 + +$(GRX_BIN_SUBDIR)\small.exe : .\small.obj $(GRXLIB) .AUTODEPEND + @%write small.lk1 FIL small.obj + @%append .lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\small $(LINK_OPTS) @small.lk1 + +$(GRX_BIN_SUBDIR)\tellipse.exe : .\tellipse.obj $(GRXLIB) .AUTODEPEND + @%write tellipse.lk1 FIL tellipse.obj + @%append tellipse.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\tellipse $(LINK_OPTS) @tellipse.lk1 + +$(GRX_BIN_SUBDIR)\tfill.exe : .\tfill.obj $(GRXLIB) .AUTODEPEND + @%write tfill.lk1 FIL tfill.obj + @%append tfill.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\tfill $(LINK_OPTS) @tfill.lk1 + +$(GRX_BIN_SUBDIR)\tmodes.exe : .\tmodes.obj $(GRXLIB) .AUTODEPEND + @%write tmodes.lk1 FIL tmodes.obj + @%append tmodes.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\tmodes $(LINK_OPTS) @tmodes.lk1 + +$(GRX_BIN_SUBDIR)\tpoly.exe : .\tpoly.obj $(GRXLIB) .AUTODEPEND + @%write tpoly.lk1 FIL tpoly.obj + @%append tpoly.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\tpoly $(LINK_OPTS) @.tpolylk1 + +$(GRX_BIN_SUBDIR)\ttext.exe : .\ttext.obj $(GRXLIB) .AUTODEPEND + @%write ttext.lk1 FIL ttext.obj + @%append ttext.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\ttext $(LINK_OPTS) @ttext.lk1 + +$(GRX_BIN_SUBDIR)\life.exe : .\life.obj $(GRXLIB) .AUTODEPEND + @%write life.lk1 FIL life.obj + @%append life.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\life $(LINK_OPTS) @life.lk1 + +$(GRX_BIN_SUBDIR)\bgilink.exe : .\bgilink.obj $(GRXLIB) .AUTODEPEND + @%write bgilink.lk1 FIL bgilink.obj + @%append bgilink.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\bgilink $(LINK_OPTS) @bgilink.lk1 + + +$(GRX_BIN_SUBDIR)\blittest.exe : .\blittest.obj $(GRXLIB) .AUTODEPEND + @%write blittest.lk1 FIL blittest.obj + @%append blittest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\blittest $(LINK_OPTS) @blittest.lk1 + + +$(GRX_BIN_SUBDIR)\circtest.exe : .\circtest.obj $(GRXLIB) .AUTODEPEND + @%write circtest.lk1 FIL circtest.obj + @%append circtest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\circtest $(LINK_OPTS) @circtest.lk1 + + +$(GRX_BIN_SUBDIR)\cliptest.exe : .\cliptest.obj $(GRXLIB) .AUTODEPEND + @%write cliptest.lk1 FIL cliptest.obj + @%append cliptest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\cliptest $(LINK_OPTS) @cliptest.lk1 + +$(GRX_BIN_SUBDIR)\colorops.exe : .\colorops.obj $(GRXLIB) .AUTODEPEND + @%write colorops.lk1 FIL colorops.obj + @%append colorops.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\colorops $(LINK_OPTS) @colorops.lk1 + +$(GRX_BIN_SUBDIR)\curstest.exe : .\curstest.obj $(GRXLIB) .AUTODEPEND + @%write curstest.lk1 FIL curstest.obj + @%append curstest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\curstest $(LINK_OPTS) @curstest.lk1 + +$(GRX_BIN_SUBDIR)\fnt2c.exe : .\fnt2c.obj $(GRXLIB) .AUTODEPEND + @%write fnt2c.lk1 FIL fnt2c.obj + @%append fnt2c.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\fnt2c $(LINK_OPTS) @fnt2c.lk1 + +$(GRX_BIN_SUBDIR)\fnt2text.exe : .\fnt2text.obj $(GRXLIB) .AUTODEPEND + @%write fnt2text.lk1 FIL fnt2text.obj + @%append fnt2text.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\fnt2text $(LINK_OPTS) @fnt2text.lk1 + +$(GRX_BIN_SUBDIR)\fonttest.exe : .\fonttest.obj $(GRXLIB) .AUTODEPEND + @%write fonttest.lk1 FIL fonttest.obj + @%append fonttest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\fonttest $(LINK_OPTS) @fonttest.lk1 + +$(GRX_BIN_SUBDIR)\imgtest.exe : .\imgtest.obj $(GRXLIB) .AUTODEPEND + @%write imgtest.lk1 FIL imgtest.obj + @%append imgtest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\imgtest $(LINK_OPTS) @imgtest.lk1 + +$(GRX_BIN_SUBDIR)\keys.exe : .\keys.obj $(GRXLIB) .AUTODEPEND + @%write keys.lk1 FIL keys.obj + @%append keys.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\keys $(LINK_OPTS) @keys.lk1 + +$(GRX_BIN_SUBDIR)\arctest.exe : .\arctest.obj $(GRXLIB) .AUTODEPEND + @%write arctest.lk1 FIL arctest.obj + @%append arctest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\arctest $(LINK_OPTS) @arctest.lk1 + +$(GRX_BIN_SUBDIR)\linetest.exe : .\linetest.obj $(GRXLIB) .AUTODEPEND + @%write linetest.lk1 FIL linetest.obj + @%append linetest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\linetest $(LINK_OPTS) @linetest.lk1 + +$(GRX_BIN_SUBDIR)\modetest.exe : .\modetest.obj $(GRXLIB) .AUTODEPEND + @%write modetest.lk1 FIL modetest.obj + @%append modetest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\modetest $(LINK_OPTS) @modetest.lk1 + +$(GRX_BIN_SUBDIR)\mousetst.exe : .\mousetst.obj $(GRXLIB) .AUTODEPEND + @%write mousetst.lk1 FIL mousetst.obj + @%append mousetst.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\mousetst $(LINK_OPTS) @mousetst.lk1 + +$(GRX_BIN_SUBDIR)\pcirctst.exe : .\pcirctst.obj $(GRXLIB) .AUTODEPEND + @%write pcirctst.lk1 FIL pcirctst.obj + @%append pcirctst.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\pcirctst $(LINK_OPTS) @pcirctst.lk1 + +$(GRX_BIN_SUBDIR)\polytest.exe : .\polytest.obj $(GRXLIB) .AUTODEPEND + @%write polytest.lk1 FIL polytest.obj + @%append polytest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\polytest $(LINK_OPTS) @polytest.lk1 + +$(GRX_BIN_SUBDIR)\rgbtest.exe : .\rgbtest.obj $(GRXLIB) .AUTODEPEND + @%write rgbtest.lk1 FIL rgbtest.obj + @%append rgbtest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\rgbtest $(LINK_OPTS) @rgbtest.lk1 + +$(GRX_BIN_SUBDIR)\speedtst.exe : .\speedtst.obj $(GRXLIB) .AUTODEPEND + @%write speedtst.lk1 FIL speedtst.obj + @%append speedtst.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\speedtst $(LINK_OPTS) @speedtst.lk1 + +$(GRX_BIN_SUBDIR)\sbctest.exe : .\sbctest.obj $(GRXLIB) .AUTODEPEND + @%write sbctest.lk1 FIL sbctest.obj + @%append sbctest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\sbctest $(LINK_OPTS) @sbctest.lk1 + +$(GRX_BIN_SUBDIR)\textpatt.exe : .\textpatt.obj $(GRXLIB) .AUTODEPEND + @%write textpatt.lk1 FIL textpatt.obj + @%append textpatt.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\textpatt $(LINK_OPTS) @textpatt.lk1 + +$(GRX_BIN_SUBDIR)\winclip.exe : .\winclip.obj $(GRXLIB) .AUTODEPEND + @%write winclip.lk1 FIL winclip.obj + @%append winclip.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\winclip $(LINK_OPTS) @winclip.lk1 + +$(GRX_BIN_SUBDIR)\wintest.exe : .\wintest.obj $(GRXLIB) .AUTODEPEND + @%write wintest.lk1 FIL wintest.obj + @%append wintest.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\wintest $(LINK_OPTS) @wintest.lk1 + +$(GRX_BIN_SUBDIR)\scroltst.exe : .\scroltst.obj $(GRXLIB) .AUTODEPEND + @%write scroltst.lk1 FIL scroltst.obj + @%append scroltst.lk1 LIBR $(GRXLIB) + $(LINK) name $(GRX_BIN_SUBDIR)\scroltst $(LINK_OPTS) @scroltst.lk1 + +$(GRX_BIN_SUBDIR)\arctest.dat : .\test\arctest.dat + @copy .\test\arctest.dat $(GRX_BIN_SUBDIR)\arctest.dat + +$(GRX_BIN_SUBDIR)\polytest.dat : .\test\polytest.dat + @copy .\test\polytest.dat $(GRX_BIN_SUBDIR)\polytest.dat diff --git a/thirdparty/grx249/test/makefile.x11 b/thirdparty/grx249/test/makefile.x11 new file mode 100644 index 0000000..ce9e23a --- /dev/null +++ b/thirdparty/grx249/test/makefile.x11 @@ -0,0 +1,108 @@ +# +# GRX test programs makefile for LINUX/X11. Uses GNU make. +# +.PHONY : clean setsuid + +GRXVX11=y + +include ../makedefs.grx + +INCDIR= -I../include + +# Enable this line for static linked test progs (default) +GRX20X = ../lib/$(GRX_LIB_SUBDIR)/libgrx20X.a +# or this if you've already installed the shared libs +#GRX20X = -L../lib/$(GRX_LIB_SUBDIR) -lgrx20X + +ifeq ($(SET_XSUIDROOT),y) +EXECBITS = 4755 +else +EXECBITS = 0755 +endif + +ADDON_LIBS= + +ifeq ($(USE_XF86DGA_DRIVER),y) + ADDON_LIBS += -lXxf86dga -lXext +endif + +ifeq ($(HAVE_LIBTIFF),y) + ADDON_LIBS += -ltiff +endif + +ifeq ($(HAVE_LIBJPEG),y) + ADDON_LIBS += -ljpeg +endif + +ifeq ($(HAVE_LIBPNG),y) + ADDON_LIBS += -lpng +endif + +ifeq ($(NEED_ZLIB),y) + ADDON_LIBS += -lz +endif + +LIBS= $(GRX20X) $(ADDON_LIBS) $(X11LIBS) -lm + +PROGS= xarctest \ + xbb1test \ + xblittest \ + xcirctest \ + xcliptest \ + xcolorops \ + xcurstest \ + xfontdemo \ + xfonttest \ + ximgtest \ + xjpgtest \ + xkeys \ + xlife \ + xlinetest \ + xmemtest \ + xmousetst \ + xpcirctst \ + xpnmtest \ + xpngtest \ + xpolytest \ + xrgbtest \ + xsbctest \ + xscroltst \ + xspeedtst \ + xtextpatt \ + xwinclip \ + xwintest + +all: $(PROGS) xdemogrx + +xdemogrx: demogrx.o gfaz.o $(GRX20X) + $(CC) $(LDOPT) -o xdemogrx demogrx.o gfaz.o $(LIBS) + chmod $(EXECBITS) xdemogrx + +$(PROGS): x%: %.o $(GRX20X) + $(CC) $(LDOPT) -o $@ $*.o $(LIBS) + chmod $(EXECBITS) $@ + +$(PROGS:x%=%.o): %.o : %.c + $(CC) -c $(CCOPT) -D__XWIN__ $(INCDIR) $*.c -o $*.o + +.c.o: + $(CC) -c $(CCOPT) -D__XWIN__ $(INCDIR) $*.c + +.c.s: + $(CC) -S $(CCOPT) $(INCDIR) $*.c + +clean: + rm -f *.o $(PROGS) xdemogrx + +setsuid: $(PROGS) xdemogrx +ifeq ($(SET_XSUIDROOT),y) + chown root $(PROGS) xdemogrx + chmod $(EXECBITS) $(PROGS) xdemogrx +else + @echo "Nothing to do, SET_XSUIDROOT is not set to 'y' in makedefs.grx" +endif + +depend.new: + $(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:x%=%.c) > depend.new + +include depend.gnu diff --git a/thirdparty/grx249/test/memtest.c b/thirdparty/grx249/test/memtest.c new file mode 100644 index 0000000..008af03 --- /dev/null +++ b/thirdparty/grx249/test/memtest.c @@ -0,0 +1,67 @@ +/** + ** memtest.c ---- test memory driver + ** + ** Copyright (C) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "grx20.h" +#include "drawing.h" + +int main() +{ + int x, y, ww, wh; + GrColor c; + GrContext *w1, *w2, *w3, *w4; + + GrSetDriver( "memory gw 400 gh 400 nc 256" ); + GrSetMode( GR_default_graphics ); + + x = GrSizeX(); + y = GrSizeY(); + ww = (x / 2) - 10; + wh = (y / 2) - 10; + w1 = GrCreateSubContext(5,5,ww+4,wh+4,NULL,NULL); + w2 = GrCreateSubContext(15+ww,5,ww+ww+14,wh+4,NULL,NULL); + w3 = GrCreateSubContext(5,15+wh,ww+4,wh+wh+14,NULL,NULL); + w4 = GrCreateSubContext(15+ww,15+wh,ww+ww+14,wh+wh+14,NULL,NULL); + + GrSetContext(w1); + c = GrAllocColor(200,100,100); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w2); + c = GrAllocColor(100,200,200); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w3); + c = GrAllocColor(200,200,0); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w4); + c = GrAllocColor(0,100,200); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext( NULL ); +// GrSaveBmpImage( "memtest.bmp",NULL,0,0,639,479 ); + GrSaveContextToPpm( NULL,"memtest.ppm","GRX MemTest" ); + + return 0; +} diff --git a/thirdparty/grx249/test/mousetst.c b/thirdparty/grx249/test/mousetst.c new file mode 100644 index 0000000..508c65a --- /dev/null +++ b/thirdparty/grx249/test/mousetst.c @@ -0,0 +1,113 @@ +/** + ** mousetst.c ---- test mouse cursor and mouse/keyboard input + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include +#include "test.h" + +TESTFUNC(mousetest) +{ + GrMouseEvent evt; + GrColor bgc = GrAllocColor(0,0,128); + GrColor fgc = GrAllocColor(255,255,0); + int testmotion = 0; + int ii,mode; + + if(GrMouseDetect()) { + GrMouseEventMode(1); + GrMouseInit(); + GrMouseSetColors(GrAllocColor(255,0,0),GrBlack()); + GrMouseDisplayCursor(); + GrClearScreen(bgc); + ii = 0; + mode = GR_M_CUR_NORMAL; + GrTextXY( + 10,(GrScreenY() - 20), + "Commands: 'N' -- next mouse mode, 'Q' -- exit", + GrWhite(), + bgc + ); + for( ; ; ) { + char msg[200]; + drawing(ii,ii,(GrSizeX() - 20),(GrSizeY() - 20),((fgc ^ bgc) | GrXOR),GrNOCOLOR); + GrMouseGetEventT(GR_M_EVENT,&evt,0L); + if(evt.flags & (GR_M_KEYPRESS | GR_M_BUTTON_CHANGE | testmotion)) { + strcpy(msg,"Got event(s): "); +# define mend (&msg[strlen(msg)]) + if(evt.flags & GR_M_MOTION) strcpy( mend,"[moved] "); + if(evt.flags & GR_M_LEFT_DOWN) strcpy( mend,"[left down] "); + if(evt.flags & GR_M_MIDDLE_DOWN) strcpy( mend,"[middle down] "); + if(evt.flags & GR_M_RIGHT_DOWN) strcpy( mend,"[right down] "); + if(evt.flags & GR_M_P4_DOWN) strcpy( mend,"[p4 down] "); + if(evt.flags & GR_M_P5_DOWN) strcpy( mend,"[p5 down] "); + if(evt.flags & GR_M_LEFT_UP) strcpy( mend,"[left up] "); + if(evt.flags & GR_M_MIDDLE_UP) strcpy( mend,"[middle up] "); + if(evt.flags & GR_M_RIGHT_UP) strcpy( mend,"[right up] "); + if(evt.flags & GR_M_P4_UP) strcpy( mend,"[p4 up] "); + if(evt.flags & GR_M_P5_UP) strcpy( mend,"[p5 up] "); + if(evt.flags & GR_M_KEYPRESS) sprintf(mend,"[key (0x%03x)] ",evt.key); + sprintf(mend,"at X=%d, Y=%d, ",evt.x,evt.y); + sprintf(mend, + "buttons=%c%c%c, ", + (evt.buttons & GR_M_LEFT) ? 'L' : 'l', + (evt.buttons & GR_M_MIDDLE) ? 'M' : 'm', + (evt.buttons & GR_M_RIGHT) ? 'R' : 'r' + ); + sprintf(mend,"deltaT=%ld (ms)",evt.dtime); + strcpy (mend," "); + GrTextXY(10,(GrScreenY() - 40),msg,GrWhite(),bgc); + testmotion = evt.buttons ? GR_M_MOTION : 0; + } + if(evt.flags & GR_M_KEYPRESS) { + int key = evt.key; + if((key == 'Q') || (key == 'q')) break; + if((key != 'N') && (key != 'n')) continue; + GrMouseEraseCursor(); + switch(mode = (mode + 1) & 3) { + case GR_M_CUR_RUBBER: + GrMouseSetCursorMode(GR_M_CUR_RUBBER,evt.x,evt.y,GrWhite() ^ bgc); + break; + case GR_M_CUR_LINE: + GrMouseSetCursorMode(GR_M_CUR_LINE,evt.x,evt.y,GrWhite() ^ bgc); + break; + case GR_M_CUR_BOX: + GrMouseSetCursorMode(GR_M_CUR_BOX,-20,-10,20,10,GrWhite() ^ bgc); + break; + default: + GrMouseSetCursorMode(GR_M_CUR_NORMAL); + break; + } + GrMouseDisplayCursor(); + } + if((ii += 7) > 20) ii -= 20; + } + GrMouseUnInit(); + } else { + GrClearScreen(bgc); + ii = 0; + mode = GR_M_CUR_NORMAL; + GrTextXY( + (GrScreenX()/3),(GrScreenY() - 20), + "Sorry, no mouse found !", + GrWhite(), + bgc + ); + } +} diff --git a/thirdparty/grx249/test/pcirctst.c b/thirdparty/grx249/test/pcirctst.c new file mode 100644 index 0000000..f282ef3 --- /dev/null +++ b/thirdparty/grx249/test/pcirctst.c @@ -0,0 +1,109 @@ +/** + ** pcirctst.c ---- test custom circle and ellipse rendering + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" +#include + +static int stop = 0; + +static int widths[] = { 1, 2, 5, 10, 20, 50, 0 }; + +static GrLineOption Solid = { 0, 1, 0, NULL }; /* normal solid */ + +static GrLineOption *Patterns[] = { + &Solid, NULL +}; + +void drawellip(int xc,int yc,int xa,int ya,GrColor c1,GrColor c2,GrColor c3) +{ + double ddx = (double)xa; + double ddy = (double)ya; + double R2 = ddx*ddx*ddy*ddy; + double SQ; + int x1,x2,y1,y2; + int dx,dy; + int *wdt, idx; + GrLineOption *l; + + for (idx = 0, l = *Patterns; l != NULL; l = Patterns[++idx]) + for (wdt=widths; *wdt != 0; ++wdt) { + GrClearScreen(GrBlack()); + + GrFilledBox(xc-xa,yc-ya,xc+xa,yc+ya,c1); + dx = xa; + dy = 0; + GrPlot(xc-dx,yc,c3); + GrPlot(xc+dx,yc,c3); + while(++dy <= ya) { + SQ = R2 - (double)dy * (double)dy * ddx * ddx; + dx = (int)(sqrt(SQ)/ddy + 0.5); + x1 = xc - dx; + x2 = xc + dx; + y1 = yc - dy; + y2 = yc + dy; + GrPlot(x1,y1,c3); + GrPlot(x2,y1,c3); + GrPlot(x1,y2,c3); + GrPlot(x2,y2,c3); + } + + l->lno_color = c2; + l->lno_width = *wdt; + GrCustomEllipse(xc,yc,xa,ya,l); + if(GrKeyRead() == 'q') { + stop = 1; + return; + } + } +} + +TESTFUNC(circtest) +{ + int xc,yc; + int xr,yr; + GrColor c1,c2,c3; + + c1 = GrAllocColor(64,64,255); + c2 = GrAllocColor(255,255,64); + c3 = GrAllocColor(255,64,64); + xc = GrSizeX() / 2; + yc = GrSizeY() / 2; + xr = 1; + yr = 1; + while(!stop && ((xr < 1000) || (yr < 1000))) { + drawellip(xc,yc,xr,yr,c1,c2,c3); + xr += xr/4+1; + yr += yr/4+1; + } + xr = 4; + yr = 1; + while(!stop && ((xr < 1000) || (yr < 1000))) { + drawellip(xc,yc,xr,yr,c1,c2,c3); + yr += yr/4+1; + xr = yr * 4; + } + xr = 1; + yr = 4; + while(!stop && ((xr < 1000) || (yr < 1000))) { + drawellip(xc,yc,xr,yr,c1,c2,c3); + xr += xr/4+1; + yr = xr * 4; + } +} + diff --git a/thirdparty/grx249/test/pngcompo.png b/thirdparty/grx249/test/pngcompo.png new file mode 100644 index 0000000..1c85d44 --- /dev/null +++ b/thirdparty/grx249/test/pngcompo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b1c7d9d5a2180bc559ccfea2919c65a4d542c502ff23c4e7b5a06721cb65ba7 +size 15787 diff --git a/thirdparty/grx249/test/pngowl.png b/thirdparty/grx249/test/pngowl.png new file mode 100644 index 0000000..61dca1b --- /dev/null +++ b/thirdparty/grx249/test/pngowl.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0205081fcc0f706836d42aeab0aa3677a0f18ac5d273ae4896c9589534525796 +size 59535 diff --git a/thirdparty/grx249/test/pngred.png b/thirdparty/grx249/test/pngred.png new file mode 100644 index 0000000..0fed116 --- /dev/null +++ b/thirdparty/grx249/test/pngred.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b53d61b233ffd1b4147f89ad91dc8c75140ba0f9a8a390a7fb1972db73579ef4 +size 35945 diff --git a/thirdparty/grx249/test/pngtest.c b/thirdparty/grx249/test/pngtest.c new file mode 100644 index 0000000..b8b3fb1 --- /dev/null +++ b/thirdparty/grx249/test/pngtest.c @@ -0,0 +1,107 @@ +/** + ** pngtest.c ---- test the ctx2png routines + ** + ** Copyright (c) 2001 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + **/ + +#include +#include +#include "grx20.h" +#include "grxkeys.h" + +void imagen( char *nf ) +{ + GrContext *grc; + int wide, high; + char s[81]; + int w, h; + + GrQueryPng( nf,&w,&h ); + sprintf( s,"%s %dx%d",nf,w,h ); + wide = (w > 300) ? 300 : w; + high = (h > 400) ? 400 : h; + GrClearScreen( GrAllocColor( 0,0,200 ) ); + + GrBox( 10,40,10+wide+1,40+high+1,GrWhite() ); + grc = GrCreateSubContext( 11,41,11+wide-1,41+high-1,NULL,NULL ); + GrLoadContextFromPng( grc,nf,0 ); + GrDestroyContext( grc ); + + GrBox( 320,40,320+wide+1,40+high+1,GrWhite() ); + grc = GrCreateSubContext( 321,41,321+wide-1,41+high-1,NULL,NULL ); + GrLoadContextFromPng( grc,nf,1 ); + GrDestroyContext( grc ); + + GrTextXY( 10,10,s,GrBlack(),GrWhite() ); + GrTextXY( 10,50+high,"Press any key to continue",GrBlack(),GrWhite() ); + GrKeyRead(); +} + +void nopngsupport( void ) +{ + char *s[6] = { + "Warning!", + "You need libpng (http://www.libpng.org/pub/png/libpng.html)", + "and enable png support in the GRX lib (edit makedefs.grx)", + "to run this demo", + " ", + "Press any key to continue..." }; + int i; + + GrClearScreen( GrAllocColor( 0,0,100 ) ); + for( i=0; i<6; i++ ) + GrTextXY( 90,160+i*18,s[i],GrWhite(),GrNOCOLOR ); + GrKeyRead(); +} + + +int main() +{ + GrContext *grc; + + GrSetMode( GR_width_height_bpp_graphics,640,480,24 ); + + if( !GrPngSupport() ){ + nopngsupport(); + GrSetMode(GR_default_text); + exit( 1 ); + } + + imagen( "pngcompo.png" ); + imagen( "pngowl.png" ); + imagen( "pngred.png" ); + + GrClearScreen( GrAllocColor( 0,100,0 ) ); + grc = GrCreateSubContext( 191,121,191+256-1,121+240-1,NULL,NULL ); + GrLoadContextFromPng( grc,"pngred.png",1 ); + GrDestroyContext( grc ); + grc = GrCreateSubContext( 181,241,181+289-1,241+80-1,NULL,NULL ); + GrLoadContextFromPng( grc,"pngcompo.png",1 ); + GrDestroyContext( grc ); + + GrTextXY( 10,10,"Press any key to save screen",GrBlack(),GrWhite() ); + GrKeyRead(); + GrSaveContextToPng( NULL,"output.png" ); + + GrClearScreen( GrBlack() ); + GrTextXY( 10,10,"Press any key to reload screen",GrBlack(),GrWhite() ); + GrKeyRead(); + GrLoadContextFromPng( NULL,"output.png",0 ); + + GrTextXY( 10,10,"Press any key to end ",GrBlack(),GrWhite() ); + GrKeyRead(); + GrSetMode(GR_default_text); + return 0; +} diff --git a/thirdparty/grx249/test/pnmtest.c b/thirdparty/grx249/test/pnmtest.c new file mode 100644 index 0000000..a1cfdff --- /dev/null +++ b/thirdparty/grx249/test/pnmtest.c @@ -0,0 +1,103 @@ +/** + ** pnmtest.c ---- test the ctx2pnm routines + ** + ** Copyright (c) 2000 Mariano Alvarez Fernandez + ** [e-mail: malfer@teleline.es] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + **/ + +#include +#include +#include "grx20.h" +#include "grxkeys.h" + +#define FIMAGEPPM "pnmtest.ppm" +#define FIMAGEPBM "pnmtest.pbm" + +#define FIMAGEPGM "prueba.pgm" +#define FIMAGEPBM2 "prueba.pbm" +#define FSCREEN "output.ppm" + +int main(void) +{ + GrContext *grc; + int wide, high, maxval; + char s[81]; + +/* GrSetMode( GR_default_graphics ); */ + GrSetMode( GR_width_height_color_graphics,640,480,32768 ); + GrQueryPnm( FIMAGEPPM, &wide, &high, &maxval ); + sprintf( s,"%s %d x %d pixels",FIMAGEPPM,wide,high ); + GrTextXY( 10,20,s,GrBlack(),GrWhite() ); + GrBox( 10,40,10+wide+1,40+high+1,GrWhite() ); + grc = GrCreateSubContext( 11,41,11+wide-1,41+high-1,NULL,NULL ); + GrLoadContextFromPnm( grc,FIMAGEPPM ); + GrSaveContextToPgm( grc,FIMAGEPGM,"TestPnm" ); + GrDestroyContext( grc ); + GrTextXY( 10,50+high,"Press any key to continue",GrBlack(),GrWhite() ); + GrKeyRead(); + + GrClearScreen( GrBlack() ); + GrQueryPnm( FIMAGEPGM, &wide, &high, &maxval ); + sprintf( s,"%s %d x %d pixels",FIMAGEPGM,wide,high ); + GrTextXY( 10,20,s,GrBlack(),GrWhite() ); + GrBox( 10,40,10+wide+1,40+high+1,GrWhite() ); + grc = GrCreateSubContext( 11,41,11+wide-1,41+high-1,NULL,NULL ); + GrLoadContextFromPnm( grc,FIMAGEPGM ); + GrDestroyContext( grc ); + GrTextXY( 10,50+high,"Press any key to continue",GrBlack(),GrWhite() ); + GrKeyRead(); + + GrClearScreen( GrBlack() ); + GrQueryPnm( FIMAGEPBM, &wide, &high, &maxval ); + sprintf( s,"%s %d x %d pixels",FIMAGEPBM,wide,high ); + GrTextXY( 10,20,s,GrBlack(),GrWhite() ); + GrBox( 10,40,10+wide+1,40+high+1,GrWhite() ); + grc = GrCreateSubContext( 11,41,11+wide-1,41+high-1,NULL,NULL ); + GrLoadContextFromPnm( grc,FIMAGEPBM ); + GrSaveContextToPbm( grc,FIMAGEPBM2,"TestPnm" ); + GrDestroyContext( grc ); + GrTextXY( 10,50+high,"Press any key to continue",GrBlack(),GrWhite() ); + GrKeyRead(); + + GrClearScreen( GrBlack() ); + GrQueryPnm( FIMAGEPPM, &wide, &high, &maxval ); + GrBox( 10,40,10+wide+1,40+high+1,GrWhite() ); + grc = GrCreateSubContext( 11,41,11+wide-1,41+high-1,NULL,NULL ); + GrLoadContextFromPnm( grc,FIMAGEPPM ); + GrDestroyContext( grc ); + GrQueryPnm( FIMAGEPGM, &wide, &high, &maxval ); + GrBox( 110,140,110+wide+1,140+high+1,GrWhite() ); + grc = GrCreateSubContext( 111,141,111+wide-1,141+high-1,NULL,NULL ); + GrLoadContextFromPnm( grc,FIMAGEPGM ); + GrDestroyContext( grc ); + GrQueryPnm( FIMAGEPBM, &wide, &high, &maxval ); + GrBox( 210,240,210+wide+1,240+high+1,GrWhite() ); + grc = GrCreateSubContext( 211,241,211+wide-1,241+high-1,NULL,NULL ); + GrLoadContextFromPnm( grc,FIMAGEPBM2 ); + GrDestroyContext( grc ); + GrTextXY( 10,20,"Press any key to save screen",GrBlack(),GrWhite() ); + GrKeyRead(); + + GrSaveContextToPpm( NULL,FSCREEN,"TestPnm" ); + GrClearScreen( GrWhite() ); + GrTextXY( 10,20,"Press any key to reload screen",GrWhite(),GrBlack() ); + GrKeyRead(); + + GrLoadContextFromPnm( NULL,FSCREEN ); + GrTextXY( 10,20,"Press any key to end ",GrBlack(),GrWhite() ); + GrKeyRead(); + + GrSetMode(GR_default_text); + return 0; +} diff --git a/thirdparty/grx249/test/pnmtest.pbm b/thirdparty/grx249/test/pnmtest.pbm new file mode 100644 index 0000000..02760f2 Binary files /dev/null and b/thirdparty/grx249/test/pnmtest.pbm differ diff --git a/thirdparty/grx249/test/pnmtest.ppm b/thirdparty/grx249/test/pnmtest.ppm new file mode 100644 index 0000000..9d81ce2 --- /dev/null +++ b/thirdparty/grx249/test/pnmtest.ppm @@ -0,0 +1,4 @@ +P6 +227 149 +255 +0/-0/-10.21/51.51.62/62/83/83/:3-:3-:3-:3-:3-:3-:2/91.91.80-80-91.91.:2/80-80-80-80-80-80-80-80-6.+6.+6.+5-*5-*4,)4,)4,)4,)4,)4,)4,)4,)4,)4,)2-)/*$/,%/,%0-&1.'2/(30)30)63,63,74-85.85.96/:70:7.A:0B<0D>2F@4IA4JB5KC6KC6MD5MD5OC3NB2OC3OC3PD4RE5R?1Y?2b@4nB5}E6‹H8™G9£F7¯G:¸G9¾E:ÅG;ÇG>ÊG?ËH@ÐE@çFLíCLëDKëEIîCIïBDñ>Bô=Aø;A÷:@ô:?ð×?<ËA7»=/µ@.µ@.´?-´?-³@-²?-¯@-­@,ªA,¦A-¢B,Ÿ@*›A)˜@*–A,”>-’?/’?/‘>.‘>,=+’<+’<+”?+”?+”=*”=*”=*•>+–?,–@/–?6•>5—=2Ÿ?1©B3³D3¼D4¿D4¹?0µA2¬F8žH;‡H9oA2T8*C3&=5295495473271160050-50-72/72/72/61.61-50,50,41,//-.0-//-//-0/-0/-2.-2.-5,-4+,4*+3)*7(+=.1E69P:0U?1^A3jC4xD6„E4’E5œC3§C4¯A4µA4¼B7ÀD:ÄE<ÅF=ÍC@áEIçBIèCIêDHíDGïBDó@Cö?Cø;A÷:@ô:?ðÕ@<Ê@6¹>/µ@.´?-´?-´?-²?,°?-¯@-­@,©@+¦A-¡A+Ÿ@*›A)˜@*–A,”>-’?/‘>.‘>.‘>,=+’<+’<+”?+“>*”=*”=*”=*•>+–?,–@/”@5•>5˜>3 >1«A3µD4½C4¿D5»A2·C6¬F8œI;…G:l@3S9*B4)>63:6595484382271161.61.72/72/72/61.61-50,50,41,//-.0-//-//-0/-0/-2.-2.-3--5,-4*+3)*5)+<-0C47N8:d>=vEA†JINLšTV¤aj¥l}rŽ‘{¢†€®…¹{„»ou©[[QHuOCiOFeOG_PH_RN_[Yfnotƒ‡ˆ”™•™ž—š ”™‘ƒ~ojkY][LVSJXSZVRaXQa/.,/.,0/-10.40-40-51.51.72.72.72.72.92,92,92,92,91.80.7/-7/-7/-7/-80.91/80.80.80.80.80.80.80.80.6.,5-+5-+5-+4,*4,*4,*4,*5-+5-+5-+5-+5-+5-+5-+3.*2-'1.'2/(30)30)41*41*52+63,63,63,74-85.96/96/:7.?8.@:.B<0D>2G?4H@5H@3H@3I@1I@1K?1K?1K?/L@0MA1NB2MA1QA1YB2dC2qC3|C2‡B2’A0˜<- :+§;.¯=2µ@6ºD:¿F=ÅD>ÙCEá@FãBGçBFêDFðCEôADø?Dú;@ù:?õ;@ð=@è@@ÜA=Ñ@;Æ@5·=.³@-³@-²?,²?-°?-¯>,­@,ª?-§@-¥@,¡A+A,š?*˜@*•@+”>-‘>.‘>.‘>.=+=+=+=+‘>,‘>,’<+’<+“=,“=,”?+•?.•A6–?5š>3£>2¯A4¹C5¿D5ÁC5ÀD8¸F;®I=™J=G;h@4Q:,B5,?74=77<66:4494183072/72/62/62/62/51.52-41,41,21,.0-,1-.0-.0-//-//-0/-2.-5//4..5,-4*+4*+9-/>24I56[97l?9|E@†IDOM˜[`›fv”mˆŒwžƒ}­}‚¹u~·fm¤TV‰MEvLAkMAeOFcQHcMH^NK\[[eqty…‰ˆ‡Œ†Šˆ…†Š|xzlfiXZ[MVSLZU[ZT`[S`.-+/.,/.,0/-3/,40-40-40-61-61-61-61-81+81+81+81+7/-7/-6.,6.,6.,6.,7/-7/-80.80.80.80.80.80.80.80.5-+5-+5-+4,*4,*4,*3+)3+)6.,6.,6.,6.,6.,6.,6.,4/,30+30)30)41*41*52+52+52+52+52+63,74-85.85.96/96->7-?9-@:.B<0E=2E=2F>1F>1G=1G>/H<.I=/I=/J>.L@0JA0KD2NE4UD4^D3iD2sB1~A/†?-Œ9)”9'9*£<-¬@3³E8¸H<ÁF>ÒDCÚACÞBCâDCçCDìBCó@C÷?Aú;@ù:?õ;@î>@åA@ÚB=Í@9Â@3µ=-°@,°@,°@,¯>,®?,®?,¬?+©@-¦?,£@+ @*œ@+˜@*–@)”?*‘>,‘>.‘>.=-=+=+<*<*=+=+<*<*’<+‘>,”>-’?-•A6–?5œ>2¦@4²B6¼C8ÁC7ÂB7ÂF<ºJ?¬L@—K>|F:b@4L:.A7-@85>96=77<74:5294183083062/62/62/32.52-21,21,12--2.-2./1./1.00.00.10.10.5106005//5,-4+,6,-:01D22T71c;3qA7{E;‚HD‰RU_l‹i‚ƒs˜}y«x}µowµ`f¢QR‹LEyL@pL@hPEgQFfLC^GBVMLZ^^fjnquyxx}wz€vwzokoa`bTWYLTTL]WY]V]]V^------.-+/.,0/-10.3/,40-3/,3/,4/+4/+4/+4/+6/)6/)4/,4/,3.+3.+3.+3.+4/,4/,50-50-50-50-50-50-50-50-3.+3.+2-*2-*2-*1,)1,)1,)4/,4/,4/,4/,4/,4/,4/,4/,41,41,41,41,41,52-52-52-52-52-63.63.74/85096196/<5-=6,?8.@9/B:/C;0C;0C;.D:.D:.F:.G;-H<.I=/J>0I@1JG6MH5RG5YF5bE3jD1uB/}>,‚;)‹:)“:*š=,£B2¬F8²J=»I?ÌGBÔDCØDBÝEBâBBéAAð=@ô<>ù:?ø:<ô<>í?>áB>ÓC:ÅA5¹?0²?-®?,®?,®?,­>-¬>-¬>-ª?-¨>.¤?- ?,ž?+š?,—?+•>*“>*‘>,?.>->->-Ž=,Ž=,Ž=,Ž=,Ž=,Ž=,Ž=,<,>-‘>.?.”B4—A4@1¨@3¶A7¿C9ÅB8ÄA7¾C;·H?¦LCJ@tE;Z>2E9-<5+@93@85?75>63=52<4194083/62/43/43/23.32.12-12-02--2.,2.-2.-2./1./1.00.10.3205105104..2,,4+,7./=/.N5.Y9.e=1n@3sB;yKK€Zeƒg€p—zxªu{·ks´_d¦TT”OGƒLBwNAmNBhMAeJA`GBYGFXKKWMPU]cc`fbbia`f\Z`TW[MUXMXXP^YV`WX`WZ,,,,,,.-+.-+/.,0/-3/,3/,2.+2.+3.*3.*3.*3.*5.(5-*3.+3.+2-*1,)1,)2-*3.+3.+3.+3.+3.+3.+3.+3.+3.+3.+2-*2-*2-*2-*1,)1,)1,)0+(3.+3.+3.+3.+3.+3.+3.+3.+41,41,41,41,41,41,41,41,41,52-52-63.74/85085085.;4,<5+=6,>7-@7.A9.A9.A9.C9/C9-E9-F:.G;/H<.J>0HA1JG6IH6NG5VF6\E3dC2n@0v>-{<+‚;)Œ;*”=,œ@1£F5ªJ:´J=ÄH@ÌEAÑFAÖE@ÞCAä@>ì>?ñ:<÷;<ô:;ð<=é@=ÜC=ÍC8¾@2±>,®?,«@,ª?+ª?+ª?-©>,©>,¨?,¥>-¢?, ?,›>,—?+•>*“>)‘?*>+>->->-Ž=,Ž=,Ž=,<+Ž=,‹<+<+‹<+‹<-Œ=,>/Ž?.”B4—A2 @2¬B5¹C9ÂC:ÅB:ÂA;ºA9±I@£NGNEoG=S?4A;/96-@93A75?74>63<4194083/74/43/43/34/23.23.02-02-.3--3/-3/.3/.3/02/02/11/11/21/32032040/2.-1-,4..8.,G4-O4)X8+`<0e?6mGFyYd‚k…€uŸ||²w|¼nu»dh¯[[¡RMLB~OArL@hI=cH>`HB^ECX@BO;@FBGJDMJJQJJQIIQFKQEOUIVWO^YS`YS`XU++++++,,,---/.,/.,0/-0/-1-*1-*1-*1-*2-)2-)2-)2-)2-*2,,1++1++1++1++2,,2,,1++1++1++1++1++1++1++1++2,,2,,2,,1++1++1++0**0**3--3--3--3--3--3--3--3.+41,41,41,30+30+30+30+30+41,41,52-63.74/74/85085.:3+;4,<5-=6.?6/?6-?6-?7,B8.B8.E8/E9-G;/H<0J>2H@3HE6GF4KE5QD4XC2_B2f?.n=,v=,|:*…9)Œ;*“=.›B2¢F7¬F8»F<ÂF>ÉF>ÐE>ÙD@âC?ê@@ð>>ò::ñ;:ì<<äA<ÖC;ÆD6µ@/ª=)ª?-©@-©@-¨?,¨>.¨>.§=-¥>-£=. ?.ž?-š?-–?,“>*‘?*>)>+>->-Œ=,Œ=.Œ=.‹<-‹<-‹<-Š=-Š;,‰<,Š.‹=0Œ?/’C2˜B1¡A1®B6¼C:ÂC<ÄC=ÀC=¹FA²QJ¥XRXQsRIWI>CC793@72>71=60:5/94.83/63.43.43.34/13.13..3-.3-.3--3/-3/-3/-3/.3/.3/02/02/00.11/22021/0/-/.,2.-4/,?0+D0)K3)T8-Z<4dFFu]jƒs‰€«…„¾~ƒÇtzÆmp½ce¯VSšLC‚K?qI_FB]DBW?AN;?H:BE>HGDMHGQIGQHJRGNVKUXM^ZOaYNaXO++++++,,,,,,.,-/.,0/-0/-1-*1-*1-*1-*2-)2-)2-)2-*2,,1++1++0**0**1++1++2,,0**0**0**0**0**0**0**0**2,,2,,2,,1++1++0**0**0**2,,2,,2,,2,,2,,2,,2,,2,,3/,30+30+30+30+30+30+30+41,41,52-63.63.74/85085092,:3+;4,<5->5.>5.>5.>5,B8/B8.E8/E8/G:1I=1J>2I?3FC4FC4JB5OA4TA2\@2b>0j<-q<.w9*}8)…8(Œ:,•=/›B4¤B5²F:ºE;ÁF>ÊG?ÔG@ÞFAçCAîB@í;;ë;;ç>;ßB;ÑD:¿D4¯@-¤>(¦A-¦A-¥@,¥@.¥@.¤?-¤?-¤>/¢>.Ÿ@.œ?.˜?-•>+‘?*>)>+>->->-Œ=,Œ=.‹<-‹<-Š=-Š=-ˆ<.ˆ<.ˆ<.ˆ/ˆ>1‹?1‘D2–C1¢B4­C6ºC;ÁD>ÁD>»EA¹PL²[T¥e\‘f]u_T[UIGMACI?<92?82>71;6094.74-63.43.43.34.24/13./4..3-.3-.3--3/-3/-3/-3/.3/.3/02/02///-00.22022010.0/-0/-3/,8,,;,)C0*K70S<6^IHtbn‡z”жŒÆ„ˆÏz€ÌrxÆik¶WWŸID„E=nG^CAY@CV@DP>EKGQRKWUQ^WU`XS_UR^TT^SY_S^[LaZJaZJ,-/,-/,-/,.-------.-+.-+/.,/.,1-*0,)0,)0,)/+(/+(/+*/+*/+*/+*/+*/+*/+*0,+/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+1-,1-,2.-1-,1-,1-,1-,1-,1-,1-,1-,0,)1-*2.+3/,3/,3/,3/,3/,3/,3/,3/,3/,40-51.62/74/80-92,:3-;4.=4/>5.>5.>5.?4.?5,B5-C6.D7/F90G:1F<2G?4H@5J@6P?5T>3X<1^90b6+m9.t8-|8+ƒ9,;/“=0˜?1ž>0§A3­A4µC8¾E:ÊG=ÔG>ÞE?åC@è@?êBAæDAÚE>ÈD8·B1ªA.¢B,¢A.¡@-¢?,¢>.¡=-¡=-¢>. ?/œ<,š=,˜<-•>-“=,=+Ž=*Œ>*‹<+‹<+Š=-‰<,‰<,‰<,ˆ:-‡;-‰=/†3ˆ@2‰A5‹A4‘E5—D4£E9±I>ºG@»D>»EA¸MG´ZR¯f_£qf‘sh~rdjj^V^SIQFLLBJF=B>5<8/95,74+63,33+43.34.14-14-02-/1,,1+,1+-2.-2.-2.-2./1./1./1./1.02/02/11/11/11/11/11/40/4+0;/3A32C4/J;6]OOymy‹…Ÿ“»”–ϕك‰ÓtzÆjn·_b§Z[”LItHBdA>]>>X?BUAIVLU\U`bbqnn}xv†|rulyoguh_k_W_P]\Hb\Fc]G,-/,-/,-/,-/------.,-.-+/.,.-+0,)0,)/+(/+(/+(/+(.*).*).*).*)/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+0,+1-,1-,1-,1-,1-,1-,1-,1-,1-,1-,0,+0,)1-*2.+3/,3/,2.+2.+2.+2.+2.+2.+3/,40-51.62/80.91.:2/;4.=4/>50>50=4-?4.?4.A4.B5-C6.E80G:2H;3H>5H>5L=6O>6Q=4V;2Z90_7/h70p7.w7-9-‰9.<1–<1›=1¢@3§A3¬B5´D8¾E:ÉF<ÔE=ÛD=ßD@àE@ÞFAÔG>ÄF8²C2¥B-žB-ŸC.žB-Ÿ@.ž?-ž?-ž?-ž>.ž>.š=,™>,–=-”=,=+>+Œ>*Œ=,‹<+Š=+‰<,‰<,‰<,‡;+‡;-…<-†2†@6‡A7ˆB6“G9—E7£G<¯J@¸IB¸GA·LF³TN±d\ªqfŸ~oo|mmseZfZNXMLNAKI=EC7@=4=:188.44,11)23-23-03,/2+/1,.0+.0+.0+/1.-2./1./1./1./1./1./1.02/02/11/11/11/11/11/2015+49-7<23?53H?:^VTxr|Šˆž““¹”—Ê–Ô„‹ÏyÂqy¸kt­hnž\_€XZqSUjRWjT^hZgmfvvr‚tˆ~’‡ƒ•‰~Žv†yr€qfteZeT[ZE`Z@b\D,-/,-/,-/,-/,-/,.-------.-+.-+.-+-,*/+(.*'.*'.*',+),*+,*+,*++)*+)*+)*+)*-+,-+,-+,-+,-+,-+,-+,-+,,*+,*+-+,-+,-+,.,-.,-.,-.,-.,-.,-/-./-./-./-./.,0,+0,+1-,2.-2.-2.-2.-1-,1-,1-,1-,1-,2.-3/.40/51.80.91.:2/;30=31=4/=4/=4/?40?4.A4.A4.C60D71F93G:4H;5J;6K<7N=6P;6S:5V72[6.c60k6.t5,}7/‡9/;0”<0–<1?3 @4¢@3¨@3±C6ºD8ÅE:ÍD:ÕF@×H@ÔIBÌI?¾E:®C3¡B.œA.B/œA.œ?.›>-›>-›>-›>/›?0˜<-–=-”<.“=.>-Œ=,‹<+Š=+‰<*‰<*‰<,‡;+‡;-…<-„:-ƒ;-„<0‚<0‚<2‚>3ƒ?4…A8‡C:ˆD9”J=—H; H>¬KD²KF³LG²SM®`V­sg¦qŒz‘Ž{‚‰ws€ocqbXcUNRDMN@HI;DD8@@49;.46+/1&01)01)/0*/0*./*./*//-//-//-.0-//-//-//-//-//-//-00.00.00.00.00.00.00.1/26+97+98/4;63HE>_^Yzz|‹š”±’—¿•Ç„ŽÃ}‰»{‰¶|‹²}Œ«}ˆšwƒq~‡n}‚n~~o‚~yŽ…ƒ™‹¡”‘¨˜¥”ˆŠƒ–ƒ|{j{i\hTXX@]Y<_[@-.0-.0-.0-.0-.0-.0.......-+.-+-,*-,*.*'.*'.*'.*),*++)*+)*+)*+)**()*()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+-+,-+,-+,-+,.,-.,-.,-.,-/-./-./-./+*0,+1-,1-,1-,1-,0,+0,+0,+0,+0,+0,+1-,2.-3/.40/91/:20;31<41=31=31=31=4/>3/>3/@2/@3-A4.C60D71E82F93H94I:5J;6L:6N94Q83T50^72e60o6/x8/‚90Š:/<1”>1™?4›?4›?2Ÿ?1¥A2®B5¸D7¿E:ÇG>ËH@ÊJAÃI>¶F:ªB5žA0™@.™A-™A-˜?-—>,—>,™>,™=.—>.•<,”=,“=.=-Ž=,Š=+Š=-‰<,ˆ;)ˆ;)‡;+‡;+„;,„;,ƒ;-€;,;/€<1€<1>5ƒ@7ƒC:‡D<ˆE<”L@–H<žG>§JC®LI®QL­]Vªj^§€o¡yšš‚›ƒ†•€z‹xm{jbm]SZJQUFKO@EI:@D6;=057,13(01)/0(./).-(.-).-)/.,0/-/.,/.,/.,/.,/.,..,/.,..,0/-//-0/-//-//-//-//-2-17,:6*83-1961HJ?bfX{€z‹““£–°Œ•¶ƒ²¯…™²¤¶’¨³“¨«¤£Œ ž‡ž˜‚™}˜‰œ‹ˆ£”°š˜±›”­—‹£…›„’|k|iXfOSV;ZV9^Z=+/2+/2+/2+/2-.0-.0......------.-+-,*-,*,+),+),+),*+,*+,*++)*+)**()*()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*++)*+)*+)*,*+-+,-+,.,-.,-/-./-./-./+*0,+0,+0,+0,+0,+/+*.*)/+*/+*/+*/+*0,+1-,3/.40/901:20;31<42=32=31<20<20=20=2.?1.?1.@2/A30B5/C60D63C84D95E:6G96H94K84N50X72_60i70r7/}:1†<1Œ>2>2—@6—?5—?5—?3œ@3£C5«C6³E8ºE;½G=¾H>¹G=°D8¦A5›?0—@/—@-—@-–?.•>-”=,•<,–=/–=/•<.“;-’0->0-?1.@2/A4.?4.@51@72@93A:4B94C84F74H5/Q51X5/a6/l8-u9.€0‹=1“?5•>5“?5“?4•B4šB4 C4¥D4¬B5°D8´E:±E;ªB7¡?4š>1–>0•?.”?+“=,“=,“<+“<+”<.”<.“;-’<-<.;-Š;,‰<,‡;+‡;+†:*†:*…9)ƒ:)ƒ:+9*9-9-€<1<3?6€A8‚C<…F?ˆIBŠICŽJAG>—HCŸNJ§VR§`Z©pe¤ƒrœ”}–¡ƒ¨Šˆ§ˆƒ „~–~yˆup{jdp\]iSR^JJS@BK:>E5:@29<134,22*1.)/,'/))0**1++2,,1++1++1++1++1++0,+0,+0,+1-,1-,1-,1-,/.,/.,/.,2,.8*75(13+(56&EK1\gGu‚d†“yޛБž”Ÿš‹ž˜¥——´ž¢Å¥©Î­¥É­¦Ê°§Ë±¤È¬—¾Ÿ‹³‘ˆ°²Ž²Ž²¬Š„¡‚€™{wŽrdx]Q_ENR7QQ5SR6,03,03,03,03./1./1./1./1/////////////.,/.,.-+.-+/-..,-.,--+,,*++)*+)**()+)*+)*+)*+)*+)*+)*+)*+)*+)*+)*+)**()*()*())'()'(+)*+)*,*+-+,.,-.,-/-./-./+*/+*/+*/+*/+*.*)-)(,('0,+0,+0,+0,+1-,2.-40/40/:12;23;23<34=32<21<21;10<1/<1/>0/=/.>0->0-?1.>3/=60;60;83<94=:5>93@72C60G4.O4+Y4+d5+n8,x:-;.…;.<4‘<5>3@3A2“B1—A2™@0 >1¦@4ªB7ªB9¥@6Ÿ>5—=2•?2’?-’?-‘>,=+‘;*‘;*’<-’<-‘;.‘;.Ž;-;-Š;.ˆ:-†:,„;,…9)…9)ƒ:)‚9(‚9*9*~8,~8,€<1€=4€@7B9„E>…IAˆKFŒMFŒIAŽH@˜JF¡SO¨]X©hb©{n¤Žy™œ’§†‰¬‹‚ªˆ€¡„™€~‹wxnjxadr[ZhQQ]IITCCL;>D60-?1.=2.=4-=6.;819919:29:2;81?6/C2+J1,T2)^3*g7+o9-u=.z2¢B6¡C7žB7™?4–>2”>1”>/“=.=-<,Ž=,Œ=,Œ=.>/Ž<.Ž<.‹2>5€@6‚C:ƒG=…JB‡NE‹OGŒICŽID“PJ˜\Tžg`uiž‡už˜€”¡…ª‰‰¬‹ƒ¨‡€¡„~›zytˆoi}bby]\pUUgOO\HGRAAH8=A388.85.7/,3+)2()2()3)*4*+0*,/+*0*,0**0*,0*,2),2),3*-1+-1+-1+-0,-0,-0,-1+/4)/4*+4-%46!?F%T`8m|Qg‰™tžz¡~ˆ¡zЧ{‘¶‚›ÄˆŸËŸÉ™žÇÆš˜Á•Œ·Š‚­€…®‚Œµ‰„«‰®…‰©‚~œxvolƒfZnSJZ?GM3FJ1DF./0+.0+/0+01,01,01,12-21-32.43/43/62/51.41,3/,4/,50-50-4/,3.+2,,1-,0,+0,+.,-.,---/--/,,.++-*).))+.)/.)-/(/.)-/)-.)-.*+.*+/+*/+*-,*.-)--+-.)./*./*------.,-/-./.,0/-2.+2.+2-*4,)5-*6.+8/*:1,:1*;2+=4-=4->50>50>50=4/<3.;2-=2.<1-<1/;0.=/.>0/>0/@1.A0)@2);4*77-39-28.56.:3-?-)F*'L)'S*&Z/(`5,d<0k@0yA0@/†A1‹B3@3“=0“;/’8-“;/“=.”A1•B2”C2’A0‘>.‘;,—;0—:2’;1Œ=0ˆ?0„?/‚?.ƒ>.ˆ@1ˆ?0Š>1Š<0‰;/ˆ:.†:-ƒ;-{9+~@3w<.q7)w>-w>-v;-}?2{;/‚@4‡E9‰I?ˆLA†MB„PC‡NE‘KI—SP”bY‘paŒ}j‰‰q‰–|Šž‚¤‡¦‰Ž§Š§Œ‡¤ˆ~Ÿ‚uš{o—uiib„_[zXZsUZnSWeNPWEJK=C?6@93;0.6**3')3'+3'+1&*,*-)+***,*(),'+.(,1(-2'-3(.3(.3(02(00)10)1/*1/*0/)-1++0-(//#5,>5,>5.>5.>5.=4-<3.<3.=2.<1-;0.;0.=/.=/.>0/@1.C0*C0)A2+>4+:6-95,:3-<1-?-+D*)I*(N+'T/)Z5-_:1e>/pA/xA-€A0ˆ@2?4‘=3“:2“;19.‹.Œ@0A1A1ŽA/‘?1•;2•;2<2‹=0†>0ƒ@/?/‚?.…@1†>/‰=0ˆ<.‡;.„;,‚:,€;,x8,x<1s9-n9+s>.s>.r8*u:,}=1ƒA5‰E:‹I=‰K@†NA„PC‡NE‘JH—SR’f]Œwf„†p€“wž„¥†ˆ§ˆ§Š§§Š¤‰Ÿƒwœ}o˜ve’i`‹`Y‚ZY{X\wXZnSSaJNUCFH;C@7<737/-3*+2)*1(+.(*,*+**,+),+),-(,/)-2(02(02(02(02(10)1/*1-*3-*3-*12-12.-0,)--%8:,SXBox]€‹i‡–o†™l†žnˆ£p†¤p„¥pŠ­w“¶€™¹‡–¶„“³Œ®{†«x‚¨w‚¨yƒ¨|ƒ¦|‚¤{x’uqˆnh{eYjWMZHEL<@D5;=/12,12,12,12,23-23-43.43.54/54/85085085074/72.61-80-80-7/,6.+4/,3.+2,,1-,1-./-.0.1/-0--/,,.+*/+)./(/1'//)-/)-/)-/)-.*+.*+0,+0,+/.*/.*/.)0/*0/*0/+//-///0./0./0/-/.,1-*2-*6.+70*90+:1*<1+=3*>4+?5,?6-?6-@7.@7.?6/>5.=4-=4-=2.<1-;0.;0.;0.;0.<1/?1.C2+E0+H/+K--L,/K+.I*/E+.A-,@.*A.(E.(M.)X1*b3-g5,j:,o;-w;0=4‡<6Œ<5:4:4Š<2‡=2†>2…?3†A2‰A3ŒB5C5Ž?2=/Œ>1Š>.‡>/…>,†=.ˆ<,‰;.‰<,ˆ:-†:*ƒ;,<)~=+{<+}=1z<1v:/u;/x@1x@1v<.v;-?5‚B8‰F=‹H?‰JA‡KA‡NCŠNF‘JH˜TQ–f\ve‡…n‚‘t{¤ƒ…¨‡ˆª‰ªŒ©ŒŽ¥‰ˆŸƒš}y˜xi–ma’e\‹a\†`]‚`[|]UrVPhPFYEBP?:D93:2.3,*/)*,)**(0'(1&*1&*1&*0'*1(+0*.0+//*.-+.,+0+,0)-0(-1(-1)-01/23/..*'**"57*PUAmv[|Ši€k~“j™jƒŸn€ n~ m€¥q‡¬x¯|‹­zˆªx„©v§v§u¦w¦y¤y€¢}}›yw‘tp‡mh|cYkUMZHDH9=?299-23-23-34.34.34.45/54/54/650761961:72:72961940940:2/91.91.80-50-4/,4..4..3/03/01/01/20.1..0--/-+.0)02).0*.0*.0*.0*,/+,/+*1-,1-,0/+0/+10+10+10+10,11/1111/010.10.2.+3.+3.*92,92,;2+<3,>4+@6-@6-A7.B8/A8/B90A8/A81@70>5.>5.=2.=2.<1/;0.;0.<1/=20=2.B3.E2.L..R+0V'/U&.P'/I).C/.<1+;2)?2)G0(R/)_.*d/)i9/k;/u<3}<6…;8‰;9Š;7ˆ:6‰>8†@8†B9…B9…C7†B7‡A7‰A5ˆ@1ˆA/‡@.‡@.‡>-ˆ<,ˆ;+‰:+Š8*ˆ9*‡:*ƒ:)<){=(x>(x>*‚>1{7.z7.z<1v;-w=/|A3{@2€B7ƒE:†H=ˆJ?†J@‡MBˆODŠQHŒSJŽ\QŽh[‹tb…g€‹m~–vž|ƒ§ƒ„©‡‡ª‰‹ªŠ‹¦‡‡ ‚ƒš~}˜yq•oi”ifgfŒeg‹gd†e_~_Zw[PhPK^JBP?8D62:/.4*,/(+*%2&&5%(4%(2&(1'(/)+/+,.,-+++*+-*+-(,-(,/',/',/*+-.*+1++0+'.+"88,PUAiqYv„c{Œhyh|–iœl}Ÿmyžkz m¥r‚§t€¥q}£p}£p}¥s~¥v~¥x}¤x|¡x}Ÿzz™wuqn‡je|bWkRN[GDF9?=1:8,45/45/45/560560560761761872872;83<94<94<94<73<73<41<41;30;3083072/61.61.5106216213122011/00./1-.2,04+.4+.4+.2,.2,,2,,2,,3/.3/,3/,3/,21,21,32-32.32032032032051051.61.61-;4.<5/=4-?6-A7.B8/E8/C9/D:1D:1E;2D:1C90B8/@5/@5/>3/>3/=2.=2.=20=20>31>31@51E31M02T,4X)3W(2R)1K,1B30:6-77+:6*B4)M2)X/)^/)f:1j;3s<7z=:‚<:†<;‡;;†::‚;7>8A8B9ƒC:ƒC:…@9„@7‚C2‚C1ƒB0„?/†=.ˆ<.‰:-‹9-‰7+‡8+…9+‚:+~=+x>*v?*x>*9-|/'‚8/„>4w4+s5*}A6}C7E:€G<‚I>ƒJ?„KB†MD‡QG…WJ|aNzjQ€pYu]‚|bƒ†i†“uˆ|ƒ£~§‚‚ª…‚¬†©„¥€{ž}z™wz’pzlxlwŒkumr‰lm„gkd`rX[iRR[HHL=@@4;7,70&5*$6('5''3''1'&.)&+*(++)+-*',('+*)+*)+***,+),+),-)*,#$2*'50*86*BC5UZFfpWn}^tˆeqŠbuex˜iw›ks™htšiwŸkz¢nx lwŸmx ny£s{¥u{¥w|£wyžuzœww–tsŽom†hd{_WkPN[GCC7>:195,560560671671782782872872983:94=:5>;6>;6>;6>95>95?74?74>63=52;63:5294194184184395484373243151240/6-06-.6-06-.4..4..4..4/,40-40-40-51.32-32-43.43.43/431542540841850940:5/=60>7/@7.A8/C90D:0G:1H;2F<3F<3F<3F<3E;2C90B71A60@51@51?40>3/>31?42@53?53@72C52I35P16T/6S.5P05J22C52=90<:-=:+C7)I6(Q3)W2)]2+d3,l50v64}77‚87ƒ77‚66~75}:4}<6}>5€?9ƒ@8†?9…A8€B3€C1B1ƒ@0…=/‡;.ˆ:.‡9-…9,ƒ9,‚:,<,|=,y>,x?,|=,‡5*‹2,¡LE§XQ‹A8|90‚F;€K=yH:zJ<{M>|N?}OBQE‡UJ‚_LrkOosR|uX‡w]yb˜iŸ‹s ”z––z|‹£ˆ¨…§‚€¤~{Ÿy~™vƒ‘p…ŽoƒŽp€pp{ŽpwŒms‡kj~bfv\_hSV[GOM>GA3@6*=0';,'9+(6+'3+(/,',-'+.').().(+-(-,*/+*3)*4(*7'*7'(3($<3,E>4IG8QR@]bKgqVjyZn‚]k„\l‰]p‘bq•eo•do—eršfuŸmrœjq›itžnx¢rz¤vy¢vyŸvvštw™vu”rokj…fc|^UlON\ECC7@91;4,671782782782893893983:94:94;:5>;6?<7?<7?<7@;7@;7B:7B:7A96@85=84=84<73<73<73<74<74<74;639529338308/09/.8/080.80.80.61.61-61-61-52-52-63.63.74/74/540540841952:63<94=84@93@70A8/C90D:0G:1H<0I=1I=1J=4J=4J=4I<3F<3D:1B8/A7.A81@70@72?61?61@72@72A83?74@85B86D97G96H96H96H94E80E8/E9-E9+G9,I9*K9+Q7*Z/&d/'n3-z63ƒ98‰;9‹;:‹=;‹A>‡@:‚=6<3:3‚<4ˆ=7‰@7ƒA5B3‚@2ƒ?2ƒ=1„<0;/€/|>/}>/=/†9/1+¢<8ÍlfÙ~y­ZTŒC<ˆLAN@tJ(+C&+E$+C&(F5-LC4VQ>[YD`bJgmQiwVj{Wl‚[g‚Wf†WlŽ\o”an”an–bršfsko›jo™irœnw ty¢xxžwu›vs—su—vs’rn‹li„cb{[TmMM]CGH:E<5@707827828938938939:4:94:94;:5<;6?<7@=8@=8@=8A<8A<8C;8C;8C;8B:7?:6>95>95=84>95>95>95>95=85<73:51;30:0.:0.91.91.91/91.91.72.61-61-63.63.63.74/74/74/540651952;83<94?:4B;5B;3A8/B:/C9/E;/H<0I=1J>2J>2K>5K>5J=4J=4F<3E;2C90B8/B92B92A83@72@72A83B94A:4?82@93B;5D=7F=6G<6K<5N;4M6.N6,Q6+Q6+Q7*P9+P9)V6'f6*r6,~;3‰@9•D@›HDŸJGŸLF QJ™LDŽD;…;0„7-…7-Œ91=4ˆ>5‡>7†=6…<5…<5=4}=3z>3x@3vA3x@3z>3<3ƒ:3ˆ73‘31˜(&³=;ì|zý•’Åhc–G@‰K@xH:nMhV>lX@t[E`L€hPysQ„wUžt\´l^É__ÓV\ÙQ[×T\äouÙzx̆|À~µ•€«•}£’xŸvœŠrœŠt™u•u‘‘u‹’s†‘s‚‘r|‹ny†ju{amoWgbN_TBUE5R/(9/&7.'6/'81):/)=.+A,+F)+H(+K'+H)'TB4YQ9B?:D?;D?;E@8E>8D=7B;5B;5B;5B;5B:7B;5A:4A:4A83A83A83@72@64>71>71>71<71<71;60:5/85.85.74/74/961961961:70<71=82A:2B;1C:1D<1F<2J>2K?3L@2N@3N@5N@7N@7L?6K>5I<3H;2E;2E;2B90A8/@91?80?80?80@93@93<5/MD=M@:K:3T@9R62O0+a<6\3-`5.`4+^/'^/%f6,m=1q=0‰I=G;—I?ŸKAŸF>›>7š=6žD;¦ND¤PE¨VJ«YK¥OB™A5—;0›>6“98‘98Œ65†52†84„?8|@6r>1rB4oA2q=0v:0‚72Œ43’-1š',ÈHIèbaÅEDÍWUáyv«VO†F<„VFmR=i[AibFjeHj`En^D|dLjT’bL²m]ÑnhÛX]à;Lç-Eò+Hõ0Lö@YìI\ä[eånrâ{|Û€}Ûƒ؉‚Ãv½wº„x¶†x²ˆx­Šw¨‹y¥Œxš€o™~m˜xi“oabY„UM{IBxA>u:9:49:49:49:4:;5;<6>=8?>9>=8>=8A>9A>9B?:C@;D?;D?;FA=E@8E>8E>8E>8E>8D=5C<6C<4D;4C:1B92B92B92B92A83A83@93@93>71<71;60;6096/85.74/74/96196/96/:70<71>:1A:0B<0C;0E;/I=1J>0L@2L@2N@3N@3N@5N@7M?6J=4I<3H;2E;2E;2C:1B90@91@91@91@91A:4B92D93I81L/+V.,j76u99{;;…ECƒD?„H@…IA†G>ŽIB™NH¡PL¢OG“D7”B4šB6ŸC8 >3œ7-œ7-Ÿ=0£C5›?0™@0 E3¤G6§F6®H:¶NE´LM¯HL¥@D™9;‘98>:ƒ@8x>3o>0zI;…LA„?8„,+’).³9DÒLWÜKNßMMÊ>=À@?Ð`\³YQ„@5‚TDyaIe[@^]?ihIslOvgJ~dK–cN¼dXÖ_[æUZëANò,Eþ%Dÿ&Hÿ'Iÿ.Nù3Nò6UE8[O5cZ9gaAifEnrOz‚]z‰bt†^r‰_p‰_p‹`qŽ`u’dw”dw”dw”fs’ix–rz—xy–x~˜}ƒ„…‡ƒ›…™ƒz’zr‰om„hhd`y[TmMNaERSAVPBUOC8938938939:4;<6<=7?>9@?:@?:@?:C@;C@;C@;C@;D?;D?;FA;FA;FA;E@:E@:E@:G@8F?7JA:I@9H?8G>5F=6E<3F<3E;1D:1D:1D:1D:1D;4D;4D;4C<4?80?80<71;60:5/:5/94.94.96/96/:5/;7.>7/@9/B90C;0E;1F<0I=1K?1M?2M@0NA1M@0P?5M?4L>3K=2I<3H;2E;1D:0C:1C:1A:0A:0?;2@<3@<3D;4UD—I?–LAœNB¬RJ¾URÌOSÄLK¥@4B0 @0¥?1¥;.£7+¤8+§=/«E6¡>+˜7$:'¥>-¬A/²C2¶D:§02¯:B¹DL½LRºMR­KL–A>‚71{8/v6,x2*„1-œ37¹=GÕGWèM[âFIÏ53Ð:9½31ÈNKÆc]”J?Œ[J}cLj_CgdEtoOpQhJhN°hYäbbõQZôDQö7Iý1Jÿ2Nÿ/Mÿ*Hÿ2Oü0K÷1Jõ5Lò4Mð2Kó3Ló7Pò@XïC[îF]íIaëNcêQeèUhèVkåSjäRiãOiäNiçNlëPoòSsóVuþh…ña|å[tÕUlÍYlÉdr¨R]r-2^&'Y0,W:4Q?5B:-:8)>B1LN9VO3aV6e_?heDquT†e~ŒiwˆdxŒiu‹er‹dr‹cvŒeyhzizj€•v„›~Šž… Š’£—¨–˜©™–¦™‘¢’‡˜†zypƒmg~b^wYTmMPcGSXDXUDYVG7827828939:4;<6=>8@?:A@;BA5G=3F<2E;1D:0D:0E;1E;2D;2E<3E<5E<5@91?80=82<71;60:5/:5/:5/96/96-;7.;7,?8.@:.C;0D0K?/M@0M@0M@/M@0O?2O>4L>3K=2J<3G:1E;1D:0D;2D;2B;1@<1@<3A=4B>5F<3S81[*&‰:?¾T`ÙTeæUfãUcËJOŸ30–:/‘>0™A3®F=ÅIGÕBHÍ>@±B7§F5©B3¬@3¯?3°>3³B4´D6²G5©B/£<)¤;(©<(«:(®6&­3(¶97º9=½7>¼7<¿^õ@aøCfö@fõ?eõ?gø?hüCmÿErÿIsÿOuÿQuþUvòSqçTnåaxÖfv·Wb}15j0/X1*P8,G>/>A.;D/?G/PK._T8g`CokN||`ˆŽr‡‘v}‹qzq|s|szozŠm}Œoƒ’uˆ—z•£Šœ©•£®¦±¡¬´§±¹®°·°«µ­¡«¢” ”ƒ‘‚s„qh|c]tXSlNPdHRZCWYDYZH671671782893:;5<=7?>9@?:BA/K?1M@0M@0NA0O?/O?0O?2N=3N=3J<1I;0G;/D:0D:0D<1D<1B;1@<1A=2A?3B?6K=4\5.w32­LSÛ]iæM_å@Q×6E·&+¨1)7(’:&—<)¬@3ÃD=Ô>?Í;;±?5¨B4ª@2­?2²@5¸C9¼H;»J<¬>/ª?/¨=+¦;)ª9)°:,·;/¼<1ÊFAÎDAÐ>?Ð79Ö7<ÞBEâLNÝROÄC>ÆKCÍTLÔSMÙKJÛ?Bà5>á27Û4.Ú7.Ð1+Ï:4¿84³@9µ[P–UC{N9‚bI†kP„`F’[F­fTËrdçmhêEKò:Dê9Cç=8@?:@?:C@;DAGB>GD=GD=HC=ID>IE2I=1G=1G=1F<0F<0E;1E;1D;2C:1A:0A:0@91@91=82<71;60;60;7.;7.;7,<8-?9-A;/D0L?/M@0NA0NA0O?/O?/O?2N=3M<2L;1I;0G;/F90C9/C;0B<0B;1@<1@>2A?3B?6N;4m84—FEÄY_ÛWbßCQÞ8FÔ3;½++­1'¡8%˜:!—9 ¤;&¶>.Ã:2¾71§7,¢:-¥9-§7,¯:1¸B8ºE;·E:®>2­?0§<,¤6'ª6)¶>0ÃD;ÊG=¾8-Î@6áD?ìBBô=Aó9>ë27Þ.0Û75âGBèSLåNGÜ=9Ù10ã/2ê67Ù1(ÞÒA>ÒGBÝOMëWWíNRïDMð:Gö5F÷2Fø.Dû1Gþ7Nþ8Sý8Tý8Vþ9Wÿ;\ÿ>aÿAeÿCkþ;eýjý?mú>nø>oô=mö:jÿHrÿ;aÿ?dÿKnÿKn÷NmïUoãZnèr‚Âaj˜ILt:8\6-P9+PC2UM:^QAreUˆ|n•‚Ÿ‘¦§Ÿ¡¦Ÿ–œ˜•ž›ž§¤¦¯¬¦¬¨¢§£¦¨£µ´°ÂÁ¼ÌÉÀÑÎÅÕÐÌÕÐÍÔÎÎÕÏÑÑËÏËÆÊ¿½À°²¯˜Ÿ˜€Œ~m~k`t[WnRVjNS`FV`EX`H560560560560671893:94;:5=<7>=8A>9C@;DAHC?HC?GD=HE>ID>ID>JF=JF=MF2@@4P91r1/¨JKÁSV»>D½06Â03Á//º1)©1!£9#œ=!™;›< ¡=#¥;%¤6%ž6) 8-¢6,¥4,­81·@:¸C<²@6±B7­A4¨-Ï>-Ù5+á*&í"%ú%+ÿ*1ÿ.4í)*ç.+á3,ß4,à3,ã2,é0-ç2+Ú2%Ö6&Ð2&Ï7,Å6.½>7È`UÒq¦eSVBŠM:£WIÈf[ßd_çRTèCIõFMí@Dß??Ô@<É@8Æ@7ÑFAãMLïJNô@Kù9Hý7Hü5Hø3E÷6Gú;Mú8Pü7Rû6Rý6Uÿ6Xÿ9]ÿ;aÿkÿ?mÿ@qÿBtÿBuþBuüBtùBpÿFmúAaþEeÿKjþKkÿVtÿ_zõ]tòj~æp~Óow®^aƒCAg6/hB7sUJye\Œ}v£–­£¡²®«¶¶¶²¶¹ª¯³°·½¶½Å½ÁÊÀÃÊÃÂÊÉÆÍÕÎÖÝ×ÛâÚØçÝÛéÝÝæÚÜåØßä×ààÔÞÙÏØÊÅ˺ºº¢§£ˆ’‡t‚qexb\sW[oS[jM\iK]gL561561561560561671872983<;6=<7@=8B?:DAHE>HE>HE2G=1E=2D;2C:1C:3A:2A:4@93?74<73<71>7/>7/<8/=90>:1A:2C<2D=3H@5I?3L@2MA1NA0P@0O@-O@-L?/L>1M=0L;1J91I81E80C90@9/>:/;;/<<0=>0>?1A?0S8-‡<7Ä\[ÊZY®86«.*²1+®.%­2#¬9&¬B*ªF,¦D'£A&£A&¢<#Ÿ9# 9*£;0¦:0¦7.­<4¶C<·E;°@5«=0¨Dá;=Ö<<Í@9Á>4¶8,¹6.Ä94âHHé@Eð;Dö:Hú:Iø8G÷;Iû?NþAUÿ?Vþiÿ>lÿ>oÿ>pý>qú@rø@t÷Aq÷CjÿMmÿSs÷Jhë@`ýTsÿg…ÿe‚÷]wï_xçh{Üp}Æqx§gg^X{ZQ—~wª™’¾°­Ä¼ºÆÂÃÈÇÌÇÇÏÃÃÏËÊØÌÊØÑÊÚ×ÎßßÔäæÛéêàëíãëïåæòèæôèèðäæîáèíàéêÝçäØâÑÊÑÁ¿Â««©‘–z†xl{hbu_`rXbpVboScmT21/320431651875984984984;:5<;6==5??7AA9CC9EE;EE;HH@HH>HHLC4J@4KA5MC9LB8F=4B90E<5C:5@93?74@85?75<74<42C:5B94A96>95?:7>:7?;8@<9B?:D@7G@6J@4L@0O@-O@+L?,G@.F?/I;0K81M53K65J88F;9B?:6904,«=,­<,³=/½C4ÄF8À>1º2&Ç9+Ì8*Ð8+Ö8-Û7-â5.é3/î1-ñ.,ô.-ó0,ñ1,ê5*ã7)Ý:)Û:(Ü9&Ô3Ð3 Ï8'Æ7'¾6(ÂB5ÏSIÈNCÏSKá\Wî]ZðPRí>Cò9?÷?GêAFßCDÕAAÈ?9»<3±;/°HH>HH9H?:F=8B;5D:8A96?74?74@85@85=85;62=4/=4/=52<74=96>:9=<:>=9B?:D?9G@6J@4M@0O@-P?+L@*B?,B?.F<0H:1J65I56F35@65@<9:=6;>5@@4E<-J9)^B4€L>®QB«;- 2#¡6&£:'ž7$ž9%£>*¡;%§<(®?+³@-¶=,·9*¸6(µ7)ª9)¥:*¤9)¥;+¨>.«A1«B/«@.®?,«:(±<+¿E6ÆH9Á?1¼8+À6)Ë7+Ï7,Ð9.Ñ;-Ô8·;1®:-ª<-«=.¶E5ÆL?ÔNEÜGCã?>ï?Bú?Fþ@JøCJ÷CLúDPÿFTýBSù>Sü>XÿBaÿFhÿCiü?iù@jùBpüFvþJzÿK{ÿJzÿHtõKpñQsõ\zù_{ûXwüNqýEkúDlïEiÚKgÈ_p±nukLI~t°–‰Ì²¥äÓÉìãÜëçæêéîêçòíâóöãùûáúÿâýÿçÿÿìÿÿòþÿöþÿùûþú÷ýúõü÷ôúõòøïðôëîñèíïæëæÝàÜÖØÊÆÅ³²®ž¡šŽ“Œ‰…ˆƒ•‡‰€†Œ~/.,0/-10.21/43/540762761:94::2<<4>>6@@6BB8CC9DD:IF=IG;JH;LI8MJ7NL7NL7OL9KI:NKBTRS_^fihxmm…lkŠkhƒ`YiYQ\OGRH@KH>GG=EE93>:1=9083-94.;60<92=:3>;4?<5@<3E>4G?4I?3L@0O?0P?/P?-L?,<;&:=(?<+A;-B71A62>42;30=84B;5H94N2.Y,)l/.‡;= FE£;0¢2$Ÿ1 ¤9'¥<)ž7$ž8"¢<&¤;&ª=)±A-¶A/¹>.»<-¾:-¾-­>-­<,²?-°8(¹>.ËL=ËG:¼6*º2&É9.Ð6,Ô6+Ô8,Ö:.Ø:/Ü8.ã6/è3,ð0-ô.+ô.+ð1)ç2'Ý6&Ô8"Ò7!Ý8$Ü5#Ú9'Ú>/Ó=.È6)Å9,ËA7É<5Í>8ÙEAåKIêJJéCCì?AëCCÞCAÕD?ÍB=Â=4¶:.®8*«:*¬;+¬8)ÀD8ÔNEÝIEà@@è>A÷BIÿHPôAGô@IùCOýGTþEUú@Uû?XþA_ÿDfÿCiÿCkÿFpÿIwÿK{ÿL|ÿJzÿFxÿHwÿKtúNtÿZ|ÿa€ýUvñCdûIkÿTvÜ?\ÍI`Ø{…¸||aC;|n®ŽÕ³§óÛÑûìåúòðù÷ú÷ôýôìûúëÿÿêÿÿìÿÿîÿÿóÿÿ÷ÿÿûÿÿýüÿþûÿýùÿúøÿøöÿõöýóôûðôùðóðçêåßáÓÏξ½¹­®¨¢¥ž£™£—£«žž¦—›£–/.,/.,0/-10,21-32.54/650880991;;3==5??5AA7BB8CC9HEQPL^]bmlzzz’‚¡€‚¨€€¦{u—rkŠe_{YSmTLdMEZG@PB;2?=1@<1?;/A;-F?/H?.K?/M@/O?0O?/P>0L?/@=*?>,@=.?;/?;2>93=:5:94<94D95M51V-+j)-„28ž8C«>C¦7.¥7(¥:(ª?-¨?, 9&¡8#¤;&¥:&«<)³>,¹@/½>/Á=0Å=1Ä>2½?3¶=2²9.®8*¯9+°:,²:,³9*¶;,¹;-ÄB4ËE9È>3¾1'À2(Í9/Ö5+Ø4*Ú6-Û7-Þ7.á6,æ3,ì1*ó0,ô.+ô/)ï0(ä2&Û4$Ò6 Ð5×2Ú0Ú4$Ü<.Ö=/Ð9.Í=2ÒD:Ä5-Å60Ê;5ØD@âMIåKIÞC?Ö=8Ó@9ÎA8Ç>4¾VádtþŸ§ÓŽd92lJ>¥ynÐ¥œõÔËÿéãÿôòÿýÿÿüÿùóÿüïÿÿïÿÿðÿÿòÿÿôÿÿ÷ÿÿûýÿüûÿýúÿüøÿúøÿù÷ÿö÷ÿõöÿôøþó÷öëïìãäÚÕÒÉÆÁº¹´³´¬±´©°¶ª¶¾³°¸­¬´©10,10,0/+0/+10,21,43.54/77/880991;;3==3??5AA7DA8IE:LF:NH:PJ:RK9RM:SL:QK=OJDVTUfdqwx††¨¹“ÃÆŽ‹À‡ƒ¶{w©pmšid_[~UPnNJaKGXEBM?=B;7895296/85,85,671783891;;1>5L?6K>5F<3B92=82:946;47<59<5>:1H4-Y2-w78”?D¦>E§9<ª;0ª<+«@.¬A/©@-¥<)¦;'«>*§8$­:'µ<+¼=.Á<-Å;.Ê<0Ê=3Å?6¾>3º:/·7,·7,¸8+º8+º8+»7+ÇA5ÍC8Å8.Á1&Æ3)Ë7-Ï5+Û4+ß3)á4-â6,ã5,ç5+ì1*ð/*õ/,ö/*ò/)ì0'â2#Ù4!Ð5Ï4Ö1Ù/Ø2"Ø6)×9-Ô:0Ö?6ØE=ÖF>Í@7É<5Ë@9ÖKDÙNGÒE>Å;1Å=1Â<0ÀCòBLûIUÿJYýFXúCYûC]û@_ûBdÿElÿJsÿNzÿO|ÿLyþIvÿJwÿTÿT}ýJqùImÿStÿVtøNiëD^äF]êXkÿ–¢ÿµ¼óžŽHFk.)¦kcÍ–óÈÁÿãÞÿñðÿüýÿýÿü÷þþöÿÿöÿÿ÷ÿÿøÿÿúÿÿüÿÿýýÿýúÿüøÿûøÿùøÿø÷ÿöøÿõ÷ÿôøÿôøýñóóéêäÜÚÖÑÍÍÊÃÉÉ¿ÊÊÀÊÍÂÉÐȾȿ·Á¸65143.32.10+10+21,32-43.66.77/880::2<<2>>4@@6B@4JD8ME8OH8RK;TK:TM;SL*F@*G?*H@+IA,IB0IA4HB6HA9G@:K=?ž51§;/ª<+ª?-ª?-©>,©>*¬?+°?-«8%²9(¹:+¿9-Ã9,È:.Í:0Ï<4Ë>5Æ;4Â91Á8.Á8.Â9/Â8.Ã6,Å7-ÑC9Ð@7Ã0&Ã,#Ð7/Ö<4Ó2*à3,ä2(ç2+è3*ê3+í2+ð/*ó-*ö/*õ.)ñ0)ì1(á4$Ú5"Ñ6 Ð5Ø7#Ù3#Ö3$Õ3&Õ5)Ô8,Ô<1Ö?6ìYQáRJÓHAÌC;ÊE<ÌI?ÈE;À>1¼:*¼;(¼:*¹:)·:(¸:+¼>0¿A3ÁA6Á<3Å<6ÏA=×EEÝGHäIMëLPèBFê@CðCIùKTþNYüJZüF\üF_øA_ùBaýEiÿJpÿNwÿOzÿNxÿLvÿQ{ÿRyþOvýOtÿVyÿ]{ÿSoîD^úTlîQd÷dtÿ’žÿ‹•ôƒ‰Ç`d§MMµjgΊXÿÞÙÿïîÿúùÿüþýûÿýúÿþûÿÿûÿÿûÿÿüÿÿûýÿûûÿûøÿûøÿüùÿûúÿûúÿøúÿöøÿó÷ýñóùíïòææçÝÛߨÒÛ×ÎÝÛÏàÞÒßáÖÜãÛÏØÓÅÎÉ<94;8185052+41*41*52+63,74-85.96/;81=:1?<3A>5C?4JB7MC7PG8SJ;WK;UL=UK?SJCSJK]Wcnl‚‚‚¦‘•Åš ÚŸ¦ê¢©ñ¡¥ïž ë™›å•˜Ý”•֑ʉ‰½‚ƒ±zy¡rq‘fc~XVkPN\IGRFCLCBJ??K==G;:@;9:<94?;/C=-E@,F@*FA+EB/EC4CC7BC;AC>@ACBLCANEEOCHNAIL>HI>GDCHAA=2L:.gF7ƒOAI<Ž?2”8)¥>/©>,«>*¬?+­@,¯@-°?-±<*±8'¶8)½9*Ã9,È8-Ì8.Ò91Ô;5Ï:4Í:3Ë81Ë81Ì92Í:2Ì70Ë6/Ó<5Õ>5Ò91Ì2(Î4*Ø;2Ú<3×3*ä1*é1'ì1*î2)ð1)ò/)ô-(ö,(÷-)ô/)ð1)é3(â5'Ù6%Ò7!Ï7 Ô9%Õ8%Ó6%Ñ4%Ò4(Ó7+Ò8.Ð7/ãNGèXPçZSÚQIÌG>ÄD9¿@7¹>/¹<*¹<&¹<(¹:'¸9(º;*À>0ÃA4ÉD;Æ@7É@:ÑFCÕIHÖHGØGJßIKæFHèBDíDIõLSüQZûO]ûL]ûK`öD^÷DaùFfýIlÿNuÿOxÿOxÿPw÷VxóUvôTvüYxÿ]{ÿZwûQkòI`ýWköUgêM^ö^mâKZæTaåTa×XaÁefȃ~å«§ÿÔÑÿëèÿóòÿøùÿþÿûüÿûüÿûüÿüüþüúýýùúý÷÷ü÷ôÿú÷ÿûøÿüûÿûúÿøøÿóóýîñúëîðáäéÝÝäÙÕâÙÒæßÕëçÛñíáññåìóìÛæâÎÙÕ@=6=:3:7074-52+52+52+63,74-74-96/;81=:1?<3@=4B>3JB7MC7RF8VJ:WK;XL?:6@<1A>/C@/CB0BC3BD7?D=>D@CVCIaLRhU\o\br`dobbjd`afXWaJDlG>ƒSE•XF“J7‘@+™>+¨A.®@/®A-¯@-°A.´A/²=+°7&µ7(¼8+Â8+È8-Í6-Ñ7/Õ81Ø;4Ò72Ð72Ð72Ñ82Ô94Ô94Ó83Ó6/ÞA:Õ8/Ñ3*Ö8/Þ=5Þ=5Ú91Ü5,ç2)ë0'ï0(ñ0)ô/)÷-)÷,(÷,(÷-)ô/)î2)é4)á5'Ú7&Ô7$Ï8#Î7"Ï8%Î7$Ï6&Ð7)Ò9+Ñ7+Î4*Ë4+ãNGód\ë`YÕOFÄA7º;2µ9-¸>)¸>'¹<&¹;%º9&½9*À2ÊD9ÊA9ÎE?ÕKHÓLIÎGDÍEEÖHGãIIæCDèEHòMSøSZùR\÷O^úOaôH^õG`øGdûIiÿNrÿQxÿRyÿTzðUuïZwù^}ý^|ùUpõMgùOiÿYnÿ[mÿctðM^÷TeôO`üUgõL_äR_À^_»vqל˜úÉÅÿåãÿíëÿôôÿÿýüÿÿûÿÿûÿÿûÿþýýýýüúþùöýøõÿøõÿùöÿúùÿúùÿööüððøéìôææëÝÝèÚÙäÙÓèÞÕðèÝùóåÿúìþþòôúöáëêÓÝÜB>5A=4@<3>:1<8/:6-84+73*62)62)73*84+;60>93A<6E>6I@7MC7RF8UI9WJ:XK;ZLA[NHTIMXR`gd|~§’Ê— ãžªö¥°ÿª³ÿ«²ÿ¬´ÿ¬²üª±ùª¯ó¨¬ì©«èŸ¡Ú™šÒÁ±tr¡he’]Z‡XR~XQzYQvVOnMH_C?M?:@?;:B?8>>4@B5BE:?D=:CB>FH?LUDVnQfƒarŽisŽtvx„o€€^lŠ[c’WYžWU¦VM¦M?Ÿ@.œ9$ :$§<(¬=*®?,±@.³@-´?-¶=,¹;,º6'¾6(Ä6*Ë7-Ñ7-Ö8/Ú91Ú83×84Ø95Ù:6Ø93Ø61Ø61Ú83Ý:3æC<à=6Ú70ã@7þ[Rÿlcÿ]Tç?6å3)í2)ñ2*ô/)ô*&õ(%ø(&ø+(÷-+ó0,í2+ã1'Ú0#Ô1"Ô4$Ó:(Ì;&Ê<(Í<)Ï<*Ò:,Ò9+Ò8,Ñ7-Ú@8Ï81ÜGAôc^åXQËB<Å@;·4*·:&¶<$¹<&º<&½:(¿:+Ä<0Æ>2Ç>4ÌC;ÙPJßXRÔOJÃ?:À?:ÏHDÞHGâGEæJKïPTñRWïNVíKXñL\ùRføOf÷Ke÷JfüMlÿQsÿRvýRvôWvîXuõXuû[wÿ\xÿZsÿWnÿVkÿbuýVgÿ\mÿ[lñFXôDXÿQeîVeÆfgªieʋ網øÒÏÿëçýïîüø÷ùýüùÿÿùÿÿúÿþüþýÿþüÿûøþöôþùõÿû÷ÿùöÿöôÿööÿõõöèèæØØãÕÔÞÐÍáÖÐñçÞüôçþøèÿüéÿÿóúÿùèñðØáàC?6B>3A=4?;2=90;7.:6-95,73*73*73*84+:5/=82@;5D=5H?6LB6QE7TH8VI8WJ9YK>ZMEUJNWQ_eby{¤ŠÉ”⛦õ£®þ«´ÿ¬µÿ®¶ÿ¯·ÿ°·ÿ¯¶ü¯´ø¯²õ©ªë¢£ã˜˜ØŒŠÉ€»uq®ie c^˜`WŽ`Vˆ]TVPtMIbFCTBAIAAC<<:AB=FEACD?A?@DBEOMRWVdch†quš}¢‡}Ÿ’}œ {š¥pФ`u¬Yi¶VaºQU¸HF°@4¬;)¬<&­='¨8$¨7%«8&®9(°8'²9(µ7(¸6(»3%Â4(Ê7-Ó:2Ù<3Þ=5ß<5ß<5á>9ß<7ß<7á>9åB=èC=çB<æA;å@:æB9ä@7Ü8/Õ1(Ø6+ëI>ÿ[Oñ@6î6,ê+#î)#ø-)ÿ/-þ,+ö((ú0.õ4/ï61ç6.Þ3)Ö2&Ô2%Ï6&Ë:'È;'Ê<(Í:(Ï9*Ð7)Ñ5)Ð4(Ó9/Ï5-Ô=6åPJåTQÛLHÍB?·1(¼;(»=&½<'¾;'¾9(À8(Â:,Ä:/È>4ËB8ÕOFÜWPÒRIÃD=¿C;ÌHCÛLHßJFåMLëSRíTWëPVéNVìOZ÷VføUhùSiúRküRmÿSqÿStÿRuòMmøUtÿ\zÿ_{ÿ\vÿUoûRiûReüUf÷RbÿZhÿZhóN^øScþYißS^¶`_—^W¶}Ù©¥îÈÅýáÞùééýøõúüùùÿÿøÿÿ÷ÿýúþýÿÿýÿûûÿ÷õýøôþùõþùõþöóÿ÷öÿõõöêêêÜÛäÖÓÝÐÊßÕÌïåÛüõåÿùçÿýéÿÿïúÿøèñîÛáßEA6EA5C?4A=2?;0=9.<8-;7,84+84+73*84+:5/=82?:4C<4G>5JB7ND8RF6TG6WG7YIBZEJpW]‚cs˜r—¥z§®«²{£¸vœÀp“ÂcƒÀTnÂG\ÐK\ÑHPÄ<<º5.¸9*µ<'°<%°;'°;)²:)´;*·<,»<-À<-Ä<.Ä6*Ë8.Ó<1Ù?5ßA8á>7à<3ß:4Ü71Ù4.Ø3-Þ93æA;ìE?éB<ä=5ã<4Û4,Ø4+Û7-Ô2'Ì, Ö6*éG:õK>ò@6ï4-ð-)ö,*ú,,ü,,ø*,ð*)ì/+è2.ã5.Ü4+Ø1(Õ1'Ñ3'Í7(Ë:)Í:(Ð:)Ò;*Ó:*Ô8+Ô8,Ñ4+Ö<4Õ:5Õ<7åONíYWÙEEÂ3/À;,¿<(À;*¿:)Á9)À8(À8*À8,Æ=3ÇA6ÏJAØUKÒRGÆG>ÀD:ÇG>ÖKDØICÝLIäSPåSTâPSâMSåNWòXdöZhý[pþZrüVnúRlûQlÿQpýGmÿPvÿZ}ÿ[{ÿVrýTkþWkÿ\mûYhøZhûamö`kí]gïfnìfmÉ\_ ]W{OF˜mfÁ˜”ݺ¶ðÔÑôàßÿõôùù÷ùÿýùÿÿ÷ÿýúþýÿÿÿÿýÿÿøùüùôüùòüùôýøôÿùöÿøöùîìïäâåÚÖÛÐÊÜÒÈîäØýöäÿûèÿýçÿÿíúýôêðìÞãßIE9HD8FB6D@4B>3@<1?;0>:/:6-95,95,95,:5/<71>93@;5E>6I@7LD7OF5RE4UE5WG8WI>XMKXNW^Zqpp–€†ºŒ–Ô•¡é©õ¨°ù©±ù­³ý°·ÿ±·ÿ²¹ÿ´¸ÿ´¸ÿ¯±ü«­ø¥§òŸžê—–⌋ׂÍ}yÅum¶pgªf`ž_ZYX„QQuGGcA>Q=5DH8BT=C`@EnCJ€OU–]d«fx¿kÉnšËo˜ÉiÈ`ƒÉWxÆIgÄ;UÆ2HÙAPàEMÑ;<Æ71Ä?0½@,±:$­6"­5$®5$³5&¶7(¼8+Ã;-È/Û?0Ü@3Ü@3Ò6*æLBåJEÎ50ßGFóZ\ßIKÕA?È2ÈF9ÏOBÎPDÆH<¿C7ÁC7ÎH?ÑF?ÕJEÛPKÝROÙMLÚKMÜKPëX`ó[güaqÿauúXmõOgõMgÿNkÿOuÿRyÿUwÿTqüTmý[pÿcuÿjxÿguúboõamídlãflÙhjÎghµfa^TeG<^U©ˆÍ«©åÇÅïÚÙÿóóùøöùýüøÿÿ÷ÿÿûÿÿÿþÿÿüÿÿùúþûöûûóûúõþûöÿýùÿûøþôòøíéêßÙÞÔËÝÓÉíæÖÿøåÿþèÿÿæÿÿëøúïêïèãæßNH:MG9LF8JD6HB6F@4D=3C<2?80>7/=6.=6.=60>71@93?:4C>8EA8KC8NE6QD3RE2VF6VH;ZMGVMR[Whlk‹~‚±Š“Î’Ÿãš¦î¦®÷©¯ù­°ý¯³ý°³ÿ°´þ°³ÿ¯³ý«®û¨«ø¤§ô ¢ïšœé“•⊌ن…уÉ{u»mk¬dež_a’Y[„RQsNHbWFY_CQmBLEM˜MT¬U]¼[bÊZhÙRpâRußTuÙPlÒJbÍBWÇ8JÅ.?Ô8EãCKæGKØ>>Í>6ÌF:ÃH6¶?+·>-¸=-º<-½>/Ã?0ÊB4ÐD7ÕE:ÙE9ÚB7Û>5Ù;2Ù6-Ù5,Ú3+×3*Ô1*×4-Ú7.Ý90ß80Þ7/Ý6.Ü5,Ö/&Ù5+×7+Ï2#Í1"Ò9)Õ>-Ô;)Ø<-æD7øJAýD?ù64õ*-ö*-÷/2÷67í55â30Ú1,×0*×/,Ù0-Ù0+ã81ä91â:1â;2à<0ß=0Ü?0Ú>1Ñ7+ïWLøaZÓ;6Ñ;:æPQÜFHæPQÏ<4Ê:/Æ8,Å9,Ä:-Ä<.Ã;-À;,¾:-¾<.ÃA3ÇH9ÇI;ÂD6¾@2¼>0ÉF<ÊE<ÎIBÕPI×RMÕNKÓKK×LOéZ`ð^hüfrÿhxü]qòPeóMeýNkÿVzÿTxÿRrøTmö]qûhxûjw÷erüetó_mì`kêkrßruÃjfªd\žla}fVXH9kXJ”|r½ œÞÂÁîÖÖþîïûõõûûûûÿÿùÿÿýþÿÿþÿÿûÿÿúýÿþùûþõûüöÿþùÿÿúÿþúÿûõÿ÷òñèáäÜÑáÙÌðé×ÿúäÿÿæÿþåÿÿê÷ùëíðçèéáQK=PJ1ÃE6ÃE6ÅF7ÉE8ÎF8ÑG:×G<ÚG=Ö>3Õ;1Ö8/Õ4,Ö3*Ø4+Û4,Ú6-Û81Ý<4à=4ß<3Ý90Ü5-Ü5,Û7-Ò.$Ý;0Ú=.Í1"Æ-Î7&Ò=)Í:&Ì9'Ô8)â:/ó=9ÿ@@ÿ<>þ37ó,/ê,.á+*Ø*)Ô+(×/,Þ44ä88é99ï75ð74î73è71ã7-Ü6*×5(Ñ5&Í5(çPEÿmcÛHAÈ42×CCÓ>BêVVÙA<Ò>4Ë8.Æ6+Æ:-Æ/Á=.»9+»<-¾?0ÀA2¿A2½@.¼=.»<-ÃC6ÄD9ÈH?ÐPGÓRLÐOIÒNLÕONé^cîagûitÿnzÿduõVjõQiÿUoÿWvÿVtúXpñ^pônyöw€íksÞXañ`mñ`mìboïs}숊Ì|ªth™yjskXON:_VGƒqg¯–’ÜÀ¿ïÕØüéëþôõýûüýþÿúþÿþýÿÿýÿÿûÿÿùþÿÿûùÿõúýöÿÿúÿÿúÿÿøÿý÷ÿþöùðçíåÚéáÔôïÜÿûåÿþåÿÿãÿÿèùúêòôçîðåSM=RL4D=3B;3A:2@93A:4A96@;7A@;CC;IE9MG7OG2RF0UF1UH5WK?RHFXR^jg‚}§‰“Ä’žÚ˜¢ç¤§ö¦§ú«©ü«¬þ¬­ÿ­®þ¬®û¬®û¨¬ö¦ªô¤¨ñ£§ð¡¨î §í¤è›¢æ™žâ’šÛ‹“҆ʃ„ˆ·ƒ¨ˆyšmˆšcz©Xi»Q_ÏMYàIRèAIê=Aé=;ã>8ÝC9ÖH:ÎI8ÅF3ÂC0Å@1äTIàG?Ú;7Ø64Ø88Ø:;Ñ98È74À:/¾<.¿;.À:.Â8+Ã7*Æ4'Æ2&Î4*Ð3*Ñ3(Ô3)Ö3*Ù5,Ý6.Ü8/Þ=3Û=2Ü;1Û8/Û7-Ú6,Ø4*×3)Õ3&Ó3%Ð4%Ï6&Ò=)Ñ>*Ê9$À2È:&Ê4%Õ1'ç51ú<<ÿ=@ÿ7=÷37ê-1á-.Ù--×/.Ü43ã9:é;=ð9=ö26ø03ô01í1/ä1*Þ2(Õ1%Ï3$É1$Ñ=1új_äTLÈ95Ð@?Ë:=äRSäJHÜC=Ñ:3É6.Æ8.Å;0Â<0¿=/º;*¼?-½@.¼?-º;*º;(½;+¾<,¼>0¼>2ÀD8ÈLBÌPHÊNFÌLIÐNLèaeìaføhrÿo{ÿhx÷Zk÷UjþZrÿYsû]tîaræjtë}€ñ‡‰èwyÚ_dñgtþm|óeuëlwö‘•ì¢ŸÄ”Š¢|hjUHQSK>PJ>êDFå@DÙ8=Î65ÍB;ÈD8ÉC8ÇA5Æ>2Ã9,Â6)Â2'Æ2(Ë3(Î4*Ó5,Ø5.Ù4.Û4.Û4,äB7Ý=1Ù7,Ú6,ß9-ß9-Û5)Õ1%Ø8(Í2 Ê1!Ï9(Î8'Ç4"Ê7%ÔC0È7&Î8*×6,Þ5.æ3/î53ö:9û?>ÿLKúHFòBBì>=ê<=ç7:å26æ,1ô+1ø)/ô,.ï/.è1+à4*Ù5)Ó7(Æ0!À.ôdYë]SÏ@:ÔDCË;;ßMMêRQàHEÓ;6É6/Æ8.Æ9/Ã;-¾:+¾<,Á@-ÀA.»<)·8%¸9&½<)¾?.µ7)³7+¸>1ÁG:ÅK@ÅIAÈIBËJEåa_æ^`ñdjþnwþkuó]iðXeø]mú^sõbtèdoãlrì~ù‹ö†…éqsøryÿy†õaqàXföˆ‘ÿ´´Ð®¢ ›‡]jPDR9QT?jbU›ˆÚÀ¿òØÙöàãÿô÷ÿúýÿþÿýüÿþüÿÿýÿÿûÿþùýûÿúôÿòòþòùÿôüÿöûýòÿýôÿÿôÿÿóûõç÷ñáþùåÿýçþüãþýáÿÿêÿÿñýýóüüòXO@WP@WN?UN>TK2G?2H>2F@4GC:GE9JG8NI6RJ5UJ4UJ4VK9XNDULMZTbkhƒ{~§‰Ã‘™×˜Ÿç£¤ö¥¢ù¢¢ü¡¢ü ¤ÿ¢¨ÿ£«ÿ¤­ü¡ªõ¡©ñ¡¨ì¥¨íª©ï­©ó±©ö¬©ø ©ø—§ò’¡â–ŸÖ¦£Î¶ž¾¹…œ¸gz¿L]ÑERß>Mç;Gç?ß<=ÝEBÉ:4ÊD9ÊF:º1)ÛJEèJIéCEë>Bè;?æÚ<=Ô<;ÏB;È?7ÊD;ÑMAÍK>¿=0¸6)½9,¿7+Ã6,È5-Ë2*Ñ/*Ô/+Û2/Þ5.çA5ß9+Ù1$Ý3&å9+ç;-ß8&Õ2Ï2Ì4Ê5!Ç4"Ç4"Ê4%Í5'Ï5)Ê0&Ï2)Ñ5)Ò6*Ò4(Õ3&×3'Ü4)à2)æ3.ë52ë33é/2ç-2è-4í.5ö-3ö+/ï+,ì/-ê5.ã9,Ù7(Ð4%Ã-Ä3"çXHéYNË;3ßNIÅ41ÚHHáOPÜJJÔC@Ì;6È80Æ8,Ç9+È<+Å<*Â;(¾9&¼;(»<)º=)º=+·<,´8,µ;0¹=1»?3»?3¾@4À@5ÄA7ïjaõpiêc_ômjûqqìadôgmÿpyÿlzûhxðdoébiëdjîlnîqoîqoûy{ÿ}…ùZlücwßbpû¬¯¶ªš}‘u]rQJY:LR8snZ¥•ˆË·°íÕÓÿîðÿö÷ÿ÷ûýøüüüþþÿÿþÿÿÿþÿûÿþðÿôåþéæûêïÿîøÿöüÿôþÿóÿþñÿýñÿûîÿúêÿùæÿùãÿùáÿùáüúåÿÿõÿÿûÿÿûYPAXO@XO@VM>UL=TKÌLAÁC5¸:,·9+¹7*¿7+Æ6-Ë4-Ñ2.Ø3/á53ä84ä>2á;-Þ6)ß5&á5'á5'Ú5"Ó4Ñ9$Ë9"Ç9%Ç:&É<+Ë<,Ì8,Î4*Õ3.Ö5-Ó7+Ï7)É6&Ç4"Ë4!Ï4"Ø2$Þ2&ã0+æ.,æ,-æ,/æ-2è.3ì+.í,-ì0.è2.à4*Û5'Õ8'Ò9'Õ?.»*ÖD5Ð>1ÙF>ëVPÚB?ØBAçUVâRRÜKHÔC>Í=5É9.È9+Ç8(È;*Ä;(¿:'½<)½>+º?-¹@/¶>.²:,´;0·=0¸>1º?0½?1ÁB3ÅC5ëi\òmdçb[ðkfõolèbañklütxÿq~ÿo|öirí]fêY`ñbf÷qpþzxûvwÿx~ùRdþ[pä]nö¦©©¦“jŒkZtON_;SZ;us\©ÖĸöáÜÿõñÿúúÿúûÿûüüüüúþýûÿþúþÿõÿúíÿóáÿéáýæéÿëóÿñøÿòýÿòÿÿñÿýïÿýíÿúéÿöåûóàúòÝüôßü÷äýúóüüúÿÿý\PB[OA[OAYM?XL>WK=VJDã=?å==åAá>CàBè;?ã9<Ü68Ö66Ñ96Ì;6ÕHAÄ;1¾5+ÅA5ÍK>ÆH:»=/·8)º6)¿7)Ç7,Ï6.×50Þ71æ95é=9×3*×5*Ú6*Ü6*Ý5*Ý7)Ú:*×>,Å4!¿4¹4!¹6"¼8)½8)½3(À-%ã@;å>8Þ=3Õ<.Ì9)È7$È7"Ì7#Ò7%Õ3$×/&Ù.'Û.*Ü.-Û//Ü./Û,)ß0+à5-Ü5,Õ3&Ð4%Ð9&Ñ>*ÔA/Â1 çSEÒ;0ÚA;ÞC?èJIðTUíUTçSQãOMÝJCÖC;Ï<2Ê8+Å6&Ä7&À7%¼7&¹:'¹<*·>-µ=,²=,°:,±;/´<.µ=/·=.¹?0¾C4ÃE7Ü\Qêg]äaYðlgöpmça`ìfgójqàR^ï^kõhqòemñ`gôeiùqqþxwútuÿnuóJ]øRhä[mñœ¡£œŠa€`UoHOd=W`Aww]­¥’áÑÂÿîæÿøñÿüøÿþúþÿúûÿüûÿýûÿýùÿûóÿöèÿîÜþãÚøÞáùáèûåïüèöýëýþìýúéÿúêÿ÷æúñàôèØòçÕöëÙøñáþúñýüøÿþû\PB\PB[OAZN@YM?YM?XL>XL>UI;TH:SG9RF8RF8RF8RF8PF:LE;KGEç=Fã?FÖ:>Ñ?@ÑEDÆA<º61Å>:êZYÝABã@Cæ=@ã:=Û89Ó97Ð<8ÎA8ÏE;Â:.»2(À/¸9(½8)Â9)Ë8.Ò:/Ù80à91è;7ë>8Ø1+Ù2*Ü3,Ý5,à5-ß7.Û9.Ö=/É7(Æ:)Á<+¾<,¿;.Á;0Å<6Î95ëC@í@<ä@7Ù=1Ï9*Ç9%È:&É;%Ï<(Ð7'Ï1%Ñ1%Ô1(Ö3,Ô1,Ñ/*Ó2*Ó5,Ó7+Ð7)Í5'Ê7%Ì;(Ì>*Ì;(Ï<,ô^PàF<Ò3/Ò.,æ@@ûWXÿusÿroÿjgö^YçPGÕA7Ç5(½. Ä8'À8(»8&¸;)·<,µ=-²=,°<-¯;.­<.°.¼B3ÀF7ËMAß`Wâa[ôpløtræ`aä]aæ]dÖHTçYeógrôgoöelükpþsvþvvûpsûenñDXôKbåXkë’– •ƒ_zYQlCSh?\gEy|_°ª”çÜÊÿõèÿùðÿûñþþôýÿ÷ûÿúùÿúöÿøòüóêûëÚøÞÎóÒÊëÌÏìÎ×îÒàðÖéóÛò÷áöõáûöãüõãõìÛíáÑéÝÍíáÑñèÙüõíü÷ñþùó\PB\PB[OA[OAZN@YM?YM?YM?WK=VJ@Ð@?ÐIE¿>8³2,ÈC<àUPÜDCáACã?@á>?Ú?=Ô@<ÑD;ÏF<Ç=2À8*½5)½9*¿=-¿=-½;+½<)Â:*Ç;*Ï;/Õ;/Û8/à8/ç83é:5æ95ä52ä20æ21ç32æ40Ý2+Ô0'Ë1'Ë7-È:0Ä7.Á4-Ã40Ì:;Ý?@ë8;í76ä71Ø5,Ì4&Æ5"Ä7#Å:%Ë=)Ë8&Ì4&Î5'Ô8,Ô:0Ó9/Ð8-Ð>1Ê;-Å8'Ä7%Æ9'Ç<)Ç<)Ç:(Í>-Í:*Ø>2áC:Ô/-ä::à24ß56×53Ö;6ÞC>åKCêQIêSHèTHäUGË?0Ä?.¾<,¸=-·>-´?.°?/®>0¬<.¬<.¬<.¬=,­<,±=.·A3ºD6ÆLAÞbXâc]ðnlôrrå`cå`eç`g÷kvûoz÷kví`hð_fýlqÿx{ÿy|úmsø^jóAWôC]èUh懣“ƒg]YtI^uIhwPˆf³²–èâÌÿúéÿýíÿþïýÿòûÿôøÿôôÿñíûêäòáØî×Åèǻ伺޺¿Þ¼ÇàÀÍâÃØæÌãëÓìîØôñÞ÷òßóêÙìàÒèÚÍêÜÏïáÖòèßñèáòéâ[OA[OA[OAZN@ZN@YM?YM?YM?XL>XL>WK=VJQI>QI>SK>UL;XM9XM7YL9XM;WK?ULGYSWe^nnjƒut–~}¥„…±†‰´‡‰¹Š‹Á‹ÈŽÏŽŽÔÕӔӋʃˆÀ|¸u|²ov­io«ljœ€lˆ“cy®YvËPoãBdð7Vö4L÷8Hï@EåFBÝJCÛJEáGGèCJò=Nð>LäCI×CCÌA>ÎIDº;4°4,ÉI@ÕLFØBAÚ?=Û;;Ú<;Ø@=ÔE?ÍG<ËG:À8*Á8(À8*¾9(¼9'»8&½:(À;(Ä;)Ê=,Ò<.×;.Ü8.á6.ä6/è50é32è./é,0î02õ47õ77î45æ21Ú.*×4/Õ62Ñ32Ï/1Ò/4Û6=ê:Dí06î02æ3/Ü3,Ñ5)Ê7'È9(É<(Æ8$É6$Î6(Ó:,Ú>2ÝA5ÝA5ØA6ÓG8ÉA1Â;(À9&Ã<)Æ=*Å<*Å8&Ì:+Í7)Í0'æC<Û2/ï?Aã/2Ú*,Õ1/Ò5.Õ81Ö90Ò8.Ì5*Æ2&À1#ÎE5ÆA2¼=.µ:*±9)¯9+«:,ª:,«;/«=0¬>/¬<.«<+­<,²>/µA2ÉSGàg^àc_êjiînoæchðjqõoxúq{ýt~ömuîbködnÿrzÿx~ÿquúipøWfùAYô@[êQfá~ƒ¬—†ykmˆ]o‰ZyŠ`—r¶·˜ßÞÂùôÞüúåÿÿïûÿïõÿïïÿëçúäÜïÙÐãÍÅÞÁ°Ö­¨Ó¦ªÐ§°Ó«¶Ô®¼Ö±ÇÚºÒßÁàæÌèêÔòíÚòéØîâÔìÛÑêÙÏìÛÓéÚÓæÙÑåØÐ[N>[N>[N>[N>ZM=ZM=ZM=ZM=YLUL=XLNÝAEÔFDÈA=ÉHB´:/±7,ÎOFÉB<Î=8Ð64Ï10Ð51Ó>8ÏE;ÈF9ÃD5¾9(Ã:(Â:*¿:'½8%¾9&¿:'Á:&Ä9&Ë:)Ó:,Ù9+Ý7+á5+ä3+ê3-ë*+ñ*-ø-3ü/4ÿ17ÿ37ÿ38ý58ù8;õ8<ò9>ò9Aô9D÷7Fû6Hþ5Eô+5ô-2í12ã4/Ù6-Ð8*Î;+Î=,Ë5&Ñ8*Ù;/ß=2â>4ä=4å>5ßA6ÙJ<ÏG7ÉA1Ä<,Â9)Â9'Æ8*È9)É2'Ó9/á@8ëD>Þ0/à..ë46è66Ø3-Õ7.×90×:1Õ;1Ò;0Í:0É;/ÖL?ÌF:¿@1´9*°6)¬6(«7*©8*¬;-­=/®>0­=/«<+«<+­<.±=0ÀKAÚdZÞc^èkiðosêinõrzüvîfp÷oyùryöjsþlvÿwÿv}ùhoùcn÷RbþB[÷ZM=ZM=ZM=ZM=ZM=YLVJ>XL>YN5É83Ç/,Å*&È/*Í:3ÌC9ÃC6¼>/À;*Ä;)Ã<)Á:'Â;(Ã<)Â;'Ã8%Ä5$Ê7%Ô8)Ù7*Ý5*á3*å3)ê2*õ33ÿ58ÿ8<ÿ4:ÿ-2ÿ(-ÿ(-þ+1ü-3ö)0ò&1÷)6ÿ,?ÿ*Aü 9ó/ö"0ó(.í,1æ0/Ú1,Ô3+Ñ5)Ð6*Ô6+Ý90æ=6ë>7ë:4è71è50â92ßH=×K<ÓE7Ë=/Ä6(Â3%È6)Ï8-Î4*Ô6-æC<ß82à21Ò ì89å63Õ1(Ò4)Ò4)Ï5)Î6+Ê6*È5+Å7+ãYNØRFÊH;¾@2·;/µ;.µ<1µ<1¯9-±;/±=0±=.¯;,­9*­9,®:-±<2ÐYQÜb]ìppôvyîmrõq|ör}ÿzƒÿ‰ÿy€ôhq÷epÿq|ÿuÿktø^jöOaÿA^÷8WéG^Ûntº‹™©„‚žn~šg—hœq¡©‚´º–ÈÍ­ÕܽÌÙ»ÁÔ´²Ì©§ÂŸž¼˜š¶–²Œ±†‰³†µ~¹„•À‹œÂŸÄ‘¨Å™²È¡¾ÎªÉÒµÚÙÄæßÍêÞÒéÖÏáÌÉÛÆÃÔÁ»Î½µÈ·°ZM=ZM=ZM=ZM=ZM=ZM=ZM=ZM=XK;XK;XK;YLYM=WMCWLHXNOZPX]Ub`Yia\rjfokŽsp›vq§{u³ƒ~ÁŠƒÉŠƒÇˆÀŠ~¼ˆy²ƒr¨†r§t«‡l£†\„HL¤B9¶A:ÍC@Þ@?è:;ô<>ÿDE÷><ó=<ì>=ê@AëBIêCMëANãALÐ>>Å@9¾?6·>3°,º7%Á:'Ã<)Â;(À9%Â9&Å:'Ç:(Ë:'Ð9(Ö6(Ø2$Ú."à/%ì7.õ=5õ82÷40÷0-ø**û&(û%'û%'û%'û&*÷!)ø".ÿ'7ÿ(>ÿ!;ÿ6ý1ÿ'8ï#,æ#+ã+-Ý--Ô+(Ò-)Ü41â62è64î66ò65ò12ï./î,,å/,Ü92Ñ:1Ò91ìSK»"Ä+#ßF>È.&Í.(Þ<7èE@â:7Ø/*Ú.*â51å<7ß>4Õ<.Ï5)Ë3&Ì5*Í;.Ë;0Å8.ìbXàZOÈC:¹6,º:/¸8-±3'´6*°0%°2&®2&¯4%°6'²:*´<.³=1°:0ºC;Ö\Wìppñsvöx|ûyƒõq|ÿ|„ýw€út}üs{ÿr~ÿr}ÿmxÿgsü`nôI\ÿ>\ÿ>[äAVÔek´•€’¡zƒm}™f~”c‡—j”Ÿwž¦ ¨ƒœ¨„’£Š£|€Ÿvzšqyšo|r vƒ¤u‚­wƒ³y‹¸‘¼„“¾†—¾‡œ¾Œ¢½§¼“¯½š¾Â§Ï̹ßÓÇãÒÊÜÇÄÔ¿¼Ìº¶Á²«¹ª¥ZM=ZM=ZM=ZM=ZM=ZM=ZM=ZM=XK;XK;XK;YL]P@[OC[NFYNJZPQ\SX_U^_Wfd\tibƒng‘qjxp¬€y¼‡€ÄŠÄ€Á~ºt«Œn¢—q¤¡u¨šjž™W{=Aª5+±5+Â<3Ó@8Ý>8è?:óA=õ=;õ;<ô;@ñ>Bî@IèAIâ@KÚAFÇ<9½=4¶<1±;/«:,®:+½A5ÐJAÚG@ÜA=Ô63Ð51Õ@9ÍC8»9+²5#½8'Â;(Ä=*Ä=*Ä;(Æ;(Ç:(Ê9(Ï9(Ï6&Ô2%Ú2%ã5*ê8.ï80ð91ç1&ç/%ê.%ï,&ö+'û+)þ,+ÿ-.ü*-ú%+ú$.ÿ'7ÿ$;ÿ7ÿ3ü0õ0ö.9õ3<å*1Û(,Ü.0Þ02Û+.ñ:>ô7=÷4:ö26ö/4ø03ù25ô87Û2-Ú;5×82äE?äE?Î/+Ñ2.Á"Ô51á?:èE@à=8Ø3-Ù2,Ý60Ý:1Ô:.Ï9*É5'Ç5(È9+Ê<0Ê<2Æ9/ícYáXNÉ@8º4+Â91Ã:0¿6,Â9/¿5+¾4*½4*»5)¸6)µ5(´6(°6)´;0»B9ÓYTèljïqtöx|þ|„øv€þ|„üyùv~þuÿsÿp}ÿkwüdqý_nöI]ÿ>\ÿ>\éCYÓeh®Žw‰˜oz•bu’\xŽ]cŠ•k˜p‹•p…”mp‡]l‰]h‰\g^k_q•ey›izŸk¬t„±vŠ·|»}¼“¼‚–½†›»‰›µ†¡³‹­¶—¾½¨ÏÆ·ØÇ¿ÖÁ¼Ï¼¸Æ·´º¬©²¤£\L<\L<\L<\L<\L<\L<\L<\Lù:Aö=Eï@GæAHÙ@EÏ@BÀ;6¸90±9+­9*©8(­9*»?3ÏF<ÙD>×96Ù74Ú;7ÜC=ÝOEÎH<µ3#¾9(Á:'Ä;)Æ=+É=,È<+É:)Ì9)Ï7)Ï2#Ó/#ß4*î=3ô?6ñ91é4+à4&ß5&â2%å/$ë,$î+%ñ+(ò+(ó+-ð(+ò&/ø(6þ%:ý7ü3ø3ô%7ò0;ó5Aò8Cð;Dðä,6ð2<ó/;ö.9ö-7õ.3õ.1ó/1í42Ü0,â=9Ú64ß;9ÿmjåCAÑ/-Î/,Ù:7ß@<àA;Û<6Õ7.Ö5-Ö5+Ò6*È6'Ã6%Â6'Ä8)Å;.Æ<1Æ<1Å;1ë`YáTMÉ<3¿0(Ë;3Ñ>6Î;3Ò=6Ø=8×<7Ô=6Ï<2É;1Ã9.¼6*¶6)¹;/¼@6ÏTMãgeíorøz~ÿˆû|ƒû|ƒûyûx€ÿwÿsÿn}ÿgvû`pü[mõG^ÿ\ìFZÎ`až~ev…Zi„Qh…OmƒRt…X{ˆ]}ˆ^x„\q‚X`zM_Pa…UeYn•`uœg} j~£mƒ¬r„²tˆ¶x‹¹y‹¹y¹z‘º~”º“±•¬€›©†©­’ºµ¢Ç¹®Ë¸²È¶´¸¬¬ª¡¢ —š[K;[K;[K;[K;[K;[K;[K;[K;ZJ:ZJ:ZJ:[K;[K;\L<\L<\L<]K=]K=]L<^M=^M;^O<^O<^O<^Q@^Q@]OB[OC\NE[NF\OI]OO^P_bTmdY{i^‰pgœ|t­…{·ˆ{³™…º¥…´¯€ª¸z¡ÆxŸÑuœÌcŒÈMlÜFRßA@ÕA=ÏE;ÌH;ÍG;ÓE9ÞA:î@Aõ0ÎD:Õ<7Õ31à;9åA?áD?èSLßUJ¿:+Á9)¾7$À7%Ä;)É=,Ê=,Ë9*Î8)Í4&Ò2&Ù2)å9/ñ>7õ>6ð5.ä/&à6)Þ6)à4*ã1'ç.)ê-)ì*(ì**ê),è',ë'1ò)9ö&<÷!;û=û%Aû6Hä(6ç.<ÿP\ÿ`lÿP\ò;åGDÛ=:Ú<9Õ:5Ò80Ñ7-Ð6*Í4&Æ3#¾5#¹6$»8&¿;,À9é=9æ?9á@8Ù?5Ð<2È:.Á9-»9,»=1ËNHàc_ìnoú|ÿ„ˆý~…øy€øy€üyÿx‚ÿt‚ÿn}ýetù^n÷VhóE\ý8Vÿ^N>\O?^NA]OB^PE^OJbNYbQdcTqdZ}le‘xr¢w¨ƒv¤”}§¬†«Â‰©Î‚žÚw”ál‰ÛXwÚD_óBTúDPïJPáIHÐE>ËE<ÐF<ÙD>èBBð@Cõ@GõBHíDGßCDÏA=Â?7¿@7µ=/®:+«:*ª9)®8*»;.Ì?6áFAâ=;îBBëAAÞ;6ãJBæXLÕK>È@2À8(¼3#Á8(È<-É:*Ë7)Ð8+Î0%×3)à8/é;4í:5í60ë0+å,'ã0,ã1-ç10ì31ó25ö37÷48÷6;ì-5ê,6í.=ñ0Có-Fö)Gý+Nÿ3Rô9Lå3?ð@Mÿ_lÿlzÿWfõCSõ>Pî3Dí3Aí3>é6<ã99Û83Î4*Ç/$Ë2*Ç.(Ð72òYTö\ZòXVÛA?âHFÜB@Ô<7Î70Í6-Ï8-Ï9+Ê7'Â5#¹8#³9$µ:(¸=-¹;,¶6)¼7.Æ=5ÛNGÙEAÎ50Ð1-á>9ç@:ã81ç51ë20î21ë52ç83á:2Ø:/Ð9.È:.¾6*º8+ÈIBÜ_Yënlû}€ÿ…‰ýƒõv}öw~üyÿx‚ÿsƒÿk}ýdvù^pôSeôF]ý8Vþ=ZïL]ÀTRz_BWhÑC?ÖEBãEFèBDîAEíCFçDEÚEAËB:¿?4»?3±;-©8(¨9(ª9)°8*¼:-Ê;3èIEé??ë=>å78Ú2/ÞA:îZPôh[ÚPCÉA3¾5%Â6'Ç9+È9+Ë7+Ò8,Ñ0&Ú6-æ;4é;4ê40è/,ê-+ë--ó49õ3;ø3=ü3=ÿ1>þ0=ý1=ù1>õ0Aò1Bô4Kõ5Nõ0Nö-Oÿ1Xÿ>_æ3HùO\ÿanÿ_nÿWfûP`ôDXé8JóAQê:GÝ2:Ò/2Ê2-Â8-½;+¼:*Ä:/À2(ÙJBúkcÝLGáPKÏ;9Ï;9àLJÔ@<Ê70Ê7-Î-±9)¯3'º:/ÊD;ÖGAØC=Ô72×2.ç;7ì:6è2.í2-ò,-ô,,ò./ï31è71â:1Ú<1Ò>2Â6)º4)ÅB:×XRçjhú|}ÿ†‰þ€„õv}÷xýz‚ÿx‚ÿqÿi{ûbtø]oòQc÷I`ÿ:Xý?[ðO_ºQNqX:Sf8]uEa|InSv†Y{ˆ]~‹`g‚—l€œl}Ÿm|¤o}¨p€©o‚ªnƒ©l…©lˆ«qˆ®qˆ°r†³r„³oƒµp…·r‰¸t‹µv‰¬tŽ¥wš¨„°´™ÈïØÌ¾ÚÑÌÂÂÌ«±Á›¡±ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8[L9[L9\M:\M:]L:^K<`J<^K<_L=^M;_N<^O<^O<^O:_P;`O;aP>aP>aP>aPÉ@8¾>3¸>1¯9+¨7'©:)­<*´<,Á=1Ï?7ß=:å99ã03â/2à42Û94æMEülaòh[ÙQCÆÍD>Á63É;7äUQÕF@É91È8-É:,È9(È9(Ä=)±?'¦<&¨;&¬=*«7(¬3(¼=4ÓLFÖGAÝE@Û96Ü30é73ì51ë0+ô1-ý,/ÿ+-ú./ô1/í4/æ81ß;1Ø>2É9.½3(À;2ÏNHáa^÷yzÿˆŠÿƒ‡ùzû|ƒÿ{†ÿx„ÿn~þew÷^põZlëL`õIaü9Wû=YîM]²JGhQ1Qd6\tDf~Nuˆ[Žc„h†’jˆ—n‰žsˆ¤t„¦t§r}¨p¨n©mƒ©l…©l…¨n‡«n…­o…¯o°l€²k‚¶n…·r‡³t‡­t§wœ¬…²¹šÈƯ×νÙÒÌ»¿Ê¤¬¿’š­[J8ZK8[J8ZK8[J8ZK8[J8ZK8[J8ZK8[J8[L9\K9\M:]L:]L:^K<^K<^K<^M=^M=^O<^O<\O<`Q>aR=aR?bQ?bQ?aP>aO;bL>hOKgNRbP\cWkjfuv”}|œx—‘z–«•Æ„’Ú}…ðuzþlmÿY[ýDLþ/Iÿ5Rÿ4½=0µ?1¬;+©8(­<,´?.»@1ÊA7ØC=Ù74á85Þ..â30æ:6Ó0'Ï5)ëUGÿwjë[PÑC7Ê<0Ë;0É7*Í6+Ô:0Ú70ß82å63ç32ê01í12ô36ý4<þ%6ÿ#9ÿ"9ÿ"9ÿ!8ÿ6ý5ø6ï2î9ð%Bï(Gî&Jñ'Mÿ3\ÿEhÿbuÿ`l÷WcñQ]òP]ïMZâ@MÔ2=Ú=FÌ7;»/.®/(¦5'¢;(›?&œ>%ª9'²8+ÒVJ»;2Ä?8¾41½2/ÎC@åWSÕHAÈ91Ä6*Å6(Ä5%Æ5$Ã:(±<(§:&¨7%­9*¬4&¯1%Â?5ÛRJÙIAáHBÞ;6Þ2.ê41í1/ï-+ü22þ,/ý+.ù+-ó++í-*æ1*ß4,Ö8,Ñ=1¿2(¼7.ÈIBÙ\Xówwÿ‰‹ÿ‡Šû€…þ†ÿ}ˆÿv„ÿj|þ_s÷XlöTiêD\õD^õ6Uñ:VàLZ¥HC^K-Mc5Uo?b}JtŒ\€–g‡˜lˆ›nŠ r‹¥vŒ¬z†«wªr~§m|¥i}¥g¥g‚¦i‚¥k‚¨mƒ«m‚¬l®h~°i³j„¶o‰¶s‰¯rެx™°„­»˜¿Å©ËʵËͶ½Åžªº‹—§]K7\K7]K7\K7]K7\K7]K7\K7^L8]L8^L8]L8^L8]L8^L8]L:]J<]K=^L>\L<\L<[N=]P?^SA`SB_R?`P@bQAcRBdQBdNAdLBjMIhKMdPYf[lnk†w{ž€…­‰ˆ²ƒ©¥‡©¾ˆ Ð‚’ây~ðsqújbÿa^ùJWñ>Që:Lî?NïCQê@Kæ9Ê=4Á;0¸:,§6&¯A0­<,¬6(¿A5ÌF=Ì=5Ð72Ú85Ü71Þ5.Þ6-Þ8*Ý<*×:'Ó6%Ù;0ðSLòZOÙE9Ç8*Í>.ÔB3Ò:-Ô3+ðGBá//î5:ó6=î,7ÿBMñ'3ú&2ÿ)2ÿ(2ù'ý"*ÿ'/þ'/ð&ð)ù+7ê .ì&7ñ-Aç#;ÿXrç-Dÿ]lÿ_iþZcùU\õPWëHMÝ?@Í84Ë>7ÄA7·?1¦7&™2!™6#š;'Ÿ<)§8-®7/ÂE?¿;7½31Ä64Å54ÔDCÛLHÚKEÑD;È:0Ä4)Ç5(Ë4)Å5*¼1¹=3Ö_Yésqÿû„†û‡Šÿ„Œÿxˆÿh}ÿ_wÿ[uÿUoøLføEcñ:Yô;[æ?YÛ]i‹@;VF-L^6YuBg†Mw–]}œcg€¡jƒ¦n‚¨o€§n¦m~¥l}¥i|¤h}£f£e£f¥l¦m«l¬k~­g®f±gƒ³i‡µm‹´r°vŽ®|™´‰§½™±Á¤²Á®¦²°˜žz…‹]K7]K7]K7]K7]K7]K7]K7]K7^L8^L8^L8^L8^L8^L8^L8^K:\K;^L>_M?^N>[N=[N=\Q?^RB_SC]QA]OB_OB`NDbPFcOHeNHiMJgNQeS_g_tnny~¨€‡»‡ŠÁž•Ê£‹»«£¹xÓyƒê|{ôvjöi`ø]aóOZìFRòHSøIVõEPï?Jë;Eä9?à:<Ú::Õ=8Î?7Ç>4À/Ç8(Ê8)Ó;.Þ;4öJFä01ð6;ö6Añ.<ÿ@Nï'4ó$,÷%(û),ý+,ü*+ø((ö((÷+,ï$'í%(ê%,ý;DÙ'ð4CüARØ&6ÿjuÿbjþZaüW]ôOSåBC×<8Ñ>6¾8,¿D5¹H6©>,™/)(’(ž-%°:6ÑTPÎHGÃ54Æ45Ñ==ëWUØGBÖG?ÐA9Ç9/Æ3)Ê6,Ð7/Î70Ç=3Â91Â5.Ã2-É4.Ñ83Ø?9ÞE=äJ@ÞA8Ú6-Ý0*ç0,ò21û03û03ô02ó12ô01ó/0ó0.î1-ç4-ß9-×=1¿3$¾aP@`P@]P?\O>[O?[RC[QE[QG\OG\OI_PMcQOfTTgUUgUUgV\h]nli†sv£|ƒº‚ŠËŠÔ˜‘× ŠÊª‚´¹}ŸÏ€“䄆îvósjûeg÷S\íGQðFOöHR÷EQòAKî=Eä7=à7:Ù99Ô<7Í@7ÅA4¾?0¶>-­>-ª<+«:,¸B6ÇH?À;2»0)Ê:2Í6/Ð6.Õ7,Ø8,Ù7(Ù8&Ü9&à:*Ý4-Û4.âA9éOCÞH:È5%È2#Ù@2â>5õHDè13ò5;ù7@ø4@ÿESø2?ð)0ë#&ì$'ù13õ-/ï''ì&%õ12ë)*ö8:è+1â)1ë3=ÿR^ï=Kÿ[gþ^fñV\îOTðMRêEIÝ:;Õ74Ô?9À6,Á?2¼B5³=1¬7-¥3)¡,#œ' š%©/*ÇECÂ::¼,,È35×ABô^]Ð?:ÒC;ÐA9Ë=3Ì9/Ô=4Ú@8Û@;Û@<Ø=;Ý>;ãA?ä>>à::ã?=ëIDàB9Ý<4Ù5,Ý2+ç1-ð31õ12ø02ô02ô02ô01ó/0ó0.î1-ç4-ß9-Ø>2À4%º8+µ;0Ð[Tízwÿ“’û‡Šúƒ‰ý~‰ÿr‚ÿdyÿ[tÿTqÿNmÿFgû=_ô=\îEbßTg¢AHp;3SH2Qa<]xEf‡Nr“Zu˜^tš_xžc{£g{£gy¢fy¢fy¡cx byŸby a| bz cz¢f{¤h{§h{¨e{©a{©`}«`®`‡²jеn‹²s‰¬t†¦w‚žuy“no†lSeYAPM2A>^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^L8`N:aP<`Q>]P?ZN>YOCXPEXOH[QO_UTbXYeX_iYcl\fk^glaildqok‚rtšy~µ†Ê…ŒÚŒŽáŽ‡×Ÿ‹Ó­ŠÄ³€©½yŽÌ{Þzò‚wÿsrÿcgùU\ôMTõGPôCMò>Gï-±=0¼F:ÌRGÇH?º5.º1)È91Í81Ó;0Ù=1Û;-Ù6'Ü6&à8+à5-Û2+à=4ìNBãK=Ò:,Ñ8*àB6ß7.ð>:é/0ð16÷4<ü8BÿNZÿLUý>Eò38â$&í/1ê,,ð22è**ë/.ò::Ñæ37Ý,2è9@ðEMÿXcóMWØ=CÚADáBFá>AÞ9=Ü89Ø88Ó97É83Â91½:2ÀA:ÍNHÖVSÐNNÃC@²72¶95ÏKIÙMLãQRïYZêRQñYVÉ51Î>6ÒB9Ð@7Ó?5ÙB9àC<â@;é?@ç8=ì9=ò?Cï:?è58ì>=öMJÞ93Û60Ú3+Þ3,å4.ì30ò21ô01ô02ö/2ö01õ/0õ/.ð0-é4-à8-Ù?3Â6'·5(³9.ËVOï|yÿ“’üˆ‹ý‰þz‡ýoücwÿXqÿOlÿFhÿ@cû9\ô?^éKdØZh…35g;0WO8WgCa{Kj‰Ps’Yt•\u˜^wby¡ez¢fw dv awŸavž`xŸ`xŸ`{Ÿaz cz¢fz£gz§fz§bz¨`z¨]|«]~­_†²g‹´nŒ³tŠ­s†¦u€qtŽii€dQcUDSL8G@^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M9]K5_M5`P9_P;\O>ZN@XOFXQKYPQ`W\g`hnfsshysg{sg}qh}ol}pq†rw—v}«z‚Á‡Ò„ŠàŠ‹å“ãŒÚ „¿žuŸ l‚¬nq¼vlÒviòsmÿllÿgiþ^`ûRWõFMï3Û=1Ú6*Ü4'â6*à3,â70ä=5åE9âF9ÞB3ÞA2â>2Û0&ê72ì0/ï.1ñ.4ú7?ÿPXÿ]dÿZ_ÿOSá.1ã03à,-÷EEè66Ü,,Û-.ë>@Ü25Ù37ÿbhà=BË*2Ê-4Á&*Õ;=á@EÛ6:Ù37ß9=Ü7;Í/0Ì43Í;;ÕGFÞRSì`cõilôekê^aÄ@>ÆE@å^[øhgÿopÿjjåKK×=;É40Ñ>7×D<ÖC;Õ>5Õ<4Ø:1Ü41î5;ñ-7ð,6ò.8ï,4ë,3ó9<þJKß3/Ü3.Ú3+Ü3,ã5.ê40ï4/ò21ô02ö/2÷/1ö.0õ/.ð0-ê3-â7-Ù?3Æ8*´2%²8-ÃNGï|yÿ’‘ÿˆŒÿ‰ÿw…úl|øatûTnýHgÿ>bÿ:_ú6\óAaàNeÂWap/+_?0[W>^lIe}Mk‰St’\u–_v™_xžcy¡cx buŸ`uŸ`u_vž_wž_xŸ`{Ÿaz¡bz¢d{¥e|¦d|§`y§^y¨Z{ª\}¬^€¬a…¯g‡®m‡ªp…¥sƒ r{•nrŠjexe[k^RbU_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N:^L4_N4`N8^O:[N>YOEZSMZTT_ZahbprmzuŒ{u‘{q“zp“vp’qt“rxšt}¨w¶zƒÄ~†Ï„‰Ú‹ŒÞ–Ü™ŠÍ›…¶¢ƒ£ª„‘«~yŸl[šQ>¼MBÔQIâWRëWUñSRñKMí>Cå4:é9<æ9;à;9Ø=8Ó@8ÊB6ÀA0º?/³9,ºA6«5+£.$¾I?Ùg\ÙdZËUI¸<2¸6)À3)Î:0Ù;0Ú6,Þ3)ä6-ß1*ä71ã;2Ý9/Þ>0ãF5äB3ß9+ß1(é4-ð31ï-.í*.ô17ÿEJÿV[ÿ]bÿ\aâ9<ã9<Õ+,ôJKâ89×//Û57Ì()Ì'+øXZÝ>BÕ9=Ñ6:º#Ä(+Ü<>æAEÝ49Ù,2Þ17Ù05Í(.Ò37äKNöaeûhnùcl÷`iú`løbkÖLLÕNJê\ZêVTçMMãHFÏ42Î3/ÙA<àKDäOHßJCÙ@8×:3×6.Ü.-õ2:û-:ø*7õ'4õ)4ø0:ÿ>CÿJJà1.Þ3,Ü3,Ý5,á4-ç4/í4/ð3/ô02÷/2ù.1ø-0ö..ñ/-ë2-â7-Ù=1É;-³1$±7,ºC=ìyvÿÿˆÿ|ˆÿqöhxö_rùRlûDcÿ9^ÿ6]ú6\ðFcÑN`¢IMe5+VD0[Y@^lIe|NkˆRt‘[w•_x™`{ždz cvž`s›]rœ\s›\tœ]v^wž_{Ÿaz¡by¡bz¤b|§b{¦_x¦[x§Yz©Y{ªZ~ª_ƒ­e…¬k‡©m‰§s‰¥u„s|”ru‰pnlfwe_P=_P=_P=_P=_P=_P=_P=_P=^O<^O<^O<^O<^O<^O<^O<_N:aP6aP6aO9^O<[OA[RK\VV_Zakgvso†}z—‚~¡|¥}w£{u¥xv§sy©s}°x¸{„¿~†Ä„‰ÉŽÎ”“Íš“Ç •½«›µ¼¦²É­©Å¦”ªˆmœfJœE2¯A4¶@4ÂB9ÖHDèNNîJKì?Cë=?é;=ä<;ß=:Ù@8Ð@5È>1Á=0½:0¾?6¯4,§1'»I?ÑcVÖh[ÕeWÃOBº>2º4)Ç7,Ö90Ù5,ß2+ç60â0,ã4/â7/Þ7.à>1åC4ä>0Þ4%æ4*é0+ð3/ð..ï-.ò14ó78öBEöMRüY^éFKöQWØ37ëFJÝ8<æAEÚ7:Î.0Ñ05äHKÒ7;Ð7:¹#%Õ;=Û8;å;>ëÿ0=ú*7ü.:ÿ;EÿCHûABã1/ß4-Ý4-Ý5,â4-æ3,í4/ñ40ô02÷/2ù.1ø-0ö..ñ/-ë2-ã7-Ø:/Í>0µ1%±7,²;5ésqÿŠŠÿ‡ÿv†þi}óató[p÷PjúCbÿ7`ÿ7aù;_ìLf¿O[~86]=0NF1VX@ZeEcxMj…RrŽ[v”^yša{ždxžas›]p˜Yp™WqšXqšXt›\uœ]y_xŸ`x¡_y¢^z¥^y¤\x¤Yx¤Wy¥V{§X©_‚¬d„«h†¨l‡¥o†¢q€šmx‘jq…ij~cbv]_P=_P=_P=_P=_P=_P=_P=_P=^O<^O<^O<^O<^O<^O<^O<_N:cQ9cQ9aP<]P@ZPG\TR_Zaa_mtrŠyx˜€¨ƒ°~~°yy¯yu°wwµw|¾x€Á}…Ä‚ˆÄ…ŠÁ¿—–¾ ¼¬§»¶¬µ¾³±È¸«Ð¾¦ÖÁ¢Ñ»–Ьˆ¯oT®\G¤G5¨>0ÂG?àWQïWVñNOé@Cê=?æ<=â=;ß=:×=5Ñ:1É90Á80Á<5¹:3¸=5ÁOEÇXMÇ]OÑeXÓcUÂL>¼:-Å8.Ò91×4-ß2,ç60æ40á2-à5.ã<3çC7æC4â:-ß3%ê5,æ.&ð0-ï/,ð31ñ54ç-.â24çBF÷X]öW\ÿouåDJëHMà@Æ02Ö:=òHKî9>ð7?ø=Fò7Bè-8ô>Jÿ]gÿmwÿjrÿcn÷]gú^kÿaoÿ]nùYeò\]ãPIâJGÕ74Ò/0Ù54Ò0.Ø95ßD?ãJDâIAÙ@8Ó6/Ö4/Ü71è66ê'/ü0<þ2=÷+6ù0:ÿ>Eý?Aì44â3.à5.Þ6-ß4,á3*è3,ï4/ô41ö01÷/2ù.1ø-0ø..ò/-ë2-ã7-×9.Ñ?2¶0%²6,°61èpoÿ‡ˆÿ†Žÿp‚ücxñ\pôXn÷OiûBbÿ9aÿ`P@`P@_O?_O?_O?aQAbRB_O?]M=]M=aQAcSCbRB`Q>dS?aP>]P@^QI[QPZSZeapsq‰yxšz|¥~€±€¹}ºxz·rs´lo¶twÈv{Ì€ƒÊ‹Æ–—䤾²°»¼¹´ËƳÓ̰ÙϬÛϧÜÏ£ÝУÙ˜٘Ѩˆ¸€g ^FËzgÖue½H?×QN÷ccéKLå?Aâ89ä::â:9Ü75Ù61Ö;6Ë81À5.ÇB;»<3¿I?ÆXK¹OAÎdVÑcTÌXIÅG9Ä:/Í6-Ø7/á6/ã4/ß0-ß2,à70ä=4à<0Ý7)ß5(å7,ä/$ê/&ì/)î1-î20ë40è51â64×79æJNõY]íNS×8=×6<ùX`ÿ~„ÿ~†ÿouÿgoÿipÿflõ\añX[ûZ_ÿUZÿDKü8Bû7Aö2>î+9ì0>ñ=HÿS_ÿ`iÿgrÿepþbmÿcnÿ`oý]gíSSßF@Ö85Ö41×11×/.Ø31Û94áD=ÜB:Ù?7Ö<4×90Û81à93æ66ð7<ó4;ó4;ö4<õ6;ò59ë33ã1/Þ3,Þ5.ß7.à5+ä3+é2,ï2,õ20÷12ø03ú/2ù.1ù//ó0.ì3.å7.à?5Ì8,¿6,¯/&¸;7ÒXWÿ˜šþ{ƒÿm€ÿe|ø\rðPhôGeüCeÿ;dù9`õNlÓRd‰=?P, C;&CG.KM5Y_CZjEcxMqˆZx’bx–`t•\r–Yq˜Yl•Sm–Rn—So˜Tr™Xt›Zuœ]uœ[t›XtWv Xw¡Wv¢Wv¢Uu¡Tt S{¥[{£]zž^u—[m‹Ub~MXrCSj>AW0?U/`P@`P@`P@_O?`P@aQAbRB`P@_O?`P@bRBcSCbRB`P@fVG_QF\OG^TSaZad`omkƒvw–wy¢{}®}¸x|¹quµkp´lo¶nq¾uvÐ|~Õ‰‰Ó˜˜Î¨§Ç¸¶ÁÉźÓαÛתâÛ¥çÞ¥æÝ¢äÛ¤âØ£ÛÑ ÔÇ›Ó¼š»œ€©}dÅ‹wÊ}m´VJÒa[örpìZ[çKLã?@ç=>ë>@ç;;â66Û64Ö=8É83Ê?8¹6.¸>3½K@¶H;È]MÝo`Ô`QÆH:½5)Ä0&Ô6-Ü5-Û0)â51å95ä=7à<3Ü8.Û5)ß4*ã5*ì7.í5+í2+ë0+ç0,ã2,á4.Ý52Ö87Ø>@äJLóW[ú^bü\dþ]eÿaiôS[ïNVñQYÿ_gÿjqÿflõZ`óNTí4:ñ,5ô*6÷-9ñ'5å!-æ'6í7CþPZÿZdÿblÿdmÿenÿcmý[hõQZåEEÞ<7Û64Þ63ß55Ü30Ú2/Û62à>9Û>7Ø;4×:3Û81ß82å95ç:6é9;ê7:ë7:î79î79ì65å31ß2,Ü3,Ý6-ß7,â6,å2+ê1,ò1,õ20÷12÷03ú/2ù.1÷//ó0.ì3.å7.ß<3Ô=2Â8.¶1*·74ØZ[ÿ“ûs}ÿfzÿ^vùWo÷OiùFfû?bü^QA^QA^QA^QA_RB`SCaTD`SC_RB`SCaTDaTD`SC^PCbUM\QM[QRcYbkdtqm„vu•y{¤y{¬y~¶x|»nsµei°`g¯jn¸ruÆ}}ׇ„Ý—”Û©§Ø»¹ÏËÊÈÜØ¿åá´éäªíè¦ðé¥íå¤çá§âÛ§×Ï¡Ëܸ¯©››ƒk¨ƒp§o`œRGº]UÝmi÷uuï__äJLå@DëADì>@è8:â66ß=:Ô;6ÔA:Â70·7,·>3®=/¶F8Ûj\ßi[Ù[MÊB6Å2(Ñ4+Ù6-Ù2,Þ52éA>ìGCà=6Õ2)Õ1'Ú2'Þ0%æ4*è1)ç.)æ/)ã2,â7/á=4àB9Æ-(Ê43ÜDCðVXú^b÷ZaóS[ñQ[èFQêHSïOYü\fÿmvÿntôY_ã>Dé.5ô-4û2<ü2>õ+9í'4ö6EÿKW÷ISõPWøW_þ^fÿckÿ`i÷RYéBIÞ97Þ71ã75é<8ë;;æ95á51Ý60Ý:3Ù;2×90×90Ü71á83ç:6é<8ã99ã99å97ç98è88æ74á40Û2+Ú6-Û7-Þ8,â6,ç2)ë0)ó0,÷10õ12õ13ø02÷/1÷//ò0.î3.ç6.Ý90ÜD9Ç80»4.µ/.ä_bÿƒˆølwþbxþWsúPmþLlÿCfö:]ó;_ìIfÔSgDJl;4O>,=<':?(ED/FH0Q\U'B\/E_2Ic6WJ:ZM=\O?^QA]P@^QA_RBaTD`SC`SC`SCaTDaTD`SC_RB\PDZOMZQVbXcjcsqm†vu•xz£z|­w|´sy·mr´bi¯]d¬ag±lr¾x{ʉ‰ß•‘夡䶵áÇÄÙÕÑÎáÝÄçä¹ëæ¯îê­îè¬éâ«ãÛªÚÓ©Ë¡»¶™¥¥›™„“ˆv˜q™rc›bW³i`Ïrmû‹‰õutê[]æLNèCGí@Dìô@?ï=;æ95à72Ý82Ú91Ù80Ù80Ü71ã73è96é:7â:7à;9ã:7æ:8ç:6å84à5.Ú3+Ú6,Û7-Þ8,â6,ç2)ë0)ò/+ö0/ô22ô23÷12ö01ö0/ò0.î3.ç6.Ü8/àF<É91¾3.¶,,îfjÿy€øgtÿbyýTqþKkÿGjÿ>cò6Yë=^ãQhÄXeˆBBgC7[N;GF1AC-JH3EE-LU6Sc>btLlƒUp‹XnRkPiŽKgIhJh‘Kj“Mk”Pm–To–Wp—Vt›Xs›Uq™So—Pj“MgJeŽHdG`‡D]AWy=Rq8Mi6Lf6Ne7Of8Lf7Oi9Sm>UH8WJ:[N>\O?]P@]P@_RBaTD_RB`SCaTDaTD`SC_RB_RB^QIVMR_Xhnf{tp‰xt—xw¡xz«y{´sy·jr³`g­[c«_g°jr»v|Æ€„Γ•àžžä­®ç»½æËÉßÔÓØÝÛÎá߯åá¾æâ¼äß¹à×¶ÚÐµÎÆ±¾µ¦­§›˜šŒŒŽ€‰…yŠ|q‘vk›si¨meºoi扄î~ósrñedñWYðMNîDEì@@ã:7à;7äB=ÞE?Ì<3Æ=3ÄB5¯1#®0"ÇI;ÜXKÖN@Ì=/Î8*Ð6*Ñ3*Ö42õUUÿkhú]XãD>Ü;3ß;2ã80â4-ã2,â1+Ý0)Ô0'Í/$Æ/$Â0#Å9,À4'Á3)Ë:5×CAÛEGÛBGÚ@HàDOëOZòVaòVaú^iÿgoóYaáBGê:<í57í38ï28ñ3=÷9CÿHSÿV_ä6?Ý4;ß6;ëADùJOüIMô;Aé13è51ë95ï<8ò<9ó;9ð:7é73â70ß;2Ü;1Û:0Ü90ß82ä73è64é75æ:8ä;8æ:8è:9è;7æ95á6/Ü3,Û7-Ü8.ß9-á7*å3)é1)ñ0)ô1-ó32ñ33ô22ô01ô1/ò0.î3.ç6.Þ7/àC:Ê70À1-À13÷jpÿqzúftû]túPmÿCfÿ=dÿ9cõ8^æEdÙZm«V[wE>dJ=aYFTO;KI4PI6GE.GP3L\8ZlFf|Nm…SmŠRlŒMhJfŽHgHg‘Ii’Lj“Ol•Sn•Vo–Ut™Vs˜Un•Rj’LfKcŒHaŠF_ˆFZBX|?St;Pn8Ok:Rl=Wn@ZqCUo?Vq>WqARE5UH8XK;ZM=[N>\O?^QA`SC`SCaTDaTDaTD`SC`SCbUEaVP^Vcje|yu}yšzy¡xy©vy°sw´jr³cj°[c«]e®hp¹v~LJшŒÓ™Ý£¥à¯³ã»¿åÆÇãÏÎÞÔÓØ×ÖÑÙ×ËÙÖÇ×ÑÅÒÉÀÌþʹ´¨¬£šŠ‹†x{tyvquleleogŽa[`[ÀsmØyuð{ü|yÿrpýccöSTðHGïC?ê>:á<6àA;Ñ:1ÓC:ÝTJÂ>2¸6)½9,Â=.È?/ÏB1×C5Ö@1Ñ7-Ð2/êLMú_]òWSßD?Ù:4Û81à70æ93ç92ç92â:1Ú9/Ñ9,Ê8+Ä8)°(¸3"È@2ÓI>ÒD@Ë;:Ì7;Ï:@Ñ7AâHRíV_ðYbõ^g÷`iêU[ÜAEå@>ì?;ñACúGJÿLTÿQYÿT]ÿV^á4:Ú/5Ü/3ç7:ô=Aø;?÷48ó12í42ï95ð86í42ë20ê20ç40á4.ã<4à=4ß<3Þ;2á83ä73è43è43è88ç98è88ë99ë97é75â5/Þ3,Û7-Ü8,Ý:+ß7*ã2(ç0(ï0(ò1,ñ42ð43ó32ó11ó1/ñ1.ì3.ç6.à91Ù<3Ì71Á0-Ñ@CÿnuýkuùbqðRiõHfÿ;aÿ4^ÿ6bû>däNiÊ\i‹GFjF:]L<]VCXQ>RJ7OG4ID.DJ.GU2Sc>^sHgMj‡OjŠKgŒGgŒFfŽGfHgJi’Nk”Rm”Um”Uq•Uo”Qj‘NgŽKcŒH`‰E_ˆF^†G\‚E[~DWxAVr?Uo@YpB]rG^uG[sCYtAXs@NB2QE5UI9WK;XL\P@^RBaUEbVFbVFaUE_SCaUEfZJh]YngwupŽ|x™{y wx¦vw­pu¯jo¯ah¬^f®_g°em¶pxÀ}…ؙ͉ؗ Ö¡¨Öª±Û´¹ßº¿ßÀÁÝÃÃÛÇÆØÆÃÔÅÁÐÁ»É¼³Ä»°Áµ¨¼¦˜¯–‹œˆ…Œqqqtpopfewhe†nj„_Y•d_›ZT¹f`Ùsnðzvÿ{wÿwsÿhfüZWþRNõHBæ=6çD=Ø;4ÛG=ê\RÅ;0Ä<0½7+¾6(Ç>.ÑD3ÔB3ÔA1×A3Ò86Ø>>ÝCCÜB@Ö=7Õ81Ø7/Þ7/å:3æ93å:3â;3Û>5ÕA5ÑE8ÌG6®-¼;%ÍJ8ÑL=Æ=5»0+À00Ê9>×AJáKTëU`ðZeð]eìYaßLRÔ>@Ï4/Ø7/à;9ê@@òCHõDJñBIî?Fâ5;ß26ã36ï8<õ79ø14û/2ü14ï20ð95ð74ì0.è,*ç0,æ3.à3,ä=5à=4à=4à<3ã:5æ95ê65ì65ì57ì57í57î68î66ë54ä2.Þ1+Þ7.Ý9-Ý:+ß7*á4&æ1&í1(ñ1,ð42î53ñ42ò21ó1/ñ1.ì3.ç6.â;3Ò4+Ò:5Æ20çUXÿpxùcnòZiçI`óEfÿ8bÿ/]ÿ5bÿBhÜLe±PYj5/^G7XK:UN;[P>VI8M@0JC0@F,AO.K[6Xj@bxGfJhˆIf‹FeŠDc‹BcEeŽHgLh‘Oi‘Rk’Sn’RlPhNd‹JaŠH_ˆF_‡H_‡H_…H_‚H]~G]yF]wH`wKcxOczN]uC[vAZu@JC3MF6QH9TK.ÑE6Ë>-Á2"Ê7'ÛE7ÞE?Ó97Ì3.Í50Ô;5×=5Ý<4á=4ä;4ä92Þ5.×4+Ï5)Ê8+Å<,Â?-ÔS>ÈG2½<)¾:-Ã=2Ä;5Â74Â43ÜKNÞMRáPUåTYèY]åVXÜMOÓD@É5+Ñ7+Ø7/Ý52â24å26æ18æ.6ì4>ì3;ó5?û9Bý4>ú+5ÿ(3ÿ/9ø-3ù57ù59ð./ë*+é0.è51â5/ã<4à=4à=4á=4ä;6ç:6ë76î66ì46ë35ì25í34í55ê41ã1-Û0(Þ8,Ý:+Ý:+Þ8(à4&ã3$é3&ì4*î50î52ð42ð3/ò2/ï2,ì4,ç6.ä=4Í/&×>9Ì35ùbgÿoy÷[iðNcêC]ùEhÿ:eÿ0]ÿ6aöGhÉJ]“CFR,#VI8SL:OH6[O?UI9F?-HF1>B'@J(IU1Sd:_rEe}Ig„JeˆHcˆCa‰BbŠCcEeŽHfMhPiQlPkMfJcŠIaˆG`‡F`‡H`†I^G^F_}G`|Ia{Kd{Mf|Nf~N]xC]z@^{CDB6FD8JF;PG>RH>WI>]M>_O?`Q>aR?`SB_VGbYRgb_ojnso~wq“zt |y¨yw©pp¦gg£`a¢\_¤`b­fhµopÀyzÌ„‚Ö‹ß–’眙栞ݡ¡×££Ù¤¤Ú¦£Ø¥¢×¥¡Ô¤ Ó¥žÑ£Í¢šÉ¢™ÈŸ–Ù»Ž‚°ƒ|žrn}igld^`fZZkYUrWP}WNŒWO•RI¨ZPµXPÁZSØkdìyrù‚|ÿ‹†ùuqÿusí_]ßPLÙEAïZTÌ71Å2*Ä6*Ã7(À7'Ã7&Æ9(Ê;+Ð<.Õ?1Ò8.Ö<2×?4Ó;0Í5(Í3'Ø:/â@5à90á90Þ7.×7+Ï7)É:*Æ?,ÄA/Â=.Æ@4ËE:ÍG<ÌC;Å<4»2,¶+&Ç<7ÐEBÙOLàVSãYVáXRØOIÐC:Ì;*Ó:(Ü8,â5.è./ì*2ð(3ô'6ú->ú+?û*?ý)?ÿ(?ÿ&?ÿ$<ÿ$<ÿ$8ÿ'9ÿ+<þ,9ó+5í.5è45ç;9Ý84Ý:3Þ;4à;5ã:5æ95é73ë54ë35ì46ë54é54ç53â5/Ý5,Û5)Ü8,Û9*Ü9(Þ9&ß8&â7%ã6%æ4&ì5-í4/ð50ñ4.ñ5,í5+ê5*å7,à90Ø7/Õ:6Û?BÿmwÿbsûSjõIcÿKjö6[ÿ6_ÿcçNj¯IV^$"D, ?:'HE4PMC/?G/BH&EK%KS.S]8[kDavKd~NdƒJb†F`ˆBa‰@c‹BeFhJlPm‘Ql‘LiŽHgŒGf‹HfŠJe‰Ic…HaƒGdƒJdIbGc~GdJdHe~Ga}C[{<\=_‚B=?4?A6FC[K>]M=`O;`Q<^SA^VIc[Xhcinlyso†tp•vpžtp¢pm¢gfŸaaŸ]^¡\\¤ed°kjºtrÅ}{φ‚Ù‰à”Žæ˜“å›–Ùœ˜Õ™Öžš×ž˜Ö—Õœ–Ô›•Ñž–Ñœ”Íœ“Ê›’ǚ牻ˆ®‚xtk|mdif]^f[YiZSoWM{UJŠVKšVK°\RºYRÁXRÓfaàqjãvoí~wý‡…ÿ‡…÷usîgdãUSëZUÇ2,Â/%Å7)Ã7&À7%Á8&Ä8'È;*Ï;-Ó=/Õ9,Õ9,Ó:,Ò:,Ñ9+Ñ9+Ô8+Ø8,ß;1à90Ü8.Ö8,Ï9*È9(Á:&¾9&¾6*Á80Æ=5É@8ÊA9È?7Å<4Â91¿4-Ç>6ÑH@ØOGÚQI×NFÌC;Ã7*Ê7%Ó8$Ý7)å4,í//ô+3ù)7ý(:ÿ+@ÿ*Aÿ)Aÿ&Aÿ#@ÿ!<ÿ=ÿ:ÿ:ÿ 9ÿ%;ÿ);÷-9ð19ê7:å;;Ü94Ü:5Þ;4à;5ã:5æ95é73ë52ë35ì46ë54è64ä71ß6/Ü5,Ù5)Û9*Û9*Ü9(Ü9&Þ9&ß8%á8%ã6%ç5+ê3+ë4,ë5*ë5*ê6(ä7)á7*ß;1Õ4,Ó54óTYÿesÿ[põGbÿIhÿAdÿ;`ý3[ù;aòMmÍLb‰8?S*$A5'69(;<,B@1DA0@?-=B.>G,=CKP'\b_„?b‡B69.:<1??7DA:KB;OE/Ô>/Î6(Ë/"Ú:.Ú8-Ù7,Ö8,Ð:+É:)Â9&¾7$½5)À6,Â8.Ä:0Ç=3Ê@6ËA7ÌB8Ç:1Ê@6ÏE;ÐF<ÒH>ÑG=Ê@6Å7+Ì6%Ö6&ß7,ç4/ñ03ö-5û+9ÿ*<ü';ü'=û%=ù#;û!:ú7ü7þ6ÿ8ÿ6ÿ$8ý*;÷2<ñ6=ë8;ä::Ü94Ü:5Þ;4à;5å95ç85é73ë52í36î47í55ê65å61á6/Ü5,Ø4(Ú8)Ù9)Ú9'Û8%Ý8%Þ7$à7$á6%á5'â4)ã5*ã6(ã6(á7(Þ6)Û7+Ý<2Ð1+Ø88ÿkrÿ]nþPiñ<[ÿHlÿ7]ÿ>eù5[î>bæVqª?Qa#(L/);7+07'37&9<)@=*A<(@>)BB&?FXa4s~T€Œdw‡`hSa}La€G`ƒC`…?a‰@cŒ@hŽEjJkMl‘Nn“Mk‘HhHgŒGh‹Kh‹KfˆLd†Je„KdƒJc€FdGf‚Hf‚GeFb€Bc†DeŠEhH25*58-;<4A>7G@:KB;RE.Ñ>.Ë8(Ç/!Ò6)Ó5)Ò4(Ò6)Ñ9+Í<+È=*Ä;)Ä:-Ä:/Æ90Æ9/Ç:1È;1É<3Ë=3ÓD<ÓE;ÐA9Ë=3Ë<4ÏA7Ï@8Î;1Î5'Ù5)â5.ë31ò/5÷+6ù)7ü):ù&9÷&;÷&;ø'<û&<ý%:ÿ$:ÿ#:ÿ"7þ#7ú%7ù,;÷5>ò9?è8:à87Ü94Ü:5Þ;4à;5å95ç85é73ë54î47î47î66ê65æ72á6/Ü5,×5*Ø8*Ø8(Ø8(Ù8&Ú7&Ü7$Ý6$Ý6$Û5%Ü6(Ý7'Ü9(Ü9(Û:(Ù9)×:+×:1Ð3.ëHKÿoyÿVjøD_ø<_ÿAgÿ3\ÿ8bø>cèMlÅOe€0=J C1-11'.6'4=,=B.B@+B<$E>$HE$U\0p~MŸr—¨|ƒ˜mj„W_{J]~E_ƒCa†@bŠAfCkJl‘Lm’Om’Oo”Nl’IiŽIhHiŒLiŒLhŠNg‰Mf…LdƒJdGe‚HgƒHh„If‚Gd‚DgŠHiŽIl‘L-3'36+891<;6B=9G@:MD=QG=SI=SK>UNDZUQa^eigumklkŠjhb`XVˆPP†QQXYš`cªfj´orÁuxÉ|Ђ…Ö†‡Ù‡ˆØŠ‰Ù‹ŠÖ‹ŒÏ‹ŠÌŠ‰Í‰‡Ð‰…ш„ÑŠƒÑ‰‚ÐŒ„Ï‹„È…Á†º†°‡¥~w–m…„Yj€SZnVTc\RZaOZ_HeZDxUB’LD¸TRÐSWÛRYå^dèejãklæuqäunâoh÷~vÿ‚{ÿ‡~ôl`É?2Á8(À;(¿='¿='À<'Â;'Å:'Ç8(Í7)Ø:/Ù8.Ò8,Ï9+Ì:+É:*È9)É7(Ï9+Ñ7+Ò8,Ñ7+Ï7*Ì8*Ë<,Ë>-Ê<0É=0Ê<2É;/È:0Æ8,Å7-Å5*Ð@7Ð@5Í=4É9.Ë80Î;1Í:2Ì5,Ð/%Ù0)ä20ì25ô/8ù-9û+;ü,<ü-?û.?ü/@ü/@þ/Aÿ/?ÿ-?ÿ.@ÿ)9ü)8÷+7õ0:ñ6=í8=ã77Ü43Ü94Ü:5Þ;6â:7å95ç85ê65ì44ñ48ñ48ï56í76æ72á6/Ú6,×5*Ø8*Ö9(Ö9(Ø9&Ø9&Ù8&Ú7&Ù8&Õ8%Õ:&Ö;'Õ=(Ô=(Ô=*Ô=,Ô<.Ñ7/Ú;8ÿ^eÿaqÿPi÷<[ÿAiÿ4_ÿ4`û1YôKlÛYq•>NZ%-C),:2/-0)08+7@/:B+<<"A<UH(`[5{…S£lª¾‹¨¾Ž¥wo‹[aK^F`„DcˆBeDj“Go”Np•Po“So“So”Nl’IiŽIgŒGiŒLiŒLi‹OhŠNf…Je„IdƒHe„Ig…Ih†Hg…Ge…DiŽIi‘Kl”N+1%.4*470893>:7B=:HA;KD1Î8*È4&Ê8)Ë<,É:,È:,É;/É;-Ê:/È9+È5+Ç5(Ê6,Ï;/Ò>4Ó?3Ö?6Õ>3Î7.É,#Ò+%Ü-*ç02ð39ö1;ú0<ý0?ý0?ù0@÷1@÷1@ö0=÷/<÷-9ú,9ú*7ý/<ù/;õ0:ð3:í6;æ69ß55Ù42Ü94Ý:5ß:6â:7å95ç85ê65ì44ò59ò59ð67í76æ74ß6/Ú6-Ö6*Õ7+Ô8)Ô8)Ô9'Õ8'Õ8%×7'Ô9%Ð9$Î<%Ï=&Ï?'Î@(Î@*Ð?.Ò;0Ñ61ëHIÿfrÿOdÿHfû7[ÿAmý/]ÿ7aò4XãPj¼Ufm19E(*E697325406906=-3;#38CCja:…TŸ®w©Á‡µÎ—¯Ç“’®}v”be†Q`‚F`…BcˆBgFm–Jr˜Or—Rq•Up”To”Nl‘KhHf‹Fh‹KiŒLi‹Ni‹Og†Kf…Je„If…IhˆIi‰Hi‡Gf†CjJk“Mn–P(0#+1'/4-350764<85@=8C>8IEù4>ù1>ú0@ø/?ò.<ï/<í/9í07ï-5ï,2ò+2ñ*1õ2:õ3;ò5;ì59å57á55Þ65Ü75Ü86Ý97ß:6ã:7æ87é77ê67ì46ô5:ô5:ñ7:î87æ74à70Ú6-Ô6*Ó7*Ñ8*Ð8*Ð9(Ð9(Ð9&Ñ8(Ð9&Ë9"È:"È>$Ç?%È@(È@*Ì=-Ï;1×96üU\ÿ^qÿGcÿ?aÿ:aÿ7gþ3bû8`íFdÅNa‰@IS12A64@:<:46?56<7179+4="9CSZ.‚‚P¢§q±ÅŠ¯ËŽ°Ì’¦Ã’®}{™egˆQ_E^ƒ@c‰@iDo•Js™Ps˜Sq•Uo“Sn“NkJgŒGeŠEgŠJh‹Ki‹Ni‹NfˆKd†Id†IeˆHgŠJh‹Ii‰Hf‰Ej’Ll–No™Q&.!(0%-2+13.331764:95<;6GD=DD*¾;'¼7$À4#ÑB2ãOAäN@ØB4Ë7)Ë7)Ð>/Ê;+É:*Ç8(Æ7'È6'Ê6(Î8*Ð8+Ó;.Õ;/Õ9-Ò6*Õ7,Ú<1Ý<2Ü71è88ñ8=÷:Aû9Bú4Aõ/<ò,;ï,:í/;ê19ê38ë48í57ñ56ô36ó57ð37ï6;í9<é69â45Ý33ß76à;9Ý86Þ97á96ã:7æ87é77ê67ì46ô5:ô5:ñ7:ì89æ95ß82Ø7/Ó7+Ð8+Í:*Í9+Ì;*Í:*Í:(Í:*Ì;(Å9"Â:"Ã=$Â>%Ã?(Æ?+Ê<.Ï81ß<89?48E26C41=:)>E&FU*bs?›a­½±ËŒ«É‹¦Ã‹º„ެz{™ef‡PZ|@^?a‡>hŽCo•Jr˜Or—Rp”Tn’Rn“NjIf‹Fd‰Df‰Ih‹Ki‹Ni‹NfˆKe‡Jd‡GeˆFgŠHh‹Gh‹GeŠDk“Lm—OpšR(0!'/"(-&).(.0-3317839:4==5?@8DE@JLKORYVXeZ\s]^}YX‚[Y‹^]–ee£nn¶wxÈØ„…⌌ðŠŠì†‡ä‚‚Ü€€Ö‚€Óƒ‚΀ƒÈ„ǃƒË„„ΆƒÐˆƒÓ‹„ÒŒ„ÏŠ€ÅŠ€¼‰€¯‡}Ÿ€xwozkegf]Xm[Qm[Mi\Lf^Kd_IeaHhaGo_FoP;…UA¥]O¿aYÑYXÝQTîS[ø\`ùheæYPÔD<Î70Ñ7/×:1Ö=/Ô;+Ï9(Í:&Ï9(Ñ:)Ô8)Ø8*Ü5,Ü5,Ð/%Í3)Ì8,Ê>/Å@/Á@-¾=*¼9'Â9)¾0"éWJßK?Ã/#Ñ=1Î2Ü<0Ù7,Ú8-â>4ìC<õBEò9?ð2<ö4?ö2@ñ-;í-:í2=ì7>æ5;ä68å78ë99ð:9ñ78ï77ò;=î<<ê::æ87á85ß74Ü75Ü75Þ97á98ã99æ::é9;ì9<í9<ï8<ô7;ó6:ð8:í9:ç;9à;5×90Ï7,Ê8+È9)Ç9+Æ:)Ç:)Ç:(È;*Ç<)Á9#Ä='¾:#¶4¼9%ÉD3Ï?6Ê1,ÿ^eÿVgÿIbÿ<\ø1X÷0Yû6cõBiçYo¬FQo33N3,B?6>C<@78@-1L/3K2.A9&DJ(Zn=~š_ž¸w¨Å‚¬ÊŒŸ¾‚˜¶€”²~‚ nf„RXvBY{?]€>c‡AiDn”Im•Ll”Nk’Ol‘NiŽIfŠDc†Bc†Bf‰Ih‹KfŠLdˆJg‹MhŒNg‹Kf‹HeŠEf‹EjIk“Jq›QržSt U*0")/#).').(-/,130561782;<4>?7AD=HJGOPTSUaXYkZ\u\Z^]‰db”kj¤utº~·‡ß‹Œéð‰‰ë…„ ؀~Ҁς‚Ì…†É†‡È‡ˆË‰ˆÎ‹ˆÏŒ†Î†ÌŽ…ÈŠ€¼‰±†|¡‚x‘{s€tknlb`e]Re`Me^Kf^Kh]Ki\Ij^Hk_Gn^Ew_G[C’YF­ZLÇVPÞRSõQXÿX_ðUSãLEÙ>9Õ60Ù6/Ü90Û9,Ö9(Ó8&Ñ8&Ñ8(Ô8)×7)Ü6*ß4,Ý5,Î0'É5)È9+Æ=-ÄA/Á@-¿<*¾9(Ä8)Ë<.äREÜH<È4(Ì:-È:,Â4&Ê=,Ë<+Ê;*Ê;*Ë:)Ì9)Î8)Ï6(Ó7*Ö8,Ù7,×3)Õ1'Ø1(Þ7.ç<5øDGñ8>í/9ï/:ð0=î.;ë1<ë6?ä5:Ü36Ø22ß:8îEBøIFøDCó?>é:7ç98å97â96á85à85á98á98à87â88å99ç9:é9;ì9<í9<î7;ó6:ò59î68ê88ä;8Ü:5Ó9/Ë7+Æ8*Ã:*Â:*À;*À;*Á<)Á<+Á<)½9$Á?)»:%³5¹:'Á;/Ê:2Ø<=ÿ^gÿPdÿA[ù8Wö6[õ;`ô>dãIe«?Lƒ?>_:2G;/:>08>2F<:R>=N0.S8/VK5ciEx[°pÂ}¡Æš¹}š¹€š¶ƒ©xrŽ^YuETp=\{B_@b†@iCm“Hl”Kk“LiMiMgŒGe‰Cc†Bc†DgŠJiŒLhŒNg‹MiOiMiŽKgŒGgŒFfŽEl’Im•LpœQoRt U-1"-1#,/&,.)//-11/34/45-9;0<>1@B7EHAKMLQRWUUaVWi\Yt^]fdŒpn zx·…ƒÎ‹ßêŽïŽŒíŠ‰ç‡„ßÓ|Ë}ȀƅLjˆÆŠŠÊŒŠÉŒŠÉŒˆÅŒ„¿‹‚·‰€­†|¡€v{p€ujpndbi_Vc]M_aL_aKc^Jg\Jl[In\Ho]Gq]EwaIxX?‡S=£VDÇXOãUSøOTþMSâ><Þ<7Ý84Þ71á6/á6.Ý7+Ú7(Ô7&Ó8$Ó8&Õ8'Ø6)Ý5*à3,Ý5,Ë3(Ä6(Â9)Á<+Â?-Â?-Á<+À8(Ã5'ÜJ=ÚF:ÕA5Îå84â62à72à72à72á85â96ä;8ä;8á77ä88æ8:è8;ë8<ë8<ë8<ì8;ï58î47ì57ç77â:7Ù:4Ï8/Ç7,Â8+¿:+½;+»<+»<+»<)»<+»<)¸9&½@*³9$±6$¶;+µ0'Ã40ìPTÿ[iÿJ`õ:Uð7Vñ@]ïHfçHdÍNa‚89e?6R@2DA09=,57)>6+K9/E-#R=,g]Bˆ_’«t—»{–Áz–¿{”³xœ¸…š´…€šm\uKHb5Nh8[xB_}?cƒ@hŒDl’Gj’Ih’JgLfKd‰Dd‡Cc†DeˆFh‹KkŽNkOjŽNiOiOiMhJgHh’Hl”Ko™Ms¡Vs£Wv¤Y24&04&01)01+12-23.34.46+9;-;>-?A3DF9IJDMONRQWSS]XVd\Zoda~nl”zw¬„‚ÃŒ‰Ö‘㔑ê“뎋≅قÌ|Ã|¿€~½„‚Á†…Á‰ˆÂŠÃ‹ˆ¿‰…¸‡®…}¤…{€vŽyn~rgmmaak^Vi[Pc\J]`K]aJc^Jh[JmZKqZJtZIv[FsWAxR;ŠQ=ªYFÍ[PãTPðFIñ>AÛ2/Ü5/á51ã60ã5.á5+à6)Û8)Ö7$Ó8$Ñ8&Ô9'Ø6)Ü6*à3,Ú6-È6)½8'¼7&½:(¿>+Â?-Ã;+Ä8)Æ4'éUIÓ<1Ì8,ÑB4¾5%À=+À=+À8(Ä8'Å9(Ç:)È9)Ë7)Ì6(Í3'Ò6*Ô3)Õ2)Û4,ã:3é>7ì?9ì=:è45ì59ï6;î5;ê2:æ39ä7=â<@óUVübbÿmjÿidóVQäA<ß63Ý4/ß61Þ71Þ71ß82á85â96å97æ:8å78æ89è8;é9<ë8<ë8<ë8<ì7<î5:î68ê67å97ß<7Ö<4Ì9/Å9,¾9*º;*¶;)µ<)µ<+´=)³;*³<(³:'·@,­8&­8'³;-«+"Ã54ý`gÿTdúG\ð-=@-@C.DG4IK>MNFQPNRRRVUSYX]a_lkius›€}²ˆ†ÇŒŠÓ•’ᔑâÜ‹‡Ó„Ä}º|µ|³~·„º‡„¹‰…·Š„²†¨z›€xs‡znzrfjm_^j[Ti[PjZKfZJb_Lb_Le^Li\Kn[Lr[Kw\K{ZG~UA†R=›RA¶VFÎRHÚG@â88å33Ý1-ß3/â5/ã5.á3,ß3)Ý5(Ü9(Ó8$Ð9$Ï:&Ñ:'Ô8)Ù7*Ý5,Ø7-Ä;+¹:)µ6%·8'½;+Â=.Ç;.Ç7,Ð90õ\TÖ=5É5+ÏA5¸3$·:(¼?+¿:)Ã:*Æ:+È:,Ê;-Ì:-Ï8-Ñ7-Ð3*Ò1)Ö1+Þ71å<7ê>:è;7æ74é75ï;<ðë8>è7=ê7;î7;î79ê7:ä::ß=:Ö=7Ë;2Ã;/º8*µ:*³;*¯<)¯<*¬<(¬;)¬;)ª;(¬=*¦8'§9*ª8-¬/)Ë@CÿhrôM^óH[íDYåH[ÙO^ÉT]·TWœXUdM?OL9LG4JE1FD-?B'=D#>H#KV.\g.==1==3==5;<4;=2;=/?B/@D-CG.FJ3KL:NOAQQIRRHYWJZZN_^\gerqn‰{y¡ƒ€·‡…Čьӊϊ…ǃº~y¯zw¦yv¥{v¬|y®€|®ƒ}©ƒ}£x—|t‹zrvksrffm_\j\Sk[NlZLl[Kk[Ki]Mg^Mi]Mj]Mn]Ms^Mz]MZI“`O›VG§N@¸J=Å@7Ï6.Ø1+Þ1+á51á6/â5.â4-à2)Þ4'Ü6&Ú;(Ñ9$Í;$Ì;&Î;'Ñ:)Õ9*Ù7,Ó9-Á>,´;(°5#²5#»9)Ä<.É;/Ë7-Ù?7ø[TãIAÎ:0Ì@3¸6&¬3 µ<)¼9'¿7'À7'Ã7(Å7)É7*Î7,Ñ7-Ù<3Û:2Þ93å<7ê>:ê=9ç85ã41è96ë<9ì::è8:ì>@øPPÿbcÿppùheâTPÊ=6À1+É40Ö;7ß=:à;7â;5á:2â94á83ã73ä73å55æ66é69é69ê7;ë8<ë8>ê7=è7=é6:ï8<ì89è8:ã;:Ý>:Ó>7É<2À8ÛTXûepîK\ïI]éJ\ÛM[ÉQZ´VV ZRŠ`RPI7HM9NI5H@+;567>O%Lf6lŠTw”\„›e‰šd›f£k”­t˜°|ƒ•mn}\Q`Cg{HiƒFl‹Gm‘Gj“Gf’GbGcŽGhJlMo’Pn“PlMiŽKjJj’Ls›TsUsSržQržOs¢Rw¦Uz«Zv¦Zu¥[s£YRK;RK;RJ=RJ=RJ=RJ=RJ=RK;UNXQ?YR@[TD\UE\UEb[HaZHaYLbYRe][kaiqftuj{zn„|pˆs‹s‰|p„uj{mbre]jc`k`_g_\c_Z^^ZY^YUaZRbZOe[Og[Ki\Kk\Ik\Gm]Fm]Fj^HicMqfTqZJuOB‹WJœ\P£YL¬ZL¥N=¦E4§<,±7(Â8-Ñ80Ü41Ý1-ß6/Þ7.Þ7.Þ7.Þ7.Û7+Ø6)×7)Õ8)Ô8)Ò9)Ò9)Ò9+Ò9+Ô8+Í;,½;+¶>-®9(©1 «2!·9*ÀÔH9Â=,·2#ÝPFØJ@ÔF<ÔD;ÚG?ÞG@àC>à<:à74æ87ì::ì::ç77â64à93Ü=7ÙF>ÏB9Ä:/¼4(·1&¹5)¿;/Ã?3Ã:0É<3Ò?7Ú?:â=;ç;9ì89í9:ç7:å8:å8:å99å97å97å95å95à40á51ä65å76æ89ç9:ç9:ç9;ë;>æ9;ß99Ü=:ÖA=ÍB;ÁA6·?1©:)£<+ =*›<(™:&–:%—8&‘8&A0‹<-‡/#‘/&¼LJämoçloÍVZ½LNµNOªQM¢UO›XO—]R•aTŠjSWZ/:M7FTa)~ŽP›°oŸ¼yœ½x’µs~ah€L\mCYdBT]BHP9?D0:=,@C2<@1:>0]sBgƒHpKo“Kl’Gj’Ii“KgJlPm‘So“Sl“Pm’Mk“Jm–Jm˜IqœLqžMrŸNr¡Pt£Rv§UyªYzª^y¦cm™ZbŽOWN?WN?WN?WN?WN?WN?WN?WN?XO@YPAYPA[RC\SD]TE^UF_VGd[JcZIcYMcYOf[Uj_]nbdpdhreltgpvirvirsfmm`gg[_bXY^[VZZRYVOWTKXTIXTH\VH^WGcZKcZIf[Ig\Hi]Gj^Fk_Gh`IcbMngTv\MSFšVM«VO°RJ·QE¯H9¬C0¬=,±9)¾8,Ë80Õ62Ù40Ý6.Ü8.Ü8.Ü8.Û7-Ú8-Ù7,×7+×7+Õ7+Õ7+Õ7+Ô8+Ô8+Ô8+Î:,¾<.¶>.®9(¦1 §2 ²:)¹>.¾<.Æ:-Ç4*Ë4)Ò;0ÜE:áOBßQCÝOCÛF?Ø@;Ó<5Ò;4Ö=7Ú=8Ü86Ý33ç77ë78î79ë78ç77å97â=9ÛB:ÊA7¿?4¸:,±6'¯5&²8)¸=-¿@1ÅA4Í@6×@7ß=8ã:7é77ï56ñ7:é6:ç6<ç7:æ89æ87å95å95ã:5â92ã:3ã:5ä;6ä;8ä;8å99å99ä:;ã;;ß<=Ù?=ÐA;Ä?6·=2¬;-¥;+ =*œ=+—<)–;(’:&“8%Œ:%€9'€8)‰5*<5¿QP×eeÑ^a·MM¬NL¤TMYP˜\Q—^S—^S˜_VŒfQ`_/Sg*^r3zO™¯n¥¾|™²pˆ bj‚HauBTe;JX7FP7?H59?158-:^tEgƒHqMp”Ln’Hk”Hk“Lh‘Km‘Qn’Tm”Sm”Qk“Lk”Hl—Hm˜HpJpJp Ls¢Qu¦Tx©Xx©Xx¨^m—Xb‹QY‚H]TE]TE]TE]TE]TE]TE]TE]TE[RC\SD]TE^UF_VG`WHaXIaXGe]Je]Hd[Jd[Le[Qf[Uh]Yh][i]]j^^k__k__i^\f[YbWS_VQZVMWTKUQHRNCQMBSOCWQCXRB^WG^WEaYFc[Fg\Hi^Hk`JhbLbaMngUy_PˆXN¢[U±VQ²IE¸E@¹@7¸>1·;/¸8+¼8+Ã9,É;/Ñ:/Ù8.Û7-Û7-Û9.Ú8-Ù7,Ù7,×7+×7+Õ7+Õ7+Ô8+Ô8+Ô8+Ò9+Í;,À>0¶>.­:(£2 £3ª:&³>,¹>.Ä?0Ä8+Å2(È4*Ð<0ØF9ÜM?âNDÙ:6Ø43Ô20Ö42Û97á=<æ<<é;<í9<î5:ë27é26è58å99á<:Ù@:¾8-µ:+±6'®4%­5%°8(µ<+»=.ÈD5ÏC6ÖB8Ü=7â94è64í55ï79ê69é69é69ç77ç77æ95å95å:3ã:3ä;4ä;6ã<6ã;8â:9á99Þ88Ý9:Ü<<Ú@>ÓB=È?9¹:1­7+¥7(¡;,<+™<+”;)“:(9&7%Š9&z6#y6%ˆ9, F=¹SOÀWT¸PO«IF¢MHœSL™YP—^S—aW—aW˜_V‹ePsrFzV“¦n¤¹€«À‡ž³{|[[oaXIaXIaXIaXIaXIaXIaXIaXI_VG`WH`WHaXIbYJcZKd[Ld[Je]Hf^Gf^Ig_Lg^Of\Pf\Rf\Sh]Wh]Wh]Wh^Ug]Te[QdZPc[N]YMZVJVRFRNBPL@PM>TN@UO?WQAYTA[VC]XDaZGd]Jf_LfaMdcQleUv\OŠ[Q©b\¸ZX¶FD¹<:Ã<8Æ;6Ä:0Â8-½8)¼:*¾?.Ç?/Ó9-Ù7,Ú8-Ù9-Ú8-Ø8,Ø8,Õ7+Õ7+Ô8+Ô8+Ô8+Ô8+Ô8+Ò9+Í;,Á?1¶>.¬9'¢3 3¢8"¬=)µ@.¼?-¿:+Ã7*Å5*Ë7+Î:.Îî7<ì38é06æ25å58á77Ú65Î61·5(¯7'®6&¬7&¬7&®9(²:)µ:*ÃA1ÊB4ÔA7Ü?8â;5æ95ë76î87í68ë78ë78ê86ê86è94ç:4æ;4â92á:2ß:4à;7Þ:8Ü:8Û97Ù99Ö<:Õ@<ÒC=ÊA;»;2¯6+¤6'ž7(œ;*˜;)”;)’;(:&8$Œ7#‡9%€=*v5#5'™E:ªPH¬MG©LG¦QLPJ˜UL”ZO”^R•aV•aV—aWgT‰…_™©x­½Ž¦¸ˆ¡ts†YN`8/A->3B%:F.=F3;A3:=2:=4<=599-?@2<>39<1<@29B/?L2PbNK:NK:NK:PMTQ@VS@XWC[ZF]\H^]Kb`Qf^QmWJ†[R¬ic¾c`ÁMMÈBCÐ;=Ô89Ó84Ì70Á9+º=)µC+¼B+Î;+×7)Ø8*×:+Ù9+Ö9*Ö9*Ô8)Ô8)Ô8)Ô8)Ò9)Ò9)Ò9)Ò9)Í;,Á?1¶>0«:(¡6"š4›7 £=&¯B-³;*º;,Â:,Ç9-Ë8.Î:0Ð<0Ù:4é9<ì4<æ39ã28â38á48â38â25é6<é49ç4:ç7:ã9<Û76Ð21À0(´6(­:(­:(«:(«:(«:(¬9&¯7&¸:+Á;/Î>3Ø?7à=8ä;8è96ì87î66î66î66í74ê84è:3ç:3ä<3á:2ß;2ß<5Ü=7Û=:Ù><×=;Ô>=Ï@<ËB<ÅB:¹=5­7-£5(ž7(š:*–;)“<)‘;*:(Š9&‰8%ˆ7$ƒ8%ƒ@-u4"{3%“G:¤QI¡NFžNG¡WN˜UL’XLZN\N]R”`U—aWhW‰f˜¥z©€Žj]kHDS42@&$2-:&0;*5=.9?3?1;=28;0;?18A.>K1PbÜ87Ô70Ç;.¼?+±C*µA(Ê;*Ô7(Õ8)Õ9*Ö9*Õ9*Õ9*Ô8)Ô8)Ò9)Ò9)Ò9)Ò9)Ò9)Ò9)Í;,Á?1µ=/«<)¢9$™6•5›;"§A*²B.¹@/¿;,Ã7*Å2(Ë4+Ò;0ß=8ê5:î3<ë6=é8>ç:>ä;>ã:=â9<ß58á7:â9>á=>Û=>Ñ96Ã2/¶0'¯9+«>*«>*©>*ª=)©<(©:'«8%¯6%¹7)Å;0Ð=3Ù<5ß<7ä;8è;7î87ï75ï75î85ë:4é;4ç<4ä=4â>5à?7ÞA:ÚA;ÙA>ÕA?Ñ@=ÍB?Ã?:»@8³=3ª8-¡5(›5'˜8(•<*‘<(<)Š<(ˆ:&†9'„7%ƒ6$6%}:)t3!~9*—OA£YNœRG•OE˜VJ•YN[MŽZMŒ[MŽ\Q“_T™`W‘gW~xXyƒ^r|ZU`B;E,/;%0;*0<.3=24<16<2?1:<17:/:>07@-=J0Oa;bxIk‡Lu”Qu™Qt˜NqšNršSpšRršQsœPr›Op™Kn™Jp›LsžOv¡Ry¥X{§Zz¨]x¦]qŸWg”O]ŠEX‚B`‡NY€ISzCg^Og^Og^Og^Og^Og^Og^Og^Og^Og^Og^Oh_Ph_Ph_Ph_Pi`OjaPjbOjbOjbOi`Oi`OiaNiaNiaNh`Kh`Kh`Ih`IhaGhaGhaGf_Le^Kb[I\WDWR?PM:LI8IH6IH6GH6GJ9GK:HL;IMì;Aê@CæAEàBCÜ@AÙ??Í12Ð66Ó:<Ñ=;É;9¾71µ4.­4)ª<-¥>+¥>+¥@,¥>+¤>(¦;'©:'ª7%²7'¼8+Å8.Ì70Ô94Ü=9æ>;é:7ì95ì95ë:4é;4è;4å=4â>4àB7ÝC9ÚC<ÕB;ÏA=Ê?<Ç=;¿>9±<3©:/¢8+œ6(˜7'”8)‘:):(‹=)‰<*‡<)ƒ:'‚9(€7&6%}6$x3#x5%…B2˜UEWK”PCPD•ZL“YMZN\Q\Q’[T•\U˜[VŽbUkbEV`=JS4=G,6?*2=,4>35?66=68?8=B;CF=EG/;9*78*=>0:<17:/:>06?,=J0N`:awHk‡Lu”Qu™Qt˜Nr›OršSpšPq›OrNqœMp›LošKrNu¡Ty¥X«`~©az¥]qœUf‘L_‰G]‡E^ˆIb‰PY€ISzCh_Ph_Ph_Ph_Ph_Ph_Ph_Ph_Pg^Oh_Ph_Ph_Ph_Ph_Pi`Qi`QmdUlcTjaRi`Qh_Pg^Og^Mh`MiaNiaLiaLiaLh`Ih`IhaGh`IgaKf_Le^Kb[H\WDUR?PMSQDSPAXLÂYSÙROàDEà::Ü75Õ;3Ê>/º=)µ8"É:)Ï8'Ð9(Ò;*Ò;*Ò;*Ò;*Ò;*Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Í;,Á;0¶:.­<,§>+™9#3“7Ÿ?'£9#°;)À>0Æ<1Ì8.Ð7/Ù<5ã?=ì=Bî?DéCEâDCØ@?Ê;7À50»1.¹/,¼51¾:6»<6³:2ª8.¤8,¡:+¡=-Ÿ>+ ?,¡@-¡@-¡A+£>*¦=*©;*­:(²7(¹5)¿5+É90Ô?9àC>ä=7è;5è;5ç<4å<5ä=4á>5Þ@5ÜD9ØD:ÒC;ÊA9Ä?:¼;6¸85°93¢7-™8(•5'“6'‘:)<*‹:)…8&ˆ=*…<+ƒ<*€<)~:'|8%{6&{6&y1#€8*ŒG8–SC’PB‹L=RE™_S‘WL’YN”[R–]T–]V—\V–YTŒ^QaX;EM(6@8A&>G26BE*;:&78(=>09;069.:>06?,F7GK=IK=AE4KJ6\Q;aE/ƒJ9Àj]Üg`ãUSäFEåA@àA=Õ>5É=0Æ=-Æ4%Ë5&Ì6'Í7(Í7(Î8)Ñ;,Ó=.Ò<-Ò<-Ò<-Ò<-Ñ;,Ñ;,Ñ;,Î<-»2(¶7.±;/¨:)š7"”5•7œ9"®A-³;+º6)Á4*Í6/×<7âC?êHEèDEèEHÝCCÉ:6»61´80®8.©4+«9/©9.¤8. 8-›9,–:+“<+’<+–=+˜=*™>+š?,›@-A, A-£@-¢;*¥:(«7(°6)¶6+¾8-Ä;3Ì<4Ú=6à=6â?8âA7âA9ÞB6Ú@6×@5ØH=ÒE;ÇA8»;2²5/ª3-¦1*Ÿ2+™9-’;*‘9+:*‹:)ˆ;)‡;+…<+€9'}8(|9(|9(|9({8'y6&x3$w- ‹A4—OC“MAŽL@‘QE“UJŽRG˜\R˜\R‘UMTL—ZU•XS”WT“gZ]T5IQ*AK(BK,>H/7@+2=-4?14<1HPCZ^PW[JMO:DF.AA'==%:;)>?1;=2:=2;?14=*;H.PbF7>F7=E6@F8>E5>F1HL5MI0U?'Q:¼sbËcXà_ZëUTçGGâ@>àA=Ø?9Î:0Í9+Î=,Ï=.Ï>-Ï;-Î;+Í9+Í:*Î:,Ð:+Ð:,Ð:+Ð:,Ð:+Ð:,Í;.É?5ÅB:¼B7®=/Ÿ6#–1–1›2¨5#´6(Ã;/ÑA8ÞE?æIDéJFêKHÞCAÛEDÐB>¼<3¯9/©=0¥?1Ÿ=0Ÿ?1œ>2—>0”>/=/Š>.‡@.ˆ?,Ž=*‘;*’<+“=,”?+•>+—>,™>,Ÿ@.¡=-¤:,¨8,¬8+±8-¶:0¼9/Ê<2Ð<2Ó?5ÕA7×C9ÖC9ÔD9ÑE8ÊB6ÃA4¹=3°:0©6/¤5.Ÿ4,™7,’:.Œ=,Š;,ˆ;+†:*„;*ƒ<*<,~;*|;){9)y:)x9(w8'u6'w4$€4'D7˜NC‘K?ŒJ>QD’TIRG“SJ˜XO˜UO—VPœ]X”WRŽSOŠcT]W5Xc9_jBZfBIT66C)4@*0:<19<1<@25>+;H.PbMKD63Å?3ÅA4ÃA3ÁA4¶;,²:,ª8-£7+ž6+›6,˜7.”:/;/ˆ<,‡;-„;,‚:+€;+€;+<,};+z;*z;,w9*v8)u7(t6)v4&ˆ;1”F<–NBŽJ=ˆHEI0?C(=@#:<$89';<.8:/9<1=A36?,MK4Ñ>4Ò>4Ò>4Ó?5Ó?5Ó?5Ó>7Ó?;ÑB>ËD>ÆF=ÂF<ÃI>ÇM@ÎPDÙSHÝPGâMGäIEäGBâC?àA=ÛB=ÕFBÉD?º?7«=0Ÿ>.šC0•G3”I6F4ŒE3ˆC3…B1€A0}@.zA.|?-‚:,†8,…9+†:,†:,‡;-‡;+ˆ;+‰:+‹:)Ž8)8*•9,™;/=/¢<0ª:/­8.¯9/°:.°:.°:,¯9+®8*¨7)¥7(ž6)›6*•7+’8-‘9/Ž<0ˆ<.…<-ƒ;,9*:*~9*}:*};+|:,z;,y;,w9*s8*q6(r7)u5)ŒD8’H=‘K?ŠH:‡I<‹OD“TK—TL–QL›TP˜QO”SO–\X_Xh^—~j””p…’fu‚WYh?CR+?O*P`B)=A(;='78(:;-79.9<1=A37@-NKB1=I1?G/LG1S>+g=-•ZL­_Sœ>4ž3+¶?9ØXUóigödeëRUæJNèNPÙIAÓF<Í@6Ë>4Î@6ÒD:ÕG=×G>ÚJAÚJAÝJBÝJBÞKCÞKCàKDàKEëSRèTTãSRÜROØSLØSLÛULàUNàLHáIFãEBâC@äB@âC@äEBàFDÙJFÊE@¹>7¬=2¡?2˜B1’E3G4ŒE3ˆC3‡B3ƒ@0?1~?0z?/|>/€:.ƒ9.ƒ9.ƒ9.ƒ;-ƒ;-ƒ;-ƒ;-9*‚9*…9+‡:*‰:+;-<.“;/›;/ž9-Ÿ9- :,¡9,¢8+¢8*¢8*Ÿ8)œ8)˜8(”8)9*Œ:,‰:-‡;-„:-‚:,9+€8*}8)}7+|8+{9+z8,y9-x:-v8+q5*o5)q7+t9+ŒH;I<‰I=„I;…K?ŒRF“WM˜XO˜QMœUQ˜RP“VQ’`YˆbWƒg[†zdnrQZi@JY0AR(IZ0Wi?dvNj|VXiEL[:?L.:D)C-B47@-;H.L^8_uFi…Jt“Pt˜Pt˜Nr›Os›TpœQnMmžLp¡Pw¨Y|ªaz¨`rXi“QZƒA\„EaˆIeŒMgŽMgŽKhJfŠLc†PY{IRtBi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkaUlbYlbYlbYlbVlbVlcRlcRldQldQldQlcRlcTlbVlbXlbXlbXocUnbRkbQlcRlcRkbQg`Pd]M^WGYSCSM?MJ;KH9GE6EB3?B/;H.?H-OC-a=-ƒE:«XR´NJž,+²:9¹=;ÓSRòpnþvvñehëX^ð^_ãUQÚPFÔG@ÐC:ÑD=ÔG>ÖGAÖG?ÙHCÚJBÜHDÝJCÞJFÞKDàKGàKGâHHáGIÜHHÙGGÖHD×HDØGBÛFBàBAäABæBAèBBçCBäB@ßA>ÛA?ÛJGÊC?¹<6®>3¢@3˜A0A0C3ŠA2ˆ@1‡?1…=1‚<0€<1=1=1;1;1ƒ:3;1;1€.™9)–9(“:*:+Š;,‡;+„;,‚:+‚:,9+7)~6({5){5){5)z6)x6*x8,w9,s8*p4)o5)r:-v<0‹M@‰K<„J<‚M=…QC‹VH’XM—WN“NI™TO—VR•\Ue\{^PfVF`^GEO->N)?O(J\2_rEk~QexKXj@M_7@Q-6E&7D*=F1=D4:>07;-8:,:;-68-8;0>B47@-9F,I[5[qBeFr‘Ns—Os—Mr›Os›TpœQmœLo Os¤Ux¨\z¨`s [i“Q`ŠHYB^†GeŒMgŽMfJeGgŒGhŒLa„NXzHQsAi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkbSlbXlbVlbVlcRlcRldOldOldMldMldMldOldQlcRlcTlbVlbVocUmaSkbSlcTmdUlcTi`Qf_Ob[K^WGXQARLÐB>Í@9ÒC?ÒC=ÔC@ÕD?×CAØD@ÙECÚDCÝADÝADÞDFÝGHßIHàJIãIIåGHçACêADìBEìBEçAAâ@>Û=:Õ=:ÚFFÉ=<¹83°;2¦@4˜?1‘>0@1ŠG]/AV-7H$1@!6B*=F5PK8MH5ID1DC.@F*DD([B,ˆTG¯\X«>A¬/3ÎINÆ?EÀ;>»;<ÄFGØZ[ãefÛY[ÌGHÑJGÐEBÍB?ÐB>ÔFBÔFBÐB>É>7ÏD=ÏD=ÒD@ÔEAÖEBÙECÚDEÝDFÞ?Cß@DÞBEßEEáGGàFFàBCá>?èBDé@Cè>Aç=>ä>>ãA?áC@ßECÖBBÅ98¶50°;4¦?6š>3=/?2ˆ)=C5ã?>â@=â@=ÞC?ÓB?Å>:¶93ª70Ÿ:0—=2Ž>3†>2ƒ?2?3=2;3„93†93ˆ81ˆ92…;0„<.„<.ƒ;-;/€:.€:.€:.~:-~:-~:-~:-};/};/};/};/}90}90~80~8.€7.€7.€7.~8,€8,~8,}9,|8-{9-z8,x8,x8,x8.x8.w7-v8-v6,t6+s5*q5+m1'r6,n4)m3(o6+m4)q8-I=…SH…SJ†RGˆRH‹PHQJ”QK•RL“TMTK‰[N‚cQo_HYU:MV7O_;j~YbxQYoHUjCRg@Mb;IY5CR17D&4>#2:#6;'<>0@B5@@6<>358-39-4:.7:/9=/;?.=B,%Q?)kP=XG„NBˆE=“D?±WV¸TT»QQÀPOÀNMÁMMÂLJÃKJÐTTÈHGÂ=>Ä=:ÐB@ÓEAÏB;Ç>4ÊD9ÉE9ËF=ÍG>ÔFBØDDÜAEÝAEáBFáCDáCDâDEâDCáFDáFDáFDàEAßD@àB?ßA>àA=àA=àA=ÞC?ÔE?ÈC<º>6¬:0 90”:/Š<0‚<0€A2~@3~>4<3ƒ:3†91ˆ81‰90‡;.…<-„;,„;,ƒ;-‚:,‚:,‚:,9-9-9-9-~:/~:/~:/~:/}90}90}90}90}90}90|90|90|90z:0z:0y9/y9/y9/w9.w9.w8/w8/t8.s7-r6,r6,p6+p6+k1&q7,m4)l3(o6+l3(p7,~H>„RI…SLˆQJ‹PJQL”PM•QN”SOŠOG…SH€[K{ePsiPhkLfqQgxT^tMXnGPf?La:K_:K\:GV7CP4>2;=04:03;05;16<0:A,>D*Q[9^mDkRpŒRp“Sq™RsSsžVxŸ^|¢exžak‘T`†I]ƒF]ƒF\‚E`†Ia‡Jc‰Le‹NdŠMbˆK`†I^„I]LRtBIk9i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTqdTo_Pm]Pm_RqeYog\ldYhbVfbWpl`{xi~{jyizubpiVe`JTT(MB.S@/U8(]7*l=3n70u91~;5‡@:’IB›PJ¥XP­ZR»^YºSN·GE¼B?ÈDBÑFCÓD@Ï@:ÐA;ÐC<ÒE>ÔG@ÖGCÚFFÛEFÞDFßCDßCDßCDßCDàDEßEEßECßECÞDBÞDBÜD?ÛC>ÜC=ÜC=ÜC=ÛC>ÖE@ÎE?ÃB<³>5¢:1”8-ˆ9,ƒ;-‚@2@1~>2=1ƒ:1†91‡81ˆ:0‡;.„;,„;,„;,‚:,‚:,€:.€:.9-9-~:/~:/~:/~:/~:/~:/}90}90}90}90|90{8/{8/{8/{;1{;1z:0y;0x:/x:/x:/x:/t8.t8.s7-s7-r6,q5+o5*o5*j1&o6+m4)k2'l6*i3'm7+}G=‡PI‡PI‹PJŽQL‘RM’SN”UP‘VPŒWO‡[P~^OtbNoiQorUlwYfwUQeBK_:EY6DU3EV6GV9GT8ER8?I0*7;*:<.<>0;=/9;.6<25=26<26<0:0=@-=C)MW5Zi@f|MlˆNn‘Qq™RuŸUtŸWz¡`w`n”Wc‰L\‚E\‚E\‚EZ€C_…Ha‡JbˆKdŠMc‰La‡J_…H]ƒH[}JPr@Gi7i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTrdWoaTm_Rk_SkaWlcZle[jf]jf]xtiˆ„x‘•’Œ~‰‚r}zg`cNOT>DG2FE1HC0F=,L<,VC4P9+R6*V4*Y5)\6+a9/e=1m=1ŠKBSJ®UO¶NK¼FDÆABÒDCØFFÔ@>ÕA?ÖB>ÖE@ÙECÚFDÛEDÝEDÞDDßCDßCDÞDDÞDDÝEDÝEBÞFCÛFBÚEAÙD>ØE>×D<×D<ÙD=ØE>ÔD<ÓF?ÉF>ºA8§;1˜8,Œ9+…<-ƒ@0@1~?0=/ƒ:1„:/‡9/ˆ:.„:-„;,„;,ƒ:+‚:,‚:,9-9-9-9-~:/~:/~:/~:/~:/~:/}90|90}90{8/{8/{8/{8/x8.{;1y;0y;0y;0x:/x:/x:/v:/s7-s7-s7-r6,q5+o5*o5*m4)j1&o6+l3(h2&k5)h2&l6*|F<ŠOGŒOJPKRMSN‘VPWPŒZQ‰]R…aUy_PiZGd_IdhO\fKN]@EU8AQ4=M0G2:A/9=,9=.9=.8<-7;-7=36=56;46<2:<1;=/bxIj†Ln‘Qs›Tw¡Wx¢Z{¢ar˜[e‹N\‚EZ€C\‚E\‚EZ€C_…H`†Ia‡JbˆKa‡J`†I^„G]ƒHY{HNp>Eg5haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTrfXth\sg[mcYjaXle]snhzwp~w† ”¨¥œ«§œ¨¤™£‘™–‡z{kcfSOR?GJ7EH5BE2BE2EH5KL0A9,A7+@6*F4(S5*qB8ŒPHŸPK¯IG¿GIÌEIÓBEÖ@BÙ@BÚBAÛCBÚEAÚEAÜDAÜDAÞDDÞDFÞDFÞDFÞDDÝEDÝEDÚDCÚFB×FAÖF>ÔE=ÔE=ÓF=ÔE=ÕF>ÔA:ÓC;ÎE=ÁB9®>3ž9-‘;.Š.€=-;/„:-†:-‡;.„:-ƒ;-‚:,‚:,‚:,9+9-9-~:/~:/~:/~:/}:1}:1}:1}:1|91z:1|91y90y90x8/x8/v7.y:1y:1x90v:0v:0u9/u9/t:/r7/q6.q6.p5-o4,n3+n3+m4+j1(m7-j4*h2(j4*f2'j6+}D;NGNHQJTLUOŽWPŠYRƒ[Q{YMv\OkZJ]UBYXDY^HOYA?K3:H/7E.4B+5A+8D.=I3CL7EN9BK6?H5.5<,4:,5<45<56;56;49;0:-;@)GP1Ra:`vGi…Ko’RuVy£Yy£[xŸ`n‘W`ƒIZ}C[~D^G^G]€F`ƒIa„Jb…Kb…Ka„J`ƒI_‚H^IW|ILp@Bf6haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTkaUndZpf\lcZkd\rmg„|‘Œ§£ µ±®ÄÁ¼ÉÆÁÉľÅÀºÀ¹±¹²¨¤œˆ‚rfcTPQ?FI8>E3;D1:F28E38E38C2:B34(P:/e?6€EA¡PO¿X[ÊQVÊCIÕFJ×EFÚFFÛEDÝEBÞDBÝD?ÞCAÞDDÞDFÞDFÞDFÜDCÜDCÜDCÚDCÙEA×FAÕF@ÓF=ÒE<ÐF<ÑG=ÔE=Ô?8Õ@9ÐC:ÆC9¶A7¥=0–=/Œ=.†>/‚?/>.€=-<-ƒ;-„:-…;.‚:,‚:,‚:,‚:,9+:+9-~8,~:/~:/~:/~:/}:1}:1}:1}:1z:1z:1y90y90x8/v7.v7.t8.w8/u9/u9/s9.t8.s9.r8-r8-q6.q6.p5-o4,n3+m4+l3*j4*h2(l6,i3)f2'h4)e1&i5*{B9ŽMG’MH‘PJTLVO‡XNYO|\Qs\Nk[L`WFVSBPSBJQ?@I64@,3<+2;*09(09(2;*5>-9B1G4:F2:C25@/3>-1<,3:33954954928919;.;>-;@*CL/O^7]sDi„Mp“SwŸYy£Yw¡Yq˜Yf‰OZ}CX{A\E]€F]€F^G`ƒI`ƒI`ƒI`ƒI`ƒI_‚H^G]€JV{HJn@Ae7haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlbVj`VjaXkdZkg^upjˆ…€Ÿžš°°®ÃÂÀÓÒÐâáßçæäçãàãÞÚÞÖÓÙÎÈμ²¸¥——‡zym]_YIKL:@E1;D/>J6=H7=F5;C4;>5:;3983880==3C<2N71a84ˆHH¯]_Å`dÊWZÍQSÓNO×MKÛKJÞHGáFDãDAâBBßCDÞDFÞDFÝCEÝCEÜBDÜBBÛCBÚDCØD@ÕD?ÓF?ÒE<ÐF<ÐG=ÔE=Ù@:Ù@:ÑB:ÈC:¼C:¬@4™;/Œ9+‰=/ƒ>.>-€=,<,ƒ;,ƒ;,„<-‚:,‚:,‚:,9+9-9-~8.}9.~:/~:/}:1}:1}:1}:1}:1}:1z:1y:1x90x90w8/t8.s7-r8-t8.s9.r8-q8-r8-p7,p7,p7,o6-o6-n5,n5,m4+l3*k2)i3)g1'k7,h4)e1&h4)b0%f4)zA8MG’MH‘PJŽULˆXNYOxZOr\Nk^N^WGRPAKN=CJ:9B12:+08)17+17-06,/5+/5)08+2:+4<-9D4;F5=H7-.800621622717829;0:<.:?)?H+KY5[qChƒLq“Vwž[w¡YsœVgP^IUx@WzB[~F[~F[~F]€H_‚J_‚J_‚J_‚J^I^I]€H]€JUvIJk@@a6haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlbVpg^ng_lgatqj‡„¡ œ¼¼ºÎÐÏÏÏÏàààòòòúøùû÷ö÷óðñìéðâßèÐÆÝÁµÁ«¢‘}ub^\GKM7CH2AI2AI4@G5BD7AA7B=9C97?:69<5>?7B71J.+d66QR³giÆnmÀ\\ÇZWÐVS×QNÜLKâHHæCDåBCßCFÝDFÝDFÝCEÝCEÜBDÜBBÜBBÜDCÙCB×C?ÓD>ÒE>ÐF<ÐF<ÔE=ÜC=ÛA9ÒB:ÊD;¿E:°A6œ:-‹5&ŠD69A208+/7*6<247058157247025.06,08-19,6A3:E5=J9>K9-,6..400511606718:/:<.:?+WzB[~FY|DY|D\G_‚J_‚J^I^I^I]€H]€H]LStIHhA?]7icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSjcSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUmdUmdUldWibZgd]vsn“’ޝ¯­ÄÆÅÚÜÛêîïóôöö÷ùüüþÿÿÿÿÿýÿûúü÷ôýòì÷áÔòØÇàʵƶŸª ‡ˆ„ibbFEH-DH/CG0FE1GD5F<3C60F42H:9>=9>?:B:7I75cGF’jjÅ“’è­©Ò‹‡ÇtnÀ]XÆSPÕONßJLçFKéFKßEGßIKÚDFÔ;>Ø>@áGIàDGÖ:=Ú@@Ú@@ÙA@ÖB>ÔC>ÑB<ÐA;ÑA9ÞC>ÛA9Ó@9ÊA9¾B8°@5Ÿ:.8*Œ=0‡>/ƒ>.>-€=,<+=*<,:+9-9-~8,~8.|8-|8-|8-|90|90|90|90z:1z:1z:1z:1y=5w<4w;3u:2t91q8/p7.p7.o6-m7-m7-l8-m7-l8-m7-m7-i2+m6/p92o81k4-g2*g2*h3+e0(i7.d2)]-#`0&_/%b2(s>6ŒOJPKˆQJRJ}YMv_QfYITN>DE5>E5:C25@04&DR1WlCh‚Rs”]wž_r›Wk”R[~DXyDTu@Tu@WxCZ{F[|GZ{F^JbƒNbƒN^J\}H_€K`L^~MTsJFd@2I:3L95K<9?:7BA?MHE]RPyjg£Ž‹Î²®èÅ¿ÿ×Ñ쳪͂|Àc^ÊVVØRSßHMÚADÖDEÕEEØHHÜJKÛEFÕ<>Ö<>ÛACÙ??Ù??ÙA@×A@ÖB>ÓB=ÒA<Ó@9ÜA<Û@;Ó@9ËB:¿C;±A6 ;1’8-Œ=0‡>/ƒ>.>-€=,<+<,<,:+9-9-~8,}9.|8-|8-|8-|90|90|90|90z:1{;2{;2z;2w<4u<3u:2s:1r90n8.o6-m7-m7-l8-l8-l8-l8-j8-l8-l8-k6.n70o81n91l7/i4,g2*e3*c1(d4*_/%^.$b2(^.$`0&p>5JE‡RL‡XR~XOrVKdRDQJ:>?/:A16A05@03>04<14<15;17:379477577557246116//6./7,.9+1<.4A08E49H58G44E24B1.8/.5..3--2+23+46+8:-9=,7?(DQ3WlEh‚Ut•`wbp˜YgPY|DWxCTu@Tu@VwBYzEYzEYzE[|G_€K_€K\}H[|G^J^J^{MSnKF_A9R4icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUneVneVlfZed_y{x—™˜²¶·ÍÑÒäéìôùüúÿÿûÿÿüÿÿýþÿþþþÿþüÿÿûÿÿúÿÿôþüçúùÝïðÑáåÄÒØ´¼ÄŸ ¨ƒ‡‘l`gEQX7DG,DC.JD4LD7KA8I>:C;9SJKia_wvœ’¾³¯ÙÎÈêÜÓþèÝÿóéÿäÛð©£ÃecµBEÇDIÚRVÛUTÑMKÊDAÍCAÔFE×EFØDDÙCDÖ=?×>@Ø@?Ö@?ÖB@ÓB?ÓB=ÔA:Ù@:Ù@:ÒB:ËE<ÀD<²B7¡<2“9.Ž<0‰=0ƒ>/>.=-~<,€=-€=-9-9-~:/}9.}9.|8-{8/{8/}:1}:1{;2{;2{;2{;2z;4x<4t;2q;1r90o9/n8.l8-l6,k7,l8-j8-j8-j8-j8-i9-j8-j8-n91m80m80m80m80i7.f4+c1(d2)a1']-#_0&c4*\-#_0&sD<}PJVP~YQpTI^J?OC7?<-46(2;*0;+1<.2=/4<14<15;17:379479668357257227007/08-.9+0;-2?.6C27E48G48G49F54>33:2/4-,2(/0(13(57*6:)6>'DQ5YmJk„Zw—fwœfl“Z_‡KWxCWuCTr@Tr@VtBXvDYwEYwEZxF]{I_}K]{I]{I_}K^|JZwKPgJAW@3I2icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSjcSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUneVneVneVneVmg[jkfƒ‡ˆ£§¨¹¾ÁÐÕØåíïóûýõýÿûÿÿûÿÿüÿÿüþûýþùþýøÿþ÷ÿÿóøýæôýÞî÷ØæòÎÝéÃÎÚ´¶Á™¡«†€‡efmLMQ6FH0HJ5KI:HD9D@7OGDj`_‹€¤š™·¯¬ËÆÂÞÛÔêæÝúñèÿûñÿ÷íÿÝÕû¶±åŽÊcd°@?ÃPKÉTMÉPHÃF@ÈGBÔMJÖKHÐ@?Ò>>Ó??Õ?>ÕA?ÕA?ÓB?ÓB=ÓB=Ö>9Õ@:ÒC=ÌE?ÀE>²A9¢=5•;2Ž<1‰=0ƒ>/>.=/~<,€=-€=-9-9-~:/}9.}9.|8-{8/{8/~;2~;2|<3{;2{;2{;2z;4x<4r90o9/o9/m9.l8-k7,j6+h6+i7,i7,i7,h8,h8,h8,h8,h8,m;2l7/j5-i7.j8/j8/f4+a1'e5+a2(].$a2(b3)Y* a2(yNE\VvWRiNGWC:I<3@:.:;-8<.08)/:*3;.4Ð@?ÑA@ÒC?ÑC?ÑC?ÒC=Ó?;ÒA<ÐE@ÉE@½C>¯@9 >5•=3Ž<1‰<2ƒ=1=0=1~<.=/=/~:/~:/~:/}9.|90{8/{8/{8/|<3|<3|<3{;2z;4y:3y:3w;3n70m80l7/l7/k6.h6-h6-h6-i7.h8.h8.g8.g8.g8.g8.h8.k92h6/f4-g5.i70h70e4-b1*c2+b3+_0(]1(]1(V*!b6-{ULtYRaNHN?8A7.=6,;9-9;.9<139-3;.5;/6<06<07:/58-47.69049238139/39/2:/19.19,.9+.9+/:,0;-3>.6C2:E5Qn>Qn>Qn>Qn>Qn>Sp@Sp@WtD[xH]zJ]zJ_|L_|LZwGRlECU?6D7(6)gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSkbSkbSlcTlcTmdUmdUmdUmdUmdUneVneVofWpgXpgXng]lnmz‚…“š «µ·ÄÎÐÜæèí÷ùôþÿõþýöÿüúÿúûÿùûþóøúíõöèñôãôýêôýèôüåóùßòöÛéìÍØ×¹ÅÄ¥±°’ŽregOMP;GK:FM=GOBKQG{{sŸš”ž¸ØÎÌßÓÓçÛÛóëéü÷ôðïêüüôÿÿöÿýóÿùïÿóêÿçÞÿ×ËØ“ƒ¸eS£J:´TF½WIµF;·@8ÈKEÇC>ÊC?ÌB?ÎC@ÎC>ÎC>ÍD>ÍB=ÑB<ÒC?ÎDAÅD?¸A=ª=8ž;5•<4Ž;3‰<2ƒ=3=2=1~<0=1=/~:/~:/~:/}9.|90{8/{8/{8/|<3{;2{;2z:1y:3x92w81u91n70l7/l7/j8/i7.i7.h6-g7-g7-g7-f7-f7-f7-f7-f7-f7-h70h6/g5.g5.g6/h70g6/f5.a2*e6.^2)\0'`4+a5,i=4uSJXG@E>6<5/95,;8/8:/57,36+69.5;/7:/69.69.58-57,36+28,19,28.19,19.19,19,19,.9+.9+.9+/:,0;+3>.6A17B2ex\umt’lf‰_RwKBh9KkVsCZwG]zJ^{K_|L_|LVsCNg@ÉD=ÈC<ÉB<ÑC?ÐE@ÌEAÂC=³=9¦;5œ;5•<6Œ<3‡=4…<5=4<3~<0=1=1~:/~:/~:/}9.|90{8/{8/{8/{;2{;2y:3x92w81v70v70s7/n70j8/j8/j8/j8/h8.h8.h8.g7-f7-f7-f7-d8-d8-d8-f7-g6/h70i81i81h70i81j;3l=5g80k<4b6-a5,oC:xLCtI@nMDC9056.45/8918;247.14+25,58-58-57,46+46+46+46)37)/7(.9)08+.9).9+.9)08)08)19*08)08+/7*08+19,3;.4<-9B1:C0;B0:A1:<.68*24&/3$29'IU?cu[m„gf„bWyTInE?d8Hg;Li;Nk=Nk=Li;Li;Mj
    UrDYvH[xJ]zL^{M\yKQn@G_;6B4+4/#)%gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSjcSjbUlbVlbVmcWmdUmdUmdUleUmfVngWogZnh\oh^mjekormtzƒŠ¥®³ÃÌÑÕßáæîñôüþôýú÷ýùùþ÷úÿôüÿòüÿñüÿîýþðûøïþúñÿùïÿúíÿùéÿòßïàËÝηÁ²›¢—|ubb_NXZL]cWmwn|†}¦¬¢¾ÀµÚÕÏîäâüîîÿôôÿô÷þôõÿùùûúøûýøüÿúøÿõôüñ÷ýñÿÿñÿùèÿôãÿÌ»½p›QD©SFµSH²C:ÀJ@ÄH@ÇG>ÉF>ÈE=ÇD<ÆC;ÆC;ÍG>ÌG>ÇG>¼C;­>5Ÿ:2—:3‘>6Š=5†=4ƒ=5=4€<3;0;1;1~:/~:/~:1}90|90{8/{8/{8/z:1z:1x92w81v70u6/u6/q6.m80k90j8/j8/i9/i9/i9/h8.g7-f7-g7-f7-f7-f7-f7-f7-f5.j81m;4k:3j92j:0m>4oC8l@5oD;d<2c=2zVJ†dZyWMbLA>:13814927<54:0/5+25,9<336+25*24)03(13(25*46+47,.6),7)/7*-8*/7*/7*/7*/7*19,08+08-/7,/7,/7,08-08+7?09B14*00!''heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVjdXldYlcZmeZmeXmfVg`NjeRnkXol]he\feasqr‚†Š“–ž¡«³¶ÃÈËØÝàêîïö÷ùùûúüþýþþüÿÿúýþöúýòùüñúýòûþóùúòúúòùùíüúëþüçù÷ÞéåÊÕÔ¶º¹›˜˜|qtY_dMbkXr}l„‚‘›´¹²ËÌÇãâÞòîë÷óòû÷öýùøüø÷ÿþüþþüþþüýÿúýÿúýÿúýÿúýÿúúü÷ÿÿúÿûöÿê娧 £`X›D=µNE¿MCÂF<ÄD9ÊE<ÎI@ÎKAËH@ÇG<ÆG8ÃH8½J8³H8¦E5šB4‘B5‹C5†B5„B6‚@4‚>3‚<2„:1†91†9191~:1|91{80z7/z7/w7.v6-w7.w7.w8/w8/v7.u6-q5+n3+l7/i81i81h70h70g6/g6/g6/f5.g6/i70i81h70g6/e4-e3,h3-j5/m80k90j:0i;.i=0kA3gB2jI:dH:v_O~k\ŠxjŒoRJ=79.4:04:039/39/39/28.28.17-17-36-06,25,/5+14+/5+/4-.5-/4-.5-/4-/4-/4-/4-05./4-/4-.3,.3,/4-/4-/6.1;23=26@58B79D67B45@03>-4?.DQ=WeN[kQPbHEX<@T8BW6Ic>Ke>Kf=Kf=JeOj?UpGYtK\vO]wP]wRWqNHb?;O6&1+&+.$),heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVidQjhSmjWjk[gg_lll~„“š¨¯µ¸ÂÄÑÖÙâçêòóõûüþÿþÿÿþÿþýûÿþúÿÿúþÿùûüôøûòöüò÷ýó÷úñøúïøúí÷úéùûåòõÚßâÃÌЯ´¸—‘–vkqUYaI_kUtoŒ˜Š§œ¿Á¼ÓÓÑççåóóñ÷÷õûûùüüúûûùþþüþþüþþüþþüþþüþþüþþüûÿþõÿÿõÿÿþÿÿÿûúÿíêð¿ºÂ~uŸKA¯M@¹K>ÂL@ÅK>ÃE9¼=4¾?6ÃE9ÄF7ÃJ7½L:³J7¦F6™C2‘C6E7…C7‚B8A7>5‚<4ƒ:3†91„93~92}:2z:1z:1y90x8/v7.v7.u6-v7.t8.t8.t8.r6,o5*m4+l7/i81j81h70i70h70g6/g6/e3,e3,g5.h6/j81j81j81k92k60l71k90k;1k;/j>1j@0iD2gH6kP=gRAufSueŒ…s†ƒrKL<69.39/39/39/28.28.28.17-17-17-17-06,06,/5+/5+/5+/4./4./4./4./4./4./4./4.05//4..3-.3-.3-.3-/4./6/.80/:21=34@66B66B66B45B16C1CP>P]IR`IIW@AO6BP7EU:Jb@Jd?Ke@Ke>Ic6I5&1-',0$)-heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVmhUkiTmjWjk[kkcwww‘’—§¬²¿ÆÌÒÜÞìñô÷üÿþÿÿþÿÿÿþÿÿþÿþýûÿþúÿÿúýþøúûóõøïñ÷ëñ÷ëô÷ìõùëöøêõøåõ÷áîîÔÛÛ¿ÉÊ«°±’“–yuy`kpZt{iˆŸ§œ®µ­ÍÏÊÞÞÜïïíøøöûûùþþüþþüýýûþþüþþüþþüþþüþþüþþüþþüýÿþûÿÿûÿÿÿÿÿÿûùÿúôÿ÷íýÑÆØž”L=¥RB©L;§@1·G;ÏYMÏUJ¼@4ÄD7ÆH:ÃK=¹I;ªB7?3—@7“E;‰@9„A9A8?6~>5}=4<4}=4z;4x<4w;3w;3u:2t91t91t91r90r90r90r90o9/n8.l6,k5+l7/j81l71j81k60i70i70h6/g5.g5.f5.g6/h70i81k:3k:3l;4j;3i:0h<1k?2jC4iD2fE2fI7lVAjYGujV†m‘Ž{€mEF658-28.28.28.17-17-17-06,17-17-17-06,06,/5+/5+/5+/4./4./4./4./4./4./4./4./4./4..3--2,-2,.3-/4..5.+5-+6.-9//;12>24@46B47D38E3?L:ER>CQ:;I28F->L3DT9J_@Jb@LdBKc?Ia=G`9F_8G`9RkDXpL]uS^vVZqTPgK=T8.A.&1-',0%*.heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVniVljUlkWlm]pqi€‚ž¡¦¹¾ÄÄËÑÛåçõúýûÿÿüýÿüýÿþüýüûùÿþüÿÿûÿþùûüôõöîîñæéïãçíßíñâðôåñôãñôßòñÜêêÐØØ¼ÇÇ«²±•¡¡‰‘“}“€œž‘ª­¢¶»´ÀÅ¿ÜÜÚééçööôûûùýýûÿÿýÿÿýýýûþþüþþüþþüþþüþþüþþüþþüþþþûûýÿþÿÿþÿ÷òïüóìÿüóÿûíÿôäìñ¹p•P@¢O?¸XJ·M?µE9ÀG<ÁA6ÈE;ÅI?½G=¯@9¡<4š=6–A4e=1f>2hC3iE5fG3cG2cJ6hV@i\IskV…‚oŽzpq_9=,47,28.17-17-17-06,06,06,17-17-17-06,06,/5+/5+/5+.3-.3-.3-.3-.3-.3-.3-.3-.3-.3--2,-2,-2,-2,.3--4-*4,)4,*6,+7-.:.1=14@25A36C2:G5N4DX¿@7ÆC;ÅF?¿D=±>;¦:7ž:8™>;‘=;Š?<„@=}@=xA6s>6r=5r=5r=5p>5o=4n>4m=3l<2k;1j;1i:0i:0j:0n72p62p62m61m61l71i70i70l;4k:3h91e90e90e90e:1d<2fB6cA5cC4dD5dG5dI6bI3_I2^L6eV?jbMrmW„ƒo„‡r[`L3:(28,28.17-17-17-06,06,06,17-17-17-06,06,/5+/5+/5+.3-.3-.3-.3-.3-.3-.3-.3--2,-2,,1+,1+,1+,1+-2,,3,,6.+5-*4+*4++5,.8-0;-2=/2=-5@/6A05A-1=)1=)5A-8F/=O5@T8FY=H\@J]?I^=K^>K`?TgG[pQcvZauZYkSJ]G6G4&4%$-*$),"'*heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZlfVjgTkjUlnYorasvm…„Ÿ¤¨¸¿ÇÖßäí÷ùûÿÿûÿÿûüÿþÿÿÿþÿþýûÿÿûÿÿúüüôóõêëíâãçÙÝãÕÜãÑäéÓçìÕéíÖêìÔëëÓèæÏßÚÄÓθÓÎºÌÆ¶ËøÐÉÁ×ÒÎàÛØêæåðïíóòðùù÷ýýûýýûýýûÿÿýþþüüüúþþüþþüþþüþþüþþüþþüþþüÿýüÿûüÿøùÿþýþÿýùÿýôÿøïÿõ÷ÿöð÷çÿÿíÿîÛͧ”¤kX¢[GªWE­L;¹D:ÀD<ÀE>¼E?´A>ª=:¢:9š;9•=5o?5o?5o@6n?5m>4k<2h<1h<1h<1l<2o83q62p62p62m61l71j81i81h70g80e90e:1d<2e?4f@5dB6^B4aG8cL:dM;cM8`K6]K3]M4]Q9bX?mhRss[€ƒnv{eFO:4=*39-28.28.28.17-17-17-06,17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,-2,,1++0*+0*+0*+0*,1+,3,.5.,6.*4+*4+*4++5,-7,.9+-8*0;+4?/5@/4?.3?+3>-3@,7F/9K3@O8BT:GW¸J=¹I>¸I@´G@¯D>¥=:œ:7–=9>:ˆ?9€A:xA:tD:pF:pE5j>5n=6o83r73p62p62n72l71j81i81d8/d90c;1d>3d@4cA5cA5_C5ZE4_NnlUtv^|kcmU2>(6B.3;.39/39/39/28.28.28.17-17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1+,1++0**/)*/)+0*,1++2+-4-+5-*4,*4,+5,+5,,6+-7,,6+/:,2=/6A17B27B15@04?.2?-4C.:G3=L5AO8DT:JX?L\BTbI\kTcqZ^mXUbPDRA2>0#/%&/,&,,$**heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVjcYkdZlc\md[lfZlfVolYmlWjlWgkZflbr{xŽ˜š¨±¸ÊÓØãìñøýÿ÷üÿúûÿþÿÿÿþÿúùõÿÿúýýõøøîðòåéëÝåéØãêØåíÖæìÒéíÒêíÒèèÎèæÏèãÏáÚÈØÐÃØÎÄÝÒÌêßÛøíëÿôöÿõùÿõûÿùüþüýÿÿýÿÿýþþüþþüÿÿýÿÿýýýûþþüþþüþþüþþüþþüþþüþþüÿþúÿýûÿýûýüúùýüøÿÿõÿÿóÿÿíýúóÿûûÿúÿÿôÿöæÿóßÿãÍ×­•©oY¨WD®Q@¬O>¯OA±OB­K@¤C<™<5•>7?6ˆ?8A7{B7uD6qE8qE8p?8q?8s>8q?8q?8q?8q?8p?8sB;qB:o@8m>6l=5j>5m>6o>7o83q73o83m82m82i81h91f:1f;2d>3d@4bB5`C5]A3\@2WB1TG4[S>f^Gi^HbX?ZS9ZS7\W:ZV;XW;kmUsw^u}fUaI&28D03;.4:04:039/39/39/28.28.17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1++0*+0**/)*/)+0*+0*,1++2+)3+*4,+5-+5,,6--7.-7,,6+.8-2<16A39D69D47B46A10;+2?-5B09F22=/x=/t?/sB3tD6r=5r=7t=8s>8u@:u@:t?9q?8sA:q@9q@9q@9p?8n?7o>7o>7k92m82l:3l;4l;4h<3g<3c=2c?3^>1dG9cG9T=-N9(M8'@1WQ;PN7KI0OK2]Y>ieJeaDVU7XX<]`CosZz€fdlU=I1-9#2>*4-1=)2>*9E/BN8IU?O[GVbN]hWYdTLWI/u@8s>8u>9u@:t?9o=6p>7sA:q?8p?8p?8n?7o>7m>6n=6m>6k<4l=5m>6k?6j?6gA6eA5bB5dG9[A2^G7^I8N=+F7$G8%>6!LL4GK2DG,DD*MM1\[?baC`aBYY=dgJsw^sy_X`I:D,/;%7C/6>16<26<26<25;15;15;15;15;15;15;14:04:039/39/39/27127127116016016005/05/.3-.3--2,-2,,1+,1++0*+0**1**1*)0))0))0)*1*+2*,3+.5--4,.5-07/4;39A6?F>BJ?;F8:E57B14?.3?+6B.)r>)s@+tD0vE4q?4n<3q<4tB9sA8o?5qA7xH>n>4m>4m>4k?4l=3j>3l=3j>3g?5gA6gA6gC7eC7cC6`C5^D5bK;UB1ZI7`S@RG3C;&E=(FA+AE,BH.AE*<@%?B%NN2_`AijKaaEnqTvzagmSJO94<%4=(=F38>28>48>48>47=37=37=36<28>48>47=37=37=36<26<26<25:449349349338238238227105/05//4..3--2,,1++0*+0*).().().().().(*/)+0*,1+160/4.,1+,1+/4.6;4=BK:4.8/-4--4-,3,gdUgdUheVheVheVheVifWifWifWifWifWifWifWifWifWifWkeWkeWlcZmd[md]mf\mg[jiWkmXimVjoYjs`hthm|wˆ˜˜¦³¹¿ÊÐÓÜãëðööûÿüýÿýÿþÿÿýÿþùþþöýýñúûí÷úçô÷âîóÜåíÕâèÎÛàÀ×Ú»ÖÖ¼Ù×ÂÝ×ÇÞ×ÍåÛÙìààøìðûðöÿõûÿùþÿúýÿûûÿûûÿýüÿþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüýÿüøÿþøÿþûÿþþþþÿüþÿúÿÿùÿÿøþÿúýÿùüÿùùÿýúÿÿøÿÿøûÿõüþðÿÿíÿüéÿñßÿðÝÿïÚñÒ½´z{R>tJ4uH3vI4zM8}P;yL7nA.e7'{M@sD:qB8sD:oC8g;0d8-g=1i?3i?3i?3g?3f>2f>2f>2e?2b@4bB5`C5_C5_C5[D4ZE4WD3XI6OB/\T?oiSc^HMK4IG0IK3>D*?H-@F*48>47=37=37=39?58>48>48>48>48>48>48>47<67<67<66;56;56;55:45:438238216005//4.-2,,1+,1++0*+0**/)*/)+0*,1+-2,-2,05/.3-+0*+0*-2.2718=9;B:@K=@M;@M;=J68E13@,1?(0>'4.:0,6..5.-4-gdUgdUgdUheVheVifWifWifWifWifWifWifWifWifWifWifWkeWldWlcZmd[md]mf\mg[jiWkmXinWiqZgs_drejyt…••£²·½ÈÎÒÛâêïõôùýûüÿýÿþÿÿýÿÿúÿÿøÿÿóþÿñûþë÷úåðõÞæîÖâèÌÙÜ¿ÕÕ¹ÒйÔѾÚÔÈàÙÑêàßôéíþóùÿ÷üÿûÿÿýÿÿþÿÿþüÿþúÿþúþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüýÿþúÿÿúÿÿûÿÿþþþÿýþÿüüÿûüÿûúÿúøÿù÷ÿú÷ÿýøÿÿûÿÿûýÿúýþùùôîÿþöÿýôÿüóÿûîÿ÷çûæÕéÒÀÏ´¡¶š…”uawVCjI6lI6rM;uP>mF7iB3gB2jE5nI9nJ:oK;oK;eA1cB1cB1cB1cB1cB1bC1`C3]F6\G6\G6ZG6ZG6WH5TG4RG3PH3NH2fdM~~frrZVX@JL4GM3A.:>-;>39?59?58>48>47=37=37=38>48>48>48>48>48>48>48>49>89>89>88=78=78=77<67<66;55:449338227105//4./4.-2.-2.,1-+0,+0,,1--2.-2.,1-,1-,1-,1-.210513764;4;G9=L9@O<@O:8F71?2-9-,6--4,,3+fcTfcTgdUheVheVifWjgXjgXifWifWifWifWifWifWifWifWldWldWlcZmd[md]mf\mg[jiWkmXinWiqZgs_bpcgxr‚””£²·ÀËÑÔÝäëðöõúþûüÿýÿþÿÿýÿÿúÿÿøÿÿôÿÿóÿÿïúýèò÷àçðÕâèÌ×Ú½ÑѵÍË´Î˺ÖÏÅÞ×Ñìâã÷îóÿöþÿúÿÿýÿÿþÿÿÿýþÿúþÿùþÿúþÿúþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþþýþÿýþÿýþÿýÿþýÿüþÿúþÿùÿÿ÷ýýóýýõþýøþýùÿþüþþþÿýÿÿþÿþùÿÿüÿÿûüûöóÿøòÿýôÿþñÿýíÿúéÿòà÷äÓçÒ¿Ò»©¹ŸŽŸ„srb|]K}^LtUCaD2W:(Y<*[>,X=*`E2`E2`E2_F2`G3`G3`G3]H3\K7\M:\M:YL9XM9UM8RL6QL6NL5QQ9ikS|€gmqXSY?FL2>G,48>48>48>47=37=38>48>48>48>49?59?5:?9:?9:?9:?99>89>89>88=78=78=77<66;55:4493382382/40.3/-2.,1-+0,+0,+0,+0,+0,,1--10.21/32/32/32-4-3?17F3=L7@O:?N7M:MJ9BC3=@5;A7;A7;A7:@6:@6:@69?58>48>48>49?59?5:@6:@6:@6;@:;@:;@::?9:?99>89>89>8:?9:?99>89>88=78=77<67<6495273162/40-2.,1-+/.+/.,0/,0/-10.21.23.23-12+1-+9*/@-6H2;M7=O7A6>A6>A6=@7=@79?59?59?5:@6:@6:B7:B7:B7;@9;@9;@::?8:?99>79>89>7;@:;@9;@:;@9:?9:?8:?9:?98?87=94;4382160/4..3/.3/.21.21,2.,2.+2++2*,4))6%$6)=!2F+8L1;O6;M5;M5;M58J29K3;M5H&DK*FM+EL*PV4PT3KN/HK,TT8bbFccIZZ@[Y@\ZA][B][B[Y@XV=US:SQ8HF1GD1DA0A?0@>1>>2??5>@5;>59?59?59A69A48C58C58C5:B79A69@88@58?79A69@8:B7:A9:B79@8:B7;B:E=8B:8B:7A88@56>14O<>P::L6@R8EW=FY=DX=@T;5H2+<),6+,3++2*ZgM[hN\hP]iQbjSckTglXhkXghVghVifWifWkeWlfXmeZmgYmgYkhYkg[kg\jf]jf[hfZefVhiWglVfo\erajwnzЉœ«²ºÈÑÐÙàáéìò÷ûøþþùþúúÿøûþóùýïøùë÷øæõôâíìØéæÓåâÏÜ×ÄÒ˹ʿ­Á´¤¹­¡¼¯¦Á¶²ËÁÀÛÐÖæßæûóþý÷ÿþûÿÿþÿþýÿüýÿüýÿüýÿþþþþþþþþþþþþþþþþþþÿþüÿþüÿþüÿþüÿýúÿüùÿüùÿýúÿýùÿþúÿþýÿýüÿüýÿýþÿþÿÿþÿÿýþýûüÿþýÿþûÿüúÿøóøíçòåÝöèßûðêÿúýÿüÿÿýþÿÿýÿÿûýÿüýÿþüýÿýþÿýþÿÿýÿÿþüÿþõÿÿîÿþèÿÿäúöÝýûâäàÇ‹‡lRM0SN0QK+QK+UO/UO/TO1TO1SO2SO2QP4QP4QM2PO3PN5NQ6MO7JP6HM6EM5HQ6EN1BK.?I'BI(FM+JP,KQ-NR/PT1VZ7^bA_bCY\?TWWU>XV=YW>XV=XW;WV:XT9QK3OI3LG4ID1DA2B@3A?3>@5<=59?59?59A67B48C57D37D3:B79A69A68@58@59A69A6:B7:B7:B7:B7:B7;C874>63=40>-3C)9M*BY/Ga1Op;Ln;Li=Fa>BY?F;J@?I>>I9?G8>F7>D8=B;>E>9C;6@74B19I/BV3Pg=XrB^J[}JXuIMhECZ@9O:6G54E2XR6:@6:@69A67B47B46C26C2;C8:B79A69A69A69A6:B7;C8;C8:B7:B7;C8;C8=E:>F;=G<=G?>H=>I9?G8>F7>D8=B;=D=9C;6@74B19I/DX5Ri?[uEZ{FWyFTqEIdA=T:2H3/@.->+6H2@R8L_CReGSgKOcG@W=6I30:/07/-4,YgMZhN\hP^jRblTemVinZjo[mn\lm[mk\mj[nhZnhZoi]oi[liZkhYjfZieZie\ieZig[ghXghVchRajWerao|s{‹ŠŸ¦¢°¹ÁËÔÔÝäéñôòúüôúøñöðíðçèìÞâãÕÚÛÉÒÑ¿ÌɶÉıþ«¿¸¦¼³¢Ê¾®ÓŸÜÐÄæÙÑíâàöìíÿôúÿùÿÿ÷ÿÿúÿÿüÿþýÿýüÿûüþüþýþÿÿþþþþþþþþþþþþþþþþþþÿþüÿþüþýûþýûÿýúÿýúÿýúÿûøÿúöþùõÿýüÿûúýùúþúûþüýÿýþÿþÿÿýþÿüûÿýúÿüúÿøó÷ìæòåÝøêáÿôîÿúýÿüÿÿýþÿÿýÿÿûýÿúýÿþüýÿüýÿýþÿÿþÿÿÿýÿþõÿýìÿûãþúßÿüæÿÿéçâÌŒˆoRL2TO2TM0UN1TN.UO/VQ3VQ3UQ4SO2ON2NM1PL1NM1NL3KN3LN6KQ7KP9JR:LU:IR5JS6OY7SZ9T[9]c?fnG‚’c’¦sŸ±›ª’¡zˆ”pr{\\bFLP7KM5LK6KI4LJ5PK5TN8VP:WQ;VP:SN;QL9LI:IG:GE9CE:=>6:@6:@69A67B47B46C26C2;C8;C8:B79A69A6:B7;C8;C8;C8;C8;C8;C8F;=G<=G?=G<=H8>F7=E6=C7=B;:A:7A95?64B19I/BV3Ne;Uo?Tu@RtAPmAE`=9P6-C.+<*+<)1C- +#include + +#include "test.h" + +static GrColor *EGA; +#define black EGA[0] +#define red EGA[12] +#define blue EGA[1] +#define white EGA[15] + +static void testpoly(int n,int points[][2],int convex) +{ + GrClearScreen(black); + GrPolygon(n,points,white); + GrFilledPolygon(n,points,(red | GrXOR)); + GrKeyRead(); + if(convex || (n <= 3)) { + GrClearScreen(black); + GrFilledPolygon(n,points,white); + GrFilledConvexPolygon(n,points,(red | GrXOR)); + GrKeyRead(); + } +} + +static void speedtest(void) +{ + int pts[4][2]; + int ww = GrSizeX() / 10; + int hh = GrSizeY() / 10; + int sx = (GrSizeX() - 2*ww) / 32; + int sy = (GrSizeY() - 2*hh) / 32; + int ii,jj; + GrColor color; + long t1,t2,t3; + char msg[81]; + + GrClearScreen(black); + t1 = GrMsecTime(); + pts[0][1] = 0; + pts[1][1] = hh; + pts[2][1] = 2*hh; + pts[3][1] = hh; + color = 0; + for(ii = 0; ii < 32; ii++) { + pts[0][0] = ww; + pts[1][0] = 2*ww; + pts[2][0] = ww; + pts[3][0] = 0; + for(jj = 0; jj < 32; jj++) { + GrFilledPolygon(4,pts, EGA[color] | GrXOR); + color = (color + 1) & 15; + pts[0][0] += sx; + pts[1][0] += sx; + pts[2][0] += sx; + pts[3][0] += sx; + } + pts[0][1] += sy; + pts[1][1] += sy; + pts[2][1] += sy; + pts[3][1] += sy; + } + t2 = GrMsecTime(); + pts[0][1] = 0; + pts[1][1] = hh; + pts[2][1] = 2*hh; + pts[3][1] = hh; + color = 0; + for(ii = 0; ii < 32; ii++) { + pts[0][0] = ww; + pts[1][0] = 2*ww; + pts[2][0] = ww; + pts[3][0] = 0; + for(jj = 0; jj < 32; jj++) { + GrFilledConvexPolygon(4,pts, EGA[color] | GrXOR); + color = (color + 1) & 15; + pts[0][0] += sx; + pts[1][0] += sx; + pts[2][0] += sx; + pts[3][0] += sx; + } + pts[0][1] += sy; + pts[1][1] += sy; + pts[2][1] += sy; + pts[3][1] += sy; + } + t3 = GrMsecTime(); + GrTextXY(0, 0, "Times to scan 1024 polygons", white, black); + sprintf(msg, " with 'GrFilledPolygon': %.2f (s)", + (double)(t2 - t1) / (double)1000); + GrTextXY(0, 18, msg, white, black); + sprintf(msg, " with 'GrFilledConvexPolygon': %.2f (s)", + (double)(t3 - t2) / (double)1000); + GrTextXY(0, 36, msg, white, black); +} + +TESTFUNC(ptest) +{ + char buff[300]; + int pts[300][2]; + int ii,collect; + int convex; + FILE *fp; + + fp = fopen("polytest.dat","r"); + if(fp == NULL) return; + EGA = GrAllocEgaColors(); + ii = collect = convex = 0; + while(fgets(buff,299,fp) != NULL) { + if(!collect) { + if(strncmp(buff,"begin",5) == 0) { + convex = (buff[5] == 'c'); + collect = 1; + ii = 0; + } + continue; + } + if(strncmp(buff,"end",3) == 0) { + testpoly(ii,pts,convex); + collect = 0; + continue; + } + if(sscanf(buff,"%d %d",&pts[ii][0],&pts[ii][1]) == 2) ii++; + } + fclose(fp); + speedtest(); + GrKeyRead(); +} + diff --git a/thirdparty/grx249/test/polytest.dat b/thirdparty/grx249/test/polytest.dat new file mode 100644 index 0000000..0ebde62 --- /dev/null +++ b/thirdparty/grx249/test/polytest.dat @@ -0,0 +1,87 @@ +beginc +300 200 +400 400 +200 400 +end + +beginc +300 200 +400 400 +150 470 +200 400 +end + +beginc +300 200 +400 400 +150 470 +120 330 +end + +beginc +300 200 +400 400 +050 470 +020 330 +end + +beginc +300 -100 +400 400 +050 870 +020 330 +end + +beginc +300 20 +400 100 +050 100 +end + +beginc +400 500 +050 500 +200 560 +end + +beginc +400 500 +250 495 +050 500 +200 560 +end + +beginc +100 500 +400 500 +300 550 +end + +beginc +150 150 +300 150 +250 250 +300 400 +120 444 +end + +begin +250 150 +200 450 +350 250 +150 250 +400 450 +end + +beginc +150 150 +400 200 +400 202 +end + +begin +-10 0 +100 -10 +200 200 +-10 200 +end diff --git a/thirdparty/grx249/test/rand.h b/thirdparty/grx249/test/rand.h new file mode 100644 index 0000000..ce7cf04 --- /dev/null +++ b/thirdparty/grx249/test/rand.h @@ -0,0 +1,44 @@ +/** + ** rand.h ---- a very simple random number generator + ** (from "Numerical recipies") + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __RAND_H_INCLUDED +#define __RAND_H_INCLUDED + +#define _IA 16807 +#define _IM 2147483647L +#define _IQ 127773L +#define _IR 2836 +#define _MASK 123459876UL + +static long _idum = 0; + +unsigned long ran0(void) { + long k; + _idum ^= _MASK; + k = _idum / _IQ; + _idum = _IA * (_idum - k * _IQ) - _IR * k; + if (_idum < 0) _idum += _IM; + return (unsigned long) _idum; +} + +#define sran0(x) do _idum = (x); while(0) + +#define RND() ran0() +#define SRND(x) sran0(x) +#define RND_MAX (_MASK) + +#endif diff --git a/thirdparty/grx249/test/rgbtest.c b/thirdparty/grx249/test/rgbtest.c new file mode 100644 index 0000000..d318a58 --- /dev/null +++ b/thirdparty/grx249/test/rgbtest.c @@ -0,0 +1,38 @@ +/** + ** rgbtest.c ---- show 256 color RGB palette + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" + +TESTFUNC(rgbtest) +{ + int x = GrSizeX(); + int y = GrSizeY(); + int ww = (x-10)/32; + int wh = (y-10)/8; + int ii,jj; + + GrSetRGBcolorMode(); + for(ii = 0; ii < 8; ii++) { + for(jj = 0; jj < 32; jj++) { + GrFilledBox(5+jj*ww,5+ii*wh,5+jj*ww+ww-1,5+ii*wh+wh-1,ii*32+jj); + } + } + GrKeyRead(); +} + diff --git a/thirdparty/grx249/test/sbctest.c b/thirdparty/grx249/test/sbctest.c new file mode 100644 index 0000000..72718cc --- /dev/null +++ b/thirdparty/grx249/test/sbctest.c @@ -0,0 +1,197 @@ +/** + ** sbctest.c ---- test subcontext + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include "test.h" + +static void drawpf( int border, GrPattern *pat ); +static void drawp( int border, GrLinePattern *grlp ); + +TESTFUNC(sbctest) +{ + char bits[] = {0, 76, 50, 0, 0, 76, 60, 0}; + GrContext *grc, *grsc; + GrPattern *pat1, *pat2; + GrLineOption grl; + GrLinePattern grlp; + GrFont *grf; + GrTextOption grt; + + grc = GrCreateContext( 300,300,NULL,NULL ); + if( grc == NULL ) return; + grsc = GrCreateSubContext( 10,10,290,290,grc,NULL ); + if( grsc == NULL ) return; + pat1 = GrBuildPixmapFromBits( bits,8,8,GrWhite(),GrBlack() ); + if( pat1 == NULL ) return; + pat2 = GrBuildPixmapFromBits( bits,8,8,GrBlack(),GrWhite() ); + if( pat2 == NULL ) return; + grf = GrLoadFont( "lucb40.fnt" ); + if( grf == NULL ){ + grf = GrLoadFont( "../fonts/lucb40.fnt" ); + if( grf == NULL ) return; + } + + GrBox( 19,19,320,320,GrWhite() ); + + GrTextXY( 0,0,"White drawing on context ",GrWhite(),GrBlack() ); + GrSetContext( grc ); + GrClearContext( GrBlack() ); + drawing( 10,10,280,280,GrWhite(),GrNOCOLOR ); + GrSetContext( NULL ); + GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); + GrKeyRead(); + + GrTextXY( 0,0,"Black drawing on subcontext ",GrWhite(),GrBlack() ); + GrSetContext( grsc ); + drawing( 0,0,280,280,GrBlack(),GrNOCOLOR ); + GrSetContext( NULL ); + GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); + GrKeyRead(); + + GrTextXY( 0,0,"Pattern drawing on context ",GrWhite(),GrBlack() ); + GrSetContext( grc ); + GrClearContext( GrBlack() ); + drawpf( 10,pat1 ); + GrSetContext( NULL ); + GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); + GrKeyRead(); + + GrTextXY( 0,0,"Pattern drawing on subcontext ",GrWhite(),GrBlack() ); + GrSetContext( grsc ); + GrClearContext( GrBlack() ); + drawpf( 0,pat2 ); + GrSetContext( NULL ); + GrBitBlt( NULL,20,20,grc,0,0,299,299,GrXOR ); + GrKeyRead(); + + grl.lno_color = GrWhite(); + grl.lno_width = 3; + grl.lno_pattlen = 0; + grlp.lnp_pattern = pat1; + grlp.lnp_option = &grl; + + GrTextXY( 0,0,"Patterned drawing on context ",GrWhite(),GrBlack() ); + GrSetContext( grc ); + GrClearContext( GrBlack() ); + grlp.lnp_pattern = pat1; + drawp( 10,&grlp ); + GrSetContext( NULL ); + GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); + GrKeyRead(); + + GrTextXY( 0,0,"Patterned drawing on subcontext",GrWhite(),GrBlack() ); + GrSetContext( grsc ); + GrClearContext( GrBlack() ); + grlp.lnp_pattern = pat2; + drawp( 0,&grlp ); + GrSetContext( NULL ); + GrBitBlt( NULL,20,20,grc,0,0,299,299,GrXOR ); + GrKeyRead(); + + grt.txo_fgcolor.v = GrWhite(); + grt.txo_bgcolor.v = GrBlack() | GrOR; + grt.txo_font = grf; + grt.txo_direct = GR_TEXT_RIGHT; + grt.txo_xalign = GR_ALIGN_LEFT; + grt.txo_yalign = GR_ALIGN_CENTER; + grt.txo_chrtype = GR_BYTE_TEXT; + + GrTextXY( 0,0,"Patterned text on context ",GrWhite(),GrBlack() ); + GrSetContext( grc ); + GrClearContext( GrBlack() ); + GrPatternDrawString( "Hello all",9,20,60,&grt,pat1 ); + GrPatternDrawChar( 'G',20,120,&grt,pat1 ); + GrPatternDrawStringExt( "Hola a todos",12,20,180,&grt,pat1 ); + GrSetContext( NULL ); + GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); + GrKeyRead(); + + GrTextXY( 0,0,"Patterned text on subcontext ",GrWhite(),GrBlack() ); + GrSetContext( grsc ); + GrClearContext( GrBlack() ); + GrPatternDrawString( "Hello all",9,10,50,&grt,pat2 ); + GrPatternDrawChar( 'G',10,110,&grt,pat2 ); + GrPatternDrawStringExt( "Hola a todos",12,10,170,&grt,pat2 ); + GrSetContext( NULL ); + GrBitBlt( NULL,20,20,grc,0,0,299,299,GrXOR ); + GrKeyRead(); + + GrUnloadFont( grf ); + GrDestroyPattern( pat2 ); + GrDestroyPattern( pat1 ); + GrDestroyContext( grsc ); + GrDestroyContext( grc ); +} + +/***/ + +static void drawpf( int border, GrPattern *pat ) +{ + int pt1[4][2] = {{130,200},{140,240},{150,250},{160,180}}; + int pt2[4][2] = {{230,200},{235,240},{246,250},{258,180}}; + int ptaux[4][2]; + int i,j; + + GrPatternFilledBox( 0+border,0+border,93+border,93+border,pat ); + GrPatternFilledCircle( 139+border,46+border,45,pat ); + GrPatternFilledEllipse( 232+border,46+border,45,35,pat ); + GrPatternFilledCircleArc( 46+border,139+border,45,-300,600, + GR_ARC_STYLE_CLOSE2,pat ); + GrPatternFilledEllipseArc( 139+border,139+border,45,35,-700,400, + GR_ARC_STYLE_CLOSE2,pat ); + GrPatternFilledLine( 188+border,139+border,278+border,139+border,pat ); + GrPatternFilledPlot( 47+border,228+border,pat ); + GrPatternFilledPlot( 47+border,229+border,pat ); + GrPatternFilledPlot( 47+border,230+border,pat ); + GrPatternFilledPlot( 47+border,231+border,pat ); + GrPatternFilledPlot( 47+border,232+border,pat ); + for( i=0; i<4; i++ ) + for( j=0; j<2; j++ ) + ptaux[i][j] = pt1[i][j] + border; + GrPatternFilledPolygon( 4,ptaux,pat ); + for( i=0; i<4; i++ ) + for( j=0; j<2; j++ ) + ptaux[i][j] = pt2[i][j] + border; + GrPatternFilledConvexPolygon( 4,ptaux,pat ); +} + +/***/ + +static void drawp( int border, GrLinePattern *grlp ) +{ + int pt1[4][2] = {{130,200},{140,240},{150,250},{160,180}}; + int pt2[4][2] = {{230,200},{235,240},{246,250},{258,180}}; + int ptaux[4][2]; + int i,j; + + GrPatternedBox( 0+border,0+border,93+border,93+border,grlp ); + GrPatternedCircle( 139+border,46+border,45,grlp ); + GrPatternedEllipse( 232+border,46+border,45,35,grlp ); + GrPatternedCircleArc( 46+border,139+border,45,-300,600, + GR_ARC_STYLE_CLOSE2,grlp ); + GrPatternedEllipseArc( 139+border,139+border,45,35,-700,400, + GR_ARC_STYLE_CLOSE2,grlp ); + GrPatternedLine( 188+border,139+border,278+border,139+border,grlp ); + for( i=0; i<4; i++ ) + for( j=0; j<2; j++ ) + ptaux[i][j] = pt1[i][j] + border; + GrPatternedPolygon( 4,ptaux,grlp ); + for( i=0; i<4; i++ ) + for( j=0; j<2; j++ ) + ptaux[i][j] = pt2[i][j] + border; + GrPatternedPolyLine( 4,ptaux,grlp ); +} + diff --git a/thirdparty/grx249/test/scroltst.c b/thirdparty/grx249/test/scroltst.c new file mode 100644 index 0000000..3a7c7b8 --- /dev/null +++ b/thirdparty/grx249/test/scroltst.c @@ -0,0 +1,75 @@ +/** + ** scroltst.c ---- test virtual screen set/scroll + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" + +TESTFUNC(scrolltest) +{ + int wdt = GrScreenX(); + int hgt = GrScreenY(); + GrColor nc = GrNumColors(); + int txh = GrDefaultFont.h.height + 2; + for( ; ; ) { + char buff[100]; + char *l1 = "Screen resolution: %dx%d"; + char *l2 = "Virtual resolution: %dx%d"; + char *l3 = "Current screen start: x=%-4d y=%-4d"; + char *l4 = "Commands: q -- exit program,"; + char *l5 = "w W h H -- shrink/GROW screen width or height,"; + char *l6 = "x X y Y -- decrease/INCREASE screen start position"; + GrColor bgc = GrAllocColor(0,0,128); + GrColor fgc = GrAllocColor(200,200,0); + GrColor txc = GrAllocColor(255,0,255); + int vw = GrVirtualX(); + int vh = GrVirtualY(); + int vx = GrViewportX(); + int vy = GrViewportY(); + int x = (vw / 3) - (strlen(l6) * GrDefaultFont.h.width / 2); + int y = (vh / 3) - (3 * txh); + GrClearScreen(bgc); + drawing(0,0,vw,vh,fgc,bgc); + sprintf(buff,l1,wdt,hgt); GrTextXY(x,y,buff,txc,bgc); y += txh; + sprintf(buff,l2,vw, vh ); GrTextXY(x,y,buff,txc,bgc); y += txh; + for( ; ; GrSetViewport(vx,vy)) { + int yy = y; + vx = GrViewportX(); + vy = GrViewportY(); + sprintf(buff,l3,vx,vy); GrTextXY(x,yy,buff,txc,bgc); yy += txh; + GrTextXY(x,yy,l4,txc,bgc); yy += txh; + GrTextXY(x,yy,l5,txc,bgc); yy += txh; + GrTextXY(x,yy,l6,txc,bgc); yy += txh; + switch(GrKeyRead()) { + case 'w': vw -= 8; break; + case 'W': vw += 8; break; + case 'h': vh -= 8; break; + case 'H': vh += 8; break; + case 'x': vx--; continue; + case 'X': vx++; continue; + case 'y': vy--; continue; + case 'Y': vy++; continue; + case 'q': return; + case 'Q': return; + default: continue; + } + GrSetMode(GR_custom_graphics,wdt,hgt,nc,vw,vh); + break; + } + } +} + diff --git a/thirdparty/grx249/test/speedtst.c b/thirdparty/grx249/test/speedtst.c new file mode 100644 index 0000000..127d5d4 --- /dev/null +++ b/thirdparty/grx249/test/speedtst.c @@ -0,0 +1,888 @@ +/** + ** speedtst.c ---- check all available frame drivers speed + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + ** 070512 M.Alvarez, new version more accurate, but still had problems + ** in X11, because functions returns before the paint + ** is done. + **/ + +#include +#include +#include +#include +#include +#ifdef __WATCOMC__ +/*#include */ +#include +#else +#include +#endif +#include +#include "rand.h" + +#include "grx20.h" + +#if GRX_VERSION_API-0 <= 0x0220 +#define GrColor unsigned long +#define BLIT_FAIL(gp) ((gp)->fm!=GR_frameVGA8X) +#else +#define BLIT_FAIL(gp) 0 +#endif + +#define MEASURE_RAM_MODES 1 + +#define READPIX_loops (384*1) +#define READPIX_X11_loops (4*1) +#define DRAWPIX_loops (256*1) +#define DRAWLIN_loops (12*1) +#define DRAWHLIN_loops (16*1) +#define DRAWVLIN_loops (12*1) +#define DRAWBLK_loops (1*1) +#define BLIT_loops (1*1) + +typedef struct { + double rate, count; +} perfm; + +typedef struct { + GrFrameMode fm; + int w,h,bpp; + int flags; + perfm readpix; + perfm drawpix; + perfm drawlin; + perfm drawhlin; + perfm drawvlin; + perfm drawblk; + perfm blitv2v; + perfm blitv2r; + perfm blitr2v; +} gvmode; +#define FLG_measured 0x0001 +#define FLG_tagged 0x0002 +#define FLG_rammode 0x0004 +#define MEASURED(g) (((g)->flags&FLG_measured)!=0) +#define TAGGED(g) (((g)->flags&FLG_tagged)!=0) +#define RAMMODE(g) (((g)->flags&FLG_rammode)!=0) +#define SET_MEASURED(g) (g)->flags |= FLG_measured +#define SET_TAGGED(g) (g)->flags |= FLG_tagged +#define SET_RAMMODE(g) (g)->flags |= FLG_rammode +#define TOGGLE_TAGGED(g) (g)->flags ^= FLG_tagged + +int nmodes = 0; +#define MAX_MODES 256 +gvmode *grmodes = NULL; +#if MEASURE_RAM_MODES +gvmode *rammodes = NULL; +#endif + +/* No of Points [(x,y) pairs]. Must be multiple of 2*3=6 */ +#define PAIRS 4200 + +#define UL(x) ((unsigned long)(x)) +#define DBL(x) ((double)(x)) +#define INT(x) ((int)(x)) + +#ifndef min +#define min(a,b) ((a)<(b) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) ((a)>(b) ? (a) : (b)) +#endif + +typedef struct XYpairs { + int x[PAIRS]; + int y[PAIRS]; + int w, h; + struct XYpairs *nxt; +} XY_PAIRS; + +XY_PAIRS *xyp = NULL; +int *xb = NULL, *yb = NULL; /* need sorted pairs for block operations */ +int measured_any = 0; + +XY_PAIRS *checkpairs(int w, int h) { + XY_PAIRS *res = xyp; + int i; + + if (xb == NULL) { + xb = malloc(sizeof(int) * PAIRS); + yb = malloc(sizeof(int) * PAIRS); + } + + while (res != NULL) { + if (res->w == w && res->h == h) + return res; + res = res->nxt; + } + + SRND(12345); + + res = malloc(sizeof(XY_PAIRS)); + assert(res != NULL); + res->w = w; + res->h = h; + res->nxt = xyp; + xyp = res; + for (i=0; i < PAIRS; ++i) { + int x = RND() % w; + int y = RND() % h; + if (x < 0) x = 0; else + if (x >=w) x = w-1; + if (y < 0) y = 0; else + if (y >=h) y = h-1; + res->x[i] = x; + res->y[i] = y; + } + return res; +} + +double SQR(int a, int b) { + double r = DBL(a-b); + return r*r; +} + +double ABS(int a, int b) { + double r = DBL(a-b); + return fabs(r); +} + +char *FrameDriverName(GrFrameMode m) { + +#if GRX_VERSION_API-0 >= 0x0229 + unsigned sys = GrGetLibrarySystem(); +#else + unsigned sys = (unsigned) GRX_VERSION; +#endif + + int x11 = ( (sys == GRX_VERSION_GENERIC_X11) || + (sys == GRX_VERSION_GCC_386_X11) || + (sys == GRX_VERSION_GCC_X86_64_X11) ); + int w32 = ( (sys == GRX_VERSION_GCC_386_WIN32) || + (sys == GRX_VERSION_MSC_386_WIN32) || + (sys == GRX_VERSION_GCC_386_CYG32) ); + int sdl = strcmp( GrCurrentVideoDriver()->name , "sdl") == 0; + + switch(m) { + case GR_frameUndef: return "Undef"; + case GR_frameText : return "Text"; + case GR_frameHERC1: return "HERC1"; + case GR_frameEGAVGA1: return x11 ? "XWIN1" : w32 ? "WIN32_1" : "EGAVGA1"; + case GR_frameEGA4: return "EGA4"; + case GR_frameSVGA4: return x11 ? "XWIN4" : w32 ? "WIN32_4" : "SVGA4"; + case GR_frameSVGA8: return sdl ? "SDL8" : x11 ? "XWIN8" : w32 ? "WIN32_8" : "SVGA8"; + case GR_frameVGA8X: return "VGA8X"; + case GR_frameSVGA16: return sdl ? "SDL16" : x11 ? "XWIN16" : w32 ? "WIN32_16" : "SVGA16"; + case GR_frameSVGA24: return sdl ? "SDL24" : x11 ? "XWIN24" : w32 ? "WIN32_24" : "SVGA24"; + case GR_frameSVGA32L: return sdl ? "SDL32L" : x11 ? "XWIN32L" : w32 ? "WIN32_32L" : "SVGA32L"; + case GR_frameSVGA32H: return sdl ? "SDL32H" : x11 ? "XWIN32H" : w32 ? "WIN32_32H" : "SVGA32H"; + case GR_frameSVGA8_LFB: return "LFB8"; + case GR_frameSVGA16_LFB: return "LFB16"; + case GR_frameSVGA24_LFB: return "LFB24"; + case GR_frameSVGA32L_LFB: return "LFB32L"; + case GR_frameSVGA32H_LFB: return "LFB32H"; + case GR_frameRAM1: return "RAM1"; + case GR_frameRAM4: return "RAM4"; + case GR_frameRAM8: return "RAM8"; + case GR_frameRAM16: return "RAM16"; + case GR_frameRAM24: return "RAM24"; + case GR_frameRAM32L: return "RAM32L"; + case GR_frameRAM32H: return "RAM32H"; + case GR_frameRAM3x8: return "RAM3x8"; + default: return "UNKNOWN"; + } + return "UNKNOWN"; +} + +void Message(int disp, char *txt, gvmode *gp) { + char msg[200]; + sprintf(msg, "%s: %d x %d x %dbpp", + FrameDriverName(gp->fm), gp->w, gp->h, gp->bpp); +#if GRX_VERSION_API-0 >= 0x0229 + unsigned sys = GrGetLibrarySystem(); +#else + unsigned sys = (unsigned) GRX_VERSION; +#endif + if ( (sys == GRX_VERSION_GENERIC_X11) || + (sys == GRX_VERSION_GCC_386_X11) || + (sys == GRX_VERSION_GCC_X86_64_X11) ) + fprintf(stderr,"%s\t%s\n", msg, txt); + if (disp) { + GrTextOption to; + GrContext save; + GrSaveContext(&save); + GrSetContext(NULL); + to.txo_font = &GrFont_PC6x8; + to.txo_fgcolor.v = GrWhite(); + to.txo_bgcolor.v = GrBlack(); + to.txo_chrtype = GR_BYTE_TEXT; + to.txo_direct = GR_TEXT_RIGHT; + to.txo_xalign = GR_ALIGN_LEFT; + to.txo_yalign = GR_ALIGN_TOP; + GrDrawString(msg,strlen(msg),0,0,&to); + GrDrawString(txt,strlen(txt),0,10,&to); + GrSetContext(&save); + } +} + +void printresultheader(FILE *f) { + fprintf(f, "Driver readp drawp line hline vline block v2v v2r r2v\n"); +} + +void printresultline(FILE *f, gvmode * gp) { + fprintf(f, "%-9s %4dx%4d ", FrameDriverName(gp->fm), gp->w, gp->h); + fprintf(f, "%6.2f", gp->readpix.rate / (1024.0 * 1024.0)); + fprintf(f, "%6.2f", gp->drawpix.rate / (1024.0 * 1024.0)); + fprintf(f, "%6.2f", gp->drawlin.rate / (1024.0 * 1024.0)); + fprintf(f, "%7.2f", gp->drawhlin.rate / (1024.0 * 1024.0)); + fprintf(f, "%6.2f", gp->drawvlin.rate / (1024.0 * 1024.0)); + fprintf(f, "%7.2f", gp->drawblk.rate / (1024.0 * 1024.0)); + fprintf(f, "%7.2f", gp->blitv2v.rate / (1024.0 * 1024.0)); + fprintf(f, "%7.2f", gp->blitv2r.rate / (1024.0 * 1024.0)); + fprintf(f, "%7.2f", gp->blitr2v.rate / (1024.0 * 1024.0)); + fprintf(f, "\n"); +} + +void readpixeltest(gvmode *gp, XY_PAIRS *pairs,int loops) { + int i, j; + long t1,t2; + double seconds; + int *x = pairs->x; + int *y = pairs->y; + + if (!MEASURED(gp)) { + gp->readpix.rate = 0.0; + gp->readpix.count = DBL(PAIRS) * DBL(loops); + } + + t1 = GrMsecTime(); + for (i=loops; i > 0; --i) { + for (j=PAIRS-1; j >= 0; j--) + GrPixelNC(x[j],y[j]); + } + t2 = GrMsecTime(); + seconds = (double)(t2 - t1) / 1000.0; + if (seconds > 0) + gp->readpix.rate = gp->readpix.count / seconds; +} + +void drawpixeltest(gvmode *gp, XY_PAIRS *pairs) { + int i, j; + GrColor c1 = GrWhite(); + GrColor c2 = GrWhite() | GrXOR; + GrColor c3 = GrWhite() | GrOR; + GrColor c4 = GrBlack() | GrAND; + long t1,t2; + double seconds; + int *x = pairs->x; + int *y = pairs->y; + + if (!MEASURED(gp)) { + gp->drawpix.rate = 0.0; + gp->drawpix.count = DBL(PAIRS) * DBL(DRAWPIX_loops) * 4.0; + } + + t1 = GrMsecTime(); + for (i=0; i < DRAWPIX_loops; ++i) { + for (j=PAIRS-1; j >= 0; j--) GrPlotNC(x[j],y[j],c1); + for (j=PAIRS-1; j >= 0; j--) GrPlotNC(x[j],y[j],c2); + for (j=PAIRS-1; j >= 0; j--) GrPlotNC(x[j],y[j],c3); + for (j=PAIRS-1; j >= 0; j--) GrPlotNC(x[j],y[j],c4); + } + t2 = GrMsecTime(); + seconds = (double)(t2 - t1) / 1000.0; + if (seconds > 0) + gp->drawpix.rate = gp->drawpix.count / seconds; +} + +void drawlinetest(gvmode *gp, XY_PAIRS *pairs) { + int i, j; + int *x = pairs->x; + int *y = pairs->y; + GrColor c1 = GrWhite(); + GrColor c2 = GrWhite() | GrXOR; + GrColor c3 = GrWhite() | GrOR; + GrColor c4 = GrBlack() | GrAND; + long t1,t2; + double seconds; + + if (!MEASURED(gp)) { + gp->drawlin.rate = 0.0; + gp->drawlin.count = 0.0; + for (j=0; j < PAIRS; j+=2) + gp->drawlin.count += sqrt(SQR(x[j],x[j+1])+SQR(y[j],y[j+1])); + gp->drawlin.count *= 4.0 * DRAWLIN_loops; + } + + t1 = GrMsecTime(); + for (i=0; i < DRAWLIN_loops; ++i) { + for (j=PAIRS-2; j >= 0; j-=2) + GrLineNC(x[j],y[j],x[j+1],y[j+1],c1); + for (j=PAIRS-2; j >= 0; j-=2) + GrLineNC(x[j],y[j],x[j+1],y[j+1],c2); + for (j=PAIRS-2; j >= 0; j-=2) + GrLineNC(x[j],y[j],x[j+1],y[j+1],c3); + for (j=PAIRS-2; j >= 0; j-=2) + GrLineNC(x[j],y[j],x[j+1],y[j+1],c4); + } + t2 = GrMsecTime(); + seconds = (double)(t2 - t1) / 1000.0; + if (seconds > 0) + gp->drawlin.rate = gp->drawlin.count / seconds; +} + +void drawhlinetest(gvmode *gp, XY_PAIRS *pairs) { + int i, j; + int *x = pairs->x; + int *y = pairs->y; + GrColor c1 = GrWhite(); + GrColor c2 = GrWhite() | GrXOR; + GrColor c3 = GrWhite() | GrOR; + GrColor c4 = GrBlack() | GrAND; + long t1,t2; + double seconds; + + if (!MEASURED(gp)) { + gp->drawhlin.rate = 0.0; + gp->drawhlin.count = 0.0; + for (j=0; j < PAIRS; j+=2) + gp->drawhlin.count += ABS(x[j],x[j+1]); + gp->drawhlin.count *= 4.0 * DRAWHLIN_loops; + } + + t1 = GrMsecTime(); + for (i=0; i < DRAWHLIN_loops; ++i) { + for (j=PAIRS-2; j >= 0; j-=2) + GrHLineNC(x[j],x[j+1],y[j],c1); + for (j=PAIRS-2; j >= 0; j-=2) + GrHLineNC(x[j],x[j+1],y[j],c2); + for (j=PAIRS-2; j >= 0; j-=2) + GrHLineNC(x[j],x[j+1],y[j],c3); + for (j=PAIRS-2; j >= 0; j-=2) + GrHLineNC(x[j],x[j+1],y[j],c4); + } + t2 = GrMsecTime(); + seconds = (double)(t2 - t1) / 1000.0; + if (seconds > 0) + gp->drawhlin.rate = gp->drawhlin.count / seconds; +} + +void drawvlinetest(gvmode *gp, XY_PAIRS *pairs) { + int i, j; + int *x = pairs->x; + int *y = pairs->y; + GrColor c1 = GrWhite(); + GrColor c2 = GrWhite() | GrXOR; + GrColor c3 = GrWhite() | GrOR; + GrColor c4 = GrBlack() | GrAND; + long t1,t2; + double seconds; + + if (!MEASURED(gp)) { + gp->drawvlin.rate = 0.0; + gp->drawvlin.count = 0.0; + for (j=0; j < PAIRS; j+=2) + gp->drawvlin.count += ABS(y[j],y[j+1]); + gp->drawvlin.count *= 4.0 * DRAWVLIN_loops; + } + + t1 = GrMsecTime(); + for (i=0; i < DRAWVLIN_loops; ++i) { + for (j=PAIRS-2; j >= 0; j-=2) + GrVLineNC(x[j],y[j],y[j+1],c1); + for (j=PAIRS-2; j >= 0; j-=2) + GrVLineNC(x[j],y[j],y[j+1],c2); + for (j=PAIRS-2; j >= 0; j-=2) + GrVLineNC(x[j],y[j],y[j+1],c3); + for (j=PAIRS-2; j >= 0; j-=2) + GrVLineNC(x[j],y[j],y[j+1],c4); + } + t2 = GrMsecTime(); + seconds = (double)(t2 - t1) / 1000.0; + if (seconds > 0) + gp->drawvlin.rate = gp->drawvlin.count / seconds; +} + +void drawblocktest(gvmode *gp, XY_PAIRS *pairs) { + int i, j; + GrColor c1 = GrWhite(); + GrColor c2 = GrWhite() | GrXOR; + GrColor c3 = GrWhite() | GrOR; + GrColor c4 = GrBlack() | GrAND; + long t1,t2; + double seconds; + + if (xb == NULL || yb == NULL) return; + + for (j=0; j < PAIRS; j+=2) { + xb[j] = min(pairs->x[j],pairs->x[j+1]); + xb[j+1] = max(pairs->x[j],pairs->x[j+1]); + yb[j] = min(pairs->y[j],pairs->y[j+1]); + yb[j+1] = max(pairs->y[j],pairs->y[j+1]); + } + + if (!MEASURED(gp)) { + gp->drawblk.rate = 0.0; + gp->drawblk.count = 0.0; + for (j=0; j < PAIRS; j+=2) + gp->drawblk.count += ABS(xb[j],xb[j+1]) * ABS(yb[j],yb[j+1]); + gp->drawblk.count *= 4.0 * DRAWBLK_loops; + } + + t1 = GrMsecTime(); + for (i=0; i < DRAWBLK_loops; ++i) { + for (j=PAIRS-2; j >= 0; j-=2) + GrFilledBoxNC(xb[j],yb[j],xb[j+1],yb[j+1],c1); + for (j=PAIRS-2; j >= 0; j-=2) + GrFilledBoxNC(xb[j],yb[j],xb[j+1],yb[j+1],c2); + for (j=PAIRS-2; j >= 0; j-=2) + GrFilledBoxNC(xb[j],yb[j],xb[j+1],yb[j+1],c3); + for (j=PAIRS-2; j >= 0; j-=2) + GrFilledBoxNC(xb[j],yb[j],xb[j+1],yb[j+1],c4); + } + t2 = GrMsecTime(); + seconds = (double)(t2 - t1) / 1000.0; + if (seconds > 0) + gp->drawblk.rate = gp->drawblk.count / seconds; +} + +void xor_draw_blocks(GrContext *c) { + GrContext save; + int i; + + GrSaveContext(&save); + GrSetContext(c); + GrClearContext(GrBlack()); + for (i=28; i > 1; --i) + GrFilledBox(GrMaxX()/i,GrMaxY()/i, + (i-1)*GrMaxX()/i,(i-1)*GrMaxY()/i,GrWhite()|GrXOR); + GrSetContext(&save); +} + +void blit_measure(gvmode *gp, perfm *p, + int *xb, int *yb, + GrContext *dst,GrContext *src) { + int i, j; + long t1,t2; + double seconds; + GrContext save; + + GrSaveContext(&save); + if (dst != src) { + GrSetContext(dst); + GrClearContext(GrBlack()); + } + xor_draw_blocks(src); + GrSetContext(&save); + + if (dst != NULL) { + char *s = src != NULL ? "ram" : "video"; + char *d = dst != NULL ? "ram" : "video"; + char txt[50]; + sprintf(txt, "blit test: %s -> %s", s, d); + Message(1,txt, gp); + } + + t1 = GrMsecTime(); + for (i=0; i < BLIT_loops; ++i) { + for (j=PAIRS-3; j >= 0; j-=3) + GrBitBlt(dst,xb[j+2],yb[j+2],src,xb[j+1],yb[j+1],xb[j],yb[j],GrWRITE); + for (j=PAIRS-3; j >= 0; j-=3) + GrBitBlt(dst,xb[j+2],yb[j+2],src,xb[j+1],yb[j+1],xb[j],yb[j],GrXOR); + for (j=PAIRS-3; j >= 0; j-=3) + GrBitBlt(dst,xb[j+2],yb[j+2],src,xb[j+1],yb[j+1],xb[j],yb[j],GrOR); + for (j=PAIRS-3; j >= 0; j-=3) + GrBitBlt(dst,xb[j+2],yb[j+2],src,xb[j+1],yb[j+1],xb[j],yb[j],GrAND); + } + t2 = GrMsecTime(); + seconds = (double)(t2 - t1) / 1000.0; + if (seconds > 0) + p->rate = p->count / seconds; +} + +void blittest(gvmode *gp, XY_PAIRS *pairs, int ram) { + int j; + + if (xb == NULL || yb == NULL) return; + + for (j=0; j < PAIRS; j+=3) { + int wh; + xb[j] = max(pairs->x[j],pairs->x[j+1]); + xb[j+1] = min(pairs->x[j],pairs->x[j+1]); + xb[j+2] = pairs->x[j+2]; + wh = xb[j]-xb[j+1]; + if (xb[j+2]+wh >= gp->w) xb[j+2] = gp->w - wh - 1; + yb[j] = max(pairs->y[j],pairs->y[j+1]); + yb[j+1] = min(pairs->y[j],pairs->y[j+1]); + yb[j+2] = pairs->y[j+2]; + wh = yb[j]-yb[j+1]; + if (yb[j+2]+wh >= gp->h) yb[j+2] = gp->h - wh - 1; + } + + if (!MEASURED(gp)) { + double count = 0.0; + for (j=0; j < PAIRS; j+=3) + count += ABS(xb[j],xb[j+1]) * ABS(yb[j],yb[j+1]); + gp->blitv2v.count = + gp->blitr2v.count = + gp->blitv2r.count = count * 4.0 * BLIT_loops; + gp->blitv2v.rate = + gp->blitr2v.rate = + gp->blitv2r.rate = 0.0; + } + +#if BLIT_loops-0 + blit_measure(gp, &gp->blitv2v, xb, yb, + (GrContext *)(RAMMODE(gp) ? GrCurrentContext() : NULL), + (GrContext *)(RAMMODE(gp) ? GrCurrentContext() : NULL)); + if (!BLIT_FAIL(gp) && !ram) { + GrContext rc; + GrContext *rcp = GrCreateContext(gp->w,gp->h,NULL,&rc); + if (rcp) { + blit_measure(gp, &gp->blitv2r, xb, yb, rcp, NULL); + blit_measure(gp, &gp->blitr2v, xb, yb, NULL, rcp); + GrDestroyContext(rcp); + } + } +#endif +} + +void measure_one(gvmode *gp, int ram) { + XY_PAIRS *pairs; + + if (MEASURED(gp)) return; + pairs = checkpairs(gp->w, gp->h); + GrFilledBox( 0, 0, gp->w-1, gp->h-1, GrBlack()); + Message(RAMMODE(gp),"read pixel test", gp); + { int rd_loops = READPIX_loops; +#if GRX_VERSION_API-0 >= 0x0229 + unsigned sys = GrGetLibrarySystem(); +#else + unsigned sys = (unsigned) GRX_VERSION; +#endif + if ( (sys == GRX_VERSION_GENERIC_X11) || + (sys == GRX_VERSION_GCC_386_X11) || + (sys == GRX_VERSION_GCC_X86_64_X11) ) + if (!RAMMODE(gp)) rd_loops = READPIX_X11_loops; + readpixeltest(gp,pairs,rd_loops); + } + GrFilledBox( 0, 0, gp->w-1, gp->h-1, GrBlack()); + Message(RAMMODE(gp),"draw pixel test", gp); + drawpixeltest(gp,pairs); + GrFilledBox( 0, 0, gp->w-1, gp->h-1, GrBlack()); + Message(RAMMODE(gp),"draw line test ", gp); + drawlinetest(gp,pairs); + GrFilledBox( 0, 0, gp->w-1, gp->h-1, GrBlack()); + Message(RAMMODE(gp),"draw hline test", gp); + drawhlinetest(gp,pairs); + GrFilledBox( 0, 0, gp->w-1, gp->h-1, GrBlack()); + Message(RAMMODE(gp),"draw vline test", gp); + drawvlinetest(gp,pairs); + GrFilledBox( 0, 0, gp->w-1, gp->h-1, GrBlack()); + Message(RAMMODE(gp),"draw block test", gp); + drawblocktest(gp,pairs); + GrFilledBox( 0, 0, gp->w-1, gp->h-1, GrBlack()); + blittest(gp, pairs, ram); + GrFilledBox( 0, 0, gp->w-1, gp->h-1, GrBlack()); + SET_MEASURED(gp); + measured_any = 1; +} + +#if MEASURE_RAM_MODES +int identical_measured(gvmode *tm) { + int i; + for (i=0; i < nmodes; ++i) { + if (tm != &rammodes[i] && + tm->fm == rammodes[i].fm && + tm->w == rammodes[i].w && + tm->h == rammodes[i].h && + tm->bpp == rammodes[i].bpp && + MEASURED(&rammodes[i]) ) return (1); + } + return 0; +} +#endif + +static int first = 0; + +void speedcheck(gvmode *gp, int print, int wait) { + char m[41]; + gvmode *rp = NULL; + + if (first) { + printf( + "speedtest may take some time to process.\n" + "Now press to continue..." + ); + fflush(stdout); + fgets(m,40,stdin); + } + + GrSetMode( + GR_width_height_bpp_graphics, + gp->w, gp->h, gp->bpp + ); + + if (first) { + /* xor_draw_blocks(NULL); + getch(); */ + first = 0; + } + + if ( GrScreenFrameMode() != gp->fm) { + GrFrameMode act = GrScreenFrameMode(); + GrSetMode(GR_default_text); + printf("Setup failed : %s != %s\n", + FrameDriverName(act), + FrameDriverName(gp->fm)); + fgets(m,40,stdin); + return; + } + + if (!MEASURED(gp)) + measure_one(gp, 0); + +#if MEASURE_RAM_MODES + rp = &rammodes[(unsigned)(gp-grmodes)]; + rp->fm = GrCoreFrameMode(); + if (!MEASURED(rp) && !identical_measured(rp)) { + GrContext rc; + if (GrCreateFrameContext(rp->fm,gp->w,gp->h,NULL,&rc)) { + GrSetContext(&rc); + measure_one(rp, 1); + GrDestroyContext(&rc); + GrSetContext(NULL); + } + } +#endif + + GrSetMode(GR_default_text); + if (print) { + printf("Results: \n"); + printresultheader(stdout); + printresultline(stdout, gp); + if (rp) + printresultline(stdout, rp); + } + if (wait) + fgets(m,40,stdin); +} + +int collectmodes(const GrVideoDriver *drv) +{ + gvmode *gp = grmodes; + GrFrameMode fm; + const GrVideoMode *mp; + for(fm =GR_firstGraphicsFrameMode; + fm <= GR_lastGraphicsFrameMode; fm++) { + for(mp = GrFirstVideoMode(fm); mp; mp = GrNextVideoMode(mp)) { + gp->fm = fm; + gp->w = mp->width; + gp->h = mp->height; + gp->bpp = mp->bpp; + gp->flags = 0; + gp++; + if (gp-grmodes >= MAX_MODES) return MAX_MODES; + } + } + return(int)(gp-grmodes); +} + +int vmcmp(const void *m1,const void *m2) +{ + gvmode *md1 = (gvmode *)m1; + gvmode *md2 = (gvmode *)m2; + if(md1->bpp != md2->bpp) return(md1->bpp - md2->bpp); + if(md1->w != md2->w ) return(md1->w - md2->w ); + if(md1->h != md2->h ) return(md1->h - md2->h ); + return(0); +} + +#define LINES 20 +#define COLUMNS 80 + +void ModeText(int i, int shrt,char *mdtxt) { + char *flg; + + if (MEASURED(&grmodes[i])) flg = " #"; else + if (TAGGED(&grmodes[i])) flg = " *"; else + flg = ") "; + switch (shrt) { + case 2 : sprintf(mdtxt,"%2d%s %dx%d ", i+1, flg, grmodes[i].w, grmodes[i].h); + break; + case 1 : sprintf(mdtxt,"%2d%s %4dx%-4d ", i+1, flg, grmodes[i].w, grmodes[i].h); + break; + default: sprintf(mdtxt," %2d%s %4dx%-4d ", i+1, flg, grmodes[i].w, grmodes[i].h); + break; + } + mdtxt += strlen(mdtxt); + + if (grmodes[i].bpp > 20) + sprintf(mdtxt, "%ldM", 1L << (grmodes[i].bpp-20)); + else if (grmodes[i].bpp > 10) + sprintf(mdtxt, "%ldk", 1L << (grmodes[i].bpp-10)); + else + sprintf(mdtxt, "%ld", 1L << grmodes[i].bpp); + switch (shrt) { + case 2 : break; + case 1 : strcat(mdtxt, " col"); break; + default: strcat(mdtxt, " colors"); break; + } +} + +int ColsCheck(int cols, int ml, int sep) { + int len; + + len = ml * cols + (cols-1) * sep + 1; + return len <= COLUMNS; +} + +void PrintModes(void) { + char mdtxt[100]; + unsigned int maxlen; + int i, n, shrt, c, cols; + + cols = (nmodes+LINES-1) / LINES; + do { + for (shrt = 0; shrt <= 2; ++shrt) { + maxlen = 0; + for (i = 0; i < nmodes; ++i) { + ModeText(i,shrt,mdtxt); + if (strlen(mdtxt) > maxlen) maxlen = strlen(mdtxt); + } + n = 2; + if (cols>1 || shrt<2) { + if (!ColsCheck(cols, maxlen, n)) continue; + while (ColsCheck(cols, maxlen, n+1) && n < 4) ++n; + } + c = 0; + for (i = 0; i < nmodes; ++i) { + if (++c == cols) c = 0; + ModeText(i,shrt,mdtxt); + printf("%*s%s", (c ? -((int)(maxlen+n)) : -((int)maxlen)), mdtxt, (c || (i+1==nmodes) ? "" : "\n") ); + } + return; + } + --cols; + } while (1); +} + +int main(int argc, char **argv) +{ + int i; + + grmodes = malloc(MAX_MODES*sizeof(gvmode)); + assert(grmodes!=NULL); +#if MEASURE_RAM_MODES + rammodes = malloc(MAX_MODES*sizeof(gvmode)); + assert(rammodes!=NULL); +#endif + + GrSetDriver(NULL); + if(GrCurrentVideoDriver() == NULL) { + printf("No graphics driver found\n"); + exit(1); + } + + nmodes = collectmodes(GrCurrentVideoDriver()); + if(nmodes == 0) { + printf("No graphics modes found\n"); + exit(1); + } + qsort(grmodes,nmodes,sizeof(grmodes[0]),vmcmp); +#if MEASURE_RAM_MODES + for (i=0; i < nmodes; ++i) { + rammodes[i].fm = GR_frameUndef; /* filled in later */ + rammodes[i].w = grmodes[i].w; + rammodes[i].h = grmodes[i].h; + rammodes[i].bpp = grmodes[i].bpp; + rammodes[i].flags = FLG_rammode; + } +#endif + + if(argc >= 2 && (i = atoi(argv[1])) >= 1 && i <= nmodes) { + speedcheck(&grmodes[i - 1], 1, 0); + goto done; + } + + first = 1; + for( ; ; ) { + char mb[41], *m = mb; + int tflag = 0; + GrSetMode(GR_default_text); + printf( + "Graphics driver: \"%s\"\t" + "graphics defaults: %dx%d %ld colors\n", + GrCurrentVideoDriver()->name, + GrDriverInfo->defgw, + GrDriverInfo->defgh, + (long)GrDriverInfo->defgc + ); + PrintModes(); + printf("\nEnter #, 't#' toggels tag, 'm' measure tagged and 'q' to quit> "); + fflush(stdout); + if(!fgets(m,40,stdin)) break; + switch (*m) { + case 't': + case 'T': tflag = 1; + ++m; + break; + case 'A': + case 'a': for (i=0; i < nmodes; ++i) + SET_TAGGED(&grmodes[i]); + break; + case 'M': + case 'm': for (i=0; i < nmodes; ++i) + if (TAGGED(&grmodes[i])) { + speedcheck(&grmodes[i], 0, 0); + TOGGLE_TAGGED(&grmodes[i]); + } + break; + case 'Q': + case 'q': goto done; + } + if ((sscanf(m,"%d",&i) != 1) || (i < 1) || (i > nmodes)) + continue; + i--; + if (tflag) TOGGLE_TAGGED(&grmodes[i]); + else speedcheck(&grmodes[i], 1, 1); + } +done: + if (measured_any) { + int i; + FILE *log = fopen("speedtst.log", "a"); + + if (!log) exit(1); + + fprintf( log, "\nGraphics driver: \"%s\"\n\n", + GrCurrentVideoDriver()->name); + printf("Results: \n"); + printresultheader(log); + + for (i=0; i < nmodes; ++i) + if (MEASURED(&grmodes[i])) + printresultline(log, &grmodes[i]); +#if MEASURE_RAM_MODES + for (i=0; i < nmodes; ++i) + if (MEASURED(&rammodes[i])) + printresultline(log, &rammodes[i]); +#endif + fclose(log); + } + return(0); +} + diff --git a/thirdparty/grx249/test/test.h b/thirdparty/grx249/test/test.h new file mode 100644 index 0000000..e7be295 --- /dev/null +++ b/thirdparty/grx249/test/test.h @@ -0,0 +1,91 @@ +/** + ** test.h ---- common declarations for test programs + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#ifndef __TEST_H_INCLUDED__ +#define __TEST_H_INCLUDED__ + +#include +#include +#include + +#include "grx20.h" +#include "grxkeys.h" +#include "drawing.h" + +extern void (*testfunc)(void); +char exit_message[2000] = { "" }; +int Argc; +char **Argv; + +#define TESTFUNC(name) \ +void name(void); \ +void (*testfunc)(void) = name; \ +void name(void) + +int main(int argc,char **argv) +{ + int x = 0; + int y = 0; + long c = 0; + int xv = 0; + int yv = 0; + + Argc = argc - 1; + Argv = argv + 1; + if((Argc >= 2) && + (sscanf(Argv[0],"%d",&x) == 1) && (x >= 320) && + (sscanf(Argv[1],"%d",&y) == 1) && (y >= 200)) { + Argc -= 2; + Argv += 2; + if (Argc > 0) { + char *endp; + c = strtol(Argv[0], &endp, 0); + switch (*endp) { + case 'k': + case 'K': c <<= 10; break; + case 'm': + case 'M': c <<= 20; break; + } + Argc--; + Argv++; + } + } + if((Argc >= 2) && + (sscanf(Argv[0],"%d",&xv) == 1) && (xv >= x) && + (sscanf(Argv[1],"%d",&yv) == 1) && (yv >= y)) { + Argc -= 2; + Argv += 2; + } + if((xv >= x) && (yv >= y) && (c >= 2)) + GrSetMode(GR_custom_graphics,x,y,c,xv,yv); + else if(c >= 2) + GrSetMode(GR_width_height_color_graphics,x,y,c); + else if((x >= 320) && (y >= 200)) + GrSetMode(GR_width_height_graphics,x,y); + else GrSetMode(GR_default_graphics); + (*testfunc)(); + GrSetMode(GR_default_text); + if(strlen(exit_message) > 0) { + puts(exit_message); + } + return(0); +} + +#endif /* _TEST_H_ */ + diff --git a/thirdparty/grx249/test/textpatt.c b/thirdparty/grx249/test/textpatt.c new file mode 100644 index 0000000..92544e0 --- /dev/null +++ b/thirdparty/grx249/test/textpatt.c @@ -0,0 +1,67 @@ +/** + ** textpatt.c + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include +#include +#include "grx20.h" +#include "grxkeys.h" + +#define FONT "../fonts/tms38b.fnt" + +int main(void) +{ + char bits[] = {0, 76, 50, 0, 0, 76, 60, 0}; + GrPattern *p1, *p2; + GrFont *font; + GrTextOption opt; + + GrSetMode(GR_width_height_color_graphics, 320, 200, (GrColor)256); + p1 = GrBuildPixmapFromBits(bits, 8, 8, 11, 3); + p2 = GrBuildPixmapFromBits(bits, 8, 8, 3, 11); + font = GrLoadFont(FONT); + if (font && p1 && p2) { + memset(&opt, 0, sizeof(GrTextOption)); + opt.txo_font = font; + opt.txo_xalign = 0; + opt.txo_yalign = 0; + opt.txo_direct = GR_TEXT_RIGHT; + opt.txo_fgcolor.v = GrNOCOLOR; + opt.txo_bgcolor.v = GrNOCOLOR; + GrPatternFilledBox(0, 0, GrMaxX(), GrMaxY(), p1); + GrKeyRead(); + GrPatternDrawString(" Hello world !", 15, 40, 10, &opt, p1); + GrPatternDrawString(" Hello world !", 15, 44, 50, &opt, p2); + GrPatternDrawStringExt(" Hello world !!", 16, 40, 100, &opt, p1); + GrPatternDrawStringExt(" Hello world !!", 16, 44, 140, &opt, p2); + GrKeyRead(); + opt.txo_bgcolor.v = GrBlack(); + GrPatternDrawString(" Hello world !", 15, 40, 10, &opt, p1); + GrPatternDrawString(" Hello world !", 15, 44, 50, &opt, p2); + GrPatternDrawStringExt(" Hello world !!", 16, 40, 100, &opt, p1); + GrPatternDrawStringExt(" Hello world !!", 16, 44, 140, &opt, p2); + GrKeyRead(); + } + if (p1) GrDestroyPattern(p1); + if (p2) GrDestroyPattern(p2); + if (font) GrUnloadFont(font); + GrSetMode(GR_default_text); + if (!p1) fprintf(stderr, "Couldn't create first pattern\n"); + if (!p2) fprintf(stderr, "Couldn't create second pattern\n"); + if (!font) fprintf(stderr, "Couldn't load font %s\n", FONT); + + return 0; +} + diff --git a/thirdparty/grx249/test/winclip.c b/thirdparty/grx249/test/winclip.c new file mode 100644 index 0000000..b2dc3dd --- /dev/null +++ b/thirdparty/grx249/test/winclip.c @@ -0,0 +1,56 @@ +/** + ** winclip.c ---- clip a drawing to various windows (contexts) + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" + +TESTFUNC(winclip) +{ + int x = GrSizeX(); + int y = GrSizeY(); + int ww = (x / 2) - 10; + int wh = (y / 2) - 10; + GrColor c; + GrContext *w1 = GrCreateSubContext(5,5,ww+4,wh+4,NULL,NULL); + GrContext *w2 = GrCreateSubContext(15+ww,5,ww+ww+14,wh+4,NULL,NULL); + GrContext *w3 = GrCreateSubContext(5,15+wh,ww+4,wh+wh+14,NULL,NULL); + GrContext *w4 = GrCreateSubContext(15+ww,15+wh,ww+ww+14,wh+wh+14,NULL,NULL); + + GrSetContext(w1); + c = GrAllocColor(200,100,100); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w2); + c = GrAllocColor(100,200,200); + drawing(-ww/4,ww/3,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w3); + c = GrAllocColor(200,200,0); + drawing(ww/2,-wh/2,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w4); + c = GrAllocColor(0,100,200); + drawing(-ww/2,-wh/2,ww*2,wh*2,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrKeyRead(); +} + diff --git a/thirdparty/grx249/test/wintest.c b/thirdparty/grx249/test/wintest.c new file mode 100644 index 0000000..5e7da7e --- /dev/null +++ b/thirdparty/grx249/test/wintest.c @@ -0,0 +1,56 @@ +/** + ** wintest.c ---- test window (context) mapping + ** + ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 + ** [e-mail: csaba@vuse.vanderbilt.edu] + ** + ** This is a test/demo file of the GRX graphics library. + ** You can use GRX test/demo files as you want. + ** + ** The GRX graphics library is free software; you can redistribute it + ** and/or modify it under some conditions; see the "copying.grx" file + ** for details. + ** + ** This library is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ** + **/ + +#include "test.h" + +TESTFUNC(wintest) +{ + int x = GrSizeX(); + int y = GrSizeY(); + int ww = (x / 2) - 10; + int wh = (y / 2) - 10; + GrColor c; + GrContext *w1 = GrCreateSubContext(5,5,ww+4,wh+4,NULL,NULL); + GrContext *w2 = GrCreateSubContext(15+ww,5,ww+ww+14,wh+4,NULL,NULL); + GrContext *w3 = GrCreateSubContext(5,15+wh,ww+4,wh+wh+14,NULL,NULL); + GrContext *w4 = GrCreateSubContext(15+ww,15+wh,ww+ww+14,wh+wh+14,NULL,NULL); + + GrSetContext(w1); + c = GrAllocColor(200,100,100); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w2); + c = GrAllocColor(100,200,200); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w3); + c = GrAllocColor(200,200,0); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrSetContext(w4); + c = GrAllocColor(0,100,200); + drawing(0,0,ww,wh,c,GrBlack()); + GrBox(0,0,ww-1,wh-1,c); + + GrKeyRead(); +} + diff --git a/thirdparty/jpeg-9e/Makefile b/thirdparty/jpeg-9e/Makefile new file mode 100644 index 0000000..9119f62 --- /dev/null +++ b/thirdparty/jpeg-9e/Makefile @@ -0,0 +1,1249 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + +# +# Automake Makefile for the JPEG library +# +# This file is written by Bob Friesenhahn, Guido Vollbeding +# + + + + + +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/libjpeg +pkgincludedir = $(includedir)/libjpeg +pkglibdir = $(libdir)/libjpeg +pkglibexecdir = $(libexecdir)/libjpeg +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = x86_64-pc-linux-gnu +host_triplet = x86_64-pc-linux-gnu +target_triplet = x86_64-pc-linux-gnu +am__append_1 = -Wl,--version-script=$(srcdir)/libjpeg.map +bin_PROGRAMS = cjpeg$(EXEEXT) djpeg$(EXEEXT) jpegtran$(EXEEXT) \ + rdjpgcom$(EXEEXT) wrjpgcom$(EXEEXT) +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(include_HEADERS) $(noinst_HEADERS) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = jconfig.h +CONFIG_CLEAN_FILES = libjpeg.pc +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" \ + "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(pkgconfigdir)" \ + "$(DESTDIR)$(includedir)" +PROGRAMS = $(bin_PROGRAMS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +LTLIBRARIES = $(lib_LTLIBRARIES) +libjpeg_la_LIBADD = +am__objects_1 = jaricom.lo jcapimin.lo jcapistd.lo jcarith.lo \ + jccoefct.lo jccolor.lo jcdctmgr.lo jchuff.lo jcinit.lo \ + jcmainct.lo jcmarker.lo jcmaster.lo jcomapi.lo jcparam.lo \ + jcprepct.lo jcsample.lo jctrans.lo jdapimin.lo jdapistd.lo \ + jdarith.lo jdatadst.lo jdatasrc.lo jdcoefct.lo jdcolor.lo \ + jddctmgr.lo jdhuff.lo jdinput.lo jdmainct.lo jdmarker.lo \ + jdmaster.lo jdmerge.lo jdpostct.lo jdsample.lo jdtrans.lo \ + jerror.lo jfdctflt.lo jfdctfst.lo jfdctint.lo jidctflt.lo \ + jidctfst.lo jidctint.lo jquant1.lo jquant2.lo jutils.lo \ + jmemmgr.lo jmemnobs.lo +am_libjpeg_la_OBJECTS = $(am__objects_1) +libjpeg_la_OBJECTS = $(am_libjpeg_la_OBJECTS) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +am__v_lt_1 = +libjpeg_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libjpeg_la_LDFLAGS) $(LDFLAGS) -o $@ +am_cjpeg_OBJECTS = cjpeg.$(OBJEXT) rdppm.$(OBJEXT) rdgif.$(OBJEXT) \ + rdtarga.$(OBJEXT) rdrle.$(OBJEXT) rdbmp.$(OBJEXT) \ + rdswitch.$(OBJEXT) cdjpeg.$(OBJEXT) +cjpeg_OBJECTS = $(am_cjpeg_OBJECTS) +cjpeg_DEPENDENCIES = libjpeg.la +am_djpeg_OBJECTS = djpeg.$(OBJEXT) wrppm.$(OBJEXT) wrgif.$(OBJEXT) \ + wrtarga.$(OBJEXT) wrrle.$(OBJEXT) wrbmp.$(OBJEXT) \ + rdcolmap.$(OBJEXT) cdjpeg.$(OBJEXT) +djpeg_OBJECTS = $(am_djpeg_OBJECTS) +djpeg_DEPENDENCIES = libjpeg.la +am_jpegtran_OBJECTS = jpegtran.$(OBJEXT) rdswitch.$(OBJEXT) \ + cdjpeg.$(OBJEXT) transupp.$(OBJEXT) +jpegtran_OBJECTS = $(am_jpegtran_OBJECTS) +jpegtran_DEPENDENCIES = libjpeg.la +am_rdjpgcom_OBJECTS = rdjpgcom.$(OBJEXT) +rdjpgcom_OBJECTS = $(am_rdjpgcom_OBJECTS) +rdjpgcom_LDADD = $(LDADD) +am_wrjpgcom_OBJECTS = wrjpgcom.$(OBJEXT) +wrjpgcom_OBJECTS = $(am_wrjpgcom_OBJECTS) +wrjpgcom_LDADD = $(LDADD) +AM_V_P = $(am__v_P_$(V)) +am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY)) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I. +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/jmemnobs.Plo \ + ./$(DEPDIR)/cdjpeg.Po ./$(DEPDIR)/cjpeg.Po \ + ./$(DEPDIR)/djpeg.Po ./$(DEPDIR)/jaricom.Plo \ + ./$(DEPDIR)/jcapimin.Plo ./$(DEPDIR)/jcapistd.Plo \ + ./$(DEPDIR)/jcarith.Plo ./$(DEPDIR)/jccoefct.Plo \ + ./$(DEPDIR)/jccolor.Plo ./$(DEPDIR)/jcdctmgr.Plo \ + ./$(DEPDIR)/jchuff.Plo ./$(DEPDIR)/jcinit.Plo \ + ./$(DEPDIR)/jcmainct.Plo ./$(DEPDIR)/jcmarker.Plo \ + ./$(DEPDIR)/jcmaster.Plo ./$(DEPDIR)/jcomapi.Plo \ + ./$(DEPDIR)/jcparam.Plo ./$(DEPDIR)/jcprepct.Plo \ + ./$(DEPDIR)/jcsample.Plo ./$(DEPDIR)/jctrans.Plo \ + ./$(DEPDIR)/jdapimin.Plo ./$(DEPDIR)/jdapistd.Plo \ + ./$(DEPDIR)/jdarith.Plo ./$(DEPDIR)/jdatadst.Plo \ + ./$(DEPDIR)/jdatasrc.Plo ./$(DEPDIR)/jdcoefct.Plo \ + ./$(DEPDIR)/jdcolor.Plo ./$(DEPDIR)/jddctmgr.Plo \ + ./$(DEPDIR)/jdhuff.Plo ./$(DEPDIR)/jdinput.Plo \ + ./$(DEPDIR)/jdmainct.Plo ./$(DEPDIR)/jdmarker.Plo \ + ./$(DEPDIR)/jdmaster.Plo ./$(DEPDIR)/jdmerge.Plo \ + ./$(DEPDIR)/jdpostct.Plo ./$(DEPDIR)/jdsample.Plo \ + ./$(DEPDIR)/jdtrans.Plo ./$(DEPDIR)/jerror.Plo \ + ./$(DEPDIR)/jfdctflt.Plo ./$(DEPDIR)/jfdctfst.Plo \ + ./$(DEPDIR)/jfdctint.Plo ./$(DEPDIR)/jidctflt.Plo \ + ./$(DEPDIR)/jidctfst.Plo ./$(DEPDIR)/jidctint.Plo \ + ./$(DEPDIR)/jmemmgr.Plo ./$(DEPDIR)/jpegtran.Po \ + ./$(DEPDIR)/jquant1.Plo ./$(DEPDIR)/jquant2.Plo \ + ./$(DEPDIR)/jutils.Plo ./$(DEPDIR)/rdbmp.Po \ + ./$(DEPDIR)/rdcolmap.Po ./$(DEPDIR)/rdgif.Po \ + ./$(DEPDIR)/rdjpgcom.Po ./$(DEPDIR)/rdppm.Po \ + ./$(DEPDIR)/rdrle.Po ./$(DEPDIR)/rdswitch.Po \ + ./$(DEPDIR)/rdtarga.Po ./$(DEPDIR)/transupp.Po \ + ./$(DEPDIR)/wrbmp.Po ./$(DEPDIR)/wrgif.Po \ + ./$(DEPDIR)/wrjpgcom.Po ./$(DEPDIR)/wrppm.Po \ + ./$(DEPDIR)/wrrle.Po ./$(DEPDIR)/wrtarga.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libjpeg_la_SOURCES) $(cjpeg_SOURCES) $(djpeg_SOURCES) \ + $(jpegtran_SOURCES) $(rdjpgcom_SOURCES) $(wrjpgcom_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man_MANS) +DATA = $(nodist_pkgconfig_DATA) +HEADERS = $(include_HEADERS) $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \ + jconfig.cfg +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +AM_RECURSIVE_TARGETS = cscope +ACLOCAL = ${SHELL} '/home/scott/code/gui/thirdparty/jpeg-9e/missing' aclocal-1.16 +AMTAR = $${TAR-tar} +AM_DEFAULT_VERBOSITY = 0 +AR = ar +AS = as +AUTOCONF = ${SHELL} '/home/scott/code/gui/thirdparty/jpeg-9e/missing' autoconf +AUTOHEADER = echo autoheader ignored +AUTOMAKE = ${SHELL} '/home/scott/code/gui/thirdparty/jpeg-9e/missing' automake-1.16 +AWK = gawk +CC = gcc +CCDEPMODE = depmode=gcc3 +CFLAGS = -g -O2 +CPP = gcc -E +CPPFLAGS = +CSCOPE = cscope +CTAGS = ctags +CYGPATH_W = echo +DEFS = -DHAVE_CONFIG_H +DEPDIR = .deps +DLLTOOL = false +DSYMUTIL = +DUMPBIN = +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /usr/bin/grep -E +ETAGS = etags +EXEEXT = +FGREP = /usr/bin/grep -F +GREP = /usr/bin/grep +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +JPEG_LIB_VERSION = 14:0:5 +JPEG_LIB_VERSION_MAJOR = 9 +JPEG_LIB_VERSION_MINOR = 5 +LD = /usr/bin/ld -m elf_x86_64 +LDFLAGS = +LIBOBJS = +LIBS = +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LIPO = +LN_S = ln -s +LTLIBOBJS = +LT_SYS_LIBRARY_PATH = +MAINT = # +MAKEINFO = ${SHELL} '/home/scott/code/gui/thirdparty/jpeg-9e/missing' makeinfo +MANIFEST_TOOL = : +MEMORYMGR = jmemnobs +MKDIR_P = /usr/bin/mkdir -p +NM = /usr/bin/nm -B +NMEDIT = +OBJDUMP = objdump +OBJEXT = o +OTOOL = +OTOOL64 = +PACKAGE = libjpeg +PACKAGE_BUGREPORT = +PACKAGE_NAME = libjpeg +PACKAGE_STRING = libjpeg 9.5.0 +PACKAGE_TARNAME = libjpeg +PACKAGE_URL = +PACKAGE_VERSION = 9.5.0 +PATH_SEPARATOR = : +RANLIB = ranlib +SED = /usr/bin/sed +SET_MAKE = +SHELL = /bin/bash +STRIP = strip +VERSION = 9.5.0 +abs_builddir = /home/scott/code/gui/thirdparty/jpeg-9e +abs_srcdir = /home/scott/code/gui/thirdparty/jpeg-9e +abs_top_builddir = /home/scott/code/gui/thirdparty/jpeg-9e +abs_top_srcdir = /home/scott/code/gui/thirdparty/jpeg-9e +ac_ct_AR = ar +ac_ct_CC = gcc +ac_ct_DUMPBIN = +am__include = include +am__leading_dot = . +am__quote = +am__tar = $${TAR-tar} chof - "$$tardir" +am__untar = $${TAR-tar} xf - +bindir = ${exec_prefix}/bin +build = x86_64-pc-linux-gnu +build_alias = +build_cpu = x86_64 +build_os = linux-gnu +build_vendor = pc +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = x86_64-pc-linux-gnu +host_alias = +host_cpu = x86_64 +host_os = linux-gnu +host_vendor = pc +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = ${SHELL} /home/scott/code/gui/thirdparty/jpeg-9e/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = $(MKDIR_P) +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /home/scott/code/gui/installed/linux +program_transform_name = s,x,x, +psdir = ${docdir} +runstatedir = ${localstatedir}/run +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target = x86_64-pc-linux-gnu +target_alias = +target_cpu = x86_64 +target_os = linux-gnu +target_vendor = pc +top_build_prefix = +top_builddir = . +top_srcdir = . + +# Sources to build library +LIBSOURCES = jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c jmemnobs.c + + +# System dependent sources +SYSDEPSOURCES = jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c + +# Headers which are installed to support the library +INSTINCLUDES = jerror.h jmorecfg.h jpeglib.h + +# Headers which are not installed +OTHERINCLUDES = cderror.h cdjpeg.h jdct.h jinclude.h jmemsys.h jpegint.h \ + jversion.h transupp.h + + +# Manual pages (Automake uses 'MANS' for itself) +DISTMANS = cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1 + +# Other documentation files +DOCS = README install.txt usage.txt wizard.txt example.c libjpeg.txt \ + structure.txt coderules.txt filelist.txt cdaltui.txt change.log + + +# Makefiles for various systems +MKFILES = configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt + + +# Configuration files +CONFIGFILES = jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms + + +# Support scripts for configure +CONFIGUREFILES = config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib + + +# Miscellaneous support files +OTHERFILES = jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c + + +# Test support files +TESTFILES = testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg + + +# libtool libraries to build +lib_LTLIBRARIES = libjpeg.la + +# Library sources for libjpeg.la +libjpeg_la_SOURCES = $(LIBSOURCES) + +# LDFLAGS for libjpeg.la +libjpeg_la_LDFLAGS = -no-undefined -version-info $(JPEG_LIB_VERSION) \ + $(am__append_1) + +# Executable sources & libs +cjpeg_SOURCES = cjpeg.c rdppm.c rdgif.c rdtarga.c rdrle.c rdbmp.c \ + rdswitch.c cdjpeg.c + +cjpeg_LDADD = libjpeg.la +djpeg_SOURCES = djpeg.c wrppm.c wrgif.c wrtarga.c wrrle.c wrbmp.c \ + rdcolmap.c cdjpeg.c + +djpeg_LDADD = libjpeg.la +jpegtran_SOURCES = jpegtran.c rdswitch.c cdjpeg.c transupp.c +jpegtran_LDADD = libjpeg.la +rdjpgcom_SOURCES = rdjpgcom.c +wrjpgcom_SOURCES = wrjpgcom.c + +# Manual pages to install +man_MANS = $(DISTMANS) + +# Headers to install +include_HEADERS = $(INSTINCLUDES) + +# Other distributed headers +noinst_HEADERS = $(OTHERINCLUDES) + +# Other distributed files +EXTRA_DIST = $(DOCS) $(DISTMANS) $(MKFILES) $(CONFIGFILES) $(SYSDEPSOURCES) \ + $(OTHERFILES) $(TESTFILES) + + +# pkg-config file +pkgconfigdir = $(libdir)/pkgconfig +nodist_pkgconfig_DATA = libjpeg.pc + +# Files to be cleaned +CLEANFILES = testout.ppm testout.gif testout.bmp testout.jpg testoutp.ppm \ + testoutp.jpg testoutt.jpg + +all: jconfig.h + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +am--refresh: Makefile + @: +$(srcdir)/Makefile.in: # $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: # $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): # $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +jconfig.h: stamp-h1 + @test -f $@ || rm -f stamp-h1 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 + +stamp-h1: $(srcdir)/jconfig.cfg $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status jconfig.h +$(srcdir)/jconfig.cfg: # $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f jconfig.h stamp-h1 +libjpeg.pc: $(top_builddir)/config.status $(srcdir)/libjpeg.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libjpeg.la: $(libjpeg_la_OBJECTS) $(libjpeg_la_DEPENDENCIES) $(EXTRA_libjpeg_la_DEPENDENCIES) + $(AM_V_CCLD)$(libjpeg_la_LINK) -rpath $(libdir) $(libjpeg_la_OBJECTS) $(libjpeg_la_LIBADD) $(LIBS) + +cjpeg$(EXEEXT): $(cjpeg_OBJECTS) $(cjpeg_DEPENDENCIES) $(EXTRA_cjpeg_DEPENDENCIES) + @rm -f cjpeg$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(cjpeg_OBJECTS) $(cjpeg_LDADD) $(LIBS) + +djpeg$(EXEEXT): $(djpeg_OBJECTS) $(djpeg_DEPENDENCIES) $(EXTRA_djpeg_DEPENDENCIES) + @rm -f djpeg$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(djpeg_OBJECTS) $(djpeg_LDADD) $(LIBS) + +jpegtran$(EXEEXT): $(jpegtran_OBJECTS) $(jpegtran_DEPENDENCIES) $(EXTRA_jpegtran_DEPENDENCIES) + @rm -f jpegtran$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(jpegtran_OBJECTS) $(jpegtran_LDADD) $(LIBS) + +rdjpgcom$(EXEEXT): $(rdjpgcom_OBJECTS) $(rdjpgcom_DEPENDENCIES) $(EXTRA_rdjpgcom_DEPENDENCIES) + @rm -f rdjpgcom$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(rdjpgcom_OBJECTS) $(rdjpgcom_LDADD) $(LIBS) + +wrjpgcom$(EXEEXT): $(wrjpgcom_OBJECTS) $(wrjpgcom_DEPENDENCIES) $(EXTRA_wrjpgcom_DEPENDENCIES) + @rm -f wrjpgcom$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(wrjpgcom_OBJECTS) $(wrjpgcom_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/jmemnobs.Plo # am--include-marker +include ./$(DEPDIR)/cdjpeg.Po # am--include-marker +include ./$(DEPDIR)/cjpeg.Po # am--include-marker +include ./$(DEPDIR)/djpeg.Po # am--include-marker +include ./$(DEPDIR)/jaricom.Plo # am--include-marker +include ./$(DEPDIR)/jcapimin.Plo # am--include-marker +include ./$(DEPDIR)/jcapistd.Plo # am--include-marker +include ./$(DEPDIR)/jcarith.Plo # am--include-marker +include ./$(DEPDIR)/jccoefct.Plo # am--include-marker +include ./$(DEPDIR)/jccolor.Plo # am--include-marker +include ./$(DEPDIR)/jcdctmgr.Plo # am--include-marker +include ./$(DEPDIR)/jchuff.Plo # am--include-marker +include ./$(DEPDIR)/jcinit.Plo # am--include-marker +include ./$(DEPDIR)/jcmainct.Plo # am--include-marker +include ./$(DEPDIR)/jcmarker.Plo # am--include-marker +include ./$(DEPDIR)/jcmaster.Plo # am--include-marker +include ./$(DEPDIR)/jcomapi.Plo # am--include-marker +include ./$(DEPDIR)/jcparam.Plo # am--include-marker +include ./$(DEPDIR)/jcprepct.Plo # am--include-marker +include ./$(DEPDIR)/jcsample.Plo # am--include-marker +include ./$(DEPDIR)/jctrans.Plo # am--include-marker +include ./$(DEPDIR)/jdapimin.Plo # am--include-marker +include ./$(DEPDIR)/jdapistd.Plo # am--include-marker +include ./$(DEPDIR)/jdarith.Plo # am--include-marker +include ./$(DEPDIR)/jdatadst.Plo # am--include-marker +include ./$(DEPDIR)/jdatasrc.Plo # am--include-marker +include ./$(DEPDIR)/jdcoefct.Plo # am--include-marker +include ./$(DEPDIR)/jdcolor.Plo # am--include-marker +include ./$(DEPDIR)/jddctmgr.Plo # am--include-marker +include ./$(DEPDIR)/jdhuff.Plo # am--include-marker +include ./$(DEPDIR)/jdinput.Plo # am--include-marker +include ./$(DEPDIR)/jdmainct.Plo # am--include-marker +include ./$(DEPDIR)/jdmarker.Plo # am--include-marker +include ./$(DEPDIR)/jdmaster.Plo # am--include-marker +include ./$(DEPDIR)/jdmerge.Plo # am--include-marker +include ./$(DEPDIR)/jdpostct.Plo # am--include-marker +include ./$(DEPDIR)/jdsample.Plo # am--include-marker +include ./$(DEPDIR)/jdtrans.Plo # am--include-marker +include ./$(DEPDIR)/jerror.Plo # am--include-marker +include ./$(DEPDIR)/jfdctflt.Plo # am--include-marker +include ./$(DEPDIR)/jfdctfst.Plo # am--include-marker +include ./$(DEPDIR)/jfdctint.Plo # am--include-marker +include ./$(DEPDIR)/jidctflt.Plo # am--include-marker +include ./$(DEPDIR)/jidctfst.Plo # am--include-marker +include ./$(DEPDIR)/jidctint.Plo # am--include-marker +include ./$(DEPDIR)/jmemmgr.Plo # am--include-marker +include ./$(DEPDIR)/jpegtran.Po # am--include-marker +include ./$(DEPDIR)/jquant1.Plo # am--include-marker +include ./$(DEPDIR)/jquant2.Plo # am--include-marker +include ./$(DEPDIR)/jutils.Plo # am--include-marker +include ./$(DEPDIR)/rdbmp.Po # am--include-marker +include ./$(DEPDIR)/rdcolmap.Po # am--include-marker +include ./$(DEPDIR)/rdgif.Po # am--include-marker +include ./$(DEPDIR)/rdjpgcom.Po # am--include-marker +include ./$(DEPDIR)/rdppm.Po # am--include-marker +include ./$(DEPDIR)/rdrle.Po # am--include-marker +include ./$(DEPDIR)/rdswitch.Po # am--include-marker +include ./$(DEPDIR)/rdtarga.Po # am--include-marker +include ./$(DEPDIR)/transupp.Po # am--include-marker +include ./$(DEPDIR)/wrbmp.Po # am--include-marker +include ./$(DEPDIR)/wrgif.Po # am--include-marker +include ./$(DEPDIR)/wrjpgcom.Po # am--include-marker +include ./$(DEPDIR)/wrppm.Po # am--include-marker +include ./$(DEPDIR)/wrrle.Po # am--include-marker +include ./$(DEPDIR)/wrtarga.Po # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: + $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# $(AM_V_CC)source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(AM_V_CC_no)$(COMPILE) -c -o $@ $< + +.c.obj: + $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` + $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# $(AM_V_CC)source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(AM_V_CC_no)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: + $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +# $(AM_V_CC)source='$<' object='$@' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(AM_V_CC_no)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool config.lt +install-man1: $(man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(man_MANS)'; \ + test -n "$(man1dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.1[a-z]*$$/p'; \ + fi; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ + done; } + +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man1dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.1[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) +install-nodist_pkgconfigDATA: $(nodist_pkgconfig_DATA) + @$(NORMAL_INSTALL) + @list='$(nodist_pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ + done + +uninstall-nodist_pkgconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(nodist_pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscope: cscope.files + test ! -s cscope.files \ + || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) +clean-cscope: + -rm -f cscope.files +cscope.files: clean-cscope cscopelist +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + -rm -f cscope.out cscope.in.out cscope.po.out cscope.files +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local +check: check-am +all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(MANS) $(DATA) $(HEADERS) \ + jconfig.h +install-binPROGRAMS: install-libLTLIBRARIES + +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ + clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f ./$(DEPDIR)/jmemnobs.Plo + -rm -f ./$(DEPDIR)/cdjpeg.Po + -rm -f ./$(DEPDIR)/cjpeg.Po + -rm -f ./$(DEPDIR)/djpeg.Po + -rm -f ./$(DEPDIR)/jaricom.Plo + -rm -f ./$(DEPDIR)/jcapimin.Plo + -rm -f ./$(DEPDIR)/jcapistd.Plo + -rm -f ./$(DEPDIR)/jcarith.Plo + -rm -f ./$(DEPDIR)/jccoefct.Plo + -rm -f ./$(DEPDIR)/jccolor.Plo + -rm -f ./$(DEPDIR)/jcdctmgr.Plo + -rm -f ./$(DEPDIR)/jchuff.Plo + -rm -f ./$(DEPDIR)/jcinit.Plo + -rm -f ./$(DEPDIR)/jcmainct.Plo + -rm -f ./$(DEPDIR)/jcmarker.Plo + -rm -f ./$(DEPDIR)/jcmaster.Plo + -rm -f ./$(DEPDIR)/jcomapi.Plo + -rm -f ./$(DEPDIR)/jcparam.Plo + -rm -f ./$(DEPDIR)/jcprepct.Plo + -rm -f ./$(DEPDIR)/jcsample.Plo + -rm -f ./$(DEPDIR)/jctrans.Plo + -rm -f ./$(DEPDIR)/jdapimin.Plo + -rm -f ./$(DEPDIR)/jdapistd.Plo + -rm -f ./$(DEPDIR)/jdarith.Plo + -rm -f ./$(DEPDIR)/jdatadst.Plo + -rm -f ./$(DEPDIR)/jdatasrc.Plo + -rm -f ./$(DEPDIR)/jdcoefct.Plo + -rm -f ./$(DEPDIR)/jdcolor.Plo + -rm -f ./$(DEPDIR)/jddctmgr.Plo + -rm -f ./$(DEPDIR)/jdhuff.Plo + -rm -f ./$(DEPDIR)/jdinput.Plo + -rm -f ./$(DEPDIR)/jdmainct.Plo + -rm -f ./$(DEPDIR)/jdmarker.Plo + -rm -f ./$(DEPDIR)/jdmaster.Plo + -rm -f ./$(DEPDIR)/jdmerge.Plo + -rm -f ./$(DEPDIR)/jdpostct.Plo + -rm -f ./$(DEPDIR)/jdsample.Plo + -rm -f ./$(DEPDIR)/jdtrans.Plo + -rm -f ./$(DEPDIR)/jerror.Plo + -rm -f ./$(DEPDIR)/jfdctflt.Plo + -rm -f ./$(DEPDIR)/jfdctfst.Plo + -rm -f ./$(DEPDIR)/jfdctint.Plo + -rm -f ./$(DEPDIR)/jidctflt.Plo + -rm -f ./$(DEPDIR)/jidctfst.Plo + -rm -f ./$(DEPDIR)/jidctint.Plo + -rm -f ./$(DEPDIR)/jmemmgr.Plo + -rm -f ./$(DEPDIR)/jpegtran.Po + -rm -f ./$(DEPDIR)/jquant1.Plo + -rm -f ./$(DEPDIR)/jquant2.Plo + -rm -f ./$(DEPDIR)/jutils.Plo + -rm -f ./$(DEPDIR)/rdbmp.Po + -rm -f ./$(DEPDIR)/rdcolmap.Po + -rm -f ./$(DEPDIR)/rdgif.Po + -rm -f ./$(DEPDIR)/rdjpgcom.Po + -rm -f ./$(DEPDIR)/rdppm.Po + -rm -f ./$(DEPDIR)/rdrle.Po + -rm -f ./$(DEPDIR)/rdswitch.Po + -rm -f ./$(DEPDIR)/rdtarga.Po + -rm -f ./$(DEPDIR)/transupp.Po + -rm -f ./$(DEPDIR)/wrbmp.Po + -rm -f ./$(DEPDIR)/wrgif.Po + -rm -f ./$(DEPDIR)/wrjpgcom.Po + -rm -f ./$(DEPDIR)/wrppm.Po + -rm -f ./$(DEPDIR)/wrrle.Po + -rm -f ./$(DEPDIR)/wrtarga.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-data-local install-includeHEADERS install-man \ + install-nodist_pkgconfigDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: install-man1 + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f ./$(DEPDIR)/jmemnobs.Plo + -rm -f ./$(DEPDIR)/cdjpeg.Po + -rm -f ./$(DEPDIR)/cjpeg.Po + -rm -f ./$(DEPDIR)/djpeg.Po + -rm -f ./$(DEPDIR)/jaricom.Plo + -rm -f ./$(DEPDIR)/jcapimin.Plo + -rm -f ./$(DEPDIR)/jcapistd.Plo + -rm -f ./$(DEPDIR)/jcarith.Plo + -rm -f ./$(DEPDIR)/jccoefct.Plo + -rm -f ./$(DEPDIR)/jccolor.Plo + -rm -f ./$(DEPDIR)/jcdctmgr.Plo + -rm -f ./$(DEPDIR)/jchuff.Plo + -rm -f ./$(DEPDIR)/jcinit.Plo + -rm -f ./$(DEPDIR)/jcmainct.Plo + -rm -f ./$(DEPDIR)/jcmarker.Plo + -rm -f ./$(DEPDIR)/jcmaster.Plo + -rm -f ./$(DEPDIR)/jcomapi.Plo + -rm -f ./$(DEPDIR)/jcparam.Plo + -rm -f ./$(DEPDIR)/jcprepct.Plo + -rm -f ./$(DEPDIR)/jcsample.Plo + -rm -f ./$(DEPDIR)/jctrans.Plo + -rm -f ./$(DEPDIR)/jdapimin.Plo + -rm -f ./$(DEPDIR)/jdapistd.Plo + -rm -f ./$(DEPDIR)/jdarith.Plo + -rm -f ./$(DEPDIR)/jdatadst.Plo + -rm -f ./$(DEPDIR)/jdatasrc.Plo + -rm -f ./$(DEPDIR)/jdcoefct.Plo + -rm -f ./$(DEPDIR)/jdcolor.Plo + -rm -f ./$(DEPDIR)/jddctmgr.Plo + -rm -f ./$(DEPDIR)/jdhuff.Plo + -rm -f ./$(DEPDIR)/jdinput.Plo + -rm -f ./$(DEPDIR)/jdmainct.Plo + -rm -f ./$(DEPDIR)/jdmarker.Plo + -rm -f ./$(DEPDIR)/jdmaster.Plo + -rm -f ./$(DEPDIR)/jdmerge.Plo + -rm -f ./$(DEPDIR)/jdpostct.Plo + -rm -f ./$(DEPDIR)/jdsample.Plo + -rm -f ./$(DEPDIR)/jdtrans.Plo + -rm -f ./$(DEPDIR)/jerror.Plo + -rm -f ./$(DEPDIR)/jfdctflt.Plo + -rm -f ./$(DEPDIR)/jfdctfst.Plo + -rm -f ./$(DEPDIR)/jfdctint.Plo + -rm -f ./$(DEPDIR)/jidctflt.Plo + -rm -f ./$(DEPDIR)/jidctfst.Plo + -rm -f ./$(DEPDIR)/jidctint.Plo + -rm -f ./$(DEPDIR)/jmemmgr.Plo + -rm -f ./$(DEPDIR)/jpegtran.Po + -rm -f ./$(DEPDIR)/jquant1.Plo + -rm -f ./$(DEPDIR)/jquant2.Plo + -rm -f ./$(DEPDIR)/jutils.Plo + -rm -f ./$(DEPDIR)/rdbmp.Po + -rm -f ./$(DEPDIR)/rdcolmap.Po + -rm -f ./$(DEPDIR)/rdgif.Po + -rm -f ./$(DEPDIR)/rdjpgcom.Po + -rm -f ./$(DEPDIR)/rdppm.Po + -rm -f ./$(DEPDIR)/rdrle.Po + -rm -f ./$(DEPDIR)/rdswitch.Po + -rm -f ./$(DEPDIR)/rdtarga.Po + -rm -f ./$(DEPDIR)/transupp.Po + -rm -f ./$(DEPDIR)/wrbmp.Po + -rm -f ./$(DEPDIR)/wrgif.Po + -rm -f ./$(DEPDIR)/wrjpgcom.Po + -rm -f ./$(DEPDIR)/wrppm.Po + -rm -f ./$(DEPDIR)/wrrle.Po + -rm -f ./$(DEPDIR)/wrtarga.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \ + uninstall-libLTLIBRARIES uninstall-local uninstall-man \ + uninstall-nodist_pkgconfigDATA + +uninstall-man: uninstall-man1 + +.MAKE: all check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles am--refresh check \ + check-am check-local clean clean-binPROGRAMS clean-cscope \ + clean-generic clean-libLTLIBRARIES clean-libtool cscope \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-hdr distclean-libtool \ + distclean-tags dvi dvi-am html html-am info info-am install \ + install-am install-binPROGRAMS install-data install-data-am \ + install-data-local install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am \ + install-includeHEADERS install-info install-info-am \ + install-libLTLIBRARIES install-man install-man1 \ + install-nodist_pkgconfigDATA install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-includeHEADERS uninstall-libLTLIBRARIES \ + uninstall-local uninstall-man uninstall-man1 \ + uninstall-nodist_pkgconfigDATA + +.PRECIOUS: Makefile + + +# Install jconfig.h +install-data-local: + $(mkinstalldirs) $(DESTDIR)$(includedir) + $(INSTALL_HEADER) jconfig.h $(DESTDIR)$(includedir)/jconfig.h + +# Uninstall jconfig.h +uninstall-local: + rm -f $(DESTDIR)$(includedir)/jconfig.h + +# Run tests +test: check-local +check-local: + rm -f testout* + ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg + ./djpeg -dct int -gif -outfile testout.gif $(srcdir)/testorig.jpg + ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg + ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm + ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg + ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm + ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg + cmp $(srcdir)/testimg.ppm testout.ppm + cmp $(srcdir)/testimg.gif testout.gif + cmp $(srcdir)/testimg.bmp testout.bmp + cmp $(srcdir)/testimg.jpg testout.jpg + cmp $(srcdir)/testimg.ppm testoutp.ppm + cmp $(srcdir)/testimgp.jpg testoutp.jpg + cmp $(srcdir)/testorig.jpg testoutt.jpg + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/thirdparty/jpeg-9e/Makefile.am b/thirdparty/jpeg-9e/Makefile.am new file mode 100644 index 0000000..2ccb592 --- /dev/null +++ b/thirdparty/jpeg-9e/Makefile.am @@ -0,0 +1,143 @@ +## Process this file with automake to produce Makefile.in +# +# Automake Makefile for the JPEG library +# +# This file is written by Bob Friesenhahn, Guido Vollbeding +# + +# Sources to build library +LIBSOURCES = jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c @MEMORYMGR@.c + +# System dependent sources +SYSDEPSOURCES = jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c + +# Headers which are installed to support the library +INSTINCLUDES = jerror.h jmorecfg.h jpeglib.h + +# Headers which are not installed +OTHERINCLUDES = cderror.h cdjpeg.h jdct.h jinclude.h jmemsys.h jpegint.h \ + jversion.h transupp.h + +# Manual pages (Automake uses 'MANS' for itself) +DISTMANS= cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1 + +# Other documentation files +DOCS= README install.txt usage.txt wizard.txt example.c libjpeg.txt \ + structure.txt coderules.txt filelist.txt cdaltui.txt change.log + +# Makefiles for various systems +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt + +# Configuration files +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms + +# Support scripts for configure +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib + +# Miscellaneous support files +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c + +# Test support files +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg + +# libtool libraries to build +lib_LTLIBRARIES = libjpeg.la + +# Library sources for libjpeg.la +libjpeg_la_SOURCES = $(LIBSOURCES) + +# LDFLAGS for libjpeg.la +libjpeg_la_LDFLAGS = -no-undefined \ + -version-info $(JPEG_LIB_VERSION) + +if HAVE_LD_VERSION_SCRIPT + libjpeg_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libjpeg.map +endif + +# Executables to build +bin_PROGRAMS = cjpeg djpeg jpegtran rdjpgcom wrjpgcom + +# Executable sources & libs +cjpeg_SOURCES = cjpeg.c rdppm.c rdgif.c rdtarga.c rdrle.c rdbmp.c \ + rdswitch.c cdjpeg.c +cjpeg_LDADD = libjpeg.la +djpeg_SOURCES = djpeg.c wrppm.c wrgif.c wrtarga.c wrrle.c wrbmp.c \ + rdcolmap.c cdjpeg.c +djpeg_LDADD = libjpeg.la +jpegtran_SOURCES = jpegtran.c rdswitch.c cdjpeg.c transupp.c +jpegtran_LDADD = libjpeg.la +rdjpgcom_SOURCES = rdjpgcom.c +wrjpgcom_SOURCES = wrjpgcom.c + +# Manual pages to install +man_MANS = $(DISTMANS) + +# Headers to install +include_HEADERS = $(INSTINCLUDES) + +# Other distributed headers +noinst_HEADERS = $(OTHERINCLUDES) + +# Other distributed files +EXTRA_DIST = $(DOCS) $(DISTMANS) $(MKFILES) $(CONFIGFILES) $(SYSDEPSOURCES) \ + $(OTHERFILES) $(TESTFILES) + +# pkg-config file +pkgconfigdir = $(libdir)/pkgconfig +nodist_pkgconfig_DATA = libjpeg.pc + +# Files to be cleaned +CLEANFILES = testout.ppm testout.gif testout.bmp testout.jpg testoutp.ppm \ + testoutp.jpg testoutt.jpg + +# Install jconfig.h +install-data-local: + $(mkinstalldirs) $(DESTDIR)$(includedir) + $(INSTALL_HEADER) jconfig.h $(DESTDIR)$(includedir)/jconfig.h + +# Uninstall jconfig.h +uninstall-local: + rm -f $(DESTDIR)$(includedir)/jconfig.h + +# Run tests +test: check-local +check-local: + rm -f testout* + ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg + ./djpeg -dct int -gif -outfile testout.gif $(srcdir)/testorig.jpg + ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg + ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm + ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg + ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm + ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg + cmp $(srcdir)/testimg.ppm testout.ppm + cmp $(srcdir)/testimg.gif testout.gif + cmp $(srcdir)/testimg.bmp testout.bmp + cmp $(srcdir)/testimg.jpg testout.jpg + cmp $(srcdir)/testimg.ppm testoutp.ppm + cmp $(srcdir)/testimgp.jpg testoutp.jpg + cmp $(srcdir)/testorig.jpg testoutt.jpg diff --git a/thirdparty/jpeg-9e/Makefile.in b/thirdparty/jpeg-9e/Makefile.in new file mode 100644 index 0000000..7cfc261 --- /dev/null +++ b/thirdparty/jpeg-9e/Makefile.in @@ -0,0 +1,1249 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# +# Automake Makefile for the JPEG library +# +# This file is written by Bob Friesenhahn, Guido Vollbeding +# + + + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +@HAVE_LD_VERSION_SCRIPT_TRUE@am__append_1 = -Wl,--version-script=$(srcdir)/libjpeg.map +bin_PROGRAMS = cjpeg$(EXEEXT) djpeg$(EXEEXT) jpegtran$(EXEEXT) \ + rdjpgcom$(EXEEXT) wrjpgcom$(EXEEXT) +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(include_HEADERS) $(noinst_HEADERS) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = jconfig.h +CONFIG_CLEAN_FILES = libjpeg.pc +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" \ + "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(pkgconfigdir)" \ + "$(DESTDIR)$(includedir)" +PROGRAMS = $(bin_PROGRAMS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +LTLIBRARIES = $(lib_LTLIBRARIES) +libjpeg_la_LIBADD = +am__objects_1 = jaricom.lo jcapimin.lo jcapistd.lo jcarith.lo \ + jccoefct.lo jccolor.lo jcdctmgr.lo jchuff.lo jcinit.lo \ + jcmainct.lo jcmarker.lo jcmaster.lo jcomapi.lo jcparam.lo \ + jcprepct.lo jcsample.lo jctrans.lo jdapimin.lo jdapistd.lo \ + jdarith.lo jdatadst.lo jdatasrc.lo jdcoefct.lo jdcolor.lo \ + jddctmgr.lo jdhuff.lo jdinput.lo jdmainct.lo jdmarker.lo \ + jdmaster.lo jdmerge.lo jdpostct.lo jdsample.lo jdtrans.lo \ + jerror.lo jfdctflt.lo jfdctfst.lo jfdctint.lo jidctflt.lo \ + jidctfst.lo jidctint.lo jquant1.lo jquant2.lo jutils.lo \ + jmemmgr.lo @MEMORYMGR@.lo +am_libjpeg_la_OBJECTS = $(am__objects_1) +libjpeg_la_OBJECTS = $(am_libjpeg_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +libjpeg_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libjpeg_la_LDFLAGS) $(LDFLAGS) -o $@ +am_cjpeg_OBJECTS = cjpeg.$(OBJEXT) rdppm.$(OBJEXT) rdgif.$(OBJEXT) \ + rdtarga.$(OBJEXT) rdrle.$(OBJEXT) rdbmp.$(OBJEXT) \ + rdswitch.$(OBJEXT) cdjpeg.$(OBJEXT) +cjpeg_OBJECTS = $(am_cjpeg_OBJECTS) +cjpeg_DEPENDENCIES = libjpeg.la +am_djpeg_OBJECTS = djpeg.$(OBJEXT) wrppm.$(OBJEXT) wrgif.$(OBJEXT) \ + wrtarga.$(OBJEXT) wrrle.$(OBJEXT) wrbmp.$(OBJEXT) \ + rdcolmap.$(OBJEXT) cdjpeg.$(OBJEXT) +djpeg_OBJECTS = $(am_djpeg_OBJECTS) +djpeg_DEPENDENCIES = libjpeg.la +am_jpegtran_OBJECTS = jpegtran.$(OBJEXT) rdswitch.$(OBJEXT) \ + cdjpeg.$(OBJEXT) transupp.$(OBJEXT) +jpegtran_OBJECTS = $(am_jpegtran_OBJECTS) +jpegtran_DEPENDENCIES = libjpeg.la +am_rdjpgcom_OBJECTS = rdjpgcom.$(OBJEXT) +rdjpgcom_OBJECTS = $(am_rdjpgcom_OBJECTS) +rdjpgcom_LDADD = $(LDADD) +am_wrjpgcom_OBJECTS = wrjpgcom.$(OBJEXT) +wrjpgcom_OBJECTS = $(am_wrjpgcom_OBJECTS) +wrjpgcom_LDADD = $(LDADD) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/@MEMORYMGR@.Plo \ + ./$(DEPDIR)/cdjpeg.Po ./$(DEPDIR)/cjpeg.Po \ + ./$(DEPDIR)/djpeg.Po ./$(DEPDIR)/jaricom.Plo \ + ./$(DEPDIR)/jcapimin.Plo ./$(DEPDIR)/jcapistd.Plo \ + ./$(DEPDIR)/jcarith.Plo ./$(DEPDIR)/jccoefct.Plo \ + ./$(DEPDIR)/jccolor.Plo ./$(DEPDIR)/jcdctmgr.Plo \ + ./$(DEPDIR)/jchuff.Plo ./$(DEPDIR)/jcinit.Plo \ + ./$(DEPDIR)/jcmainct.Plo ./$(DEPDIR)/jcmarker.Plo \ + ./$(DEPDIR)/jcmaster.Plo ./$(DEPDIR)/jcomapi.Plo \ + ./$(DEPDIR)/jcparam.Plo ./$(DEPDIR)/jcprepct.Plo \ + ./$(DEPDIR)/jcsample.Plo ./$(DEPDIR)/jctrans.Plo \ + ./$(DEPDIR)/jdapimin.Plo ./$(DEPDIR)/jdapistd.Plo \ + ./$(DEPDIR)/jdarith.Plo ./$(DEPDIR)/jdatadst.Plo \ + ./$(DEPDIR)/jdatasrc.Plo ./$(DEPDIR)/jdcoefct.Plo \ + ./$(DEPDIR)/jdcolor.Plo ./$(DEPDIR)/jddctmgr.Plo \ + ./$(DEPDIR)/jdhuff.Plo ./$(DEPDIR)/jdinput.Plo \ + ./$(DEPDIR)/jdmainct.Plo ./$(DEPDIR)/jdmarker.Plo \ + ./$(DEPDIR)/jdmaster.Plo ./$(DEPDIR)/jdmerge.Plo \ + ./$(DEPDIR)/jdpostct.Plo ./$(DEPDIR)/jdsample.Plo \ + ./$(DEPDIR)/jdtrans.Plo ./$(DEPDIR)/jerror.Plo \ + ./$(DEPDIR)/jfdctflt.Plo ./$(DEPDIR)/jfdctfst.Plo \ + ./$(DEPDIR)/jfdctint.Plo ./$(DEPDIR)/jidctflt.Plo \ + ./$(DEPDIR)/jidctfst.Plo ./$(DEPDIR)/jidctint.Plo \ + ./$(DEPDIR)/jmemmgr.Plo ./$(DEPDIR)/jpegtran.Po \ + ./$(DEPDIR)/jquant1.Plo ./$(DEPDIR)/jquant2.Plo \ + ./$(DEPDIR)/jutils.Plo ./$(DEPDIR)/rdbmp.Po \ + ./$(DEPDIR)/rdcolmap.Po ./$(DEPDIR)/rdgif.Po \ + ./$(DEPDIR)/rdjpgcom.Po ./$(DEPDIR)/rdppm.Po \ + ./$(DEPDIR)/rdrle.Po ./$(DEPDIR)/rdswitch.Po \ + ./$(DEPDIR)/rdtarga.Po ./$(DEPDIR)/transupp.Po \ + ./$(DEPDIR)/wrbmp.Po ./$(DEPDIR)/wrgif.Po \ + ./$(DEPDIR)/wrjpgcom.Po ./$(DEPDIR)/wrppm.Po \ + ./$(DEPDIR)/wrrle.Po ./$(DEPDIR)/wrtarga.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libjpeg_la_SOURCES) $(cjpeg_SOURCES) $(djpeg_SOURCES) \ + $(jpegtran_SOURCES) $(rdjpgcom_SOURCES) $(wrjpgcom_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man_MANS) +DATA = $(nodist_pkgconfig_DATA) +HEADERS = $(include_HEADERS) $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \ + jconfig.cfg +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +AM_RECURSIVE_TARGETS = cscope +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ETAGS = @ETAGS@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +JPEG_LIB_VERSION = @JPEG_LIB_VERSION@ +JPEG_LIB_VERSION_MAJOR = @JPEG_LIB_VERSION_MAJOR@ +JPEG_LIB_VERSION_MINOR = @JPEG_LIB_VERSION_MINOR@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MEMORYMGR = @MEMORYMGR@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +# Sources to build library +LIBSOURCES = jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c @MEMORYMGR@.c + + +# System dependent sources +SYSDEPSOURCES = jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c + +# Headers which are installed to support the library +INSTINCLUDES = jerror.h jmorecfg.h jpeglib.h + +# Headers which are not installed +OTHERINCLUDES = cderror.h cdjpeg.h jdct.h jinclude.h jmemsys.h jpegint.h \ + jversion.h transupp.h + + +# Manual pages (Automake uses 'MANS' for itself) +DISTMANS = cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1 + +# Other documentation files +DOCS = README install.txt usage.txt wizard.txt example.c libjpeg.txt \ + structure.txt coderules.txt filelist.txt cdaltui.txt change.log + + +# Makefiles for various systems +MKFILES = configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt + + +# Configuration files +CONFIGFILES = jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms + + +# Support scripts for configure +CONFIGUREFILES = config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib + + +# Miscellaneous support files +OTHERFILES = jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c + + +# Test support files +TESTFILES = testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg + + +# libtool libraries to build +lib_LTLIBRARIES = libjpeg.la + +# Library sources for libjpeg.la +libjpeg_la_SOURCES = $(LIBSOURCES) + +# LDFLAGS for libjpeg.la +libjpeg_la_LDFLAGS = -no-undefined -version-info $(JPEG_LIB_VERSION) \ + $(am__append_1) + +# Executable sources & libs +cjpeg_SOURCES = cjpeg.c rdppm.c rdgif.c rdtarga.c rdrle.c rdbmp.c \ + rdswitch.c cdjpeg.c + +cjpeg_LDADD = libjpeg.la +djpeg_SOURCES = djpeg.c wrppm.c wrgif.c wrtarga.c wrrle.c wrbmp.c \ + rdcolmap.c cdjpeg.c + +djpeg_LDADD = libjpeg.la +jpegtran_SOURCES = jpegtran.c rdswitch.c cdjpeg.c transupp.c +jpegtran_LDADD = libjpeg.la +rdjpgcom_SOURCES = rdjpgcom.c +wrjpgcom_SOURCES = wrjpgcom.c + +# Manual pages to install +man_MANS = $(DISTMANS) + +# Headers to install +include_HEADERS = $(INSTINCLUDES) + +# Other distributed headers +noinst_HEADERS = $(OTHERINCLUDES) + +# Other distributed files +EXTRA_DIST = $(DOCS) $(DISTMANS) $(MKFILES) $(CONFIGFILES) $(SYSDEPSOURCES) \ + $(OTHERFILES) $(TESTFILES) + + +# pkg-config file +pkgconfigdir = $(libdir)/pkgconfig +nodist_pkgconfig_DATA = libjpeg.pc + +# Files to be cleaned +CLEANFILES = testout.ppm testout.gif testout.bmp testout.jpg testoutp.ppm \ + testoutp.jpg testoutt.jpg + +all: jconfig.h + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +am--refresh: Makefile + @: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +jconfig.h: stamp-h1 + @test -f $@ || rm -f stamp-h1 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 + +stamp-h1: $(srcdir)/jconfig.cfg $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status jconfig.h +$(srcdir)/jconfig.cfg: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f jconfig.h stamp-h1 +libjpeg.pc: $(top_builddir)/config.status $(srcdir)/libjpeg.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libjpeg.la: $(libjpeg_la_OBJECTS) $(libjpeg_la_DEPENDENCIES) $(EXTRA_libjpeg_la_DEPENDENCIES) + $(AM_V_CCLD)$(libjpeg_la_LINK) -rpath $(libdir) $(libjpeg_la_OBJECTS) $(libjpeg_la_LIBADD) $(LIBS) + +cjpeg$(EXEEXT): $(cjpeg_OBJECTS) $(cjpeg_DEPENDENCIES) $(EXTRA_cjpeg_DEPENDENCIES) + @rm -f cjpeg$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(cjpeg_OBJECTS) $(cjpeg_LDADD) $(LIBS) + +djpeg$(EXEEXT): $(djpeg_OBJECTS) $(djpeg_DEPENDENCIES) $(EXTRA_djpeg_DEPENDENCIES) + @rm -f djpeg$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(djpeg_OBJECTS) $(djpeg_LDADD) $(LIBS) + +jpegtran$(EXEEXT): $(jpegtran_OBJECTS) $(jpegtran_DEPENDENCIES) $(EXTRA_jpegtran_DEPENDENCIES) + @rm -f jpegtran$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(jpegtran_OBJECTS) $(jpegtran_LDADD) $(LIBS) + +rdjpgcom$(EXEEXT): $(rdjpgcom_OBJECTS) $(rdjpgcom_DEPENDENCIES) $(EXTRA_rdjpgcom_DEPENDENCIES) + @rm -f rdjpgcom$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(rdjpgcom_OBJECTS) $(rdjpgcom_LDADD) $(LIBS) + +wrjpgcom$(EXEEXT): $(wrjpgcom_OBJECTS) $(wrjpgcom_DEPENDENCIES) $(EXTRA_wrjpgcom_DEPENDENCIES) + @rm -f wrjpgcom$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(wrjpgcom_OBJECTS) $(wrjpgcom_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/@MEMORYMGR@.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdjpeg.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cjpeg.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/djpeg.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jaricom.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcapimin.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcapistd.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcarith.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jccoefct.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jccolor.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcdctmgr.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jchuff.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcinit.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcmainct.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcmarker.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcmaster.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcomapi.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcparam.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcprepct.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jcsample.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jctrans.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdapimin.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdapistd.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdarith.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdatadst.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdatasrc.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdcoefct.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdcolor.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jddctmgr.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdhuff.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdinput.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdmainct.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdmarker.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdmaster.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdmerge.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdpostct.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdsample.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jdtrans.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jerror.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jfdctflt.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jfdctfst.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jfdctint.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jidctflt.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jidctfst.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jidctint.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jmemmgr.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jpegtran.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jquant1.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jquant2.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jutils.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rdbmp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rdcolmap.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rdgif.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rdjpgcom.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rdppm.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rdrle.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rdswitch.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rdtarga.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transupp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wrbmp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wrgif.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wrjpgcom.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wrppm.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wrrle.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wrtarga.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool config.lt +install-man1: $(man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(man_MANS)'; \ + test -n "$(man1dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.1[a-z]*$$/p'; \ + fi; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ + done; } + +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man1dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.1[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) +install-nodist_pkgconfigDATA: $(nodist_pkgconfig_DATA) + @$(NORMAL_INSTALL) + @list='$(nodist_pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ + done + +uninstall-nodist_pkgconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(nodist_pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscope: cscope.files + test ! -s cscope.files \ + || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) +clean-cscope: + -rm -f cscope.files +cscope.files: clean-cscope cscopelist +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + -rm -f cscope.out cscope.in.out cscope.po.out cscope.files +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local +check: check-am +all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(MANS) $(DATA) $(HEADERS) \ + jconfig.h +install-binPROGRAMS: install-libLTLIBRARIES + +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ + clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f ./$(DEPDIR)/@MEMORYMGR@.Plo + -rm -f ./$(DEPDIR)/cdjpeg.Po + -rm -f ./$(DEPDIR)/cjpeg.Po + -rm -f ./$(DEPDIR)/djpeg.Po + -rm -f ./$(DEPDIR)/jaricom.Plo + -rm -f ./$(DEPDIR)/jcapimin.Plo + -rm -f ./$(DEPDIR)/jcapistd.Plo + -rm -f ./$(DEPDIR)/jcarith.Plo + -rm -f ./$(DEPDIR)/jccoefct.Plo + -rm -f ./$(DEPDIR)/jccolor.Plo + -rm -f ./$(DEPDIR)/jcdctmgr.Plo + -rm -f ./$(DEPDIR)/jchuff.Plo + -rm -f ./$(DEPDIR)/jcinit.Plo + -rm -f ./$(DEPDIR)/jcmainct.Plo + -rm -f ./$(DEPDIR)/jcmarker.Plo + -rm -f ./$(DEPDIR)/jcmaster.Plo + -rm -f ./$(DEPDIR)/jcomapi.Plo + -rm -f ./$(DEPDIR)/jcparam.Plo + -rm -f ./$(DEPDIR)/jcprepct.Plo + -rm -f ./$(DEPDIR)/jcsample.Plo + -rm -f ./$(DEPDIR)/jctrans.Plo + -rm -f ./$(DEPDIR)/jdapimin.Plo + -rm -f ./$(DEPDIR)/jdapistd.Plo + -rm -f ./$(DEPDIR)/jdarith.Plo + -rm -f ./$(DEPDIR)/jdatadst.Plo + -rm -f ./$(DEPDIR)/jdatasrc.Plo + -rm -f ./$(DEPDIR)/jdcoefct.Plo + -rm -f ./$(DEPDIR)/jdcolor.Plo + -rm -f ./$(DEPDIR)/jddctmgr.Plo + -rm -f ./$(DEPDIR)/jdhuff.Plo + -rm -f ./$(DEPDIR)/jdinput.Plo + -rm -f ./$(DEPDIR)/jdmainct.Plo + -rm -f ./$(DEPDIR)/jdmarker.Plo + -rm -f ./$(DEPDIR)/jdmaster.Plo + -rm -f ./$(DEPDIR)/jdmerge.Plo + -rm -f ./$(DEPDIR)/jdpostct.Plo + -rm -f ./$(DEPDIR)/jdsample.Plo + -rm -f ./$(DEPDIR)/jdtrans.Plo + -rm -f ./$(DEPDIR)/jerror.Plo + -rm -f ./$(DEPDIR)/jfdctflt.Plo + -rm -f ./$(DEPDIR)/jfdctfst.Plo + -rm -f ./$(DEPDIR)/jfdctint.Plo + -rm -f ./$(DEPDIR)/jidctflt.Plo + -rm -f ./$(DEPDIR)/jidctfst.Plo + -rm -f ./$(DEPDIR)/jidctint.Plo + -rm -f ./$(DEPDIR)/jmemmgr.Plo + -rm -f ./$(DEPDIR)/jpegtran.Po + -rm -f ./$(DEPDIR)/jquant1.Plo + -rm -f ./$(DEPDIR)/jquant2.Plo + -rm -f ./$(DEPDIR)/jutils.Plo + -rm -f ./$(DEPDIR)/rdbmp.Po + -rm -f ./$(DEPDIR)/rdcolmap.Po + -rm -f ./$(DEPDIR)/rdgif.Po + -rm -f ./$(DEPDIR)/rdjpgcom.Po + -rm -f ./$(DEPDIR)/rdppm.Po + -rm -f ./$(DEPDIR)/rdrle.Po + -rm -f ./$(DEPDIR)/rdswitch.Po + -rm -f ./$(DEPDIR)/rdtarga.Po + -rm -f ./$(DEPDIR)/transupp.Po + -rm -f ./$(DEPDIR)/wrbmp.Po + -rm -f ./$(DEPDIR)/wrgif.Po + -rm -f ./$(DEPDIR)/wrjpgcom.Po + -rm -f ./$(DEPDIR)/wrppm.Po + -rm -f ./$(DEPDIR)/wrrle.Po + -rm -f ./$(DEPDIR)/wrtarga.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-data-local install-includeHEADERS install-man \ + install-nodist_pkgconfigDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: install-man1 + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f ./$(DEPDIR)/@MEMORYMGR@.Plo + -rm -f ./$(DEPDIR)/cdjpeg.Po + -rm -f ./$(DEPDIR)/cjpeg.Po + -rm -f ./$(DEPDIR)/djpeg.Po + -rm -f ./$(DEPDIR)/jaricom.Plo + -rm -f ./$(DEPDIR)/jcapimin.Plo + -rm -f ./$(DEPDIR)/jcapistd.Plo + -rm -f ./$(DEPDIR)/jcarith.Plo + -rm -f ./$(DEPDIR)/jccoefct.Plo + -rm -f ./$(DEPDIR)/jccolor.Plo + -rm -f ./$(DEPDIR)/jcdctmgr.Plo + -rm -f ./$(DEPDIR)/jchuff.Plo + -rm -f ./$(DEPDIR)/jcinit.Plo + -rm -f ./$(DEPDIR)/jcmainct.Plo + -rm -f ./$(DEPDIR)/jcmarker.Plo + -rm -f ./$(DEPDIR)/jcmaster.Plo + -rm -f ./$(DEPDIR)/jcomapi.Plo + -rm -f ./$(DEPDIR)/jcparam.Plo + -rm -f ./$(DEPDIR)/jcprepct.Plo + -rm -f ./$(DEPDIR)/jcsample.Plo + -rm -f ./$(DEPDIR)/jctrans.Plo + -rm -f ./$(DEPDIR)/jdapimin.Plo + -rm -f ./$(DEPDIR)/jdapistd.Plo + -rm -f ./$(DEPDIR)/jdarith.Plo + -rm -f ./$(DEPDIR)/jdatadst.Plo + -rm -f ./$(DEPDIR)/jdatasrc.Plo + -rm -f ./$(DEPDIR)/jdcoefct.Plo + -rm -f ./$(DEPDIR)/jdcolor.Plo + -rm -f ./$(DEPDIR)/jddctmgr.Plo + -rm -f ./$(DEPDIR)/jdhuff.Plo + -rm -f ./$(DEPDIR)/jdinput.Plo + -rm -f ./$(DEPDIR)/jdmainct.Plo + -rm -f ./$(DEPDIR)/jdmarker.Plo + -rm -f ./$(DEPDIR)/jdmaster.Plo + -rm -f ./$(DEPDIR)/jdmerge.Plo + -rm -f ./$(DEPDIR)/jdpostct.Plo + -rm -f ./$(DEPDIR)/jdsample.Plo + -rm -f ./$(DEPDIR)/jdtrans.Plo + -rm -f ./$(DEPDIR)/jerror.Plo + -rm -f ./$(DEPDIR)/jfdctflt.Plo + -rm -f ./$(DEPDIR)/jfdctfst.Plo + -rm -f ./$(DEPDIR)/jfdctint.Plo + -rm -f ./$(DEPDIR)/jidctflt.Plo + -rm -f ./$(DEPDIR)/jidctfst.Plo + -rm -f ./$(DEPDIR)/jidctint.Plo + -rm -f ./$(DEPDIR)/jmemmgr.Plo + -rm -f ./$(DEPDIR)/jpegtran.Po + -rm -f ./$(DEPDIR)/jquant1.Plo + -rm -f ./$(DEPDIR)/jquant2.Plo + -rm -f ./$(DEPDIR)/jutils.Plo + -rm -f ./$(DEPDIR)/rdbmp.Po + -rm -f ./$(DEPDIR)/rdcolmap.Po + -rm -f ./$(DEPDIR)/rdgif.Po + -rm -f ./$(DEPDIR)/rdjpgcom.Po + -rm -f ./$(DEPDIR)/rdppm.Po + -rm -f ./$(DEPDIR)/rdrle.Po + -rm -f ./$(DEPDIR)/rdswitch.Po + -rm -f ./$(DEPDIR)/rdtarga.Po + -rm -f ./$(DEPDIR)/transupp.Po + -rm -f ./$(DEPDIR)/wrbmp.Po + -rm -f ./$(DEPDIR)/wrgif.Po + -rm -f ./$(DEPDIR)/wrjpgcom.Po + -rm -f ./$(DEPDIR)/wrppm.Po + -rm -f ./$(DEPDIR)/wrrle.Po + -rm -f ./$(DEPDIR)/wrtarga.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \ + uninstall-libLTLIBRARIES uninstall-local uninstall-man \ + uninstall-nodist_pkgconfigDATA + +uninstall-man: uninstall-man1 + +.MAKE: all check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles am--refresh check \ + check-am check-local clean clean-binPROGRAMS clean-cscope \ + clean-generic clean-libLTLIBRARIES clean-libtool cscope \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-hdr distclean-libtool \ + distclean-tags dvi dvi-am html html-am info info-am install \ + install-am install-binPROGRAMS install-data install-data-am \ + install-data-local install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am \ + install-includeHEADERS install-info install-info-am \ + install-libLTLIBRARIES install-man install-man1 \ + install-nodist_pkgconfigDATA install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-includeHEADERS uninstall-libLTLIBRARIES \ + uninstall-local uninstall-man uninstall-man1 \ + uninstall-nodist_pkgconfigDATA + +.PRECIOUS: Makefile + + +# Install jconfig.h +install-data-local: + $(mkinstalldirs) $(DESTDIR)$(includedir) + $(INSTALL_HEADER) jconfig.h $(DESTDIR)$(includedir)/jconfig.h + +# Uninstall jconfig.h +uninstall-local: + rm -f $(DESTDIR)$(includedir)/jconfig.h + +# Run tests +test: check-local +check-local: + rm -f testout* + ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg + ./djpeg -dct int -gif -outfile testout.gif $(srcdir)/testorig.jpg + ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg + ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm + ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg + ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm + ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg + cmp $(srcdir)/testimg.ppm testout.ppm + cmp $(srcdir)/testimg.gif testout.gif + cmp $(srcdir)/testimg.bmp testout.bmp + cmp $(srcdir)/testimg.jpg testout.jpg + cmp $(srcdir)/testimg.ppm testoutp.ppm + cmp $(srcdir)/testimgp.jpg testoutp.jpg + cmp $(srcdir)/testorig.jpg testoutt.jpg + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/thirdparty/jpeg-9e/README b/thirdparty/jpeg-9e/README new file mode 100644 index 0000000..d288f41 --- /dev/null +++ b/thirdparty/jpeg-9e/README @@ -0,0 +1,374 @@ +The Independent JPEG Group's JPEG software +========================================== + +README for release 9e of 16-Jan-2022 +==================================== + +This distribution contains the ninth public release of the Independent JPEG +Group's free JPEG software. You are welcome to redistribute this software and +to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. + +This software is the work of Tom Lane, Guido Vollbeding, Philip Gladstone, +Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson, +John Korejwa, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, +Ge' Weijers, and other members of the Independent JPEG Group. + +IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee +(previously known as JPEG, together with ITU-T SG16). + + +DOCUMENTATION ROADMAP +===================== + +This file contains the following sections: + +OVERVIEW General description of JPEG and the IJG software. +LEGAL ISSUES Copyright, lack of warranty, terms of distribution. +REFERENCES Where to learn more about JPEG. +ARCHIVE LOCATIONS Where to find newer versions of this software. +ACKNOWLEDGMENTS Special thanks. +FILE FORMAT WARS Software *not* to get. +TO DO Plans for future IJG releases. + +Other documentation files in the distribution are: + +User documentation: + install.txt How to configure and install the IJG software. + usage.txt Usage instructions for cjpeg, djpeg, jpegtran, + rdjpgcom, and wrjpgcom. + *.1 Unix-style man pages for programs (same info as usage.txt). + wizard.txt Advanced usage instructions for JPEG wizards only. + cdaltui.txt Description of alternate user interface for cjpeg/djpeg. + change.log Version-to-version change highlights. +Programmer and internal documentation: + libjpeg.txt How to use the JPEG library in your own programs. + example.c Sample code for calling the JPEG library. + structure.txt Overview of the JPEG library's internal structure. + filelist.txt Road map of IJG files. + coderules.txt Coding style rules --- please read if you contribute code. + +Please read at least the files install.txt and usage.txt. Some information +can also be found in the JPEG FAQ (Frequently Asked Questions) article. See +ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. + +If you want to understand how the JPEG code works, we suggest reading one or +more of the REFERENCES, then looking at the documentation files (in roughly +the order listed) before diving into the code. + + +OVERVIEW +======== + +This package contains C software to implement JPEG image encoding, decoding, +and transcoding. JPEG (pronounced "jay-peg") is a standardized compression +method for full-color and grayscale images. + +This software implements JPEG baseline, extended-sequential, and progressive +compression processes. Provision is made for supporting all variants of these +processes, although some uncommon parameter settings aren't implemented yet. +We have made no provision for supporting the hierarchical or lossless +processes defined in the standard. + +We provide a set of library routines for reading and writing JPEG image files, +plus two sample applications "cjpeg" and "djpeg", which use the library to +perform conversion between JPEG and some other popular image file formats. +The library is intended to be reused in other applications. + +In order to support file conversion and viewing software, we have included +considerable functionality beyond the bare JPEG coding/decoding capability; +for example, the color quantization modules are not strictly part of JPEG +decoding, but they are essential for output to colormapped file formats or +colormapped displays. These extra functions can be compiled out of the +library if not required for a particular application. + +We have also included "jpegtran", a utility for lossless transcoding between +different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple +applications for inserting and extracting textual comments in JFIF files. + +The emphasis in designing this software has been on achieving portability and +flexibility, while also making it fast enough to be useful. In particular, +the software is not intended to be read as a tutorial on JPEG. (See the +REFERENCES section for introductory material.) Rather, it is intended to +be reliable, portable, industrial-strength code. We do not claim to have +achieved that goal in every aspect of the software, but we strive for it. + +We welcome the use of this software as a component of commercial products. +No royalty is required, but we do ask for an acknowledgement in product +documentation, as described under LEGAL ISSUES. + + +LEGAL ISSUES +============ + +In plain English: + +1. We don't promise that this software works. (But if you find any bugs, + please let us know!) +2. You can use this software for whatever you want. You don't have to pay us. +3. You may not pretend that you wrote this software. If you use it in a + program, you must acknowledge somewhere in your documentation that + you've used the IJG code. + +In legalese: + +The authors make NO WARRANTY or representation, either express or implied, +with respect to this software, its quality, accuracy, merchantability, or +fitness for a particular purpose. This software is provided "AS IS", and you, +its user, assume the entire risk as to its quality and accuracy. + +This software is copyright (C) 1991-2022, Thomas G. Lane, Guido Vollbeding. +All Rights Reserved except as specified below. + +Permission is hereby granted to use, copy, modify, and distribute this +software (or portions thereof) for any purpose, without fee, subject to these +conditions: +(1) If any part of the source code for this software is distributed, then this +README file must be included, with this copyright and no-warranty notice +unaltered; and any additions, deletions, or changes to the original files +must be clearly indicated in accompanying documentation. +(2) If only executable code is distributed, then the accompanying +documentation must state that "this software is based in part on the work of +the Independent JPEG Group". +(3) Permission for use of this software is granted only if the user accepts +full responsibility for any undesirable consequences; the authors accept +NO LIABILITY for damages of any kind. + +These conditions apply to any software derived from or based on the IJG code, +not just to the unmodified library. If you use our work, you ought to +acknowledge us. + +Permission is NOT granted for the use of any IJG author's name or company name +in advertising or publicity relating to this software or products derived from +it. This software may be referred to only as "the Independent JPEG Group's +software". + +We specifically permit and encourage the use of this software as the basis of +commercial products, provided that all warranty or liability claims are +assumed by the product vendor. + + +The Unix configuration script "configure" was produced with GNU Autoconf. +It is copyright by the Free Software Foundation but is freely distributable. +The same holds for its supporting scripts (config.guess, config.sub, +ltmain.sh). Another support script, install-sh, is copyright by X Consortium +but is also freely distributable. + + +REFERENCES +========== + +We recommend reading one or more of these references before trying to +understand the innards of the JPEG software. + +The best short technical introduction to the JPEG compression algorithm is + Wallace, Gregory K. "The JPEG Still Picture Compression Standard", + Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. +(Adjacent articles in that issue discuss MPEG motion picture compression, +applications of JPEG, and related topics.) If you don't have the CACM issue +handy, a PDF file containing a revised version of Wallace's article is +available at https://www.ijg.org/files/Wallace.JPEG.pdf. The file (actually +a preprint for an article that appeared in IEEE Trans. Consumer Electronics) +omits the sample images that appeared in CACM, but it includes corrections +and some added material. Note: the Wallace article is copyright ACM and IEEE, +and it may not be used for commercial purposes. + +A somewhat less technical, more leisurely introduction to JPEG can be found in +"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by +M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides +good explanations and example C code for a multitude of compression methods +including JPEG. It is an excellent source if you are comfortable reading C +code but don't know much about data compression in general. The book's JPEG +sample code is far from industrial-strength, but when you are ready to look +at a full implementation, you've got one here... + +The best currently available description of JPEG is the textbook "JPEG Still +Image Data Compression Standard" by William B. Pennebaker and Joan L. +Mitchell, published by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. +Price US$59.95, 638 pp. The book includes the complete text of the ISO JPEG +standards (DIS 10918-1 and draft DIS 10918-2). +Although this is by far the most detailed and comprehensive exposition of +JPEG publicly available, we point out that it is still missing an explanation +of the most essential properties and algorithms of the underlying DCT +technology. +If you think that you know about DCT-based JPEG after reading this book, +then you are in delusion. The real fundamentals and corresponding potential +of DCT-based JPEG are not publicly known so far, and that is the reason for +all the mistaken developments taking place in the image coding domain. + +The original JPEG standard is divided into two parts, Part 1 being the actual +specification, while Part 2 covers compliance testing methods. Part 1 is +titled "Digital Compression and Coding of Continuous-tone Still Images, +Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS +10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of +Continuous-tone Still Images, Part 2: Compliance testing" and has document +numbers ISO/IEC IS 10918-2, ITU-T T.83. +IJG JPEG 8 introduced an implementation of the JPEG SmartScale extension +which is specified in two documents: A contributed document at ITU and ISO +with title "ITU-T JPEG-Plus Proposal for Extending ITU-T T.81 for Advanced +Image Coding", April 2006, Geneva, Switzerland. The latest version of this +document is Revision 3. And a contributed document ISO/IEC JTC1/SC29/WG1 N +5799 with title "Evolution of JPEG", June/July 2011, Berlin, Germany. +IJG JPEG 9 introduces a reversible color transform for improved lossless +compression which is described in a contributed document ISO/IEC JTC1/SC29/ +WG1 N 6080 with title "JPEG 9 Lossless Coding", June/July 2012, Paris, France. + +The JPEG standard does not specify all details of an interchangeable file +format. For the omitted details we follow the "JFIF" conventions, version 2. +JFIF version 1 has been adopted as Recommendation ITU-T T.871 (05/2011) : +Information technology - Digital compression and coding of continuous-tone +still images: JPEG File Interchange Format (JFIF). It is available as a +free download in PDF file format from https://www.itu.int/rec/T-REC-T.871. +A PDF file of the older JFIF document is available at +https://www.w3.org/Graphics/JPEG/jfif3.pdf. + +The TIFF 6.0 file format specification can be obtained by FTP from +ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme +found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. +IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). +Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 +(Compression tag 7). Copies of this Note can be obtained from +https://www.ijg.org/files/. It is expected that the next revision +of the TIFF spec will replace the 6.0 JPEG design with the Note's design. +Although IJG's own code does not support TIFF/JPEG, the free libtiff library +uses our library to implement TIFF/JPEG per the Note. + + +ARCHIVE LOCATIONS +================= + +The "official" archive site for this software is www.ijg.org. +The most recent released version can always be found there in +directory "files". This particular version will be archived +in Windows-compatible "zip" archive format as +https://www.ijg.org/files/jpegsr9e.zip, and +in Unix-compatible "tar.gz" archive format as +https://www.ijg.org/files/jpegsrc.v9e.tar.gz. + +The JPEG FAQ (Frequently Asked Questions) article is a source of some +general information about JPEG. +It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/ +and other news.answers archive sites, including the official news.answers +archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. +If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu +with body + send usenet/news.answers/jpeg-faq/part1 + send usenet/news.answers/jpeg-faq/part2 + + +ACKNOWLEDGMENTS +=============== + +Thank to Juergen Bruder for providing me with a copy of the common DCT +algorithm article, only to find out that I had come to the same result +in a more direct and comprehensible way with a more generative approach. + +Thank to Istvan Sebestyen and Joan L. Mitchell for inviting me to the +ITU JPEG (Study Group 16) meeting in Geneva, Switzerland. + +Thank to Thomas Wiegand and Gary Sullivan for inviting me to the +Joint Video Team (MPEG & ITU) meeting in Geneva, Switzerland. + +Thank to Thomas Richter and Daniel Lee for inviting me to the +ISO/IEC JTC1/SC29/WG1 (previously known as JPEG, together with ITU-T SG16) +meeting in Berlin, Germany. + +Thank to John Korejwa and Massimo Ballerini for inviting me to +fruitful consultations in Boston, MA and Milan, Italy. + +Thank to Hendrik Elstner, Roland Fassauer, Simone Zuck, Guenther +Maier-Gerber, Walter Stoeber, Fred Schmitz, and Norbert Braunagel +for corresponding business development. + +Thank to Nico Zschach and Dirk Stelling of the technical support team +at the Digital Images company in Halle for providing me with extra +equipment for configuration tests. + +Thank to Richard F. Lyon (then of Foveon Inc.) for fruitful +communication about JPEG configuration in Sigma Photo Pro software. + +Thank to Andrew Finkenstadt for hosting the ijg.org site. + +Thank to Thomas G. Lane for the original design and development +of this singular software package. + +Thank to Lars Goehler, Andreas Heinecke, Sebastian Fuss, +Yvonne Roebert, Andrej Werner, Ulf-Dietrich Braumann, +and Nina Ssymank for support and public relations. + + +FILE FORMAT WARS +================ + +The ISO/IEC JTC1/SC29/WG1 standards committee (previously known as JPEG, +together with ITU-T SG16) currently promotes different formats containing +the name "JPEG" which is misleading because these formats are incompatible +with original DCT-based JPEG and are based on faulty technologies. +IJG therefore does not and will not support such momentary mistakes +(see REFERENCES). +There exist also distributions under the name "OpenJPEG" promoting such +kind of formats which is misleading because they don't support original +JPEG images. +We have no sympathy for the promotion of inferior formats. Indeed, one of +the original reasons for developing this free software was to help force +convergence on common, interoperable format standards for JPEG files. +Don't use an incompatible file format! +(In any case, our decoder will remain capable of reading existing JPEG +image files indefinitely.) + +The ISO committee pretends to be "responsible for the popular JPEG" in their +public reports which is not true because they don't respond to actual +requirements for the maintenance of the original JPEG specification. +Furthermore, the ISO committee pretends to "ensure interoperability" with +their standards which is not true because their "standards" support only +application-specific and proprietary use cases and contain mathematically +incorrect code. + +There are currently different distributions in circulation containing the +name "libjpeg" which is misleading because they don't have the features and +are incompatible with formats supported by actual IJG libjpeg distributions. +One of those fakes is released by members of the ISO committee and just uses +the name of libjpeg for misdirection of people, similar to the abuse of the +name JPEG as described above, while having nothing in common with actual IJG +libjpeg distributions and containing mathematically incorrect code. +The other one claims to be a "derivative" or "fork" of the original libjpeg, +but violates the license conditions as described under LEGAL ISSUES above +and violates basic C programming properties. +We have no sympathy for the release of misleading, incorrect and illegal +distributions derived from obsolete code bases. +Don't use an obsolete code base! + +According to the UCC (Uniform Commercial Code) law, IJG has the lawful and +legal right to foreclose on certain standardization bodies and other +institutions or corporations that knowingly perform substantial and +systematic deceptive acts and practices, fraud, theft, and damaging of the +value of the people of this planet without their knowing, willing and +intentional consent. +The titles, ownership, and rights of these institutions and all their assets +are now duly secured and held in trust for the free people of this planet. +People of the planet, on every country, may have a financial interest in +the assets of these former principals, agents, and beneficiaries of the +foreclosed institutions and corporations. +IJG asserts what is: that each man, woman, and child has unalienable value +and rights granted and deposited in them by the Creator and not any one of +the people is subordinate to any artificial principality, corporate fiction +or the special interest of another without their appropriate knowing, +willing and intentional consent made by contract or accommodation agreement. +IJG expresses that which already was. +The people have already determined and demanded that public administration +entities, national governments, and their supporting judicial systems must +be fully transparent, accountable, and liable. +IJG has secured the value for all concerned free people of the planet. + +A partial list of foreclosed institutions and corporations ("Hall of Shame") +is currently prepared and will be published later. + + +TO DO +===== + +Version 9 is the second release of a new generation JPEG standard +to overcome the limitations of the original JPEG specification, +and is the first true source reference JPEG codec. +More features are being prepared for coming releases... + +Please send bug reports, offers of help, etc. to jpeg-info@jpegclub.org. diff --git a/thirdparty/jpeg-9e/aclocal.m4 b/thirdparty/jpeg-9e/aclocal.m4 new file mode 100644 index 0000000..d9cdb41 --- /dev/null +++ b/thirdparty/jpeg-9e/aclocal.m4 @@ -0,0 +1,10275 @@ +# generated automatically by aclocal 1.16.5 -*- Autoconf -*- + +# Copyright (C) 1996-2021 Free Software Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],, +[m4_warning([this file was generated for autoconf 2.71. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically 'autoreconf'.])]) + +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +# +# Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +m4_define([_LT_COPYING], [dnl +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +]) + +# serial 58 LT_INIT + + +# LT_PREREQ(VERSION) +# ------------------ +# Complain and exit if this libtool version is less that VERSION. +m4_defun([LT_PREREQ], +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, + [m4_default([$3], + [m4_fatal([Libtool version $1 or higher is required], + 63)])], + [$2])]) + + +# _LT_CHECK_BUILDDIR +# ------------------ +# Complain if the absolute build directory name contains unusual characters +m4_defun([_LT_CHECK_BUILDDIR], +[case `pwd` in + *\ * | *\ *) + AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; +esac +]) + + +# LT_INIT([OPTIONS]) +# ------------------ +AC_DEFUN([LT_INIT], +[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK +AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +AC_BEFORE([$0], [LT_LANG])dnl +AC_BEFORE([$0], [LT_OUTPUT])dnl +AC_BEFORE([$0], [LTDL_INIT])dnl +m4_require([_LT_CHECK_BUILDDIR])dnl + +dnl Autoconf doesn't catch unexpanded LT_ macros by default: +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 +dnl unless we require an AC_DEFUNed macro: +AC_REQUIRE([LTOPTIONS_VERSION])dnl +AC_REQUIRE([LTSUGAR_VERSION])dnl +AC_REQUIRE([LTVERSION_VERSION])dnl +AC_REQUIRE([LTOBSOLETE_VERSION])dnl +m4_require([_LT_PROG_LTMAIN])dnl + +_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) + +dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS=$ltmain + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +_LT_SETUP + +# Only expand once: +m4_define([LT_INIT]) +])# LT_INIT + +# Old names: +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PROG_LIBTOOL], []) +dnl AC_DEFUN([AM_PROG_LIBTOOL], []) + + +# _LT_PREPARE_CC_BASENAME +# ----------------------- +m4_defun([_LT_PREPARE_CC_BASENAME], [ +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in @S|@*""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} +])# _LT_PREPARE_CC_BASENAME + + +# _LT_CC_BASENAME(CC) +# ------------------- +# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME, +# but that macro is also expanded into generated libtool script, which +# arranges for $SED and $ECHO to be set by different means. +m4_defun([_LT_CC_BASENAME], +[m4_require([_LT_PREPARE_CC_BASENAME])dnl +AC_REQUIRE([_LT_DECL_SED])dnl +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl +func_cc_basename $1 +cc_basename=$func_cc_basename_result +]) + + +# _LT_FILEUTILS_DEFAULTS +# ---------------------- +# It is okay to use these file commands and assume they have been set +# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'. +m4_defun([_LT_FILEUTILS_DEFAULTS], +[: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +])# _LT_FILEUTILS_DEFAULTS + + +# _LT_SETUP +# --------- +m4_defun([_LT_SETUP], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl + +_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl +dnl +_LT_DECL([], [host_alias], [0], [The host system])dnl +_LT_DECL([], [host], [0])dnl +_LT_DECL([], [host_os], [0])dnl +dnl +_LT_DECL([], [build_alias], [0], [The build system])dnl +_LT_DECL([], [build], [0])dnl +_LT_DECL([], [build_os], [0])dnl +dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +test -z "$LN_S" && LN_S="ln -s" +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl +dnl +AC_REQUIRE([LT_CMD_MAX_LEN])dnl +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl +dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl +m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl +m4_require([_LT_CMD_OLD_ARCHIVE])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_WITH_SYSROOT])dnl +m4_require([_LT_CMD_TRUNCATE])dnl + +_LT_CONFIG_LIBTOOL_INIT([ +# See if we are running on zsh, and set the options that allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi +]) +if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + +_LT_CHECK_OBJDIR + +m4_require([_LT_TAG_COMPILER])dnl + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld=$lt_cv_prog_gnu_ld + +old_CC=$CC +old_CFLAGS=$CFLAGS + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + _LT_PATH_MAGIC + fi + ;; +esac + +# Use C for the default configuration in the libtool script +LT_SUPPORTED_TAG([CC]) +_LT_LANG_C_CONFIG +_LT_LANG_DEFAULT_CONFIG +_LT_CONFIG_COMMANDS +])# _LT_SETUP + + +# _LT_PREPARE_SED_QUOTE_VARS +# -------------------------- +# Define a few sed substitution that help us do robust quoting. +m4_defun([_LT_PREPARE_SED_QUOTE_VARS], +[# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' +]) + +# _LT_PROG_LTMAIN +# --------------- +# Note that this code is called both from 'configure', and 'config.status' +# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, +# 'config.status' has no value for ac_aux_dir unless we are using Automake, +# so we pass a copy along to make sure it has a sensible value anyway. +m4_defun([_LT_PROG_LTMAIN], +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) +ltmain=$ac_aux_dir/ltmain.sh +])# _LT_PROG_LTMAIN + + + +# So that we can recreate a full libtool script including additional +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS +# in macros and then make a single call at the end using the 'libtool' +# label. + + +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) +# ---------------------------------------- +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL_INIT], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_INIT], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_INIT]) + + +# _LT_CONFIG_LIBTOOL([COMMANDS]) +# ------------------------------ +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) + + +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) +# ----------------------------------------------------- +m4_defun([_LT_CONFIG_SAVE_COMMANDS], +[_LT_CONFIG_LIBTOOL([$1]) +_LT_CONFIG_LIBTOOL_INIT([$2]) +]) + + +# _LT_FORMAT_COMMENT([COMMENT]) +# ----------------------------- +# Add leading comment marks to the start of each line, and a trailing +# full-stop to the whole comment if one is not present already. +m4_define([_LT_FORMAT_COMMENT], +[m4_ifval([$1], [ +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], + [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) +)]) + + + + + +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) +# ------------------------------------------------------------------- +# CONFIGNAME is the name given to the value in the libtool script. +# VARNAME is the (base) name used in the configure script. +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on +# VARNAME. Any other value will be used directly. +m4_define([_LT_DECL], +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], + [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], + [m4_ifval([$1], [$1], [$2])]) + lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) + m4_ifval([$4], + [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) + lt_dict_add_subkey([lt_decl_dict], [$2], + [tagged?], [m4_ifval([$5], [yes], [no])])]) +]) + + +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) +# -------------------------------------------------------- +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) + + +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_tag_varnames], +[_lt_decl_filter([tagged?], [yes], $@)]) + + +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) +# --------------------------------------------------------- +m4_define([_lt_decl_filter], +[m4_case([$#], + [0], [m4_fatal([$0: too few arguments: $#])], + [1], [m4_fatal([$0: too few arguments: $#: $1])], + [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], + [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], + [lt_dict_filter([lt_decl_dict], $@)])[]dnl +]) + + +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) +# -------------------------------------------------- +m4_define([lt_decl_quote_varnames], +[_lt_decl_filter([value], [1], $@)]) + + +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_dquote_varnames], +[_lt_decl_filter([value], [2], $@)]) + + +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_varnames_tagged], +[m4_assert([$# <= 2])dnl +_$0(m4_quote(m4_default([$1], [[, ]])), + m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), + m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) +m4_define([_lt_decl_varnames_tagged], +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) + + +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_all_varnames], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_if([$2], [], + m4_quote(lt_decl_varnames), + m4_quote(m4_shift($@))))[]dnl +]) +m4_define([_lt_decl_all_varnames], +[lt_join($@, lt_decl_varnames_tagged([$1], + lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl +]) + + +# _LT_CONFIG_STATUS_DECLARE([VARNAME]) +# ------------------------------------ +# Quote a variable value, and forward it to 'config.status' so that its +# declaration there will have the same value as in 'configure'. VARNAME +# must have a single quote delimited value for this to work. +m4_define([_LT_CONFIG_STATUS_DECLARE], +[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) + + +# _LT_CONFIG_STATUS_DECLARATIONS +# ------------------------------ +# We delimit libtool config variables with single quotes, so when +# we write them to config.status, we have to be sure to quote all +# embedded single quotes properly. In configure, this macro expands +# each variable declared with _LT_DECL (and _LT_TAGDECL) into: +# +# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), + [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAGS +# ---------------- +# Output comment and list of tags supported by the script +m4_defun([_LT_LIBTOOL_TAGS], +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl +available_tags='_LT_TAGS'dnl +]) + + +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) +# ----------------------------------- +# Extract the dictionary values for VARNAME (optionally with TAG) and +# expand to a commented shell variable setting: +# +# # Some comment about what VAR is for. +# visible_name=$lt_internal_name +m4_define([_LT_LIBTOOL_DECLARE], +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], + [description])))[]dnl +m4_pushdef([_libtool_name], + m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), + [0], [_libtool_name=[$]$1], + [1], [_libtool_name=$lt_[]$1], + [2], [_libtool_name=$lt_[]$1], + [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl +]) + + +# _LT_LIBTOOL_CONFIG_VARS +# ----------------------- +# Produce commented declarations of non-tagged libtool config variables +# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool' +# script. Tagged libtool config variables (even for the LIBTOOL CONFIG +# section) are produced by _LT_LIBTOOL_TAG_VARS. +m4_defun([_LT_LIBTOOL_CONFIG_VARS], +[m4_foreach([_lt_var], + m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAG_VARS(TAG) +# ------------------------- +m4_define([_LT_LIBTOOL_TAG_VARS], +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) + + +# _LT_TAGVAR(VARNAME, [TAGNAME]) +# ------------------------------ +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) + + +# _LT_CONFIG_COMMANDS +# ------------------- +# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of +# variables for single and double quote escaping we saved from calls +# to _LT_DECL, we can put quote escaped variables declarations +# into 'config.status', and then the shell code to quote escape them in +# for loops in 'config.status'. Finally, any additional code accumulated +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. +m4_defun([_LT_CONFIG_COMMANDS], +[AC_PROVIDE_IFELSE([LT_OUTPUT], + dnl If the libtool generation code has been placed in $CONFIG_LT, + dnl instead of duplicating it all over again into config.status, + dnl then we will have config.status run $CONFIG_LT later, so it + dnl needs to know what name is stored there: + [AC_CONFIG_COMMANDS([libtool], + [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], + dnl If the libtool generation code is destined for config.status, + dnl expand the accumulated commands and init code now: + [AC_CONFIG_COMMANDS([libtool], + [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) +])#_LT_CONFIG_COMMANDS + + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], +[ + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +_LT_CONFIG_STATUS_DECLARATIONS +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$[]1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_quote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_dquote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +_LT_OUTPUT_LIBTOOL_INIT +]) + +# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) +# ------------------------------------ +# Generate a child script FILE with all initialization necessary to +# reuse the environment learned by the parent script, and make the +# file executable. If COMMENT is supplied, it is inserted after the +# '#!' sequence but before initialization text begins. After this +# macro, additional text can be appended to FILE to form the body of +# the child script. The macro ends with non-zero status if the +# file could not be fully written (such as if the disk is full). +m4_ifdef([AS_INIT_GENERATED], +[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], +[m4_defun([_LT_GENERATED_FILE_INIT], +[m4_require([AS_PREPARE])]dnl +[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl +[lt_write_fail=0 +cat >$1 <<_ASEOF || lt_write_fail=1 +#! $SHELL +# Generated by $as_me. +$2 +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$1 <<\_ASEOF || lt_write_fail=1 +AS_SHELL_SANITIZE +_AS_PREPARE +exec AS_MESSAGE_FD>&1 +_ASEOF +test 0 = "$lt_write_fail" && chmod +x $1[]dnl +m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT + +# LT_OUTPUT +# --------- +# This macro allows early generation of the libtool script (before +# AC_OUTPUT is called), incase it is used in configure for compilation +# tests. +AC_DEFUN([LT_OUTPUT], +[: ${CONFIG_LT=./config.lt} +AC_MSG_NOTICE([creating $CONFIG_LT]) +_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], +[# Run this file to recreate a libtool stub with the current configuration.]) + +cat >>"$CONFIG_LT" <<\_LTEOF +lt_cl_silent=false +exec AS_MESSAGE_LOG_FD>>config.log +{ + echo + AS_BOX([Running $as_me.]) +} >&AS_MESSAGE_LOG_FD + +lt_cl_help="\ +'$as_me' creates a local libtool stub from the current configuration, +for use in further configure time tests before the real libtool is +generated. + +Usage: $[0] [[OPTIONS]] + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + +Report bugs to ." + +lt_cl_version="\ +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) +configured by $[0], generated by m4_PACKAGE_STRING. + +Copyright (C) 2011 Free Software Foundation, Inc. +This config.lt script is free software; the Free Software Foundation +gives unlimited permision to copy, distribute and modify it." + +while test 0 != $[#] +do + case $[1] in + --version | --v* | -V ) + echo "$lt_cl_version"; exit 0 ;; + --help | --h* | -h ) + echo "$lt_cl_help"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --quiet | --q* | --silent | --s* | -q ) + lt_cl_silent=: ;; + + -*) AC_MSG_ERROR([unrecognized option: $[1] +Try '$[0] --help' for more information.]) ;; + + *) AC_MSG_ERROR([unrecognized argument: $[1] +Try '$[0] --help' for more information.]) ;; + esac + shift +done + +if $lt_cl_silent; then + exec AS_MESSAGE_FD>/dev/null +fi +_LTEOF + +cat >>"$CONFIG_LT" <<_LTEOF +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AC_MSG_NOTICE([creating $ofile]) +_LT_OUTPUT_LIBTOOL_COMMANDS +AS_EXIT(0) +_LTEOF +chmod +x "$CONFIG_LT" + +# configure is writing to config.log, but config.lt does its own redirection, +# appending to config.log, which fails on DOS, as config.log is still kept +# open by configure. Here we exec the FD to /dev/null, effectively closing +# config.log, so it can be properly (re)opened and appended to by config.lt. +lt_cl_success=: +test yes = "$silent" && + lt_config_lt_args="$lt_config_lt_args --quiet" +exec AS_MESSAGE_LOG_FD>/dev/null +$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false +exec AS_MESSAGE_LOG_FD>>config.log +$lt_cl_success || AS_EXIT(1) +])# LT_OUTPUT + + +# _LT_CONFIG(TAG) +# --------------- +# If TAG is the built-in tag, create an initial libtool script with a +# default configuration from the untagged config vars. Otherwise add code +# to config.status for appending the configuration named by TAG from the +# matching tagged config vars. +m4_defun([_LT_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_CONFIG_SAVE_COMMANDS([ + m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl + m4_if(_LT_TAG, [C], [ + # See if we are running on zsh, and set the options that allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST + fi + + cfgfile=${ofile}T + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL +# Generated automatically by $as_me ($PACKAGE) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +_LT_COPYING +_LT_LIBTOOL_TAGS + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} + +# ### BEGIN LIBTOOL CONFIG +_LT_LIBTOOL_CONFIG_VARS +_LT_LIBTOOL_TAG_VARS +# ### END LIBTOOL CONFIG + +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +_LT_PREPARE_MUNGE_PATH_LIST +_LT_PREPARE_CC_BASENAME + +# ### END FUNCTIONS SHARED WITH CONFIGURE + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + _LT_PROG_LTMAIN + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +], +[cat <<_LT_EOF >> "$ofile" + +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded +dnl in a comment (ie after a #). +# ### BEGIN LIBTOOL TAG CONFIG: $1 +_LT_LIBTOOL_TAG_VARS(_LT_TAG) +# ### END LIBTOOL TAG CONFIG: $1 +_LT_EOF +])dnl /m4_if +], +[m4_if([$1], [], [ + PACKAGE='$PACKAGE' + VERSION='$VERSION' + RM='$RM' + ofile='$ofile'], []) +])dnl /_LT_CONFIG_SAVE_COMMANDS +])# _LT_CONFIG + + +# LT_SUPPORTED_TAG(TAG) +# --------------------- +# Trace this macro to discover what tags are supported by the libtool +# --tag option, using: +# autoconf --trace 'LT_SUPPORTED_TAG:$1' +AC_DEFUN([LT_SUPPORTED_TAG], []) + + +# C support is built-in for now +m4_define([_LT_LANG_C_enabled], []) +m4_define([_LT_TAGS], []) + + +# LT_LANG(LANG) +# ------------- +# Enable libtool support for the given language if not already enabled. +AC_DEFUN([LT_LANG], +[AC_BEFORE([$0], [LT_OUTPUT])dnl +m4_case([$1], + [C], [_LT_LANG(C)], + [C++], [_LT_LANG(CXX)], + [Go], [_LT_LANG(GO)], + [Java], [_LT_LANG(GCJ)], + [Fortran 77], [_LT_LANG(F77)], + [Fortran], [_LT_LANG(FC)], + [Windows Resource], [_LT_LANG(RC)], + [m4_ifdef([_LT_LANG_]$1[_CONFIG], + [_LT_LANG($1)], + [m4_fatal([$0: unsupported language: "$1"])])])dnl +])# LT_LANG + + +# _LT_LANG(LANGNAME) +# ------------------ +m4_defun([_LT_LANG], +[m4_ifdef([_LT_LANG_]$1[_enabled], [], + [LT_SUPPORTED_TAG([$1])dnl + m4_append([_LT_TAGS], [$1 ])dnl + m4_define([_LT_LANG_]$1[_enabled], [])dnl + _LT_LANG_$1_CONFIG($1)])dnl +])# _LT_LANG + + +m4_ifndef([AC_PROG_GO], [ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_GO. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +m4_defun([AC_PROG_GO], +[AC_LANG_PUSH(Go)dnl +AC_ARG_VAR([GOC], [Go compiler command])dnl +AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +AC_CHECK_TOOL(GOC, gccgo) +if test -z "$GOC"; then + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) + fi +fi +if test -z "$GOC"; then + AC_CHECK_PROG(GOC, gccgo, gccgo, false) +fi +])#m4_defun +])#m4_ifndef + + +# _LT_LANG_DEFAULT_CONFIG +# ----------------------- +m4_defun([_LT_LANG_DEFAULT_CONFIG], +[AC_PROVIDE_IFELSE([AC_PROG_CXX], + [LT_LANG(CXX)], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) + +AC_PROVIDE_IFELSE([AC_PROG_F77], + [LT_LANG(F77)], + [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) + +AC_PROVIDE_IFELSE([AC_PROG_FC], + [LT_LANG(FC)], + [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) + +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal +dnl pulling things in needlessly. +AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([LT_PROG_GCJ], + [LT_LANG(GCJ)], + [m4_ifdef([AC_PROG_GCJ], + [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([A][M_PROG_GCJ], + [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([LT_PROG_GCJ], + [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) + +AC_PROVIDE_IFELSE([AC_PROG_GO], + [LT_LANG(GO)], + [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) + +AC_PROVIDE_IFELSE([LT_PROG_RC], + [LT_LANG(RC)], + [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) +])# _LT_LANG_DEFAULT_CONFIG + +# Obsolete macros: +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) +AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_CXX], []) +dnl AC_DEFUN([AC_LIBTOOL_F77], []) +dnl AC_DEFUN([AC_LIBTOOL_FC], []) +dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) +dnl AC_DEFUN([AC_LIBTOOL_RC], []) + + +# _LT_TAG_COMPILER +# ---------------- +m4_defun([_LT_TAG_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_TAG_COMPILER + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +m4_defun([_LT_COMPILER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +m4_defun([_LT_LINKER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# ------------------------- +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CHECK_TOOL([LIPO], [lipo], [:]) + AC_CHECK_TOOL([OTOOL], [otool], [:]) + AC_CHECK_TOOL([OTOOL64], [otool64], [:]) + _LT_DECL([], [DSYMUTIL], [1], + [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) + _LT_DECL([], [NMEDIT], [1], + [Tool to change global to local symbols on Mac OS X]) + _LT_DECL([], [LIPO], [1], + [Tool to manipulate fat objects and archives on Mac OS X]) + _LT_DECL([], [OTOOL], [1], + [ldd/readelf like tool for Mach-O binaries on Mac OS X]) + _LT_DECL([], [OTOOL64], [1], + [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "$LT_MULTI_MODULE"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test 0 = "$_lt_result"; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi]) + + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS=$save_LDFLAGS + ]) + + AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], + [lt_cv_ld_force_load=no + cat > conftest.c << _LT_EOF +int forced_loaded() { return 2;} +_LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD + echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD + $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err + _lt_result=$? + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then + lt_cv_ld_force_load=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + ]) + case $host_os in + rhapsody* | darwin1.[[012]]) + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + 10.[[012]][[,.]]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test yes = "$lt_cv_apple_cc_single_mod"; then + _lt_dar_single_mod='$single_module' + fi + if test yes = "$lt_cv_ld_exported_symbols_list"; then + _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' + fi + if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac +]) + + +# _LT_DARWIN_LINKER_FEATURES([TAG]) +# --------------------------------- +# Checks for linker and compiler features on darwin +m4_defun([_LT_DARWIN_LINKER_FEATURES], +[ + m4_require([_LT_REQUIRED_DARWIN_CHECKS]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_automatic, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + if test yes = "$lt_cv_ld_force_load"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], + [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='' + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined + case $cc_basename in + ifort*|nagfor*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test yes = "$_lt_dar_can_shared"; then + output_verbose_link_cmd=func_echo_all + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + m4_if([$1], [CXX], +[ if test yes != "$lt_cv_apple_cc_single_mod"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" + fi +],[]) + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi +]) + +# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) +# ---------------------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +# Store the results from the different compilers for each TAGNAME. +# Allow to override them for all tags through lt_cv_aix_libpath. +m4_defun([_LT_SYS_MODULE_PATH_AIX], +[m4_require([_LT_DECL_SED])dnl +if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], + [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ + lt_aix_libpath_sed='[ + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }]' + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi],[]) + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib + fi + ]) + aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) +fi +])# _LT_SYS_MODULE_PATH_AIX + + +# _LT_SHELL_INIT(ARG) +# ------------------- +m4_define([_LT_SHELL_INIT], +[m4_divert_text([M4SH-INIT], [$1 +])])# _LT_SHELL_INIT + + + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Find how we can fake an echo command that does not interpret backslash. +# In particular, with Autoconf 2.60 or later we add some code to the start +# of the generated configure script that will find a shell with a builtin +# printf (that we can use as an echo command). +m4_defun([_LT_PROG_ECHO_BACKSLASH], +[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +AC_MSG_CHECKING([how to print strings]) +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$[]1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + +case $ECHO in + printf*) AC_MSG_RESULT([printf]) ;; + print*) AC_MSG_RESULT([print -r]) ;; + *) AC_MSG_RESULT([cat]) ;; +esac + +m4_ifdef([_AS_DETECT_SUGGESTED], +[_AS_DETECT_SUGGESTED([ + test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( + ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' + ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO + ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + PATH=/empty FPATH=/empty; export PATH FPATH + test "X`printf %s $ECHO`" = "X$ECHO" \ + || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) + +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) +_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) +])# _LT_PROG_ECHO_BACKSLASH + + +# _LT_WITH_SYSROOT +# ---------------- +AC_DEFUN([_LT_WITH_SYSROOT], +[AC_MSG_CHECKING([for sysroot]) +AC_ARG_WITH([sysroot], +[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], + [Search for dependent libraries within DIR (or the compiler's sysroot + if not specified).])], +[], [with_sysroot=no]) + +dnl lt_sysroot will always be passed unquoted. We quote it here +dnl in case the user passed a directory name. +lt_sysroot= +case $with_sysroot in #( + yes) + if test yes = "$GCC"; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + AC_MSG_RESULT([$with_sysroot]) + AC_MSG_ERROR([The sysroot must be an absolute path.]) + ;; +esac + + AC_MSG_RESULT([${lt_sysroot:-no}]) +_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl +[dependent libraries, and where our libraries should be installed.])]) + +# _LT_ENABLE_LOCK +# --------------- +m4_defun([_LT_ENABLE_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AS_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test no = "$enable_libtool_lock" || enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out what ABI is being produced by ac_compile, and set mode + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE=32 + ;; + *ELF-64*) + HPUX_IA64_MODE=64 + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test yes = "$lt_cv_prog_gnu_ld"; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +mips64*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + emul=elf + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; + *64-bit*) + emul="${emul}64" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; + *LSB*) + emul="${emul}ltsmip" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; + esac + LD="${LD-ld} -m $emul" + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. Note that the listed cases only cover the + # situations where additional linker options are needed (such as when + # doing 32-bit compilation for a host where ld defaults to 64-bit, or + # vice versa); the common cases where no linker options are needed do + # not appear in the list. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac + ;; + powerpc64le-*linux*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + powerpcle-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test yes != "$lt_cv_cc_needs_belf"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS=$SAVE_CFLAGS + fi + ;; +*-*solaris*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) + case $host in + i?86-*-solaris*|x86_64-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD=${LD-ld}_sol2 + fi + ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks=$enable_libtool_lock +])# _LT_ENABLE_LOCK + + +# _LT_PROG_AR +# ----------- +m4_defun([_LT_PROG_AR], +[AC_CHECK_TOOLS(AR, [ar], false) +: ${AR=ar} +: ${AR_FLAGS=cru} +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) + +AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], + [lt_cv_ar_at_file=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM], + [echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' + AC_TRY_EVAL([lt_ar_try]) + if test 0 -eq "$ac_status"; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + AC_TRY_EVAL([lt_ar_try]) + if test 0 -ne "$ac_status"; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + ]) + ]) + +if test no = "$lt_cv_ar_at_file"; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi +_LT_DECL([], [archiver_list_spec], [1], + [How to feed a file listing to the archiver]) +])# _LT_PROG_AR + + +# _LT_CMD_OLD_ARCHIVE +# ------------------- +m4_defun([_LT_CMD_OLD_ARCHIVE], +[_LT_PROG_AR + +AC_CHECK_TOOL(STRIP, strip, :) +test -z "$STRIP" && STRIP=: +_LT_DECL([], [STRIP], [1], [A symbol stripping program]) + +AC_CHECK_TOOL(RANLIB, ranlib, :) +test -z "$RANLIB" && RANLIB=: +_LT_DECL([], [RANLIB], [1], + [Commands used to install an old-style archive]) + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + bitrig* | openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" +fi + +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; +esac +_LT_DECL([], [old_postinstall_cmds], [2]) +_LT_DECL([], [old_postuninstall_cmds], [2]) +_LT_TAGDECL([], [old_archive_cmds], [2], + [Commands used to build an old-style archive]) +_LT_DECL([], [lock_old_archive_extraction], [0], + [Whether to use a lock for old archive extraction]) +])# _LT_CMD_OLD_ARCHIVE + + +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([_LT_COMPILER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $RM conftest* +]) + +if test yes = "[$]$2"; then + m4_if([$5], , :, [$5]) +else + m4_if([$6], , :, [$6]) +fi +])# _LT_COMPILER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) + + +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------- +# Check whether the given linker option works +AC_DEFUN([_LT_LINKER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS +]) + +if test yes = "[$]$2"; then + m4_if([$4], , :, [$4]) +else + m4_if([$5], , :, [$5]) +fi +])# _LT_LINKER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) + + +# LT_CMD_MAX_LEN +#--------------- +AC_DEFUN([LT_CMD_MAX_LEN], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring=ABCD + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + mint*) + # On MiNT this can take a long time and run out of memory. + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test X`env echo "$teststring$teststring" 2>/dev/null` \ + = "X$teststring$teststring"; } >/dev/null 2>&1 && + test 17 != "$i" # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n "$lt_cv_sys_max_cmd_len"; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +_LT_DECL([], [max_cmd_len], [0], + [What is the maximum length of a command?]) +])# LT_CMD_MAX_LEN + +# Old name: +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) + + +# _LT_HEADER_DLFCN +# ---------------- +m4_defun([_LT_HEADER_DLFCN], +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl +])# _LT_HEADER_DLFCN + + +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ---------------------------------------------------------------- +m4_defun([_LT_TRY_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test yes = "$cross_compiling"; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +[#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +}] +_LT_EOF + if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_TRY_DLOPEN_SELF + + +# LT_SYS_DLOPEN_SELF +# ------------------ +AC_DEFUN([LT_SYS_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test yes != "$enable_dlopen"; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen=load_add_on + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen=LoadLibrary + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[ + lt_cv_dlopen=dyld + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + tpf*) + # Don't try to run any link tests for TPF. We know it's impossible + # because TPF is a cross-compiler, and we know how we open DSOs. + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + lt_cv_dlopen_self=no + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen=shl_load], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen=dlopen], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test no = "$lt_cv_dlopen"; then + enable_dlopen=no + else + enable_dlopen=yes + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS=$CPPFLAGS + test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS=$LDFLAGS + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS=$LIBS + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test yes = "$lt_cv_dlopen_self"; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +_LT_DECL([dlopen_support], [enable_dlopen], [0], + [Whether dlopen is supported]) +_LT_DECL([dlopen_self], [enable_dlopen_self], [0], + [Whether dlopen of programs is supported]) +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], + [Whether dlopen of statically linked programs is supported]) +])# LT_SYS_DLOPEN_SELF + +# Old name: +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) + + +# _LT_COMPILER_C_O([TAGNAME]) +# --------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler. +# This macro does not hard code the compiler like AC_PROG_CC_C_O. +m4_defun([_LT_COMPILER_C_O], +[m4_require([_LT_DECL_SED])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* +]) +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], + [Does compiler simultaneously support -c and -o options?]) +])# _LT_COMPILER_C_O + + +# _LT_COMPILER_FILE_LOCKS([TAGNAME]) +# ---------------------------------- +# Check to see if we can do hard links to lock some files if needed +m4_defun([_LT_COMPILER_FILE_LOCKS], +[m4_require([_LT_ENABLE_LOCK])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_COMPILER_C_O([$1]) + +hard_links=nottested +if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test no = "$hard_links"; then + AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) +])# _LT_COMPILER_FILE_LOCKS + + +# _LT_CHECK_OBJDIR +# ---------------- +m4_defun([_LT_CHECK_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +_LT_DECL([], [objdir], [0], + [The name of the directory that contains temporary libtool files])dnl +m4_pattern_allow([LT_OBJDIR])dnl +AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/", + [Define to the sub-directory where libtool stores uninstalled libraries.]) +])# _LT_CHECK_OBJDIR + + +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) +# -------------------------------------- +# Check hardcoding attributes. +m4_defun([_LT_LINKER_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || + test -n "$_LT_TAGVAR(runpath_var, $1)" || + test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then + + # We can hardcode non-existent directories. + if test no != "$_LT_TAGVAR(hardcode_direct, $1)" && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" && + test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then + # Linking always hardcodes the temporary library directory. + _LT_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) + +if test relink = "$_LT_TAGVAR(hardcode_action, $1)" || + test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then + # Fast installation is not supported + enable_fast_install=no +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then + # Fast installation is not necessary + enable_fast_install=needless +fi +_LT_TAGDECL([], [hardcode_action], [0], + [How to hardcode a shared library path into an executable]) +])# _LT_LINKER_HARDCODE_LIBPATH + + +# _LT_CMD_STRIPLIB +# ---------------- +m4_defun([_LT_CMD_STRIPLIB], +[m4_require([_LT_DECL_EGREP]) +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP"; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) +_LT_DECL([], [striplib], [1]) +])# _LT_CMD_STRIPLIB + + +# _LT_PREPARE_MUNGE_PATH_LIST +# --------------------------- +# Make sure func_munge_path_list() is defined correctly. +m4_defun([_LT_PREPARE_MUNGE_PATH_LIST], +[[# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x@S|@2 in + x) + ;; + *:) + eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\" + ;; + x:*) + eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\" + ;; + *) + eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\" + ;; + esac +} +]])# _LT_PREPARE_PATH_LIST + + +# _LT_SYS_DYNAMIC_LINKER([TAG]) +# ----------------------------- +# PORTME Fill in your ld.so characteristics +m4_defun([_LT_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_OBJDUMP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +m4_if([$1], + [], [ +if test yes = "$GCC"; then + case $host_os in + darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; + *) lt_awk_arg='/^libraries:/' ;; + esac + case $host_os in + mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; + *) lt_sed_strip_eq='s|=/|/|g' ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` + case $lt_search_path_spec in + *\;*) + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary... + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + # ...but if some path component already ends with the multilib dir we assume + # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). + case "$lt_multi_os_dir; $lt_search_path_spec " in + "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) + lt_multi_os_dir= + ;; + esac + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" + elif test -n "$lt_multi_os_dir"; then + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' +BEGIN {RS = " "; FS = "/|\n";} { + lt_foo = ""; + lt_count = 0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo = "/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + # AWK program above erroneously prepends '/' to C:/dos/paths + # for these hosts. + case $host_os in + mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; + esac + sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=.so +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +AC_ARG_VAR([LT_SYS_LIBRARY_PATH], +[User-defined run-time library search path.]) + +case $host_os in +aix3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='$libname$release$shared_ext$major' + ;; + +aix[[4-9]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test ia64 = "$host_cpu"; then + # AIX 5 supports IA64 + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a[(]lib.so.V[)]' + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='$libname$shared_ext' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + + case $GCC,$cc_basename in + yes,*) + # gcc + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec=$LIB + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' + ;; + + *) + # Assume MSVC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; + esac + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[23]].*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2.*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + dynamic_linker="$host_os runtime_loader" + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=no + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 + fi + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 + ;; + +interix[[3-9]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test yes = "$lt_cv_prog_gnu_ld"; then + version_type=linux # correct to gnu/linux during the next big refactor + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + + # Some binutils ld are patched to set DT_RUNPATH + AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], + [lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [lt_cv_shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + ]) + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd* | bitrig*) + version_type=sunos + sys_lib_dlsearch_path_spec=/usr/lib + need_lib_prefix=no + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +os2*) + libname_spec='$name' + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test yes = "$with_gnu_ld"; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec; then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=sco + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test yes = "$with_gnu_ld"; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test no = "$dynamic_linker" && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test yes = "$GCC"; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec +fi + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec +fi + +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + +_LT_DECL([], [variables_saved_for_relink], [1], + [Variables whose values should be saved in libtool wrapper scripts and + restored at link time]) +_LT_DECL([], [need_lib_prefix], [0], + [Do we need the "lib" prefix for modules?]) +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) +_LT_DECL([], [version_type], [0], [Library versioning type]) +_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) +_LT_DECL([], [shlibpath_overrides_runpath], [0], + [Is shlibpath searched before the hard-coded library search path?]) +_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) +_LT_DECL([], [library_names_spec], [1], + [[List of archive names. First name is the real one, the rest are links. + The last name is the one that the linker finds with -lNAME]]) +_LT_DECL([], [soname_spec], [1], + [[The coded name of the library, if different from the real name]]) +_LT_DECL([], [install_override_mode], [1], + [Permission mode override for installation of shared libraries]) +_LT_DECL([], [postinstall_cmds], [2], + [Command to use after installation of a shared archive]) +_LT_DECL([], [postuninstall_cmds], [2], + [Command to use after uninstallation of a shared archive]) +_LT_DECL([], [finish_cmds], [2], + [Commands used to finish a libtool library installation in a directory]) +_LT_DECL([], [finish_eval], [1], + [[As "finish_cmds", except a single script fragment to be evaled but + not shown]]) +_LT_DECL([], [hardcode_into_libs], [0], + [Whether we should hardcode library paths into libraries]) +_LT_DECL([], [sys_lib_search_path_spec], [2], + [Compile-time system search path for libraries]) +_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2], + [Detected run-time system search path for libraries]) +_LT_DECL([], [configure_time_lt_sys_library_path], [2], + [Explicit LT_SYS_LIBRARY_PATH set during ./configure time]) +])# _LT_SYS_DYNAMIC_LINKER + + +# _LT_PATH_TOOL_PREFIX(TOOL) +# -------------------------- +# find a file program that can recognize shared library +AC_DEFUN([_LT_PATH_TOOL_PREFIX], +[m4_require([_LT_DECL_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="m4_if([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$1"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac]) +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +_LT_DECL([], [MAGIC_CMD], [0], + [Used to examine libraries when file_magic_cmd begins with "file"])dnl +])# _LT_PATH_TOOL_PREFIX + +# Old name: +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) + + +# _LT_PATH_MAGIC +# -------------- +# find a file program that can recognize a shared library +m4_defun([_LT_PATH_MAGIC], +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# _LT_PATH_MAGIC + + +# LT_PATH_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([LT_PATH_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PROG_ECHO_BACKSLASH])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test no = "$withval" || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +ac_prog=ld +if test yes = "$GCC"; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return, which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD=$ac_prog + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test yes = "$with_gnu_ld"; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD=$ac_dir/$ac_prog + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 conftest.i +cat conftest.i conftest.i >conftest2.i +: ${lt_DD:=$DD} +AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd], +[if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: +fi]) +rm -f conftest.i conftest2.i conftest.out]) +])# _LT_PATH_DD + + +# _LT_CMD_TRUNCATE +# ---------------- +# find command to truncate a binary pipe +m4_defun([_LT_CMD_TRUNCATE], +[m4_require([_LT_PATH_DD]) +AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin], +[printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +lt_cv_truncate_bin= +if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out +test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"]) +_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1], + [Command to truncate a binary pipe]) +])# _LT_CMD_TRUNCATE + + +# _LT_CHECK_MAGIC_METHOD +# ---------------------- +# how to check for library dependencies +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_MAGIC_METHOD], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +AC_CACHE_CHECK([how to recognize dependent libraries], +lt_cv_deplibs_check_method, +[lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# 'unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# that responds to the $file_magic_cmd with a given extended regex. +# If you have 'file' or equivalent on your system and you're not sure +# whether 'pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[[4-9]]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[[45]]*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + # Keep this pattern in sync with the one in func_win32_libid. + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc*) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +haiku*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd* | bitrig*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +os2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` + fi + ;; + esac +fi + +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +_LT_DECL([], [deplibs_check_method], [1], + [Method to check whether dependent libraries are shared objects]) +_LT_DECL([], [file_magic_cmd], [1], + [Command to use when deplibs_check_method = "file_magic"]) +_LT_DECL([], [file_magic_glob], [1], + [How to find potential files when deplibs_check_method = "file_magic"]) +_LT_DECL([], [want_nocaseglob], [1], + [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) +])# _LT_CHECK_MAGIC_METHOD + + +# LT_PATH_NM +# ---------- +# find the pathname to a BSD- or MS-compatible name lister +AC_DEFUN([LT_PATH_NM], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM=$NM +else + lt_nm_to_check=${ac_tool_prefix}nm + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + tmp_nm=$ac_dir/$lt_tmp_nm + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the 'sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + case $build_os in + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac + case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break 2 + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break 2 + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS=$lt_save_ifs + done + : ${lt_cv_path_NM=no} +fi]) +if test no != "$lt_cv_path_NM"; then + NM=$lt_cv_path_NM +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$DUMPBIN"; then : + # Let the user override the test. + else + AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols -headers" + ;; + *) + DUMPBIN=: + ;; + esac + fi + AC_SUBST([DUMPBIN]) + if test : != "$DUMPBIN"; then + NM=$DUMPBIN + fi +fi +test -z "$NM" && NM=nm +AC_SUBST([NM]) +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl + +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], + [lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) + cat conftest.out >&AS_MESSAGE_LOG_FD + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest*]) +])# LT_PATH_NM + +# Old names: +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_NM], []) +dnl AC_DEFUN([AC_PROG_NM], []) + +# _LT_CHECK_SHAREDLIB_FROM_LINKLIB +# -------------------------------- +# how to determine the name of the shared library +# associated with a specific link library. +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +m4_require([_LT_DECL_DLLTOOL]) +AC_CACHE_CHECK([how to associate runtime and link libraries], +lt_cv_sharedlib_from_linklib_cmd, +[lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd=$ECHO + ;; +esac +]) +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + +_LT_DECL([], [sharedlib_from_linklib_cmd], [1], + [Command to associate shared and link libraries]) +])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB + + +# _LT_PATH_MANIFEST_TOOL +# ---------------------- +# locate the manifest tool +m4_defun([_LT_PATH_MANIFEST_TOOL], +[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], + [lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&AS_MESSAGE_LOG_FD + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest*]) +if test yes != "$lt_cv_path_mainfest_tool"; then + MANIFEST_TOOL=: +fi +_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl +])# _LT_PATH_MANIFEST_TOOL + + +# _LT_DLL_DEF_P([FILE]) +# --------------------- +# True iff FILE is a Windows DLL '.def' file. +# Keep in sync with func_dll_def_p in the libtool script +AC_DEFUN([_LT_DLL_DEF_P], +[dnl + test DEF = "`$SED -n dnl + -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace + -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments + -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl + -e q dnl Only consider the first "real" line + $1`" dnl +])# _LT_DLL_DEF_P + + +# LT_LIB_M +# -------- +# check for math library +AC_DEFUN([LT_LIB_M], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw) + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM=-lm) + ;; +esac +AC_SUBST([LIBM]) +])# LT_LIB_M + +# Old name: +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_CHECK_LIBM], []) + + +# _LT_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------- +m4_defun([_LT_COMPILER_NO_RTTI], +[m4_require([_LT_TAG_COMPILER])dnl + +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test yes = "$GCC"; then + case $cc_basename in + nvcc*) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; + *) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; + esac + + _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], + [Compiler flag to turn off builtin functions]) +])# _LT_COMPILER_NO_RTTI + + +# _LT_CMD_GLOBAL_SYMBOLS +# ---------------------- +m4_defun([_LT_CMD_GLOBAL_SYMBOLS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([LT_PATH_NM])dnl +AC_REQUIRE([LT_PATH_LD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_TAG_COMPILER])dnl + +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) + if test ia64 = "$host_cpu"; then + symcode='[[ABCDEGRST]]' + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. + lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" + lt_c_name_lib_hook="\ + -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ + -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" +else + # Disable hooks by default. + lt_cv_sys_global_symbol_to_import= + lt_cdecl_hook= + lt_c_name_hook= + lt_c_name_lib_hook= +fi + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +$lt_cdecl_hook\ +" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +$lt_c_name_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + +# Transform an extracted symbol line into symbol name with lib prefix and +# symbol address. +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +$lt_c_name_lib_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK ['"\ +" {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ +" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ +" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ +" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ +" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx]" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT@&t@_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT@&t@_DLSYM_CONST +#else +# define LT@&t@_DLSYM_CONST const +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +LT@&t@_DLSYM_CONST struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[[]] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS + LIBS=conftstm.$ac_objext + CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then + pipe_works=yes + fi + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test yes = "$pipe_works"; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi + +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then + nm_file_list_spec='@' +fi + +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], + [Take the output of nm and produce a listing of raw symbols and C names]) +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], + [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1], + [Transform the output of nm into a list of symbols to manually relocate]) +_LT_DECL([global_symbol_to_c_name_address], + [lt_cv_sys_global_symbol_to_c_name_address], [1], + [Transform the output of nm in a C name address pair]) +_LT_DECL([global_symbol_to_c_name_address_lib_prefix], + [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], + [Transform the output of nm in a C name address pair when lib prefix is needed]) +_LT_DECL([nm_interface], [lt_cv_nm_interface], [1], + [The name lister interface]) +_LT_DECL([], [nm_file_list_spec], [1], + [Specify filename containing input files for $NM]) +]) # _LT_CMD_GLOBAL_SYMBOLS + + +# _LT_COMPILER_PIC([TAGNAME]) +# --------------------------- +m4_defun([_LT_COMPILER_PIC], +[m4_require([_LT_TAG_COMPILER])dnl +_LT_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_TAGVAR(lt_prog_compiler_static, $1)= + +m4_if([$1], [CXX], [ + # C++ specific cases for pic, static, wl, etc. + if test yes = "$GXX"; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + if test ia64 != "$host_cpu"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64, which still supported -KPIC. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) + # IBM XL 8.0, 9.0 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test yes = "$GCC"; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' + if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + + hpux9* | hpux10* | hpux11*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + # old Intel for x86_64, which still supported -KPIC. + ecc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' + _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' + ;; + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + *Sun\ F* | *Sun*Fortran*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Intel*\ [[CF]]*Compiler*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + *Portland\ Group*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +case $host_os in + # For platforms that do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" + ;; +esac + +AC_CACHE_CHECK([for $compiler option to produce PIC], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], + [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], + [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], + [Additional compiler flags for building library objects]) + +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) +# +# Check to make sure the static flag actually works. +# +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], + [Compiler flag to prevent dynamic linking]) +])# _LT_COMPILER_PIC + + +# _LT_LINKER_SHLIBS([TAGNAME]) +# ---------------------------- +# See if the linker supports building shared libraries. +m4_defun([_LT_LINKER_SHLIBS], +[AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +m4_if([$1], [CXX], [ + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds + ;; + cygwin* | mingw* | cegcc*) + case $cc_basename in + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + ;; + esac + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac +], [ + runpath_var= + _LT_TAGVAR(allow_undefined_flag, $1)= + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(archive_cmds, $1)= + _LT_TAGVAR(archive_expsym_cmds, $1)= + _LT_TAGVAR(compiler_needs_object, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(hardcode_automatic, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_separator, $1)= + _LT_TAGVAR(hardcode_minus_L, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(inherit_rpath, $1)=no + _LT_TAGVAR(link_all_deplibs, $1)=unknown + _LT_TAGVAR(module_cmds, $1)= + _LT_TAGVAR(module_expsym_cmds, $1)= + _LT_TAGVAR(old_archive_from_new_cmds, $1)= + _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_TAGVAR(thread_safe_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ' (' and ')$', so one must not match beginning or + # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', + # as well as any symbol that contains 'd'. + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test yes != "$GCC"; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd* | bitrig*) + with_gnu_ld=no + ;; + esac + + _LT_TAGVAR(ld_shlibs, $1)=yes + + # On some targets, GNU ld is compatible enough with the native linker + # that we're better off using the native interface for both. + lt_use_gnu_ld_interface=no + if test yes = "$with_gnu_ld"; then + case $host_os in + aix*) + # The AIX port of GNU ld has always aspired to compatibility + # with the native linker. However, as the warning in the GNU ld + # block says, versions before 2.19.5* couldn't really create working + # shared libraries, regardless of the interface used. + case `$LD -v 2>&1` in + *\ \(GNU\ Binutils\)\ 2.19.5*) ;; + *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; + *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + fi + + if test yes = "$lt_use_gnu_ld_interface"; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='$wl' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test ia64 != "$host_cpu"; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.19, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to install binutils +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. +*** You will then need to restart the configuration process. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + tmp_diet=no + if test linux-dietlibc = "$host_os"; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test no = "$tmp_diet" + then + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group f77 and f90 compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + _LT_TAGVAR(whole_archive_flag_spec, $1)= + tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 + tmp_sharedflag='-Wl,-shared' ;; + xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + nvcc*) # Cuda Compiler Driver 2.2 + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + tcc*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic' + ;; + xlf* | bgf* | bgxlf* | mpixlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then + runpath_var= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then + aix_use_runtimelinking=yes + break + fi + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # traditional, no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + ;; + esac + + if test yes = "$GCC"; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag="$shared_flag "'$wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + bsdi[[45]]*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in + cl*) + # Native MSVC + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + esac + ;; + + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2.*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + ;; + + hpux10*) + if test yes,no = "$GCC,$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test yes,no = "$GCC,$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + m4_if($1, [], [ + # Older versions of the 11.00 compiler do not understand -b yet + # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) + _LT_LINKER_OPTION([if $CC understands -b], + _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], + [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) + ;; + esac + fi + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + # This should be the same for all languages, so no per-tag cache variable. + AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], + [lt_cv_irix_exported_symbol], + [save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" + AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], + [C++], [[int foo (void) { return 0; }]], + [Fortran 77], [[ + subroutine foo + end]], + [Fortran], [[ + subroutine foo + end]])])], + [lt_cv_irix_exported_symbol=yes], + [lt_cv_irix_exported_symbol=no]) + LDFLAGS=$save_LDFLAGS]) + if test yes = "$lt_cv_irix_exported_symbol"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' + fi + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + linux*) + case $cc_basename in + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + _LT_TAGVAR(ld_shlibs, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *nto* | *qnx*) + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + fi + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + osf3*) + if test yes = "$GCC"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test yes = "$GCC"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' + if test yes = "$GCC"; then + wlarc='$wl' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='$wl' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. GCC discards it without '$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test yes = "$GCC"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test sequent = "$host_vendor"; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + if test sni = "$host_vendor"; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym' + ;; + esac + fi + fi +]) +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) +test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no + +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld + +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl +_LT_DECL([], [extract_expsyms_cmds], [2], + [The commands to extract the exported symbol list from a shared archive]) + +# +# Do we need to explicitly link libc? +# +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test yes,yes = "$GCC,$enable_shared"; then + case $_LT_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_CACHE_CHECK([whether -lc should be explicitly linked in], + [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), + [$RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + ]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) + ;; + esac + fi + ;; +esac + +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], + [Whether or not to add -lc for building shared libraries]) +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], + [enable_shared_with_static_runtimes], [0], + [Whether or not to disallow shared libs when runtime libs are static]) +_LT_TAGDECL([], [export_dynamic_flag_spec], [1], + [Compiler flag to allow reflexive dlopens]) +_LT_TAGDECL([], [whole_archive_flag_spec], [1], + [Compiler flag to generate shared objects directly from archives]) +_LT_TAGDECL([], [compiler_needs_object], [1], + [Whether the compiler copes with passing no objects directly]) +_LT_TAGDECL([], [old_archive_from_new_cmds], [2], + [Create an old-style archive from a shared archive]) +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], + [Create a temporary old-style archive to link instead of a shared archive]) +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) +_LT_TAGDECL([], [archive_expsym_cmds], [2]) +_LT_TAGDECL([], [module_cmds], [2], + [Commands used to build a loadable module if different from building + a shared archive.]) +_LT_TAGDECL([], [module_expsym_cmds], [2]) +_LT_TAGDECL([], [with_gnu_ld], [1], + [Whether we are building with GNU ld or not]) +_LT_TAGDECL([], [allow_undefined_flag], [1], + [Flag that allows shared libraries with undefined symbols to be built]) +_LT_TAGDECL([], [no_undefined_flag], [1], + [Flag that enforces no undefined symbols]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], + [Flag to hardcode $libdir into a binary during linking. + This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_separator], [1], + [Whether we need a single "-rpath" flag with a separated argument]) +_LT_TAGDECL([], [hardcode_direct], [0], + [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes + DIR into the resulting binary]) +_LT_TAGDECL([], [hardcode_direct_absolute], [0], + [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes + DIR into the resulting binary and the resulting library dependency is + "absolute", i.e impossible to change by setting $shlibpath_var if the + library is relocated]) +_LT_TAGDECL([], [hardcode_minus_L], [0], + [Set to "yes" if using the -LDIR flag during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_shlibpath_var], [0], + [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_automatic], [0], + [Set to "yes" if building a shared library automatically hardcodes DIR + into the library and all subsequent libraries and executables linked + against it]) +_LT_TAGDECL([], [inherit_rpath], [0], + [Set to yes if linker adds runtime paths of dependent libraries + to runtime path list]) +_LT_TAGDECL([], [link_all_deplibs], [0], + [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [always_export_symbols], [0], + [Set to "yes" if exported symbols are required]) +_LT_TAGDECL([], [export_symbols_cmds], [2], + [The commands to list exported symbols]) +_LT_TAGDECL([], [exclude_expsyms], [1], + [Symbols that should not be listed in the preloaded symbols]) +_LT_TAGDECL([], [include_expsyms], [1], + [Symbols that must always be exported]) +_LT_TAGDECL([], [prelink_cmds], [2], + [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [postlink_cmds], [2], + [Commands necessary for finishing linking programs]) +_LT_TAGDECL([], [file_list_spec], [1], + [Specify filename containing input files]) +dnl FIXME: Not yet implemented +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], +dnl [Compiler flag to generate thread safe objects]) +])# _LT_LINKER_SHLIBS + + +# _LT_LANG_C_CONFIG([TAG]) +# ------------------------ +# Ensure that the configuration variables for a C compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_C_CONFIG], +[m4_require([_LT_DECL_EGREP])dnl +lt_save_CC=$CC +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_TAG_COMPILER +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + LT_SYS_DLOPEN_SELF + _LT_CMD_STRIPLIB + + # Report what library types will actually be built + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_CONFIG($1) +fi +AC_LANG_POP +CC=$lt_save_CC +])# _LT_LANG_C_CONFIG + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +if test -n "$CXX" && ( test no != "$CXX" && + ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || + (test g++ != "$CXX"))); then + AC_PROG_CXXCPP +else + _lt_caught_CXX_error=yes +fi + +AC_LANG_PUSH(C++) +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(compiler_needs_object, $1)=no +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_caught_CXX_error"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_CFLAGS=$CFLAGS + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + CFLAGS=$CXXFLAGS + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test yes = "$GXX"; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + else + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + fi + + if test yes = "$GXX"; then + # Set up default GNU C++ configuration + + LT_PATH_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test yes = "$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='$wl' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) + _LT_TAGVAR(ld_shlibs, $1)=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + ;; + esac + + if test yes = "$GXX"; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag=$shared_flag' $wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + # The "-G" linker flag allows undefined symbols. + _LT_TAGVAR(no_undefined_flag, $1)='-bernotok' + # Determine the default libpath from the value encoded in an empty + # executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared + # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32* | cegcc*) + case $GXX,$cc_basename in + ,cl* | no,cl*) + # Native MSVC + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + func_to_tool_file "$lt_outputfile"~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # g++ + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + freebsd2.*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + freebsd-elf*) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + hpux9*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes = "$GXX"; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' + fi + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) + _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' + _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ + $RANLIB $oldlib' + _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 6 and above use weak symbols + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' + ;; + xl* | mpixl* | bgxl*) + # IBM XL 8.0 on PPC, with GNU ld + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + fi + output_verbose_link_cmd=func_echo_all + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + case $host in + osf3*) + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + ;; + *) + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ + $RM $lib.exp' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes,no = "$GXX,$with_gnu_ld"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + case $host in + osf3*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test yes,no = "$GXX,$with_gnu_ld"; then + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + else + # g++ 2.7 appears to require '-G' NOT '-shared' on this + # platform. + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + fi + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ + '"$_LT_TAGVAR(old_archive_cmds, $1)" + _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ + '"$_LT_TAGVAR(reload_cmds, $1)" + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) + test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no + + _LT_TAGVAR(GCC, $1)=$GXX + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test yes != "$_lt_caught_CXX_error" + +AC_LANG_POP +])# _LT_LANG_CXX_CONFIG + + +# _LT_FUNC_STRIPNAME_CNF +# ---------------------- +# func_stripname_cnf prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# +# This function is identical to the (non-XSI) version of func_stripname, +# except this one can be used by m4 code that may be executed by configure, +# rather than the libtool script. +m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl +AC_REQUIRE([_LT_DECL_SED]) +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) +func_stripname_cnf () +{ + case @S|@2 in + .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;; + *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;; + esac +} # func_stripname_cnf +])# _LT_FUNC_STRIPNAME_CNF + + +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) +# --------------------------------- +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +m4_defun([_LT_SYS_HIDDEN_LIBDEPS], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl +# Dependencies to place before and after the object being linked: +_LT_TAGVAR(predep_objects, $1)= +_LT_TAGVAR(postdep_objects, $1)= +_LT_TAGVAR(predeps, $1)= +_LT_TAGVAR(postdeps, $1)= +_LT_TAGVAR(compiler_lib_search_path, $1)= + +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF +int a; +void foo (void) { a = 0; } +_LT_EOF +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +_LT_EOF +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer a + a=0 + return + end +_LT_EOF +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +_LT_EOF +], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF +package foo +func foo() { +} +_LT_EOF +]) + +_lt_libdeps_save_CFLAGS=$CFLAGS +case "$CC $CFLAGS " in #( +*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; +*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; +*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; +esac + +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case $prev$p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test x-L = "$p" || + test x-R = "$p"; then + prev=$p + continue + fi + + # Expand the sysroot to ease extracting the directories later. + if test -z "$prev"; then + case $p in + -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; + -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; + -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; + esac + fi + case $p in + =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; + esac + if test no = "$pre_test_object_deps_done"; then + case $prev in + -L | -R) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p + else + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$_LT_TAGVAR(postdeps, $1)"; then + _LT_TAGVAR(postdeps, $1)=$prev$p + else + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p" + fi + fi + prev= + ;; + + *.lto.$objext) ;; # Ignore GCC LTO objects + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test no = "$pre_test_object_deps_done"; then + if test -z "$_LT_TAGVAR(predep_objects, $1)"; then + _LT_TAGVAR(predep_objects, $1)=$p + else + _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then + _LT_TAGVAR(postdep_objects, $1)=$p + else + _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$RM -f confest.$objext +CFLAGS=$_lt_libdeps_save_CFLAGS + +# PORTME: override above test on systems where it is broken +m4_if([$1], [CXX], +[case $host_os in +interix[[3-9]]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + _LT_TAGVAR(predep_objects,$1)= + _LT_TAGVAR(postdep_objects,$1)= + _LT_TAGVAR(postdeps,$1)= + ;; +esac +]) + +case " $_LT_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac + _LT_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'` +fi +_LT_TAGDECL([], [compiler_lib_search_dirs], [1], + [The directories searched by this compiler when creating a shared library]) +_LT_TAGDECL([], [predep_objects], [1], + [Dependencies to place before and after the objects being linked to + create a shared library]) +_LT_TAGDECL([], [postdep_objects], [1]) +_LT_TAGDECL([], [predeps], [1]) +_LT_TAGDECL([], [postdeps], [1]) +_LT_TAGDECL([], [compiler_lib_search_path], [1], + [The library search path used internally by the compiler when linking + a shared library]) +])# _LT_SYS_HIDDEN_LIBDEPS + + +# _LT_LANG_F77_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a Fortran 77 compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_F77_CONFIG], +[AC_LANG_PUSH(Fortran 77) +if test -z "$F77" || test no = "$F77"; then + _lt_disable_F77=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the F77 compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_disable_F77"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${F77-"f77"} + CFLAGS=$FFLAGS + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + GCC=$G77 + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)=$G77 + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS +fi # test yes != "$_lt_disable_F77" + +AC_LANG_POP +])# _LT_LANG_F77_CONFIG + + +# _LT_LANG_FC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for a Fortran compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_FC_CONFIG], +[AC_LANG_PUSH(Fortran) + +if test -z "$FC" || test no = "$FC"; then + _lt_disable_FC=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for fc test sources. +ac_ext=${ac_fc_srcext-f} + +# Object file extension for compiled fc test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the FC compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_disable_FC"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${FC-"f95"} + CFLAGS=$FCFLAGS + compiler=$CC + GCC=$ac_cv_fc_compiler_gnu + + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS +fi # test yes != "$_lt_disable_FC" + +AC_LANG_POP +])# _LT_LANG_FC_CONFIG + + +# _LT_LANG_GCJ_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Java Compiler compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_GCJ_CONFIG], +[AC_REQUIRE([LT_PROG_GCJ])dnl +AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GCJ-"gcj"} +CFLAGS=$GCJFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)=$LD +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GCJ_CONFIG + + +# _LT_LANG_GO_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Go compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_GO_CONFIG], +[AC_REQUIRE([LT_PROG_GO])dnl +AC_LANG_SAVE + +# Source file extension for Go test sources. +ac_ext=go + +# Object file extension for compiled Go test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="package main; func main() { }" + +# Code to be used in simple link tests +lt_simple_link_test_code='package main; func main() { }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GOC-"gccgo"} +CFLAGS=$GOFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)=$LD +_LT_CC_BASENAME([$compiler]) + +# Go did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GO_CONFIG + + +# _LT_LANG_RC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for the Windows resource compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_RC_CONFIG], +[AC_REQUIRE([LT_PROG_RC])dnl +AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code=$lt_simple_compile_test_code + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC= +CC=${RC-"windres"} +CFLAGS= +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +if test -n "$compiler"; then + : + _LT_CONFIG($1) +fi + +GCC=$lt_save_GCC +AC_LANG_RESTORE +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_RC_CONFIG + + +# LT_PROG_GCJ +# ----------- +AC_DEFUN([LT_PROG_GCJ], +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], + [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], + [AC_CHECK_TOOL(GCJ, gcj,) + test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS)])])[]dnl +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_GCJ], []) + + +# LT_PROG_GO +# ---------- +AC_DEFUN([LT_PROG_GO], +[AC_CHECK_TOOL(GOC, gccgo,) +]) + + +# LT_PROG_RC +# ---------- +AC_DEFUN([LT_PROG_RC], +[AC_CHECK_TOOL(RC, windres,) +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_RC], []) + + +# _LT_DECL_EGREP +# -------------- +# If we don't have a new enough Autoconf to choose the best grep +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_EGREP], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_REQUIRE([AC_PROG_FGREP])dnl +test -z "$GREP" && GREP=grep +_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) +_LT_DECL([], [EGREP], [1], [An ERE matcher]) +_LT_DECL([], [FGREP], [1], [A literal string matcher]) +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too +AC_SUBST([GREP]) +]) + + +# _LT_DECL_OBJDUMP +# -------------- +# If we don't have a new enough Autoconf to choose the best objdump +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_OBJDUMP], +[AC_CHECK_TOOL(OBJDUMP, objdump, false) +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) +AC_SUBST([OBJDUMP]) +]) + +# _LT_DECL_DLLTOOL +# ---------------- +# Ensure DLLTOOL variable is set. +m4_defun([_LT_DECL_DLLTOOL], +[AC_CHECK_TOOL(DLLTOOL, dlltool, false) +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) +AC_SUBST([DLLTOOL]) +]) + +# _LT_DECL_SED +# ------------ +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +m4_defun([_LT_DECL_SED], +[AC_PROG_SED +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" +_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], + [Sed that helps us avoid accidentally triggering echo(1) options like -n]) +])# _LT_DECL_SED + +m4_ifndef([AC_PROG_SED], [ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # + +m4_defun([AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f "$lt_ac_sed" && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test 10 -lt "$lt_ac_count" && break + lt_ac_count=`expr $lt_ac_count + 1` + if test "$lt_ac_count" -gt "$lt_ac_max"; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +])#AC_PROG_SED +])#m4_ifndef + +# Old name: +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_SED], []) + + +# _LT_CHECK_SHELL_FEATURES +# ------------------------ +# Find out whether the shell is Bourne or XSI compatible, +# or has some other useful features. +m4_defun([_LT_CHECK_SHELL_FEATURES], +[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl +])# _LT_CHECK_SHELL_FEATURES + + +# _LT_PATH_CONVERSION_FUNCTIONS +# ----------------------------- +# Determine what file name conversion functions should be used by +# func_to_host_file (and, implicitly, by func_to_host_path). These are needed +# for certain cross-compile configurations and native mingw. +m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_MSG_CHECKING([how to convert $build file names to $host format]) +AC_CACHE_VAL(lt_cv_to_host_file_cmd, +[case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac +]) +to_host_file_cmd=$lt_cv_to_host_file_cmd +AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) +_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], + [0], [convert $build file names to $host format])dnl + +AC_MSG_CHECKING([how to convert $build file names to toolchain format]) +AC_CACHE_VAL(lt_cv_to_tool_file_cmd, +[#assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac +]) +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) +_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], + [0], [convert $build files to toolchain format])dnl +])# _LT_PATH_CONVERSION_FUNCTIONS + +# Helper functions for option handling. -*- Autoconf -*- +# +# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software +# Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 8 ltoptions.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) + + +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) +# ------------------------------------------ +m4_define([_LT_MANGLE_OPTION], +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) + + +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) +# --------------------------------------- +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a +# matching handler defined, dispatch to it. Other OPTION-NAMEs are +# saved as a flag. +m4_define([_LT_SET_OPTION], +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), + _LT_MANGLE_DEFUN([$1], [$2]), + [m4_warning([Unknown $1 option '$2'])])[]dnl +]) + + +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) +# ------------------------------------------------------------ +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +m4_define([_LT_IF_OPTION], +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) + + +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) +# ------------------------------------------------------- +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME +# are set. +m4_define([_LT_UNLESS_OPTIONS], +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), + [m4_define([$0_found])])])[]dnl +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 +])[]dnl +]) + + +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) +# ---------------------------------------- +# OPTION-LIST is a space-separated list of Libtool options associated +# with MACRO-NAME. If any OPTION has a matching handler declared with +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about +# the unknown option and exit. +m4_defun([_LT_SET_OPTIONS], +[# Set options +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [_LT_SET_OPTION([$1], _LT_Option)]) + +m4_if([$1],[LT_INIT],[ + dnl + dnl Simply set some default values (i.e off) if boolean options were not + dnl specified: + _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no + ]) + _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no + ]) + dnl + dnl If no reference was made to various pairs of opposing options, then + dnl we run the default mode handler for the pair. For example, if neither + dnl 'shared' nor 'disable-shared' was passed, we enable building of shared + dnl archives by default: + _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) + _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], + [_LT_ENABLE_FAST_INSTALL]) + _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4], + [_LT_WITH_AIX_SONAME([aix])]) + ]) +])# _LT_SET_OPTIONS + + + +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) +# ----------------------------------------- +m4_define([_LT_MANGLE_DEFUN], +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) + + +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) +# ----------------------------------------------- +m4_define([LT_OPTION_DEFINE], +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl +])# LT_OPTION_DEFINE + + +# dlopen +# ------ +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes +]) + +AU_DEFUN([AC_LIBTOOL_DLOPEN], +[_LT_SET_OPTION([LT_INIT], [dlopen]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'dlopen' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) + + +# win32-dll +# --------- +# Declare package support for building win32 dll's. +LT_OPTION_DEFINE([LT_INIT], [win32-dll], +[enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +esac + +test -z "$AS" && AS=as +_LT_DECL([], [AS], [1], [Assembler program])dnl + +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl + +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl +])# win32-dll + +AU_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +_LT_SET_OPTION([LT_INIT], [win32-dll]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'win32-dll' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) + + +# _LT_ENABLE_SHARED([DEFAULT]) +# ---------------------------- +# implement the --enable-shared flag, and supports the 'shared' and +# 'disable-shared' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_SHARED], +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([shared], + [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) + + _LT_DECL([build_libtool_libs], [enable_shared], [0], + [Whether or not to build shared libraries]) +])# _LT_ENABLE_SHARED + +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) +]) + +AC_DEFUN([AC_DISABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], [disable-shared]) +]) + +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_SHARED], []) +dnl AC_DEFUN([AM_DISABLE_SHARED], []) + + + +# _LT_ENABLE_STATIC([DEFAULT]) +# ---------------------------- +# implement the --enable-static flag, and support the 'static' and +# 'disable-static' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_STATIC], +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_static=]_LT_ENABLE_STATIC_DEFAULT) + + _LT_DECL([build_old_libs], [enable_static], [0], + [Whether or not to build static libraries]) +])# _LT_ENABLE_STATIC + +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) +]) + +AC_DEFUN([AC_DISABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], [disable-static]) +]) + +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_STATIC], []) +dnl AC_DEFUN([AM_DISABLE_STATIC], []) + + + +# _LT_ENABLE_FAST_INSTALL([DEFAULT]) +# ---------------------------------- +# implement the --enable-fast-install flag, and support the 'fast-install' +# and 'disable-fast-install' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_FAST_INSTALL], +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([fast-install], + [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) + +_LT_DECL([fast_install], [enable_fast_install], [0], + [Whether or not to optimize for fast installation])dnl +])# _LT_ENABLE_FAST_INSTALL + +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) + +# Old names: +AU_DEFUN([AC_ENABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the 'fast-install' option into LT_INIT's first parameter.]) +]) + +AU_DEFUN([AC_DISABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the 'disable-fast-install' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) + + +# _LT_WITH_AIX_SONAME([DEFAULT]) +# ---------------------------------- +# implement the --with-aix-soname flag, and support the `aix-soname=aix' +# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT +# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'. +m4_define([_LT_WITH_AIX_SONAME], +[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl +shared_archive_member_spec= +case $host,$enable_shared in +power*-*-aix[[5-9]]*,yes) + AC_MSG_CHECKING([which variant of shared library versioning to provide]) + AC_ARG_WITH([aix-soname], + [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], + [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])], + [case $withval in + aix|svr4|both) + ;; + *) + AC_MSG_ERROR([Unknown argument to --with-aix-soname]) + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname], + [AC_CACHE_VAL([lt_cv_with_aix_soname], + [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT) + with_aix_soname=$lt_cv_with_aix_soname]) + AC_MSG_RESULT([$with_aix_soname]) + if test aix != "$with_aix_soname"; then + # For the AIX way of multilib, we name the shared archive member + # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', + # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. + # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, + # the AIX toolchain works better with OBJECT_MODE set (default 32). + if test 64 = "${OBJECT_MODE-32}"; then + shared_archive_member_spec=shr_64 + else + shared_archive_member_spec=shr + fi + fi + ;; +*) + with_aix_soname=aix + ;; +esac + +_LT_DECL([], [shared_archive_member_spec], [0], + [Shared archive member basename, for filename based shared library versioning on AIX])dnl +])# _LT_WITH_AIX_SONAME + +LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])]) +LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])]) +LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])]) + + +# _LT_WITH_PIC([MODE]) +# -------------------- +# implement the --with-pic flag, and support the 'pic-only' and 'no-pic' +# LT_INIT options. +# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'. +m4_define([_LT_WITH_PIC], +[AC_ARG_WITH([pic], + [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $withval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [pic_mode=m4_default([$1], [default])]) + +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl +])# _LT_WITH_PIC + +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) + +# Old name: +AU_DEFUN([AC_LIBTOOL_PICMODE], +[_LT_SET_OPTION([LT_INIT], [pic-only]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'pic-only' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) + + +m4_define([_LTDL_MODE], []) +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], + [m4_define([_LTDL_MODE], [nonrecursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [recursive], + [m4_define([_LTDL_MODE], [recursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [subproject], + [m4_define([_LTDL_MODE], [subproject])]) + +m4_define([_LTDL_TYPE], []) +LT_OPTION_DEFINE([LTDL_INIT], [installable], + [m4_define([_LTDL_TYPE], [installable])]) +LT_OPTION_DEFINE([LTDL_INIT], [convenience], + [m4_define([_LTDL_TYPE], [convenience])]) + +# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- +# +# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software +# Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltsugar.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) + + +# lt_join(SEP, ARG1, [ARG2...]) +# ----------------------------- +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their +# associated separator. +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier +# versions in m4sugar had bugs. +m4_define([lt_join], +[m4_if([$#], [1], [], + [$#], [2], [[$2]], + [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) +m4_define([_lt_join], +[m4_if([$#$2], [2], [], + [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) + + +# lt_car(LIST) +# lt_cdr(LIST) +# ------------ +# Manipulate m4 lists. +# These macros are necessary as long as will still need to support +# Autoconf-2.59, which quotes differently. +m4_define([lt_car], [[$1]]) +m4_define([lt_cdr], +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], + [$#], 1, [], + [m4_dquote(m4_shift($@))])]) +m4_define([lt_unquote], $1) + + +# lt_append(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------ +# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. +# Note that neither SEPARATOR nor STRING are expanded; they are appended +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). +# No SEPARATOR is output if MACRO-NAME was previously undefined (different +# than defined and empty). +# +# This macro is needed until we can rely on Autoconf 2.62, since earlier +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. +m4_define([lt_append], +[m4_define([$1], + m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) + + + +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) +# ---------------------------------------------------------- +# Produce a SEP delimited list of all paired combinations of elements of +# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list +# has the form PREFIXmINFIXSUFFIXn. +# Needed until we can rely on m4_combine added in Autoconf 2.62. +m4_define([lt_combine], +[m4_if(m4_eval([$# > 3]), [1], + [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl +[[m4_foreach([_Lt_prefix], [$2], + [m4_foreach([_Lt_suffix], + ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, + [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) + + +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) +# ----------------------------------------------------------------------- +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. +m4_define([lt_if_append_uniq], +[m4_ifdef([$1], + [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], + [lt_append([$1], [$2], [$3])$4], + [$5])], + [lt_append([$1], [$2], [$3])$4])]) + + +# lt_dict_add(DICT, KEY, VALUE) +# ----------------------------- +m4_define([lt_dict_add], +[m4_define([$1($2)], [$3])]) + + +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) +# -------------------------------------------- +m4_define([lt_dict_add_subkey], +[m4_define([$1($2:$3)], [$4])]) + + +# lt_dict_fetch(DICT, KEY, [SUBKEY]) +# ---------------------------------- +m4_define([lt_dict_fetch], +[m4_ifval([$3], + m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), + m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) + + +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) +# ----------------------------------------------------------------- +m4_define([lt_if_dict_fetch], +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], + [$5], + [$6])]) + + +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) +# -------------------------------------------------------------- +m4_define([lt_dict_filter], +[m4_if([$5], [], [], + [lt_join(m4_quote(m4_default([$4], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), + [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl +]) + +# ltversion.m4 -- version numbers -*- Autoconf -*- +# +# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# @configure_input@ + +# serial 4179 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.4.6]) +m4_define([LT_PACKAGE_REVISION], [2.4.6]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.4.6' +macro_revision='2.4.6' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +]) + +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- +# +# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software +# Foundation, Inc. +# Written by Scott James Remnant, 2004. +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 5 lt~obsolete.m4 + +# These exist entirely to fool aclocal when bootstrapping libtool. +# +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN), +# which have later been changed to m4_define as they aren't part of the +# exported API, or moved to Autoconf or Automake where they belong. +# +# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us +# using a macro with the same name in our local m4/libtool.m4 it'll +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define +# and doesn't know about Autoconf macros at all.) +# +# So we provide this file, which has a silly filename so it's always +# included after everything else. This provides aclocal with the +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything +# because those macros already exist, or will be overwritten later. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. +# Yes, that means every name once taken will need to remain here until +# we give up compatibility with versions before 1.7, at which point +# we need to keep only those names which we still refer to. + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) + +m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) +m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) +m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) +m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) +m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) +m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) +m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) +m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) +m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) +m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) +m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) +m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) +m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) +m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) +m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) +m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) +m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) +m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) +m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) +m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) +m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) +m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) +m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) +m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) +m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) +m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) +m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) +m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) +m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) +m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) +m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) +m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) +m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) +m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) +m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) +m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) +m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) +m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) + +# Copyright (C) 2002-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.16' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.16.5], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.16.5])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) + +# Copyright (C) 2011-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_AR([ACT-IF-FAIL]) +# ------------------------- +# Try to determine the archiver interface, and trigger the ar-lib wrapper +# if it is needed. If the detection of archiver interface fails, run +# ACT-IF-FAIL (default is to abort configure with a proper error message). +AC_DEFUN([AM_PROG_AR], +[AC_BEFORE([$0], [LT_INIT])dnl +AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl +AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([ar-lib])dnl +AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false]) +: ${AR=ar} + +AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface], + [AC_LANG_PUSH([C]) + am_cv_ar_interface=ar + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])], + [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD' + AC_TRY_EVAL([am_ar_try]) + if test "$ac_status" -eq 0; then + am_cv_ar_interface=ar + else + am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD' + AC_TRY_EVAL([am_ar_try]) + if test "$ac_status" -eq 0; then + am_cv_ar_interface=lib + else + am_cv_ar_interface=unknown + fi + fi + rm -f conftest.lib libconftest.a + ]) + AC_LANG_POP([C])]) + +case $am_cv_ar_interface in +ar) + ;; +lib) + # Microsoft lib, so override with the ar-lib wrapper script. + # FIXME: It is wrong to rewrite AR. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__AR in this case, + # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something + # similar. + AR="$am_aux_dir/ar-lib $AR" + ;; +unknown) + m4_default([$1], + [AC_MSG_ERROR([could not determine $AR interface])]) + ;; +esac +AC_SUBST([AR])dnl +]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to +# '$srcdir', '$srcdir/..', or '$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is '.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ([2.52])dnl + m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + + +# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], + [$1], [CXX], [depcc="$CXX" am_compiler_list=], + [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], + [$1], [UPC], [depcc="$UPC" am_compiler_list=], + [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + am__universal=false + m4_case([$1], [CC], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac], + [CXX], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac]) + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES. +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE([dependency-tracking], [dnl +AS_HELP_STRING( + [--enable-dependency-tracking], + [do not reject slow dependency extractors]) +AS_HELP_STRING( + [--disable-dependency-tracking], + [speeds up one-time build])]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +AC_SUBST([am__nodep])dnl +_AM_SUBST_NOTMAKE([am__nodep])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[{ + # Older Autoconf quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + AS_CASE([$CONFIG_FILES], + [*\'*], [eval set x "$CONFIG_FILES"], + [*], [set x $CONFIG_FILES]) + shift + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf + do + # Strip MF so we end up with the name of the file. + am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`AS_DIRNAME(["$am_mf"])` + am_filepart=`AS_BASENAME(["$am_mf"])` + AM_RUN_LOG([cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles]) || am_rc=$? + done + if test $am_rc -ne 0; then + AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE="gmake" (or whatever is + necessary). You can also try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking).]) + fi + AS_UNSET([am_dirpart]) + AS_UNSET([am_filepart]) + AS_UNSET([am_mf]) + AS_UNSET([am_rc]) + rm -f conftest-deps.mk +} +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking is enabled. +# This creates each '.Po' and '.Plo' makefile fragment that we'll need in +# order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. +m4_define([AC_PROG_CC], +m4_defn([AC_PROG_CC]) +[_AM_PROG_CC_C_O +]) + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.65])dnl +m4_ifdef([_$0_ALREADY_INIT], + [m4_fatal([$0 expanded multiple times +]m4_defn([_$0_ALREADY_INIT]))], + [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[AC_DIAGNOSE([obsolete], + [$0: two- and three-arguments forms are deprecated.]) +m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if( + m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]), + [ok:ok],, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) + AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) +AM_MISSING_PROG([AUTOCONF], [autoconf]) +AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) +AM_MISSING_PROG([AUTOHEADER], [autoheader]) +AM_MISSING_PROG([MAKEINFO], [makeinfo]) +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +AC_SUBST([mkdir_p], ['$(MKDIR_P)']) +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES([CC])], + [m4_define([AC_PROG_CC], + m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES([CXX])], + [m4_define([AC_PROG_CXX], + m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES([OBJC])], + [m4_define([AC_PROG_OBJC], + m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], + [_AM_DEPENDENCIES([OBJCXX])], + [m4_define([AC_PROG_OBJCXX], + m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl +]) +# Variables for tags utilities; see am/tags.am +if test -z "$CTAGS"; then + CTAGS=ctags +fi +AC_SUBST([CTAGS]) +if test -z "$ETAGS"; then + ETAGS=etags +fi +AC_SUBST([ETAGS]) +if test -z "$CSCOPE"; then + CSCOPE=cscope +fi +AC_SUBST([CSCOPE]) + +AC_REQUIRE([AM_SILENT_RULES])dnl +dnl The testsuite driver may need to know about EXEEXT, so add the +dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This +dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_CONFIG_COMMANDS_PRE(dnl +[m4_provide_if([_AM_COMPILER_EXEEXT], + [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) + fi +fi +dnl The trailing newline in this macro's definition is deliberate, for +dnl backward compatibility and to allow trailing 'dnl'-style comments +dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. +]) + +dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further +dnl mangled by Autoconf and run in a shell conditional statement. +m4_define([_AC_COMPILER_EXEEXT], +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +if test x"${install_sh+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi +AC_SUBST([install_sh])]) + +# Copyright (C) 2003-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering + +# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_MAINTAINER_MODE([DEFAULT-MODE]) +# ---------------------------------- +# Control maintainer-specific portions of Makefiles. +# Default is to disable them, unless 'enable' is passed literally. +# For symmetry, 'disable' may be passed as well. Anyway, the user +# can override the default with the --enable/--disable switch. +AC_DEFUN([AM_MAINTAINER_MODE], +[m4_case(m4_default([$1], [disable]), + [enable], [m4_define([am_maintainer_other], [disable])], + [disable], [m4_define([am_maintainer_other], [enable])], + [m4_define([am_maintainer_other], [enable]) + m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) +AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + dnl maintainer-mode's default is 'disable' unless 'enable' is passed + AC_ARG_ENABLE([maintainer-mode], + [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], + am_maintainer_other[ make rules and dependencies not useful + (and sometimes confusing) to the casual installer])], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST([MAINT])dnl +] +) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_MAKE_INCLUDE() +# ----------------- +# Check whether make has an 'include' directive that can support all +# the idioms we need for our automatic dependency tracking code. +AC_DEFUN([AM_MAKE_INCLUDE], +[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) +cat > confinc.mk << 'END' +am__doit: + @echo this is the am__doit target >confinc.out +.PHONY: am__doit +END +am__include="#" +am__quote= +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) + AS_CASE([$?:`cat confinc.out 2>/dev/null`], + ['0:this is the am__doit target'], + [AS_CASE([$s], + [BSD], [am__include='.include' am__quote='"'], + [am__include='include' am__quote=''])]) + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +AC_MSG_RESULT([${_am_result}]) +AC_SUBST([am__include])]) +AC_SUBST([am__quote])]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it is modern enough. +# If it is, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +if test x"${MISSING+set}" != xset; then + MISSING="\${SHELL} '$am_aux_dir/missing'" +fi +# Use eval to expand $SHELL +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " +else + am_missing_run= + AC_MSG_WARN(['missing' script is too old or missing]) +fi +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# -------------------- +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) + +# _AM_SET_OPTIONS(OPTIONS) +# ------------------------ +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_PROG_CC_C_O +# --------------- +# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC +# to automatically call this. +AC_DEFUN([_AM_PROG_CC_C_O], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([compile])dnl +AC_LANG_PUSH([C])dnl +AC_CACHE_CHECK( + [whether $CC understands -c and -o together], + [am_cv_prog_cc_c_o], + [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i]) +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +AC_LANG_POP([C])]) + +# For backward compatibility. +AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) + +# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_RUN_LOG(COMMAND) +# ------------------- +# Run COMMAND, save the exit status in ac_status, and log it. +# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) +AC_DEFUN([AM_RUN_LOG], +[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD + ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + (exit $ac_status); }]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[[\\\"\#\$\&\'\`$am_lf]]*) + AC_MSG_ERROR([unsafe absolute working directory name]);; +esac +case $srcdir in + *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) + AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; +esac + +# Do 'set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken + alias in your environment]) + fi + if test "$[2]" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT([yes]) +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi +AC_CONFIG_COMMANDS_PRE( + [AC_MSG_CHECKING([that generated files are newer than configure]) + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + AC_MSG_RESULT([done])]) +rm -f conftest.file +]) + +# Copyright (C) 2009-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_SILENT_RULES([DEFAULT]) +# -------------------------- +# Enable less verbose build rules; with the default set to DEFAULT +# ("yes" being less verbose, "no" or empty being verbose). +AC_DEFUN([AM_SILENT_RULES], +[AC_ARG_ENABLE([silent-rules], [dnl +AS_HELP_STRING( + [--enable-silent-rules], + [less verbose build output (undo: "make V=1")]) +AS_HELP_STRING( + [--disable-silent-rules], + [verbose build output (undo: "make V=0")])dnl +]) +case $enable_silent_rules in @%:@ ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; +esac +dnl +dnl A few 'make' implementations (e.g., NonStop OS and NextStep) +dnl do not support nested variable expansions. +dnl See automake bug#9928 and bug#10237. +am_make=${MAKE-make} +AC_CACHE_CHECK([whether $am_make supports nested variables], + [am_cv_make_support_nested_variables], + [if AS_ECHO([['TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi]) +if test $am_cv_make_support_nested_variables = yes; then + dnl Using '$V' instead of '$(V)' breaks IRIX make. + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AC_SUBST([AM_V])dnl +AM_SUBST_NOTMAKE([AM_V])dnl +AC_SUBST([AM_DEFAULT_V])dnl +AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl +AC_SUBST([AM_DEFAULT_VERBOSITY])dnl +AM_BACKSLASH='\' +AC_SUBST([AM_BACKSLASH])dnl +_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl +]) + +# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor 'install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in "make install-strip", and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the 'STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# -------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004-2021 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of 'v7', 'ustar', or 'pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +# +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) + +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' + +m4_if([$1], [v7], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], + + [m4_case([$1], + [ustar], + [# The POSIX 1988 'ustar' format is defined with fixed-size fields. + # There is notably a 21 bits limit for the UID and the GID. In fact, + # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 + # and bug#13588). + am_max_uid=2097151 # 2^21 - 1 + am_max_gid=$am_max_uid + # The $UID and $GID variables are not portable, so we need to resort + # to the POSIX-mandated id(1) utility. Errors in the 'id' calls + # below are definitely unexpected, so allow the users to see them + # (that is, avoid stderr redirection). + am_uid=`id -u || echo unknown` + am_gid=`id -g || echo unknown` + AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) + if test $am_uid -le $am_max_uid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi + AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) + if test $am_gid -le $am_max_gid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi], + + [pax], + [], + + [m4_fatal([Unknown tar format])]) + + AC_MSG_CHECKING([how to create a $1 tar archive]) + + # Go ahead even if we have the value already cached. We do so because we + # need to set the values for the 'am__tar' and 'am__untar' variables. + _am_tools=${am_cv_prog_tar_$1-$_am_tools} + + for _am_tool in $_am_tools; do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works. + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi + done + rm -rf conftest.dir + + AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) + AC_MSG_RESULT([$am_cv_prog_tar_$1])]) + +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + diff --git a/thirdparty/jpeg-9e/ar-lib b/thirdparty/jpeg-9e/ar-lib new file mode 100755 index 0000000..c349042 --- /dev/null +++ b/thirdparty/jpeg-9e/ar-lib @@ -0,0 +1,271 @@ +#! /bin/sh +# Wrapper for Microsoft lib.exe + +me=ar-lib +scriptversion=2019-07-04.01; # UTC + +# Copyright (C) 2010-2021 Free Software Foundation, Inc. +# Written by Peter Rosin . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + + +# func_error message +func_error () +{ + echo "$me: $1" 1>&2 + exit 1 +} + +file_conv= + +# func_file_conv build_file +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN* | MSYS*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv in + mingw) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin | msys) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_at_file at_file operation archive +# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE +# for each of them. +# When interpreting the content of the @FILE, do NOT use func_file_conv, +# since the user would need to supply preconverted file names to +# binutils ar, at least for MinGW. +func_at_file () +{ + operation=$2 + archive=$3 + at_file_contents=`cat "$1"` + eval set x "$at_file_contents" + shift + + for member + do + $AR -NOLOGO $operation:"$member" "$archive" || exit $? + done +} + +case $1 in + '') + func_error "no command. Try '$0 --help' for more information." + ;; + -h | --h*) + cat < /* to declare isupper(), tolower() */ +#ifdef NEED_SIGNAL_CATCHER +#include /* to declare signal() */ +#endif +#ifdef USE_SETMODE +#include /* to declare setmode()'s parameter macros */ +/* If you have setmode() but not , just delete this line: */ +#include /* to declare setmode() */ +#endif + + +/* + * Signal catcher to ensure that temporary files are removed before aborting. + * NB: for Amiga Manx C this is actually a global routine named _abort(); + * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... + */ + +#ifdef NEED_SIGNAL_CATCHER + +static j_common_ptr sig_cinfo; + +void /* must be global for Manx C */ +signal_catcher (int signum) +{ + if (sig_cinfo != NULL) { + if (sig_cinfo->err != NULL) /* turn off trace output */ + sig_cinfo->err->trace_level = 0; + jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ + } + exit(EXIT_FAILURE); +} + + +GLOBAL(void) +enable_signal_catcher (j_common_ptr cinfo) +{ + sig_cinfo = cinfo; +#ifdef SIGINT /* not all systems have SIGINT */ + signal(SIGINT, signal_catcher); +#endif +#ifdef SIGTERM /* not all systems have SIGTERM */ + signal(SIGTERM, signal_catcher); +#endif +} + +#endif + + +/* + * Optional progress monitor: display a percent-done figure on stderr. + */ + +#ifdef PROGRESS_REPORT + +METHODDEF(void) +progress_monitor (j_common_ptr cinfo) +{ + cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; + int total_passes = prog->pub.total_passes + prog->total_extra_passes; + int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); + + if (percent_done != prog->percent_done) { + prog->percent_done = percent_done; + if (total_passes > 1) { + fprintf(stderr, "\rPass %d/%d: %3d%% ", + prog->pub.completed_passes + prog->completed_extra_passes + 1, + total_passes, percent_done); + } else { + fprintf(stderr, "\r %3d%% ", percent_done); + } + fflush(stderr); + } +} + + +GLOBAL(void) +start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress) +{ + /* Enable progress display, unless trace output is on */ + if (cinfo->err->trace_level == 0) { + progress->pub.progress_monitor = progress_monitor; + progress->completed_extra_passes = 0; + progress->total_extra_passes = 0; + progress->percent_done = -1; + cinfo->progress = &progress->pub; + } +} + + +GLOBAL(void) +end_progress_monitor (j_common_ptr cinfo) +{ + /* Clear away progress display */ + if (cinfo->err->trace_level == 0) { + fprintf(stderr, "\r \r"); + fflush(stderr); + } +} + +#endif + + +/* + * Case-insensitive matching of possibly-abbreviated keyword switches. + * keyword is the constant keyword (must be lower case already), + * minchars is length of minimum legal abbreviation. + */ + +GLOBAL(boolean) +keymatch (char * arg, const char * keyword, int minchars) +{ + register int ca, ck; + register int nmatched = 0; + + while ((ca = *arg++) != '\0') { + if ((ck = *keyword++) == '\0') + return FALSE; /* arg longer than keyword, no good */ + if (isupper(ca)) /* force arg to lcase (assume ck is already) */ + ca = tolower(ca); + if (ca != ck) + return FALSE; /* no good */ + nmatched++; /* count matched characters */ + } + /* reached end of argument; fail if it's too short for unique abbrev */ + if (nmatched < minchars) + return FALSE; + return TRUE; /* A-OK */ +} + + +/* + * Routines to establish binary I/O mode for stdin and stdout. + * Non-Unix systems often require some hacking to get out of text mode. + */ + +GLOBAL(FILE *) +read_stdin (void) +{ + FILE * input_file = stdin; + +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdin), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { + fprintf(stderr, "Cannot reopen stdin\n"); + exit(EXIT_FAILURE); + } +#endif + return input_file; +} + + +GLOBAL(FILE *) +write_stdout (void) +{ + FILE * output_file = stdout; + +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdout), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { + fprintf(stderr, "Cannot reopen stdout\n"); + exit(EXIT_FAILURE); + } +#endif + return output_file; +} diff --git a/thirdparty/jpeg-9e/cdjpeg.h b/thirdparty/jpeg-9e/cdjpeg.h new file mode 100644 index 0000000..524ab3a --- /dev/null +++ b/thirdparty/jpeg-9e/cdjpeg.h @@ -0,0 +1,189 @@ +/* + * cdjpeg.h + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * Modified 2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains common declarations for the sample applications + * cjpeg and djpeg. It is NOT used by the core JPEG library. + */ + +#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */ +#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jerror.h" /* get library error codes too */ +#include "cderror.h" /* get application-specific error codes */ + + +/* + * Object interface for cjpeg's source file decoding modules + */ + +typedef struct cjpeg_source_struct * cjpeg_source_ptr; + +struct cjpeg_source_struct { + JMETHOD(void, start_input, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); + JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); + JMETHOD(void, finish_input, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); + + FILE *input_file; + + JSAMPARRAY buffer; + JDIMENSION buffer_height; +}; + + +/* + * Object interface for djpeg's output file encoding modules + */ + +typedef struct djpeg_dest_struct * djpeg_dest_ptr; + +struct djpeg_dest_struct { + /* start_output is called after jpeg_start_decompress finishes. + * The color map will be ready at this time, if one is needed. + */ + JMETHOD(void, start_output, (j_decompress_ptr cinfo, + djpeg_dest_ptr dinfo)); + /* Emit the specified number of pixel rows from the buffer. */ + JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo, + djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied)); + /* Finish up at the end of the image. */ + JMETHOD(void, finish_output, (j_decompress_ptr cinfo, + djpeg_dest_ptr dinfo)); + + /* Target file spec; filled in by djpeg.c after object is created. */ + FILE * output_file; + + /* Output pixel-row buffer. Created by module init or start_output. + * Width is cinfo->output_width * cinfo->output_components; + * height is buffer_height. + */ + JSAMPARRAY buffer; + JDIMENSION buffer_height; +}; + + +/* + * cjpeg/djpeg may need to perform extra passes to convert to or from + * the source/destination file format. The JPEG library does not know + * about these passes, but we'd like them to be counted by the progress + * monitor. We use an expanded progress monitor object to hold the + * additional pass count. + */ + +struct cdjpeg_progress_mgr { + struct jpeg_progress_mgr pub; /* fields known to JPEG library */ + int completed_extra_passes; /* extra passes completed */ + int total_extra_passes; /* total extra */ + /* last printed percentage stored here to avoid multiple printouts */ + int percent_done; +}; + +typedef struct cdjpeg_progress_mgr * cd_progress_ptr; + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jinit_read_bmp jIRdBMP +#define jinit_write_bmp jIWrBMP +#define jinit_read_gif jIRdGIF +#define jinit_write_gif jIWrGIF +#define jinit_read_ppm jIRdPPM +#define jinit_write_ppm jIWrPPM +#define jinit_read_rle jIRdRLE +#define jinit_write_rle jIWrRLE +#define jinit_read_targa jIRdTarga +#define jinit_write_targa jIWrTarga +#define read_quant_tables RdQTables +#define read_scan_script RdScnScript +#define set_quality_ratings SetQRates +#define set_quant_slots SetQSlots +#define set_sample_factors SetSFacts +#define read_color_map RdCMap +#define enable_signal_catcher EnSigCatcher +#define start_progress_monitor StProgMon +#define end_progress_monitor EnProgMon +#define read_stdin RdStdin +#define write_stdout WrStdout +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + +/* Module selection routines for I/O modules. */ + +EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo, + boolean is_os2)); +EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo, + boolean is_lzw)); +EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo)); +EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo)); +EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo)); + +/* cjpeg support routines (in rdswitch.c) */ + +EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename, + boolean force_baseline)); +EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename)); +EXTERN(boolean) set_quality_ratings JPP((j_compress_ptr cinfo, char *arg, + boolean force_baseline)); +EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg)); +EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg)); + +/* djpeg support routines (in rdcolmap.c) */ + +EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile)); + +/* common support routines (in cdjpeg.c) */ + +EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo)); +EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo, + cd_progress_ptr progress)); +EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo)); +EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars)); +EXTERN(FILE *) read_stdin JPP((void)); +EXTERN(FILE *) write_stdout JPP((void)); + +/* miscellaneous useful macros */ + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#define WRITE_BINARY "w" +#else +#ifdef VMS /* VMS is very nonstandard */ +#define READ_BINARY "rb", "ctx=stm" +#define WRITE_BINARY "wb", "ctx=stm" +#else /* standard ANSI-compliant case */ +#define READ_BINARY "rb" +#define WRITE_BINARY "wb" +#endif +#endif + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif +#ifndef EXIT_SUCCESS +#ifdef VMS +#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ +#else +#define EXIT_SUCCESS 0 +#endif +#endif +#ifndef EXIT_WARNING +#ifdef VMS +#define EXIT_WARNING 1 /* VMS is very nonstandard */ +#else +#define EXIT_WARNING 2 +#endif +#endif diff --git a/thirdparty/jpeg-9e/change.log b/thirdparty/jpeg-9e/change.log new file mode 100644 index 0000000..7d45931 --- /dev/null +++ b/thirdparty/jpeg-9e/change.log @@ -0,0 +1,516 @@ +CHANGE LOG for Independent JPEG Group's JPEG software + + +Version 9e 16-Jan-2022 +----------------------- + +Include alternate user interface files for cjpeg/djpeg. + +jcparam.c: change default chrominance DC quantization factor +for lossless support. Note: Requires rebuild of test images. + +rdgif.c, cderror.h: add sanity check for GIF image dimensions. +Thank to Casper Sun for cjpeg potential vulnerability report. + +Add ARM and ARM64 platform support in the Visual Studio build. + + +Version 9d 12-Jan-2020 +----------------------- + +Optimize the optimal Huffman code table generation to produce +slightly smaller files. Thank to John Korejwa for suggestion. +Note: Requires rebuild of testimgp.jpg. + +Decoding Huffman: Use default tables if tables are not defined. +Thank to Simone Azzalin for report (Motion JPEG), +and to Martin Strunz for hint. + +Add sanity check in optimal Huffman code table generation. +Thank to Adam Farley for suggestion. + +rdtarga.c: use read_byte(), with EOF check, instead of getc() +in read_*_pixel(). +Thank to Chijin Zhou for cjpeg potential vulnerability report. + +jmemnobs.c: respect the max_memory_to_use setting in +jpeg_mem_available() computation. Thank to Sheng Shu and +Dongdong She for djpeg potential vulnerability report. + +jdarith.c, jdhuff.c: avoid left shift of negative value +compiler warning in decode_mcu_AC_refine(). +Thank to Indu Bhagat for suggestion. + +Add x64 (64-bit) platform support, avoid compiler warnings. +Thank to Jonathan Potter, Feiyun Wang, and Sheng Shu for suggestion. + +Adjust libjpeg version specification for pkg-config file. +Thank to Chen Chen for suggestion. + +Restore GIF read and write support from libjpeg version 6a. +Thank to Wolfgang Werner (W.W.) Heinz for suggestion. + +Improve consistency in raw (downsampled) image data processing mode. +Thank to Zhongyuan Zhou for hint. + +Avoid out of bounds array read (AC derived table pointers) +in start pass in jdhuff.c. Thank to Peng Li for report. + +Improve code sanity (jdhuff.c). +Thank to Reza Mirzazade farkhani for reports. + +Add jpegtran -drop option; add options to the crop extension and wipe +to fill the extra area with content from the source image region, +instead of gray out. + + +Version 9c 14-Jan-2018 +----------------------- + +jpegtran: add an option to the -wipe switch to fill the region +with the average of adjacent blocks, instead of gray out. +Thank to Caitlyn Feddock and Maddie Ziegler for inspiration. + +Make range extension bits adjustable (in jpegint.h). +Thank to Robin Watts for suggestion. + +Provide macros for fflush() and ferror() in jinclude.h in order +to facilitate adaption by applications using an own FILE class. +Thank to Gerhard Huber for suggestion. + +Add libjpeg pkg-config file. Thank to Mark Lavi, Vincent Torri, +Patrick McMunn, and Huw Davies for suggestion. + +Add sanity checks in cjpeg image reader modules. +Thank to Bingchang, Liu for reports. + + +Version 9b 17-Jan-2016 +----------------------- + +Improvements and optimizations in DCT and color calculations. +Normalize range limit array composition and access pattern. +Thank to Sia Furler and Maddie Ziegler for inspiration. + +Use merged upsample with scaled DCT sizes larger than 8. +Thank to Taylor Hatala for inspiration. + +Check for excessive comment lengths in argument parsing in wrjpgcom.c. +Thank to Julian Cohen for hint. + +Add makefile.b32 for use with Borland C++ 32-bit (bcc32). +Thank to Joe Slater for contribution. + +Document 'f' specifier for jpegtran -crop specification. +Thank to Michele Martone for suggestion. + +Use defined value from header instead of hardwired number in rdswitch.c. +Thank to Robert Sprowson for hint. + + +Version 9a 19-Jan-2014 +----------------------- + +Add support for wide gamut color spaces (JFIF version 2). +Improve clarity and accuracy in color conversion modules. +Note: Requires rebuild of test images. + +Extend the bit depth support to all values from 8 to 12 +(BITS_IN_JSAMPLE configuration option in jmorecfg.h). +jpegtran now supports N bits sample data precision with all N from 8 to 12 +in a single instance. Thank to Roland Fassauer for inspiration. + +Try to resolve issues with new boolean type definition. +Thank also to v4hn for suggestion. + +Enable option to use default Huffman tables for lossless compression +(for hardware solution), and in this case improve lossless RGB compression +with reversible color transform. Thank to Benny Alexandar for hint. + +Extend the entropy decoding structure, so that extraneous bytes between +compressed scan data and following marker can be reported correctly. +Thank to Nigel Tao for hint. + +Add jpegtran -wipe option and extension for -crop. +Thank to Andrew Senior, David Clunie, and Josef Schmid for suggestion. + + +Version 9 13-Jan-2013 +---------------------- + +Add cjpeg -rgb1 option to create an RGB JPEG file, and insert +a simple reversible color transform into the processing which +significantly improves the compression. +The recommended command for lossless coding of RGB images is now +cjpeg -rgb1 -block 1 -arithmetic. +As said, this option improves the compression significantly, but +the files are not compatible with JPEG decoders prior to IJG v9 +due to the included color transform. +The used color transform and marker signaling is compatible with +other JPEG standards (e.g., JPEG-LS part 2). + +Remove the automatic de-ANSI-fication support (Automake 1.12). +Thank also to Nitin A Kamble for suggestion. + +Add remark for jpeg_mem_dest() in jdatadst.c. +Thank to Elie-Gregoire Khoury for the hint. + +Support files with invalid component identifiers (created +by Adobe PDF). Thank to Robin Watts for the suggestion. + +Adapt full buffer case in jcmainct.c for use with scaled DCT. +Thank to Sergii Biloshytskyi for the suggestion. + +Add type identifier for declaration of noreturn functions. +Thank to Brett L. Moore for the suggestion. + +Correct argument type in format string, avoid compiler warnings. +Thank to Vincent Torri for hint. + +Add missing #include directives in configuration checks, avoid +configuration errors. Thank to John Spencer for the hint. + + +Version 8d 15-Jan-2012 +----------------------- + +Add cjpeg -rgb option to create RGB JPEG files. +Using this switch suppresses the conversion from RGB +colorspace input to the default YCbCr JPEG colorspace. +This feature allows true lossless JPEG coding of RGB color images. +The recommended command for this purpose is currently +cjpeg -rgb -block 1 -arithmetic. +SmartScale capable decoder (introduced with IJG JPEG 8) required. +Thank to Michael Koch for the initial suggestion. + +Add option to disable the region adjustment in the transupp crop code. +Thank to Jeffrey Friedl for the suggestion. + +Thank to Richard Jones and Edd Dawson for various minor corrections. + +Thank to Akim Demaille for configure.ac cleanup. + + +Version 8c 16-Jan-2011 +----------------------- + +Add option to compression library and cjpeg (-block N) to use +different DCT block size. +All N from 1 to 16 are possible. Default is 8 (baseline format). +Larger values produce higher compression, +smaller values produce higher quality. +SmartScale capable decoder (introduced with IJG JPEG 8) required. + + +Version 8b 16-May-2010 +----------------------- + +Repair problem in new memory source manager with corrupt JPEG data. +Thank to Ted Campbell and Samuel Chun for the report. + +Repair problem in Makefile.am test target. +Thank to anonymous user for the report. + +Support MinGW installation with automatic configure. +Thank to Volker Grabsch for the suggestion. + + +Version 8a 28-Feb-2010 +----------------------- + +Writing tables-only datastreams via jpeg_write_tables works again. + +Support 32-bit BMPs (RGB image with Alpha channel) for read in cjpeg. +Thank to Brett Blackham for the suggestion. + +Improve accuracy in floating point IDCT calculation. +Thank to Robert Hooke for the hint. + + +Version 8 10-Jan-2010 +---------------------- + +jpegtran now supports the same -scale option as djpeg for "lossless" resize. +An implementation of the JPEG SmartScale extension is required for this +feature. A (draft) specification of the JPEG SmartScale extension is +available as a contributed document at ITU and ISO. Revision 2 or later +of the document is required (latest document version is Revision 3). +The SmartScale extension will enable more features beside lossless resize +in future implementations, as described in the document (new compression +options). + +Add sanity check in BMP reader module to avoid cjpeg crash for empty input +image (thank to Isaev Ildar of ISP RAS, Moscow, RU for reporting this error). + +Add data source and destination managers for read from and write to +memory buffers. New API functions jpeg_mem_src and jpeg_mem_dest. +Thank to Roberto Boni from Italy for the suggestion. + + +Version 7 27-Jun-2009 +---------------------- + +New scaled DCTs implemented. +djpeg now supports scalings N/8 with all N from 1 to 16. +cjpeg now supports scalings 8/N with all N from 1 to 16. +Scaled DCTs with size larger than 8 are now also used for resolving the +common 2x2 chroma subsampling case without additional spatial resampling. +Separate spatial resampling for those kind of files is now only necessary +for N>8 scaling cases. +Furthermore, separate scaled DCT functions are provided for direct resolving +of the common asymmetric subsampling cases (2x1 and 1x2) without additional +spatial resampling. + +cjpeg -quality option has been extended for support of separate quality +settings for luminance and chrominance (or in general, for every provided +quantization table slot). +New API function jpeg_default_qtables() and q_scale_factor array in library. + +Added -nosmooth option to cjpeg, complementary to djpeg. +New variable "do_fancy_downsampling" in library, complement to fancy +upsampling. Fancy upsampling now uses direct DCT scaling with sizes +larger than 8. The old method is not reversible and has been removed. + +Support arithmetic entropy encoding and decoding. +Added files jaricom.c, jcarith.c, jdarith.c. + +Straighten the file structure: +Removed files jidctred.c, jcphuff.c, jchuff.h, jdphuff.c, jdhuff.h. + +jpegtran has a new "lossless" cropping feature. + +Implement -perfect option in jpegtran, new API function +jtransform_perfect_transform() in transupp. (DP 204_perfect.dpatch) + +Better error messages for jpegtran fopen failure. +(DP 203_jpegtran_errmsg.dpatch) + +Fix byte order issue with 16bit PPM/PGM files in rdppm.c/wrppm.c: +according to Netpbm, the de facto standard implementation of the PNM formats, +the most significant byte is first. (DP 203_rdppm.dpatch) + +Add -raw option to rdjpgcom not to mangle the output. +(DP 205_rdjpgcom_raw.dpatch) + +Make rdjpgcom locale aware. (DP 201_rdjpgcom_locale.dpatch) + +Add extern "C" to jpeglib.h. +This avoids the need to put extern "C" { ... } around #include "jpeglib.h" +in your C++ application. Defining the symbol DONT_USE_EXTERN_C in the +configuration prevents this. (DP 202_jpeglib.h_c++.dpatch) + + +Version 6b 27-Mar-1998 +----------------------- + +jpegtran has new features for lossless image transformations (rotation +and flipping) as well as "lossless" reduction to grayscale. + +jpegtran now copies comments by default; it has a -copy switch to enable +copying all APPn blocks as well, or to suppress comments. (Formerly it +always suppressed comments and APPn blocks.) jpegtran now also preserves +JFIF version and resolution information. + +New decompressor library feature: COM and APPn markers found in the input +file can be saved in memory for later use by the application. (Before, +you had to code this up yourself with a custom marker processor.) + +There is an unused field "void * client_data" now in compress and decompress +parameter structs; this may be useful in some applications. + +JFIF version number information is now saved by the decoder and accepted by +the encoder. jpegtran uses this to copy the source file's version number, +to ensure "jpegtran -copy all" won't create bogus files that contain JFXX +extensions but claim to be version 1.01. Applications that generate their +own JFXX extension markers also (finally) have a supported way to cause the +encoder to emit JFIF version number 1.02. + +djpeg's trace mode reports JFIF 1.02 thumbnail images as such, rather +than as unknown APP0 markers. + +In -verbose mode, djpeg and rdjpgcom will try to print the contents of +APP12 markers as text. Some digital cameras store useful text information +in APP12 markers. + +Handling of truncated data streams is more robust: blocks beyond the one in +which the error occurs will be output as uniform gray, or left unchanged +if decoding a progressive JPEG. The appearance no longer depends on the +Huffman tables being used. + +Huffman tables are checked for validity much more carefully than before. + +To avoid the Unisys LZW patent, djpeg's GIF output capability has been +changed to produce "uncompressed GIFs", and cjpeg's GIF input capability +has been removed altogether. We're not happy about it either, but there +seems to be no good alternative. + +The configure script now supports building libjpeg as a shared library +on many flavors of Unix (all the ones that GNU libtool knows how to +build shared libraries for). Use "./configure --enable-shared" to +try this out. + +New jconfig file and makefiles for Microsoft Visual C++ and Developer Studio. +Also, a jconfig file and a build script for Metrowerks CodeWarrior +on Apple Macintosh. makefile.dj has been updated for DJGPP v2, and there +are miscellaneous other minor improvements in the makefiles. + +jmemmac.c now knows how to create temporary files following Mac System 7 +conventions. + +djpeg's -map switch is now able to read raw-format PPM files reliably. + +cjpeg -progressive -restart no longer generates any unnecessary DRI markers. + +Multiple calls to jpeg_simple_progression for a single JPEG object +no longer leak memory. + + +Version 6a 7-Feb-96 +-------------------- + +Library initialization sequence modified to detect version mismatches +and struct field packing mismatches between library and calling application. +This change requires applications to be recompiled, but does not require +any application source code change. + +All routine declarations changed to the style "GLOBAL(type) name ...", +that is, GLOBAL, LOCAL, METHODDEF, EXTERN are now macros taking the +routine's return type as an argument. This makes it possible to add +Microsoft-style linkage keywords to all the routines by changing just +these macros. Note that any application code that was using these macros +will have to be changed. + +DCT coefficient quantization tables are now stored in normal array order +rather than zigzag order. Application code that calls jpeg_add_quant_table, +or otherwise manipulates quantization tables directly, will need to be +changed. If you need to make such code work with either older or newer +versions of the library, a test like "#if JPEG_LIB_VERSION >= 61" is +recommended. + +djpeg's trace capability now dumps DQT tables in natural order, not zigzag +order. This allows the trace output to be made into a "-qtables" file +more easily. + +New system-dependent memory manager module for use on Apple Macintosh. + +Fix bug in cjpeg's -smooth option: last one or two scanlines would be +duplicates of the prior line unless the image height mod 16 was 1 or 2. + +Repair minor problems in VMS, BCC, MC6 makefiles. + +New configure script based on latest GNU Autoconf. + +Correct the list of include files needed by MetroWerks C for ccommand(). + +Numerous small documentation updates. + + +Version 6 2-Aug-95 +------------------- + +Progressive JPEG support: library can read and write full progressive JPEG +files. A "buffered image" mode supports incremental decoding for on-the-fly +display of progressive images. Simply recompiling an existing IJG-v5-based +decoder with v6 should allow it to read progressive files, though of course +without any special progressive display. + +New "jpegtran" application performs lossless transcoding between different +JPEG formats; primarily, it can be used to convert baseline to progressive +JPEG and vice versa. In support of jpegtran, the library now allows lossless +reading and writing of JPEG files as DCT coefficient arrays. This ability +may be of use in other applications. + +Notes for programmers: +* We changed jpeg_start_decompress() to be able to suspend; this makes all +decoding modes available to suspending-input applications. However, +existing applications that use suspending input will need to be changed +to check the return value from jpeg_start_decompress(). You don't need to +do anything if you don't use a suspending data source. +* We changed the interface to the virtual array routines: access_virt_array +routines now take a count of the number of rows to access this time. The +last parameter to request_virt_array routines is now interpreted as the +maximum number of rows that may be accessed at once, but not necessarily +the height of every access. + + +Version 5b 15-Mar-95 +--------------------- + +Correct bugs with grayscale images having v_samp_factor > 1. + +jpeg_write_raw_data() now supports output suspension. + +Correct bugs in "configure" script for case of compiling in +a directory other than the one containing the source files. + +Repair bug in jquant1.c: sometimes didn't use as many colors as it could. + +Borland C makefile and jconfig file work under either MS-DOS or OS/2. + +Miscellaneous improvements to documentation. + + +Version 5a 7-Dec-94 +-------------------- + +Changed color conversion roundoff behavior so that grayscale values are +represented exactly. (This causes test image files to change.) + +Make ordered dither use 16x16 instead of 4x4 pattern for a small quality +improvement. + +New configure script based on latest GNU Autoconf. +Fix configure script to handle CFLAGS correctly. +Rename *.auto files to *.cfg, so that configure script still works if +file names have been truncated for DOS. + +Fix bug in rdbmp.c: didn't allow for extra data between header and image. + +Modify rdppm.c/wrppm.c to handle 2-byte raw PPM/PGM formats for 12-bit data. + +Fix several bugs in rdrle.c. + +NEED_SHORT_EXTERNAL_NAMES option was broken. + +Revise jerror.h/jerror.c for more flexibility in message table. + +Repair oversight in jmemname.c NO_MKTEMP case: file could be there +but unreadable. + + +Version 5 24-Sep-94 +-------------------- + +Version 5 represents a nearly complete redesign and rewrite of the IJG +software. Major user-visible changes include: + * Automatic configuration simplifies installation for most Unix systems. + * A range of speed vs. image quality tradeoffs are supported. + This includes resizing of an image during decompression: scaling down + by a factor of 1/2, 1/4, or 1/8 is handled very efficiently. + * New programs rdjpgcom and wrjpgcom allow insertion and extraction + of text comments in a JPEG file. + +The application programmer's interface to the library has changed completely. +Notable improvements include: + * We have eliminated the use of callback routines for handling the + uncompressed image data. The application now sees the library as a + set of routines that it calls to read or write image data on a + scanline-by-scanline basis. + * The application image data is represented in a conventional interleaved- + pixel format, rather than as a separate array for each color channel. + This can save a copying step in many programs. + * The handling of compressed data has been cleaned up: the application can + supply routines to source or sink the compressed data. It is possible to + suspend processing on source/sink buffer overrun, although this is not + supported in all operating modes. + * All static state has been eliminated from the library, so that multiple + instances of compression or decompression can be active concurrently. + * JPEG abbreviated datastream formats are supported, ie, quantization and + Huffman tables can be stored separately from the image data. + * And not only that, but the documentation of the library has improved + considerably! + + +The last widely used release before the version 5 rewrite was version 4A of +18-Feb-93. Change logs before that point have been discarded, since they +are not of much interest after the rewrite. diff --git a/thirdparty/jpeg-9e/cjpeg.1 b/thirdparty/jpeg-9e/cjpeg.1 new file mode 100644 index 0000000..355d340 --- /dev/null +++ b/thirdparty/jpeg-9e/cjpeg.1 @@ -0,0 +1,384 @@ +.TH CJPEG 1 "28 April 2019" +.SH NAME +cjpeg \- compress an image file to a JPEG file +.SH SYNOPSIS +.B cjpeg +[ +.I options +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B cjpeg +compresses the named image file, or the standard input if no file is +named, and produces a JPEG/JFIF file on the standard output. +The currently supported input file formats are: PPM (PBMPLUS color +format), PGM (PBMPLUS grayscale format), BMP, GIF, Targa, and RLE (Utah Raster +Toolkit format). (RLE is supported only if the URT library is available, +which it isn't on most non-Unix systems.) +.SH OPTIONS +All switch names may be abbreviated; for example, +.B \-grayscale +may be written +.B \-gray +or +.BR \-gr . +Most of the "basic" switches can be abbreviated to as little as one letter. +Upper and lower case are equivalent (thus +.B \-BMP +is the same as +.BR \-bmp ). +British spellings are also accepted (e.g., +.BR \-greyscale ), +though for brevity these are not mentioned below. +.PP +The basic switches are: +.TP +.BI \-quality " N[,...]" +Scale quantization tables to adjust image quality. Quality is 0 (worst) to +100 (best); default is 75. (See below for more info.) +.TP +.B \-grayscale +Create monochrome JPEG file from color input. Be sure to use this switch when +compressing a grayscale BMP or GIF file, because +.B cjpeg +isn't bright enough to notice whether a BMP or GIF file uses only shades of +gray. By saying +.BR \-grayscale , +you'll get a smaller JPEG file that takes less time to process. +.TP +.B \-rgb +Create RGB JPEG file. +Using this switch suppresses the conversion from RGB +colorspace input to the default YCbCr JPEG colorspace. +You can use this switch in combination with the +.BI \-block " N" +switch (see below) for lossless JPEG coding. +See also the +.B \-rgb1 +switch below. +.TP +.B \-optimize +Perform optimization of entropy encoding parameters. Without this, default +encoding parameters are used. +.B \-optimize +usually makes the JPEG file a little smaller, but +.B cjpeg +runs somewhat slower and needs much more memory. Image quality and speed of +decompression are unaffected by +.BR \-optimize . +.TP +.B \-progressive +Create progressive JPEG file (see below). +.TP +.BI \-scale " M/N" +Scale the output image by a factor M/N. Currently supported scale factors are +M/N with all N from 1 to 16, where M is the destination DCT size, which is 8 +by default (see +.BI \-block " N" +switch below). +.TP +.B \-targa +Input file is Targa format. Targa files that contain an "identification" +field will not be automatically recognized by +.BR cjpeg ; +for such files you must specify +.B \-targa +to make +.B cjpeg +treat the input as Targa format. +For most Targa files, you won't need this switch. +.PP +The +.B \-quality +switch lets you trade off compressed file size against quality of the +reconstructed image: the higher the quality setting, the larger the JPEG file, +and the closer the output image will be to the original input. Normally you +want to use the lowest quality setting (smallest file) that decompresses into +something visually indistinguishable from the original image. For this +purpose the quality setting should be between 50 and 95; the default of 75 is +often about right. If you see defects at +.B \-quality +75, then go up 5 or 10 counts at a time until you are happy with the output +image. (The optimal setting will vary from one image to another.) +.PP +.B \-quality +100 will generate a quantization table of all 1's, minimizing loss in the +quantization step (but there is still information loss in subsampling, as well +as roundoff error). This setting is mainly of interest for experimental +purposes. Quality values above about 95 are +.B not +recommended for normal use; the compressed file size goes up dramatically for +hardly any gain in output image quality. +.PP +In the other direction, quality values below 50 will produce very small files +of low image quality. Settings around 5 to 10 might be useful in preparing an +index of a large image library, for example. Try +.B \-quality +2 (or so) for some amusing Cubist effects. (Note: quality +values below about 25 generate 2-byte quantization tables, which are +considered optional in the JPEG standard. +.B cjpeg +emits a warning message when you give such a quality value, because some +other JPEG programs may be unable to decode the resulting file. Use +.B \-baseline +if you need to ensure compatibility at low quality values.) +.PP +The +.B \-quality +option has been extended in IJG version 7 for support of separate quality +settings for luminance and chrominance (or in general, for every provided +quantization table slot). This feature is useful for high-quality +applications which cannot accept the damage of color data by coarse +subsampling settings. You can now easily reduce the color data amount more +smoothly with finer control without separate subsampling. The resulting file +is fully compliant with standard JPEG decoders. +Note that the +.B \-quality +ratings refer to the quantization table slots, and that the last value is +replicated if there are more q-table slots than parameters. The default +q-table slots are 0 for luminance and 1 for chrominance with default tables as +given in the JPEG standard. This is compatible with the old behaviour in case +that only one parameter is given, which is then used for both luminance and +chrominance (slots 0 and 1). More or custom quantization tables can be set +with +.B \-qtables +and assigned to components with +.B \-qslots +parameter (see the "wizard" switches below). +.B Caution: +You must explicitly add +.BI \-sample " 1x1" +for efficient separate color +quality selection, since the default value used by library is 2x2! +.PP +The +.B \-progressive +switch creates a "progressive JPEG" file. In this type of JPEG file, the data +is stored in multiple scans of increasing quality. If the file is being +transmitted over a slow communications link, the decoder can use the first +scan to display a low-quality image very quickly, and can then improve the +display with each subsequent scan. The final image is exactly equivalent to a +standard JPEG file of the same quality setting, and the total file size is +about the same --- often a little smaller. +.PP +Switches for advanced users: +.TP +.B \-arithmetic +Use arithmetic coding. +.B Caution: +arithmetic coded JPEG is not yet widely implemented, so many decoders will +be unable to view an arithmetic coded JPEG file at all. +.TP +.BI \-block " N" +Set DCT block size. All N from 1 to 16 are possible. +Default is 8 (baseline format). +Larger values produce higher compression, +smaller values produce higher quality +(exact DCT stage possible with 1 or 2; with the default quality of 75 and +default Luminance qtable the DCT+Quantization stage is lossless for N=1). +.B Caution: +An implementation of the JPEG SmartScale extension is required for this +feature. SmartScale enabled JPEG is not yet widely implemented, so many +decoders will be unable to view a SmartScale extended JPEG file at all. +.TP +.B \-rgb1 +Create RGB JPEG file with reversible color transform. +Works like the +.B \-rgb +switch (see above) and inserts a simple reversible color transform +into the processing which significantly improves the compression. +Use this switch in combination with the +.BI \-block " N" +switch (see above) for lossless JPEG coding. +.B Caution: +A decoder with inverse color transform support is required for +this feature. Reversible color transform support is not yet +widely implemented, so many decoders will be unable to view +a reversible color transformed JPEG file at all. +.TP +.B \-bgycc +Create big gamut YCC JPEG file. +In this type of encoding the color difference components are quantized +further by a factor of 2 compared to the normal Cb/Cr values, thus creating +space to allow larger color values with higher saturation than the normal +gamut limits to be encoded. In order to compensate for the loss of color +fidelity compared to a normal YCC encoded file, the color quantization +tables can be adjusted accordingly. For example, +.B cjpeg \-bgycc \-quality +80,90 will give similar results as +.B cjpeg \-quality +80. +.B Caution: +For correct decompression a decoder with big gamut YCC support (JFIF +version 2) is required. An old decoder may or may not display a big +gamut YCC encoded JPEG file, depending on JFIF version check and +corresponding warning/error configuration. In case of a granted +decompression the old decoder will display the image with half +saturated colors. +.TP +.B \-dct int +Use integer DCT method (default). +.TP +.B \-dct fast +Use fast integer DCT (less accurate). +.TP +.B \-dct float +Use floating-point DCT method. +The float method is very slightly more accurate than the int method, but is +much slower unless your machine has very fast floating-point hardware. Also +note that results of the floating-point method may vary slightly across +machines, while the integer methods should give the same results everywhere. +The fast integer method is much less accurate than the other two. +.TP +.B \-nosmooth +Don't use high-quality downsampling. +.TP +.BI \-restart " N" +Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is +attached to the number. +.B \-restart 0 +(the default) means no restart markers. +.TP +.BI \-smooth " N" +Smooth the input image to eliminate dithering noise. N, ranging from 1 to +100, indicates the strength of smoothing. 0 (the default) means no smoothing. +.TP +.BI \-maxmemory " N" +Set limit for amount of memory to use in processing large images. Value is +in thousands of bytes, or millions of bytes if "M" is attached to the +number. For example, +.B \-max 4m +selects 4000000 bytes. If more space is needed, temporary files will be used. +.TP +.BI \-outfile " name" +Send output image to the named file, not to standard output. +.TP +.B \-verbose +Enable debug printout. More +.BR \-v 's +give more output. Also, version information is printed at startup. +.TP +.B \-debug +Same as +.BR \-verbose . +.PP +The +.B \-restart +option inserts extra markers that allow a JPEG decoder to resynchronize after +a transmission error. Without restart markers, any damage to a compressed +file will usually ruin the image from the point of the error to the end of the +image; with restart markers, the damage is usually confined to the portion of +the image up to the next restart marker. Of course, the restart markers +occupy extra space. We recommend +.B \-restart 1 +for images that will be transmitted across unreliable networks such as Usenet. +.PP +The +.B \-smooth +option filters the input to eliminate fine-scale noise. This is often useful +when converting dithered images to JPEG: a moderate smoothing factor of 10 to +50 gets rid of dithering patterns in the input file, resulting in a smaller +JPEG file and a better-looking image. Too large a smoothing factor will +visibly blur the image, however. +.PP +Switches for wizards: +.TP +.B \-baseline +Force baseline-compatible quantization tables to be generated. This clamps +quantization values to 8 bits even at low quality settings. (This switch is +poorly named, since it does not ensure that the output is actually baseline +JPEG. For example, you can use +.B \-baseline +and +.B \-progressive +together.) +.TP +.BI \-qtables " file" +Use the quantization tables given in the specified text file. +.TP +.BI \-qslots " N[,...]" +Select which quantization table to use for each color component. +.TP +.BI \-sample " HxV[,...]" +Set JPEG sampling factors for each color component. +.TP +.BI \-scans " file" +Use the scan script given in the specified text file. +.PP +The "wizard" switches are intended for experimentation with JPEG. If you +don't know what you are doing, \fBdon't use them\fR. These switches are +documented further in the file wizard.txt. +.SH EXAMPLES +.LP +This example compresses the PPM file foo.ppm with a quality factor of +60 and saves the output as foo.jpg: +.IP +.B cjpeg \-quality +.I 60 foo.ppm +.B > +.I foo.jpg +.SH HINTS +Color GIF files are not the ideal input for JPEG; JPEG is really intended for +compressing full-color (24-bit) images. In particular, don't try to convert +cartoons, line drawings, and other images that have only a few distinct +colors. GIF works great on these, JPEG does not. If you want to convert a +GIF to JPEG, you should experiment with +.BR cjpeg 's +.B \-quality +and +.B \-smooth +options to get a satisfactory conversion. +.B \-smooth 10 +or so is often helpful. +.PP +Avoid running an image through a series of JPEG compression/decompression +cycles. Image quality loss will accumulate; after ten or so cycles the image +may be noticeably worse than it was after one cycle. It's best to use a +lossless format while manipulating an image, then convert to JPEG format when +you are ready to file the image away. +.PP +The +.B \-optimize +option to +.B cjpeg +is worth using when you are making a "final" version for posting or archiving. +It's also a win when you are using low quality settings to make very small +JPEG files; the percentage improvement is often a lot more than it is on +larger files. (At present, +.B \-optimize +mode is always selected when generating progressive JPEG files.) +.SH ENVIRONMENT +.TP +.B JPEGMEM +If this environment variable is set, its value is the default memory limit. +The value is specified as described for the +.B \-maxmemory +switch. +.B JPEGMEM +overrides the default value specified when the program was compiled, and +itself is overridden by an explicit +.BR \-maxmemory . +.SH SEE ALSO +.BR djpeg (1), +.BR jpegtran (1), +.BR rdjpgcom (1), +.BR wrjpgcom (1) +.br +.BR ppm (5), +.BR pgm (5) +.br +Wallace, Gregory K. "The JPEG Still Picture Compression Standard", +Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. +.SH AUTHOR +Independent JPEG Group +.SH BUGS +Not all variants of BMP and Targa file formats are supported. +.PP +The +.B \-targa +switch is not a bug, it's a feature. (It would be a bug if the Targa format +designers had not been clueless.) diff --git a/thirdparty/jpeg-9e/cjpeg.c b/thirdparty/jpeg-9e/cjpeg.c new file mode 100644 index 0000000..3cb07fa --- /dev/null +++ b/thirdparty/jpeg-9e/cjpeg.c @@ -0,0 +1,664 @@ +/* + * cjpeg.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * Modified 2003-2013 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a command-line user interface for the JPEG compressor. + * It should work on any system with Unix- or MS-DOS-style command lines. + * + * Two different command line styles are permitted, depending on the + * compile-time switch TWO_FILE_COMMANDLINE: + * cjpeg [options] inputfile outputfile + * cjpeg [options] [inputfile] + * In the second style, output is always to standard output, which you'd + * normally redirect to a file or pipe to some other program. Input is + * either from a named file or from standard input (typically redirected). + * The second style is convenient on Unix but is unhelpful on systems that + * don't support pipes. Also, you MUST use the first style if your system + * doesn't do binary I/O to stdin/stdout. + * To simplify script writing, the "-outfile" switch is provided. The syntax + * cjpeg [options] -outfile outputfile inputfile + * works regardless of which command line style is used. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "jversion.h" /* for version message */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + + +/* Create the add-on message string table. */ + +#define JMESSAGE(code,string) string , + +static const char * const cdjpeg_message_table[] = { +#include "cderror.h" + NULL +}; + + +/* + * This routine determines what format the input file is, + * and selects the appropriate input-reading module. + * + * To determine which family of input formats the file belongs to, + * we may look only at the first byte of the file, since C does not + * guarantee that more than one character can be pushed back with ungetc. + * Looking at additional bytes would require one of these approaches: + * 1) assume we can fseek() the input file (fails for piped input); + * 2) assume we can push back more than one character (works in + * some C implementations, but unportable); + * 3) provide our own buffering (breaks input readers that want to use + * stdio directly, such as the RLE library); + * or 4) don't put back the data, and modify the input_init methods to assume + * they start reading after the start of file (also breaks RLE library). + * #1 is attractive for MS-DOS but is untenable on Unix. + * + * The most portable solution for file types that can't be identified by their + * first byte is to make the user tell us what they are. This is also the + * only approach for "raw" file types that contain only arbitrary values. + * We presently apply this method for Targa files. Most of the time Targa + * files start with 0x00, so we recognize that case. Potentially, however, + * a Targa file could start with any byte value (byte 0 is the length of the + * seldom-used ID field), so we provide a switch to force Targa input mode. + */ + +static boolean is_targa; /* records user -targa switch */ + + +LOCAL(cjpeg_source_ptr) +select_file_type (j_compress_ptr cinfo, FILE * infile) +{ + int c; + + if (is_targa) { +#ifdef TARGA_SUPPORTED + return jinit_read_targa(cinfo); +#else + ERREXIT(cinfo, JERR_TGA_NOTCOMP); +#endif + } + + if ((c = getc(infile)) == EOF) + ERREXIT(cinfo, JERR_INPUT_EMPTY); + if (ungetc(c, infile) == EOF) + ERREXIT(cinfo, JERR_UNGETC_FAILED); + + switch (c) { +#ifdef BMP_SUPPORTED + case 'B': + return jinit_read_bmp(cinfo); +#endif +#ifdef GIF_SUPPORTED + case 'G': + return jinit_read_gif(cinfo); +#endif +#ifdef PPM_SUPPORTED + case 'P': + return jinit_read_ppm(cinfo); +#endif +#ifdef RLE_SUPPORTED + case 'R': + return jinit_read_rle(cinfo); +#endif +#ifdef TARGA_SUPPORTED + case 0x00: + return jinit_read_targa(cinfo); +#endif + default: + ERREXIT(cinfo, JERR_UNKNOWN_FORMAT); + break; + } + + return NULL; /* suppress compiler warnings */ +} + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + * The main program in this file doesn't actually use this capability... + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -quality N[,...] Compression quality (0..100; 5-95 is useful range)\n"); + fprintf(stderr, " -grayscale Create monochrome JPEG file\n"); + fprintf(stderr, " -rgb Create RGB JPEG file\n"); +#ifdef ENTROPY_OPT_SUPPORTED + fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); +#endif +#ifdef C_PROGRESSIVE_SUPPORTED + fprintf(stderr, " -progressive Create progressive JPEG file\n"); +#endif +#ifdef DCT_SCALING_SUPPORTED + fprintf(stderr, " -scale M/N Scale image by fraction M/N, eg, 1/2\n"); +#endif +#ifdef TARGA_SUPPORTED + fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n"); +#endif + fprintf(stderr, "Switches for advanced users:\n"); +#ifdef C_ARITH_CODING_SUPPORTED + fprintf(stderr, " -arithmetic Use arithmetic coding\n"); +#endif +#ifdef DCT_SCALING_SUPPORTED + fprintf(stderr, " -block N DCT block size (1..16; default is 8)\n"); +#endif +#if JPEG_LIB_VERSION_MAJOR >= 9 + fprintf(stderr, " -rgb1 Create RGB JPEG file with reversible color transform\n"); + fprintf(stderr, " -bgycc Create big gamut YCC JPEG file\n"); +#endif +#ifdef DCT_ISLOW_SUPPORTED + fprintf(stderr, " -dct int Use integer DCT method%s\n", + (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); +#endif +#ifdef DCT_IFAST_SUPPORTED + fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", + (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); +#endif +#ifdef DCT_FLOAT_SUPPORTED + fprintf(stderr, " -dct float Use floating-point DCT method%s\n", + (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); +#endif + fprintf(stderr, " -nosmooth Don't use high-quality downsampling\n"); + fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); +#ifdef INPUT_SMOOTHING_SUPPORTED + fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n"); +#endif + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + fprintf(stderr, "Switches for wizards:\n"); + fprintf(stderr, " -baseline Force baseline quantization tables\n"); + fprintf(stderr, " -qtables file Use quantization tables given in file\n"); + fprintf(stderr, " -qslots N[,...] Set component quantization tables\n"); + fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n"); +#ifdef C_MULTISCAN_FILES_SUPPORTED + fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); +#endif + exit(EXIT_FAILURE); +} + + +LOCAL(int) +parse_switches (j_compress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + boolean force_baseline; + boolean simple_progressive; + char * qualityarg = NULL; /* saves -quality parm if any */ + char * qtablefile = NULL; /* saves -qtables filename if any */ + char * qslotsarg = NULL; /* saves -qslots parm if any */ + char * samplearg = NULL; /* saves -sample parm if any */ + char * scansarg = NULL; /* saves -scans parm if any */ + + /* Set up default JPEG parameters. */ + + force_baseline = FALSE; /* by default, allow 16-bit quantizers */ + simple_progressive = FALSE; + is_targa = FALSE; + outfilename = NULL; + cinfo->err->trace_level = 0; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "arithmetic", 1)) { + /* Use arithmetic coding. */ +#ifdef C_ARITH_CODING_SUPPORTED + cinfo->arith_code = TRUE; +#else + fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "baseline", 2)) { + /* Force baseline-compatible output (8-bit quantizer values). */ + force_baseline = TRUE; + + } else if (keymatch(arg, "block", 2)) { + /* Set DCT block size. */ +#if defined DCT_SCALING_SUPPORTED && JPEG_LIB_VERSION_MAJOR >= 8 && \ + (JPEG_LIB_VERSION_MAJOR > 8 || JPEG_LIB_VERSION_MINOR >= 3) + int val; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &val) != 1) + usage(); + if (val < 1 || val > 16) + usage(); + cinfo->block_size = val; +#else + fprintf(stderr, "%s: sorry, block size setting not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "dct", 2)) { + /* Select DCT algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "int", 1)) { + cinfo->dct_method = JDCT_ISLOW; + } else if (keymatch(argv[argn], "fast", 2)) { + cinfo->dct_method = JDCT_IFAST; + } else if (keymatch(argv[argn], "float", 2)) { + cinfo->dct_method = JDCT_FLOAT; + } else + usage(); + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { + /* Force a monochrome JPEG file to be generated. */ + jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); + + } else if (keymatch(arg, "rgb", 3) || keymatch(arg, "rgb1", 4)) { + /* Force an RGB JPEG file to be generated. */ +#if JPEG_LIB_VERSION_MAJOR >= 9 + /* Note: Entropy table assignment in jpeg_set_colorspace depends + * on color_transform. + */ + cinfo->color_transform = arg[3] ? JCT_SUBTRACT_GREEN : JCT_NONE; +#endif + jpeg_set_colorspace(cinfo, JCS_RGB); + + } else if (keymatch(arg, "bgycc", 5)) { + /* Force a big gamut YCC JPEG file to be generated. */ +#if JPEG_LIB_VERSION_MAJOR >= 9 && \ + (JPEG_LIB_VERSION_MAJOR > 9 || JPEG_LIB_VERSION_MINOR >= 1) + jpeg_set_colorspace(cinfo, JCS_BG_YCC); +#else + fprintf(stderr, "%s: sorry, BG_YCC colorspace not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "nosmooth", 3)) { + /* Suppress fancy downsampling. */ + cinfo->do_fancy_downsampling = FALSE; + + } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { + /* Enable entropy parm optimization. */ +#ifdef ENTROPY_OPT_SUPPORTED + cinfo->optimize_coding = TRUE; +#else + fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "progressive", 1)) { + /* Select simple progressive mode. */ +#ifdef C_PROGRESSIVE_SUPPORTED + simple_progressive = TRUE; + /* We must postpone execution until num_components is known. */ +#else + fprintf(stderr, "%s: sorry, progressive output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "quality", 1)) { + /* Quality ratings (quantization table scaling factors). */ + if (++argn >= argc) /* advance to next argument */ + usage(); + qualityarg = argv[argn]; + + } else if (keymatch(arg, "qslots", 2)) { + /* Quantization table slot numbers. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + qslotsarg = argv[argn]; + /* Must delay setting qslots until after we have processed any + * colorspace-determining switches, since jpeg_set_colorspace sets + * default quant table numbers. + */ + + } else if (keymatch(arg, "qtables", 2)) { + /* Quantization tables fetched from file. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + qtablefile = argv[argn]; + /* We postpone actually reading the file in case -quality comes later. */ + + } else if (keymatch(arg, "restart", 1)) { + /* Restart interval in MCU rows (or in MCUs with 'b'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (lval < 0 || lval > 65535L) + usage(); + if (ch == 'b' || ch == 'B') { + cinfo->restart_interval = (unsigned int) lval; + cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ + } else { + cinfo->restart_in_rows = (int) lval; + /* restart_interval will be computed during startup */ + } + + } else if (keymatch(arg, "sample", 2)) { + /* Set sampling factors. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + samplearg = argv[argn]; + /* Must delay setting sample factors until after we have processed any + * colorspace-determining switches, since jpeg_set_colorspace sets + * default sampling factors. + */ + + } else if (keymatch(arg, "scale", 4)) { + /* Scale the image by a fraction M/N. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%u/%u", + &cinfo->scale_num, &cinfo->scale_denom) != 2) + usage(); + + } else if (keymatch(arg, "scans", 4)) { + /* Set scan script. */ +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (++argn >= argc) /* advance to next argument */ + usage(); + scansarg = argv[argn]; + /* We must postpone reading the file in case -progressive appears. */ +#else + fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "smooth", 2)) { + /* Set input smoothing factor. */ + int val; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &val) != 1) + usage(); + if (val < 0 || val > 100) + usage(); + cinfo->smoothing_factor = val; + + } else if (keymatch(arg, "targa", 1)) { + /* Input file is Targa format. */ + is_targa = TRUE; + + } else { + usage(); /* bogus switch */ + } + } + + /* Post-switch-scanning cleanup */ + + if (for_real) { + + /* Set quantization tables for selected quality. */ + /* Some or all may be overridden if -qtables is present. */ + if (qualityarg != NULL) /* process -quality if it was present */ + if (! set_quality_ratings(cinfo, qualityarg, force_baseline)) + usage(); + + if (qtablefile != NULL) /* process -qtables if it was present */ + if (! read_quant_tables(cinfo, qtablefile, force_baseline)) + usage(); + + if (qslotsarg != NULL) /* process -qslots if it was present */ + if (! set_quant_slots(cinfo, qslotsarg)) + usage(); + + if (samplearg != NULL) /* process -sample if it was present */ + if (! set_sample_factors(cinfo, samplearg)) + usage(); + +#ifdef C_PROGRESSIVE_SUPPORTED + if (simple_progressive) /* process -progressive; -scans can override */ + jpeg_simple_progression(cinfo); +#endif + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (scansarg != NULL) /* process -scans if it was present */ + if (! read_scan_script(cinfo, scansarg)) + usage(); +#endif + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + int file_index; + cjpeg_source_ptr src_mgr; + FILE * input_file; + FILE * output_file; + JDIMENSION num_scanlines; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "cjpeg"; /* in case C library doesn't provide it */ + + /* Initialize the JPEG compression object with default error handling. */ + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + /* Add some application-specific error messages (from cderror.h) */ + jerr.addon_message_table = cdjpeg_message_table; + jerr.first_addon_message = JMSG_FIRSTADDONCODE; + jerr.last_addon_message = JMSG_LASTADDONCODE; + + /* Now safe to enable signal catcher. */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &cinfo); +#endif + + /* Initialize JPEG parameters. + * Much of this may be overridden later. + * In particular, we don't yet know the input file's color space, + * but we need to provide some value for jpeg_set_defaults() to work. + */ + + cinfo.in_color_space = JCS_RGB; /* arbitrary guess */ + jpeg_set_defaults(&cinfo); + + /* Scan command line to find file names. + * It is convenient to use just one switch-parsing routine, but the switch + * values read here are ignored; we will rescan the switches after opening + * the input file. + */ + + file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); + +#ifdef TWO_FILE_COMMANDLINE + /* Must have either -outfile switch or explicit output file name */ + if (outfilename == NULL) { + if (file_index != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + outfilename = argv[file_index+1]; + } else { + if (file_index != argc-1) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + } +#else + /* Unix style: expect zero or one file name */ + if (file_index < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } +#endif /* TWO_FILE_COMMANDLINE */ + + /* Open the input file. */ + if (file_index < argc) { + if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ + input_file = read_stdin(); + } + + /* Open the output file. */ + if (outfilename != NULL) { + if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, outfilename); + exit(EXIT_FAILURE); + } + } else { + /* default output file is stdout */ + output_file = write_stdout(); + } + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &cinfo, &progress); +#endif + + /* Figure out the input file format, and set up to read it. */ + src_mgr = select_file_type(&cinfo, input_file); + src_mgr->input_file = input_file; + + /* Read the input file header to obtain file size & colorspace. */ + (*src_mgr->start_input) (&cinfo, src_mgr); + + /* Now that we know input colorspace, fix colorspace-dependent defaults */ + jpeg_default_colorspace(&cinfo); + + /* Adjust default compression parameters by re-parsing the options */ + file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); + + /* Specify data destination for compression */ + jpeg_stdio_dest(&cinfo, output_file); + + /* Start compressor */ + jpeg_start_compress(&cinfo, TRUE); + + /* Process data */ + while (cinfo.next_scanline < cinfo.image_height) { + num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr); + (void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines); + } + + /* Finish compression and release memory */ + (*src_mgr->finish_input) (&cinfo, src_mgr); + jpeg_finish_compress(&cinfo); + jpeg_destroy_compress(&cinfo); + + /* Close files, if we opened them */ + if (input_file != stdin) + fclose(input_file); + if (output_file != stdout) + fclose(output_file); + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &cinfo); +#endif + + /* All done. */ + exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/thirdparty/jpeg-9e/cjpegalt.c b/thirdparty/jpeg-9e/cjpegalt.c new file mode 100644 index 0000000..4f35b04 --- /dev/null +++ b/thirdparty/jpeg-9e/cjpegalt.c @@ -0,0 +1,791 @@ +/* + * alternate cjpeg.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * Modified 2009-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains an alternate user interface for the JPEG compressor. + * One or more input files are named on the command line, and output file + * names are created by substituting ".jpg" for the input file's extension. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "jversion.h" /* for version message */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + +#ifndef PATH_MAX /* ANSI maximum-pathname-length constant */ +#define PATH_MAX 256 +#endif + + +/* Create the add-on message string table. */ + +#define JMESSAGE(code,string) string , + +static const char * const cdjpeg_message_table[] = { +#include "cderror.h" + NULL +}; + + +/* + * Automatic determination of available memory. + */ + +static long default_maxmem; /* saves value determined at startup, or 0 */ + +#ifndef FREE_MEM_ESTIMATE /* may be defined from command line */ + +#ifdef MSDOS /* For MS-DOS (unless flat-memory model) */ + +#include /* for access to intdos() call */ + +LOCAL(long) +unused_dos_memory (void) +/* Obtain total amount of unallocated DOS memory */ +{ + union REGS regs; + long nparas; + + regs.h.ah = 0x48; /* DOS function Allocate Memory Block */ + regs.x.bx = 0xFFFF; /* Ask for more memory than DOS can have */ + (void) intdos(®s, ®s); + /* DOS will fail and return # of paragraphs actually available in BX. */ + nparas = (unsigned int) regs.x.bx; + /* Times 16 to convert to bytes. */ + return nparas << 4; +} + +/* The default memory setting is 95% of the available space. */ +#define FREE_MEM_ESTIMATE ((unused_dos_memory() * 95L) / 100L) + +#endif /* MSDOS */ + +#ifdef ATARI /* For Atari ST/STE/TT, Pure C or Turbo C */ + +#include + +/* The default memory setting is 90% of the available space. */ +#define FREE_MEM_ESTIMATE (((long) coreleft() * 90L) / 100L) + +#endif /* ATARI */ + +/* Add memory-estimation procedures for other operating systems here, + * with appropriate #ifdef's around them. + */ + +#endif /* !FREE_MEM_ESTIMATE */ + + +/* + * This routine determines what format the input file is, + * and selects the appropriate input-reading module. + * + * To determine which family of input formats the file belongs to, + * we may look only at the first byte of the file, since C does not + * guarantee that more than one character can be pushed back with ungetc. + * Looking at additional bytes would require one of these approaches: + * 1) assume we can fseek() the input file (fails for piped input); + * 2) assume we can push back more than one character (works in + * some C implementations, but unportable); + * 3) provide our own buffering (breaks input readers that want to use + * stdio directly, such as the RLE library); + * or 4) don't put back the data, and modify the input_init methods to assume + * they start reading after the start of file (also breaks RLE library). + * #1 is attractive for MS-DOS but is untenable on Unix. + * + * The most portable solution for file types that can't be identified by their + * first byte is to make the user tell us what they are. This is also the + * only approach for "raw" file types that contain only arbitrary values. + * We presently apply this method for Targa files. Most of the time Targa + * files start with 0x00, so we recognize that case. Potentially, however, + * a Targa file could start with any byte value (byte 0 is the length of the + * seldom-used ID field), so we provide a switch to force Targa input mode. + */ + +static boolean is_targa; /* records user -targa switch */ + + +LOCAL(cjpeg_source_ptr) +select_file_type (j_compress_ptr cinfo, FILE * infile) +{ + int c; + + if (is_targa) { +#ifdef TARGA_SUPPORTED + return jinit_read_targa(cinfo); +#else + ERREXIT(cinfo, JERR_TGA_NOTCOMP); +#endif + } + + if ((c = getc(infile)) == EOF) + ERREXIT(cinfo, JERR_INPUT_EMPTY); + if (ungetc(c, infile) == EOF) + ERREXIT(cinfo, JERR_UNGETC_FAILED); + + switch (c) { +#ifdef BMP_SUPPORTED + case 'B': + return jinit_read_bmp(cinfo); +#endif +#ifdef GIF_SUPPORTED + case 'G': + return jinit_read_gif(cinfo); +#endif +#ifdef PPM_SUPPORTED + case 'P': + return jinit_read_ppm(cinfo); +#endif +#ifdef RLE_SUPPORTED + case 'R': + return jinit_read_rle(cinfo); +#endif +#ifdef TARGA_SUPPORTED + case 0x00: + return jinit_read_targa(cinfo); +#endif + default: + ERREXIT(cinfo, JERR_UNKNOWN_FORMAT); + break; + } + + return NULL; /* suppress compiler warnings */ +} + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] inputfile(s)\n", progname); + fprintf(stderr, "List of input files may use wildcards (* and ?)\n"); + fprintf(stderr, "Output filename is same as input filename, but extension .jpg\n"); + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -quality N[,...] Compression quality (0..100; 5-95 is useful range)\n"); + fprintf(stderr, " -grayscale Create monochrome JPEG file\n"); + fprintf(stderr, " -rgb Create RGB JPEG file\n"); +#ifdef ENTROPY_OPT_SUPPORTED + fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); +#endif +#ifdef C_PROGRESSIVE_SUPPORTED + fprintf(stderr, " -progressive Create progressive JPEG file\n"); +#endif +#ifdef DCT_SCALING_SUPPORTED + fprintf(stderr, " -scale M/N Scale image by fraction M/N, eg, 1/2\n"); +#endif +#ifdef TARGA_SUPPORTED + fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n"); +#endif + fprintf(stderr, "Switches for advanced users:\n"); +#ifdef C_ARITH_CODING_SUPPORTED + fprintf(stderr, " -arithmetic Use arithmetic coding\n"); +#endif +#ifdef DCT_SCALING_SUPPORTED + fprintf(stderr, " -block N DCT block size (1..16; default is 8)\n"); +#endif +#if JPEG_LIB_VERSION_MAJOR >= 9 + fprintf(stderr, " -rgb1 Create RGB JPEG file with reversible color transform\n"); + fprintf(stderr, " -bgycc Create big gamut YCC JPEG file\n"); +#endif +#ifdef DCT_ISLOW_SUPPORTED + fprintf(stderr, " -dct int Use integer DCT method%s\n", + (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); +#endif +#ifdef DCT_IFAST_SUPPORTED + fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", + (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); +#endif +#ifdef DCT_FLOAT_SUPPORTED + fprintf(stderr, " -dct float Use floating-point DCT method%s\n", + (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); +#endif + fprintf(stderr, " -nosmooth Don't use high-quality downsampling\n"); + fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); +#ifdef INPUT_SMOOTHING_SUPPORTED + fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n"); +#endif +#ifndef FREE_MEM_ESTIMATE + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); +#endif + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + fprintf(stderr, "Switches for wizards:\n"); + fprintf(stderr, " -baseline Force baseline quantization tables\n"); + fprintf(stderr, " -qtables file Use quantization tables given in file\n"); + fprintf(stderr, " -qslots N[,...] Set component quantization tables\n"); + fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n"); +#ifdef C_MULTISCAN_FILES_SUPPORTED + fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); +#endif + exit(EXIT_FAILURE); +} + + +LOCAL(int) +parse_switches (j_compress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + boolean force_baseline; + boolean simple_progressive; + char * qualityarg = NULL; /* saves -quality parm if any */ + char * qtablefile = NULL; /* saves -qtables filename if any */ + char * qslotsarg = NULL; /* saves -qslots parm if any */ + char * samplearg = NULL; /* saves -sample parm if any */ + char * scansarg = NULL; /* saves -scans parm if any */ + + /* Set up default JPEG parameters. */ + + force_baseline = FALSE; /* by default, allow 16-bit quantizers */ + simple_progressive = FALSE; + is_targa = FALSE; + outfilename = NULL; + cinfo->err->trace_level = 0; + if (default_maxmem > 0) /* override library's default value */ + cinfo->mem->max_memory_to_use = default_maxmem; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "arithmetic", 1)) { + /* Use arithmetic coding. */ +#ifdef C_ARITH_CODING_SUPPORTED + cinfo->arith_code = TRUE; +#else + fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "baseline", 2)) { + /* Force baseline-compatible output (8-bit quantizer values). */ + force_baseline = TRUE; + + } else if (keymatch(arg, "block", 2)) { + /* Set DCT block size. */ +#if defined DCT_SCALING_SUPPORTED && JPEG_LIB_VERSION_MAJOR >= 8 && \ + (JPEG_LIB_VERSION_MAJOR > 8 || JPEG_LIB_VERSION_MINOR >= 3) + int val; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &val) != 1) + usage(); + if (val < 1 || val > 16) + usage(); + cinfo->block_size = val; +#else + fprintf(stderr, "%s: sorry, block size setting not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "dct", 2)) { + /* Select DCT algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "int", 1)) { + cinfo->dct_method = JDCT_ISLOW; + } else if (keymatch(argv[argn], "fast", 2)) { + cinfo->dct_method = JDCT_IFAST; + } else if (keymatch(argv[argn], "float", 2)) { + cinfo->dct_method = JDCT_FLOAT; + } else + usage(); + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { + /* Force a monochrome JPEG file to be generated. */ + jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); + + } else if (keymatch(arg, "rgb", 3) || keymatch(arg, "rgb1", 4)) { + /* Force an RGB JPEG file to be generated. */ +#if JPEG_LIB_VERSION_MAJOR >= 9 + /* Note: Entropy table assignment in jpeg_set_colorspace depends + * on color_transform. + */ + cinfo->color_transform = arg[3] ? JCT_SUBTRACT_GREEN : JCT_NONE; +#endif + jpeg_set_colorspace(cinfo, JCS_RGB); + + } else if (keymatch(arg, "bgycc", 5)) { + /* Force a big gamut YCC JPEG file to be generated. */ +#if JPEG_LIB_VERSION_MAJOR >= 9 && \ + (JPEG_LIB_VERSION_MAJOR > 9 || JPEG_LIB_VERSION_MINOR >= 1) + jpeg_set_colorspace(cinfo, JCS_BG_YCC); +#else + fprintf(stderr, "%s: sorry, BG_YCC colorspace not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "nosmooth", 3)) { + /* Suppress fancy downsampling. */ + cinfo->do_fancy_downsampling = FALSE; + + } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { + /* Enable entropy parm optimization. */ +#ifdef ENTROPY_OPT_SUPPORTED + cinfo->optimize_coding = TRUE; +#else + fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "progressive", 1)) { + /* Select simple progressive mode. */ +#ifdef C_PROGRESSIVE_SUPPORTED + simple_progressive = TRUE; + /* We must postpone execution until num_components is known. */ +#else + fprintf(stderr, "%s: sorry, progressive output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "quality", 1)) { + /* Quality ratings (quantization table scaling factors). */ + if (++argn >= argc) /* advance to next argument */ + usage(); + qualityarg = argv[argn]; + + } else if (keymatch(arg, "qslots", 2)) { + /* Quantization table slot numbers. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + qslotsarg = argv[argn]; + /* Must delay setting qslots until after we have processed any + * colorspace-determining switches, since jpeg_set_colorspace sets + * default quant table numbers. + */ + + } else if (keymatch(arg, "qtables", 2)) { + /* Quantization tables fetched from file. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + qtablefile = argv[argn]; + /* We postpone actually reading the file in case -quality comes later. */ + + } else if (keymatch(arg, "restart", 1)) { + /* Restart interval in MCU rows (or in MCUs with 'b'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (lval < 0 || lval > 65535L) + usage(); + if (ch == 'b' || ch == 'B') { + cinfo->restart_interval = (unsigned int) lval; + cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ + } else { + cinfo->restart_in_rows = (int) lval; + /* restart_interval will be computed during startup */ + } + + } else if (keymatch(arg, "sample", 2)) { + /* Set sampling factors. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + samplearg = argv[argn]; + /* Must delay setting sample factors until after we have processed any + * colorspace-determining switches, since jpeg_set_colorspace sets + * default sampling factors. + */ + + } else if (keymatch(arg, "scale", 4)) { + /* Scale the image by a fraction M/N. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d/%d", + &cinfo->scale_num, &cinfo->scale_denom) != 2) + usage(); + + } else if (keymatch(arg, "scans", 4)) { + /* Set scan script. */ +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (++argn >= argc) /* advance to next argument */ + usage(); + scansarg = argv[argn]; + /* We must postpone reading the file in case -progressive appears. */ +#else + fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "smooth", 2)) { + /* Set input smoothing factor. */ + int val; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &val) != 1) + usage(); + if (val < 0 || val > 100) + usage(); + cinfo->smoothing_factor = val; + + } else if (keymatch(arg, "targa", 1)) { + /* Input file is Targa format. */ + is_targa = TRUE; + + } else { + usage(); /* bogus switch */ + } + } + + /* Post-switch-scanning cleanup */ + + if (for_real) { + + /* Set quantization tables for selected quality. */ + /* Some or all may be overridden if -qtables is present. */ + if (qualityarg != NULL) /* process -quality if it was present */ + if (! set_quality_ratings(cinfo, qualityarg, force_baseline)) + usage(); + + if (qtablefile != NULL) /* process -qtables if it was present */ + if (! read_quant_tables(cinfo, qtablefile, force_baseline)) + usage(); + + if (qslotsarg != NULL) /* process -qslots if it was present */ + if (! set_quant_slots(cinfo, qslotsarg)) + usage(); + + if (samplearg != NULL) /* process -sample if it was present */ + if (! set_sample_factors(cinfo, samplearg)) + usage(); + +#ifdef C_PROGRESSIVE_SUPPORTED + if (simple_progressive) /* process -progressive; -scans can override */ + jpeg_simple_progression(cinfo); +#endif + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (scansarg != NULL) /* process -scans if it was present */ + if (! read_scan_script(cinfo, scansarg)) + usage(); +#endif + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * Check for overwrite of an existing file; clear it with user + */ + +#ifndef NO_OVERWRITE_CHECK + +LOCAL(boolean) +is_write_ok (char * outfname) +{ + FILE * ofile; + int ch; + + ofile = fopen(outfname, READ_BINARY); + if (ofile == NULL) + return TRUE; /* not present */ + fclose(ofile); /* oops, it is present */ + + for (;;) { + fprintf(stderr, "%s already exists, overwrite it? [y/n] ", + outfname); + fflush(stderr); + ch = getc(stdin); + if (ch != '\n') /* flush rest of line */ + while (getc(stdin) != '\n') + /* nothing */; + + switch (ch) { + case 'Y': + case 'y': + return TRUE; + case 'N': + case 'n': + return FALSE; + /* otherwise, ask again */ + } + } +} + +#endif + + +/* + * Process a single input file name, and return its index in argv[]. + * File names at or to left of old_file_index have been processed already. + */ + +LOCAL(int) +process_one_file (int argc, char **argv, int old_file_index) +{ + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + char *infilename; + char workfilename[PATH_MAX]; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + int file_index; + cjpeg_source_ptr src_mgr; + FILE * input_file = NULL; + FILE * output_file = NULL; + JDIMENSION num_scanlines; + + /* Initialize the JPEG compression object with default error handling. */ + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + /* Add some application-specific error messages (from cderror.h) */ + jerr.addon_message_table = cdjpeg_message_table; + jerr.first_addon_message = JMSG_FIRSTADDONCODE; + jerr.last_addon_message = JMSG_LASTADDONCODE; + + /* Now safe to enable signal catcher. */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &cinfo); +#endif + + /* Initialize JPEG parameters. + * Much of this may be overridden later. + * In particular, we don't yet know the input file's color space, + * but we need to provide some value for jpeg_set_defaults() to work. + */ + + cinfo.in_color_space = JCS_RGB; /* arbitrary guess */ + jpeg_set_defaults(&cinfo); + + /* Scan command line to find next file name. + * It is convenient to use just one switch-parsing routine, but the switch + * values read here are ignored; we will rescan the switches after opening + * the input file. + */ + + file_index = parse_switches(&cinfo, argc, argv, old_file_index, FALSE); + if (file_index >= argc) { + fprintf(stderr, "%s: missing input file name\n", progname); + usage(); + } + + /* Open the input file. */ + infilename = argv[file_index]; + if ((input_file = fopen(infilename, READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, infilename); + goto fail; + } + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &cinfo, &progress); +#endif + + /* Figure out the input file format, and set up to read it. */ + src_mgr = select_file_type(&cinfo, input_file); + src_mgr->input_file = input_file; + + /* Read the input file header to obtain file size & colorspace. */ + (*src_mgr->start_input) (&cinfo, src_mgr); + + /* Now that we know input colorspace, fix colorspace-dependent defaults */ + jpeg_default_colorspace(&cinfo); + + /* Adjust default compression parameters by re-parsing the options */ + file_index = parse_switches(&cinfo, argc, argv, old_file_index, TRUE); + + /* If user didn't supply -outfile switch, select output file name. */ + if (outfilename == NULL) { + int i; + + outfilename = workfilename; + /* Make outfilename be infilename with .jpg substituted for extension */ + strcpy(outfilename, infilename); + for (i = (int)strlen(outfilename)-1; i >= 0; i--) { + switch (outfilename[i]) { + case ':': + case '/': + case '\\': + i = 0; /* stop scanning */ + break; + case '.': + outfilename[i] = '\0'; /* lop off existing extension */ + i = 0; /* stop scanning */ + break; + default: + break; /* keep scanning */ + } + } + strcat(outfilename, ".jpg"); + } + + fprintf(stderr, "Compressing %s => %s\n", infilename, outfilename); +#ifndef NO_OVERWRITE_CHECK + if (! is_write_ok(outfilename)) + goto fail; +#endif + + /* Open the output file. */ + if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't create %s\n", progname, outfilename); + goto fail; + } + + /* Specify data destination for compression */ + jpeg_stdio_dest(&cinfo, output_file); + + /* Start compressor */ + jpeg_start_compress(&cinfo, TRUE); + + /* Process data */ + while (cinfo.next_scanline < cinfo.image_height) { + num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr); + (void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines); + } + + /* Finish compression and release memory */ + (*src_mgr->finish_input) (&cinfo, src_mgr); + jpeg_finish_compress(&cinfo); + + /* Clean up and exit */ +fail: + jpeg_destroy_compress(&cinfo); + + if (input_file != NULL) fclose(input_file); + if (output_file != NULL) fclose(output_file); + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &cinfo); +#endif + + /* Disable signal catcher. */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) NULL); +#endif + + return file_index; +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + int file_index; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + +#ifdef MSDOS + progname = "cjpeg"; /* DOS tends to be too verbose about argv[0] */ +#else + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "cjpeg"; /* in case C library doesn't provide it */ +#endif + + /* The default maxmem must be computed only once at program startup, + * since releasing memory with free() won't give it back to the OS. + */ +#ifdef FREE_MEM_ESTIMATE + default_maxmem = FREE_MEM_ESTIMATE; +#else + default_maxmem = 0; +#endif + + /* Scan command line, parse switches and locate input file names */ + + if (argc < 2) + usage(); /* nothing on the command line?? */ + + file_index = 0; + + while (file_index < argc-1) + file_index = process_one_file(argc, argv, file_index); + + /* All done. */ + exit(EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/thirdparty/jpeg-9e/ckconfig.c b/thirdparty/jpeg-9e/ckconfig.c new file mode 100644 index 0000000..e658623 --- /dev/null +++ b/thirdparty/jpeg-9e/ckconfig.c @@ -0,0 +1,402 @@ +/* + * ckconfig.c + * + * Copyright (C) 1991-1994, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + */ + +/* + * This program is intended to help you determine how to configure the JPEG + * software for installation on a particular system. The idea is to try to + * compile and execute this program. If your compiler fails to compile the + * program, make changes as indicated in the comments below. Once you can + * compile the program, run it, and it will produce a "jconfig.h" file for + * your system. + * + * As a general rule, each time you try to compile this program, + * pay attention only to the *first* error message you get from the compiler. + * Many C compilers will issue lots of spurious error messages once they + * have gotten confused. Go to the line indicated in the first error message, + * and read the comments preceding that line to see what to change. + * + * Almost all of the edits you may need to make to this program consist of + * changing a line that reads "#define SOME_SYMBOL" to "#undef SOME_SYMBOL", + * or vice versa. This is called defining or undefining that symbol. + */ + + +/* First we must see if your system has the include files we need. + * We start out with the assumption that your system has all the ANSI-standard + * include files. If you get any error trying to include one of these files, + * undefine the corresponding HAVE_xxx symbol. + */ + +#define HAVE_STDDEF_H /* replace 'define' by 'undef' if error here */ +#ifdef HAVE_STDDEF_H /* next line will be skipped if you undef... */ +#include +#endif + +#define HAVE_STDLIB_H /* same thing for stdlib.h */ +#ifdef HAVE_STDLIB_H +#include +#endif + +#include /* If you ain't got this, you ain't got C. */ + +/* We have to see if your string functions are defined by + * strings.h (old BSD convention) or string.h (everybody else). + * We try the non-BSD convention first; define NEED_BSD_STRINGS + * if the compiler says it can't find string.h. + */ + +#undef NEED_BSD_STRINGS + +#ifdef NEED_BSD_STRINGS +#include +#else +#include +#endif + +/* On some systems (especially older Unix machines), type size_t is + * defined only in the include file . If you get a failure + * on the size_t test below, try defining NEED_SYS_TYPES_H. + */ + +#undef NEED_SYS_TYPES_H /* start by assuming we don't need it */ +#ifdef NEED_SYS_TYPES_H +#include +#endif + + +/* Usually type size_t is defined in one of the include files we've included + * above. If not, you'll get an error on the "typedef size_t my_size_t;" line. + * In that case, first try defining NEED_SYS_TYPES_H just above. + * If that doesn't work, you'll have to search through your system library + * to figure out which include file defines "size_t". Look for a line that + * says "typedef something-or-other size_t;". Then, change the line below + * that says "#include " to instead include the file + * you found size_t in, and define NEED_SPECIAL_INCLUDE. If you can't find + * type size_t anywhere, try replacing "#include " with + * "typedef unsigned int size_t;". + */ + +#undef NEED_SPECIAL_INCLUDE /* assume we DON'T need it, for starters */ + +#ifdef NEED_SPECIAL_INCLUDE +#include +#endif + +typedef size_t my_size_t; /* The payoff: do we have size_t now? */ + + +/* The next question is whether your compiler supports ANSI-style function + * prototypes. You need to know this in order to choose between using + * makefile.ansi and using makefile.unix. + * The #define line below is set to assume you have ANSI function prototypes. + * If you get an error in this group of lines, undefine HAVE_PROTOTYPES. + */ + +#define HAVE_PROTOTYPES + +#ifdef HAVE_PROTOTYPES +int testfunction (int arg1, int * arg2); /* check prototypes */ + +struct methods_struct { /* check method-pointer declarations */ + int (*error_exit) (char *msgtext); + int (*trace_message) (char *msgtext); + int (*another_method) (void); +}; + +int testfunction (int arg1, int * arg2) /* check definitions */ +{ + return arg2[arg1]; +} + +int test2function (void) /* check void arg list */ +{ + return 0; +} +#endif + + +/* Now we want to find out if your compiler knows what "unsigned char" means. + * If you get an error on the "unsigned char un_char;" line, + * then undefine HAVE_UNSIGNED_CHAR. + */ + +#define HAVE_UNSIGNED_CHAR + +#ifdef HAVE_UNSIGNED_CHAR +unsigned char un_char; +#endif + + +/* Now we want to find out if your compiler knows what "unsigned short" means. + * If you get an error on the "unsigned short un_short;" line, + * then undefine HAVE_UNSIGNED_SHORT. + */ + +#define HAVE_UNSIGNED_SHORT + +#ifdef HAVE_UNSIGNED_SHORT +unsigned short un_short; +#endif + + +/* Now we want to find out if your compiler understands type "void". + * If you get an error anywhere in here, undefine HAVE_VOID. + */ + +#define HAVE_VOID + +#ifdef HAVE_VOID +/* Caution: a C++ compiler will insist on complete prototypes */ +typedef void * void_ptr; /* check void * */ +#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ +typedef void (*void_func) (int a, int b); +#else +typedef void (*void_func) (); +#endif + +#ifdef HAVE_PROTOTYPES /* check void function result */ +void test3function (void_ptr arg1, void_func arg2) +#else +void test3function (arg1, arg2) + void_ptr arg1; + void_func arg2; +#endif +{ + char * locptr = (char *) arg1; /* check casting to and from void * */ + arg1 = (void *) locptr; + (*arg2) (1, 2); /* check call of fcn returning void */ +} +#endif + + +/* Now we want to find out if your compiler knows what "const" means. + * If you get an error here, undefine HAVE_CONST. + */ + +#define HAVE_CONST + +#ifdef HAVE_CONST +static const int carray[3] = {1, 2, 3}; + +#ifdef HAVE_PROTOTYPES +int test4function (const int arg1) +#else +int test4function (arg1) + const int arg1; +#endif +{ + return carray[arg1]; +} +#endif + + +/* If you get an error or warning about this structure definition, + * define INCOMPLETE_TYPES_BROKEN. + */ + +#undef INCOMPLETE_TYPES_BROKEN + +#ifndef INCOMPLETE_TYPES_BROKEN +typedef struct undefined_structure * undef_struct_ptr; +#endif + + +/* If you get an error about duplicate names, + * define NEED_SHORT_EXTERNAL_NAMES. + */ + +#undef NEED_SHORT_EXTERNAL_NAMES + +#ifndef NEED_SHORT_EXTERNAL_NAMES + +int possibly_duplicate_function () +{ + return 0; +} + +int possibly_dupli_function () +{ + return 1; +} + +#endif + + + +/************************************************************************ + * OK, that's it. You should not have to change anything beyond this + * point in order to compile and execute this program. (You might get + * some warnings, but you can ignore them.) + * When you run the program, it will make a couple more tests that it + * can do automatically, and then it will create jconfig.h and print out + * any additional suggestions it has. + ************************************************************************ + */ + + +#ifdef HAVE_PROTOTYPES +int is_char_signed (int arg) +#else +int is_char_signed (arg) + int arg; +#endif +{ + if (arg == 189) { /* expected result for unsigned char */ + return 0; /* type char is unsigned */ + } + else if (arg != -67) { /* expected result for signed char */ + printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + } + return 1; /* assume char is signed otherwise */ +} + + +#ifdef HAVE_PROTOTYPES +int is_shifting_signed (long arg) +#else +int is_shifting_signed (arg) + long arg; +#endif +/* See whether right-shift on a long is signed or not. */ +{ + long res = arg >> 4; + + if (res == -0x7F7E80CL) { /* expected result for signed shift */ + return 1; /* right shift is signed */ + } + /* see if unsigned-shift hack will fix it. */ + /* we can't just test exact value since it depends on width of long... */ + res |= (~0L) << (32-4); + if (res == -0x7F7E80CL) { /* expected result now? */ + return 0; /* right shift is unsigned */ + } + printf("Right shift isn't acting as I expect it to.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + return 0; /* try it with unsigned anyway */ +} + + +#ifdef HAVE_PROTOTYPES +int main (int argc, char ** argv) +#else +int main (argc, argv) + int argc; + char ** argv; +#endif +{ + char signed_char_check = (char) (-67); + FILE *outfile; + + /* Attempt to write jconfig.h */ + if ((outfile = fopen("jconfig.h", "w")) == NULL) { + printf("Failed to write jconfig.h\n"); + return 1; + } + + /* Write out all the info */ + fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n"); + fprintf(outfile, "/* see jconfig.txt for explanations */\n\n"); +#ifdef HAVE_PROTOTYPES + fprintf(outfile, "#define HAVE_PROTOTYPES\n"); +#else + fprintf(outfile, "#undef HAVE_PROTOTYPES\n"); +#endif +#ifdef HAVE_UNSIGNED_CHAR + fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n"); +#else + fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n"); +#endif +#ifdef HAVE_UNSIGNED_SHORT + fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n"); +#else + fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n"); +#endif +#ifdef HAVE_VOID + fprintf(outfile, "/* #define void char */\n"); +#else + fprintf(outfile, "#define void char\n"); +#endif +#ifdef HAVE_CONST + fprintf(outfile, "/* #define const */\n"); +#else + fprintf(outfile, "#define const\n"); +#endif + if (is_char_signed((int) signed_char_check)) + fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n"); + else + fprintf(outfile, "#define CHAR_IS_UNSIGNED\n"); +#ifdef HAVE_STDDEF_H + fprintf(outfile, "#define HAVE_STDDEF_H\n"); +#else + fprintf(outfile, "#undef HAVE_STDDEF_H\n"); +#endif +#ifdef HAVE_STDLIB_H + fprintf(outfile, "#define HAVE_STDLIB_H\n"); +#else + fprintf(outfile, "#undef HAVE_STDLIB_H\n"); +#endif +#ifdef NEED_BSD_STRINGS + fprintf(outfile, "#define NEED_BSD_STRINGS\n"); +#else + fprintf(outfile, "#undef NEED_BSD_STRINGS\n"); +#endif +#ifdef NEED_SYS_TYPES_H + fprintf(outfile, "#define NEED_SYS_TYPES_H\n"); +#else + fprintf(outfile, "#undef NEED_SYS_TYPES_H\n"); +#endif + fprintf(outfile, "#undef NEED_FAR_POINTERS\n"); +#ifdef NEED_SHORT_EXTERNAL_NAMES + fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n"); +#else + fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n"); +#endif +#ifdef INCOMPLETE_TYPES_BROKEN + fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n"); +#else + fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n"); +#endif + fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n"); + if (is_shifting_signed(-0x7F7E80B1L)) + fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n"); + else + fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n"); + fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n"); + fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n"); + fprintf(outfile, "#define BMP_SUPPORTED /* BMP image file format */\n"); + fprintf(outfile, "#define GIF_SUPPORTED /* GIF image file format */\n"); + fprintf(outfile, "#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */\n"); + fprintf(outfile, "#undef RLE_SUPPORTED /* Utah RLE image file format */\n"); + fprintf(outfile, "#define TARGA_SUPPORTED /* Targa image file format */\n\n"); + fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n"); + fprintf(outfile, "#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */\n"); + fprintf(outfile, "#undef DONT_USE_B_MODE\n"); + fprintf(outfile, "/* #define PROGRESS_REPORT */ /* optional */\n"); + fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n"); + + /* Close the jconfig.h file */ + fclose(outfile); + + /* User report */ + printf("Configuration check for Independent JPEG Group's software done.\n"); + printf("\nI have written the jconfig.h file for you.\n\n"); +#ifdef HAVE_PROTOTYPES + printf("You should use makefile.ansi as the starting point for your Makefile.\n"); +#else + printf("You should use makefile.unix as the starting point for your Makefile.\n"); +#endif + +#ifdef NEED_SPECIAL_INCLUDE + printf("\nYou'll need to change jconfig.h to include the system include file\n"); + printf("that you found type size_t in, or add a direct definition of type\n"); + printf("size_t if that's what you used. Just add it to the end.\n"); +#endif + + return 0; +} diff --git a/thirdparty/jpeg-9e/coderules.txt b/thirdparty/jpeg-9e/coderules.txt new file mode 100644 index 0000000..357929f --- /dev/null +++ b/thirdparty/jpeg-9e/coderules.txt @@ -0,0 +1,118 @@ +IJG JPEG LIBRARY: CODING RULES + +Copyright (C) 1991-1996, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +Since numerous people will be contributing code and bug fixes, it's important +to establish a common coding style. The goal of using similar coding styles +is much more important than the details of just what that style is. + +In general we follow the recommendations of "Recommended C Style and Coding +Standards" revision 6.1 (Cannon et al. as modified by Spencer, Keppel and +Brader). This document is available in the IJG FTP archive (see +jpeg/doc/cstyle.ms.tbl.Z, or cstyle.txt.Z for those without nroff/tbl). + +Block comments should be laid out thusly: + +/* + * Block comments in this style. + */ + +We indent statements in K&R style, e.g., + if (test) { + then-part; + } else { + else-part; + } +with two spaces per indentation level. (This indentation convention is +handled automatically by GNU Emacs and many other text editors.) + +Multi-word names should be written in lower case with underscores, e.g., +multi_word_name (not multiWordName). Preprocessor symbols and enum constants +are similar but upper case (MULTI_WORD_NAME). Names should be unique within +the first fifteen characters. (On some older systems, global names must be +unique within six characters. We accommodate this without cluttering the +source code by using macros to substitute shorter names.) + +We use function prototypes everywhere; we rely on automatic source code +transformation to feed prototype-less C compilers. Transformation is done +by the simple and portable tool 'ansi2knr.c' (courtesy of Ghostscript). +ansi2knr is not very bright, so it imposes a format requirement on function +declarations: the function name MUST BEGIN IN COLUMN 1. Thus all functions +should be written in the following style: + +LOCAL(int *) +function_name (int a, char *b) +{ + code... +} + +Note that each function definition must begin with GLOBAL(type), LOCAL(type), +or METHODDEF(type). These macros expand to "static type" or just "type" as +appropriate. They provide a readable indication of the routine's usage and +can readily be changed for special needs. (For instance, special linkage +keywords can be inserted for use in Windows DLLs.) + +ansi2knr does not transform method declarations (function pointers in +structs). We handle these with a macro JMETHOD, defined as + #ifdef HAVE_PROTOTYPES + #define JMETHOD(type,methodname,arglist) type (*methodname) arglist + #else + #define JMETHOD(type,methodname,arglist) type (*methodname) () + #endif +which is used like this: + struct function_pointers { + JMETHOD(void, init_entropy_encoder, (int somearg, jparms *jp)); + JMETHOD(void, term_entropy_encoder, (void)); + }; +Note the set of parentheses surrounding the parameter list. + +A similar solution is used for forward and external function declarations +(see the EXTERN and JPP macros). + +If the code is to work on non-ANSI compilers, we cannot rely on a prototype +declaration to coerce actual parameters into the right types. Therefore, use +explicit casts on actual parameters whenever the actual parameter type is not +identical to the formal parameter. Beware of implicit conversions to "int". + +It seems there are some non-ANSI compilers in which the sizeof() operator +is defined to return int, yet size_t is defined as long. Needless to say, +this is brain-damaged. Always use the SIZEOF() macro in place of sizeof(), +so that the result is guaranteed to be of type size_t. + + +The JPEG library is intended to be used within larger programs. Furthermore, +we want it to be reentrant so that it can be used by applications that process +multiple images concurrently. The following rules support these requirements: + +1. Avoid direct use of file I/O, "malloc", error report printouts, etc; +pass these through the common routines provided. + +2. Minimize global namespace pollution. Functions should be declared static +wherever possible. (Note that our method-based calling conventions help this +a lot: in many modules only the initialization function will ever need to be +called directly, so only that function need be externally visible.) All +global function names should begin with "jpeg_", and should have an +abbreviated name (unique in the first six characters) substituted by macro +when NEED_SHORT_EXTERNAL_NAMES is set. + +3. Don't use global variables; anything that must be used in another module +should be in the common data structures. + +4. Don't use static variables except for read-only constant tables. Variables +that should be private to a module can be placed into private structures (see +the system architecture document, structure.txt). + +5. Source file names should begin with "j" for files that are part of the +library proper; source files that are not part of the library, such as cjpeg.c +and djpeg.c, do not begin with "j". Keep source file names to eight +characters (plus ".c" or ".h", etc) to make life easy for MS-DOSers. Keep +compression and decompression code in separate source files --- some +applications may want only one half of the library. + +Note: these rules (particularly #4) are not followed religiously in the +modules that are used in cjpeg/djpeg but are not part of the JPEG library +proper. Those modules are not really intended to be used in other +applications. diff --git a/thirdparty/jpeg-9e/compile b/thirdparty/jpeg-9e/compile new file mode 100755 index 0000000..df363c8 --- /dev/null +++ b/thirdparty/jpeg-9e/compile @@ -0,0 +1,348 @@ +#! /bin/sh +# Wrapper for compilers which do not understand '-c -o'. + +scriptversion=2018-03-07.03; # UTC + +# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN* | MSYS*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/* | msys/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + if test -f "$dir/lib$lib.a"; then + found=yes + lib=$dir/lib$lib.a + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file 'INSTALL'. + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; +esac + +ofile= +cfile= + +for arg +do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. + eat=1 + case $2 in + *.o | *.obj) + ofile=$2 + ;; + *) + set x "$@" -o "$2" + shift + ;; + esac + ;; + *.c) + cfile=$1 + set x "$@" "$1" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no '-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # '.c' file was seen then we are probably linking. That is also + # ok. + exec "$@" +fi + +# Name of file we expect compiler to create. +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` + +# Create the lock directory. +# Note: use '[/\\:.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d +while true; do + if mkdir "$lockdir" >/dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir '$lockdir'; exit 1" 1 2 15 + +# Run the compile. +"$@" +ret=$? + +if test -f "$cofile"; then + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" +elif test -f "${cofile}bj"; then + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" +fi + +rmdir "$lockdir" +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/thirdparty/jpeg-9e/config.guess b/thirdparty/jpeg-9e/config.guess new file mode 100755 index 0000000..e81d3ae --- /dev/null +++ b/thirdparty/jpeg-9e/config.guess @@ -0,0 +1,1748 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2021 Free Software Foundation, Inc. + +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2021-06-03' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess +# +# Please send patches to . + + +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2021 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +# Just in case it came from the environment. +GUESS= + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039,SC3028 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD=$driver + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if test -f /.attbin/uname ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case $UNAME_SYSTEM in +Linux|GNU|GNU/*) + LIBC=unknown + + set_cc_for_build + cat <<-EOF > "$dummy.c" + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #elif defined(__GLIBC__) + LIBC=gnu + #else + #include + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif + #endif + EOF + cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "$cc_set_libc" + + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu + fi + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + echo unknown)` + case $UNAME_MACHINE_ARCH in + aarch64eb) machine=aarch64_be-unknown ;; + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown + ;; + *) machine=$UNAME_MACHINE_ARCH-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently (or will in the future) and ABI. + case $UNAME_MACHINE_ARCH in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case $UNAME_MACHINE_ARCH in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case $UNAME_VERSION in + Debian*) + release='-gnu' + ;; + *) + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + GUESS=$machine-${os}${release}${abi-} + ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE + ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE + ;; + *:SecBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE + ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE + ;; + *:MidnightBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE + ;; + *:ekkoBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE + ;; + *:SolidBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE + ;; + *:OS108:*:*) + GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE + ;; + macppc:MirBSD:*:*) + GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE + ;; + *:MirBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE + ;; + *:Sortix:*:*) + GUESS=$UNAME_MACHINE-unknown-sortix + ;; + *:Twizzler:*:*) + GUESS=$UNAME_MACHINE-unknown-twizzler + ;; + *:Redox:*:*) + GUESS=$UNAME_MACHINE-unknown-redox + ;; + mips:OSF1:*.*) + GUESS=mips-dec-osf1 + ;; + alpha:OSF1:*:*) + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + trap '' 0 + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case $ALPHA_CPU_TYPE in + "EV4 (21064)") + UNAME_MACHINE=alpha ;; + "EV4.5 (21064)") + UNAME_MACHINE=alpha ;; + "LCA4 (21066/21068)") + UNAME_MACHINE=alpha ;; + "EV5 (21164)") + UNAME_MACHINE=alphaev5 ;; + "EV5.6 (21164A)") + UNAME_MACHINE=alphaev56 ;; + "EV5.6 (21164PC)") + UNAME_MACHINE=alphapca56 ;; + "EV5.7 (21164PC)") + UNAME_MACHINE=alphapca57 ;; + "EV6 (21264)") + UNAME_MACHINE=alphaev6 ;; + "EV6.7 (21264A)") + UNAME_MACHINE=alphaev67 ;; + "EV6.8CB (21264C)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8AL (21264B)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8CX (21264D)") + UNAME_MACHINE=alphaev68 ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE=alphaev69 ;; + "EV7 (21364)") + UNAME_MACHINE=alphaev7 ;; + "EV7.9 (21364A)") + UNAME_MACHINE=alphaev79 ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + GUESS=$UNAME_MACHINE-dec-osf$OSF_REL + ;; + Amiga*:UNIX_System_V:4.0:*) + GUESS=m68k-unknown-sysv4 + ;; + *:[Aa]miga[Oo][Ss]:*:*) + GUESS=$UNAME_MACHINE-unknown-amigaos + ;; + *:[Mm]orph[Oo][Ss]:*:*) + GUESS=$UNAME_MACHINE-unknown-morphos + ;; + *:OS/390:*:*) + GUESS=i370-ibm-openedition + ;; + *:z/VM:*:*) + GUESS=s390-ibm-zvmoe + ;; + *:OS400:*:*) + GUESS=powerpc-ibm-os400 + ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + GUESS=arm-acorn-riscix$UNAME_RELEASE + ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + GUESS=arm-unknown-riscos + ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + GUESS=hppa1.1-hitachi-hiuxmpp + ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + case `(/bin/universe) 2>/dev/null` in + att) GUESS=pyramid-pyramid-sysv3 ;; + *) GUESS=pyramid-pyramid-bsd ;; + esac + ;; + NILE*:*:*:dcosx) + GUESS=pyramid-pyramid-svr4 + ;; + DRS?6000:unix:4.0:6*) + GUESS=sparc-icl-nx6 + ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) GUESS=sparc-icl-nx7 ;; + esac + ;; + s390x:SunOS:*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL + ;; + sun4H:SunOS:5.*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-hal-solaris2$SUN_REL + ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris2$SUN_REL + ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + GUESS=i386-pc-auroraux$UNAME_RELEASE + ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + set_cc_for_build + SUN_ARCH=i386 + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH=x86_64 + fi + fi + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$SUN_ARCH-pc-solaris2$SUN_REL + ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris3$SUN_REL + ;; + sun4*:SunOS:*:*) + case `/usr/bin/arch -k` in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` + GUESS=sparc-sun-sunos$SUN_REL + ;; + sun3*:SunOS:*:*) + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + case `/bin/arch` in + sun3) + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; + sun4) + GUESS=sparc-sun-sunos$UNAME_RELEASE + ;; + esac + ;; + aushp:SunOS:*:*) + GUESS=sparc-auspex-sunos$UNAME_RELEASE + ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + GUESS=m68k-milan-mint$UNAME_RELEASE + ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + GUESS=m68k-hades-mint$UNAME_RELEASE + ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + GUESS=m68k-unknown-mint$UNAME_RELEASE + ;; + m68k:machten:*:*) + GUESS=m68k-apple-machten$UNAME_RELEASE + ;; + powerpc:machten:*:*) + GUESS=powerpc-apple-machten$UNAME_RELEASE + ;; + RISC*:Mach:*:*) + GUESS=mips-dec-mach_bsd4.3 + ;; + RISC*:ULTRIX:*:*) + GUESS=mips-dec-ultrix$UNAME_RELEASE + ;; + VAX*:ULTRIX*:*:*) + GUESS=vax-dec-ultrix$UNAME_RELEASE + ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + GUESS=clipper-intergraph-clix$UNAME_RELEASE + ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && + { echo "$SYSTEM_NAME"; exit; } + GUESS=mips-mips-riscos$UNAME_RELEASE + ;; + Motorola:PowerMAX_OS:*:*) + GUESS=powerpc-motorola-powermax + ;; + Motorola:*:4.3:PL8-*) + GUESS=powerpc-harris-powermax + ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + GUESS=powerpc-harris-powermax + ;; + Night_Hawk:Power_UNIX:*:*) + GUESS=powerpc-harris-powerunix + ;; + m88k:CX/UX:7*:*) + GUESS=m88k-harris-cxux7 + ;; + m88k:*:4*:R4*) + GUESS=m88k-motorola-sysv4 + ;; + m88k:*:3*:R3*) + GUESS=m88k-motorola-sysv3 + ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 + then + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x + then + GUESS=m88k-dg-dgux$UNAME_RELEASE + else + GUESS=m88k-dg-dguxbcs$UNAME_RELEASE + fi + else + GUESS=i586-dg-dgux$UNAME_RELEASE + fi + ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + GUESS=m88k-dolphin-sysv3 + ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + GUESS=m88k-motorola-sysv3 + ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + GUESS=m88k-tektronix-sysv3 + ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + GUESS=m68k-tektronix-bsd + ;; + *:IRIX*:*:*) + IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` + GUESS=mips-sgi-irix$IRIX_REL + ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id + ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + GUESS=i386-ibm-aix + ;; + ia64:AIX:*:*) + if test -x /usr/bin/oslevel ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE + fi + GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV + ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` + then + GUESS=$SYSTEM_NAME + else + GUESS=rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + GUESS=rs6000-ibm-aix3.2.4 + else + GUESS=rs6000-ibm-aix3.2 + fi + ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if test -x /usr/bin/lslpp ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE + fi + GUESS=$IBM_ARCH-ibm-aix$IBM_REV + ;; + *:AIX:*:*) + GUESS=rs6000-ibm-aix + ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + GUESS=romp-ibm-bsd4.4 + ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to + ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + GUESS=rs6000-bull-bosx + ;; + DPX/2?00:B.O.S.:*:*) + GUESS=m68k-bull-sysv3 + ;; + 9000/[34]??:4.3bsd:1.*:*) + GUESS=m68k-hp-bsd + ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + GUESS=m68k-hp-bsd4.4 + ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + case $UNAME_MACHINE in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if test -x /usr/bin/getconf; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case $sc_cpu_version in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case $sc_kernel_bits in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac + fi + if test "$HP_ARCH" = ""; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if test "$HP_ARCH" = hppa2.0w + then + set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH=hppa2.0w + else + HP_ARCH=hppa64 + fi + fi + GUESS=$HP_ARCH-hp-hpux$HPUX_REV + ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + GUESS=ia64-hp-hpux$HPUX_REV + ;; + 3050*:HI-UX:*:*) + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + GUESS=unknown-hitachi-hiuxwe2 + ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + GUESS=hppa1.1-hp-bsd + ;; + 9000/8??:4.3bsd:*:*) + GUESS=hppa1.0-hp-bsd + ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + GUESS=hppa1.0-hp-mpeix + ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + GUESS=hppa1.1-hp-osf + ;; + hp8??:OSF1:*:*) + GUESS=hppa1.0-hp-osf + ;; + i*86:OSF1:*:*) + if test -x /usr/sbin/sysversion ; then + GUESS=$UNAME_MACHINE-unknown-osf1mk + else + GUESS=$UNAME_MACHINE-unknown-osf1 + fi + ;; + parisc*:Lites*:*:*) + GUESS=hppa1.1-hp-lites + ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + GUESS=c1-convex-bsd + ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + GUESS=c34-convex-bsd + ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + GUESS=c38-convex-bsd + ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + GUESS=c4-convex-bsd + ;; + CRAY*Y-MP:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=ymp-cray-unicos$CRAY_REL + ;; + CRAY*[A-Z]90:*:*:*) + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=t90-cray-unicos$CRAY_REL + ;; + CRAY*T3E:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=alphaev5-cray-unicosmk$CRAY_REL + ;; + CRAY*SV1:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=sv1-cray-unicos$CRAY_REL + ;; + *:UNICOS/mp:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=craynv-cray-unicosmp$CRAY_REL + ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE + ;; + sparc*:BSD/OS:*:*) + GUESS=sparc-unknown-bsdi$UNAME_RELEASE + ;; + *:BSD/OS:*:*) + GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE + ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi + else + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf + fi + ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case $UNAME_PROCESSOR in + amd64) + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; + esac + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL + ;; + i*:CYGWIN*:*) + GUESS=$UNAME_MACHINE-pc-cygwin + ;; + *:MINGW64*:*) + GUESS=$UNAME_MACHINE-pc-mingw64 + ;; + *:MINGW*:*) + GUESS=$UNAME_MACHINE-pc-mingw32 + ;; + *:MSYS*:*) + GUESS=$UNAME_MACHINE-pc-msys + ;; + i*:PW*:*) + GUESS=$UNAME_MACHINE-pc-pw32 + ;; + *:Interix*:*) + case $UNAME_MACHINE in + x86) + GUESS=i586-pc-interix$UNAME_RELEASE + ;; + authenticamd | genuineintel | EM64T) + GUESS=x86_64-unknown-interix$UNAME_RELEASE + ;; + IA64) + GUESS=ia64-unknown-interix$UNAME_RELEASE + ;; + esac ;; + i*:UWIN*:*) + GUESS=$UNAME_MACHINE-pc-uwin + ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + GUESS=x86_64-pc-cygwin + ;; + prep*:SunOS:5.*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=powerpcle-unknown-solaris2$SUN_REL + ;; + *:GNU:*:*) + # the GNU system + GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` + GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL + ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC + ;; + *:Minix:*:*) + GUESS=$UNAME_MACHINE-unknown-minix + ;; + aarch64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arm*:Linux:*:*) + set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi + else + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf + fi + fi + ;; + avr32*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + cris:Linux:*:*) + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; + crisv32:Linux:*:*) + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; + e2k:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + frv:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + hexagon:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + i*86:Linux:*:*) + GUESS=$UNAME_MACHINE-pc-linux-$LIBC + ;; + ia64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + k1om:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + m32r*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + m68*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + mips:Linux:*:* | mips64:Linux:*:*) + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" + #undef CPU + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + MIPS_ENDIAN=el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + MIPS_ENDIAN= + #else + MIPS_ENDIAN= + #endif + #endif +EOF + cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` + eval "$cc_set_vars" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } + ;; + mips64el:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + openrisc*:Linux:*:*) + GUESS=or1k-unknown-linux-$LIBC + ;; + or32:Linux:*:* | or1k*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + padre:Linux:*:*) + GUESS=sparc-unknown-linux-$LIBC + ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + GUESS=hppa64-unknown-linux-$LIBC + ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; + PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; + *) GUESS=hppa-unknown-linux-$LIBC ;; + esac + ;; + ppc64:Linux:*:*) + GUESS=powerpc64-unknown-linux-$LIBC + ;; + ppc:Linux:*:*) + GUESS=powerpc-unknown-linux-$LIBC + ;; + ppc64le:Linux:*:*) + GUESS=powerpc64le-unknown-linux-$LIBC + ;; + ppcle:Linux:*:*) + GUESS=powerpcle-unknown-linux-$LIBC + ;; + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + s390:Linux:*:* | s390x:Linux:*:*) + GUESS=$UNAME_MACHINE-ibm-linux-$LIBC + ;; + sh64*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + sh*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + tile*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + vax:Linux:*:*) + GUESS=$UNAME_MACHINE-dec-linux-$LIBC + ;; + x86_64:Linux:*:*) + set_cc_for_build + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_X32 >/dev/null + then + LIBCABI=${LIBC}x32 + fi + fi + GUESS=$UNAME_MACHINE-pc-linux-$LIBCABI + ;; + xtensa*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + GUESS=i386-sequent-sysv4 + ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION + ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + GUESS=$UNAME_MACHINE-pc-os2-emx + ;; + i*86:XTS-300:*:STOP) + GUESS=$UNAME_MACHINE-unknown-stop + ;; + i*86:atheos:*:*) + GUESS=$UNAME_MACHINE-unknown-atheos + ;; + i*86:syllable:*:*) + GUESS=$UNAME_MACHINE-pc-syllable + ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + GUESS=i386-unknown-lynxos$UNAME_RELEASE + ;; + i*86:*DOS:*:*) + GUESS=$UNAME_MACHINE-pc-msdosdjgpp + ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL + else + GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL + fi + ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL + else + GUESS=$UNAME_MACHINE-pc-sysv32 + fi + ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configure will decide that + # this is a cross-build. + GUESS=i586-pc-msdosdjgpp + ;; + Intel:Mach:3*:*) + GUESS=i386-pc-mach3 + ;; + paragon:*:*:*) + GUESS=i860-intel-osf1 + ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 + fi + ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + GUESS=m68010-convergent-sysv + ;; + mc68k:UNIX:SYSTEM5:3.51m) + GUESS=m68k-convergent-sysv + ;; + M680?0:D-NIX:5.3:*) + GUESS=m68k-diab-dnix + ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + GUESS=m68k-unknown-lynxos$UNAME_RELEASE + ;; + mc68030:UNIX_System_V:4.*:*) + GUESS=m68k-atari-sysv4 + ;; + TSUNAMI:LynxOS:2.*:*) + GUESS=sparc-unknown-lynxos$UNAME_RELEASE + ;; + rs6000:LynxOS:2.*:*) + GUESS=rs6000-unknown-lynxos$UNAME_RELEASE + ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + GUESS=powerpc-unknown-lynxos$UNAME_RELEASE + ;; + SM[BE]S:UNIX_SV:*:*) + GUESS=mips-dde-sysv$UNAME_RELEASE + ;; + RM*:ReliantUNIX-*:*:*) + GUESS=mips-sni-sysv4 + ;; + RM*:SINIX-*:*:*) + GUESS=mips-sni-sysv4 + ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + GUESS=$UNAME_MACHINE-sni-sysv4 + else + GUESS=ns32k-sni-sysv + fi + ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + GUESS=i586-unisys-sysv4 + ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + GUESS=hppa1.1-stratus-sysv4 + ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + GUESS=i860-stratus-sysv4 + ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + GUESS=$UNAME_MACHINE-stratus-vos + ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + GUESS=hppa1.1-stratus-vos + ;; + mc68*:A/UX:*:*) + GUESS=m68k-apple-aux$UNAME_RELEASE + ;; + news*:NEWS-OS:6*:*) + GUESS=mips-sony-newsos6 + ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if test -d /usr/nec; then + GUESS=mips-nec-sysv$UNAME_RELEASE + else + GUESS=mips-unknown-sysv$UNAME_RELEASE + fi + ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + GUESS=powerpc-be-beos + ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + GUESS=powerpc-apple-beos + ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + GUESS=i586-pc-beos + ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + GUESS=i586-pc-haiku + ;; + x86_64:Haiku:*:*) + GUESS=x86_64-unknown-haiku + ;; + SX-4:SUPER-UX:*:*) + GUESS=sx4-nec-superux$UNAME_RELEASE + ;; + SX-5:SUPER-UX:*:*) + GUESS=sx5-nec-superux$UNAME_RELEASE + ;; + SX-6:SUPER-UX:*:*) + GUESS=sx6-nec-superux$UNAME_RELEASE + ;; + SX-7:SUPER-UX:*:*) + GUESS=sx7-nec-superux$UNAME_RELEASE + ;; + SX-8:SUPER-UX:*:*) + GUESS=sx8-nec-superux$UNAME_RELEASE + ;; + SX-8R:SUPER-UX:*:*) + GUESS=sx8r-nec-superux$UNAME_RELEASE + ;; + SX-ACE:SUPER-UX:*:*) + GUESS=sxace-nec-superux$UNAME_RELEASE + ;; + Power*:Rhapsody:*:*) + GUESS=powerpc-apple-rhapsody$UNAME_RELEASE + ;; + *:Rhapsody:*:*) + GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE + ;; + arm64:Darwin:*:*) + GUESS=aarch64-apple-darwin$UNAME_RELEASE + ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build + fi + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE + fi + GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE + ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = x86; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE + ;; + *:QNX:*:4*) + GUESS=i386-pc-qnx + ;; + NEO-*:NONSTOP_KERNEL:*:*) + GUESS=neo-tandem-nsk$UNAME_RELEASE + ;; + NSE-*:NONSTOP_KERNEL:*:*) + GUESS=nse-tandem-nsk$UNAME_RELEASE + ;; + NSR-*:NONSTOP_KERNEL:*:*) + GUESS=nsr-tandem-nsk$UNAME_RELEASE + ;; + NSV-*:NONSTOP_KERNEL:*:*) + GUESS=nsv-tandem-nsk$UNAME_RELEASE + ;; + NSX-*:NONSTOP_KERNEL:*:*) + GUESS=nsx-tandem-nsk$UNAME_RELEASE + ;; + *:NonStop-UX:*:*) + GUESS=mips-compaq-nonstopux + ;; + BS2000:POSIX*:*:*) + GUESS=bs2000-siemens-sysv + ;; + DS/*:UNIX_System_V:*:*) + GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE + ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "${cputype-}" = 386; then + UNAME_MACHINE=i386 + elif test "x${cputype-}" != x; then + UNAME_MACHINE=$cputype + fi + GUESS=$UNAME_MACHINE-unknown-plan9 + ;; + *:TOPS-10:*:*) + GUESS=pdp10-unknown-tops10 + ;; + *:TENEX:*:*) + GUESS=pdp10-unknown-tenex + ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + GUESS=pdp10-dec-tops20 + ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + GUESS=pdp10-xkl-tops20 + ;; + *:TOPS-20:*:*) + GUESS=pdp10-unknown-tops20 + ;; + *:ITS:*:*) + GUESS=pdp10-unknown-its + ;; + SEI:*:*:SEIUX) + GUESS=mips-sei-seiux$UNAME_RELEASE + ;; + *:DragonFly:*:*) + DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL + ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case $UNAME_MACHINE in + A*) GUESS=alpha-dec-vms ;; + I*) GUESS=ia64-dec-vms ;; + V*) GUESS=vax-dec-vms ;; + esac ;; + *:XENIX:*:SysV) + GUESS=i386-pc-xenix + ;; + i*86:skyos:*:*) + SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` + GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL + ;; + i*86:rdos:*:*) + GUESS=$UNAME_MACHINE-pc-rdos + ;; + *:AROS:*:*) + GUESS=$UNAME_MACHINE-unknown-aros + ;; + x86_64:VMkernel:*:*) + GUESS=$UNAME_MACHINE-unknown-esx + ;; + amd64:Isilon\ OneFS:*:*) + GUESS=x86_64-unknown-onefs + ;; + *:Unleashed:*:*) + GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE + ;; +esac + +# Do we have a guess based on uname results? +if test "x$GUESS" != x; then + echo "$GUESS" + exit +fi + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" < +#include +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case $UNAME_MACHINE:$UNAME_SYSTEM in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 <&2 </dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" +EOF +fi + +exit 1 + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/thirdparty/jpeg-9e/config.log b/thirdparty/jpeg-9e/config.log new file mode 100644 index 0000000..cb44440 --- /dev/null +++ b/thirdparty/jpeg-9e/config.log @@ -0,0 +1,856 @@ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by libjpeg configure 9.5.0, which was +generated by GNU Autoconf 2.71. Invocation command line was + + $ ./configure --prefix=/home/scott/code/gui/installed/linux --disable-shared + +## --------- ## +## Platform. ## +## --------- ## + +hostname = kpdev +uname -m = x86_64 +uname -r = 5.14.0-1032-oem +uname -s = Linux +uname -v = #35-Ubuntu SMP Thu Mar 31 12:49:29 UTC 2022 + +/usr/bin/uname -p = x86_64 +/bin/uname -X = unknown + +/bin/arch = x86_64 +/usr/bin/arch -k = unknown +/usr/convex/getsysinfo = unknown +/usr/bin/hostinfo = unknown +/bin/machine = unknown +/usr/bin/oslevel = unknown +/bin/universe = unknown + +PATH: /home/scott/opt/bin/ +PATH: /home/scott/joey/sdks/IIgs/ +PATH: /home/scott/.local/bin/ +PATH: /home/scott/bin/ +PATH: /usr/local/sbin/ +PATH: /usr/local/bin/ +PATH: /usr/sbin/ +PATH: /usr/bin/ +PATH: /sbin/ +PATH: /bin/ +PATH: /usr/games/ +PATH: /usr/local/games/ +PATH: /snap/bin/ + + +## ----------- ## +## Core tests. ## +## ----------- ## + +configure:2455: looking for aux files: ltmain.sh ar-lib compile missing install-sh config.guess config.sub +configure:2468: trying ././ +configure:2497: ././ltmain.sh found +configure:2497: ././ar-lib found +configure:2497: ././compile found +configure:2497: ././missing found +configure:2479: ././install-sh found +configure:2497: ././config.guess found +configure:2497: ././config.sub found +configure:2627: checking build system type +configure:2642: result: x86_64-pc-linux-gnu +configure:2662: checking host system type +configure:2676: result: x86_64-pc-linux-gnu +configure:2696: checking target system type +configure:2710: result: x86_64-pc-linux-gnu +configure:2756: checking for a BSD-compatible install +configure:2829: result: /usr/bin/install -c +configure:2840: checking whether build environment is sane +configure:2895: result: yes +configure:3052: checking for a race-free mkdir -p +configure:3096: result: /usr/bin/mkdir -p +configure:3103: checking for gawk +configure:3124: found /usr/bin/gawk +configure:3135: result: gawk +configure:3146: checking whether make sets $(MAKE) +configure:3169: result: yes +configure:3199: checking whether make supports nested variables +configure:3217: result: yes +configure:3369: checking whether make supports nested variables +configure:3387: result: yes +configure:3403: checking whether to enable maintainer-specific portions of Makefiles +configure:3413: result: no +configure:3490: checking for gcc +configure:3511: found /usr/bin/gcc +configure:3522: result: gcc +configure:3875: checking for C compiler version +configure:3884: gcc --version >&5 +gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 +Copyright (C) 2019 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +configure:3895: $? = 0 +configure:3884: gcc -v >&5 +Using built-in specs. +COLLECT_GCC=gcc +COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper +OFFLOAD_TARGET_NAMES=nvptx-none:hsa +OFFLOAD_TARGET_DEFAULT=1 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) +configure:3895: $? = 0 +configure:3884: gcc -V >&5 +gcc: error: unrecognized command line option '-V' +gcc: fatal error: no input files +compilation terminated. +configure:3895: $? = 1 +configure:3884: gcc -qversion >&5 +gcc: error: unrecognized command line option '-qversion'; did you mean '--version'? +gcc: fatal error: no input files +compilation terminated. +configure:3895: $? = 1 +configure:3884: gcc -version >&5 +gcc: error: unrecognized command line option '-version' +gcc: fatal error: no input files +compilation terminated. +configure:3895: $? = 1 +configure:3915: checking whether the C compiler works +configure:3937: gcc conftest.c >&5 +configure:3941: $? = 0 +configure:3991: result: yes +configure:3994: checking for C compiler default output file name +configure:3996: result: a.out +configure:4002: checking for suffix of executables +configure:4009: gcc -o conftest conftest.c >&5 +configure:4013: $? = 0 +configure:4036: result: +configure:4058: checking whether we are cross compiling +configure:4066: gcc -o conftest conftest.c >&5 +configure:4070: $? = 0 +configure:4077: ./conftest +configure:4081: $? = 0 +configure:4069: result: no +configure:4074: checking for suffix of object files +configure:4097: gcc -c conftest.c >&5 +configure:4101: $? = 0 +configure:4123: result: o +configure:4127: checking whether the compiler supports GNU C +configure:4147: gcc -c conftest.c >&5 +configure:4147: $? = 0 +configure:4157: result: yes +configure:4168: checking whether gcc accepts -g +configure:4189: gcc -c -g conftest.c >&5 +configure:4189: $? = 0 +configure:4233: result: yes +configure:4253: checking for gcc option to enable C11 features +configure:4268: gcc -c -g -O2 conftest.c >&5 +configure:4268: $? = 0 +configure:4286: result: none needed +configure:4402: checking whether gcc understands -c and -o together +configure:4425: gcc -c conftest.c -o conftest2.o +configure:4428: $? = 0 +configure:4425: gcc -c conftest.c -o conftest2.o +configure:4428: $? = 0 +configure:4440: result: yes +configure:4460: checking whether make supports the include directive +configure:4475: make -f confmf.GNU && cat confinc.out +this is the am__doit target +configure:4478: $? = 0 +configure:4497: result: yes (GNU style) +configure:4523: checking dependency style of gcc +configure:4635: result: gcc3 +configure:4655: checking how to run the C preprocessor +configure:4681: gcc -E conftest.c +configure:4681: $? = 0 +configure:4696: gcc -E conftest.c +conftest.c:11:10: fatal error: ac_nonexistent.h: No such file or directory + 11 | #include + | ^~~~~~~~~~~~~~~~~~ +compilation terminated. +configure:4696: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "libjpeg" +| #define PACKAGE_TARNAME "libjpeg" +| #define PACKAGE_VERSION "9.5.0" +| #define PACKAGE_STRING "libjpeg 9.5.0" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE_URL "" +| #define PACKAGE "libjpeg" +| #define VERSION "9.5.0" +| /* end confdefs.h. */ +| #include +configure:4723: result: gcc -E +configure:4737: gcc -E conftest.c +configure:4737: $? = 0 +configure:4752: gcc -E conftest.c +conftest.c:11:10: fatal error: ac_nonexistent.h: No such file or directory + 11 | #include + | ^~~~~~~~~~~~~~~~~~ +compilation terminated. +configure:4752: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "libjpeg" +| #define PACKAGE_TARNAME "libjpeg" +| #define PACKAGE_VERSION "9.5.0" +| #define PACKAGE_STRING "libjpeg 9.5.0" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE_URL "" +| #define PACKAGE "libjpeg" +| #define VERSION "9.5.0" +| /* end confdefs.h. */ +| #include +configure:4783: checking whether make sets $(MAKE) +configure:4806: result: yes +configure:4815: checking whether ln -s works +configure:4819: result: yes +configure:4826: checking for grep that handles long lines and -e +configure:4890: result: /usr/bin/grep +configure:4895: checking for egrep +configure:4963: result: /usr/bin/grep -E +configure:5024: checking for ar +configure:5045: found /usr/bin/ar +configure:5056: result: ar +configure:5082: checking the archiver (ar) interface +configure:5099: gcc -c -g -O2 conftest.c >&5 +configure:5099: $? = 0 +configure:5102: ar cru libconftest.a conftest.o >&5 +ar: `u' modifier ignored since `D' is the default (see `U') +configure:5105: $? = 0 +configure:5104: result: ar +configure:5134: checking if LD -Wl,--version-script works +configure:5158: gcc -o conftest -g -O2 -Wl,--version-script=conftest.map conftest.c >&5 +configure:5158: $? = 0 +configure:5168: result: yes +configure:5181: checking for function prototypes +configure:5202: gcc -c -g -O2 conftest.c >&5 +configure:5202: $? = 0 +configure:5211: result: yes +configure:5235: checking for stdio.h +configure:5235: gcc -c -g -O2 conftest.c >&5 +configure:5235: $? = 0 +configure:5235: result: yes +configure:5235: checking for stdlib.h +configure:5235: gcc -c -g -O2 conftest.c >&5 +configure:5235: $? = 0 +configure:5235: result: yes +configure:5235: checking for string.h +configure:5235: gcc -c -g -O2 conftest.c >&5 +configure:5235: $? = 0 +configure:5235: result: yes +configure:5235: checking for inttypes.h +configure:5235: gcc -c -g -O2 conftest.c >&5 +configure:5235: $? = 0 +configure:5235: result: yes +configure:5235: checking for stdint.h +configure:5235: gcc -c -g -O2 conftest.c >&5 +configure:5235: $? = 0 +configure:5235: result: yes +configure:5235: checking for strings.h +configure:5235: gcc -c -g -O2 conftest.c >&5 +configure:5235: $? = 0 +configure:5235: result: yes +configure:5235: checking for sys/stat.h +configure:5235: gcc -c -g -O2 conftest.c >&5 +configure:5235: $? = 0 +configure:5235: result: yes +configure:5235: checking for sys/types.h +configure:5235: gcc -c -g -O2 conftest.c >&5 +configure:5235: $? = 0 +configure:5235: result: yes +configure:5235: checking for unistd.h +configure:5235: gcc -c -g -O2 conftest.c >&5 +configure:5235: $? = 0 +configure:5235: result: yes +configure:5260: checking for stddef.h +configure:5260: gcc -c -g -O2 conftest.c >&5 +configure:5260: $? = 0 +configure:5260: result: yes +configure:5266: checking for stdlib.h +configure:5266: result: yes +configure:5272: checking for locale.h +configure:5272: gcc -c -g -O2 conftest.c >&5 +configure:5272: $? = 0 +configure:5272: result: yes +configure:5279: checking for string.h +configure:5279: result: yes +configure:5292: checking for size_t +configure:5319: gcc -c -g -O2 conftest.c >&5 +configure:5319: $? = 0 +configure:5326: result: yes +configure:5364: checking for type unsigned char +configure:5377: gcc -c -g -O2 conftest.c >&5 +configure:5377: $? = 0 +configure:5379: result: yes +configure:5390: checking for type unsigned short +configure:5403: gcc -c -g -O2 conftest.c >&5 +configure:5403: $? = 0 +configure:5405: result: yes +configure:5416: checking for type void +configure:5450: gcc -c -g -O2 conftest.c >&5 +configure:5450: $? = 0 +configure:5452: result: yes +configure:5462: checking for an ANSI C-conforming const +configure:5529: gcc -c -g -O2 conftest.c >&5 +configure:5529: $? = 0 +configure:5537: result: yes +configure:5547: checking for inline +configure:5562: gcc -c -g -O2 conftest.c >&5 +configure:5562: $? = 0 +configure:5603: result: __inline__ +configure:5610: checking for broken incomplete types +configure:5625: gcc -c -g -O2 conftest.c >&5 +configure:5625: $? = 0 +configure:5627: result: ok +configure:5639: checking for short external names +configure:5655: gcc -o conftest -g -O2 conftest.c >&5 +configure:5655: $? = 0 +configure:5657: result: ok +configure:5670: checking to see if char is signed +configure:5708: gcc -o conftest -g -O2 conftest.c >&5 +configure:5708: $? = 0 +configure:5708: ./conftest +configure:5708: $? = 1 +configure: program exited with status 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "libjpeg" +| #define PACKAGE_TARNAME "libjpeg" +| #define PACKAGE_VERSION "9.5.0" +| #define PACKAGE_STRING "libjpeg 9.5.0" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE_URL "" +| #define PACKAGE "libjpeg" +| #define VERSION "9.5.0" +| #define HAVE_PROTOTYPES 1 +| #define HAVE_STDIO_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_UNISTD_H 1 +| #define STDC_HEADERS 1 +| #define HAVE_STDDEF_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_LOCALE_H 1 +| #define HAVE_UNSIGNED_CHAR 1 +| #define HAVE_UNSIGNED_SHORT 1 +| #define INLINE __inline__ +| /* end confdefs.h. */ +| +| #ifdef HAVE_STDLIB_H +| #include +| #endif +| #include +| #ifdef HAVE_PROTOTYPES +| int is_char_signed (int arg) +| #else +| int is_char_signed (arg) +| int arg; +| #endif +| { +| if (arg == 189) { /* expected result for unsigned char */ +| return 0; /* type char is unsigned */ +| } +| else if (arg != -67) { /* expected result for signed char */ +| printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); +| printf("I fear the JPEG software will not work at all.\n\n"); +| } +| return 1; /* assume char is signed otherwise */ +| } +| char signed_char_check = (char) (-67); +| int main() { +| exit(is_char_signed((int) signed_char_check)); +| } +configure:5716: result: yes +configure:5724: checking to see if right shift is signed +configure:5765: gcc -o conftest -g -O2 conftest.c >&5 +configure:5765: $? = 0 +configure:5765: ./conftest +configure:5765: $? = 1 +configure: program exited with status 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "libjpeg" +| #define PACKAGE_TARNAME "libjpeg" +| #define PACKAGE_VERSION "9.5.0" +| #define PACKAGE_STRING "libjpeg 9.5.0" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE_URL "" +| #define PACKAGE "libjpeg" +| #define VERSION "9.5.0" +| #define HAVE_PROTOTYPES 1 +| #define HAVE_STDIO_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_UNISTD_H 1 +| #define STDC_HEADERS 1 +| #define HAVE_STDDEF_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_LOCALE_H 1 +| #define HAVE_UNSIGNED_CHAR 1 +| #define HAVE_UNSIGNED_SHORT 1 +| #define INLINE __inline__ +| /* end confdefs.h. */ +| +| #ifdef HAVE_STDLIB_H +| #include +| #endif +| #include +| #ifdef HAVE_PROTOTYPES +| int is_shifting_signed (long arg) +| #else +| int is_shifting_signed (arg) +| long arg; +| #endif +| /* See whether right-shift on a long is signed or not. */ +| { +| long res = arg >> 4; +| +| if (res == -0x7F7E80CL) { /* expected result for signed shift */ +| return 1; /* right shift is signed */ +| } +| /* see if unsigned-shift hack will fix it. */ +| /* we can't just test exact value since it depends on width of long... */ +| res |= (~0L) << (32-4); +| if (res == -0x7F7E80CL) { /* expected result now? */ +| return 0; /* right shift is unsigned */ +| } +| printf("Right shift isn't acting as I expect it to.\n"); +| printf("I fear the JPEG software will not work at all.\n\n"); +| return 0; /* try it with unsigned anyway */ +| } +| int main() { +| exit(is_shifting_signed(-0x7F7E80B1L)); +| } +configure:5773: result: yes +configure:5781: checking to see if fopen accepts b spec +configure:5801: gcc -o conftest -g -O2 conftest.c >&5 +configure:5801: $? = 0 +configure:5801: ./conftest +configure:5801: $? = 0 +configure:5803: result: yes +configure:5865: checking how to print strings +configure:5892: result: printf +configure:5913: checking for a sed that does not truncate output +configure:5983: result: /usr/bin/sed +configure:6001: checking for fgrep +configure:6069: result: /usr/bin/grep -F +configure:6105: checking for ld used by gcc +configure:6173: result: /usr/bin/ld +configure:6180: checking if the linker (/usr/bin/ld) is GNU ld +configure:6196: result: yes +configure:6208: checking for BSD- or MS-compatible name lister (nm) +configure:6263: result: /usr/bin/nm -B +configure:6403: checking the name lister (/usr/bin/nm -B) interface +configure:6411: gcc -c -g -O2 conftest.c >&5 +configure:6414: /usr/bin/nm -B "conftest.o" +configure:6417: output +0000000000000000 B some_variable +configure:6418: result: BSD nm +configure:6422: checking the maximum length of command line arguments +configure:6554: result: 1572864 +configure:6602: checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format +configure:6643: result: func_convert_file_noop +configure:6650: checking how to convert x86_64-pc-linux-gnu file names to toolchain format +configure:6671: result: func_convert_file_noop +configure:6678: checking for /usr/bin/ld option to reload object files +configure:6686: result: -r +configure:6765: checking for objdump +configure:6786: found /usr/bin/objdump +configure:6797: result: objdump +configure:6826: checking how to recognize dependent libraries +configure:7027: result: pass_all +configure:7117: checking for dlltool +configure:7152: result: no +configure:7179: checking how to associate runtime and link libraries +configure:7207: result: printf %s\n +configure:7341: checking for archiver @FILE support +configure:7359: gcc -c -g -O2 conftest.c >&5 +configure:7359: $? = 0 +configure:7363: ar cru libconftest.a @conftest.lst >&5 +ar: `u' modifier ignored since `D' is the default (see `U') +configure:7366: $? = 0 +configure:7371: ar cru libconftest.a @conftest.lst >&5 +ar: `u' modifier ignored since `D' is the default (see `U') +ar: conftest.o: No such file or directory +configure:7374: $? = 1 +configure:7373: result: @ +configure:7436: checking for strip +configure:7457: found /usr/bin/strip +configure:7468: result: strip +configure:7545: checking for ranlib +configure:7566: found /usr/bin/ranlib +configure:7577: result: ranlib +configure:7679: checking command to parse /usr/bin/nm -B output from gcc object +configure:7833: gcc -c -g -O2 conftest.c >&5 +configure:7836: $? = 0 +configure:7840: /usr/bin/nm -B conftest.o \| sed -n -e 's/^.*[ ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | sed '/ __gnu_lto/d' \> conftest.nm +configure:7843: $? = 0 +configure:7909: gcc -o conftest -g -O2 conftest.c conftstm.o >&5 +configure:7912: $? = 0 +configure:7950: result: ok +configure:7997: checking for sysroot +configure:8028: result: no +configure:8035: checking for a working dd +configure:8079: result: /usr/bin/dd +configure:8083: checking how to truncate binary pipes +configure:8099: result: /usr/bin/dd bs=4096 count=1 +configure:8236: gcc -c -g -O2 conftest.c >&5 +configure:8239: $? = 0 +configure:8436: checking for mt +configure:8457: found /usr/bin/mt +configure:8468: result: mt +configure:8491: checking if mt is a manifest tool +configure:8498: mt '-?' +configure:8506: result: no +configure:9232: checking for dlfcn.h +configure:9232: gcc -c -g -O2 conftest.c >&5 +configure:9232: $? = 0 +configure:9232: result: yes +configure:9819: checking for objdir +configure:9835: result: .libs +configure:10095: checking if gcc supports -fno-rtti -fno-exceptions +configure:10114: gcc -c -g -O2 -fno-rtti -fno-exceptions conftest.c >&5 +cc1: warning: command line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C +configure:10118: $? = 0 +configure:10131: result: no +configure:10489: checking for gcc option to produce PIC +configure:10497: result: -fPIC -DPIC +configure:10505: checking if gcc PIC flag -fPIC -DPIC works +configure:10524: gcc -c -g -O2 -fPIC -DPIC -DPIC conftest.c >&5 +configure:10528: $? = 0 +configure:10541: result: yes +configure:10570: checking if gcc static flag -static works +configure:10599: result: yes +configure:10614: checking if gcc supports -c -o file.o +configure:10636: gcc -c -g -O2 -o out/conftest2.o conftest.c >&5 +configure:10640: $? = 0 +configure:10662: result: yes +configure:10670: checking if gcc supports -c -o file.o +configure:10718: result: yes +configure:10751: checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries +configure:12017: result: yes +configure:12258: checking dynamic linker characteristics +configure:12840: gcc -o conftest -g -O2 -Wl,-rpath -Wl,/foo conftest.c >&5 +configure:12840: $? = 0 +configure:13079: result: GNU/Linux ld.so +configure:13201: checking how to hardcode library paths into programs +configure:13226: result: immediate +configure:13778: checking whether stripping libraries is possible +configure:13783: result: yes +configure:13818: checking if libtool supports shared libraries +configure:13820: result: yes +configure:13823: checking whether to build shared libraries +configure:13848: result: no +configure:13851: checking whether to build static libraries +configure:13855: result: yes +configure:10751: checking libjpeg version number +configure:10761: result: 9.5.0 +configure:10867: checking that generated files are newer than configure +configure:10873: result: done +configure:10904: creating ./config.status + +## ---------------------- ## +## Running config.status. ## +## ---------------------- ## + +This file was extended by libjpeg config.status 9.5.0, which was +generated by GNU Autoconf 2.71. Invocation command line was + + CONFIG_FILES = + CONFIG_HEADERS = + CONFIG_LINKS = + CONFIG_COMMANDS = + $ ./config.status + +on kpdev + +config.status:1099: creating Makefile +config.status:1099: creating libjpeg.pc +config.status:1099: creating jconfig.h +config.status:1328: executing depfiles commands +config.status:1405: cd . && sed -e '/# am--include-marker/d' Makefile | make -f - am--depfiles +make: Nothing to be done for 'am--depfiles'. +config.status:1410: $? = 0 +config.status:1328: executing libtool commands + +## ---------------- ## +## Cache variables. ## +## ---------------- ## + +ac_cv_build=x86_64-pc-linux-gnu +ac_cv_c_compiler_gnu=yes +ac_cv_c_const=yes +ac_cv_env_CC_set= +ac_cv_env_CC_value= +ac_cv_env_CFLAGS_set= +ac_cv_env_CFLAGS_value= +ac_cv_env_CPPFLAGS_set= +ac_cv_env_CPPFLAGS_value= +ac_cv_env_CPP_set= +ac_cv_env_CPP_value= +ac_cv_env_LDFLAGS_set= +ac_cv_env_LDFLAGS_value= +ac_cv_env_LIBS_set= +ac_cv_env_LIBS_value= +ac_cv_env_LT_SYS_LIBRARY_PATH_set= +ac_cv_env_LT_SYS_LIBRARY_PATH_value= +ac_cv_env_build_alias_set= +ac_cv_env_build_alias_value= +ac_cv_env_host_alias_set= +ac_cv_env_host_alias_value= +ac_cv_env_target_alias_set= +ac_cv_env_target_alias_value= +ac_cv_header_dlfcn_h=yes +ac_cv_header_inttypes_h=yes +ac_cv_header_locale_h=yes +ac_cv_header_stddef_h=yes +ac_cv_header_stdint_h=yes +ac_cv_header_stdio_h=yes +ac_cv_header_stdlib_h=yes +ac_cv_header_string_h=yes +ac_cv_header_strings_h=yes +ac_cv_header_sys_stat_h=yes +ac_cv_header_sys_types_h=yes +ac_cv_header_unistd_h=yes +ac_cv_host=x86_64-pc-linux-gnu +ac_cv_objext=o +ac_cv_path_EGREP='/usr/bin/grep -E' +ac_cv_path_FGREP='/usr/bin/grep -F' +ac_cv_path_GREP=/usr/bin/grep +ac_cv_path_SED=/usr/bin/sed +ac_cv_path_install='/usr/bin/install -c' +ac_cv_path_lt_DD=/usr/bin/dd +ac_cv_path_mkdir=/usr/bin/mkdir +ac_cv_prog_AWK=gawk +ac_cv_prog_CPP='gcc -E' +ac_cv_prog_ac_ct_AR=ar +ac_cv_prog_ac_ct_CC=gcc +ac_cv_prog_ac_ct_MANIFEST_TOOL=mt +ac_cv_prog_ac_ct_OBJDUMP=objdump +ac_cv_prog_ac_ct_RANLIB=ranlib +ac_cv_prog_ac_ct_STRIP=strip +ac_cv_prog_cc_c11= +ac_cv_prog_cc_g=yes +ac_cv_prog_cc_stdc= +ac_cv_prog_make_make_set=yes +ac_cv_target=x86_64-pc-linux-gnu +am_cv_CC_dependencies_compiler_type=gcc3 +am_cv_ar_interface=ar +am_cv_make_support_nested_variables=yes +am_cv_prog_cc_c_o=yes +ijg_cv_have_prototypes=yes +ijg_cv_inline=__inline__ +lt_cv_ar_at_file=@ +lt_cv_deplibs_check_method=pass_all +lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_ld_reload_flag=-r +lt_cv_nm_interface='BSD nm' +lt_cv_objdir=.libs +lt_cv_path_LD=/usr/bin/ld +lt_cv_path_NM='/usr/bin/nm -B' +lt_cv_path_mainfest_tool=no +lt_cv_prog_compiler_c_o=yes +lt_cv_prog_compiler_pic='-fPIC -DPIC' +lt_cv_prog_compiler_pic_works=yes +lt_cv_prog_compiler_rtti_exceptions=no +lt_cv_prog_compiler_static_works=yes +lt_cv_prog_gnu_ld=yes +lt_cv_sharedlib_from_linklib_cmd='printf %s\n' +lt_cv_shlibpath_overrides_runpath=yes +lt_cv_sys_global_symbol_pipe='sed -n -e '\''s/^.*[ ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p'\'' | sed '\''/ __gnu_lto/d'\''' +lt_cv_sys_global_symbol_to_c_name_address='sed -n -e '\''s/^: \(.*\) .*$/ {"\1", (void *) 0},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/ {"\1", (void *) \&\1},/p'\''' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='sed -n -e '\''s/^: \(.*\) .*$/ {"\1", (void *) 0},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(lib.*\)$/ {"\1", (void *) \&\1},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/ {"lib\1", (void *) \&\1},/p'\''' +lt_cv_sys_global_symbol_to_cdecl='sed -n -e '\''s/^T .* \(.*\)$/extern int \1();/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/extern char \1;/p'\''' +lt_cv_sys_global_symbol_to_import= +lt_cv_sys_max_cmd_len=1572864 +lt_cv_to_host_file_cmd=func_convert_file_noop +lt_cv_to_tool_file_cmd=func_convert_file_noop +lt_cv_truncate_bin='/usr/bin/dd bs=4096 count=1' + +## ----------------- ## +## Output variables. ## +## ----------------- ## + +ACLOCAL='${SHELL} '\''/home/scott/code/gui/thirdparty/jpeg-9e/missing'\'' aclocal-1.16' +AMDEPBACKSLASH='\' +AMDEP_FALSE='#' +AMDEP_TRUE='' +AMTAR='$${TAR-tar}' +AM_BACKSLASH='\' +AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +AM_DEFAULT_VERBOSITY='0' +AM_V='$(V)' +AR='ar' +AS='as' +AUTOCONF='${SHELL} '\''/home/scott/code/gui/thirdparty/jpeg-9e/missing'\'' autoconf' +AUTOHEADER='echo autoheader ignored' +AUTOMAKE='${SHELL} '\''/home/scott/code/gui/thirdparty/jpeg-9e/missing'\'' automake-1.16' +AWK='gawk' +CC='gcc' +CCDEPMODE='depmode=gcc3' +CFLAGS='-g -O2' +CPP='gcc -E' +CPPFLAGS='' +CSCOPE='cscope' +CTAGS='ctags' +CYGPATH_W='echo' +DEFS='-DHAVE_CONFIG_H' +DEPDIR='.deps' +DLLTOOL='false' +DSYMUTIL='' +DUMPBIN='' +ECHO_C='' +ECHO_N='-n' +ECHO_T='' +EGREP='/usr/bin/grep -E' +ETAGS='etags' +EXEEXT='' +FGREP='/usr/bin/grep -F' +GREP='/usr/bin/grep' +HAVE_LD_VERSION_SCRIPT_FALSE='#' +HAVE_LD_VERSION_SCRIPT_TRUE='' +INSTALL_DATA='${INSTALL} -m 644' +INSTALL_PROGRAM='${INSTALL}' +INSTALL_SCRIPT='${INSTALL}' +INSTALL_STRIP_PROGRAM='$(install_sh) -c -s' +JPEG_LIB_VERSION='14:0:5' +JPEG_LIB_VERSION_MAJOR='9' +JPEG_LIB_VERSION_MINOR='5' +LD='/usr/bin/ld -m elf_x86_64' +LDFLAGS='' +LIBOBJS='' +LIBS='' +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +LIPO='' +LN_S='ln -s' +LTLIBOBJS='' +LT_SYS_LIBRARY_PATH='' +MAINT='#' +MAINTAINER_MODE_FALSE='' +MAINTAINER_MODE_TRUE='#' +MAKEINFO='${SHELL} '\''/home/scott/code/gui/thirdparty/jpeg-9e/missing'\'' makeinfo' +MANIFEST_TOOL=':' +MEMORYMGR='jmemnobs' +MKDIR_P='/usr/bin/mkdir -p' +NM='/usr/bin/nm -B' +NMEDIT='' +OBJDUMP='objdump' +OBJEXT='o' +OTOOL64='' +OTOOL='' +PACKAGE='libjpeg' +PACKAGE_BUGREPORT='' +PACKAGE_NAME='libjpeg' +PACKAGE_STRING='libjpeg 9.5.0' +PACKAGE_TARNAME='libjpeg' +PACKAGE_URL='' +PACKAGE_VERSION='9.5.0' +PATH_SEPARATOR=':' +RANLIB='ranlib' +SED='/usr/bin/sed' +SET_MAKE='' +SHELL='/bin/bash' +STRIP='strip' +VERSION='9.5.0' +ac_ct_AR='ar' +ac_ct_CC='gcc' +ac_ct_DUMPBIN='' +am__EXEEXT_FALSE='' +am__EXEEXT_TRUE='#' +am__fastdepCC_FALSE='#' +am__fastdepCC_TRUE='' +am__include='include' +am__isrc='' +am__leading_dot='.' +am__nodep='_no' +am__quote='' +am__tar='$${TAR-tar} chof - "$$tardir"' +am__untar='$${TAR-tar} xf -' +bindir='${exec_prefix}/bin' +build='x86_64-pc-linux-gnu' +build_alias='' +build_cpu='x86_64' +build_os='linux-gnu' +build_vendor='pc' +datadir='${datarootdir}' +datarootdir='${prefix}/share' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +dvidir='${docdir}' +exec_prefix='${prefix}' +host='x86_64-pc-linux-gnu' +host_alias='' +host_cpu='x86_64' +host_os='linux-gnu' +host_vendor='pc' +htmldir='${docdir}' +includedir='${prefix}/include' +infodir='${datarootdir}/info' +install_sh='${SHELL} /home/scott/code/gui/thirdparty/jpeg-9e/install-sh' +libdir='${exec_prefix}/lib' +libexecdir='${exec_prefix}/libexec' +localedir='${datarootdir}/locale' +localstatedir='${prefix}/var' +mandir='${datarootdir}/man' +mkdir_p='$(MKDIR_P)' +oldincludedir='/usr/include' +pdfdir='${docdir}' +prefix='/home/scott/code/gui/installed/linux' +program_transform_name='s,x,x,' +psdir='${docdir}' +runstatedir='${localstatedir}/run' +sbindir='${exec_prefix}/sbin' +sharedstatedir='${prefix}/com' +sysconfdir='${prefix}/etc' +target='x86_64-pc-linux-gnu' +target_alias='' +target_cpu='x86_64' +target_os='linux-gnu' +target_vendor='pc' + +## ----------- ## +## confdefs.h. ## +## ----------- ## + +/* confdefs.h */ +#define PACKAGE_NAME "libjpeg" +#define PACKAGE_TARNAME "libjpeg" +#define PACKAGE_VERSION "9.5.0" +#define PACKAGE_STRING "libjpeg 9.5.0" +#define PACKAGE_BUGREPORT "" +#define PACKAGE_URL "" +#define PACKAGE "libjpeg" +#define VERSION "9.5.0" +#define HAVE_PROTOTYPES 1 +#define HAVE_STDIO_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_UNISTD_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_LOCALE_H 1 +#define HAVE_UNSIGNED_CHAR 1 +#define HAVE_UNSIGNED_SHORT 1 +#define INLINE __inline__ +#define HAVE_DLFCN_H 1 +#define LT_OBJDIR ".libs/" + +configure: exit 0 diff --git a/thirdparty/jpeg-9e/config.status b/thirdparty/jpeg-9e/config.status new file mode 100755 index 0000000..174b950 --- /dev/null +++ b/thirdparty/jpeg-9e/config.status @@ -0,0 +1,1987 @@ +#! /bin/bash +# Generated by configure. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=${CONFIG_SHELL-/bin/bash} +export SHELL +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +as_nop=: +if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 +then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else $as_nop + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + + +# Reset variables that may have inherited troublesome values from +# the environment. + +# IFS needs to be set, to space, tab, and newline, in precisely that order. +# (If _AS_PATH_WALK were called with IFS unset, it would have the +# side effect of setting IFS to empty, thus disabling word splitting.) +# Quoting is to prevent editors from complaining about space-tab. +as_nl=' +' +export as_nl +IFS=" "" $as_nl" + +PS1='$ ' +PS2='> ' +PS4='+ ' + +# Ensure predictable behavior from utilities with locale-dependent output. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# We cannot yet rely on "unset" to work, but we need these variables +# to be unset--not just set to an empty or harmless value--now, to +# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct +# also avoids known problems related to "unset" and subshell syntax +# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). +for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH +do eval test \${$as_var+y} \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done + +# Ensure that fds 0, 1, and 2 are open. +if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi +if (exec 3>&2) ; then :; else exec 2>/dev/null; fi + +# The user is always right. +if ${PATH_SEPARATOR+false} :; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + test -r "$as_dir$0" && as_myself=$as_dir$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + printf "%s\n" "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null +then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else $as_nop + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null +then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else $as_nop + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + +# Determine whether it's possible to make 'echo' print without a newline. +# These variables are no longer used directly by Autoconf, but are AC_SUBSTed +# for compatibility with existing Makefiles. +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +# For backward compatibility with old third-party macros, we provide +# the shell variables $as_echo and $as_echo_n. New code should use +# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. +as_echo='printf %s\n' +as_echo_n='printf %s' + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by libjpeg $as_me 9.5.0, which was +generated by GNU Autoconf 2.71. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +# Files that config.status was made for. +config_files=" Makefile libjpeg.pc" +config_headers=" jconfig.h:jconfig.cfg" +config_commands=" depfiles libtool" + +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to the package provider." + +ac_cs_config='--prefix=/home/scott/code/gui/installed/linux --disable-shared' +ac_cs_version="\ +libjpeg config.status 9.5.0 +configured by ./configure, generated by GNU Autoconf 2.71, + with options \"$ac_cs_config\" + +Copyright (C) 2021 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='/home/scott/code/gui/thirdparty/jpeg-9e' +srcdir='.' +INSTALL='/usr/bin/install -c' +MKDIR_P='/usr/bin/mkdir -p' +AWK='gawk' +test -n "$AWK" || AWK=awk +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + printf "%s\n" "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + printf "%s\n" "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + printf "%s\n" "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +if $ac_cs_recheck; then + set X /bin/bash './configure' '--prefix=/home/scott/code/gui/installed/linux' '--disable-shared' $ac_configure_extra_args --no-create --no-recursion + shift + \printf "%s\n" "running CONFIG_SHELL=/bin/bash $*" >&6 + CONFIG_SHELL='/bin/bash' + export CONFIG_SHELL + exec "$@" +fi + +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + printf "%s\n" "$ac_log" +} >&5 + +# +# INIT-COMMANDS +# +AMDEP_TRUE="" MAKE="make" + + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +double_quote_subst='s/\(["`\\]\)/\\\1/g' +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' +macro_version='2.4.6' +macro_revision='2.4.6' +AS='as' +DLLTOOL='false' +OBJDUMP='objdump' +enable_shared='no' +enable_static='yes' +pic_mode='default' +enable_fast_install='needless' +shared_archive_member_spec='' +SHELL='/bin/bash' +ECHO='printf %s\n' +PATH_SEPARATOR=':' +host_alias='' +host='x86_64-pc-linux-gnu' +host_os='linux-gnu' +build_alias='' +build='x86_64-pc-linux-gnu' +build_os='linux-gnu' +SED='/usr/bin/sed' +Xsed='/usr/bin/sed -e 1s/^X//' +GREP='/usr/bin/grep' +EGREP='/usr/bin/grep -E' +FGREP='/usr/bin/grep -F' +LD='/usr/bin/ld -m elf_x86_64' +NM='/usr/bin/nm -B' +LN_S='ln -s' +max_cmd_len='1572864' +ac_objext='o' +exeext='' +lt_unset='unset' +lt_SP2NL='tr \040 \012' +lt_NL2SP='tr \015\012 \040\040' +lt_cv_to_host_file_cmd='func_convert_file_noop' +lt_cv_to_tool_file_cmd='func_convert_file_noop' +reload_flag=' -r' +reload_cmds='$LD$reload_flag -o $output$reload_objs' +deplibs_check_method='pass_all' +file_magic_cmd='$MAGIC_CMD' +file_magic_glob='' +want_nocaseglob='no' +sharedlib_from_linklib_cmd='printf %s\n' +AR='ar' +AR_FLAGS='cru' +archiver_list_spec='@' +STRIP='strip' +RANLIB='ranlib' +old_postinstall_cmds='chmod 644 $oldlib~$RANLIB $tool_oldlib' +old_postuninstall_cmds='' +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs~$RANLIB $tool_oldlib' +lock_old_archive_extraction='no' +CC='gcc' +CFLAGS='-g -O2' +compiler='gcc' +GCC='yes' +lt_cv_sys_global_symbol_pipe='sed -n -e '\''s/^.*[ ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p'\'' | sed '\''/ __gnu_lto/d'\''' +lt_cv_sys_global_symbol_to_cdecl='sed -n -e '\''s/^T .* \(.*\)$/extern int \1();/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/extern char \1;/p'\''' +lt_cv_sys_global_symbol_to_import='' +lt_cv_sys_global_symbol_to_c_name_address='sed -n -e '\''s/^: \(.*\) .*$/ {"\1", (void *) 0},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/ {"\1", (void *) \&\1},/p'\''' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='sed -n -e '\''s/^: \(.*\) .*$/ {"\1", (void *) 0},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(lib.*\)$/ {"\1", (void *) \&\1},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/ {"lib\1", (void *) \&\1},/p'\''' +lt_cv_nm_interface='BSD nm' +nm_file_list_spec='@' +lt_sysroot='' +lt_cv_truncate_bin='/usr/bin/dd bs=4096 count=1' +objdir='.libs' +MAGIC_CMD='file' +lt_prog_compiler_no_builtin_flag=' -fno-builtin' +lt_prog_compiler_pic=' -fPIC -DPIC' +lt_prog_compiler_wl='-Wl,' +lt_prog_compiler_static='-static' +lt_cv_prog_compiler_c_o='yes' +need_locks='no' +MANIFEST_TOOL=':' +DSYMUTIL='' +NMEDIT='' +LIPO='' +OTOOL='' +OTOOL64='' +libext='a' +shrext_cmds='.so' +extract_expsyms_cmds='' +archive_cmds_need_lc='yes' +enable_shared_with_static_runtimes='no' +export_dynamic_flag_spec='$wl--export-dynamic' +whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' +compiler_needs_object='no' +old_archive_from_new_cmds='' +old_archive_from_expsyms_cmds='' +archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' +archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' +module_cmds='' +module_expsym_cmds='' +with_gnu_ld='yes' +allow_undefined_flag='' +no_undefined_flag='' +hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' +hardcode_libdir_separator='' +hardcode_direct='no' +hardcode_direct_absolute='no' +hardcode_minus_L='no' +hardcode_shlibpath_var='unsupported' +hardcode_automatic='no' +inherit_rpath='no' +link_all_deplibs='unknown' +always_export_symbols='no' +export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' +exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' +include_expsyms='' +prelink_cmds='' +postlink_cmds='' +file_list_spec='' +variables_saved_for_relink='PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH' +need_lib_prefix='no' +need_version='no' +version_type='linux' +runpath_var='LD_RUN_PATH' +shlibpath_var='LD_LIBRARY_PATH' +shlibpath_overrides_runpath='yes' +libname_spec='lib$name' +library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' +soname_spec='$libname$release$shared_ext$major' +install_override_mode='' +postinstall_cmds='' +postuninstall_cmds='' +finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' +finish_eval='' +hardcode_into_libs='yes' +sys_lib_search_path_spec='/usr/lib/gcc/x86_64-linux-gnu/9 /usr/lib/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib ' +configure_time_dlsearch_path='/lib /usr/lib /usr/lib/x86_64-linux-gnu/libfakeroot /usr/local/lib/i386-linux-gnu /lib/i386-linux-gnu /usr/lib/i386-linux-gnu /usr/local/lib/i686-linux-gnu /lib/i686-linux-gnu /usr/lib/i686-linux-gnu /usr/local/lib /usr/local/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /lib32 /usr/lib32 /libx32 /usr/libx32 ' +configure_time_lt_sys_library_path='' +hardcode_action='immediate' +enable_dlopen='unknown' +enable_dlopen_self='unknown' +enable_dlopen_self_static='unknown' +old_striplib='strip --strip-debug' +striplib='strip --strip-unneeded' + +LTCC='gcc' +LTCFLAGS='-g -O2' +compiler='gcc' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in AS DLLTOOL OBJDUMP SHELL ECHO PATH_SEPARATOR SED GREP EGREP FGREP LD NM LN_S lt_SP2NL lt_NL2SP reload_flag deplibs_check_method file_magic_cmd file_magic_glob want_nocaseglob sharedlib_from_linklib_cmd AR AR_FLAGS archiver_list_spec STRIP RANLIB CC CFLAGS compiler lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl lt_cv_sys_global_symbol_to_import lt_cv_sys_global_symbol_to_c_name_address lt_cv_sys_global_symbol_to_c_name_address_lib_prefix lt_cv_nm_interface nm_file_list_spec lt_cv_truncate_bin lt_prog_compiler_no_builtin_flag lt_prog_compiler_pic lt_prog_compiler_wl lt_prog_compiler_static lt_cv_prog_compiler_c_o need_locks MANIFEST_TOOL DSYMUTIL NMEDIT LIPO OTOOL OTOOL64 shrext_cmds export_dynamic_flag_spec whole_archive_flag_spec compiler_needs_object with_gnu_ld allow_undefined_flag no_undefined_flag hardcode_libdir_flag_spec hardcode_libdir_separator exclude_expsyms include_expsyms file_list_spec variables_saved_for_relink libname_spec library_names_spec soname_spec install_override_mode finish_eval old_striplib striplib; do + case `eval \\$ECHO \\""\\$$var"\\"` in + *[\\\`\"\$]*) + eval "lt_$var=\\\"\`\$ECHO \"\$$var\" | \$SED \"\$sed_quote_subst\"\`\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_$var=\\\"\$$var\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in reload_cmds old_postinstall_cmds old_postuninstall_cmds old_archive_cmds extract_expsyms_cmds old_archive_from_new_cmds old_archive_from_expsyms_cmds archive_cmds archive_expsym_cmds module_cmds module_expsym_cmds export_symbols_cmds prelink_cmds postlink_cmds postinstall_cmds postuninstall_cmds finish_cmds sys_lib_search_path_spec configure_time_dlsearch_path configure_time_lt_sys_library_path; do + case `eval \\$ECHO \\""\\$$var"\\"` in + *[\\\`\"\$]*) + eval "lt_$var=\\\"\`\$ECHO \"\$$var\" | \$SED -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_$var=\\\"\$$var\\\"" + ;; + esac +done + +ac_aux_dir='././' + +# See if we are running on zsh, and set the options that allow our +# commands through without removal of \ escapes INIT. +if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + + + PACKAGE='libjpeg' + VERSION='9.5.0' + RM='rm -f' + ofile='libtool' + + + + + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "jconfig.h") CONFIG_HEADERS="$CONFIG_HEADERS jconfig.h:jconfig.cfg" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "libjpeg.pc") CONFIG_FILES="$CONFIG_FILES libjpeg.pc" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files + test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers + test ${CONFIG_COMMANDS+y} || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +cat >>"$ac_tmp/subs1.awk" <<\_ACAWK && +S["am__EXEEXT_FALSE"]="" +S["am__EXEEXT_TRUE"]="#" +S["LTLIBOBJS"]="" +S["LIBOBJS"]="" +S["JPEG_LIB_VERSION_MINOR"]="5" +S["JPEG_LIB_VERSION_MAJOR"]="9" +S["JPEG_LIB_VERSION"]="14:0:5" +S["MEMORYMGR"]="jmemnobs" +S["LT_SYS_LIBRARY_PATH"]="" +S["OTOOL64"]="" +S["OTOOL"]="" +S["LIPO"]="" +S["NMEDIT"]="" +S["DSYMUTIL"]="" +S["MANIFEST_TOOL"]=":" +S["RANLIB"]="ranlib" +S["NM"]="/usr/bin/nm -B" +S["ac_ct_DUMPBIN"]="" +S["DUMPBIN"]="" +S["LD"]="/usr/bin/ld -m elf_x86_64" +S["FGREP"]="/usr/bin/grep -F" +S["SED"]="/usr/bin/sed" +S["LIBTOOL"]="$(SHELL) $(top_builddir)/libtool" +S["OBJDUMP"]="objdump" +S["DLLTOOL"]="false" +S["AS"]="as" +S["HAVE_LD_VERSION_SCRIPT_FALSE"]="#" +S["HAVE_LD_VERSION_SCRIPT_TRUE"]="" +S["ac_ct_AR"]="ar" +S["AR"]="ar" +S["EGREP"]="/usr/bin/grep -E" +S["GREP"]="/usr/bin/grep" +S["LN_S"]="ln -s" +S["CPP"]="gcc -E" +S["am__fastdepCC_FALSE"]="#" +S["am__fastdepCC_TRUE"]="" +S["CCDEPMODE"]="depmode=gcc3" +S["am__nodep"]="_no" +S["AMDEPBACKSLASH"]="\\" +S["AMDEP_FALSE"]="#" +S["AMDEP_TRUE"]="" +S["am__include"]="include" +S["DEPDIR"]=".deps" +S["OBJEXT"]="o" +S["EXEEXT"]="" +S["ac_ct_CC"]="gcc" +S["CPPFLAGS"]="" +S["LDFLAGS"]="" +S["CFLAGS"]="-g -O2" +S["CC"]="gcc" +S["MAINT"]="#" +S["MAINTAINER_MODE_FALSE"]="" +S["MAINTAINER_MODE_TRUE"]="#" +S["AM_BACKSLASH"]="\\" +S["AM_DEFAULT_VERBOSITY"]="0" +S["AM_DEFAULT_V"]="$(AM_DEFAULT_VERBOSITY)" +S["AM_V"]="$(V)" +S["CSCOPE"]="cscope" +S["ETAGS"]="etags" +S["CTAGS"]="ctags" +S["am__untar"]="$${TAR-tar} xf -" +S["am__tar"]="$${TAR-tar} chof - \"$$tardir\"" +S["AMTAR"]="$${TAR-tar}" +S["am__leading_dot"]="." +S["SET_MAKE"]="" +S["AWK"]="gawk" +S["mkdir_p"]="$(MKDIR_P)" +S["MKDIR_P"]="/usr/bin/mkdir -p" +S["INSTALL_STRIP_PROGRAM"]="$(install_sh) -c -s" +S["STRIP"]="strip" +S["install_sh"]="${SHELL} /home/scott/code/gui/thirdparty/jpeg-9e/install-sh" +S["MAKEINFO"]="${SHELL} '/home/scott/code/gui/thirdparty/jpeg-9e/missing' makeinfo" +S["AUTOHEADER"]="echo autoheader ignored" +S["AUTOMAKE"]="${SHELL} '/home/scott/code/gui/thirdparty/jpeg-9e/missing' automake-1.16" +S["AUTOCONF"]="${SHELL} '/home/scott/code/gui/thirdparty/jpeg-9e/missing' autoconf" +S["ACLOCAL"]="${SHELL} '/home/scott/code/gui/thirdparty/jpeg-9e/missing' aclocal-1.16" +S["VERSION"]="9.5.0" +S["PACKAGE"]="libjpeg" +S["CYGPATH_W"]="echo" +S["am__isrc"]="" +S["INSTALL_DATA"]="${INSTALL} -m 644" +S["INSTALL_SCRIPT"]="${INSTALL}" +S["INSTALL_PROGRAM"]="${INSTALL}" +S["target_os"]="linux-gnu" +S["target_vendor"]="pc" +S["target_cpu"]="x86_64" +S["target"]="x86_64-pc-linux-gnu" +S["host_os"]="linux-gnu" +S["host_vendor"]="pc" +S["host_cpu"]="x86_64" +S["host"]="x86_64-pc-linux-gnu" +S["build_os"]="linux-gnu" +S["build_vendor"]="pc" +S["build_cpu"]="x86_64" +S["build"]="x86_64-pc-linux-gnu" +S["target_alias"]="" +S["host_alias"]="" +S["build_alias"]="" +S["LIBS"]="" +S["ECHO_T"]="" +S["ECHO_N"]="-n" +S["ECHO_C"]="" +S["DEFS"]="-DHAVE_CONFIG_H" +S["mandir"]="${datarootdir}/man" +S["localedir"]="${datarootdir}/locale" +S["libdir"]="${exec_prefix}/lib" +S["psdir"]="${docdir}" +S["pdfdir"]="${docdir}" +S["dvidir"]="${docdir}" +S["htmldir"]="${docdir}" +S["infodir"]="${datarootdir}/info" +S["docdir"]="${datarootdir}/doc/${PACKAGE_TARNAME}" +S["oldincludedir"]="/usr/include" +S["includedir"]="${prefix}/include" +S["runstatedir"]="${localstatedir}/run" +S["localstatedir"]="${prefix}/var" +S["sharedstatedir"]="${prefix}/com" +S["sysconfdir"]="${prefix}/etc" +S["datadir"]="${datarootdir}" +S["datarootdir"]="${prefix}/share" +S["libexecdir"]="${exec_prefix}/libexec" +S["sbindir"]="${exec_prefix}/sbin" +S["bindir"]="${exec_prefix}/bin" +S["program_transform_name"]="s,x,x," +S["prefix"]="/home/scott/code/gui/installed/linux" +S["exec_prefix"]="${prefix}" +S["PACKAGE_URL"]="" +S["PACKAGE_BUGREPORT"]="" +S["PACKAGE_STRING"]="libjpeg 9.5.0" +S["PACKAGE_VERSION"]="9.5.0" +S["PACKAGE_TARNAME"]="libjpeg" +S["PACKAGE_NAME"]="libjpeg" +S["PATH_SEPARATOR"]=":" +S["SHELL"]="/bin/bash" +S["am__quote"]="" +_ACAWK +cat >>"$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +D["PACKAGE_NAME"]=" \"libjpeg\"" +D["PACKAGE_TARNAME"]=" \"libjpeg\"" +D["PACKAGE_VERSION"]=" \"9.5.0\"" +D["PACKAGE_STRING"]=" \"libjpeg 9.5.0\"" +D["PACKAGE_BUGREPORT"]=" \"\"" +D["PACKAGE_URL"]=" \"\"" +D["PACKAGE"]=" \"libjpeg\"" +D["VERSION"]=" \"9.5.0\"" +D["HAVE_PROTOTYPES"]=" 1" +D["HAVE_STDIO_H"]=" 1" +D["HAVE_STDLIB_H"]=" 1" +D["HAVE_STRING_H"]=" 1" +D["HAVE_INTTYPES_H"]=" 1" +D["HAVE_STDINT_H"]=" 1" +D["HAVE_STRINGS_H"]=" 1" +D["HAVE_SYS_STAT_H"]=" 1" +D["HAVE_SYS_TYPES_H"]=" 1" +D["HAVE_UNISTD_H"]=" 1" +D["STDC_HEADERS"]=" 1" +D["HAVE_STDDEF_H"]=" 1" +D["HAVE_STDLIB_H"]=" 1" +D["HAVE_LOCALE_H"]=" 1" +D["HAVE_UNSIGNED_CHAR"]=" 1" +D["HAVE_UNSIGNED_SHORT"]=" 1" +D["INLINE"]=" __inline__" +D["HAVE_DLFCN_H"]=" 1" +D["LT_OBJDIR"]=" \".libs/\"" + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ { + line = $ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +printf "%s\n" "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`printf "%s\n" "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} + ac_datarootdir_hack=' + s&@datadir@&${datarootdir}&g + s&@docdir@&${datarootdir}/doc/${PACKAGE_TARNAME}&g + s&@infodir@&${datarootdir}/info&g + s&@localedir@&${datarootdir}/locale&g + s&@mandir@&${datarootdir}/man&g + s&\${datarootdir}&${prefix}/share&g' ;; +esac +ac_sed_extra="/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +} + +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + printf "%s\n" "/* $configure_input */" >&1 \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + printf "%s\n" "/* $configure_input */" >&1 \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +printf "%s\n" "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Older Autoconf quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + case $CONFIG_FILES in #( + *\'*) : + eval set x "$CONFIG_FILES" ;; #( + *) : + set x $CONFIG_FILES ;; #( + *) : + ;; +esac + shift + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf + do + # Strip MF so we end up with the name of the file. + am_mf=`printf "%s\n" "$am_mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`$as_dirname -- "$am_mf" || +$as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$am_mf" : 'X\(//\)[^/]' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$am_mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + am_filepart=`$as_basename -- "$am_mf" || +$as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X/"$am_mf" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { echo "$as_me:$LINENO: cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles" >&5 + (cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } || am_rc=$? + done + if test $am_rc -ne 0; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE=\"gmake\" (or whatever is + necessary). You can also try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking). +See \`config.log' for more details" "$LINENO" 5; } + fi + { am_dirpart=; unset am_dirpart;} + { am_filepart=; unset am_filepart;} + { am_mf=; unset am_mf;} + { am_rc=; unset am_rc;} + rm -f conftest-deps.mk +} + ;; + "libtool":C) + + # See if we are running on zsh, and set the options that allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST + fi + + cfgfile=${ofile}T + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL +# Generated automatically by $as_me ($PACKAGE) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# The names of the tagged configurations supported by this script. +available_tags='' + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} + +# ### BEGIN LIBTOOL CONFIG + +# Which release of libtool.m4 was used? +macro_version=$macro_version +macro_revision=$macro_revision + +# Assembler program. +AS=$lt_AS + +# DLL creation program. +DLLTOOL=$lt_DLLTOOL + +# Object dumper program. +OBJDUMP=$lt_OBJDUMP + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# What type of objects to build. +pic_mode=$pic_mode + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# Shared archive member basename,for filename based shared library versioning on AIX. +shared_archive_member_spec=$shared_archive_member_spec + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# An echo program that protects backslashes. +ECHO=$lt_ECHO + +# The PATH separator for the build system. +PATH_SEPARATOR=$lt_PATH_SEPARATOR + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="\$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP=$lt_GREP + +# An ERE matcher. +EGREP=$lt_EGREP + +# A literal string matcher. +FGREP=$lt_FGREP + +# A BSD- or MS-compatible name lister. +NM=$lt_NM + +# Whether we need soft or hard links. +LN_S=$lt_LN_S + +# What is the maximum length of a command? +max_cmd_len=$max_cmd_len + +# Object file suffix (normally "o"). +objext=$ac_objext + +# Executable file suffix (normally ""). +exeext=$exeext + +# whether the shell understands "unset". +lt_unset=$lt_unset + +# turn spaces into newlines. +SP2NL=$lt_lt_SP2NL + +# turn newlines into spaces. +NL2SP=$lt_lt_NL2SP + +# convert \$build file names to \$host format. +to_host_file_cmd=$lt_cv_to_host_file_cmd + +# convert \$build files to toolchain format. +to_tool_file_cmd=$lt_cv_to_tool_file_cmd + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method = "file_magic". +file_magic_cmd=$lt_file_magic_cmd + +# How to find potential files when deplibs_check_method = "file_magic". +file_magic_glob=$lt_file_magic_glob + +# Find potential files using nocaseglob when deplibs_check_method = "file_magic". +want_nocaseglob=$lt_want_nocaseglob + +# Command to associate shared and link libraries. +sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd + +# The archiver. +AR=$lt_AR + +# Flags to create an archive. +AR_FLAGS=$lt_AR_FLAGS + +# How to feed a file listing to the archiver. +archiver_list_spec=$lt_archiver_list_spec + +# A symbol stripping program. +STRIP=$lt_STRIP + +# Commands used to install an old-style archive. +RANLIB=$lt_RANLIB +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Whether to use a lock for old archive extraction. +lock_old_archive_extraction=$lock_old_archive_extraction + +# A C compiler. +LTCC=$lt_CC + +# LTCC compiler flags. +LTCFLAGS=$lt_CFLAGS + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm into a list of symbols to manually relocate. +global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix + +# The name lister interface. +nm_interface=$lt_lt_cv_nm_interface + +# Specify filename containing input files for \$NM. +nm_file_list_spec=$lt_nm_file_list_spec + +# The root where to search for dependent libraries,and where our libraries should be installed. +lt_sysroot=$lt_sysroot + +# Command to truncate a binary pipe. +lt_truncate_bin=$lt_lt_cv_truncate_bin + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=$MAGIC_CMD + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Manifest tool. +MANIFEST_TOOL=$lt_MANIFEST_TOOL + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL=$lt_DSYMUTIL + +# Tool to change global to local symbols on Mac OS X. +NMEDIT=$lt_NMEDIT + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO=$lt_LIPO + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL=$lt_OTOOL + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64=$lt_OTOOL64 + +# Old archive suffix (normally "a"). +libext=$libext + +# Shared library suffix (normally ".so"). +shrext_cmds=$lt_shrext_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink=$lt_variables_saved_for_relink + +# Do we need the "lib" prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Library versioning type. +version_type=$version_type + +# Shared library runtime path variable. +runpath_var=$runpath_var + +# Shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Permission mode override for installation of shared libraries. +install_override_mode=$lt_install_override_mode + +# Command to use after installation of a shared archive. +postinstall_cmds=$lt_postinstall_cmds + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval=$lt_finish_eval + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Compile-time system search path for libraries. +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Detected run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path + +# Explicit LT_SYS_LIBRARY_PATH set during ./configure time. +configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + + +# The linker used to build libraries. +LD=$lt_LD + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds + +# A language specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU compiler? +with_gcc=$GCC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \$shlibpath_var if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds + +# Commands necessary for finishing linking programs. +postlink_cmds=$lt_postlink_cmds + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# ### END LIBTOOL CONFIG + +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + + +# ### END FUNCTIONS SHARED WITH CONFIGURE + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + + +ltmain=$ac_aux_dir/ltmain.sh + + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + + ;; + + esac +done # for ac_tag + + +as_fn_exit 0 diff --git a/thirdparty/jpeg-9e/config.sub b/thirdparty/jpeg-9e/config.sub new file mode 100755 index 0000000..d74fb6d --- /dev/null +++ b/thirdparty/jpeg-9e/config.sub @@ -0,0 +1,1884 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2021 Free Software Foundation, Inc. + +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2021-08-14' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS + +Canonicalize a configuration name. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2021 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo "$1" + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Split fields of configuration type +# shellcheck disable=SC2162 +saved_IFS=$IFS +IFS="-" read field1 field2 field3 field4 <&2 + exit 1 + ;; + *-*-*-*) + basic_machine=$field1-$field2 + basic_os=$field3-$field4 + ;; + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + basic_os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + basic_os=linux-android + ;; + *) + basic_machine=$field1-$field2 + basic_os=$field3 + ;; + esac + ;; + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + zephyr*) + basic_machine=$field1-unknown + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; + esac + ;; + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + basic_os=bsd + ;; + a29khif) + basic_machine=a29k-amd + basic_os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= + ;; + am29k) + basic_machine=a29k-none + basic_os=bsd + ;; + amdahl) + basic_machine=580-amdahl + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + basic_os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + basic_os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + basic_os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + basic_os=bsd + ;; + aros) + basic_machine=i386-pc + basic_os=aros + ;; + aux) + basic_machine=m68k-apple + basic_os=aux + ;; + balance) + basic_machine=ns32k-sequent + basic_os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + basic_os=linux + ;; + cegcc) + basic_machine=arm-unknown + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd + ;; + cray) + basic_machine=j90-cray + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= + ;; + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= + ;; + delta88) + basic_machine=m88k-motorola + basic_os=sysv3 + ;; + dicos) + basic_machine=i686-pc + basic_os=dicos + ;; + djgpp) + basic_machine=i586-pc + basic_os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + basic_os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + basic_os=ose + ;; + gmicro) + basic_machine=tron-gmicro + basic_os=sysv + ;; + go32) + basic_machine=i386-pc + basic_os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + basic_os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + basic_os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + basic_os=hms + ;; + harris) + basic_machine=m88k-harris + basic_os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + basic_os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + basic_os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + basic_os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + basic_os=proelf + ;; + i386mach) + basic_machine=i386-mach + basic_os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + basic_os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + basic_os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + basic_os=sysv + ;; + merlin) + basic_machine=ns32k-utek + basic_os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + basic_os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + basic_os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + basic_os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + basic_os=coff + ;; + morphos) + basic_machine=powerpc-unknown + basic_os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + basic_os=moxiebox + ;; + msdos) + basic_machine=i386-pc + basic_os=msdos + ;; + msys) + basic_machine=i686-pc + basic_os=msys + ;; + mvs) + basic_machine=i370-ibm + basic_os=mvs + ;; + nacl) + basic_machine=le32-unknown + basic_os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + basic_os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + basic_os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + basic_os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + basic_os=newsos + ;; + news1000) + basic_machine=m68030-sony + basic_os=newsos + ;; + necv70) + basic_machine=v70-nec + basic_os=sysv + ;; + nh3000) + basic_machine=m68k-harris + basic_os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + basic_os=cxux + ;; + nindy960) + basic_machine=i960-intel + basic_os=nindy + ;; + mon960) + basic_machine=i960-intel + basic_os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + basic_os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + basic_os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + basic_os=ose + ;; + os68k) + basic_machine=m68k-none + basic_os=os68k + ;; + paragon) + basic_machine=i860-intel + basic_os=osf + ;; + parisc) + basic_machine=hppa-unknown + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp + ;; + pw32) + basic_machine=i586-unknown + basic_os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + basic_os=rdos + ;; + rdos32) + basic_machine=i386-pc + basic_os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + basic_os=coff + ;; + sa29200) + basic_machine=a29k-amd + basic_os=udi + ;; + sei) + basic_machine=mips-sei + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= + ;; + sps7) + basic_machine=m68k-bull + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= + ;; + stratus) + basic_machine=i860-stratus + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= + ;; + sun2os3) + basic_machine=m68000-sun + basic_os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= + ;; + sun3os3) + basic_machine=m68k-sun + basic_os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= + ;; + sun4os3) + basic_machine=sparc-sun + basic_os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + basic_os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= + ;; + sv1) + basic_machine=sv1-cray + basic_os=unicos + ;; + symmetry) + basic_machine=i386-sequent + basic_os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + basic_os=unicos + ;; + t90) + basic_machine=t90-cray + basic_os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + basic_os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + basic_os=tpf + ;; + udi29k) + basic_machine=a29k-amd + basic_os=udi + ;; + ultra3) + basic_machine=a29k-nyu + basic_os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + basic_os=none + ;; + vaxv) + basic_machine=vax-dec + basic_os=sysv + ;; + vms) + basic_machine=vax-dec + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + basic_os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + basic_os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + basic_os=vxworks + ;; + xbox) + basic_machine=i686-pc + basic_os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + basic_os=unicos + ;; + *) + basic_machine=$1 + basic_os= + ;; + esac + ;; +esac + +# Decode 1-component or ad-hoc basic machines +case $basic_machine in + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond + ;; + op50n) + cpu=hppa1.1 + vendor=oki + ;; + op60c) + cpu=hppa1.1 + vendor=oki + ;; + ibm*) + cpu=i370 + vendor=ibm + ;; + orion105) + cpu=clipper + vendor=highlevel + ;; + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple + ;; + pmac | pmac-mpw) + cpu=powerpc + vendor=apple + ;; + + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + cpu=m68000 + vendor=att + ;; + 3b*) + cpu=we32k + vendor=att + ;; + bluegene*) + cpu=powerpc + vendor=ibm + basic_os=cnk + ;; + decsystem10* | dec10*) + cpu=pdp10 + vendor=dec + basic_os=tops10 + ;; + decsystem20* | dec20*) + cpu=pdp10 + vendor=dec + basic_os=tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + cpu=m68k + vendor=motorola + ;; + dpx2*) + cpu=m68k + vendor=bull + basic_os=sysv3 + ;; + encore | umax | mmax) + cpu=ns32k + vendor=encore + ;; + elxsi) + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} + ;; + fx2800) + cpu=i860 + vendor=alliant + ;; + genix) + cpu=ns32k + vendor=ns + ;; + h3050r* | hiux*) + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + cpu=m68000 + vendor=hp + ;; + hp9k3[2-9][0-9]) + cpu=m68k + vendor=hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + i*86v32) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv32 + ;; + i*86v4*) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv4 + ;; + i*86v) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv + ;; + i*86sol2) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=solaris2 + ;; + j90 | j90-cray) + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} + ;; + iris | iris4d) + cpu=mips + vendor=sgi + case $basic_os in + irix*) + ;; + *) + basic_os=irix4 + ;; + esac + ;; + miniframe) + cpu=m68000 + vendor=convergent + ;; + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + basic_os=mint + ;; + news-3600 | risc-news) + cpu=mips + vendor=sony + basic_os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) + ;; + ns2*) + basic_os=nextstep2 + ;; + *) + basic_os=nextstep3 + ;; + esac + ;; + np1) + cpu=np1 + vendor=gould + ;; + op50n-* | op60c-*) + cpu=hppa1.1 + vendor=oki + basic_os=proelf + ;; + pa-hitachi) + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 + ;; + pbd) + cpu=sparc + vendor=tti + ;; + pbb) + cpu=m68k + vendor=tti + ;; + pc532) + cpu=ns32k + vendor=pc532 + ;; + pn) + cpu=pn + vendor=gould + ;; + power) + cpu=power + vendor=ibm + ;; + ps2) + cpu=i386 + vendor=ibm + ;; + rm[46]00) + cpu=mips + vendor=siemens + ;; + rtpc | rtpc-*) + cpu=romp + vendor=ibm + ;; + sde) + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} + ;; + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks + ;; + tower | tower-32) + cpu=m68k + vendor=ncr + ;; + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu + ;; + w65) + cpu=w65 + vendor=wdc + ;; + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf + ;; + none) + cpu=none + vendor=none + ;; + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine + ;; + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` + ;; + + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read cpu vendor <&2 + exit 1 + ;; + esac + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $vendor in + digital*) + vendor=dec + ;; + commodore*) + vendor=cbm + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if test x$basic_os != x +then + +# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just +# set os. +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` + ;; + os2-emx) + kernel=os2 + os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` + ;; + nto-qnx*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read kernel os <&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \ + | linux-musl* | linux-relibc* | linux-uclibc* ) + ;; + uclinux-uclibc* ) + ;; + -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + vxworks-simlinux | vxworks-simwindows | vxworks-spe) + ;; + nto-qnx*) + ;; + os2-emx) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) + vendor=acorn + ;; + *-sunos*) + vendor=sun + ;; + *-cnk* | *-aix*) + vendor=ibm + ;; + *-beos*) + vendor=be + ;; + *-hpux*) + vendor=hp + ;; + *-mpeix*) + vendor=hp + ;; + *-hiux*) + vendor=hitachi + ;; + *-unos*) + vendor=crds + ;; + *-dgux*) + vendor=dg + ;; + *-luna*) + vendor=omron + ;; + *-genix*) + vendor=ns + ;; + *-clix*) + vendor=intergraph + ;; + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) + vendor=ibm + ;; + s390-* | s390x-*) + vendor=ibm + ;; + *-ptx*) + vendor=sequent + ;; + *-tpf*) + vendor=ibm + ;; + *-vxsim* | *-vxworks* | *-windiss*) + vendor=wrs + ;; + *-aux*) + vendor=apple + ;; + *-hms*) + vendor=hitachi + ;; + *-mpw* | *-macos*) + vendor=apple + ;; + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) + vendor=atari + ;; + *-vos*) + vendor=stratus + ;; + esac + ;; +esac + +echo "$cpu-$vendor-${kernel:+$kernel-}$os" +exit + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/thirdparty/jpeg-9e/configure b/thirdparty/jpeg-9e/configure new file mode 100755 index 0000000..9e1d1fc --- /dev/null +++ b/thirdparty/jpeg-9e/configure @@ -0,0 +1,16365 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.71 for libjpeg 9.5.0. +# +# +# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, +# Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +as_nop=: +if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 +then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else $as_nop + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + + +# Reset variables that may have inherited troublesome values from +# the environment. + +# IFS needs to be set, to space, tab, and newline, in precisely that order. +# (If _AS_PATH_WALK were called with IFS unset, it would have the +# side effect of setting IFS to empty, thus disabling word splitting.) +# Quoting is to prevent editors from complaining about space-tab. +as_nl=' +' +export as_nl +IFS=" "" $as_nl" + +PS1='$ ' +PS2='> ' +PS4='+ ' + +# Ensure predictable behavior from utilities with locale-dependent output. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# We cannot yet rely on "unset" to work, but we need these variables +# to be unset--not just set to an empty or harmless value--now, to +# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct +# also avoids known problems related to "unset" and subshell syntax +# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). +for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH +do eval test \${$as_var+y} \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done + +# Ensure that fds 0, 1, and 2 are open. +if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi +if (exec 3>&2) ; then :; else exec 2>/dev/null; fi + +# The user is always right. +if ${PATH_SEPARATOR+false} :; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + test -r "$as_dir$0" && as_myself=$as_dir$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="as_nop=: +if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 +then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else \$as_nop + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ) +then : + +else \$as_nop + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +blah=\$(echo \$(echo blah)) +test x\"\$blah\" = xblah || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1 + + test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( + ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + PATH=/empty FPATH=/empty; export PATH FPATH + test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ + || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" + if (eval "$as_required") 2>/dev/null +then : + as_have_required=yes +else $as_nop + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null +then : + +else $as_nop + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null +then : + CONFIG_SHELL=$as_shell as_have_required=yes + if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null +then : + break 2 +fi +fi + done;; + esac + as_found=false +done +IFS=$as_save_IFS +if $as_found +then : + +else $as_nop + if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null +then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi +fi + + + if test "x$CONFIG_SHELL" != x +then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno +then : + printf "%s\n" "$0: This script requires a shell more modern than all" + printf "%s\n" "$0: the shells that I found on your system." + if test ${ZSH_VERSION+y} ; then + printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" + printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." + else + printf "%s\n" "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit +# as_fn_nop +# --------- +# Do nothing but, unlike ":", preserve the value of $?. +as_fn_nop () +{ + return $? +} +as_nop=as_fn_nop + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null +then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else $as_nop + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null +then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else $as_nop + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + +# as_fn_nop +# --------- +# Do nothing but, unlike ":", preserve the value of $?. +as_fn_nop () +{ + return $? +} +as_nop=as_fn_nop + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + printf "%s\n" "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +# Determine whether it's possible to make 'echo' print without a newline. +# These variables are no longer used directly by Autoconf, but are AC_SUBSTed +# for compatibility with existing Makefiles. +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +# For backward compatibility with old third-party macros, we provide +# the shell variables $as_echo and $as_echo_n. New code should use +# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. +as_echo='printf %s\n' +as_echo_n='printf %s' + + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + +SHELL=${CONFIG_SHELL-/bin/sh} + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='libjpeg' +PACKAGE_TARNAME='libjpeg' +PACKAGE_VERSION='9.5.0' +PACKAGE_STRING='libjpeg 9.5.0' +PACKAGE_BUGREPORT='' +PACKAGE_URL='' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_STDIO_H +# include +#endif +#ifdef HAVE_STDLIB_H +# include +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_header_c_list= +ac_subst_vars='am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +LIBOBJS +JPEG_LIB_VERSION_MINOR +JPEG_LIB_VERSION_MAJOR +JPEG_LIB_VERSION +MEMORYMGR +LT_SYS_LIBRARY_PATH +OTOOL64 +OTOOL +LIPO +NMEDIT +DSYMUTIL +MANIFEST_TOOL +RANLIB +NM +ac_ct_DUMPBIN +DUMPBIN +LD +FGREP +SED +LIBTOOL +OBJDUMP +DLLTOOL +AS +HAVE_LD_VERSION_SCRIPT_FALSE +HAVE_LD_VERSION_SCRIPT_TRUE +ac_ct_AR +AR +EGREP +GREP +LN_S +CPP +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +am__nodep +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +MAINT +MAINTAINER_MODE_FALSE +MAINTAINER_MODE_TRUE +AM_BACKSLASH +AM_DEFAULT_VERBOSITY +AM_DEFAULT_V +AM_V +CSCOPE +ETAGS +CTAGS +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +target_os +target_vendor +target_cpu +target +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +runstatedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL +am__quote' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_silent_rules +enable_maintainer_mode +enable_dependency_tracking +enable_ld_version_script +enable_shared +enable_static +with_pic +enable_fast_install +with_aix_soname +with_gnu_ld +with_sysroot +enable_libtool_lock +enable_maxmem +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP +LT_SYS_LIBRARY_PATH' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: \`$ac_useropt'" + ac_useropt_orig=$ac_useropt + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: \`$ac_useropt'" + ac_useropt_orig=$ac_useropt + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: \`$ac_useropt'" + ac_useropt_orig=$ac_useropt + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: \`$ac_useropt'" + ac_useropt_orig=$ac_useropt + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir runstatedir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures libjpeg 9.5.0 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/libjpeg] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of libjpeg 9.5.0:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-silent-rules less verbose build output (undo: "make V=1") + --disable-silent-rules verbose build output (undo: "make V=0") + --enable-maintainer-mode + enable make rules and dependencies not useful (and + sometimes confusing) to the casual installer + --enable-dependency-tracking + do not reject slow dependency extractors + --disable-dependency-tracking + speeds up one-time build + --enable-ld-version-script + enable linker version script (default is enabled + when possible) + --enable-shared[=PKGS] build shared libraries [default=yes] + --enable-static[=PKGS] build static libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-libtool-lock avoid locking (might break parallel builds) + --enable-maxmem=N enable use of temp files, set max mem usage to N MB + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use + both] + --with-aix-soname=aix|svr4|both + shared library versioning (aka "SONAME") variant to + provide on AIX, [default=aix]. + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-sysroot[=DIR] Search for dependent libraries within DIR (or the + compiler's sysroot if not specified). + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + LT_SYS_LIBRARY_PATH + User-defined run-time library search path. + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to the package provider. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for configure.gnu first; this name is used for a wrapper for + # Metaconfig's "Configure" on case-insensitive file systems. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +libjpeg configure 9.5.0 +generated by GNU Autoconf 2.71 + +Copyright (C) 2021 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest.beam + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + } +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + } +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +printf %s "checking for $2... " >&6; } +if eval test \${$3+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + eval "$3=yes" +else $as_nop + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +eval ac_res=\$$3 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that +# executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: program exited with status $ac_status" >&5 + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +printf %s "checking for $2... " >&6; } +if eval test \${$3+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. */ + +#include +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main (void) +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + eval "$3=yes" +else $as_nop + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func +ac_configure_args_raw= +for ac_arg +do + case $ac_arg in + *\'*) + ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append ac_configure_args_raw " '$ac_arg'" +done + +case $ac_configure_args_raw in + *$as_nl*) + ac_safe_unquote= ;; + *) + ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. + ac_unsafe_a="$ac_unsafe_z#~" + ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" + ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; +esac + +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by libjpeg $as_me 9.5.0, which was +generated by GNU Autoconf 2.71. Invocation command line was + + $ $0$ac_configure_args_raw + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + printf "%s\n" "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Sanitize IFS. + IFS=" "" $as_nl" + # Save into config.log some information that might help in debugging. + { + echo + + printf "%s\n" "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + printf "%s\n" "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + printf "%s\n" "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + printf "%s\n" "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + printf "%s\n" "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + printf "%s\n" "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + printf "%s\n" "$as_me: caught signal $ac_signal" + printf "%s\n" "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +printf "%s\n" "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h + +printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h + +printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h + +printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h + +printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h + +printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +if test -n "$CONFIG_SITE"; then + ac_site_files="$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + ac_site_files="$prefix/share/config.site $prefix/etc/config.site" +else + ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" +fi + +for ac_site_file in $ac_site_files +do + case $ac_site_file in #( + */*) : + ;; #( + *) : + ac_site_file=./$ac_site_file ;; +esac + if test -f "$ac_site_file" && test -r "$ac_site_file"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +printf "%s\n" "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +printf "%s\n" "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Test code for whether the C compiler supports C89 (global declarations) +ac_c_conftest_c89_globals=' +/* Does the compiler advertise C89 conformance? + Do not test the value of __STDC__, because some compilers set it to 0 + while being otherwise adequately conformant. */ +#if !defined __STDC__ +# error "Compiler does not advertise C89 conformance" +#endif + +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ +struct buf { int x; }; +struct buf * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not \xHH hex character constants. + These do not provoke an error unfortunately, instead are silently treated + as an "x". The following induces an error, until -std is added to get + proper ANSI mode. Curiously \x00 != x always comes out true, for an + array size at least. It is necessary to write \x00 == 0 to get something + that is true only with -std. */ +int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) '\''x'\'' +int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), + int, int);' + +# Test code for whether the C compiler supports C89 (body of main). +ac_c_conftest_c89_main=' +ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]); +' + +# Test code for whether the C compiler supports C99 (global declarations) +ac_c_conftest_c99_globals=' +// Does the compiler advertise C99 conformance? +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L +# error "Compiler does not advertise C99 conformance" +#endif + +#include +extern int puts (const char *); +extern int printf (const char *, ...); +extern int dprintf (int, const char *, ...); +extern void *malloc (size_t); + +// Check varargs macros. These examples are taken from C99 6.10.3.5. +// dprintf is used instead of fprintf to avoid needing to declare +// FILE and stderr. +#define debug(...) dprintf (2, __VA_ARGS__) +#define showlist(...) puts (#__VA_ARGS__) +#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) +static void +test_varargs_macros (void) +{ + int x = 1234; + int y = 5678; + debug ("Flag"); + debug ("X = %d\n", x); + showlist (The first, second, and third items.); + report (x>y, "x is %d but y is %d", x, y); +} + +// Check long long types. +#define BIG64 18446744073709551615ull +#define BIG32 4294967295ul +#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) +#if !BIG_OK + #error "your preprocessor is broken" +#endif +#if BIG_OK +#else + #error "your preprocessor is broken" +#endif +static long long int bignum = -9223372036854775807LL; +static unsigned long long int ubignum = BIG64; + +struct incomplete_array +{ + int datasize; + double data[]; +}; + +struct named_init { + int number; + const wchar_t *name; + double average; +}; + +typedef const char *ccp; + +static inline int +test_restrict (ccp restrict text) +{ + // See if C++-style comments work. + // Iterate through items via the restricted pointer. + // Also check for declarations in for loops. + for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) + continue; + return 0; +} + +// Check varargs and va_copy. +static bool +test_varargs (const char *format, ...) +{ + va_list args; + va_start (args, format); + va_list args_copy; + va_copy (args_copy, args); + + const char *str = ""; + int number = 0; + float fnumber = 0; + + while (*format) + { + switch (*format++) + { + case '\''s'\'': // string + str = va_arg (args_copy, const char *); + break; + case '\''d'\'': // int + number = va_arg (args_copy, int); + break; + case '\''f'\'': // float + fnumber = va_arg (args_copy, double); + break; + default: + break; + } + } + va_end (args_copy); + va_end (args); + + return *str && number && fnumber; +} +' + +# Test code for whether the C compiler supports C99 (body of main). +ac_c_conftest_c99_main=' + // Check bool. + _Bool success = false; + success |= (argc != 0); + + // Check restrict. + if (test_restrict ("String literal") == 0) + success = true; + char *restrict newvar = "Another string"; + + // Check varargs. + success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234); + test_varargs_macros (); + + // Check flexible array members. + struct incomplete_array *ia = + malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); + ia->datasize = 10; + for (int i = 0; i < ia->datasize; ++i) + ia->data[i] = i * 1.234; + + // Check named initializers. + struct named_init ni = { + .number = 34, + .name = L"Test wide string", + .average = 543.34343, + }; + + ni.number = 58; + + int dynamic_array[ni.number]; + dynamic_array[0] = argv[0][0]; + dynamic_array[ni.number - 1] = 543; + + // work around unused variable warnings + ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\'' + || dynamic_array[ni.number - 1] != 543); +' + +# Test code for whether the C compiler supports C11 (global declarations) +ac_c_conftest_c11_globals=' +// Does the compiler advertise C11 conformance? +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L +# error "Compiler does not advertise C11 conformance" +#endif + +// Check _Alignas. +char _Alignas (double) aligned_as_double; +char _Alignas (0) no_special_alignment; +extern char aligned_as_int; +char _Alignas (0) _Alignas (int) aligned_as_int; + +// Check _Alignof. +enum +{ + int_alignment = _Alignof (int), + int_array_alignment = _Alignof (int[100]), + char_alignment = _Alignof (char) +}; +_Static_assert (0 < -_Alignof (int), "_Alignof is signed"); + +// Check _Noreturn. +int _Noreturn does_not_return (void) { for (;;) continue; } + +// Check _Static_assert. +struct test_static_assert +{ + int x; + _Static_assert (sizeof (int) <= sizeof (long int), + "_Static_assert does not work in struct"); + long int y; +}; + +// Check UTF-8 literals. +#define u8 syntax error! +char const utf8_literal[] = u8"happens to be ASCII" "another string"; + +// Check duplicate typedefs. +typedef long *long_ptr; +typedef long int *long_ptr; +typedef long_ptr long_ptr; + +// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. +struct anonymous +{ + union { + struct { int i; int j; }; + struct { int k; long int l; } w; + }; + int m; +} v1; +' + +# Test code for whether the C compiler supports C11 (body of main). +ac_c_conftest_c11_main=' + _Static_assert ((offsetof (struct anonymous, i) + == offsetof (struct anonymous, w.k)), + "Anonymous union alignment botch"); + v1.i = 2; + v1.w.k = 5; + ok |= v1.i != 5; +' + +# Test code for whether the C compiler supports C11 (complete). +ac_c_conftest_c11_program="${ac_c_conftest_c89_globals} +${ac_c_conftest_c99_globals} +${ac_c_conftest_c11_globals} + +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_c_conftest_c89_main} + ${ac_c_conftest_c99_main} + ${ac_c_conftest_c11_main} + return ok; +} +" + +# Test code for whether the C compiler supports C99 (complete). +ac_c_conftest_c99_program="${ac_c_conftest_c89_globals} +${ac_c_conftest_c99_globals} + +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_c_conftest_c89_main} + ${ac_c_conftest_c99_main} + return ok; +} +" + +# Test code for whether the C compiler supports C89 (complete). +ac_c_conftest_c89_program="${ac_c_conftest_c89_globals} + +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_c_conftest_c89_main} + return ok; +} +" + +as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H" +as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H" +as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H" +as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H" +as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H" +as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H" +as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" +as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" +as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" + +# Auxiliary files required by this configure script. +ac_aux_files="ltmain.sh ar-lib compile missing install-sh config.guess config.sub" + +# Locations in which to look for auxiliary files. +ac_aux_dir_candidates="${srcdir}/." + +# Search for a directory containing all of the required auxiliary files, +# $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates. +# If we don't find one directory that contains all the files we need, +# we report the set of missing files from the *first* directory in +# $ac_aux_dir_candidates and give up. +ac_missing_aux_files="" +ac_first_candidate=: +printf "%s\n" "$as_me:${as_lineno-$LINENO}: looking for aux files: $ac_aux_files" >&5 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in $ac_aux_dir_candidates +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + as_found=: + + printf "%s\n" "$as_me:${as_lineno-$LINENO}: trying $as_dir" >&5 + ac_aux_dir_found=yes + ac_install_sh= + for ac_aux in $ac_aux_files + do + # As a special case, if "install-sh" is required, that requirement + # can be satisfied by any of "install-sh", "install.sh", or "shtool", + # and $ac_install_sh is set appropriately for whichever one is found. + if test x"$ac_aux" = x"install-sh" + then + if test -f "${as_dir}install-sh"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install-sh found" >&5 + ac_install_sh="${as_dir}install-sh -c" + elif test -f "${as_dir}install.sh"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install.sh found" >&5 + ac_install_sh="${as_dir}install.sh -c" + elif test -f "${as_dir}shtool"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}shtool found" >&5 + ac_install_sh="${as_dir}shtool install -c" + else + ac_aux_dir_found=no + if $ac_first_candidate; then + ac_missing_aux_files="${ac_missing_aux_files} install-sh" + else + break + fi + fi + else + if test -f "${as_dir}${ac_aux}"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}${ac_aux} found" >&5 + else + ac_aux_dir_found=no + if $ac_first_candidate; then + ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}" + else + break + fi + fi + fi + done + if test "$ac_aux_dir_found" = yes; then + ac_aux_dir="$as_dir" + break + fi + ac_first_candidate=false + + as_found=false +done +IFS=$as_save_IFS +if $as_found +then : + +else $as_nop + as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 +fi + + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +if test -f "${ac_aux_dir}config.guess"; then + ac_config_guess="$SHELL ${ac_aux_dir}config.guess" +fi +if test -f "${ac_aux_dir}config.sub"; then + ac_config_sub="$SHELL ${ac_aux_dir}config.sub" +fi +if test -f "$ac_aux_dir/configure"; then + ac_configure="$SHELL ${ac_aux_dir}configure" +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' + and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +# Directory where autotools helper scripts lives. + + +# Generate configuration headers. +ac_config_headers="$ac_config_headers jconfig.h:jconfig.cfg" + + +# Hack: disable autoheader so that it doesn't overwrite our cfg template. +AUTOHEADER="echo autoheader ignored" + +# Check system type + + + + # Make sure we can run config.sub. +$SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5 + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +printf %s "checking build system type... " >&6; } +if test ${ac_cv_build+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +printf "%s\n" "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +printf %s "checking host system type... " >&6; } +if test ${ac_cv_host+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || + as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +printf "%s\n" "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 +printf %s "checking target system type... " >&6; } +if test ${ac_cv_target+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "${ac_aux_dir}config.sub" $target_alias` || + as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $target_alias failed" "$LINENO" 5 +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 +printf "%s\n" "$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; +esac +target=$ac_cv_target +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +# Initialize Automake +# Don't require all the GNU mandated files +am__api_version='1.16' + + + # Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +printf %s "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if test ${ac_cv_path_install+y} +then : + printf %s "(cached) " >&6 +else $as_nop + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + # Account for fact that we put trailing slashes in our PATH walk. +case $as_dir in #(( + ./ | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir/" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test ${ac_cv_path_install+y}; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +printf "%s\n" "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +printf %s "checking whether build environment is sane... " >&6; } +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; +esac +case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) + as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; +esac + +# Do 'set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken + alias in your environment" "$LINENO" 5 + fi + if test "$2" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done + test "$2" = conftest.file + ) +then + # Ok. + : +else + as_fn_error $? "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi + +rm -f conftest.file + +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`printf "%s\n" "$program_transform_name" | sed "$ac_script"` + + +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` + + + if test x"${MISSING+set}" != xset; then + MISSING="\${SHELL} '$am_aux_dir/missing'" +fi +# Use eval to expand $SHELL +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " +else + am_missing_run= + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 +printf "%s\n" "$as_me: WARNING: 'missing' script is too old or missing" >&2;} +fi + +if test x"${install_sh+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the 'STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +printf "%s\n" "$STRIP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +printf "%s\n" "$ac_ct_STRIP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a race-free mkdir -p" >&5 +printf %s "checking for a race-free mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if test ${ac_cv_path_mkdir+y} +then : + printf %s "(cached) " >&6 +else $as_nop + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext" || continue + case `"$as_dir$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir ('*'coreutils) '* | \ + 'BusyBox '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + test -d ./--version && rmdir ./--version + if test ${ac_cv_path_mkdir+y}; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + MKDIR_P="$ac_install_sh -d" + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +printf "%s\n" "$MKDIR_P" >&6; } + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_AWK+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +printf "%s\n" "$AWK" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +printf %s "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval test \${ac_cv_prog_make_${ac_make}_set+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + SET_MAKE= +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +# Check whether --enable-silent-rules was given. +if test ${enable_silent_rules+y} +then : + enableval=$enable_silent_rules; +fi + +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=1;; +esac +am_make=${MAKE-make} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +printf %s "checking whether $am_make supports nested variables... " >&6; } +if test ${am_cv_make_support_nested_variables+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if printf "%s\n" 'TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +printf "%s\n" "$am_cv_make_support_nested_variables" >&6; } +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AM_BACKSLASH='\' + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='libjpeg' + VERSION='9.5.0' + + +printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h + + +printf "%s\n" "#define VERSION \"$VERSION\"" >>confdefs.h + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +mkdir_p='$(MKDIR_P)' + +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. +# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AMTAR='$${TAR-tar}' + + +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar pax cpio none' + +am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' + + + + + +# Variables for tags utilities; see am/tags.am +if test -z "$CTAGS"; then + CTAGS=ctags +fi + +if test -z "$ETAGS"; then + ETAGS=etags +fi + +if test -z "$CSCOPE"; then + CSCOPE=cscope +fi + + + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 + fi +fi + + +# Make --enable-silent-rules the default. +# To get verbose build output you may configure +# with --disable-silent-rules or use "make V=1". +# Check whether --enable-silent-rules was given. +if test ${enable_silent_rules+y} +then : + enableval=$enable_silent_rules; +fi + +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=0;; +esac +am_make=${MAKE-make} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +printf %s "checking whether $am_make supports nested variables... " >&6; } +if test ${am_cv_make_support_nested_variables+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if printf "%s\n" 'TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +printf "%s\n" "$am_cv_make_support_nested_variables" >&6; } +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AM_BACKSLASH='\' + + +# Add configure option --enable-maintainer-mode which enables +# dependency checking and generation useful to package maintainers. +# This is made an option to avoid confusing end users. + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 +printf %s "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } + # Check whether --enable-maintainer-mode was given. +if test ${enable_maintainer_mode+y} +then : + enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval +else $as_nop + USE_MAINTAINER_MODE=no +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 +printf "%s\n" "$USE_MAINTAINER_MODE" >&6; } + if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + + MAINT=$MAINTAINER_MODE_TRUE + + + +# Check for programs + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +printf "%s\n" "$ac_ct_CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +printf "%s\n" "$ac_ct_CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. +set dummy ${ac_tool_prefix}clang; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}clang" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "clang", so it can be a program name with args. +set dummy clang; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="clang" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +printf "%s\n" "$ac_ct_CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +fi + + +test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion -version; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +printf %s "checking whether the C compiler works... " >&6; } +ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else $as_nop + ac_file='' +fi +if test -z "$ac_file" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +printf %s "checking for C compiler default output file name... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +printf "%s\n" "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +printf %s "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else $as_nop + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +printf "%s\n" "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +printf %s "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +printf "%s\n" "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +printf %s "checking for suffix of object files... " >&6; } +if test ${ac_cv_objext+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +printf "%s\n" "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 +printf %s "checking whether the compiler supports GNU C... " >&6; } +if test ${ac_cv_c_compiler_gnu+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_compiler_gnu=yes +else $as_nop + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+y} +ac_save_CFLAGS=$CFLAGS +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +printf %s "checking whether $CC accepts -g... " >&6; } +if test ${ac_cv_prog_cc_g+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_g=yes +else $as_nop + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + +else $as_nop + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +printf "%s\n" "$ac_cv_prog_cc_g" >&6; } +if test $ac_test_CFLAGS; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +ac_prog_cc_stdc=no +if test x$ac_prog_cc_stdc = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 +printf %s "checking for $CC option to enable C11 features... " >&6; } +if test ${ac_cv_prog_cc_c11+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cc_c11=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_c_conftest_c11_program +_ACEOF +for ac_arg in '' -std=gnu11 +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_c11=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cc_c11" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC +fi + +if test "x$ac_cv_prog_cc_c11" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cc_c11" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 +printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } + CC="$CC $ac_cv_prog_cc_c11" +fi + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 + ac_prog_cc_stdc=c11 +fi +fi +if test x$ac_prog_cc_stdc = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 +printf %s "checking for $CC option to enable C99 features... " >&6; } +if test ${ac_cv_prog_cc_c99+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cc_c99=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_c_conftest_c99_program +_ACEOF +for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_c99=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cc_c99" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC +fi + +if test "x$ac_cv_prog_cc_c99" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cc_c99" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 +printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } + CC="$CC $ac_cv_prog_cc_c99" +fi + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 + ac_prog_cc_stdc=c99 +fi +fi +if test x$ac_prog_cc_stdc = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 +printf %s "checking for $CC option to enable C89 features... " >&6; } +if test ${ac_cv_prog_cc_c89+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_c_conftest_c89_program +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC +fi + +if test "x$ac_cv_prog_cc_c89" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cc_c89" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } + CC="$CC $ac_cv_prog_cc_c89" +fi + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 + ac_prog_cc_stdc=c89 +fi +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 +printf %s "checking whether $CC understands -c and -o together... " >&6; } +if test ${am_cv_prog_cc_c_o+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 + ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +printf "%s\n" "$am_cv_prog_cc_c_o" >&6; } +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 +printf %s "checking whether ${MAKE-make} supports the include directive... " >&6; } +cat > confinc.mk << 'END' +am__doit: + @echo this is the am__doit target >confinc.out +.PHONY: am__doit +END +am__include="#" +am__quote= +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 + (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + case $?:`cat confinc.out 2>/dev/null` in #( + '0:this is the am__doit target') : + case $s in #( + BSD) : + am__include='.include' am__quote='"' ;; #( + *) : + am__include='include' am__quote='' ;; +esac ;; #( + *) : + ;; +esac + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 +printf "%s\n" "${_am_result}" >&6; } + +# Check whether --enable-dependency-tracking was given. +if test ${enable_dependency_tracking+y} +then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +depcc="$CC" am_compiler_list= + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +printf %s "checking dependency style of $depcc... " >&6; } +if test ${am_cv_CC_dependencies_compiler_type+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +printf "%s\n" "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +printf %s "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test ${ac_cv_prog_CPP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + # Double quotes because $CC needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO" +then : + +else $as_nop + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO" +then : + # Broken: success on invalid input. +continue +else $as_nop + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok +then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +printf "%s\n" "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO" +then : + +else $as_nop + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO" +then : + # Broken: success on invalid input. +continue +else $as_nop + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok +then : + +else $as_nop + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +printf %s "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval test \${ac_cv_prog_make_${ac_make}_set+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + SET_MAKE= +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +printf %s "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +printf "%s\n" "no, using $LN_S" >&6; } +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +printf %s "checking for grep that handles long lines and -e... " >&6; } +if test ${ac_cv_path_GREP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in grep ggrep + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +printf "%s\n" "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +printf %s "checking for egrep... " >&6; } +if test ${ac_cv_path_EGREP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in egrep + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +printf "%s\n" "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + + + + if test -n "$ac_tool_prefix"; then + for ac_prog in ar lib "link -lib" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_AR+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +printf "%s\n" "$AR" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$AR" && break + done +fi +if test -z "$AR"; then + ac_ct_AR=$AR + for ac_prog in ar lib "link -lib" +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_AR+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +printf "%s\n" "$ac_ct_AR" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$ac_ct_AR" && break +done + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +fi + +: ${AR=ar} + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5 +printf %s "checking the archiver ($AR) interface... " >&6; } +if test ${am_cv_ar_interface+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + am_cv_ar_interface=ar + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int some_variable = 0; +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 + (eval $am_ar_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test "$ac_status" -eq 0; then + am_cv_ar_interface=ar + else + am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 + (eval $am_ar_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test "$ac_status" -eq 0; then + am_cv_ar_interface=lib + else + am_cv_ar_interface=unknown + fi + fi + rm -f conftest.lib libconftest.a + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5 +printf "%s\n" "$am_cv_ar_interface" >&6; } + +case $am_cv_ar_interface in +ar) + ;; +lib) + # Microsoft lib, so override with the ar-lib wrapper script. + # FIXME: It is wrong to rewrite AR. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__AR in this case, + # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something + # similar. + AR="$am_aux_dir/ar-lib $AR" + ;; +unknown) + as_fn_error $? "could not determine $AR interface" "$LINENO" 5 + ;; +esac + + +# Check if LD supports linker scripts, +# and define automake conditional HAVE_LD_VERSION_SCRIPT if so. +# Check whether --enable-ld-version-script was given. +if test ${enable_ld_version_script+y} +then : + enableval=$enable_ld_version_script; have_ld_version_script=$enableval +fi + +if test -z "$have_ld_version_script"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if LD -Wl,--version-script works" >&5 +printf %s "checking if LD -Wl,--version-script works... " >&6; } + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" + cat > conftest.map <conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + have_ld_version_script=yes +else $as_nop + have_ld_version_script=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + rm -f conftest.map + LDFLAGS="$save_LDFLAGS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_ld_version_script" >&5 +printf "%s\n" "$have_ld_version_script" >&6; } +fi + if test "$have_ld_version_script" = "yes"; then + HAVE_LD_VERSION_SCRIPT_TRUE= + HAVE_LD_VERSION_SCRIPT_FALSE='#' +else + HAVE_LD_VERSION_SCRIPT_TRUE='#' + HAVE_LD_VERSION_SCRIPT_FALSE= +fi + + +# See if compiler supports prototypes. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function prototypes" >&5 +printf %s "checking for function prototypes... " >&6; } +if test ${ijg_cv_have_prototypes+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int testfunction (int arg1, int * arg2); /* check prototypes */ +struct methods_struct { /* check method-pointer declarations */ + int (*error_exit) (char *msgtext); + int (*trace_message) (char *msgtext); + int (*another_method) (void); +}; +int testfunction (int arg1, int * arg2) /* check definitions */ +{ return arg2[arg1]; } +int test2function (void) /* check void arg list */ +{ return 0; } + +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ijg_cv_have_prototypes=yes +else $as_nop + ijg_cv_have_prototypes=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ijg_cv_have_prototypes" >&5 +printf "%s\n" "$ijg_cv_have_prototypes" >&6; } +if test $ijg_cv_have_prototypes = yes; then + +printf "%s\n" "#define HAVE_PROTOTYPES 1" >>confdefs.h + +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Your compiler does not seem to know about function prototypes. + Perhaps it needs a special switch to enable ANSI C mode. + If so, we recommend running configure like this: + ./configure CC='cc -switch' + where -switch is the proper switch." >&5 +printf "%s\n" "$as_me: WARNING: Your compiler does not seem to know about function prototypes. + Perhaps it needs a special switch to enable ANSI C mode. + If so, we recommend running configure like this: + ./configure CC='cc -switch' + where -switch is the proper switch." >&2;} +fi + +# Check header files +ac_header= ac_cache= +for ac_item in $ac_header_c_list +do + if test $ac_cache; then + ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" + if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then + printf "%s\n" "#define $ac_item 1" >> confdefs.h + fi + ac_header= ac_cache= + elif test $ac_header; then + ac_cache=$ac_item + else + ac_header=$ac_item + fi +done + + + + + + + + +if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes +then : + +printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "stddef.h" "ac_cv_header_stddef_h" "$ac_includes_default" +if test "x$ac_cv_header_stddef_h" = xyes +then : + printf "%s\n" "#define HAVE_STDDEF_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" +if test "x$ac_cv_header_stdlib_h" = xyes +then : + printf "%s\n" "#define HAVE_STDLIB_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default" +if test "x$ac_cv_header_locale_h" = xyes +then : + printf "%s\n" "#define HAVE_LOCALE_H 1" >>confdefs.h + +fi + +ac_fn_c_check_header_compile "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default" +if test "x$ac_cv_header_string_h" = xyes +then : + +else $as_nop + +printf "%s\n" "#define NEED_BSD_STRINGS 1" >>confdefs.h + +fi + + +# See whether type size_t is defined in any ANSI-standard places; +# if not, perhaps it is defined in . +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for size_t" >&5 +printf %s "checking for size_t... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_STDDEF_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#ifdef NEED_BSD_STRINGS +#include +#else +#include +#endif +typedef size_t my_size_t; + +int +main (void) +{ + my_size_t foovar; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ijg_size_t_ok=yes +else $as_nop + ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h" +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ijg_size_t_ok" >&5 +printf "%s\n" "$ijg_size_t_ok" >&6; } +if test "$ijg_size_t_ok" != yes; then + +ac_fn_c_check_header_compile "$LINENO" "sys/types.h" "ac_cv_header_sys_types_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_types_h" = xyes +then : + +printf "%s\n" "#define NEED_SYS_TYPES_H 1" >>confdefs.h + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "size_t" >/dev/null 2>&1 +then : + ijg_size_t_ok="size_t is in sys/types.h" +else $as_nop + ijg_size_t_ok=no +fi +rm -rf conftest* + +else $as_nop + ijg_size_t_ok=no +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ijg_size_t_ok" >&5 +printf "%s\n" "$ijg_size_t_ok" >&6; } + if test "$ijg_size_t_ok" = no; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Type size_t is not defined in any of the usual places. + Try putting '\"typedef unsigned int size_t;\"' in jconfig.h." >&5 +printf "%s\n" "$as_me: WARNING: Type size_t is not defined in any of the usual places. + Try putting '\"typedef unsigned int size_t;\"' in jconfig.h." >&2;} + fi +fi + +# Check compiler characteristics +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for type unsigned char" >&5 +printf %s "checking for type unsigned char... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + unsigned char un_char; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + +printf "%s\n" "#define HAVE_UNSIGNED_CHAR 1" >>confdefs.h + +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for type unsigned short" >&5 +printf %s "checking for type unsigned short... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + unsigned short un_short; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + +printf "%s\n" "#define HAVE_UNSIGNED_SHORT 1" >>confdefs.h + +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for type void" >&5 +printf %s "checking for type void... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Caution: a C++ compiler will insist on valid prototypes */ +typedef void * void_ptr; /* check void * */ +#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ +typedef void (*void_func) (int a, int b); +#else +typedef void (*void_func) (); +#endif + +#ifdef HAVE_PROTOTYPES /* check void function result */ +void test3function (void_ptr arg1, void_func arg2) +#else +void test3function (arg1, arg2) + void_ptr arg1; + void_func arg2; +#endif +{ + char * locptr = (char *) arg1; /* check casting to and from void * */ + arg1 = (void *) locptr; + (*arg2) (1, 2); /* check call of fcn returning void */ +} + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +printf "%s\n" "#define void char" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 +printf %s "checking for an ANSI C-conforming const... " >&6; } +if test ${ac_cv_c_const+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + +#ifndef __cplusplus + /* Ultrix mips cc rejects this sort of thing. */ + typedef int charset[2]; + const charset cs = { 0, 0 }; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* IBM XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* IBM XL C 1.02.0.0 rejects this sort of thing, saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_c_const=yes +else $as_nop + ac_cv_c_const=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 +printf "%s\n" "$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +printf "%s\n" "#define const /**/" >>confdefs.h + +fi + + +# Check for non-broken inline under various spellings +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +printf %s "checking for inline... " >&6; } +ijg_cv_inline="" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +} __inline__ int foo() { return 0; } +int bar() { return foo(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ijg_cv_inline="__inline__" +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +} __inline int foo() { return 0; } +int bar() { return foo(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ijg_cv_inline="__inline" +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +} inline int foo() { return 0; } +int bar() { return foo(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ijg_cv_inline="inline" +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ijg_cv_inline" >&5 +printf "%s\n" "$ijg_cv_inline" >&6; } + +printf "%s\n" "#define INLINE $ijg_cv_inline" >>confdefs.h + + +# We cannot check for bogus warnings, but at least we can check for errors +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for broken incomplete types" >&5 +printf %s "checking for broken incomplete types... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +typedef struct undefined_structure * undef_struct_ptr; + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +printf "%s\n" "ok" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: broken" >&5 +printf "%s\n" "broken" >&6; } + +printf "%s\n" "#define INCOMPLETE_TYPES_BROKEN 1" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + +# Test whether global names are unique to at least 15 chars +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for short external names" >&5 +printf %s "checking for short external names... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int possibly_duplicate_function () { return 0; } +int possibly_dupli_function () { return 1; } + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +printf "%s\n" "ok" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: short" >&5 +printf "%s\n" "short" >&6; } + +printf "%s\n" "#define NEED_SHORT_EXTERNAL_NAMES 1" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + +# Run-time checks +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking to see if char is signed" >&5 +printf %s "checking to see if char is signed... " >&6; } +if test "$cross_compiling" = yes +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Assuming that char is signed on target machine. + If it is unsigned, this will be a little bit inefficient." >&5 +printf "%s\n" "$as_me: WARNING: Assuming that char is signed on target machine. + If it is unsigned, this will be a little bit inefficient." >&2;} + +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#ifdef HAVE_PROTOTYPES +int is_char_signed (int arg) +#else +int is_char_signed (arg) + int arg; +#endif +{ + if (arg == 189) { /* expected result for unsigned char */ + return 0; /* type char is unsigned */ + } + else if (arg != -67) { /* expected result for signed char */ + printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + } + return 1; /* assume char is signed otherwise */ +} +char signed_char_check = (char) (-67); +int main() { + exit(is_char_signed((int) signed_char_check)); +} +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +printf "%s\n" "#define CHAR_IS_UNSIGNED 1" >>confdefs.h + +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking to see if right shift is signed" >&5 +printf %s "checking to see if right shift is signed... " >&6; } +if test "$cross_compiling" = yes +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Assuming that right shift is signed on target machine." >&5 +printf "%s\n" "Assuming that right shift is signed on target machine." >&6; } +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#ifdef HAVE_PROTOTYPES +int is_shifting_signed (long arg) +#else +int is_shifting_signed (arg) + long arg; +#endif +/* See whether right-shift on a long is signed or not. */ +{ + long res = arg >> 4; + + if (res == -0x7F7E80CL) { /* expected result for signed shift */ + return 1; /* right shift is signed */ + } + /* see if unsigned-shift hack will fix it. */ + /* we can't just test exact value since it depends on width of long... */ + res |= (~0L) << (32-4); + if (res == -0x7F7E80CL) { /* expected result now? */ + return 0; /* right shift is unsigned */ + } + printf("Right shift isn't acting as I expect it to.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + return 0; /* try it with unsigned anyway */ +} +int main() { + exit(is_shifting_signed(-0x7F7E80B1L)); +} +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +printf "%s\n" "#define RIGHT_SHIFT_IS_UNSIGNED 1" >>confdefs.h + +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking to see if fopen accepts b spec" >&5 +printf %s "checking to see if fopen accepts b spec... " >&6; } +if test "$cross_compiling" = yes +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Assuming that it does." >&5 +printf "%s\n" "Assuming that it does." >&6; } +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_STDLIB_H +#include +#endif +#include +int main() { + if (fopen("conftestdata", "wb") != NULL) + exit(0); + exit(1); +} +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +printf "%s\n" "#define DONT_USE_B_MODE 1" >>confdefs.h + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +# Configure libtool +case `pwd` in + *\ * | *\ *) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 +printf "%s\n" "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; +esac + + + +macro_version='2.4.6' +macro_revision='2.4.6' + + + + + + + + + + + + + + +ltmain=$ac_aux_dir/ltmain.sh + +# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 +printf %s "checking how to print strings... " >&6; } +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "" +} + +case $ECHO in + printf*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: printf" >&5 +printf "%s\n" "printf" >&6; } ;; + print*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 +printf "%s\n" "print -r" >&6; } ;; + *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: cat" >&5 +printf "%s\n" "cat" >&6; } ;; +esac + + + + + + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +printf %s "checking for a sed that does not truncate output... " >&6; } +if test ${ac_cv_path_SED+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + { ac_script=; unset ac_script;} + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in sed gsed + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_SED" || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_SED_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi +else + ac_cv_path_SED=$SED +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +printf "%s\n" "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed + +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" + + + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 +printf %s "checking for fgrep... " >&6; } +if test ${ac_cv_path_FGREP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 + then ac_cv_path_FGREP="$GREP -F" + else + if test -z "$FGREP"; then + ac_path_FGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in fgrep + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_FGREP="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_FGREP" || continue +# Check for GNU ac_path_FGREP and select it if it is found. + # Check for GNU $ac_path_FGREP +case `"$ac_path_FGREP" --version 2>&1` in +*GNU*) + ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" 'FGREP' >> "conftest.nl" + "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_FGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_FGREP="$ac_path_FGREP" + ac_path_FGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_FGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_FGREP"; then + as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_FGREP=$FGREP +fi + + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 +printf "%s\n" "$ac_cv_path_FGREP" >&6; } + FGREP="$ac_cv_path_FGREP" + + +test -z "$GREP" && GREP=grep + + + + + + + + + + + + + + + + + + + +# Check whether --with-gnu-ld was given. +if test ${with_gnu_ld+y} +then : + withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes +else $as_nop + with_gnu_ld=no +fi + +ac_prog=ld +if test yes = "$GCC"; then + # Check if gcc -print-prog-name=ld gives a path. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +printf %s "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return, which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD=$ac_prog + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test yes = "$with_gnu_ld"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +printf %s "checking for GNU ld... " >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +printf %s "checking for non-GNU ld... " >&6; } +fi +if test ${lt_cv_path_LD+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -z "$LD"; then + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD=$ac_dir/$ac_prog + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +printf "%s\n" "$LD" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +printf %s "checking if the linker ($LD) is GNU ld... " >&6; } +if test ${lt_cv_prog_gnu_ld+y} +then : + printf %s "(cached) " >&6 +else $as_nop + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 +printf %s "checking for BSD- or MS-compatible name lister (nm)... " >&6; } +if test ${lt_cv_path_NM+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM=$NM +else + lt_nm_to_check=${ac_tool_prefix}nm + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + tmp_nm=$ac_dir/$lt_tmp_nm + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the 'sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + case $build_os in + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac + case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break 2 + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break 2 + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS=$lt_save_ifs + done + : ${lt_cv_path_NM=no} +fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 +printf "%s\n" "$lt_cv_path_NM" >&6; } +if test no != "$lt_cv_path_NM"; then + NM=$lt_cv_path_NM +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$DUMPBIN"; then : + # Let the user override the test. + else + if test -n "$ac_tool_prefix"; then + for ac_prog in dumpbin "link -dump" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_DUMPBIN+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$DUMPBIN"; then + ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DUMPBIN=$ac_cv_prog_DUMPBIN +if test -n "$DUMPBIN"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 +printf "%s\n" "$DUMPBIN" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$DUMPBIN" && break + done +fi +if test -z "$DUMPBIN"; then + ac_ct_DUMPBIN=$DUMPBIN + for ac_prog in dumpbin "link -dump" +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_DUMPBIN+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_DUMPBIN"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN +if test -n "$ac_ct_DUMPBIN"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 +printf "%s\n" "$ac_ct_DUMPBIN" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$ac_ct_DUMPBIN" && break +done + + if test "x$ac_ct_DUMPBIN" = x; then + DUMPBIN=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DUMPBIN=$ac_ct_DUMPBIN + fi +fi + + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols -headers" + ;; + *) + DUMPBIN=: + ;; + esac + fi + + if test : != "$DUMPBIN"; then + NM=$DUMPBIN + fi +fi +test -z "$NM" && NM=nm + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 +printf %s "checking the name lister ($NM) interface... " >&6; } +if test ${lt_cv_nm_interface+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&5 + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&5 + (eval echo "\"\$as_me:$LINENO: output\"" >&5) + cat conftest.out >&5 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest* +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 +printf "%s\n" "$lt_cv_nm_interface" >&6; } + +# find the maximum length of command line arguments +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 +printf %s "checking the maximum length of command line arguments... " >&6; } +if test ${lt_cv_sys_max_cmd_len+y} +then : + printf %s "(cached) " >&6 +else $as_nop + i=0 + teststring=ABCD + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + mint*) + # On MiNT this can take a long time and run out of memory. + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test X`env echo "$teststring$teststring" 2>/dev/null` \ + = "X$teststring$teststring"; } >/dev/null 2>&1 && + test 17 != "$i" # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac + +fi + +if test -n "$lt_cv_sys_max_cmd_len"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 +printf "%s\n" "$lt_cv_sys_max_cmd_len" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5 +printf "%s\n" "none" >&6; } +fi +max_cmd_len=$lt_cv_sys_max_cmd_len + + + + + + +: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi + + + + + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 +printf %s "checking how to convert $build file names to $host format... " >&6; } +if test ${lt_cv_to_host_file_cmd+y} +then : + printf %s "(cached) " >&6 +else $as_nop + case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac + +fi + +to_host_file_cmd=$lt_cv_to_host_file_cmd +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 +printf "%s\n" "$lt_cv_to_host_file_cmd" >&6; } + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 +printf %s "checking how to convert $build file names to toolchain format... " >&6; } +if test ${lt_cv_to_tool_file_cmd+y} +then : + printf %s "(cached) " >&6 +else $as_nop + #assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac + +fi + +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 +printf "%s\n" "$lt_cv_to_tool_file_cmd" >&6; } + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 +printf %s "checking for $LD option to reload object files... " >&6; } +if test ${lt_cv_ld_reload_flag+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_ld_reload_flag='-r' +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 +printf "%s\n" "$lt_cv_ld_reload_flag" >&6; } +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + if test yes != "$GCC"; then + reload_cmds=false + fi + ;; + darwin*) + if test yes = "$GCC"; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_OBJDUMP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +printf "%s\n" "$OBJDUMP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_OBJDUMP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +printf "%s\n" "$ac_ct_OBJDUMP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + +test -z "$OBJDUMP" && OBJDUMP=objdump + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 +printf %s "checking how to recognize dependent libraries... " >&6; } +if test ${lt_cv_deplibs_check_method+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# 'unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# that responds to the $file_magic_cmd with a given extended regex. +# If you have 'file' or equivalent on your system and you're not sure +# whether 'pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[4-9]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + # Keep this pattern in sync with the one in func_win32_libid. + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc*) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +haiku*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[3-9]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd* | bitrig*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +os2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 +printf "%s\n" "$lt_cv_deplibs_check_method" >&6; } + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` + fi + ;; + esac +fi + +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + + + + + + + + + + + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_DLLTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +printf "%s\n" "$DLLTOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_DLLTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DLLTOOL="dlltool" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +printf "%s\n" "$ac_ct_DLLTOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" +fi + +test -z "$DLLTOOL" && DLLTOOL=dlltool + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 +printf %s "checking how to associate runtime and link libraries... " >&6; } +if test ${lt_cv_sharedlib_from_linklib_cmd+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd=$ECHO + ;; +esac + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 +printf "%s\n" "$lt_cv_sharedlib_from_linklib_cmd" >&6; } +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + + + + + + + +if test -n "$ac_tool_prefix"; then + for ac_prog in ar + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_AR+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +printf "%s\n" "$AR" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$AR" && break + done +fi +if test -z "$AR"; then + ac_ct_AR=$AR + for ac_prog in ar +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_AR+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +printf "%s\n" "$ac_ct_AR" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$ac_ct_AR" && break +done + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +fi + +: ${AR=ar} +: ${AR_FLAGS=cru} + + + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 +printf %s "checking for archiver @FILE support... " >&6; } +if test ${lt_cv_ar_at_file+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_ar_at_file=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test 0 -eq "$ac_status"; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test 0 -ne "$ac_status"; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 +printf "%s\n" "$lt_cv_ar_at_file" >&6; } + +if test no = "$lt_cv_ar_at_file"; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +printf "%s\n" "$STRIP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +printf "%s\n" "$ac_ct_STRIP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +test -z "$STRIP" && STRIP=: + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_RANLIB+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +printf "%s\n" "$RANLIB" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_RANLIB+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +printf "%s\n" "$ac_ct_RANLIB" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +test -z "$RANLIB" && RANLIB=: + + + + + + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + bitrig* | openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" +fi + +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 +printf %s "checking command to parse $NM output from $compiler object... " >&6; } +if test ${lt_cv_sys_global_symbol_pipe+y} +then : + printf %s "(cached) " >&6 +else $as_nop + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[ABCDGISTW]' + ;; +hpux*) + if test ia64 = "$host_cpu"; then + symcode='[ABCDEGRST]' + fi + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris*) + symcode='[BDRT]' + ;; +sco3.2v5*) + symcode='[DT]' + ;; +sysv4.2uw2*) + symcode='[DT]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[ABDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. + lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" + lt_c_name_lib_hook="\ + -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ + -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" +else + # Disable hooks by default. + lt_cv_sys_global_symbol_to_import= + lt_cdecl_hook= + lt_c_name_hook= + lt_c_name_lib_hook= +fi + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +$lt_cdecl_hook\ +" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +$lt_c_name_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + +# Transform an extracted symbol line into symbol name with lib prefix and +# symbol address. +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +$lt_c_name_lib_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK '"\ +" {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ +" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ +" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ +" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ +" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 + (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +LT_DLSYM_CONST struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS + LIBS=conftstm.$ac_objext + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest$ac_exeext; then + pipe_works=yes + fi + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test yes = "$pipe_works"; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +printf "%s\n" "failed" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +printf "%s\n" "ok" >&6; } +fi + +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then + nm_file_list_spec='@' +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 +printf %s "checking for sysroot... " >&6; } + +# Check whether --with-sysroot was given. +if test ${with_sysroot+y} +then : + withval=$with_sysroot; +else $as_nop + with_sysroot=no +fi + + +lt_sysroot= +case $with_sysroot in #( + yes) + if test yes = "$GCC"; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 +printf "%s\n" "$with_sysroot" >&6; } + as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 + ;; +esac + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 +printf "%s\n" "${lt_sysroot:-no}" >&6; } + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 +printf %s "checking for a working dd... " >&6; } +if test ${ac_cv_path_lt_DD+y} +then : + printf %s "(cached) " >&6 +else $as_nop + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +: ${lt_DD:=$DD} +if test -z "$lt_DD"; then + ac_path_lt_DD_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in dd + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_lt_DD="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_lt_DD" || continue +if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: +fi + $ac_path_lt_DD_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_lt_DD"; then + : + fi +else + ac_cv_path_lt_DD=$lt_DD +fi + +rm -f conftest.i conftest2.i conftest.out +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 +printf "%s\n" "$ac_cv_path_lt_DD" >&6; } + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 +printf %s "checking how to truncate binary pipes... " >&6; } +if test ${lt_cv_truncate_bin+y} +then : + printf %s "(cached) " >&6 +else $as_nop + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +lt_cv_truncate_bin= +if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out +test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 +printf "%s\n" "$lt_cv_truncate_bin" >&6; } + + + + + + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + +# Check whether --enable-libtool-lock was given. +if test ${enable_libtool_lock+y} +then : + enableval=$enable_libtool_lock; +fi + +test no = "$enable_libtool_lock" || enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out what ABI is being produced by ac_compile, and set mode + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE=32 + ;; + *ELF-64*) + HPUX_IA64_MODE=64 + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + if test yes = "$lt_cv_prog_gnu_ld"; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +mips64*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + emul=elf + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; + *64-bit*) + emul="${emul}64" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; + *LSB*) + emul="${emul}ltsmip" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; + esac + LD="${LD-ld} -m $emul" + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. Note that the listed cases only cover the + # situations where additional linker options are needed (such as when + # doing 32-bit compilation for a host where ld defaults to 64-bit, or + # vice versa); the common cases where no linker options are needed do + # not appear in the list. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac + ;; + powerpc64le-*linux*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + powerpcle-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -belf" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 +printf %s "checking whether the C compiler needs -belf... " >&6; } +if test ${lt_cv_cc_needs_belf+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + lt_cv_cc_needs_belf=yes +else $as_nop + lt_cv_cc_needs_belf=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 +printf "%s\n" "$lt_cv_cc_needs_belf" >&6; } + if test yes != "$lt_cv_cc_needs_belf"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS=$SAVE_CFLAGS + fi + ;; +*-*solaris*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) + case $host in + i?86-*-solaris*|x86_64-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD=${LD-ld}_sol2 + fi + ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks=$enable_libtool_lock + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. +set dummy ${ac_tool_prefix}mt; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_MANIFEST_TOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$MANIFEST_TOOL"; then + ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL +if test -n "$MANIFEST_TOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 +printf "%s\n" "$MANIFEST_TOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_MANIFEST_TOOL"; then + ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL + # Extract the first word of "mt", so it can be a program name with args. +set dummy mt; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_MANIFEST_TOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_MANIFEST_TOOL"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL +if test -n "$ac_ct_MANIFEST_TOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 +printf "%s\n" "$ac_ct_MANIFEST_TOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_MANIFEST_TOOL" = x; then + MANIFEST_TOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL + fi +else + MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" +fi + +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 +printf %s "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } +if test ${lt_cv_path_mainfest_tool+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&5 + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest* +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 +printf "%s\n" "$lt_cv_path_mainfest_tool" >&6; } +if test yes != "$lt_cv_path_mainfest_tool"; then + MANIFEST_TOOL=: +fi + + + + + + + case $host_os in + rhapsody* | darwin*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. +set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_DSYMUTIL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$DSYMUTIL"; then + ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DSYMUTIL=$ac_cv_prog_DSYMUTIL +if test -n "$DSYMUTIL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 +printf "%s\n" "$DSYMUTIL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DSYMUTIL"; then + ac_ct_DSYMUTIL=$DSYMUTIL + # Extract the first word of "dsymutil", so it can be a program name with args. +set dummy dsymutil; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_DSYMUTIL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_DSYMUTIL"; then + ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL +if test -n "$ac_ct_DSYMUTIL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 +printf "%s\n" "$ac_ct_DSYMUTIL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_DSYMUTIL" = x; then + DSYMUTIL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DSYMUTIL=$ac_ct_DSYMUTIL + fi +else + DSYMUTIL="$ac_cv_prog_DSYMUTIL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. +set dummy ${ac_tool_prefix}nmedit; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_NMEDIT+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$NMEDIT"; then + ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +NMEDIT=$ac_cv_prog_NMEDIT +if test -n "$NMEDIT"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 +printf "%s\n" "$NMEDIT" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_NMEDIT"; then + ac_ct_NMEDIT=$NMEDIT + # Extract the first word of "nmedit", so it can be a program name with args. +set dummy nmedit; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_NMEDIT+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_NMEDIT"; then + ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_NMEDIT="nmedit" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT +if test -n "$ac_ct_NMEDIT"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 +printf "%s\n" "$ac_ct_NMEDIT" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_NMEDIT" = x; then + NMEDIT=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + NMEDIT=$ac_ct_NMEDIT + fi +else + NMEDIT="$ac_cv_prog_NMEDIT" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. +set dummy ${ac_tool_prefix}lipo; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_LIPO+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$LIPO"; then + ac_cv_prog_LIPO="$LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_LIPO="${ac_tool_prefix}lipo" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +LIPO=$ac_cv_prog_LIPO +if test -n "$LIPO"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 +printf "%s\n" "$LIPO" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_LIPO"; then + ac_ct_LIPO=$LIPO + # Extract the first word of "lipo", so it can be a program name with args. +set dummy lipo; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_LIPO+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_LIPO"; then + ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_LIPO="lipo" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO +if test -n "$ac_ct_LIPO"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 +printf "%s\n" "$ac_ct_LIPO" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_LIPO" = x; then + LIPO=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + LIPO=$ac_ct_LIPO + fi +else + LIPO="$ac_cv_prog_LIPO" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_OTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$OTOOL"; then + ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_OTOOL="${ac_tool_prefix}otool" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL=$ac_cv_prog_OTOOL +if test -n "$OTOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 +printf "%s\n" "$OTOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL"; then + ac_ct_OTOOL=$OTOOL + # Extract the first word of "otool", so it can be a program name with args. +set dummy otool; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_OTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_OTOOL"; then + ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OTOOL="otool" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL +if test -n "$ac_ct_OTOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 +printf "%s\n" "$ac_ct_OTOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_OTOOL" = x; then + OTOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL=$ac_ct_OTOOL + fi +else + OTOOL="$ac_cv_prog_OTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool64; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_OTOOL64+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$OTOOL64"; then + ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL64=$ac_cv_prog_OTOOL64 +if test -n "$OTOOL64"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 +printf "%s\n" "$OTOOL64" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL64"; then + ac_ct_OTOOL64=$OTOOL64 + # Extract the first word of "otool64", so it can be a program name with args. +set dummy otool64; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_OTOOL64+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_OTOOL64"; then + ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OTOOL64="otool64" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 +if test -n "$ac_ct_OTOOL64"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 +printf "%s\n" "$ac_ct_OTOOL64" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_OTOOL64" = x; then + OTOOL64=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL64=$ac_ct_OTOOL64 + fi +else + OTOOL64="$ac_cv_prog_OTOOL64" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 +printf %s "checking for -single_module linker flag... " >&6; } +if test ${lt_cv_apple_cc_single_mod+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_apple_cc_single_mod=no + if test -z "$LT_MULTI_MODULE"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&5 + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test 0 = "$_lt_result"; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&5 + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 +printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 +printf %s "checking for -exported_symbols_list linker flag... " >&6; } +if test ${lt_cv_ld_exported_symbols_list+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + lt_cv_ld_exported_symbols_list=yes +else $as_nop + lt_cv_ld_exported_symbols_list=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 +printf "%s\n" "$lt_cv_ld_exported_symbols_list" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 +printf %s "checking for -force_load linker flag... " >&6; } +if test ${lt_cv_ld_force_load+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_ld_force_load=no + cat > conftest.c << _LT_EOF +int forced_loaded() { return 2;} +_LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 + echo "$AR cru libconftest.a conftest.o" >&5 + $AR cru libconftest.a conftest.o 2>&5 + echo "$RANLIB libconftest.a" >&5 + $RANLIB libconftest.a 2>&5 + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err + _lt_result=$? + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&5 + elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then + lt_cv_ld_force_load=yes + else + cat conftest.err >&5 + fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 +printf "%s\n" "$lt_cv_ld_force_load" >&6; } + case $host_os in + rhapsody* | darwin1.[012]) + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[91]*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + 10.[012][,.]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test yes = "$lt_cv_apple_cc_single_mod"; then + _lt_dar_single_mod='$single_module' + fi + if test yes = "$lt_cv_ld_exported_symbols_list"; then + _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' + fi + if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + +ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default +" +if test "x$ac_cv_header_dlfcn_h" = xyes +then : + printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h + +fi + + + + + +# Set options +enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. +set dummy ${ac_tool_prefix}as; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_AS+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_AS="${ac_tool_prefix}as" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AS=$ac_cv_prog_AS +if test -n "$AS"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 +printf "%s\n" "$AS" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AS"; then + ac_ct_AS=$AS + # Extract the first word of "as", so it can be a program name with args. +set dummy as; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_AS+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_AS"; then + ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AS="as" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AS=$ac_cv_prog_ac_ct_AS +if test -n "$ac_ct_AS"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 +printf "%s\n" "$ac_ct_AS" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_AS" = x; then + AS="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AS=$ac_ct_AS + fi +else + AS="$ac_cv_prog_AS" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_DLLTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +printf "%s\n" "$DLLTOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_DLLTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DLLTOOL="dlltool" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +printf "%s\n" "$ac_ct_DLLTOOL" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_OBJDUMP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +printf "%s\n" "$OBJDUMP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_OBJDUMP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +printf "%s\n" "$ac_ct_OBJDUMP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + + ;; +esac + +test -z "$AS" && AS=as + + + + + +test -z "$DLLTOOL" && DLLTOOL=dlltool + + + + + +test -z "$OBJDUMP" && OBJDUMP=objdump + + + + + + + + enable_dlopen=no + + + + # Check whether --enable-shared was given. +if test ${enable_shared+y} +then : + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else $as_nop + enable_shared=yes +fi + + + + + + + + + + # Check whether --enable-static was given. +if test ${enable_static+y} +then : + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else $as_nop + enable_static=yes +fi + + + + + + + + + + +# Check whether --with-pic was given. +if test ${with_pic+y} +then : + withval=$with_pic; lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $withval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else $as_nop + pic_mode=default +fi + + + + + + + + + # Check whether --enable-fast-install was given. +if test ${enable_fast_install+y} +then : + enableval=$enable_fast_install; p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else $as_nop + enable_fast_install=yes +fi + + + + + + + + + shared_archive_member_spec= +case $host,$enable_shared in +power*-*-aix[5-9]*,yes) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 +printf %s "checking which variant of shared library versioning to provide... " >&6; } + +# Check whether --with-aix-soname was given. +if test ${with_aix_soname+y} +then : + withval=$with_aix_soname; case $withval in + aix|svr4|both) + ;; + *) + as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname +else $as_nop + if test ${lt_cv_with_aix_soname+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_with_aix_soname=aix +fi + + with_aix_soname=$lt_cv_with_aix_soname +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 +printf "%s\n" "$with_aix_soname" >&6; } + if test aix != "$with_aix_soname"; then + # For the AIX way of multilib, we name the shared archive member + # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', + # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. + # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, + # the AIX toolchain works better with OBJECT_MODE set (default 32). + if test 64 = "${OBJECT_MODE-32}"; then + shared_archive_member_spec=shr_64 + else + shared_archive_member_spec=shr + fi + fi + ;; +*) + with_aix_soname=aix + ;; +esac + + + + + + + + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS=$ltmain + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +test -z "$LN_S" && LN_S="ln -s" + + + + + + + + + + + + + + +if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 +printf %s "checking for objdir... " >&6; } +if test ${lt_cv_objdir+y} +then : + printf %s "(cached) " >&6 +else $as_nop + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 +printf "%s\n" "$lt_cv_objdir" >&6; } +objdir=$lt_cv_objdir + + + + + +printf "%s\n" "#define LT_OBJDIR \"$lt_cv_objdir/\"" >>confdefs.h + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld=$lt_cv_prog_gnu_ld + +old_CC=$CC +old_CFLAGS=$CFLAGS + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +func_cc_basename $compiler +cc_basename=$func_cc_basename_result + + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 +printf %s "checking for ${ac_tool_prefix}file... " >&6; } +if test ${lt_cv_path_MAGIC_CMD+y} +then : + printf %s "(cached) " >&6 +else $as_nop + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/${ac_tool_prefix}file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac +fi + +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +printf "%s\n" "$MAGIC_CMD" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + + + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for file" >&5 +printf %s "checking for file... " >&6; } +if test ${lt_cv_path_MAGIC_CMD+y} +then : + printf %s "(cached) " >&6 +else $as_nop + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac +fi + +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +printf "%s\n" "$MAGIC_CMD" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +# Use C for the default configuration in the libtool script + +lt_save_CC=$CC +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* + +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* + + +if test -n "$compiler"; then + +lt_prog_compiler_no_builtin_flag= + +if test yes = "$GCC"; then + case $cc_basename in + nvcc*) + lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; + *) + lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; + esac + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +printf %s "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } +if test ${lt_cv_prog_compiler_rtti_exceptions+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +printf "%s\n" "$lt_cv_prog_compiler_rtti_exceptions" >&6; } + +if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + + + + + + + lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + + + if test yes = "$GCC"; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + lt_prog_compiler_pic='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + lt_prog_compiler_pic='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + lt_prog_compiler_static= + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + lt_prog_compiler_wl='-Xlinker ' + if test -n "$lt_prog_compiler_pic"; then + lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='$wl-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + # old Intel for x86_64, which still supported -KPIC. + ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='--shared' + lt_prog_compiler_static='--static' + ;; + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-qpic' + lt_prog_compiler_static='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' + ;; + *Sun\ F* | *Sun*Fortran*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Wl,' + ;; + *Intel*\ [CF]*Compiler*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + *Portland\ Group*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + rdos*) + lt_prog_compiler_static='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +case $host_os in + # For platforms that do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +printf %s "checking for $compiler option to produce PIC... " >&6; } +if test ${lt_cv_prog_compiler_pic+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_pic=$lt_prog_compiler_pic +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic" >&6; } +lt_prog_compiler_pic=$lt_cv_prog_compiler_pic + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if test ${lt_cv_prog_compiler_pic_works+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works=yes + fi + fi + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic_works" >&6; } + +if test yes = "$lt_cv_prog_compiler_pic_works"; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi + + + + + + + + + + + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if test ${lt_cv_prog_compiler_static_works+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_static_works=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works=yes + fi + else + lt_cv_prog_compiler_static_works=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 +printf "%s\n" "$lt_cv_prog_compiler_static_works" >&6; } + +if test yes = "$lt_cv_prog_compiler_static_works"; then + : +else + lt_prog_compiler_static= +fi + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test ${lt_cv_prog_compiler_c_o+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test ${lt_cv_prog_compiler_c_o+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } + + + + +hard_links=nottested +if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then + # do not overwrite the value of need_locks provided by the user + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +printf %s "checking if we can lock with hard links... " >&6; } + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +printf "%s\n" "$hard_links" >&6; } + if test no = "$hard_links"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + runpath_var= + allow_undefined_flag= + always_export_symbols=no + archive_cmds= + archive_expsym_cmds= + compiler_needs_object=no + enable_shared_with_static_runtimes=no + export_dynamic_flag_spec= + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + hardcode_automatic=no + hardcode_direct=no + hardcode_direct_absolute=no + hardcode_libdir_flag_spec= + hardcode_libdir_separator= + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + inherit_rpath=no + link_all_deplibs=unknown + module_cmds= + module_expsym_cmds= + old_archive_from_new_cmds= + old_archive_from_expsyms_cmds= + thread_safe_flag_spec= + whole_archive_flag_spec= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ' (' and ')$', so one must not match beginning or + # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', + # as well as any symbol that contains 'd'. + exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test yes != "$GCC"; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd* | bitrig*) + with_gnu_ld=no + ;; + esac + + ld_shlibs=yes + + # On some targets, GNU ld is compatible enough with the native linker + # that we're better off using the native interface for both. + lt_use_gnu_ld_interface=no + if test yes = "$with_gnu_ld"; then + case $host_os in + aix*) + # The AIX port of GNU ld has always aspired to compatibility + # with the native linker. However, as the warning in the GNU ld + # block says, versions before 2.19.5* couldn't really create working + # shared libraries, regardless of the interface used. + case `$LD -v 2>&1` in + *\ \(GNU\ Binutils\)\ 2.19.5*) ;; + *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; + *\ \(GNU\ Binutils\)\ [3-9]*) ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + fi + + if test yes = "$lt_use_gnu_ld_interface"; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='$wl' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + export_dynamic_flag_spec='$wl--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + whole_archive_flag_spec= + fi + supports_anon_versioning=no + case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test ia64 != "$host_cpu"; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.19, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to install binutils +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. +*** You will then need to restart the configuration process. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + export_dynamic_flag_spec='$wl--export-all-symbols' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' + exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs=no + fi + ;; + + haiku*) + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + link_all_deplibs=yes + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes + ;; + + interix[3-9]*) + hardcode_direct=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + tmp_diet=no + if test linux-dietlibc = "$host_os"; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test no = "$tmp_diet" + then + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group f77 and f90 compilers + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + whole_archive_flag_spec= + tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 + tmp_sharedflag='-Wl,-shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + nvcc*) # Cuda Compiler Driver 2.2 + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + compiler_needs_object=yes + ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + compiler_needs_object=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + tcc*) + export_dynamic_flag_spec='-rdynamic' + ;; + xlf* | bgf* | bgxlf* | mpixlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test no = "$ld_shlibs"; then + runpath_var= + hardcode_libdir_flag_spec= + export_dynamic_flag_spec= + whole_archive_flag_spec= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix[4-9]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then + aix_use_runtimelinking=yes + break + fi + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_direct_absolute=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + file_list_spec='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # traditional, no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + hardcode_direct=no + hardcode_direct_absolute=no + ;; + esac + + if test yes = "$GCC"; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag="$shared_flag "'$wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + export_dynamic_flag_spec='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if test ${lt_cv_aix_libpath_+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=/usr/lib:/lib + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if test ${lt_cv_aix_libpath_+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=/usr/lib:/lib + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' $wl-bernotok' + allow_undefined_flag=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + fi + archive_cmds_need_lc=yes + archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in + cl*) + # Native MSVC + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + always_export_symbols=yes + file_list_spec='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, )='true' + enable_shared_with_static_runtimes=yes + exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + old_postinstall_cmds='chmod 644 $oldlib' + postlink_cmds='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + enable_shared_with_static_runtimes=yes + ;; + esac + ;; + + darwin* | rhapsody*) + + + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + if test yes = "$lt_cv_ld_force_load"; then + whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + + else + whole_archive_flag_spec='' + fi + link_all_deplibs=yes + allow_undefined_flag=$_lt_dar_allow_undefined + case $cc_basename in + ifort*|nagfor*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test yes = "$_lt_dar_can_shared"; then + output_verbose_link_cmd=func_echo_all + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + + else + ld_shlibs=no + fi + + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2.*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test yes = "$GCC"; then + archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='$wl-E' + ;; + + hpux10*) + if test yes,no = "$GCC,$with_gnu_ld"; then + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='$wl-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + + hpux11*) + if test yes,no = "$GCC,$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + + # Older versions of the 11.00 compiler do not understand -b yet + # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 +printf %s "checking if $CC understands -b... " >&6; } +if test ${lt_cv_prog_compiler__b+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_prog_compiler__b=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -b" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler__b=yes + fi + else + lt_cv_prog_compiler__b=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 +printf "%s\n" "$lt_cv_prog_compiler__b" >&6; } + +if test yes = "$lt_cv_prog_compiler__b"; then + archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' +else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' +fi + + ;; + esac + fi + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + *) + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='$wl-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test yes = "$GCC"; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + # This should be the same for all languages, so no per-tag cache variable. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 +printf %s "checking whether the $host_os linker accepts -exported_symbol... " >&6; } +if test ${lt_cv_irix_exported_symbol+y} +then : + printf %s "(cached) " >&6 +else $as_nop + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo (void) { return 0; } +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + lt_cv_irix_exported_symbol=yes +else $as_nop + lt_cv_irix_exported_symbol=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 +printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } + if test yes = "$lt_cv_irix_exported_symbol"; then + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' + fi + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + inherit_rpath=yes + link_all_deplibs=yes + ;; + + linux*) + case $cc_basename in + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + ld_shlibs=yes + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + *nto* | *qnx*) + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + hardcode_shlibpath_var=no + hardcode_direct_absolute=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' + else + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + fi + else + ld_shlibs=no + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes + ;; + + osf3*) + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + archive_cmds_need_lc='no' + hardcode_libdir_separator=: + ;; + + solaris*) + no_undefined_flag=' -z defs' + if test yes = "$GCC"; then + wlarc='$wl' + archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='$wl' + archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. GCC discards it without '$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test yes = "$GCC"; then + whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + else + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' + fi + ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test sequent = "$host_vendor"; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag='$wl-z,text' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag='$wl-z,text' + allow_undefined_flag='$wl-z,nodefs' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='$wl-R,$libdir' + hardcode_libdir_separator=':' + link_all_deplibs=yes + export_dynamic_flag_spec='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + + if test sni = "$host_vendor"; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + export_dynamic_flag_spec='$wl-Blargedynsym' + ;; + esac + fi + fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 +printf "%s\n" "$ld_shlibs" >&6; } +test no = "$ld_shlibs" && can_build_shared=no + +with_gnu_ld=$with_gnu_ld + + + + + + + + + + + + + + + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test yes,yes = "$GCC,$enable_shared"; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +printf %s "checking whether -lc should be explicitly linked in... " >&6; } +if test ${lt_cv_archive_cmds_need_lc+y} +then : + printf %s "(cached) " >&6 +else $as_nop + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 + (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + then + lt_cv_archive_cmds_need_lc=no + else + lt_cv_archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 +printf "%s\n" "$lt_cv_archive_cmds_need_lc" >&6; } + archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc + ;; + esac + fi + ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +printf %s "checking dynamic linker characteristics... " >&6; } + +if test yes = "$GCC"; then + case $host_os in + darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; + *) lt_awk_arg='/^libraries:/' ;; + esac + case $host_os in + mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; + *) lt_sed_strip_eq='s|=/|/|g' ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` + case $lt_search_path_spec in + *\;*) + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary... + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + # ...but if some path component already ends with the multilib dir we assume + # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). + case "$lt_multi_os_dir; $lt_search_path_spec " in + "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) + lt_multi_os_dir= + ;; + esac + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" + elif test -n "$lt_multi_os_dir"; then + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' +BEGIN {RS = " "; FS = "/|\n";} { + lt_foo = ""; + lt_count = 0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo = "/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[lt_foo]++; } + if (lt_freq[lt_foo] == 1) { print lt_foo; } +}'` + # AWK program above erroneously prepends '/' to C:/dos/paths + # for these hosts. + case $host_os in + mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + $SED 's|/\([A-Za-z]:\)|\1|g'` ;; + esac + sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=.so +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + + + +case $host_os in +aix3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='$libname$release$shared_ext$major' + ;; + +aix[4-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test ia64 = "$host_cpu"; then + # AIX 5 supports IA64 + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a(lib.so.V)' + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='$libname$shared_ext' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + + case $GCC,$cc_basename in + yes,*) + # gcc + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec=$LIB + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' + ;; + + *) + # Assume MSVC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; + esac + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[23].*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2.*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + dynamic_linker="$host_os runtime_loader" + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=no + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 + fi + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 + ;; + +interix[3-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test yes = "$lt_cv_prog_gnu_ld"; then + version_type=linux # correct to gnu/linux during the next big refactor + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + hardcode_libdir_flag_spec='-L$libdir' + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + + # Some binutils ld are patched to set DT_RUNPATH + if test ${lt_cv_shlibpath_overrides_runpath+y} +then : + printf %s "(cached) " >&6 +else $as_nop + lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null +then : + lt_cv_shlibpath_overrides_runpath=yes +fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + +fi + + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd* | bitrig*) + version_type=sunos + sys_lib_dlsearch_path_spec=/usr/lib + need_lib_prefix=no + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +os2*) + libname_spec='$name' + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test yes = "$with_gnu_ld"; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec; then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=sco + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test yes = "$with_gnu_ld"; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +printf "%s\n" "$dynamic_linker" >&6; } +test no = "$dynamic_linker" && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test yes = "$GCC"; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec +fi + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec +fi + +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +printf %s "checking how to hardcode library paths into programs... " >&6; } +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || + test -n "$runpath_var" || + test yes = "$hardcode_automatic"; then + + # We can hardcode non-existent directories. + if test no != "$hardcode_direct" && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && + test no != "$hardcode_minus_L"; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 +printf "%s\n" "$hardcode_action" >&6; } + +if test relink = "$hardcode_action" || + test yes = "$inherit_rpath"; then + # Fast installation is not supported + enable_fast_install=no +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + + + + + + if test yes != "$enable_dlopen"; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen=load_add_on + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen=LoadLibrary + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +printf %s "checking for dlopen in -ldl... " >&6; } +if test ${ac_cv_lib_dl_dlopen+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main (void) +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_dl_dlopen=yes +else $as_nop + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes +then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl +else $as_nop + + lt_cv_dlopen=dyld + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + tpf*) + # Don't try to run any link tests for TPF. We know it's impossible + # because TPF is a cross-compiler, and we know how we open DSOs. + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + lt_cv_dlopen_self=no + ;; + + *) + ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" +if test "x$ac_cv_func_shl_load" = xyes +then : + lt_cv_dlopen=shl_load +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 +printf %s "checking for shl_load in -ldld... " >&6; } +if test ${ac_cv_lib_dld_shl_load+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char shl_load (); +int +main (void) +{ +return shl_load (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_dld_shl_load=yes +else $as_nop + ac_cv_lib_dld_shl_load=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 +printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = xyes +then : + lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld +else $as_nop + ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" +if test "x$ac_cv_func_dlopen" = xyes +then : + lt_cv_dlopen=dlopen +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +printf %s "checking for dlopen in -ldl... " >&6; } +if test ${ac_cv_lib_dl_dlopen+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main (void) +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_dl_dlopen=yes +else $as_nop + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes +then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 +printf %s "checking for dlopen in -lsvld... " >&6; } +if test ${ac_cv_lib_svld_dlopen+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main (void) +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_svld_dlopen=yes +else $as_nop + ac_cv_lib_svld_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 +printf "%s\n" "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = xyes +then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 +printf %s "checking for dld_link in -ldld... " >&6; } +if test ${ac_cv_lib_dld_dld_link+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char dld_link (); +int +main (void) +{ +return dld_link (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_dld_dld_link=yes +else $as_nop + ac_cv_lib_dld_dld_link=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 +printf "%s\n" "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = xyes +then : + lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test no = "$lt_cv_dlopen"; then + enable_dlopen=no + else + enable_dlopen=yes + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS=$CPPFLAGS + test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS=$LDFLAGS + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS=$LIBS + LIBS="$lt_cv_dlopen_libs $LIBS" + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 +printf %s "checking whether a program can dlopen itself... " >&6; } +if test ${lt_cv_dlopen_self+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test yes = "$cross_compiling"; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 +printf "%s\n" "$lt_cv_dlopen_self" >&6; } + + if test yes = "$lt_cv_dlopen_self"; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 +printf %s "checking whether a statically linked program can dlopen itself... " >&6; } +if test ${lt_cv_dlopen_self_static+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test yes = "$cross_compiling"; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 +printf "%s\n" "$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + + + + + + + + + + + + + + + + +striplib= +old_striplib= +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 +printf %s "checking whether stripping libraries is possible... " >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP"; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + fi + ;; + *) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + ;; + esac +fi + + + + + + + + + + + + + # Report what library types will actually be built + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 +printf %s "checking if libtool supports shared libraries... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 +printf "%s\n" "$can_build_shared" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 +printf %s "checking whether to build shared libraries... " >&6; } + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[4-9]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 +printf "%s\n" "$enable_shared" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 +printf %s "checking whether to build static libraries... " >&6; } + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 +printf "%s\n" "$enable_static" >&6; } + + + + +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC=$lt_save_CC + + + + + + + + + + + + + + + + ac_config_commands="$ac_config_commands libtool" + + + + +# Only expand once: + + + +# Select memory manager depending on user input. +# If no "-enable-maxmem", use jmemnobs +MEMORYMGR='jmemnobs' +MAXMEM="no" +# Check whether --enable-maxmem was given. +if test ${enable_maxmem+y} +then : + enableval=$enable_maxmem; MAXMEM="$enableval" +fi + +if test "x$MAXMEM" = xyes; then + MAXMEM=1 +fi +if test "x$MAXMEM" != xno; then + if test -n "`echo $MAXMEM | sed 's/[0-9]//g'`"; then + as_fn_error $? "non-numeric argument to --enable-maxmem" "$LINENO" 5 + fi + DEFAULTMAXMEM=`expr $MAXMEM \* 1048576` + +printf "%s\n" "#define DEFAULT_MAX_MEM ${DEFAULTMAXMEM}" >>confdefs.h + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for 'tmpfile()'" >&5 +printf %s "checking for 'tmpfile()'... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ + FILE * tfile = tmpfile(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + MEMORYMGR='jmemansi' +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + MEMORYMGR='jmemname' + + # Test for the need to remove temporary files using a signal handler + # (for cjpeg/djpeg) + +printf "%s\n" "#define NEED_SIGNAL_CATCHER 1" >>confdefs.h + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for 'mktemp()'" >&5 +printf %s "checking for 'mktemp()'... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + char fname[80]; mktemp(fname); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +printf "%s\n" "#define NO_MKTEMP 1" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +fi + + +# Extract the library version IDs from jpeglib.h. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking libjpeg version number" >&5 +printf %s "checking libjpeg version number... " >&6; } +major=`sed -ne 's/^#define JPEG_LIB_VERSION_MAJOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h` +minor=`sed -ne 's/^#define JPEG_LIB_VERSION_MINOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h` +JPEG_LIB_VERSION=`expr $major + $minor`:0:$minor + +JPEG_LIB_VERSION_MAJOR=$major + +JPEG_LIB_VERSION_MINOR=$minor + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $major.$minor.0" >&5 +printf "%s\n" "$major.$minor.0" >&6; } + +ac_config_files="$ac_config_files Makefile libjpeg.pc" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +printf "%s\n" "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 +printf %s "checking that generated files are newer than configure... " >&6; } + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: done" >&5 +printf "%s\n" "done" >&6; } + if test -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= +fi + +if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then + as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + as_fn_error $? "conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_LD_VERSION_SCRIPT_TRUE}" && test -z "${HAVE_LD_VERSION_SCRIPT_FALSE}"; then + as_fn_error $? "conditional \"HAVE_LD_VERSION_SCRIPT\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +as_nop=: +if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 +then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else $as_nop + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + + +# Reset variables that may have inherited troublesome values from +# the environment. + +# IFS needs to be set, to space, tab, and newline, in precisely that order. +# (If _AS_PATH_WALK were called with IFS unset, it would have the +# side effect of setting IFS to empty, thus disabling word splitting.) +# Quoting is to prevent editors from complaining about space-tab. +as_nl=' +' +export as_nl +IFS=" "" $as_nl" + +PS1='$ ' +PS2='> ' +PS4='+ ' + +# Ensure predictable behavior from utilities with locale-dependent output. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# We cannot yet rely on "unset" to work, but we need these variables +# to be unset--not just set to an empty or harmless value--now, to +# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct +# also avoids known problems related to "unset" and subshell syntax +# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). +for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH +do eval test \${$as_var+y} \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done + +# Ensure that fds 0, 1, and 2 are open. +if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi +if (exec 3>&2) ; then :; else exec 2>/dev/null; fi + +# The user is always right. +if ${PATH_SEPARATOR+false} :; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + test -r "$as_dir$0" && as_myself=$as_dir$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + printf "%s\n" "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null +then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else $as_nop + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null +then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else $as_nop + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + +# Determine whether it's possible to make 'echo' print without a newline. +# These variables are no longer used directly by Autoconf, but are AC_SUBSTed +# for compatibility with existing Makefiles. +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +# For backward compatibility with old third-party macros, we provide +# the shell variables $as_echo and $as_echo_n. New code should use +# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. +as_echo='printf %s\n' +as_echo_n='printf %s' + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by libjpeg $as_me 9.5.0, which was +generated by GNU Autoconf 2.71. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to the package provider." + +_ACEOF +ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` +ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config='$ac_cs_config_escaped' +ac_cs_version="\\ +libjpeg config.status 9.5.0 +configured by $0, generated by GNU Autoconf 2.71, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2021 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + printf "%s\n" "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + printf "%s\n" "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + printf "%s\n" "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + printf "%s\n" "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" + + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' +macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' +AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`' +DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' +OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' +enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' +enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' +pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' +enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' +shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' +SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' +ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' +PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' +host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' +host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' +host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' +build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' +build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' +build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' +SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' +Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' +GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' +EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' +FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' +LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' +NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' +LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' +max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' +ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' +exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' +lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' +lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' +lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' +lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' +lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' +reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' +reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' +deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' +file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' +file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' +want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' +sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' +AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' +AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' +archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' +STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' +RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' +old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' +old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' +lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' +CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' +CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' +compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' +GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' +lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' +nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' +lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' +lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' +objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' +MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' +need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' +MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' +DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' +NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' +LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' +OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' +OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' +libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' +shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' +extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' +export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' +whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' +compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' +old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' +archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' +module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' +module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' +with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' +allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' +no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' +hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' +hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' +hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' +hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' +hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' +inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' +link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' +always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' +export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' +exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' +include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' +prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' +postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' +file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' +variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' +need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' +need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' +version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' +runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' +libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' +library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' +soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' +install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' +postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' +postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' +finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' +hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' +sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' +configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' +configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' +hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' +enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' +old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' +striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' + +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in AS \ +DLLTOOL \ +OBJDUMP \ +SHELL \ +ECHO \ +PATH_SEPARATOR \ +SED \ +GREP \ +EGREP \ +FGREP \ +LD \ +NM \ +LN_S \ +lt_SP2NL \ +lt_NL2SP \ +reload_flag \ +deplibs_check_method \ +file_magic_cmd \ +file_magic_glob \ +want_nocaseglob \ +sharedlib_from_linklib_cmd \ +AR \ +AR_FLAGS \ +archiver_list_spec \ +STRIP \ +RANLIB \ +CC \ +CFLAGS \ +compiler \ +lt_cv_sys_global_symbol_pipe \ +lt_cv_sys_global_symbol_to_cdecl \ +lt_cv_sys_global_symbol_to_import \ +lt_cv_sys_global_symbol_to_c_name_address \ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ +lt_cv_nm_interface \ +nm_file_list_spec \ +lt_cv_truncate_bin \ +lt_prog_compiler_no_builtin_flag \ +lt_prog_compiler_pic \ +lt_prog_compiler_wl \ +lt_prog_compiler_static \ +lt_cv_prog_compiler_c_o \ +need_locks \ +MANIFEST_TOOL \ +DSYMUTIL \ +NMEDIT \ +LIPO \ +OTOOL \ +OTOOL64 \ +shrext_cmds \ +export_dynamic_flag_spec \ +whole_archive_flag_spec \ +compiler_needs_object \ +with_gnu_ld \ +allow_undefined_flag \ +no_undefined_flag \ +hardcode_libdir_flag_spec \ +hardcode_libdir_separator \ +exclude_expsyms \ +include_expsyms \ +file_list_spec \ +variables_saved_for_relink \ +libname_spec \ +library_names_spec \ +soname_spec \ +install_override_mode \ +finish_eval \ +old_striplib \ +striplib; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in reload_cmds \ +old_postinstall_cmds \ +old_postuninstall_cmds \ +old_archive_cmds \ +extract_expsyms_cmds \ +old_archive_from_new_cmds \ +old_archive_from_expsyms_cmds \ +archive_cmds \ +archive_expsym_cmds \ +module_cmds \ +module_expsym_cmds \ +export_symbols_cmds \ +prelink_cmds \ +postlink_cmds \ +postinstall_cmds \ +postuninstall_cmds \ +finish_cmds \ +sys_lib_search_path_spec \ +configure_time_dlsearch_path \ +configure_time_lt_sys_library_path; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +ac_aux_dir='$ac_aux_dir' + +# See if we are running on zsh, and set the options that allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + + + PACKAGE='$PACKAGE' + VERSION='$VERSION' + RM='$RM' + ofile='$ofile' + + + + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "jconfig.h") CONFIG_HEADERS="$CONFIG_HEADERS jconfig.h:jconfig.cfg" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "libjpeg.pc") CONFIG_FILES="$CONFIG_FILES libjpeg.pc" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files + test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers + test ${CONFIG_COMMANDS+y} || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +printf "%s\n" "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`printf "%s\n" "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + printf "%s\n" "/* $configure_input */" >&1 \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + printf "%s\n" "/* $configure_input */" >&1 \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +printf "%s\n" "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Older Autoconf quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + case $CONFIG_FILES in #( + *\'*) : + eval set x "$CONFIG_FILES" ;; #( + *) : + set x $CONFIG_FILES ;; #( + *) : + ;; +esac + shift + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf + do + # Strip MF so we end up with the name of the file. + am_mf=`printf "%s\n" "$am_mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`$as_dirname -- "$am_mf" || +$as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$am_mf" : 'X\(//\)[^/]' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$am_mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + am_filepart=`$as_basename -- "$am_mf" || +$as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X/"$am_mf" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { echo "$as_me:$LINENO: cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles" >&5 + (cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } || am_rc=$? + done + if test $am_rc -ne 0; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE=\"gmake\" (or whatever is + necessary). You can also try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking). +See \`config.log' for more details" "$LINENO" 5; } + fi + { am_dirpart=; unset am_dirpart;} + { am_filepart=; unset am_filepart;} + { am_mf=; unset am_mf;} + { am_rc=; unset am_rc;} + rm -f conftest-deps.mk +} + ;; + "libtool":C) + + # See if we are running on zsh, and set the options that allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST + fi + + cfgfile=${ofile}T + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL +# Generated automatically by $as_me ($PACKAGE) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# The names of the tagged configurations supported by this script. +available_tags='' + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} + +# ### BEGIN LIBTOOL CONFIG + +# Which release of libtool.m4 was used? +macro_version=$macro_version +macro_revision=$macro_revision + +# Assembler program. +AS=$lt_AS + +# DLL creation program. +DLLTOOL=$lt_DLLTOOL + +# Object dumper program. +OBJDUMP=$lt_OBJDUMP + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# What type of objects to build. +pic_mode=$pic_mode + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# Shared archive member basename,for filename based shared library versioning on AIX. +shared_archive_member_spec=$shared_archive_member_spec + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# An echo program that protects backslashes. +ECHO=$lt_ECHO + +# The PATH separator for the build system. +PATH_SEPARATOR=$lt_PATH_SEPARATOR + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="\$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP=$lt_GREP + +# An ERE matcher. +EGREP=$lt_EGREP + +# A literal string matcher. +FGREP=$lt_FGREP + +# A BSD- or MS-compatible name lister. +NM=$lt_NM + +# Whether we need soft or hard links. +LN_S=$lt_LN_S + +# What is the maximum length of a command? +max_cmd_len=$max_cmd_len + +# Object file suffix (normally "o"). +objext=$ac_objext + +# Executable file suffix (normally ""). +exeext=$exeext + +# whether the shell understands "unset". +lt_unset=$lt_unset + +# turn spaces into newlines. +SP2NL=$lt_lt_SP2NL + +# turn newlines into spaces. +NL2SP=$lt_lt_NL2SP + +# convert \$build file names to \$host format. +to_host_file_cmd=$lt_cv_to_host_file_cmd + +# convert \$build files to toolchain format. +to_tool_file_cmd=$lt_cv_to_tool_file_cmd + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method = "file_magic". +file_magic_cmd=$lt_file_magic_cmd + +# How to find potential files when deplibs_check_method = "file_magic". +file_magic_glob=$lt_file_magic_glob + +# Find potential files using nocaseglob when deplibs_check_method = "file_magic". +want_nocaseglob=$lt_want_nocaseglob + +# Command to associate shared and link libraries. +sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd + +# The archiver. +AR=$lt_AR + +# Flags to create an archive. +AR_FLAGS=$lt_AR_FLAGS + +# How to feed a file listing to the archiver. +archiver_list_spec=$lt_archiver_list_spec + +# A symbol stripping program. +STRIP=$lt_STRIP + +# Commands used to install an old-style archive. +RANLIB=$lt_RANLIB +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Whether to use a lock for old archive extraction. +lock_old_archive_extraction=$lock_old_archive_extraction + +# A C compiler. +LTCC=$lt_CC + +# LTCC compiler flags. +LTCFLAGS=$lt_CFLAGS + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm into a list of symbols to manually relocate. +global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix + +# The name lister interface. +nm_interface=$lt_lt_cv_nm_interface + +# Specify filename containing input files for \$NM. +nm_file_list_spec=$lt_nm_file_list_spec + +# The root where to search for dependent libraries,and where our libraries should be installed. +lt_sysroot=$lt_sysroot + +# Command to truncate a binary pipe. +lt_truncate_bin=$lt_lt_cv_truncate_bin + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=$MAGIC_CMD + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Manifest tool. +MANIFEST_TOOL=$lt_MANIFEST_TOOL + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL=$lt_DSYMUTIL + +# Tool to change global to local symbols on Mac OS X. +NMEDIT=$lt_NMEDIT + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO=$lt_LIPO + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL=$lt_OTOOL + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64=$lt_OTOOL64 + +# Old archive suffix (normally "a"). +libext=$libext + +# Shared library suffix (normally ".so"). +shrext_cmds=$lt_shrext_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink=$lt_variables_saved_for_relink + +# Do we need the "lib" prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Library versioning type. +version_type=$version_type + +# Shared library runtime path variable. +runpath_var=$runpath_var + +# Shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Permission mode override for installation of shared libraries. +install_override_mode=$lt_install_override_mode + +# Command to use after installation of a shared archive. +postinstall_cmds=$lt_postinstall_cmds + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval=$lt_finish_eval + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Compile-time system search path for libraries. +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Detected run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path + +# Explicit LT_SYS_LIBRARY_PATH set during ./configure time. +configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + + +# The linker used to build libraries. +LD=$lt_LD + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds + +# A language specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU compiler? +with_gcc=$GCC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \$shlibpath_var if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds + +# Commands necessary for finishing linking programs. +postlink_cmds=$lt_postlink_cmds + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# ### END LIBTOOL CONFIG + +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + + +# ### END FUNCTIONS SHARED WITH CONFIGURE + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + + +ltmain=$ac_aux_dir/ltmain.sh + + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + + ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + + diff --git a/thirdparty/jpeg-9e/configure.ac b/thirdparty/jpeg-9e/configure.ac new file mode 100644 index 0000000..f7d4035 --- /dev/null +++ b/thirdparty/jpeg-9e/configure.ac @@ -0,0 +1,365 @@ +# IJG auto-configuration source file. +# Process this file with autoconf to produce a configure script. + +# +# Configure script for IJG libjpeg +# + +AC_INIT([libjpeg], [9.5.0]) + +# Directory where autotools helper scripts lives. +AC_CONFIG_AUX_DIR([.]) + +# Generate configuration headers. +AC_CONFIG_HEADERS([jconfig.h:jconfig.cfg]) + +# Hack: disable autoheader so that it doesn't overwrite our cfg template. +AUTOHEADER="echo autoheader ignored" + +# Check system type +AC_CANONICAL_TARGET + +# Initialize Automake +# Don't require all the GNU mandated files +AM_INIT_AUTOMAKE([-Wall -Werror no-dist foreign]) + +# Make --enable-silent-rules the default. +# To get verbose build output you may configure +# with --disable-silent-rules or use "make V=1". +AM_SILENT_RULES([yes]) + +# Add configure option --enable-maintainer-mode which enables +# dependency checking and generation useful to package maintainers. +# This is made an option to avoid confusing end users. +AM_MAINTAINER_MODE + +# Check for programs +AC_PROG_CC +AC_PROG_CPP +AC_PROG_INSTALL +AC_PROG_MAKE_SET +AC_PROG_LN_S +AC_PROG_EGREP +AM_PROG_AR + +# Check if LD supports linker scripts, +# and define automake conditional HAVE_LD_VERSION_SCRIPT if so. +AC_ARG_ENABLE([ld-version-script], + AS_HELP_STRING([--enable-ld-version-script], + [enable linker version script (default is enabled when possible)]), + [have_ld_version_script=$enableval], []) +if test -z "$have_ld_version_script"; then + AC_MSG_CHECKING([if LD -Wl,--version-script works]) + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" + cat > conftest.map < rather than standard .])]) + +# See whether type size_t is defined in any ANSI-standard places; +# if not, perhaps it is defined in . +AC_MSG_CHECKING([for size_t]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifdef HAVE_STDDEF_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#ifdef NEED_BSD_STRINGS +#include +#else +#include +#endif +typedef size_t my_size_t; +]], [[ my_size_t foovar; ]])], + [ijg_size_t_ok=yes], + [ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h"]) +AC_MSG_RESULT([$ijg_size_t_ok]) +if test "$ijg_size_t_ok" != yes; then + AC_CHECK_HEADER([sys/types.h], + [AC_DEFINE([NEED_SYS_TYPES_H], [1], + [Need to include in order to obtain size_t.]) + AC_EGREP_CPP([size_t], [#include ], + [ijg_size_t_ok="size_t is in sys/types.h"], + [ijg_size_t_ok=no])], + [ijg_size_t_ok=no]) + AC_MSG_RESULT([$ijg_size_t_ok]) + if test "$ijg_size_t_ok" = no; then + AC_MSG_WARN([Type size_t is not defined in any of the usual places. + Try putting '"typedef unsigned int size_t;"' in jconfig.h.]) + fi +fi + +# Check compiler characteristics +AC_MSG_CHECKING([for type unsigned char]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ unsigned char un_char; ]])], + [AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_UNSIGNED_CHAR], [1], + [Compiler supports 'unsigned char'.])], + [AC_MSG_RESULT(no)]) + +AC_MSG_CHECKING([for type unsigned short]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ unsigned short un_short; ]])], + [AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_UNSIGNED_SHORT], [1], + [Compiler supports 'unsigned short'.])], + [AC_MSG_RESULT(no)]) + +AC_MSG_CHECKING([for type void]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +/* Caution: a C++ compiler will insist on valid prototypes */ +typedef void * void_ptr; /* check void * */ +#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ +typedef void (*void_func) (int a, int b); +#else +typedef void (*void_func) (); +#endif + +#ifdef HAVE_PROTOTYPES /* check void function result */ +void test3function (void_ptr arg1, void_func arg2) +#else +void test3function (arg1, arg2) + void_ptr arg1; + void_func arg2; +#endif +{ + char * locptr = (char *) arg1; /* check casting to and from void * */ + arg1 = (void *) locptr; + (*arg2) (1, 2); /* check call of fcn returning void */ +} +]], [[ ]])], + [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) + AC_DEFINE([void], [char], + [Define 'void' as 'char' for archaic compilers + that don't understand it.])]) +AC_C_CONST + +# Check for non-broken inline under various spellings +AC_MSG_CHECKING([for inline]) +ijg_cv_inline="" +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[} __inline__ int foo() { return 0; } +int bar() { return foo();]])], ijg_cv_inline="__inline__", +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[} __inline int foo() { return 0; } +int bar() { return foo();]])], ijg_cv_inline="__inline", +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[} inline int foo() { return 0; } +int bar() { return foo();]])], ijg_cv_inline="inline")])]) +AC_MSG_RESULT($ijg_cv_inline) +AC_DEFINE_UNQUOTED([INLINE], [$ijg_cv_inline], + [How to obtain function inlining.]) + +# We cannot check for bogus warnings, but at least we can check for errors +AC_MSG_CHECKING([for broken incomplete types]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +typedef struct undefined_structure * undef_struct_ptr; +]], [[]])], + [AC_MSG_RESULT(ok)], + [AC_MSG_RESULT(broken) + AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1], + [Compiler does not support pointers to unspecified + structures.])]) + +# Test whether global names are unique to at least 15 chars +AC_MSG_CHECKING([for short external names]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +int possibly_duplicate_function () { return 0; } +int possibly_dupli_function () { return 1; } +]], [[]])], + [AC_MSG_RESULT(ok)], + [AC_MSG_RESULT(short) + AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], [1], + [Linker requires that global names be unique in + first 15 characters.])]) + +# Run-time checks +AC_MSG_CHECKING([to see if char is signed]) +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#ifdef HAVE_PROTOTYPES +int is_char_signed (int arg) +#else +int is_char_signed (arg) + int arg; +#endif +{ + if (arg == 189) { /* expected result for unsigned char */ + return 0; /* type char is unsigned */ + } + else if (arg != -67) { /* expected result for signed char */ + printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + } + return 1; /* assume char is signed otherwise */ +} +char signed_char_check = (char) (-67); +int main() { + exit(is_char_signed((int) signed_char_check)); +}]])], [AC_MSG_RESULT(no) + AC_DEFINE([CHAR_IS_UNSIGNED], [1], + [Characters are unsigned])], + [AC_MSG_RESULT(yes)], +[AC_MSG_WARN([Assuming that char is signed on target machine. + If it is unsigned, this will be a little bit inefficient.]) +]) + +AC_MSG_CHECKING([to see if right shift is signed]) +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#ifdef HAVE_PROTOTYPES +int is_shifting_signed (long arg) +#else +int is_shifting_signed (arg) + long arg; +#endif +/* See whether right-shift on a long is signed or not. */ +{ + long res = arg >> 4; + + if (res == -0x7F7E80CL) { /* expected result for signed shift */ + return 1; /* right shift is signed */ + } + /* see if unsigned-shift hack will fix it. */ + /* we can't just test exact value since it depends on width of long... */ + res |= (~0L) << (32-4); + if (res == -0x7F7E80CL) { /* expected result now? */ + return 0; /* right shift is unsigned */ + } + printf("Right shift isn't acting as I expect it to.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + return 0; /* try it with unsigned anyway */ +} +int main() { + exit(is_shifting_signed(-0x7F7E80B1L)); +}]])], + [AC_MSG_RESULT(no) + AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], [1], + [Broken compiler shifts signed values as an unsigned shift.])], + [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)]) + +AC_MSG_CHECKING([to see if fopen accepts b spec]) +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifdef HAVE_STDLIB_H +#include +#endif +#include +int main() { + if (fopen("conftestdata", "wb") != NULL) + exit(0); + exit(1); +}]])], + [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) + AC_DEFINE([DONT_USE_B_MODE], [1], + [Don't open files in binary mode.])], + [AC_MSG_RESULT(Assuming that it does.)]) + +# Configure libtool +LT_INIT([win32-dll]) + +# Select memory manager depending on user input. +# If no "-enable-maxmem", use jmemnobs +MEMORYMGR='jmemnobs' +MAXMEM="no" +AC_ARG_ENABLE([maxmem], +[ --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB], +[MAXMEM="$enableval"]) +dnl [# support --with-maxmem for backwards compatibility with IJG V5.] +dnl AC_ARG_WITH(maxmem, , MAXMEM="$withval") +if test "x$MAXMEM" = xyes; then + MAXMEM=1 +fi +if test "x$MAXMEM" != xno; then + if test -n "`echo $MAXMEM | sed 's/[[0-9]]//g'`"; then + AC_MSG_ERROR(non-numeric argument to --enable-maxmem) + fi + DEFAULTMAXMEM=`expr $MAXMEM \* 1048576` + AC_DEFINE_UNQUOTED([DEFAULT_MAX_MEM], [${DEFAULTMAXMEM}], + [Maximum data space library will allocate.]) + AC_MSG_CHECKING([for 'tmpfile()']) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ FILE * tfile = tmpfile(); ]])], + [AC_MSG_RESULT(yes) + MEMORYMGR='jmemansi'], + [AC_MSG_RESULT(no) + dnl if tmpfile is not present, must use jmemname. + MEMORYMGR='jmemname' + + # Test for the need to remove temporary files using a signal handler + # (for cjpeg/djpeg) + AC_DEFINE([NEED_SIGNAL_CATCHER], [1], + [Need signal handler to clean up temporary files.]) + AC_MSG_CHECKING([for 'mktemp()']) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ char fname[80]; mktemp(fname); ]])], + [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) + AC_DEFINE([NO_MKTEMP], [1], + [The mktemp() function is not available.])])]) +fi +AC_SUBST([MEMORYMGR]) + +# Extract the library version IDs from jpeglib.h. +AC_MSG_CHECKING([libjpeg version number]) +[major=`sed -ne 's/^#define JPEG_LIB_VERSION_MAJOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h` +minor=`sed -ne 's/^#define JPEG_LIB_VERSION_MINOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h`] +AC_SUBST([JPEG_LIB_VERSION], [`expr $major + $minor`:0:$minor]) +AC_SUBST([JPEG_LIB_VERSION_MAJOR], [$major]) +AC_SUBST([JPEG_LIB_VERSION_MINOR], [$minor]) +AC_MSG_RESULT([$major.$minor.0]) + +AC_CONFIG_FILES([Makefile libjpeg.pc]) +AC_OUTPUT diff --git a/thirdparty/jpeg-9e/depcomp b/thirdparty/jpeg-9e/depcomp new file mode 100755 index 0000000..715e343 --- /dev/null +++ b/thirdparty/jpeg-9e/depcomp @@ -0,0 +1,791 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2018-03-07.03; # UTC + +# Copyright (C) 1999-2021 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by 'PROGRAMS ARGS'. + object Object file output by 'PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputting dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +# Get the directory component of the given path, and save it in the +# global variables '$dir'. Note that this directory component will +# be either empty or ending with a '/' character. This is deliberate. +set_dir_from () +{ + case $1 in + */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; + *) dir=;; + esac +} + +# Get the suffix-stripped basename of the given path, and save it the +# global variable '$base'. +set_base_from () +{ + base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` +} + +# If no dependency file was actually created by the compiler invocation, +# we still have to create a dummy depfile, to avoid errors with the +# Makefile "include basename.Plo" scheme. +make_dummy_depfile () +{ + echo "#dummy" > "$depfile" +} + +# Factor out some common post-processing of the generated depfile. +# Requires the auxiliary global variable '$tmpdepfile' to be set. +aix_post_process_depfile () +{ + # If the compiler actually managed to produce a dependency file, + # post-process it. + if test -f "$tmpdepfile"; then + # Each line is of the form 'foo.o: dependency.h'. + # Do two passes, one to just change these to + # $object: dependency.h + # and one to simply output + # dependency.h: + # which is needed to avoid the deleted-header problem. + { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" + sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" + } > "$depfile" + rm -f "$tmpdepfile" + else + make_dummy_depfile + fi +} + +# A tabulation character. +tab=' ' +# A newline character. +nl=' +' +# Character ranges might be problematic outside the C locale. +# These definitions help. +upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ +lower=abcdefghijklmnopqrstuvwxyz +digits=0123456789 +alpha=${upper}${lower} + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Avoid interferences from the environment. +gccflag= dashmflag= + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +cygpath_u="cygpath -u -f -" +if test "$depmode" = msvcmsys; then + # This is just like msvisualcpp but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvisualcpp +fi + +if test "$depmode" = msvc7msys; then + # This is just like msvc7 but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvc7 +fi + +if test "$depmode" = xlc; then + # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. + gccflag=-qmakedep=gcc,-MF + depmode=gcc +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. +## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. +## (see the conditional assignment to $gccflag above). +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). Also, it might not be +## supported by the other compilers which use the 'gcc' depmode. +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The second -e expression handles DOS-style file names with drive + # letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the "deleted header file" problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. +## Some versions of gcc put a space before the ':'. On the theory +## that the space means something, we add a space to the output as +## well. hp depmode also adds that space, but also prefixes the VPATH +## to the object. Take care to not repeat it in the output. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like '#:fec' to the end of the + # dependency line. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ + | tr "$nl" ' ' >> "$depfile" + echo >> "$depfile" + # The second pass generates a dummy entry for each header file. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" + ;; + +xlc) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts '$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u + "$@" -Wc,-M + else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u + "$@" -M + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + aix_post_process_depfile + ;; + +tcc) + # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 + # FIXME: That version still under development at the moment of writing. + # Make that this statement remains true also for stable, released + # versions. + # It will wrap lines (doesn't matter whether long or short) with a + # trailing '\', as in: + # + # foo.o : \ + # foo.c \ + # foo.h \ + # + # It will put a trailing '\' even on the last line, and will use leading + # spaces rather than leading tabs (at least since its commit 0394caf7 + # "Emit spaces for -MD"). + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. + # We have to change lines of the first kind to '$object: \'. + sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" + # And for each line of the second kind, we have to emit a 'dep.h:' + # dummy dependency, to avoid the deleted-header problem. + sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" + rm -f "$tmpdepfile" + ;; + +## The order of this option in the case statement is important, since the +## shell code in configure will try each of these formats in the order +## listed in this file. A plain '-MD' option would be understood by many +## compilers, so we must ensure this comes after the gcc and icc options. +pgcc) + # Portland's C compiler understands '-MD'. + # Will always output deps to 'file.d' where file is the root name of the + # source file under compilation, even if file resides in a subdirectory. + # The object file name does not affect the name of the '.d' file. + # pgcc 10.2 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using '\' : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + set_dir_from "$object" + # Use the source, not the object, to determine the base name, since + # that's sadly what pgcc will do too. + set_base_from "$source" + tmpdepfile=$base.d + + # For projects that build the same source file twice into different object + # files, the pgcc approach of using the *source* file root name can cause + # problems in parallel builds. Use a locking strategy to avoid stomping on + # the same $tmpdepfile. + lockdir=$base.d-lock + trap " + echo '$0: caught signal, cleaning up...' >&2 + rmdir '$lockdir' + exit 1 + " 1 2 13 15 + numtries=100 + i=$numtries + while test $i -gt 0; do + # mkdir is a portable test-and-set. + if mkdir "$lockdir" 2>/dev/null; then + # This process acquired the lock. + "$@" -MD + stat=$? + # Release the lock. + rmdir "$lockdir" + break + else + # If the lock is being held by a different process, wait + # until the winning process is done or we timeout. + while test -d "$lockdir" && test $i -gt 0; do + sleep 1 + i=`expr $i - 1` + done + fi + i=`expr $i - 1` + done + trap - 1 2 13 15 + if test $i -le 0; then + echo "$0: failed to acquire lock after $numtries attempts" >&2 + echo "$0: check lockdir '$lockdir'" >&2 + exit 1 + fi + + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" + # Add 'dependent.h:' lines. + sed -ne '2,${ + s/^ *// + s/ \\*$// + s/$/:/ + p + }' "$tmpdepfile" >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in 'foo.d' instead, so we check for that too. + # Subdirectories are respected. + set_dir_from "$object" + set_base_from "$object" + + if test "$libtool" = yes; then + # Libtool generates 2 separate objects for the 2 libraries. These + # two compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir$base.o.d # libtool 1.5 + tmpdepfile2=$dir.libs/$base.o.d # Likewise. + tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + # Same post-processing that is required for AIX mode. + aix_post_process_depfile + ;; + +msvc7) + if test "$libtool" = yes; then + showIncludes=-Wc,-showIncludes + else + showIncludes=-showIncludes + fi + "$@" $showIncludes > "$tmpdepfile" + stat=$? + grep -v '^Note: including file: ' "$tmpdepfile" + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The first sed program below extracts the file names and escapes + # backslashes for cygpath. The second sed program outputs the file + # name when reading, but also accumulates all include files in the + # hold buffer in order to output them again at the end. This only + # works with sed implementations that can handle large buffers. + sed < "$tmpdepfile" -n ' +/^Note: including file: *\(.*\)/ { + s//\1/ + s/\\/\\\\/g + p +}' | $cygpath_u | sort -u | sed -n ' +s/ /\\ /g +s/\(.*\)/'"$tab"'\1 \\/p +s/.\(.*\) \\/\1:/ +H +$ { + s/.*/'"$tab"'/ + G + p +}' >> "$depfile" + echo >> "$depfile" # make sure the fragment doesn't end with a backslash + rm -f "$tmpdepfile" + ;; + +msvc7msys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for ':' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. + "$@" $dashmflag | + sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this sed invocation + # correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no eat=no + for arg + do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + if test $eat = yes; then + eat=no + continue + fi + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -arch) + eat=yes ;; + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix=`echo "$object" | sed 's/^.*\././'` + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. + sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process the last invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed '1,2d' "$tmpdepfile" \ + | tr ' ' "$nl" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E \ + | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + | sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + IFS=" " + for arg + do + case "$arg" in + -o) + shift + ;; + $object) + shift + ;; + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E 2>/dev/null | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" + echo "$tab" >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvcmsys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/thirdparty/jpeg-9e/djpeg.1 b/thirdparty/jpeg-9e/djpeg.1 new file mode 100644 index 0000000..1cb364f --- /dev/null +++ b/thirdparty/jpeg-9e/djpeg.1 @@ -0,0 +1,264 @@ +.TH DJPEG 1 "28 April 2019" +.SH NAME +djpeg \- decompress a JPEG file to an image file +.SH SYNOPSIS +.B djpeg +[ +.I options +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B djpeg +decompresses the named JPEG file, or the standard input if no file is named, +and produces an image file on the standard output. PBMPLUS (PPM/PGM), BMP, +GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected. +(RLE is supported only if the URT library is available, which it isn't +on most non-Unix systems.) +.SH OPTIONS +All switch names may be abbreviated; for example, +.B \-grayscale +may be written +.B \-gray +or +.BR \-gr . +Most of the "basic" switches can be abbreviated to as little as one letter. +Upper and lower case are equivalent (thus +.B \-BMP +is the same as +.BR \-bmp ). +British spellings are also accepted (e.g., +.BR \-greyscale ), +though for brevity these are not mentioned below. +.PP +The basic switches are: +.TP +.BI \-colors " N" +Reduce image to at most N colors. This reduces the number of colors used in +the output image, so that it can be displayed on a colormapped display or +stored in a colormapped file format. For example, if you have an 8-bit +display, you'd need to reduce to 256 or fewer colors. +.TP +.BI \-quantize " N" +Same as +.BR \-colors . +.B \-colors +is the recommended name, +.B \-quantize +is provided only for backwards compatibility. +.TP +.B \-fast +Select recommended processing options for fast, low quality output. (The +default options are chosen for highest quality output.) Currently, this is +equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR. +.TP +.B \-grayscale +Force grayscale output even if JPEG file is color. +Useful for viewing on monochrome displays; also, +.B djpeg +runs noticeably faster in this mode. +.TP +.B \-rgb +Force RGB output even if JPEG file is grayscale. +This is provided to support applications that don't +want to cope with grayscale as a separate case. +.TP +.BI \-scale " M/N" +Scale the output image by a factor M/N. Currently supported scale factors are +M/N with all M from 1 to 16, where N is the source DCT size, which is 8 for +baseline JPEG. If the /N part is omitted, then M specifies the DCT scaled +size to be applied on the given input. For baseline JPEG this is equivalent +to M/8 scaling, since the source DCT size for baseline JPEG is 8. +Scaling is handy if the image is larger than your screen; also, +.B djpeg +runs much faster when scaling down the output. +.TP +.B \-bmp +Select BMP output format (Windows flavor). +8-bit colormapped format is emitted if +.B \-colors +or +.B \-grayscale +is specified, or if the JPEG file is grayscale; otherwise, 24-bit full-color +format is emitted. +.TP +.B \-gif +Select GIF output format (LZW compressed). +Since GIF does not support more than 256 colors, +.B \-colors 256 +is assumed (unless you specify a smaller number of colors). If you specify +.BR \-fast , +the default number of colors is 216. +.TP +.B \-gif0 +Select GIF output format (uncompressed). +Since GIF does not support more than 256 colors, +.B \-colors 256 +is assumed (unless you specify a smaller number of colors). If you specify +.BR \-fast , +the default number of colors is 216. +.TP +.B \-os2 +Select BMP output format (OS/2 1.x flavor). +8-bit colormapped format is emitted if +.B \-colors +or +.B \-grayscale +is specified, or if the JPEG file is grayscale; otherwise, 24-bit full-color +format is emitted. +.TP +.B \-pnm +Select PBMPLUS (PPM/PGM) output format (this is the default format). +PGM is emitted if the JPEG file is grayscale or if +.B \-grayscale +is specified; otherwise PPM is emitted. +.TP +.B \-rle +Select RLE output format. (Requires URT library.) +.TP +.B \-targa +Select Targa output format. Grayscale format is emitted if the JPEG file is +grayscale or if +.B \-grayscale +is specified; otherwise, colormapped format is emitted if +.B \-colors +is specified; otherwise, 24-bit full-color format is emitted. +.PP +Switches for advanced users: +.TP +.B \-dct int +Use integer DCT method (default). +.TP +.B \-dct fast +Use fast integer DCT (less accurate). +.TP +.B \-dct float +Use floating-point DCT method. +The float method is very slightly more accurate than the int method, but is +much slower unless your machine has very fast floating-point hardware. Also +note that results of the floating-point method may vary slightly across +machines, while the integer methods should give the same results everywhere. +The fast integer method is much less accurate than the other two. +.TP +.B \-dither fs +Use Floyd-Steinberg dithering in color quantization. +.TP +.B \-dither ordered +Use ordered dithering in color quantization. +.TP +.B \-dither none +Do not use dithering in color quantization. +By default, Floyd-Steinberg dithering is applied when quantizing colors; this +is slow but usually produces the best results. Ordered dither is a compromise +between speed and quality; no dithering is fast but usually looks awful. Note +that these switches have no effect unless color quantization is being done. +Ordered dither is only available in +.B \-onepass +mode. +.TP +.BI \-map " file" +Quantize to the colors used in the specified image file. This is useful for +producing multiple files with identical color maps, or for forcing a +predefined set of colors to be used. The +.I file +must be a GIF or PPM file. This option overrides +.B \-colors +and +.BR \-onepass . +.TP +.B \-nosmooth +Don't use high-quality upsampling. +.TP +.B \-onepass +Use one-pass instead of two-pass color quantization. The one-pass method is +faster and needs less memory, but it produces a lower-quality image. +.B \-onepass +is ignored unless you also say +.B \-colors +.IR N . +Also, the one-pass method is always used for grayscale output (the two-pass +method is no improvement then). +.TP +.BI \-maxmemory " N" +Set limit for amount of memory to use in processing large images. Value is +in thousands of bytes, or millions of bytes if "M" is attached to the +number. For example, +.B \-max 4m +selects 4000000 bytes. If more space is needed, temporary files will be used. +.TP +.BI \-outfile " name" +Send output image to the named file, not to standard output. +.TP +.B \-verbose +Enable debug printout. More +.BR \-v 's +give more output. Also, version information is printed at startup. +.TP +.B \-debug +Same as +.BR \-verbose . +.SH EXAMPLES +.LP +This example decompresses the JPEG file foo.jpg, quantizes it to +256 colors, and saves the output in 8-bit BMP format in foo.bmp: +.IP +.B djpeg \-colors 256 \-bmp +.I foo.jpg +.B > +.I foo.bmp +.SH HINTS +To get a quick preview of an image, use the +.B \-grayscale +and/or +.B \-scale +switches. +.B \-grayscale \-scale 1/8 +is the fastest case. +.PP +Several options are available that trade off image quality to gain speed. +.B \-fast +turns on the recommended settings. +.PP +.B \-dct fast +and/or +.B \-nosmooth +gain speed at a small sacrifice in quality. +When producing a color-quantized image, +.B \-onepass \-dither ordered +is fast but much lower quality than the default behavior. +.B \-dither none +may give acceptable results in two-pass mode, but is seldom tolerable in +one-pass mode. +.PP +If you are fortunate enough to have very fast floating point hardware, +\fB\-dct float\fR may be even faster than \fB\-dct fast\fR. But on most +machines \fB\-dct float\fR is slower than \fB\-dct int\fR; in this case it is +not worth using, because its theoretical accuracy advantage is too small to be +significant in practice. +.SH ENVIRONMENT +.TP +.B JPEGMEM +If this environment variable is set, its value is the default memory limit. +The value is specified as described for the +.B \-maxmemory +switch. +.B JPEGMEM +overrides the default value specified when the program was compiled, and +itself is overridden by an explicit +.BR \-maxmemory . +.SH SEE ALSO +.BR cjpeg (1), +.BR jpegtran (1), +.BR rdjpgcom (1), +.BR wrjpgcom (1) +.br +.BR ppm (5), +.BR pgm (5) +.br +Wallace, Gregory K. "The JPEG Still Picture Compression Standard", +Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. +.SH AUTHOR +Independent JPEG Group diff --git a/thirdparty/jpeg-9e/djpeg.c b/thirdparty/jpeg-9e/djpeg.c new file mode 100644 index 0000000..a01b396 --- /dev/null +++ b/thirdparty/jpeg-9e/djpeg.c @@ -0,0 +1,631 @@ +/* + * djpeg.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 2009-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a command-line user interface for the JPEG decompressor. + * It should work on any system with Unix- or MS-DOS-style command lines. + * + * Two different command line styles are permitted, depending on the + * compile-time switch TWO_FILE_COMMANDLINE: + * djpeg [options] inputfile outputfile + * djpeg [options] [inputfile] + * In the second style, output is always to standard output, which you'd + * normally redirect to a file or pipe to some other program. Input is + * either from a named file or from standard input (typically redirected). + * The second style is convenient on Unix but is unhelpful on systems that + * don't support pipes. Also, you MUST use the first style if your system + * doesn't do binary I/O to stdin/stdout. + * To simplify script writing, the "-outfile" switch is provided. The syntax + * djpeg [options] -outfile outputfile inputfile + * works regardless of which command line style is used. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "jversion.h" /* for version message */ + +#include /* to declare isprint() */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + + +/* Create the add-on message string table. */ + +#define JMESSAGE(code,string) string , + +static const char * const cdjpeg_message_table[] = { +#include "cderror.h" + NULL +}; + + +/* + * This list defines the known output image formats + * (not all of which need be supported by a given version). + * You can change the default output format by defining DEFAULT_FMT; + * indeed, you had better do so if you undefine PPM_SUPPORTED. + */ + +typedef enum { + FMT_BMP, /* BMP format (Windows flavor) */ + FMT_GIF, /* GIF format (LZW compressed) */ + FMT_GIF0, /* GIF format (uncompressed) */ + FMT_OS2, /* BMP format (OS/2 flavor) */ + FMT_PPM, /* PPM/PGM (PBMPLUS formats) */ + FMT_RLE, /* RLE format */ + FMT_TARGA, /* Targa format */ + FMT_TIFF /* TIFF format */ +} IMAGE_FORMATS; + +#ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */ +#define DEFAULT_FMT FMT_PPM +#endif + +static IMAGE_FORMATS requested_fmt; + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + * The main program in this file doesn't actually use this capability... + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -colors N Reduce image to no more than N colors\n"); + fprintf(stderr, " -fast Fast, low-quality processing\n"); + fprintf(stderr, " -grayscale Force grayscale output\n"); + fprintf(stderr, " -rgb Force RGB output\n"); +#ifdef IDCT_SCALING_SUPPORTED + fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n"); +#endif +#ifdef BMP_SUPPORTED + fprintf(stderr, " -bmp Select BMP output format (Windows style)%s\n", + (DEFAULT_FMT == FMT_BMP ? " (default)" : "")); +#endif +#ifdef GIF_SUPPORTED + fprintf(stderr, " -gif Select GIF output format (LZW compressed)%s\n", + (DEFAULT_FMT == FMT_GIF ? " (default)" : "")); + fprintf(stderr, " -gif0 Select GIF output format (uncompressed)%s\n", + (DEFAULT_FMT == FMT_GIF0 ? " (default)" : "")); +#endif +#ifdef BMP_SUPPORTED + fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n", + (DEFAULT_FMT == FMT_OS2 ? " (default)" : "")); +#endif +#ifdef PPM_SUPPORTED + fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n", + (DEFAULT_FMT == FMT_PPM ? " (default)" : "")); +#endif +#ifdef RLE_SUPPORTED + fprintf(stderr, " -rle Select Utah RLE output format%s\n", + (DEFAULT_FMT == FMT_RLE ? " (default)" : "")); +#endif +#ifdef TARGA_SUPPORTED + fprintf(stderr, " -targa Select Targa output format%s\n", + (DEFAULT_FMT == FMT_TARGA ? " (default)" : "")); +#endif + fprintf(stderr, "Switches for advanced users:\n"); +#ifdef DCT_ISLOW_SUPPORTED + fprintf(stderr, " -dct int Use integer DCT method%s\n", + (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); +#endif +#ifdef DCT_IFAST_SUPPORTED + fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", + (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); +#endif +#ifdef DCT_FLOAT_SUPPORTED + fprintf(stderr, " -dct float Use floating-point DCT method%s\n", + (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); +#endif + fprintf(stderr, " -dither fs Use F-S dithering (default)\n"); + fprintf(stderr, " -dither none Don't use dithering in quantization\n"); + fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n"); +#ifdef QUANT_2PASS_SUPPORTED + fprintf(stderr, " -map FILE Map to colors used in named image file\n"); +#endif + fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n"); +#ifdef QUANT_1PASS_SUPPORTED + fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n"); +#endif + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + exit(EXIT_FAILURE); +} + + +LOCAL(int) +parse_switches (j_decompress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + + /* Set up default JPEG parameters. */ + requested_fmt = DEFAULT_FMT; /* set default output file format */ + outfilename = NULL; + cinfo->err->trace_level = 0; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "bmp", 1)) { + /* BMP output format (Windows flavor). */ + requested_fmt = FMT_BMP; + + } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) || + keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) { + /* Do color quantization. */ + int val; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &val) != 1) + usage(); + cinfo->desired_number_of_colors = val; + cinfo->quantize_colors = TRUE; + + } else if (keymatch(arg, "dct", 2)) { + /* Select IDCT algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "int", 1)) { + cinfo->dct_method = JDCT_ISLOW; + } else if (keymatch(argv[argn], "fast", 2)) { + cinfo->dct_method = JDCT_IFAST; + } else if (keymatch(argv[argn], "float", 2)) { + cinfo->dct_method = JDCT_FLOAT; + } else + usage(); + + } else if (keymatch(arg, "dither", 2)) { + /* Select dithering algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "fs", 2)) { + cinfo->dither_mode = JDITHER_FS; + } else if (keymatch(argv[argn], "none", 2)) { + cinfo->dither_mode = JDITHER_NONE; + } else if (keymatch(argv[argn], "ordered", 2)) { + cinfo->dither_mode = JDITHER_ORDERED; + } else + usage(); + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "fast", 1)) { + /* Select recommended processing options for quick-and-dirty output. */ + cinfo->two_pass_quantize = FALSE; + cinfo->dither_mode = JDITHER_ORDERED; + if (! cinfo->quantize_colors) /* don't override an earlier -colors */ + cinfo->desired_number_of_colors = 216; + cinfo->dct_method = JDCT_FASTEST; + cinfo->do_fancy_upsampling = FALSE; + + } else if (keymatch(arg, "gif", 1)) { + /* GIF output format (LZW compressed). */ + requested_fmt = FMT_GIF; + + } else if (keymatch(arg, "gif0", 4)) { + /* GIF output format (uncompressed). */ + requested_fmt = FMT_GIF0; + + } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { + /* Force monochrome output. */ + cinfo->out_color_space = JCS_GRAYSCALE; + + } else if (keymatch(arg, "rgb", 3)) { + /* Force RGB output. */ + cinfo->out_color_space = JCS_RGB; + + } else if (keymatch(arg, "map", 3)) { + /* Quantize to a color map taken from an input file. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (for_real) { /* too expensive to do twice! */ +#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ + FILE * mapfile; + + if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + read_color_map(cinfo, mapfile); + fclose(mapfile); + cinfo->quantize_colors = TRUE; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "nosmooth", 3)) { + /* Suppress fancy upsampling. */ + cinfo->do_fancy_upsampling = FALSE; + + } else if (keymatch(arg, "onepass", 3)) { + /* Use fast one-pass quantization. */ + cinfo->two_pass_quantize = FALSE; + + } else if (keymatch(arg, "os2", 3)) { + /* BMP output format (OS/2 flavor). */ + requested_fmt = FMT_OS2; + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) { + /* PPM/PGM output format. */ + requested_fmt = FMT_PPM; + + } else if (keymatch(arg, "rle", 1)) { + /* RLE output format. */ + requested_fmt = FMT_RLE; + + } else if (keymatch(arg, "scale", 1)) { + /* Scale the output image by a fraction M/N. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%u/%u", + &cinfo->scale_num, &cinfo->scale_denom) < 1) + usage(); + + } else if (keymatch(arg, "targa", 1)) { + /* Targa output format. */ + requested_fmt = FMT_TARGA; + + } else { + usage(); /* bogus switch */ + } + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * Marker processor for COM and interesting APPn markers. + * This replaces the library's built-in processor, which just skips the marker. + * We want to print out the marker as text, to the extent possible. + * Note this code relies on a non-suspending data source. + */ + +LOCAL(unsigned int) +jpeg_getc (j_decompress_ptr cinfo) +/* Read next byte */ +{ + struct jpeg_source_mgr * datasrc = cinfo->src; + + if (datasrc->bytes_in_buffer == 0) { + if (! (*datasrc->fill_input_buffer) (cinfo)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } + datasrc->bytes_in_buffer--; + return GETJOCTET(*datasrc->next_input_byte++); +} + + +METHODDEF(boolean) +print_text_marker (j_decompress_ptr cinfo) +{ + boolean traceit = (cinfo->err->trace_level >= 1); + INT32 length; + unsigned int ch; + unsigned int lastch = 0; + + length = jpeg_getc(cinfo) << 8; + length += jpeg_getc(cinfo); + length -= 2; /* discount the length word itself */ + + if (traceit) { + if (cinfo->unread_marker == JPEG_COM) + fprintf(stderr, "Comment, length %ld:\n", (long) length); + else /* assume it is an APPn otherwise */ + fprintf(stderr, "APP%d, length %ld:\n", + cinfo->unread_marker - JPEG_APP0, (long) length); + } + + while (--length >= 0) { + ch = jpeg_getc(cinfo); + if (traceit) { + /* Emit the character in a readable form. + * Nonprintables are converted to \nnn form, + * while \ is converted to \\. + * Newlines in CR, CR/LF, or LF form will be printed as one newline. + */ + if (ch == '\r') { + fprintf(stderr, "\n"); + } else if (ch == '\n') { + if (lastch != '\r') + fprintf(stderr, "\n"); + } else if (ch == '\\') { + fprintf(stderr, "\\\\"); + } else if (isprint(ch)) { + putc(ch, stderr); + } else { + fprintf(stderr, "\\%03o", ch); + } + lastch = ch; + } + } + + if (traceit) + fprintf(stderr, "\n"); + + return TRUE; +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + int file_index; + djpeg_dest_ptr dest_mgr = NULL; + FILE * input_file; + FILE * output_file; + JDIMENSION num_scanlines; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "djpeg"; /* in case C library doesn't provide it */ + + /* Initialize the JPEG decompression object with default error handling. */ + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + /* Add some application-specific error messages (from cderror.h) */ + jerr.addon_message_table = cdjpeg_message_table; + jerr.first_addon_message = JMSG_FIRSTADDONCODE; + jerr.last_addon_message = JMSG_LASTADDONCODE; + + /* Insert custom marker processor for COM and APP12. + * APP12 is used by some digital camera makers for textual info, + * so we provide the ability to display it as text. + * If you like, additional APPn marker types can be selected for display, + * but don't try to override APP0 or APP14 this way (see libjpeg.txt). + */ + jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker); + jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker); + + /* Now safe to enable signal catcher. */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &cinfo); +#endif + + /* Scan command line to find file names. */ + /* It is convenient to use just one switch-parsing routine, but the switch + * values read here are ignored; we will rescan the switches after opening + * the input file. + * (Exception: tracing level set here controls verbosity for COM markers + * found during jpeg_read_header...) + */ + + file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); + +#ifdef TWO_FILE_COMMANDLINE + /* Must have either -outfile switch or explicit output file name */ + if (outfilename == NULL) { + if (file_index != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + outfilename = argv[file_index+1]; + } else { + if (file_index != argc-1) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + } +#else + /* Unix style: expect zero or one file name */ + if (file_index < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } +#endif /* TWO_FILE_COMMANDLINE */ + + /* Open the input file. */ + if (file_index < argc) { + if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ + input_file = read_stdin(); + } + + /* Open the output file. */ + if (outfilename != NULL) { + if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, outfilename); + exit(EXIT_FAILURE); + } + } else { + /* default output file is stdout */ + output_file = write_stdout(); + } + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &cinfo, &progress); +#endif + + /* Specify data source for decompression */ + jpeg_stdio_src(&cinfo, input_file); + + /* Read file header, set default decompression parameters */ + (void) jpeg_read_header(&cinfo, TRUE); + + /* Adjust default decompression parameters by re-parsing the options */ + file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); + + /* Initialize the output module now to let it override any crucial + * option settings (for instance, GIF wants to force color quantization). + */ + switch (requested_fmt) { +#ifdef BMP_SUPPORTED + case FMT_BMP: + dest_mgr = jinit_write_bmp(&cinfo, FALSE); + break; + case FMT_OS2: + dest_mgr = jinit_write_bmp(&cinfo, TRUE); + break; +#endif +#ifdef GIF_SUPPORTED + case FMT_GIF: + dest_mgr = jinit_write_gif(&cinfo, TRUE); + break; + case FMT_GIF0: + dest_mgr = jinit_write_gif(&cinfo, FALSE); + break; +#endif +#ifdef PPM_SUPPORTED + case FMT_PPM: + dest_mgr = jinit_write_ppm(&cinfo); + break; +#endif +#ifdef RLE_SUPPORTED + case FMT_RLE: + dest_mgr = jinit_write_rle(&cinfo); + break; +#endif +#ifdef TARGA_SUPPORTED + case FMT_TARGA: + dest_mgr = jinit_write_targa(&cinfo); + break; +#endif + default: + ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT); + } + dest_mgr->output_file = output_file; + + /* Start decompressor */ + (void) jpeg_start_decompress(&cinfo); + + /* Write output file header */ + (*dest_mgr->start_output) (&cinfo, dest_mgr); + + /* Process data */ + while (cinfo.output_scanline < cinfo.output_height) { + num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer, + dest_mgr->buffer_height); + (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines); + } + +#ifdef PROGRESS_REPORT + /* Hack: count final pass as done in case finish_output does an extra pass. + * The library won't have updated completed_passes. + */ + progress.pub.completed_passes = progress.pub.total_passes; +#endif + + /* Finish decompression and release memory. + * I must do it in this order because output module has allocated memory + * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory. + */ + (*dest_mgr->finish_output) (&cinfo, dest_mgr); + (void) jpeg_finish_decompress(&cinfo); + jpeg_destroy_decompress(&cinfo); + + /* Close files, if we opened them */ + if (input_file != stdin) + fclose(input_file); + if (output_file != stdout) + fclose(output_file); + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &cinfo); +#endif + + /* All done. */ + exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/thirdparty/jpeg-9e/djpegalt.c b/thirdparty/jpeg-9e/djpegalt.c new file mode 100644 index 0000000..da809ae --- /dev/null +++ b/thirdparty/jpeg-9e/djpegalt.c @@ -0,0 +1,766 @@ +/* + * alternate djpeg.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 2009-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains an alternate user interface for the JPEG decompressor. + * One or more input files are named on the command line, and output file + * names are created by substituting an appropriate extension. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "jversion.h" /* for version message */ + +#include /* to declare isprint() */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + +#ifndef PATH_MAX /* ANSI maximum-pathname-length constant */ +#define PATH_MAX 256 +#endif + + +/* Create the add-on message string table. */ + +#define JMESSAGE(code,string) string , + +static const char * const cdjpeg_message_table[] = { +#include "cderror.h" + NULL +}; + + +/* + * Automatic determination of available memory. + */ + +static long default_maxmem; /* saves value determined at startup, or 0 */ + +#ifndef FREE_MEM_ESTIMATE /* may be defined from command line */ + +#ifdef MSDOS /* For MS-DOS (unless flat-memory model) */ + +#include /* for access to intdos() call */ + +LOCAL(long) +unused_dos_memory (void) +/* Obtain total amount of unallocated DOS memory */ +{ + union REGS regs; + long nparas; + + regs.h.ah = 0x48; /* DOS function Allocate Memory Block */ + regs.x.bx = 0xFFFF; /* Ask for more memory than DOS can have */ + (void) intdos(®s, ®s); + /* DOS will fail and return # of paragraphs actually available in BX. */ + nparas = (unsigned int) regs.x.bx; + /* Times 16 to convert to bytes. */ + return nparas << 4; +} + +/* The default memory setting is 95% of the available space. */ +#define FREE_MEM_ESTIMATE ((unused_dos_memory() * 95L) / 100L) + +#endif /* MSDOS */ + +#ifdef ATARI /* For Atari ST/STE/TT, Pure C or Turbo C */ + +#include + +/* The default memory setting is 90% of the available space. */ +#define FREE_MEM_ESTIMATE (((long) coreleft() * 90L) / 100L) + +#endif /* ATARI */ + +/* Add memory-estimation procedures for other operating systems here, + * with appropriate #ifdef's around them. + */ + +#endif /* !FREE_MEM_ESTIMATE */ + + +/* + * This list defines the known output image formats + * (not all of which need be supported by a given version). + * You can change the default output format by defining DEFAULT_FMT; + * indeed, you had better do so if you undefine PPM_SUPPORTED. + */ + +typedef enum { + FMT_BMP, /* BMP format (Windows flavor) */ + FMT_GIF, /* GIF format (LZW compressed) */ + FMT_GIF0, /* GIF format (uncompressed) */ + FMT_OS2, /* BMP format (OS/2 flavor) */ + FMT_PPM, /* PPM/PGM (PBMPLUS formats) */ + FMT_RLE, /* RLE format */ + FMT_TARGA, /* Targa format */ + FMT_TIFF /* TIFF format */ +} IMAGE_FORMATS; + +#ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */ +#define DEFAULT_FMT FMT_BMP +#endif + +static IMAGE_FORMATS requested_fmt; + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] inputfile(s)\n", progname); + fprintf(stderr, "List of input files may use wildcards (* and ?)\n"); + fprintf(stderr, "Output filename is same as input filename except for extension\n"); + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -colors N Reduce image to no more than N colors\n"); + fprintf(stderr, " -fast Fast, low-quality processing\n"); + fprintf(stderr, " -grayscale Force grayscale output\n"); + fprintf(stderr, " -rgb Force RGB output\n"); +#ifdef IDCT_SCALING_SUPPORTED + fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n"); +#endif +#ifdef BMP_SUPPORTED + fprintf(stderr, " -bmp Select BMP output format (Windows style)%s\n", + (DEFAULT_FMT == FMT_BMP ? " (default)" : "")); +#endif +#ifdef GIF_SUPPORTED + fprintf(stderr, " -gif Select GIF output format (LZW compressed)%s\n", + (DEFAULT_FMT == FMT_GIF ? " (default)" : "")); + fprintf(stderr, " -gif0 Select GIF output format (uncompressed)%s\n", + (DEFAULT_FMT == FMT_GIF0 ? " (default)" : "")); +#endif +#ifdef BMP_SUPPORTED + fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n", + (DEFAULT_FMT == FMT_OS2 ? " (default)" : "")); +#endif +#ifdef PPM_SUPPORTED + fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n", + (DEFAULT_FMT == FMT_PPM ? " (default)" : "")); +#endif +#ifdef RLE_SUPPORTED + fprintf(stderr, " -rle Select Utah RLE output format%s\n", + (DEFAULT_FMT == FMT_RLE ? " (default)" : "")); +#endif +#ifdef TARGA_SUPPORTED + fprintf(stderr, " -targa Select Targa output format%s\n", + (DEFAULT_FMT == FMT_TARGA ? " (default)" : "")); +#endif + fprintf(stderr, "Switches for advanced users:\n"); +#ifdef DCT_ISLOW_SUPPORTED + fprintf(stderr, " -dct int Use integer DCT method%s\n", + (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); +#endif +#ifdef DCT_IFAST_SUPPORTED + fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", + (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); +#endif +#ifdef DCT_FLOAT_SUPPORTED + fprintf(stderr, " -dct float Use floating-point DCT method%s\n", + (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); +#endif + fprintf(stderr, " -dither fs Use F-S dithering (default)\n"); + fprintf(stderr, " -dither none Don't use dithering in quantization\n"); + fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n"); +#ifdef QUANT_2PASS_SUPPORTED + fprintf(stderr, " -map FILE Map to colors used in named image file\n"); +#endif + fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n"); +#ifdef QUANT_1PASS_SUPPORTED + fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n"); +#endif +#ifndef FREE_MEM_ESTIMATE + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); +#endif + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + exit(EXIT_FAILURE); +} + + +LOCAL(int) +parse_switches (j_decompress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + + /* Set up default JPEG parameters. */ + requested_fmt = DEFAULT_FMT; /* set default output file format */ + outfilename = NULL; + cinfo->err->trace_level = 0; + if (default_maxmem > 0) /* override library's default value */ + cinfo->mem->max_memory_to_use = default_maxmem; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "bmp", 1)) { + /* BMP output format (Windows flavor). */ + requested_fmt = FMT_BMP; + + } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) || + keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) { + /* Do color quantization. */ + int val; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &val) != 1) + usage(); + cinfo->desired_number_of_colors = val; + cinfo->quantize_colors = TRUE; + + } else if (keymatch(arg, "dct", 2)) { + /* Select IDCT algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "int", 1)) { + cinfo->dct_method = JDCT_ISLOW; + } else if (keymatch(argv[argn], "fast", 2)) { + cinfo->dct_method = JDCT_IFAST; + } else if (keymatch(argv[argn], "float", 2)) { + cinfo->dct_method = JDCT_FLOAT; + } else + usage(); + + } else if (keymatch(arg, "dither", 2)) { + /* Select dithering algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "fs", 2)) { + cinfo->dither_mode = JDITHER_FS; + } else if (keymatch(argv[argn], "none", 2)) { + cinfo->dither_mode = JDITHER_NONE; + } else if (keymatch(argv[argn], "ordered", 2)) { + cinfo->dither_mode = JDITHER_ORDERED; + } else + usage(); + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "fast", 1)) { + /* Select recommended processing options for quick-and-dirty output. */ + cinfo->two_pass_quantize = FALSE; + cinfo->dither_mode = JDITHER_ORDERED; + if (! cinfo->quantize_colors) /* don't override an earlier -colors */ + cinfo->desired_number_of_colors = 216; + cinfo->dct_method = JDCT_FASTEST; + cinfo->do_fancy_upsampling = FALSE; + + } else if (keymatch(arg, "gif", 1)) { + /* GIF output format (LZW compressed). */ + requested_fmt = FMT_GIF; + + } else if (keymatch(arg, "gif0", 4)) { + /* GIF output format (uncompressed). */ + requested_fmt = FMT_GIF0; + + } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { + /* Force monochrome output. */ + cinfo->out_color_space = JCS_GRAYSCALE; + + } else if (keymatch(arg, "rgb", 3)) { + /* Force RGB output. */ + cinfo->out_color_space = JCS_RGB; + + } else if (keymatch(arg, "map", 3)) { + /* Quantize to a color map taken from an input file. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (for_real) { /* too expensive to do twice! */ +#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ + FILE * mapfile; + + if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + read_color_map(cinfo, mapfile); + fclose(mapfile); + cinfo->quantize_colors = TRUE; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "nosmooth", 3)) { + /* Suppress fancy upsampling. */ + cinfo->do_fancy_upsampling = FALSE; + + } else if (keymatch(arg, "onepass", 3)) { + /* Use fast one-pass quantization. */ + cinfo->two_pass_quantize = FALSE; + + } else if (keymatch(arg, "os2", 3)) { + /* BMP output format (OS/2 flavor). */ + requested_fmt = FMT_OS2; + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) { + /* PPM/PGM output format. */ + requested_fmt = FMT_PPM; + + } else if (keymatch(arg, "rle", 1)) { + /* RLE output format. */ + requested_fmt = FMT_RLE; + + } else if (keymatch(arg, "scale", 1)) { + /* Scale the output image by a fraction M/N. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%u/%u", + &cinfo->scale_num, &cinfo->scale_denom) < 1) + usage(); + + } else if (keymatch(arg, "targa", 1)) { + /* Targa output format. */ + requested_fmt = FMT_TARGA; + + } else { + usage(); /* bogus switch */ + } + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * Marker processor for COM and interesting APPn markers. + * This replaces the library's built-in processor, which just skips the marker. + * We want to print out the marker as text, to the extent possible. + * Note this code relies on a non-suspending data source. + */ + +LOCAL(unsigned int) +jpeg_getc (j_decompress_ptr cinfo) +/* Read next byte */ +{ + struct jpeg_source_mgr * datasrc = cinfo->src; + + if (datasrc->bytes_in_buffer == 0) { + if (! (*datasrc->fill_input_buffer) (cinfo)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } + datasrc->bytes_in_buffer--; + return GETJOCTET(*datasrc->next_input_byte++); +} + + +METHODDEF(boolean) +print_text_marker (j_decompress_ptr cinfo) +{ + boolean traceit = (cinfo->err->trace_level >= 1); + INT32 length; + unsigned int ch; + unsigned int lastch = 0; + + length = jpeg_getc(cinfo) << 8; + length += jpeg_getc(cinfo); + length -= 2; /* discount the length word itself */ + + if (traceit) { + if (cinfo->unread_marker == JPEG_COM) + fprintf(stderr, "Comment, length %ld:\n", (long) length); + else /* assume it is an APPn otherwise */ + fprintf(stderr, "APP%d, length %ld:\n", + cinfo->unread_marker - JPEG_APP0, (long) length); + } + + while (--length >= 0) { + ch = jpeg_getc(cinfo); + if (traceit) { + /* Emit the character in a readable form. + * Nonprintables are converted to \nnn form, + * while \ is converted to \\. + * Newlines in CR, CR/LF, or LF form will be printed as one newline. + */ + if (ch == '\r') { + fprintf(stderr, "\n"); + } else if (ch == '\n') { + if (lastch != '\r') + fprintf(stderr, "\n"); + } else if (ch == '\\') { + fprintf(stderr, "\\\\"); + } else if (isprint(ch)) { + putc(ch, stderr); + } else { + fprintf(stderr, "\\%03o", ch); + } + lastch = ch; + } + } + + if (traceit) + fprintf(stderr, "\n"); + + return TRUE; +} + + +/* + * Check for overwrite of an existing file; clear it with user + */ + +#ifndef NO_OVERWRITE_CHECK + +LOCAL(boolean) +is_write_ok (char * outfname) +{ + FILE * ofile; + int ch; + + ofile = fopen(outfname, READ_BINARY); + if (ofile == NULL) + return TRUE; /* not present */ + fclose(ofile); /* oops, it is present */ + + for (;;) { + fprintf(stderr, "%s already exists, overwrite it? [y/n] ", + outfname); + fflush(stderr); + ch = getc(stdin); + if (ch != '\n') /* flush rest of line */ + while (getc(stdin) != '\n') + /* nothing */; + + switch (ch) { + case 'Y': + case 'y': + return TRUE; + case 'N': + case 'n': + return FALSE; + /* otherwise, ask again */ + } + } +} + +#endif + + +/* + * Process a single input file name, and return its index in argv[]. + * File names at or to left of old_file_index have been processed already. + */ + +LOCAL(int) +process_one_file (int argc, char **argv, int old_file_index) +{ + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + char *infilename; + char workfilename[PATH_MAX]; + const char *default_extension = NULL; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + int file_index; + djpeg_dest_ptr dest_mgr = NULL; + FILE * input_file = NULL; + FILE * output_file = NULL; + JDIMENSION num_scanlines; + + /* Initialize the JPEG decompression object with default error handling. */ + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + /* Add some application-specific error messages (from cderror.h) */ + jerr.addon_message_table = cdjpeg_message_table; + jerr.first_addon_message = JMSG_FIRSTADDONCODE; + jerr.last_addon_message = JMSG_LASTADDONCODE; + + /* Insert custom marker processor for COM and APP12. + * APP12 is used by some digital camera makers for textual info, + * so we provide the ability to display it as text. + * If you like, additional APPn marker types can be selected for display, + * but don't try to override APP0 or APP14 this way (see libjpeg.txt). + */ + jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker); + jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker); + + /* Now safe to enable signal catcher. */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &cinfo); +#endif + + /* Scan command line to find next file name. + * It is convenient to use just one switch-parsing routine, but the switch + * values read here are ignored; we will rescan the switches after opening + * the input file. + * (Exception: tracing level set here controls verbosity for COM markers + * found during jpeg_read_header...) + */ + + file_index = parse_switches(&cinfo, argc, argv, old_file_index, FALSE); + if (file_index >= argc) { + fprintf(stderr, "%s: missing input file name\n", progname); + usage(); + } + + /* Open the input file. */ + infilename = argv[file_index]; + if ((input_file = fopen(infilename, READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, infilename); + goto fail; + } + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &cinfo, &progress); +#endif + + /* Specify data source for decompression */ + jpeg_stdio_src(&cinfo, input_file); + + /* Read file header, set default decompression parameters */ + (void) jpeg_read_header(&cinfo, TRUE); + + /* Adjust default decompression parameters by re-parsing the options */ + file_index = parse_switches(&cinfo, argc, argv, old_file_index, TRUE); + + /* Initialize the output module now to let it override any crucial + * option settings (for instance, GIF wants to force color quantization). + */ + switch (requested_fmt) { +#ifdef BMP_SUPPORTED + case FMT_BMP: + dest_mgr = jinit_write_bmp(&cinfo, FALSE); + default_extension = ".bmp"; + break; + case FMT_OS2: + dest_mgr = jinit_write_bmp(&cinfo, TRUE); + default_extension = ".bmp"; + break; +#endif +#ifdef GIF_SUPPORTED + case FMT_GIF: + dest_mgr = jinit_write_gif(&cinfo, TRUE); + default_extension = ".gif"; + break; + case FMT_GIF0: + dest_mgr = jinit_write_gif(&cinfo, FALSE); + default_extension = ".gif"; + break; +#endif +#ifdef PPM_SUPPORTED + case FMT_PPM: + dest_mgr = jinit_write_ppm(&cinfo); + default_extension = ".ppm"; + break; +#endif +#ifdef RLE_SUPPORTED + case FMT_RLE: + dest_mgr = jinit_write_rle(&cinfo); + default_extension = ".rle"; + break; +#endif +#ifdef TARGA_SUPPORTED + case FMT_TARGA: + dest_mgr = jinit_write_targa(&cinfo); + default_extension = ".tga"; + break; +#endif + default: + ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT); + } + + /* If user didn't supply -outfile switch, select output file name. */ + if (outfilename == NULL) { + int i; + + outfilename = workfilename; + /* Make outfilename be infilename with appropriate extension */ + strcpy(outfilename, infilename); + for (i = (int)strlen(outfilename)-1; i >= 0; i--) { + switch (outfilename[i]) { + case ':': + case '/': + case '\\': + i = 0; /* stop scanning */ + break; + case '.': + outfilename[i] = '\0'; /* lop off existing extension */ + i = 0; /* stop scanning */ + break; + default: + break; /* keep scanning */ + } + } + strcat(outfilename, default_extension); + } + + fprintf(stderr, "Decompressing %s => %s\n", infilename, outfilename); +#ifndef NO_OVERWRITE_CHECK + if (! is_write_ok(outfilename)) + goto fail; +#endif + + /* Open the output file. */ + if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't create %s\n", progname, outfilename); + goto fail; + } + dest_mgr->output_file = output_file; + + /* Start decompressor */ + (void) jpeg_start_decompress(&cinfo); + + /* Write output file header */ + (*dest_mgr->start_output) (&cinfo, dest_mgr); + + /* Process data */ + while (cinfo.output_scanline < cinfo.output_height) { + num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer, + dest_mgr->buffer_height); + (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines); + } + +#ifdef PROGRESS_REPORT + /* Hack: count final pass as done in case finish_output does an extra pass. + * The library won't have updated completed_passes. + */ + progress.pub.completed_passes = progress.pub.total_passes; +#endif + + /* Finish decompression and release memory. + * I must do it in this order because output module has allocated memory + * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory. + */ + (*dest_mgr->finish_output) (&cinfo, dest_mgr); + (void) jpeg_finish_decompress(&cinfo); + + /* Clean up and exit */ +fail: + jpeg_destroy_decompress(&cinfo); + + if (input_file != NULL) fclose(input_file); + if (output_file != NULL) fclose(output_file); + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &cinfo); +#endif + + /* Disable signal catcher. */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) NULL); +#endif + + return file_index; +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + int file_index; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + +#ifdef MSDOS + progname = "djpeg"; /* DOS tends to be too verbose about argv[0] */ +#else + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "djpeg"; /* in case C library doesn't provide it */ +#endif + + /* The default maxmem must be computed only once at program startup, + * since releasing memory with free() won't give it back to the OS. + */ +#ifdef FREE_MEM_ESTIMATE + default_maxmem = FREE_MEM_ESTIMATE; +#else + default_maxmem = 0; +#endif + + /* Scan command line, parse switches and locate input file names */ + + if (argc < 2) + usage(); /* nothing on the command line?? */ + + file_index = 0; + + while (file_index < argc-1) + file_index = process_one_file(argc, argv, file_index); + + /* All done. */ + exit(EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/thirdparty/jpeg-9e/example.c b/thirdparty/jpeg-9e/example.c new file mode 100644 index 0000000..1d6f6cc --- /dev/null +++ b/thirdparty/jpeg-9e/example.c @@ -0,0 +1,433 @@ +/* + * example.c + * + * This file illustrates how to use the IJG code as a subroutine library + * to read or write JPEG image files. You should look at this code in + * conjunction with the documentation file libjpeg.txt. + * + * This code will not do anything useful as-is, but it may be helpful as a + * skeleton for constructing routines that call the JPEG library. + * + * We present these routines in the same coding style used in the JPEG code + * (ANSI function definitions, etc); but you are of course free to code your + * routines in a different style if you prefer. + */ + +#include + +/* + * Include file for users of JPEG library. + * You will need to have included system headers that define at least + * the typedefs FILE and size_t before you can include jpeglib.h. + * (stdio.h is sufficient on ANSI-conforming systems.) + * You may also wish to include "jerror.h". + */ + +#include "jpeglib.h" + +/* + * is used for the optional error recovery mechanism shown in + * the second part of the example. + */ + +#include + + + +/******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ + +/* This half of the example shows how to feed data into the JPEG compressor. + * We present a minimal version that does not worry about refinements such + * as error recovery (the JPEG code will just exit() if it gets an error). + */ + + +/* + * IMAGE DATA FORMATS: + * + * The standard input image format is a rectangular array of pixels, with + * each pixel having the same number of "component" values (color channels). + * Each pixel row is an array of JSAMPLEs (which typically are unsigned chars). + * If you are working with color data, then the color values for each pixel + * must be adjacent in the row; for example, R,G,B,R,G,B,R,G,B,... for 24-bit + * RGB color. + * + * For this example, we'll assume that this data structure matches the way + * our application has stored the image in memory, so we can just pass a + * pointer to our image buffer. In particular, let's say that the image is + * RGB color and is described by: + */ + +extern JSAMPLE * image_buffer; /* Points to large array of R,G,B-order data */ +extern int image_height; /* Number of rows in image */ +extern int image_width; /* Number of columns in image */ + + +/* + * Sample routine for JPEG compression. We assume that the target file name + * and a compression quality factor are passed in. + */ + +GLOBAL(void) +write_JPEG_file (char * filename, int quality) +{ + /* This struct contains the JPEG compression parameters and pointers to + * working space (which is allocated as needed by the JPEG library). + * It is possible to have several such structures, representing multiple + * compression/decompression processes, in existence at once. We refer + * to any one struct (and its associated working data) as a "JPEG object". + */ + struct jpeg_compress_struct cinfo; + /* This struct represents a JPEG error handler. It is declared separately + * because applications often want to supply a specialized error handler + * (see the second half of this file for an example). But here we just + * take the easy way out and use the standard error handler, which will + * print a message on stderr and call exit() if compression fails. + * Note that this struct must live as long as the main JPEG parameter + * struct, to avoid dangling-pointer problems. + */ + struct jpeg_error_mgr jerr; + /* More stuff */ + FILE * outfile; /* target file */ + JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ + int row_stride; /* physical row width in image buffer */ + + /* Step 1: allocate and initialize JPEG compression object */ + + /* We have to set up the error handler first, in case the initialization + * step fails. (Unlikely, but it could happen if you are out of memory.) + * This routine fills in the contents of struct jerr, and returns jerr's + * address which we place into the link field in cinfo. + */ + cinfo.err = jpeg_std_error(&jerr); + /* Now we can initialize the JPEG compression object. */ + jpeg_create_compress(&cinfo); + + /* Step 2: specify data destination (eg, a file) */ + /* Note: steps 2 and 3 can be done in either order. */ + + /* Here we use the library-supplied code to send compressed data to a + * stdio stream. You can also write your own code to do something else. + * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that + * requires it in order to write binary files. + */ + if ((outfile = fopen(filename, "wb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_dest(&cinfo, outfile); + + /* Step 3: set parameters for compression */ + + /* First we supply a description of the input image. + * Four fields of the cinfo struct must be filled in: + */ + cinfo.image_width = image_width; /* image width and height, in pixels */ + cinfo.image_height = image_height; + cinfo.input_components = 3; /* # of color components per pixel */ + cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ + /* Now use the library's routine to set default compression parameters. + * (You must set at least cinfo.in_color_space before calling this, + * since the defaults depend on the source color space.) + */ + jpeg_set_defaults(&cinfo); + /* Now you can set any non-default parameters you wish to. + * Here we just illustrate the use of quality (quantization table) scaling: + */ + jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); + + /* Step 4: Start compressor */ + + /* TRUE ensures that we will write a complete interchange-JPEG file. + * Pass TRUE unless you are very sure of what you're doing. + */ + jpeg_start_compress(&cinfo, TRUE); + + /* Step 5: while (scan lines remain to be written) */ + /* jpeg_write_scanlines(...); */ + + /* Here we use the library's state variable cinfo.next_scanline as the + * loop counter, so that we don't have to keep track ourselves. + * To keep things simple, we pass one scanline per call; you can pass + * more if you wish, though. + */ + row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ + + while (cinfo.next_scanline < cinfo.image_height) { + /* jpeg_write_scanlines expects an array of pointers to scanlines. + * Here the array is only one element long, but you could pass + * more than one scanline at a time if that's more convenient. + */ + row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; + (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + + /* Step 6: Finish compression */ + + jpeg_finish_compress(&cinfo); + /* After finish_compress, we can close the output file. */ + fclose(outfile); + + /* Step 7: release JPEG compression object */ + + /* This is an important step since it will release a good deal of memory. */ + jpeg_destroy_compress(&cinfo); + + /* And we're done! */ +} + + +/* + * SOME FINE POINTS: + * + * In the above loop, we ignored the return value of jpeg_write_scanlines, + * which is the number of scanlines actually written. We could get away + * with this because we were only relying on the value of cinfo.next_scanline, + * which will be incremented correctly. If you maintain additional loop + * variables then you should be careful to increment them properly. + * Actually, for output to a stdio stream you needn't worry, because + * then jpeg_write_scanlines will write all the lines passed (or else exit + * with a fatal error). Partial writes can only occur if you use a data + * destination module that can demand suspension of the compressor. + * (If you don't know what that's for, you don't need it.) + * + * If the compressor requires full-image buffers (for entropy-coding + * optimization or a multi-scan JPEG file), it will create temporary + * files for anything that doesn't fit within the maximum-memory setting. + * (Note that temp files are NOT needed if you use the default parameters.) + * On some systems you may need to set up a signal handler to ensure that + * temporary files are deleted if the program is interrupted. See libjpeg.txt. + * + * Scanlines MUST be supplied in top-to-bottom order if you want your JPEG + * files to be compatible with everyone else's. If you cannot readily read + * your data in that order, you'll need an intermediate array to hold the + * image. See rdtarga.c or rdbmp.c for examples of handling bottom-to-top + * source data using the JPEG code's internal virtual-array mechanisms. + */ + + + +/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/ + +/* This half of the example shows how to read data from the JPEG decompressor. + * It's a bit more refined than the above, in that we show: + * (a) how to modify the JPEG library's standard error-reporting behavior; + * (b) how to allocate workspace using the library's memory manager. + * + * Just to make this example a little different from the first one, we'll + * assume that we do not intend to put the whole image into an in-memory + * buffer, but to send it line-by-line someplace else. We need a one- + * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG + * memory manager allocate it for us. This approach is actually quite useful + * because we don't need to remember to deallocate the buffer separately: it + * will go away automatically when the JPEG object is cleaned up. + */ + + +/* + * ERROR HANDLING: + * + * The JPEG library's standard error handler (jerror.c) is divided into + * several "methods" which you can override individually. This lets you + * adjust the behavior without duplicating a lot of code, which you might + * have to update with each future release. + * + * Our example here shows how to override the "error_exit" method so that + * control is returned to the library's caller when a fatal error occurs, + * rather than calling exit() as the standard error_exit method does. + * + * We use C's setjmp/longjmp facility to return control. This means that the + * routine which calls the JPEG library must first execute a setjmp() call to + * establish the return point. We want the replacement error_exit to do a + * longjmp(). But we need to make the setjmp buffer accessible to the + * error_exit routine. To do this, we make a private extension of the + * standard JPEG error handler object. (If we were using C++, we'd say we + * were making a subclass of the regular error handler.) + * + * Here's the extended error handler struct: + */ + +struct my_error_mgr { + struct jpeg_error_mgr pub; /* "public" fields */ + + jmp_buf setjmp_buffer; /* for return to caller */ +}; + +typedef struct my_error_mgr * my_error_ptr; + +/* + * Here's the routine that will replace the standard error_exit method: + */ + +METHODDEF(void) +my_error_exit (j_common_ptr cinfo) +{ + /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ + my_error_ptr myerr = (my_error_ptr) cinfo->err; + + /* Always display the message. */ + /* We could postpone this until after returning, if we chose. */ + (*cinfo->err->output_message) (cinfo); + + /* Return control to the setjmp point */ + longjmp(myerr->setjmp_buffer, 1); +} + + +/* + * Sample routine for JPEG decompression. We assume that the source file name + * is passed in. We want to return 1 on success, 0 on error. + */ + + +GLOBAL(int) +read_JPEG_file (char * filename) +{ + /* This struct contains the JPEG decompression parameters and pointers to + * working space (which is allocated as needed by the JPEG library). + */ + struct jpeg_decompress_struct cinfo; + /* We use our private extension JPEG error handler. + * Note that this struct must live as long as the main JPEG parameter + * struct, to avoid dangling-pointer problems. + */ + struct my_error_mgr jerr; + /* More stuff */ + FILE * infile; /* source file */ + JSAMPARRAY buffer; /* Output row buffer */ + int row_stride; /* physical row width in output buffer */ + + /* In this example we want to open the input file before doing anything else, + * so that the setjmp() error recovery below can assume the file is open. + * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that + * requires it in order to read binary files. + */ + + if ((infile = fopen(filename, "rb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + return 0; + } + + /* Step 1: allocate and initialize JPEG decompression object */ + + /* We set up the normal JPEG error routines, then override error_exit. */ + cinfo.err = jpeg_std_error(&jerr.pub); + jerr.pub.error_exit = my_error_exit; + /* Establish the setjmp return context for my_error_exit to use. */ + if (setjmp(jerr.setjmp_buffer)) { + /* If we get here, the JPEG code has signaled an error. + * We need to clean up the JPEG object, close the input file, and return. + */ + jpeg_destroy_decompress(&cinfo); + fclose(infile); + return 0; + } + /* Now we can initialize the JPEG decompression object. */ + jpeg_create_decompress(&cinfo); + + /* Step 2: specify data source (eg, a file) */ + + jpeg_stdio_src(&cinfo, infile); + + /* Step 3: read file parameters with jpeg_read_header() */ + + (void) jpeg_read_header(&cinfo, TRUE); + /* We can ignore the return value from jpeg_read_header since + * (a) suspension is not possible with the stdio data source, and + * (b) we passed TRUE to reject a tables-only JPEG file as an error. + * See libjpeg.txt for more info. + */ + + /* Step 4: set parameters for decompression */ + + /* In this example, we don't need to change any of the defaults set by + * jpeg_read_header(), so we do nothing here. + */ + + /* Step 5: Start decompressor */ + + (void) jpeg_start_decompress(&cinfo); + /* We can ignore the return value since suspension is not possible + * with the stdio data source. + */ + + /* We may need to do some setup of our own at this point before reading + * the data. After jpeg_start_decompress() we have the correct scaled + * output image dimensions available, as well as the output colormap + * if we asked for color quantization. + * In this example, we need to make an output work buffer of the right size. + */ + /* JSAMPLEs per row in output buffer */ + row_stride = cinfo.output_width * cinfo.output_components; + /* Make a one-row-high sample array that will go away when done with image */ + buffer = (*cinfo.mem->alloc_sarray) + ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); + + /* Step 6: while (scan lines remain to be read) */ + /* jpeg_read_scanlines(...); */ + + /* Here we use the library's state variable cinfo.output_scanline as the + * loop counter, so that we don't have to keep track ourselves. + */ + while (cinfo.output_scanline < cinfo.output_height) { + /* jpeg_read_scanlines expects an array of pointers to scanlines. + * Here the array is only one element long, but you could ask for + * more than one scanline at a time if that's more convenient. + */ + (void) jpeg_read_scanlines(&cinfo, buffer, 1); + /* Assume put_scanline_someplace wants a pointer and sample count. */ + put_scanline_someplace(buffer[0], row_stride); + } + + /* Step 7: Finish decompression */ + + (void) jpeg_finish_decompress(&cinfo); + /* We can ignore the return value since suspension is not possible + * with the stdio data source. + */ + + /* Step 8: Release JPEG decompression object */ + + /* This is an important step since it will release a good deal of memory. */ + jpeg_destroy_decompress(&cinfo); + + /* After finish_decompress, we can close the input file. + * Here we postpone it until after no more JPEG errors are possible, + * so as to simplify the setjmp error logic above. (Actually, I don't + * think that jpeg_destroy can do an error exit, but why assume anything...) + */ + fclose(infile); + + /* At this point you may want to check to see whether any corrupt-data + * warnings occurred (test whether jerr.pub.num_warnings is nonzero). + */ + + /* And we're done! */ + return 1; +} + + +/* + * SOME FINE POINTS: + * + * In the above code, we ignored the return value of jpeg_read_scanlines, + * which is the number of scanlines actually read. We could get away with + * this because we asked for only one line at a time and we weren't using + * a suspending data source. See libjpeg.txt for more info. + * + * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress(); + * we should have done it beforehand to ensure that the space would be + * counted against the JPEG max_memory setting. In some systems the above + * code would risk an out-of-memory error. However, in general we don't + * know the output image dimensions before jpeg_start_decompress(), unless we + * call jpeg_calc_output_dimensions(). See libjpeg.txt for more about this. + * + * Scanlines are returned in the same order as they appear in the JPEG file, + * which is standardly top-to-bottom. If you must emit data bottom-to-top, + * you can use one of the virtual arrays provided by the JPEG memory manager + * to invert the data. See wrbmp.c for an example. + * + * As with compression, some operating modes may require temporary files. + * On some systems you may need to set up a signal handler to ensure that + * temporary files are deleted if the program is interrupted. See libjpeg.txt. + */ diff --git a/thirdparty/jpeg-9e/filelist.txt b/thirdparty/jpeg-9e/filelist.txt new file mode 100644 index 0000000..ddd681b --- /dev/null +++ b/thirdparty/jpeg-9e/filelist.txt @@ -0,0 +1,218 @@ +IJG JPEG LIBRARY: FILE LIST + +Copyright (C) 1994-2020, Thomas G. Lane, Guido Vollbeding. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +Here is a road map to the files in the IJG JPEG distribution. The +distribution includes the JPEG library proper, plus two application +programs ("cjpeg" and "djpeg") which use the library to convert JPEG +files to and from some other popular image formats. A third application +"jpegtran" uses the library to do lossless conversion between different +variants of JPEG. There are also two stand-alone applications, +"rdjpgcom" and "wrjpgcom". + + +THE JPEG LIBRARY +================ + +Include files: + +jpeglib.h JPEG library's exported data and function declarations. +jconfig.h Configuration declarations. Note: this file is not present + in the distribution; it is generated during installation. +jmorecfg.h Additional configuration declarations; need not be changed + for a standard installation. +jerror.h Declares JPEG library's error and trace message codes. +jinclude.h Central include file used by all IJG .c files to reference + system include files. +jpegint.h JPEG library's internal data structures. +jdct.h Private declarations for forward & reverse DCT subsystems. +jmemsys.h Private declarations for memory management subsystem. +jversion.h Version information. + +Applications using the library should include jpeglib.h (which in turn +includes jconfig.h and jmorecfg.h). Optionally, jerror.h may be included +if the application needs to reference individual JPEG error codes. The +other include files are intended for internal use and would not normally +be included by an application program. (cjpeg/djpeg/etc do use jinclude.h, +since its function is to improve portability of the whole IJG distribution. +Most other applications will directly include the system include files they +want, and hence won't need jinclude.h.) + + +C source code files: + +These files contain most of the functions intended to be called directly by +an application program: + +jcapimin.c Application program interface: core routines for compression. +jcapistd.c Application program interface: standard compression. +jdapimin.c Application program interface: core routines for decompression. +jdapistd.c Application program interface: standard decompression. +jcomapi.c Application program interface routines common to compression + and decompression. +jcparam.c Compression parameter setting helper routines. +jctrans.c API and library routines for transcoding compression. +jdtrans.c API and library routines for transcoding decompression. + +Compression side of the library: + +jcinit.c Initialization: determines which other modules to use. +jcmaster.c Master control: setup and inter-pass sequencing logic. +jcmainct.c Main buffer controller (preprocessor => JPEG compressor). +jcprepct.c Preprocessor buffer controller. +jccoefct.c Buffer controller for DCT coefficient buffer. +jccolor.c Color space conversion. +jcsample.c Downsampling. +jcdctmgr.c DCT manager (DCT implementation selection & control). +jfdctint.c Forward DCT using slow-but-accurate integer method. +jfdctfst.c Forward DCT using faster, less accurate integer method. +jfdctflt.c Forward DCT using floating-point arithmetic. +jchuff.c Huffman entropy coding. +jcarith.c Arithmetic entropy coding. +jcmarker.c JPEG marker writing. +jdatadst.c Data destination managers for memory and stdio output. + +Decompression side of the library: + +jdmaster.c Master control: determines which other modules to use. +jdinput.c Input controller: controls input processing modules. +jdmainct.c Main buffer controller (JPEG decompressor => postprocessor). +jdcoefct.c Buffer controller for DCT coefficient buffer. +jdpostct.c Postprocessor buffer controller. +jdmarker.c JPEG marker reading. +jdhuff.c Huffman entropy decoding. +jdarith.c Arithmetic entropy decoding. +jddctmgr.c IDCT manager (IDCT implementation selection & control). +jidctint.c Inverse DCT using slow-but-accurate integer method. +jidctfst.c Inverse DCT using faster, less accurate integer method. +jidctflt.c Inverse DCT using floating-point arithmetic. +jdsample.c Upsampling. +jdcolor.c Color space conversion. +jdmerge.c Merged upsampling/color conversion (faster, lower quality). +jquant1.c One-pass color quantization using a fixed-spacing colormap. +jquant2.c Two-pass color quantization using a custom-generated colormap. + Also handles one-pass quantization to an externally given map. +jdatasrc.c Data source managers for memory and stdio input. + +Support files for both compression and decompression: + +jaricom.c Tables for common use in arithmetic entropy encoding and + decoding routines. +jerror.c Standard error handling routines (application replaceable). +jmemmgr.c System-independent (more or less) memory management code. +jutils.c Miscellaneous utility routines. + +jmemmgr.c relies on a system-dependent memory management module. The IJG +distribution includes the following implementations of the system-dependent +module: + +jmemnobs.c "No backing store": assumes adequate virtual memory exists. +jmemansi.c Makes temporary files with ANSI-standard routine tmpfile(). +jmemname.c Makes temporary files with program-generated file names. +jmemdos.c Custom implementation for MS-DOS (16-bit environment only): + can use extended and expanded memory as well as temp files. +jmemmac.c Custom implementation for Apple Macintosh. + +Exactly one of the system-dependent modules should be configured into an +installed JPEG library (see install.txt for hints about which one to use). +On unusual systems you may find it worthwhile to make a special +system-dependent memory manager. + + +Non-C source code files: + +jmemdosa.asm 80x86 assembly code support for jmemdos.c; used only in + MS-DOS-specific configurations of the JPEG library. + + +CJPEG/DJPEG/JPEGTRAN +==================== + +Include files: + +cdjpeg.h Declarations shared by cjpeg/djpeg/jpegtran modules. +cderror.h Additional error and trace message codes for cjpeg et al. +transupp.h Declarations for jpegtran support routines in transupp.c. + +C source code files: + +cjpeg.c Main program for cjpeg. +cjpegalt.c Main program for cjpeg with alternate user interface. +djpeg.c Main program for djpeg. +djpegalt.c Main program for djpeg with alternate user interface. +jpegtran.c Main program for jpegtran. +cdjpeg.c Utility routines used by all three programs. +rdcolmap.c Code to read a colormap file for djpeg's "-map" switch. +rdswitch.c Code to process some of cjpeg's more complex switches. + Also used by jpegtran. +transupp.c Support code for jpegtran: lossless image manipulations. + +Image file reader modules for cjpeg: + +rdbmp.c BMP file input. +rdgif.c GIF file input. +rdppm.c PPM/PGM file input. +rdrle.c Utah RLE file input. +rdtarga.c Targa file input. + +Image file writer modules for djpeg: + +wrbmp.c BMP file output. +wrgif.c GIF file output. +wrppm.c PPM/PGM file output. +wrrle.c Utah RLE file output. +wrtarga.c Targa file output. + + +RDJPGCOM/WRJPGCOM +================= + +C source code files: + +rdjpgcom.c Stand-alone rdjpgcom application. +wrjpgcom.c Stand-alone wrjpgcom application. + +These programs do not depend on the IJG library. They do use +jconfig.h and jinclude.h, only to improve portability. + + +ADDITIONAL FILES +================ + +Documentation (see README for a guide to the documentation files): + +README Master documentation file. +*.txt Other documentation files. +*.1 Documentation in Unix man page format. +change.log Version-to-version change highlights. +example.c Sample code for calling JPEG library. + +Configuration/installation files and programs (see install.txt for more info): + +configure Unix shell script to perform automatic configuration. +configure.ac Source file for use with Autoconf to generate configure. +ltmain.sh Support scripts for configure (from GNU libtool). +config.guess +config.sub +depcomp +missing +ar-lib +compile +install-sh Install shell script for those Unix systems lacking one. +Makefile.in Makefile input for configure. +Makefile.am Source file for use with Automake to generate Makefile.in. +ckconfig.c Program to generate jconfig.h on non-Unix systems. +jconfig.txt Template for making jconfig.h by hand. +mak*.* Sample makefiles for particular systems. +jconfig.* Sample jconfig.h for particular systems. +libjpeg.map Script to generate shared library with versioned symbols. +libjpeg.pc.in libjpeg.pc pkg-config file input for configure. +aclocal.m4 M4 macro definitions for use with Autoconf. + +Test files (see install.txt for test procedure): + +test*.* Source and comparison files for confidence test. + These are binary image files, NOT text files. diff --git a/thirdparty/jpeg-9e/install-sh b/thirdparty/jpeg-9e/install-sh new file mode 100755 index 0000000..ec298b5 --- /dev/null +++ b/thirdparty/jpeg-9e/install-sh @@ -0,0 +1,541 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2020-11-14.01; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# 'make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +tab=' ' +nl=' +' +IFS=" $tab$nl" + +# Set DOITPROG to "echo" to test this script. + +doit=${DOITPROG-} +doit_exec=${doit:-exec} + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +# Create dirs (including intermediate dirs) using mode 755. +# This is like GNU 'install' as of coreutils 8.32 (2020). +mkdir_umask=22 + +backupsuffix= +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +is_target_a_directory=possibly + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -p pass -p to $cpprog. + -s $stripprog installed files. + -S SUFFIX attempt to back up existing files, with suffix SUFFIX. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG + +By default, rm is invoked with -f; when overridden with RMPROG, +it's up to you to specify -f if you want it. + +If -S is not specified, no backups are attempted. + +Email bug reports to bug-automake@gnu.org. +Automake home page: https://www.gnu.org/software/automake/ +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -p) cpprog="$cpprog -p";; + + -s) stripcmd=$stripprog;; + + -S) backupsuffix="$2" + shift;; + + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) is_target_a_directory=never;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call 'install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names problematic for 'test' and other utilities. + case $src in + -* | [=\(\)!]) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + # Don't chown directories that already exist. + if test $dstdir_status = 0; then + chowncmd="" + fi + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + dst=$dst_arg + + # If destination is a directory, append the input filename. + if test -d "$dst"; then + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dstbase=`basename "$src"` + case $dst in + */) dst=$dst$dstbase;; + *) dst=$dst/$dstbase;; + esac + dstdir_status=0 + else + dstdir=`dirname "$dst"` + test -d "$dstdir" + dstdir_status=$? + fi + fi + + case $dstdir in + */) dstdirslash=$dstdir;; + *) dstdirslash=$dstdir/;; + esac + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + # The $RANDOM variable is not portable (e.g., dash). Use it + # here however when possible just to lower collision chance. + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + + trap ' + ret=$? + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null + exit $ret + ' 0 + + # Because "mkdir -p" follows existing symlinks and we likely work + # directly in world-writeable /tmp, make sure that the '$tmpdir' + # directory is successfully created first before we actually test + # 'mkdir -p'. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null + fi + trap '' 0;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; + esac + + oIFS=$IFS + IFS=/ + set -f + set fnord $dstdir + shift + set +f + IFS=$oIFS + + prefixes= + + for d + do + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=${dstdirslash}_inst.$$_ + rmtmp=${dstdirslash}_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && + { test -z "$stripcmd" || { + # Create $dsttmp read-write so that cp doesn't create it read-only, + # which would cause strip to fail. + if test -z "$doit"; then + : >"$dsttmp" # No need to fork-exec 'touch'. + else + $doit touch "$dsttmp" + fi + } + } && + $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + set +f && + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # If $backupsuffix is set, and the file being installed + # already exists, attempt a backup. Don't worry if it fails, + # e.g., if mv doesn't support -f. + if test -n "$backupsuffix" && test -f "$dst"; then + $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null + fi + + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/thirdparty/jpeg-9e/install.txt b/thirdparty/jpeg-9e/install.txt new file mode 100644 index 0000000..6420513 --- /dev/null +++ b/thirdparty/jpeg-9e/install.txt @@ -0,0 +1,1198 @@ +INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software + +Copyright (C) 1991-2021, Thomas G. Lane, Guido Vollbeding. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file explains how to configure and install the IJG software. We have +tried to make this software extremely portable and flexible, so that it can be +adapted to almost any environment. The downside of this decision is that the +installation process is complicated. We have provided shortcuts to simplify +the task on common systems. But in any case, you will need at least a little +familiarity with C programming and program build procedures for your system. + +If you are only using this software as part of a larger program, the larger +program's installation procedure may take care of configuring the IJG code. +For example, Ghostscript's installation script will configure the IJG code. +You don't need to read this file if you just want to compile Ghostscript. + +If you are on a Unix machine, you may not need to read this file at all. +Try doing + ./configure + make + make test +If that doesn't complain, do + make install +(better do "make -n install" first to see if the makefile will put the files +where you want them). Read further if you run into snags or want to customize +the code for your system. + + +TABLE OF CONTENTS +----------------- + +Before you start +Configuring the software: + using the automatic "configure" script + using one of the supplied jconfig and makefile files + by hand +Building the software +Testing the software +Installing the software +Optional stuff +Optimization +Hints for specific systems + + +BEFORE YOU START +================ + +Before installing the software you must unpack the distributed source code. +Since you are reading this file, you have probably already succeeded in this +task. However, there is a potential for error if you needed to convert the +files to the local standard text file format (for example, if you are on +MS-DOS you may have converted LF end-of-line to CR/LF). You must apply +such conversion to all the files EXCEPT those whose names begin with "test". +The test files contain binary data; if you change them in any way then the +self-test will give bad results. + +Please check the last section of this file to see if there are hints for the +specific machine or compiler you are using. + + +CONFIGURING THE SOFTWARE +======================== + +To configure the IJG code for your system, you need to create two files: + * jconfig.h: contains values for system-dependent #define symbols. + * Makefile: controls the compilation process. +(On a non-Unix machine, you may create "project files" or some other +substitute for a Makefile. jconfig.h is needed in any environment.) + +We provide three different ways to generate these files: + * On a Unix system, you can just run the "configure" script. + * We provide sample jconfig files and makefiles for popular machines; + if your machine matches one of the samples, just copy the right sample + files to jconfig.h and Makefile. + * If all else fails, read the instructions below and make your own files. + + +Configuring the software using the automatic "configure" script +--------------------------------------------------------------- + +If you are on a Unix machine, you can just type + ./configure +and let the configure script construct appropriate configuration files. +If you're using "csh" on an old version of System V, you might need to type + sh configure +instead to prevent csh from trying to execute configure itself. +Expect configure to run for a few minutes, particularly on slower machines; +it works by compiling a series of test programs. + +Configure was created with GNU Autoconf and it follows the usual conventions +for GNU configure scripts. It makes a few assumptions that you may want to +override. You can do this by providing optional switches to configure: + +* Configure will build both static and shared libraries, if possible. +If you want to build libjpeg only as a static library, say + ./configure --disable-shared +If you want to build libjpeg only as a shared library, say + ./configure --disable-static +Configure uses GNU libtool to take care of system-dependent shared library +building methods. + +* Configure will use gcc (GNU C compiler) if it's available, otherwise cc. +To force a particular compiler to be selected, use the CC option, for example + ./configure CC='cc' +The same method can be used to include any unusual compiler switches. +For example, on HP-UX you probably want to say + ./configure CC='cc -Aa' +to get HP's compiler to run in ANSI mode. + +* The default CFLAGS setting is "-g" for non-gcc compilers, "-g -O2" for gcc. +You can override this by saying, for example, + ./configure CFLAGS='-O2' +if you want to compile without debugging support. + +* Configure will set up the makefile so that "make install" will install files +into /usr/local/bin, /usr/local/man, etc. You can specify an installation +prefix other than "/usr/local" by giving configure the option "--prefix=PATH". + +* If you don't have a lot of swap space, you may need to enable the IJG +software's internal virtual memory mechanism. To do this, give the option +"--enable-maxmem=N" where N is the default maxmemory limit in megabytes. +This is discussed in more detail under "Selecting a memory manager", below. +You probably don't need to worry about this on reasonably-sized Unix machines, +unless you plan to process very large images. + +Configure has some other features that are useful if you are cross-compiling +or working in a network of multiple machine types; but if you need those +features, you probably already know how to use them. + + +Configuring the software using one of the supplied jconfig and makefile files +----------------------------------------------------------------------------- + +If you have one of these systems, you can just use the provided configuration +files: + +Makefile jconfig file System and/or compiler + +makefile.manx jconfig.manx Amiga, Manx Aztec C +makefile.sas jconfig.sas Amiga, SAS C +makeproj.mac jconfig.mac Apple Macintosh, Metrowerks CodeWarrior +mak*jpeg.st jconfig.st Atari ST/STE/TT, Pure C or Turbo C +makefile.bcc jconfig.bcc MS-DOS or OS/2, Borland C +makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C) +makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C (16-bit only) +makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C +makefile.vc jconfig.vc Windows, MS Visual C++ +makefile.vs jconfig.vc Windows, MS Visual C++ 6 Developer Studio +make*.vc6 +makefile.vs jconfig.vc Windows, Visual Studio 2019 Version 16 +make*.v16 +makefile.vs jconfig.vc Windows, Visual Studio 2022 Version 17 +make*.v16 +make*.v17 +makefile.b32 jconfig.vc Windows, Borland C++ 32-bit (bcc32) +makefile.mms jconfig.vms Digital VMS, with MMS software +makefile.vms jconfig.vms Digital VMS, without MMS software + +Copy the proper jconfig file to jconfig.h and the makefile to Makefile (or +whatever your system uses as the standard makefile name). For more info see +the appropriate system-specific hints section near the end of this file. + + +Configuring the software by hand +-------------------------------- + +First, generate a jconfig.h file. If you are moderately familiar with C, +the comments in jconfig.txt should be enough information to do this; just +copy jconfig.txt to jconfig.h and edit it appropriately. Otherwise, you may +prefer to use the ckconfig.c program. You will need to compile and execute +ckconfig.c by hand --- we hope you know at least enough to do that. +ckconfig.c may not compile the first try (in fact, the whole idea is for it +to fail if anything is going to). If you get compile errors, fix them by +editing ckconfig.c according to the directions given in ckconfig.c. Once +you get it to run, it will write a suitable jconfig.h file, and will also +print out some advice about which makefile to use. + +You may also want to look at the canned jconfig files, if there is one for a +system similar to yours. + +Second, select a makefile and copy it to Makefile (or whatever your system +uses as the standard makefile name). The most generic makefiles we provide +are + makefile.ansi: if your C compiler supports function prototypes + makefile.unix: if not. +(You have function prototypes if ckconfig.c put "#define HAVE_PROTOTYPES" +in jconfig.h.) You may want to start from one of the other makefiles if +there is one for a system similar to yours. + +Look over the selected Makefile and adjust options as needed. In particular +you may want to change the CC and CFLAGS definitions. For instance, if you +are using GCC, set CC=gcc. If you had to use any compiler switches to get +ckconfig.c to work, make sure the same switches are in CFLAGS. + +If you are on a system that doesn't use makefiles, you'll need to set up +project files (or whatever you do use) to compile all the source files and +link them into executable files cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom. +See the file lists in any of the makefiles to find out which files go into +each program. Note that the provided makefiles all make a "library" file +libjpeg first, but you don't have to do that if you don't want to; the file +lists identify which source files are actually needed for compression, +decompression, or both. As a last resort, you can make a batch script that +just compiles everything and links it all together; makefile.vms is an example +of this (it's for VMS systems that have no make-like utility). + +Here are comments about some specific configuration decisions you'll +need to make: + +Command line style +------------------ + +These programs can use a Unix-like command line style which supports +redirection and piping, like this: + cjpeg inputfile >outputfile + cjpeg outputfile + source program | cjpeg >outputfile +The simpler "two file" command line style is just + cjpeg inputfile outputfile +You may prefer the two-file style, particularly if you don't have pipes. + +You MUST use two-file style on any system that doesn't cope well with binary +data fed through stdin/stdout; this is true for some MS-DOS compilers, for +example. If you're not on a Unix system, it's safest to assume you need +two-file style. (But if your compiler provides either the Posix-standard +fdopen() library routine or a Microsoft-compatible setmode() routine, you +can safely use the Unix command line style, by defining USE_FDOPEN or +USE_SETMODE respectively.) + +To use the two-file style, make jconfig.h say "#define TWO_FILE_COMMANDLINE". + +Selecting a memory manager +-------------------------- + +The IJG code is capable of working on images that are too big to fit in main +memory; data is swapped out to temporary files as necessary. However, the +code to do this is rather system-dependent. We provide five different +memory managers: + +* jmemansi.c This version uses the ANSI-standard library routine tmpfile(), + which not all non-ANSI systems have. On some systems + tmpfile() may put the temporary file in a non-optimal + location; if you don't like what it does, use jmemname.c. + +* jmemname.c This version creates named temporary files. For anything + except a Unix machine, you'll need to configure the + select_file_name() routine appropriately; see the comments + near the head of jmemname.c. If you use this version, define + NEED_SIGNAL_CATCHER in jconfig.h to make sure the temp files + are removed if the program is aborted. + +* jmemnobs.c (That stands for No Backing Store :-).) This will compile on + almost any system, but it assumes you have enough main memory + or virtual memory to hold the biggest images you work with. + +* jmemdos.c This should be used with most 16-bit MS-DOS compilers. + See the system-specific notes about MS-DOS for more info. + IMPORTANT: if you use this, define USE_MSDOS_MEMMGR in + jconfig.h, and include the assembly file jmemdosa.asm in the + programs. The supplied makefiles and jconfig files for + 16-bit MS-DOS compilers already do both. + +* jmemmac.c Custom version for Apple Macintosh; see the system-specific + notes for Macintosh for more info. + +To use a particular memory manager, change the SYSDEPMEM variable in your +makefile to equal the corresponding object file name (for example, jmemansi.o +or jmemansi.obj for jmemansi.c). + +If you have plenty of (real or virtual) main memory, just use jmemnobs.c. +"Plenty" means about ten bytes for every pixel in the largest images +you plan to process, so a lot of systems don't meet this criterion. +If yours doesn't, try jmemansi.c first. If that doesn't compile, you'll have +to use jmemname.c; be sure to adjust select_file_name() for local conditions. +You may also need to change unlink() to remove() in close_backing_store(). + +Except with jmemnobs.c or jmemmac.c, you need to adjust the DEFAULT_MAX_MEM +setting to a reasonable value for your system (either by adding a #define for +DEFAULT_MAX_MEM to jconfig.h, or by adding a -D switch to the Makefile). +This value limits the amount of data space the program will attempt to +allocate. Code and static data space isn't counted, so the actual memory +needs for cjpeg or djpeg are typically 100 to 150Kb more than the max-memory +setting. Larger max-memory settings reduce the amount of I/O needed to +process a large image, but too large a value can result in "insufficient +memory" failures. On most Unix machines (and other systems with virtual +memory), just set DEFAULT_MAX_MEM to several million and forget it. At the +other end of the spectrum, for MS-DOS machines you probably can't go much +above 300K to 400K. (On MS-DOS the value refers to conventional memory only. +Extended/expanded memory is handled separately by jmemdos.c.) + + +BUILDING THE SOFTWARE +===================== + +Now you should be able to compile the software. Just say "make" (or +whatever's necessary to start the compilation). Have a cup of coffee. + +Here are some things that could go wrong: + +If your compiler complains about undefined structures, you should be able to +shut it up by putting "#define INCOMPLETE_TYPES_BROKEN" in jconfig.h. + +If you have trouble with missing system include files or inclusion of the +wrong ones, read jinclude.h. This shouldn't happen if you used configure +or ckconfig.c to set up jconfig.h. + +There are a fair number of routines that do not use all of their parameters; +some compilers will issue warnings about this, which you can ignore. There +are also a few configuration checks that may give "unreachable code" warnings. +Any other warning deserves investigation. + +If you don't have a getenv() library routine, define NO_GETENV. + +Also see the system-specific hints, below. + + +TESTING THE SOFTWARE +==================== + +As a quick test of functionality we've included a small sample image in +several forms: + testorig.jpg Starting point for the djpeg tests. + testimg.ppm The output of djpeg testorig.jpg + testimg.gif The output of djpeg -gif testorig.jpg + testimg.bmp The output of djpeg -bmp -colors 256 testorig.jpg + testimg.jpg The output of cjpeg testimg.ppm + testprog.jpg Progressive-mode equivalent of testorig.jpg. + testimgp.jpg The output of cjpeg -progressive -optimize testimg.ppm +(The first- and second-generation .jpg files aren't identical since the +default compression parameters are lossy.) If you can generate duplicates +of the testimg* files then you probably have working programs. + +With most of the makefiles, "make test" will perform the necessary +comparisons. + +If you're using a makefile that doesn't provide the test option, run djpeg +and cjpeg by hand and compare the output files to testimg* with whatever +binary file comparison tool you have. The files should be bit-for-bit +identical. + +If the programs complain "MAX_ALLOC_CHUNK is wrong, please fix", then you +need to reduce MAX_ALLOC_CHUNK to a value that fits in type size_t. +Try adding "#define MAX_ALLOC_CHUNK 65520L" to jconfig.h. A less likely +configuration error is "ALIGN_TYPE is wrong, please fix": defining ALIGN_TYPE +as long should take care of that one. + +If the cjpeg test run fails with "Missing Huffman code table entry", it's a +good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED. Go back to the +configuration step and run ckconfig.c. (This is a good plan for any other +test failure, too.) + +If you are using Unix (one-file) command line style on a non-Unix system, +it's a good idea to check that binary I/O through stdin/stdout actually +works. You should get the same results from "djpeg out.ppm" +as from "djpeg -outfile out.ppm testorig.jpg". Note that the makefiles all +use the latter style and therefore do not exercise stdin/stdout! If this +check fails, try recompiling with USE_SETMODE or USE_FDOPEN defined. +If it still doesn't work, better use two-file style. + +If you chose a memory manager other than jmemnobs.c, you should test that +temporary-file usage works. Try "djpeg -bmp -colors 256 -max 0 testorig.jpg" +and make sure its output matches testimg.bmp. If you have any really large +images handy, try compressing them with -optimize and/or decompressing with +-colors 256 to make sure your DEFAULT_MAX_MEM setting is not too large. + +NOTE: this is far from an exhaustive test of the JPEG software; some modules, +such as 1-pass color quantization, are not exercised at all. It's just a +quick test to give you some confidence that you haven't missed something +major. + + +INSTALLING THE SOFTWARE +======================= + +Once you're done with the above steps, you can install the software by +copying the executable files (cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom) +to wherever you normally install programs. On Unix systems, you'll also want +to put the man pages (cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1) +in the man-page directory. The pre-fab makefiles don't support this step +since there's such a wide variety of installation procedures on different +systems. + +If you generated a Makefile with the "configure" script, you can just say + make install +to install the programs and their man pages into the standard places. +(You'll probably need to be root to do this.) We recommend first saying + make -n install +to see where configure thought the files should go. You may need to edit +the Makefile, particularly if your system's conventions for man page +filenames don't match what configure expects. + +If you want to install the IJG library itself, for use in compiling other +programs besides ours, then you need to put the four include files + jpeglib.h jerror.h jconfig.h jmorecfg.h +into your include-file directory, and put the library file libjpeg.a +(extension may vary depending on system) wherever library files go. +If you generated a Makefile with "configure", it will do what it thinks +is the right thing if you say + make install-lib + + +OPTIONAL STUFF +============== + +Progress monitor: + +If you like, you can #define PROGRESS_REPORT (in jconfig.h) to enable display +of percent-done progress reports. The routine provided in cdjpeg.c merely +prints percentages to stderr, but you can customize it to do something +fancier. + +Utah RLE file format support: + +We distribute the software with support for RLE image files (Utah Raster +Toolkit format) disabled, because the RLE support won't compile without the +Utah library. If you have URT version 3.1 or later, you can enable RLE +support as follows: + 1. #define RLE_SUPPORTED in jconfig.h. + 2. Add a -I option to CFLAGS in the Makefile for the directory + containing the URT .h files (typically the "include" + subdirectory of the URT distribution). + 3. Add -L... -lrle to LDLIBS in the Makefile, where ... specifies + the directory containing the URT "librle.a" file (typically the + "lib" subdirectory of the URT distribution). + +Support for 9-bit to 12-bit deep pixel data: + +The IJG code currently allows 8, 9, 10, 11, or 12 bits sample data precision. +(For color, this means 8 to 12 bits per channel, of course.) If you need to +work with deeper than 8-bit data, you can compile the IJG code for 9-bit to +12-bit operation. +To do so: + 1. In jmorecfg.h, define BITS_IN_JSAMPLE as 9, 10, 11, or 12 rather than 8. + 2. In jconfig.h, undefine BMP_SUPPORTED, RLE_SUPPORTED, and TARGA_SUPPORTED, + because the code for those formats doesn't handle deeper than 8-bit data + and won't even compile. (The PPM code does work, as explained below. + The GIF code works too; it scales 8-bit GIF data to and from 12-bit + depth automatically.) + 3. Compile. Don't expect "make test" to pass, since the supplied test + files are for 8-bit data. + +Currently, 9-bit to 12-bit support does not work on 16-bit-int machines. + +Run-time selection and conversion of data precision are currently not +supported and may be added later. +Exception: The transcoding part (jpegtran) supports all settings in a +single instance, since it operates on the level of DCT coefficients and +not sample values. + +The PPM reader (rdppm.c) can read deeper than 8-bit data from either +text-format or binary-format PPM and PGM files. Binary-format PPM/PGM files +which have a maxval greater than 255 are assumed to use 2 bytes per sample, +MSB first (big-endian order). As of early 1995, 2-byte binary format is not +officially supported by the PBMPLUS library, but it is expected that a +future release of PBMPLUS will support it. Note that the PPM reader will +read files of any maxval regardless of the BITS_IN_JSAMPLE setting; incoming +data is automatically rescaled to maxval=MAXJSAMPLE as appropriate for the +cjpeg bit depth. + +The PPM writer (wrppm.c) will normally write 2-byte binary PPM or PGM +format, maxval=MAXJSAMPLE, when compiled with BITS_IN_JSAMPLE>8. Since this +format is not yet widely supported, you can disable it by compiling wrppm.c +with PPM_NORAWWORD defined; then the data is scaled down to 8 bits to make a +standard 1-byte/sample PPM or PGM file. (Yes, this means still another copy +of djpeg to keep around. But hopefully you won't need it for very long. +Poskanzer's supposed to get that new PBMPLUS release out Real Soon Now.) + +Of course, if you are working with 9-bit to 12-bit data, you probably have +it stored in some other, nonstandard format. In that case you'll probably +want to write your own I/O modules to read and write your format. + +Note: +The standard Huffman tables are only valid for 8-bit data precision. If +you selected more than 8-bit data precision, cjpeg uses arithmetic coding +by default. The Huffman encoder normally uses entropy optimization to +compute usable tables for higher precision. Otherwise, you'll have to +supply different default Huffman tables. + +Removing code: + +If you need to make a smaller version of the JPEG software, some optional +functions can be removed at compile time. See the xxx_SUPPORTED #defines in +jconfig.h and jmorecfg.h. If at all possible, we recommend that you leave in +decoder support for all valid JPEG files, to ensure that you can read anyone's +output. Taking out support for image file formats that you don't use is the +most painless way to make the programs smaller. Another possibility is to +remove some of the DCT methods: in particular, the "IFAST" method may not be +enough faster than the others to be worth keeping on your machine. (If you +do remove ISLOW or IFAST, be sure to redefine JDCT_DEFAULT or JDCT_FASTEST +to a supported method, by adding a #define in jconfig.h.) + + +OPTIMIZATION +============ + +Unless you own a Cray, you'll probably be interested in making the JPEG +software go as fast as possible. This section covers some machine-dependent +optimizations you may want to try. We suggest that before trying any of +this, you first get the basic installation to pass the self-test step. +Repeat the self-test after any optimization to make sure that you haven't +broken anything. + +The integer DCT routines perform a lot of multiplications. These +multiplications must yield 32-bit results, but none of their input values +are more than 16 bits wide. On many machines, notably the 680x0 and 80x86 +CPUs, a 16x16=>32 bit multiply instruction is faster than a full 32x32=>32 +bit multiply. Unfortunately there is no portable way to specify such a +multiplication in C, but some compilers can generate one when you use the +right combination of casts. See the MULTIPLYxxx macro definitions in +jdct.h. If your compiler makes "int" be 32 bits and "short" be 16 bits, +defining SHORTxSHORT_32 is fairly likely to work. When experimenting with +alternate definitions, be sure to test not only whether the code still works +(use the self-test), but also whether it is actually faster --- on some +compilers, alternate definitions may compute the right answer, yet be slower +than the default. Timing cjpeg on a large PGM (grayscale) input file is the +best way to check this, as the DCT will be the largest fraction of the runtime +in that mode. (Note: some of the distributed compiler-specific jconfig files +already contain #define switches to select appropriate MULTIPLYxxx +definitions.) + +If your machine has sufficiently fast floating point hardware, you may find +that the float DCT method is faster than the integer DCT methods, even +after tweaking the integer multiply macros. In that case you may want to +make the float DCT be the default method. (The only objection to this is +that float DCT results may vary slightly across machines.) To do that, add +"#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change +the default, you should redefine JDCT_FASTEST, which is the method selected +by djpeg's -fast switch. Don't forget to update the documentation files +(usage.txt and/or cjpeg.1, djpeg.1) to agree with what you've done. + +If access to "short" arrays is slow on your machine, it may be a win to +define type JCOEF as int rather than short. This will cost a good deal of +memory though, particularly in some multi-pass modes, so don't do it unless +you have memory to burn and short is REALLY slow. + +If your compiler can compile function calls in-line, make sure the INLINE +macro in jmorecfg.h is defined as the keyword that marks a function +inline-able. Some compilers have a switch that tells the compiler to inline +any function it thinks is profitable (e.g., -finline-functions for gcc). +Enabling such a switch is likely to make the compiled code bigger but faster. + +In general, it's worth trying the maximum optimization level of your compiler, +and experimenting with any optional optimizations such as loop unrolling. +(Unfortunately, far too many compilers have optimizer bugs ... be prepared to +back off if the code fails self-test.) If you do any experimentation along +these lines, please report the optimal settings to jpeg-info@jpegclub.org so +we can mention them in future releases. Be sure to specify your machine and +compiler version. + + +HINTS FOR SPECIFIC SYSTEMS +========================== + +We welcome reports on changes needed for systems not mentioned here. Submit +'em to jpeg-info@jpegclub.org. Also, if configure or ckconfig.c is wrong +about how to configure the JPEG software for your system, please let us know. + + +Acorn RISC OS: + +(Thanks to Simon Middleton for these hints on compiling with Desktop C.) +After renaming the files according to Acorn conventions, take a copy of +makefile.ansi, change all occurrences of 'libjpeg.a' to 'libjpeg.o' and +change these definitions as indicated: + +CFLAGS= -throwback -IC: -Wn +LDLIBS=C:o.Stubs +SYSDEPMEM=jmemansi.o +LN=Link +AR=LibFile -c -o + +Also add a new line '.c.o:; $(cc) $< $(cflags) -c -o $@'. Remove the +lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h' +dependency section. + +Copy jconfig.txt to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE +and CHAR_IS_UNSIGNED. + +Run the makefile using !AMU not !Make. If you want to use the 'clean' and +'test' makefile entries then you will have to fiddle with the syntax a bit +and rename the test files. + + +Amiga: + +SAS C 6.50 reportedly is too buggy to compile the IJG code properly. +A patch to update to 6.51 is available from SAS or AmiNet FTP sites. + +The supplied config files are set up to use jmemname.c as the memory +manager, with temporary files being created on the device named by +"JPEGTMP:". + + +Atari ST/STE/TT: + +Copy the project files makcjpeg.st, makdjpeg.st, maktjpeg.st, and makljpeg.st +to cjpeg.prj, djpeg.prj, jpegtran.prj, and libjpeg.prj respectively. The +project files should work as-is with Pure C. For Turbo C, change library +filenames "pc..." to "tc..." in each project file. Note that libjpeg.prj +selects jmemansi.c as the recommended memory manager. You'll probably want to +adjust the DEFAULT_MAX_MEM setting --- you want it to be a couple hundred K +less than your normal free memory. Put "#define DEFAULT_MAX_MEM nnnn" into +jconfig.h to do this. + +To use the 68881/68882 coprocessor for the floating point DCT, add the +compiler option "-8" to the project files and replace pcfltlib.lib with +pc881lib.lib in cjpeg.prj and djpeg.prj. Or if you don't have a +coprocessor, you may prefer to remove the float DCT code by undefining +DCT_FLOAT_SUPPORTED in jmorecfg.h (since without a coprocessor, the float +code will be too slow to be useful). In that case, you can delete +pcfltlib.lib from the project files. + +Note that you must make libjpeg.lib before making cjpeg.ttp, djpeg.ttp, +or jpegtran.ttp. You'll have to perform the self-test by hand. + +We haven't bothered to include project files for rdjpgcom and wrjpgcom. +Those source files should just be compiled by themselves; they don't +depend on the JPEG library. You can use the default.prj project file +of the Pure C distribution to make the programs. + +There is a bug in some older versions of the Turbo C library which causes the +space used by temporary files created with "tmpfile()" not to be freed after +an abnormal program exit. If you check your disk afterwards, you will find +cluster chains that are allocated but not used by a file. This should not +happen in cjpeg/djpeg/jpegtran, since we enable a signal catcher to explicitly +close temp files before exiting. But if you use the JPEG library with your +own code, be sure to supply a signal catcher, or else use a different +system-dependent memory manager. + + +Cray: + +Should you be so fortunate as to be running JPEG on a Cray YMP, there is a +compiler bug in old versions of Cray's Standard C (prior to 3.1). If you +still have an old compiler, you'll need to insert a line reading +"#pragma novector" just before the loop + for (i = 1; i <= (int) htbl->bits[l]; i++) + huffsize[p++] = (char) l; +in fix_huff_tbl (in V5beta1, line 204 of jchuff.c and line 176 of jdhuff.c). +[This bug may or may not still occur with the current IJG code, but it's +probably a dead issue anyway...] + + +HP-UX: + +If you have HP-UX 7.05 or later with the "software development" C compiler, +you should run the compiler in ANSI mode. If using the configure script, +say + ./configure CC='cc -Aa' +(or -Ae if you prefer). If configuring by hand, use makefile.ansi and add +"-Aa" to the CFLAGS line in the makefile. + +If you have a pre-7.05 system, or if you are using the non-ANSI C compiler +delivered with a minimum HP-UX system, then you must use makefile.unix +(and do NOT add -Aa); or just run configure without the CC option. + +On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior +to A.08.07. If you get complaints about "not a typedef name", you'll have to +use makefile.unix, or run configure without the CC option. + + +Macintosh, generic comments: + +The supplied user-interface files (cjpeg.c, djpeg.c, etc) are set up to +provide a Unix-style command line interface. You can use this interface on +the Mac by means of the ccommand() library routine provided by Metrowerks +CodeWarrior or Think C. This is only appropriate for testing the library, +however; to make a user-friendly equivalent of cjpeg/djpeg you'd really want +to develop a Mac-style user interface. There isn't a complete example +available at the moment, but there are some helpful starting points: +1. Sam Bushell's free "To JPEG" applet provides drag-and-drop conversion to +JPEG under System 7 and later. This only illustrates how to use the +compression half of the library, but it does a very nice job of that part. +The CodeWarrior source code is available from http://www.pobox.com/~jsam. +2. Jim Brunner prepared a Mac-style user interface for both compression and +decompression. Unfortunately, it hasn't been updated since IJG v4, and +the library's API has changed considerably since then. Still it may be of +some help, particularly as a guide to compiling the IJG code under Think C. +Jim's code is available from the Info-Mac archives, at sumex-aim.stanford.edu +or mirrors thereof; see file /info-mac/dev/src/jpeg-convert-c.hqx. + +jmemmac.c is the recommended memory manager back end for Macintosh. It uses +NewPtr/DisposePtr instead of malloc/free, and has a Mac-specific +implementation of jpeg_mem_available(). It also creates temporary files that +follow Mac conventions. (That part of the code relies on System-7-or-later OS +functions. See the comments in jmemmac.c if you need to run it on System 6.) +NOTE that USE_MAC_MEMMGR must be defined in jconfig.h to use jmemmac.c. + +You can also use jmemnobs.c, if you don't care about handling images larger +than available memory. If you use any memory manager back end other than +jmemmac.c, we recommend replacing "malloc" and "free" by "NewPtr" and +"DisposePtr", because Mac C libraries often have peculiar implementations of +malloc/free. (For instance, free() may not return the freed space to the +Mac Memory Manager. This is undesirable for the IJG code because jmemmgr.c +already clumps space requests.) + + +Macintosh, Metrowerks CodeWarrior: + +The Unix-command-line-style interface can be used by defining USE_CCOMMAND. +You'll also need to define TWO_FILE_COMMANDLINE to avoid stdin/stdout. +This means that when using the cjpeg/djpeg programs, you'll have to type the +input and output file names in the "Arguments" text-edit box, rather than +using the file radio buttons. (Perhaps USE_FDOPEN or USE_SETMODE would +eliminate the problem, but I haven't heard from anyone who's tried it.) + +On 680x0 Macs, Metrowerks defines type "double" as a 10-byte IEEE extended +float. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power +of 2. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. + +The supplied configuration file jconfig.mac can be used for your jconfig.h; +it includes all the recommended symbol definitions. If you have AppleScript +installed, you can run the supplied script makeproj.mac to create CodeWarrior +project files for the library and the testbed applications, then build the +library and applications. (Thanks to Dan Sears and Don Agro for this nifty +hack, which saves us from trying to maintain CodeWarrior project files as part +of the IJG distribution...) + + +Macintosh, Think C: + +The documentation in Jim Brunner's "JPEG Convert" source code (see above) +includes detailed build instructions for Think C; it's probably somewhat +out of date for the current release, but may be helpful. + +If you want to build the minimal command line version, proceed as follows. +You'll have to prepare project files for the programs; we don't include any +in the distribution since they are not text files. Use the file lists in +any of the supplied makefiles as a guide. Also add the ANSI and Unix C +libraries in a separate segment. You may need to divide the JPEG files into +more than one segment; we recommend dividing compression and decompression +modules. Define USE_CCOMMAND in jconfig.h so that the ccommand() routine is +called. You must also define TWO_FILE_COMMANDLINE because stdin/stdout +don't handle binary data correctly. + +On 680x0 Macs, Think C defines type "double" as a 12-byte IEEE extended float. +jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power of 2. +Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. + +jconfig.mac should work as a jconfig.h configuration file for Think C, +but the makeproj.mac AppleScript script is specific to CodeWarrior. Sorry. + + +MIPS R3000: + +MIPS's cc version 1.31 has a rather nasty optimization bug. Don't use -O +if you have that compiler version. (Use "cc -V" to check the version.) +Note that the R3000 chip is found in workstations from DEC and others. + + +MS-DOS, generic comments for 16-bit compilers: + +The IJG code is designed to work well in 80x86 "small" or "medium" memory +models (i.e., data pointers are 16 bits unless explicitly declared "far"; +code pointers can be either size). You may be able to use small model to +compile cjpeg or djpeg by itself, but you will probably have to use medium +model for any larger application. This won't make much difference in +performance. You *will* take a noticeable performance hit if you use a +large-data memory model, and you should avoid "huge" model if at all +possible. Be sure that NEED_FAR_POINTERS is defined in jconfig.h if you use +a small-data memory model; be sure it is NOT defined if you use a large-data +model. (The supplied makefiles and jconfig files for Borland and Microsoft C +compile in medium model and define NEED_FAR_POINTERS.) + +The DOS-specific memory manager, jmemdos.c, should be used if possible. +It needs some assembly-code routines which are in jmemdosa.asm; make sure +your makefile assembles that file and includes it in the library. If you +don't have a suitable assembler, you can get pre-assembled object files for +jmemdosa by FTP from ftp.uu.net:/graphics/jpeg/jdosaobj.zip. (DOS-oriented +distributions of the IJG source code often include these object files.) + +When using jmemdos.c, jconfig.h must define USE_MSDOS_MEMMGR and must set +MAX_ALLOC_CHUNK to less than 64K (65520L is a typical value). If your +C library's far-heap malloc() can't allocate blocks that large, reduce +MAX_ALLOC_CHUNK to whatever it can handle. + +If you can't use jmemdos.c for some reason --- for example, because you +don't have an assembler to assemble jmemdosa.asm --- you'll have to fall +back to jmemansi.c or jmemname.c. You'll probably still need to set +MAX_ALLOC_CHUNK in jconfig.h, because most DOS C libraries won't malloc() +more than 64K at a time. IMPORTANT: if you use jmemansi.c or jmemname.c, +you will have to compile in a large-data memory model in order to get the +right stdio library. Too bad. + +wrjpgcom needs to be compiled in large model, because it malloc()s a 64KB +work area to hold the comment text. If your C library's malloc can't +handle that, reduce MAX_COM_LENGTH as necessary in wrjpgcom.c. + +Most MS-DOS compilers treat stdin/stdout as text files, so you must use +two-file command line style. But if your compiler has either fdopen() or +setmode(), you can use one-file style if you like. To do this, define +USE_SETMODE or USE_FDOPEN so that stdin/stdout will be set to binary mode. +(USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.) You +should test that I/O through stdin/stdout produces the same results as I/O +to explicitly named files... the "make test" procedures in the supplied +makefiles do NOT use stdin/stdout. + + +MS-DOS, generic comments for 32-bit compilers: + +None of the above comments about memory models apply if you are using a +32-bit flat-memory-space environment, such as DJGPP or Watcom C. (And you +should use one if you have it, as performance will be much better than +8086-compatible code!) For flat-memory-space compilers, do NOT define +NEED_FAR_POINTERS, and do NOT use jmemdos.c. Use jmemnobs.c if the +environment supplies adequate virtual memory, otherwise use jmemansi.c or +jmemname.c. + +You'll still need to be careful about binary I/O through stdin/stdout. +See the last paragraph of the previous section. + + +MS-DOS, Borland C: + +Be sure to convert all the source files to DOS text format (CR/LF newlines). +Although Borland C will often work OK with unmodified Unix (LF newlines) +source files, sometimes it will give bogus compile errors. +"Illegal character '#'" is the most common such error. (This is true with +Borland C 3.1, but perhaps is fixed in newer releases.) + +If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. +jconfig.bcc already includes #define USE_SETMODE to make this work. +(fdopen does not work correctly.) + + +MS-DOS, Microsoft C: + +makefile.mc6 works with Microsoft C, DOS Visual C++, etc. It should only +be used if you want to build a 16-bit (small or medium memory model) program. + +If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. +jconfig.mc6 already includes #define USE_SETMODE to make this work. +(fdopen does not work correctly.) + +Note that this makefile assumes that the working copy of itself is called +"makefile". If you want to call it something else, say "makefile.mak", +be sure to adjust the dependency line that reads "$(RFILE) : makefile". +Otherwise the make will fail because it doesn't know how to create "makefile". +Worse, some releases of Microsoft's make utilities give an incorrect error +message in this situation. + +Old versions of MS C fail with an "out of macro expansion space" error +because they can't cope with the macro TRACEMS8 (defined in jerror.h). +If this happens to you, the easiest solution is to change TRACEMS8 to +expand to nothing. You'll lose the ability to dump out JPEG coefficient +tables with djpeg -debug -debug, but at least you can compile. + +Original MS C 6.0 is very buggy; it compiles incorrect code unless you turn +off optimization entirely (remove -O from CFLAGS). 6.00A is better, but it +still generates bad code if you enable loop optimizations (-Ol or -Ox). + +MS C 8.0 crashes when compiling jquant1.c with optimization switch /Oo ... +which is on by default. To work around this bug, compile that one file +with /Oo-. + + +Microsoft Windows (all versions), generic comments: + +Some Windows system include files define typedef boolean as "unsigned char". +The IJG code also defines typedef boolean, but we make it an "enum" by default. +This doesn't affect the IJG programs because we don't import those Windows +include files. But if you use the JPEG library in your own program, and some +of your program's files import one definition of boolean while some import the +other, you can get all sorts of mysterious problems. A good preventive step +is to make the IJG library use "unsigned char" for boolean. To do that, +add something like this to your jconfig.h file: + /* Define "boolean" as unsigned char, not enum, per Windows custom */ + #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ + typedef unsigned char boolean; + #endif + #ifndef FALSE /* in case these macros already exist */ + #define FALSE 0 /* values of boolean */ + #endif + #ifndef TRUE + #define TRUE 1 + #endif + #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ +(This is already in jconfig.vc, by the way.) + +windef.h contains the declarations + #define far + #define FAR far +Since jmorecfg.h tries to define FAR as empty, you may get a compiler +warning if you include both jpeglib.h and windef.h (which windows.h +includes). To suppress the warning, you can put "#ifndef FAR"/"#endif" +around the line "#define FAR" in jmorecfg.h. +(Something like this is already in jmorecfg.h, by the way.) + +When using the library in a Windows application, you will almost certainly +want to modify or replace the error handler module jerror.c, since our +default error handler does a couple of inappropriate things: + 1. it tries to write error and warning messages on stderr; + 2. in event of a fatal error, it exits by calling exit(). + +A simple stopgap solution for problem 1 is to replace the line + fprintf(stderr, "%s\n", buffer); +(in output_message in jerror.c) with + MessageBox(GetActiveWindow(),buffer,"JPEG Error",MB_OK|MB_ICONERROR); +It's highly recommended that you at least do that much, since otherwise +error messages will disappear into nowhere. (Beginning with IJG v6b, this +code is already present in jerror.c; just define USE_WINDOWS_MESSAGEBOX in +jconfig.h to enable it.) + +The proper solution for problem 2 is to return control to your calling +application after a library error. This can be done with the setjmp/longjmp +technique discussed in libjpeg.txt and illustrated in example.c. (NOTE: +some older Windows C compilers provide versions of setjmp/longjmp that +don't actually work under Windows. You may need to use the Windows system +functions Catch and Throw instead.) + +The recommended memory manager under Windows is jmemnobs.c; in other words, +let Windows do any virtual memory management needed. You should NOT use +jmemdos.c nor jmemdosa.asm under Windows. + +For Windows 3.1, we recommend compiling in medium or large memory model; +for newer Windows versions, use a 32-bit flat memory model. (See the MS-DOS +sections above for more info about memory models.) In the 16-bit memory +models only, you'll need to put + #define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ +into jconfig.h to limit allocation chunks to 64Kb. (Without that, you'd +have to use huge memory model, which slows things down unnecessarily.) +jmemnobs.c works without modification in large or flat memory models, but to +use medium model, you need to modify its jpeg_get_large and jpeg_free_large +routines to allocate far memory. In any case, you might like to replace +its calls to malloc and free with direct calls on Windows memory allocation +functions. + +You may also want to modify jdatasrc.c and jdatadst.c to use Windows file +operations rather than fread/fwrite. This is only necessary if your C +compiler doesn't provide a competent implementation of C stdio functions. + +You might want to tweak the RGB_xxx macros in jmorecfg.h so that the library +will accept or deliver color pixels in BGR sample order, not RGB; BGR order +is usually more convenient under Windows. Note that this change will break +the sample applications cjpeg/djpeg, but the library itself works fine. + + +Many people want to convert the IJG library into a DLL. This is reasonably +straightforward, but watch out for the following: + + 1. Don't try to compile as a DLL in small or medium memory model; use +large model, or even better, 32-bit flat model. Many places in the IJG code +assume the address of a local variable is an ordinary (not FAR) pointer; +that isn't true in a medium-model DLL. + + 2. Microsoft C cannot pass file pointers between applications and DLLs. +(See Microsoft Knowledge Base, PSS ID Number Q50336.) So jdatasrc.c and +jdatadst.c don't work if you open a file in your application and then pass +the pointer to the DLL. One workaround is to make jdatasrc.c/jdatadst.c +part of your main application rather than part of the DLL. + + 3. You'll probably need to modify the macros GLOBAL() and EXTERN() to +attach suitable linkage keywords to the exported routine names. Similarly, +you'll want to modify METHODDEF() and JMETHOD() to ensure function pointers +are declared in a way that lets application routines be called back through +the function pointers. These macros are in jmorecfg.h. Typical definitions +for a 16-bit DLL are: + #define GLOBAL(type) type _far _pascal _loadds _export + #define EXTERN(type) extern type _far _pascal _loadds + #define METHODDEF(type) static type _far _pascal + #define JMETHOD(type,methodname,arglist) \ + type (_far _pascal *methodname) arglist +For a 32-bit DLL you may want something like + #define GLOBAL(type) __declspec(dllexport) type + #define EXTERN(type) extern __declspec(dllexport) type +Although not all the GLOBAL routines are actually intended to be called by +the application, the performance cost of making them all DLL entry points is +negligible. + +The unmodified IJG library presents a very C-specific application interface, +so the resulting DLL is only usable from C or C++ applications. There has +been some talk of writing wrapper code that would present a simpler interface +usable from other languages, such as Visual Basic. This is on our to-do list +but hasn't been very high priority --- any volunteers out there? + + +Microsoft Windows, Borland C: + +The provided jconfig.bcc should work OK in a 32-bit Windows environment, +but you'll need to tweak it in a 16-bit environment (you'd need to define +NEED_FAR_POINTERS and MAX_ALLOC_CHUNK). Beware that makefile.bcc will need +alteration if you want to use it for Windows --- in particular, you should +use jmemnobs.c not jmemdos.c under Windows. + +Borland C++ 4.5 fails with an internal compiler error when trying to compile +jdmerge.c in 32-bit mode. If enough people complain, perhaps Borland will fix +it. In the meantime, the simplest known workaround is to add a redundant +definition of the variable range_limit in h2v1_merged_upsample(), at the head +of the block that handles odd image width (about line 268 in v6 jdmerge.c): + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + register JSAMPLE * range_limit = cinfo->sample_range_limit; /* ADD THIS */ + cb = GETJSAMPLE(*inptr1); +Pretty bizarre, especially since the very similar routine h2v2_merged_upsample +doesn't trigger the bug. +Recent reports suggest that this bug does not occur with "bcc32a" (the +Pentium-optimized version of the compiler). + +Another report from a user of Borland C 4.5 was that incorrect code (leading +to a color shift in processed images) was produced if any of the following +optimization switch combinations were used: + -Ot -Og + -Ot -Op + -Ot -Om +So try backing off on optimization if you see such a problem. (Are there +several different releases all numbered "4.5"??) + + +Microsoft Windows, Microsoft Visual C++: + +jconfig.vc should work OK with any Microsoft compiler for a 32-bit memory +model. makefile.vc is intended for command-line use. (If you are using +the Developer Studio environment, you may prefer the DevStudio project +files; see below.) + +IJG JPEG 7 adds extern "C" to jpeglib.h. This avoids the need to put +extern "C" { ... } around #include "jpeglib.h" in your C++ application. +You can also force VC++ to treat the library as C++ code by renaming +all the *.c files to *.cpp (and adjusting the makefile to match). +In this case you also need to define the symbol DONT_USE_EXTERN_C in +the configuration to prevent jpeglib.h from using extern "C". + + +Microsoft Windows, Microsoft Visual C++ 6 Developer Studio: + +We include makefiles that should work as project files in Developer Studio +6.0 or later. There is a library makefile that builds the IJG library as +a static Win32 library, and application makefiles that build the sample +applications as Win32 console applications. (Even if you only want the +library, we recommend building the applications so that you can run the +self-test.) + +To use: +1. Open the Windows Command Prompt, change to the source directory and + execute the command line + nmake /f makefile.vs setup-vc6 + If you get an error message saying that the "nmake" command could + not be found, execute the command + "%ProgramFiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32" + to set the environment for using Microsoft Visual C++ tools, + and repeat the nmake call. + This will move jconfig.vc to jconfig.h and makefiles to project files. + (Note that the renaming is critical!) + Alternatively you can use + nmake /f makefile.vs setupcopy-vc6 + This will create renamed copies of the files, which allows to repeat + the setup later. +2. Open the workspace file jpeg.dsw, build the library project. + (If you are using Developer Studio more recent than 6.0, you'll + probably get a message saying that the project files are being updated.) +3. Open the workspace file apps.dsw, build the application projects. +4. To perform the self-test, execute the command line + nmake /f makefile.vs test-build +5. Move the application .exe files from the Release folder to an + appropriate location on your path. + + +Microsoft Windows, Visual Studio 2019 Version 16: + +We include makefiles that should work as project files in Visual Studio +2019 Version 16 or later. There is a library makefile that builds the +IJG library as a static Win32/x64/ARM/ARM64 library, and application +makefiles that build the sample applications as Win32/x64/ARM/ARM64 +console applications. (Even if you only want the library, we recommend +building the applications so that you can run the self-test.) + +To use: +1. Ensure you’ve checked the item "Desktop development with C++" in the + Workloads tab of Visual Studio Installer. + Open the Developer Command Prompt for VS 2019, change to the source + directory and execute the command line + nmake /f makefile.vs setup-v16 + This will move jconfig.vc to jconfig.h and makefiles to project files. + (Note that the renaming is critical!) + Alternatively you can use + nmake /f makefile.vs setupcopy-v16 + This will create renamed copies of the files, which allows to repeat + the setup later. +2. Open the solution file jpeg.sln, build the library project. + a) If you are using Visual Studio more recent than + 2019 Version 16, you'll probably get a message + saying that the project files are being updated. + b) If necessary, open the project properties and + adapt the Windows Target Platform Version in + the Configuration Properties, General section; + we support the latest version at the time of release. + c) If you get a warning saying that a platform cannot be found, + you can either + * forgo the platform and ignore the warning, or + * remove the platform in the Configuration Manager, or + * install the corresponding platform Buildtools in + Visual Studio Installer (Workloads tab Optional components + or Individual components tab). + d) If you want to build x64 code, change the platform setting from + Win32 to x64. You can build Win32 and x64 versions side by side. + e) If you want to build ARM/ARM64 code, change the platform setting + to ARM/ARM64. Ensure you've installed the ARM/ARM64-Buildtools + in Visual Studio Installer (Workloads tab Optional components + or Individual components tab). + You can build Win32/x64/ARM/ARM64 versions side by side. +3. Open the solution file apps.sln, build the application projects. +4. To perform the self-test, execute the command line + nmake /f makefile.vs test-32 + for the Win32 build, or on a 64-bit system + nmake /f makefile.vs test-64 + for the x64 build. +5. Move the application .exe files from the Release folder to an + appropriate location on your path. + + +Microsoft Windows, Visual Studio 2022 Version 17: + +We include makefiles that should work as project files in Visual Studio +2022 Version 17 or later. There is a library makefile that builds the +IJG library as a static Win32/x64/ARM/ARM64 library, and application +makefiles that build the sample applications as Win32/x64/ARM/ARM64 +console applications. (Even if you only want the library, we recommend +building the applications so that you can run the self-test.) + +To use: +1. Ensure you’ve checked the item "Desktop development with C++" in the + Workloads tab of Visual Studio Installer. + Open the Developer Command Prompt for VS 2022, change to the source + directory and execute the command line + nmake /f makefile.vs setup-v17 + This will move jconfig.vc to jconfig.h and makefiles to project files. + (Note that the renaming is critical!) + Alternatively you can use + nmake /f makefile.vs setupcopy-v17 + This will create renamed copies of the files, which allows to repeat + the setup later. +2. Open the solution file jpeg.sln, build the library project. + a) If you are using Visual Studio more recent than + 2022 Version 17, you'll probably get a message + saying that the project files are being updated. + b) If necessary, open the project properties and + adapt the Windows Target Platform Version in + the Configuration Properties, General section; + we support the latest version at the time of release. + c) If you get a warning saying that a platform cannot be found, + you can either + * forgo the platform and ignore the warning, or + * remove the platform in the Configuration Manager, or + * install the corresponding platform Buildtools in + Visual Studio Installer (Workloads tab Optional components + or Individual components tab). + d) If you want to build x64 code, change the platform setting from + Win32 to x64. You can build Win32 and x64 versions side by side. + e) If you want to build ARM/ARM64 code, change the platform setting + to ARM/ARM64. Ensure you've installed the ARM/ARM64-Buildtools + in Visual Studio Installer (Workloads tab Optional components + or Individual components tab). + You can build Win32/x64/ARM/ARM64 versions side by side. +3. Open the solution file apps.sln, build the application projects. +4. To perform the self-test, execute the command line + nmake /f makefile.vs test-32 + for the Win32 build, or on a 64-bit system + nmake /f makefile.vs test-64 + for the x64 build. +5. Move the application .exe files from the Release folder to an + appropriate location on your path. + + +OS/2, Borland C++: + +Watch out for optimization bugs in older Borland compilers; you may need +to back off the optimization switch settings. See the comments in +makefile.bcc. + + +SGI: + +On some SGI systems, you may need to set "AR2= ar -ts" in the Makefile. +If you are using configure, you can do this by saying + ./configure RANLIB='ar -ts' +This change is not needed on all SGIs. Use it only if the make fails at the +stage of linking the completed programs. + +On the MIPS R4000 architecture (Indy, etc.), the compiler option "-mips2" +reportedly speeds up the float DCT method substantially, enough to make it +faster than the default int method (but still slower than the fast int +method). If you use -mips2, you may want to alter the default DCT method to +be float. To do this, put "#define JDCT_DEFAULT JDCT_FLOAT" in jconfig.h. + + +VMS: + +On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1" +qualifier with MMS when building the JPEG package. + +VAX/VMS v5.5-1 may have problems with the test step of the build procedure +reporting differences when it compares the original and test images. If the +error points to the last block of the files, it is most likely bogus and may +be safely ignored. It seems to be because the files are Stream_LF and +Backup/Compare has difficulty with the (presumably) null padded files. +This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1. diff --git a/thirdparty/jpeg-9e/jaricom.c b/thirdparty/jpeg-9e/jaricom.c new file mode 100644 index 0000000..6900688 --- /dev/null +++ b/thirdparty/jpeg-9e/jaricom.c @@ -0,0 +1,153 @@ +/* + * jaricom.c + * + * Developed 1997-2011 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains probability estimation tables for common use in + * arithmetic entropy encoding and decoding routines. + * + * This data represents Table D.3 in the JPEG spec (D.2 in the draft), + * ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81, and Table 24 + * in the JBIG spec, ISO/IEC IS 11544 and CCITT Recommendation ITU-T T.82. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +/* The following #define specifies the packing of the four components + * into the compact INT32 representation. + * Note that this formula must match the actual arithmetic encoder + * and decoder implementation. The implementation has to be changed + * if this formula is changed. + * The current organization is leaned on Markus Kuhn's JBIG + * implementation (jbig_tab.c). + */ + +#define V(i,a,b,c,d) (((INT32)a << 16) | ((INT32)c << 8) | ((INT32)d << 7) | b) + +const INT32 jpeg_aritab[113+1] = { +/* + * Index, Qe_Value, Next_Index_LPS, Next_Index_MPS, Switch_MPS + */ + V( 0, 0x5a1d, 1, 1, 1 ), + V( 1, 0x2586, 14, 2, 0 ), + V( 2, 0x1114, 16, 3, 0 ), + V( 3, 0x080b, 18, 4, 0 ), + V( 4, 0x03d8, 20, 5, 0 ), + V( 5, 0x01da, 23, 6, 0 ), + V( 6, 0x00e5, 25, 7, 0 ), + V( 7, 0x006f, 28, 8, 0 ), + V( 8, 0x0036, 30, 9, 0 ), + V( 9, 0x001a, 33, 10, 0 ), + V( 10, 0x000d, 35, 11, 0 ), + V( 11, 0x0006, 9, 12, 0 ), + V( 12, 0x0003, 10, 13, 0 ), + V( 13, 0x0001, 12, 13, 0 ), + V( 14, 0x5a7f, 15, 15, 1 ), + V( 15, 0x3f25, 36, 16, 0 ), + V( 16, 0x2cf2, 38, 17, 0 ), + V( 17, 0x207c, 39, 18, 0 ), + V( 18, 0x17b9, 40, 19, 0 ), + V( 19, 0x1182, 42, 20, 0 ), + V( 20, 0x0cef, 43, 21, 0 ), + V( 21, 0x09a1, 45, 22, 0 ), + V( 22, 0x072f, 46, 23, 0 ), + V( 23, 0x055c, 48, 24, 0 ), + V( 24, 0x0406, 49, 25, 0 ), + V( 25, 0x0303, 51, 26, 0 ), + V( 26, 0x0240, 52, 27, 0 ), + V( 27, 0x01b1, 54, 28, 0 ), + V( 28, 0x0144, 56, 29, 0 ), + V( 29, 0x00f5, 57, 30, 0 ), + V( 30, 0x00b7, 59, 31, 0 ), + V( 31, 0x008a, 60, 32, 0 ), + V( 32, 0x0068, 62, 33, 0 ), + V( 33, 0x004e, 63, 34, 0 ), + V( 34, 0x003b, 32, 35, 0 ), + V( 35, 0x002c, 33, 9, 0 ), + V( 36, 0x5ae1, 37, 37, 1 ), + V( 37, 0x484c, 64, 38, 0 ), + V( 38, 0x3a0d, 65, 39, 0 ), + V( 39, 0x2ef1, 67, 40, 0 ), + V( 40, 0x261f, 68, 41, 0 ), + V( 41, 0x1f33, 69, 42, 0 ), + V( 42, 0x19a8, 70, 43, 0 ), + V( 43, 0x1518, 72, 44, 0 ), + V( 44, 0x1177, 73, 45, 0 ), + V( 45, 0x0e74, 74, 46, 0 ), + V( 46, 0x0bfb, 75, 47, 0 ), + V( 47, 0x09f8, 77, 48, 0 ), + V( 48, 0x0861, 78, 49, 0 ), + V( 49, 0x0706, 79, 50, 0 ), + V( 50, 0x05cd, 48, 51, 0 ), + V( 51, 0x04de, 50, 52, 0 ), + V( 52, 0x040f, 50, 53, 0 ), + V( 53, 0x0363, 51, 54, 0 ), + V( 54, 0x02d4, 52, 55, 0 ), + V( 55, 0x025c, 53, 56, 0 ), + V( 56, 0x01f8, 54, 57, 0 ), + V( 57, 0x01a4, 55, 58, 0 ), + V( 58, 0x0160, 56, 59, 0 ), + V( 59, 0x0125, 57, 60, 0 ), + V( 60, 0x00f6, 58, 61, 0 ), + V( 61, 0x00cb, 59, 62, 0 ), + V( 62, 0x00ab, 61, 63, 0 ), + V( 63, 0x008f, 61, 32, 0 ), + V( 64, 0x5b12, 65, 65, 1 ), + V( 65, 0x4d04, 80, 66, 0 ), + V( 66, 0x412c, 81, 67, 0 ), + V( 67, 0x37d8, 82, 68, 0 ), + V( 68, 0x2fe8, 83, 69, 0 ), + V( 69, 0x293c, 84, 70, 0 ), + V( 70, 0x2379, 86, 71, 0 ), + V( 71, 0x1edf, 87, 72, 0 ), + V( 72, 0x1aa9, 87, 73, 0 ), + V( 73, 0x174e, 72, 74, 0 ), + V( 74, 0x1424, 72, 75, 0 ), + V( 75, 0x119c, 74, 76, 0 ), + V( 76, 0x0f6b, 74, 77, 0 ), + V( 77, 0x0d51, 75, 78, 0 ), + V( 78, 0x0bb6, 77, 79, 0 ), + V( 79, 0x0a40, 77, 48, 0 ), + V( 80, 0x5832, 80, 81, 1 ), + V( 81, 0x4d1c, 88, 82, 0 ), + V( 82, 0x438e, 89, 83, 0 ), + V( 83, 0x3bdd, 90, 84, 0 ), + V( 84, 0x34ee, 91, 85, 0 ), + V( 85, 0x2eae, 92, 86, 0 ), + V( 86, 0x299a, 93, 87, 0 ), + V( 87, 0x2516, 86, 71, 0 ), + V( 88, 0x5570, 88, 89, 1 ), + V( 89, 0x4ca9, 95, 90, 0 ), + V( 90, 0x44d9, 96, 91, 0 ), + V( 91, 0x3e22, 97, 92, 0 ), + V( 92, 0x3824, 99, 93, 0 ), + V( 93, 0x32b4, 99, 94, 0 ), + V( 94, 0x2e17, 93, 86, 0 ), + V( 95, 0x56a8, 95, 96, 1 ), + V( 96, 0x4f46, 101, 97, 0 ), + V( 97, 0x47e5, 102, 98, 0 ), + V( 98, 0x41cf, 103, 99, 0 ), + V( 99, 0x3c3d, 104, 100, 0 ), + V( 100, 0x375e, 99, 93, 0 ), + V( 101, 0x5231, 105, 102, 0 ), + V( 102, 0x4c0f, 106, 103, 0 ), + V( 103, 0x4639, 107, 104, 0 ), + V( 104, 0x415e, 103, 99, 0 ), + V( 105, 0x5627, 105, 106, 1 ), + V( 106, 0x50e7, 108, 107, 0 ), + V( 107, 0x4b85, 109, 103, 0 ), + V( 108, 0x5597, 110, 109, 0 ), + V( 109, 0x504f, 111, 107, 0 ), + V( 110, 0x5a10, 110, 111, 1 ), + V( 111, 0x5522, 112, 109, 0 ), + V( 112, 0x59eb, 112, 111, 1 ), +/* + * This last entry is used for fixed probability estimate of 0.5 + * as suggested in Section 10.3 Table 5 of ITU-T Rec. T.851. + */ + V( 113, 0x5a1d, 113, 113, 0 ) +}; diff --git a/thirdparty/jpeg-9e/jcapimin.c b/thirdparty/jpeg-9e/jcapimin.c new file mode 100644 index 0000000..639ce86 --- /dev/null +++ b/thirdparty/jpeg-9e/jcapimin.c @@ -0,0 +1,288 @@ +/* + * jcapimin.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * Modified 2003-2010 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the compression half + * of the JPEG library. These are the "minimum" API routines that may be + * needed in either the normal full-compression case or the transcoding-only + * case. + * + * Most of the routines intended to be called directly by an application + * are in this file or in jcapistd.c. But also see jcparam.c for + * parameter-setup helper routines, jcomapi.c for routines shared by + * compression and decompression, and jctrans.c for the transcoding case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Initialization of a JPEG compression object. + * The error manager must already be set up (in case memory manager fails). + */ + +GLOBAL(void) +jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize) +{ + int i; + + /* Guard against version mismatches between library and caller. */ + cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ + if (version != JPEG_LIB_VERSION) + ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); + if (structsize != SIZEOF(struct jpeg_compress_struct)) + ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, + (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); + + /* For debugging purposes, we zero the whole master structure. + * But the application has already set the err pointer, and may have set + * client_data, so we have to save and restore those fields. + * Note: if application hasn't set client_data, tools like Purify may + * complain here. + */ + { + struct jpeg_error_mgr * err = cinfo->err; + void * client_data = cinfo->client_data; /* ignore Purify complaint here */ + MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); + cinfo->err = err; + cinfo->client_data = client_data; + } + cinfo->is_decompressor = FALSE; + + /* Initialize a memory manager instance for this object */ + jinit_memory_mgr((j_common_ptr) cinfo); + + /* Zero out pointers to permanent structures. */ + cinfo->progress = NULL; + cinfo->dest = NULL; + + cinfo->comp_info = NULL; + + for (i = 0; i < NUM_QUANT_TBLS; i++) { + cinfo->quant_tbl_ptrs[i] = NULL; + cinfo->q_scale_factor[i] = 100; + } + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + cinfo->dc_huff_tbl_ptrs[i] = NULL; + cinfo->ac_huff_tbl_ptrs[i] = NULL; + } + + /* Must do it here for emit_dqt in case jpeg_write_tables is used */ + cinfo->block_size = DCTSIZE; + cinfo->natural_order = jpeg_natural_order; + cinfo->lim_Se = DCTSIZE2-1; + + cinfo->script_space = NULL; + + cinfo->input_gamma = 1.0; /* in case application forgets */ + + /* OK, I'm ready */ + cinfo->global_state = CSTATE_START; +} + + +/* + * Destruction of a JPEG compression object + */ + +GLOBAL(void) +jpeg_destroy_compress (j_compress_ptr cinfo) +{ + jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Abort processing of a JPEG compression operation, + * but don't destroy the object itself. + */ + +GLOBAL(void) +jpeg_abort_compress (j_compress_ptr cinfo) +{ + jpeg_abort((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Forcibly suppress or un-suppress all quantization and Huffman tables. + * Marks all currently defined tables as already written (if suppress) + * or not written (if !suppress). This will control whether they get emitted + * by a subsequent jpeg_start_compress call. + * + * This routine is exported for use by applications that want to produce + * abbreviated JPEG datastreams. It logically belongs in jcparam.c, but + * since it is called by jpeg_start_compress, we put it here --- otherwise + * jcparam.o would be linked whether the application used it or not. + */ + +GLOBAL(void) +jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress) +{ + int i; + JQUANT_TBL * qtbl; + JHUFF_TBL * htbl; + + for (i = 0; i < NUM_QUANT_TBLS; i++) { + if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) + qtbl->sent_table = suppress; + } + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) + htbl->sent_table = suppress; + if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL) + htbl->sent_table = suppress; + } +} + + +/* + * Finish JPEG compression. + * + * If a multipass operating mode was selected, this may do a great deal of + * work including most of the actual output. + */ + +GLOBAL(void) +jpeg_finish_compress (j_compress_ptr cinfo) +{ + JDIMENSION iMCU_row; + + if (cinfo->global_state == CSTATE_SCANNING || + cinfo->global_state == CSTATE_RAW_OK) { + /* Terminate first pass */ + if (cinfo->next_scanline < cinfo->image_height) + ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); + (*cinfo->master->finish_pass) (cinfo); + } else if (cinfo->global_state != CSTATE_WRCOEFS) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Perform any remaining passes */ + while (! cinfo->master->is_last_pass) { + (*cinfo->master->prepare_for_pass) (cinfo); + for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) { + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) iMCU_row; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + /* We bypass the main controller and invoke coef controller directly; + * all work is being done from the coefficient buffer. + */ + if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } + (*cinfo->master->finish_pass) (cinfo); + } + /* Write EOI, do final cleanup */ + (*cinfo->marker->write_file_trailer) (cinfo); + (*cinfo->dest->term_destination) (cinfo); + /* We can use jpeg_abort to release memory and reset global_state */ + jpeg_abort((j_common_ptr) cinfo); +} + + +/* + * Write a special marker. + * This is only recommended for writing COM or APPn markers. + * Must be called after jpeg_start_compress() and before + * first call to jpeg_write_scanlines() or jpeg_write_raw_data(). + */ + +GLOBAL(void) +jpeg_write_marker (j_compress_ptr cinfo, int marker, + const JOCTET *dataptr, unsigned int datalen) +{ + JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val)); + + if (cinfo->next_scanline != 0 || + (cinfo->global_state != CSTATE_SCANNING && + cinfo->global_state != CSTATE_RAW_OK && + cinfo->global_state != CSTATE_WRCOEFS)) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); + write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */ + while (datalen--) { + (*write_marker_byte) (cinfo, *dataptr); + dataptr++; + } +} + +/* Same, but piecemeal. */ + +GLOBAL(void) +jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen) +{ + if (cinfo->next_scanline != 0 || + (cinfo->global_state != CSTATE_SCANNING && + cinfo->global_state != CSTATE_RAW_OK && + cinfo->global_state != CSTATE_WRCOEFS)) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); +} + +GLOBAL(void) +jpeg_write_m_byte (j_compress_ptr cinfo, int val) +{ + (*cinfo->marker->write_marker_byte) (cinfo, val); +} + + +/* + * Alternate compression function: just write an abbreviated table file. + * Before calling this, all parameters and a data destination must be set up. + * + * To produce a pair of files containing abbreviated tables and abbreviated + * image data, one would proceed as follows: + * + * initialize JPEG object + * set JPEG parameters + * set destination to table file + * jpeg_write_tables(cinfo); + * set destination to image file + * jpeg_start_compress(cinfo, FALSE); + * write data... + * jpeg_finish_compress(cinfo); + * + * jpeg_write_tables has the side effect of marking all tables written + * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress + * will not re-emit the tables unless it is passed write_all_tables=TRUE. + */ + +GLOBAL(void) +jpeg_write_tables (j_compress_ptr cinfo) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Initialize the marker writer ... bit of a crock to do it here. */ + jinit_marker_writer(cinfo); + /* Write them tables! */ + (*cinfo->marker->write_tables_only) (cinfo); + /* And clean up. */ + (*cinfo->dest->term_destination) (cinfo); + /* + * In library releases up through v6a, we called jpeg_abort() here to free + * any working memory allocated by the destination manager and marker + * writer. Some applications had a problem with that: they allocated space + * of their own from the library memory manager, and didn't want it to go + * away during write_tables. So now we do nothing. This will cause a + * memory leak if an app calls write_tables repeatedly without doing a full + * compression cycle or otherwise resetting the JPEG object. However, that + * seems less bad than unexpectedly freeing memory in the normal case. + * An app that prefers the old behavior can call jpeg_abort for itself after + * each call to jpeg_write_tables(). + */ +} diff --git a/thirdparty/jpeg-9e/jcapistd.c b/thirdparty/jpeg-9e/jcapistd.c new file mode 100644 index 0000000..0917afa --- /dev/null +++ b/thirdparty/jpeg-9e/jcapistd.c @@ -0,0 +1,162 @@ +/* + * jcapistd.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2013 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the compression half + * of the JPEG library. These are the "standard" API routines that are + * used in the normal full-compression case. They are not used by a + * transcoding-only application. Note that if an application links in + * jpeg_start_compress, it will end up linking in the entire compressor. + * We thus must separate this file from jcapimin.c to avoid linking the + * whole compression library into a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Compression initialization. + * Before calling this, all parameters and a data destination must be set up. + * + * We require a write_all_tables parameter as a failsafe check when writing + * multiple datastreams from the same compression object. Since prior runs + * will have left all the tables marked sent_table=TRUE, a subsequent run + * would emit an abbreviated stream (no tables) by default. This may be what + * is wanted, but for safety's sake it should not be the default behavior: + * programmers should have to make a deliberate choice to emit abbreviated + * images. Therefore the documentation and examples should encourage people + * to pass write_all_tables=TRUE; then it will take active thought to do the + * wrong thing. + */ + +GLOBAL(void) +jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (write_all_tables) + jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ + + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Perform master selection of active modules */ + jinit_compress_master(cinfo); + /* Set up for the first pass */ + (*cinfo->master->prepare_for_pass) (cinfo); + /* Ready for application to drive first pass through jpeg_write_scanlines + * or jpeg_write_raw_data. + */ + cinfo->next_scanline = 0; + cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING); +} + + +/* + * Write some scanlines of data to the JPEG compressor. + * + * The return value will be the number of lines actually written. + * This should be less than the supplied num_lines only in case that + * the data destination module has requested suspension of the compressor, + * or if more than image_height scanlines are passed in. + * + * Note: we warn about excess calls to jpeg_write_scanlines() since + * this likely signals an application programmer error. However, + * excess scanlines passed in the last valid call are *silently* ignored, + * so that the application need not adjust num_lines for end-of-image + * when using a multiple-scanline buffer. + */ + +GLOBAL(JDIMENSION) +jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, + JDIMENSION num_lines) +{ + JDIMENSION row_ctr, rows_left; + + if (cinfo->global_state != CSTATE_SCANNING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->next_scanline >= cinfo->image_height) + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->next_scanline; + cinfo->progress->pass_limit = (long) cinfo->image_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Give master control module another chance if this is first call to + * jpeg_write_scanlines. This lets output of the frame/scan headers be + * delayed so that application can write COM, etc, markers between + * jpeg_start_compress and jpeg_write_scanlines. + */ + if (cinfo->master->call_pass_startup) + (*cinfo->master->pass_startup) (cinfo); + + /* Ignore any extra scanlines at bottom of image. */ + rows_left = cinfo->image_height - cinfo->next_scanline; + if (num_lines > rows_left) + num_lines = rows_left; + + row_ctr = 0; + (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines); + cinfo->next_scanline += row_ctr; + return row_ctr; +} + + +/* + * Alternate entry point to write raw data. + * Processes exactly one iMCU row per call, unless suspended. + */ + +GLOBAL(JDIMENSION) +jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, + JDIMENSION num_lines) +{ + JDIMENSION lines_per_iMCU_row; + + if (cinfo->global_state != CSTATE_RAW_OK) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->next_scanline >= cinfo->image_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->next_scanline; + cinfo->progress->pass_limit = (long) cinfo->image_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Give master control module another chance if this is first call to + * jpeg_write_raw_data. This lets output of the frame/scan headers be + * delayed so that application can write COM, etc, markers between + * jpeg_start_compress and jpeg_write_raw_data. + */ + if (cinfo->master->call_pass_startup) + (*cinfo->master->pass_startup) (cinfo); + + /* Verify that at least one iMCU row has been passed. */ + lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size; + if (num_lines < lines_per_iMCU_row) + ERREXIT(cinfo, JERR_BUFFER_SIZE); + + /* Directly compress the row. */ + if (! (*cinfo->coef->compress_data) (cinfo, data)) { + /* If compressor did not consume the whole row, suspend processing. */ + return 0; + } + + /* OK, we processed one iMCU row. */ + cinfo->next_scanline += lines_per_iMCU_row; + return lines_per_iMCU_row; +} diff --git a/thirdparty/jpeg-9e/jcarith.c b/thirdparty/jpeg-9e/jcarith.c new file mode 100644 index 0000000..1b45089 --- /dev/null +++ b/thirdparty/jpeg-9e/jcarith.c @@ -0,0 +1,945 @@ +/* + * jcarith.c + * + * Developed 1997-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains portable arithmetic entropy encoding routines for JPEG + * (implementing the ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81). + * + * Both sequential and progressive modes are supported in this single module. + * + * Suspension is not currently supported in this module. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Expanded entropy encoder object for arithmetic encoding. */ + +typedef struct { + struct jpeg_entropy_encoder pub; /* public fields */ + + INT32 c; /* C register, base of coding interval, layout as in sec. D.1.3 */ + INT32 a; /* A register, normalized size of coding interval */ + INT32 sc; /* counter for stacked 0xFF values which might overflow */ + INT32 zc; /* counter for pending 0x00 output values which might * + * be discarded at the end ("Pacman" termination) */ + int ct; /* bit shift counter, determines when next byte will be written */ + int buffer; /* buffer for most recent output byte != 0xFF */ + + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ + int dc_context[MAX_COMPS_IN_SCAN]; /* context index for DC conditioning */ + + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + int next_restart_num; /* next restart number to write (0-7) */ + + /* Pointers to statistics areas (these workspaces have image lifespan) */ + unsigned char * dc_stats[NUM_ARITH_TBLS]; + unsigned char * ac_stats[NUM_ARITH_TBLS]; + + /* Statistics bin for coding with fixed probability 0.5 */ + unsigned char fixed_bin[4]; +} arith_entropy_encoder; + +typedef arith_entropy_encoder * arith_entropy_ptr; + +/* The following two definitions specify the allocation chunk size + * for the statistics area. + * According to sections F.1.4.4.1.3 and F.1.4.4.2, we need at least + * 49 statistics bins for DC, and 245 statistics bins for AC coding. + * + * We use a compact representation with 1 byte per statistics bin, + * thus the numbers directly represent byte sizes. + * This 1 byte per statistics bin contains the meaning of the MPS + * (more probable symbol) in the highest bit (mask 0x80), and the + * index into the probability estimation state machine table + * in the lower bits (mask 0x7F). + */ + +#define DC_STAT_BINS 64 +#define AC_STAT_BINS 256 + +/* NOTE: Uncomment the following #define if you want to use the + * given formula for calculating the AC conditioning parameter Kx + * for spectral selection progressive coding in section G.1.3.2 + * of the spec (Kx = Kmin + SRL (8 + Se - Kmin) 4). + * Although the spec and P&M authors claim that this "has proven + * to give good results for 8 bit precision samples", I'm not + * convinced yet that this is really beneficial. + * Early tests gave only very marginal compression enhancements + * (a few - around 5 or so - bytes even for very large files), + * which would turn out rather negative if we'd suppress the + * DAC (Define Arithmetic Conditioning) marker segments for + * the default parameters in the future. + * Note that currently the marker writing module emits 12-byte + * DAC segments for a full-component scan in a color image. + * This is not worth worrying about IMHO. However, since the + * spec defines the default values to be used if the tables + * are omitted (unlike Huffman tables, which are required + * anyway), one might optimize this behaviour in the future, + * and then it would be disadvantageous to use custom tables if + * they don't provide sufficient gain to exceed the DAC size. + * + * On the other hand, I'd consider it as a reasonable result + * that the conditioning has no significant influence on the + * compression performance. This means that the basic + * statistical model is already rather stable. + * + * Thus, at the moment, we use the default conditioning values + * anyway, and do not use the custom formula. + * +#define CALCULATE_SPECTRAL_CONDITIONING + */ + +/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32. + * We assume that int right shift is unsigned if INT32 right shift is, + * which should be safe. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define ISHIFT_TEMPS int ishift_temp; +#define IRIGHT_SHIFT(x,shft) \ + ((ishift_temp = (x)) < 0 ? \ + (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \ + (ishift_temp >> (shft))) +#else +#define ISHIFT_TEMPS +#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + + +LOCAL(void) +emit_byte (int val, j_compress_ptr cinfo) +/* Write next output byte; we do not support suspension in this module. */ +{ + struct jpeg_destination_mgr * dest = cinfo->dest; + + *dest->next_output_byte++ = (JOCTET) val; + if (--dest->free_in_buffer == 0) + if (! (*dest->empty_output_buffer) (cinfo)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); +} + + +/* + * Finish up at the end of an arithmetic-compressed scan. + */ + +METHODDEF(void) +finish_pass (j_compress_ptr cinfo) +{ + arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy; + INT32 temp; + + /* Section D.1.8: Termination of encoding */ + + /* Find the e->c in the coding interval with the largest + * number of trailing zero bits */ + if ((temp = (e->a - 1 + e->c) & 0xFFFF0000L) < e->c) + e->c = temp + 0x8000L; + else + e->c = temp; + /* Send remaining bytes to output */ + e->c <<= e->ct; + if (e->c & 0xF8000000L) { + /* One final overflow has to be handled */ + if (e->buffer >= 0) { + if (e->zc) + do emit_byte(0x00, cinfo); + while (--e->zc); + emit_byte(e->buffer + 1, cinfo); + if (e->buffer + 1 == 0xFF) + emit_byte(0x00, cinfo); + } + e->zc += e->sc; /* carry-over converts stacked 0xFF bytes to 0x00 */ + e->sc = 0; + } else { + if (e->buffer == 0) + ++e->zc; + else if (e->buffer >= 0) { + if (e->zc) + do emit_byte(0x00, cinfo); + while (--e->zc); + emit_byte(e->buffer, cinfo); + } + if (e->sc) { + if (e->zc) + do emit_byte(0x00, cinfo); + while (--e->zc); + do { + emit_byte(0xFF, cinfo); + emit_byte(0x00, cinfo); + } while (--e->sc); + } + } + /* Output final bytes only if they are not 0x00 */ + if (e->c & 0x7FFF800L) { + if (e->zc) /* output final pending zero bytes */ + do emit_byte(0x00, cinfo); + while (--e->zc); + emit_byte((int) ((e->c >> 19) & 0xFF), cinfo); + if (((e->c >> 19) & 0xFF) == 0xFF) + emit_byte(0x00, cinfo); + if (e->c & 0x7F800L) { + emit_byte((int) ((e->c >> 11) & 0xFF), cinfo); + if (((e->c >> 11) & 0xFF) == 0xFF) + emit_byte(0x00, cinfo); + } + } +} + + +/* + * The core arithmetic encoding routine (common in JPEG and JBIG). + * This needs to go as fast as possible. + * Machine-dependent optimization facilities + * are not utilized in this portable implementation. + * However, this code should be fairly efficient and + * may be a good base for further optimizations anyway. + * + * Parameter 'val' to be encoded may be 0 or 1 (binary decision). + * + * Note: I've added full "Pacman" termination support to the + * byte output routines, which is equivalent to the optional + * Discard_final_zeros procedure (Figure D.15) in the spec. + * Thus, we always produce the shortest possible output + * stream compliant to the spec (no trailing zero bytes, + * except for FF stuffing). + * + * I've also introduced a new scheme for accessing + * the probability estimation state machine table, + * derived from Markus Kuhn's JBIG implementation. + */ + +LOCAL(void) +arith_encode (j_compress_ptr cinfo, unsigned char *st, int val) +{ + register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy; + register unsigned char nl, nm; + register INT32 qe, temp; + register int sv; + + /* Fetch values from our compact representation of Table D.3(D.2): + * Qe values and probability estimation state machine + */ + sv = *st; + qe = jpeg_aritab[sv & 0x7F]; /* => Qe_Value */ + nl = qe & 0xFF; qe >>= 8; /* Next_Index_LPS + Switch_MPS */ + nm = qe & 0xFF; qe >>= 8; /* Next_Index_MPS */ + + /* Encode & estimation procedures per sections D.1.4 & D.1.5 */ + e->a -= qe; + if (val != (sv >> 7)) { + /* Encode the less probable symbol */ + if (e->a >= qe) { + /* If the interval size (qe) for the less probable symbol (LPS) + * is larger than the interval size for the MPS, then exchange + * the two symbols for coding efficiency, otherwise code the LPS + * as usual: */ + e->c += e->a; + e->a = qe; + } + *st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */ + } else { + /* Encode the more probable symbol */ + if (e->a >= 0x8000L) + return; /* A >= 0x8000 -> ready, no renormalization required */ + if (e->a < qe) { + /* If the interval size (qe) for the less probable symbol (LPS) + * is larger than the interval size for the MPS, then exchange + * the two symbols for coding efficiency: */ + e->c += e->a; + e->a = qe; + } + *st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */ + } + + /* Renormalization & data output per section D.1.6 */ + do { + e->a <<= 1; + e->c <<= 1; + if (--e->ct == 0) { + /* Another byte is ready for output */ + temp = e->c >> 19; + if (temp > 0xFF) { + /* Handle overflow over all stacked 0xFF bytes */ + if (e->buffer >= 0) { + if (e->zc) + do emit_byte(0x00, cinfo); + while (--e->zc); + emit_byte(e->buffer + 1, cinfo); + if (e->buffer + 1 == 0xFF) + emit_byte(0x00, cinfo); + } + e->zc += e->sc; /* carry-over converts stacked 0xFF bytes to 0x00 */ + e->sc = 0; + /* Note: The 3 spacer bits in the C register guarantee + * that the new buffer byte can't be 0xFF here + * (see page 160 in the P&M JPEG book). */ + /* New output byte, might overflow later */ + e->buffer = (int) (temp & 0xFF); + } else if (temp == 0xFF) { + ++e->sc; /* stack 0xFF byte (which might overflow later) */ + } else { + /* Output all stacked 0xFF bytes, they will not overflow any more */ + if (e->buffer == 0) + ++e->zc; + else if (e->buffer >= 0) { + if (e->zc) + do emit_byte(0x00, cinfo); + while (--e->zc); + emit_byte(e->buffer, cinfo); + } + if (e->sc) { + if (e->zc) + do emit_byte(0x00, cinfo); + while (--e->zc); + do { + emit_byte(0xFF, cinfo); + emit_byte(0x00, cinfo); + } while (--e->sc); + } + /* New output byte (can still overflow) */ + e->buffer = (int) (temp & 0xFF); + } + e->c &= 0x7FFFFL; + e->ct += 8; + } + } while (e->a < 0x8000L); +} + + +/* + * Emit a restart marker & resynchronize predictions. + */ + +LOCAL(void) +emit_restart (j_compress_ptr cinfo, int restart_num) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + int ci; + jpeg_component_info * compptr; + + finish_pass(cinfo); + + emit_byte(0xFF, cinfo); + emit_byte(JPEG_RST0 + restart_num, cinfo); + + /* Re-initialize statistics areas */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* DC needs no table for refinement scan */ + if (cinfo->Ss == 0 && cinfo->Ah == 0) { + MEMZERO(entropy->dc_stats[compptr->dc_tbl_no], DC_STAT_BINS); + /* Reset DC predictions to 0 */ + entropy->last_dc_val[ci] = 0; + entropy->dc_context[ci] = 0; + } + /* AC needs no table when not present */ + if (cinfo->Se) { + MEMZERO(entropy->ac_stats[compptr->ac_tbl_no], AC_STAT_BINS); + } + } + + /* Reset arithmetic encoding variables */ + entropy->c = 0; + entropy->a = 0x10000L; + entropy->sc = 0; + entropy->zc = 0; + entropy->ct = 11; + entropy->buffer = -1; /* empty */ +} + + +/* + * MCU encoding for DC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + unsigned char *st; + int blkn, ci, tbl; + int v, v2, m; + ISHIFT_TEMPS + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + emit_restart(cinfo, entropy->next_restart_num); + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + tbl = cinfo->cur_comp_info[ci]->dc_tbl_no; + + /* Compute the DC value after the required point transform by Al. + * This is simply an arithmetic right shift. + */ + m = IRIGHT_SHIFT((int) (MCU_data[blkn][0][0]), cinfo->Al); + + /* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */ + + /* Table F.4: Point to statistics bin S0 for DC coefficient coding */ + st = entropy->dc_stats[tbl] + entropy->dc_context[ci]; + + /* Figure F.4: Encode_DC_DIFF */ + if ((v = m - entropy->last_dc_val[ci]) == 0) { + arith_encode(cinfo, st, 0); + entropy->dc_context[ci] = 0; /* zero diff category */ + } else { + entropy->last_dc_val[ci] = m; + arith_encode(cinfo, st, 1); + /* Figure F.6: Encoding nonzero value v */ + /* Figure F.7: Encoding the sign of v */ + if (v > 0) { + arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */ + st += 2; /* Table F.4: SP = S0 + 2 */ + entropy->dc_context[ci] = 4; /* small positive diff category */ + } else { + v = -v; + arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */ + st += 3; /* Table F.4: SN = S0 + 3 */ + entropy->dc_context[ci] = 8; /* small negative diff category */ + } + /* Figure F.8: Encoding the magnitude category of v */ + m = 0; + if (v -= 1) { + arith_encode(cinfo, st, 1); + m = 1; + v2 = v; + st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */ + while (v2 >>= 1) { + arith_encode(cinfo, st, 1); + m <<= 1; + st += 1; + } + } + arith_encode(cinfo, st, 0); + /* Section F.1.4.4.1.2: Establish dc_context conditioning category */ + if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1)) + entropy->dc_context[ci] = 0; /* zero diff category */ + else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1)) + entropy->dc_context[ci] += 8; /* large diff category */ + /* Figure F.9: Encoding the magnitude bit pattern of v */ + st += 14; + while (m >>= 1) + arith_encode(cinfo, st, (m & v) ? 1 : 0); + } + } + + return TRUE; +} + + +/* + * MCU encoding for AC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + const int * natural_order; + JBLOCKROW block; + unsigned char *st; + int tbl, k, ke; + int v, v2, m; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + emit_restart(cinfo, entropy->next_restart_num); + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + natural_order = cinfo->natural_order; + + /* Encode the MCU data block */ + block = MCU_data[0]; + tbl = cinfo->cur_comp_info[0]->ac_tbl_no; + + /* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */ + + /* Establish EOB (end-of-block) index */ + ke = cinfo->Se; + do { + /* We must apply the point transform by Al. For AC coefficients this + * is an integer division with rounding towards 0. To do this portably + * in C, we shift after obtaining the absolute value. + */ + if ((v = (*block)[natural_order[ke]]) >= 0) { + if (v >>= cinfo->Al) break; + } else { + v = -v; + if (v >>= cinfo->Al) break; + } + } while (--ke); + + /* Figure F.5: Encode_AC_Coefficients */ + for (k = cinfo->Ss - 1; k < ke;) { + st = entropy->ac_stats[tbl] + 3 * k; + arith_encode(cinfo, st, 0); /* EOB decision */ + for (;;) { + if ((v = (*block)[natural_order[++k]]) >= 0) { + if (v >>= cinfo->Al) { + arith_encode(cinfo, st + 1, 1); + arith_encode(cinfo, entropy->fixed_bin, 0); + break; + } + } else { + v = -v; + if (v >>= cinfo->Al) { + arith_encode(cinfo, st + 1, 1); + arith_encode(cinfo, entropy->fixed_bin, 1); + break; + } + } + arith_encode(cinfo, st + 1, 0); + st += 3; + } + st += 2; + /* Figure F.8: Encoding the magnitude category of v */ + m = 0; + if (v -= 1) { + arith_encode(cinfo, st, 1); + m = 1; + v2 = v; + if (v2 >>= 1) { + arith_encode(cinfo, st, 1); + m <<= 1; + st = entropy->ac_stats[tbl] + + (k <= cinfo->arith_ac_K[tbl] ? 189 : 217); + while (v2 >>= 1) { + arith_encode(cinfo, st, 1); + m <<= 1; + st += 1; + } + } + } + arith_encode(cinfo, st, 0); + /* Figure F.9: Encoding the magnitude bit pattern of v */ + st += 14; + while (m >>= 1) + arith_encode(cinfo, st, (m & v) ? 1 : 0); + } + /* Encode EOB decision only if k < cinfo->Se */ + if (k < cinfo->Se) { + st = entropy->ac_stats[tbl] + 3 * k; + arith_encode(cinfo, st, 1); + } + + return TRUE; +} + + +/* + * MCU encoding for DC successive approximation refinement scan. + * Note: we assume such scans can be multi-component, + * although the spec is not very clear on the point. + */ + +METHODDEF(boolean) +encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + unsigned char *st; + int Al, blkn; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + emit_restart(cinfo, entropy->next_restart_num); + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + st = entropy->fixed_bin; /* use fixed probability estimation */ + Al = cinfo->Al; + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + /* We simply emit the Al'th bit of the DC coefficient value. */ + arith_encode(cinfo, st, (MCU_data[blkn][0][0] >> Al) & 1); + } + + return TRUE; +} + + +/* + * MCU encoding for AC successive approximation refinement scan. + */ + +METHODDEF(boolean) +encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + const int * natural_order; + JBLOCKROW block; + unsigned char *st; + int tbl, k, ke, kex; + int v; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + emit_restart(cinfo, entropy->next_restart_num); + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + natural_order = cinfo->natural_order; + + /* Encode the MCU data block */ + block = MCU_data[0]; + tbl = cinfo->cur_comp_info[0]->ac_tbl_no; + + /* Section G.1.3.3: Encoding of AC coefficients */ + + /* Establish EOB (end-of-block) index */ + ke = cinfo->Se; + do { + /* We must apply the point transform by Al. For AC coefficients this + * is an integer division with rounding towards 0. To do this portably + * in C, we shift after obtaining the absolute value. + */ + if ((v = (*block)[natural_order[ke]]) >= 0) { + if (v >>= cinfo->Al) break; + } else { + v = -v; + if (v >>= cinfo->Al) break; + } + } while (--ke); + + /* Establish EOBx (previous stage end-of-block) index */ + for (kex = ke; kex > 0; kex--) + if ((v = (*block)[natural_order[kex]]) >= 0) { + if (v >>= cinfo->Ah) break; + } else { + v = -v; + if (v >>= cinfo->Ah) break; + } + + /* Figure G.10: Encode_AC_Coefficients_SA */ + for (k = cinfo->Ss - 1; k < ke;) { + st = entropy->ac_stats[tbl] + 3 * k; + if (k >= kex) + arith_encode(cinfo, st, 0); /* EOB decision */ + for (;;) { + if ((v = (*block)[natural_order[++k]]) >= 0) { + if (v >>= cinfo->Al) { + if (v >> 1) /* previously nonzero coef */ + arith_encode(cinfo, st + 2, (v & 1)); + else { /* newly nonzero coef */ + arith_encode(cinfo, st + 1, 1); + arith_encode(cinfo, entropy->fixed_bin, 0); + } + break; + } + } else { + v = -v; + if (v >>= cinfo->Al) { + if (v >> 1) /* previously nonzero coef */ + arith_encode(cinfo, st + 2, (v & 1)); + else { /* newly nonzero coef */ + arith_encode(cinfo, st + 1, 1); + arith_encode(cinfo, entropy->fixed_bin, 1); + } + break; + } + } + arith_encode(cinfo, st + 1, 0); + st += 3; + } + } + /* Encode EOB decision only if k < cinfo->Se */ + if (k < cinfo->Se) { + st = entropy->ac_stats[tbl] + 3 * k; + arith_encode(cinfo, st, 1); + } + + return TRUE; +} + + +/* + * Encode and output one MCU's worth of arithmetic-compressed coefficients. + */ + +METHODDEF(boolean) +encode_mcu (j_compress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + const int * natural_order; + JBLOCKROW block; + unsigned char *st; + int tbl, k, ke; + int v, v2, m; + int blkn, ci; + jpeg_component_info * compptr; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + emit_restart(cinfo, entropy->next_restart_num); + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + natural_order = cinfo->natural_order; + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + + /* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */ + + tbl = compptr->dc_tbl_no; + + /* Table F.4: Point to statistics bin S0 for DC coefficient coding */ + st = entropy->dc_stats[tbl] + entropy->dc_context[ci]; + + /* Figure F.4: Encode_DC_DIFF */ + if ((v = (*block)[0] - entropy->last_dc_val[ci]) == 0) { + arith_encode(cinfo, st, 0); + entropy->dc_context[ci] = 0; /* zero diff category */ + } else { + entropy->last_dc_val[ci] = (*block)[0]; + arith_encode(cinfo, st, 1); + /* Figure F.6: Encoding nonzero value v */ + /* Figure F.7: Encoding the sign of v */ + if (v > 0) { + arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */ + st += 2; /* Table F.4: SP = S0 + 2 */ + entropy->dc_context[ci] = 4; /* small positive diff category */ + } else { + v = -v; + arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */ + st += 3; /* Table F.4: SN = S0 + 3 */ + entropy->dc_context[ci] = 8; /* small negative diff category */ + } + /* Figure F.8: Encoding the magnitude category of v */ + m = 0; + if (v -= 1) { + arith_encode(cinfo, st, 1); + m = 1; + v2 = v; + st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */ + while (v2 >>= 1) { + arith_encode(cinfo, st, 1); + m <<= 1; + st += 1; + } + } + arith_encode(cinfo, st, 0); + /* Section F.1.4.4.1.2: Establish dc_context conditioning category */ + if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1)) + entropy->dc_context[ci] = 0; /* zero diff category */ + else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1)) + entropy->dc_context[ci] += 8; /* large diff category */ + /* Figure F.9: Encoding the magnitude bit pattern of v */ + st += 14; + while (m >>= 1) + arith_encode(cinfo, st, (m & v) ? 1 : 0); + } + + /* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */ + + if ((ke = cinfo->lim_Se) == 0) continue; + tbl = compptr->ac_tbl_no; + + /* Establish EOB (end-of-block) index */ + do { + if ((*block)[natural_order[ke]]) break; + } while (--ke); + + /* Figure F.5: Encode_AC_Coefficients */ + for (k = 0; k < ke;) { + st = entropy->ac_stats[tbl] + 3 * k; + arith_encode(cinfo, st, 0); /* EOB decision */ + while ((v = (*block)[natural_order[++k]]) == 0) { + arith_encode(cinfo, st + 1, 0); + st += 3; + } + arith_encode(cinfo, st + 1, 1); + /* Figure F.6: Encoding nonzero value v */ + /* Figure F.7: Encoding the sign of v */ + if (v > 0) { + arith_encode(cinfo, entropy->fixed_bin, 0); + } else { + v = -v; + arith_encode(cinfo, entropy->fixed_bin, 1); + } + st += 2; + /* Figure F.8: Encoding the magnitude category of v */ + m = 0; + if (v -= 1) { + arith_encode(cinfo, st, 1); + m = 1; + v2 = v; + if (v2 >>= 1) { + arith_encode(cinfo, st, 1); + m <<= 1; + st = entropy->ac_stats[tbl] + + (k <= cinfo->arith_ac_K[tbl] ? 189 : 217); + while (v2 >>= 1) { + arith_encode(cinfo, st, 1); + m <<= 1; + st += 1; + } + } + } + arith_encode(cinfo, st, 0); + /* Figure F.9: Encoding the magnitude bit pattern of v */ + st += 14; + while (m >>= 1) + arith_encode(cinfo, st, (m & v) ? 1 : 0); + } + /* Encode EOB decision only if k < cinfo->lim_Se */ + if (k < cinfo->lim_Se) { + st = entropy->ac_stats[tbl] + 3 * k; + arith_encode(cinfo, st, 1); + } + } + + return TRUE; +} + + +/* + * Initialize for an arithmetic-compressed scan. + */ + +METHODDEF(void) +start_pass (j_compress_ptr cinfo, boolean gather_statistics) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + int ci, tbl; + jpeg_component_info * compptr; + + if (gather_statistics) + /* Make sure to avoid that in the master control logic! + * We are fully adaptive here and need no extra + * statistics gathering pass! + */ + ERREXIT(cinfo, JERR_NOT_COMPILED); + + /* We assume jcmaster.c already validated the progressive scan parameters. */ + + /* Select execution routines */ + if (cinfo->progressive_mode) { + if (cinfo->Ah == 0) { + if (cinfo->Ss == 0) + entropy->pub.encode_mcu = encode_mcu_DC_first; + else + entropy->pub.encode_mcu = encode_mcu_AC_first; + } else { + if (cinfo->Ss == 0) + entropy->pub.encode_mcu = encode_mcu_DC_refine; + else + entropy->pub.encode_mcu = encode_mcu_AC_refine; + } + } else + entropy->pub.encode_mcu = encode_mcu; + + /* Allocate & initialize requested statistics areas */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* DC needs no table for refinement scan */ + if (cinfo->Ss == 0 && cinfo->Ah == 0) { + tbl = compptr->dc_tbl_no; + if (tbl < 0 || tbl >= NUM_ARITH_TBLS) + ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl); + if (entropy->dc_stats[tbl] == NULL) + entropy->dc_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, DC_STAT_BINS); + MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS); + /* Initialize DC predictions to 0 */ + entropy->last_dc_val[ci] = 0; + entropy->dc_context[ci] = 0; + } + /* AC needs no table when not present */ + if (cinfo->Se) { + tbl = compptr->ac_tbl_no; + if (tbl < 0 || tbl >= NUM_ARITH_TBLS) + ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl); + if (entropy->ac_stats[tbl] == NULL) + entropy->ac_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, AC_STAT_BINS); + MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS); +#ifdef CALCULATE_SPECTRAL_CONDITIONING + if (cinfo->progressive_mode) + /* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */ + cinfo->arith_ac_K[tbl] = cinfo->Ss + ((8 + cinfo->Se - cinfo->Ss) >> 4); +#endif + } + } + + /* Initialize arithmetic encoding variables */ + entropy->c = 0; + entropy->a = 0x10000L; + entropy->sc = 0; + entropy->zc = 0; + entropy->ct = 11; + entropy->buffer = -1; /* empty */ + + /* Initialize restart stuff */ + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num = 0; +} + + +/* + * Module initialization routine for arithmetic entropy encoding. + */ + +GLOBAL(void) +jinit_arith_encoder (j_compress_ptr cinfo) +{ + arith_entropy_ptr entropy; + int i; + + entropy = (arith_entropy_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(arith_entropy_encoder)); + cinfo->entropy = &entropy->pub; + entropy->pub.start_pass = start_pass; + entropy->pub.finish_pass = finish_pass; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_ARITH_TBLS; i++) { + entropy->dc_stats[i] = NULL; + entropy->ac_stats[i] = NULL; + } + + /* Initialize index for fixed probability estimation */ + entropy->fixed_bin[0] = 113; +} diff --git a/thirdparty/jpeg-9e/jccoefct.c b/thirdparty/jpeg-9e/jccoefct.c new file mode 100644 index 0000000..77851f3 --- /dev/null +++ b/thirdparty/jpeg-9e/jccoefct.c @@ -0,0 +1,456 @@ +/* + * jccoefct.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * Modified 2003-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the coefficient buffer controller for compression. + * This controller is the top level of the JPEG compressor proper. + * The coefficient buffer lies between forward-DCT and entropy encoding steps. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* We use a full-image coefficient buffer when doing Huffman optimization, + * and also for writing multiple-scan JPEG files. In all cases, the DCT + * step is run during the first pass, and subsequent passes need only read + * the buffered coefficients. + */ +#ifdef ENTROPY_OPT_SUPPORTED +#define FULL_COEF_BUFFER_SUPPORTED +#else +#ifdef C_MULTISCAN_FILES_SUPPORTED +#define FULL_COEF_BUFFER_SUPPORTED +#endif +#endif + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_coef_controller pub; /* public fields */ + + JDIMENSION iMCU_row_num; /* iMCU row # within image */ + JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* For single-pass compression, it's sufficient to buffer just one MCU + * (although this may prove a bit slow in practice). We append a + * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it + * for each MCU constructed and sent. + * In multi-pass modes, this array points to the current MCU's blocks + * within the virtual arrays. + */ + JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; + + /* In multi-pass modes, we need a virtual block array for each component. */ + jvirt_barray_ptr whole_image[MAX_COMPONENTS]; + + /* Workspace for single-pass compression (omitted otherwise). */ + JBLOCK blk_buffer[C_MAX_BLOCKS_IN_MCU]; +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + + +/* Forward declarations */ +METHODDEF(boolean) compress_data + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +#ifdef FULL_COEF_BUFFER_SUPPORTED +METHODDEF(boolean) compress_first_pass + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +METHODDEF(boolean) compress_output + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +#endif + + +LOCAL(void) +start_iMCU_row (j_compress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->MCU_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + coef->iMCU_row_num = 0; + start_iMCU_row(cinfo); + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (coef->whole_image[0] != NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_data; + break; +#ifdef FULL_COEF_BUFFER_SUPPORTED + case JBUF_SAVE_AND_PASS: + if (coef->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_first_pass; + break; + case JBUF_CRANK_DEST: + if (coef->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_output; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + } +} + + +/* + * Process some data in the single-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the image. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf contains a plane for each component in image, + * which we index according to the component's SOF position. + */ + +METHODDEF(boolean) +compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int ci, xindex, yindex, yoffset, blockcnt; + JBLOCKROW blkp; + JSAMPARRAY input_ptr; + JDIMENSION xpos; + jpeg_component_info *compptr; + forward_DCT_ptr forward_DCT; + + /* Loop to write as much as one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; + MCU_col_num++) { + /* Determine where data comes from in input_buf and do the DCT thing. + * Each call on forward_DCT processes a horizontal row of DCT blocks as + * wide as an MCU. Dummy blocks at the right or bottom edge are filled in + * specially. The data in them does not matter for image reconstruction, + * so we fill them with values that will encode to the smallest amount of + * data, viz: all zeroes in the AC entries, DC entries equal to previous + * block's DC value. (Thanks to Thomas Kinsman for this idea.) + */ + blkp = coef->blk_buffer; /* pointer to current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + forward_DCT = cinfo->fdct->forward_DCT[compptr->component_index]; + input_ptr = input_buf[compptr->component_index] + + yoffset * compptr->DCT_v_scaled_size; + /* ypos == (yoffset + yindex) * compptr->DCT_v_scaled_size */ + blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + xpos = MCU_col_num * compptr->MCU_sample_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (coef->iMCU_row_num < last_iMCU_row || + yoffset + yindex < compptr->last_row_height) { + (*forward_DCT) (cinfo, compptr, input_ptr, blkp, + xpos, (JDIMENSION) blockcnt); + input_ptr += compptr->DCT_v_scaled_size; + blkp += blockcnt; + /* Dummy blocks at right edge */ + if ((xindex = compptr->MCU_width - blockcnt) == 0) + continue; + } else { + /* At bottom of image, need a whole row of dummy blocks */ + xindex = compptr->MCU_width; + } + /* Fill in any dummy blocks needed in this row */ + MEMZERO(blkp, xindex * SIZEOF(JBLOCK)); + do { + blkp[0][0] = blkp[-1][0]; + blkp++; + } while (--xindex); + } + } + /* Try to write the MCU. In event of a suspension failure, we will + * re-DCT the MCU on restart (a bit inefficient, could be fixed...) + */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->MCU_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->MCU_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + + +#ifdef FULL_COEF_BUFFER_SUPPORTED + +/* + * Process some data in the first pass of a multi-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the image. + * This amount of data is read from the source buffer, DCT'd and quantized, + * and saved into the virtual arrays. We also generate suitable dummy blocks + * as needed at the right and lower edges. (The dummy blocks are constructed + * in the virtual arrays, which have been padded appropriately.) This makes + * it possible for subsequent passes not to worry about real vs. dummy blocks. + * + * We must also emit the data to the entropy encoder. This is conveniently + * done by calling compress_output() after we've loaded the current strip + * of the virtual arrays. + * + * NB: input_buf contains a plane for each component in image. All + * components are DCT'd and loaded into the virtual arrays in this pass. + * However, it may be that only a subset of the components are emitted to + * the entropy encoder during this first pass; be careful about looking + * at the scan-dependent variables (MCU dimensions, etc). + */ + +METHODDEF(boolean) +compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION blocks_across, MCUs_across, MCUindex; + int bi, ci, h_samp_factor, block_row, block_rows, ndummy; + JCOEF lastDC; + jpeg_component_info *compptr; + JBLOCKARRAY buffer; + JBLOCKROW thisblockrow, lastblockrow; + JSAMPARRAY input_ptr; + forward_DCT_ptr forward_DCT; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Align the virtual buffer for this component. */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, TRUE); + /* Count non-dummy DCT block rows in this iMCU row. */ + if (coef->iMCU_row_num < last_iMCU_row) + block_rows = compptr->v_samp_factor; + else { + /* NB: can't use last_row_height here, since may not be set! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + } + blocks_across = compptr->width_in_blocks; + h_samp_factor = compptr->h_samp_factor; + /* Count number of dummy blocks to be added at the right margin. */ + ndummy = (int) (blocks_across % h_samp_factor); + if (ndummy > 0) + ndummy = h_samp_factor - ndummy; + forward_DCT = cinfo->fdct->forward_DCT[ci]; + input_ptr = input_buf[ci]; + /* Perform DCT for all non-dummy blocks in this iMCU row. Each call + * on forward_DCT processes a complete horizontal row of DCT blocks. + */ + for (block_row = 0; block_row < block_rows; block_row++) { + thisblockrow = buffer[block_row]; + (*forward_DCT) (cinfo, compptr, input_ptr, thisblockrow, + (JDIMENSION) 0, blocks_across); + input_ptr += compptr->DCT_v_scaled_size; + if (ndummy > 0) { + /* Create dummy blocks at the right edge of the image. */ + thisblockrow += blocks_across; /* => first dummy block */ + FMEMZERO((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); + lastDC = thisblockrow[-1][0]; + for (bi = 0; bi < ndummy; bi++) { + thisblockrow[bi][0] = lastDC; + } + } + } + /* If at end of image, create dummy block rows as needed. + * The tricky part here is that within each MCU, we want the DC values + * of the dummy blocks to match the last real block's DC value. + * This squeezes a few more bytes out of the resulting file... + */ + if (block_row < compptr->v_samp_factor) { + blocks_across += ndummy; /* include lower right corner */ + MCUs_across = blocks_across / h_samp_factor; + do { + thisblockrow = buffer[block_row]; + lastblockrow = buffer[block_row-1]; + FMEMZERO((void FAR *) thisblockrow, + (size_t) blocks_across * SIZEOF(JBLOCK)); + for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { + lastDC = lastblockrow[h_samp_factor-1][0]; + for (bi = 0; bi < h_samp_factor; bi++) { + thisblockrow[bi][0] = lastDC; + } + thisblockrow += h_samp_factor; /* advance to next MCU in row */ + lastblockrow += h_samp_factor; + } + } while (++block_row < compptr->v_samp_factor); + } + } + /* NB: compress_output will increment iMCU_row_num if successful. + * A suspension return will result in redoing all the work above next time. + */ + + /* Emit data to the entropy encoder, sharing code with subsequent passes */ + return compress_output(cinfo, input_buf); +} + + +/* + * Process some data in subsequent passes of a multi-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the scan. + * The data is obtained from the virtual arrays and fed to the entropy coder. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf is ignored; it is likely to be a NULL pointer. + */ + +METHODDEF(boolean) +compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + int ci, xindex, yindex, yoffset; + JDIMENSION start_col; + JBLOCKARRAY blkp; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. + * NB: during first pass, this is safe only because the buffers will + * already be aligned properly, so jmemmgr.c won't need to do any I/O. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkp = coef->MCU_buffer; /* pointer to current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + start_col = MCU_col_num * compptr->MCU_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + buffer_ptr = buffer[ci][yoffset + yindex] + start_col; + xindex = compptr->MCU_width; + do { + *blkp++ = buffer_ptr++; + } while (--xindex); + } + } + /* Try to write the MCU. */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->MCU_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->MCU_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + +#endif /* FULL_COEF_BUFFER_SUPPORTED */ + + +/* + * Initialize coefficient buffer controller. + */ + +GLOBAL(void) +jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_coef_ptr coef; + + if (need_full_buffer) { +#ifdef FULL_COEF_BUFFER_SUPPORTED + /* Allocate a full-image virtual array for each component, */ + /* padded to a multiple of samp_factor DCT blocks in each direction. */ + int ci; + jpeg_component_info *compptr; + + coef = (my_coef_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_coef_controller) - SIZEOF(coef->blk_buffer)); + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) jround_up((long) compptr->width_in_blocks, + (long) compptr->h_samp_factor), + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor), + (JDIMENSION) compptr->v_samp_factor); + } +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + } else { + /* We only need a single-MCU buffer. */ + JBLOCKARRAY blkp; + JBLOCKROW buffer_ptr; + int bi; + + coef = (my_coef_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_coef_controller)); + blkp = coef->MCU_buffer; + buffer_ptr = coef->blk_buffer; + bi = C_MAX_BLOCKS_IN_MCU; + do { + *blkp++ = buffer_ptr++; + } while (--bi); + coef->whole_image[0] = NULL; /* flag for no virtual arrays */ + } + + coef->pub.start_pass = start_pass_coef; + cinfo->coef = &coef->pub; +} diff --git a/thirdparty/jpeg-9e/jccolor.c b/thirdparty/jpeg-9e/jccolor.c new file mode 100644 index 0000000..db2ca42 --- /dev/null +++ b/thirdparty/jpeg-9e/jccolor.c @@ -0,0 +1,601 @@ +/* + * jccolor.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2011-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains input colorspace conversion routines. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private subobject */ + +typedef struct { + struct jpeg_color_converter pub; /* public fields */ + + /* Private state for RGB->YCC conversion */ + INT32 * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */ +} my_color_converter; + +typedef my_color_converter * my_cconvert_ptr; + + +/**************** RGB -> YCbCr conversion: most common case **************/ + +/* + * YCbCr is defined per Recommendation ITU-R BT.601-7 (03/2011), + * previously known as Recommendation CCIR 601-1, except that Cb and Cr + * are normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. + * sRGB (standard RGB color space) is defined per IEC 61966-2-1:1999. + * sYCC (standard luma-chroma-chroma color space with extended gamut) + * is defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex F. + * bg-sRGB and bg-sYCC (big gamut standard color spaces) + * are defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex G. + * Note that the derived conversion coefficients given in some of these + * documents are imprecise. The general conversion equations are + * Y = Kr * R + (1 - Kr - Kb) * G + Kb * B + * Cb = 0.5 * (B - Y) / (1 - Kb) + * Cr = 0.5 * (R - Y) / (1 - Kr) + * With Kr = 0.299 and Kb = 0.114 (derived according to SMPTE RP 177-1993 + * from the 1953 FCC NTSC primaries and CIE Illuminant C), + * the conversion equations to be implemented are therefore + * Y = 0.299 * R + 0.587 * G + 0.114 * B + * Cb = -0.168735892 * R - 0.331264108 * G + 0.5 * B + CENTERJSAMPLE + * Cr = 0.5 * R - 0.418687589 * G - 0.081312411 * B + CENTERJSAMPLE + * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2, + * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and + * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0) + * were not represented exactly. Now we sacrifice exact representation of + * maximum red and maximum blue in order to get exact grayscales. + * + * To avoid floating-point arithmetic, we represent the fractional constants + * as integers scaled up by 2^16 (about 4 digits precision); we have to divide + * the products by 2^16, with appropriate rounding, to get the correct answer. + * + * For even more speed, we avoid doing any multiplications in the inner loop + * by precalculating the constants times R,G,B for all possible values. + * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); + * for 9-bit to 12-bit samples it is still acceptable. It's not very + * reasonable for 16-bit samples, but if you want lossless storage you + * shouldn't be changing colorspace anyway. + * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included + * in the tables to save adding them separately in the inner loop. + */ + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define CBCR_OFFSET ((INT32) CENTERJSAMPLE << SCALEBITS) +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L< Y section */ +#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */ +#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */ +#define R_CB_OFF (3*(MAXJSAMPLE+1)) +#define G_CB_OFF (4*(MAXJSAMPLE+1)) +#define B_CB_OFF (5*(MAXJSAMPLE+1)) +#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */ +#define G_CR_OFF (6*(MAXJSAMPLE+1)) +#define B_CR_OFF (7*(MAXJSAMPLE+1)) +#define TABLE_SIZE (8*(MAXJSAMPLE+1)) + + +/* + * Initialize for RGB->YCC colorspace conversion. + */ + +METHODDEF(void) +rgb_ycc_start (j_compress_ptr cinfo) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + INT32 * rgb_ycc_tab; + INT32 i; + + /* Allocate and fill in the conversion tables. */ + cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + TABLE_SIZE * SIZEOF(INT32)); + + for (i = 0; i <= MAXJSAMPLE; i++) { + rgb_ycc_tab[i+R_Y_OFF] = FIX(0.299) * i; + rgb_ycc_tab[i+G_Y_OFF] = FIX(0.587) * i; + rgb_ycc_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF; + rgb_ycc_tab[i+R_CB_OFF] = (- FIX(0.168735892)) * i; + rgb_ycc_tab[i+G_CB_OFF] = (- FIX(0.331264108)) * i; + /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr. + * This ensures that the maximum output will round to MAXJSAMPLE + * not MAXJSAMPLE+1, and thus that we don't have to range-limit. + */ + rgb_ycc_tab[i+B_CB_OFF] = FIX(0.5) * i + CBCR_OFFSET + ONE_HALF-1; +/* B=>Cb and R=>Cr tables are the same + rgb_ycc_tab[i+R_CR_OFF] = FIX(0.5) * i + CBCR_OFFSET + ONE_HALF-1; +*/ + rgb_ycc_tab[i+G_CR_OFF] = (- FIX(0.418687589)) * i; + rgb_ycc_tab[i+B_CR_OFF] = (- FIX(0.081312411)) * i; + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * + * Note that we change from the application's interleaved-pixel format + * to our internal noninterleaved, one-plane-per-component format. The + * input buffer is therefore three times as wide as the output buffer. + * + * A starting row offset is provided only for the output buffer. The + * caller can easily adjust the passed input_buf value to accommodate + * any row offset required on that side. + */ + +METHODDEF(void) +rgb_ycc_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr0, outptr1, outptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr0 = output_buf[0][output_row]; + outptr1 = output_buf[1][output_row]; + outptr2 = output_buf[2][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr[RGB_RED]); + g = GETJSAMPLE(inptr[RGB_GREEN]); + b = GETJSAMPLE(inptr[RGB_BLUE]); + inptr += RGB_PIXELSIZE; + /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations + * must be too; we do not need an explicit range-limiting operation. + * Hence the value being shifted is never negative, and we don't + * need the general RIGHT_SHIFT macro. + */ + /* Y */ + outptr0[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + /* Cb */ + outptr1[col] = (JSAMPLE) + ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) + >> SCALEBITS); + /* Cr */ + outptr2[col] = (JSAMPLE) + ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) + >> SCALEBITS); + } + } +} + + +/**************** Cases other than RGB -> YCbCr **************/ + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles RGB->grayscale conversion, which is the same + * as the RGB->Y portion of RGB->YCbCr. + * We assume rgb_ycc_start has been called (we only use the Y tables). + */ + +METHODDEF(void) +rgb_gray_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr = output_buf[0][output_row++]; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr[RGB_RED]); + g = GETJSAMPLE(inptr[RGB_GREEN]); + b = GETJSAMPLE(inptr[RGB_BLUE]); + inptr += RGB_PIXELSIZE; + /* Y */ + outptr[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles Adobe-style CMYK->YCCK conversion, + * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the + * same conversion as above, while passing K (black) unchanged. + * We assume rgb_ycc_start has been called. + */ + +METHODDEF(void) +cmyk_ycck_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr0, outptr1, outptr2, outptr3; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr0 = output_buf[0][output_row]; + outptr1 = output_buf[1][output_row]; + outptr2 = output_buf[2][output_row]; + outptr3 = output_buf[3][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = MAXJSAMPLE - GETJSAMPLE(inptr[0]); + g = MAXJSAMPLE - GETJSAMPLE(inptr[1]); + b = MAXJSAMPLE - GETJSAMPLE(inptr[2]); + /* K passes through as-is */ + outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */ + inptr += 4; + /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations + * must be too; we do not need an explicit range-limiting operation. + * Hence the value being shifted is never negative, and we don't + * need the general RIGHT_SHIFT macro. + */ + /* Y */ + outptr0[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + /* Cb */ + outptr1[col] = (JSAMPLE) + ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) + >> SCALEBITS); + /* Cr */ + outptr2[col] = (JSAMPLE) + ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) + >> SCALEBITS); + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * [R,G,B] to [R-G,G,B-G] conversion with modulo calculation + * (forward reversible color transform). + * This can be seen as an adaption of the general RGB->YCbCr + * conversion equation with Kr = Kb = 0, while replacing the + * normalization by modulo calculation. + */ + +METHODDEF(void) +rgb_rgb1_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + register int r, g, b; + register JSAMPROW inptr; + register JSAMPROW outptr0, outptr1, outptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr0 = output_buf[0][output_row]; + outptr1 = output_buf[1][output_row]; + outptr2 = output_buf[2][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr[RGB_RED]); + g = GETJSAMPLE(inptr[RGB_GREEN]); + b = GETJSAMPLE(inptr[RGB_BLUE]); + inptr += RGB_PIXELSIZE; + /* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD + * (modulo) operator is equivalent to the bitmask operator AND. + */ + outptr0[col] = (JSAMPLE) ((r - g + CENTERJSAMPLE) & MAXJSAMPLE); + outptr1[col] = (JSAMPLE) g; + outptr2[col] = (JSAMPLE) ((b - g + CENTERJSAMPLE) & MAXJSAMPLE); + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles grayscale output with no conversion. + * The source can be either plain grayscale or YCC (since Y == gray). + */ + +METHODDEF(void) +grayscale_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION count; + register int instride = cinfo->input_components; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr = output_buf[0][output_row++]; + for (count = num_cols; count > 0; count--) { + *outptr++ = *inptr; /* don't need GETJSAMPLE() here */ + inptr += instride; + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * No colorspace conversion, but change from interleaved + * to separate-planes representation. + */ + +METHODDEF(void) +rgb_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + register JSAMPROW inptr; + register JSAMPROW outptr0, outptr1, outptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr0 = output_buf[0][output_row]; + outptr1 = output_buf[1][output_row]; + outptr2 = output_buf[2][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + /* We can dispense with GETJSAMPLE() here */ + outptr0[col] = inptr[RGB_RED]; + outptr1[col] = inptr[RGB_GREEN]; + outptr2[col] = inptr[RGB_BLUE]; + inptr += RGB_PIXELSIZE; + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles multi-component colorspaces without conversion. + * We assume input_components == num_components. + */ + +METHODDEF(void) +null_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION count; + register int num_comps = cinfo->num_components; + JDIMENSION num_cols = cinfo->image_width; + int ci; + + while (--num_rows >= 0) { + /* It seems fastest to make a separate pass for each component. */ + for (ci = 0; ci < num_comps; ci++) { + inptr = input_buf[0] + ci; + outptr = output_buf[ci][output_row]; + for (count = num_cols; count > 0; count--) { + *outptr++ = *inptr; /* don't need GETJSAMPLE() here */ + inptr += num_comps; + } + } + input_buf++; + output_row++; + } +} + + +/* + * Empty method for start_pass. + */ + +METHODDEF(void) +null_method (j_compress_ptr cinfo) +{ + /* no work needed */ +} + + +/* + * Module initialization routine for input colorspace conversion. + */ + +GLOBAL(void) +jinit_color_converter (j_compress_ptr cinfo) +{ + my_cconvert_ptr cconvert; + + cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_converter)); + cinfo->cconvert = &cconvert->pub; + /* set start_pass to null method until we find out differently */ + cconvert->pub.start_pass = null_method; + + /* Make sure input_components agrees with in_color_space */ + switch (cinfo->in_color_space) { + case JCS_GRAYSCALE: + if (cinfo->input_components != 1) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + case JCS_RGB: + case JCS_BG_RGB: +#if RGB_PIXELSIZE != 3 + if (cinfo->input_components != RGB_PIXELSIZE) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; +#endif /* else share code with YCbCr */ + + case JCS_YCbCr: + case JCS_BG_YCC: + if (cinfo->input_components != 3) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + case JCS_CMYK: + case JCS_YCCK: + if (cinfo->input_components != 4) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + default: /* JCS_UNKNOWN can be anything */ + if (cinfo->input_components < 1) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + } + + /* Support color transform only for RGB colorspaces */ + if (cinfo->color_transform && + cinfo->jpeg_color_space != JCS_RGB && + cinfo->jpeg_color_space != JCS_BG_RGB) + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + + /* Check num_components, set conversion method based on requested space */ + switch (cinfo->jpeg_color_space) { + case JCS_GRAYSCALE: + if (cinfo->num_components != 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + switch (cinfo->in_color_space) { + case JCS_GRAYSCALE: + case JCS_YCbCr: + case JCS_BG_YCC: + cconvert->pub.color_convert = grayscale_convert; + break; + case JCS_RGB: + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = rgb_gray_convert; + break; + default: + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + } + break; + + case JCS_RGB: + case JCS_BG_RGB: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space != cinfo->jpeg_color_space) + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + switch (cinfo->color_transform) { + case JCT_NONE: + cconvert->pub.color_convert = rgb_convert; + break; + case JCT_SUBTRACT_GREEN: + cconvert->pub.color_convert = rgb_rgb1_convert; + break; + default: + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + } + break; + + case JCS_YCbCr: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + switch (cinfo->in_color_space) { + case JCS_RGB: + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = rgb_ycc_convert; + break; + case JCS_YCbCr: + cconvert->pub.color_convert = null_convert; + break; + default: + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + } + break; + + case JCS_BG_YCC: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + switch (cinfo->in_color_space) { + case JCS_RGB: + /* For conversion from normal RGB input to BG_YCC representation, + * the Cb/Cr values are first computed as usual, and then + * quantized further after DCT processing by a factor of + * 2 in reference to the nominal quantization factor. + */ + /* need quantization scale by factor of 2 after DCT */ + cinfo->comp_info[1].component_needed = TRUE; + cinfo->comp_info[2].component_needed = TRUE; + /* compute normal YCC first */ + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = rgb_ycc_convert; + break; + case JCS_YCbCr: + /* need quantization scale by factor of 2 after DCT */ + cinfo->comp_info[1].component_needed = TRUE; + cinfo->comp_info[2].component_needed = TRUE; + /*FALLTHROUGH*/ + case JCS_BG_YCC: + /* Pass through for BG_YCC input */ + cconvert->pub.color_convert = null_convert; + break; + default: + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + } + break; + + case JCS_CMYK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space != JCS_CMYK) + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + cconvert->pub.color_convert = null_convert; + break; + + case JCS_YCCK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + switch (cinfo->in_color_space) { + case JCS_CMYK: + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = cmyk_ycck_convert; + break; + case JCS_YCCK: + cconvert->pub.color_convert = null_convert; + break; + default: + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + } + break; + + default: /* allow null conversion of JCS_UNKNOWN */ + if (cinfo->jpeg_color_space != cinfo->in_color_space || + cinfo->num_components != cinfo->input_components) + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + cconvert->pub.color_convert = null_convert; + } +} diff --git a/thirdparty/jpeg-9e/jcdctmgr.c b/thirdparty/jpeg-9e/jcdctmgr.c new file mode 100644 index 0000000..a48ccd8 --- /dev/null +++ b/thirdparty/jpeg-9e/jcdctmgr.c @@ -0,0 +1,466 @@ +/* + * jcdctmgr.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2003-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the forward-DCT management logic. + * This code selects a particular DCT implementation to be used, + * and it performs related housekeeping chores including coefficient + * quantization. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + + +/* Private subobject for this module */ + +typedef struct { + struct jpeg_forward_dct pub; /* public fields */ + + /* Pointer to the DCT routine actually in use */ + forward_DCT_method_ptr do_dct[MAX_COMPONENTS]; + +#ifdef DCT_FLOAT_SUPPORTED + /* Same as above for the floating-point case. */ + float_DCT_method_ptr do_float_dct[MAX_COMPONENTS]; +#endif +} my_fdct_controller; + +typedef my_fdct_controller * my_fdct_ptr; + + +/* The allocated post-DCT divisor tables -- big enough for any + * supported variant and not identical to the quant table entries, + * because of scaling (especially for an unnormalized DCT) -- + * are pointed to by dct_table in the per-component comp_info + * structures. Each table is given in normal array order. + */ + +typedef union { + DCTELEM int_array[DCTSIZE2]; +#ifdef DCT_FLOAT_SUPPORTED + FAST_FLOAT float_array[DCTSIZE2]; +#endif +} divisor_table; + + +/* The current scaled-DCT routines require ISLOW-style divisor tables, + * so be sure to compile that code if either ISLOW or SCALING is requested. + */ +#ifdef DCT_ISLOW_SUPPORTED +#define PROVIDE_ISLOW_TABLES +#else +#ifdef DCT_SCALING_SUPPORTED +#define PROVIDE_ISLOW_TABLES +#endif +#endif + + +/* + * Perform forward DCT on one or more blocks of a component. + * + * The input samples are taken from the sample_data[] array starting at + * position start_col, and moving to the right for any additional blocks. + * The quantized coefficients are returned in coef_blocks[]. + */ + +METHODDEF(void) +forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_col, JDIMENSION num_blocks) +/* This version is used for integer DCT implementations. */ +{ + /* This routine is heavily used, so it's worth coding it tightly. */ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + forward_DCT_method_ptr do_dct = fdct->do_dct[compptr->component_index]; + DCTELEM * divisors = (DCTELEM *) compptr->dct_table; + DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */ + JDIMENSION bi; + + for (bi = 0; bi < num_blocks; bi++, start_col += compptr->DCT_h_scaled_size) { + /* Perform the DCT */ + (*do_dct) (workspace, sample_data, start_col); + + /* Quantize/descale the coefficients, and store into coef_blocks[] */ + { register DCTELEM temp, qval; + register int i; + register JCOEFPTR output_ptr = coef_blocks[bi]; + + for (i = 0; i < DCTSIZE2; i++) { + qval = divisors[i]; + temp = workspace[i]; + /* Divide the coefficient value by qval, ensuring proper rounding. + * Since C does not specify the direction of rounding for negative + * quotients, we have to force the dividend positive for portability. + * + * In most files, at least half of the output values will be zero + * (at default quantization settings, more like three-quarters...) + * so we should ensure that this case is fast. On many machines, + * a comparison is enough cheaper than a divide to make a special test + * a win. Since both inputs will be nonnegative, we need only test + * for a < b to discover whether a/b is 0. + * If your machine's division is fast enough, define FAST_DIVIDE. + */ +#ifdef FAST_DIVIDE +#define DIVIDE_BY(a,b) a /= b +#else +#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 +#endif + if (temp < 0) { + temp = -temp; + temp += qval>>1; /* for rounding */ + DIVIDE_BY(temp, qval); + temp = -temp; + } else { + temp += qval>>1; /* for rounding */ + DIVIDE_BY(temp, qval); + } + output_ptr[i] = (JCOEF) temp; + } + } + } +} + + +#ifdef DCT_FLOAT_SUPPORTED + +METHODDEF(void) +forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_col, JDIMENSION num_blocks) +/* This version is used for floating-point DCT implementations. */ +{ + /* This routine is heavily used, so it's worth coding it tightly. */ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + float_DCT_method_ptr do_dct = fdct->do_float_dct[compptr->component_index]; + FAST_FLOAT * divisors = (FAST_FLOAT *) compptr->dct_table; + FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */ + JDIMENSION bi; + + for (bi = 0; bi < num_blocks; bi++, start_col += compptr->DCT_h_scaled_size) { + /* Perform the DCT */ + (*do_dct) (workspace, sample_data, start_col); + + /* Quantize/descale the coefficients, and store into coef_blocks[] */ + { register FAST_FLOAT temp; + register int i; + register JCOEFPTR output_ptr = coef_blocks[bi]; + + for (i = 0; i < DCTSIZE2; i++) { + /* Apply the quantization and scaling factor */ + temp = workspace[i] * divisors[i]; + /* Round to nearest integer. + * Since C does not specify the direction of rounding for negative + * quotients, we have to force the dividend positive for portability. + * The maximum coefficient size is +-16K (for 12-bit data), so this + * code should work for either 16-bit or 32-bit ints. + */ + output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); + } + } + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ + + +/* + * Initialize for a processing pass. + * Verify that all referenced Q-tables are present, and set up + * the divisor table for each one. + * In the current implementation, DCT of all components is done during + * the first pass, even if only some components will be output in the + * first scan. Hence all components should be examined here. + */ + +METHODDEF(void) +start_pass_fdctmgr (j_compress_ptr cinfo) +{ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + int ci, qtblno, i; + jpeg_component_info *compptr; + int method = 0; + JQUANT_TBL * qtbl; + DCTELEM * dtbl; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Select the proper DCT routine for this component's scaling */ + switch ((compptr->DCT_h_scaled_size << 8) + compptr->DCT_v_scaled_size) { +#ifdef DCT_SCALING_SUPPORTED + case ((1 << 8) + 1): + fdct->do_dct[ci] = jpeg_fdct_1x1; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((2 << 8) + 2): + fdct->do_dct[ci] = jpeg_fdct_2x2; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((3 << 8) + 3): + fdct->do_dct[ci] = jpeg_fdct_3x3; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((4 << 8) + 4): + fdct->do_dct[ci] = jpeg_fdct_4x4; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((5 << 8) + 5): + fdct->do_dct[ci] = jpeg_fdct_5x5; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((6 << 8) + 6): + fdct->do_dct[ci] = jpeg_fdct_6x6; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((7 << 8) + 7): + fdct->do_dct[ci] = jpeg_fdct_7x7; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((9 << 8) + 9): + fdct->do_dct[ci] = jpeg_fdct_9x9; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((10 << 8) + 10): + fdct->do_dct[ci] = jpeg_fdct_10x10; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((11 << 8) + 11): + fdct->do_dct[ci] = jpeg_fdct_11x11; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((12 << 8) + 12): + fdct->do_dct[ci] = jpeg_fdct_12x12; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((13 << 8) + 13): + fdct->do_dct[ci] = jpeg_fdct_13x13; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((14 << 8) + 14): + fdct->do_dct[ci] = jpeg_fdct_14x14; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((15 << 8) + 15): + fdct->do_dct[ci] = jpeg_fdct_15x15; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((16 << 8) + 16): + fdct->do_dct[ci] = jpeg_fdct_16x16; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((16 << 8) + 8): + fdct->do_dct[ci] = jpeg_fdct_16x8; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((14 << 8) + 7): + fdct->do_dct[ci] = jpeg_fdct_14x7; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((12 << 8) + 6): + fdct->do_dct[ci] = jpeg_fdct_12x6; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((10 << 8) + 5): + fdct->do_dct[ci] = jpeg_fdct_10x5; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((8 << 8) + 4): + fdct->do_dct[ci] = jpeg_fdct_8x4; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((6 << 8) + 3): + fdct->do_dct[ci] = jpeg_fdct_6x3; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((4 << 8) + 2): + fdct->do_dct[ci] = jpeg_fdct_4x2; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((2 << 8) + 1): + fdct->do_dct[ci] = jpeg_fdct_2x1; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((8 << 8) + 16): + fdct->do_dct[ci] = jpeg_fdct_8x16; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((7 << 8) + 14): + fdct->do_dct[ci] = jpeg_fdct_7x14; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((6 << 8) + 12): + fdct->do_dct[ci] = jpeg_fdct_6x12; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((5 << 8) + 10): + fdct->do_dct[ci] = jpeg_fdct_5x10; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((4 << 8) + 8): + fdct->do_dct[ci] = jpeg_fdct_4x8; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((3 << 8) + 6): + fdct->do_dct[ci] = jpeg_fdct_3x6; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((2 << 8) + 4): + fdct->do_dct[ci] = jpeg_fdct_2x4; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; + case ((1 << 8) + 2): + fdct->do_dct[ci] = jpeg_fdct_1x2; + method = JDCT_ISLOW; /* jfdctint uses islow-style table */ + break; +#endif + case ((DCTSIZE << 8) + DCTSIZE): + switch (cinfo->dct_method) { +#ifdef DCT_ISLOW_SUPPORTED + case JDCT_ISLOW: + fdct->do_dct[ci] = jpeg_fdct_islow; + method = JDCT_ISLOW; + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + fdct->do_dct[ci] = jpeg_fdct_ifast; + method = JDCT_IFAST; + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + fdct->do_float_dct[ci] = jpeg_fdct_float; + method = JDCT_FLOAT; + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + } + break; + default: + ERREXIT2(cinfo, JERR_BAD_DCTSIZE, + compptr->DCT_h_scaled_size, compptr->DCT_v_scaled_size); + } + qtblno = compptr->quant_tbl_no; + /* Make sure specified quantization table is present */ + if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || + cinfo->quant_tbl_ptrs[qtblno] == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); + qtbl = cinfo->quant_tbl_ptrs[qtblno]; + /* Create divisor table from quant table */ + switch (method) { +#ifdef PROVIDE_ISLOW_TABLES + case JDCT_ISLOW: + /* For LL&M IDCT method, divisors are equal to raw quantization + * coefficients multiplied by 8 (to counteract scaling). + */ + dtbl = (DCTELEM *) compptr->dct_table; + for (i = 0; i < DCTSIZE2; i++) { + dtbl[i] = + ((DCTELEM) qtbl->quantval[i]) << (compptr->component_needed ? 4 : 3); + } + fdct->pub.forward_DCT[ci] = forward_DCT; + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + { + /* For AA&N IDCT method, divisors are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * We apply a further scale factor of 8. + */ +#define CONST_BITS 14 + static const INT16 aanscales[DCTSIZE2] = { + /* precomputed values scaled up by 14 bits */ + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, + 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, + 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, + 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, + 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 + }; + SHIFT_TEMPS + + dtbl = (DCTELEM *) compptr->dct_table; + for (i = 0; i < DCTSIZE2; i++) { + dtbl[i] = (DCTELEM) + DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], + (INT32) aanscales[i]), + compptr->component_needed ? CONST_BITS-4 : CONST_BITS-3); + } + } + fdct->pub.forward_DCT[ci] = forward_DCT; + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + { + /* For float AA&N IDCT method, divisors are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * We apply a further scale factor of 8. + * What's actually stored is 1/divisor so that the inner loop can + * use a multiplication rather than a division. + */ + FAST_FLOAT * fdtbl = (FAST_FLOAT *) compptr->dct_table; + int row, col; + static const double aanscalefactor[DCTSIZE] = { + 1.0, 1.387039845, 1.306562965, 1.175875602, + 1.0, 0.785694958, 0.541196100, 0.275899379 + }; + + i = 0; + for (row = 0; row < DCTSIZE; row++) { + for (col = 0; col < DCTSIZE; col++) { + fdtbl[i] = (FAST_FLOAT) + (1.0 / ((double) qtbl->quantval[i] * + aanscalefactor[row] * aanscalefactor[col] * + (compptr->component_needed ? 16.0 : 8.0))); + i++; + } + } + } + fdct->pub.forward_DCT[ci] = forward_DCT_float; + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + } + } +} + + +/* + * Initialize FDCT manager. + */ + +GLOBAL(void) +jinit_forward_dct (j_compress_ptr cinfo) +{ + my_fdct_ptr fdct; + int ci; + jpeg_component_info *compptr; + + fdct = (my_fdct_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_fdct_controller)); + cinfo->fdct = &fdct->pub; + fdct->pub.start_pass = start_pass_fdctmgr; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Allocate a divisor table for each component */ + compptr->dct_table = (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(divisor_table)); + } +} diff --git a/thirdparty/jpeg-9e/jchuff.c b/thirdparty/jpeg-9e/jchuff.c new file mode 100644 index 0000000..f3272c9 --- /dev/null +++ b/thirdparty/jpeg-9e/jchuff.c @@ -0,0 +1,1640 @@ +/* + * jchuff.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 2006-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy encoding routines. + * Both sequential and progressive modes are supported in this single module. + * + * Much of the complexity here has to do with supporting output suspension. + * If the data destination module demands suspension, we want to be able to + * back up to the start of the current MCU. To do this, we copy state + * variables into local working storage, and update them back to the + * permanent JPEG objects only upon successful completion of an MCU. + * + * We do not support output suspension for the progressive JPEG mode, since + * the library currently does not allow multiple-scan files to be written + * with output suspension. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* The legal range of a DCT coefficient is + * -1024 .. +1023 for 8-bit data; + * -16384 .. +16383 for 12-bit data. + * Hence the magnitude should always fit in 10 or 14 bits respectively. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MAX_COEF_BITS 10 +#else +#define MAX_COEF_BITS 14 +#endif + +/* Derived data constructed for each Huffman table */ + +typedef struct { + unsigned int ehufco[256]; /* code for each symbol */ + char ehufsi[256]; /* length of code for each symbol */ + /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ +} c_derived_tbl; + + +/* Expanded entropy encoder object for Huffman encoding. + * + * The savable_state subrecord contains fields that change within an MCU, + * but must not be updated permanently until we complete the MCU. + */ + +typedef struct { + INT32 put_buffer; /* current bit-accumulation buffer */ + int put_bits; /* # of bits now in it */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ +} savable_state; + +/* This macro is to work around compilers with missing or broken + * structure assignment. You'll need to fix this code if you have + * such a compiler and you change MAX_COMPS_IN_SCAN. + */ + +#ifndef NO_STRUCT_ASSIGN +#define ASSIGN_STATE(dest,src) ((dest) = (src)) +#else +#if MAX_COMPS_IN_SCAN == 4 +#define ASSIGN_STATE(dest,src) \ + ((dest).put_buffer = (src).put_buffer, \ + (dest).put_bits = (src).put_bits, \ + (dest).last_dc_val[0] = (src).last_dc_val[0], \ + (dest).last_dc_val[1] = (src).last_dc_val[1], \ + (dest).last_dc_val[2] = (src).last_dc_val[2], \ + (dest).last_dc_val[3] = (src).last_dc_val[3]) +#endif +#endif + + +typedef struct { + struct jpeg_entropy_encoder pub; /* public fields */ + + savable_state saved; /* Bit buffer & DC state at start of MCU */ + + /* These fields are NOT loaded into local working state. */ + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + int next_restart_num; /* next restart number to write (0-7) */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; + c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; + + /* Statistics tables for optimization */ + long * dc_count_ptrs[NUM_HUFF_TBLS]; + long * ac_count_ptrs[NUM_HUFF_TBLS]; + + /* Following fields used only in progressive mode */ + + /* Mode flag: TRUE for optimization, FALSE for actual data output */ + boolean gather_statistics; + + /* next_output_byte/free_in_buffer are local copies of cinfo->dest fields. + */ + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */ + + /* Coding status for AC components */ + int ac_tbl_no; /* the table number of the single component */ + unsigned int EOBRUN; /* run length of EOBs */ + unsigned int BE; /* # of buffered correction bits before MCU */ + char * bit_buffer; /* buffer for correction bits (1 per char) */ + /* packing correction bits tightly would save some space but cost time... */ +} huff_entropy_encoder; + +typedef huff_entropy_encoder * huff_entropy_ptr; + +/* Working state while writing an MCU (sequential mode). + * This struct contains all the fields that are needed by subroutines. + */ + +typedef struct { + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + savable_state cur; /* Current bit buffer & DC state */ + j_compress_ptr cinfo; /* dump_buffer needs access to this */ +} working_state; + +/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit + * buffer can hold. Larger sizes may slightly improve compression, but + * 1000 is already well into the realm of overkill. + * The minimum safe size is 64 bits. + */ + +#define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */ + +/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32. + * We assume that int right shift is unsigned if INT32 right shift is, + * which should be safe. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define ISHIFT_TEMPS int ishift_temp; +#define IRIGHT_SHIFT(x,shft) \ + ((ishift_temp = (x)) < 0 ? \ + (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \ + (ishift_temp >> (shft))) +#else +#define ISHIFT_TEMPS +#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + + +/* + * Compute the derived values for a Huffman table. + * This routine also performs some validation checks on the table. + */ + +LOCAL(void) +jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno, + c_derived_tbl ** pdtbl) +{ + JHUFF_TBL *htbl; + c_derived_tbl *dtbl; + int p, i, l, lastp, si, maxsymbol; + char huffsize[257]; + unsigned int huffcode[257]; + unsigned int code; + + /* Note that huffsize[] and huffcode[] are filled in code-length order, + * paralleling the order of the symbols themselves in htbl->huffval[]. + */ + + /* Find the input Huffman table */ + if (tblno < 0 || tblno >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); + htbl = + isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; + if (htbl == NULL) + htbl = jpeg_std_huff_table((j_common_ptr) cinfo, isDC, tblno); + + /* Allocate a workspace if we haven't already done so. */ + if (*pdtbl == NULL) + *pdtbl = (c_derived_tbl *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(c_derived_tbl)); + dtbl = *pdtbl; + + /* Figure C.1: make table of Huffman code length for each symbol */ + + p = 0; + for (l = 1; l <= 16; l++) { + i = (int) htbl->bits[l]; + if (i < 0 || p + i > 256) /* protect against table overrun */ + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + while (i--) + huffsize[p++] = (char) l; + } + huffsize[p] = 0; + lastp = p; + + /* Figure C.2: generate the codes themselves */ + /* We also validate that the counts represent a legal Huffman code tree. */ + + code = 0; + si = huffsize[0]; + p = 0; + while (huffsize[p]) { + while (((int) huffsize[p]) == si) { + huffcode[p++] = code; + code++; + } + /* code is now 1 more than the last code used for codelength si; but + * it must still fit in si bits, since no code is allowed to be all ones. + */ + if (((INT32) code) >= (((INT32) 1) << si)) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + code <<= 1; + si++; + } + + /* Figure C.3: generate encoding tables */ + /* These are code and size indexed by symbol value */ + + /* Set all codeless symbols to have code length 0; + * this lets us detect duplicate VAL entries here, and later + * allows emit_bits to detect any attempt to emit such symbols. + */ + MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi)); + + /* This is also a convenient place to check for out-of-range + * and duplicated VAL entries. We allow 0..255 for AC symbols + * but only 0..15 for DC. (We could constrain them further + * based on data depth and mode, but this seems enough.) + */ + maxsymbol = isDC ? 15 : 255; + + for (p = 0; p < lastp; p++) { + i = htbl->huffval[p]; + if (i < 0 || i > maxsymbol || dtbl->ehufsi[i]) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + dtbl->ehufco[i] = huffcode[p]; + dtbl->ehufsi[i] = huffsize[p]; + } +} + + +/* Outputting bytes to the file. + * NB: these must be called only when actually outputting, + * that is, entropy->gather_statistics == FALSE. + */ + +/* Emit a byte, taking 'action' if must suspend. */ +#define emit_byte_s(state,val,action) \ + { *(state)->next_output_byte++ = (JOCTET) (val); \ + if (--(state)->free_in_buffer == 0) \ + if (! dump_buffer_s(state)) \ + { action; } } + +/* Emit a byte */ +#define emit_byte_e(entropy,val) \ + { *(entropy)->next_output_byte++ = (JOCTET) (val); \ + if (--(entropy)->free_in_buffer == 0) \ + dump_buffer_e(entropy); } + + +LOCAL(boolean) +dump_buffer_s (working_state * state) +/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */ +{ + struct jpeg_destination_mgr * dest = state->cinfo->dest; + + if (! (*dest->empty_output_buffer) (state->cinfo)) + return FALSE; + /* After a successful buffer dump, must reset buffer pointers */ + state->next_output_byte = dest->next_output_byte; + state->free_in_buffer = dest->free_in_buffer; + return TRUE; +} + + +LOCAL(void) +dump_buffer_e (huff_entropy_ptr entropy) +/* Empty the output buffer; we do not support suspension in this case. */ +{ + struct jpeg_destination_mgr * dest = entropy->cinfo->dest; + + if (! (*dest->empty_output_buffer) (entropy->cinfo)) + ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); + /* After a successful buffer dump, must reset buffer pointers */ + entropy->next_output_byte = dest->next_output_byte; + entropy->free_in_buffer = dest->free_in_buffer; +} + + +/* Outputting bits to the file */ + +/* Only the right 24 bits of put_buffer are used; the valid bits are + * left-justified in this part. At most 16 bits can be passed to emit_bits + * in one call, and we never retain more than 7 bits in put_buffer + * between calls, so 24 bits are sufficient. + */ + +INLINE +LOCAL(boolean) +emit_bits_s (working_state * state, unsigned int code, int size) +/* Emit some bits; return TRUE if successful, FALSE if must suspend */ +{ + /* This routine is heavily used, so it's worth coding tightly. */ + register INT32 put_buffer; + register int put_bits; + + /* if size is 0, caller used an invalid Huffman table entry */ + if (size == 0) + ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE); + + /* mask off any extra bits in code */ + put_buffer = ((INT32) code) & ((((INT32) 1) << size) - 1); + + /* new number of bits in buffer */ + put_bits = size + state->cur.put_bits; + + put_buffer <<= 24 - put_bits; /* align incoming bits */ + + /* and merge with old buffer contents */ + put_buffer |= state->cur.put_buffer; + + while (put_bits >= 8) { + int c = (int) ((put_buffer >> 16) & 0xFF); + + emit_byte_s(state, c, return FALSE); + if (c == 0xFF) { /* need to stuff a zero byte? */ + emit_byte_s(state, 0, return FALSE); + } + put_buffer <<= 8; + put_bits -= 8; + } + + state->cur.put_buffer = put_buffer; /* update state variables */ + state->cur.put_bits = put_bits; + + return TRUE; +} + + +INLINE +LOCAL(void) +emit_bits_e (huff_entropy_ptr entropy, unsigned int code, int size) +/* Emit some bits, unless we are in gather mode */ +{ + /* This routine is heavily used, so it's worth coding tightly. */ + register INT32 put_buffer; + register int put_bits; + + /* if size is 0, caller used an invalid Huffman table entry */ + if (size == 0) + ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); + + if (entropy->gather_statistics) + return; /* do nothing if we're only getting stats */ + + /* mask off any extra bits in code */ + put_buffer = ((INT32) code) & ((((INT32) 1) << size) - 1); + + /* new number of bits in buffer */ + put_bits = size + entropy->saved.put_bits; + + put_buffer <<= 24 - put_bits; /* align incoming bits */ + + /* and merge with old buffer contents */ + put_buffer |= entropy->saved.put_buffer; + + while (put_bits >= 8) { + int c = (int) ((put_buffer >> 16) & 0xFF); + + emit_byte_e(entropy, c); + if (c == 0xFF) { /* need to stuff a zero byte? */ + emit_byte_e(entropy, 0); + } + put_buffer <<= 8; + put_bits -= 8; + } + + entropy->saved.put_buffer = put_buffer; /* update variables */ + entropy->saved.put_bits = put_bits; +} + + +LOCAL(boolean) +flush_bits_s (working_state * state) +{ + if (! emit_bits_s(state, 0x7F, 7)) /* fill any partial byte with ones */ + return FALSE; + state->cur.put_buffer = 0; /* and reset bit-buffer to empty */ + state->cur.put_bits = 0; + return TRUE; +} + + +LOCAL(void) +flush_bits_e (huff_entropy_ptr entropy) +{ + emit_bits_e(entropy, 0x7F, 7); /* fill any partial byte with ones */ + entropy->saved.put_buffer = 0; /* and reset bit-buffer to empty */ + entropy->saved.put_bits = 0; +} + + +/* + * Emit (or just count) a Huffman symbol. + */ + +INLINE +LOCAL(void) +emit_dc_symbol (huff_entropy_ptr entropy, int tbl_no, int symbol) +{ + if (entropy->gather_statistics) + entropy->dc_count_ptrs[tbl_no][symbol]++; + else { + c_derived_tbl * tbl = entropy->dc_derived_tbls[tbl_no]; + emit_bits_e(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); + } +} + + +INLINE +LOCAL(void) +emit_ac_symbol (huff_entropy_ptr entropy, int tbl_no, int symbol) +{ + if (entropy->gather_statistics) + entropy->ac_count_ptrs[tbl_no][symbol]++; + else { + c_derived_tbl * tbl = entropy->ac_derived_tbls[tbl_no]; + emit_bits_e(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); + } +} + + +/* + * Emit bits from a correction bit buffer. + */ + +LOCAL(void) +emit_buffered_bits (huff_entropy_ptr entropy, char * bufstart, + unsigned int nbits) +{ + if (entropy->gather_statistics) + return; /* no real work */ + + while (nbits > 0) { + emit_bits_e(entropy, (unsigned int) (*bufstart), 1); + bufstart++; + nbits--; + } +} + + +/* + * Emit any pending EOBRUN symbol. + */ + +LOCAL(void) +emit_eobrun (huff_entropy_ptr entropy) +{ + register int temp, nbits; + + if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ + temp = entropy->EOBRUN; + nbits = 0; + while ((temp >>= 1)) + nbits++; + /* safety check: shouldn't happen given limited correction-bit buffer */ + if (nbits > 14) + ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); + + emit_ac_symbol(entropy, entropy->ac_tbl_no, nbits << 4); + if (nbits) + emit_bits_e(entropy, entropy->EOBRUN, nbits); + + entropy->EOBRUN = 0; + + /* Emit any buffered correction bits */ + emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); + entropy->BE = 0; + } +} + + +/* + * Emit a restart marker & resynchronize predictions. + */ + +LOCAL(boolean) +emit_restart_s (working_state * state, int restart_num) +{ + int ci; + + if (! flush_bits_s(state)) + return FALSE; + + emit_byte_s(state, 0xFF, return FALSE); + emit_byte_s(state, JPEG_RST0 + restart_num, return FALSE); + + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < state->cinfo->comps_in_scan; ci++) + state->cur.last_dc_val[ci] = 0; + + /* The restart counter is not updated until we successfully write the MCU. */ + + return TRUE; +} + + +LOCAL(void) +emit_restart_e (huff_entropy_ptr entropy, int restart_num) +{ + int ci; + + emit_eobrun(entropy); + + if (! entropy->gather_statistics) { + flush_bits_e(entropy); + emit_byte_e(entropy, 0xFF); + emit_byte_e(entropy, JPEG_RST0 + restart_num); + } + + if (entropy->cinfo->Ss == 0) { + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + } else { + /* Re-initialize all AC-related fields to 0 */ + entropy->EOBRUN = 0; + entropy->BE = 0; + } +} + + +/* + * MCU encoding for DC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + register int temp, temp2; + register int nbits; + int blkn, ci, tbl; + ISHIFT_TEMPS + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart_e(entropy, entropy->next_restart_num); + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + tbl = cinfo->cur_comp_info[ci]->dc_tbl_no; + + /* Compute the DC value after the required point transform by Al. + * This is simply an arithmetic right shift. + */ + temp = IRIGHT_SHIFT((int) (MCU_data[blkn][0][0]), cinfo->Al); + + /* DC differences are figured on the point-transformed values. */ + temp2 = temp - entropy->saved.last_dc_val[ci]; + entropy->saved.last_dc_val[ci] = temp; + + /* Encode the DC coefficient difference per section G.1.2.1 */ + temp = temp2; + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* For a negative input, want temp2 = bitwise complement of abs(input) */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + /* Check for out-of-range coefficient values. + * Since we're encoding a difference, the range limit is twice as much. + */ + if (nbits > MAX_COEF_BITS+1) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count/emit the Huffman-coded symbol for the number of bits */ + emit_dc_symbol(entropy, tbl, nbits); + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (nbits) /* emit_bits rejects calls with size 0 */ + emit_bits_e(entropy, (unsigned int) temp2, nbits); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for AC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + const int * natural_order; + JBLOCKROW block; + register int temp, temp2; + register int nbits; + register int r, k; + int Se, Al; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart_e(entropy, entropy->next_restart_num); + + Se = cinfo->Se; + Al = cinfo->Al; + natural_order = cinfo->natural_order; + + /* Encode the MCU data block */ + block = MCU_data[0]; + + /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */ + + r = 0; /* r = run length of zeros */ + + for (k = cinfo->Ss; k <= Se; k++) { + if ((temp = (*block)[natural_order[k]]) == 0) { + r++; + continue; + } + /* We must apply the point transform by Al. For AC coefficients this + * is an integer division with rounding towards 0. To do this portably + * in C, we shift after obtaining the absolute value; so the code is + * interwoven with finding the abs value (temp) and output bits (temp2). + */ + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + temp >>= Al; /* apply the point transform */ + /* For a negative coef, want temp2 = bitwise complement of abs(coef) */ + temp2 = ~temp; + } else { + temp >>= Al; /* apply the point transform */ + temp2 = temp; + } + /* Watch out for case that nonzero coef is zero after point transform */ + if (temp == 0) { + r++; + continue; + } + + /* Emit any pending EOBRUN */ + if (entropy->EOBRUN > 0) + emit_eobrun(entropy); + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + emit_ac_symbol(entropy, entropy->ac_tbl_no, 0xF0); + r -= 16; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + /* Check for out-of-range coefficient values */ + if (nbits > MAX_COEF_BITS) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count/emit Huffman symbol for run length / number of bits */ + emit_ac_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + emit_bits_e(entropy, (unsigned int) temp2, nbits); + + r = 0; /* reset zero run length */ + } + + if (r > 0) { /* If there are trailing zeroes, */ + entropy->EOBRUN++; /* count an EOB */ + if (entropy->EOBRUN == 0x7FFF) + emit_eobrun(entropy); /* force it out to avoid overflow */ + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for DC successive approximation refinement scan. + * Note: we assume such scans can be multi-component, + * although the spec is not very clear on the point. + */ + +METHODDEF(boolean) +encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int Al, blkn; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart_e(entropy, entropy->next_restart_num); + + Al = cinfo->Al; + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + /* We simply emit the Al'th bit of the DC coefficient value. */ + emit_bits_e(entropy, (unsigned int) (MCU_data[blkn][0][0] >> Al), 1); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for AC successive approximation refinement scan. + */ + +METHODDEF(boolean) +encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + const int * natural_order; + JBLOCKROW block; + register int temp; + register int r, k; + int Se, Al; + int EOB; + char *BR_buffer; + unsigned int BR; + int absvalues[DCTSIZE2]; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart_e(entropy, entropy->next_restart_num); + + Se = cinfo->Se; + Al = cinfo->Al; + natural_order = cinfo->natural_order; + + /* Encode the MCU data block */ + block = MCU_data[0]; + + /* It is convenient to make a pre-pass to determine the transformed + * coefficients' absolute values and the EOB position. + */ + EOB = 0; + for (k = cinfo->Ss; k <= Se; k++) { + temp = (*block)[natural_order[k]]; + /* We must apply the point transform by Al. For AC coefficients this + * is an integer division with rounding towards 0. To do this portably + * in C, we shift after obtaining the absolute value. + */ + if (temp < 0) + temp = -temp; /* temp is abs value of input */ + temp >>= Al; /* apply the point transform */ + absvalues[k] = temp; /* save abs value for main pass */ + if (temp == 1) + EOB = k; /* EOB = index of last newly-nonzero coef */ + } + + /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */ + + r = 0; /* r = run length of zeros */ + BR = 0; /* BR = count of buffered bits added now */ + BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ + + for (k = cinfo->Ss; k <= Se; k++) { + if ((temp = absvalues[k]) == 0) { + r++; + continue; + } + + /* Emit any required ZRLs, but not if they can be folded into EOB */ + while (r > 15 && k <= EOB) { + /* emit any pending EOBRUN and the BE correction bits */ + emit_eobrun(entropy); + /* Emit ZRL */ + emit_ac_symbol(entropy, entropy->ac_tbl_no, 0xF0); + r -= 16; + /* Emit buffered correction bits that must be associated with ZRL */ + emit_buffered_bits(entropy, BR_buffer, BR); + BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ + BR = 0; + } + + /* If the coef was previously nonzero, it only needs a correction bit. + * NOTE: a straight translation of the spec's figure G.7 would suggest + * that we also need to test r > 15. But if r > 15, we can only get here + * if k > EOB, which implies that this coefficient is not 1. + */ + if (temp > 1) { + /* The correction bit is the next bit of the absolute value. */ + BR_buffer[BR++] = (char) (temp & 1); + continue; + } + + /* Emit any pending EOBRUN and the BE correction bits */ + emit_eobrun(entropy); + + /* Count/emit Huffman symbol for run length / number of bits */ + emit_ac_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); + + /* Emit output bit for newly-nonzero coef */ + temp = ((*block)[natural_order[k]] < 0) ? 0 : 1; + emit_bits_e(entropy, (unsigned int) temp, 1); + + /* Emit buffered correction bits that must be associated with this code */ + emit_buffered_bits(entropy, BR_buffer, BR); + BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ + BR = 0; + r = 0; /* reset zero run length */ + } + + if (r > 0 || BR > 0) { /* If there are trailing zeroes, */ + entropy->EOBRUN++; /* count an EOB */ + entropy->BE += BR; /* concat my correction bits to older ones */ + /* We force out the EOB if we risk either: + * 1. overflow of the EOB counter; + * 2. overflow of the correction bit buffer during the next MCU. + */ + if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1)) + emit_eobrun(entropy); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* Encode a single block's worth of coefficients */ + +LOCAL(boolean) +encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val, + c_derived_tbl *dctbl, c_derived_tbl *actbl) +{ + register int temp, temp2; + register int nbits; + register int r, k; + int Se = state->cinfo->lim_Se; + const int * natural_order = state->cinfo->natural_order; + + /* Encode the DC coefficient difference per section F.1.2.1 */ + + temp = temp2 = block[0] - last_dc_val; + + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* For a negative input, want temp2 = bitwise complement of abs(input) */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + /* Check for out-of-range coefficient values. + * Since we're encoding a difference, the range limit is twice as much. + */ + if (nbits > MAX_COEF_BITS+1) + ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); + + /* Emit the Huffman-coded symbol for the number of bits */ + if (! emit_bits_s(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits])) + return FALSE; + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (nbits) /* emit_bits rejects calls with size 0 */ + if (! emit_bits_s(state, (unsigned int) temp2, nbits)) + return FALSE; + + /* Encode the AC coefficients per section F.1.2.2 */ + + r = 0; /* r = run length of zeros */ + + for (k = 1; k <= Se; k++) { + if ((temp2 = block[natural_order[k]]) == 0) { + r++; + } else { + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + if (! emit_bits_s(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0])) + return FALSE; + r -= 16; + } + + temp = temp2; + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + /* Check for out-of-range coefficient values */ + if (nbits > MAX_COEF_BITS) + ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); + + /* Emit Huffman symbol for run length / number of bits */ + temp = (r << 4) + nbits; + if (! emit_bits_s(state, actbl->ehufco[temp], actbl->ehufsi[temp])) + return FALSE; + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (! emit_bits_s(state, (unsigned int) temp2, nbits)) + return FALSE; + + r = 0; + } + } + + /* If the last coef(s) were zero, emit an end-of-block code */ + if (r > 0) + if (! emit_bits_s(state, actbl->ehufco[0], actbl->ehufsi[0])) + return FALSE; + + return TRUE; +} + + +/* + * Encode and output one MCU's worth of Huffman-compressed coefficients. + */ + +METHODDEF(boolean) +encode_mcu_huff (j_compress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + working_state state; + int blkn, ci; + jpeg_component_info * compptr; + + /* Load up working state */ + state.next_output_byte = cinfo->dest->next_output_byte; + state.free_in_buffer = cinfo->dest->free_in_buffer; + ASSIGN_STATE(state.cur, entropy->saved); + state.cinfo = cinfo; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! emit_restart_s(&state, entropy->next_restart_num)) + return FALSE; + } + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + if (! encode_one_block(&state, + MCU_data[blkn][0], state.cur.last_dc_val[ci], + entropy->dc_derived_tbls[compptr->dc_tbl_no], + entropy->ac_derived_tbls[compptr->ac_tbl_no])) + return FALSE; + /* Update last_dc_val */ + state.cur.last_dc_val[ci] = MCU_data[blkn][0][0]; + } + + /* Completed MCU, so update state */ + cinfo->dest->next_output_byte = state.next_output_byte; + cinfo->dest->free_in_buffer = state.free_in_buffer; + ASSIGN_STATE(entropy->saved, state.cur); + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * Finish up at the end of a Huffman-compressed scan. + */ + +METHODDEF(void) +finish_pass_huff (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + working_state state; + + if (cinfo->progressive_mode) { + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Flush out any buffered data */ + emit_eobrun(entropy); + flush_bits_e(entropy); + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + } else { + /* Load up working state ... flush_bits needs it */ + state.next_output_byte = cinfo->dest->next_output_byte; + state.free_in_buffer = cinfo->dest->free_in_buffer; + ASSIGN_STATE(state.cur, entropy->saved); + state.cinfo = cinfo; + + /* Flush out the last data */ + if (! flush_bits_s(&state)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + + /* Update state */ + cinfo->dest->next_output_byte = state.next_output_byte; + cinfo->dest->free_in_buffer = state.free_in_buffer; + ASSIGN_STATE(entropy->saved, state.cur); + } +} + + +/* + * Huffman coding optimization. + * + * We first scan the supplied data and count the number of uses of each symbol + * that is to be Huffman-coded. (This process MUST agree with the code above.) + * Then we build a Huffman coding tree for the observed counts. + * Symbols which are not needed at all for the particular image are not + * assigned any code, which saves space in the DHT marker as well as in + * the compressed data. + */ + + +/* Process a single block's worth of coefficients */ + +LOCAL(void) +htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val, + long dc_counts[], long ac_counts[]) +{ + register int temp; + register int nbits; + register int r, k; + int Se = cinfo->lim_Se; + const int * natural_order = cinfo->natural_order; + + /* Encode the DC coefficient difference per section F.1.2.1 */ + + temp = block[0] - last_dc_val; + if (temp < 0) + temp = -temp; + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + /* Check for out-of-range coefficient values. + * Since we're encoding a difference, the range limit is twice as much. + */ + if (nbits > MAX_COEF_BITS+1) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count the Huffman symbol for the number of bits */ + dc_counts[nbits]++; + + /* Encode the AC coefficients per section F.1.2.2 */ + + r = 0; /* r = run length of zeros */ + + for (k = 1; k <= Se; k++) { + if ((temp = block[natural_order[k]]) == 0) { + r++; + } else { + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + ac_counts[0xF0]++; + r -= 16; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + if (temp < 0) + temp = -temp; + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + /* Check for out-of-range coefficient values */ + if (nbits > MAX_COEF_BITS) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count Huffman symbol for run length / number of bits */ + ac_counts[(r << 4) + nbits]++; + + r = 0; + } + } + + /* If the last coef(s) were zero, emit an end-of-block code */ + if (r > 0) + ac_counts[0]++; +} + + +/* + * Trial-encode one MCU's worth of Huffman-compressed coefficients. + * No data is actually output, so no suspension return is possible. + */ + +METHODDEF(boolean) +encode_mcu_gather (j_compress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int blkn, ci; + jpeg_component_info * compptr; + + /* Take care of restart intervals if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + /* Update restart state */ + entropy->restarts_to_go = cinfo->restart_interval; + } + entropy->restarts_to_go--; + } + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci], + entropy->dc_count_ptrs[compptr->dc_tbl_no], + entropy->ac_count_ptrs[compptr->ac_tbl_no]); + entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0]; + } + + return TRUE; +} + + +/* + * Generate the best Huffman code table for the given counts, fill htbl. + * + * The JPEG standard requires that no symbol be assigned a codeword of all + * one bits (so that padding bits added at the end of a compressed segment + * can't look like a valid code). Because of the canonical ordering of + * codewords, this just means that there must be an unused slot in the + * longest codeword length category. Section K.2 of the JPEG spec suggests + * reserving such a slot by pretending that symbol 256 is a valid symbol + * with count 1. In theory that's not optimal; giving it count zero but + * including it in the symbol set anyway should give a better Huffman code. + * But the theoretically better code actually seems to come out worse in + * practice, because it produces more all-ones bytes (which incur stuffed + * zero bytes in the final file). In any case the difference is tiny. + * + * The JPEG standard requires Huffman codes to be no more than 16 bits long. + * If some symbols have a very small but nonzero probability, the Huffman tree + * must be adjusted to meet the code length restriction. We currently use + * the adjustment method suggested in JPEG section K.2. This method is *not* + * optimal; it may not choose the best possible limited-length code. But + * typically only very-low-frequency symbols will be given less-than-optimal + * lengths, so the code is almost optimal. Experimental comparisons against + * an optimal limited-length-code algorithm indicate that the difference is + * microscopic --- usually less than a hundredth of a percent of total size. + * So the extra complexity of an optimal algorithm doesn't seem worthwhile. + */ + +LOCAL(void) +jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]) +{ +#define MAX_CLEN 32 /* assumed maximum initial code length */ + UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */ + int codesize[257]; /* codesize[k] = code length of symbol k */ + int others[257]; /* next symbol in current branch of tree */ + int c1, c2, i, j; + UINT8 *p; + long v; + + freq[256] = 1; /* make sure 256 has a nonzero count */ + /* Including the pseudo-symbol 256 in the Huffman procedure guarantees + * that no real symbol is given code-value of all ones, because 256 + * will be placed last in the largest codeword category. + * In the symbol list build procedure this element serves as sentinel + * for the zero run loop. + */ + +#ifndef DONT_USE_FANCY_HUFF_OPT + + /* Build list of symbols sorted in order of descending frequency */ + /* This approach has several benefits (thank to John Korejwa for the idea): + * 1. + * If a codelength category is split during the length limiting procedure + * below, the feature that more frequent symbols are assigned shorter + * codewords remains valid for the adjusted code. + * 2. + * To reduce consecutive ones in a Huffman data stream (thus reducing the + * number of stuff bytes in JPEG) it is preferable to follow 0 branches + * (and avoid 1 branches) as much as possible. This is easily done by + * assigning symbols to leaves of the Huffman tree in order of decreasing + * frequency, with no secondary sort based on codelengths. + * 3. + * The symbol list can be built independently from the assignment of code + * lengths by the Huffman procedure below. + * Note: The symbol list build procedure must be performed first, because + * the Huffman procedure assigning the codelengths clobbers the frequency + * counts! + */ + + /* Here we use the others array as a linked list of nonzero frequencies + * to be sorted. Already sorted elements are removed from the list. + */ + + /* Building list */ + + /* This item does not correspond to a valid symbol frequency and is used + * as starting index. + */ + j = 256; + + for (i = 0;; i++) { + if (freq[i] == 0) /* skip zero frequencies */ + continue; + if (i > 255) + break; + others[j] = i; /* this symbol value */ + j = i; /* previous symbol value */ + } + others[j] = -1; /* mark end of list */ + + /* Sorting list */ + + p = htbl->huffval; + while ((c1 = others[256]) >= 0) { + v = freq[c1]; + i = c1; /* first symbol value */ + j = 256; /* pseudo symbol value for starting index */ + while ((c2 = others[c1]) >= 0) { + if (freq[c2] > v) { + v = freq[c2]; + i = c2; /* this symbol value */ + j = c1; /* previous symbol value */ + } + c1 = c2; + } + others[j] = others[i]; /* remove this symbol i from list */ + *p++ = (UINT8) i; + } + +#endif /* DONT_USE_FANCY_HUFF_OPT */ + + /* This algorithm is explained in section K.2 of the JPEG standard */ + + MEMZERO(bits, SIZEOF(bits)); + MEMZERO(codesize, SIZEOF(codesize)); + for (i = 0; i < 257; i++) + others[i] = -1; /* init links to empty */ + + /* Huffman's basic algorithm to assign optimal code lengths to symbols */ + + for (;;) { + /* Find the smallest nonzero frequency, set c1 = its symbol */ + /* In case of ties, take the larger symbol number */ + c1 = -1; + v = 1000000000L; + for (i = 0; i <= 256; i++) { + if (freq[i] && freq[i] <= v) { + v = freq[i]; + c1 = i; + } + } + + /* Find the next smallest nonzero frequency, set c2 = its symbol */ + /* In case of ties, take the larger symbol number */ + c2 = -1; + v = 1000000000L; + for (i = 0; i <= 256; i++) { + if (freq[i] && freq[i] <= v && i != c1) { + v = freq[i]; + c2 = i; + } + } + + /* Done if we've merged everything into one frequency */ + if (c2 < 0) + break; + + /* Else merge the two counts/trees */ + freq[c1] += freq[c2]; + freq[c2] = 0; + + /* Increment the codesize of everything in c1's tree branch */ + codesize[c1]++; + while (others[c1] >= 0) { + c1 = others[c1]; + codesize[c1]++; + } + + others[c1] = c2; /* chain c2 onto c1's tree branch */ + + /* Increment the codesize of everything in c2's tree branch */ + codesize[c2]++; + while (others[c2] >= 0) { + c2 = others[c2]; + codesize[c2]++; + } + } + + /* Now count the number of symbols of each code length */ + for (i = 0; i <= 256; i++) { + if (codesize[i]) { + /* The JPEG standard seems to think that this can't happen, */ + /* but I'm paranoid... */ + if (codesize[i] > MAX_CLEN) + ERREXIT(cinfo, JERR_HUFF_CLEN_OUTOFBOUNDS); + + bits[codesize[i]]++; + } + } + + /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure + * Huffman procedure assigned any such lengths, we must adjust the coding. + * Here is what the JPEG spec says about how this next bit works: + * Since symbols are paired for the longest Huffman code, the symbols are + * removed from this length category two at a time. The prefix for the pair + * (which is one bit shorter) is allocated to one of the pair; then, + * skipping the BITS entry for that prefix length, a code word from the next + * shortest nonzero BITS entry is converted into a prefix for two code words + * one bit longer. + */ + + for (i = MAX_CLEN; i > 16; i--) { + while (bits[i] > 0) { + j = i - 2; /* find length of new prefix to be used */ + while (bits[j] == 0) { + if (j == 0) + ERREXIT(cinfo, JERR_HUFF_CLEN_OUTOFBOUNDS); + j--; + } + + bits[i] -= 2; /* remove two symbols */ + bits[i-1]++; /* one goes in this length */ + bits[j+1] += 2; /* two new symbols in this length */ + bits[j]--; /* symbol of this length is now a prefix */ + } + } + + /* Remove the count for the pseudo-symbol 256 from the largest codelength */ + while (bits[i] == 0) /* find largest codelength still in use */ + i--; + bits[i]--; + + /* Return final symbol counts (only for lengths 0..16) */ + MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); + +#ifdef DONT_USE_FANCY_HUFF_OPT + + /* Return a list of the symbols sorted by code length */ + /* Note: Due to the codelength changes made above, it can happen + * that more frequent symbols are assigned longer codewords. + */ + p = htbl->huffval; + for (i = 1; i <= MAX_CLEN; i++) { + for (j = 0; j <= 255; j++) { + if (codesize[j] == i) { + *p++ = (UINT8) j; + } + } + } + +#endif /* DONT_USE_FANCY_HUFF_OPT */ + + /* Set sent_table FALSE so updated table will be written to JPEG file. */ + htbl->sent_table = FALSE; +} + + +/* + * Finish up a statistics-gathering pass and create the new Huffman tables. + */ + +METHODDEF(void) +finish_pass_gather (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, tbl; + jpeg_component_info * compptr; + JHUFF_TBL **htblptr; + boolean did_dc[NUM_HUFF_TBLS]; + boolean did_ac[NUM_HUFF_TBLS]; + + if (cinfo->progressive_mode) + /* Flush out buffered data (all we care about is counting the EOB symbol) */ + emit_eobrun(entropy); + + /* It's important not to apply jpeg_gen_optimal_table more than once + * per table, because it clobbers the input frequency counts! + */ + MEMZERO(did_dc, SIZEOF(did_dc)); + MEMZERO(did_ac, SIZEOF(did_ac)); + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* DC needs no table for refinement scan */ + if (cinfo->Ss == 0 && cinfo->Ah == 0) { + tbl = compptr->dc_tbl_no; + if (! did_dc[tbl]) { + htblptr = & cinfo->dc_huff_tbl_ptrs[tbl]; + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[tbl]); + did_dc[tbl] = TRUE; + } + } + /* AC needs no table when not present */ + if (cinfo->Se) { + tbl = compptr->ac_tbl_no; + if (! did_ac[tbl]) { + htblptr = & cinfo->ac_huff_tbl_ptrs[tbl]; + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[tbl]); + did_ac[tbl] = TRUE; + } + } + } +} + + +/* + * Initialize for a Huffman-compressed scan. + * If gather_statistics is TRUE, we do not output anything during the scan, + * just count the Huffman symbols used and generate Huffman code tables. + */ + +METHODDEF(void) +start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, tbl; + jpeg_component_info * compptr; + + if (gather_statistics) + entropy->pub.finish_pass = finish_pass_gather; + else + entropy->pub.finish_pass = finish_pass_huff; + + if (cinfo->progressive_mode) { + entropy->cinfo = cinfo; + entropy->gather_statistics = gather_statistics; + + /* We assume jcmaster.c already validated the scan parameters. */ + + /* Select execution routine */ + if (cinfo->Ah == 0) { + if (cinfo->Ss == 0) + entropy->pub.encode_mcu = encode_mcu_DC_first; + else + entropy->pub.encode_mcu = encode_mcu_AC_first; + } else { + if (cinfo->Ss == 0) + entropy->pub.encode_mcu = encode_mcu_DC_refine; + else { + entropy->pub.encode_mcu = encode_mcu_AC_refine; + /* AC refinement needs a correction bit buffer */ + if (entropy->bit_buffer == NULL) + entropy->bit_buffer = (char *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, MAX_CORR_BITS * SIZEOF(char)); + } + } + + /* Initialize AC stuff */ + entropy->ac_tbl_no = cinfo->cur_comp_info[0]->ac_tbl_no; + entropy->EOBRUN = 0; + entropy->BE = 0; + } else { + if (gather_statistics) + entropy->pub.encode_mcu = encode_mcu_gather; + else + entropy->pub.encode_mcu = encode_mcu_huff; + } + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* DC needs no table for refinement scan */ + if (cinfo->Ss == 0 && cinfo->Ah == 0) { + tbl = compptr->dc_tbl_no; + if (gather_statistics) { + /* Check for invalid table index */ + /* (make_c_derived_tbl does this in the other path) */ + if (tbl < 0 || tbl >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl); + /* Allocate and zero the statistics tables */ + /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ + if (entropy->dc_count_ptrs[tbl] == NULL) + entropy->dc_count_ptrs[tbl] = (long *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, 257 * SIZEOF(long)); + MEMZERO(entropy->dc_count_ptrs[tbl], 257 * SIZEOF(long)); + } else { + /* Compute derived values for Huffman tables */ + /* We may do this more than once for a table, but it's not expensive */ + jpeg_make_c_derived_tbl(cinfo, TRUE, tbl, + & entropy->dc_derived_tbls[tbl]); + } + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + /* AC needs no table when not present */ + if (cinfo->Se) { + tbl = compptr->ac_tbl_no; + if (gather_statistics) { + if (tbl < 0 || tbl >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl); + if (entropy->ac_count_ptrs[tbl] == NULL) + entropy->ac_count_ptrs[tbl] = (long *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, 257 * SIZEOF(long)); + MEMZERO(entropy->ac_count_ptrs[tbl], 257 * SIZEOF(long)); + } else { + jpeg_make_c_derived_tbl(cinfo, FALSE, tbl, + & entropy->ac_derived_tbls[tbl]); + } + } + } + + /* Initialize bit buffer to empty */ + entropy->saved.put_buffer = 0; + entropy->saved.put_bits = 0; + + /* Initialize restart stuff */ + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num = 0; +} + + +/* + * Module initialization routine for Huffman entropy encoding. + */ + +GLOBAL(void) +jinit_huff_encoder (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy; + int i; + + entropy = (huff_entropy_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(huff_entropy_encoder)); + cinfo->entropy = &entropy->pub; + entropy->pub.start_pass = start_pass_huff; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; + entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL; + } + + if (cinfo->progressive_mode) + entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ +} diff --git a/thirdparty/jpeg-9e/jcinit.c b/thirdparty/jpeg-9e/jcinit.c new file mode 100644 index 0000000..2aea7ca --- /dev/null +++ b/thirdparty/jpeg-9e/jcinit.c @@ -0,0 +1,249 @@ +/* + * jcinit.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 2003-2017 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains initialization logic for the JPEG compressor. + * This routine is in charge of selecting the modules to be executed and + * making an initialization call to each one. + * + * Logically, this code belongs in jcmaster.c. It's split out because + * linking this routine implies linking the entire compression library. + * For a transcoding-only application, we want to be able to use jcmaster.c + * without linking in the whole library. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Compute JPEG image dimensions and related values. + * NOTE: this is exported for possible use by application. + * Hence it mustn't do anything that can't be done twice. + */ + +GLOBAL(void) +jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo) +/* Do computations that are needed before master selection phase */ +{ + /* Sanity check on input image dimensions to prevent overflow in + * following calculations. + * We do check jpeg_width and jpeg_height in initial_setup in jcmaster.c, + * but image_width and image_height can come from arbitrary data, + * and we need some space for multiplication by block_size. + */ + if (((long) cinfo->image_width >> 24) || ((long) cinfo->image_height >> 24)) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); + +#ifdef DCT_SCALING_SUPPORTED + + /* Compute actual JPEG image dimensions and DCT scaling choices. */ + if (cinfo->scale_num >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/1 scaling */ + cinfo->jpeg_width = cinfo->image_width * cinfo->block_size; + cinfo->jpeg_height = cinfo->image_height * cinfo->block_size; + cinfo->min_DCT_h_scaled_size = 1; + cinfo->min_DCT_v_scaled_size = 1; + } else if (cinfo->scale_num * 2 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/2 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 2L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 2L); + cinfo->min_DCT_h_scaled_size = 2; + cinfo->min_DCT_v_scaled_size = 2; + } else if (cinfo->scale_num * 3 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/3 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 3L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 3L); + cinfo->min_DCT_h_scaled_size = 3; + cinfo->min_DCT_v_scaled_size = 3; + } else if (cinfo->scale_num * 4 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/4 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 4L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 4L); + cinfo->min_DCT_h_scaled_size = 4; + cinfo->min_DCT_v_scaled_size = 4; + } else if (cinfo->scale_num * 5 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/5 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 5L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 5L); + cinfo->min_DCT_h_scaled_size = 5; + cinfo->min_DCT_v_scaled_size = 5; + } else if (cinfo->scale_num * 6 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/6 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 6L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 6L); + cinfo->min_DCT_h_scaled_size = 6; + cinfo->min_DCT_v_scaled_size = 6; + } else if (cinfo->scale_num * 7 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/7 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 7L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 7L); + cinfo->min_DCT_h_scaled_size = 7; + cinfo->min_DCT_v_scaled_size = 7; + } else if (cinfo->scale_num * 8 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/8 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 8L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 8L); + cinfo->min_DCT_h_scaled_size = 8; + cinfo->min_DCT_v_scaled_size = 8; + } else if (cinfo->scale_num * 9 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/9 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 9L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 9L); + cinfo->min_DCT_h_scaled_size = 9; + cinfo->min_DCT_v_scaled_size = 9; + } else if (cinfo->scale_num * 10 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/10 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 10L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 10L); + cinfo->min_DCT_h_scaled_size = 10; + cinfo->min_DCT_v_scaled_size = 10; + } else if (cinfo->scale_num * 11 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/11 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 11L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 11L); + cinfo->min_DCT_h_scaled_size = 11; + cinfo->min_DCT_v_scaled_size = 11; + } else if (cinfo->scale_num * 12 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/12 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 12L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 12L); + cinfo->min_DCT_h_scaled_size = 12; + cinfo->min_DCT_v_scaled_size = 12; + } else if (cinfo->scale_num * 13 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/13 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 13L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 13L); + cinfo->min_DCT_h_scaled_size = 13; + cinfo->min_DCT_v_scaled_size = 13; + } else if (cinfo->scale_num * 14 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/14 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 14L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 14L); + cinfo->min_DCT_h_scaled_size = 14; + cinfo->min_DCT_v_scaled_size = 14; + } else if (cinfo->scale_num * 15 >= cinfo->scale_denom * cinfo->block_size) { + /* Provide block_size/15 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 15L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 15L); + cinfo->min_DCT_h_scaled_size = 15; + cinfo->min_DCT_v_scaled_size = 15; + } else { + /* Provide block_size/16 scaling */ + cinfo->jpeg_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 16L); + cinfo->jpeg_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 16L); + cinfo->min_DCT_h_scaled_size = 16; + cinfo->min_DCT_v_scaled_size = 16; + } + +#else /* !DCT_SCALING_SUPPORTED */ + + /* Hardwire it to "no scaling" */ + cinfo->jpeg_width = cinfo->image_width; + cinfo->jpeg_height = cinfo->image_height; + cinfo->min_DCT_h_scaled_size = DCTSIZE; + cinfo->min_DCT_v_scaled_size = DCTSIZE; + +#endif /* DCT_SCALING_SUPPORTED */ +} + + +/* + * Master selection of compression modules. + * This is done once at the start of processing an image. We determine + * which modules will be used and give them appropriate initialization calls. + */ + +GLOBAL(void) +jinit_compress_master (j_compress_ptr cinfo) +{ + long samplesperrow; + JDIMENSION jd_samplesperrow; + + /* For now, precision must match compiled-in value... */ + if (cinfo->data_precision != BITS_IN_JSAMPLE) + ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); + + /* Sanity check on input image dimensions */ + if (cinfo->image_height <= 0 || cinfo->image_width <= 0 || + cinfo->input_components <= 0) + ERREXIT(cinfo, JERR_EMPTY_IMAGE); + + /* Width of an input scanline must be representable as JDIMENSION. */ + samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; + jd_samplesperrow = (JDIMENSION) samplesperrow; + if ((long) jd_samplesperrow != samplesperrow) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + + /* Compute JPEG image dimensions and related values. */ + jpeg_calc_jpeg_dimensions(cinfo); + + /* Initialize master control (includes parameter checking/processing) */ + jinit_c_master_control(cinfo, FALSE /* full compression */); + + /* Preprocessing */ + if (! cinfo->raw_data_in) { + jinit_color_converter(cinfo); + jinit_downsampler(cinfo); + jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); + } + /* Forward DCT */ + jinit_forward_dct(cinfo); + /* Entropy encoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) + jinit_arith_encoder(cinfo); + else { + jinit_huff_encoder(cinfo); + } + + /* Need a full-image coefficient buffer in any multi-pass mode. */ + jinit_c_coef_controller(cinfo, + (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); + jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); + + jinit_marker_writer(cinfo); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Write the datastream header (SOI) immediately. + * Frame and scan headers are postponed till later. + * This lets application insert special markers after the SOI. + */ + (*cinfo->marker->write_file_header) (cinfo); +} diff --git a/thirdparty/jpeg-9e/jcmainct.c b/thirdparty/jpeg-9e/jcmainct.c new file mode 100644 index 0000000..39b9790 --- /dev/null +++ b/thirdparty/jpeg-9e/jcmainct.c @@ -0,0 +1,297 @@ +/* + * jcmainct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2003-2012 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the main buffer controller for compression. + * The main buffer lies between the pre-processor and the JPEG + * compressor proper; it holds downsampled data in the JPEG colorspace. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Note: currently, there is no operating mode in which a full-image buffer + * is needed at this step. If there were, that mode could not be used with + * "raw data" input, since this module is bypassed in that case. However, + * we've left the code here for possible use in special applications. + */ +#undef FULL_MAIN_BUFFER_SUPPORTED + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_main_controller pub; /* public fields */ + + JDIMENSION cur_iMCU_row; /* number of current iMCU row */ + JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */ + boolean suspended; /* remember if we suspended output */ + J_BUF_MODE pass_mode; /* current operating mode */ + + /* If using just a strip buffer, this points to the entire set of buffers + * (we allocate one for each component). In the full-image case, this + * points to the currently accessible strips of the virtual arrays. + */ + JSAMPARRAY buffer[MAX_COMPONENTS]; + +#ifdef FULL_MAIN_BUFFER_SUPPORTED + /* If using full-image storage, this array holds pointers to virtual-array + * control blocks for each component. Unused if not full-image storage. + */ + jvirt_sarray_ptr whole_image[MAX_COMPONENTS]; +#endif +} my_main_controller; + +typedef my_main_controller * my_main_ptr; + + +/* Forward declarations */ +METHODDEF(void) process_data_simple_main + JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); +#ifdef FULL_MAIN_BUFFER_SUPPORTED +METHODDEF(void) process_data_buffer_main + JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); +#endif + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_main_ptr mainp = (my_main_ptr) cinfo->main; + + /* Do nothing in raw-data mode. */ + if (cinfo->raw_data_in) + return; + + mainp->cur_iMCU_row = 0; /* initialize counters */ + mainp->rowgroup_ctr = 0; + mainp->suspended = FALSE; + mainp->pass_mode = pass_mode; /* save mode for use by process_data */ + + switch (pass_mode) { + case JBUF_PASS_THRU: +#ifdef FULL_MAIN_BUFFER_SUPPORTED + if (mainp->whole_image[0] != NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + mainp->pub.process_data = process_data_simple_main; + break; +#ifdef FULL_MAIN_BUFFER_SUPPORTED + case JBUF_SAVE_SOURCE: + case JBUF_CRANK_DEST: + case JBUF_SAVE_AND_PASS: + if (mainp->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + mainp->pub.process_data = process_data_buffer_main; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } +} + + +/* + * Process some data. + * This routine handles the simple pass-through mode, + * where we have only a strip buffer. + */ + +METHODDEF(void) +process_data_simple_main (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail) +{ + my_main_ptr mainp = (my_main_ptr) cinfo->main; + + while (mainp->cur_iMCU_row < cinfo->total_iMCU_rows) { + /* Read input data if we haven't filled the main buffer yet */ + if (mainp->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size) + (*cinfo->prep->pre_process_data) (cinfo, + input_buf, in_row_ctr, in_rows_avail, + mainp->buffer, &mainp->rowgroup_ctr, + (JDIMENSION) cinfo->min_DCT_v_scaled_size); + + /* If we don't have a full iMCU row buffered, return to application for + * more data. Note that preprocessor will always pad to fill the iMCU row + * at the bottom of the image. + */ + if (mainp->rowgroup_ctr != (JDIMENSION) cinfo->min_DCT_v_scaled_size) + return; + + /* Send the completed row to the compressor */ + if (! (*cinfo->coef->compress_data) (cinfo, mainp->buffer)) { + /* If compressor did not consume the whole row, then we must need to + * suspend processing and return to the application. In this situation + * we pretend we didn't yet consume the last input row; otherwise, if + * it happened to be the last row of the image, the application would + * think we were done. + */ + if (! mainp->suspended) { + (*in_row_ctr)--; + mainp->suspended = TRUE; + } + return; + } + /* We did finish the row. Undo our little suspension hack if a previous + * call suspended; then mark the main buffer empty. + */ + if (mainp->suspended) { + (*in_row_ctr)++; + mainp->suspended = FALSE; + } + mainp->rowgroup_ctr = 0; + mainp->cur_iMCU_row++; + } +} + + +#ifdef FULL_MAIN_BUFFER_SUPPORTED + +/* + * Process some data. + * This routine handles all of the modes that use a full-size buffer. + */ + +METHODDEF(void) +process_data_buffer_main (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail) +{ + my_main_ptr mainp = (my_main_ptr) cinfo->main; + int ci; + jpeg_component_info *compptr; + boolean writing = (mainp->pass_mode != JBUF_CRANK_DEST); + + while (mainp->cur_iMCU_row < cinfo->total_iMCU_rows) { + /* Realign the virtual buffers if at the start of an iMCU row. */ + if (mainp->rowgroup_ctr == 0) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + mainp->buffer[ci] = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, mainp->whole_image[ci], mainp->cur_iMCU_row * + ((JDIMENSION) (compptr->v_samp_factor * cinfo->min_DCT_v_scaled_size)), + (JDIMENSION) (compptr->v_samp_factor * cinfo->min_DCT_v_scaled_size), + writing); + } + /* In a read pass, pretend we just read some source data. */ + if (! writing) { + *in_row_ctr += (JDIMENSION) + (cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size); + mainp->rowgroup_ctr = (JDIMENSION) cinfo->min_DCT_v_scaled_size; + } + } + + /* If a write pass, read input data until the current iMCU row is full. */ + /* Note: preprocessor will pad if necessary to fill the last iMCU row. */ + if (writing) { + (*cinfo->prep->pre_process_data) (cinfo, + input_buf, in_row_ctr, in_rows_avail, + mainp->buffer, &mainp->rowgroup_ctr, + (JDIMENSION) cinfo->min_DCT_v_scaled_size); + /* Return to application if we need more data to fill the iMCU row. */ + if (mainp->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size) + return; + } + + /* Emit data, unless this is a sink-only pass. */ + if (mainp->pass_mode != JBUF_SAVE_SOURCE) { + if (! (*cinfo->coef->compress_data) (cinfo, mainp->buffer)) { + /* If compressor did not consume the whole row, then we must need to + * suspend processing and return to the application. In this situation + * we pretend we didn't yet consume the last input row; otherwise, if + * it happened to be the last row of the image, the application would + * think we were done. + */ + if (! mainp->suspended) { + (*in_row_ctr)--; + mainp->suspended = TRUE; + } + return; + } + /* We did finish the row. Undo our little suspension hack if a previous + * call suspended; then mark the main buffer empty. + */ + if (mainp->suspended) { + (*in_row_ctr)++; + mainp->suspended = FALSE; + } + } + + /* If get here, we are done with this iMCU row. Mark buffer empty. */ + mainp->rowgroup_ctr = 0; + mainp->cur_iMCU_row++; + } +} + +#endif /* FULL_MAIN_BUFFER_SUPPORTED */ + + +/* + * Initialize main buffer controller. + */ + +GLOBAL(void) +jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_main_ptr mainp; + int ci; + jpeg_component_info *compptr; + + mainp = (my_main_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_main_controller)); + cinfo->main = &mainp->pub; + mainp->pub.start_pass = start_pass_main; + + /* We don't need to create a buffer in raw-data mode. */ + if (cinfo->raw_data_in) + return; + + /* Create the buffer. It holds downsampled data, so each component + * may be of a different size. + */ + if (need_full_buffer) { +#ifdef FULL_MAIN_BUFFER_SUPPORTED + /* Allocate a full-image virtual array for each component */ + /* Note we pad the bottom to a multiple of the iMCU height */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + mainp->whole_image[ci] = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size), + ((JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor)) * + ((JDIMENSION) cinfo->min_DCT_v_scaled_size), + (JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size)); + } +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + } else { +#ifdef FULL_MAIN_BUFFER_SUPPORTED + mainp->whole_image[0] = NULL; /* flag for no virtual arrays */ +#endif + /* Allocate a strip buffer for each component */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + mainp->buffer[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size), + (JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size)); + } + } +} diff --git a/thirdparty/jpeg-9e/jcmarker.c b/thirdparty/jpeg-9e/jcmarker.c new file mode 100644 index 0000000..8874cd8 --- /dev/null +++ b/thirdparty/jpeg-9e/jcmarker.c @@ -0,0 +1,717 @@ +/* + * jcmarker.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * Modified 2003-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write JPEG datastream markers. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +typedef enum { /* JPEG marker codes */ + M_SOF0 = 0xc0, + M_SOF1 = 0xc1, + M_SOF2 = 0xc2, + M_SOF3 = 0xc3, + + M_SOF5 = 0xc5, + M_SOF6 = 0xc6, + M_SOF7 = 0xc7, + + M_JPG = 0xc8, + M_SOF9 = 0xc9, + M_SOF10 = 0xca, + M_SOF11 = 0xcb, + + M_SOF13 = 0xcd, + M_SOF14 = 0xce, + M_SOF15 = 0xcf, + + M_DHT = 0xc4, + + M_DAC = 0xcc, + + M_RST0 = 0xd0, + M_RST1 = 0xd1, + M_RST2 = 0xd2, + M_RST3 = 0xd3, + M_RST4 = 0xd4, + M_RST5 = 0xd5, + M_RST6 = 0xd6, + M_RST7 = 0xd7, + + M_SOI = 0xd8, + M_EOI = 0xd9, + M_SOS = 0xda, + M_DQT = 0xdb, + M_DNL = 0xdc, + M_DRI = 0xdd, + M_DHP = 0xde, + M_EXP = 0xdf, + + M_APP0 = 0xe0, + M_APP1 = 0xe1, + M_APP2 = 0xe2, + M_APP3 = 0xe3, + M_APP4 = 0xe4, + M_APP5 = 0xe5, + M_APP6 = 0xe6, + M_APP7 = 0xe7, + M_APP8 = 0xe8, + M_APP9 = 0xe9, + M_APP10 = 0xea, + M_APP11 = 0xeb, + M_APP12 = 0xec, + M_APP13 = 0xed, + M_APP14 = 0xee, + M_APP15 = 0xef, + + M_JPG0 = 0xf0, + M_JPG8 = 0xf8, + M_JPG13 = 0xfd, + M_COM = 0xfe, + + M_TEM = 0x01, + + M_ERROR = 0x100 +} JPEG_MARKER; + + +/* Private state */ + +typedef struct { + struct jpeg_marker_writer pub; /* public fields */ + + unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */ +} my_marker_writer; + +typedef my_marker_writer * my_marker_ptr; + + +/* + * Basic output routines. + * + * Note that we do not support suspension while writing a marker. + * Therefore, an application using suspension must ensure that there is + * enough buffer space for the initial markers (typ. 600-700 bytes) before + * calling jpeg_start_compress, and enough space to write the trailing EOI + * (a few bytes) before calling jpeg_finish_compress. Multipass compression + * modes are not supported at all with suspension, so those two are the only + * points where markers will be written. + */ + +LOCAL(void) +emit_byte (j_compress_ptr cinfo, int val) +/* Emit a byte */ +{ + struct jpeg_destination_mgr * dest = cinfo->dest; + + *(dest->next_output_byte)++ = (JOCTET) val; + if (--dest->free_in_buffer == 0) { + if (! (*dest->empty_output_buffer) (cinfo)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } +} + + +LOCAL(void) +emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) +/* Emit a marker code */ +{ + emit_byte(cinfo, 0xFF); + emit_byte(cinfo, (int) mark); +} + + +LOCAL(void) +emit_2bytes (j_compress_ptr cinfo, int value) +/* Emit a 2-byte integer; these are always MSB first in JPEG files */ +{ + emit_byte(cinfo, (value >> 8) & 0xFF); + emit_byte(cinfo, value & 0xFF); +} + + +/* + * Routines to write specific marker types. + */ + +LOCAL(int) +emit_dqt (j_compress_ptr cinfo, int index) +/* Emit a DQT marker */ +/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ +{ + JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; + int prec; + int i; + + if (qtbl == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); + + prec = 0; + for (i = 0; i <= cinfo->lim_Se; i++) { + if (qtbl->quantval[cinfo->natural_order[i]] > 255) + prec = 1; + } + + if (! qtbl->sent_table) { + emit_marker(cinfo, M_DQT); + + emit_2bytes(cinfo, + prec ? cinfo->lim_Se * 2 + 2 + 1 + 2 : cinfo->lim_Se + 1 + 1 + 2); + + emit_byte(cinfo, index + (prec<<4)); + + for (i = 0; i <= cinfo->lim_Se; i++) { + /* The table entries must be emitted in zigzag order. */ + unsigned int qval = qtbl->quantval[cinfo->natural_order[i]]; + if (prec) + emit_byte(cinfo, (int) (qval >> 8)); + emit_byte(cinfo, (int) (qval & 0xFF)); + } + + qtbl->sent_table = TRUE; + } + + return prec; +} + + +LOCAL(void) +emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) +/* Emit a DHT marker */ +{ + JHUFF_TBL * htbl; + int length, i; + + if (is_ac) { + htbl = cinfo->ac_huff_tbl_ptrs[index]; + index += 0x10; /* output index has AC bit set */ + } else { + htbl = cinfo->dc_huff_tbl_ptrs[index]; + } + + if (htbl == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); + + if (! htbl->sent_table) { + emit_marker(cinfo, M_DHT); + + length = 0; + for (i = 1; i <= 16; i++) + length += htbl->bits[i]; + + emit_2bytes(cinfo, length + 2 + 1 + 16); + emit_byte(cinfo, index); + + for (i = 1; i <= 16; i++) + emit_byte(cinfo, htbl->bits[i]); + + for (i = 0; i < length; i++) + emit_byte(cinfo, htbl->huffval[i]); + + htbl->sent_table = TRUE; + } +} + + +LOCAL(void) +emit_dac (j_compress_ptr cinfo) +/* Emit a DAC marker */ +/* Since the useful info is so small, we want to emit all the tables in */ +/* one DAC marker. Therefore this routine does its own scan of the table. */ +{ +#ifdef C_ARITH_CODING_SUPPORTED + char dc_in_use[NUM_ARITH_TBLS]; + char ac_in_use[NUM_ARITH_TBLS]; + int length, i; + jpeg_component_info *compptr; + + for (i = 0; i < NUM_ARITH_TBLS; i++) + dc_in_use[i] = ac_in_use[i] = 0; + + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + /* DC needs no table for refinement scan */ + if (cinfo->Ss == 0 && cinfo->Ah == 0) + dc_in_use[compptr->dc_tbl_no] = 1; + /* AC needs no table when not present */ + if (cinfo->Se) + ac_in_use[compptr->ac_tbl_no] = 1; + } + + length = 0; + for (i = 0; i < NUM_ARITH_TBLS; i++) + length += dc_in_use[i] + ac_in_use[i]; + + if (length) { + emit_marker(cinfo, M_DAC); + + emit_2bytes(cinfo, length*2 + 2); + + for (i = 0; i < NUM_ARITH_TBLS; i++) { + if (dc_in_use[i]) { + emit_byte(cinfo, i); + emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); + } + if (ac_in_use[i]) { + emit_byte(cinfo, i + 0x10); + emit_byte(cinfo, cinfo->arith_ac_K[i]); + } + } + } +#endif /* C_ARITH_CODING_SUPPORTED */ +} + + +LOCAL(void) +emit_dri (j_compress_ptr cinfo) +/* Emit a DRI marker */ +{ + emit_marker(cinfo, M_DRI); + + emit_2bytes(cinfo, 4); /* fixed length */ + + emit_2bytes(cinfo, (int) cinfo->restart_interval); +} + + +LOCAL(void) +emit_lse_ict (j_compress_ptr cinfo) +/* Emit an LSE inverse color transform specification marker */ +{ + /* Support only 1 transform */ + if (cinfo->color_transform != JCT_SUBTRACT_GREEN || + cinfo->num_components < 3) + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + + emit_marker(cinfo, M_JPG8); + + emit_2bytes(cinfo, 24); /* fixed length */ + + emit_byte(cinfo, 0x0D); /* ID inverse transform specification */ + emit_2bytes(cinfo, MAXJSAMPLE); /* MAXTRANS */ + emit_byte(cinfo, 3); /* Nt=3 */ + emit_byte(cinfo, cinfo->comp_info[1].component_id); + emit_byte(cinfo, cinfo->comp_info[0].component_id); + emit_byte(cinfo, cinfo->comp_info[2].component_id); + emit_byte(cinfo, 0x80); /* F1: CENTER1=1, NORM1=0 */ + emit_2bytes(cinfo, 0); /* A(1,1)=0 */ + emit_2bytes(cinfo, 0); /* A(1,2)=0 */ + emit_byte(cinfo, 0); /* F2: CENTER2=0, NORM2=0 */ + emit_2bytes(cinfo, 1); /* A(2,1)=1 */ + emit_2bytes(cinfo, 0); /* A(2,2)=0 */ + emit_byte(cinfo, 0); /* F3: CENTER3=0, NORM3=0 */ + emit_2bytes(cinfo, 1); /* A(3,1)=1 */ + emit_2bytes(cinfo, 0); /* A(3,2)=0 */ +} + + +LOCAL(void) +emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) +/* Emit a SOF marker */ +{ + int ci; + jpeg_component_info *compptr; + + emit_marker(cinfo, code); + + emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ + + /* Make sure image isn't bigger than SOF field can handle */ + if ((long) cinfo->jpeg_height > 65535L || + (long) cinfo->jpeg_width > 65535L) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); + + emit_byte(cinfo, cinfo->data_precision); + emit_2bytes(cinfo, (int) cinfo->jpeg_height); + emit_2bytes(cinfo, (int) cinfo->jpeg_width); + + emit_byte(cinfo, cinfo->num_components); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + emit_byte(cinfo, compptr->component_id); + emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); + emit_byte(cinfo, compptr->quant_tbl_no); + } +} + + +LOCAL(void) +emit_sos (j_compress_ptr cinfo) +/* Emit a SOS marker */ +{ + int i, td, ta; + jpeg_component_info *compptr; + + emit_marker(cinfo, M_SOS); + + emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ + + emit_byte(cinfo, cinfo->comps_in_scan); + + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + emit_byte(cinfo, compptr->component_id); + + /* We emit 0 for unused field(s); this is recommended by the P&M text + * but does not seem to be specified in the standard. + */ + + /* DC needs no table for refinement scan */ + td = cinfo->Ss == 0 && cinfo->Ah == 0 ? compptr->dc_tbl_no : 0; + /* AC needs no table when not present */ + ta = cinfo->Se ? compptr->ac_tbl_no : 0; + + emit_byte(cinfo, (td << 4) + ta); + } + + emit_byte(cinfo, cinfo->Ss); + emit_byte(cinfo, cinfo->Se); + emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al); +} + + +LOCAL(void) +emit_pseudo_sos (j_compress_ptr cinfo) +/* Emit a pseudo SOS marker */ +{ + emit_marker(cinfo, M_SOS); + + emit_2bytes(cinfo, 2 + 1 + 3); /* length */ + + emit_byte(cinfo, 0); /* Ns */ + + emit_byte(cinfo, 0); /* Ss */ + emit_byte(cinfo, cinfo->block_size * cinfo->block_size - 1); /* Se */ + emit_byte(cinfo, 0); /* Ah/Al */ +} + + +LOCAL(void) +emit_jfif_app0 (j_compress_ptr cinfo) +/* Emit a JFIF-compliant APP0 marker */ +{ + /* + * Length of APP0 block (2 bytes) + * Block ID (4 bytes - ASCII "JFIF") + * Zero byte (1 byte to terminate the ID string) + * Version Major, Minor (2 bytes - major first) + * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) + * Xdpu (2 bytes - dots per unit horizontal) + * Ydpu (2 bytes - dots per unit vertical) + * Thumbnail X size (1 byte) + * Thumbnail Y size (1 byte) + */ + + emit_marker(cinfo, M_APP0); + + emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ + + emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ + emit_byte(cinfo, 0x46); + emit_byte(cinfo, 0x49); + emit_byte(cinfo, 0x46); + emit_byte(cinfo, 0); + emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */ + emit_byte(cinfo, cinfo->JFIF_minor_version); + emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ + emit_2bytes(cinfo, (int) cinfo->X_density); + emit_2bytes(cinfo, (int) cinfo->Y_density); + emit_byte(cinfo, 0); /* No thumbnail image */ + emit_byte(cinfo, 0); +} + + +LOCAL(void) +emit_adobe_app14 (j_compress_ptr cinfo) +/* Emit an Adobe APP14 marker */ +{ + /* + * Length of APP14 block (2 bytes) + * Block ID (5 bytes - ASCII "Adobe") + * Version Number (2 bytes - currently 100) + * Flags0 (2 bytes - currently 0) + * Flags1 (2 bytes - currently 0) + * Color transform (1 byte) + * + * Although Adobe TN 5116 mentions Version = 101, all the Adobe files + * now in circulation seem to use Version = 100, so that's what we write. + * + * We write the color transform byte as 1 if the JPEG color space is + * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with + * whether the encoder performed a transformation, which is pretty useless. + */ + + emit_marker(cinfo, M_APP14); + + emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ + + emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ + emit_byte(cinfo, 0x64); + emit_byte(cinfo, 0x6F); + emit_byte(cinfo, 0x62); + emit_byte(cinfo, 0x65); + emit_2bytes(cinfo, 100); /* Version */ + emit_2bytes(cinfo, 0); /* Flags0 */ + emit_2bytes(cinfo, 0); /* Flags1 */ + switch (cinfo->jpeg_color_space) { + case JCS_YCbCr: + emit_byte(cinfo, 1); /* Color transform = 1 */ + break; + case JCS_YCCK: + emit_byte(cinfo, 2); /* Color transform = 2 */ + break; + default: + emit_byte(cinfo, 0); /* Color transform = 0 */ + } +} + + +/* + * These routines allow writing an arbitrary marker with parameters. + * The only intended use is to emit COM or APPn markers after calling + * write_file_header and before calling write_frame_header. + * Other uses are not guaranteed to produce desirable results. + * Counting the parameter bytes properly is the caller's responsibility. + */ + +METHODDEF(void) +write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) +/* Emit an arbitrary marker header */ +{ + if (datalen > (unsigned int) 65533) /* safety check */ + ERREXIT(cinfo, JERR_BAD_LENGTH); + + emit_marker(cinfo, (JPEG_MARKER) marker); + + emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ +} + +METHODDEF(void) +write_marker_byte (j_compress_ptr cinfo, int val) +/* Emit one byte of marker parameters following write_marker_header */ +{ + emit_byte(cinfo, val); +} + + +/* + * Write datastream header. + * This consists of an SOI and optional APPn markers. + * We recommend use of the JFIF marker, but not the Adobe marker, + * when using YCbCr or grayscale data. The JFIF marker is also used + * for other standard JPEG colorspaces. The Adobe marker is helpful + * to distinguish RGB, CMYK, and YCCK colorspaces. + * Note that an application can write additional header markers after + * jpeg_start_compress returns. + */ + +METHODDEF(void) +write_file_header (j_compress_ptr cinfo) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + + emit_marker(cinfo, M_SOI); /* first the SOI */ + + /* SOI is defined to reset restart interval to 0 */ + marker->last_restart_interval = 0; + + if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ + emit_jfif_app0(cinfo); + if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ + emit_adobe_app14(cinfo); +} + + +/* + * Write frame header. + * This consists of DQT and SOFn markers, + * a conditional LSE marker and a conditional pseudo SOS marker. + * Note that we do not emit the SOF until we have emitted the DQT(s). + * This avoids compatibility problems with incorrect implementations that + * try to error-check the quant table numbers as soon as they see the SOF. + */ + +METHODDEF(void) +write_frame_header (j_compress_ptr cinfo) +{ + int ci, prec; + boolean is_baseline; + jpeg_component_info *compptr; + + /* Emit DQT for each quantization table. + * Note that emit_dqt() suppresses any duplicate tables. + */ + prec = 0; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + prec += emit_dqt(cinfo, compptr->quant_tbl_no); + } + /* now prec is nonzero iff there are any 16-bit quant tables. */ + + /* Check for a non-baseline specification. + * Note we assume that Huffman table numbers won't be changed later. + */ + if (cinfo->arith_code || cinfo->progressive_mode || + cinfo->data_precision != 8 || cinfo->block_size != DCTSIZE) { + is_baseline = FALSE; + } else { + is_baseline = TRUE; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) + is_baseline = FALSE; + } + if (prec && is_baseline) { + is_baseline = FALSE; + /* If it's baseline except for quantizer size, warn the user */ + TRACEMS(cinfo, 0, JTRC_16BIT_TABLES); + } + } + + /* Emit the proper SOF marker */ + if (cinfo->arith_code) { + if (cinfo->progressive_mode) + emit_sof(cinfo, M_SOF10); /* SOF code for progressive arithmetic */ + else + emit_sof(cinfo, M_SOF9); /* SOF code for sequential arithmetic */ + } else { + if (cinfo->progressive_mode) + emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ + else if (is_baseline) + emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ + else + emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ + } + + /* Check to emit LSE inverse color transform specification marker */ + if (cinfo->color_transform) + emit_lse_ict(cinfo); + + /* Check to emit pseudo SOS marker */ + if (cinfo->progressive_mode && cinfo->block_size != DCTSIZE) + emit_pseudo_sos(cinfo); +} + + +/* + * Write scan header. + * This consists of DHT or DAC markers, optional DRI, and SOS. + * Compressed data will be written following the SOS. + */ + +METHODDEF(void) +write_scan_header (j_compress_ptr cinfo) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + int i; + jpeg_component_info *compptr; + + if (cinfo->arith_code) { + /* Emit arith conditioning info. We may have some duplication + * if the file has multiple scans, but it's so small it's hardly + * worth worrying about. + */ + emit_dac(cinfo); + } else { + /* Emit Huffman tables. + * Note that emit_dht() suppresses any duplicate tables. + */ + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + /* DC needs no table for refinement scan */ + if (cinfo->Ss == 0 && cinfo->Ah == 0) + emit_dht(cinfo, compptr->dc_tbl_no, FALSE); + /* AC needs no table when not present */ + if (cinfo->Se) + emit_dht(cinfo, compptr->ac_tbl_no, TRUE); + } + } + + /* Emit DRI if required --- note that DRI value could change for each scan. + * We avoid wasting space with unnecessary DRIs, however. + */ + if (cinfo->restart_interval != marker->last_restart_interval) { + emit_dri(cinfo); + marker->last_restart_interval = cinfo->restart_interval; + } + + emit_sos(cinfo); +} + + +/* + * Write datastream trailer. + */ + +METHODDEF(void) +write_file_trailer (j_compress_ptr cinfo) +{ + emit_marker(cinfo, M_EOI); +} + + +/* + * Write an abbreviated table-specification datastream. + * This consists of SOI, DQT and DHT tables, and EOI. + * Any table that is defined and not marked sent_table = TRUE will be + * emitted. Note that all tables will be marked sent_table = TRUE at exit. + */ + +METHODDEF(void) +write_tables_only (j_compress_ptr cinfo) +{ + int i; + + emit_marker(cinfo, M_SOI); + + for (i = 0; i < NUM_QUANT_TBLS; i++) { + if (cinfo->quant_tbl_ptrs[i] != NULL) + (void) emit_dqt(cinfo, i); + } + + if (! cinfo->arith_code) { + for (i = 0; i < NUM_HUFF_TBLS; i++) { + if (cinfo->dc_huff_tbl_ptrs[i] != NULL) + emit_dht(cinfo, i, FALSE); + if (cinfo->ac_huff_tbl_ptrs[i] != NULL) + emit_dht(cinfo, i, TRUE); + } + } + + emit_marker(cinfo, M_EOI); +} + + +/* + * Initialize the marker writer module. + */ + +GLOBAL(void) +jinit_marker_writer (j_compress_ptr cinfo) +{ + my_marker_ptr marker; + + /* Create the subobject */ + marker = (my_marker_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_marker_writer)); + cinfo->marker = &marker->pub; + /* Initialize method pointers */ + marker->pub.write_file_header = write_file_header; + marker->pub.write_frame_header = write_frame_header; + marker->pub.write_scan_header = write_scan_header; + marker->pub.write_file_trailer = write_file_trailer; + marker->pub.write_tables_only = write_tables_only; + marker->pub.write_marker_header = write_marker_header; + marker->pub.write_marker_byte = write_marker_byte; + /* Initialize private state */ + marker->last_restart_interval = 0; +} diff --git a/thirdparty/jpeg-9e/jcmaster.c b/thirdparty/jpeg-9e/jcmaster.c new file mode 100644 index 0000000..a70af0c --- /dev/null +++ b/thirdparty/jpeg-9e/jcmaster.c @@ -0,0 +1,675 @@ +/* + * jcmaster.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 2003-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains master control logic for the JPEG compressor. + * These routines are concerned with parameter validation, initial setup, + * and inter-pass control (determining the number of passes and the work + * to be done in each pass). + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef enum { + main_pass, /* input data, also do first output step */ + huff_opt_pass, /* Huffman code optimization pass */ + output_pass /* data output pass */ +} c_pass_type; + +typedef struct { + struct jpeg_comp_master pub; /* public fields */ + + c_pass_type pass_type; /* the type of the current pass */ + + int pass_number; /* # of passes completed */ + int total_passes; /* total # of passes needed */ + + int scan_number; /* current index in scan_info[] */ +} my_comp_master; + +typedef my_comp_master * my_master_ptr; + + +/* + * Support routines that do various essential calculations. + */ + +LOCAL(void) +initial_setup (j_compress_ptr cinfo) +/* Do computations that are needed before master selection phase */ +{ + int ci, ssize; + jpeg_component_info *compptr; + + /* Sanity check on block_size */ + if (cinfo->block_size < 1 || cinfo->block_size > 16) + ERREXIT2(cinfo, JERR_BAD_DCTSIZE, cinfo->block_size, cinfo->block_size); + + /* Derive natural_order from block_size */ + switch (cinfo->block_size) { + case 2: cinfo->natural_order = jpeg_natural_order2; break; + case 3: cinfo->natural_order = jpeg_natural_order3; break; + case 4: cinfo->natural_order = jpeg_natural_order4; break; + case 5: cinfo->natural_order = jpeg_natural_order5; break; + case 6: cinfo->natural_order = jpeg_natural_order6; break; + case 7: cinfo->natural_order = jpeg_natural_order7; break; + default: cinfo->natural_order = jpeg_natural_order; + } + + /* Derive lim_Se from block_size */ + cinfo->lim_Se = cinfo->block_size < DCTSIZE ? + cinfo->block_size * cinfo->block_size - 1 : DCTSIZE2-1; + + /* Sanity check on image dimensions */ + if (cinfo->jpeg_height <= 0 || cinfo->jpeg_width <= 0 || + cinfo->num_components <= 0) + ERREXIT(cinfo, JERR_EMPTY_IMAGE); + + /* Make sure image isn't bigger than I can handle */ + if ((long) cinfo->jpeg_height > (long) JPEG_MAX_DIMENSION || + (long) cinfo->jpeg_width > (long) JPEG_MAX_DIMENSION) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); + + /* Only 8 to 12 bits data precision are supported for DCT based JPEG */ + if (cinfo->data_precision < 8 || cinfo->data_precision > 12) + ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); + + /* Check that number of components won't exceed internal array sizes */ + if (cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + + /* Compute maximum sampling factors; check factor validity */ + cinfo->max_h_samp_factor = 1; + cinfo->max_v_samp_factor = 1; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || + compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) + ERREXIT(cinfo, JERR_BAD_SAMPLING); + cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, + compptr->h_samp_factor); + cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, + compptr->v_samp_factor); + } + + /* Compute dimensions of components */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Fill in the correct component_index value; don't rely on application */ + compptr->component_index = ci; + /* In selecting the actual DCT scaling for each component, we try to + * scale down the chroma components via DCT scaling rather than downsampling. + * This saves time if the downsampler gets to use 1:1 scaling. + * Note this code adapts subsampling ratios which are powers of 2. + */ + ssize = 1; +#ifdef DCT_SCALING_SUPPORTED + if (! cinfo->raw_data_in) + while (cinfo->min_DCT_h_scaled_size * ssize <= + (cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) && + (cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == + 0) { + ssize = ssize * 2; + } +#endif + compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize; + ssize = 1; +#ifdef DCT_SCALING_SUPPORTED + if (! cinfo->raw_data_in) + while (cinfo->min_DCT_v_scaled_size * ssize <= + (cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) && + (cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == + 0) { + ssize = ssize * 2; + } +#endif + compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize; + + /* We don't support DCT ratios larger than 2. */ + if (compptr->DCT_h_scaled_size > compptr->DCT_v_scaled_size * 2) + compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2; + else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2) + compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2; + + /* Size in DCT blocks */ + compptr->width_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->jpeg_width * (long) compptr->h_samp_factor, + (long) (cinfo->max_h_samp_factor * cinfo->block_size)); + compptr->height_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->jpeg_height * (long) compptr->v_samp_factor, + (long) (cinfo->max_v_samp_factor * cinfo->block_size)); + /* Size in samples */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->jpeg_width * + (long) (compptr->h_samp_factor * compptr->DCT_h_scaled_size), + (long) (cinfo->max_h_samp_factor * cinfo->block_size)); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->jpeg_height * + (long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size), + (long) (cinfo->max_v_samp_factor * cinfo->block_size)); + /* Don't need quantization scale after DCT, + * until color conversion says otherwise. + */ + compptr->component_needed = FALSE; + } + + /* Compute number of fully interleaved MCU rows (number of times that + * main controller will call coefficient controller). + */ + cinfo->total_iMCU_rows = (JDIMENSION) + jdiv_round_up((long) cinfo->jpeg_height, + (long) (cinfo->max_v_samp_factor * cinfo->block_size)); +} + + +#ifdef C_MULTISCAN_FILES_SUPPORTED + +LOCAL(void) +validate_script (j_compress_ptr cinfo) +/* Verify that the scan script in cinfo->scan_info[] is valid; also + * determine whether it uses progressive JPEG, and set cinfo->progressive_mode. + */ +{ + const jpeg_scan_info * scanptr; + int scanno, ncomps, ci, coefi, thisi; + int Ss, Se, Ah, Al; + boolean component_sent[MAX_COMPONENTS]; +#ifdef C_PROGRESSIVE_SUPPORTED + int * last_bitpos_ptr; + int last_bitpos[MAX_COMPONENTS][DCTSIZE2]; + /* -1 until that coefficient has been seen; then last Al for it */ +#endif + + if (cinfo->num_scans <= 0) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0); + + /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1; + * for progressive JPEG, no scan can have this. + */ + scanptr = cinfo->scan_info; + if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) { +#ifdef C_PROGRESSIVE_SUPPORTED + cinfo->progressive_mode = TRUE; + last_bitpos_ptr = & last_bitpos[0][0]; + for (ci = 0; ci < cinfo->num_components; ci++) + for (coefi = 0; coefi < DCTSIZE2; coefi++) + *last_bitpos_ptr++ = -1; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + cinfo->progressive_mode = FALSE; + for (ci = 0; ci < cinfo->num_components; ci++) + component_sent[ci] = FALSE; + } + + for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) { + /* Validate component indexes */ + ncomps = scanptr->comps_in_scan; + if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN); + for (ci = 0; ci < ncomps; ci++) { + thisi = scanptr->component_index[ci]; + if (thisi < 0 || thisi >= cinfo->num_components) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + /* Components must appear in SOF order within each scan */ + if (ci > 0 && thisi <= scanptr->component_index[ci-1]) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + } + /* Validate progression parameters */ + Ss = scanptr->Ss; + Se = scanptr->Se; + Ah = scanptr->Ah; + Al = scanptr->Al; + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + /* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that + * seems wrong: the upper bound ought to depend on data precision. + * Perhaps they really meant 0..N+1 for N-bit precision. + * Here we allow 0..10 for 8-bit data; Al larger than 10 results in + * out-of-range reconstructed DC values during the first DC scan, + * which might cause problems for some decoders. + */ + if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 || + Ah < 0 || Ah > (cinfo->data_precision > 8 ? 13 : 10) || + Al < 0 || Al > (cinfo->data_precision > 8 ? 13 : 10)) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + if (Ss == 0) { + if (Se != 0) /* DC and AC together not OK */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } else { + if (ncomps != 1) /* AC scans must be for only one component */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } + for (ci = 0; ci < ncomps; ci++) { + last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0]; + if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + for (coefi = Ss; coefi <= Se; coefi++) { + if (last_bitpos_ptr[coefi] < 0) { + /* first scan of this coefficient */ + if (Ah != 0) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } else { + /* not first scan */ + if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } + last_bitpos_ptr[coefi] = Al; + } + } +#endif + } else { + /* For sequential JPEG, all progression parameters must be these: */ + if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + /* Make sure components are not sent twice */ + for (ci = 0; ci < ncomps; ci++) { + thisi = scanptr->component_index[ci]; + if (component_sent[thisi]) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + component_sent[thisi] = TRUE; + } + } + } + + /* Now verify that everything got sent. */ + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + /* For progressive mode, we only check that at least some DC data + * got sent for each component; the spec does not require that all bits + * of all coefficients be transmitted. Would it be wiser to enforce + * transmission of all coefficient bits?? + */ + for (ci = 0; ci < cinfo->num_components; ci++) { + if (last_bitpos[ci][0] < 0) + ERREXIT(cinfo, JERR_MISSING_DATA); + } +#endif + } else { + for (ci = 0; ci < cinfo->num_components; ci++) { + if (! component_sent[ci]) + ERREXIT(cinfo, JERR_MISSING_DATA); + } + } +} + + +LOCAL(void) +reduce_script (j_compress_ptr cinfo) +/* Adapt scan script for use with reduced block size; + * assume that script has been validated before. + */ +{ + jpeg_scan_info * scanptr; + int idxout, idxin; + + /* Circumvent const declaration for this function */ + scanptr = (jpeg_scan_info *) cinfo->scan_info; + idxout = 0; + + for (idxin = 0; idxin < cinfo->num_scans; idxin++) { + /* After skipping, idxout becomes smaller than idxin */ + if (idxin != idxout) + /* Copy rest of data; + * note we stay in given chunk of allocated memory. + */ + scanptr[idxout] = scanptr[idxin]; + if (scanptr[idxout].Ss > cinfo->lim_Se) + /* Entire scan out of range - skip this entry */ + continue; + if (scanptr[idxout].Se > cinfo->lim_Se) + /* Limit scan to end of block */ + scanptr[idxout].Se = cinfo->lim_Se; + idxout++; + } + + cinfo->num_scans = idxout; +} + +#endif /* C_MULTISCAN_FILES_SUPPORTED */ + + +LOCAL(void) +select_scan_parameters (j_compress_ptr cinfo) +/* Set up the scan parameters for the current scan */ +{ + int ci; + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (cinfo->scan_info != NULL) { + /* Prepare for current scan --- the script is already validated */ + my_master_ptr master = (my_master_ptr) cinfo->master; + const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number; + + cinfo->comps_in_scan = scanptr->comps_in_scan; + for (ci = 0; ci < scanptr->comps_in_scan; ci++) { + cinfo->cur_comp_info[ci] = + &cinfo->comp_info[scanptr->component_index[ci]]; + } + if (cinfo->progressive_mode) { + cinfo->Ss = scanptr->Ss; + cinfo->Se = scanptr->Se; + cinfo->Ah = scanptr->Ah; + cinfo->Al = scanptr->Al; + return; + } + } + else +#endif + { + /* Prepare for single sequential-JPEG scan containing all components */ + if (cinfo->num_components > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPS_IN_SCAN); + cinfo->comps_in_scan = cinfo->num_components; + for (ci = 0; ci < cinfo->num_components; ci++) { + cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci]; + } + } + cinfo->Ss = 0; + cinfo->Se = cinfo->block_size * cinfo->block_size - 1; + cinfo->Ah = 0; + cinfo->Al = 0; +} + + +LOCAL(void) +per_scan_setup (j_compress_ptr cinfo) +/* Do computations that are needed before processing a JPEG scan */ +/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */ +{ + int ci, mcublks, tmp; + jpeg_component_info *compptr; + + if (cinfo->comps_in_scan == 1) { + + /* Noninterleaved (single-component) scan */ + compptr = cinfo->cur_comp_info[0]; + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = compptr->width_in_blocks; + cinfo->MCU_rows_in_scan = compptr->height_in_blocks; + + /* For noninterleaved scan, always one block per MCU */ + compptr->MCU_width = 1; + compptr->MCU_height = 1; + compptr->MCU_blocks = 1; + compptr->MCU_sample_width = compptr->DCT_h_scaled_size; + compptr->last_col_width = 1; + /* For noninterleaved scans, it is convenient to define last_row_height + * as the number of block rows present in the last iMCU row. + */ + tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (tmp == 0) tmp = compptr->v_samp_factor; + compptr->last_row_height = tmp; + + /* Prepare array describing MCU composition */ + cinfo->blocks_in_MCU = 1; + cinfo->MCU_membership[0] = 0; + + } else { + + /* Interleaved (multi-component) scan */ + if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, + MAX_COMPS_IN_SCAN); + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = (JDIMENSION) + jdiv_round_up((long) cinfo->jpeg_width, + (long) (cinfo->max_h_samp_factor * cinfo->block_size)); + cinfo->MCU_rows_in_scan = cinfo->total_iMCU_rows; + + cinfo->blocks_in_MCU = 0; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Sampling factors give # of blocks of component in each MCU */ + compptr->MCU_width = compptr->h_samp_factor; + compptr->MCU_height = compptr->v_samp_factor; + compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; + compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_h_scaled_size; + /* Figure number of non-dummy blocks in last MCU column & row */ + tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); + if (tmp == 0) tmp = compptr->MCU_width; + compptr->last_col_width = tmp; + tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); + if (tmp == 0) tmp = compptr->MCU_height; + compptr->last_row_height = tmp; + /* Prepare array describing MCU composition */ + mcublks = compptr->MCU_blocks; + if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU) + ERREXIT(cinfo, JERR_BAD_MCU_SIZE); + while (mcublks-- > 0) { + cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; + } + } + + } + + /* Convert restart specified in rows to actual MCU count. */ + /* Note that count must fit in 16 bits, so we provide limiting. */ + if (cinfo->restart_in_rows > 0) { + long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row; + cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L); + } +} + + +/* + * Per-pass setup. + * This is called at the beginning of each pass. We determine which modules + * will be active during this pass and give them appropriate start_pass calls. + * We also set is_last_pass to indicate whether any more passes will be + * required. + */ + +METHODDEF(void) +prepare_for_pass (j_compress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + switch (master->pass_type) { + case main_pass: + /* Initial pass: will collect input data, and do either Huffman + * optimization or data output for the first scan. + */ + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + if (! cinfo->raw_data_in) { + (*cinfo->cconvert->start_pass) (cinfo); + (*cinfo->downsample->start_pass) (cinfo); + (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU); + } + (*cinfo->fdct->start_pass) (cinfo); + (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding); + (*cinfo->coef->start_pass) (cinfo, + (master->total_passes > 1 ? + JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); + (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); + if (cinfo->optimize_coding) { + /* No immediate data output; postpone writing frame/scan headers */ + master->pub.call_pass_startup = FALSE; + } else { + /* Will write frame/scan headers at first jpeg_write_scanlines call */ + master->pub.call_pass_startup = TRUE; + } + break; +#ifdef ENTROPY_OPT_SUPPORTED + case huff_opt_pass: + /* Do Huffman optimization for a scan after the first one. */ + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + if (cinfo->Ss != 0 || cinfo->Ah == 0) { + (*cinfo->entropy->start_pass) (cinfo, TRUE); + (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); + master->pub.call_pass_startup = FALSE; + break; + } + /* Special case: Huffman DC refinement scans need no Huffman table + * and therefore we can skip the optimization pass for them. + */ + master->pass_type = output_pass; + master->pass_number++; + /*FALLTHROUGH*/ +#endif + case output_pass: + /* Do a data-output pass. */ + /* We need not repeat per-scan setup if prior optimization pass did it. */ + if (! cinfo->optimize_coding) { + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + } + (*cinfo->entropy->start_pass) (cinfo, FALSE); + (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); + /* We emit frame/scan headers now */ + if (master->scan_number == 0) + (*cinfo->marker->write_frame_header) (cinfo); + (*cinfo->marker->write_scan_header) (cinfo); + master->pub.call_pass_startup = FALSE; + break; + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + } + + master->pub.is_last_pass = (master->pass_number == master->total_passes-1); + + /* Set up progress monitor's pass info if present */ + if (cinfo->progress != NULL) { + cinfo->progress->completed_passes = master->pass_number; + cinfo->progress->total_passes = master->total_passes; + } +} + + +/* + * Special start-of-pass hook. + * This is called by jpeg_write_scanlines if call_pass_startup is TRUE. + * In single-pass processing, we need this hook because we don't want to + * write frame/scan headers during jpeg_start_compress; we want to let the + * application write COM markers etc. between jpeg_start_compress and the + * jpeg_write_scanlines loop. + * In multi-pass processing, this routine is not used. + */ + +METHODDEF(void) +pass_startup (j_compress_ptr cinfo) +{ + cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */ + + (*cinfo->marker->write_frame_header) (cinfo); + (*cinfo->marker->write_scan_header) (cinfo); +} + + +/* + * Finish up at end of pass. + */ + +METHODDEF(void) +finish_pass_master (j_compress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + /* The entropy coder always needs an end-of-pass call, + * either to analyze statistics or to flush its output buffer. + */ + (*cinfo->entropy->finish_pass) (cinfo); + + /* Update state for next pass */ + switch (master->pass_type) { + case main_pass: + /* next pass is either output of scan 0 (after optimization) + * or output of scan 1 (if no optimization). + */ + master->pass_type = output_pass; + if (! cinfo->optimize_coding) + master->scan_number++; + break; + case huff_opt_pass: + /* next pass is always output of current scan */ + master->pass_type = output_pass; + break; + case output_pass: + /* next pass is either optimization or output of next scan */ + if (cinfo->optimize_coding) + master->pass_type = huff_opt_pass; + master->scan_number++; + break; + } + + master->pass_number++; +} + + +/* + * Initialize master compression control. + */ + +GLOBAL(void) +jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only) +{ + my_master_ptr master; + + master = (my_master_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_comp_master)); + cinfo->master = &master->pub; + master->pub.prepare_for_pass = prepare_for_pass; + master->pub.pass_startup = pass_startup; + master->pub.finish_pass = finish_pass_master; + master->pub.is_last_pass = FALSE; + + /* Validate parameters, determine derived values */ + initial_setup(cinfo); + + if (cinfo->scan_info != NULL) { +#ifdef C_MULTISCAN_FILES_SUPPORTED + validate_script(cinfo); + if (cinfo->block_size < DCTSIZE) + reduce_script(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + cinfo->progressive_mode = FALSE; + cinfo->num_scans = 1; + } + + if (cinfo->optimize_coding) + cinfo->arith_code = FALSE; /* disable arithmetic coding */ + else if (! cinfo->arith_code && + (cinfo->progressive_mode || + (cinfo->block_size > 1 && cinfo->block_size < DCTSIZE))) + /* TEMPORARY HACK ??? */ + /* assume default tables no good for progressive or reduced AC mode */ + cinfo->optimize_coding = TRUE; /* force Huffman optimization */ + + /* Initialize my private state */ + if (transcode_only) { + /* no main pass in transcoding */ + if (cinfo->optimize_coding) + master->pass_type = huff_opt_pass; + else + master->pass_type = output_pass; + } else { + /* for normal compression, first pass is always this type: */ + master->pass_type = main_pass; + } + master->scan_number = 0; + master->pass_number = 0; + if (cinfo->optimize_coding) + master->total_passes = cinfo->num_scans * 2; + else + master->total_passes = cinfo->num_scans; +} diff --git a/thirdparty/jpeg-9e/jcomapi.c b/thirdparty/jpeg-9e/jcomapi.c new file mode 100644 index 0000000..678c5d1 --- /dev/null +++ b/thirdparty/jpeg-9e/jcomapi.c @@ -0,0 +1,244 @@ +/* + * jcomapi.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * Modified 2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface routines that are used for both + * compression and decompression. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Abort processing of a JPEG compression or decompression operation, + * but don't destroy the object itself. + * + * For this, we merely clean up all the nonpermanent memory pools. + * Note that temp files (virtual arrays) are not allowed to belong to + * the permanent pool, so we will be able to close all temp files here. + * Closing a data source or destination, if necessary, is the application's + * responsibility. + */ + +GLOBAL(void) +jpeg_abort (j_common_ptr cinfo) +{ + int pool; + + /* Do nothing if called on a not-initialized or destroyed JPEG object. */ + if (cinfo->mem == NULL) + return; + + /* Releasing pools in reverse order might help avoid fragmentation + * with some (brain-damaged) malloc libraries. + */ + for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { + (*cinfo->mem->free_pool) (cinfo, pool); + } + + /* Reset overall state for possible reuse of object */ + if (cinfo->is_decompressor) { + cinfo->global_state = DSTATE_START; + /* Try to keep application from accessing now-deleted marker list. + * A bit kludgy to do it here, but this is the most central place. + */ + ((j_decompress_ptr) cinfo)->marker_list = NULL; + } else { + cinfo->global_state = CSTATE_START; + } +} + + +/* + * Destruction of a JPEG object. + * + * Everything gets deallocated except the master jpeg_compress_struct itself + * and the error manager struct. Both of these are supplied by the application + * and must be freed, if necessary, by the application. (Often they are on + * the stack and so don't need to be freed anyway.) + * Closing a data source or destination, if necessary, is the application's + * responsibility. + */ + +GLOBAL(void) +jpeg_destroy (j_common_ptr cinfo) +{ + /* We need only tell the memory manager to release everything. */ + /* NB: mem pointer is NULL if memory mgr failed to initialize. */ + if (cinfo->mem != NULL) + (*cinfo->mem->self_destruct) (cinfo); + cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ + cinfo->global_state = 0; /* mark it destroyed */ +} + + +/* + * Convenience routines for allocating quantization and Huffman tables. + * (Would jutils.c be a more reasonable place to put these?) + */ + +GLOBAL(JQUANT_TBL *) +jpeg_alloc_quant_table (j_common_ptr cinfo) +{ + JQUANT_TBL *tbl; + + tbl = (JQUANT_TBL *) + (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); + tbl->sent_table = FALSE; /* make sure this is false in any new table */ + return tbl; +} + + +GLOBAL(JHUFF_TBL *) +jpeg_alloc_huff_table (j_common_ptr cinfo) +{ + JHUFF_TBL *tbl; + + tbl = (JHUFF_TBL *) + (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); + tbl->sent_table = FALSE; /* make sure this is false in any new table */ + return tbl; +} + + +/* + * Set up the standard Huffman tables (cf. JPEG standard section K.3). + * IMPORTANT: these are only valid for 8-bit data precision! + * (Would jutils.c be a more reasonable place to put this?) + */ + +GLOBAL(JHUFF_TBL *) +jpeg_std_huff_table (j_common_ptr cinfo, boolean isDC, int tblno) +{ + JHUFF_TBL **htblptr, *htbl; + const UINT8 *bits, *val; + int nsymbols, len; + + static const UINT8 bits_dc_luminance[17] = + { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_luminance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + static const UINT8 bits_dc_chrominance[17] = + { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_chrominance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + static const UINT8 bits_ac_luminance[17] = + { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; + static const UINT8 val_ac_luminance[] = + { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, + 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, + 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, + 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, + 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, + 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, + 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, + 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, + 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, + 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, + 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; + + static const UINT8 bits_ac_chrominance[17] = + { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; + static const UINT8 val_ac_chrominance[] = + { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, + 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, + 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, + 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, + 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, + 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, + 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, + 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, + 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, + 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, + 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, + 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, + 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; + + if (cinfo->is_decompressor) { + if (isDC) + htblptr = ((j_decompress_ptr) cinfo)->dc_huff_tbl_ptrs; + else + htblptr = ((j_decompress_ptr) cinfo)->ac_huff_tbl_ptrs; + } else { + if (isDC) + htblptr = ((j_compress_ptr) cinfo)->dc_huff_tbl_ptrs; + else + htblptr = ((j_compress_ptr) cinfo)->ac_huff_tbl_ptrs; + } + + switch (tblno) { + case 0: + if (isDC) { + bits = bits_dc_luminance; + val = val_dc_luminance; + } else { + bits = bits_ac_luminance; + val = val_ac_luminance; + } + break; + case 1: + if (isDC) { + bits = bits_dc_chrominance; + val = val_dc_chrominance; + } else { + bits = bits_ac_chrominance; + val = val_ac_chrominance; + } + break; + default: + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); + return NULL; /* avoid compiler warnings for uninitialized variables */ + } + + if (htblptr[tblno] == NULL) + htblptr[tblno] = jpeg_alloc_huff_table(cinfo); + + htbl = htblptr[tblno]; + + /* Copy the number-of-symbols-of-each-code-length counts */ + MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); + + /* Validate the counts. We do this here mainly so we can copy the right + * number of symbols from the val[] array, without risking marching off + * the end of memory. jxhuff.c will do a more thorough test later. + */ + nsymbols = 0; + for (len = 1; len <= 16; len++) + nsymbols += bits[len]; + if (nsymbols > 256) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + + if (nsymbols > 0) + MEMCOPY(htbl->huffval, val, nsymbols * SIZEOF(UINT8)); + + /* Initialize sent_table FALSE so table will be written to JPEG file. */ + htbl->sent_table = FALSE; + + return htbl; +} diff --git a/thirdparty/jpeg-9e/jconfig.bcc b/thirdparty/jpeg-9e/jconfig.bcc new file mode 100644 index 0000000..e4da3d7 --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.bcc @@ -0,0 +1,48 @@ +/* jconfig.bcc --- jconfig.h for Borland C (Turbo C) on MS-DOS or OS/2. */ +/* see jconfig.txt for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#ifdef __MSDOS__ +#define NEED_FAR_POINTERS /* for small or medium memory model */ +#endif +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN /* this assumes you have -w-stu in CFLAGS */ + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#ifdef __MSDOS__ +#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ +#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ +#define USE_FMEM /* Borland has _fmemcpy() and _fmemset() */ +#endif + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define USE_SETMODE /* Borland has setmode() */ +#ifdef __MSDOS__ +#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ +#endif +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.cfg b/thirdparty/jpeg-9e/jconfig.cfg new file mode 100644 index 0000000..c4548fc --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.cfg @@ -0,0 +1,59 @@ +/* jconfig.cfg --- source file edited by configure script */ +/* see jconfig.txt for explanations */ + +#undef HAVE_PROTOTYPES +#undef HAVE_UNSIGNED_CHAR +#undef HAVE_UNSIGNED_SHORT +#undef void +#undef const +#undef CHAR_IS_UNSIGNED +#undef HAVE_STDDEF_H +#undef HAVE_STDLIB_H +#undef HAVE_LOCALE_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +/* Define this if you get warnings about undefined structures. */ +#undef INCOMPLETE_TYPES_BROKEN + +/* Define "boolean" as unsigned char, not enum, on Windows systems. */ +#ifdef _WIN32 +#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ +typedef unsigned char boolean; +#endif +#ifndef FALSE /* in case these macros already exist */ +#define FALSE 0 /* values of boolean */ +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ +#endif + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED +#undef INLINE +/* These are for configuring the JPEG memory manager. */ +#undef DEFAULT_MAX_MEM +#undef NO_MKTEMP + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#undef TWO_FILE_COMMANDLINE +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE + +/* Define this if you want percent-done progress reports from cjpeg/djpeg. */ +#undef PROGRESS_REPORT + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.dj b/thirdparty/jpeg-9e/jconfig.dj new file mode 100644 index 0000000..a0d4092 --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.dj @@ -0,0 +1,38 @@ +/* jconfig.dj --- jconfig.h for DJGPP (Delorie's GNU C port) on MS-DOS. */ +/* see jconfig.txt for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* DJGPP uses flat 32-bit addressing */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#undef TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Needed to make one-file style work in DJGPP */ +#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.h b/thirdparty/jpeg-9e/jconfig.h new file mode 100644 index 0000000..2d05a3b --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.h @@ -0,0 +1,60 @@ +/* jconfig.h. Generated from jconfig.cfg by configure. */ +/* jconfig.cfg --- source file edited by configure script */ +/* see jconfig.txt for explanations */ + +#define HAVE_PROTOTYPES 1 +#define HAVE_UNSIGNED_CHAR 1 +#define HAVE_UNSIGNED_SHORT 1 +/* #undef void */ +/* #undef const */ +/* #undef CHAR_IS_UNSIGNED */ +#define HAVE_STDDEF_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_LOCALE_H 1 +/* #undef NEED_BSD_STRINGS */ +/* #undef NEED_SYS_TYPES_H */ +/* #undef NEED_FAR_POINTERS */ +/* #undef NEED_SHORT_EXTERNAL_NAMES */ +/* Define this if you get warnings about undefined structures. */ +/* #undef INCOMPLETE_TYPES_BROKEN */ + +/* Define "boolean" as unsigned char, not enum, on Windows systems. */ +#ifdef _WIN32 +#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ +typedef unsigned char boolean; +#endif +#ifndef FALSE /* in case these macros already exist */ +#define FALSE 0 /* values of boolean */ +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ +#endif + +#ifdef JPEG_INTERNALS + +/* #undef RIGHT_SHIFT_IS_UNSIGNED */ +#define INLINE __inline__ +/* These are for configuring the JPEG memory manager. */ +/* #undef DEFAULT_MAX_MEM */ +/* #undef NO_MKTEMP */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +/* #undef RLE_SUPPORTED */ +#define TARGA_SUPPORTED /* Targa image file format */ + +/* #undef TWO_FILE_COMMANDLINE */ +/* #undef NEED_SIGNAL_CATCHER */ +/* #undef DONT_USE_B_MODE */ + +/* Define this if you want percent-done progress reports from cjpeg/djpeg. */ +/* #undef PROGRESS_REPORT */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.mac b/thirdparty/jpeg-9e/jconfig.mac new file mode 100644 index 0000000..70ed66c --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.mac @@ -0,0 +1,43 @@ +/* jconfig.mac --- jconfig.h for CodeWarrior on Apple Macintosh */ +/* see jconfig.txt for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define USE_MAC_MEMMGR /* Define this if you use jmemmac.c */ + +#define ALIGN_TYPE long /* Needed for 680x0 Macs */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define USE_CCOMMAND /* Command line reader for Macintosh */ +#define TWO_FILE_COMMANDLINE /* Binary I/O thru stdin/stdout doesn't work */ + +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.manx b/thirdparty/jpeg-9e/jconfig.manx new file mode 100644 index 0000000..cd529d7 --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.manx @@ -0,0 +1,43 @@ +/* jconfig.manx --- jconfig.h for Amiga systems using Manx Aztec C ver 5.x. */ +/* see jconfig.txt for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ + +#define SHORTxSHORT_32 /* produces better DCT code with Aztec C */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#define signal_catcher _abort /* hack for Aztec C naming requirements */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.mc6 b/thirdparty/jpeg-9e/jconfig.mc6 new file mode 100644 index 0000000..6b05e81 --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.mc6 @@ -0,0 +1,52 @@ +/* jconfig.mc6 --- jconfig.h for Microsoft C on MS-DOS, version 6.00A & up. */ +/* see jconfig.txt for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#define NEED_FAR_POINTERS /* for small or medium memory model */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ + +#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ + +#define USE_FMEM /* Microsoft has _fmemcpy() and _fmemset() */ + +#define NEED_FHEAPMIN /* far heap management routines are broken */ + +#define SHORTxLCONST_32 /* enable compiler-specific DCT optimization */ +/* Note: the above define is known to improve the code with Microsoft C 6.00A. + * I do not know whether it is good for later compiler versions. + * Please report any info on this point to jpeg-info@jpegclub.org. + */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define USE_SETMODE /* Microsoft has setmode() */ +#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.sas b/thirdparty/jpeg-9e/jconfig.sas new file mode 100644 index 0000000..b8a1819 --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.sas @@ -0,0 +1,43 @@ +/* jconfig.sas --- jconfig.h for Amiga systems using SAS C 6.0 and up. */ +/* see jconfig.txt for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ + +#define NO_MKTEMP /* SAS C doesn't have mktemp() */ + +#define SHORTxSHORT_32 /* produces better DCT code with SAS C */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.st b/thirdparty/jpeg-9e/jconfig.st new file mode 100644 index 0000000..5afa0b6 --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.st @@ -0,0 +1,42 @@ +/* jconfig.st --- jconfig.h for Atari ST/STE/TT using Pure C or Turbo C. */ +/* see jconfig.txt for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#define INCOMPLETE_TYPES_BROKEN /* suppress undefined-structure warnings */ + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define ALIGN_TYPE long /* apparently double is a weird size? */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE /* optional -- undef if you like Unix style */ +/* Note: if you undef TWO_FILE_COMMANDLINE, you may need to define + * USE_SETMODE. Some Atari compilers require it, some do not. + */ +#define NEED_SIGNAL_CATCHER /* needed if you use jmemname.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.txt b/thirdparty/jpeg-9e/jconfig.txt new file mode 100644 index 0000000..d1710ae --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.txt @@ -0,0 +1,171 @@ +/* + * jconfig.txt + * + * Copyright (C) 1991-1994, Thomas G. Lane. + * Modified 2009-2013 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file documents the configuration options that are required to + * customize the JPEG software for a particular system. + * + * The actual configuration options for a particular installation are stored + * in jconfig.h. On many machines, jconfig.h can be generated automatically + * or copied from one of the "canned" jconfig files that we supply. But if + * you need to generate a jconfig.h file by hand, this file tells you how. + * + * DO NOT EDIT THIS FILE --- IT WON'T ACCOMPLISH ANYTHING. + * EDIT A COPY NAMED JCONFIG.H. + */ + + +/* + * These symbols indicate the properties of your machine or compiler. + * #define the symbol if yes, #undef it if no. + */ + +/* Does your compiler support function prototypes? + * (If not, you also need to use ansi2knr, see install.txt) + */ +#define HAVE_PROTOTYPES + +/* Does your compiler support the declaration "unsigned char" ? + * How about "unsigned short" ? + */ +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT + +/* Define "void" as "char" if your compiler doesn't know about type void. + * NOTE: be sure to define void such that "void *" represents the most general + * pointer type, e.g., that returned by malloc(). + */ +/* #define void char */ + +/* Define "const" as empty if your compiler doesn't know the "const" keyword. + */ +/* #define const */ + +/* Define this if an ordinary "char" type is unsigned. + * If you're not sure, leaving it undefined will work at some cost in speed. + * If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal. + */ +#undef CHAR_IS_UNSIGNED + +/* Define this if your system has an ANSI-conforming file. + */ +#define HAVE_STDDEF_H + +/* Define this if your system has an ANSI-conforming file. + */ +#define HAVE_STDLIB_H + +/* Define this if your system does not have an ANSI/SysV , + * but does have a BSD-style . + */ +#undef NEED_BSD_STRINGS + +/* Define this if your system does not provide typedef size_t in any of the + * ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in + * instead. + */ +#undef NEED_SYS_TYPES_H + +/* For 80x86 machines, you need to define NEED_FAR_POINTERS, + * unless you are using a large-data memory model or 80386 flat-memory mode. + * On less brain-damaged CPUs this symbol must not be defined. + * (Defining this symbol causes large data structures to be referenced through + * "far" pointers and to be allocated with a special version of malloc.) + */ +#undef NEED_FAR_POINTERS + +/* Define this if your linker needs global names to be unique in less + * than the first 15 characters. + */ +#undef NEED_SHORT_EXTERNAL_NAMES + +/* Although a real ANSI C compiler can deal perfectly well with pointers to + * unspecified structures (see "incomplete types" in the spec), a few pre-ANSI + * and pseudo-ANSI compilers get confused. To keep one of these bozos happy, + * define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you + * actually get "missing structure definition" warnings or errors while + * compiling the JPEG code. + */ +#undef INCOMPLETE_TYPES_BROKEN + +/* Define "boolean" as unsigned char, not enum, on Windows systems. + */ +#ifdef _WIN32 +#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ +typedef unsigned char boolean; +#endif +#ifndef FALSE /* in case these macros already exist */ +#define FALSE 0 /* values of boolean */ +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ +#endif + + +/* + * The following options affect code selection within the JPEG library, + * but they don't need to be visible to applications using the library. + * To minimize application namespace pollution, the symbols won't be + * defined unless JPEG_INTERNALS has been defined. + */ + +#ifdef JPEG_INTERNALS + +/* Define this if your compiler implements ">>" on signed values as a logical + * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift, + * which is the normal and rational definition. + */ +#undef RIGHT_SHIFT_IS_UNSIGNED + + +#endif /* JPEG_INTERNALS */ + + +/* + * The remaining options do not affect the JPEG library proper, + * but only the sample applications cjpeg/djpeg (see cjpeg.c, djpeg.c). + * Other applications can ignore these. + */ + +#ifdef JPEG_CJPEG_DJPEG + +/* These defines indicate which image (non-JPEG) file formats are allowed. */ + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +/* Define this if you want to name both input and output files on the command + * line, rather than using stdout and optionally stdin. You MUST do this if + * your system can't cope with binary I/O to stdin/stdout. See comments at + * head of cjpeg.c or djpeg.c. + */ +#undef TWO_FILE_COMMANDLINE + +/* Define this if your system needs explicit cleanup of temporary files. + * This is crucial under MS-DOS, where the temporary "files" may be areas + * of extended memory; on most other systems it's not as important. + */ +#undef NEED_SIGNAL_CATCHER + +/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb"). + * This is necessary on systems that distinguish text files from binary files, + * and is harmless on most systems that don't. If you have one of the rare + * systems that complains about the "b" spec, define this symbol. + */ +#undef DONT_USE_B_MODE + +/* Define this if you want percent-done progress reports from cjpeg/djpeg. + */ +#undef PROGRESS_REPORT + + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.vc b/thirdparty/jpeg-9e/jconfig.vc new file mode 100644 index 0000000..e9d33e5 --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.vc @@ -0,0 +1,52 @@ +/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 9x or NT. */ +/* This file also works for Borland C++ 32-bit (bcc32) on Windows 9x or NT. */ +/* see jconfig.txt for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +/* Define "boolean" as unsigned char, not enum, per Windows custom */ +#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ +typedef unsigned char boolean; +#endif +#ifndef FALSE /* in case these macros already exist */ +#define FALSE 0 /* values of boolean */ +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ + + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Microsoft has setmode() */ +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.vms b/thirdparty/jpeg-9e/jconfig.vms new file mode 100644 index 0000000..8337b0b --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.vms @@ -0,0 +1,37 @@ +/* jconfig.vms --- jconfig.h for use on Digital VMS. */ +/* see jconfig.txt for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE /* Needed on VMS */ +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jconfig.wat b/thirdparty/jpeg-9e/jconfig.wat new file mode 100644 index 0000000..190cc75 --- /dev/null +++ b/thirdparty/jpeg-9e/jconfig.wat @@ -0,0 +1,38 @@ +/* jconfig.wat --- jconfig.h for Watcom C/C++ on MS-DOS or OS/2. */ +/* see jconfig.txt for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#define CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* Watcom uses flat 32-bit addressing */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#undef TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Needed to make one-file style work in Watcom */ +#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/thirdparty/jpeg-9e/jcparam.c b/thirdparty/jpeg-9e/jcparam.c new file mode 100644 index 0000000..261ae86 --- /dev/null +++ b/thirdparty/jpeg-9e/jcparam.c @@ -0,0 +1,591 @@ +/* + * jcparam.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * Modified 2003-2022 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains optional default-setting code for the JPEG compressor. + * Applications do not have to use this file, but those that don't use it + * must know a lot more about the innards of the JPEG code. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Quantization table setup routines + */ + +GLOBAL(void) +jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, boolean force_baseline) +/* Define a quantization table equal to the basic_table times + * a scale factor (given as a percentage). + * If force_baseline is TRUE, the computed quantization table entries + * are limited to 1..255 for JPEG baseline compatibility. + */ +{ + JQUANT_TBL ** qtblptr; + int i; + long temp; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS) + ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl); + + qtblptr = & cinfo->quant_tbl_ptrs[which_tbl]; + + if (*qtblptr == NULL) + *qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo); + + for (i = 0; i < DCTSIZE2; i++) { + temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; + /* limit the values to the valid range */ + if (temp <= 0L) temp = 1L; + if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */ + if (force_baseline && temp > 255L) + temp = 255L; /* limit to baseline range if requested */ + (*qtblptr)->quantval[i] = (UINT16) temp; + } + + /* Initialize sent_table FALSE so table will be written to JPEG file. */ + (*qtblptr)->sent_table = FALSE; +} + + +/* These are the sample quantization tables given in JPEG spec section K.1. + * NOTE: chrominance DC value is changed from 17 to 16 for lossless support. + * The spec says that the values given produce "good" quality, + * and when divided by 2, "very good" quality. + */ +static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = { + 16, 11, 10, 16, 24, 40, 51, 61, + 12, 12, 14, 19, 26, 58, 60, 55, + 14, 13, 16, 24, 40, 57, 69, 56, + 14, 17, 22, 29, 51, 87, 80, 62, + 18, 22, 37, 56, 68, 109, 103, 77, + 24, 35, 55, 64, 81, 104, 113, 92, + 49, 64, 78, 87, 103, 121, 120, 101, + 72, 92, 95, 98, 112, 100, 103, 99 +}; +static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = { + 16, 18, 24, 47, 99, 99, 99, 99, + 18, 21, 26, 66, 99, 99, 99, 99, + 24, 26, 56, 99, 99, 99, 99, 99, + 47, 66, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99 +}; + + +GLOBAL(void) +jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline) +/* Set or change the 'quality' (quantization) setting, using default tables + * and straight percentage-scaling quality scales. + * This entry point allows different scalings for luminance and chrominance. + */ +{ + /* Set up two quantization tables using the specified scaling */ + jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, + cinfo->q_scale_factor[0], force_baseline); + jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, + cinfo->q_scale_factor[1], force_baseline); +} + + +GLOBAL(void) +jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, + boolean force_baseline) +/* Set or change the 'quality' (quantization) setting, using default tables + * and a straight percentage-scaling quality scale. In most cases it's better + * to use jpeg_set_quality (below); this entry point is provided for + * applications that insist on a linear percentage scaling. + */ +{ + /* Set up two quantization tables using the specified scaling */ + jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, + scale_factor, force_baseline); + jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, + scale_factor, force_baseline); +} + + +GLOBAL(int) +jpeg_quality_scaling (int quality) +/* Convert a user-specified quality rating to a percentage scaling factor + * for an underlying quantization table, using our recommended scaling curve. + * The input 'quality' factor should be 0 (terrible) to 100 (very good). + */ +{ + /* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */ + if (quality <= 0) quality = 1; + if (quality > 100) quality = 100; + + /* The basic table is used as-is (scaling 100) for a quality of 50. + * Qualities 50..100 are converted to scaling percentage 200 - 2*Q; + * note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table + * to make all the table entries 1 (hence, minimum quantization loss). + * Qualities 1..50 are converted to scaling percentage 5000/Q. + */ + if (quality < 50) + quality = 5000 / quality; + else + quality = 200 - quality*2; + + return quality; +} + + +GLOBAL(void) +jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) +/* Set or change the 'quality' (quantization) setting, using default tables. + * This is the standard quality-adjusting entry point for typical user + * interfaces; only those who want detailed control over quantization tables + * would use the preceding routines directly. + */ +{ + /* Convert user 0-100 rating to percentage scaling */ + quality = jpeg_quality_scaling(quality); + + /* Set up standard quality tables */ + jpeg_set_linear_quality(cinfo, quality, force_baseline); +} + + +/* + * Reset standard Huffman tables + */ + +LOCAL(void) +std_huff_tables (j_compress_ptr cinfo) +{ + if (cinfo->dc_huff_tbl_ptrs[0] != NULL) + (void) jpeg_std_huff_table((j_common_ptr) cinfo, TRUE, 0); + + if (cinfo->ac_huff_tbl_ptrs[0] != NULL) + (void) jpeg_std_huff_table((j_common_ptr) cinfo, FALSE, 0); + + if (cinfo->dc_huff_tbl_ptrs[1] != NULL) + (void) jpeg_std_huff_table((j_common_ptr) cinfo, TRUE, 1); + + if (cinfo->ac_huff_tbl_ptrs[1] != NULL) + (void) jpeg_std_huff_table((j_common_ptr) cinfo, FALSE, 1); +} + + +/* + * Default parameter setup for compression. + * + * Applications that don't choose to use this routine must do their + * own setup of all these parameters. Alternately, you can call this + * to establish defaults and then alter parameters selectively. This + * is the recommended approach since, if we add any new parameters, + * your code will still work (they'll be set to reasonable defaults). + */ + +GLOBAL(void) +jpeg_set_defaults (j_compress_ptr cinfo) +{ + int i; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* Allocate comp_info array large enough for maximum component count. + * Array is made permanent in case application wants to compress + * multiple images at same param settings. + */ + if (cinfo->comp_info == NULL) + cinfo->comp_info = (jpeg_component_info *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + MAX_COMPONENTS * SIZEOF(jpeg_component_info)); + + /* Initialize everything not dependent on the color space */ + + cinfo->scale_num = 1; /* 1:1 scaling */ + cinfo->scale_denom = 1; + cinfo->data_precision = BITS_IN_JSAMPLE; + /* Set up two quantization tables using default quality of 75 */ + jpeg_set_quality(cinfo, 75, TRUE); + /* Reset standard Huffman tables */ + std_huff_tables(cinfo); + + /* Initialize default arithmetic coding conditioning */ + for (i = 0; i < NUM_ARITH_TBLS; i++) { + cinfo->arith_dc_L[i] = 0; + cinfo->arith_dc_U[i] = 1; + cinfo->arith_ac_K[i] = 5; + } + + /* Default is no multiple-scan output */ + cinfo->scan_info = NULL; + cinfo->num_scans = 0; + + /* Expect normal source image, not raw downsampled data */ + cinfo->raw_data_in = FALSE; + + /* The standard Huffman tables are only valid for 8-bit data precision. + * If the precision is higher, use arithmetic coding. + * (Alternatively, using Huffman coding would be possible with forcing + * optimization on so that usable tables will be computed, or by + * supplying default tables that are valid for the desired precision.) + * Otherwise, use Huffman coding by default. + */ + cinfo->arith_code = cinfo->data_precision > 8 ? TRUE : FALSE; + + /* By default, don't do extra passes to optimize entropy coding */ + cinfo->optimize_coding = FALSE; + + /* By default, use the simpler non-cosited sampling alignment */ + cinfo->CCIR601_sampling = FALSE; + + /* By default, apply fancy downsampling */ + cinfo->do_fancy_downsampling = TRUE; + + /* No input smoothing */ + cinfo->smoothing_factor = 0; + + /* DCT algorithm preference */ + cinfo->dct_method = JDCT_DEFAULT; + + /* No restart markers */ + cinfo->restart_interval = 0; + cinfo->restart_in_rows = 0; + + /* Fill in default JFIF marker parameters. Note that whether the marker + * will actually be written is determined by jpeg_set_colorspace. + * + * By default, the library emits JFIF version code 1.01. + * An application that wants to emit JFIF 1.02 extension markers should set + * JFIF_minor_version to 2. We could probably get away with just defaulting + * to 1.02, but there may still be some decoders in use that will complain + * about that; saying 1.01 should minimize compatibility problems. + * + * For wide gamut colorspaces (BG_RGB and BG_YCC), the major version will be + * overridden by jpeg_set_colorspace and set to 2. + */ + cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */ + cinfo->JFIF_minor_version = 1; + cinfo->density_unit = 0; /* Pixel size is unknown by default */ + cinfo->X_density = 1; /* Pixel aspect ratio is square by default */ + cinfo->Y_density = 1; + + /* No color transform */ + cinfo->color_transform = JCT_NONE; + + /* Choose JPEG colorspace based on input space, set defaults accordingly */ + + jpeg_default_colorspace(cinfo); +} + + +/* + * Select an appropriate JPEG colorspace for in_color_space. + */ + +GLOBAL(void) +jpeg_default_colorspace (j_compress_ptr cinfo) +{ + switch (cinfo->in_color_space) { + case JCS_UNKNOWN: + jpeg_set_colorspace(cinfo, JCS_UNKNOWN); + break; + case JCS_GRAYSCALE: + jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); + break; + case JCS_RGB: + jpeg_set_colorspace(cinfo, JCS_YCbCr); + break; + case JCS_YCbCr: + jpeg_set_colorspace(cinfo, JCS_YCbCr); + break; + case JCS_CMYK: + jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */ + break; + case JCS_YCCK: + jpeg_set_colorspace(cinfo, JCS_YCCK); + break; + case JCS_BG_RGB: + /* No translation for now -- conversion to BG_YCC not yet supportet */ + jpeg_set_colorspace(cinfo, JCS_BG_RGB); + break; + case JCS_BG_YCC: + jpeg_set_colorspace(cinfo, JCS_BG_YCC); + break; + default: + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + } +} + + +/* + * Set the JPEG colorspace, and choose colorspace-dependent default values. + */ + +GLOBAL(void) +jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) +{ + jpeg_component_info * compptr; + int ci; + +#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \ + (compptr = &cinfo->comp_info[index], \ + compptr->component_id = (id), \ + compptr->h_samp_factor = (hsamp), \ + compptr->v_samp_factor = (vsamp), \ + compptr->quant_tbl_no = (quant), \ + compptr->dc_tbl_no = (dctbl), \ + compptr->ac_tbl_no = (actbl) ) + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* For all colorspaces, we use Q and Huff tables 0 for luminance components, + * tables 1 for chrominance components. + */ + + cinfo->jpeg_color_space = colorspace; + + cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */ + cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */ + + switch (colorspace) { + case JCS_UNKNOWN: + cinfo->num_components = cinfo->input_components; + if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + for (ci = 0; ci < cinfo->num_components; ci++) { + SET_COMP(ci, ci, 1,1, 0, 0,0); + } + break; + case JCS_GRAYSCALE: + cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ + cinfo->num_components = 1; + /* JFIF specifies component ID 1 */ + SET_COMP(0, 0x01, 1,1, 0, 0,0); + break; + case JCS_RGB: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */ + cinfo->num_components = 3; + SET_COMP(0, 0x52 /* 'R' */, 1,1, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0); + SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0); + SET_COMP(2, 0x42 /* 'B' */, 1,1, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0); + break; + case JCS_YCbCr: + cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ + cinfo->num_components = 3; + /* JFIF specifies component IDs 1,2,3 */ + /* We default to 2x2 subsamples of chrominance */ + SET_COMP(0, 0x01, 2,2, 0, 0,0); + SET_COMP(1, 0x02, 1,1, 1, 1,1); + SET_COMP(2, 0x03, 1,1, 1, 1,1); + break; + case JCS_CMYK: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */ + cinfo->num_components = 4; + SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0); + SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0); + SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0); + SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0); + break; + case JCS_YCCK: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */ + cinfo->num_components = 4; + SET_COMP(0, 0x01, 2,2, 0, 0,0); + SET_COMP(1, 0x02, 1,1, 1, 1,1); + SET_COMP(2, 0x03, 1,1, 1, 1,1); + SET_COMP(3, 0x04, 2,2, 0, 0,0); + break; + case JCS_BG_RGB: + cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ + cinfo->JFIF_major_version = 2; /* Set JFIF major version = 2 */ + cinfo->num_components = 3; + /* Add offset 0x20 to the normal R/G/B component IDs */ + SET_COMP(0, 0x72 /* 'r' */, 1,1, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0); + SET_COMP(1, 0x67 /* 'g' */, 1,1, 0, 0,0); + SET_COMP(2, 0x62 /* 'b' */, 1,1, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0, + cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0); + break; + case JCS_BG_YCC: + cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ + cinfo->JFIF_major_version = 2; /* Set JFIF major version = 2 */ + cinfo->num_components = 3; + /* Add offset 0x20 to the normal Cb/Cr component IDs */ + /* We default to 2x2 subsamples of chrominance */ + SET_COMP(0, 0x01, 2,2, 0, 0,0); + SET_COMP(1, 0x22, 1,1, 1, 1,1); + SET_COMP(2, 0x23, 1,1, 1, 1,1); + break; + default: + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + } +} + + +#ifdef C_PROGRESSIVE_SUPPORTED + +LOCAL(jpeg_scan_info *) +fill_a_scan (jpeg_scan_info * scanptr, int ci, + int Ss, int Se, int Ah, int Al) +/* Support routine: generate one scan for specified component */ +{ + scanptr->comps_in_scan = 1; + scanptr->component_index[0] = ci; + scanptr->Ss = Ss; + scanptr->Se = Se; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + return scanptr; +} + +LOCAL(jpeg_scan_info *) +fill_scans (jpeg_scan_info * scanptr, int ncomps, + int Ss, int Se, int Ah, int Al) +/* Support routine: generate one scan for each component */ +{ + int ci; + + for (ci = 0; ci < ncomps; ci++) { + scanptr->comps_in_scan = 1; + scanptr->component_index[0] = ci; + scanptr->Ss = Ss; + scanptr->Se = Se; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + } + return scanptr; +} + +LOCAL(jpeg_scan_info *) +fill_dc_scans (jpeg_scan_info * scanptr, int ncomps, int Ah, int Al) +/* Support routine: generate interleaved DC scan if possible, else N scans */ +{ + int ci; + + if (ncomps <= MAX_COMPS_IN_SCAN) { + /* Single interleaved DC scan */ + scanptr->comps_in_scan = ncomps; + for (ci = 0; ci < ncomps; ci++) + scanptr->component_index[ci] = ci; + scanptr->Ss = scanptr->Se = 0; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + } else { + /* Noninterleaved DC scan for each component */ + scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al); + } + return scanptr; +} + + +/* + * Create a recommended progressive-JPEG script. + * cinfo->num_components and cinfo->jpeg_color_space must be correct. + */ + +GLOBAL(void) +jpeg_simple_progression (j_compress_ptr cinfo) +{ + int ncomps = cinfo->num_components; + int nscans; + jpeg_scan_info * scanptr; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* Figure space needed for script. Calculation must match code below! */ + if (ncomps == 3 && + (cinfo->jpeg_color_space == JCS_YCbCr || + cinfo->jpeg_color_space == JCS_BG_YCC)) { + /* Custom script for YCC color images. */ + nscans = 10; + } else { + /* All-purpose script for other color spaces. */ + if (ncomps > MAX_COMPS_IN_SCAN) + nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */ + else + nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */ + } + + /* Allocate space for script. + * We need to put it in the permanent pool in case the application performs + * multiple compressions without changing the settings. To avoid a memory + * leak if jpeg_simple_progression is called repeatedly for the same JPEG + * object, we try to re-use previously allocated space, and we allocate + * enough space to handle YCC even if initially asked for grayscale. + */ + if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) { + cinfo->script_space_size = MAX(nscans, 10); + cinfo->script_space = (jpeg_scan_info *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + cinfo->script_space_size * SIZEOF(jpeg_scan_info)); + } + scanptr = cinfo->script_space; + cinfo->scan_info = scanptr; + cinfo->num_scans = nscans; + + if (ncomps == 3 && + (cinfo->jpeg_color_space == JCS_YCbCr || + cinfo->jpeg_color_space == JCS_BG_YCC)) { + /* Custom script for YCC color images. */ + /* Initial DC scan */ + scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); + /* Initial AC scan: get some luma data out in a hurry */ + scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2); + /* Chroma data is too small to be worth expending many scans on */ + scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1); + scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1); + /* Complete spectral selection for luma AC */ + scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2); + /* Refine next bit of luma AC */ + scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1); + /* Finish DC successive approximation */ + scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); + /* Finish AC successive approximation */ + scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0); + scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0); + /* Luma bottom bit comes last since it's usually largest scan */ + scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0); + } else { + /* All-purpose script for other color spaces. */ + /* Successive approximation first pass */ + scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); + scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2); + scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2); + /* Successive approximation second pass */ + scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1); + /* Successive approximation final pass */ + scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); + scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0); + } +} + +#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/jcprepct.c b/thirdparty/jpeg-9e/jcprepct.c new file mode 100644 index 0000000..586964b --- /dev/null +++ b/thirdparty/jpeg-9e/jcprepct.c @@ -0,0 +1,358 @@ +/* + * jcprepct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2003-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the compression preprocessing controller. + * This controller manages the color conversion, downsampling, + * and edge expansion steps. + * + * Most of the complexity here is associated with buffering input rows + * as required by the downsampler. See the comments at the head of + * jcsample.c for the downsampler's needs. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* At present, jcsample.c can request context rows only for smoothing. + * In the future, we might also need context rows for CCIR601 sampling + * or other more-complex downsampling procedures. The code to support + * context rows should be compiled only if needed. + */ +#ifdef INPUT_SMOOTHING_SUPPORTED +#define CONTEXT_ROWS_SUPPORTED +#endif + + +/* + * For the simple (no-context-row) case, we just need to buffer one + * row group's worth of pixels for the downsampling step. At the bottom of + * the image, we pad to a full row group by replicating the last pixel row. + * The downsampler's last output row is then replicated if needed to pad + * out to a full iMCU row. + * + * When providing context rows, we must buffer three row groups' worth of + * pixels. Three row groups are physically allocated, but the row pointer + * arrays are made five row groups high, with the extra pointers above and + * below "wrapping around" to point to the last and first real row groups. + * This allows the downsampler to access the proper context rows. + * At the top and bottom of the image, we create dummy context rows by + * copying the first or last real pixel row. This copying could be avoided + * by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the + * trouble on the compression side. + */ + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_prep_controller pub; /* public fields */ + + /* Downsampling input buffer. This buffer holds color-converted data + * until we have enough to do a downsample step. + */ + JSAMPARRAY color_buf[MAX_COMPONENTS]; + + JDIMENSION rows_to_go; /* counts rows remaining in source image */ + int next_buf_row; /* index of next row to store in color_buf */ + +#ifdef CONTEXT_ROWS_SUPPORTED /* only needed for context case */ + int this_row_group; /* starting row index of group to process */ + int next_buf_stop; /* downsample when we reach this index */ +#endif +} my_prep_controller; + +typedef my_prep_controller * my_prep_ptr; + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + + if (pass_mode != JBUF_PASS_THRU) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + /* Initialize total-height counter for detecting bottom of image */ + prep->rows_to_go = cinfo->image_height; + /* Mark the conversion buffer empty */ + prep->next_buf_row = 0; +#ifdef CONTEXT_ROWS_SUPPORTED + /* Preset additional state variables for context mode. + * These aren't used in non-context mode, so we needn't test which mode. + */ + prep->this_row_group = 0; + /* Set next_buf_stop to stop after two row groups have been read in. */ + prep->next_buf_stop = 2 * cinfo->max_v_samp_factor; +#endif +} + + +/* + * Expand an image vertically from height input_rows to height output_rows, + * by duplicating the bottom row. + */ + +LOCAL(void) +expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols, + int input_rows, int output_rows) +{ + register int row; + + for (row = input_rows; row < output_rows; row++) { + jcopy_sample_rows(image_data + input_rows - 1, + image_data + row, + 1, num_cols); + } +} + + +/* + * Process some data in the simple no-context case. + * + * Preprocessor output data is counted in "row groups". A row group + * is defined to be v_samp_factor sample rows of each component. + * Downsampling will produce this much data from each max_v_samp_factor + * input rows. + */ + +METHODDEF(void) +pre_process_data (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int numrows, ci; + JDIMENSION inrows; + jpeg_component_info * compptr; + + while (*in_row_ctr < in_rows_avail && + *out_row_group_ctr < out_row_groups_avail) { + /* Do color conversion to fill the conversion buffer. */ + inrows = in_rows_avail - *in_row_ctr; + numrows = cinfo->max_v_samp_factor - prep->next_buf_row; + numrows = (int) MIN((JDIMENSION) numrows, inrows); + (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, + prep->color_buf, + (JDIMENSION) prep->next_buf_row, + numrows); + *in_row_ctr += numrows; + prep->next_buf_row += numrows; + prep->rows_to_go -= numrows; + /* If at bottom of image, pad to fill the conversion buffer. */ + if (prep->rows_to_go == 0 && + prep->next_buf_row < cinfo->max_v_samp_factor) { + for (ci = 0; ci < cinfo->num_components; ci++) { + expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, + prep->next_buf_row, cinfo->max_v_samp_factor); + } + prep->next_buf_row = cinfo->max_v_samp_factor; + } + /* If we've filled the conversion buffer, empty it. */ + if (prep->next_buf_row == cinfo->max_v_samp_factor) { + (*cinfo->downsample->downsample) (cinfo, + prep->color_buf, (JDIMENSION) 0, + output_buf, *out_row_group_ctr); + prep->next_buf_row = 0; + (*out_row_group_ctr)++; + } + /* If at bottom of image, pad the output to a full iMCU height. + * Note we assume the caller is providing a one-iMCU-height output buffer! + */ + if (prep->rows_to_go == 0 && + *out_row_group_ctr < out_row_groups_avail) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + numrows = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) / + cinfo->min_DCT_v_scaled_size; + expand_bottom_edge(output_buf[ci], + compptr->width_in_blocks * compptr->DCT_h_scaled_size, + (int) (*out_row_group_ctr * numrows), + (int) (out_row_groups_avail * numrows)); + } + *out_row_group_ctr = out_row_groups_avail; + break; /* can exit outer loop without test */ + } + } +} + + +#ifdef CONTEXT_ROWS_SUPPORTED + +/* + * Process some data in the context case. + */ + +METHODDEF(void) +pre_process_context (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int numrows, ci; + int buf_height = cinfo->max_v_samp_factor * 3; + JDIMENSION inrows; + + while (*out_row_group_ctr < out_row_groups_avail) { + if (*in_row_ctr < in_rows_avail) { + /* Do color conversion to fill the conversion buffer. */ + inrows = in_rows_avail - *in_row_ctr; + numrows = prep->next_buf_stop - prep->next_buf_row; + numrows = (int) MIN((JDIMENSION) numrows, inrows); + (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, + prep->color_buf, + (JDIMENSION) prep->next_buf_row, + numrows); + /* Pad at top of image, if first time through */ + if (prep->rows_to_go == cinfo->image_height) { + for (ci = 0; ci < cinfo->num_components; ci++) { + int row; + for (row = 1; row <= cinfo->max_v_samp_factor; row++) { + jcopy_sample_rows(prep->color_buf[ci], + prep->color_buf[ci] - row, + 1, cinfo->image_width); + } + } + } + *in_row_ctr += numrows; + prep->next_buf_row += numrows; + prep->rows_to_go -= numrows; + } else { + /* Return for more data, unless we are at the bottom of the image. */ + if (prep->rows_to_go != 0) + break; + /* When at bottom of image, pad to fill the conversion buffer. */ + if (prep->next_buf_row < prep->next_buf_stop) { + for (ci = 0; ci < cinfo->num_components; ci++) { + expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, + prep->next_buf_row, prep->next_buf_stop); + } + prep->next_buf_row = prep->next_buf_stop; + } + } + /* If we've gotten enough data, downsample a row group. */ + if (prep->next_buf_row == prep->next_buf_stop) { + (*cinfo->downsample->downsample) (cinfo, + prep->color_buf, + (JDIMENSION) prep->this_row_group, + output_buf, *out_row_group_ctr); + (*out_row_group_ctr)++; + /* Advance pointers with wraparound as necessary. */ + prep->this_row_group += cinfo->max_v_samp_factor; + if (prep->this_row_group >= buf_height) + prep->this_row_group = 0; + if (prep->next_buf_row >= buf_height) + prep->next_buf_row = 0; + prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor; + } + } +} + + +/* + * Create the wrapped-around downsampling input buffer needed for context mode. + */ + +LOCAL(void) +create_context_buffer (j_compress_ptr cinfo) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int rgroup_height = cinfo->max_v_samp_factor; + int ci, i; + jpeg_component_info * compptr; + JSAMPARRAY true_buffer, fake_buffer; + + /* Grab enough space for fake row pointers for all the components; + * we need five row groups' worth of pointers for each component. + */ + fake_buffer = (JSAMPARRAY) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (cinfo->num_components * 5 * rgroup_height) * SIZEOF(JSAMPROW)); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Allocate the actual buffer space (3 row groups) for this component. + * We make the buffer wide enough to allow the downsampler to edge-expand + * horizontally within the buffer, if it so chooses. + */ + true_buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (((long) compptr->width_in_blocks * + cinfo->min_DCT_h_scaled_size * + cinfo->max_h_samp_factor) / compptr->h_samp_factor), + (JDIMENSION) (3 * rgroup_height)); + /* Copy true buffer row pointers into the middle of the fake row array */ + MEMCOPY(fake_buffer + rgroup_height, true_buffer, + 3 * rgroup_height * SIZEOF(JSAMPROW)); + /* Fill in the above and below wraparound pointers */ + for (i = 0; i < rgroup_height; i++) { + fake_buffer[i] = true_buffer[2 * rgroup_height + i]; + fake_buffer[4 * rgroup_height + i] = true_buffer[i]; + } + prep->color_buf[ci] = fake_buffer + rgroup_height; + fake_buffer += 5 * rgroup_height; /* point to space for next component */ + } +} + +#endif /* CONTEXT_ROWS_SUPPORTED */ + + +/* + * Initialize preprocessing controller. + */ + +GLOBAL(void) +jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_prep_ptr prep; + int ci; + jpeg_component_info * compptr; + + if (need_full_buffer) /* safety check */ + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + prep = (my_prep_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_prep_controller)); + cinfo->prep = &prep->pub; + prep->pub.start_pass = start_pass_prep; + + /* Allocate the color conversion buffer. + * We make the buffer wide enough to allow the downsampler to edge-expand + * horizontally within the buffer, if it so chooses. + */ + if (cinfo->downsample->need_context_rows) { + /* Set up to provide context rows */ +#ifdef CONTEXT_ROWS_SUPPORTED + prep->pub.pre_process_data = pre_process_context; + create_context_buffer(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + /* No context, just make it tall enough for one row group */ + prep->pub.pre_process_data = pre_process_data; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + prep->color_buf[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (((long) compptr->width_in_blocks * + cinfo->min_DCT_h_scaled_size * + cinfo->max_h_samp_factor) / compptr->h_samp_factor), + (JDIMENSION) cinfo->max_v_samp_factor); + } + } +} diff --git a/thirdparty/jpeg-9e/jcsample.c b/thirdparty/jpeg-9e/jcsample.c new file mode 100644 index 0000000..2372c41 --- /dev/null +++ b/thirdparty/jpeg-9e/jcsample.c @@ -0,0 +1,545 @@ +/* + * jcsample.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2003-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains downsampling routines. + * + * Downsampling input data is counted in "row groups". A row group + * is defined to be max_v_samp_factor pixel rows of each component, + * from which the downsampler produces v_samp_factor sample rows. + * A single row group is processed in each call to the downsampler module. + * + * The downsampler is responsible for edge-expansion of its output data + * to fill an integral number of DCT blocks horizontally. The source buffer + * may be modified if it is helpful for this purpose (the source buffer is + * allocated wide enough to correspond to the desired output width). + * The caller (the prep controller) is responsible for vertical padding. + * + * The downsampler may request "context rows" by setting need_context_rows + * during startup. In this case, the input arrays will contain at least + * one row group's worth of pixels above and below the passed-in data; + * the caller will create dummy rows at image top and bottom by replicating + * the first or last real pixel row. + * + * An excellent reference for image resampling is + * Digital Image Warping, George Wolberg, 1990. + * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. + * + * The downsampling algorithm used here is a simple average of the source + * pixels covered by the output pixel. The hi-falutin sampling literature + * refers to this as a "box filter". In general the characteristics of a box + * filter are not very good, but for the specific cases we normally use (1:1 + * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not + * nearly so bad. If you intend to use other sampling ratios, you'd be well + * advised to improve this code. + * + * A simple input-smoothing capability is provided. This is mainly intended + * for cleaning up color-dithered GIF input files (if you find it inadequate, + * we suggest using an external filtering program such as pnmconvol). When + * enabled, each input pixel P is replaced by a weighted sum of itself and its + * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF, + * where SF = (smoothing_factor / 1024). + * Currently, smoothing is only supported for 2h2v sampling factors. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Pointer to routine to downsample a single component */ +typedef JMETHOD(void, downsample1_ptr, + (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data)); + +/* Private subobject */ + +typedef struct { + struct jpeg_downsampler pub; /* public fields */ + + /* Downsampling method pointers, one per component */ + downsample1_ptr methods[MAX_COMPONENTS]; + + /* Height of an output row group for each component. */ + int rowgroup_height[MAX_COMPONENTS]; + + /* These arrays save pixel expansion factors so that int_downsample need not + * recompute them each time. They are unused for other downsampling methods. + */ + UINT8 h_expand[MAX_COMPONENTS]; + UINT8 v_expand[MAX_COMPONENTS]; +} my_downsampler; + +typedef my_downsampler * my_downsample_ptr; + + +/* + * Initialize for a downsampling pass. + */ + +METHODDEF(void) +start_pass_downsample (j_compress_ptr cinfo) +{ + /* no work for now */ +} + + +/* + * Expand a component horizontally from width input_cols to width output_cols, + * by duplicating the rightmost samples. + */ + +LOCAL(void) +expand_right_edge (JSAMPARRAY image_data, int num_rows, + JDIMENSION input_cols, JDIMENSION output_cols) +{ + register JSAMPROW ptr; + register JSAMPLE pixval; + register int count; + int row; + int numcols = (int) (output_cols - input_cols); + + if (numcols > 0) { + for (row = 0; row < num_rows; row++) { + ptr = image_data[row] + input_cols; + pixval = ptr[-1]; /* don't need GETJSAMPLE() here */ + for (count = numcols; count > 0; count--) + *ptr++ = pixval; + } + } +} + + +/* + * Do downsampling for a whole row group (all components). + * + * In this version we simply downsample each component independently. + */ + +METHODDEF(void) +sep_downsample (j_compress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_index, + JSAMPIMAGE output_buf, JDIMENSION out_row_group_index) +{ + my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample; + int ci; + jpeg_component_info * compptr; + JSAMPARRAY in_ptr, out_ptr; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + in_ptr = input_buf[ci] + in_row_index; + out_ptr = output_buf[ci] + + (out_row_group_index * downsample->rowgroup_height[ci]); + (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr); + } +} + + +/* + * Downsample pixel values of a single component. + * One row group is processed per call. + * This version handles arbitrary integral sampling ratios, without smoothing. + * Note that this version is not actually used for customary sampling ratios. + */ + +METHODDEF(void) +int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample; + int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v; + JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */ + JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size; + JSAMPROW inptr, outptr; + INT32 outvalue; + + h_expand = downsample->h_expand[compptr->component_index]; + v_expand = downsample->v_expand[compptr->component_index]; + numpix = h_expand * v_expand; + numpix2 = numpix/2; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * h_expand); + + inrow = outrow = 0; + while (inrow < cinfo->max_v_samp_factor) { + outptr = output_data[outrow]; + for (outcol = 0, outcol_h = 0; outcol < output_cols; + outcol++, outcol_h += h_expand) { + outvalue = 0; + for (v = 0; v < v_expand; v++) { + inptr = input_data[inrow+v] + outcol_h; + for (h = 0; h < h_expand; h++) { + outvalue += (INT32) GETJSAMPLE(*inptr++); + } + } + *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix); + } + inrow += v_expand; + outrow++; + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the special case of a full-size component, + * without smoothing. + */ + +METHODDEF(void) +fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + /* Copy the data */ + jcopy_sample_rows(input_data, output_data, + cinfo->max_v_samp_factor, cinfo->image_width); + /* Edge-expand */ + expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width, + compptr->width_in_blocks * compptr->DCT_h_scaled_size); +} + + +/* + * Downsample pixel values of a single component. + * This version handles the common case of 2:1 horizontal and 1:1 vertical, + * without smoothing. + * + * A note about the "bias" calculations: when rounding fractional values to + * integer, we do not want to always round 0.5 up to the next integer. + * If we did that, we'd introduce a noticeable bias towards larger values. + * Instead, this code is arranged so that 0.5 will be rounded up or down at + * alternate pixel locations (a simple ordered dither pattern). + */ + +METHODDEF(void) +h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow; + JDIMENSION outcol; + JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size; + register JSAMPROW inptr, outptr; + register int bias; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * 2); + + for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { + outptr = output_data[inrow]; + inptr = input_data[inrow]; + bias = 0; /* bias = 0,1,0,1,... for successive samples */ + for (outcol = 0; outcol < output_cols; outcol++) { + *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) + + bias) >> 1); + bias ^= 1; /* 0=>1, 1=>0 */ + inptr += 2; + } + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the standard case of 2:1 horizontal and 2:1 vertical, + * without smoothing. + */ + +METHODDEF(void) +h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow, outrow; + JDIMENSION outcol; + JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size; + register JSAMPROW inptr0, inptr1, outptr; + register int bias; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * 2); + + inrow = outrow = 0; + while (inrow < cinfo->max_v_samp_factor) { + outptr = output_data[outrow]; + inptr0 = input_data[inrow]; + inptr1 = input_data[inrow+1]; + bias = 1; /* bias = 1,2,1,2,... for successive samples */ + for (outcol = 0; outcol < output_cols; outcol++) { + *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) + + bias) >> 2); + bias ^= 3; /* 1=>2, 2=>1 */ + inptr0 += 2; inptr1 += 2; + } + inrow += 2; + outrow++; + } +} + + +#ifdef INPUT_SMOOTHING_SUPPORTED + +/* + * Downsample pixel values of a single component. + * This version handles the standard case of 2:1 horizontal and 2:1 vertical, + * with smoothing. One row of context is required. + */ + +METHODDEF(void) +h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow, outrow; + JDIMENSION colctr; + JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size; + register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr; + INT32 membersum, neighsum, memberscale, neighscale; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, + cinfo->image_width, output_cols * 2); + + /* We don't bother to form the individual "smoothed" input pixel values; + * we can directly compute the output which is the average of the four + * smoothed values. Each of the four member pixels contributes a fraction + * (1-8*SF) to its own smoothed image and a fraction SF to each of the three + * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final + * output. The four corner-adjacent neighbor pixels contribute a fraction + * SF to just one smoothed pixel, or SF/4 to the final output; while the + * eight edge-adjacent neighbors contribute SF to each of two smoothed + * pixels, or SF/2 overall. In order to use integer arithmetic, these + * factors are scaled by 2^16 = 65536. + * Also recall that SF = smoothing_factor / 1024. + */ + + memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */ + neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */ + + inrow = outrow = 0; + while (inrow < cinfo->max_v_samp_factor) { + outptr = output_data[outrow]; + inptr0 = input_data[inrow]; + inptr1 = input_data[inrow+1]; + above_ptr = input_data[inrow-1]; + below_ptr = input_data[inrow+2]; + + /* Special case for first column: pretend column -1 is same as column 0 */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]); + neighsum += neighsum; + neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]); + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; + + for (colctr = output_cols - 2; colctr > 0; colctr--) { + /* sum of pixels directly mapped to this output element */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + /* sum of edge-neighbor pixels */ + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) + + GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]); + /* The edge-neighbors count twice as much as corner-neighbors */ + neighsum += neighsum; + /* Add in the corner-neighbors */ + neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) + + GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]); + /* form final output scaled up by 2^16 */ + membersum = membersum * memberscale + neighsum * neighscale; + /* round, descale and output it */ + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; + } + + /* Special case for last column */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]); + neighsum += neighsum; + neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]); + membersum = membersum * memberscale + neighsum * neighscale; + *outptr = (JSAMPLE) ((membersum + 32768) >> 16); + + inrow += 2; + outrow++; + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the special case of a full-size component, + * with smoothing. One row of context is required. + */ + +METHODDEF(void) +fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow; + JDIMENSION colctr; + JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size; + register JSAMPROW inptr, above_ptr, below_ptr, outptr; + INT32 membersum, neighsum, memberscale, neighscale; + int colsum, lastcolsum, nextcolsum; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, + cinfo->image_width, output_cols); + + /* Each of the eight neighbor pixels contributes a fraction SF to the + * smoothed pixel, while the main pixel contributes (1-8*SF). In order + * to use integer arithmetic, these factors are multiplied by 2^16 = 65536. + * Also recall that SF = smoothing_factor / 1024. + */ + + memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */ + neighscale = cinfo->smoothing_factor * 64; /* scaled SF */ + + for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { + outptr = output_data[inrow]; + inptr = input_data[inrow]; + above_ptr = input_data[inrow-1]; + below_ptr = input_data[inrow+1]; + + /* Special case for first column */ + colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) + + GETJSAMPLE(*inptr); + membersum = GETJSAMPLE(*inptr++); + nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + + GETJSAMPLE(*inptr); + neighsum = colsum + (colsum - membersum) + nextcolsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + lastcolsum = colsum; colsum = nextcolsum; + + for (colctr = output_cols - 2; colctr > 0; colctr--) { + membersum = GETJSAMPLE(*inptr++); + above_ptr++; below_ptr++; + nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + + GETJSAMPLE(*inptr); + neighsum = lastcolsum + (colsum - membersum) + nextcolsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + lastcolsum = colsum; colsum = nextcolsum; + } + + /* Special case for last column */ + membersum = GETJSAMPLE(*inptr); + neighsum = lastcolsum + (colsum - membersum) + colsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr = (JSAMPLE) ((membersum + 32768) >> 16); + + } +} + +#endif /* INPUT_SMOOTHING_SUPPORTED */ + + +/* + * Module initialization routine for downsampling. + * Note that we must select a routine for each component. + */ + +GLOBAL(void) +jinit_downsampler (j_compress_ptr cinfo) +{ + my_downsample_ptr downsample; + int ci; + jpeg_component_info * compptr; + boolean smoothok = TRUE; + int h_in_group, v_in_group, h_out_group, v_out_group; + + downsample = (my_downsample_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_downsampler)); + cinfo->downsample = &downsample->pub; + downsample->pub.start_pass = start_pass_downsample; + downsample->pub.downsample = sep_downsample; + downsample->pub.need_context_rows = FALSE; + + if (cinfo->CCIR601_sampling) + ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); + + /* Verify we can handle the sampling factors, and set up method pointers */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Compute size of an "output group" for DCT scaling. This many samples + * are to be converted from max_h_samp_factor * max_v_samp_factor pixels. + */ + h_out_group = (compptr->h_samp_factor * compptr->DCT_h_scaled_size) / + cinfo->min_DCT_h_scaled_size; + v_out_group = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) / + cinfo->min_DCT_v_scaled_size; + h_in_group = cinfo->max_h_samp_factor; + v_in_group = cinfo->max_v_samp_factor; + downsample->rowgroup_height[ci] = v_out_group; /* save for use later */ + if (h_in_group == h_out_group && v_in_group == v_out_group) { +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor) { + downsample->methods[ci] = fullsize_smooth_downsample; + downsample->pub.need_context_rows = TRUE; + } else +#endif + downsample->methods[ci] = fullsize_downsample; + } else if (h_in_group == h_out_group * 2 && + v_in_group == v_out_group) { + smoothok = FALSE; + downsample->methods[ci] = h2v1_downsample; + } else if (h_in_group == h_out_group * 2 && + v_in_group == v_out_group * 2) { +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor) { + downsample->methods[ci] = h2v2_smooth_downsample; + downsample->pub.need_context_rows = TRUE; + } else +#endif + downsample->methods[ci] = h2v2_downsample; + } else if ((h_in_group % h_out_group) == 0 && + (v_in_group % v_out_group) == 0) { + smoothok = FALSE; + downsample->methods[ci] = int_downsample; + downsample->h_expand[ci] = (UINT8) (h_in_group / h_out_group); + downsample->v_expand[ci] = (UINT8) (v_in_group / v_out_group); + } else + ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); + } + +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor && !smoothok) + TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL); +#endif +} diff --git a/thirdparty/jpeg-9e/jctrans.c b/thirdparty/jpeg-9e/jctrans.c new file mode 100644 index 0000000..261dd29 --- /dev/null +++ b/thirdparty/jpeg-9e/jctrans.c @@ -0,0 +1,399 @@ +/* + * jctrans.c + * + * Copyright (C) 1995-1998, Thomas G. Lane. + * Modified 2000-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains library routines for transcoding compression, + * that is, writing raw DCT coefficient arrays to an output JPEG file. + * The routines in jcapimin.c will also be needed by a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(void) transencode_master_selection + JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); +LOCAL(void) transencode_coef_controller + JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); + + +/* + * Compression initialization for writing raw-coefficient data. + * Before calling this, all parameters and a data destination must be set up. + * Call jpeg_finish_compress() to actually write the data. + * + * The number of passed virtual arrays must match cinfo->num_components. + * Note that the virtual arrays need not be filled or even realized at + * the time write_coefficients is called; indeed, if the virtual arrays + * were requested from this compression object's memory manager, they + * typically will be realized during this routine and filled afterwards. + */ + +GLOBAL(void) +jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Mark all tables to be written */ + jpeg_suppress_tables(cinfo, FALSE); + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Perform master selection of active modules */ + transencode_master_selection(cinfo, coef_arrays); + /* Wait for jpeg_finish_compress() call */ + cinfo->next_scanline = 0; /* so jpeg_write_marker works */ + cinfo->global_state = CSTATE_WRCOEFS; +} + + +/* + * Initialize the compression object with default parameters, + * then copy from the source object all parameters needed for lossless + * transcoding. Parameters that can be varied without loss (such as + * scan script and Huffman optimization) are left in their default states. + */ + +GLOBAL(void) +jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, + j_compress_ptr dstinfo) +{ + JQUANT_TBL ** qtblptr; + jpeg_component_info *incomp, *outcomp; + JQUANT_TBL *c_quant, *slot_quant; + int tblno, ci, coefi; + + /* Safety check to ensure start_compress not called yet. */ + if (dstinfo->global_state != CSTATE_START) + ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); + /* Copy fundamental image dimensions */ + dstinfo->image_width = srcinfo->image_width; + dstinfo->image_height = srcinfo->image_height; + dstinfo->input_components = srcinfo->num_components; + dstinfo->in_color_space = srcinfo->jpeg_color_space; + dstinfo->jpeg_width = srcinfo->output_width; + dstinfo->jpeg_height = srcinfo->output_height; + dstinfo->min_DCT_h_scaled_size = srcinfo->min_DCT_h_scaled_size; + dstinfo->min_DCT_v_scaled_size = srcinfo->min_DCT_v_scaled_size; + /* Initialize all parameters to default values */ + jpeg_set_defaults(dstinfo); + /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. + * Fix it to get the right header markers for the image colorspace. + * Note: Entropy table assignment in jpeg_set_colorspace + * depends on color_transform. + * Adaption is also required for setting the appropriate + * entropy coding mode dependent on image data precision. + */ + dstinfo->color_transform = srcinfo->color_transform; + jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); + dstinfo->data_precision = srcinfo->data_precision; + dstinfo->arith_code = srcinfo->data_precision > 8 ? TRUE : FALSE; + dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; + /* Copy the source's quantization tables. */ + for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { + if (srcinfo->quant_tbl_ptrs[tblno] != NULL) { + qtblptr = & dstinfo->quant_tbl_ptrs[tblno]; + if (*qtblptr == NULL) + *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); + MEMCOPY((*qtblptr)->quantval, + srcinfo->quant_tbl_ptrs[tblno]->quantval, + SIZEOF((*qtblptr)->quantval)); + (*qtblptr)->sent_table = FALSE; + } + } + /* Copy the source's per-component info. + * Note we assume jpeg_set_defaults has allocated the dest comp_info array. + */ + dstinfo->num_components = srcinfo->num_components; + if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS) + ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components, + MAX_COMPONENTS); + for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info; + ci < dstinfo->num_components; ci++, incomp++, outcomp++) { + outcomp->component_id = incomp->component_id; + outcomp->h_samp_factor = incomp->h_samp_factor; + outcomp->v_samp_factor = incomp->v_samp_factor; + outcomp->quant_tbl_no = incomp->quant_tbl_no; + /* Make sure saved quantization table for component matches the qtable + * slot. If not, the input file re-used this qtable slot. + * IJG encoder currently cannot duplicate this. + */ + tblno = outcomp->quant_tbl_no; + if (tblno < 0 || tblno >= NUM_QUANT_TBLS || + srcinfo->quant_tbl_ptrs[tblno] == NULL) + ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno); + slot_quant = srcinfo->quant_tbl_ptrs[tblno]; + c_quant = incomp->quant_table; + if (c_quant != NULL) { + for (coefi = 0; coefi < DCTSIZE2; coefi++) { + if (c_quant->quantval[coefi] != slot_quant->quantval[coefi]) + ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno); + } + } + /* Note: we do not copy the source's entropy table assignments; + * instead we rely on jpeg_set_colorspace to have made a suitable choice. + */ + } + /* Also copy JFIF version and resolution information, if available. + * Strictly speaking this isn't "critical" info, but it's nearly + * always appropriate to copy it if available. In particular, + * if the application chooses to copy JFIF 1.02 extension markers from + * the source file, we need to copy the version to make sure we don't + * emit a file that has 1.02 extensions but a claimed version of 1.01. + */ + if (srcinfo->saw_JFIF_marker) { + if (srcinfo->JFIF_major_version == 1 || + srcinfo->JFIF_major_version == 2) { + dstinfo->JFIF_major_version = srcinfo->JFIF_major_version; + dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version; + } + dstinfo->density_unit = srcinfo->density_unit; + dstinfo->X_density = srcinfo->X_density; + dstinfo->Y_density = srcinfo->Y_density; + } +} + + +LOCAL(void) +jpeg_calc_trans_dimensions (j_compress_ptr cinfo) +/* Do computations that are needed before master selection phase */ +{ + if (cinfo->min_DCT_h_scaled_size != cinfo->min_DCT_v_scaled_size) + ERREXIT2(cinfo, JERR_BAD_DCTSIZE, + cinfo->min_DCT_h_scaled_size, cinfo->min_DCT_v_scaled_size); + + cinfo->block_size = cinfo->min_DCT_h_scaled_size; +} + + +/* + * Master selection of compression modules for transcoding. + * This substitutes for jcinit.c's initialization of the full compressor. + */ + +LOCAL(void) +transencode_master_selection (j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays) +{ + /* Do computations that are needed before master selection phase */ + jpeg_calc_trans_dimensions(cinfo); + + /* Initialize master control (includes parameter checking/processing) */ + jinit_c_master_control(cinfo, TRUE /* transcode only */); + + /* Entropy encoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) + jinit_arith_encoder(cinfo); + else { + jinit_huff_encoder(cinfo); + } + + /* We need a special coefficient buffer controller. */ + transencode_coef_controller(cinfo, coef_arrays); + + jinit_marker_writer(cinfo); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Write the datastream header (SOI, JFIF) immediately. + * Frame and scan headers are postponed till later. + * This lets application insert special markers after the SOI. + */ + (*cinfo->marker->write_file_header) (cinfo); +} + + +/* + * The rest of this file is a special implementation of the coefficient + * buffer controller. This is similar to jccoefct.c, but it handles only + * output from presupplied virtual arrays. Furthermore, we generate any + * dummy padding blocks on-the-fly rather than expecting them to be present + * in the arrays. + */ + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_coef_controller pub; /* public fields */ + + JDIMENSION iMCU_row_num; /* iMCU row # within image */ + JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* Virtual block array for each component. */ + jvirt_barray_ptr * whole_image; + + /* Workspace for constructing dummy blocks at right/bottom edges. */ + JBLOCK dummy_buffer[C_MAX_BLOCKS_IN_MCU]; +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + + +LOCAL(void) +start_iMCU_row (j_compress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->MCU_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + if (pass_mode != JBUF_CRANK_DEST) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + coef->iMCU_row_num = 0; + start_iMCU_row(cinfo); +} + + +/* + * Process some data. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the scan. + * The data is obtained from the virtual arrays and fed to the entropy coder. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf is ignored; it is likely to be a NULL pointer. + */ + +METHODDEF(boolean) +compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int blkn, ci, xindex, yindex, yoffset, blockcnt; + JDIMENSION start_col; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + start_col = MCU_col_num * compptr->MCU_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (coef->iMCU_row_num < last_iMCU_row || + yoffset + yindex < compptr->last_row_height) { + /* Fill in pointers to real blocks in this row */ + buffer_ptr = buffer[ci][yoffset + yindex] + start_col; + xindex = blockcnt; + do { + MCU_buffer[blkn++] = buffer_ptr++; + } while (--xindex); + /* Dummy blocks at right edge */ + if ((xindex = compptr->MCU_width - blockcnt) == 0) + continue; + } else { + /* At bottom of image, need a whole row of dummy blocks */ + xindex = compptr->MCU_width; + } + /* Fill in any dummy blocks needed in this row. + * Dummy blocks are filled in the same way as in jccoefct.c: + * all zeroes in the AC entries, DC entries equal to previous + * block's DC value. The init routine has already zeroed the + * AC entries, so we need only set the DC entries correctly. + */ + buffer_ptr = coef->dummy_buffer + blkn; + do { + buffer_ptr[0][0] = MCU_buffer[blkn-1][0][0]; + MCU_buffer[blkn++] = buffer_ptr++; + } while (--xindex); + } + } + /* Try to write the MCU. */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->MCU_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->MCU_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + + +/* + * Initialize coefficient buffer controller. + * + * Each passed coefficient array must be the right size for that + * coefficient: width_in_blocks wide and height_in_blocks high, + * with unitheight at least v_samp_factor. + */ + +LOCAL(void) +transencode_coef_controller (j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays) +{ + my_coef_ptr coef; + + coef = (my_coef_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_coef_controller)); + cinfo->coef = &coef->pub; + coef->pub.start_pass = start_pass_coef; + coef->pub.compress_data = compress_output; + + /* Save pointer to virtual arrays */ + coef->whole_image = coef_arrays; + + /* Pre-zero space for dummy DCT blocks */ + MEMZERO(coef->dummy_buffer, SIZEOF(coef->dummy_buffer)); +} diff --git a/thirdparty/jpeg-9e/jdapimin.c b/thirdparty/jpeg-9e/jdapimin.c new file mode 100644 index 0000000..785e527 --- /dev/null +++ b/thirdparty/jpeg-9e/jdapimin.c @@ -0,0 +1,412 @@ +/* + * jdapimin.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * Modified 2009-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the decompression half + * of the JPEG library. These are the "minimum" API routines that may be + * needed in either the normal full-decompression case or the + * transcoding-only case. + * + * Most of the routines intended to be called directly by an application + * are in this file or in jdapistd.c. But also see jcomapi.c for routines + * shared by compression and decompression, and jdtrans.c for the transcoding + * case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Initialization of a JPEG decompression object. + * The error manager must already be set up (in case memory manager fails). + */ + +GLOBAL(void) +jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize) +{ + int i; + + /* Guard against version mismatches between library and caller. */ + cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ + if (version != JPEG_LIB_VERSION) + ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); + if (structsize != SIZEOF(struct jpeg_decompress_struct)) + ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, + (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); + + /* For debugging purposes, we zero the whole master structure. + * But the application has already set the err pointer, and may have set + * client_data, so we have to save and restore those fields. + * Note: if application hasn't set client_data, tools like Purify may + * complain here. + */ + { + struct jpeg_error_mgr * err = cinfo->err; + void * client_data = cinfo->client_data; /* ignore Purify complaint here */ + MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct)); + cinfo->err = err; + cinfo->client_data = client_data; + } + cinfo->is_decompressor = TRUE; + + /* Initialize a memory manager instance for this object */ + jinit_memory_mgr((j_common_ptr) cinfo); + + /* Zero out pointers to permanent structures. */ + cinfo->progress = NULL; + cinfo->src = NULL; + + for (i = 0; i < NUM_QUANT_TBLS; i++) + cinfo->quant_tbl_ptrs[i] = NULL; + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + cinfo->dc_huff_tbl_ptrs[i] = NULL; + cinfo->ac_huff_tbl_ptrs[i] = NULL; + } + + /* Initialize marker processor so application can override methods + * for COM, APPn markers before calling jpeg_read_header. + */ + cinfo->marker_list = NULL; + jinit_marker_reader(cinfo); + + /* And initialize the overall input controller. */ + jinit_input_controller(cinfo); + + /* OK, I'm ready */ + cinfo->global_state = DSTATE_START; +} + + +/* + * Destruction of a JPEG decompression object + */ + +GLOBAL(void) +jpeg_destroy_decompress (j_decompress_ptr cinfo) +{ + jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Abort processing of a JPEG decompression operation, + * but don't destroy the object itself. + */ + +GLOBAL(void) +jpeg_abort_decompress (j_decompress_ptr cinfo) +{ + jpeg_abort((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Set default decompression parameters. + */ + +LOCAL(void) +default_decompress_parms (j_decompress_ptr cinfo) +{ + int cid0, cid1, cid2, cid3; + + /* Guess the input colorspace, and set output colorspace accordingly. */ + /* Note application may override our guesses. */ + switch (cinfo->num_components) { + case 1: + cinfo->jpeg_color_space = JCS_GRAYSCALE; + cinfo->out_color_space = JCS_GRAYSCALE; + break; + + case 3: + cid0 = cinfo->comp_info[0].component_id; + cid1 = cinfo->comp_info[1].component_id; + cid2 = cinfo->comp_info[2].component_id; + + /* For robust detection of standard colorspaces + * regardless of the presence of special markers, + * check component IDs from SOF marker first. + */ + if (cid0 == 0x01 && cid1 == 0x02 && cid2 == 0x03) + cinfo->jpeg_color_space = JCS_YCbCr; + else if (cid0 == 0x01 && cid1 == 0x22 && cid2 == 0x23) + cinfo->jpeg_color_space = JCS_BG_YCC; + else if (cid0 == 0x52 && cid1 == 0x47 && cid2 == 0x42) + cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */ + else if (cid0 == 0x72 && cid1 == 0x67 && cid2 == 0x62) + cinfo->jpeg_color_space = JCS_BG_RGB; /* ASCII 'r', 'g', 'b' */ + else if (cinfo->saw_JFIF_marker) + cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ + else if (cinfo->saw_Adobe_marker) { + switch (cinfo->Adobe_transform) { + case 0: + cinfo->jpeg_color_space = JCS_RGB; + break; + case 1: + cinfo->jpeg_color_space = JCS_YCbCr; + break; + default: + WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); + cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ + } + } else { + TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2); + cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ + } + /* Always guess RGB is proper output colorspace. */ + cinfo->out_color_space = JCS_RGB; + break; + + case 4: + cid0 = cinfo->comp_info[0].component_id; + cid1 = cinfo->comp_info[1].component_id; + cid2 = cinfo->comp_info[2].component_id; + cid3 = cinfo->comp_info[3].component_id; + + /* For robust detection of standard colorspaces + * regardless of the presence of special markers, + * check component IDs from SOF marker first. + */ + if (cid0 == 0x01 && cid1 == 0x02 && cid2 == 0x03 && cid3 == 0x04) + cinfo->jpeg_color_space = JCS_YCCK; + else if (cid0 == 0x43 && cid1 == 0x4D && cid2 == 0x59 && cid3 == 0x4B) + cinfo->jpeg_color_space = JCS_CMYK; /* ASCII 'C', 'M', 'Y', 'K' */ + else if (cinfo->saw_Adobe_marker) { + switch (cinfo->Adobe_transform) { + case 0: + cinfo->jpeg_color_space = JCS_CMYK; + break; + case 2: + cinfo->jpeg_color_space = JCS_YCCK; + break; + default: + WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); + cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */ + } + } else { + /* Unknown IDs and no special markers, assume straight CMYK. */ + cinfo->jpeg_color_space = JCS_CMYK; + } + cinfo->out_color_space = JCS_CMYK; + break; + + default: + cinfo->jpeg_color_space = JCS_UNKNOWN; + cinfo->out_color_space = JCS_UNKNOWN; + } + + /* Set defaults for other decompression parameters. */ + cinfo->scale_num = cinfo->block_size; /* 1:1 scaling */ + cinfo->scale_denom = cinfo->block_size; + cinfo->output_gamma = 1.0; + cinfo->buffered_image = FALSE; + cinfo->raw_data_out = FALSE; + cinfo->dct_method = JDCT_DEFAULT; + cinfo->do_fancy_upsampling = TRUE; + cinfo->do_block_smoothing = TRUE; + cinfo->quantize_colors = FALSE; + /* We set these in case application only sets quantize_colors. */ + cinfo->dither_mode = JDITHER_FS; +#ifdef QUANT_2PASS_SUPPORTED + cinfo->two_pass_quantize = TRUE; +#else + cinfo->two_pass_quantize = FALSE; +#endif + cinfo->desired_number_of_colors = 256; + cinfo->colormap = NULL; + /* Initialize for no mode change in buffered-image mode. */ + cinfo->enable_1pass_quant = FALSE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; +} + + +/* + * Decompression startup: read start of JPEG datastream to see what's there. + * Need only initialize JPEG object and supply a data source before calling. + * + * This routine will read as far as the first SOS marker (ie, actual start of + * compressed data), and will save all tables and parameters in the JPEG + * object. It will also initialize the decompression parameters to default + * values, and finally return JPEG_HEADER_OK. On return, the application may + * adjust the decompression parameters and then call jpeg_start_decompress. + * (Or, if the application only wanted to determine the image parameters, + * the data need not be decompressed. In that case, call jpeg_abort or + * jpeg_destroy to release any temporary space.) + * If an abbreviated (tables only) datastream is presented, the routine will + * return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then + * re-use the JPEG object to read the abbreviated image datastream(s). + * It is unnecessary (but OK) to call jpeg_abort in this case. + * The JPEG_SUSPENDED return code only occurs if the data source module + * requests suspension of the decompressor. In this case the application + * should load more source data and then re-call jpeg_read_header to resume + * processing. + * If a non-suspending data source is used and require_image is TRUE, then the + * return code need not be inspected since only JPEG_HEADER_OK is possible. + * + * This routine is now just a front end to jpeg_consume_input, with some + * extra error checking. + */ + +GLOBAL(int) +jpeg_read_header (j_decompress_ptr cinfo, boolean require_image) +{ + int retcode; + + if (cinfo->global_state != DSTATE_START && + cinfo->global_state != DSTATE_INHEADER) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + retcode = jpeg_consume_input(cinfo); + + switch (retcode) { + case JPEG_REACHED_SOS: + retcode = JPEG_HEADER_OK; + break; + case JPEG_REACHED_EOI: + if (require_image) /* Complain if application wanted an image */ + ERREXIT(cinfo, JERR_NO_IMAGE); + /* Reset to start state; it would be safer to require the application to + * call jpeg_abort, but we can't change it now for compatibility reasons. + * A side effect is to free any temporary memory (there shouldn't be any). + */ + jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */ + retcode = JPEG_HEADER_TABLES_ONLY; + break; + case JPEG_SUSPENDED: + /* no work */ + break; + } + + return retcode; +} + + +/* + * Consume data in advance of what the decompressor requires. + * This can be called at any time once the decompressor object has + * been created and a data source has been set up. + * + * This routine is essentially a state machine that handles a couple + * of critical state-transition actions, namely initial setup and + * transition from header scanning to ready-for-start_decompress. + * All the actual input is done via the input controller's consume_input + * method. + */ + +GLOBAL(int) +jpeg_consume_input (j_decompress_ptr cinfo) +{ + int retcode = JPEG_SUSPENDED; + + /* NB: every possible DSTATE value should be listed in this switch */ + switch (cinfo->global_state) { + case DSTATE_START: + /* Start-of-datastream actions: reset appropriate modules */ + (*cinfo->inputctl->reset_input_controller) (cinfo); + /* Initialize application's data source module */ + (*cinfo->src->init_source) (cinfo); + cinfo->global_state = DSTATE_INHEADER; + /*FALLTHROUGH*/ + case DSTATE_INHEADER: + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */ + /* Set up default parameters based on header data */ + default_decompress_parms(cinfo); + /* Set global state: ready for start_decompress */ + cinfo->global_state = DSTATE_READY; + } + break; + case DSTATE_READY: + /* Can't advance past first SOS until start_decompress is called */ + retcode = JPEG_REACHED_SOS; + break; + case DSTATE_PRELOAD: + case DSTATE_PRESCAN: + case DSTATE_SCANNING: + case DSTATE_RAW_OK: + case DSTATE_BUFIMAGE: + case DSTATE_BUFPOST: + case DSTATE_STOPPING: + retcode = (*cinfo->inputctl->consume_input) (cinfo); + break; + default: + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + return retcode; +} + + +/* + * Have we finished reading the input file? + */ + +GLOBAL(boolean) +jpeg_input_complete (j_decompress_ptr cinfo) +{ + /* Check for valid jpeg object */ + if (cinfo->global_state < DSTATE_START || + cinfo->global_state > DSTATE_STOPPING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + return cinfo->inputctl->eoi_reached; +} + + +/* + * Is there more than one scan? + */ + +GLOBAL(boolean) +jpeg_has_multiple_scans (j_decompress_ptr cinfo) +{ + /* Only valid after jpeg_read_header completes */ + if (cinfo->global_state < DSTATE_READY || + cinfo->global_state > DSTATE_STOPPING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + return cinfo->inputctl->has_multiple_scans; +} + + +/* + * Finish JPEG decompression. + * + * This will normally just verify the file trailer and release temp storage. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_finish_decompress (j_decompress_ptr cinfo) +{ + if ((cinfo->global_state == DSTATE_SCANNING || + cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) { + /* Terminate final pass of non-buffered mode */ + if (cinfo->output_scanline < cinfo->output_height) + ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); + (*cinfo->master->finish_output_pass) (cinfo); + cinfo->global_state = DSTATE_STOPPING; + } else if (cinfo->global_state == DSTATE_BUFIMAGE) { + /* Finishing after a buffered-image operation */ + cinfo->global_state = DSTATE_STOPPING; + } else if (cinfo->global_state != DSTATE_STOPPING) { + /* STOPPING = repeat call after a suspension, anything else is error */ + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + /* Read until EOI */ + while (! cinfo->inputctl->eoi_reached) { + if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) + return FALSE; /* Suspend, come back later */ + } + /* Do final cleanup */ + (*cinfo->src->term_source) (cinfo); + /* We can use jpeg_abort to release memory and reset global_state */ + jpeg_abort((j_common_ptr) cinfo); + return TRUE; +} diff --git a/thirdparty/jpeg-9e/jdapistd.c b/thirdparty/jpeg-9e/jdapistd.c new file mode 100644 index 0000000..7f3a78b --- /dev/null +++ b/thirdparty/jpeg-9e/jdapistd.c @@ -0,0 +1,276 @@ +/* + * jdapistd.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2002-2013 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the decompression half + * of the JPEG library. These are the "standard" API routines that are + * used in the normal full-decompression case. They are not used by a + * transcoding-only application. Note that if an application links in + * jpeg_start_decompress, it will end up linking in the entire decompressor. + * We thus must separate this file from jdapimin.c to avoid linking the + * whole decompression library into a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo)); + + +/* + * Decompression initialization. + * jpeg_read_header must be completed before calling this. + * + * If a multipass operating mode was selected, this will do all but the + * last pass, and thus may take a great deal of time. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_start_decompress (j_decompress_ptr cinfo) +{ + if (cinfo->global_state == DSTATE_READY) { + /* First call: initialize master control, select active modules */ + jinit_master_decompress(cinfo); + if (cinfo->buffered_image) { + /* No more work here; expecting jpeg_start_output next */ + cinfo->global_state = DSTATE_BUFIMAGE; + return TRUE; + } + cinfo->global_state = DSTATE_PRELOAD; + } + if (cinfo->global_state == DSTATE_PRELOAD) { + /* If file has multiple scans, absorb them all into the coef buffer */ + if (cinfo->inputctl->has_multiple_scans) { +#ifdef D_MULTISCAN_FILES_SUPPORTED + for (;;) { + int retcode; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + /* Absorb some more input */ + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_SUSPENDED) + return FALSE; + if (retcode == JPEG_REACHED_EOI) + break; + /* Advance progress counter if appropriate */ + if (cinfo->progress != NULL && + (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { + if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { + /* jdmaster underestimated number of scans; ratchet up one scan */ + cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; + } + } + } +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + } + cinfo->output_scan_number = cinfo->input_scan_number; + } else if (cinfo->global_state != DSTATE_PRESCAN) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Perform any dummy output passes, and set up for the final pass */ + return output_pass_setup(cinfo); +} + + +/* + * Set up for an output pass, and perform any dummy pass(es) needed. + * Common subroutine for jpeg_start_decompress and jpeg_start_output. + * Entry: global_state = DSTATE_PRESCAN only if previously suspended. + * Exit: If done, returns TRUE and sets global_state for proper output mode. + * If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN. + */ + +LOCAL(boolean) +output_pass_setup (j_decompress_ptr cinfo) +{ + if (cinfo->global_state != DSTATE_PRESCAN) { + /* First call: do pass setup */ + (*cinfo->master->prepare_for_output_pass) (cinfo); + cinfo->output_scanline = 0; + cinfo->global_state = DSTATE_PRESCAN; + } + /* Loop over any required dummy passes */ + while (cinfo->master->is_dummy_pass) { +#ifdef QUANT_2PASS_SUPPORTED + /* Crank through the dummy pass */ + while (cinfo->output_scanline < cinfo->output_height) { + JDIMENSION last_scanline; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + /* Process some data */ + last_scanline = cinfo->output_scanline; + (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, + &cinfo->output_scanline, (JDIMENSION) 0); + if (cinfo->output_scanline == last_scanline) + return FALSE; /* No progress made, must suspend */ + } + /* Finish up dummy pass, and set up for another one */ + (*cinfo->master->finish_output_pass) (cinfo); + (*cinfo->master->prepare_for_output_pass) (cinfo); + cinfo->output_scanline = 0; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* QUANT_2PASS_SUPPORTED */ + } + /* Ready for application to drive output pass through + * jpeg_read_scanlines or jpeg_read_raw_data. + */ + cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; + return TRUE; +} + + +/* + * Read some scanlines of data from the JPEG decompressor. + * + * The return value will be the number of lines actually read. + * This may be less than the number requested in several cases, + * including bottom of image, data source suspension, and operating + * modes that emit multiple scanlines at a time. + * + * Note: we warn about excess calls to jpeg_read_scanlines() since + * this likely signals an application programmer error. However, + * an oversize buffer (max_lines > scanlines remaining) is not an error. + */ + +GLOBAL(JDIMENSION) +jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, + JDIMENSION max_lines) +{ + JDIMENSION row_ctr; + + if (cinfo->global_state != DSTATE_SCANNING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->output_scanline >= cinfo->output_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Process some data */ + row_ctr = 0; + (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); + cinfo->output_scanline += row_ctr; + return row_ctr; +} + + +/* + * Alternate entry point to read raw data. + * Processes exactly one iMCU row per call, unless suspended. + */ + +GLOBAL(JDIMENSION) +jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, + JDIMENSION max_lines) +{ + JDIMENSION lines_per_iMCU_row; + + if (cinfo->global_state != DSTATE_RAW_OK) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->output_scanline >= cinfo->output_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Verify that at least one iMCU row can be returned. */ + lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size; + if (max_lines < lines_per_iMCU_row) + ERREXIT(cinfo, JERR_BUFFER_SIZE); + + /* Decompress directly into user's buffer. */ + if (! (*cinfo->coef->decompress_data) (cinfo, data)) + return 0; /* suspension forced, can do nothing more */ + + /* OK, we processed one iMCU row. */ + cinfo->output_scanline += lines_per_iMCU_row; + return lines_per_iMCU_row; +} + + +/* Additional entry points for buffered-image mode. */ + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Initialize for an output pass in buffered-image mode. + */ + +GLOBAL(boolean) +jpeg_start_output (j_decompress_ptr cinfo, int scan_number) +{ + if (cinfo->global_state != DSTATE_BUFIMAGE && + cinfo->global_state != DSTATE_PRESCAN) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Limit scan number to valid range */ + if (scan_number <= 0) + scan_number = 1; + if (cinfo->inputctl->eoi_reached && + scan_number > cinfo->input_scan_number) + scan_number = cinfo->input_scan_number; + cinfo->output_scan_number = scan_number; + /* Perform any dummy output passes, and set up for the real pass */ + return output_pass_setup(cinfo); +} + + +/* + * Finish up after an output pass in buffered-image mode. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_finish_output (j_decompress_ptr cinfo) +{ + if ((cinfo->global_state == DSTATE_SCANNING || + cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) { + /* Terminate this pass. */ + /* We do not require the whole pass to have been completed. */ + (*cinfo->master->finish_output_pass) (cinfo); + cinfo->global_state = DSTATE_BUFPOST; + } else if (cinfo->global_state != DSTATE_BUFPOST) { + /* BUFPOST = repeat call after a suspension, anything else is error */ + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + /* Read markers looking for SOS or EOI */ + while (cinfo->input_scan_number <= cinfo->output_scan_number && + ! cinfo->inputctl->eoi_reached) { + if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) + return FALSE; /* Suspend, come back later */ + } + cinfo->global_state = DSTATE_BUFIMAGE; + return TRUE; +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/jdarith.c b/thirdparty/jpeg-9e/jdarith.c new file mode 100644 index 0000000..2c9abe2 --- /dev/null +++ b/thirdparty/jpeg-9e/jdarith.c @@ -0,0 +1,796 @@ +/* + * jdarith.c + * + * Developed 1997-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains portable arithmetic entropy decoding routines for JPEG + * (implementing the ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81). + * + * Both sequential and progressive modes are supported in this single module. + * + * Suspension is not currently supported in this module. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Expanded entropy decoder object for arithmetic decoding. */ + +typedef struct { + struct jpeg_entropy_decoder pub; /* public fields */ + + INT32 c; /* C register, base of coding interval + input bit buffer */ + INT32 a; /* A register, normalized size of coding interval */ + int ct; /* bit shift counter, # of bits left in bit buffer part of C */ + /* init: ct = -16 */ + /* run: ct = 0..7 */ + /* error: ct = -1 */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ + int dc_context[MAX_COMPS_IN_SCAN]; /* context index for DC conditioning */ + + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + + /* Pointers to statistics areas (these workspaces have image lifespan) */ + unsigned char * dc_stats[NUM_ARITH_TBLS]; + unsigned char * ac_stats[NUM_ARITH_TBLS]; + + /* Statistics bin for coding with fixed probability 0.5 */ + unsigned char fixed_bin[4]; +} arith_entropy_decoder; + +typedef arith_entropy_decoder * arith_entropy_ptr; + +/* The following two definitions specify the allocation chunk size + * for the statistics area. + * According to sections F.1.4.4.1.3 and F.1.4.4.2, we need at least + * 49 statistics bins for DC, and 245 statistics bins for AC coding. + * + * We use a compact representation with 1 byte per statistics bin, + * thus the numbers directly represent byte sizes. + * This 1 byte per statistics bin contains the meaning of the MPS + * (more probable symbol) in the highest bit (mask 0x80), and the + * index into the probability estimation state machine table + * in the lower bits (mask 0x7F). + */ + +#define DC_STAT_BINS 64 +#define AC_STAT_BINS 256 + + +LOCAL(int) +get_byte (j_decompress_ptr cinfo) +/* Read next input byte; we do not support suspension in this module. */ +{ + struct jpeg_source_mgr * src = cinfo->src; + + if (src->bytes_in_buffer == 0) + if (! (*src->fill_input_buffer) (cinfo)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + src->bytes_in_buffer--; + return GETJOCTET(*src->next_input_byte++); +} + + +/* + * The core arithmetic decoding routine (common in JPEG and JBIG). + * This needs to go as fast as possible. + * Machine-dependent optimization facilities + * are not utilized in this portable implementation. + * However, this code should be fairly efficient and + * may be a good base for further optimizations anyway. + * + * Return value is 0 or 1 (binary decision). + * + * Note: I've changed the handling of the code base & bit + * buffer register C compared to other implementations + * based on the standards layout & procedures. + * While it also contains both the actual base of the + * coding interval (16 bits) and the next-bits buffer, + * the cut-point between these two parts is floating + * (instead of fixed) with the bit shift counter CT. + * Thus, we also need only one (variable instead of + * fixed size) shift for the LPS/MPS decision, and + * we can do away with any renormalization update + * of C (except for new data insertion, of course). + * + * I've also introduced a new scheme for accessing + * the probability estimation state machine table, + * derived from Markus Kuhn's JBIG implementation. + */ + +LOCAL(int) +arith_decode (j_decompress_ptr cinfo, unsigned char *st) +{ + register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy; + register unsigned char nl, nm; + register INT32 qe, temp; + register int sv, data; + + /* Renormalization & data input per section D.2.6 */ + while (e->a < 0x8000L) { + if (--e->ct < 0) { + /* Need to fetch next data byte */ + if (cinfo->unread_marker) + data = 0; /* stuff zero data */ + else { + data = get_byte(cinfo); /* read next input byte */ + if (data == 0xFF) { /* zero stuff or marker code */ + do data = get_byte(cinfo); + while (data == 0xFF); /* swallow extra 0xFF bytes */ + if (data == 0) + data = 0xFF; /* discard stuffed zero byte */ + else { + /* Note: Different from the Huffman decoder, hitting + * a marker while processing the compressed data + * segment is legal in arithmetic coding. + * The convention is to supply zero data + * then until decoding is complete. + */ + cinfo->unread_marker = data; + data = 0; + } + } + } + e->c = (e->c << 8) | data; /* insert data into C register */ + if ((e->ct += 8) < 0) /* update bit shift counter */ + /* Need more initial bytes */ + if (++e->ct == 0) + /* Got 2 initial bytes -> re-init A and exit loop */ + e->a = 0x8000L; /* => e->a = 0x10000L after loop exit */ + } + e->a <<= 1; + } + + /* Fetch values from our compact representation of Table D.3(D.2): + * Qe values and probability estimation state machine + */ + sv = *st; + qe = jpeg_aritab[sv & 0x7F]; /* => Qe_Value */ + nl = qe & 0xFF; qe >>= 8; /* Next_Index_LPS + Switch_MPS */ + nm = qe & 0xFF; qe >>= 8; /* Next_Index_MPS */ + + /* Decode & estimation procedures per sections D.2.4 & D.2.5 */ + temp = e->a - qe; + e->a = temp; + temp <<= e->ct; + if (e->c >= temp) { + e->c -= temp; + /* Conditional LPS (less probable symbol) exchange */ + if (e->a < qe) { + e->a = qe; + *st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */ + } else { + e->a = qe; + *st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */ + sv ^= 0x80; /* Exchange LPS/MPS */ + } + } else if (e->a < 0x8000L) { + /* Conditional MPS (more probable symbol) exchange */ + if (e->a < qe) { + *st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */ + sv ^= 0x80; /* Exchange LPS/MPS */ + } else { + *st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */ + } + } + + return sv >> 7; +} + + +/* + * Check for a restart marker & resynchronize decoder. + */ + +LOCAL(void) +process_restart (j_decompress_ptr cinfo) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + int ci; + jpeg_component_info * compptr; + + /* Advance past the RSTn marker */ + if (! (*cinfo->marker->read_restart_marker) (cinfo)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + + /* Re-initialize statistics areas */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + if (! cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) { + MEMZERO(entropy->dc_stats[compptr->dc_tbl_no], DC_STAT_BINS); + /* Reset DC predictions to 0 */ + entropy->last_dc_val[ci] = 0; + entropy->dc_context[ci] = 0; + } + if ((! cinfo->progressive_mode && cinfo->lim_Se) || + (cinfo->progressive_mode && cinfo->Ss)) { + MEMZERO(entropy->ac_stats[compptr->ac_tbl_no], AC_STAT_BINS); + } + } + + /* Reset arithmetic decoding variables */ + entropy->c = 0; + entropy->a = 0; + entropy->ct = -16; /* force reading 2 initial bytes to fill C */ + + /* Reset restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; +} + + +/* + * Arithmetic MCU decoding. + * Each of these routines decodes and returns one MCU's worth of + * arithmetic-compressed coefficients. + * The coefficients are reordered from zigzag order into natural array order, + * but are not dequantized. + * + * The i'th block of the MCU is stored into the block pointed to by + * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER. + */ + +/* + * MCU decoding for DC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + JBLOCKROW block; + unsigned char *st; + int blkn, ci, tbl, sign; + int v, m; + + /* Process restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + process_restart(cinfo); + entropy->restarts_to_go--; + } + + if (entropy->ct == -1) return TRUE; /* if error do nothing */ + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + ci = cinfo->MCU_membership[blkn]; + tbl = cinfo->cur_comp_info[ci]->dc_tbl_no; + + /* Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients */ + + /* Table F.4: Point to statistics bin S0 for DC coefficient coding */ + st = entropy->dc_stats[tbl] + entropy->dc_context[ci]; + + /* Figure F.19: Decode_DC_DIFF */ + if (arith_decode(cinfo, st) == 0) + entropy->dc_context[ci] = 0; + else { + /* Figure F.21: Decoding nonzero value v */ + /* Figure F.22: Decoding the sign of v */ + sign = arith_decode(cinfo, st + 1); + st += 2; st += sign; + /* Figure F.23: Decoding the magnitude category of v */ + if ((m = arith_decode(cinfo, st)) != 0) { + st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */ + while (arith_decode(cinfo, st)) { + if ((m <<= 1) == (int) 0x8000U) { + WARNMS(cinfo, JWRN_ARITH_BAD_CODE); + entropy->ct = -1; /* magnitude overflow */ + return TRUE; + } + st += 1; + } + } + /* Section F.1.4.4.1.2: Establish dc_context conditioning category */ + if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1)) + entropy->dc_context[ci] = 0; /* zero diff category */ + else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1)) + entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */ + else + entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */ + v = m; + /* Figure F.24: Decoding the magnitude bit pattern of v */ + st += 14; + while (m >>= 1) + if (arith_decode(cinfo, st)) v |= m; + v += 1; if (sign) v = -v; + entropy->last_dc_val[ci] += v; + } + + /* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */ + (*block)[0] = (JCOEF) (entropy->last_dc_val[ci] << cinfo->Al); + } + + return TRUE; +} + + +/* + * MCU decoding for AC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + JBLOCKROW block; + unsigned char *st; + int tbl, sign, k; + int v, m; + const int * natural_order; + + /* Process restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + process_restart(cinfo); + entropy->restarts_to_go--; + } + + if (entropy->ct == -1) return TRUE; /* if error do nothing */ + + natural_order = cinfo->natural_order; + + /* There is always only one block per MCU */ + block = MCU_data[0]; + tbl = cinfo->cur_comp_info[0]->ac_tbl_no; + + /* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */ + + /* Figure F.20: Decode_AC_coefficients */ + k = cinfo->Ss - 1; + do { + st = entropy->ac_stats[tbl] + 3 * k; + if (arith_decode(cinfo, st)) break; /* EOB flag */ + for (;;) { + k++; + if (arith_decode(cinfo, st + 1)) break; + st += 3; + if (k >= cinfo->Se) { + WARNMS(cinfo, JWRN_ARITH_BAD_CODE); + entropy->ct = -1; /* spectral overflow */ + return TRUE; + } + } + /* Figure F.21: Decoding nonzero value v */ + /* Figure F.22: Decoding the sign of v */ + sign = arith_decode(cinfo, entropy->fixed_bin); + st += 2; + /* Figure F.23: Decoding the magnitude category of v */ + if ((m = arith_decode(cinfo, st)) != 0) { + if (arith_decode(cinfo, st)) { + m <<= 1; + st = entropy->ac_stats[tbl] + + (k <= cinfo->arith_ac_K[tbl] ? 189 : 217); + while (arith_decode(cinfo, st)) { + if ((m <<= 1) == (int) 0x8000U) { + WARNMS(cinfo, JWRN_ARITH_BAD_CODE); + entropy->ct = -1; /* magnitude overflow */ + return TRUE; + } + st += 1; + } + } + } + v = m; + /* Figure F.24: Decoding the magnitude bit pattern of v */ + st += 14; + while (m >>= 1) + if (arith_decode(cinfo, st)) v |= m; + v += 1; if (sign) v = -v; + /* Scale and output coefficient in natural (dezigzagged) order */ + (*block)[natural_order[k]] = (JCOEF) (v << cinfo->Al); + } while (k < cinfo->Se); + + return TRUE; +} + + +/* + * MCU decoding for DC successive approximation refinement scan. + * Note: we assume such scans can be multi-component, + * although the spec is not very clear on the point. + */ + +METHODDEF(boolean) +decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + unsigned char *st; + JCOEF p1; + int blkn; + + /* Process restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + process_restart(cinfo); + entropy->restarts_to_go--; + } + + st = entropy->fixed_bin; /* use fixed probability estimation */ + p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + /* Encoded data is simply the next bit of the two's-complement DC value */ + if (arith_decode(cinfo, st)) + MCU_data[blkn][0][0] |= p1; + } + + return TRUE; +} + + +/* + * MCU decoding for AC successive approximation refinement scan. + */ + +METHODDEF(boolean) +decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + JBLOCKROW block; + JCOEFPTR thiscoef; + unsigned char *st; + int tbl, k, kex; + JCOEF p1, m1; + const int * natural_order; + + /* Process restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + process_restart(cinfo); + entropy->restarts_to_go--; + } + + if (entropy->ct == -1) return TRUE; /* if error do nothing */ + + natural_order = cinfo->natural_order; + + /* There is always only one block per MCU */ + block = MCU_data[0]; + tbl = cinfo->cur_comp_info[0]->ac_tbl_no; + + p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ + m1 = -p1; /* -1 in the bit position being coded */ + + /* Establish EOBx (previous stage end-of-block) index */ + kex = cinfo->Se; + do { + if ((*block)[natural_order[kex]]) break; + } while (--kex); + + k = cinfo->Ss - 1; + do { + st = entropy->ac_stats[tbl] + 3 * k; + if (k >= kex) + if (arith_decode(cinfo, st)) break; /* EOB flag */ + for (;;) { + thiscoef = *block + natural_order[++k]; + if (*thiscoef) { /* previously nonzero coef */ + if (arith_decode(cinfo, st + 2)) { + if (*thiscoef < 0) + *thiscoef += m1; + else + *thiscoef += p1; + } + break; + } + if (arith_decode(cinfo, st + 1)) { /* newly nonzero coef */ + if (arith_decode(cinfo, entropy->fixed_bin)) + *thiscoef = m1; + else + *thiscoef = p1; + break; + } + st += 3; + if (k >= cinfo->Se) { + WARNMS(cinfo, JWRN_ARITH_BAD_CODE); + entropy->ct = -1; /* spectral overflow */ + return TRUE; + } + } + } while (k < cinfo->Se); + + return TRUE; +} + + +/* + * Decode one MCU's worth of arithmetic-compressed coefficients. + */ + +METHODDEF(boolean) +decode_mcu (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + jpeg_component_info * compptr; + JBLOCKROW block; + unsigned char *st; + int blkn, ci, tbl, sign, k; + int v, m; + const int * natural_order; + + /* Process restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + process_restart(cinfo); + entropy->restarts_to_go--; + } + + if (entropy->ct == -1) return TRUE; /* if error do nothing */ + + natural_order = cinfo->natural_order; + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + + /* Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients */ + + tbl = compptr->dc_tbl_no; + + /* Table F.4: Point to statistics bin S0 for DC coefficient coding */ + st = entropy->dc_stats[tbl] + entropy->dc_context[ci]; + + /* Figure F.19: Decode_DC_DIFF */ + if (arith_decode(cinfo, st) == 0) + entropy->dc_context[ci] = 0; + else { + /* Figure F.21: Decoding nonzero value v */ + /* Figure F.22: Decoding the sign of v */ + sign = arith_decode(cinfo, st + 1); + st += 2; st += sign; + /* Figure F.23: Decoding the magnitude category of v */ + if ((m = arith_decode(cinfo, st)) != 0) { + st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */ + while (arith_decode(cinfo, st)) { + if ((m <<= 1) == (int) 0x8000U) { + WARNMS(cinfo, JWRN_ARITH_BAD_CODE); + entropy->ct = -1; /* magnitude overflow */ + return TRUE; + } + st += 1; + } + } + /* Section F.1.4.4.1.2: Establish dc_context conditioning category */ + if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1)) + entropy->dc_context[ci] = 0; /* zero diff category */ + else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1)) + entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */ + else + entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */ + v = m; + /* Figure F.24: Decoding the magnitude bit pattern of v */ + st += 14; + while (m >>= 1) + if (arith_decode(cinfo, st)) v |= m; + v += 1; if (sign) v = -v; + entropy->last_dc_val[ci] += v; + } + + (*block)[0] = (JCOEF) entropy->last_dc_val[ci]; + + /* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */ + + if (cinfo->lim_Se == 0) continue; + tbl = compptr->ac_tbl_no; + k = 0; + + /* Figure F.20: Decode_AC_coefficients */ + do { + st = entropy->ac_stats[tbl] + 3 * k; + if (arith_decode(cinfo, st)) break; /* EOB flag */ + for (;;) { + k++; + if (arith_decode(cinfo, st + 1)) break; + st += 3; + if (k >= cinfo->lim_Se) { + WARNMS(cinfo, JWRN_ARITH_BAD_CODE); + entropy->ct = -1; /* spectral overflow */ + return TRUE; + } + } + /* Figure F.21: Decoding nonzero value v */ + /* Figure F.22: Decoding the sign of v */ + sign = arith_decode(cinfo, entropy->fixed_bin); + st += 2; + /* Figure F.23: Decoding the magnitude category of v */ + if ((m = arith_decode(cinfo, st)) != 0) { + if (arith_decode(cinfo, st)) { + m <<= 1; + st = entropy->ac_stats[tbl] + + (k <= cinfo->arith_ac_K[tbl] ? 189 : 217); + while (arith_decode(cinfo, st)) { + if ((m <<= 1) == (int) 0x8000U) { + WARNMS(cinfo, JWRN_ARITH_BAD_CODE); + entropy->ct = -1; /* magnitude overflow */ + return TRUE; + } + st += 1; + } + } + } + v = m; + /* Figure F.24: Decoding the magnitude bit pattern of v */ + st += 14; + while (m >>= 1) + if (arith_decode(cinfo, st)) v |= m; + v += 1; if (sign) v = -v; + (*block)[natural_order[k]] = (JCOEF) v; + } while (k < cinfo->lim_Se); + } + + return TRUE; +} + + +/* + * Initialize for an arithmetic-compressed scan. + */ + +METHODDEF(void) +start_pass (j_decompress_ptr cinfo) +{ + arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy; + int ci, tbl; + jpeg_component_info * compptr; + + if (cinfo->progressive_mode) { + /* Validate progressive scan parameters */ + if (cinfo->Ss == 0) { + if (cinfo->Se != 0) + goto bad; + } else { + /* need not check Ss/Se < 0 since they came from unsigned bytes */ + if (cinfo->Se < cinfo->Ss || cinfo->Se > cinfo->lim_Se) + goto bad; + /* AC scans may have only one component */ + if (cinfo->comps_in_scan != 1) + goto bad; + } + if (cinfo->Ah != 0) { + /* Successive approximation refinement scan: must have Al = Ah-1. */ + if (cinfo->Ah-1 != cinfo->Al) + goto bad; + } + if (cinfo->Al > 13) { /* need not check for < 0 */ + bad: + ERREXIT4(cinfo, JERR_BAD_PROGRESSION, + cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); + } + /* Update progression status, and verify that scan order is legal. + * Note that inter-scan inconsistencies are treated as warnings + * not fatal errors ... not clear if this is right way to behave. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + int coefi, cindex = cinfo->cur_comp_info[ci]->component_index; + int *coef_bit_ptr = & cinfo->coef_bits[cindex][0]; + if (cinfo->Ss && coef_bit_ptr[0] < 0) /* AC without prior DC scan */ + WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); + for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { + int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; + if (cinfo->Ah != expected) + WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); + coef_bit_ptr[coefi] = cinfo->Al; + } + } + /* Select MCU decoding routine */ + if (cinfo->Ah == 0) { + if (cinfo->Ss == 0) + entropy->pub.decode_mcu = decode_mcu_DC_first; + else + entropy->pub.decode_mcu = decode_mcu_AC_first; + } else { + if (cinfo->Ss == 0) + entropy->pub.decode_mcu = decode_mcu_DC_refine; + else + entropy->pub.decode_mcu = decode_mcu_AC_refine; + } + } else { + /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG. + * This ought to be an error condition, but we make it a warning. + */ + if (cinfo->Ss != 0 || cinfo->Ah != 0 || cinfo->Al != 0 || + (cinfo->Se < DCTSIZE2 && cinfo->Se != cinfo->lim_Se)) + WARNMS(cinfo, JWRN_NOT_SEQUENTIAL); + /* Select MCU decoding routine */ + entropy->pub.decode_mcu = decode_mcu; + } + + /* Allocate & initialize requested statistics areas */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + if (! cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) { + tbl = compptr->dc_tbl_no; + if (tbl < 0 || tbl >= NUM_ARITH_TBLS) + ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl); + if (entropy->dc_stats[tbl] == NULL) + entropy->dc_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, DC_STAT_BINS); + MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS); + /* Initialize DC predictions to 0 */ + entropy->last_dc_val[ci] = 0; + entropy->dc_context[ci] = 0; + } + if ((! cinfo->progressive_mode && cinfo->lim_Se) || + (cinfo->progressive_mode && cinfo->Ss)) { + tbl = compptr->ac_tbl_no; + if (tbl < 0 || tbl >= NUM_ARITH_TBLS) + ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl); + if (entropy->ac_stats[tbl] == NULL) + entropy->ac_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, AC_STAT_BINS); + MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS); + } + } + + /* Initialize arithmetic decoding variables */ + entropy->c = 0; + entropy->a = 0; + entropy->ct = -16; /* force reading 2 initial bytes to fill C */ + + /* Initialize restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; +} + + +/* + * Finish up at the end of an arithmetic-compressed scan. + */ + +METHODDEF(void) +finish_pass (j_decompress_ptr cinfo) +{ + /* no work necessary here */ +} + + +/* + * Module initialization routine for arithmetic entropy decoding. + */ + +GLOBAL(void) +jinit_arith_decoder (j_decompress_ptr cinfo) +{ + arith_entropy_ptr entropy; + int i; + + entropy = (arith_entropy_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(arith_entropy_decoder)); + cinfo->entropy = &entropy->pub; + entropy->pub.start_pass = start_pass; + entropy->pub.finish_pass = finish_pass; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_ARITH_TBLS; i++) { + entropy->dc_stats[i] = NULL; + entropy->ac_stats[i] = NULL; + } + + /* Initialize index for fixed probability estimation */ + entropy->fixed_bin[0] = 113; + + if (cinfo->progressive_mode) { + /* Create progression status table */ + int *coef_bit_ptr, ci; + cinfo->coef_bits = (int (*)[DCTSIZE2]) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * DCTSIZE2 * SIZEOF(int)); + coef_bit_ptr = & cinfo->coef_bits[0][0]; + for (ci = 0; ci < cinfo->num_components; ci++) + for (i = 0; i < DCTSIZE2; i++) + *coef_bit_ptr++ = -1; + } +} diff --git a/thirdparty/jpeg-9e/jdatadst.c b/thirdparty/jpeg-9e/jdatadst.c new file mode 100644 index 0000000..75ebd7c --- /dev/null +++ b/thirdparty/jpeg-9e/jdatadst.c @@ -0,0 +1,267 @@ +/* + * jdatadst.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2009-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains compression data destination routines for the case of + * emitting JPEG data to memory or to a file (or any stdio stream). + * While these routines are sufficient for most applications, + * some will want to use a different destination manager. + * IMPORTANT: we assume that fwrite() will correctly transcribe an array of + * JOCTETs into 8-bit-wide elements on external storage. If char is wider + * than 8 bits on your machine, you may need to do some tweaking. + */ + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jerror.h" + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + + +/* Expanded data destination object for stdio output */ + +typedef struct { + struct jpeg_destination_mgr pub; /* public fields */ + + FILE * outfile; /* target stream */ + JOCTET * buffer; /* start of buffer */ +} my_destination_mgr; + +typedef my_destination_mgr * my_dest_ptr; + +#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ + + +/* Expanded data destination object for memory output */ + +typedef struct { + struct jpeg_destination_mgr pub; /* public fields */ + + unsigned char ** outbuffer; /* target buffer */ + size_t * outsize; + unsigned char * newbuffer; /* newly allocated buffer */ + JOCTET * buffer; /* start of buffer */ + size_t bufsize; +} my_mem_destination_mgr; + +typedef my_mem_destination_mgr * my_mem_dest_ptr; + + +/* + * Initialize destination --- called by jpeg_start_compress + * before any data is actually written. + */ + +METHODDEF(void) +init_destination (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + + /* Allocate the output buffer --- it will be released when done with image */ + dest->buffer = (JOCTET *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, OUTPUT_BUF_SIZE * SIZEOF(JOCTET)); + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; +} + +METHODDEF(void) +init_mem_destination (j_compress_ptr cinfo) +{ + /* no work necessary here */ +} + + +/* + * Empty the output buffer --- called whenever buffer fills up. + * + * In typical applications, this should write the entire output buffer + * (ignoring the current state of next_output_byte & free_in_buffer), + * reset the pointer & count to the start of the buffer, and return TRUE + * indicating that the buffer has been dumped. + * + * In applications that need to be able to suspend compression due to output + * overrun, a FALSE return indicates that the buffer cannot be emptied now. + * In this situation, the compressor will return to its caller (possibly with + * an indication that it has not accepted all the supplied scanlines). The + * application should resume compression after it has made more room in the + * output buffer. Note that there are substantial restrictions on the use of + * suspension --- see the documentation. + * + * When suspending, the compressor will back up to a convenient restart point + * (typically the start of the current MCU). next_output_byte & free_in_buffer + * indicate where the restart point will be if the current call returns FALSE. + * Data beyond this point will be regenerated after resumption, so do not + * write it out when emptying the buffer externally. + */ + +METHODDEF(boolean) +empty_output_buffer (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + + if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) != + (size_t) OUTPUT_BUF_SIZE) + ERREXIT(cinfo, JERR_FILE_WRITE); + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; + + return TRUE; +} + +METHODDEF(boolean) +empty_mem_output_buffer (j_compress_ptr cinfo) +{ + size_t nextsize; + JOCTET * nextbuffer; + my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest; + + /* Try to allocate new buffer with double size */ + nextsize = dest->bufsize * 2; + nextbuffer = (JOCTET *) malloc(nextsize); + + if (nextbuffer == NULL) + ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 11); + + MEMCOPY(nextbuffer, dest->buffer, dest->bufsize); + + if (dest->newbuffer != NULL) + free(dest->newbuffer); + + dest->newbuffer = nextbuffer; + + dest->pub.next_output_byte = nextbuffer + dest->bufsize; + dest->pub.free_in_buffer = dest->bufsize; + + dest->buffer = nextbuffer; + dest->bufsize = nextsize; + + return TRUE; +} + + +/* + * Terminate destination --- called by jpeg_finish_compress + * after all data has been written. Usually needs to flush buffer. + * + * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding + * application must deal with any cleanup that should happen even + * for error exit. + */ + +METHODDEF(void) +term_destination (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; + + /* Write any data remaining in the buffer */ + if (datacount > 0) { + if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount) + ERREXIT(cinfo, JERR_FILE_WRITE); + } + JFFLUSH(dest->outfile); + /* Make sure we wrote the output file OK */ + if (JFERROR(dest->outfile)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + +METHODDEF(void) +term_mem_destination (j_compress_ptr cinfo) +{ + my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest; + + *dest->outbuffer = dest->buffer; + *dest->outsize = dest->bufsize - dest->pub.free_in_buffer; +} + + +/* + * Prepare for output to a stdio stream. + * The caller must have already opened the stream, and is responsible + * for closing it after finishing compression. + */ + +GLOBAL(void) +jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile) +{ + my_dest_ptr dest; + + /* The destination object is made permanent so that multiple JPEG images + * can be written to the same file without re-executing jpeg_stdio_dest. + * This makes it dangerous to use this manager and a different destination + * manager serially with the same JPEG object, because their private object + * sizes may be different. Caveat programmer. + */ + if (cinfo->dest == NULL) { /* first time for this JPEG object? */ + cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_destination_mgr)); + } + + dest = (my_dest_ptr) cinfo->dest; + dest->pub.init_destination = init_destination; + dest->pub.empty_output_buffer = empty_output_buffer; + dest->pub.term_destination = term_destination; + dest->outfile = outfile; +} + + +/* + * Prepare for output to a memory buffer. + * The caller may supply an own initial buffer with appropriate size. + * Otherwise, or when the actual data output exceeds the given size, + * the library adapts the buffer size as necessary. + * The standard library functions malloc/free are used for allocating + * larger memory, so the buffer is available to the application after + * finishing compression, and then the application is responsible for + * freeing the requested memory. + * Note: An initial buffer supplied by the caller is expected to be + * managed by the application. The library does not free such buffer + * when allocating a larger buffer. + */ + +GLOBAL(void) +jpeg_mem_dest (j_compress_ptr cinfo, + unsigned char ** outbuffer, size_t * outsize) +{ + my_mem_dest_ptr dest; + + if (outbuffer == NULL || outsize == NULL) /* sanity check */ + ERREXIT(cinfo, JERR_BUFFER_SIZE); + + /* The destination object is made permanent so that multiple JPEG images + * can be written to the same buffer without re-executing jpeg_mem_dest. + */ + if (cinfo->dest == NULL) { /* first time for this JPEG object? */ + cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_mem_destination_mgr)); + } + + dest = (my_mem_dest_ptr) cinfo->dest; + dest->pub.init_destination = init_mem_destination; + dest->pub.empty_output_buffer = empty_mem_output_buffer; + dest->pub.term_destination = term_mem_destination; + dest->outbuffer = outbuffer; + dest->outsize = outsize; + dest->newbuffer = NULL; + + if (*outbuffer == NULL || *outsize == 0) { + /* Allocate initial buffer */ + dest->newbuffer = *outbuffer = (unsigned char *) malloc(OUTPUT_BUF_SIZE); + if (dest->newbuffer == NULL) + ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10); + *outsize = OUTPUT_BUF_SIZE; + } + + dest->pub.next_output_byte = dest->buffer = *outbuffer; + dest->pub.free_in_buffer = dest->bufsize = *outsize; +} diff --git a/thirdparty/jpeg-9e/jdatasrc.c b/thirdparty/jpeg-9e/jdatasrc.c new file mode 100644 index 0000000..606ae11 --- /dev/null +++ b/thirdparty/jpeg-9e/jdatasrc.c @@ -0,0 +1,274 @@ +/* + * jdatasrc.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2009-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains decompression data source routines for the case of + * reading JPEG data from memory or from a file (or any stdio stream). + * While these routines are sufficient for most applications, + * some will want to use a different source manager. + * IMPORTANT: we assume that fread() will correctly transcribe an array of + * JOCTETs from 8-bit-wide elements on external storage. If char is wider + * than 8 bits on your machine, you may need to do some tweaking. + */ + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jerror.h" + + +/* Expanded data source object for stdio input */ + +typedef struct { + struct jpeg_source_mgr pub; /* public fields */ + + FILE * infile; /* source stream */ + JOCTET * buffer; /* start of buffer */ + boolean start_of_file; /* have we gotten any data yet? */ +} my_source_mgr; + +typedef my_source_mgr * my_src_ptr; + +#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ + + +/* + * Initialize source --- called by jpeg_read_header + * before any data is actually read. + */ + +METHODDEF(void) +init_source (j_decompress_ptr cinfo) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + + /* We reset the empty-input-file flag for each image, + * but we don't clear the input buffer. + * This is correct behavior for reading a series of images from one source. + */ + src->start_of_file = TRUE; +} + +METHODDEF(void) +init_mem_source (j_decompress_ptr cinfo) +{ + /* no work necessary here */ +} + + +/* + * Fill the input buffer --- called whenever buffer is emptied. + * + * In typical applications, this should read fresh data into the buffer + * (ignoring the current state of next_input_byte & bytes_in_buffer), + * reset the pointer & count to the start of the buffer, and return TRUE + * indicating that the buffer has been reloaded. It is not necessary to + * fill the buffer entirely, only to obtain at least one more byte. + * + * There is no such thing as an EOF return. If the end of the file has been + * reached, the routine has a choice of ERREXIT() or inserting fake data into + * the buffer. In most cases, generating a warning message and inserting a + * fake EOI marker is the best course of action --- this will allow the + * decompressor to output however much of the image is there. However, + * the resulting error message is misleading if the real problem is an empty + * input file, so we handle that case specially. + * + * In applications that need to be able to suspend compression due to input + * not being available yet, a FALSE return indicates that no more data can be + * obtained right now, but more may be forthcoming later. In this situation, + * the decompressor will return to its caller (with an indication of the + * number of scanlines it has read, if any). The application should resume + * decompression after it has loaded more data into the input buffer. Note + * that there are substantial restrictions on the use of suspension --- see + * the documentation. + * + * When suspending, the decompressor will back up to a convenient restart point + * (typically the start of the current MCU). next_input_byte & bytes_in_buffer + * indicate where the restart point will be if the current call returns FALSE. + * Data beyond this point must be rescanned after resumption, so move it to + * the front of the buffer rather than discarding it. + */ + +METHODDEF(boolean) +fill_input_buffer (j_decompress_ptr cinfo) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + size_t nbytes; + + nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE); + + if (nbytes <= 0) { + if (src->start_of_file) /* Treat empty input file as fatal error */ + ERREXIT(cinfo, JERR_INPUT_EMPTY); + WARNMS(cinfo, JWRN_JPEG_EOF); + /* Insert a fake EOI marker */ + src->buffer[0] = (JOCTET) 0xFF; + src->buffer[1] = (JOCTET) JPEG_EOI; + nbytes = 2; + } + + src->pub.next_input_byte = src->buffer; + src->pub.bytes_in_buffer = nbytes; + src->start_of_file = FALSE; + + return TRUE; +} + +METHODDEF(boolean) +fill_mem_input_buffer (j_decompress_ptr cinfo) +{ + static const JOCTET mybuffer[4] = { + (JOCTET) 0xFF, (JOCTET) JPEG_EOI, 0, 0 + }; + + /* The whole JPEG data is expected to reside in the supplied memory + * buffer, so any request for more data beyond the given buffer size + * is treated as an error. + */ + WARNMS(cinfo, JWRN_JPEG_EOF); + + /* Insert a fake EOI marker */ + + cinfo->src->next_input_byte = mybuffer; + cinfo->src->bytes_in_buffer = 2; + + return TRUE; +} + + +/* + * Skip data --- used to skip over a potentially large amount of + * uninteresting data (such as an APPn marker). + * + * Writers of suspendable-input applications must note that skip_input_data + * is not granted the right to give a suspension return. If the skip extends + * beyond the data currently in the buffer, the buffer can be marked empty so + * that the next read will cause a fill_input_buffer call that can suspend. + * Arranging for additional bytes to be discarded before reloading the input + * buffer is the application writer's problem. + */ + +METHODDEF(void) +skip_input_data (j_decompress_ptr cinfo, long num_bytes) +{ + struct jpeg_source_mgr * src = cinfo->src; + size_t nbytes; + + /* Just a dumb implementation for now. Could use fseek() except + * it doesn't work on pipes. Not clear that being smart is worth + * any trouble anyway --- large skips are infrequent. + */ + if (num_bytes > 0) { + nbytes = (size_t) num_bytes; + while (nbytes > src->bytes_in_buffer) { + nbytes -= src->bytes_in_buffer; + (void) (*src->fill_input_buffer) (cinfo); + /* note we assume that fill_input_buffer will never return FALSE, + * so suspension need not be handled. + */ + } + src->next_input_byte += nbytes; + src->bytes_in_buffer -= nbytes; + } +} + + +/* + * An additional method that can be provided by data source modules is the + * resync_to_restart method for error recovery in the presence of RST markers. + * For the moment, this source module just uses the default resync method + * provided by the JPEG library. That method assumes that no backtracking + * is possible. + */ + + +/* + * Terminate source --- called by jpeg_finish_decompress + * after all data has been read. Often a no-op. + * + * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding + * application must deal with any cleanup that should happen even + * for error exit. + */ + +METHODDEF(void) +term_source (j_decompress_ptr cinfo) +{ + /* no work necessary here */ +} + + +/* + * Prepare for input from a stdio stream. + * The caller must have already opened the stream, and is responsible + * for closing it after finishing decompression. + */ + +GLOBAL(void) +jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile) +{ + my_src_ptr src; + + /* The source object and input buffer are made permanent so that a series + * of JPEG images can be read from the same file by calling jpeg_stdio_src + * only before the first one. (If we discarded the buffer at the end of + * one image, we'd likely lose the start of the next one.) + * This makes it unsafe to use this manager and a different source + * manager serially with the same JPEG object. Caveat programmer. + */ + if (cinfo->src == NULL) { /* first time for this JPEG object? */ + cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_source_mgr)); + src = (my_src_ptr) cinfo->src; + src->buffer = (JOCTET *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_PERMANENT, INPUT_BUF_SIZE * SIZEOF(JOCTET)); + } + + src = (my_src_ptr) cinfo->src; + src->pub.init_source = init_source; + src->pub.fill_input_buffer = fill_input_buffer; + src->pub.skip_input_data = skip_input_data; + src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ + src->pub.term_source = term_source; + src->infile = infile; + src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ + src->pub.next_input_byte = NULL; /* until buffer loaded */ +} + + +/* + * Prepare for input from a supplied memory buffer. + * The buffer must contain the whole JPEG data. + */ + +GLOBAL(void) +jpeg_mem_src (j_decompress_ptr cinfo, + const unsigned char * inbuffer, size_t insize) +{ + struct jpeg_source_mgr * src; + + if (inbuffer == NULL || insize == 0) /* Treat empty input as fatal error */ + ERREXIT(cinfo, JERR_INPUT_EMPTY); + + /* The source object is made permanent so that a series of JPEG images + * can be read from the same buffer by calling jpeg_mem_src only before + * the first one. + */ + if (cinfo->src == NULL) { /* first time for this JPEG object? */ + cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(struct jpeg_source_mgr)); + } + + src = cinfo->src; + src->init_source = init_mem_source; + src->fill_input_buffer = fill_mem_input_buffer; + src->skip_input_data = skip_input_data; + src->resync_to_restart = jpeg_resync_to_restart; /* use default method */ + src->term_source = term_source; + src->bytes_in_buffer = insize; + src->next_input_byte = (const JOCTET *) inbuffer; +} diff --git a/thirdparty/jpeg-9e/jdcoefct.c b/thirdparty/jpeg-9e/jdcoefct.c new file mode 100644 index 0000000..79ba420 --- /dev/null +++ b/thirdparty/jpeg-9e/jdcoefct.c @@ -0,0 +1,744 @@ +/* + * jdcoefct.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * Modified 2002-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the coefficient buffer controller for decompression. + * This controller is the top level of the JPEG decompressor proper. + * The coefficient buffer lies between entropy decoding and inverse-DCT steps. + * + * In buffered-image mode, this controller is the interface between + * input-oriented processing and output-oriented processing. + * Also, the input side (only) is used when reading a file for transcoding. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Block smoothing is only applicable for progressive JPEG, so: */ +#ifndef D_PROGRESSIVE_SUPPORTED +#undef BLOCK_SMOOTHING_SUPPORTED +#endif + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_coef_controller pub; /* public fields */ + + /* These variables keep track of the current location of the input side. */ + /* cinfo->input_iMCU_row is also used for this. */ + JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* The output side's location is represented by cinfo->output_iMCU_row. */ + + /* In single-pass modes, it's sufficient to buffer just one MCU. + * We append a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, + * and let the entropy decoder write into that workspace each time. + * In multi-pass modes, this array points to the current MCU's blocks + * within the virtual arrays; it is used only by the input side. + */ + JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; + +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* In multi-pass modes, we need a virtual block array for each component. */ + jvirt_barray_ptr whole_image[MAX_COMPONENTS]; +#endif + +#ifdef BLOCK_SMOOTHING_SUPPORTED + /* When doing block smoothing, we latch coefficient Al values here */ + int * coef_bits_latch; +#define SAVED_COEFS 6 /* we save coef_bits[0..5] */ +#endif + + /* Workspace for single-pass modes (omitted otherwise). */ + JBLOCK blk_buffer[D_MAX_BLOCKS_IN_MCU]; +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + + +/* Forward declarations */ +METHODDEF(int) decompress_onepass + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#ifdef D_MULTISCAN_FILES_SUPPORTED +METHODDEF(int) decompress_data + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#endif +#ifdef BLOCK_SMOOTHING_SUPPORTED +LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); +METHODDEF(int) decompress_smooth_data + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#endif + + +LOCAL(void) +start_iMCU_row (j_decompress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row (input side) */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->MCU_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for an input processing pass. + */ + +METHODDEF(void) +start_input_pass (j_decompress_ptr cinfo) +{ + cinfo->input_iMCU_row = 0; + start_iMCU_row(cinfo); +} + + +/* + * Initialize for an output processing pass. + */ + +METHODDEF(void) +start_output_pass (j_decompress_ptr cinfo) +{ +#ifdef BLOCK_SMOOTHING_SUPPORTED + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* If multipass, check to see whether to use block smoothing on this pass */ + if (coef->pub.coef_arrays != NULL) { + if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) + coef->pub.decompress_data = decompress_smooth_data; + else + coef->pub.decompress_data = decompress_data; + } +#endif + cinfo->output_iMCU_row = 0; +} + + +/* + * Decompress and return some data in the single-pass case. + * Always attempts to emit one fully interleaved MCU row ("iMCU" row). + * Input and output must run in lockstep since we have only a one-MCU buffer. + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + * + * NB: output_buf contains a plane for each component in image, + * which we index according to the component's SOF position. + */ + +METHODDEF(int) +decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int ci, xindex, yindex, yoffset, useful_width; + JBLOCKROW blkp; + JSAMPARRAY output_ptr; + JDIMENSION start_col, output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + + /* Loop to process as much as one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; + MCU_col_num++) { + blkp = coef->blk_buffer; /* pointer to current DCT block within MCU */ + /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ + if (cinfo->lim_Se) /* can bypass in DC only case */ + MEMZERO(blkp, cinfo->blocks_in_MCU * SIZEOF(JBLOCK)); + if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->MCU_ctr = MCU_col_num; + return JPEG_SUSPENDED; + } + /* Determine where data should go in output_buf and do the IDCT thing. + * We skip dummy blocks at the right and bottom edges (but blkp gets + * incremented past them!). + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) { + blkp += compptr->MCU_blocks; + continue; + } + inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index]; + output_ptr = output_buf[compptr->component_index] + + yoffset * compptr->DCT_v_scaled_size; + useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + start_col = MCU_col_num * compptr->MCU_sample_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (cinfo->input_iMCU_row < last_iMCU_row || + yoffset + yindex < compptr->last_row_height) { + output_col = start_col; + for (xindex = 0; xindex < useful_width; xindex++) { + (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) (blkp + xindex), + output_ptr, output_col); + output_col += compptr->DCT_h_scaled_size; + } + output_ptr += compptr->DCT_v_scaled_size; + } + blkp += compptr->MCU_width; + } + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->MCU_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + cinfo->output_iMCU_row++; + if (++(cinfo->input_iMCU_row) <= last_iMCU_row) { + start_iMCU_row(cinfo); + return JPEG_ROW_COMPLETED; + } + /* Completed the scan */ + (*cinfo->inputctl->finish_input_pass) (cinfo); + return JPEG_SCAN_COMPLETED; +} + + +/* + * Dummy consume-input routine for single-pass operation. + */ + +METHODDEF(int) +dummy_consume_data (j_decompress_ptr cinfo) +{ + return JPEG_SUSPENDED; /* Always indicate nothing was done */ +} + + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Consume input data and store it in the full-image coefficient buffer. + * We read as much as one fully interleaved MCU row ("iMCU" row) per call, + * ie, v_samp_factor block rows for each component in the scan. + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + */ + +METHODDEF(int) +consume_data (j_decompress_ptr cinfo) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + int ci, xindex, yindex, yoffset; + JDIMENSION start_col; + JBLOCKARRAY blkp; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + cinfo->input_iMCU_row * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, TRUE); + /* Note: entropy decoder expects buffer to be zeroed, + * but this is handled automatically by the memory manager + * because we requested a pre-zeroed array. + */ + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkp = coef->MCU_buffer; /* pointer to current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + start_col = MCU_col_num * compptr->MCU_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + buffer_ptr = buffer[ci][yoffset + yindex] + start_col; + xindex = compptr->MCU_width; + do { + *blkp++ = buffer_ptr++; + } while (--xindex); + } + } + /* Try to fetch the MCU. */ + if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->MCU_ctr = MCU_col_num; + return JPEG_SUSPENDED; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->MCU_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { + start_iMCU_row(cinfo); + return JPEG_ROW_COMPLETED; + } + /* Completed the scan */ + (*cinfo->inputctl->finish_input_pass) (cinfo); + return JPEG_SCAN_COMPLETED; +} + + +/* + * Decompress and return some data in the multi-pass case. + * Always attempts to emit one fully interleaved MCU row ("iMCU" row). + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + * + * NB: output_buf contains a plane for each component in image. + */ + +METHODDEF(int) +decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION block_num; + int ci, block_row, block_rows; + JBLOCKARRAY buffer; + JBLOCKROW buffer_ptr; + JSAMPARRAY output_ptr; + JDIMENSION output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + + /* Force some input to be done if we are getting ahead of the input. */ + while (cinfo->input_scan_number < cinfo->output_scan_number || + (cinfo->input_scan_number == cinfo->output_scan_number && + cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { + if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) + return JPEG_SUSPENDED; + } + + /* OK, output from the virtual arrays. */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) + continue; + /* Align the virtual buffer for this component. */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + cinfo->output_iMCU_row * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + /* Count non-dummy DCT block rows in this iMCU row. */ + if (cinfo->output_iMCU_row < last_iMCU_row) + block_rows = compptr->v_samp_factor; + else { + /* NB: can't use last_row_height here; it is input-side-dependent! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + } + inverse_DCT = cinfo->idct->inverse_DCT[ci]; + output_ptr = output_buf[ci]; + /* Loop over all DCT blocks to be processed. */ + for (block_row = 0; block_row < block_rows; block_row++) { + buffer_ptr = buffer[block_row]; + output_col = 0; + for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) { + (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, + output_ptr, output_col); + buffer_ptr++; + output_col += compptr->DCT_h_scaled_size; + } + output_ptr += compptr->DCT_v_scaled_size; + } + } + + if (++(cinfo->output_iMCU_row) <= last_iMCU_row) + return JPEG_ROW_COMPLETED; + return JPEG_SCAN_COMPLETED; +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + + +#ifdef BLOCK_SMOOTHING_SUPPORTED + +/* + * This code applies interblock smoothing as described by section K.8 + * of the JPEG standard: the first 5 AC coefficients are estimated from + * the DC values of a DCT block and its 8 neighboring blocks. + * We apply smoothing only for progressive JPEG decoding, and only if + * the coefficients it can estimate are not yet known to full precision. + */ + +/* Natural-order array positions of the first 5 zigzag-order coefficients */ +#define Q01_POS 1 +#define Q10_POS 8 +#define Q20_POS 16 +#define Q11_POS 9 +#define Q02_POS 2 + +/* + * Determine whether block smoothing is applicable and safe. + * We also latch the current states of the coef_bits[] entries for the + * AC coefficients; otherwise, if the input side of the decompressor + * advances into a new scan, we might think the coefficients are known + * more accurately than they really are. + */ + +LOCAL(boolean) +smoothing_ok (j_decompress_ptr cinfo) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + boolean smoothing_useful = FALSE; + int ci, coefi; + jpeg_component_info *compptr; + JQUANT_TBL * qtable; + int * coef_bits; + int * coef_bits_latch; + + if (! cinfo->progressive_mode || cinfo->coef_bits == NULL) + return FALSE; + + /* Allocate latch area if not already done */ + if (coef->coef_bits_latch == NULL) + coef->coef_bits_latch = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * (SAVED_COEFS * SIZEOF(int))); + coef_bits_latch = coef->coef_bits_latch; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* All components' quantization values must already be latched. */ + if ((qtable = compptr->quant_table) == NULL) + return FALSE; + /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */ + if (qtable->quantval[0] == 0 || + qtable->quantval[Q01_POS] == 0 || + qtable->quantval[Q10_POS] == 0 || + qtable->quantval[Q20_POS] == 0 || + qtable->quantval[Q11_POS] == 0 || + qtable->quantval[Q02_POS] == 0) + return FALSE; + /* DC values must be at least partly known for all components. */ + coef_bits = cinfo->coef_bits[ci]; + if (coef_bits[0] < 0) + return FALSE; + /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ + for (coefi = 1; coefi <= 5; coefi++) { + coef_bits_latch[coefi] = coef_bits[coefi]; + if (coef_bits[coefi] != 0) + smoothing_useful = TRUE; + } + coef_bits_latch += SAVED_COEFS; + } + + return smoothing_useful; +} + + +/* + * Variant of decompress_data for use when doing block smoothing. + */ + +METHODDEF(int) +decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION block_num, last_block_column; + int ci, block_row, block_rows, access_rows; + JBLOCKARRAY buffer; + JBLOCKROW buffer_ptr, prev_block_row, next_block_row; + JSAMPARRAY output_ptr; + JDIMENSION output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + boolean first_row, last_row; + JBLOCK workspace; + int *coef_bits; + JQUANT_TBL *quanttbl; + INT32 Q00,Q01,Q02,Q10,Q11,Q20, num; + int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9; + int Al, pred; + + /* Force some input to be done if we are getting ahead of the input. */ + while (cinfo->input_scan_number <= cinfo->output_scan_number && + ! cinfo->inputctl->eoi_reached) { + if (cinfo->input_scan_number == cinfo->output_scan_number) { + /* If input is working on current scan, we ordinarily want it to + * have completed the current row. But if input scan is DC, + * we want it to keep one row ahead so that next block row's DC + * values are up to date. + */ + JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0; + if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta) + break; + } + if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) + return JPEG_SUSPENDED; + } + + /* OK, output from the virtual arrays. */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) + continue; + /* Count non-dummy DCT block rows in this iMCU row. */ + if (cinfo->output_iMCU_row < last_iMCU_row) { + block_rows = compptr->v_samp_factor; + access_rows = block_rows * 2; /* this and next iMCU row */ + last_row = FALSE; + } else { + /* NB: can't use last_row_height here; it is input-side-dependent! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + access_rows = block_rows; /* this iMCU row only */ + last_row = TRUE; + } + /* Align the virtual buffer for this component. */ + if (cinfo->output_iMCU_row > 0) { + access_rows += compptr->v_samp_factor; /* prior iMCU row too */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, + (JDIMENSION) access_rows, FALSE); + buffer += compptr->v_samp_factor; /* point to current iMCU row */ + first_row = FALSE; + } else { + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE); + first_row = TRUE; + } + /* Fetch component-dependent info */ + coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); + quanttbl = compptr->quant_table; + Q00 = quanttbl->quantval[0]; + Q01 = quanttbl->quantval[Q01_POS]; + Q10 = quanttbl->quantval[Q10_POS]; + Q20 = quanttbl->quantval[Q20_POS]; + Q11 = quanttbl->quantval[Q11_POS]; + Q02 = quanttbl->quantval[Q02_POS]; + inverse_DCT = cinfo->idct->inverse_DCT[ci]; + output_ptr = output_buf[ci]; + /* Loop over all DCT blocks to be processed. */ + for (block_row = 0; block_row < block_rows; block_row++) { + buffer_ptr = buffer[block_row]; + if (first_row && block_row == 0) + prev_block_row = buffer_ptr; + else + prev_block_row = buffer[block_row-1]; + if (last_row && block_row == block_rows-1) + next_block_row = buffer_ptr; + else + next_block_row = buffer[block_row+1]; + /* We fetch the surrounding DC values using a sliding-register approach. + * Initialize all nine here so as to do the right thing on narrow pics. + */ + DC1 = DC2 = DC3 = (int) prev_block_row[0][0]; + DC4 = DC5 = DC6 = (int) buffer_ptr[0][0]; + DC7 = DC8 = DC9 = (int) next_block_row[0][0]; + output_col = 0; + last_block_column = compptr->width_in_blocks - 1; + for (block_num = 0; block_num <= last_block_column; block_num++) { + /* Fetch current DCT block into workspace so we can modify it. */ + jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1); + /* Update DC values */ + if (block_num < last_block_column) { + DC3 = (int) prev_block_row[1][0]; + DC6 = (int) buffer_ptr[1][0]; + DC9 = (int) next_block_row[1][0]; + } + /* Compute coefficient estimates per K.8. + * An estimate is applied only if coefficient is still zero, + * and is not known to be fully accurate. + */ + /* AC01 */ + if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { + num = 36 * Q00 * (DC4 - DC6); + if (num >= 0) { + pred = (int) (((Q01<<7) + num) / (Q01<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q10<<7) + num) / (Q10<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q20<<7) + num) / (Q20<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q11<<7) + num) / (Q11<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q02<<7) + num) / (Q02<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<DCT_h_scaled_size; + } + output_ptr += compptr->DCT_v_scaled_size; + } + } + + if (++(cinfo->output_iMCU_row) <= last_iMCU_row) + return JPEG_ROW_COMPLETED; + return JPEG_SCAN_COMPLETED; +} + +#endif /* BLOCK_SMOOTHING_SUPPORTED */ + + +/* + * Initialize coefficient buffer controller. + */ + +GLOBAL(void) +jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_coef_ptr coef; + + if (need_full_buffer) { +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* Allocate a full-image virtual array for each component, */ + /* padded to a multiple of samp_factor DCT blocks in each direction. */ + /* Note we ask for a pre-zeroed array. */ + int ci, access_rows; + jpeg_component_info *compptr; + + coef = (my_coef_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_coef_controller) - SIZEOF(coef->blk_buffer)); + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + access_rows = compptr->v_samp_factor; +#ifdef BLOCK_SMOOTHING_SUPPORTED + /* If block smoothing could be used, need a bigger window */ + if (cinfo->progressive_mode) + access_rows *= 3; +#endif + coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE, + (JDIMENSION) jround_up((long) compptr->width_in_blocks, + (long) compptr->h_samp_factor), + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor), + (JDIMENSION) access_rows); + } + coef->pub.consume_data = consume_data; + coef->pub.decompress_data = decompress_data; + coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + /* We only need a single-MCU buffer. */ + JBLOCKARRAY blkp; + JBLOCKROW buffer_ptr; + int bi; + + coef = (my_coef_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_coef_controller)); + buffer_ptr = coef->blk_buffer; + if (cinfo->lim_Se == 0) /* DC only case: want to bypass later */ + MEMZERO(buffer_ptr, SIZEOF(coef->blk_buffer)); + blkp = coef->MCU_buffer; + bi = D_MAX_BLOCKS_IN_MCU; + do { + *blkp++ = buffer_ptr++; + } while (--bi); + coef->pub.consume_data = dummy_consume_data; + coef->pub.decompress_data = decompress_onepass; + coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ + } + + coef->pub.start_input_pass = start_input_pass; + coef->pub.start_output_pass = start_output_pass; +#ifdef BLOCK_SMOOTHING_SUPPORTED + coef->coef_bits_latch = NULL; +#endif + cinfo->coef = &coef->pub; +} diff --git a/thirdparty/jpeg-9e/jdcolor.c b/thirdparty/jpeg-9e/jdcolor.c new file mode 100644 index 0000000..7750df1 --- /dev/null +++ b/thirdparty/jpeg-9e/jdcolor.c @@ -0,0 +1,778 @@ +/* + * jdcolor.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 2011-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains output colorspace conversion routines. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +#if RANGE_BITS < 2 + /* Deliberate syntax err */ + Sorry, this code requires 2 or more range extension bits. +#endif + + +/* Private subobject */ + +typedef struct { + struct jpeg_color_deconverter pub; /* public fields */ + + /* Private state for YCbCr->RGB and BG_YCC->RGB conversion */ + int * Cr_r_tab; /* => table for Cr to R conversion */ + int * Cb_b_tab; /* => table for Cb to B conversion */ + INT32 * Cr_g_tab; /* => table for Cr to G conversion */ + INT32 * Cb_g_tab; /* => table for Cb to G conversion */ + + /* Private state for RGB->Y conversion */ + INT32 * rgb_y_tab; /* => table for RGB to Y conversion */ +} my_color_deconverter; + +typedef my_color_deconverter * my_cconvert_ptr; + + +/*************** YCbCr -> RGB conversion: most common case **************/ +/*************** BG_YCC -> RGB conversion: less common case **************/ +/*************** RGB -> Y conversion: less common case **************/ + +/* + * YCbCr is defined per Recommendation ITU-R BT.601-7 (03/2011), + * previously known as Recommendation CCIR 601-1, except that Cb and Cr + * are normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. + * sRGB (standard RGB color space) is defined per IEC 61966-2-1:1999. + * sYCC (standard luma-chroma-chroma color space with extended gamut) + * is defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex F. + * bg-sRGB and bg-sYCC (big gamut standard color spaces) + * are defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex G. + * Note that the derived conversion coefficients given in some of these + * documents are imprecise. The general conversion equations are + * + * R = Y + K * (1 - Kr) * Cr + * G = Y - K * (Kb * (1 - Kb) * Cb + Kr * (1 - Kr) * Cr) / (1 - Kr - Kb) + * B = Y + K * (1 - Kb) * Cb + * + * Y = Kr * R + (1 - Kr - Kb) * G + Kb * B + * + * With Kr = 0.299 and Kb = 0.114 (derived according to SMPTE RP 177-1993 + * from the 1953 FCC NTSC primaries and CIE Illuminant C), K = 2 for sYCC, + * the conversion equations to be implemented are therefore + * + * R = Y + 1.402 * Cr + * G = Y - 0.344136286 * Cb - 0.714136286 * Cr + * B = Y + 1.772 * Cb + * + * Y = 0.299 * R + 0.587 * G + 0.114 * B + * + * where Cb and Cr represent the incoming values less CENTERJSAMPLE. + * For bg-sYCC, with K = 4, the equations are + * + * R = Y + 2.804 * Cr + * G = Y - 0.688272572 * Cb - 1.428272572 * Cr + * B = Y + 3.544 * Cb + * + * To avoid floating-point arithmetic, we represent the fractional constants + * as integers scaled up by 2^16 (about 4 digits precision); we have to divide + * the products by 2^16, with appropriate rounding, to get the correct answer. + * Notice that Y, being an integral input, does not contribute any fraction + * so it need not participate in the rounding. + * + * For even more speed, we avoid doing any multiplications in the inner loop + * by precalculating the constants times Cb and Cr for all possible values. + * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); + * for 9-bit to 12-bit samples it is still acceptable. It's not very + * reasonable for 16-bit samples, but if you want lossless storage you + * shouldn't be changing colorspace anyway. + * The Cr=>R and Cb=>B values can be rounded to integers in advance; the + * values for the G calculation are left scaled up, since we must add them + * together before rounding. + */ + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L<Y conversion and divide it up into + * three parts, instead of doing three alloc_small requests. This lets us + * use a single table base address, which can be held in a register in the + * inner loops on many machines (more than can hold all three addresses, + * anyway). + */ + +#define R_Y_OFF 0 /* offset to R => Y section */ +#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */ +#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */ +#define TABLE_SIZE (3*(MAXJSAMPLE+1)) + + +/* + * Initialize tables for YCbCr->RGB and BG_YCC->RGB colorspace conversion. + */ + +LOCAL(void) +build_ycc_rgb_table (j_decompress_ptr cinfo) +/* Normal case, sYCC */ +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + int i; + INT32 x; + SHIFT_TEMPS + + cconvert->Cr_r_tab = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int)); + cconvert->Cb_b_tab = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int)); + cconvert->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32)); + cconvert->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32)); + + for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { + /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ + /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ + /* Cr=>R value is nearest int to 1.402 * x */ + cconvert->Cr_r_tab[i] = (int) DESCALE(FIX(1.402) * x, SCALEBITS); + /* Cb=>B value is nearest int to 1.772 * x */ + cconvert->Cb_b_tab[i] = (int) DESCALE(FIX(1.772) * x, SCALEBITS); + /* Cr=>G value is scaled-up -0.714136286 * x */ + cconvert->Cr_g_tab[i] = (- FIX(0.714136286)) * x; + /* Cb=>G value is scaled-up -0.344136286 * x */ + /* We also add in ONE_HALF so that need not do it in inner loop */ + cconvert->Cb_g_tab[i] = (- FIX(0.344136286)) * x + ONE_HALF; + } +} + + +LOCAL(void) +build_bg_ycc_rgb_table (j_decompress_ptr cinfo) +/* Wide gamut case, bg-sYCC */ +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + int i; + INT32 x; + SHIFT_TEMPS + + cconvert->Cr_r_tab = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int)); + cconvert->Cb_b_tab = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int)); + cconvert->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32)); + cconvert->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32)); + + for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { + /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ + /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ + /* Cr=>R value is nearest int to 2.804 * x */ + cconvert->Cr_r_tab[i] = (int) DESCALE(FIX(2.804) * x, SCALEBITS); + /* Cb=>B value is nearest int to 3.544 * x */ + cconvert->Cb_b_tab[i] = (int) DESCALE(FIX(3.544) * x, SCALEBITS); + /* Cr=>G value is scaled-up -1.428272572 * x */ + cconvert->Cr_g_tab[i] = (- FIX(1.428272572)) * x; + /* Cb=>G value is scaled-up -0.688272572 * x */ + /* We also add in ONE_HALF so that need not do it in inner loop */ + cconvert->Cb_g_tab[i] = (- FIX(0.688272572)) * x + ONE_HALF; + } +} + + +/* + * Convert some rows of samples to the output colorspace. + * + * Note that we change from noninterleaved, one-plane-per-component format + * to interleaved-pixel format. The output buffer is therefore three times + * as wide as the input buffer. + * + * A starting row offset is provided only for the input buffer. The caller + * can easily adjust the passed output_buf value to accommodate any row + * offset required on that side. + */ + +METHODDEF(void) +ycc_rgb_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int y, cb, cr; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + register int * Crrtab = cconvert->Cr_r_tab; + register int * Cbbtab = cconvert->Cb_b_tab; + register INT32 * Crgtab = cconvert->Cr_g_tab; + register INT32 * Cbgtab = cconvert->Cb_g_tab; + SHIFT_TEMPS + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + y = GETJSAMPLE(inptr0[col]); + cb = GETJSAMPLE(inptr1[col]); + cr = GETJSAMPLE(inptr2[col]); + /* Range-limiting is essential due to noise introduced by DCT losses, + * for extended gamut (sYCC) and wide gamut (bg-sYCC) encodings. + */ + outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; + outptr[RGB_GREEN] = range_limit[y + + ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], + SCALEBITS))]; + outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; + outptr += RGB_PIXELSIZE; + } + } +} + + +/**************** Cases other than YCC -> RGB ****************/ + + +/* + * Initialize for RGB->grayscale colorspace conversion. + */ + +LOCAL(void) +build_rgb_y_table (j_decompress_ptr cinfo) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + INT32 * rgb_y_tab; + INT32 i; + + /* Allocate and fill in the conversion tables. */ + cconvert->rgb_y_tab = rgb_y_tab = (INT32 *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, TABLE_SIZE * SIZEOF(INT32)); + + for (i = 0; i <= MAXJSAMPLE; i++) { + rgb_y_tab[i+R_Y_OFF] = FIX(0.299) * i; + rgb_y_tab[i+G_Y_OFF] = FIX(0.587) * i; + rgb_y_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF; + } +} + + +/* + * Convert RGB to grayscale. + */ + +METHODDEF(void) +rgb_gray_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_y_tab; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr0[col]); + g = GETJSAMPLE(inptr1[col]); + b = GETJSAMPLE(inptr2[col]); + /* Y */ + outptr[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + } + } +} + + +/* + * Convert some rows of samples to the output colorspace. + * [R-G,G,B-G] to [R,G,B] conversion with modulo calculation + * (inverse color transform). + * This can be seen as an adaption of the general YCbCr->RGB + * conversion equation with Kr = Kb = 0, while replacing the + * normalization by modulo calculation. + */ + +METHODDEF(void) +rgb1_rgb_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + register int r, g, b; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr0[col]); + g = GETJSAMPLE(inptr1[col]); + b = GETJSAMPLE(inptr2[col]); + /* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD + * (modulo) operator is equivalent to the bitmask operator AND. + */ + outptr[RGB_RED] = (JSAMPLE) ((r + g - CENTERJSAMPLE) & MAXJSAMPLE); + outptr[RGB_GREEN] = (JSAMPLE) g; + outptr[RGB_BLUE] = (JSAMPLE) ((b + g - CENTERJSAMPLE) & MAXJSAMPLE); + outptr += RGB_PIXELSIZE; + } + } +} + + +/* + * [R-G,G,B-G] to grayscale conversion with modulo calculation + * (inverse color transform). + */ + +METHODDEF(void) +rgb1_gray_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_y_tab; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr0[col]); + g = GETJSAMPLE(inptr1[col]); + b = GETJSAMPLE(inptr2[col]); + /* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD + * (modulo) operator is equivalent to the bitmask operator AND. + */ + r = (r + g - CENTERJSAMPLE) & MAXJSAMPLE; + b = (b + g - CENTERJSAMPLE) & MAXJSAMPLE; + /* Y */ + outptr[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + } + } +} + + +/* + * Convert some rows of samples to the output colorspace. + * No colorspace change, but conversion from separate-planes + * to interleaved representation. + */ + +METHODDEF(void) +rgb_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + /* We can dispense with GETJSAMPLE() here */ + outptr[RGB_RED] = inptr0[col]; + outptr[RGB_GREEN] = inptr1[col]; + outptr[RGB_BLUE] = inptr2[col]; + outptr += RGB_PIXELSIZE; + } + } +} + + +/* + * Color conversion for no colorspace change: just copy the data, + * converting from separate-planes to interleaved representation. + * Note: Omit uninteresting components in output buffer. + */ + +METHODDEF(void) +null_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + register JSAMPROW outptr; + register JSAMPROW inptr; + register JDIMENSION count; + register int out_comps = cinfo->out_color_components; + JDIMENSION num_cols = cinfo->output_width; + JSAMPROW startptr; + int ci; + jpeg_component_info *compptr; + + while (--num_rows >= 0) { + /* It seems fastest to make a separate pass for each component. */ + startptr = *output_buf++; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (! compptr->component_needed) + continue; /* skip uninteresting component */ + inptr = input_buf[ci][input_row]; + outptr = startptr++; + for (count = num_cols; count > 0; count--) { + *outptr = *inptr++; /* don't need GETJSAMPLE() here */ + outptr += out_comps; + } + } + input_row++; + } +} + + +/* + * Color conversion for grayscale: just copy the data. + * This also works for YCC -> grayscale conversion, in which + * we just copy the Y (luminance) component and ignore chrominance. + */ + +METHODDEF(void) +grayscale_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + jcopy_sample_rows(input_buf[0] + input_row, output_buf, + num_rows, cinfo->output_width); +} + + +/* + * Convert grayscale to RGB: just duplicate the graylevel three times. + * This is provided to support applications that don't want to cope + * with grayscale as a separate case. + */ + +METHODDEF(void) +gray_rgb_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + register JSAMPROW outptr; + register JSAMPROW inptr; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + + while (--num_rows >= 0) { + inptr = input_buf[0][input_row++]; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + /* We can dispense with GETJSAMPLE() here */ + outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; + outptr += RGB_PIXELSIZE; + } + } +} + + +/* + * Convert some rows of samples to the output colorspace. + * This version handles Adobe-style YCCK->CMYK conversion, + * where we convert YCbCr to R=1-C, G=1-M, and B=1-Y using the + * same conversion as above, while passing K (black) unchanged. + * We assume build_ycc_rgb_table has been called. + */ + +METHODDEF(void) +ycck_cmyk_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int y, cb, cr; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2, inptr3; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + register int * Crrtab = cconvert->Cr_r_tab; + register int * Cbbtab = cconvert->Cb_b_tab; + register INT32 * Crgtab = cconvert->Cr_g_tab; + register INT32 * Cbgtab = cconvert->Cb_g_tab; + SHIFT_TEMPS + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + inptr3 = input_buf[3][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + y = GETJSAMPLE(inptr0[col]); + cb = GETJSAMPLE(inptr1[col]); + cr = GETJSAMPLE(inptr2[col]); + /* Range-limiting is essential due to noise introduced by DCT losses, + * and for extended gamut encodings (sYCC). + */ + outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ + outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ + ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], + SCALEBITS)))]; + outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ + /* K passes through unchanged */ + outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ + outptr += 4; + } + } +} + + +/* + * Convert CMYK to YK part of YCCK for colorless output. + * We assume build_rgb_y_table has been called. + */ + +METHODDEF(void) +cmyk_yk_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_y_tab; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2, inptr3; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + inptr3 = input_buf[3][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + r = MAXJSAMPLE - GETJSAMPLE(inptr0[col]); + g = MAXJSAMPLE - GETJSAMPLE(inptr1[col]); + b = MAXJSAMPLE - GETJSAMPLE(inptr2[col]); + /* Y */ + outptr[0] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + /* K passes through unchanged */ + outptr[1] = inptr3[col]; /* don't need GETJSAMPLE here */ + outptr += 2; + } + } +} + + +/* + * Empty method for start_pass. + */ + +METHODDEF(void) +start_pass_dcolor (j_decompress_ptr cinfo) +{ + /* no work needed */ +} + + +/* + * Module initialization routine for output colorspace conversion. + */ + +GLOBAL(void) +jinit_color_deconverter (j_decompress_ptr cinfo) +{ + my_cconvert_ptr cconvert; + int ci, i; + + cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_deconverter)); + cinfo->cconvert = &cconvert->pub; + cconvert->pub.start_pass = start_pass_dcolor; + + /* Make sure num_components agrees with jpeg_color_space */ + switch (cinfo->jpeg_color_space) { + case JCS_GRAYSCALE: + if (cinfo->num_components != 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + case JCS_RGB: + case JCS_YCbCr: + case JCS_BG_RGB: + case JCS_BG_YCC: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + case JCS_CMYK: + case JCS_YCCK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + default: /* JCS_UNKNOWN can be anything */ + if (cinfo->num_components < 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + } + + /* Support color transform only for RGB colorspaces */ + if (cinfo->color_transform && + cinfo->jpeg_color_space != JCS_RGB && + cinfo->jpeg_color_space != JCS_BG_RGB) + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + + /* Set out_color_components and conversion method based on requested space. + * Also adjust the component_needed flags for any unused components, + * so that earlier pipeline stages can avoid useless computation. + */ + + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + cinfo->out_color_components = 1; + switch (cinfo->jpeg_color_space) { + case JCS_GRAYSCALE: + case JCS_YCbCr: + case JCS_BG_YCC: + cconvert->pub.color_convert = grayscale_convert; + /* For color->grayscale conversion, only the Y (0) component is needed */ + for (ci = 1; ci < cinfo->num_components; ci++) + cinfo->comp_info[ci].component_needed = FALSE; + break; + case JCS_RGB: + switch (cinfo->color_transform) { + case JCT_NONE: + cconvert->pub.color_convert = rgb_gray_convert; + break; + case JCT_SUBTRACT_GREEN: + cconvert->pub.color_convert = rgb1_gray_convert; + break; + default: + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + } + build_rgb_y_table(cinfo); + break; + default: + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + } + break; + + case JCS_RGB: + cinfo->out_color_components = RGB_PIXELSIZE; + switch (cinfo->jpeg_color_space) { + case JCS_GRAYSCALE: + cconvert->pub.color_convert = gray_rgb_convert; + break; + case JCS_YCbCr: + cconvert->pub.color_convert = ycc_rgb_convert; + build_ycc_rgb_table(cinfo); + break; + case JCS_BG_YCC: + cconvert->pub.color_convert = ycc_rgb_convert; + build_bg_ycc_rgb_table(cinfo); + break; + case JCS_RGB: + switch (cinfo->color_transform) { + case JCT_NONE: + cconvert->pub.color_convert = rgb_convert; + break; + case JCT_SUBTRACT_GREEN: + cconvert->pub.color_convert = rgb1_rgb_convert; + break; + default: + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + } + break; + default: + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + } + break; + + case JCS_BG_RGB: + if (cinfo->jpeg_color_space != JCS_BG_RGB) + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + cinfo->out_color_components = RGB_PIXELSIZE; + switch (cinfo->color_transform) { + case JCT_NONE: + cconvert->pub.color_convert = rgb_convert; + break; + case JCT_SUBTRACT_GREEN: + cconvert->pub.color_convert = rgb1_rgb_convert; + break; + default: + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + } + break; + + case JCS_CMYK: + if (cinfo->jpeg_color_space != JCS_YCCK) + goto def_label; + cinfo->out_color_components = 4; + cconvert->pub.color_convert = ycck_cmyk_convert; + build_ycc_rgb_table(cinfo); + break; + + case JCS_YCCK: + if (cinfo->jpeg_color_space != JCS_CMYK || + /* Support only YK part of YCCK for colorless output */ + ! cinfo->comp_info[0].component_needed || + cinfo->comp_info[1].component_needed || + cinfo->comp_info[2].component_needed || + ! cinfo->comp_info[3].component_needed) + goto def_label; + cinfo->out_color_components = 2; + /* Need all components on input side */ + cinfo->comp_info[1].component_needed = TRUE; + cinfo->comp_info[2].component_needed = TRUE; + cconvert->pub.color_convert = cmyk_yk_convert; + build_rgb_y_table(cinfo); + break; + + default: def_label: /* permit null conversion to same output space */ + if (cinfo->out_color_space != cinfo->jpeg_color_space) + /* unsupported non-null conversion */ + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + i = 0; + for (ci = 0; ci < cinfo->num_components; ci++) + if (cinfo->comp_info[ci].component_needed) + i++; /* count output color components */ + cinfo->out_color_components = i; + cconvert->pub.color_convert = null_convert; + } + + if (cinfo->quantize_colors) + cinfo->output_components = 1; /* single colormapped output component */ + else + cinfo->output_components = cinfo->out_color_components; +} diff --git a/thirdparty/jpeg-9e/jdct.h b/thirdparty/jpeg-9e/jdct.h new file mode 100644 index 0000000..c8ec6cd --- /dev/null +++ b/thirdparty/jpeg-9e/jdct.h @@ -0,0 +1,409 @@ +/* + * jdct.h + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2002-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This include file contains common declarations for the forward and + * inverse DCT modules. These declarations are private to the DCT managers + * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. + * The individual DCT algorithms are kept in separate files to ease + * machine-dependent tuning (e.g., assembly coding). + */ + + +/* + * A forward DCT routine is given a pointer to an input sample array and + * a pointer to a work area of type DCTELEM[]; the DCT is to be performed + * in-place in that buffer. Type DCTELEM is int for 8-bit samples, INT32 + * for 12-bit samples. (NOTE: Floating-point DCT implementations use an + * array of type FAST_FLOAT, instead.) + * The input data is to be fetched from the sample array starting at a + * specified column. (Any row offset needed will be applied to the array + * pointer before it is passed to the FDCT code.) + * Note that the number of samples fetched by the FDCT routine is + * DCT_h_scaled_size * DCT_v_scaled_size. + * The DCT outputs are returned scaled up by a factor of 8; they therefore + * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This + * convention improves accuracy in integer implementations and saves some + * work in floating-point ones. + * Quantization of the output coefficients is done by jcdctmgr.c. + */ + +#if BITS_IN_JSAMPLE == 8 +typedef int DCTELEM; /* 16 or 32 bits is fine */ +#else +typedef INT32 DCTELEM; /* must have 32 bits */ +#endif + +typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data, + JSAMPARRAY sample_data, + JDIMENSION start_col)); +typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data, + JSAMPARRAY sample_data, + JDIMENSION start_col)); + + +/* + * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer + * to an output sample array. The routine must dequantize the input data as + * well as perform the IDCT; for dequantization, it uses the multiplier table + * pointed to by compptr->dct_table. The output data is to be placed into the + * sample array starting at a specified column. (Any row offset needed will + * be applied to the array pointer before it is passed to the IDCT code.) + * Note that the number of samples emitted by the IDCT routine is + * DCT_h_scaled_size * DCT_v_scaled_size. + */ + +/* typedef inverse_DCT_method_ptr is declared in jpegint.h */ + +/* + * Each IDCT routine has its own ideas about the best dct_table element type. + */ + +typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */ +#if BITS_IN_JSAMPLE == 8 +typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */ +#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */ +#else +typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */ +#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */ +#endif +typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */ + + +/* + * Each IDCT routine is responsible for range-limiting its results and + * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could + * be quite far out of range if the input data is corrupt, so a bulletproof + * range-limiting step is required. We use a mask-and-table-lookup method + * to do the combined operations quickly, assuming that RANGE_CENTER + * (defined in jpegint.h) is a power of 2. See the comments with + * prepare_range_limit_table (in jdmaster.c) for more info. + */ + +#define RANGE_MASK (RANGE_CENTER * 2 - 1) +#define RANGE_SUBSET (RANGE_CENTER - CENTERJSAMPLE) + +#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit - RANGE_SUBSET) + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_fdct_islow jFDislow +#define jpeg_fdct_ifast jFDifast +#define jpeg_fdct_float jFDfloat +#define jpeg_fdct_7x7 jFD7x7 +#define jpeg_fdct_6x6 jFD6x6 +#define jpeg_fdct_5x5 jFD5x5 +#define jpeg_fdct_4x4 jFD4x4 +#define jpeg_fdct_3x3 jFD3x3 +#define jpeg_fdct_2x2 jFD2x2 +#define jpeg_fdct_1x1 jFD1x1 +#define jpeg_fdct_9x9 jFD9x9 +#define jpeg_fdct_10x10 jFD10x10 +#define jpeg_fdct_11x11 jFD11x11 +#define jpeg_fdct_12x12 jFD12x12 +#define jpeg_fdct_13x13 jFD13x13 +#define jpeg_fdct_14x14 jFD14x14 +#define jpeg_fdct_15x15 jFD15x15 +#define jpeg_fdct_16x16 jFD16x16 +#define jpeg_fdct_16x8 jFD16x8 +#define jpeg_fdct_14x7 jFD14x7 +#define jpeg_fdct_12x6 jFD12x6 +#define jpeg_fdct_10x5 jFD10x5 +#define jpeg_fdct_8x4 jFD8x4 +#define jpeg_fdct_6x3 jFD6x3 +#define jpeg_fdct_4x2 jFD4x2 +#define jpeg_fdct_2x1 jFD2x1 +#define jpeg_fdct_8x16 jFD8x16 +#define jpeg_fdct_7x14 jFD7x14 +#define jpeg_fdct_6x12 jFD6x12 +#define jpeg_fdct_5x10 jFD5x10 +#define jpeg_fdct_4x8 jFD4x8 +#define jpeg_fdct_3x6 jFD3x6 +#define jpeg_fdct_2x4 jFD2x4 +#define jpeg_fdct_1x2 jFD1x2 +#define jpeg_idct_islow jRDislow +#define jpeg_idct_ifast jRDifast +#define jpeg_idct_float jRDfloat +#define jpeg_idct_7x7 jRD7x7 +#define jpeg_idct_6x6 jRD6x6 +#define jpeg_idct_5x5 jRD5x5 +#define jpeg_idct_4x4 jRD4x4 +#define jpeg_idct_3x3 jRD3x3 +#define jpeg_idct_2x2 jRD2x2 +#define jpeg_idct_1x1 jRD1x1 +#define jpeg_idct_9x9 jRD9x9 +#define jpeg_idct_10x10 jRD10x10 +#define jpeg_idct_11x11 jRD11x11 +#define jpeg_idct_12x12 jRD12x12 +#define jpeg_idct_13x13 jRD13x13 +#define jpeg_idct_14x14 jRD14x14 +#define jpeg_idct_15x15 jRD15x15 +#define jpeg_idct_16x16 jRD16x16 +#define jpeg_idct_16x8 jRD16x8 +#define jpeg_idct_14x7 jRD14x7 +#define jpeg_idct_12x6 jRD12x6 +#define jpeg_idct_10x5 jRD10x5 +#define jpeg_idct_8x4 jRD8x4 +#define jpeg_idct_6x3 jRD6x3 +#define jpeg_idct_4x2 jRD4x2 +#define jpeg_idct_2x1 jRD2x1 +#define jpeg_idct_8x16 jRD8x16 +#define jpeg_idct_7x14 jRD7x14 +#define jpeg_idct_6x12 jRD6x12 +#define jpeg_idct_5x10 jRD5x10 +#define jpeg_idct_4x8 jRD4x8 +#define jpeg_idct_3x6 jRD3x8 +#define jpeg_idct_2x4 jRD2x4 +#define jpeg_idct_1x2 jRD1x2 +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + +/* Extern declarations for the forward and inverse DCT routines. */ + +EXTERN(void) jpeg_fdct_islow + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_ifast + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_float + JPP((FAST_FLOAT * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_7x7 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_6x6 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_5x5 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_4x4 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_3x3 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_2x2 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_1x1 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_9x9 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_10x10 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_11x11 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_12x12 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_13x13 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_14x14 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_15x15 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_16x16 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_16x8 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_14x7 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_12x6 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_10x5 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_8x4 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_6x3 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_4x2 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_2x1 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_8x16 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_7x14 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_6x12 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_5x10 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_4x8 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_3x6 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_2x4 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); +EXTERN(void) jpeg_fdct_1x2 + JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)); + +EXTERN(void) jpeg_idct_islow + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_ifast + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_float + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_7x7 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_6x6 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_5x5 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_4x4 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_3x3 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_2x2 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_1x1 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_9x9 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_10x10 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_11x11 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_12x12 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_13x13 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_14x14 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_15x15 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_16x16 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_16x8 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_14x7 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_12x6 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_10x5 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_8x4 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_6x3 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_4x2 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_2x1 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_8x16 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_7x14 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_6x12 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_5x10 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_4x8 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_3x6 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_2x4 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_1x2 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); + + +/* + * Macros for handling fixed-point arithmetic; these are used by many + * but not all of the DCT/IDCT modules. + * + * All values are expected to be of type INT32. + * Fractional constants are scaled left by CONST_BITS bits. + * CONST_BITS is defined within each module using these macros, + * and may differ from one module to the next. + */ + +#define ONE ((INT32) 1) +#define CONST_SCALE (ONE << CONST_BITS) + +/* Convert a positive real constant to an integer scaled by CONST_SCALE. + * Caution: some C compilers fail to reduce "FIX(constant)" at compile time, + * thus causing a lot of useless floating-point operations at run time. + */ + +#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * This macro is used only when the two inputs will actually be no more than + * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a + * full 32x32 multiply. This provides a useful speedup on many machines. + * Unfortunately there is no way to specify a 16x16->32 multiply portably + * in C, but some C compilers will do the right thing if you provide the + * correct combination of casts. + */ + +#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ +#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const))) +#endif +#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ +#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const))) +#endif + +#ifndef MULTIPLY16C16 /* default definition */ +#define MULTIPLY16C16(var,const) ((var) * (const)) +#endif + +/* Same except both inputs are variables. */ + +#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ +#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2))) +#endif + +#ifndef MULTIPLY16V16 /* default definition */ +#define MULTIPLY16V16(var1,var2) ((var1) * (var2)) +#endif + +/* Like RIGHT_SHIFT, but applies to a DCTELEM. + * We assume that int right shift is unsigned if INT32 right shift is. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define ISHIFT_TEMPS DCTELEM ishift_temp; +#if BITS_IN_JSAMPLE == 8 +#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */ +#else +#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */ +#endif +#define IRIGHT_SHIFT(x,shft) \ + ((ishift_temp = (x)) < 0 ? \ + (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \ + (ishift_temp >> (shft))) +#else +#define ISHIFT_TEMPS +#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif diff --git a/thirdparty/jpeg-9e/jddctmgr.c b/thirdparty/jpeg-9e/jddctmgr.c new file mode 100644 index 0000000..9ecfbb5 --- /dev/null +++ b/thirdparty/jpeg-9e/jddctmgr.c @@ -0,0 +1,384 @@ +/* + * jddctmgr.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2002-2013 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the inverse-DCT management logic. + * This code selects a particular IDCT implementation to be used, + * and it performs related housekeeping chores. No code in this file + * is executed per IDCT step, only during output pass setup. + * + * Note that the IDCT routines are responsible for performing coefficient + * dequantization as well as the IDCT proper. This module sets up the + * dequantization multiplier table needed by the IDCT routine. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + + +/* + * The decompressor input side (jdinput.c) saves away the appropriate + * quantization table for each component at the start of the first scan + * involving that component. (This is necessary in order to correctly + * decode files that reuse Q-table slots.) + * When we are ready to make an output pass, the saved Q-table is converted + * to a multiplier table that will actually be used by the IDCT routine. + * The multiplier table contents are IDCT-method-dependent. To support + * application changes in IDCT method between scans, we can remake the + * multiplier tables if necessary. + * In buffered-image mode, the first output pass may occur before any data + * has been seen for some components, and thus before their Q-tables have + * been saved away. To handle this case, multiplier tables are preset + * to zeroes; the result of the IDCT will be a neutral gray level. + */ + + +/* Private subobject for this module */ + +typedef struct { + struct jpeg_inverse_dct pub; /* public fields */ + + /* This array contains the IDCT method code that each multiplier table + * is currently set up for, or -1 if it's not yet set up. + * The actual multiplier tables are pointed to by dct_table in the + * per-component comp_info structures. + */ + int cur_method[MAX_COMPONENTS]; +} my_idct_controller; + +typedef my_idct_controller * my_idct_ptr; + + +/* Allocated multiplier tables: big enough for any supported variant */ + +typedef union { + ISLOW_MULT_TYPE islow_array[DCTSIZE2]; +#ifdef DCT_IFAST_SUPPORTED + IFAST_MULT_TYPE ifast_array[DCTSIZE2]; +#endif +#ifdef DCT_FLOAT_SUPPORTED + FLOAT_MULT_TYPE float_array[DCTSIZE2]; +#endif +} multiplier_table; + + +/* The current scaled-IDCT routines require ISLOW-style multiplier tables, + * so be sure to compile that code if either ISLOW or SCALING is requested. + */ +#ifdef DCT_ISLOW_SUPPORTED +#define PROVIDE_ISLOW_TABLES +#else +#ifdef IDCT_SCALING_SUPPORTED +#define PROVIDE_ISLOW_TABLES +#endif +#endif + + +/* + * Prepare for an output pass. + * Here we select the proper IDCT routine for each component and build + * a matching multiplier table. + */ + +METHODDEF(void) +start_pass (j_decompress_ptr cinfo) +{ + my_idct_ptr idct = (my_idct_ptr) cinfo->idct; + int ci, i; + jpeg_component_info *compptr; + int method = 0; + inverse_DCT_method_ptr method_ptr = NULL; + JQUANT_TBL * qtbl; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Select the proper IDCT routine for this component's scaling */ + switch ((compptr->DCT_h_scaled_size << 8) + compptr->DCT_v_scaled_size) { +#ifdef IDCT_SCALING_SUPPORTED + case ((1 << 8) + 1): + method_ptr = jpeg_idct_1x1; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((2 << 8) + 2): + method_ptr = jpeg_idct_2x2; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((3 << 8) + 3): + method_ptr = jpeg_idct_3x3; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((4 << 8) + 4): + method_ptr = jpeg_idct_4x4; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((5 << 8) + 5): + method_ptr = jpeg_idct_5x5; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((6 << 8) + 6): + method_ptr = jpeg_idct_6x6; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((7 << 8) + 7): + method_ptr = jpeg_idct_7x7; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((9 << 8) + 9): + method_ptr = jpeg_idct_9x9; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((10 << 8) + 10): + method_ptr = jpeg_idct_10x10; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((11 << 8) + 11): + method_ptr = jpeg_idct_11x11; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((12 << 8) + 12): + method_ptr = jpeg_idct_12x12; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((13 << 8) + 13): + method_ptr = jpeg_idct_13x13; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((14 << 8) + 14): + method_ptr = jpeg_idct_14x14; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((15 << 8) + 15): + method_ptr = jpeg_idct_15x15; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((16 << 8) + 16): + method_ptr = jpeg_idct_16x16; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((16 << 8) + 8): + method_ptr = jpeg_idct_16x8; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((14 << 8) + 7): + method_ptr = jpeg_idct_14x7; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((12 << 8) + 6): + method_ptr = jpeg_idct_12x6; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((10 << 8) + 5): + method_ptr = jpeg_idct_10x5; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((8 << 8) + 4): + method_ptr = jpeg_idct_8x4; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((6 << 8) + 3): + method_ptr = jpeg_idct_6x3; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((4 << 8) + 2): + method_ptr = jpeg_idct_4x2; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((2 << 8) + 1): + method_ptr = jpeg_idct_2x1; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((8 << 8) + 16): + method_ptr = jpeg_idct_8x16; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((7 << 8) + 14): + method_ptr = jpeg_idct_7x14; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((6 << 8) + 12): + method_ptr = jpeg_idct_6x12; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((5 << 8) + 10): + method_ptr = jpeg_idct_5x10; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((4 << 8) + 8): + method_ptr = jpeg_idct_4x8; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((3 << 8) + 6): + method_ptr = jpeg_idct_3x6; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((2 << 8) + 4): + method_ptr = jpeg_idct_2x4; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; + case ((1 << 8) + 2): + method_ptr = jpeg_idct_1x2; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; +#endif + case ((DCTSIZE << 8) + DCTSIZE): + switch (cinfo->dct_method) { +#ifdef DCT_ISLOW_SUPPORTED + case JDCT_ISLOW: + method_ptr = jpeg_idct_islow; + method = JDCT_ISLOW; + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + method_ptr = jpeg_idct_ifast; + method = JDCT_IFAST; + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + method_ptr = jpeg_idct_float; + method = JDCT_FLOAT; + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + break; + default: + ERREXIT2(cinfo, JERR_BAD_DCTSIZE, + compptr->DCT_h_scaled_size, compptr->DCT_v_scaled_size); + break; + } + idct->pub.inverse_DCT[ci] = method_ptr; + /* Create multiplier table from quant table. + * However, we can skip this if the component is uninteresting + * or if we already built the table. Also, if no quant table + * has yet been saved for the component, we leave the + * multiplier table all-zero; we'll be reading zeroes from the + * coefficient controller's buffer anyway. + */ + if (! compptr->component_needed || idct->cur_method[ci] == method) + continue; + qtbl = compptr->quant_table; + if (qtbl == NULL) /* happens if no data yet for component */ + continue; + idct->cur_method[ci] = method; + switch (method) { +#ifdef PROVIDE_ISLOW_TABLES + case JDCT_ISLOW: + { + /* For LL&M IDCT method, multipliers are equal to raw quantization + * coefficients, but are stored as ints to ensure access efficiency. + */ + ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table; + for (i = 0; i < DCTSIZE2; i++) { + ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i]; + } + } + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + { + /* For AA&N IDCT method, multipliers are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * For integer operation, the multiplier table is to be scaled by + * IFAST_SCALE_BITS. + */ + IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table; +#define CONST_BITS 14 + static const INT16 aanscales[DCTSIZE2] = { + /* precomputed values scaled up by 14 bits */ + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, + 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, + 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, + 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, + 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 + }; + SHIFT_TEMPS + + for (i = 0; i < DCTSIZE2; i++) { + ifmtbl[i] = (IFAST_MULT_TYPE) + DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], + (INT32) aanscales[i]), + CONST_BITS-IFAST_SCALE_BITS); + } + } + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + { + /* For float AA&N IDCT method, multipliers are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * We apply a further scale factor of 1/8. + */ + FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; + int row, col; + static const double aanscalefactor[DCTSIZE] = { + 1.0, 1.387039845, 1.306562965, 1.175875602, + 1.0, 0.785694958, 0.541196100, 0.275899379 + }; + + i = 0; + for (row = 0; row < DCTSIZE; row++) { + for (col = 0; col < DCTSIZE; col++) { + fmtbl[i] = (FLOAT_MULT_TYPE) + ((double) qtbl->quantval[i] * + aanscalefactor[row] * aanscalefactor[col] * 0.125); + i++; + } + } + } + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + } +} + + +/* + * Initialize IDCT manager. + */ + +GLOBAL(void) +jinit_inverse_dct (j_decompress_ptr cinfo) +{ + my_idct_ptr idct; + int ci; + jpeg_component_info *compptr; + + idct = (my_idct_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_idct_controller)); + cinfo->idct = &idct->pub; + idct->pub.start_pass = start_pass; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Allocate and pre-zero a multiplier table for each component */ + compptr->dct_table = + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(multiplier_table)); + MEMZERO(compptr->dct_table, SIZEOF(multiplier_table)); + /* Mark multiplier table not yet set up for any method */ + idct->cur_method[ci] = -1; + } +} diff --git a/thirdparty/jpeg-9e/jdhuff.c b/thirdparty/jpeg-9e/jdhuff.c new file mode 100644 index 0000000..f175f0c --- /dev/null +++ b/thirdparty/jpeg-9e/jdhuff.c @@ -0,0 +1,1559 @@ +/* + * jdhuff.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 2006-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy decoding routines. + * Both sequential and progressive modes are supported in this single module. + * + * Much of the complexity here has to do with supporting input suspension. + * If the data source module demands suspension, we want to be able to back + * up to the start of the current MCU. To do this, we copy state variables + * into local working storage, and update them back to the permanent + * storage only upon successful completion of an MCU. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Derived data constructed for each Huffman table */ + +#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ + +typedef struct { + /* Basic tables: (element [0] of each array is unused) */ + INT32 maxcode[18]; /* largest code of length k (-1 if none) */ + /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */ + INT32 valoffset[17]; /* huffval[] offset for codes of length k */ + /* valoffset[k] = huffval[] index of 1st symbol of code length k, less + * the smallest code of length k; so given a code of length k, the + * corresponding symbol is huffval[code + valoffset[k]] + */ + + /* Link to public Huffman table (needed only in jpeg_huff_decode) */ + JHUFF_TBL *pub; + + /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of + * the input data stream. If the next Huffman code is no more + * than HUFF_LOOKAHEAD bits long, we can obtain its length and + * the corresponding symbol directly from these tables. + */ + int look_nbits[1< 32 bits on your machine, and shifting/masking longs is + * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE + * appropriately should be a win. Unfortunately we can't define the size + * with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8) + * because not all machines measure sizeof in 8-bit bytes. + */ + +typedef struct { /* Bitreading state saved across MCUs */ + bit_buf_type get_buffer; /* current bit-extraction buffer */ + int bits_left; /* # of unused bits in it */ +} bitread_perm_state; + +typedef struct { /* Bitreading working state within an MCU */ + /* Current data source location */ + /* We need a copy, rather than munging the original, in case of suspension */ + const JOCTET * next_input_byte; /* => next byte to read from source */ + size_t bytes_in_buffer; /* # of bytes remaining in source buffer */ + /* Bit input buffer --- note these values are kept in register variables, + * not in this struct, inside the inner loops. + */ + bit_buf_type get_buffer; /* current bit-extraction buffer */ + int bits_left; /* # of unused bits in it */ + /* Pointer needed by jpeg_fill_bit_buffer. */ + j_decompress_ptr cinfo; /* back link to decompress master record */ +} bitread_working_state; + +/* Macros to declare and load/save bitread local variables. */ +#define BITREAD_STATE_VARS \ + register bit_buf_type get_buffer; \ + register int bits_left; \ + bitread_working_state br_state + +#define BITREAD_LOAD_STATE(cinfop,permstate) \ + br_state.cinfo = cinfop; \ + br_state.next_input_byte = cinfop->src->next_input_byte; \ + br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \ + get_buffer = permstate.get_buffer; \ + bits_left = permstate.bits_left; + +#define BITREAD_SAVE_STATE(cinfop,permstate) \ + cinfop->src->next_input_byte = br_state.next_input_byte; \ + cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \ + permstate.get_buffer = get_buffer; \ + permstate.bits_left = bits_left + +/* + * These macros provide the in-line portion of bit fetching. + * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer + * before using GET_BITS, PEEK_BITS, or DROP_BITS. + * The variables get_buffer and bits_left are assumed to be locals, + * but the state struct might not be (jpeg_huff_decode needs this). + * CHECK_BIT_BUFFER(state,n,action); + * Ensure there are N bits in get_buffer; if suspend, take action. + * val = GET_BITS(n); + * Fetch next N bits. + * val = PEEK_BITS(n); + * Fetch next N bits without removing them from the buffer. + * DROP_BITS(n); + * Discard next N bits. + * The value N should be a simple variable, not an expression, because it + * is evaluated multiple times. + */ + +#define CHECK_BIT_BUFFER(state,nbits,action) \ + { if (bits_left < (nbits)) { \ + if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \ + { action; } \ + get_buffer = (state).get_buffer; bits_left = (state).bits_left; } } + +#define GET_BITS(nbits) \ + (((int) (get_buffer >> (bits_left -= (nbits)))) & BIT_MASK(nbits)) + +#define PEEK_BITS(nbits) \ + (((int) (get_buffer >> (bits_left - (nbits)))) & BIT_MASK(nbits)) + +#define DROP_BITS(nbits) \ + (bits_left -= (nbits)) + + +/* + * Code for extracting next Huffman-coded symbol from input bit stream. + * Again, this is time-critical and we make the main paths be macros. + * + * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits + * without looping. Usually, more than 95% of the Huffman codes will be 8 + * or fewer bits long. The few overlength codes are handled with a loop, + * which need not be inline code. + * + * Notes about the HUFF_DECODE macro: + * 1. Near the end of the data segment, we may fail to get enough bits + * for a lookahead. In that case, we do it the hard way. + * 2. If the lookahead table contains no entry, the next code must be + * more than HUFF_LOOKAHEAD bits long. + * 3. jpeg_huff_decode returns -1 if forced to suspend. + */ + +#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \ +{ register int nb, look; \ + if (bits_left < HUFF_LOOKAHEAD) { \ + if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \ + get_buffer = state.get_buffer; bits_left = state.bits_left; \ + if (bits_left < HUFF_LOOKAHEAD) { \ + nb = 1; goto slowlabel; \ + } \ + } \ + look = PEEK_BITS(HUFF_LOOKAHEAD); \ + if ((nb = htbl->look_nbits[look]) != 0) { \ + DROP_BITS(nb); \ + result = htbl->look_sym[look]; \ + } else { \ + nb = HUFF_LOOKAHEAD+1; \ +slowlabel: \ + if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ + { failaction; } \ + get_buffer = state.get_buffer; bits_left = state.bits_left; \ + } \ +} + + +/* + * Expanded entropy decoder object for Huffman decoding. + * + * The savable_state subrecord contains fields that change within an MCU, + * but must not be updated permanently until we complete the MCU. + */ + +typedef struct { + unsigned int EOBRUN; /* remaining EOBs in EOBRUN */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ +} savable_state; + +/* This macro is to work around compilers with missing or broken + * structure assignment. You'll need to fix this code if you have + * such a compiler and you change MAX_COMPS_IN_SCAN. + */ + +#ifndef NO_STRUCT_ASSIGN +#define ASSIGN_STATE(dest,src) ((dest) = (src)) +#else +#if MAX_COMPS_IN_SCAN == 4 +#define ASSIGN_STATE(dest,src) \ + ((dest).EOBRUN = (src).EOBRUN, \ + (dest).last_dc_val[0] = (src).last_dc_val[0], \ + (dest).last_dc_val[1] = (src).last_dc_val[1], \ + (dest).last_dc_val[2] = (src).last_dc_val[2], \ + (dest).last_dc_val[3] = (src).last_dc_val[3]) +#endif +#endif + + +typedef struct { + struct jpeg_entropy_decoder pub; /* public fields */ + + /* These fields are loaded into local variables at start of each MCU. + * In case of suspension, we exit WITHOUT updating them. + */ + bitread_perm_state bitstate; /* Bit buffer at start of MCU */ + savable_state saved; /* Other state at start of MCU */ + + /* These fields are NOT loaded into local working state. */ + boolean insufficient_data; /* set TRUE after emitting warning */ + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + + /* Following two fields used only in progressive mode */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + d_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; + + d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */ + + /* Following fields used only in sequential mode */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; + d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; + + /* Precalculated info set up by start_pass for use in decode_mcu: */ + + /* Pointers to derived tables to be used for each block within an MCU */ + d_derived_tbl * dc_cur_tbls[D_MAX_BLOCKS_IN_MCU]; + d_derived_tbl * ac_cur_tbls[D_MAX_BLOCKS_IN_MCU]; + /* Whether we care about the DC and AC coefficient values for each block */ + int coef_limit[D_MAX_BLOCKS_IN_MCU]; +} huff_entropy_decoder; + +typedef huff_entropy_decoder * huff_entropy_ptr; + + +static const int jpeg_zigzag_order[8][8] = { + { 0, 1, 5, 6, 14, 15, 27, 28 }, + { 2, 4, 7, 13, 16, 26, 29, 42 }, + { 3, 8, 12, 17, 25, 30, 41, 43 }, + { 9, 11, 18, 24, 31, 40, 44, 53 }, + { 10, 19, 23, 32, 39, 45, 52, 54 }, + { 20, 22, 33, 38, 46, 51, 55, 60 }, + { 21, 34, 37, 47, 50, 56, 59, 61 }, + { 35, 36, 48, 49, 57, 58, 62, 63 } +}; + +static const int jpeg_zigzag_order7[7][7] = { + { 0, 1, 5, 6, 14, 15, 27 }, + { 2, 4, 7, 13, 16, 26, 28 }, + { 3, 8, 12, 17, 25, 29, 38 }, + { 9, 11, 18, 24, 30, 37, 39 }, + { 10, 19, 23, 31, 36, 40, 45 }, + { 20, 22, 32, 35, 41, 44, 46 }, + { 21, 33, 34, 42, 43, 47, 48 } +}; + +static const int jpeg_zigzag_order6[6][6] = { + { 0, 1, 5, 6, 14, 15 }, + { 2, 4, 7, 13, 16, 25 }, + { 3, 8, 12, 17, 24, 26 }, + { 9, 11, 18, 23, 27, 32 }, + { 10, 19, 22, 28, 31, 33 }, + { 20, 21, 29, 30, 34, 35 } +}; + +static const int jpeg_zigzag_order5[5][5] = { + { 0, 1, 5, 6, 14 }, + { 2, 4, 7, 13, 15 }, + { 3, 8, 12, 16, 21 }, + { 9, 11, 17, 20, 22 }, + { 10, 18, 19, 23, 24 } +}; + +static const int jpeg_zigzag_order4[4][4] = { + { 0, 1, 5, 6 }, + { 2, 4, 7, 12 }, + { 3, 8, 11, 13 }, + { 9, 10, 14, 15 } +}; + +static const int jpeg_zigzag_order3[3][3] = { + { 0, 1, 5 }, + { 2, 4, 6 }, + { 3, 7, 8 } +}; + +static const int jpeg_zigzag_order2[2][2] = { + { 0, 1 }, + { 2, 3 } +}; + + +/* + * Compute the derived values for a Huffman table. + * This routine also performs some validation checks on the table. + */ + +LOCAL(void) +jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno, + d_derived_tbl ** pdtbl) +{ + JHUFF_TBL *htbl; + d_derived_tbl *dtbl; + int p, i, l, si, numsymbols; + int lookbits, ctr; + char huffsize[257]; + unsigned int huffcode[257]; + unsigned int code; + + /* Note that huffsize[] and huffcode[] are filled in code-length order, + * paralleling the order of the symbols themselves in htbl->huffval[]. + */ + + /* Find the input Huffman table */ + if (tblno < 0 || tblno >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); + htbl = + isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; + if (htbl == NULL) + htbl = jpeg_std_huff_table((j_common_ptr) cinfo, isDC, tblno); + + /* Allocate a workspace if we haven't already done so. */ + if (*pdtbl == NULL) + *pdtbl = (d_derived_tbl *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(d_derived_tbl)); + dtbl = *pdtbl; + dtbl->pub = htbl; /* fill in back link */ + + /* Figure C.1: make table of Huffman code length for each symbol */ + + p = 0; + for (l = 1; l <= 16; l++) { + i = (int) htbl->bits[l]; + if (i < 0 || p + i > 256) /* protect against table overrun */ + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + while (i--) + huffsize[p++] = (char) l; + } + huffsize[p] = 0; + numsymbols = p; + + /* Figure C.2: generate the codes themselves */ + /* We also validate that the counts represent a legal Huffman code tree. */ + + code = 0; + si = huffsize[0]; + p = 0; + while (huffsize[p]) { + while (((int) huffsize[p]) == si) { + huffcode[p++] = code; + code++; + } + /* code is now 1 more than the last code used for codelength si; but + * it must still fit in si bits, since no code is allowed to be all ones. + */ + if (((INT32) code) >= (((INT32) 1) << si)) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + code <<= 1; + si++; + } + + /* Figure F.15: generate decoding tables for bit-sequential decoding */ + + p = 0; + for (l = 1; l <= 16; l++) { + if (htbl->bits[l]) { + /* valoffset[l] = huffval[] index of 1st symbol of code length l, + * minus the minimum code of length l + */ + dtbl->valoffset[l] = (INT32) p - (INT32) huffcode[p]; + p += htbl->bits[l]; + dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */ + } else { + dtbl->maxcode[l] = -1; /* -1 if no codes of this length */ + } + } + dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */ + + /* Compute lookahead tables to speed up decoding. + * First we set all the table entries to 0, indicating "too long"; + * then we iterate through the Huffman codes that are short enough and + * fill in all the entries that correspond to bit sequences starting + * with that code. + */ + + MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits)); + + p = 0; + for (l = 1; l <= HUFF_LOOKAHEAD; l++) { + for (i = 1; i <= (int) htbl->bits[l]; i++, p++) { + /* l = current code's length, p = its index in huffcode[] & huffval[]. */ + /* Generate left-justified code followed by all possible bit sequences */ + lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l); + for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) { + dtbl->look_nbits[lookbits] = l; + dtbl->look_sym[lookbits] = htbl->huffval[p]; + lookbits++; + } + } + } + + /* Validate symbols as being reasonable. + * For AC tables, we make no check, but accept all byte values 0..255. + * For DC tables, we require the symbols to be in range 0..15. + * (Tighter bounds could be applied depending on the data depth and mode, + * but this is sufficient to ensure safe decoding.) + */ + if (isDC) { + for (i = 0; i < numsymbols; i++) { + int sym = htbl->huffval[i]; + if (sym < 0 || sym > 15) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + } + } +} + + +/* + * Out-of-line code for bit fetching. + * Note: current values of get_buffer and bits_left are passed as parameters, + * but are returned in the corresponding fields of the state struct. + * + * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width + * of get_buffer to be used. (On machines with wider words, an even larger + * buffer could be used.) However, on some machines 32-bit shifts are + * quite slow and take time proportional to the number of places shifted. + * (This is true with most PC compilers, for instance.) In this case it may + * be a win to set MIN_GET_BITS to the minimum value of 15. This reduces the + * average shift distance at the cost of more calls to jpeg_fill_bit_buffer. + */ + +#ifdef SLOW_SHIFT_32 +#define MIN_GET_BITS 15 /* minimum allowable value */ +#else +#define MIN_GET_BITS (BIT_BUF_SIZE-7) +#endif + + +LOCAL(boolean) +jpeg_fill_bit_buffer (bitread_working_state * state, + register bit_buf_type get_buffer, register int bits_left, + int nbits) +/* Load up the bit buffer to a depth of at least nbits */ +{ + /* Copy heavily used state fields into locals (hopefully registers) */ + register const JOCTET * next_input_byte = state->next_input_byte; + register size_t bytes_in_buffer = state->bytes_in_buffer; + j_decompress_ptr cinfo = state->cinfo; + + /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */ + /* (It is assumed that no request will be for more than that many bits.) */ + /* We fail to do so only if we hit a marker or are forced to suspend. */ + + if (cinfo->unread_marker == 0) { /* cannot advance past a marker */ + while (bits_left < MIN_GET_BITS) { + register int c; + + /* Attempt to read a byte */ + if (bytes_in_buffer == 0) { + if (! (*cinfo->src->fill_input_buffer) (cinfo)) + return FALSE; + next_input_byte = cinfo->src->next_input_byte; + bytes_in_buffer = cinfo->src->bytes_in_buffer; + } + bytes_in_buffer--; + c = GETJOCTET(*next_input_byte++); + + /* If it's 0xFF, check and discard stuffed zero byte */ + if (c == 0xFF) { + /* Loop here to discard any padding FF's on terminating marker, + * so that we can save a valid unread_marker value. NOTE: we will + * accept multiple FF's followed by a 0 as meaning a single FF data + * byte. This data pattern is not valid according to the standard. + */ + do { + if (bytes_in_buffer == 0) { + if (! (*cinfo->src->fill_input_buffer) (cinfo)) + return FALSE; + next_input_byte = cinfo->src->next_input_byte; + bytes_in_buffer = cinfo->src->bytes_in_buffer; + } + bytes_in_buffer--; + c = GETJOCTET(*next_input_byte++); + } while (c == 0xFF); + + if (c == 0) { + /* Found FF/00, which represents an FF data byte */ + c = 0xFF; + } else { + /* Oops, it's actually a marker indicating end of compressed data. + * Save the marker code for later use. + * Fine point: it might appear that we should save the marker into + * bitread working state, not straight into permanent state. But + * once we have hit a marker, we cannot need to suspend within the + * current MCU, because we will read no more bytes from the data + * source. So it is OK to update permanent state right away. + */ + cinfo->unread_marker = c; + /* See if we need to insert some fake zero bits. */ + goto no_more_bytes; + } + } + + /* OK, load c into get_buffer */ + get_buffer = (get_buffer << 8) | c; + bits_left += 8; + } /* end while */ + } else { + no_more_bytes: + /* We get here if we've read the marker that terminates the compressed + * data segment. There should be enough bits in the buffer register + * to satisfy the request; if so, no problem. + */ + if (nbits > bits_left) { + /* Uh-oh. Report corrupted data to user and stuff zeroes into + * the data stream, so that we can produce some kind of image. + * We use a nonvolatile flag to ensure that only one warning message + * appears per data segment. + */ + if (! ((huff_entropy_ptr) cinfo->entropy)->insufficient_data) { + WARNMS(cinfo, JWRN_HIT_MARKER); + ((huff_entropy_ptr) cinfo->entropy)->insufficient_data = TRUE; + } + /* Fill the buffer with zero bits */ + get_buffer <<= MIN_GET_BITS - bits_left; + bits_left = MIN_GET_BITS; + } + } + + /* Unload the local registers */ + state->next_input_byte = next_input_byte; + state->bytes_in_buffer = bytes_in_buffer; + state->get_buffer = get_buffer; + state->bits_left = bits_left; + + return TRUE; +} + + +/* + * Figure F.12: extend sign bit. + * On some machines, a shift and sub will be faster than a table lookup. + */ + +#ifdef AVOID_TABLES + +#define BIT_MASK(nbits) ((1<<(nbits))-1) +#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) - ((1<<(s))-1) : (x)) + +#else + +#define BIT_MASK(nbits) bmask[nbits] +#define HUFF_EXTEND(x,s) ((x) <= bmask[(s) - 1] ? (x) - bmask[s] : (x)) + +static const int bmask[16] = /* bmask[n] is mask for n rightmost bits */ + { 0, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, + 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF }; + +#endif /* AVOID_TABLES */ + + +/* + * Out-of-line code for Huffman code decoding. + */ + +LOCAL(int) +jpeg_huff_decode (bitread_working_state * state, + register bit_buf_type get_buffer, register int bits_left, + d_derived_tbl * htbl, int min_bits) +{ + register int l = min_bits; + register INT32 code; + + /* HUFF_DECODE has determined that the code is at least min_bits */ + /* bits long, so fetch that many bits in one swoop. */ + + CHECK_BIT_BUFFER(*state, l, return -1); + code = GET_BITS(l); + + /* Collect the rest of the Huffman code one bit at a time. */ + /* This is per Figure F.16 in the JPEG spec. */ + + while (code > htbl->maxcode[l]) { + code <<= 1; + CHECK_BIT_BUFFER(*state, 1, return -1); + code |= GET_BITS(1); + l++; + } + + /* Unload the local registers */ + state->get_buffer = get_buffer; + state->bits_left = bits_left; + + /* With garbage input we may reach the sentinel value l = 17. */ + + if (l > 16) { + WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE); + return 0; /* fake a zero as the safest result */ + } + + return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ]; +} + + +/* + * Finish up at the end of a Huffman-compressed scan. + */ + +METHODDEF(void) +finish_pass_huff (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + + /* Throw away any unused bits remaining in bit buffer; */ + /* include any full bytes in next_marker's count of discarded bytes */ + cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; + entropy->bitstate.bits_left = 0; +} + + +/* + * Check for a restart marker & resynchronize decoder. + * Returns FALSE if must suspend. + */ + +LOCAL(boolean) +process_restart (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci; + + finish_pass_huff(cinfo); + + /* Advance past the RSTn marker */ + if (! (*cinfo->marker->read_restart_marker) (cinfo)) + return FALSE; + + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + /* Re-init EOB run count, too */ + entropy->saved.EOBRUN = 0; + + /* Reset restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; + + /* Reset out-of-data flag, unless read_restart_marker left us smack up + * against a marker. In that case we will end up treating the next data + * segment as empty, and we can avoid producing bogus output pixels by + * leaving the flag set. + */ + if (cinfo->unread_marker == 0) + entropy->insufficient_data = FALSE; + + return TRUE; +} + + +/* + * Huffman MCU decoding. + * Each of these routines decodes and returns one MCU's worth of + * Huffman-compressed coefficients. + * The coefficients are reordered from zigzag order into natural array order, + * but are not dequantized. + * + * The i'th block of the MCU is stored into the block pointed to by + * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER. + * (Wholesale zeroing is usually a little faster than retail...) + * + * We return FALSE if data source requested suspension. In that case no + * changes have been made to permanent state. (Exception: some output + * coefficients may already have been assigned. This is harmless for + * spectral selection, since we'll just re-assign them on the next call. + * Successive approximation AC refinement has to be more careful, however.) + */ + +/* + * MCU decoding for DC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int Al = cinfo->Al; + register int s, r; + int blkn, ci; + JBLOCKROW block; + BITREAD_STATE_VARS; + savable_state state; + d_derived_tbl * tbl; + jpeg_component_info * compptr; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, just leave the MCU set to zeroes. + * This way, we return uniform gray for the remainder of the segment. + */ + if (! entropy->insufficient_data) { + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo, entropy->bitstate); + ASSIGN_STATE(state, entropy->saved); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + tbl = entropy->derived_tbls[compptr->dc_tbl_no]; + + /* Decode a single block's worth of coefficients */ + + /* Section F.2.2.1: decode the DC coefficient difference */ + HUFF_DECODE(s, br_state, tbl, return FALSE, label1); + if (s) { + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + } + + /* Convert DC difference to actual value, update last_dc_val */ + s += state.last_dc_val[ci]; + state.last_dc_val[ci] = s; + /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */ + (*block)[0] = (JCOEF) (s << Al); + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo, entropy->bitstate); + ASSIGN_STATE(entropy->saved, state); + } + + /* Account for restart interval if using restarts */ + if (cinfo->restart_interval) + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for AC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + register int s, k, r; + unsigned int EOBRUN; + int Se, Al; + const int * natural_order; + JBLOCKROW block; + BITREAD_STATE_VARS; + d_derived_tbl * tbl; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, just leave the MCU set to zeroes. + * This way, we return uniform gray for the remainder of the segment. + */ + if (! entropy->insufficient_data) { + + /* Load up working state. + * We can avoid loading/saving bitread state if in an EOB run. + */ + EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ + + /* There is always only one block per MCU */ + + if (EOBRUN) /* if it's a band of zeroes... */ + EOBRUN--; /* ...process it now (we do nothing) */ + else { + BITREAD_LOAD_STATE(cinfo, entropy->bitstate); + Se = cinfo->Se; + Al = cinfo->Al; + natural_order = cinfo->natural_order; + block = MCU_data[0]; + tbl = entropy->ac_derived_tbl; + + for (k = cinfo->Ss; k <= Se; k++) { + HUFF_DECODE(s, br_state, tbl, return FALSE, label2); + r = s >> 4; + s &= 15; + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + /* Scale and output coefficient in natural (dezigzagged) order */ + (*block)[natural_order[k]] = (JCOEF) (s << Al); + } else { + if (r != 15) { /* EOBr, run length is 2^r + appended bits */ + if (r) { /* EOBr, r > 0 */ + EOBRUN = 1 << r; + CHECK_BIT_BUFFER(br_state, r, return FALSE); + r = GET_BITS(r); + EOBRUN += r; + EOBRUN--; /* this band is processed at this moment */ + } + break; /* force end-of-band */ + } + k += 15; /* ZRL: skip 15 zeroes in band */ + } + } + + BITREAD_SAVE_STATE(cinfo, entropy->bitstate); + } + + /* Completed MCU, so update state */ + entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ + } + + /* Account for restart interval if using restarts */ + if (cinfo->restart_interval) + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for DC successive approximation refinement scan. + * Note: we assume such scans can be multi-component, + * although the spec is not very clear on the point. + */ + +METHODDEF(boolean) +decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + JCOEF p1; + int blkn; + BITREAD_STATE_VARS; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* Not worth the cycles to check insufficient_data here, + * since we will not change the data anyway if we read zeroes. + */ + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo, entropy->bitstate); + + p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + /* Encoded data is simply the next bit of the two's-complement DC value */ + CHECK_BIT_BUFFER(br_state, 1, return FALSE); + if (GET_BITS(1)) + MCU_data[blkn][0][0] |= p1; + /* Note: since we use |=, repeating the assignment later is safe */ + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo, entropy->bitstate); + + /* Account for restart interval if using restarts */ + if (cinfo->restart_interval) + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for AC successive approximation refinement scan. + */ + +METHODDEF(boolean) +decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + register int s, k, r; + unsigned int EOBRUN; + int Se; + JCOEF p1, m1; + const int * natural_order; + JBLOCKROW block; + JCOEFPTR thiscoef; + BITREAD_STATE_VARS; + d_derived_tbl * tbl; + int num_newnz; + int newnz_pos[DCTSIZE2]; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, don't modify the MCU. + */ + if (! entropy->insufficient_data) { + + Se = cinfo->Se; + p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ + m1 = -p1; /* -1 in the bit position being coded */ + natural_order = cinfo->natural_order; + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo, entropy->bitstate); + EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ + + /* There is always only one block per MCU */ + block = MCU_data[0]; + tbl = entropy->ac_derived_tbl; + + /* If we are forced to suspend, we must undo the assignments to any newly + * nonzero coefficients in the block, because otherwise we'd get confused + * next time about which coefficients were already nonzero. + * But we need not undo addition of bits to already-nonzero coefficients; + * instead, we can test the current bit to see if we already did it. + */ + num_newnz = 0; + + /* initialize coefficient loop counter to start of band */ + k = cinfo->Ss; + + if (EOBRUN == 0) { + do { + HUFF_DECODE(s, br_state, tbl, goto undoit, label3); + r = s >> 4; + s &= 15; + if (s) { + if (s != 1) /* size of new coef should always be 1 */ + WARNMS(cinfo, JWRN_HUFF_BAD_CODE); + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) + s = p1; /* newly nonzero coef is positive */ + else + s = m1; /* newly nonzero coef is negative */ + } else { + if (r != 15) { + EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */ + if (r) { + CHECK_BIT_BUFFER(br_state, r, goto undoit); + r = GET_BITS(r); + EOBRUN += r; + } + break; /* rest of block is handled by EOB logic */ + } + /* note s = 0 for processing ZRL */ + } + /* Advance over already-nonzero coefs and r still-zero coefs, + * appending correction bits to the nonzeroes. A correction bit is 1 + * if the absolute value of the coefficient must be increased. + */ + do { + thiscoef = *block + natural_order[k]; + if (*thiscoef) { + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) { + if ((*thiscoef & p1) == 0) { /* do nothing if already set it */ + if (*thiscoef >= 0) + *thiscoef += p1; + else + *thiscoef += m1; + } + } + } else { + if (--r < 0) + break; /* reached target zero coefficient */ + } + k++; + } while (k <= Se); + if (s) { + int pos = natural_order[k]; + /* Output newly nonzero coefficient */ + (*block)[pos] = (JCOEF) s; + /* Remember its position in case we have to suspend */ + newnz_pos[num_newnz++] = pos; + } + k++; + } while (k <= Se); + } + + if (EOBRUN) { + /* Scan any remaining coefficient positions after the end-of-band + * (the last newly nonzero coefficient, if any). Append a correction + * bit to each already-nonzero coefficient. A correction bit is 1 + * if the absolute value of the coefficient must be increased. + */ + do { + thiscoef = *block + natural_order[k]; + if (*thiscoef) { + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) { + if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */ + if (*thiscoef >= 0) + *thiscoef += p1; + else + *thiscoef += m1; + } + } + } + k++; + } while (k <= Se); + /* Count one block completed in EOB run */ + EOBRUN--; + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo, entropy->bitstate); + entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ + } + + /* Account for restart interval if using restarts */ + if (cinfo->restart_interval) + entropy->restarts_to_go--; + + return TRUE; + +undoit: + /* Re-zero any output coefficients that we made newly nonzero */ + while (num_newnz) + (*block)[newnz_pos[--num_newnz]] = 0; + + return FALSE; +} + + +/* + * Decode one MCU's worth of Huffman-compressed coefficients, + * partial blocks. + */ + +METHODDEF(boolean) +decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + const int * natural_order; + int Se, blkn; + BITREAD_STATE_VARS; + savable_state state; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, just leave the MCU set to zeroes. + * This way, we return uniform gray for the remainder of the segment. + */ + if (! entropy->insufficient_data) { + + natural_order = cinfo->natural_order; + Se = cinfo->lim_Se; + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo, entropy->bitstate); + ASSIGN_STATE(state, entropy->saved); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + JBLOCKROW block = MCU_data[blkn]; + d_derived_tbl * htbl; + register int s, k, r; + int coef_limit, ci; + + /* Decode a single block's worth of coefficients */ + + /* Section F.2.2.1: decode the DC coefficient difference */ + htbl = entropy->dc_cur_tbls[blkn]; + HUFF_DECODE(s, br_state, htbl, return FALSE, label1); + + htbl = entropy->ac_cur_tbls[blkn]; + k = 1; + coef_limit = entropy->coef_limit[blkn]; + if (coef_limit) { + /* Convert DC difference to actual value, update last_dc_val */ + if (s) { + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + } + ci = cinfo->MCU_membership[blkn]; + s += state.last_dc_val[ci]; + state.last_dc_val[ci] = s; + /* Output the DC coefficient */ + (*block)[0] = (JCOEF) s; + + /* Section F.2.2.2: decode the AC coefficients */ + /* Since zeroes are skipped, output area must be cleared beforehand */ + for (; k < coef_limit; k++) { + HUFF_DECODE(s, br_state, htbl, return FALSE, label2); + + r = s >> 4; + s &= 15; + + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + /* Output coefficient in natural (dezigzagged) order. + * Note: the extra entries in natural_order[] will save us + * if k > Se, which could happen if the data is corrupted. + */ + (*block)[natural_order[k]] = (JCOEF) s; + } else { + if (r != 15) + goto EndOfBlock; + k += 15; + } + } + } else { + if (s) { + CHECK_BIT_BUFFER(br_state, s, return FALSE); + DROP_BITS(s); + } + } + + /* Section F.2.2.2: decode the AC coefficients */ + /* In this path we just discard the values */ + for (; k <= Se; k++) { + HUFF_DECODE(s, br_state, htbl, return FALSE, label3); + + r = s >> 4; + s &= 15; + + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + DROP_BITS(s); + } else { + if (r != 15) + break; + k += 15; + } + } + + EndOfBlock: ; + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo, entropy->bitstate); + ASSIGN_STATE(entropy->saved, state); + } + + /* Account for restart interval if using restarts */ + if (cinfo->restart_interval) + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * Decode one MCU's worth of Huffman-compressed coefficients, + * full-size blocks. + */ + +METHODDEF(boolean) +decode_mcu (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int blkn; + BITREAD_STATE_VARS; + savable_state state; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, just leave the MCU set to zeroes. + * This way, we return uniform gray for the remainder of the segment. + */ + if (! entropy->insufficient_data) { + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo, entropy->bitstate); + ASSIGN_STATE(state, entropy->saved); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + JBLOCKROW block = MCU_data[blkn]; + d_derived_tbl * htbl; + register int s, k, r; + int coef_limit, ci; + + /* Decode a single block's worth of coefficients */ + + /* Section F.2.2.1: decode the DC coefficient difference */ + htbl = entropy->dc_cur_tbls[blkn]; + HUFF_DECODE(s, br_state, htbl, return FALSE, label1); + + htbl = entropy->ac_cur_tbls[blkn]; + k = 1; + coef_limit = entropy->coef_limit[blkn]; + if (coef_limit) { + /* Convert DC difference to actual value, update last_dc_val */ + if (s) { + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + } + ci = cinfo->MCU_membership[blkn]; + s += state.last_dc_val[ci]; + state.last_dc_val[ci] = s; + /* Output the DC coefficient */ + (*block)[0] = (JCOEF) s; + + /* Section F.2.2.2: decode the AC coefficients */ + /* Since zeroes are skipped, output area must be cleared beforehand */ + for (; k < coef_limit; k++) { + HUFF_DECODE(s, br_state, htbl, return FALSE, label2); + + r = s >> 4; + s &= 15; + + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + /* Output coefficient in natural (dezigzagged) order. + * Note: the extra entries in jpeg_natural_order[] will save us + * if k >= DCTSIZE2, which could happen if the data is corrupted. + */ + (*block)[jpeg_natural_order[k]] = (JCOEF) s; + } else { + if (r != 15) + goto EndOfBlock; + k += 15; + } + } + } else { + if (s) { + CHECK_BIT_BUFFER(br_state, s, return FALSE); + DROP_BITS(s); + } + } + + /* Section F.2.2.2: decode the AC coefficients */ + /* In this path we just discard the values */ + for (; k < DCTSIZE2; k++) { + HUFF_DECODE(s, br_state, htbl, return FALSE, label3); + + r = s >> 4; + s &= 15; + + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + DROP_BITS(s); + } else { + if (r != 15) + break; + k += 15; + } + } + + EndOfBlock: ; + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo, entropy->bitstate); + ASSIGN_STATE(entropy->saved, state); + } + + /* Account for restart interval if using restarts */ + if (cinfo->restart_interval) + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * Initialize for a Huffman-compressed scan. + */ + +METHODDEF(void) +start_pass_huff_decoder (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, blkn, tbl, i; + jpeg_component_info * compptr; + + if (cinfo->progressive_mode) { + /* Validate progressive scan parameters */ + if (cinfo->Ss == 0) { + if (cinfo->Se != 0) + goto bad; + } else { + /* need not check Ss/Se < 0 since they came from unsigned bytes */ + if (cinfo->Se < cinfo->Ss || cinfo->Se > cinfo->lim_Se) + goto bad; + /* AC scans may have only one component */ + if (cinfo->comps_in_scan != 1) + goto bad; + } + if (cinfo->Ah != 0) { + /* Successive approximation refinement scan: must have Al = Ah-1. */ + if (cinfo->Ah-1 != cinfo->Al) + goto bad; + } + if (cinfo->Al > 13) { /* need not check for < 0 */ + /* Arguably the maximum Al value should be less than 13 for 8-bit + * precision, but the spec doesn't say so, and we try to be liberal + * about what we accept. Note: large Al values could result in + * out-of-range DC coefficients during early scans, leading to bizarre + * displays due to overflows in the IDCT math. But we won't crash. + */ + bad: + ERREXIT4(cinfo, JERR_BAD_PROGRESSION, + cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); + } + /* Update progression status, and verify that scan order is legal. + * Note that inter-scan inconsistencies are treated as warnings + * not fatal errors ... not clear if this is right way to behave. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + int coefi, cindex = cinfo->cur_comp_info[ci]->component_index; + int *coef_bit_ptr = & cinfo->coef_bits[cindex][0]; + if (cinfo->Ss && coef_bit_ptr[0] < 0) /* AC without prior DC scan */ + WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); + for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { + int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; + if (cinfo->Ah != expected) + WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); + coef_bit_ptr[coefi] = cinfo->Al; + } + } + + /* Select MCU decoding routine */ + if (cinfo->Ah == 0) { + if (cinfo->Ss == 0) + entropy->pub.decode_mcu = decode_mcu_DC_first; + else + entropy->pub.decode_mcu = decode_mcu_AC_first; + } else { + if (cinfo->Ss == 0) + entropy->pub.decode_mcu = decode_mcu_DC_refine; + else + entropy->pub.decode_mcu = decode_mcu_AC_refine; + } + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Make sure requested tables are present, and compute derived tables. + * We may build same derived table more than once, but it's not expensive. + */ + if (cinfo->Ss == 0) { + if (cinfo->Ah == 0) { /* DC refinement needs no table */ + tbl = compptr->dc_tbl_no; + jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, + & entropy->derived_tbls[tbl]); + } + } else { + tbl = compptr->ac_tbl_no; + jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, + & entropy->derived_tbls[tbl]); + /* remember the single active table */ + entropy->ac_derived_tbl = entropy->derived_tbls[tbl]; + } + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + + /* Initialize private state variables */ + entropy->saved.EOBRUN = 0; + } else { + /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG. + * This ought to be an error condition, but we make it a warning because + * there are some baseline files out there with all zeroes in these bytes. + */ + if (cinfo->Ss != 0 || cinfo->Ah != 0 || cinfo->Al != 0 || + ((cinfo->is_baseline || cinfo->Se < DCTSIZE2) && + cinfo->Se != cinfo->lim_Se)) + WARNMS(cinfo, JWRN_NOT_SEQUENTIAL); + + /* Select MCU decoding routine */ + /* We retain the hard-coded case for full-size blocks. + * This is not necessary, but it appears that this version is slightly + * more performant in the given implementation. + * With an improved implementation we would prefer a single optimized + * function. + */ + if (cinfo->lim_Se != DCTSIZE2-1) + entropy->pub.decode_mcu = decode_mcu_sub; + else + entropy->pub.decode_mcu = decode_mcu; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Compute derived values for Huffman tables */ + /* We may do this more than once for a table, but it's not expensive */ + tbl = compptr->dc_tbl_no; + jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, + & entropy->dc_derived_tbls[tbl]); + if (cinfo->lim_Se) { /* AC needs no table when not present */ + tbl = compptr->ac_tbl_no; + jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, + & entropy->ac_derived_tbls[tbl]); + } + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + + /* Precalculate decoding info for each block in an MCU of this scan */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + /* Precalculate which table to use for each block */ + entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no]; + entropy->ac_cur_tbls[blkn] = /* AC needs no table when not present */ + cinfo->lim_Se ? entropy->ac_derived_tbls[compptr->ac_tbl_no] : NULL; + /* Decide whether we really care about the coefficient values */ + if (compptr->component_needed) { + ci = compptr->DCT_v_scaled_size; + i = compptr->DCT_h_scaled_size; + switch (cinfo->lim_Se) { + case (1*1-1): + entropy->coef_limit[blkn] = 1; + break; + case (2*2-1): + if (ci <= 0 || ci > 2) ci = 2; + if (i <= 0 || i > 2) i = 2; + entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order2[ci - 1][i - 1]; + break; + case (3*3-1): + if (ci <= 0 || ci > 3) ci = 3; + if (i <= 0 || i > 3) i = 3; + entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order3[ci - 1][i - 1]; + break; + case (4*4-1): + if (ci <= 0 || ci > 4) ci = 4; + if (i <= 0 || i > 4) i = 4; + entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order4[ci - 1][i - 1]; + break; + case (5*5-1): + if (ci <= 0 || ci > 5) ci = 5; + if (i <= 0 || i > 5) i = 5; + entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order5[ci - 1][i - 1]; + break; + case (6*6-1): + if (ci <= 0 || ci > 6) ci = 6; + if (i <= 0 || i > 6) i = 6; + entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order6[ci - 1][i - 1]; + break; + case (7*7-1): + if (ci <= 0 || ci > 7) ci = 7; + if (i <= 0 || i > 7) i = 7; + entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order7[ci - 1][i - 1]; + break; + default: + if (ci <= 0 || ci > 8) ci = 8; + if (i <= 0 || i > 8) i = 8; + entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order[ci - 1][i - 1]; + } + } else { + entropy->coef_limit[blkn] = 0; + } + } + } + + /* Initialize bitread state variables */ + entropy->bitstate.bits_left = 0; + entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ + entropy->insufficient_data = FALSE; + + /* Initialize restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; +} + + +/* + * Module initialization routine for Huffman entropy decoding. + */ + +GLOBAL(void) +jinit_huff_decoder (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy; + int i; + + entropy = (huff_entropy_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(huff_entropy_decoder)); + cinfo->entropy = &entropy->pub; + entropy->pub.start_pass = start_pass_huff_decoder; + entropy->pub.finish_pass = finish_pass_huff; + + if (cinfo->progressive_mode) { + /* Create progression status table */ + int *coef_bit_ptr, ci; + cinfo->coef_bits = (int (*)[DCTSIZE2]) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * DCTSIZE2 * SIZEOF(int)); + coef_bit_ptr = & cinfo->coef_bits[0][0]; + for (ci = 0; ci < cinfo->num_components; ci++) + for (i = 0; i < DCTSIZE2; i++) + *coef_bit_ptr++ = -1; + + /* Mark derived tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->derived_tbls[i] = NULL; + } + } else { + /* Mark derived tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; + } + } +} diff --git a/thirdparty/jpeg-9e/jdinput.c b/thirdparty/jpeg-9e/jdinput.c new file mode 100644 index 0000000..29fbef9 --- /dev/null +++ b/thirdparty/jpeg-9e/jdinput.c @@ -0,0 +1,657 @@ +/* + * jdinput.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 2002-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains input control logic for the JPEG decompressor. + * These routines are concerned with controlling the decompressor's input + * processing (marker reading and coefficient decoding). The actual input + * reading is done in jdmarker.c, jdhuff.c, and jdarith.c. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef struct { + struct jpeg_input_controller pub; /* public fields */ + + int inheaders; /* Nonzero until first SOS is reached */ +} my_input_controller; + +typedef my_input_controller * my_inputctl_ptr; + + +/* Forward declarations */ +METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo)); + + +/* + * Routines to calculate various quantities related to the size of the image. + */ + + +/* + * Compute output image dimensions and related values. + * NOTE: this is exported for possible use by application. + * Hence it mustn't do anything that can't be done twice. + */ + +GLOBAL(void) +jpeg_core_output_dimensions (j_decompress_ptr cinfo) +/* Do computations that are needed before master selection phase. + * This function is used for transcoding and full decompression. + */ +{ +#ifdef IDCT_SCALING_SUPPORTED + int ci; + jpeg_component_info *compptr; + + /* Compute actual output image dimensions and DCT scaling choices. */ + if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom) { + /* Provide 1/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 1; + cinfo->min_DCT_v_scaled_size = 1; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 2) { + /* Provide 2/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 2L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 2L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 2; + cinfo->min_DCT_v_scaled_size = 2; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 3) { + /* Provide 3/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 3L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 3L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 3; + cinfo->min_DCT_v_scaled_size = 3; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 4) { + /* Provide 4/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 4L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 4L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 4; + cinfo->min_DCT_v_scaled_size = 4; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 5) { + /* Provide 5/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 5L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 5L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 5; + cinfo->min_DCT_v_scaled_size = 5; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 6) { + /* Provide 6/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 6L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 6L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 6; + cinfo->min_DCT_v_scaled_size = 6; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 7) { + /* Provide 7/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 7L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 7L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 7; + cinfo->min_DCT_v_scaled_size = 7; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 8) { + /* Provide 8/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 8L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 8L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 8; + cinfo->min_DCT_v_scaled_size = 8; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 9) { + /* Provide 9/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 9L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 9L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 9; + cinfo->min_DCT_v_scaled_size = 9; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 10) { + /* Provide 10/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 10L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 10L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 10; + cinfo->min_DCT_v_scaled_size = 10; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 11) { + /* Provide 11/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 11L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 11L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 11; + cinfo->min_DCT_v_scaled_size = 11; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 12) { + /* Provide 12/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 12L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 12L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 12; + cinfo->min_DCT_v_scaled_size = 12; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 13) { + /* Provide 13/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 13L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 13L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 13; + cinfo->min_DCT_v_scaled_size = 13; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 14) { + /* Provide 14/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 14L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 14L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 14; + cinfo->min_DCT_v_scaled_size = 14; + } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 15) { + /* Provide 15/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 15L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 15L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 15; + cinfo->min_DCT_v_scaled_size = 15; + } else { + /* Provide 16/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * 16L, (long) cinfo->block_size); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * 16L, (long) cinfo->block_size); + cinfo->min_DCT_h_scaled_size = 16; + cinfo->min_DCT_v_scaled_size = 16; + } + + /* Recompute dimensions of components */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size; + compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size; + } + +#else /* !IDCT_SCALING_SUPPORTED */ + + /* Hardwire it to "no scaling" */ + cinfo->output_width = cinfo->image_width; + cinfo->output_height = cinfo->image_height; + /* initial_setup has already initialized DCT_scaled_size, + * and has computed unscaled downsampled_width and downsampled_height. + */ + +#endif /* IDCT_SCALING_SUPPORTED */ +} + + +LOCAL(void) +initial_setup (j_decompress_ptr cinfo) +/* Called once, when first SOS marker is reached */ +{ + int ci; + jpeg_component_info *compptr; + + /* Make sure image isn't bigger than I can handle */ + if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || + (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); + + /* Only 8 to 12 bits data precision are supported for DCT based JPEG */ + if (cinfo->data_precision < 8 || cinfo->data_precision > 12) + ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); + + /* Check that number of components won't exceed internal array sizes */ + if (cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + + /* Compute maximum sampling factors; check factor validity */ + cinfo->max_h_samp_factor = 1; + cinfo->max_v_samp_factor = 1; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || + compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) + ERREXIT(cinfo, JERR_BAD_SAMPLING); + cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, + compptr->h_samp_factor); + cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, + compptr->v_samp_factor); + } + + /* Derive block_size, natural_order, and lim_Se */ + if (cinfo->is_baseline || (cinfo->progressive_mode && + cinfo->comps_in_scan)) { /* no pseudo SOS marker */ + cinfo->block_size = DCTSIZE; + cinfo->natural_order = jpeg_natural_order; + cinfo->lim_Se = DCTSIZE2-1; + } else + switch (cinfo->Se) { + case (1*1-1): + cinfo->block_size = 1; + cinfo->natural_order = jpeg_natural_order; /* not needed */ + cinfo->lim_Se = cinfo->Se; + break; + case (2*2-1): + cinfo->block_size = 2; + cinfo->natural_order = jpeg_natural_order2; + cinfo->lim_Se = cinfo->Se; + break; + case (3*3-1): + cinfo->block_size = 3; + cinfo->natural_order = jpeg_natural_order3; + cinfo->lim_Se = cinfo->Se; + break; + case (4*4-1): + cinfo->block_size = 4; + cinfo->natural_order = jpeg_natural_order4; + cinfo->lim_Se = cinfo->Se; + break; + case (5*5-1): + cinfo->block_size = 5; + cinfo->natural_order = jpeg_natural_order5; + cinfo->lim_Se = cinfo->Se; + break; + case (6*6-1): + cinfo->block_size = 6; + cinfo->natural_order = jpeg_natural_order6; + cinfo->lim_Se = cinfo->Se; + break; + case (7*7-1): + cinfo->block_size = 7; + cinfo->natural_order = jpeg_natural_order7; + cinfo->lim_Se = cinfo->Se; + break; + case (8*8-1): + cinfo->block_size = 8; + cinfo->natural_order = jpeg_natural_order; + cinfo->lim_Se = DCTSIZE2-1; + break; + case (9*9-1): + cinfo->block_size = 9; + cinfo->natural_order = jpeg_natural_order; + cinfo->lim_Se = DCTSIZE2-1; + break; + case (10*10-1): + cinfo->block_size = 10; + cinfo->natural_order = jpeg_natural_order; + cinfo->lim_Se = DCTSIZE2-1; + break; + case (11*11-1): + cinfo->block_size = 11; + cinfo->natural_order = jpeg_natural_order; + cinfo->lim_Se = DCTSIZE2-1; + break; + case (12*12-1): + cinfo->block_size = 12; + cinfo->natural_order = jpeg_natural_order; + cinfo->lim_Se = DCTSIZE2-1; + break; + case (13*13-1): + cinfo->block_size = 13; + cinfo->natural_order = jpeg_natural_order; + cinfo->lim_Se = DCTSIZE2-1; + break; + case (14*14-1): + cinfo->block_size = 14; + cinfo->natural_order = jpeg_natural_order; + cinfo->lim_Se = DCTSIZE2-1; + break; + case (15*15-1): + cinfo->block_size = 15; + cinfo->natural_order = jpeg_natural_order; + cinfo->lim_Se = DCTSIZE2-1; + break; + case (16*16-1): + cinfo->block_size = 16; + cinfo->natural_order = jpeg_natural_order; + cinfo->lim_Se = DCTSIZE2-1; + break; + default: + ERREXIT4(cinfo, JERR_BAD_PROGRESSION, + cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); + } + + /* We initialize DCT_scaled_size and min_DCT_scaled_size to block_size. + * In the full decompressor, + * this will be overridden by jpeg_calc_output_dimensions in jdmaster.c; + * but in the transcoder, + * jpeg_calc_output_dimensions is not used, so we must do it here. + */ + cinfo->min_DCT_h_scaled_size = cinfo->block_size; + cinfo->min_DCT_v_scaled_size = cinfo->block_size; + + /* Compute dimensions of components */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + compptr->DCT_h_scaled_size = cinfo->block_size; + compptr->DCT_v_scaled_size = cinfo->block_size; + /* Size in DCT blocks */ + compptr->width_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) (cinfo->max_h_samp_factor * cinfo->block_size)); + compptr->height_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) (cinfo->max_v_samp_factor * cinfo->block_size)); + /* downsampled_width and downsampled_height will also be overridden by + * jdmaster.c if we are doing full decompression. The transcoder library + * doesn't use these values, but the calling application might. + */ + /* Size in samples */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) cinfo->max_h_samp_factor); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) cinfo->max_v_samp_factor); + /* Mark component needed, until color conversion says otherwise */ + compptr->component_needed = TRUE; + /* Mark no quantization table yet saved for component */ + compptr->quant_table = NULL; + } + + /* Compute number of fully interleaved MCU rows. */ + cinfo->total_iMCU_rows = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor * cinfo->block_size)); + + /* Decide whether file contains multiple scans */ + if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode) + cinfo->inputctl->has_multiple_scans = TRUE; + else + cinfo->inputctl->has_multiple_scans = FALSE; +} + + +LOCAL(void) +per_scan_setup (j_decompress_ptr cinfo) +/* Do computations that are needed before processing a JPEG scan */ +/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */ +{ + int ci, mcublks, tmp; + jpeg_component_info *compptr; + + if (cinfo->comps_in_scan == 1) { + + /* Noninterleaved (single-component) scan */ + compptr = cinfo->cur_comp_info[0]; + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = compptr->width_in_blocks; + cinfo->MCU_rows_in_scan = compptr->height_in_blocks; + + /* For noninterleaved scan, always one block per MCU */ + compptr->MCU_width = 1; + compptr->MCU_height = 1; + compptr->MCU_blocks = 1; + compptr->MCU_sample_width = compptr->DCT_h_scaled_size; + compptr->last_col_width = 1; + /* For noninterleaved scans, it is convenient to define last_row_height + * as the number of block rows present in the last iMCU row. + */ + tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (tmp == 0) tmp = compptr->v_samp_factor; + compptr->last_row_height = tmp; + + /* Prepare array describing MCU composition */ + cinfo->blocks_in_MCU = 1; + cinfo->MCU_membership[0] = 0; + + } else { + + /* Interleaved (multi-component) scan */ + if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, + MAX_COMPS_IN_SCAN); + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, + (long) (cinfo->max_h_samp_factor * cinfo->block_size)); + cinfo->MCU_rows_in_scan = cinfo->total_iMCU_rows; + + cinfo->blocks_in_MCU = 0; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Sampling factors give # of blocks of component in each MCU */ + compptr->MCU_width = compptr->h_samp_factor; + compptr->MCU_height = compptr->v_samp_factor; + compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; + compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_h_scaled_size; + /* Figure number of non-dummy blocks in last MCU column & row */ + tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); + if (tmp == 0) tmp = compptr->MCU_width; + compptr->last_col_width = tmp; + tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); + if (tmp == 0) tmp = compptr->MCU_height; + compptr->last_row_height = tmp; + /* Prepare array describing MCU composition */ + mcublks = compptr->MCU_blocks; + if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU) + ERREXIT(cinfo, JERR_BAD_MCU_SIZE); + while (mcublks-- > 0) { + cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; + } + } + + } +} + + +/* + * Save away a copy of the Q-table referenced by each component present + * in the current scan, unless already saved during a prior scan. + * + * In a multiple-scan JPEG file, the encoder could assign different components + * the same Q-table slot number, but change table definitions between scans + * so that each component uses a different Q-table. (The IJG encoder is not + * currently capable of doing this, but other encoders might.) Since we want + * to be able to dequantize all the components at the end of the file, this + * means that we have to save away the table actually used for each component. + * We do this by copying the table at the start of the first scan containing + * the component. + * The JPEG spec prohibits the encoder from changing the contents of a Q-table + * slot between scans of a component using that slot. If the encoder does so + * anyway, this decoder will simply use the Q-table values that were current + * at the start of the first scan for the component. + * + * The decompressor output side looks only at the saved quant tables, + * not at the current Q-table slots. + */ + +LOCAL(void) +latch_quant_tables (j_decompress_ptr cinfo) +{ + int ci, qtblno; + jpeg_component_info *compptr; + JQUANT_TBL * qtbl; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* No work if we already saved Q-table for this component */ + if (compptr->quant_table != NULL) + continue; + /* Make sure specified quantization table is present */ + qtblno = compptr->quant_tbl_no; + if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || + cinfo->quant_tbl_ptrs[qtblno] == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); + /* OK, save away the quantization table */ + qtbl = (JQUANT_TBL *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(JQUANT_TBL)); + MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL)); + compptr->quant_table = qtbl; + } +} + + +/* + * Initialize the input modules to read a scan of compressed data. + * The first call to this is done by jdmaster.c after initializing + * the entire decompressor (during jpeg_start_decompress). + * Subsequent calls come from consume_markers, below. + */ + +METHODDEF(void) +start_input_pass (j_decompress_ptr cinfo) +{ + per_scan_setup(cinfo); + latch_quant_tables(cinfo); + (*cinfo->entropy->start_pass) (cinfo); + (*cinfo->coef->start_input_pass) (cinfo); + cinfo->inputctl->consume_input = cinfo->coef->consume_data; +} + + +/* + * Finish up after inputting a compressed-data scan. + * This is called by the coefficient controller after it's read all + * the expected data of the scan. + */ + +METHODDEF(void) +finish_input_pass (j_decompress_ptr cinfo) +{ + (*cinfo->entropy->finish_pass) (cinfo); + cinfo->inputctl->consume_input = consume_markers; +} + + +/* + * Read JPEG markers before, between, or after compressed-data scans. + * Change state as necessary when a new scan is reached. + * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + * + * The consume_input method pointer points either here or to the + * coefficient controller's consume_data routine, depending on whether + * we are reading a compressed data segment or inter-segment markers. + * + * Note: This function should NOT return a pseudo SOS marker (with zero + * component number) to the caller. A pseudo marker received by + * read_markers is processed and then skipped for other markers. + */ + +METHODDEF(int) +consume_markers (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; + int val; + + if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */ + return JPEG_REACHED_EOI; + + for (;;) { /* Loop to pass pseudo SOS marker */ + val = (*cinfo->marker->read_markers) (cinfo); + + switch (val) { + case JPEG_REACHED_SOS: /* Found SOS */ + if (inputctl->inheaders) { /* 1st SOS */ + if (inputctl->inheaders == 1) + initial_setup(cinfo); + if (cinfo->comps_in_scan == 0) { /* pseudo SOS marker */ + inputctl->inheaders = 2; + break; + } + inputctl->inheaders = 0; + /* Note: start_input_pass must be called by jdmaster.c + * before any more input can be consumed. jdapimin.c is + * responsible for enforcing this sequencing. + */ + } else { /* 2nd or later SOS marker */ + if (! inputctl->pub.has_multiple_scans) + ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */ + if (cinfo->comps_in_scan == 0) /* unexpected pseudo SOS marker */ + break; + start_input_pass(cinfo); + } + return val; + case JPEG_REACHED_EOI: /* Found EOI */ + inputctl->pub.eoi_reached = TRUE; + if (inputctl->inheaders) { /* Tables-only datastream, apparently */ + if (cinfo->marker->saw_SOF) + ERREXIT(cinfo, JERR_SOF_NO_SOS); + } else { + /* Prevent infinite loop in coef ctlr's decompress_data routine + * if user set output_scan_number larger than number of scans. + */ + if (cinfo->output_scan_number > cinfo->input_scan_number) + cinfo->output_scan_number = cinfo->input_scan_number; + } + return val; + case JPEG_SUSPENDED: + return val; + default: + return val; + } + } +} + + +/* + * Reset state to begin a fresh datastream. + */ + +METHODDEF(void) +reset_input_controller (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; + + inputctl->pub.consume_input = consume_markers; + inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ + inputctl->pub.eoi_reached = FALSE; + inputctl->inheaders = 1; + /* Reset other modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->marker->reset_marker_reader) (cinfo); + /* Reset progression state -- would be cleaner if entropy decoder did this */ + cinfo->coef_bits = NULL; +} + + +/* + * Initialize the input controller module. + * This is called only once, when the decompression object is created. + */ + +GLOBAL(void) +jinit_input_controller (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl; + + /* Create subobject in permanent pool */ + inputctl = (my_inputctl_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_input_controller)); + cinfo->inputctl = &inputctl->pub; + /* Initialize method pointers */ + inputctl->pub.consume_input = consume_markers; + inputctl->pub.reset_input_controller = reset_input_controller; + inputctl->pub.start_input_pass = start_input_pass; + inputctl->pub.finish_input_pass = finish_input_pass; + /* Initialize state: can't use reset_input_controller since we don't + * want to try to reset other modules yet. + */ + inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ + inputctl->pub.eoi_reached = FALSE; + inputctl->inheaders = 1; +} diff --git a/thirdparty/jpeg-9e/jdmainct.c b/thirdparty/jpeg-9e/jdmainct.c new file mode 100644 index 0000000..1cd66d8 --- /dev/null +++ b/thirdparty/jpeg-9e/jdmainct.c @@ -0,0 +1,511 @@ +/* + * jdmainct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2002-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the main buffer controller for decompression. + * The main buffer lies between the JPEG decompressor proper and the + * post-processor; it holds downsampled data in the JPEG colorspace. + * + * Note that this code is bypassed in raw-data mode, since the application + * supplies the equivalent of the main buffer in that case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * In the current system design, the main buffer need never be a full-image + * buffer; any full-height buffers will be found inside the coefficient or + * postprocessing controllers. Nonetheless, the main controller is not + * trivial. Its responsibility is to provide context rows for upsampling/ + * rescaling, and doing this in an efficient fashion is a bit tricky. + * + * Postprocessor input data is counted in "row groups". A row group is + * defined to be (v_samp_factor * DCT_v_scaled_size / min_DCT_v_scaled_size) + * sample rows of each component. (We require DCT_scaled_size values to be + * chosen such that these numbers are integers. In practice DCT_scaled_size + * values will likely be powers of two, so we actually have the stronger + * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.) + * Upsampling will typically produce max_v_samp_factor pixel rows from each + * row group (times any additional scale factor that the upsampler is + * applying). + * + * The coefficient controller will deliver data to us one iMCU row at a time; + * each iMCU row contains v_samp_factor * DCT_v_scaled_size sample rows, or + * exactly min_DCT_v_scaled_size row groups. (This amount of data corresponds + * to one row of MCUs when the image is fully interleaved.) Note that the + * number of sample rows varies across components, but the number of row + * groups does not. Some garbage sample rows may be included in the last iMCU + * row at the bottom of the image. + * + * Depending on the vertical scaling algorithm used, the upsampler may need + * access to the sample row(s) above and below its current input row group. + * The upsampler is required to set need_context_rows TRUE at global selection + * time if so. When need_context_rows is FALSE, this controller can simply + * obtain one iMCU row at a time from the coefficient controller and dole it + * out as row groups to the postprocessor. + * + * When need_context_rows is TRUE, this controller guarantees that the buffer + * passed to postprocessing contains at least one row group's worth of samples + * above and below the row group(s) being processed. Note that the context + * rows "above" the first passed row group appear at negative row offsets in + * the passed buffer. At the top and bottom of the image, the required + * context rows are manufactured by duplicating the first or last real sample + * row; this avoids having special cases in the upsampling inner loops. + * + * The amount of context is fixed at one row group just because that's a + * convenient number for this controller to work with. The existing + * upsamplers really only need one sample row of context. An upsampler + * supporting arbitrary output rescaling might wish for more than one row + * group of context when shrinking the image; tough, we don't handle that. + * (This is justified by the assumption that downsizing will be handled mostly + * by adjusting the DCT_scaled_size values, so that the actual scale factor at + * the upsample step needn't be much less than one.) + * + * To provide the desired context, we have to retain the last two row groups + * of one iMCU row while reading in the next iMCU row. (The last row group + * can't be processed until we have another row group for its below-context, + * and so we have to save the next-to-last group too for its above-context.) + * We could do this most simply by copying data around in our buffer, but + * that'd be very slow. We can avoid copying any data by creating a rather + * strange pointer structure. Here's how it works. We allocate a workspace + * consisting of M+2 row groups (where M = min_DCT_v_scaled_size is the number + * of row groups per iMCU row). We create two sets of redundant pointers to + * the workspace. Labeling the physical row groups 0 to M+1, the synthesized + * pointer lists look like this: + * M+1 M-1 + * master pointer --> 0 master pointer --> 0 + * 1 1 + * ... ... + * M-3 M-3 + * M-2 M + * M-1 M+1 + * M M-2 + * M+1 M-1 + * 0 0 + * We read alternate iMCU rows using each master pointer; thus the last two + * row groups of the previous iMCU row remain un-overwritten in the workspace. + * The pointer lists are set up so that the required context rows appear to + * be adjacent to the proper places when we pass the pointer lists to the + * upsampler. + * + * The above pictures describe the normal state of the pointer lists. + * At top and bottom of the image, we diddle the pointer lists to duplicate + * the first or last sample row as necessary (this is cheaper than copying + * sample rows around). + * + * This scheme breaks down if M < 2, ie, min_DCT_v_scaled_size is 1. In that + * situation each iMCU row provides only one row group so the buffering logic + * must be different (eg, we must read two iMCU rows before we can emit the + * first row group). For now, we simply do not support providing context + * rows when min_DCT_v_scaled_size is 1. That combination seems unlikely to + * be worth providing --- if someone wants a 1/8th-size preview, they probably + * want it quick and dirty, so a context-free upsampler is sufficient. + */ + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_main_controller pub; /* public fields */ + + /* Pointer to allocated workspace (M or M+2 row groups). */ + JSAMPARRAY buffer[MAX_COMPONENTS]; + + JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */ + JDIMENSION rowgroups_avail; /* row groups available to postprocessor */ + + /* Remaining fields are only used in the context case. */ + + boolean buffer_full; /* Have we gotten an iMCU row from decoder? */ + + /* These are the master pointers to the funny-order pointer lists. */ + JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */ + + int whichptr; /* indicates which pointer set is now in use */ + int context_state; /* process_data state machine status */ + JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ +} my_main_controller; + +typedef my_main_controller * my_main_ptr; + +/* context_state values: */ +#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */ +#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */ +#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */ + + +/* Forward declarations */ +METHODDEF(void) process_data_simple_main + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +METHODDEF(void) process_data_context_main + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +#ifdef QUANT_2PASS_SUPPORTED +METHODDEF(void) process_data_crank_post + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +#endif + + +LOCAL(void) +alloc_funny_pointers (j_decompress_ptr cinfo) +/* Allocate space for the funny pointer lists. + * This is done only once, not once per pass. + */ +{ + my_main_ptr mainp = (my_main_ptr) cinfo->main; + int ci, rgroup; + int M = cinfo->min_DCT_v_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY xbuf; + + /* Get top-level space for component array pointers. + * We alloc both arrays with one call to save a few cycles. + */ + mainp->xbuffer[0] = (JSAMPIMAGE) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); + mainp->xbuffer[1] = mainp->xbuffer[0] + cinfo->num_components; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (! compptr->component_needed) + continue; /* skip uninteresting component */ + rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) / + cinfo->min_DCT_v_scaled_size; /* height of a row group of component */ + /* Get space for pointer lists --- M+4 row groups in each list. + * We alloc both pointer lists with one call to save a few cycles. + */ + xbuf = (JSAMPARRAY) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, + JPOOL_IMAGE, 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); + xbuf += rgroup; /* want one row group at negative offsets */ + mainp->xbuffer[0][ci] = xbuf; + xbuf += rgroup * (M + 4); + mainp->xbuffer[1][ci] = xbuf; + } +} + + +LOCAL(void) +make_funny_pointers (j_decompress_ptr cinfo) +/* Create the funny pointer lists discussed in the comments above. + * The actual workspace is already allocated (in mainp->buffer), + * and the space for the pointer lists is allocated too. + * This routine just fills in the curiously ordered lists. + * This will be repeated at the beginning of each pass. + */ +{ + my_main_ptr mainp = (my_main_ptr) cinfo->main; + int ci, i, rgroup; + int M = cinfo->min_DCT_v_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY buf, xbuf0, xbuf1; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (! compptr->component_needed) + continue; /* skip uninteresting component */ + rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) / + cinfo->min_DCT_v_scaled_size; /* height of a row group of component */ + xbuf0 = mainp->xbuffer[0][ci]; + xbuf1 = mainp->xbuffer[1][ci]; + /* First copy the workspace pointers as-is */ + buf = mainp->buffer[ci]; + for (i = 0; i < rgroup * (M + 2); i++) { + xbuf0[i] = xbuf1[i] = buf[i]; + } + /* In the second list, put the last four row groups in swapped order */ + for (i = 0; i < rgroup * 2; i++) { + xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i]; + xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i]; + } + /* The wraparound pointers at top and bottom will be filled later + * (see set_wraparound_pointers, below). Initially we want the "above" + * pointers to duplicate the first actual data line. This only needs + * to happen in xbuffer[0]. + */ + for (i = 0; i < rgroup; i++) { + xbuf0[i - rgroup] = xbuf0[0]; + } + } +} + + +LOCAL(void) +set_wraparound_pointers (j_decompress_ptr cinfo) +/* Set up the "wraparound" pointers at top and bottom of the pointer lists. + * This changes the pointer list state from top-of-image to the normal state. + */ +{ + my_main_ptr mainp = (my_main_ptr) cinfo->main; + int ci, i, rgroup; + int M = cinfo->min_DCT_v_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY xbuf0, xbuf1; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (! compptr->component_needed) + continue; /* skip uninteresting component */ + rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) / + cinfo->min_DCT_v_scaled_size; /* height of a row group of component */ + xbuf0 = mainp->xbuffer[0][ci]; + xbuf1 = mainp->xbuffer[1][ci]; + for (i = 0; i < rgroup; i++) { + xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; + xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; + xbuf0[rgroup*(M+2) + i] = xbuf0[i]; + xbuf1[rgroup*(M+2) + i] = xbuf1[i]; + } + } +} + + +LOCAL(void) +set_bottom_pointers (j_decompress_ptr cinfo) +/* Change the pointer lists to duplicate the last sample row at the bottom + * of the image. whichptr indicates which xbuffer holds the final iMCU row. + * Also sets rowgroups_avail to indicate number of nondummy row groups in row. + */ +{ + my_main_ptr mainp = (my_main_ptr) cinfo->main; + int ci, i, rgroup, iMCUheight, rows_left; + jpeg_component_info *compptr; + JSAMPARRAY xbuf; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (! compptr->component_needed) + continue; /* skip uninteresting component */ + /* Count sample rows in one iMCU row and in one row group */ + iMCUheight = compptr->v_samp_factor * compptr->DCT_v_scaled_size; + rgroup = iMCUheight / cinfo->min_DCT_v_scaled_size; + /* Count nondummy sample rows remaining for this component */ + rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); + if (rows_left == 0) rows_left = iMCUheight; + /* Count nondummy row groups. Should get same answer for each component, + * so we need only do it once. + */ + if (ci == 0) { + mainp->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); + } + /* Duplicate the last real sample row rgroup*2 times; this pads out the + * last partial rowgroup and ensures at least one full rowgroup of context. + */ + xbuf = mainp->xbuffer[mainp->whichptr][ci]; + for (i = 0; i < rgroup * 2; i++) { + xbuf[rows_left + i] = xbuf[rows_left-1]; + } + } +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_main_ptr mainp = (my_main_ptr) cinfo->main; + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (cinfo->upsample->need_context_rows) { + mainp->pub.process_data = process_data_context_main; + make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ + mainp->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ + mainp->context_state = CTX_PREPARE_FOR_IMCU; + mainp->iMCU_row_ctr = 0; + mainp->buffer_full = FALSE; /* Mark buffer empty */ + } else { + /* Simple case with no context needed */ + mainp->pub.process_data = process_data_simple_main; + mainp->rowgroup_ctr = mainp->rowgroups_avail; /* Mark buffer empty */ + } + break; +#ifdef QUANT_2PASS_SUPPORTED + case JBUF_CRANK_DEST: + /* For last pass of 2-pass quantization, just crank the postprocessor */ + mainp->pub.process_data = process_data_crank_post; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + } +} + + +/* + * Process some data. + * This handles the simple case where no context is required. + */ + +METHODDEF(void) +process_data_simple_main (j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail) +{ + my_main_ptr mainp = (my_main_ptr) cinfo->main; + + /* Read input data if we haven't filled the main buffer yet */ + if (mainp->rowgroup_ctr >= mainp->rowgroups_avail) { + if (! (*cinfo->coef->decompress_data) (cinfo, mainp->buffer)) + return; /* suspension forced, can do nothing more */ + mainp->rowgroup_ctr = 0; /* OK, we have an iMCU row to work with */ + } + + /* Note: at the bottom of the image, we may pass extra garbage row groups + * to the postprocessor. The postprocessor has to check for bottom + * of image anyway (at row resolution), so no point in us doing it too. + */ + + /* Feed the postprocessor */ + (*cinfo->post->post_process_data) (cinfo, mainp->buffer, + &mainp->rowgroup_ctr, mainp->rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); +} + + +/* + * Process some data. + * This handles the case where context rows must be provided. + */ + +METHODDEF(void) +process_data_context_main (j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail) +{ + my_main_ptr mainp = (my_main_ptr) cinfo->main; + + /* Read input data if we haven't filled the main buffer yet */ + if (! mainp->buffer_full) { + if (! (*cinfo->coef->decompress_data) (cinfo, + mainp->xbuffer[mainp->whichptr])) + return; /* suspension forced, can do nothing more */ + mainp->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ + mainp->iMCU_row_ctr++; /* count rows received */ + } + + /* Postprocessor typically will not swallow all the input data it is handed + * in one call (due to filling the output buffer first). Must be prepared + * to exit and restart. This switch lets us keep track of how far we got. + * Note that each case falls through to the next on successful completion. + */ + switch (mainp->context_state) { + case CTX_POSTPONED_ROW: + /* Call postprocessor using previously set pointers for postponed row */ + (*cinfo->post->post_process_data) (cinfo, mainp->xbuffer[mainp->whichptr], + &mainp->rowgroup_ctr, mainp->rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); + if (mainp->rowgroup_ctr < mainp->rowgroups_avail) + return; /* Need to suspend */ + mainp->context_state = CTX_PREPARE_FOR_IMCU; + if (*out_row_ctr >= out_rows_avail) + return; /* Postprocessor exactly filled output buf */ + /*FALLTHROUGH*/ + case CTX_PREPARE_FOR_IMCU: + /* Prepare to process first M-1 row groups of this iMCU row */ + mainp->rowgroup_ctr = 0; + mainp->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size - 1); + /* Check for bottom of image: if so, tweak pointers to "duplicate" + * the last sample row, and adjust rowgroups_avail to ignore padding rows. + */ + if (mainp->iMCU_row_ctr == cinfo->total_iMCU_rows) + set_bottom_pointers(cinfo); + mainp->context_state = CTX_PROCESS_IMCU; + /*FALLTHROUGH*/ + case CTX_PROCESS_IMCU: + /* Call postprocessor using previously set pointers */ + (*cinfo->post->post_process_data) (cinfo, mainp->xbuffer[mainp->whichptr], + &mainp->rowgroup_ctr, mainp->rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); + if (mainp->rowgroup_ctr < mainp->rowgroups_avail) + return; /* Need to suspend */ + /* After the first iMCU, change wraparound pointers to normal state */ + if (mainp->iMCU_row_ctr == 1) + set_wraparound_pointers(cinfo); + /* Prepare to load new iMCU row using other xbuffer list */ + mainp->whichptr ^= 1; /* 0=>1 or 1=>0 */ + mainp->buffer_full = FALSE; + /* Still need to process last row group of this iMCU row, */ + /* which is saved at index M+1 of the other xbuffer */ + mainp->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 1); + mainp->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 2); + mainp->context_state = CTX_POSTPONED_ROW; + } +} + + +/* + * Process some data. + * Final pass of two-pass quantization: just call the postprocessor. + * Source data will be the postprocessor controller's internal buffer. + */ + +#ifdef QUANT_2PASS_SUPPORTED + +METHODDEF(void) +process_data_crank_post (j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail) +{ + (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, + (JDIMENSION *) NULL, (JDIMENSION) 0, + output_buf, out_row_ctr, out_rows_avail); +} + +#endif /* QUANT_2PASS_SUPPORTED */ + + +/* + * Initialize main buffer controller. + */ + +GLOBAL(void) +jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_main_ptr mainp; + int ci, rgroup, ngroups; + jpeg_component_info *compptr; + + mainp = (my_main_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_main_controller)); + cinfo->main = &mainp->pub; + mainp->pub.start_pass = start_pass_main; + + if (need_full_buffer) /* shouldn't happen */ + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + /* Allocate the workspace. + * ngroups is the number of row groups we need. + */ + if (cinfo->upsample->need_context_rows) { + if (cinfo->min_DCT_v_scaled_size < 2) /* unsupported, see comments above */ + ERREXIT(cinfo, JERR_NOTIMPL); + alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ + ngroups = cinfo->min_DCT_v_scaled_size + 2; + } else { + /* There are always min_DCT_v_scaled_size row groups in an iMCU row. */ + ngroups = cinfo->min_DCT_v_scaled_size; + mainp->rowgroups_avail = (JDIMENSION) ngroups; + } + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (! compptr->component_needed) + continue; /* skip uninteresting component */ + rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) / + cinfo->min_DCT_v_scaled_size; /* height of a row group of component */ + mainp->buffer[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size), + (JDIMENSION) (rgroup * ngroups)); + } +} diff --git a/thirdparty/jpeg-9e/jdmarker.c b/thirdparty/jpeg-9e/jdmarker.c new file mode 100644 index 0000000..c10fde6 --- /dev/null +++ b/thirdparty/jpeg-9e/jdmarker.c @@ -0,0 +1,1505 @@ +/* + * jdmarker.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * Modified 2009-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to decode JPEG datastream markers. + * Most of the complexity arises from our desire to support input + * suspension: if not all of the data for a marker is available, + * we must exit back to the application. On resumption, we reprocess + * the marker. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +typedef enum { /* JPEG marker codes */ + M_SOF0 = 0xc0, + M_SOF1 = 0xc1, + M_SOF2 = 0xc2, + M_SOF3 = 0xc3, + + M_SOF5 = 0xc5, + M_SOF6 = 0xc6, + M_SOF7 = 0xc7, + + M_JPG = 0xc8, + M_SOF9 = 0xc9, + M_SOF10 = 0xca, + M_SOF11 = 0xcb, + + M_SOF13 = 0xcd, + M_SOF14 = 0xce, + M_SOF15 = 0xcf, + + M_DHT = 0xc4, + + M_DAC = 0xcc, + + M_RST0 = 0xd0, + M_RST1 = 0xd1, + M_RST2 = 0xd2, + M_RST3 = 0xd3, + M_RST4 = 0xd4, + M_RST5 = 0xd5, + M_RST6 = 0xd6, + M_RST7 = 0xd7, + + M_SOI = 0xd8, + M_EOI = 0xd9, + M_SOS = 0xda, + M_DQT = 0xdb, + M_DNL = 0xdc, + M_DRI = 0xdd, + M_DHP = 0xde, + M_EXP = 0xdf, + + M_APP0 = 0xe0, + M_APP1 = 0xe1, + M_APP2 = 0xe2, + M_APP3 = 0xe3, + M_APP4 = 0xe4, + M_APP5 = 0xe5, + M_APP6 = 0xe6, + M_APP7 = 0xe7, + M_APP8 = 0xe8, + M_APP9 = 0xe9, + M_APP10 = 0xea, + M_APP11 = 0xeb, + M_APP12 = 0xec, + M_APP13 = 0xed, + M_APP14 = 0xee, + M_APP15 = 0xef, + + M_JPG0 = 0xf0, + M_JPG8 = 0xf8, + M_JPG13 = 0xfd, + M_COM = 0xfe, + + M_TEM = 0x01, + + M_ERROR = 0x100 +} JPEG_MARKER; + + +/* Private state */ + +typedef struct { + struct jpeg_marker_reader pub; /* public fields */ + + /* Application-overridable marker processing methods */ + jpeg_marker_parser_method process_COM; + jpeg_marker_parser_method process_APPn[16]; + + /* Limit on marker data length to save for each marker type */ + unsigned int length_limit_COM; + unsigned int length_limit_APPn[16]; + + /* Status of COM/APPn marker saving */ + jpeg_saved_marker_ptr cur_marker; /* NULL if not processing a marker */ + unsigned int bytes_read; /* data bytes read so far in marker */ + /* Note: cur_marker is not linked into marker_list until it's all read. */ +} my_marker_reader; + +typedef my_marker_reader * my_marker_ptr; + + +/* + * Macros for fetching data from the data source module. + * + * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect + * the current restart point; we update them only when we have reached a + * suitable place to restart if a suspension occurs. + */ + +/* Declare and initialize local copies of input pointer/count */ +#define INPUT_VARS(cinfo) \ + struct jpeg_source_mgr * datasrc = (cinfo)->src; \ + const JOCTET * next_input_byte = datasrc->next_input_byte; \ + size_t bytes_in_buffer = datasrc->bytes_in_buffer + +/* Unload the local copies --- do this only at a restart boundary */ +#define INPUT_SYNC(cinfo) \ + ( datasrc->next_input_byte = next_input_byte, \ + datasrc->bytes_in_buffer = bytes_in_buffer ) + +/* Reload the local copies --- used only in MAKE_BYTE_AVAIL */ +#define INPUT_RELOAD(cinfo) \ + ( next_input_byte = datasrc->next_input_byte, \ + bytes_in_buffer = datasrc->bytes_in_buffer ) + +/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available. + * Note we do *not* do INPUT_SYNC before calling fill_input_buffer, + * but we must reload the local copies after a successful fill. + */ +#define MAKE_BYTE_AVAIL(cinfo,action) \ + if (bytes_in_buffer == 0) { \ + if (! (*datasrc->fill_input_buffer) (cinfo)) \ + { action; } \ + INPUT_RELOAD(cinfo); \ + } + +/* Read a byte into variable V. + * If must suspend, take the specified action (typically "return FALSE"). + */ +#define INPUT_BYTE(cinfo,V,action) \ + MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ + bytes_in_buffer--; \ + V = GETJOCTET(*next_input_byte++); ) + +/* As above, but read two bytes interpreted as an unsigned 16-bit integer. + * V should be declared unsigned int or perhaps INT32. + */ +#define INPUT_2BYTES(cinfo,V,action) \ + MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ + bytes_in_buffer--; \ + V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \ + MAKE_BYTE_AVAIL(cinfo,action); \ + bytes_in_buffer--; \ + V += GETJOCTET(*next_input_byte++); ) + + +/* + * Routines to process JPEG markers. + * + * Entry condition: JPEG marker itself has been read and its code saved + * in cinfo->unread_marker; input restart point is just after the marker. + * + * Exit: if return TRUE, have read and processed any parameters, and have + * updated the restart point to point after the parameters. + * If return FALSE, was forced to suspend before reaching end of + * marker parameters; restart point has not been moved. Same routine + * will be called again after application supplies more input data. + * + * This approach to suspension assumes that all of a marker's parameters + * can fit into a single input bufferload. This should hold for "normal" + * markers. Some COM/APPn markers might have large parameter segments + * that might not fit. If we are simply dropping such a marker, we use + * skip_input_data to get past it, and thereby put the problem on the + * source manager's shoulders. If we are saving the marker's contents + * into memory, we use a slightly different convention: when forced to + * suspend, the marker processor updates the restart point to the end of + * what it's consumed (ie, the end of the buffer) before returning FALSE. + * On resumption, cinfo->unread_marker still contains the marker code, + * but the data source will point to the next chunk of marker data. + * The marker processor must retain internal state to deal with this. + * + * Note that we don't bother to avoid duplicate trace messages if a + * suspension occurs within marker parameters. Other side effects + * require more care. + */ + + +LOCAL(boolean) +get_soi (j_decompress_ptr cinfo) +/* Process an SOI marker */ +{ + int i; + + TRACEMS(cinfo, 1, JTRC_SOI); + + if (cinfo->marker->saw_SOI) + ERREXIT(cinfo, JERR_SOI_DUPLICATE); + + /* Reset all parameters that are defined to be reset by SOI */ + + for (i = 0; i < NUM_ARITH_TBLS; i++) { + cinfo->arith_dc_L[i] = 0; + cinfo->arith_dc_U[i] = 1; + cinfo->arith_ac_K[i] = 5; + } + cinfo->restart_interval = 0; + + /* Set initial assumptions for colorspace etc */ + + cinfo->jpeg_color_space = JCS_UNKNOWN; + cinfo->color_transform = JCT_NONE; + cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */ + + cinfo->saw_JFIF_marker = FALSE; + cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */ + cinfo->JFIF_minor_version = 1; + cinfo->density_unit = 0; + cinfo->X_density = 1; + cinfo->Y_density = 1; + cinfo->saw_Adobe_marker = FALSE; + cinfo->Adobe_transform = 0; + + cinfo->marker->saw_SOI = TRUE; + + return TRUE; +} + + +LOCAL(boolean) +get_sof (j_decompress_ptr cinfo, boolean is_baseline, boolean is_prog, + boolean is_arith) +/* Process a SOFn marker */ +{ + INT32 length; + int c, ci, i; + jpeg_component_info * compptr; + INPUT_VARS(cinfo); + + cinfo->is_baseline = is_baseline; + cinfo->progressive_mode = is_prog; + cinfo->arith_code = is_arith; + + INPUT_2BYTES(cinfo, length, return FALSE); + + INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE); + INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE); + INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE); + INPUT_BYTE(cinfo, cinfo->num_components, return FALSE); + + length -= 8; + + TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker, + (int) cinfo->image_width, (int) cinfo->image_height, + cinfo->num_components); + + if (cinfo->marker->saw_SOF) + ERREXIT(cinfo, JERR_SOF_DUPLICATE); + + /* We don't support files in which the image height is initially specified */ + /* as 0 and is later redefined by DNL. As long as we have to check that, */ + /* might as well have a general sanity check. */ + if (cinfo->image_height <= 0 || cinfo->image_width <= 0 || + cinfo->num_components <= 0) + ERREXIT(cinfo, JERR_EMPTY_IMAGE); + + if (length != (cinfo->num_components * 3)) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + if (cinfo->comp_info == NULL) /* do only once, even if suspend */ + cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * SIZEOF(jpeg_component_info)); + + for (ci = 0; ci < cinfo->num_components; ci++) { + INPUT_BYTE(cinfo, c, return FALSE); + /* Check to see whether component id has already been seen */ + /* (in violation of the spec, but unfortunately seen in some */ + /* files). If so, create "fake" component id equal to the */ + /* max id seen so far + 1. */ + for (i = 0, compptr = cinfo->comp_info; i < ci; i++, compptr++) { + if (c == compptr->component_id) { + compptr = cinfo->comp_info; + c = compptr->component_id; + compptr++; + for (i = 1; i < ci; i++, compptr++) { + if (compptr->component_id > c) c = compptr->component_id; + } + c++; + break; + } + } + compptr->component_id = c; + compptr->component_index = ci; + INPUT_BYTE(cinfo, c, return FALSE); + compptr->h_samp_factor = (c >> 4) & 15; + compptr->v_samp_factor = (c ) & 15; + INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE); + + TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT, + compptr->component_id, compptr->h_samp_factor, + compptr->v_samp_factor, compptr->quant_tbl_no); + } + + cinfo->marker->saw_SOF = TRUE; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_sos (j_decompress_ptr cinfo) +/* Process a SOS marker */ +{ + INT32 length; + int c, ci, i, n; + jpeg_component_info * compptr; + INPUT_VARS(cinfo); + + if (! cinfo->marker->saw_SOF) + ERREXITS(cinfo, JERR_SOF_BEFORE, "SOS"); + + INPUT_2BYTES(cinfo, length, return FALSE); + + INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */ + + TRACEMS1(cinfo, 1, JTRC_SOS, n); + + if (length != (n * 2 + 6) || n > MAX_COMPS_IN_SCAN || + (n == 0 && !cinfo->progressive_mode)) + /* pseudo SOS marker only allowed in progressive mode */ + ERREXIT(cinfo, JERR_BAD_LENGTH); + + cinfo->comps_in_scan = n; + + /* Collect the component-spec parameters */ + + for (i = 0; i < n; i++) { + INPUT_BYTE(cinfo, c, return FALSE); + + /* Detect the case where component id's are not unique, and, if so, */ + /* create a fake component id using the same logic as in get_sof. */ + /* Note: This also ensures that all of the SOF components are */ + /* referenced in the single scan case, which prevents access to */ + /* uninitialized memory in later decoding stages. */ + for (ci = 0; ci < i; ci++) { + if (c == cinfo->cur_comp_info[ci]->component_id) { + c = cinfo->cur_comp_info[0]->component_id; + for (ci = 1; ci < i; ci++) { + compptr = cinfo->cur_comp_info[ci]; + if (compptr->component_id > c) c = compptr->component_id; + } + c++; + break; + } + } + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (c == compptr->component_id) + goto id_found; + } + + ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, c); + + id_found: + + cinfo->cur_comp_info[i] = compptr; + INPUT_BYTE(cinfo, c, return FALSE); + compptr->dc_tbl_no = (c >> 4) & 15; + compptr->ac_tbl_no = (c ) & 15; + + TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, compptr->component_id, + compptr->dc_tbl_no, compptr->ac_tbl_no); + } + + /* Collect the additional scan parameters Ss, Se, Ah/Al. */ + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Ss = c; + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Se = c; + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Ah = (c >> 4) & 15; + cinfo->Al = (c ) & 15; + + TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se, + cinfo->Ah, cinfo->Al); + + /* Prepare to scan data & restart markers */ + cinfo->marker->next_restart_num = 0; + + /* Count another (non-pseudo) SOS marker */ + if (n) cinfo->input_scan_number++; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +#ifdef D_ARITH_CODING_SUPPORTED + +LOCAL(boolean) +get_dac (j_decompress_ptr cinfo) +/* Process a DAC marker */ +{ + INT32 length; + int index, val; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 0) { + INPUT_BYTE(cinfo, index, return FALSE); + INPUT_BYTE(cinfo, val, return FALSE); + + length -= 2; + + TRACEMS2(cinfo, 1, JTRC_DAC, index, val); + + if (index < 0 || index >= (2*NUM_ARITH_TBLS)) + ERREXIT1(cinfo, JERR_DAC_INDEX, index); + + if (index >= NUM_ARITH_TBLS) { /* define AC table */ + cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val; + } else { /* define DC table */ + cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F); + cinfo->arith_dc_U[index] = (UINT8) (val >> 4); + if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index]) + ERREXIT1(cinfo, JERR_DAC_VALUE, val); + } + } + + if (length != 0) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_SYNC(cinfo); + return TRUE; +} + +#else /* ! D_ARITH_CODING_SUPPORTED */ + +#define get_dac(cinfo) skip_variable(cinfo) + +#endif /* D_ARITH_CODING_SUPPORTED */ + + +LOCAL(boolean) +get_dht (j_decompress_ptr cinfo) +/* Process a DHT marker */ +{ + INT32 length; + UINT8 bits[17]; + UINT8 huffval[256]; + int i, index, count; + JHUFF_TBL **htblptr; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 16) { + INPUT_BYTE(cinfo, index, return FALSE); + + TRACEMS1(cinfo, 1, JTRC_DHT, index); + + bits[0] = 0; + count = 0; + for (i = 1; i <= 16; i++) { + INPUT_BYTE(cinfo, bits[i], return FALSE); + count += bits[i]; + } + + length -= 1 + 16; + + TRACEMS8(cinfo, 2, JTRC_HUFFBITS, + bits[1], bits[2], bits[3], bits[4], + bits[5], bits[6], bits[7], bits[8]); + TRACEMS8(cinfo, 2, JTRC_HUFFBITS, + bits[9], bits[10], bits[11], bits[12], + bits[13], bits[14], bits[15], bits[16]); + + /* Here we just do minimal validation of the counts to avoid walking + * off the end of our table space. jdhuff.c will check more carefully. + */ + if (count > 256 || ((INT32) count) > length) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + + for (i = 0; i < count; i++) + INPUT_BYTE(cinfo, huffval[i], return FALSE); + + length -= count; + + if (index & 0x10) { /* AC table definition */ + index -= 0x10; + htblptr = &cinfo->ac_huff_tbl_ptrs[index]; + } else { /* DC table definition */ + htblptr = &cinfo->dc_huff_tbl_ptrs[index]; + } + + if (index < 0 || index >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_DHT_INDEX, index); + + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + + MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); + if (count > 0) + MEMCOPY((*htblptr)->huffval, huffval, count * SIZEOF(UINT8)); + } + + if (length != 0) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_dqt (j_decompress_ptr cinfo) +/* Process a DQT marker */ +{ + INT32 length, count, i; + int n, prec; + unsigned int tmp; + JQUANT_TBL *quant_ptr; + const int *natural_order; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 0) { + length--; + INPUT_BYTE(cinfo, n, return FALSE); + prec = n >> 4; + n &= 0x0F; + + TRACEMS2(cinfo, 1, JTRC_DQT, n, prec); + + if (n >= NUM_QUANT_TBLS) + ERREXIT1(cinfo, JERR_DQT_INDEX, n); + + if (cinfo->quant_tbl_ptrs[n] == NULL) + cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo); + quant_ptr = cinfo->quant_tbl_ptrs[n]; + + if (prec) { + if (length < DCTSIZE2 * 2) { + /* Initialize full table for safety. */ + for (i = 0; i < DCTSIZE2; i++) { + quant_ptr->quantval[i] = 1; + } + count = length >> 1; + } else + count = DCTSIZE2; + } else { + if (length < DCTSIZE2) { + /* Initialize full table for safety. */ + for (i = 0; i < DCTSIZE2; i++) { + quant_ptr->quantval[i] = 1; + } + count = length; + } else + count = DCTSIZE2; + } + + switch ((int) count) { + case (2*2): natural_order = jpeg_natural_order2; break; + case (3*3): natural_order = jpeg_natural_order3; break; + case (4*4): natural_order = jpeg_natural_order4; break; + case (5*5): natural_order = jpeg_natural_order5; break; + case (6*6): natural_order = jpeg_natural_order6; break; + case (7*7): natural_order = jpeg_natural_order7; break; + default: natural_order = jpeg_natural_order; + } + + for (i = 0; i < count; i++) { + if (prec) + INPUT_2BYTES(cinfo, tmp, return FALSE); + else + INPUT_BYTE(cinfo, tmp, return FALSE); + /* We convert the zigzag-order table to natural array order. */ + quant_ptr->quantval[natural_order[i]] = (UINT16) tmp; + } + + if (cinfo->err->trace_level >= 2) { + for (i = 0; i < DCTSIZE2; i += 8) { + TRACEMS8(cinfo, 2, JTRC_QUANTVALS, + quant_ptr->quantval[i], quant_ptr->quantval[i+1], + quant_ptr->quantval[i+2], quant_ptr->quantval[i+3], + quant_ptr->quantval[i+4], quant_ptr->quantval[i+5], + quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]); + } + } + + length -= count; + if (prec) length -= count; + } + + if (length != 0) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_dri (j_decompress_ptr cinfo) +/* Process a DRI marker */ +{ + INT32 length; + unsigned int tmp; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + + if (length != 4) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_2BYTES(cinfo, tmp, return FALSE); + + TRACEMS1(cinfo, 1, JTRC_DRI, tmp); + + cinfo->restart_interval = tmp; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_lse (j_decompress_ptr cinfo) +/* Process an LSE marker */ +{ + INT32 length; + unsigned int tmp; + int cid; + INPUT_VARS(cinfo); + + if (! cinfo->marker->saw_SOF) + ERREXITS(cinfo, JERR_SOF_BEFORE, "LSE"); + + if (cinfo->num_components < 3) goto bad; + + INPUT_2BYTES(cinfo, length, return FALSE); + + if (length != 24) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_BYTE(cinfo, tmp, return FALSE); + if (tmp != 0x0D) /* ID inverse transform specification */ + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); + INPUT_2BYTES(cinfo, tmp, return FALSE); + if (tmp != MAXJSAMPLE) goto bad; /* MAXTRANS */ + INPUT_BYTE(cinfo, tmp, return FALSE); + if (tmp != 3) goto bad; /* Nt=3 */ + INPUT_BYTE(cinfo, cid, return FALSE); + if (cid != cinfo->comp_info[1].component_id) goto bad; + INPUT_BYTE(cinfo, cid, return FALSE); + if (cid != cinfo->comp_info[0].component_id) goto bad; + INPUT_BYTE(cinfo, cid, return FALSE); + if (cid != cinfo->comp_info[2].component_id) goto bad; + INPUT_BYTE(cinfo, tmp, return FALSE); + if (tmp != 0x80) goto bad; /* F1: CENTER1=1, NORM1=0 */ + INPUT_2BYTES(cinfo, tmp, return FALSE); + if (tmp != 0) goto bad; /* A(1,1)=0 */ + INPUT_2BYTES(cinfo, tmp, return FALSE); + if (tmp != 0) goto bad; /* A(1,2)=0 */ + INPUT_BYTE(cinfo, tmp, return FALSE); + if (tmp != 0) goto bad; /* F2: CENTER2=0, NORM2=0 */ + INPUT_2BYTES(cinfo, tmp, return FALSE); + if (tmp != 1) goto bad; /* A(2,1)=1 */ + INPUT_2BYTES(cinfo, tmp, return FALSE); + if (tmp != 0) goto bad; /* A(2,2)=0 */ + INPUT_BYTE(cinfo, tmp, return FALSE); + if (tmp != 0) goto bad; /* F3: CENTER3=0, NORM3=0 */ + INPUT_2BYTES(cinfo, tmp, return FALSE); + if (tmp != 1) goto bad; /* A(3,1)=1 */ + INPUT_2BYTES(cinfo, tmp, return FALSE); + if (tmp != 0) { /* A(3,2)=0 */ + bad: + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + } + + /* OK, valid transform that we can handle. */ + cinfo->color_transform = JCT_SUBTRACT_GREEN; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +/* + * Routines for processing APPn and COM markers. + * These are either saved in memory or discarded, per application request. + * APP0 and APP14 are specially checked to see if they are + * JFIF and Adobe markers, respectively. + */ + +#define APP0_DATA_LEN 14 /* Length of interesting data in APP0 */ +#define APP14_DATA_LEN 12 /* Length of interesting data in APP14 */ +#define APPN_DATA_LEN 14 /* Must be the largest of the above!! */ + + +LOCAL(void) +examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data, + unsigned int datalen, INT32 remaining) +/* Examine first few bytes from an APP0. + * Take appropriate action if it is a JFIF marker. + * datalen is # of bytes at data[], remaining is length of rest of marker data. + */ +{ + INT32 totallen = (INT32) datalen + remaining; + + if (datalen >= APP0_DATA_LEN && + GETJOCTET(data[0]) == 0x4A && + GETJOCTET(data[1]) == 0x46 && + GETJOCTET(data[2]) == 0x49 && + GETJOCTET(data[3]) == 0x46 && + GETJOCTET(data[4]) == 0) { + /* Found JFIF APP0 marker: save info */ + cinfo->saw_JFIF_marker = TRUE; + cinfo->JFIF_major_version = GETJOCTET(data[5]); + cinfo->JFIF_minor_version = GETJOCTET(data[6]); + cinfo->density_unit = GETJOCTET(data[7]); + cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]); + cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]); + /* Check version. + * Major version must be 1 or 2, anything else signals an incompatible + * change. + * (We used to treat this as an error, but now it's a nonfatal warning, + * because some bozo at Hijaak couldn't read the spec.) + * Minor version should be 0..2, but process anyway if newer. + */ + if (cinfo->JFIF_major_version != 1 && cinfo->JFIF_major_version != 2) + WARNMS2(cinfo, JWRN_JFIF_MAJOR, + cinfo->JFIF_major_version, cinfo->JFIF_minor_version); + /* Generate trace messages */ + TRACEMS5(cinfo, 1, JTRC_JFIF, + cinfo->JFIF_major_version, cinfo->JFIF_minor_version, + cinfo->X_density, cinfo->Y_density, cinfo->density_unit); + /* Validate thumbnail dimensions and issue appropriate messages */ + if (GETJOCTET(data[12]) | GETJOCTET(data[13])) + TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, + GETJOCTET(data[12]), GETJOCTET(data[13])); + totallen -= APP0_DATA_LEN; + if (totallen != + ((INT32)GETJOCTET(data[12]) * (INT32)GETJOCTET(data[13]) * (INT32) 3)) + TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen); + } else if (datalen >= 6 && + GETJOCTET(data[0]) == 0x4A && + GETJOCTET(data[1]) == 0x46 && + GETJOCTET(data[2]) == 0x58 && + GETJOCTET(data[3]) == 0x58 && + GETJOCTET(data[4]) == 0) { + /* Found JFIF "JFXX" extension APP0 marker */ + /* The library doesn't actually do anything with these, + * but we try to produce a helpful trace message. + */ + switch (GETJOCTET(data[5])) { + case 0x10: + TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen); + break; + case 0x11: + TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen); + break; + case 0x13: + TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen); + break; + default: + TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, + GETJOCTET(data[5]), (int) totallen); + } + } else { + /* Start of APP0 does not match "JFIF" or "JFXX", or too short */ + TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen); + } +} + + +LOCAL(void) +examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data, + unsigned int datalen, INT32 remaining) +/* Examine first few bytes from an APP14. + * Take appropriate action if it is an Adobe marker. + * datalen is # of bytes at data[], remaining is length of rest of marker data. + */ +{ + unsigned int version, flags0, flags1, transform; + + if (datalen >= APP14_DATA_LEN && + GETJOCTET(data[0]) == 0x41 && + GETJOCTET(data[1]) == 0x64 && + GETJOCTET(data[2]) == 0x6F && + GETJOCTET(data[3]) == 0x62 && + GETJOCTET(data[4]) == 0x65) { + /* Found Adobe APP14 marker */ + version = (GETJOCTET(data[5]) << 8) + GETJOCTET(data[6]); + flags0 = (GETJOCTET(data[7]) << 8) + GETJOCTET(data[8]); + flags1 = (GETJOCTET(data[9]) << 8) + GETJOCTET(data[10]); + transform = GETJOCTET(data[11]); + TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform); + cinfo->saw_Adobe_marker = TRUE; + cinfo->Adobe_transform = (UINT8) transform; + } else { + /* Start of APP14 does not match "Adobe", or too short */ + TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining)); + } +} + + +METHODDEF(boolean) +get_interesting_appn (j_decompress_ptr cinfo) +/* Process an APP0 or APP14 marker without saving it */ +{ + INT32 length; + JOCTET b[APPN_DATA_LEN]; + unsigned int i, numtoread; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + /* get the interesting part of the marker data */ + if (length >= APPN_DATA_LEN) + numtoread = APPN_DATA_LEN; + else if (length > 0) + numtoread = (unsigned int) length; + else + numtoread = 0; + for (i = 0; i < numtoread; i++) + INPUT_BYTE(cinfo, b[i], return FALSE); + length -= numtoread; + + /* process it */ + switch (cinfo->unread_marker) { + case M_APP0: + examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length); + break; + case M_APP14: + examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length); + break; + default: + /* can't get here unless jpeg_save_markers chooses wrong processor */ + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); + } + + /* skip any remaining data -- could be lots */ + INPUT_SYNC(cinfo); + if (length > 0) + (*cinfo->src->skip_input_data) (cinfo, (long) length); + + return TRUE; +} + + +#ifdef SAVE_MARKERS_SUPPORTED + +METHODDEF(boolean) +save_marker (j_decompress_ptr cinfo) +/* Save an APPn or COM marker into the marker list */ +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + jpeg_saved_marker_ptr cur_marker = marker->cur_marker; + unsigned int bytes_read, data_length; + JOCTET FAR * data; + INT32 length = 0; + INPUT_VARS(cinfo); + + if (cur_marker == NULL) { + /* begin reading a marker */ + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + if (length >= 0) { /* watch out for bogus length word */ + /* figure out how much we want to save */ + unsigned int limit; + if (cinfo->unread_marker == (int) M_COM) + limit = marker->length_limit_COM; + else + limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0]; + if ((unsigned int) length < limit) + limit = (unsigned int) length; + /* allocate and initialize the marker item */ + cur_marker = (jpeg_saved_marker_ptr) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(struct jpeg_marker_struct) + limit); + cur_marker->next = NULL; + cur_marker->marker = (UINT8) cinfo->unread_marker; + cur_marker->original_length = (unsigned int) length; + cur_marker->data_length = limit; + /* data area is just beyond the jpeg_marker_struct */ + data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1); + marker->cur_marker = cur_marker; + marker->bytes_read = 0; + bytes_read = 0; + data_length = limit; + } else { + /* deal with bogus length word */ + bytes_read = data_length = 0; + data = NULL; + } + } else { + /* resume reading a marker */ + bytes_read = marker->bytes_read; + data_length = cur_marker->data_length; + data = cur_marker->data + bytes_read; + } + + while (bytes_read < data_length) { + INPUT_SYNC(cinfo); /* move the restart point to here */ + marker->bytes_read = bytes_read; + /* If there's not at least one byte in buffer, suspend */ + MAKE_BYTE_AVAIL(cinfo, return FALSE); + /* Copy bytes with reasonable rapidity */ + while (bytes_read < data_length && bytes_in_buffer > 0) { + *data++ = *next_input_byte++; + bytes_in_buffer--; + bytes_read++; + } + } + + /* Done reading what we want to read */ + if (cur_marker != NULL) { /* will be NULL if bogus length word */ + /* Add new marker to end of list */ + if (cinfo->marker_list == NULL) { + cinfo->marker_list = cur_marker; + } else { + jpeg_saved_marker_ptr prev = cinfo->marker_list; + while (prev->next != NULL) + prev = prev->next; + prev->next = cur_marker; + } + /* Reset pointer & calc remaining data length */ + data = cur_marker->data; + length = cur_marker->original_length - data_length; + } + /* Reset to initial state for next marker */ + marker->cur_marker = NULL; + + /* Process the marker if interesting; else just make a generic trace msg */ + switch (cinfo->unread_marker) { + case M_APP0: + examine_app0(cinfo, data, data_length, length); + break; + case M_APP14: + examine_app14(cinfo, data, data_length, length); + break; + default: + TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, + (int) (data_length + length)); + } + + /* skip any remaining data -- could be lots */ + INPUT_SYNC(cinfo); /* do before skip_input_data */ + if (length > 0) + (*cinfo->src->skip_input_data) (cinfo, (long) length); + + return TRUE; +} + +#endif /* SAVE_MARKERS_SUPPORTED */ + + +METHODDEF(boolean) +skip_variable (j_decompress_ptr cinfo) +/* Skip over an unknown or uninteresting variable-length marker */ +{ + INT32 length; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length); + + INPUT_SYNC(cinfo); /* do before skip_input_data */ + if (length > 0) + (*cinfo->src->skip_input_data) (cinfo, (long) length); + + return TRUE; +} + + +/* + * Find the next JPEG marker, save it in cinfo->unread_marker. + * Returns FALSE if had to suspend before reaching a marker; + * in that case cinfo->unread_marker is unchanged. + * + * Note that the result might not be a valid marker code, + * but it will never be 0 or FF. + */ + +LOCAL(boolean) +next_marker (j_decompress_ptr cinfo) +{ + int c; + INPUT_VARS(cinfo); + + for (;;) { + INPUT_BYTE(cinfo, c, return FALSE); + /* Skip any non-FF bytes. + * This may look a bit inefficient, but it will not occur in a valid file. + * We sync after each discarded byte so that a suspending data source + * can discard the byte from its buffer. + */ + while (c != 0xFF) { + cinfo->marker->discarded_bytes++; + INPUT_SYNC(cinfo); + INPUT_BYTE(cinfo, c, return FALSE); + } + /* This loop swallows any duplicate FF bytes. Extra FFs are legal as + * pad bytes, so don't count them in discarded_bytes. We assume there + * will not be so many consecutive FF bytes as to overflow a suspending + * data source's input buffer. + */ + do { + INPUT_BYTE(cinfo, c, return FALSE); + } while (c == 0xFF); + if (c != 0) + break; /* found a valid marker, exit loop */ + /* Reach here if we found a stuffed-zero data sequence (FF/00). + * Discard it and loop back to try again. + */ + cinfo->marker->discarded_bytes += 2; + INPUT_SYNC(cinfo); + } + + if (cinfo->marker->discarded_bytes != 0) { + WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c); + cinfo->marker->discarded_bytes = 0; + } + + cinfo->unread_marker = c; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +first_marker (j_decompress_ptr cinfo) +/* Like next_marker, but used to obtain the initial SOI marker. */ +/* For this marker, we do not allow preceding garbage or fill; otherwise, + * we might well scan an entire input file before realizing it ain't JPEG. + * If an application wants to process non-JFIF files, it must seek to the + * SOI before calling the JPEG library. + */ +{ + int c, c2; + INPUT_VARS(cinfo); + + INPUT_BYTE(cinfo, c, return FALSE); + INPUT_BYTE(cinfo, c2, return FALSE); + if (c != 0xFF || c2 != (int) M_SOI) + ERREXIT2(cinfo, JERR_NO_SOI, c, c2); + + cinfo->unread_marker = c2; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +/* + * Read markers until SOS or EOI. + * + * Returns same codes as are defined for jpeg_consume_input: + * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + * + * Note: This function may return a pseudo SOS marker (with zero + * component number) for treat by input controller's consume_input. + * consume_input itself should filter out (skip) the pseudo marker + * after processing for the caller. + */ + +METHODDEF(int) +read_markers (j_decompress_ptr cinfo) +{ + /* Outer loop repeats once for each marker. */ + for (;;) { + /* Collect the marker proper, unless we already did. */ + /* NB: first_marker() enforces the requirement that SOI appear first. */ + if (cinfo->unread_marker == 0) { + if (! cinfo->marker->saw_SOI) { + if (! first_marker(cinfo)) + return JPEG_SUSPENDED; + } else { + if (! next_marker(cinfo)) + return JPEG_SUSPENDED; + } + } + /* At this point cinfo->unread_marker contains the marker code and the + * input point is just past the marker proper, but before any parameters. + * A suspension will cause us to return with this state still true. + */ + switch (cinfo->unread_marker) { + case M_SOI: + if (! get_soi(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_SOF0: /* Baseline */ + if (! get_sof(cinfo, TRUE, FALSE, FALSE)) + return JPEG_SUSPENDED; + break; + + case M_SOF1: /* Extended sequential, Huffman */ + if (! get_sof(cinfo, FALSE, FALSE, FALSE)) + return JPEG_SUSPENDED; + break; + + case M_SOF2: /* Progressive, Huffman */ + if (! get_sof(cinfo, FALSE, TRUE, FALSE)) + return JPEG_SUSPENDED; + break; + + case M_SOF9: /* Extended sequential, arithmetic */ + if (! get_sof(cinfo, FALSE, FALSE, TRUE)) + return JPEG_SUSPENDED; + break; + + case M_SOF10: /* Progressive, arithmetic */ + if (! get_sof(cinfo, FALSE, TRUE, TRUE)) + return JPEG_SUSPENDED; + break; + + /* Currently unsupported SOFn types */ + case M_SOF3: /* Lossless, Huffman */ + case M_SOF5: /* Differential sequential, Huffman */ + case M_SOF6: /* Differential progressive, Huffman */ + case M_SOF7: /* Differential lossless, Huffman */ + case M_JPG: /* Reserved for JPEG extensions */ + case M_SOF11: /* Lossless, arithmetic */ + case M_SOF13: /* Differential sequential, arithmetic */ + case M_SOF14: /* Differential progressive, arithmetic */ + case M_SOF15: /* Differential lossless, arithmetic */ + ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker); + break; + + case M_SOS: + if (! get_sos(cinfo)) + return JPEG_SUSPENDED; + cinfo->unread_marker = 0; /* processed the marker */ + return JPEG_REACHED_SOS; + + case M_EOI: + TRACEMS(cinfo, 1, JTRC_EOI); + cinfo->unread_marker = 0; /* processed the marker */ + return JPEG_REACHED_EOI; + + case M_DAC: + if (! get_dac(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DHT: + if (! get_dht(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DQT: + if (! get_dqt(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DRI: + if (! get_dri(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_JPG8: + if (! get_lse(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_APP0: + case M_APP1: + case M_APP2: + case M_APP3: + case M_APP4: + case M_APP5: + case M_APP6: + case M_APP7: + case M_APP8: + case M_APP9: + case M_APP10: + case M_APP11: + case M_APP12: + case M_APP13: + case M_APP14: + case M_APP15: + if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[ + cinfo->unread_marker - (int) M_APP0]) (cinfo)) + return JPEG_SUSPENDED; + break; + + case M_COM: + if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo)) + return JPEG_SUSPENDED; + break; + + case M_RST0: /* these are all parameterless */ + case M_RST1: + case M_RST2: + case M_RST3: + case M_RST4: + case M_RST5: + case M_RST6: + case M_RST7: + case M_TEM: + TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker); + break; + + case M_DNL: /* Ignore DNL ... perhaps the wrong thing */ + if (! skip_variable(cinfo)) + return JPEG_SUSPENDED; + break; + + default: /* must be DHP, EXP, JPGn, or RESn */ + /* For now, we treat the reserved markers as fatal errors since they are + * likely to be used to signal incompatible JPEG Part 3 extensions. + * Once the JPEG 3 version-number marker is well defined, this code + * ought to change! + */ + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); + } + /* Successfully processed marker, so reset state variable */ + cinfo->unread_marker = 0; + } /* end loop */ +} + + +/* + * Read a restart marker, which is expected to appear next in the datastream; + * if the marker is not there, take appropriate recovery action. + * Returns FALSE if suspension is required. + * + * This is called by the entropy decoder after it has read an appropriate + * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder + * has already read a marker from the data source. Under normal conditions + * cinfo->unread_marker will be reset to 0 before returning; if not reset, + * it holds a marker which the decoder will be unable to read past. + */ + +METHODDEF(boolean) +read_restart_marker (j_decompress_ptr cinfo) +{ + /* Obtain a marker unless we already did. */ + /* Note that next_marker will complain if it skips any data. */ + if (cinfo->unread_marker == 0) { + if (! next_marker(cinfo)) + return FALSE; + } + + if (cinfo->unread_marker == + ((int) M_RST0 + cinfo->marker->next_restart_num)) { + /* Normal case --- swallow the marker and let entropy decoder continue */ + TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num); + cinfo->unread_marker = 0; + } else { + /* Uh-oh, the restart markers have been messed up. */ + /* Let the data source manager determine how to resync. */ + if (! (*cinfo->src->resync_to_restart) (cinfo, + cinfo->marker->next_restart_num)) + return FALSE; + } + + /* Update next-restart state */ + cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7; + + return TRUE; +} + + +/* + * This is the default resync_to_restart method for data source managers + * to use if they don't have any better approach. Some data source managers + * may be able to back up, or may have additional knowledge about the data + * which permits a more intelligent recovery strategy; such managers would + * presumably supply their own resync method. + * + * read_restart_marker calls resync_to_restart if it finds a marker other than + * the restart marker it was expecting. (This code is *not* used unless + * a nonzero restart interval has been declared.) cinfo->unread_marker is + * the marker code actually found (might be anything, except 0 or FF). + * The desired restart marker number (0..7) is passed as a parameter. + * This routine is supposed to apply whatever error recovery strategy seems + * appropriate in order to position the input stream to the next data segment. + * Note that cinfo->unread_marker is treated as a marker appearing before + * the current data-source input point; usually it should be reset to zero + * before returning. + * Returns FALSE if suspension is required. + * + * This implementation is substantially constrained by wanting to treat the + * input as a data stream; this means we can't back up. Therefore, we have + * only the following actions to work with: + * 1. Simply discard the marker and let the entropy decoder resume at next + * byte of file. + * 2. Read forward until we find another marker, discarding intervening + * data. (In theory we could look ahead within the current bufferload, + * without having to discard data if we don't find the desired marker. + * This idea is not implemented here, in part because it makes behavior + * dependent on buffer size and chance buffer-boundary positions.) + * 3. Leave the marker unread (by failing to zero cinfo->unread_marker). + * This will cause the entropy decoder to process an empty data segment, + * inserting dummy zeroes, and then we will reprocess the marker. + * + * #2 is appropriate if we think the desired marker lies ahead, while #3 is + * appropriate if the found marker is a future restart marker (indicating + * that we have missed the desired restart marker, probably because it got + * corrupted). + * We apply #2 or #3 if the found marker is a restart marker no more than + * two counts behind or ahead of the expected one. We also apply #2 if the + * found marker is not a legal JPEG marker code (it's certainly bogus data). + * If the found marker is a restart marker more than 2 counts away, we do #1 + * (too much risk that the marker is erroneous; with luck we will be able to + * resync at some future point). + * For any valid non-restart JPEG marker, we apply #3. This keeps us from + * overrunning the end of a scan. An implementation limited to single-scan + * files might find it better to apply #2 for markers other than EOI, since + * any other marker would have to be bogus data in that case. + */ + +GLOBAL(boolean) +jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired) +{ + int marker = cinfo->unread_marker; + int action = 1; + + /* Always put up a warning. */ + WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired); + + /* Outer loop handles repeated decision after scanning forward. */ + for (;;) { + if (marker < (int) M_SOF0) + action = 2; /* invalid marker */ + else if (marker < (int) M_RST0 || marker > (int) M_RST7) + action = 3; /* valid non-restart marker */ + else { + if (marker == ((int) M_RST0 + ((desired+1) & 7)) || + marker == ((int) M_RST0 + ((desired+2) & 7))) + action = 3; /* one of the next two expected restarts */ + else if (marker == ((int) M_RST0 + ((desired-1) & 7)) || + marker == ((int) M_RST0 + ((desired-2) & 7))) + action = 2; /* a prior restart, so advance */ + else + action = 1; /* desired restart or too far away */ + } + TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action); + switch (action) { + case 1: + /* Discard marker and let entropy decoder resume processing. */ + cinfo->unread_marker = 0; + return TRUE; + case 2: + /* Scan to the next marker, and repeat the decision loop. */ + if (! next_marker(cinfo)) + return FALSE; + marker = cinfo->unread_marker; + break; + case 3: + /* Return without advancing past this marker. */ + /* Entropy decoder will be forced to process an empty segment. */ + return TRUE; + } + } /* end loop */ +} + + +/* + * Reset marker processing state to begin a fresh datastream. + */ + +METHODDEF(void) +reset_marker_reader (j_decompress_ptr cinfo) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + + cinfo->comp_info = NULL; /* until allocated by get_sof */ + cinfo->input_scan_number = 0; /* no SOS seen yet */ + cinfo->unread_marker = 0; /* no pending marker */ + marker->pub.saw_SOI = FALSE; /* set internal state too */ + marker->pub.saw_SOF = FALSE; + marker->pub.discarded_bytes = 0; + marker->cur_marker = NULL; +} + + +/* + * Initialize the marker reader module. + * This is called only once, when the decompression object is created. + */ + +GLOBAL(void) +jinit_marker_reader (j_decompress_ptr cinfo) +{ + my_marker_ptr marker; + int i; + + /* Create subobject in permanent pool */ + marker = (my_marker_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_marker_reader)); + cinfo->marker = &marker->pub; + /* Initialize public method pointers */ + marker->pub.reset_marker_reader = reset_marker_reader; + marker->pub.read_markers = read_markers; + marker->pub.read_restart_marker = read_restart_marker; + /* Initialize COM/APPn processing. + * By default, we examine and then discard APP0 and APP14, + * but simply discard COM and all other APPn. + */ + marker->process_COM = skip_variable; + marker->length_limit_COM = 0; + for (i = 0; i < 16; i++) { + marker->process_APPn[i] = skip_variable; + marker->length_limit_APPn[i] = 0; + } + marker->process_APPn[0] = get_interesting_appn; + marker->process_APPn[14] = get_interesting_appn; + /* Reset marker processing state */ + reset_marker_reader(cinfo); +} + + +/* + * Control saving of COM and APPn markers into marker_list. + */ + +#ifdef SAVE_MARKERS_SUPPORTED + +GLOBAL(void) +jpeg_save_markers (j_decompress_ptr cinfo, int marker_code, + unsigned int length_limit) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + long maxlength; + jpeg_marker_parser_method processor; + + /* Length limit mustn't be larger than what we can allocate + * (should only be a concern in a 16-bit environment). + */ + maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct); + if (((long) length_limit) > maxlength) + length_limit = (unsigned int) maxlength; + + /* Choose processor routine to use. + * APP0/APP14 have special requirements. + */ + if (length_limit) { + processor = save_marker; + /* If saving APP0/APP14, save at least enough for our internal use. */ + if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN) + length_limit = APP0_DATA_LEN; + else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN) + length_limit = APP14_DATA_LEN; + } else { + processor = skip_variable; + /* If discarding APP0/APP14, use our regular on-the-fly processor. */ + if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14) + processor = get_interesting_appn; + } + + if (marker_code == (int) M_COM) { + marker->process_COM = processor; + marker->length_limit_COM = length_limit; + } else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) { + marker->process_APPn[marker_code - (int) M_APP0] = processor; + marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit; + } else + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); +} + +#endif /* SAVE_MARKERS_SUPPORTED */ + + +/* + * Install a special processing method for COM or APPn markers. + */ + +GLOBAL(void) +jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code, + jpeg_marker_parser_method routine) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + + if (marker_code == (int) M_COM) + marker->process_COM = routine; + else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) + marker->process_APPn[marker_code - (int) M_APP0] = routine; + else + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); +} diff --git a/thirdparty/jpeg-9e/jdmaster.c b/thirdparty/jpeg-9e/jdmaster.c new file mode 100644 index 0000000..3070b7b --- /dev/null +++ b/thirdparty/jpeg-9e/jdmaster.c @@ -0,0 +1,532 @@ +/* + * jdmaster.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 2002-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains master control logic for the JPEG decompressor. + * These routines are concerned with selecting the modules to be executed + * and with determining the number of passes and the work to be done in each + * pass. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef struct { + struct jpeg_decomp_master pub; /* public fields */ + + int pass_number; /* # of passes completed */ + + boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */ + + /* Saved references to initialized quantizer modules, + * in case we need to switch modes. + */ + struct jpeg_color_quantizer * quantizer_1pass; + struct jpeg_color_quantizer * quantizer_2pass; +} my_decomp_master; + +typedef my_decomp_master * my_master_ptr; + + +/* + * Determine whether merged upsample/color conversion should be used. + * CRUCIAL: this must match the actual capabilities of jdmerge.c! + */ + +LOCAL(boolean) +use_merged_upsample (j_decompress_ptr cinfo) +{ +#ifdef UPSAMPLE_MERGING_SUPPORTED + /* Merging is the equivalent of plain box-filter upsampling. */ + /* The following condition is only needed if fancy shall select + * a different upsampling method. In our current implementation + * fancy only affects the DCT scaling, thus we can use fancy + * upsampling and merged upsample simultaneously, in particular + * with scaled DCT sizes larger than the default DCTSIZE. + */ +#if 0 + if (cinfo->do_fancy_upsampling) + return FALSE; +#endif + if (cinfo->CCIR601_sampling) + return FALSE; + /* jdmerge.c only supports YCC=>RGB color conversion */ + if ((cinfo->jpeg_color_space != JCS_YCbCr && + cinfo->jpeg_color_space != JCS_BG_YCC) || + cinfo->num_components != 3 || + cinfo->out_color_space != JCS_RGB || + cinfo->out_color_components != RGB_PIXELSIZE || + cinfo->color_transform) + return FALSE; + /* and it only handles 2h1v or 2h2v sampling ratios */ + if (cinfo->comp_info[0].h_samp_factor != 2 || + cinfo->comp_info[1].h_samp_factor != 1 || + cinfo->comp_info[2].h_samp_factor != 1 || + cinfo->comp_info[0].v_samp_factor > 2 || + cinfo->comp_info[1].v_samp_factor != 1 || + cinfo->comp_info[2].v_samp_factor != 1) + return FALSE; + /* furthermore, it doesn't work if we've scaled the IDCTs differently */ + if (cinfo->comp_info[0].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size || + cinfo->comp_info[1].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size || + cinfo->comp_info[2].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size || + cinfo->comp_info[0].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size || + cinfo->comp_info[1].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size || + cinfo->comp_info[2].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size) + return FALSE; + /* ??? also need to test for upsample-time rescaling, when & if supported */ + return TRUE; /* by golly, it'll work... */ +#else + return FALSE; +#endif +} + + +/* + * Compute output image dimensions and related values. + * NOTE: this is exported for possible use by application. + * Hence it mustn't do anything that can't be done twice. + * Also note that it may be called before the master module is initialized! + */ + +GLOBAL(void) +jpeg_calc_output_dimensions (j_decompress_ptr cinfo) +/* Do computations that are needed before master selection phase. + * This function is used for full decompression. + */ +{ + int ci, i; + jpeg_component_info *compptr; + + /* Prevent application from calling me at wrong times */ + if (cinfo->global_state != DSTATE_READY) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* Compute core output image dimensions and DCT scaling choices. */ + jpeg_core_output_dimensions(cinfo); + +#ifdef IDCT_SCALING_SUPPORTED + + /* In selecting the actual DCT scaling for each component, we try to + * scale up the chroma components via IDCT scaling rather than upsampling. + * This saves time if the upsampler gets to use 1:1 scaling. + * Note this code adapts subsampling ratios which are powers of 2. + */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + int ssize = 1; + if (! cinfo->raw_data_out) + while (cinfo->min_DCT_h_scaled_size * ssize <= + (cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) && + (cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == + 0) { + ssize = ssize * 2; + } + compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize; + ssize = 1; + if (! cinfo->raw_data_out) + while (cinfo->min_DCT_v_scaled_size * ssize <= + (cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) && + (cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == + 0) { + ssize = ssize * 2; + } + compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize; + + /* We don't support IDCT ratios larger than 2. */ + if (compptr->DCT_h_scaled_size > compptr->DCT_v_scaled_size * 2) + compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2; + else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2) + compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2; + + /* Recompute downsampled dimensions of components; + * application needs to know these if using raw downsampled data. + */ + /* Size in samples, after IDCT scaling */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * + (long) (compptr->h_samp_factor * compptr->DCT_h_scaled_size), + (long) (cinfo->max_h_samp_factor * cinfo->block_size)); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * + (long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size), + (long) (cinfo->max_v_samp_factor * cinfo->block_size)); + } + +#endif /* IDCT_SCALING_SUPPORTED */ + + /* Report number of components in selected colorspace. */ + /* This should correspond to the actual code in the color conversion module. */ + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + cinfo->out_color_components = 1; + break; + case JCS_RGB: + case JCS_BG_RGB: + cinfo->out_color_components = RGB_PIXELSIZE; + break; + default: /* YCCK <=> CMYK conversion or same colorspace as in file */ + i = 0; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) + if (compptr->component_needed) + i++; /* count output color components */ + cinfo->out_color_components = i; + } + cinfo->output_components = (cinfo->quantize_colors ? 1 : + cinfo->out_color_components); + + /* See if upsampler will want to emit more than one row at a time */ + if (use_merged_upsample(cinfo)) + cinfo->rec_outbuf_height = cinfo->max_v_samp_factor; + else + cinfo->rec_outbuf_height = 1; +} + + +/* + * Several decompression processes need to range-limit values to the range + * 0..MAXJSAMPLE; the input value may fall somewhat outside this range + * due to noise introduced by quantization, roundoff error, etc. These + * processes are inner loops and need to be as fast as possible. On most + * machines, particularly CPUs with pipelines or instruction prefetch, + * a (subscript-check-less) C table lookup + * x = sample_range_limit[x]; + * is faster than explicit tests + * if (x < 0) x = 0; + * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; + * These processes all use a common table prepared by the routine below. + * + * For most steps we can mathematically guarantee that the initial value + * of x is within 2*(MAXJSAMPLE+1) of the legal range, so a table running + * from -2*(MAXJSAMPLE+1) to 3*MAXJSAMPLE+2 is sufficient. But for the + * initial limiting step (just after the IDCT), a wildly out-of-range value + * is possible if the input data is corrupt. To avoid any chance of indexing + * off the end of memory and getting a bad-pointer trap, we perform the + * post-IDCT limiting thus: + * x = (sample_range_limit - SUBSET)[(x + CENTER) & MASK]; + * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit + * samples. Under normal circumstances this is more than enough range and + * a correct output will be generated; with bogus input data the mask will + * cause wraparound, and we will safely generate a bogus-but-in-range output. + * For the post-IDCT step, we want to convert the data from signed to unsigned + * representation by adding CENTERJSAMPLE at the same time that we limit it. + * This is accomplished with SUBSET = CENTER - CENTERJSAMPLE. + * + * Note that the table is allocated in near data space on PCs; it's small + * enough and used often enough to justify this. + */ + +LOCAL(void) +prepare_range_limit_table (j_decompress_ptr cinfo) +/* Allocate and fill in the sample_range_limit table */ +{ + JSAMPLE * table; + int i; + + table = (JSAMPLE *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, + JPOOL_IMAGE, (RANGE_CENTER * 2 + MAXJSAMPLE + 1) * SIZEOF(JSAMPLE)); + /* First segment of range limit table: limit[x] = 0 for x < 0 */ + MEMZERO(table, RANGE_CENTER * SIZEOF(JSAMPLE)); + table += RANGE_CENTER; /* allow negative subscripts of table */ + cinfo->sample_range_limit = table; + /* Main part of range limit table: limit[x] = x */ + for (i = 0; i <= MAXJSAMPLE; i++) + table[i] = (JSAMPLE) i; + /* End of range limit table: limit[x] = MAXJSAMPLE for x > MAXJSAMPLE */ + for (; i <= MAXJSAMPLE + RANGE_CENTER; i++) + table[i] = MAXJSAMPLE; +} + + +/* + * Master selection of decompression modules. + * This is done once at jpeg_start_decompress time. We determine + * which modules will be used and give them appropriate initialization calls. + * We also initialize the decompressor input side to begin consuming data. + * + * Since jpeg_read_header has finished, we know what is in the SOF + * and (first) SOS markers. We also have all the application parameter + * settings. + */ + +LOCAL(void) +master_selection (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + boolean use_c_buffer; + long samplesperrow; + JDIMENSION jd_samplesperrow; + + /* For now, precision must match compiled-in value... */ + if (cinfo->data_precision != BITS_IN_JSAMPLE) + ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); + + /* Initialize dimensions and other stuff */ + jpeg_calc_output_dimensions(cinfo); + prepare_range_limit_table(cinfo); + + /* Sanity check on image dimensions */ + if (cinfo->output_height <= 0 || cinfo->output_width <= 0 || + cinfo->out_color_components <= 0) + ERREXIT(cinfo, JERR_EMPTY_IMAGE); + + /* Width of an output scanline must be representable as JDIMENSION. */ + samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components; + jd_samplesperrow = (JDIMENSION) samplesperrow; + if ((long) jd_samplesperrow != samplesperrow) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + + /* Initialize my private state */ + master->pass_number = 0; + master->using_merged_upsample = use_merged_upsample(cinfo); + + /* Color quantizer selection */ + master->quantizer_1pass = NULL; + master->quantizer_2pass = NULL; + /* No mode changes if not using buffered-image mode. */ + if (! cinfo->quantize_colors || ! cinfo->buffered_image) { + cinfo->enable_1pass_quant = FALSE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; + } + if (cinfo->quantize_colors) { + if (cinfo->raw_data_out) + ERREXIT(cinfo, JERR_NOTIMPL); + /* 2-pass quantizer only works in 3-component color space. */ + if (cinfo->out_color_components != 3) { + cinfo->enable_1pass_quant = TRUE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; + cinfo->colormap = NULL; + } else if (cinfo->colormap != NULL) { + cinfo->enable_external_quant = TRUE; + } else if (cinfo->two_pass_quantize) { + cinfo->enable_2pass_quant = TRUE; + } else { + cinfo->enable_1pass_quant = TRUE; + } + + if (cinfo->enable_1pass_quant) { +#ifdef QUANT_1PASS_SUPPORTED + jinit_1pass_quantizer(cinfo); + master->quantizer_1pass = cinfo->cquantize; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + + /* We use the 2-pass code to map to external colormaps. */ + if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) { +#ifdef QUANT_2PASS_SUPPORTED + jinit_2pass_quantizer(cinfo); + master->quantizer_2pass = cinfo->cquantize; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + /* If both quantizers are initialized, the 2-pass one is left active; + * this is necessary for starting with quantization to an external map. + */ + } + + /* Post-processing: in particular, color conversion first */ + if (! cinfo->raw_data_out) { + if (master->using_merged_upsample) { +#ifdef UPSAMPLE_MERGING_SUPPORTED + jinit_merged_upsampler(cinfo); /* does color conversion too */ +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + jinit_color_deconverter(cinfo); + jinit_upsampler(cinfo); + } + jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant); + } + /* Inverse DCT */ + jinit_inverse_dct(cinfo); + /* Entropy decoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) + jinit_arith_decoder(cinfo); + else { + jinit_huff_decoder(cinfo); + } + + /* Initialize principal buffer controllers. */ + use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image; + jinit_d_coef_controller(cinfo, use_c_buffer); + + if (! cinfo->raw_data_out) + jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Initialize input side of decompressor to consume first scan. */ + (*cinfo->inputctl->start_input_pass) (cinfo); + +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* If jpeg_start_decompress will read the whole file, initialize + * progress monitoring appropriately. The input step is counted + * as one pass. + */ + if (cinfo->progress != NULL && ! cinfo->buffered_image && + cinfo->inputctl->has_multiple_scans) { + int nscans; + /* Estimate number of scans to set pass_limit. */ + if (cinfo->progressive_mode) { + /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ + nscans = 2 + 3 * cinfo->num_components; + } else { + /* For a nonprogressive multiscan file, estimate 1 scan per component. */ + nscans = cinfo->num_components; + } + cinfo->progress->pass_counter = 0L; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; + cinfo->progress->completed_passes = 0; + cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2); + /* Count the input pass as done */ + master->pass_number++; + } +#endif /* D_MULTISCAN_FILES_SUPPORTED */ +} + + +/* + * Per-pass setup. + * This is called at the beginning of each output pass. We determine which + * modules will be active during this pass and give them appropriate + * start_pass calls. We also set is_dummy_pass to indicate whether this + * is a "real" output pass or a dummy pass for color quantization. + * (In the latter case, jdapistd.c will crank the pass to completion.) + */ + +METHODDEF(void) +prepare_for_output_pass (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + if (master->pub.is_dummy_pass) { +#ifdef QUANT_2PASS_SUPPORTED + /* Final pass of 2-pass quantization */ + master->pub.is_dummy_pass = FALSE; + (*cinfo->cquantize->start_pass) (cinfo, FALSE); + (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST); + (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* QUANT_2PASS_SUPPORTED */ + } else { + if (cinfo->quantize_colors && cinfo->colormap == NULL) { + /* Select new quantization method */ + if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) { + cinfo->cquantize = master->quantizer_2pass; + master->pub.is_dummy_pass = TRUE; + } else if (cinfo->enable_1pass_quant) { + cinfo->cquantize = master->quantizer_1pass; + } else { + ERREXIT(cinfo, JERR_MODE_CHANGE); + } + } + (*cinfo->idct->start_pass) (cinfo); + (*cinfo->coef->start_output_pass) (cinfo); + if (! cinfo->raw_data_out) { + if (! master->using_merged_upsample) + (*cinfo->cconvert->start_pass) (cinfo); + (*cinfo->upsample->start_pass) (cinfo); + if (cinfo->quantize_colors) + (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass); + (*cinfo->post->start_pass) (cinfo, + (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); + (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); + } + } + + /* Set up progress monitor's pass info if present */ + if (cinfo->progress != NULL) { + cinfo->progress->completed_passes = master->pass_number; + cinfo->progress->total_passes = master->pass_number + + (master->pub.is_dummy_pass ? 2 : 1); + /* In buffered-image mode, we assume one more output pass if EOI not + * yet reached, but no more passes if EOI has been reached. + */ + if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) { + cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1); + } + } +} + + +/* + * Finish up at end of an output pass. + */ + +METHODDEF(void) +finish_output_pass (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + if (cinfo->quantize_colors) + (*cinfo->cquantize->finish_pass) (cinfo); + master->pass_number++; +} + + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Switch to a new external colormap between output passes. + */ + +GLOBAL(void) +jpeg_new_colormap (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + /* Prevent application from calling me at wrong times */ + if (cinfo->global_state != DSTATE_BUFIMAGE) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (cinfo->quantize_colors && cinfo->enable_external_quant && + cinfo->colormap != NULL) { + /* Select 2-pass quantizer for external colormap use */ + cinfo->cquantize = master->quantizer_2pass; + /* Notify quantizer of colormap change */ + (*cinfo->cquantize->new_color_map) (cinfo); + master->pub.is_dummy_pass = FALSE; /* just in case */ + } else + ERREXIT(cinfo, JERR_MODE_CHANGE); +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + + +/* + * Initialize master decompression control and select active modules. + * This is performed at the start of jpeg_start_decompress. + */ + +GLOBAL(void) +jinit_master_decompress (j_decompress_ptr cinfo) +{ + my_master_ptr master; + + master = (my_master_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_decomp_master)); + cinfo->master = &master->pub; + master->pub.prepare_for_output_pass = prepare_for_output_pass; + master->pub.finish_output_pass = finish_output_pass; + + master->pub.is_dummy_pass = FALSE; + + master_selection(cinfo); +} diff --git a/thirdparty/jpeg-9e/jdmerge.c b/thirdparty/jpeg-9e/jdmerge.c new file mode 100644 index 0000000..8ff1314 --- /dev/null +++ b/thirdparty/jpeg-9e/jdmerge.c @@ -0,0 +1,438 @@ +/* + * jdmerge.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2013-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains code for merged upsampling/color conversion. + * + * This file combines functions from jdsample.c and jdcolor.c; + * read those files first to understand what's going on. + * + * When the chroma components are to be upsampled by simple replication + * (ie, box filtering), we can save some work in color conversion by + * calculating all the output pixels corresponding to a pair of chroma + * samples at one time. In the conversion equations + * R = Y + K1 * Cr + * G = Y + K2 * Cb + K3 * Cr + * B = Y + K4 * Cb + * only the Y term varies among the group of pixels corresponding to a pair + * of chroma samples, so the rest of the terms can be calculated just once. + * At typical sampling ratios, this eliminates half or three-quarters of the + * multiplications needed for color conversion. + * + * This file currently provides implementations for the following cases: + * YCC => RGB color conversion only (YCbCr or BG_YCC). + * Sampling ratios of 2h1v or 2h2v. + * No scaling needed at upsample time. + * Corner-aligned (non-CCIR601) sampling alignment. + * Other special cases could be added, but in most applications these are + * the only common cases. (For uncommon cases we fall back on the more + * general code in jdsample.c and jdcolor.c.) + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef UPSAMPLE_MERGING_SUPPORTED + + +#if RANGE_BITS < 2 + /* Deliberate syntax err */ + Sorry, this code requires 2 or more range extension bits. +#endif + + +/* Private subobject */ + +typedef struct { + struct jpeg_upsampler pub; /* public fields */ + + /* Pointer to routine to do actual upsampling/conversion of one row group */ + JMETHOD(void, upmethod, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf)); + + /* Private state for YCC->RGB conversion */ + int * Cr_r_tab; /* => table for Cr to R conversion */ + int * Cb_b_tab; /* => table for Cb to B conversion */ + INT32 * Cr_g_tab; /* => table for Cr to G conversion */ + INT32 * Cb_g_tab; /* => table for Cb to G conversion */ + + /* For 2:1 vertical sampling, we produce two output rows at a time. + * We need a "spare" row buffer to hold the second output row if the + * application provides just a one-row buffer; we also use the spare + * to discard the dummy last row if the image height is odd. + */ + JSAMPROW spare_row; + boolean spare_full; /* T if spare buffer is occupied */ + + JDIMENSION out_row_width; /* samples per output row */ + JDIMENSION rows_to_go; /* counts rows remaining in image */ +} my_upsampler; + +typedef my_upsampler * my_upsample_ptr; + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L<RGB and BG_YCC->RGB colorspace conversion. + * This is taken directly from jdcolor.c; see that file for more info. + */ + +LOCAL(void) +build_ycc_rgb_table (j_decompress_ptr cinfo) +/* Normal case, sYCC */ +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + int i; + INT32 x; + SHIFT_TEMPS + + upsample->Cr_r_tab = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int)); + upsample->Cb_b_tab = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int)); + upsample->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32)); + upsample->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32)); + + for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { + /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ + /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ + /* Cr=>R value is nearest int to 1.402 * x */ + upsample->Cr_r_tab[i] = (int) DESCALE(FIX(1.402) * x, SCALEBITS); + /* Cb=>B value is nearest int to 1.772 * x */ + upsample->Cb_b_tab[i] = (int) DESCALE(FIX(1.772) * x, SCALEBITS); + /* Cr=>G value is scaled-up -0.714136286 * x */ + upsample->Cr_g_tab[i] = (- FIX(0.714136286)) * x; + /* Cb=>G value is scaled-up -0.344136286 * x */ + /* We also add in ONE_HALF so that need not do it in inner loop */ + upsample->Cb_g_tab[i] = (- FIX(0.344136286)) * x + ONE_HALF; + } +} + + +LOCAL(void) +build_bg_ycc_rgb_table (j_decompress_ptr cinfo) +/* Wide gamut case, bg-sYCC */ +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + int i; + INT32 x; + SHIFT_TEMPS + + upsample->Cr_r_tab = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int)); + upsample->Cb_b_tab = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int)); + upsample->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32)); + upsample->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32)); + + for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { + /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ + /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ + /* Cr=>R value is nearest int to 2.804 * x */ + upsample->Cr_r_tab[i] = (int) DESCALE(FIX(2.804) * x, SCALEBITS); + /* Cb=>B value is nearest int to 3.544 * x */ + upsample->Cb_b_tab[i] = (int) DESCALE(FIX(3.544) * x, SCALEBITS); + /* Cr=>G value is scaled-up -1.428272572 * x */ + upsample->Cr_g_tab[i] = (- FIX(1.428272572)) * x; + /* Cb=>G value is scaled-up -0.688272572 * x */ + /* We also add in ONE_HALF so that need not do it in inner loop */ + upsample->Cb_g_tab[i] = (- FIX(0.688272572)) * x + ONE_HALF; + } +} + + +/* + * Initialize for an upsampling pass. + */ + +METHODDEF(void) +start_pass_merged_upsample (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Mark the spare buffer empty */ + upsample->spare_full = FALSE; + /* Initialize total-height counter for detecting bottom of image */ + upsample->rows_to_go = cinfo->output_height; +} + + +/* + * Control routine to do upsampling (and color conversion). + * + * The control routine just handles the row buffering considerations. + */ + +METHODDEF(void) +merged_2v_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +/* 2:1 vertical sampling case: may need a spare row. */ +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + JSAMPROW work_ptrs[2]; + JDIMENSION num_rows; /* number of rows returned to caller */ + + if (upsample->spare_full) { + /* If we have a spare row saved from a previous cycle, just return it. */ + jcopy_sample_rows(& upsample->spare_row, output_buf + *out_row_ctr, + 1, upsample->out_row_width); + num_rows = 1; + upsample->spare_full = FALSE; + } else { + /* Figure number of rows to return to caller. */ + num_rows = 2; + /* Not more than the distance to the end of the image. */ + if (num_rows > upsample->rows_to_go) + num_rows = upsample->rows_to_go; + /* And not more than what the client can accept: */ + out_rows_avail -= *out_row_ctr; + if (num_rows > out_rows_avail) + num_rows = out_rows_avail; + /* Create output pointer array for upsampler. */ + work_ptrs[0] = output_buf[*out_row_ctr]; + if (num_rows > 1) { + work_ptrs[1] = output_buf[*out_row_ctr + 1]; + } else { + work_ptrs[1] = upsample->spare_row; + upsample->spare_full = TRUE; + } + /* Now do the upsampling. */ + (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs); + } + + /* Adjust counts */ + *out_row_ctr += num_rows; + upsample->rows_to_go -= num_rows; + /* When the buffer is emptied, declare this input row group consumed */ + if (! upsample->spare_full) + (*in_row_group_ctr)++; +} + + +METHODDEF(void) +merged_1v_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +/* 1:1 vertical sampling case: much easier, never need a spare row. */ +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Just do the upsampling. */ + (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, + output_buf + *out_row_ctr); + /* Adjust counts */ + (*out_row_ctr)++; + (*in_row_group_ctr)++; +} + + +/* + * These are the routines invoked by the control routines to do + * the actual upsampling/conversion. One row group is processed per call. + * + * Note: since we may be writing directly into application-supplied buffers, + * we have to be honest about the output width; we can't assume the buffer + * has been rounded up to an even width. + */ + + +/* + * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. + */ + +METHODDEF(void) +h2v1_merged_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + register int y, cred, cgreen, cblue; + int cb, cr; + register JSAMPROW outptr; + JSAMPROW inptr0, inptr1, inptr2; + JDIMENSION col; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + int * Crrtab = upsample->Cr_r_tab; + int * Cbbtab = upsample->Cb_b_tab; + INT32 * Crgtab = upsample->Cr_g_tab; + INT32 * Cbgtab = upsample->Cb_g_tab; + SHIFT_TEMPS + + inptr0 = input_buf[0][in_row_group_ctr]; + inptr1 = input_buf[1][in_row_group_ctr]; + inptr2 = input_buf[2][in_row_group_ctr]; + outptr = output_buf[0]; + /* Loop for each pair of output pixels */ + for (col = cinfo->output_width >> 1; col > 0; col--) { + /* Do the chroma part of the calculation */ + cb = GETJSAMPLE(*inptr1++); + cr = GETJSAMPLE(*inptr2++); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + /* Fetch 2 Y values and emit 2 pixels */ + y = GETJSAMPLE(*inptr0++); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + outptr += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr0++); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + outptr += RGB_PIXELSIZE; + } + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + cb = GETJSAMPLE(*inptr1); + cr = GETJSAMPLE(*inptr2); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + y = GETJSAMPLE(*inptr0); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + } +} + + +/* + * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. + */ + +METHODDEF(void) +h2v2_merged_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + register int y, cred, cgreen, cblue; + int cb, cr; + register JSAMPROW outptr0, outptr1; + JSAMPROW inptr00, inptr01, inptr1, inptr2; + JDIMENSION col; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + int * Crrtab = upsample->Cr_r_tab; + int * Cbbtab = upsample->Cb_b_tab; + INT32 * Crgtab = upsample->Cr_g_tab; + INT32 * Cbgtab = upsample->Cb_g_tab; + SHIFT_TEMPS + + inptr00 = input_buf[0][in_row_group_ctr*2]; + inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; + inptr1 = input_buf[1][in_row_group_ctr]; + inptr2 = input_buf[2][in_row_group_ctr]; + outptr0 = output_buf[0]; + outptr1 = output_buf[1]; + /* Loop for each group of output pixels */ + for (col = cinfo->output_width >> 1; col > 0; col--) { + /* Do the chroma part of the calculation */ + cb = GETJSAMPLE(*inptr1++); + cr = GETJSAMPLE(*inptr2++); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + /* Fetch 4 Y values and emit 4 pixels */ + y = GETJSAMPLE(*inptr00++); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + outptr0 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr00++); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + outptr0 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr01++); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + outptr1 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr01++); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + outptr1 += RGB_PIXELSIZE; + } + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + cb = GETJSAMPLE(*inptr1); + cr = GETJSAMPLE(*inptr2); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + y = GETJSAMPLE(*inptr00); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + y = GETJSAMPLE(*inptr01); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + } +} + + +/* + * Module initialization routine for merged upsampling/color conversion. + * + * NB: this is called under the conditions determined by use_merged_upsample() + * in jdmaster.c. That routine MUST correspond to the actual capabilities + * of this module; no safety checks are made here. + */ + +GLOBAL(void) +jinit_merged_upsampler (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample; + + upsample = (my_upsample_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_upsampler)); + cinfo->upsample = &upsample->pub; + upsample->pub.start_pass = start_pass_merged_upsample; + upsample->pub.need_context_rows = FALSE; + + upsample->out_row_width = cinfo->output_width * cinfo->out_color_components; + + if (cinfo->max_v_samp_factor == 2) { + upsample->pub.upsample = merged_2v_upsample; + upsample->upmethod = h2v2_merged_upsample; + /* Allocate a spare row buffer */ + upsample->spare_row = (JSAMPROW) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (size_t) upsample->out_row_width * SIZEOF(JSAMPLE)); + } else { + upsample->pub.upsample = merged_1v_upsample; + upsample->upmethod = h2v1_merged_upsample; + /* No spare row needed */ + upsample->spare_row = NULL; + } + + if (cinfo->jpeg_color_space == JCS_BG_YCC) + build_bg_ycc_rgb_table(cinfo); + else + build_ycc_rgb_table(cinfo); +} + +#endif /* UPSAMPLE_MERGING_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/jdpostct.c b/thirdparty/jpeg-9e/jdpostct.c new file mode 100644 index 0000000..571563d --- /dev/null +++ b/thirdparty/jpeg-9e/jdpostct.c @@ -0,0 +1,290 @@ +/* + * jdpostct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the decompression postprocessing controller. + * This controller manages the upsampling, color conversion, and color + * quantization/reduction steps; specifically, it controls the buffering + * between upsample/color conversion and color quantization/reduction. + * + * If no color quantization/reduction is required, then this module has no + * work to do, and it just hands off to the upsample/color conversion code. + * An integrated upsample/convert/quantize process would replace this module + * entirely. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_post_controller pub; /* public fields */ + + /* Color quantization source buffer: this holds output data from + * the upsample/color conversion step to be passed to the quantizer. + * For two-pass color quantization, we need a full-image buffer; + * for one-pass operation, a strip buffer is sufficient. + */ + jvirt_sarray_ptr whole_image; /* virtual array, or NULL if one-pass */ + JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */ + JDIMENSION strip_height; /* buffer size in rows */ + /* for two-pass mode only: */ + JDIMENSION starting_row; /* row # of first row in current strip */ + JDIMENSION next_row; /* index of next row to fill/empty in strip */ +} my_post_controller; + +typedef my_post_controller * my_post_ptr; + + +/* Forward declarations */ +METHODDEF(void) post_process_1pass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +#ifdef QUANT_2PASS_SUPPORTED +METHODDEF(void) post_process_prepass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +METHODDEF(void) post_process_2pass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +#endif + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (cinfo->quantize_colors) { + /* Single-pass processing with color quantization. */ + post->pub.post_process_data = post_process_1pass; + /* We could be doing buffered-image output before starting a 2-pass + * color quantization; in that case, jinit_d_post_controller did not + * allocate a strip buffer. Use the virtual-array buffer as workspace. + */ + if (post->buffer == NULL) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + (JDIMENSION) 0, post->strip_height, TRUE); + } + } else { + /* For single-pass processing without color quantization, + * I have no work to do; just call the upsampler directly. + */ + post->pub.post_process_data = cinfo->upsample->upsample; + } + break; +#ifdef QUANT_2PASS_SUPPORTED + case JBUF_SAVE_AND_PASS: + /* First pass of 2-pass quantization */ + if (post->whole_image == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + post->pub.post_process_data = post_process_prepass; + break; + case JBUF_CRANK_DEST: + /* Second pass of 2-pass quantization */ + if (post->whole_image == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + post->pub.post_process_data = post_process_2pass; + break; +#endif /* QUANT_2PASS_SUPPORTED */ + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } + post->starting_row = post->next_row = 0; +} + + +/* + * Process some data in the one-pass (strip buffer) case. + * This is used for color precision reduction as well as one-pass quantization. + */ + +METHODDEF(void) +post_process_1pass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION num_rows, max_rows; + + /* Fill the buffer, but not more than what we can dump out in one go. */ + /* Note we rely on the upsampler to detect bottom of image. */ + max_rows = out_rows_avail - *out_row_ctr; + if (max_rows > post->strip_height) + max_rows = post->strip_height; + num_rows = 0; + (*cinfo->upsample->upsample) (cinfo, + input_buf, in_row_group_ctr, in_row_groups_avail, + post->buffer, &num_rows, max_rows); + /* Quantize and emit data. */ + (*cinfo->cquantize->color_quantize) (cinfo, + post->buffer, output_buf + *out_row_ctr, (int) num_rows); + *out_row_ctr += num_rows; +} + + +#ifdef QUANT_2PASS_SUPPORTED + +/* + * Process some data in the first pass of 2-pass quantization. + */ + +METHODDEF(void) +post_process_prepass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION old_next_row, num_rows; + + /* Reposition virtual buffer if at start of strip. */ + if (post->next_row == 0) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + post->starting_row, post->strip_height, TRUE); + } + + /* Upsample some data (up to a strip height's worth). */ + old_next_row = post->next_row; + (*cinfo->upsample->upsample) (cinfo, + input_buf, in_row_group_ctr, in_row_groups_avail, + post->buffer, &post->next_row, post->strip_height); + + /* Allow quantizer to scan new data. No data is emitted, */ + /* but we advance out_row_ctr so outer loop can tell when we're done. */ + if (post->next_row > old_next_row) { + num_rows = post->next_row - old_next_row; + (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row, + (JSAMPARRAY) NULL, (int) num_rows); + *out_row_ctr += num_rows; + } + + /* Advance if we filled the strip. */ + if (post->next_row >= post->strip_height) { + post->starting_row += post->strip_height; + post->next_row = 0; + } +} + + +/* + * Process some data in the second pass of 2-pass quantization. + */ + +METHODDEF(void) +post_process_2pass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION num_rows, max_rows; + + /* Reposition virtual buffer if at start of strip. */ + if (post->next_row == 0) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + post->starting_row, post->strip_height, FALSE); + } + + /* Determine number of rows to emit. */ + num_rows = post->strip_height - post->next_row; /* available in strip */ + max_rows = out_rows_avail - *out_row_ctr; /* available in output area */ + if (num_rows > max_rows) + num_rows = max_rows; + /* We have to check bottom of image here, can't depend on upsampler. */ + max_rows = cinfo->output_height - post->starting_row; + if (num_rows > max_rows) + num_rows = max_rows; + + /* Quantize and emit data. */ + (*cinfo->cquantize->color_quantize) (cinfo, + post->buffer + post->next_row, output_buf + *out_row_ctr, + (int) num_rows); + *out_row_ctr += num_rows; + + /* Advance if we filled the strip. */ + post->next_row += num_rows; + if (post->next_row >= post->strip_height) { + post->starting_row += post->strip_height; + post->next_row = 0; + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ + + +/* + * Initialize postprocessing controller. + */ + +GLOBAL(void) +jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_post_ptr post; + + post = (my_post_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_post_controller)); + cinfo->post = (struct jpeg_d_post_controller *) post; + post->pub.start_pass = start_pass_dpost; + post->whole_image = NULL; /* flag for no virtual arrays */ + post->buffer = NULL; /* flag for no strip buffer */ + + /* Create the quantization buffer, if needed */ + if (cinfo->quantize_colors) { + /* The buffer strip height is max_v_samp_factor, which is typically + * an efficient number of rows for upsampling to return. + * (In the presence of output rescaling, we might want to be smarter?) + */ + post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor; + if (need_full_buffer) { + /* Two-pass color quantization: need full-image storage. */ + /* We round up the number of rows to a multiple of the strip height. */ +#ifdef QUANT_2PASS_SUPPORTED + post->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + cinfo->output_width * cinfo->out_color_components, + (JDIMENSION) jround_up((long) cinfo->output_height, + (long) post->strip_height), + post->strip_height); +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif /* QUANT_2PASS_SUPPORTED */ + } else { + /* One-pass color quantization: just make a strip buffer. */ + post->buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->output_width * cinfo->out_color_components, + post->strip_height); + } + } +} diff --git a/thirdparty/jpeg-9e/jdsample.c b/thirdparty/jpeg-9e/jdsample.c new file mode 100644 index 0000000..15afeaf --- /dev/null +++ b/thirdparty/jpeg-9e/jdsample.c @@ -0,0 +1,341 @@ +/* + * jdsample.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2002-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains upsampling routines. + * + * Upsampling input data is counted in "row groups". A row group + * is defined to be (v_samp_factor * DCT_v_scaled_size / min_DCT_v_scaled_size) + * sample rows of each component. Upsampling will normally produce + * max_v_samp_factor pixel rows from each row group (but this could vary + * if the upsampler is applying a scale factor of its own). + * + * An excellent reference for image resampling is + * Digital Image Warping, George Wolberg, 1990. + * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Pointer to routine to upsample a single component */ +typedef JMETHOD(void, upsample1_ptr, + (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr)); + +/* Private subobject */ + +typedef struct { + struct jpeg_upsampler pub; /* public fields */ + + /* Color conversion buffer. When using separate upsampling and color + * conversion steps, this buffer holds one upsampled row group until it + * has been color converted and output. + * Note: we do not allocate any storage for component(s) which are full-size, + * ie do not need rescaling. The corresponding entry of color_buf[] is + * simply set to point to the input data array, thereby avoiding copying. + */ + JSAMPARRAY color_buf[MAX_COMPONENTS]; + + /* Per-component upsampling method pointers */ + upsample1_ptr methods[MAX_COMPONENTS]; + + int next_row_out; /* counts rows emitted from color_buf */ + JDIMENSION rows_to_go; /* counts rows remaining in image */ + + /* Height of an input row group for each component. */ + int rowgroup_height[MAX_COMPONENTS]; + + /* These arrays save pixel expansion factors so that int_expand need not + * recompute them each time. They are unused for other upsampling methods. + */ + UINT8 h_expand[MAX_COMPONENTS]; + UINT8 v_expand[MAX_COMPONENTS]; +} my_upsampler; + +typedef my_upsampler * my_upsample_ptr; + + +/* + * Initialize for an upsampling pass. + */ + +METHODDEF(void) +start_pass_upsample (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Mark the conversion buffer empty */ + upsample->next_row_out = cinfo->max_v_samp_factor; + /* Initialize total-height counter for detecting bottom of image */ + upsample->rows_to_go = cinfo->output_height; +} + + +/* + * Control routine to do upsampling (and color conversion). + * + * In this version we upsample each component independently. + * We upsample one row group into the conversion buffer, then apply + * color conversion a row at a time. + */ + +METHODDEF(void) +sep_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + int ci; + jpeg_component_info * compptr; + JDIMENSION num_rows; + + /* Fill the conversion buffer, if it's empty */ + if (upsample->next_row_out >= cinfo->max_v_samp_factor) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Don't bother to upsample an uninteresting component. */ + if (! compptr->component_needed) + continue; + /* Invoke per-component upsample method. Notice we pass a POINTER + * to color_buf[ci], so that fullsize_upsample can change it. + */ + (*upsample->methods[ci]) (cinfo, compptr, + input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), + upsample->color_buf + ci); + } + upsample->next_row_out = 0; + } + + /* Color-convert and emit rows */ + + /* How many we have in the buffer: */ + num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out); + /* Not more than the distance to the end of the image. Need this test + * in case the image height is not a multiple of max_v_samp_factor: + */ + if (num_rows > upsample->rows_to_go) + num_rows = upsample->rows_to_go; + /* And not more than what the client can accept: */ + out_rows_avail -= *out_row_ctr; + if (num_rows > out_rows_avail) + num_rows = out_rows_avail; + + (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf, + (JDIMENSION) upsample->next_row_out, + output_buf + *out_row_ctr, + (int) num_rows); + + /* Adjust counts */ + *out_row_ctr += num_rows; + upsample->rows_to_go -= num_rows; + upsample->next_row_out += num_rows; + /* When the buffer is emptied, declare this input row group consumed */ + if (upsample->next_row_out >= cinfo->max_v_samp_factor) + (*in_row_group_ctr)++; +} + + +/* + * These are the routines invoked by sep_upsample to upsample pixel values + * of a single component. One row group is processed per call. + */ + + +/* + * For full-size components, we just make color_buf[ci] point at the + * input buffer, and thus avoid copying any data. Note that this is + * safe only because sep_upsample doesn't declare the input row group + * "consumed" until we are done color converting and emitting it. + */ + +METHODDEF(void) +fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr) +{ + *output_data_ptr = input_data; +} + + +/* + * This version handles any integral sampling ratios. + * This is not used for typical JPEG files, so it need not be fast. + * Nor, for that matter, is it particularly accurate: the algorithm is + * simple replication of the input pixel onto the corresponding output + * pixels. The hi-falutin sampling literature refers to this as a + * "box filter". A box filter tends to introduce visible artifacts, + * so if you are actually going to use 3:1 or 4:1 sampling ratios + * you would be well advised to improve this code. + */ + +METHODDEF(void) +int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + JSAMPARRAY output_data, output_end; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + register int h; + JSAMPROW outend; + int h_expand, v_expand; + + h_expand = upsample->h_expand[compptr->component_index]; + v_expand = upsample->v_expand[compptr->component_index]; + + output_data = *output_data_ptr; + output_end = output_data + cinfo->max_v_samp_factor; + for (; output_data < output_end; output_data += v_expand) { + /* Generate one output row with proper horizontal expansion */ + inptr = *input_data++; + outptr = *output_data; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + for (h = h_expand; h > 0; h--) { + *outptr++ = invalue; + } + } + /* Generate any additional output rows by duplicating the first one */ + if (v_expand > 1) { + jcopy_sample_rows(output_data, output_data + 1, + v_expand - 1, cinfo->output_width); + } + } +} + + +/* + * Fast processing for the common case of 2:1 horizontal and 1:1 vertical. + * It's still a box filter. + */ + +METHODDEF(void) +h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + JSAMPROW outend; + int outrow; + + for (outrow = 0; outrow < cinfo->max_v_samp_factor; outrow++) { + inptr = input_data[outrow]; + outptr = output_data[outrow]; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + *outptr++ = invalue; + *outptr++ = invalue; + } + } +} + + +/* + * Fast processing for the common case of 2:1 horizontal and 2:1 vertical. + * It's still a box filter. + */ + +METHODDEF(void) +h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr) +{ + JSAMPARRAY output_data, output_end; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + JSAMPROW outend; + + output_data = *output_data_ptr; + output_end = output_data + cinfo->max_v_samp_factor; + for (; output_data < output_end; output_data += 2) { + inptr = *input_data++; + outptr = *output_data; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + *outptr++ = invalue; + *outptr++ = invalue; + } + jcopy_sample_rows(output_data, output_data + 1, + 1, cinfo->output_width); + } +} + + +/* + * Module initialization routine for upsampling. + */ + +GLOBAL(void) +jinit_upsampler (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample; + int ci; + jpeg_component_info * compptr; + int h_in_group, v_in_group, h_out_group, v_out_group; + + upsample = (my_upsample_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_upsampler)); + cinfo->upsample = &upsample->pub; + upsample->pub.start_pass = start_pass_upsample; + upsample->pub.upsample = sep_upsample; + upsample->pub.need_context_rows = FALSE; /* until we find out differently */ + + if (cinfo->CCIR601_sampling) /* this isn't supported */ + ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); + + /* Verify we can handle the sampling factors, select per-component methods, + * and create storage as needed. + */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Don't bother to upsample an uninteresting component. */ + if (! compptr->component_needed) + continue; + /* Compute size of an "input group" after IDCT scaling. This many samples + * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. + */ + h_in_group = (compptr->h_samp_factor * compptr->DCT_h_scaled_size) / + cinfo->min_DCT_h_scaled_size; + v_in_group = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) / + cinfo->min_DCT_v_scaled_size; + h_out_group = cinfo->max_h_samp_factor; + v_out_group = cinfo->max_v_samp_factor; + upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ + if (h_in_group == h_out_group && v_in_group == v_out_group) { + /* Fullsize components can be processed without any work. */ + upsample->methods[ci] = fullsize_upsample; + continue; /* don't need to allocate buffer */ + } + if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) { + /* Special case for 2h1v upsampling */ + upsample->methods[ci] = h2v1_upsample; + } else if (h_in_group * 2 == h_out_group && + v_in_group * 2 == v_out_group) { + /* Special case for 2h2v upsampling */ + upsample->methods[ci] = h2v2_upsample; + } else if ((h_out_group % h_in_group) == 0 && + (v_out_group % v_in_group) == 0) { + /* Generic integral-factors upsampling method */ + upsample->methods[ci] = int_upsample; + upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group); + upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group); + } else + ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); + upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) jround_up((long) cinfo->output_width, + (long) cinfo->max_h_samp_factor), + (JDIMENSION) cinfo->max_v_samp_factor); + } +} diff --git a/thirdparty/jpeg-9e/jdtrans.c b/thirdparty/jpeg-9e/jdtrans.c new file mode 100644 index 0000000..22dd47f --- /dev/null +++ b/thirdparty/jpeg-9e/jdtrans.c @@ -0,0 +1,140 @@ +/* + * jdtrans.c + * + * Copyright (C) 1995-1997, Thomas G. Lane. + * Modified 2000-2009 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains library routines for transcoding decompression, + * that is, reading raw DCT coefficient arrays from an input JPEG file. + * The routines in jdapimin.c will also be needed by a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo)); + + +/* + * Read the coefficient arrays from a JPEG file. + * jpeg_read_header must be completed before calling this. + * + * The entire image is read into a set of virtual coefficient-block arrays, + * one per component. The return value is a pointer to the array of + * virtual-array descriptors. These can be manipulated directly via the + * JPEG memory manager, or handed off to jpeg_write_coefficients(). + * To release the memory occupied by the virtual arrays, call + * jpeg_finish_decompress() when done with the data. + * + * An alternative usage is to simply obtain access to the coefficient arrays + * during a buffered-image-mode decompression operation. This is allowed + * after any jpeg_finish_output() call. The arrays can be accessed until + * jpeg_finish_decompress() is called. (Note that any call to the library + * may reposition the arrays, so don't rely on access_virt_barray() results + * to stay valid across library calls.) + * + * Returns NULL if suspended. This case need be checked only if + * a suspending data source is used. + */ + +GLOBAL(jvirt_barray_ptr *) +jpeg_read_coefficients (j_decompress_ptr cinfo) +{ + if (cinfo->global_state == DSTATE_READY) { + /* First call: initialize active modules */ + transdecode_master_selection(cinfo); + cinfo->global_state = DSTATE_RDCOEFS; + } + if (cinfo->global_state == DSTATE_RDCOEFS) { + /* Absorb whole file into the coef buffer */ + for (;;) { + int retcode; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + /* Absorb some more input */ + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_SUSPENDED) + return NULL; + if (retcode == JPEG_REACHED_EOI) + break; + /* Advance progress counter if appropriate */ + if (cinfo->progress != NULL && + (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { + if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { + /* startup underestimated number of scans; ratchet up one scan */ + cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; + } + } + } + /* Set state so that jpeg_finish_decompress does the right thing */ + cinfo->global_state = DSTATE_STOPPING; + } + /* At this point we should be in state DSTATE_STOPPING if being used + * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access + * to the coefficients during a full buffered-image-mode decompression. + */ + if ((cinfo->global_state == DSTATE_STOPPING || + cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) { + return cinfo->coef->coef_arrays; + } + /* Oops, improper usage */ + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + return NULL; /* keep compiler happy */ +} + + +/* + * Master selection of decompression modules for transcoding. + * This substitutes for jdmaster.c's initialization of the full decompressor. + */ + +LOCAL(void) +transdecode_master_selection (j_decompress_ptr cinfo) +{ + /* This is effectively a buffered-image operation. */ + cinfo->buffered_image = TRUE; + + /* Compute output image dimensions and related values. */ + jpeg_core_output_dimensions(cinfo); + + /* Entropy decoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) + jinit_arith_decoder(cinfo); + else { + jinit_huff_decoder(cinfo); + } + + /* Always get a full-image coefficient buffer. */ + jinit_d_coef_controller(cinfo, TRUE); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Initialize input side of decompressor to consume first scan. */ + (*cinfo->inputctl->start_input_pass) (cinfo); + + /* Initialize progress monitoring. */ + if (cinfo->progress != NULL) { + int nscans; + /* Estimate number of scans to set pass_limit. */ + if (cinfo->progressive_mode) { + /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ + nscans = 2 + 3 * cinfo->num_components; + } else if (cinfo->inputctl->has_multiple_scans) { + /* For a nonprogressive multiscan file, estimate 1 scan per component. */ + nscans = cinfo->num_components; + } else { + nscans = 1; + } + cinfo->progress->pass_counter = 0L; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; + cinfo->progress->completed_passes = 0; + cinfo->progress->total_passes = 1; + } +} diff --git a/thirdparty/jpeg-9e/jerror.c b/thirdparty/jpeg-9e/jerror.c new file mode 100644 index 0000000..7163af6 --- /dev/null +++ b/thirdparty/jpeg-9e/jerror.c @@ -0,0 +1,253 @@ +/* + * jerror.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * Modified 2012-2015 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains simple error-reporting and trace-message routines. + * These are suitable for Unix-like systems and others where writing to + * stderr is the right thing to do. Many applications will want to replace + * some or all of these routines. + * + * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile, + * you get a Windows-specific hack to display error messages in a dialog box. + * It ain't much, but it beats dropping error messages into the bit bucket, + * which is what happens to output to stderr under most Windows C compilers. + * + * These routines are used by both the compression and decompression code. + */ + +#ifdef USE_WINDOWS_MESSAGEBOX +#include +#endif + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jversion.h" +#include "jerror.h" + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif + + +/* + * Create the message string table. + * We do this from the master message list in jerror.h by re-reading + * jerror.h with a suitable definition for macro JMESSAGE. + * The message table is made an external symbol just in case any applications + * want to refer to it directly. + */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_std_message_table jMsgTable +#endif + +#define JMESSAGE(code,string) string , + +const char * const jpeg_std_message_table[] = { +#include "jerror.h" + NULL +}; + + +/* + * Error exit handler: must not return to caller. + * + * Applications may override this if they want to get control back after + * an error. Typically one would longjmp somewhere instead of exiting. + * The setjmp buffer can be made a private field within an expanded error + * handler object. Note that the info needed to generate an error message + * is stored in the error object, so you can generate the message now or + * later, at your convenience. + * You should make sure that the JPEG object is cleaned up (with jpeg_abort + * or jpeg_destroy) at some point. + */ + +METHODDEF(noreturn_t) +error_exit (j_common_ptr cinfo) +{ + /* Always display the message */ + (*cinfo->err->output_message) (cinfo); + + /* Let the memory manager delete any temp files before we die */ + jpeg_destroy(cinfo); + + exit(EXIT_FAILURE); +} + + +/* + * Actual output of an error or trace message. + * Applications may override this method to send JPEG messages somewhere + * other than stderr. + * + * On Windows, printing to stderr is generally completely useless, + * so we provide optional code to produce an error-dialog popup. + * Most Windows applications will still prefer to override this routine, + * but if they don't, it'll do something at least marginally useful. + * + * NOTE: to use the library in an environment that doesn't support the + * C stdio library, you may have to delete the call to fprintf() entirely, + * not just not use this routine. + */ + +METHODDEF(void) +output_message (j_common_ptr cinfo) +{ + char buffer[JMSG_LENGTH_MAX]; + + /* Create the message */ + (*cinfo->err->format_message) (cinfo, buffer); + +#ifdef USE_WINDOWS_MESSAGEBOX + /* Display it in a message dialog box */ + MessageBox(GetActiveWindow(), buffer, "JPEG Library Error", + MB_OK | MB_ICONERROR); +#else + /* Send it to stderr, adding a newline */ + fprintf(stderr, "%s\n", buffer); +#endif +} + + +/* + * Decide whether to emit a trace or warning message. + * msg_level is one of: + * -1: recoverable corrupt-data warning, may want to abort. + * 0: important advisory messages (always display to user). + * 1: first level of tracing detail. + * 2,3,...: successively more detailed tracing messages. + * An application might override this method if it wanted to abort on warnings + * or change the policy about which messages to display. + */ + +METHODDEF(void) +emit_message (j_common_ptr cinfo, int msg_level) +{ + struct jpeg_error_mgr * err = cinfo->err; + + if (msg_level < 0) { + /* It's a warning message. Since corrupt files may generate many warnings, + * the policy implemented here is to show only the first warning, + * unless trace_level >= 3. + */ + if (err->num_warnings == 0 || err->trace_level >= 3) + (*err->output_message) (cinfo); + /* Always count warnings in num_warnings. */ + err->num_warnings++; + } else { + /* It's a trace message. Show it if trace_level >= msg_level. */ + if (err->trace_level >= msg_level) + (*err->output_message) (cinfo); + } +} + + +/* + * Format a message string for the most recent JPEG error or message. + * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX + * characters. Note that no '\n' character is added to the string. + * Few applications should need to override this method. + */ + +METHODDEF(void) +format_message (j_common_ptr cinfo, char * buffer) +{ + struct jpeg_error_mgr * err = cinfo->err; + int msg_code = err->msg_code; + const char * msgtext = NULL; + const char * msgptr; + char ch; + boolean isstring; + + /* Look up message string in proper table */ + if (msg_code > 0 && msg_code <= err->last_jpeg_message) { + msgtext = err->jpeg_message_table[msg_code]; + } else if (err->addon_message_table != NULL && + msg_code >= err->first_addon_message && + msg_code <= err->last_addon_message) { + msgtext = err->addon_message_table[msg_code - err->first_addon_message]; + } + + /* Defend against bogus message number */ + if (msgtext == NULL) { + err->msg_parm.i[0] = msg_code; + msgtext = err->jpeg_message_table[0]; + } + + /* Check for string parameter, as indicated by %s in the message text */ + isstring = FALSE; + msgptr = msgtext; + while ((ch = *msgptr++) != '\0') { + if (ch == '%') { + if (*msgptr == 's') isstring = TRUE; + break; + } + } + + /* Format the message into the passed buffer */ + if (isstring) + sprintf(buffer, msgtext, err->msg_parm.s); + else + sprintf(buffer, msgtext, + err->msg_parm.i[0], err->msg_parm.i[1], + err->msg_parm.i[2], err->msg_parm.i[3], + err->msg_parm.i[4], err->msg_parm.i[5], + err->msg_parm.i[6], err->msg_parm.i[7]); +} + + +/* + * Reset error state variables at start of a new image. + * This is called during compression startup to reset trace/error + * processing to default state, without losing any application-specific + * method pointers. An application might possibly want to override + * this method if it has additional error processing state. + */ + +METHODDEF(void) +reset_error_mgr (j_common_ptr cinfo) +{ + cinfo->err->num_warnings = 0; + /* trace_level is not reset since it is an application-supplied parameter */ + cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */ +} + + +/* + * Fill in the standard error-handling methods in a jpeg_error_mgr object. + * Typical call is: + * struct jpeg_compress_struct cinfo; + * struct jpeg_error_mgr err; + * + * cinfo.err = jpeg_std_error(&err); + * after which the application may override some of the methods. + */ + +GLOBAL(struct jpeg_error_mgr *) +jpeg_std_error (struct jpeg_error_mgr * err) +{ + err->error_exit = error_exit; + err->emit_message = emit_message; + err->output_message = output_message; + err->format_message = format_message; + err->reset_error_mgr = reset_error_mgr; + + err->trace_level = 0; /* default = no tracing */ + err->num_warnings = 0; /* no warnings emitted yet */ + err->msg_code = 0; /* may be useful as a flag for "no error" */ + + /* Initialize message table pointers */ + err->jpeg_message_table = jpeg_std_message_table; + err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1; + + err->addon_message_table = NULL; + err->first_addon_message = 0; /* for safety */ + err->last_addon_message = 0; + + return err; +} diff --git a/thirdparty/jpeg-9e/jerror.h b/thirdparty/jpeg-9e/jerror.h new file mode 100644 index 0000000..db608b9 --- /dev/null +++ b/thirdparty/jpeg-9e/jerror.h @@ -0,0 +1,304 @@ +/* + * jerror.h + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * Modified 1997-2018 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the error and message codes for the JPEG library. + * Edit this file to add new codes, or to translate the message strings to + * some other language. + * A set of error-reporting macros are defined too. Some applications using + * the JPEG library may wish to include this file to get the error codes + * and/or the macros. + */ + +/* + * To define the enum list of message codes, include this file without + * defining macro JMESSAGE. To create a message string table, include it + * again with a suitable JMESSAGE definition (see jerror.c for an example). + */ +#ifndef JMESSAGE +#ifndef JERROR_H +/* First time through, define the enum list */ +#define JMAKE_ENUM_LIST +#else +/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ +#define JMESSAGE(code,string) +#endif /* JERROR_H */ +#endif /* JMESSAGE */ + +#ifdef JMAKE_ENUM_LIST + +typedef enum { + +#define JMESSAGE(code,string) code , + +#endif /* JMAKE_ENUM_LIST */ + +JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ + +/* For maintenance convenience, list is alphabetical by message code name */ +JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") +JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") +JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") +JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") +JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request") +JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") +JMESSAGE(JERR_BAD_DCTSIZE, "DCT scaled block size %dx%d not supported") +JMESSAGE(JERR_BAD_DROP_SAMPLING, + "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c") +JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") +JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") +JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") +JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") +JMESSAGE(JERR_BAD_LIB_VERSION, + "Wrong JPEG library version: library is %d, caller expects %d") +JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") +JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") +JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") +JMESSAGE(JERR_BAD_PROGRESSION, + "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") +JMESSAGE(JERR_BAD_PROG_SCRIPT, + "Invalid progressive parameters at scan script entry %d") +JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") +JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") +JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") +JMESSAGE(JERR_BAD_STRUCT_SIZE, + "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") +JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") +JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") +JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") +JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") +JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") +JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") +JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") +JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") +JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") +JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") +JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") +JMESSAGE(JERR_EMS_READ, "Read from EMS failed") +JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") +JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") +JMESSAGE(JERR_FILE_READ, "Input file read error") +JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") +JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") +JMESSAGE(JERR_HUFF_CLEN_OUTOFBOUNDS, "Huffman code size table out of bounds") +JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") +JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") +JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") +JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") +JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, + "Cannot transcode due to multiple use of quantization table %d") +JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") +JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") +JMESSAGE(JERR_NOTIMPL, "Not implemented yet") +JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") +JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined") +JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") +JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") +JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") +JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") +JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") +JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") +JMESSAGE(JERR_QUANT_COMPONENTS, + "Cannot quantize more than %d color components") +JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") +JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") +JMESSAGE(JERR_SOF_BEFORE, "Invalid JPEG file structure: %s before SOF") +JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") +JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") +JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") +JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") +JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") +JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") +JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") +JMESSAGE(JERR_TFILE_WRITE, + "Write failed on temporary file --- out of disk space?") +JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") +JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") +JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") +JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") +JMESSAGE(JERR_XMS_READ, "Read from XMS failed") +JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") +JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) +JMESSAGE(JMSG_VERSION, JVERSION) +JMESSAGE(JTRC_16BIT_TABLES, + "Caution: quantization tables are too coarse for baseline JPEG") +JMESSAGE(JTRC_ADOBE, + "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") +JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") +JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") +JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") +JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") +JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") +JMESSAGE(JTRC_DRI, "Define Restart Interval %u") +JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") +JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") +JMESSAGE(JTRC_EOI, "End Of Image") +JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") +JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") +JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, + "Warning: thumbnail image size does not match data length %u") +JMESSAGE(JTRC_JFIF_EXTENSION, + "JFIF extension marker: type 0x%02x, length %u") +JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") +JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") +JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") +JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") +JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") +JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") +JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") +JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") +JMESSAGE(JTRC_RST, "RST%d") +JMESSAGE(JTRC_SMOOTH_NOTIMPL, + "Smoothing not supported with nonstandard sampling ratios") +JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") +JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") +JMESSAGE(JTRC_SOI, "Start of Image") +JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") +JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") +JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") +JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") +JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") +JMESSAGE(JTRC_THUMB_JPEG, + "JFIF extension marker: JPEG-compressed thumbnail image, length %u") +JMESSAGE(JTRC_THUMB_PALETTE, + "JFIF extension marker: palette thumbnail image, length %u") +JMESSAGE(JTRC_THUMB_RGB, + "JFIF extension marker: RGB thumbnail image, length %u") +JMESSAGE(JTRC_UNKNOWN_IDS, + "Unrecognized component IDs %d %d %d, assuming YCbCr") +JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") +JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") +JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") +JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code") +JMESSAGE(JWRN_BOGUS_PROGRESSION, + "Inconsistent progression sequence for component %d coefficient %d") +JMESSAGE(JWRN_EXTRANEOUS_DATA, + "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") +JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") +JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") +JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") +JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") +JMESSAGE(JWRN_MUST_RESYNC, + "Corrupt JPEG data: found marker 0x%02x instead of RST%d") +JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") +JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") + +#ifdef JMAKE_ENUM_LIST + + JMSG_LASTMSGCODE +} J_MESSAGE_CODE; + +#undef JMAKE_ENUM_LIST +#endif /* JMAKE_ENUM_LIST */ + +/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ +#undef JMESSAGE + + +#ifndef JERROR_H +#define JERROR_H + +/* Macros to simplify using the error and trace message stuff */ +/* The first parameter is either type of cinfo pointer */ + +/* Fatal errors (print message and exit) */ +#define ERREXIT(cinfo,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT1(cinfo,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT2(cinfo,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT3(cinfo,code,p1,p2,p3) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (cinfo)->err->msg_parm.i[2] = (p3), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (cinfo)->err->msg_parm.i[2] = (p3), \ + (cinfo)->err->msg_parm.i[3] = (p4), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT6(cinfo,code,p1,p2,p3,p4,p5,p6) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (cinfo)->err->msg_parm.i[2] = (p3), \ + (cinfo)->err->msg_parm.i[3] = (p4), \ + (cinfo)->err->msg_parm.i[4] = (p5), \ + (cinfo)->err->msg_parm.i[5] = (p6), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXITS(cinfo,code,str) \ + ((cinfo)->err->msg_code = (code), \ + strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) + +#define MAKESTMT(stuff) do { stuff } while (0) + +/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ +#define WARNMS(cinfo,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) +#define WARNMS1(cinfo,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) +#define WARNMS2(cinfo,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) + +/* Informational/debugging messages */ +#define TRACEMS(cinfo,lvl,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS1(cinfo,lvl,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS2(cinfo,lvl,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + _mp[4] = (p5); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMSS(cinfo,lvl,code,str) \ + ((cinfo)->err->msg_code = (code), \ + strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) + +#endif /* JERROR_H */ diff --git a/thirdparty/jpeg-9e/jfdctflt.c b/thirdparty/jpeg-9e/jfdctflt.c new file mode 100644 index 0000000..013f29e --- /dev/null +++ b/thirdparty/jpeg-9e/jfdctflt.c @@ -0,0 +1,176 @@ +/* + * jfdctflt.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2003-2017 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a floating-point implementation of the + * forward DCT (Discrete Cosine Transform). + * + * This implementation should be more accurate than either of the integer + * DCT implementations. However, it may not give the same results on all + * machines because of differences in roundoff behavior. Speed will depend + * on the hardware's floating point capacity. + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with a fixed-point + * implementation, accuracy is lost due to imprecise representation of the + * scaled quantization values. However, that problem does not arise if + * we use floating point arithmetic. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_FLOAT_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */ +#endif + + +/* + * Perform the forward DCT on one block of samples. + * + * cK represents cos(K*pi/16). + */ + +GLOBAL(void) +jpeg_fdct_float (FAST_FLOAT * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + FAST_FLOAT tmp10, tmp11, tmp12, tmp13; + FAST_FLOAT z1, z2, z3, z4, z5, z11, z13; + FAST_FLOAT *dataptr; + JSAMPROW elemptr; + int ctr; + + /* Pass 1: process rows. */ + + dataptr = data; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Load data into workspace */ + tmp0 = (FAST_FLOAT) (GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7])); + tmp7 = (FAST_FLOAT) (GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7])); + tmp1 = (FAST_FLOAT) (GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6])); + tmp6 = (FAST_FLOAT) (GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6])); + tmp2 = (FAST_FLOAT) (GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5])); + tmp5 = (FAST_FLOAT) (GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5])); + tmp3 = (FAST_FLOAT) (GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[4])); + tmp4 = (FAST_FLOAT) (GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4])); + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + /* Apply unsigned->signed conversion. */ + dataptr[0] = tmp10 + tmp11 - 8 * CENTERJSAMPLE; /* phase 3 */ + dataptr[4] = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ + dataptr[2] = tmp13 + z1; /* phase 5 */ + dataptr[6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ + z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ + z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ + z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[5] = z13 + z2; /* phase 6 */ + dataptr[3] = z13 - z2; + dataptr[1] = z11 + z4; + dataptr[7] = z11 - z4; + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ + dataptr[DCTSIZE*4] = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ + dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ + dataptr[DCTSIZE*6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ + z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ + z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ + z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ + dataptr[DCTSIZE*3] = z13 - z2; + dataptr[DCTSIZE*1] = z11 + z4; + dataptr[DCTSIZE*7] = z11 - z4; + + dataptr++; /* advance pointer to next column */ + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/jfdctfst.c b/thirdparty/jpeg-9e/jfdctfst.c new file mode 100644 index 0000000..5e4e017 --- /dev/null +++ b/thirdparty/jpeg-9e/jfdctfst.c @@ -0,0 +1,232 @@ +/* + * jfdctfst.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2003-2017 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a fast, not so accurate integer implementation of the + * forward DCT (Discrete Cosine Transform). + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with fixed-point math, + * accuracy is lost due to imprecise representation of the scaled + * quantization values. The smaller the quantization table entry, the less + * precise the scaled value, so this implementation does worse with high- + * quality-setting files than with low-quality ones. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_IFAST_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */ +#endif + + +/* Scaling decisions are generally the same as in the LL&M algorithm; + * see jfdctint.c for more details. However, we choose to descale + * (right shift) multiplication products as soon as they are formed, + * rather than carrying additional fractional bits into subsequent additions. + * This compromises accuracy slightly, but it lets us save a few shifts. + * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) + * everywhere except in the multiplications proper; this saves a good deal + * of work on 16-bit-int machines. + * + * Again to save a few shifts, the intermediate results between pass 1 and + * pass 2 are not upscaled, but are represented only to integral precision. + * + * A final compromise is to represent the multiplicative constants to only + * 8 fractional bits, rather than 13. This saves some shifting work on some + * machines, and may also reduce the cost of multiplication (since there + * are fewer one-bits in the constants). + */ + +#define CONST_BITS 8 + + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 8 +#define FIX_0_382683433 ((INT32) 98) /* FIX(0.382683433) */ +#define FIX_0_541196100 ((INT32) 139) /* FIX(0.541196100) */ +#define FIX_0_707106781 ((INT32) 181) /* FIX(0.707106781) */ +#define FIX_1_306562965 ((INT32) 334) /* FIX(1.306562965) */ +#else +#define FIX_0_382683433 FIX(0.382683433) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_707106781 FIX(0.707106781) +#define FIX_1_306562965 FIX(1.306562965) +#endif + + +/* We can gain a little more speed, with a further compromise in accuracy, + * by omitting the addition in a descaling shift. This yields an incorrectly + * rounded result half the time... + */ + +#ifndef USE_ACCURATE_ROUNDING +#undef DESCALE +#define DESCALE(x,n) RIGHT_SHIFT(x, n) +#endif + + +/* Multiply a DCTELEM variable by an INT32 constant, and immediately + * descale to yield a DCTELEM result. + */ + +#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) + + +/* + * Perform the forward DCT on one block of samples. + * + * cK represents cos(K*pi/16). + */ + +GLOBAL(void) +jpeg_fdct_ifast (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + DCTELEM tmp10, tmp11, tmp12, tmp13; + DCTELEM z1, z2, z3, z4, z5, z11, z13; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. */ + + dataptr = data; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Load data into workspace */ + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7]); + tmp7 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6]); + tmp6 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5]); + tmp5 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[4]); + tmp4 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]); + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + /* Apply unsigned->signed conversion. */ + dataptr[0] = tmp10 + tmp11 - 8 * CENTERJSAMPLE; /* phase 3 */ + dataptr[4] = tmp10 - tmp11; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ + dataptr[2] = tmp13 + z1; /* phase 5 */ + dataptr[6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ + z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ + z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ + z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[5] = z13 + z2; /* phase 6 */ + dataptr[3] = z13 - z2; + dataptr[1] = z11 + z4; + dataptr[7] = z11 - z4; + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ + dataptr[DCTSIZE*4] = tmp10 - tmp11; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ + dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ + dataptr[DCTSIZE*6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ + z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ + z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ + z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ + dataptr[DCTSIZE*3] = z13 - z2; + dataptr[DCTSIZE*1] = z11 + z4; + dataptr[DCTSIZE*7] = z11 - z4; + + dataptr++; /* advance pointer to next column */ + } +} + +#endif /* DCT_IFAST_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/jfdctint.c b/thirdparty/jpeg-9e/jfdctint.c new file mode 100644 index 0000000..05df475 --- /dev/null +++ b/thirdparty/jpeg-9e/jfdctint.c @@ -0,0 +1,4415 @@ +/* + * jfdctint.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modification developed 2003-2018 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a slow-but-accurate integer implementation of the + * forward DCT (Discrete Cosine Transform). + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on an algorithm described in + * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT + * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, + * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. + * The primary algorithm described there uses 11 multiplies and 29 adds. + * We use their alternate method with 12 multiplies and 32 adds. + * The advantage of this method is that no data path contains more than one + * multiplication; this allows a very simple and accurate implementation in + * scaled fixed-point arithmetic, with a minimal number of shifts. + * + * We also provide FDCT routines with various input sample block sizes for + * direct resolution reduction or enlargement and for direct resolving the + * common 2x1 and 1x2 subsampling cases without additional resampling: NxN + * (N=1...16), 2NxN, and Nx2N (N=1...8) pixels for one 8x8 output DCT block. + * + * For N<8 we fill the remaining block coefficients with zero. + * For N>8 we apply a partial N-point FDCT on the input samples, computing + * just the lower 8 frequency coefficients and discarding the rest. + * + * We must scale the output coefficients of the N-point FDCT appropriately + * to the standard 8-point FDCT level by 8/N per 1-D pass. This scaling + * is folded into the constant multipliers (pass 2) and/or final/initial + * shifting. + * + * CAUTION: We rely on the FIX() macro except for the N=1,2,4,8 cases + * since there would be too many additional constants to pre-calculate. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_ISLOW_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */ +#endif + + +/* + * The poop on this scaling stuff is as follows: + * + * Each 1-D DCT step produces outputs which are a factor of sqrt(N) + * larger than the true DCT outputs. The final outputs are therefore + * a factor of N larger than desired; since N=8 this can be cured by + * a simple right shift at the end of the algorithm. The advantage of + * this arrangement is that we save two multiplications per 1-D DCT, + * because the y0 and y4 outputs need not be divided by sqrt(N). + * In the IJG code, this factor of 8 is removed by the quantization step + * (in jcdctmgr.c), NOT in this module. + * + * We have to do addition and subtraction of the integer inputs, which + * is no problem, and multiplication by fractional constants, which is + * a problem to do in integer arithmetic. We multiply all the constants + * by CONST_SCALE and convert them to integer constants (thus retaining + * CONST_BITS bits of precision in the constants). After doing a + * multiplication we have to divide the product by CONST_SCALE, with proper + * rounding, to produce the correct output. This division can be done + * cheaply as a right shift of CONST_BITS bits. We postpone shifting + * as long as possible so that partial sums can be added together with + * full fractional precision. + * + * The outputs of the first pass are scaled up by PASS1_BITS bits so that + * they are represented to better-than-integral precision. These outputs + * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word + * with the recommended scaling. (For 12-bit sample data, the intermediate + * array is INT32 anyway.) + * + * To avoid overflow of the 32-bit intermediate results in pass 2, we must + * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis + * shows that the values given below are the most effective. + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 2 +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ +#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ +#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ +#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ +#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ +#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ +#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ +#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ +#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ +#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ +#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ +#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ +#else +#define FIX_0_298631336 FIX(0.298631336) +#define FIX_0_390180644 FIX(0.390180644) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_175875602 FIX(1.175875602) +#define FIX_1_501321110 FIX(1.501321110) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_1_961570560 FIX(1.961570560) +#define FIX_2_053119869 FIX(2.053119869) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_072711026 FIX(3.072711026) +#endif + + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +jpeg_fdct_islow (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * cK represents sqrt(2) * cos(K*pi/16). + */ + + dataptr = data; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "c1" should be "c6". + */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[4]); + + tmp10 = tmp0 + tmp3; + tmp12 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp13 = tmp1 - tmp2; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]); + tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) ((tmp10 + tmp11 - 8 * CENTERJSAMPLE) << PASS1_BITS); + dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS-PASS1_BITS-1); + + dataptr[2] = (DCTELEM) + RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */ + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) + RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */ + CONST_BITS-PASS1_BITS); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * i0..i3 in the paper are tmp0..tmp3 here. + */ + + tmp12 = tmp0 + tmp2; + tmp13 = tmp1 + tmp3; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */ + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS-PASS1_BITS-1); + + tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */ + tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */ + tmp12 += z1; + tmp13 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp0 += z1 + tmp12; + tmp3 += z1 + tmp13; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp1 += z1 + tmp13; + tmp2 += z1 + tmp12; + + dataptr[1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS-PASS1_BITS); + dataptr[5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS); + dataptr[7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS-PASS1_BITS); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * cK represents sqrt(2) * cos(K*pi/16). + */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "c1" should be "c6". + */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + + /* Add fudge factor here for final descale. */ + tmp10 = tmp0 + tmp3 + (ONE << (PASS1_BITS-1)); + tmp12 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp13 = tmp1 - tmp2; + + tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp10 + tmp11, PASS1_BITS); + dataptr[DCTSIZE*4] = (DCTELEM) RIGHT_SHIFT(tmp10 - tmp11, PASS1_BITS); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS+PASS1_BITS-1); + + dataptr[DCTSIZE*2] = (DCTELEM) + RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*6] = (DCTELEM) + RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */ + CONST_BITS+PASS1_BITS); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * i0..i3 in the paper are tmp0..tmp3 here. + */ + + tmp12 = tmp0 + tmp2; + tmp13 = tmp1 + tmp3; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */ + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS+PASS1_BITS-1); + + tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */ + tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */ + tmp12 += z1; + tmp13 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp0 += z1 + tmp12; + tmp3 += z1 + tmp13; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp1 += z1 + tmp13; + tmp2 += z1 + tmp12; + + dataptr[DCTSIZE*1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + +#ifdef DCT_SCALING_SUPPORTED + + +/* + * Perform the forward DCT on a 7x7 sample block. + */ + +GLOBAL(void) +jpeg_fdct_7x7 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3; + INT32 tmp10, tmp11, tmp12; + INT32 z1, z2, z3; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * cK represents sqrt(2) * cos(K*pi/14). + */ + + dataptr = data; + for (ctr = 0; ctr < 7; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[6]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[5]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[4]); + tmp3 = GETJSAMPLE(elemptr[3]); + + tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[6]); + tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[5]); + tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[4]); + + z1 = tmp0 + tmp2; + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((z1 + tmp1 + tmp3 - 7 * CENTERJSAMPLE) << PASS1_BITS); + tmp3 += tmp3; + z1 -= tmp3; + z1 -= tmp3; + z1 = MULTIPLY(z1, FIX(0.353553391)); /* (c2+c6-c4)/2 */ + z2 = MULTIPLY(tmp0 - tmp2, FIX(0.920609002)); /* (c2+c4-c6)/2 */ + z3 = MULTIPLY(tmp1 - tmp2, FIX(0.314692123)); /* c6 */ + dataptr[2] = (DCTELEM) DESCALE(z1 + z2 + z3, CONST_BITS-PASS1_BITS); + z1 -= z2; + z2 = MULTIPLY(tmp0 - tmp1, FIX(0.881747734)); /* c4 */ + dataptr[4] = (DCTELEM) + DESCALE(z2 + z3 - MULTIPLY(tmp1 - tmp3, FIX(0.707106781)), /* c2+c6-c4 */ + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS-PASS1_BITS); + + /* Odd part */ + + tmp1 = MULTIPLY(tmp10 + tmp11, FIX(0.935414347)); /* (c3+c1-c5)/2 */ + tmp2 = MULTIPLY(tmp10 - tmp11, FIX(0.170262339)); /* (c3+c5-c1)/2 */ + tmp0 = tmp1 - tmp2; + tmp1 += tmp2; + tmp2 = MULTIPLY(tmp11 + tmp12, - FIX(1.378756276)); /* -c1 */ + tmp1 += tmp2; + tmp3 = MULTIPLY(tmp10 + tmp12, FIX(0.613604268)); /* c5 */ + tmp0 += tmp3; + tmp2 += tmp3 + MULTIPLY(tmp12, FIX(1.870828693)); /* c3+c1-c5 */ + + dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS-PASS1_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS-PASS1_BITS); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/7)**2 = 64/49, which we fold + * into the constant multipliers: + * cK now represents sqrt(2) * cos(K*pi/14) * 64/49. + */ + + dataptr = data; + for (ctr = 0; ctr < 7; ctr++) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*6]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*5]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*4]; + tmp3 = dataptr[DCTSIZE*3]; + + tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*6]; + tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*5]; + tmp12 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*4]; + + z1 = tmp0 + tmp2; + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(z1 + tmp1 + tmp3, FIX(1.306122449)), /* 64/49 */ + CONST_BITS+PASS1_BITS); + tmp3 += tmp3; + z1 -= tmp3; + z1 -= tmp3; + z1 = MULTIPLY(z1, FIX(0.461784020)); /* (c2+c6-c4)/2 */ + z2 = MULTIPLY(tmp0 - tmp2, FIX(1.202428084)); /* (c2+c4-c6)/2 */ + z3 = MULTIPLY(tmp1 - tmp2, FIX(0.411026446)); /* c6 */ + dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + z2 + z3, CONST_BITS+PASS1_BITS); + z1 -= z2; + z2 = MULTIPLY(tmp0 - tmp1, FIX(1.151670509)); /* c4 */ + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(z2 + z3 - MULTIPLY(tmp1 - tmp3, FIX(0.923568041)), /* c2+c6-c4 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS+PASS1_BITS); + + /* Odd part */ + + tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.221765677)); /* (c3+c1-c5)/2 */ + tmp2 = MULTIPLY(tmp10 - tmp11, FIX(0.222383464)); /* (c3+c5-c1)/2 */ + tmp0 = tmp1 - tmp2; + tmp1 += tmp2; + tmp2 = MULTIPLY(tmp11 + tmp12, - FIX(1.800824523)); /* -c1 */ + tmp1 += tmp2; + tmp3 = MULTIPLY(tmp10 + tmp12, FIX(0.801442310)); /* c5 */ + tmp0 += tmp3; + tmp2 += tmp3 + MULTIPLY(tmp12, FIX(2.443531355)); /* c3+c1-c5 */ + + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 6x6 sample block. + */ + +GLOBAL(void) +jpeg_fdct_6x6 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2; + INT32 tmp10, tmp11, tmp12; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * cK represents sqrt(2) * cos(K*pi/12). + */ + + dataptr = data; + for (ctr = 0; ctr < 6; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[5]); + tmp11 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[4]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[3]); + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[5]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[4]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[3]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp11 - 6 * CENTERJSAMPLE) << PASS1_BITS); + dataptr[2] = (DCTELEM) + DESCALE(MULTIPLY(tmp12, FIX(1.224744871)), /* c2 */ + CONST_BITS-PASS1_BITS); + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(0.707106781)), /* c4 */ + CONST_BITS-PASS1_BITS); + + /* Odd part */ + + tmp10 = DESCALE(MULTIPLY(tmp0 + tmp2, FIX(0.366025404)), /* c5 */ + CONST_BITS-PASS1_BITS); + + dataptr[1] = (DCTELEM) (tmp10 + ((tmp0 + tmp1) << PASS1_BITS)); + dataptr[3] = (DCTELEM) ((tmp0 - tmp1 - tmp2) << PASS1_BITS); + dataptr[5] = (DCTELEM) (tmp10 + ((tmp2 - tmp1) << PASS1_BITS)); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/6)**2 = 16/9, which we fold + * into the constant multipliers: + * cK now represents sqrt(2) * cos(K*pi/12) * 16/9. + */ + + dataptr = data; + for (ctr = 0; ctr < 6; ctr++) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*5]; + tmp11 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*4]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*3]; + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*5]; + tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*4]; + tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*3]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 + tmp11, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(MULTIPLY(tmp12, FIX(2.177324216)), /* c2 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(1.257078722)), /* c4 */ + CONST_BITS+PASS1_BITS); + + /* Odd part */ + + tmp10 = MULTIPLY(tmp0 + tmp2, FIX(0.650711829)); /* c5 */ + + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp0 + tmp1, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 - tmp1 - tmp2, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*5] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp2 - tmp1, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 5x5 sample block. + */ + +GLOBAL(void) +jpeg_fdct_5x5 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2; + INT32 tmp10, tmp11; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * We scale the results further by 2 as part of output adaption + * scaling for different DCT size. + * cK represents sqrt(2) * cos(K*pi/10). + */ + + dataptr = data; + for (ctr = 0; ctr < 5; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[4]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[3]); + tmp2 = GETJSAMPLE(elemptr[2]); + + tmp10 = tmp0 + tmp1; + tmp11 = tmp0 - tmp1; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[4]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[3]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp2 - 5 * CENTERJSAMPLE) << (PASS1_BITS+1)); + tmp11 = MULTIPLY(tmp11, FIX(0.790569415)); /* (c2+c4)/2 */ + tmp10 -= tmp2 << 2; + tmp10 = MULTIPLY(tmp10, FIX(0.353553391)); /* (c2-c4)/2 */ + dataptr[2] = (DCTELEM) DESCALE(tmp11 + tmp10, CONST_BITS-PASS1_BITS-1); + dataptr[4] = (DCTELEM) DESCALE(tmp11 - tmp10, CONST_BITS-PASS1_BITS-1); + + /* Odd part */ + + tmp10 = MULTIPLY(tmp0 + tmp1, FIX(0.831253876)); /* c3 */ + + dataptr[1] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp0, FIX(0.513743148)), /* c1-c3 */ + CONST_BITS-PASS1_BITS-1); + dataptr[3] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp1, FIX(2.176250899)), /* c1+c3 */ + CONST_BITS-PASS1_BITS-1); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/5)**2 = 64/25, which we partially + * fold into the constant multipliers (other part was done in pass 1): + * cK now represents sqrt(2) * cos(K*pi/10) * 32/25. + */ + + dataptr = data; + for (ctr = 0; ctr < 5; ctr++) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*4]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*3]; + tmp2 = dataptr[DCTSIZE*2]; + + tmp10 = tmp0 + tmp1; + tmp11 = tmp0 - tmp1; + + tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*4]; + tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*3]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 + tmp2, FIX(1.28)), /* 32/25 */ + CONST_BITS+PASS1_BITS); + tmp11 = MULTIPLY(tmp11, FIX(1.011928851)); /* (c2+c4)/2 */ + tmp10 -= tmp2 << 2; + tmp10 = MULTIPLY(tmp10, FIX(0.452548340)); /* (c2-c4)/2 */ + dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp11 + tmp10, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp11 - tmp10, CONST_BITS+PASS1_BITS); + + /* Odd part */ + + tmp10 = MULTIPLY(tmp0 + tmp1, FIX(1.064004961)); /* c3 */ + + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp0, FIX(0.657591230)), /* c1-c3 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp1, FIX(2.785601151)), /* c1+c3 */ + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 4x4 sample block. + */ + +GLOBAL(void) +jpeg_fdct_4x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1; + INT32 tmp10, tmp11; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * We must also scale the output by (8/4)**2 = 2**2, which we add here. + * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT]. + */ + + dataptr = data; + for (ctr = 0; ctr < 4; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]); + + tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]); + tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp0 + tmp1 - 4 * CENTERJSAMPLE) << (PASS1_BITS+2)); + dataptr[2] = (DCTELEM) ((tmp0 - tmp1) << (PASS1_BITS+2)); + + /* Odd part */ + + tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS-PASS1_BITS-3); + + dataptr[1] = (DCTELEM) + RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */ + CONST_BITS-PASS1_BITS-2); + dataptr[3] = (DCTELEM) + RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */ + CONST_BITS-PASS1_BITS-2); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT]. + */ + + dataptr = data; + for (ctr = 0; ctr < 4; ctr++) { + /* Even part */ + + /* Add fudge factor here for final descale. */ + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*3] + (ONE << (PASS1_BITS-1)); + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*2]; + + tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*3]; + tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*2]; + + dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp0 + tmp1, PASS1_BITS); + dataptr[DCTSIZE*2] = (DCTELEM) RIGHT_SHIFT(tmp0 - tmp1, PASS1_BITS); + + /* Odd part */ + + tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS+PASS1_BITS-1); + + dataptr[DCTSIZE*1] = (DCTELEM) + RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) + RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */ + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 3x3 sample block. + */ + +GLOBAL(void) +jpeg_fdct_3x3 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * We scale the results further by 2**2 as part of output adaption + * scaling for different DCT size. + * cK represents sqrt(2) * cos(K*pi/6). + */ + + dataptr = data; + for (ctr = 0; ctr < 3; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[2]); + tmp1 = GETJSAMPLE(elemptr[1]); + + tmp2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[2]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp0 + tmp1 - 3 * CENTERJSAMPLE) << (PASS1_BITS+2)); + dataptr[2] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 - tmp1 - tmp1, FIX(0.707106781)), /* c2 */ + CONST_BITS-PASS1_BITS-2); + + /* Odd part */ + + dataptr[1] = (DCTELEM) + DESCALE(MULTIPLY(tmp2, FIX(1.224744871)), /* c1 */ + CONST_BITS-PASS1_BITS-2); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/3)**2 = 64/9, which we partially + * fold into the constant multipliers (other part was done in pass 1): + * cK now represents sqrt(2) * cos(K*pi/6) * 16/9. + */ + + dataptr = data; + for (ctr = 0; ctr < 3; ctr++) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*2]; + tmp1 = dataptr[DCTSIZE*1]; + + tmp2 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*2]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 + tmp1, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 - tmp1 - tmp1, FIX(1.257078722)), /* c2 */ + CONST_BITS+PASS1_BITS); + + /* Odd part */ + + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(MULTIPLY(tmp2, FIX(2.177324216)), /* c1 */ + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 2x2 sample block. + */ + +GLOBAL(void) +jpeg_fdct_2x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + DCTELEM tmp0, tmp1, tmp2, tmp3; + JSAMPROW elemptr; + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT. + */ + + /* Row 0 */ + elemptr = sample_data[0] + start_col; + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[1]); + tmp1 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[1]); + + /* Row 1 */ + elemptr = sample_data[1] + start_col; + + tmp2 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[1]); + tmp3 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[1]); + + /* Pass 2: process columns. + * We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/2)**2 = 2**4. + */ + + /* Column 0 */ + /* Apply unsigned->signed conversion. */ + data[DCTSIZE*0] = (tmp0 + tmp2 - 4 * CENTERJSAMPLE) << 4; + data[DCTSIZE*1] = (tmp0 - tmp2) << 4; + + /* Column 1 */ + data[DCTSIZE*0+1] = (tmp1 + tmp3) << 4; + data[DCTSIZE*1+1] = (tmp1 - tmp3) << 4; +} + + +/* + * Perform the forward DCT on a 1x1 sample block. + */ + +GLOBAL(void) +jpeg_fdct_1x1 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + DCTELEM dcval; + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + dcval = GETJSAMPLE(sample_data[0][start_col]); + + /* We leave the result scaled up by an overall factor of 8. */ + /* We must also scale the output by (8/1)**2 = 2**6. */ + /* Apply unsigned->signed conversion. */ + data[0] = (dcval - CENTERJSAMPLE) << 6; +} + + +/* + * Perform the forward DCT on a 9x9 sample block. + */ + +GLOBAL(void) +jpeg_fdct_9x9 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1, z2; + DCTELEM workspace[8]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * we scale the results further by 2 as part of output adaption + * scaling for different DCT size. + * cK represents sqrt(2) * cos(K*pi/18). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[8]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[7]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[6]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[5]); + tmp4 = GETJSAMPLE(elemptr[4]); + + tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[8]); + tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[7]); + tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[6]); + tmp13 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[5]); + + z1 = tmp0 + tmp2 + tmp3; + z2 = tmp1 + tmp4; + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) ((z1 + z2 - 9 * CENTERJSAMPLE) << 1); + dataptr[6] = (DCTELEM) + DESCALE(MULTIPLY(z1 - z2 - z2, FIX(0.707106781)), /* c6 */ + CONST_BITS-1); + z1 = MULTIPLY(tmp0 - tmp2, FIX(1.328926049)); /* c2 */ + z2 = MULTIPLY(tmp1 - tmp4 - tmp4, FIX(0.707106781)); /* c6 */ + dataptr[2] = (DCTELEM) + DESCALE(MULTIPLY(tmp2 - tmp3, FIX(1.083350441)) /* c4 */ + + z1 + z2, CONST_BITS-1); + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp3 - tmp0, FIX(0.245575608)) /* c8 */ + + z1 - z2, CONST_BITS-1); + + /* Odd part */ + + dataptr[3] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp12 - tmp13, FIX(1.224744871)), /* c3 */ + CONST_BITS-1); + + tmp11 = MULTIPLY(tmp11, FIX(1.224744871)); /* c3 */ + tmp0 = MULTIPLY(tmp10 + tmp12, FIX(0.909038955)); /* c5 */ + tmp1 = MULTIPLY(tmp10 + tmp13, FIX(0.483689525)); /* c7 */ + + dataptr[1] = (DCTELEM) DESCALE(tmp11 + tmp0 + tmp1, CONST_BITS-1); + + tmp2 = MULTIPLY(tmp12 - tmp13, FIX(1.392728481)); /* c1 */ + + dataptr[5] = (DCTELEM) DESCALE(tmp0 - tmp11 - tmp2, CONST_BITS-1); + dataptr[7] = (DCTELEM) DESCALE(tmp1 - tmp11 + tmp2, CONST_BITS-1); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == 9) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/9)**2 = 64/81, which we partially + * fold into the constant multipliers and final/initial shifting: + * cK now represents sqrt(2) * cos(K*pi/18) * 128/81. + */ + + dataptr = data; + wsptr = workspace; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*0]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*7]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*6]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*5]; + tmp4 = dataptr[DCTSIZE*4]; + + tmp10 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*0]; + tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*7]; + tmp12 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*6]; + tmp13 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*5]; + + z1 = tmp0 + tmp2 + tmp3; + z2 = tmp1 + tmp4; + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(z1 + z2, FIX(1.580246914)), /* 128/81 */ + CONST_BITS+2); + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(MULTIPLY(z1 - z2 - z2, FIX(1.117403309)), /* c6 */ + CONST_BITS+2); + z1 = MULTIPLY(tmp0 - tmp2, FIX(2.100031287)); /* c2 */ + z2 = MULTIPLY(tmp1 - tmp4 - tmp4, FIX(1.117403309)); /* c6 */ + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(MULTIPLY(tmp2 - tmp3, FIX(1.711961190)) /* c4 */ + + z1 + z2, CONST_BITS+2); + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp3 - tmp0, FIX(0.388070096)) /* c8 */ + + z1 - z2, CONST_BITS+2); + + /* Odd part */ + + dataptr[DCTSIZE*3] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp12 - tmp13, FIX(1.935399303)), /* c3 */ + CONST_BITS+2); + + tmp11 = MULTIPLY(tmp11, FIX(1.935399303)); /* c3 */ + tmp0 = MULTIPLY(tmp10 + tmp12, FIX(1.436506004)); /* c5 */ + tmp1 = MULTIPLY(tmp10 + tmp13, FIX(0.764348879)); /* c7 */ + + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(tmp11 + tmp0 + tmp1, CONST_BITS+2); + + tmp2 = MULTIPLY(tmp12 - tmp13, FIX(2.200854883)); /* c1 */ + + dataptr[DCTSIZE*5] = (DCTELEM) + DESCALE(tmp0 - tmp11 - tmp2, CONST_BITS+2); + dataptr[DCTSIZE*7] = (DCTELEM) + DESCALE(tmp1 - tmp11 + tmp2, CONST_BITS+2); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 10x10 sample block. + */ + +GLOBAL(void) +jpeg_fdct_10x10 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14; + DCTELEM workspace[8*2]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * we scale the results further by 2 as part of output adaption + * scaling for different DCT size. + * cK represents sqrt(2) * cos(K*pi/20). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[9]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[8]); + tmp12 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[7]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[6]); + tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[5]); + + tmp10 = tmp0 + tmp4; + tmp13 = tmp0 - tmp4; + tmp11 = tmp1 + tmp3; + tmp14 = tmp1 - tmp3; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[9]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[8]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[7]); + tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[6]); + tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[5]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp11 + tmp12 - 10 * CENTERJSAMPLE) << 1); + tmp12 += tmp12; + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.144122806)) - /* c4 */ + MULTIPLY(tmp11 - tmp12, FIX(0.437016024)), /* c8 */ + CONST_BITS-1); + tmp10 = MULTIPLY(tmp13 + tmp14, FIX(0.831253876)); /* c6 */ + dataptr[2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp13, FIX(0.513743148)), /* c2-c6 */ + CONST_BITS-1); + dataptr[6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp14, FIX(2.176250899)), /* c2+c6 */ + CONST_BITS-1); + + /* Odd part */ + + tmp10 = tmp0 + tmp4; + tmp11 = tmp1 - tmp3; + dataptr[5] = (DCTELEM) ((tmp10 - tmp11 - tmp2) << 1); + tmp2 <<= CONST_BITS; + dataptr[1] = (DCTELEM) + DESCALE(MULTIPLY(tmp0, FIX(1.396802247)) + /* c1 */ + MULTIPLY(tmp1, FIX(1.260073511)) + tmp2 + /* c3 */ + MULTIPLY(tmp3, FIX(0.642039522)) + /* c7 */ + MULTIPLY(tmp4, FIX(0.221231742)), /* c9 */ + CONST_BITS-1); + tmp12 = MULTIPLY(tmp0 - tmp4, FIX(0.951056516)) - /* (c3+c7)/2 */ + MULTIPLY(tmp1 + tmp3, FIX(0.587785252)); /* (c1-c9)/2 */ + tmp13 = MULTIPLY(tmp10 + tmp11, FIX(0.309016994)) + /* (c3-c7)/2 */ + (tmp11 << (CONST_BITS - 1)) - tmp2; + dataptr[3] = (DCTELEM) DESCALE(tmp12 + tmp13, CONST_BITS-1); + dataptr[7] = (DCTELEM) DESCALE(tmp12 - tmp13, CONST_BITS-1); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == 10) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/10)**2 = 16/25, which we partially + * fold into the constant multipliers and final/initial shifting: + * cK now represents sqrt(2) * cos(K*pi/20) * 32/25. + */ + + dataptr = data; + wsptr = workspace; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*1]; + tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*0]; + tmp12 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*7]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*6]; + tmp4 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*5]; + + tmp10 = tmp0 + tmp4; + tmp13 = tmp0 - tmp4; + tmp11 = tmp1 + tmp3; + tmp14 = tmp1 - tmp3; + + tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*1]; + tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*0]; + tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*7]; + tmp3 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*6]; + tmp4 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*5]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12, FIX(1.28)), /* 32/25 */ + CONST_BITS+2); + tmp12 += tmp12; + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.464477191)) - /* c4 */ + MULTIPLY(tmp11 - tmp12, FIX(0.559380511)), /* c8 */ + CONST_BITS+2); + tmp10 = MULTIPLY(tmp13 + tmp14, FIX(1.064004961)); /* c6 */ + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp13, FIX(0.657591230)), /* c2-c6 */ + CONST_BITS+2); + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp14, FIX(2.785601151)), /* c2+c6 */ + CONST_BITS+2); + + /* Odd part */ + + tmp10 = tmp0 + tmp4; + tmp11 = tmp1 - tmp3; + dataptr[DCTSIZE*5] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp11 - tmp2, FIX(1.28)), /* 32/25 */ + CONST_BITS+2); + tmp2 = MULTIPLY(tmp2, FIX(1.28)); /* 32/25 */ + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(MULTIPLY(tmp0, FIX(1.787906876)) + /* c1 */ + MULTIPLY(tmp1, FIX(1.612894094)) + tmp2 + /* c3 */ + MULTIPLY(tmp3, FIX(0.821810588)) + /* c7 */ + MULTIPLY(tmp4, FIX(0.283176630)), /* c9 */ + CONST_BITS+2); + tmp12 = MULTIPLY(tmp0 - tmp4, FIX(1.217352341)) - /* (c3+c7)/2 */ + MULTIPLY(tmp1 + tmp3, FIX(0.752365123)); /* (c1-c9)/2 */ + tmp13 = MULTIPLY(tmp10 + tmp11, FIX(0.395541753)) + /* (c3-c7)/2 */ + MULTIPLY(tmp11, FIX(0.64)) - tmp2; /* 16/25 */ + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp12 + tmp13, CONST_BITS+2); + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp12 - tmp13, CONST_BITS+2); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on an 11x11 sample block. + */ + +GLOBAL(void) +jpeg_fdct_11x11 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14; + INT32 z1, z2, z3; + DCTELEM workspace[8*3]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * we scale the results further by 2 as part of output adaption + * scaling for different DCT size. + * cK represents sqrt(2) * cos(K*pi/22). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[10]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[9]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[8]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[7]); + tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[6]); + tmp5 = GETJSAMPLE(elemptr[5]); + + tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[10]); + tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[9]); + tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[8]); + tmp13 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[7]); + tmp14 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[6]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp0 + tmp1 + tmp2 + tmp3 + tmp4 + tmp5 - 11 * CENTERJSAMPLE) << 1); + tmp5 += tmp5; + tmp0 -= tmp5; + tmp1 -= tmp5; + tmp2 -= tmp5; + tmp3 -= tmp5; + tmp4 -= tmp5; + z1 = MULTIPLY(tmp0 + tmp3, FIX(1.356927976)) + /* c2 */ + MULTIPLY(tmp2 + tmp4, FIX(0.201263574)); /* c10 */ + z2 = MULTIPLY(tmp1 - tmp3, FIX(0.926112931)); /* c6 */ + z3 = MULTIPLY(tmp0 - tmp1, FIX(1.189712156)); /* c4 */ + dataptr[2] = (DCTELEM) + DESCALE(z1 + z2 - MULTIPLY(tmp3, FIX(1.018300590)) /* c2+c8-c6 */ + - MULTIPLY(tmp4, FIX(1.390975730)), /* c4+c10 */ + CONST_BITS-1); + dataptr[4] = (DCTELEM) + DESCALE(z2 + z3 + MULTIPLY(tmp1, FIX(0.062335650)) /* c4-c6-c10 */ + - MULTIPLY(tmp2, FIX(1.356927976)) /* c2 */ + + MULTIPLY(tmp4, FIX(0.587485545)), /* c8 */ + CONST_BITS-1); + dataptr[6] = (DCTELEM) + DESCALE(z1 + z3 - MULTIPLY(tmp0, FIX(1.620527200)) /* c2+c4-c6 */ + - MULTIPLY(tmp2, FIX(0.788749120)), /* c8+c10 */ + CONST_BITS-1); + + /* Odd part */ + + tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.286413905)); /* c3 */ + tmp2 = MULTIPLY(tmp10 + tmp12, FIX(1.068791298)); /* c5 */ + tmp3 = MULTIPLY(tmp10 + tmp13, FIX(0.764581576)); /* c7 */ + tmp0 = tmp1 + tmp2 + tmp3 - MULTIPLY(tmp10, FIX(1.719967871)) /* c7+c5+c3-c1 */ + + MULTIPLY(tmp14, FIX(0.398430003)); /* c9 */ + tmp4 = MULTIPLY(tmp11 + tmp12, - FIX(0.764581576)); /* -c7 */ + tmp5 = MULTIPLY(tmp11 + tmp13, - FIX(1.399818907)); /* -c1 */ + tmp1 += tmp4 + tmp5 + MULTIPLY(tmp11, FIX(1.276416582)) /* c9+c7+c1-c3 */ + - MULTIPLY(tmp14, FIX(1.068791298)); /* c5 */ + tmp10 = MULTIPLY(tmp12 + tmp13, FIX(0.398430003)); /* c9 */ + tmp2 += tmp4 + tmp10 - MULTIPLY(tmp12, FIX(1.989053629)) /* c9+c5+c3-c7 */ + + MULTIPLY(tmp14, FIX(1.399818907)); /* c1 */ + tmp3 += tmp5 + tmp10 + MULTIPLY(tmp13, FIX(1.305598626)) /* c1+c5-c9-c7 */ + - MULTIPLY(tmp14, FIX(1.286413905)); /* c3 */ + + dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS-1); + dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS-1); + dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS-1); + dataptr[7] = (DCTELEM) DESCALE(tmp3, CONST_BITS-1); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == 11) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/11)**2 = 64/121, which we partially + * fold into the constant multipliers and final/initial shifting: + * cK now represents sqrt(2) * cos(K*pi/22) * 128/121. + */ + + dataptr = data; + wsptr = workspace; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*2]; + tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*1]; + tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*0]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*7]; + tmp4 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*6]; + tmp5 = dataptr[DCTSIZE*5]; + + tmp10 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*2]; + tmp11 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*1]; + tmp12 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*0]; + tmp13 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*7]; + tmp14 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*6]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 + tmp1 + tmp2 + tmp3 + tmp4 + tmp5, + FIX(1.057851240)), /* 128/121 */ + CONST_BITS+2); + tmp5 += tmp5; + tmp0 -= tmp5; + tmp1 -= tmp5; + tmp2 -= tmp5; + tmp3 -= tmp5; + tmp4 -= tmp5; + z1 = MULTIPLY(tmp0 + tmp3, FIX(1.435427942)) + /* c2 */ + MULTIPLY(tmp2 + tmp4, FIX(0.212906922)); /* c10 */ + z2 = MULTIPLY(tmp1 - tmp3, FIX(0.979689713)); /* c6 */ + z3 = MULTIPLY(tmp0 - tmp1, FIX(1.258538479)); /* c4 */ + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(z1 + z2 - MULTIPLY(tmp3, FIX(1.077210542)) /* c2+c8-c6 */ + - MULTIPLY(tmp4, FIX(1.471445400)), /* c4+c10 */ + CONST_BITS+2); + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(z2 + z3 + MULTIPLY(tmp1, FIX(0.065941844)) /* c4-c6-c10 */ + - MULTIPLY(tmp2, FIX(1.435427942)) /* c2 */ + + MULTIPLY(tmp4, FIX(0.621472312)), /* c8 */ + CONST_BITS+2); + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(z1 + z3 - MULTIPLY(tmp0, FIX(1.714276708)) /* c2+c4-c6 */ + - MULTIPLY(tmp2, FIX(0.834379234)), /* c8+c10 */ + CONST_BITS+2); + + /* Odd part */ + + tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.360834544)); /* c3 */ + tmp2 = MULTIPLY(tmp10 + tmp12, FIX(1.130622199)); /* c5 */ + tmp3 = MULTIPLY(tmp10 + tmp13, FIX(0.808813568)); /* c7 */ + tmp0 = tmp1 + tmp2 + tmp3 - MULTIPLY(tmp10, FIX(1.819470145)) /* c7+c5+c3-c1 */ + + MULTIPLY(tmp14, FIX(0.421479672)); /* c9 */ + tmp4 = MULTIPLY(tmp11 + tmp12, - FIX(0.808813568)); /* -c7 */ + tmp5 = MULTIPLY(tmp11 + tmp13, - FIX(1.480800167)); /* -c1 */ + tmp1 += tmp4 + tmp5 + MULTIPLY(tmp11, FIX(1.350258864)) /* c9+c7+c1-c3 */ + - MULTIPLY(tmp14, FIX(1.130622199)); /* c5 */ + tmp10 = MULTIPLY(tmp12 + tmp13, FIX(0.421479672)); /* c9 */ + tmp2 += tmp4 + tmp10 - MULTIPLY(tmp12, FIX(2.104122847)) /* c9+c5+c3-c7 */ + + MULTIPLY(tmp14, FIX(1.480800167)); /* c1 */ + tmp3 += tmp5 + tmp10 + MULTIPLY(tmp13, FIX(1.381129125)) /* c1+c5-c9-c7 */ + - MULTIPLY(tmp14, FIX(1.360834544)); /* c3 */ + + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+2); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+2); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+2); + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp3, CONST_BITS+2); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 12x12 sample block. + */ + +GLOBAL(void) +jpeg_fdct_12x12 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; + DCTELEM workspace[8*4]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT. + * cK represents sqrt(2) * cos(K*pi/24). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[11]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[10]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[9]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[8]); + tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[7]); + tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[6]); + + tmp10 = tmp0 + tmp5; + tmp13 = tmp0 - tmp5; + tmp11 = tmp1 + tmp4; + tmp14 = tmp1 - tmp4; + tmp12 = tmp2 + tmp3; + tmp15 = tmp2 - tmp3; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[11]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[10]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[9]); + tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[8]); + tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[7]); + tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[6]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) (tmp10 + tmp11 + tmp12 - 12 * CENTERJSAMPLE); + dataptr[6] = (DCTELEM) (tmp13 - tmp14 - tmp15); + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.224744871)), /* c4 */ + CONST_BITS); + dataptr[2] = (DCTELEM) + DESCALE(tmp14 - tmp15 + MULTIPLY(tmp13 + tmp15, FIX(1.366025404)), /* c2 */ + CONST_BITS); + + /* Odd part */ + + tmp10 = MULTIPLY(tmp1 + tmp4, FIX_0_541196100); /* c9 */ + tmp14 = tmp10 + MULTIPLY(tmp1, FIX_0_765366865); /* c3-c9 */ + tmp15 = tmp10 - MULTIPLY(tmp4, FIX_1_847759065); /* c3+c9 */ + tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.121971054)); /* c5 */ + tmp13 = MULTIPLY(tmp0 + tmp3, FIX(0.860918669)); /* c7 */ + tmp10 = tmp12 + tmp13 + tmp14 - MULTIPLY(tmp0, FIX(0.580774953)) /* c5+c7-c1 */ + + MULTIPLY(tmp5, FIX(0.184591911)); /* c11 */ + tmp11 = MULTIPLY(tmp2 + tmp3, - FIX(0.184591911)); /* -c11 */ + tmp12 += tmp11 - tmp15 - MULTIPLY(tmp2, FIX(2.339493912)) /* c1+c5-c11 */ + + MULTIPLY(tmp5, FIX(0.860918669)); /* c7 */ + tmp13 += tmp11 - tmp14 + MULTIPLY(tmp3, FIX(0.725788011)) /* c1+c11-c7 */ + - MULTIPLY(tmp5, FIX(1.121971054)); /* c5 */ + tmp11 = tmp15 + MULTIPLY(tmp0 - tmp3, FIX(1.306562965)) /* c3 */ + - MULTIPLY(tmp2 + tmp5, FIX_0_541196100); /* c9 */ + + dataptr[1] = (DCTELEM) DESCALE(tmp10, CONST_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp11, CONST_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp12, CONST_BITS); + dataptr[7] = (DCTELEM) DESCALE(tmp13, CONST_BITS); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == 12) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/12)**2 = 4/9, which we partially + * fold into the constant multipliers and final shifting: + * cK now represents sqrt(2) * cos(K*pi/24) * 8/9. + */ + + dataptr = data; + wsptr = workspace; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*3]; + tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*2]; + tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*1]; + tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*0]; + tmp4 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*7]; + tmp5 = dataptr[DCTSIZE*5] + dataptr[DCTSIZE*6]; + + tmp10 = tmp0 + tmp5; + tmp13 = tmp0 - tmp5; + tmp11 = tmp1 + tmp4; + tmp14 = tmp1 - tmp4; + tmp12 = tmp2 + tmp3; + tmp15 = tmp2 - tmp3; + + tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*3]; + tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*2]; + tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*1]; + tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*0]; + tmp4 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*7]; + tmp5 = dataptr[DCTSIZE*5] - dataptr[DCTSIZE*6]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12, FIX(0.888888889)), /* 8/9 */ + CONST_BITS+1); + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(MULTIPLY(tmp13 - tmp14 - tmp15, FIX(0.888888889)), /* 8/9 */ + CONST_BITS+1); + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.088662108)), /* c4 */ + CONST_BITS+1); + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(MULTIPLY(tmp14 - tmp15, FIX(0.888888889)) + /* 8/9 */ + MULTIPLY(tmp13 + tmp15, FIX(1.214244803)), /* c2 */ + CONST_BITS+1); + + /* Odd part */ + + tmp10 = MULTIPLY(tmp1 + tmp4, FIX(0.481063200)); /* c9 */ + tmp14 = tmp10 + MULTIPLY(tmp1, FIX(0.680326102)); /* c3-c9 */ + tmp15 = tmp10 - MULTIPLY(tmp4, FIX(1.642452502)); /* c3+c9 */ + tmp12 = MULTIPLY(tmp0 + tmp2, FIX(0.997307603)); /* c5 */ + tmp13 = MULTIPLY(tmp0 + tmp3, FIX(0.765261039)); /* c7 */ + tmp10 = tmp12 + tmp13 + tmp14 - MULTIPLY(tmp0, FIX(0.516244403)) /* c5+c7-c1 */ + + MULTIPLY(tmp5, FIX(0.164081699)); /* c11 */ + tmp11 = MULTIPLY(tmp2 + tmp3, - FIX(0.164081699)); /* -c11 */ + tmp12 += tmp11 - tmp15 - MULTIPLY(tmp2, FIX(2.079550144)) /* c1+c5-c11 */ + + MULTIPLY(tmp5, FIX(0.765261039)); /* c7 */ + tmp13 += tmp11 - tmp14 + MULTIPLY(tmp3, FIX(0.645144899)) /* c1+c11-c7 */ + - MULTIPLY(tmp5, FIX(0.997307603)); /* c5 */ + tmp11 = tmp15 + MULTIPLY(tmp0 - tmp3, FIX(1.161389302)) /* c3 */ + - MULTIPLY(tmp2 + tmp5, FIX(0.481063200)); /* c9 */ + + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp10, CONST_BITS+1); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp11, CONST_BITS+1); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12, CONST_BITS+1); + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp13, CONST_BITS+1); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 13x13 sample block. + */ + +GLOBAL(void) +jpeg_fdct_13x13 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; + INT32 z1, z2; + DCTELEM workspace[8*5]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT. + * cK represents sqrt(2) * cos(K*pi/26). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[12]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[11]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[10]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[9]); + tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[8]); + tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[7]); + tmp6 = GETJSAMPLE(elemptr[6]); + + tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[12]); + tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[11]); + tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[10]); + tmp13 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[9]); + tmp14 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[8]); + tmp15 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[7]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + (tmp0 + tmp1 + tmp2 + tmp3 + tmp4 + tmp5 + tmp6 - 13 * CENTERJSAMPLE); + tmp6 += tmp6; + tmp0 -= tmp6; + tmp1 -= tmp6; + tmp2 -= tmp6; + tmp3 -= tmp6; + tmp4 -= tmp6; + tmp5 -= tmp6; + dataptr[2] = (DCTELEM) + DESCALE(MULTIPLY(tmp0, FIX(1.373119086)) + /* c2 */ + MULTIPLY(tmp1, FIX(1.058554052)) + /* c6 */ + MULTIPLY(tmp2, FIX(0.501487041)) - /* c10 */ + MULTIPLY(tmp3, FIX(0.170464608)) - /* c12 */ + MULTIPLY(tmp4, FIX(0.803364869)) - /* c8 */ + MULTIPLY(tmp5, FIX(1.252223920)), /* c4 */ + CONST_BITS); + z1 = MULTIPLY(tmp0 - tmp2, FIX(1.155388986)) - /* (c4+c6)/2 */ + MULTIPLY(tmp3 - tmp4, FIX(0.435816023)) - /* (c2-c10)/2 */ + MULTIPLY(tmp1 - tmp5, FIX(0.316450131)); /* (c8-c12)/2 */ + z2 = MULTIPLY(tmp0 + tmp2, FIX(0.096834934)) - /* (c4-c6)/2 */ + MULTIPLY(tmp3 + tmp4, FIX(0.937303064)) + /* (c2+c10)/2 */ + MULTIPLY(tmp1 + tmp5, FIX(0.486914739)); /* (c8+c12)/2 */ + + dataptr[4] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS); + dataptr[6] = (DCTELEM) DESCALE(z1 - z2, CONST_BITS); + + /* Odd part */ + + tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.322312651)); /* c3 */ + tmp2 = MULTIPLY(tmp10 + tmp12, FIX(1.163874945)); /* c5 */ + tmp3 = MULTIPLY(tmp10 + tmp13, FIX(0.937797057)) + /* c7 */ + MULTIPLY(tmp14 + tmp15, FIX(0.338443458)); /* c11 */ + tmp0 = tmp1 + tmp2 + tmp3 - + MULTIPLY(tmp10, FIX(2.020082300)) + /* c3+c5+c7-c1 */ + MULTIPLY(tmp14, FIX(0.318774355)); /* c9-c11 */ + tmp4 = MULTIPLY(tmp14 - tmp15, FIX(0.937797057)) - /* c7 */ + MULTIPLY(tmp11 + tmp12, FIX(0.338443458)); /* c11 */ + tmp5 = MULTIPLY(tmp11 + tmp13, - FIX(1.163874945)); /* -c5 */ + tmp1 += tmp4 + tmp5 + + MULTIPLY(tmp11, FIX(0.837223564)) - /* c5+c9+c11-c3 */ + MULTIPLY(tmp14, FIX(2.341699410)); /* c1+c7 */ + tmp6 = MULTIPLY(tmp12 + tmp13, - FIX(0.657217813)); /* -c9 */ + tmp2 += tmp4 + tmp6 - + MULTIPLY(tmp12, FIX(1.572116027)) + /* c1+c5-c9-c11 */ + MULTIPLY(tmp15, FIX(2.260109708)); /* c3+c7 */ + tmp3 += tmp5 + tmp6 + + MULTIPLY(tmp13, FIX(2.205608352)) - /* c3+c5+c9-c7 */ + MULTIPLY(tmp15, FIX(1.742345811)); /* c1+c11 */ + + dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS); + dataptr[7] = (DCTELEM) DESCALE(tmp3, CONST_BITS); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == 13) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/13)**2 = 64/169, which we partially + * fold into the constant multipliers and final shifting: + * cK now represents sqrt(2) * cos(K*pi/26) * 128/169. + */ + + dataptr = data; + wsptr = workspace; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*4]; + tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*3]; + tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*2]; + tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*1]; + tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*0]; + tmp5 = dataptr[DCTSIZE*5] + dataptr[DCTSIZE*7]; + tmp6 = dataptr[DCTSIZE*6]; + + tmp10 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*4]; + tmp11 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*3]; + tmp12 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*2]; + tmp13 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*1]; + tmp14 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*0]; + tmp15 = dataptr[DCTSIZE*5] - dataptr[DCTSIZE*7]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 + tmp1 + tmp2 + tmp3 + tmp4 + tmp5 + tmp6, + FIX(0.757396450)), /* 128/169 */ + CONST_BITS+1); + tmp6 += tmp6; + tmp0 -= tmp6; + tmp1 -= tmp6; + tmp2 -= tmp6; + tmp3 -= tmp6; + tmp4 -= tmp6; + tmp5 -= tmp6; + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(MULTIPLY(tmp0, FIX(1.039995521)) + /* c2 */ + MULTIPLY(tmp1, FIX(0.801745081)) + /* c6 */ + MULTIPLY(tmp2, FIX(0.379824504)) - /* c10 */ + MULTIPLY(tmp3, FIX(0.129109289)) - /* c12 */ + MULTIPLY(tmp4, FIX(0.608465700)) - /* c8 */ + MULTIPLY(tmp5, FIX(0.948429952)), /* c4 */ + CONST_BITS+1); + z1 = MULTIPLY(tmp0 - tmp2, FIX(0.875087516)) - /* (c4+c6)/2 */ + MULTIPLY(tmp3 - tmp4, FIX(0.330085509)) - /* (c2-c10)/2 */ + MULTIPLY(tmp1 - tmp5, FIX(0.239678205)); /* (c8-c12)/2 */ + z2 = MULTIPLY(tmp0 + tmp2, FIX(0.073342435)) - /* (c4-c6)/2 */ + MULTIPLY(tmp3 + tmp4, FIX(0.709910013)) + /* (c2+c10)/2 */ + MULTIPLY(tmp1 + tmp5, FIX(0.368787494)); /* (c8+c12)/2 */ + + dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS+1); + dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 - z2, CONST_BITS+1); + + /* Odd part */ + + tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.001514908)); /* c3 */ + tmp2 = MULTIPLY(tmp10 + tmp12, FIX(0.881514751)); /* c5 */ + tmp3 = MULTIPLY(tmp10 + tmp13, FIX(0.710284161)) + /* c7 */ + MULTIPLY(tmp14 + tmp15, FIX(0.256335874)); /* c11 */ + tmp0 = tmp1 + tmp2 + tmp3 - + MULTIPLY(tmp10, FIX(1.530003162)) + /* c3+c5+c7-c1 */ + MULTIPLY(tmp14, FIX(0.241438564)); /* c9-c11 */ + tmp4 = MULTIPLY(tmp14 - tmp15, FIX(0.710284161)) - /* c7 */ + MULTIPLY(tmp11 + tmp12, FIX(0.256335874)); /* c11 */ + tmp5 = MULTIPLY(tmp11 + tmp13, - FIX(0.881514751)); /* -c5 */ + tmp1 += tmp4 + tmp5 + + MULTIPLY(tmp11, FIX(0.634110155)) - /* c5+c9+c11-c3 */ + MULTIPLY(tmp14, FIX(1.773594819)); /* c1+c7 */ + tmp6 = MULTIPLY(tmp12 + tmp13, - FIX(0.497774438)); /* -c9 */ + tmp2 += tmp4 + tmp6 - + MULTIPLY(tmp12, FIX(1.190715098)) + /* c1+c5-c9-c11 */ + MULTIPLY(tmp15, FIX(1.711799069)); /* c3+c7 */ + tmp3 += tmp5 + tmp6 + + MULTIPLY(tmp13, FIX(1.670519935)) - /* c3+c5+c9-c7 */ + MULTIPLY(tmp15, FIX(1.319646532)); /* c1+c11 */ + + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+1); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+1); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+1); + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp3, CONST_BITS+1); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 14x14 sample block. + */ + +GLOBAL(void) +jpeg_fdct_14x14 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; + DCTELEM workspace[8*6]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT. + * cK represents sqrt(2) * cos(K*pi/28). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[13]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[12]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[11]); + tmp13 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[10]); + tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[9]); + tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[8]); + tmp6 = GETJSAMPLE(elemptr[6]) + GETJSAMPLE(elemptr[7]); + + tmp10 = tmp0 + tmp6; + tmp14 = tmp0 - tmp6; + tmp11 = tmp1 + tmp5; + tmp15 = tmp1 - tmp5; + tmp12 = tmp2 + tmp4; + tmp16 = tmp2 - tmp4; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[13]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[12]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[11]); + tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[10]); + tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[9]); + tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[8]); + tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[7]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + (tmp10 + tmp11 + tmp12 + tmp13 - 14 * CENTERJSAMPLE); + tmp13 += tmp13; + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.274162392)) + /* c4 */ + MULTIPLY(tmp11 - tmp13, FIX(0.314692123)) - /* c12 */ + MULTIPLY(tmp12 - tmp13, FIX(0.881747734)), /* c8 */ + CONST_BITS); + + tmp10 = MULTIPLY(tmp14 + tmp15, FIX(1.105676686)); /* c6 */ + + dataptr[2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp14, FIX(0.273079590)) /* c2-c6 */ + + MULTIPLY(tmp16, FIX(0.613604268)), /* c10 */ + CONST_BITS); + dataptr[6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp15, FIX(1.719280954)) /* c6+c10 */ + - MULTIPLY(tmp16, FIX(1.378756276)), /* c2 */ + CONST_BITS); + + /* Odd part */ + + tmp10 = tmp1 + tmp2; + tmp11 = tmp5 - tmp4; + dataptr[7] = (DCTELEM) (tmp0 - tmp10 + tmp3 - tmp11 - tmp6); + tmp3 <<= CONST_BITS; + tmp10 = MULTIPLY(tmp10, - FIX(0.158341681)); /* -c13 */ + tmp11 = MULTIPLY(tmp11, FIX(1.405321284)); /* c1 */ + tmp10 += tmp11 - tmp3; + tmp11 = MULTIPLY(tmp0 + tmp2, FIX(1.197448846)) + /* c5 */ + MULTIPLY(tmp4 + tmp6, FIX(0.752406978)); /* c9 */ + dataptr[5] = (DCTELEM) + DESCALE(tmp10 + tmp11 - MULTIPLY(tmp2, FIX(2.373959773)) /* c3+c5-c13 */ + + MULTIPLY(tmp4, FIX(1.119999435)), /* c1+c11-c9 */ + CONST_BITS); + tmp12 = MULTIPLY(tmp0 + tmp1, FIX(1.334852607)) + /* c3 */ + MULTIPLY(tmp5 - tmp6, FIX(0.467085129)); /* c11 */ + dataptr[3] = (DCTELEM) + DESCALE(tmp10 + tmp12 - MULTIPLY(tmp1, FIX(0.424103948)) /* c3-c9-c13 */ + - MULTIPLY(tmp5, FIX(3.069855259)), /* c1+c5+c11 */ + CONST_BITS); + dataptr[1] = (DCTELEM) + DESCALE(tmp11 + tmp12 + tmp3 + tmp6 - + MULTIPLY(tmp0 + tmp6, FIX(1.126980169)), /* c3+c5-c1 */ + CONST_BITS); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == 14) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/14)**2 = 16/49, which we partially + * fold into the constant multipliers and final shifting: + * cK now represents sqrt(2) * cos(K*pi/28) * 32/49. + */ + + dataptr = data; + wsptr = workspace; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*5]; + tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*4]; + tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*3]; + tmp13 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*2]; + tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*1]; + tmp5 = dataptr[DCTSIZE*5] + wsptr[DCTSIZE*0]; + tmp6 = dataptr[DCTSIZE*6] + dataptr[DCTSIZE*7]; + + tmp10 = tmp0 + tmp6; + tmp14 = tmp0 - tmp6; + tmp11 = tmp1 + tmp5; + tmp15 = tmp1 - tmp5; + tmp12 = tmp2 + tmp4; + tmp16 = tmp2 - tmp4; + + tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*5]; + tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*4]; + tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*3]; + tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*2]; + tmp4 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*1]; + tmp5 = dataptr[DCTSIZE*5] - wsptr[DCTSIZE*0]; + tmp6 = dataptr[DCTSIZE*6] - dataptr[DCTSIZE*7]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12 + tmp13, + FIX(0.653061224)), /* 32/49 */ + CONST_BITS+1); + tmp13 += tmp13; + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp13, FIX(0.832106052)) + /* c4 */ + MULTIPLY(tmp11 - tmp13, FIX(0.205513223)) - /* c12 */ + MULTIPLY(tmp12 - tmp13, FIX(0.575835255)), /* c8 */ + CONST_BITS+1); + + tmp10 = MULTIPLY(tmp14 + tmp15, FIX(0.722074570)); /* c6 */ + + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp14, FIX(0.178337691)) /* c2-c6 */ + + MULTIPLY(tmp16, FIX(0.400721155)), /* c10 */ + CONST_BITS+1); + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp15, FIX(1.122795725)) /* c6+c10 */ + - MULTIPLY(tmp16, FIX(0.900412262)), /* c2 */ + CONST_BITS+1); + + /* Odd part */ + + tmp10 = tmp1 + tmp2; + tmp11 = tmp5 - tmp4; + dataptr[DCTSIZE*7] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 - tmp10 + tmp3 - tmp11 - tmp6, + FIX(0.653061224)), /* 32/49 */ + CONST_BITS+1); + tmp3 = MULTIPLY(tmp3 , FIX(0.653061224)); /* 32/49 */ + tmp10 = MULTIPLY(tmp10, - FIX(0.103406812)); /* -c13 */ + tmp11 = MULTIPLY(tmp11, FIX(0.917760839)); /* c1 */ + tmp10 += tmp11 - tmp3; + tmp11 = MULTIPLY(tmp0 + tmp2, FIX(0.782007410)) + /* c5 */ + MULTIPLY(tmp4 + tmp6, FIX(0.491367823)); /* c9 */ + dataptr[DCTSIZE*5] = (DCTELEM) + DESCALE(tmp10 + tmp11 - MULTIPLY(tmp2, FIX(1.550341076)) /* c3+c5-c13 */ + + MULTIPLY(tmp4, FIX(0.731428202)), /* c1+c11-c9 */ + CONST_BITS+1); + tmp12 = MULTIPLY(tmp0 + tmp1, FIX(0.871740478)) + /* c3 */ + MULTIPLY(tmp5 - tmp6, FIX(0.305035186)); /* c11 */ + dataptr[DCTSIZE*3] = (DCTELEM) + DESCALE(tmp10 + tmp12 - MULTIPLY(tmp1, FIX(0.276965844)) /* c3-c9-c13 */ + - MULTIPLY(tmp5, FIX(2.004803435)), /* c1+c5+c11 */ + CONST_BITS+1); + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(tmp11 + tmp12 + tmp3 + - MULTIPLY(tmp0, FIX(0.735987049)) /* c3+c5-c1 */ + - MULTIPLY(tmp6, FIX(0.082925825)), /* c9-c11-c13 */ + CONST_BITS+1); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 15x15 sample block. + */ + +GLOBAL(void) +jpeg_fdct_15x15 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; + INT32 z1, z2, z3; + DCTELEM workspace[8*7]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT. + * cK represents sqrt(2) * cos(K*pi/30). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[14]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[13]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[12]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[11]); + tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[10]); + tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[9]); + tmp6 = GETJSAMPLE(elemptr[6]) + GETJSAMPLE(elemptr[8]); + tmp7 = GETJSAMPLE(elemptr[7]); + + tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[14]); + tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[13]); + tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[12]); + tmp13 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[11]); + tmp14 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[10]); + tmp15 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[9]); + tmp16 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[8]); + + z1 = tmp0 + tmp4 + tmp5; + z2 = tmp1 + tmp3 + tmp6; + z3 = tmp2 + tmp7; + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) (z1 + z2 + z3 - 15 * CENTERJSAMPLE); + z3 += z3; + dataptr[6] = (DCTELEM) + DESCALE(MULTIPLY(z1 - z3, FIX(1.144122806)) - /* c6 */ + MULTIPLY(z2 - z3, FIX(0.437016024)), /* c12 */ + CONST_BITS); + tmp2 += ((tmp1 + tmp4) >> 1) - tmp7 - tmp7; + z1 = MULTIPLY(tmp3 - tmp2, FIX(1.531135173)) - /* c2+c14 */ + MULTIPLY(tmp6 - tmp2, FIX(2.238241955)); /* c4+c8 */ + z2 = MULTIPLY(tmp5 - tmp2, FIX(0.798468008)) - /* c8-c14 */ + MULTIPLY(tmp0 - tmp2, FIX(0.091361227)); /* c2-c4 */ + z3 = MULTIPLY(tmp0 - tmp3, FIX(1.383309603)) + /* c2 */ + MULTIPLY(tmp6 - tmp5, FIX(0.946293579)) + /* c8 */ + MULTIPLY(tmp1 - tmp4, FIX(0.790569415)); /* (c6+c12)/2 */ + + dataptr[2] = (DCTELEM) DESCALE(z1 + z3, CONST_BITS); + dataptr[4] = (DCTELEM) DESCALE(z2 + z3, CONST_BITS); + + /* Odd part */ + + tmp2 = MULTIPLY(tmp10 - tmp12 - tmp13 + tmp15 + tmp16, + FIX(1.224744871)); /* c5 */ + tmp1 = MULTIPLY(tmp10 - tmp14 - tmp15, FIX(1.344997024)) + /* c3 */ + MULTIPLY(tmp11 - tmp13 - tmp16, FIX(0.831253876)); /* c9 */ + tmp12 = MULTIPLY(tmp12, FIX(1.224744871)); /* c5 */ + tmp4 = MULTIPLY(tmp10 - tmp16, FIX(1.406466353)) + /* c1 */ + MULTIPLY(tmp11 + tmp14, FIX(1.344997024)) + /* c3 */ + MULTIPLY(tmp13 + tmp15, FIX(0.575212477)); /* c11 */ + tmp0 = MULTIPLY(tmp13, FIX(0.475753014)) - /* c7-c11 */ + MULTIPLY(tmp14, FIX(0.513743148)) + /* c3-c9 */ + MULTIPLY(tmp16, FIX(1.700497885)) + tmp4 + tmp12; /* c1+c13 */ + tmp3 = MULTIPLY(tmp10, - FIX(0.355500862)) - /* -(c1-c7) */ + MULTIPLY(tmp11, FIX(2.176250899)) - /* c3+c9 */ + MULTIPLY(tmp15, FIX(0.869244010)) + tmp4 - tmp12; /* c11+c13 */ + + dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS); + dataptr[7] = (DCTELEM) DESCALE(tmp3, CONST_BITS); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == 15) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/15)**2 = 64/225, which we partially + * fold into the constant multipliers and final shifting: + * cK now represents sqrt(2) * cos(K*pi/30) * 256/225. + */ + + dataptr = data; + wsptr = workspace; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*6]; + tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*5]; + tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*4]; + tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*3]; + tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*2]; + tmp5 = dataptr[DCTSIZE*5] + wsptr[DCTSIZE*1]; + tmp6 = dataptr[DCTSIZE*6] + wsptr[DCTSIZE*0]; + tmp7 = dataptr[DCTSIZE*7]; + + tmp10 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*6]; + tmp11 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*5]; + tmp12 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*4]; + tmp13 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*3]; + tmp14 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*2]; + tmp15 = dataptr[DCTSIZE*5] - wsptr[DCTSIZE*1]; + tmp16 = dataptr[DCTSIZE*6] - wsptr[DCTSIZE*0]; + + z1 = tmp0 + tmp4 + tmp5; + z2 = tmp1 + tmp3 + tmp6; + z3 = tmp2 + tmp7; + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(z1 + z2 + z3, FIX(1.137777778)), /* 256/225 */ + CONST_BITS+2); + z3 += z3; + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(MULTIPLY(z1 - z3, FIX(1.301757503)) - /* c6 */ + MULTIPLY(z2 - z3, FIX(0.497227121)), /* c12 */ + CONST_BITS+2); + tmp2 += ((tmp1 + tmp4) >> 1) - tmp7 - tmp7; + z1 = MULTIPLY(tmp3 - tmp2, FIX(1.742091575)) - /* c2+c14 */ + MULTIPLY(tmp6 - tmp2, FIX(2.546621957)); /* c4+c8 */ + z2 = MULTIPLY(tmp5 - tmp2, FIX(0.908479156)) - /* c8-c14 */ + MULTIPLY(tmp0 - tmp2, FIX(0.103948774)); /* c2-c4 */ + z3 = MULTIPLY(tmp0 - tmp3, FIX(1.573898926)) + /* c2 */ + MULTIPLY(tmp6 - tmp5, FIX(1.076671805)) + /* c8 */ + MULTIPLY(tmp1 - tmp4, FIX(0.899492312)); /* (c6+c12)/2 */ + + dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + z3, CONST_BITS+2); + dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(z2 + z3, CONST_BITS+2); + + /* Odd part */ + + tmp2 = MULTIPLY(tmp10 - tmp12 - tmp13 + tmp15 + tmp16, + FIX(1.393487498)); /* c5 */ + tmp1 = MULTIPLY(tmp10 - tmp14 - tmp15, FIX(1.530307725)) + /* c3 */ + MULTIPLY(tmp11 - tmp13 - tmp16, FIX(0.945782187)); /* c9 */ + tmp12 = MULTIPLY(tmp12, FIX(1.393487498)); /* c5 */ + tmp4 = MULTIPLY(tmp10 - tmp16, FIX(1.600246161)) + /* c1 */ + MULTIPLY(tmp11 + tmp14, FIX(1.530307725)) + /* c3 */ + MULTIPLY(tmp13 + tmp15, FIX(0.654463974)); /* c11 */ + tmp0 = MULTIPLY(tmp13, FIX(0.541301207)) - /* c7-c11 */ + MULTIPLY(tmp14, FIX(0.584525538)) + /* c3-c9 */ + MULTIPLY(tmp16, FIX(1.934788705)) + tmp4 + tmp12; /* c1+c13 */ + tmp3 = MULTIPLY(tmp10, - FIX(0.404480980)) - /* -(c1-c7) */ + MULTIPLY(tmp11, FIX(2.476089912)) - /* c3+c9 */ + MULTIPLY(tmp15, FIX(0.989006518)) + tmp4 - tmp12; /* c11+c13 */ + + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+2); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+2); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+2); + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp3, CONST_BITS+2); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 16x16 sample block. + */ + +GLOBAL(void) +jpeg_fdct_16x16 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17; + DCTELEM workspace[DCTSIZE2]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * cK represents sqrt(2) * cos(K*pi/32). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[15]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[14]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[13]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[12]); + tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[11]); + tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[10]); + tmp6 = GETJSAMPLE(elemptr[6]) + GETJSAMPLE(elemptr[9]); + tmp7 = GETJSAMPLE(elemptr[7]) + GETJSAMPLE(elemptr[8]); + + tmp10 = tmp0 + tmp7; + tmp14 = tmp0 - tmp7; + tmp11 = tmp1 + tmp6; + tmp15 = tmp1 - tmp6; + tmp12 = tmp2 + tmp5; + tmp16 = tmp2 - tmp5; + tmp13 = tmp3 + tmp4; + tmp17 = tmp3 - tmp4; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[15]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[14]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[13]); + tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[12]); + tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[11]); + tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[10]); + tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[9]); + tmp7 = GETJSAMPLE(elemptr[7]) - GETJSAMPLE(elemptr[8]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp11 + tmp12 + tmp13 - 16 * CENTERJSAMPLE) << PASS1_BITS); + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.306562965)) + /* c4[16] = c2[8] */ + MULTIPLY(tmp11 - tmp12, FIX_0_541196100), /* c12[16] = c6[8] */ + CONST_BITS-PASS1_BITS); + + tmp10 = MULTIPLY(tmp17 - tmp15, FIX(0.275899379)) + /* c14[16] = c7[8] */ + MULTIPLY(tmp14 - tmp16, FIX(1.387039845)); /* c2[16] = c1[8] */ + + dataptr[2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp15, FIX(1.451774982)) /* c6+c14 */ + + MULTIPLY(tmp16, FIX(2.172734804)), /* c2+c10 */ + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp14, FIX(0.211164243)) /* c2-c6 */ + - MULTIPLY(tmp17, FIX(1.061594338)), /* c10+c14 */ + CONST_BITS-PASS1_BITS); + + /* Odd part */ + + tmp11 = MULTIPLY(tmp0 + tmp1, FIX(1.353318001)) + /* c3 */ + MULTIPLY(tmp6 - tmp7, FIX(0.410524528)); /* c13 */ + tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.247225013)) + /* c5 */ + MULTIPLY(tmp5 + tmp7, FIX(0.666655658)); /* c11 */ + tmp13 = MULTIPLY(tmp0 + tmp3, FIX(1.093201867)) + /* c7 */ + MULTIPLY(tmp4 - tmp7, FIX(0.897167586)); /* c9 */ + tmp14 = MULTIPLY(tmp1 + tmp2, FIX(0.138617169)) + /* c15 */ + MULTIPLY(tmp6 - tmp5, FIX(1.407403738)); /* c1 */ + tmp15 = MULTIPLY(tmp1 + tmp3, - FIX(0.666655658)) + /* -c11 */ + MULTIPLY(tmp4 + tmp6, - FIX(1.247225013)); /* -c5 */ + tmp16 = MULTIPLY(tmp2 + tmp3, - FIX(1.353318001)) + /* -c3 */ + MULTIPLY(tmp5 - tmp4, FIX(0.410524528)); /* c13 */ + tmp10 = tmp11 + tmp12 + tmp13 - + MULTIPLY(tmp0, FIX(2.286341144)) + /* c7+c5+c3-c1 */ + MULTIPLY(tmp7, FIX(0.779653625)); /* c15+c13-c11+c9 */ + tmp11 += tmp14 + tmp15 + MULTIPLY(tmp1, FIX(0.071888074)) /* c9-c3-c15+c11 */ + - MULTIPLY(tmp6, FIX(1.663905119)); /* c7+c13+c1-c5 */ + tmp12 += tmp14 + tmp16 - MULTIPLY(tmp2, FIX(1.125726048)) /* c7+c5+c15-c3 */ + + MULTIPLY(tmp5, FIX(1.227391138)); /* c9-c11+c1-c13 */ + tmp13 += tmp15 + tmp16 + MULTIPLY(tmp3, FIX(1.065388962)) /* c15+c3+c11-c7 */ + + MULTIPLY(tmp4, FIX(2.167985692)); /* c1+c13+c5-c9 */ + + dataptr[1] = (DCTELEM) DESCALE(tmp10, CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp11, CONST_BITS-PASS1_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp12, CONST_BITS-PASS1_BITS); + dataptr[7] = (DCTELEM) DESCALE(tmp13, CONST_BITS-PASS1_BITS); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == DCTSIZE * 2) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/16)**2 = 1/2**2. + * cK represents sqrt(2) * cos(K*pi/32). + */ + + dataptr = data; + wsptr = workspace; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*3]; + tmp5 = dataptr[DCTSIZE*5] + wsptr[DCTSIZE*2]; + tmp6 = dataptr[DCTSIZE*6] + wsptr[DCTSIZE*1]; + tmp7 = dataptr[DCTSIZE*7] + wsptr[DCTSIZE*0]; + + tmp10 = tmp0 + tmp7; + tmp14 = tmp0 - tmp7; + tmp11 = tmp1 + tmp6; + tmp15 = tmp1 - tmp6; + tmp12 = tmp2 + tmp5; + tmp16 = tmp2 - tmp5; + tmp13 = tmp3 + tmp4; + tmp17 = tmp3 - tmp4; + + tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*3]; + tmp5 = dataptr[DCTSIZE*5] - wsptr[DCTSIZE*2]; + tmp6 = dataptr[DCTSIZE*6] - wsptr[DCTSIZE*1]; + tmp7 = dataptr[DCTSIZE*7] - wsptr[DCTSIZE*0]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(tmp10 + tmp11 + tmp12 + tmp13, PASS1_BITS+2); + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.306562965)) + /* c4[16] = c2[8] */ + MULTIPLY(tmp11 - tmp12, FIX_0_541196100), /* c12[16] = c6[8] */ + CONST_BITS+PASS1_BITS+2); + + tmp10 = MULTIPLY(tmp17 - tmp15, FIX(0.275899379)) + /* c14[16] = c7[8] */ + MULTIPLY(tmp14 - tmp16, FIX(1.387039845)); /* c2[16] = c1[8] */ + + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp15, FIX(1.451774982)) /* c6+c14 */ + + MULTIPLY(tmp16, FIX(2.172734804)), /* c2+10 */ + CONST_BITS+PASS1_BITS+2); + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp14, FIX(0.211164243)) /* c2-c6 */ + - MULTIPLY(tmp17, FIX(1.061594338)), /* c10+c14 */ + CONST_BITS+PASS1_BITS+2); + + /* Odd part */ + + tmp11 = MULTIPLY(tmp0 + tmp1, FIX(1.353318001)) + /* c3 */ + MULTIPLY(tmp6 - tmp7, FIX(0.410524528)); /* c13 */ + tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.247225013)) + /* c5 */ + MULTIPLY(tmp5 + tmp7, FIX(0.666655658)); /* c11 */ + tmp13 = MULTIPLY(tmp0 + tmp3, FIX(1.093201867)) + /* c7 */ + MULTIPLY(tmp4 - tmp7, FIX(0.897167586)); /* c9 */ + tmp14 = MULTIPLY(tmp1 + tmp2, FIX(0.138617169)) + /* c15 */ + MULTIPLY(tmp6 - tmp5, FIX(1.407403738)); /* c1 */ + tmp15 = MULTIPLY(tmp1 + tmp3, - FIX(0.666655658)) + /* -c11 */ + MULTIPLY(tmp4 + tmp6, - FIX(1.247225013)); /* -c5 */ + tmp16 = MULTIPLY(tmp2 + tmp3, - FIX(1.353318001)) + /* -c3 */ + MULTIPLY(tmp5 - tmp4, FIX(0.410524528)); /* c13 */ + tmp10 = tmp11 + tmp12 + tmp13 - + MULTIPLY(tmp0, FIX(2.286341144)) + /* c7+c5+c3-c1 */ + MULTIPLY(tmp7, FIX(0.779653625)); /* c15+c13-c11+c9 */ + tmp11 += tmp14 + tmp15 + MULTIPLY(tmp1, FIX(0.071888074)) /* c9-c3-c15+c11 */ + - MULTIPLY(tmp6, FIX(1.663905119)); /* c7+c13+c1-c5 */ + tmp12 += tmp14 + tmp16 - MULTIPLY(tmp2, FIX(1.125726048)) /* c7+c5+c15-c3 */ + + MULTIPLY(tmp5, FIX(1.227391138)); /* c9-c11+c1-c13 */ + tmp13 += tmp15 + tmp16 + MULTIPLY(tmp3, FIX(1.065388962)) /* c15+c3+c11-c7 */ + + MULTIPLY(tmp4, FIX(2.167985692)); /* c1+c13+c5-c9 */ + + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp10, CONST_BITS+PASS1_BITS+2); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp11, CONST_BITS+PASS1_BITS+2); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12, CONST_BITS+PASS1_BITS+2); + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp13, CONST_BITS+PASS1_BITS+2); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 16x8 sample block. + * + * 16-point FDCT in pass 1 (rows), 8-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_16x8 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17; + INT32 z1; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * 16-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/32). + */ + + dataptr = data; + ctr = 0; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[15]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[14]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[13]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[12]); + tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[11]); + tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[10]); + tmp6 = GETJSAMPLE(elemptr[6]) + GETJSAMPLE(elemptr[9]); + tmp7 = GETJSAMPLE(elemptr[7]) + GETJSAMPLE(elemptr[8]); + + tmp10 = tmp0 + tmp7; + tmp14 = tmp0 - tmp7; + tmp11 = tmp1 + tmp6; + tmp15 = tmp1 - tmp6; + tmp12 = tmp2 + tmp5; + tmp16 = tmp2 - tmp5; + tmp13 = tmp3 + tmp4; + tmp17 = tmp3 - tmp4; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[15]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[14]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[13]); + tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[12]); + tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[11]); + tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[10]); + tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[9]); + tmp7 = GETJSAMPLE(elemptr[7]) - GETJSAMPLE(elemptr[8]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp11 + tmp12 + tmp13 - 16 * CENTERJSAMPLE) << PASS1_BITS); + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.306562965)) + /* c4[16] = c2[8] */ + MULTIPLY(tmp11 - tmp12, FIX_0_541196100), /* c12[16] = c6[8] */ + CONST_BITS-PASS1_BITS); + + tmp10 = MULTIPLY(tmp17 - tmp15, FIX(0.275899379)) + /* c14[16] = c7[8] */ + MULTIPLY(tmp14 - tmp16, FIX(1.387039845)); /* c2[16] = c1[8] */ + + dataptr[2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp15, FIX(1.451774982)) /* c6+c14 */ + + MULTIPLY(tmp16, FIX(2.172734804)), /* c2+c10 */ + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp14, FIX(0.211164243)) /* c2-c6 */ + - MULTIPLY(tmp17, FIX(1.061594338)), /* c10+c14 */ + CONST_BITS-PASS1_BITS); + + /* Odd part */ + + tmp11 = MULTIPLY(tmp0 + tmp1, FIX(1.353318001)) + /* c3 */ + MULTIPLY(tmp6 - tmp7, FIX(0.410524528)); /* c13 */ + tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.247225013)) + /* c5 */ + MULTIPLY(tmp5 + tmp7, FIX(0.666655658)); /* c11 */ + tmp13 = MULTIPLY(tmp0 + tmp3, FIX(1.093201867)) + /* c7 */ + MULTIPLY(tmp4 - tmp7, FIX(0.897167586)); /* c9 */ + tmp14 = MULTIPLY(tmp1 + tmp2, FIX(0.138617169)) + /* c15 */ + MULTIPLY(tmp6 - tmp5, FIX(1.407403738)); /* c1 */ + tmp15 = MULTIPLY(tmp1 + tmp3, - FIX(0.666655658)) + /* -c11 */ + MULTIPLY(tmp4 + tmp6, - FIX(1.247225013)); /* -c5 */ + tmp16 = MULTIPLY(tmp2 + tmp3, - FIX(1.353318001)) + /* -c3 */ + MULTIPLY(tmp5 - tmp4, FIX(0.410524528)); /* c13 */ + tmp10 = tmp11 + tmp12 + tmp13 - + MULTIPLY(tmp0, FIX(2.286341144)) + /* c7+c5+c3-c1 */ + MULTIPLY(tmp7, FIX(0.779653625)); /* c15+c13-c11+c9 */ + tmp11 += tmp14 + tmp15 + MULTIPLY(tmp1, FIX(0.071888074)) /* c9-c3-c15+c11 */ + - MULTIPLY(tmp6, FIX(1.663905119)); /* c7+c13+c1-c5 */ + tmp12 += tmp14 + tmp16 - MULTIPLY(tmp2, FIX(1.125726048)) /* c7+c5+c15-c3 */ + + MULTIPLY(tmp5, FIX(1.227391138)); /* c9-c11+c1-c13 */ + tmp13 += tmp15 + tmp16 + MULTIPLY(tmp3, FIX(1.065388962)) /* c15+c3+c11-c7 */ + + MULTIPLY(tmp4, FIX(2.167985692)); /* c1+c13+c5-c9 */ + + dataptr[1] = (DCTELEM) DESCALE(tmp10, CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp11, CONST_BITS-PASS1_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp12, CONST_BITS-PASS1_BITS); + dataptr[7] = (DCTELEM) DESCALE(tmp13, CONST_BITS-PASS1_BITS); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by 8/16 = 1/2. + * 8-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/16). + */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "c1" should be "c6". + */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + + tmp10 = tmp0 + tmp3; + tmp12 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp13 = tmp1 - tmp2; + + tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS+1); + dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS+1); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */ + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */ + CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */ + CONST_BITS+PASS1_BITS+1); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * i0..i3 in the paper are tmp0..tmp3 here. + */ + + tmp12 = tmp0 + tmp2; + tmp13 = tmp1 + tmp3; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */ + tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */ + tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */ + tmp12 += z1; + tmp13 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp0 += z1 + tmp12; + tmp3 += z1 + tmp13; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp1 += z1 + tmp13; + tmp2 += z1 + tmp12; + + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp3, CONST_BITS+PASS1_BITS+1); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 14x7 sample block. + * + * 14-point FDCT in pass 1 (rows), 7-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_14x7 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; + INT32 z1, z2, z3; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Zero bottom row of output coefficient block. */ + MEMZERO(&data[DCTSIZE*7], SIZEOF(DCTELEM) * DCTSIZE); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * 14-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/28). + */ + + dataptr = data; + for (ctr = 0; ctr < 7; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[13]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[12]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[11]); + tmp13 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[10]); + tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[9]); + tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[8]); + tmp6 = GETJSAMPLE(elemptr[6]) + GETJSAMPLE(elemptr[7]); + + tmp10 = tmp0 + tmp6; + tmp14 = tmp0 - tmp6; + tmp11 = tmp1 + tmp5; + tmp15 = tmp1 - tmp5; + tmp12 = tmp2 + tmp4; + tmp16 = tmp2 - tmp4; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[13]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[12]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[11]); + tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[10]); + tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[9]); + tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[8]); + tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[7]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp11 + tmp12 + tmp13 - 14 * CENTERJSAMPLE) << PASS1_BITS); + tmp13 += tmp13; + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.274162392)) + /* c4 */ + MULTIPLY(tmp11 - tmp13, FIX(0.314692123)) - /* c12 */ + MULTIPLY(tmp12 - tmp13, FIX(0.881747734)), /* c8 */ + CONST_BITS-PASS1_BITS); + + tmp10 = MULTIPLY(tmp14 + tmp15, FIX(1.105676686)); /* c6 */ + + dataptr[2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp14, FIX(0.273079590)) /* c2-c6 */ + + MULTIPLY(tmp16, FIX(0.613604268)), /* c10 */ + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp15, FIX(1.719280954)) /* c6+c10 */ + - MULTIPLY(tmp16, FIX(1.378756276)), /* c2 */ + CONST_BITS-PASS1_BITS); + + /* Odd part */ + + tmp10 = tmp1 + tmp2; + tmp11 = tmp5 - tmp4; + dataptr[7] = (DCTELEM) ((tmp0 - tmp10 + tmp3 - tmp11 - tmp6) << PASS1_BITS); + tmp3 <<= CONST_BITS; + tmp10 = MULTIPLY(tmp10, - FIX(0.158341681)); /* -c13 */ + tmp11 = MULTIPLY(tmp11, FIX(1.405321284)); /* c1 */ + tmp10 += tmp11 - tmp3; + tmp11 = MULTIPLY(tmp0 + tmp2, FIX(1.197448846)) + /* c5 */ + MULTIPLY(tmp4 + tmp6, FIX(0.752406978)); /* c9 */ + dataptr[5] = (DCTELEM) + DESCALE(tmp10 + tmp11 - MULTIPLY(tmp2, FIX(2.373959773)) /* c3+c5-c13 */ + + MULTIPLY(tmp4, FIX(1.119999435)), /* c1+c11-c9 */ + CONST_BITS-PASS1_BITS); + tmp12 = MULTIPLY(tmp0 + tmp1, FIX(1.334852607)) + /* c3 */ + MULTIPLY(tmp5 - tmp6, FIX(0.467085129)); /* c11 */ + dataptr[3] = (DCTELEM) + DESCALE(tmp10 + tmp12 - MULTIPLY(tmp1, FIX(0.424103948)) /* c3-c9-c13 */ + - MULTIPLY(tmp5, FIX(3.069855259)), /* c1+c5+c11 */ + CONST_BITS-PASS1_BITS); + dataptr[1] = (DCTELEM) + DESCALE(tmp11 + tmp12 + tmp3 + tmp6 - + MULTIPLY(tmp0 + tmp6, FIX(1.126980169)), /* c3+c5-c1 */ + CONST_BITS-PASS1_BITS); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/14)*(8/7) = 32/49, which we + * partially fold into the constant multipliers and final shifting: + * 7-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/14) * 64/49. + */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*6]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*5]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*4]; + tmp3 = dataptr[DCTSIZE*3]; + + tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*6]; + tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*5]; + tmp12 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*4]; + + z1 = tmp0 + tmp2; + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(z1 + tmp1 + tmp3, FIX(1.306122449)), /* 64/49 */ + CONST_BITS+PASS1_BITS+1); + tmp3 += tmp3; + z1 -= tmp3; + z1 -= tmp3; + z1 = MULTIPLY(z1, FIX(0.461784020)); /* (c2+c6-c4)/2 */ + z2 = MULTIPLY(tmp0 - tmp2, FIX(1.202428084)); /* (c2+c4-c6)/2 */ + z3 = MULTIPLY(tmp1 - tmp2, FIX(0.411026446)); /* c6 */ + dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + z2 + z3, CONST_BITS+PASS1_BITS+1); + z1 -= z2; + z2 = MULTIPLY(tmp0 - tmp1, FIX(1.151670509)); /* c4 */ + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(z2 + z3 - MULTIPLY(tmp1 - tmp3, FIX(0.923568041)), /* c2+c6-c4 */ + CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS+PASS1_BITS+1); + + /* Odd part */ + + tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.221765677)); /* (c3+c1-c5)/2 */ + tmp2 = MULTIPLY(tmp10 - tmp11, FIX(0.222383464)); /* (c3+c5-c1)/2 */ + tmp0 = tmp1 - tmp2; + tmp1 += tmp2; + tmp2 = MULTIPLY(tmp11 + tmp12, - FIX(1.800824523)); /* -c1 */ + tmp1 += tmp2; + tmp3 = MULTIPLY(tmp10 + tmp12, FIX(0.801442310)); /* c5 */ + tmp0 += tmp3; + tmp2 += tmp3 + MULTIPLY(tmp12, FIX(2.443531355)); /* c3+c1-c5 */ + + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+PASS1_BITS+1); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 12x6 sample block. + * + * 12-point FDCT in pass 1 (rows), 6-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_12x6 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Zero 2 bottom rows of output coefficient block. */ + MEMZERO(&data[DCTSIZE*6], SIZEOF(DCTELEM) * DCTSIZE * 2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * 12-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/24). + */ + + dataptr = data; + for (ctr = 0; ctr < 6; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[11]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[10]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[9]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[8]); + tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[7]); + tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[6]); + + tmp10 = tmp0 + tmp5; + tmp13 = tmp0 - tmp5; + tmp11 = tmp1 + tmp4; + tmp14 = tmp1 - tmp4; + tmp12 = tmp2 + tmp3; + tmp15 = tmp2 - tmp3; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[11]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[10]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[9]); + tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[8]); + tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[7]); + tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[6]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp11 + tmp12 - 12 * CENTERJSAMPLE) << PASS1_BITS); + dataptr[6] = (DCTELEM) ((tmp13 - tmp14 - tmp15) << PASS1_BITS); + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.224744871)), /* c4 */ + CONST_BITS-PASS1_BITS); + dataptr[2] = (DCTELEM) + DESCALE(tmp14 - tmp15 + MULTIPLY(tmp13 + tmp15, FIX(1.366025404)), /* c2 */ + CONST_BITS-PASS1_BITS); + + /* Odd part */ + + tmp10 = MULTIPLY(tmp1 + tmp4, FIX_0_541196100); /* c9 */ + tmp14 = tmp10 + MULTIPLY(tmp1, FIX_0_765366865); /* c3-c9 */ + tmp15 = tmp10 - MULTIPLY(tmp4, FIX_1_847759065); /* c3+c9 */ + tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.121971054)); /* c5 */ + tmp13 = MULTIPLY(tmp0 + tmp3, FIX(0.860918669)); /* c7 */ + tmp10 = tmp12 + tmp13 + tmp14 - MULTIPLY(tmp0, FIX(0.580774953)) /* c5+c7-c1 */ + + MULTIPLY(tmp5, FIX(0.184591911)); /* c11 */ + tmp11 = MULTIPLY(tmp2 + tmp3, - FIX(0.184591911)); /* -c11 */ + tmp12 += tmp11 - tmp15 - MULTIPLY(tmp2, FIX(2.339493912)) /* c1+c5-c11 */ + + MULTIPLY(tmp5, FIX(0.860918669)); /* c7 */ + tmp13 += tmp11 - tmp14 + MULTIPLY(tmp3, FIX(0.725788011)) /* c1+c11-c7 */ + - MULTIPLY(tmp5, FIX(1.121971054)); /* c5 */ + tmp11 = tmp15 + MULTIPLY(tmp0 - tmp3, FIX(1.306562965)) /* c3 */ + - MULTIPLY(tmp2 + tmp5, FIX_0_541196100); /* c9 */ + + dataptr[1] = (DCTELEM) DESCALE(tmp10, CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp11, CONST_BITS-PASS1_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp12, CONST_BITS-PASS1_BITS); + dataptr[7] = (DCTELEM) DESCALE(tmp13, CONST_BITS-PASS1_BITS); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/12)*(8/6) = 8/9, which we + * partially fold into the constant multipliers and final shifting: + * 6-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/12) * 16/9. + */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*5]; + tmp11 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*4]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*3]; + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*5]; + tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*4]; + tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*3]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 + tmp11, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(MULTIPLY(tmp12, FIX(2.177324216)), /* c2 */ + CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(1.257078722)), /* c4 */ + CONST_BITS+PASS1_BITS+1); + + /* Odd part */ + + tmp10 = MULTIPLY(tmp0 + tmp2, FIX(0.650711829)); /* c5 */ + + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp0 + tmp1, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*3] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 - tmp1 - tmp2, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*5] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp2 - tmp1, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS+1); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 10x5 sample block. + * + * 10-point FDCT in pass 1 (rows), 5-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_10x5 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Zero 3 bottom rows of output coefficient block. */ + MEMZERO(&data[DCTSIZE*5], SIZEOF(DCTELEM) * DCTSIZE * 3); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * 10-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/20). + */ + + dataptr = data; + for (ctr = 0; ctr < 5; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[9]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[8]); + tmp12 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[7]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[6]); + tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[5]); + + tmp10 = tmp0 + tmp4; + tmp13 = tmp0 - tmp4; + tmp11 = tmp1 + tmp3; + tmp14 = tmp1 - tmp3; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[9]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[8]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[7]); + tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[6]); + tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[5]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp11 + tmp12 - 10 * CENTERJSAMPLE) << PASS1_BITS); + tmp12 += tmp12; + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.144122806)) - /* c4 */ + MULTIPLY(tmp11 - tmp12, FIX(0.437016024)), /* c8 */ + CONST_BITS-PASS1_BITS); + tmp10 = MULTIPLY(tmp13 + tmp14, FIX(0.831253876)); /* c6 */ + dataptr[2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp13, FIX(0.513743148)), /* c2-c6 */ + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp14, FIX(2.176250899)), /* c2+c6 */ + CONST_BITS-PASS1_BITS); + + /* Odd part */ + + tmp10 = tmp0 + tmp4; + tmp11 = tmp1 - tmp3; + dataptr[5] = (DCTELEM) ((tmp10 - tmp11 - tmp2) << PASS1_BITS); + tmp2 <<= CONST_BITS; + dataptr[1] = (DCTELEM) + DESCALE(MULTIPLY(tmp0, FIX(1.396802247)) + /* c1 */ + MULTIPLY(tmp1, FIX(1.260073511)) + tmp2 + /* c3 */ + MULTIPLY(tmp3, FIX(0.642039522)) + /* c7 */ + MULTIPLY(tmp4, FIX(0.221231742)), /* c9 */ + CONST_BITS-PASS1_BITS); + tmp12 = MULTIPLY(tmp0 - tmp4, FIX(0.951056516)) - /* (c3+c7)/2 */ + MULTIPLY(tmp1 + tmp3, FIX(0.587785252)); /* (c1-c9)/2 */ + tmp13 = MULTIPLY(tmp10 + tmp11, FIX(0.309016994)) + /* (c3-c7)/2 */ + (tmp11 << (CONST_BITS - 1)) - tmp2; + dataptr[3] = (DCTELEM) DESCALE(tmp12 + tmp13, CONST_BITS-PASS1_BITS); + dataptr[7] = (DCTELEM) DESCALE(tmp12 - tmp13, CONST_BITS-PASS1_BITS); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/10)*(8/5) = 32/25, which we + * fold into the constant multipliers: + * 5-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/10) * 32/25. + */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*4]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*3]; + tmp2 = dataptr[DCTSIZE*2]; + + tmp10 = tmp0 + tmp1; + tmp11 = tmp0 - tmp1; + + tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*4]; + tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*3]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 + tmp2, FIX(1.28)), /* 32/25 */ + CONST_BITS+PASS1_BITS); + tmp11 = MULTIPLY(tmp11, FIX(1.011928851)); /* (c2+c4)/2 */ + tmp10 -= tmp2 << 2; + tmp10 = MULTIPLY(tmp10, FIX(0.452548340)); /* (c2-c4)/2 */ + dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp11 + tmp10, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp11 - tmp10, CONST_BITS+PASS1_BITS); + + /* Odd part */ + + tmp10 = MULTIPLY(tmp0 + tmp1, FIX(1.064004961)); /* c3 */ + + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp0, FIX(0.657591230)), /* c1-c3 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp1, FIX(2.785601151)), /* c1+c3 */ + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on an 8x4 sample block. + * + * 8-point FDCT in pass 1 (rows), 4-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_8x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Zero 4 bottom rows of output coefficient block. */ + MEMZERO(&data[DCTSIZE*4], SIZEOF(DCTELEM) * DCTSIZE * 4); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * We must also scale the output by 8/4 = 2, which we add here. + * 8-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/16). + */ + + dataptr = data; + for (ctr = 0; ctr < 4; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "c1" should be "c6". + */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[4]); + + tmp10 = tmp0 + tmp3; + tmp12 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp13 = tmp1 - tmp2; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]); + tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp11 - 8 * CENTERJSAMPLE) << (PASS1_BITS+1)); + dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << (PASS1_BITS+1)); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS-PASS1_BITS-2); + + dataptr[2] = (DCTELEM) + RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */ + CONST_BITS-PASS1_BITS-1); + dataptr[6] = (DCTELEM) + RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */ + CONST_BITS-PASS1_BITS-1); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * i0..i3 in the paper are tmp0..tmp3 here. + */ + + tmp12 = tmp0 + tmp2; + tmp13 = tmp1 + tmp3; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */ + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS-PASS1_BITS-2); + + tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */ + tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */ + tmp12 += z1; + tmp13 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp0 += z1 + tmp12; + tmp3 += z1 + tmp13; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp1 += z1 + tmp13; + tmp2 += z1 + tmp12; + + dataptr[1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS-PASS1_BITS-1); + dataptr[3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS-PASS1_BITS-1); + dataptr[5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS-1); + dataptr[7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS-PASS1_BITS-1); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * 4-point FDCT kernel, + * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT]. + */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + /* Add fudge factor here for final descale. */ + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*3] + (ONE << (PASS1_BITS-1)); + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*2]; + + tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*3]; + tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*2]; + + dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp0 + tmp1, PASS1_BITS); + dataptr[DCTSIZE*2] = (DCTELEM) RIGHT_SHIFT(tmp0 - tmp1, PASS1_BITS); + + /* Odd part */ + + tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS+PASS1_BITS-1); + + dataptr[DCTSIZE*1] = (DCTELEM) + RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) + RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */ + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 6x3 sample block. + * + * 6-point FDCT in pass 1 (rows), 3-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_6x3 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2; + INT32 tmp10, tmp11, tmp12; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * We scale the results further by 2 as part of output adaption + * scaling for different DCT size. + * 6-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/12). + */ + + dataptr = data; + for (ctr = 0; ctr < 3; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[5]); + tmp11 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[4]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[3]); + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[5]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[4]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[3]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp11 - 6 * CENTERJSAMPLE) << (PASS1_BITS+1)); + dataptr[2] = (DCTELEM) + DESCALE(MULTIPLY(tmp12, FIX(1.224744871)), /* c2 */ + CONST_BITS-PASS1_BITS-1); + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(0.707106781)), /* c4 */ + CONST_BITS-PASS1_BITS-1); + + /* Odd part */ + + tmp10 = DESCALE(MULTIPLY(tmp0 + tmp2, FIX(0.366025404)), /* c5 */ + CONST_BITS-PASS1_BITS-1); + + dataptr[1] = (DCTELEM) (tmp10 + ((tmp0 + tmp1) << (PASS1_BITS+1))); + dataptr[3] = (DCTELEM) ((tmp0 - tmp1 - tmp2) << (PASS1_BITS+1)); + dataptr[5] = (DCTELEM) (tmp10 + ((tmp2 - tmp1) << (PASS1_BITS+1))); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/6)*(8/3) = 32/9, which we partially + * fold into the constant multipliers (other part was done in pass 1): + * 3-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/6) * 16/9. + */ + + dataptr = data; + for (ctr = 0; ctr < 6; ctr++) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*2]; + tmp1 = dataptr[DCTSIZE*1]; + + tmp2 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*2]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 + tmp1, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 - tmp1 - tmp1, FIX(1.257078722)), /* c2 */ + CONST_BITS+PASS1_BITS); + + /* Odd part */ + + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(MULTIPLY(tmp2, FIX(2.177324216)), /* c1 */ + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 4x2 sample block. + * + * 4-point FDCT in pass 1 (rows), 2-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_4x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + DCTELEM tmp0, tmp2, tmp10, tmp12, tmp4, tmp5; + INT32 tmp1, tmp3, tmp11, tmp13; + INT32 z1, z2, z3; + JSAMPROW elemptr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT. + * 4-point FDCT kernel, + * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT]. + */ + + /* Row 0 */ + elemptr = sample_data[0] + start_col; + + /* Even part */ + + tmp4 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]); + tmp5 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]); + + tmp0 = tmp4 + tmp5; + tmp2 = tmp4 - tmp5; + + /* Odd part */ + + z2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]); + z3 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]); + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS-3-1); + tmp1 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + /* Row 1 */ + elemptr = sample_data[1] + start_col; + + /* Even part */ + + tmp4 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]); + tmp5 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]); + + tmp10 = tmp4 + tmp5; + tmp12 = tmp4 - tmp5; + + /* Odd part */ + + z2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]); + z3 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]); + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + tmp11 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp13 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + /* Pass 2: process columns. + * We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/4)*(8/2) = 2**3. + */ + + /* Column 0 */ + /* Apply unsigned->signed conversion. */ + data[DCTSIZE*0] = (tmp0 + tmp10 - 8 * CENTERJSAMPLE) << 3; + data[DCTSIZE*1] = (tmp0 - tmp10) << 3; + + /* Column 1 */ + data[DCTSIZE*0+1] = (DCTELEM) RIGHT_SHIFT(tmp1 + tmp11, CONST_BITS-3); + data[DCTSIZE*1+1] = (DCTELEM) RIGHT_SHIFT(tmp1 - tmp11, CONST_BITS-3); + + /* Column 2 */ + data[DCTSIZE*0+2] = (tmp2 + tmp12) << 3; + data[DCTSIZE*1+2] = (tmp2 - tmp12) << 3; + + /* Column 3 */ + data[DCTSIZE*0+3] = (DCTELEM) RIGHT_SHIFT(tmp3 + tmp13, CONST_BITS-3); + data[DCTSIZE*1+3] = (DCTELEM) RIGHT_SHIFT(tmp3 - tmp13, CONST_BITS-3); +} + + +/* + * Perform the forward DCT on a 2x1 sample block. + * + * 2-point FDCT in pass 1 (rows), 1-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_2x1 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + DCTELEM tmp0, tmp1; + JSAMPROW elemptr; + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + elemptr = sample_data[0] + start_col; + + tmp0 = GETJSAMPLE(elemptr[0]); + tmp1 = GETJSAMPLE(elemptr[1]); + + /* We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/2)*(8/1) = 2**5. + */ + + /* Even part */ + + /* Apply unsigned->signed conversion. */ + data[0] = (tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 5; + + /* Odd part */ + + data[1] = (tmp0 - tmp1) << 5; +} + + +/* + * Perform the forward DCT on an 8x16 sample block. + * + * 8-point FDCT in pass 1 (rows), 16-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_8x16 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17; + INT32 z1; + DCTELEM workspace[DCTSIZE2]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * 8-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/16). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "c1" should be "c6". + */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5]); + tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[4]); + + tmp10 = tmp0 + tmp3; + tmp12 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp13 = tmp1 - tmp2; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]); + tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) ((tmp10 + tmp11 - 8 * CENTERJSAMPLE) << PASS1_BITS); + dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */ + dataptr[2] = (DCTELEM) + DESCALE(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */ + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) + DESCALE(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */ + CONST_BITS-PASS1_BITS); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * i0..i3 in the paper are tmp0..tmp3 here. + */ + + tmp12 = tmp0 + tmp2; + tmp13 = tmp1 + tmp3; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */ + tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */ + tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */ + tmp12 += z1; + tmp13 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp0 += z1 + tmp12; + tmp3 += z1 + tmp13; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp1 += z1 + tmp13; + tmp2 += z1 + tmp12; + + dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS-PASS1_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS-PASS1_BITS); + dataptr[7] = (DCTELEM) DESCALE(tmp3, CONST_BITS-PASS1_BITS); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == DCTSIZE * 2) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by 8/16 = 1/2. + * 16-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/32). + */ + + dataptr = data; + wsptr = workspace; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*3]; + tmp5 = dataptr[DCTSIZE*5] + wsptr[DCTSIZE*2]; + tmp6 = dataptr[DCTSIZE*6] + wsptr[DCTSIZE*1]; + tmp7 = dataptr[DCTSIZE*7] + wsptr[DCTSIZE*0]; + + tmp10 = tmp0 + tmp7; + tmp14 = tmp0 - tmp7; + tmp11 = tmp1 + tmp6; + tmp15 = tmp1 - tmp6; + tmp12 = tmp2 + tmp5; + tmp16 = tmp2 - tmp5; + tmp13 = tmp3 + tmp4; + tmp17 = tmp3 - tmp4; + + tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*3]; + tmp5 = dataptr[DCTSIZE*5] - wsptr[DCTSIZE*2]; + tmp6 = dataptr[DCTSIZE*6] - wsptr[DCTSIZE*1]; + tmp7 = dataptr[DCTSIZE*7] - wsptr[DCTSIZE*0]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(tmp10 + tmp11 + tmp12 + tmp13, PASS1_BITS+1); + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.306562965)) + /* c4[16] = c2[8] */ + MULTIPLY(tmp11 - tmp12, FIX_0_541196100), /* c12[16] = c6[8] */ + CONST_BITS+PASS1_BITS+1); + + tmp10 = MULTIPLY(tmp17 - tmp15, FIX(0.275899379)) + /* c14[16] = c7[8] */ + MULTIPLY(tmp14 - tmp16, FIX(1.387039845)); /* c2[16] = c1[8] */ + + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp15, FIX(1.451774982)) /* c6+c14 */ + + MULTIPLY(tmp16, FIX(2.172734804)), /* c2+c10 */ + CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp14, FIX(0.211164243)) /* c2-c6 */ + - MULTIPLY(tmp17, FIX(1.061594338)), /* c10+c14 */ + CONST_BITS+PASS1_BITS+1); + + /* Odd part */ + + tmp11 = MULTIPLY(tmp0 + tmp1, FIX(1.353318001)) + /* c3 */ + MULTIPLY(tmp6 - tmp7, FIX(0.410524528)); /* c13 */ + tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.247225013)) + /* c5 */ + MULTIPLY(tmp5 + tmp7, FIX(0.666655658)); /* c11 */ + tmp13 = MULTIPLY(tmp0 + tmp3, FIX(1.093201867)) + /* c7 */ + MULTIPLY(tmp4 - tmp7, FIX(0.897167586)); /* c9 */ + tmp14 = MULTIPLY(tmp1 + tmp2, FIX(0.138617169)) + /* c15 */ + MULTIPLY(tmp6 - tmp5, FIX(1.407403738)); /* c1 */ + tmp15 = MULTIPLY(tmp1 + tmp3, - FIX(0.666655658)) + /* -c11 */ + MULTIPLY(tmp4 + tmp6, - FIX(1.247225013)); /* -c5 */ + tmp16 = MULTIPLY(tmp2 + tmp3, - FIX(1.353318001)) + /* -c3 */ + MULTIPLY(tmp5 - tmp4, FIX(0.410524528)); /* c13 */ + tmp10 = tmp11 + tmp12 + tmp13 - + MULTIPLY(tmp0, FIX(2.286341144)) + /* c7+c5+c3-c1 */ + MULTIPLY(tmp7, FIX(0.779653625)); /* c15+c13-c11+c9 */ + tmp11 += tmp14 + tmp15 + MULTIPLY(tmp1, FIX(0.071888074)) /* c9-c3-c15+c11 */ + - MULTIPLY(tmp6, FIX(1.663905119)); /* c7+c13+c1-c5 */ + tmp12 += tmp14 + tmp16 - MULTIPLY(tmp2, FIX(1.125726048)) /* c7+c5+c15-c3 */ + + MULTIPLY(tmp5, FIX(1.227391138)); /* c9-c11+c1-c13 */ + tmp13 += tmp15 + tmp16 + MULTIPLY(tmp3, FIX(1.065388962)) /* c15+c3+c11-c7 */ + + MULTIPLY(tmp4, FIX(2.167985692)); /* c1+c13+c5-c9 */ + + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp10, CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp11, CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12, CONST_BITS+PASS1_BITS+1); + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp13, CONST_BITS+PASS1_BITS+1); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 7x14 sample block. + * + * 7-point FDCT in pass 1 (rows), 14-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_7x14 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; + INT32 z1, z2, z3; + DCTELEM workspace[8*6]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * 7-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/14). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[6]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[5]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[4]); + tmp3 = GETJSAMPLE(elemptr[3]); + + tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[6]); + tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[5]); + tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[4]); + + z1 = tmp0 + tmp2; + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((z1 + tmp1 + tmp3 - 7 * CENTERJSAMPLE) << PASS1_BITS); + tmp3 += tmp3; + z1 -= tmp3; + z1 -= tmp3; + z1 = MULTIPLY(z1, FIX(0.353553391)); /* (c2+c6-c4)/2 */ + z2 = MULTIPLY(tmp0 - tmp2, FIX(0.920609002)); /* (c2+c4-c6)/2 */ + z3 = MULTIPLY(tmp1 - tmp2, FIX(0.314692123)); /* c6 */ + dataptr[2] = (DCTELEM) DESCALE(z1 + z2 + z3, CONST_BITS-PASS1_BITS); + z1 -= z2; + z2 = MULTIPLY(tmp0 - tmp1, FIX(0.881747734)); /* c4 */ + dataptr[4] = (DCTELEM) + DESCALE(z2 + z3 - MULTIPLY(tmp1 - tmp3, FIX(0.707106781)), /* c2+c6-c4 */ + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS-PASS1_BITS); + + /* Odd part */ + + tmp1 = MULTIPLY(tmp10 + tmp11, FIX(0.935414347)); /* (c3+c1-c5)/2 */ + tmp2 = MULTIPLY(tmp10 - tmp11, FIX(0.170262339)); /* (c3+c5-c1)/2 */ + tmp0 = tmp1 - tmp2; + tmp1 += tmp2; + tmp2 = MULTIPLY(tmp11 + tmp12, - FIX(1.378756276)); /* -c1 */ + tmp1 += tmp2; + tmp3 = MULTIPLY(tmp10 + tmp12, FIX(0.613604268)); /* c5 */ + tmp0 += tmp3; + tmp2 += tmp3 + MULTIPLY(tmp12, FIX(1.870828693)); /* c3+c1-c5 */ + + dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS-PASS1_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS-PASS1_BITS); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == 14) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/7)*(8/14) = 32/49, which we + * fold into the constant multipliers: + * 14-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/28) * 32/49. + */ + + dataptr = data; + wsptr = workspace; + for (ctr = 0; ctr < 7; ctr++) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*5]; + tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*4]; + tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*3]; + tmp13 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*2]; + tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*1]; + tmp5 = dataptr[DCTSIZE*5] + wsptr[DCTSIZE*0]; + tmp6 = dataptr[DCTSIZE*6] + dataptr[DCTSIZE*7]; + + tmp10 = tmp0 + tmp6; + tmp14 = tmp0 - tmp6; + tmp11 = tmp1 + tmp5; + tmp15 = tmp1 - tmp5; + tmp12 = tmp2 + tmp4; + tmp16 = tmp2 - tmp4; + + tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*5]; + tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*4]; + tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*3]; + tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*2]; + tmp4 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*1]; + tmp5 = dataptr[DCTSIZE*5] - wsptr[DCTSIZE*0]; + tmp6 = dataptr[DCTSIZE*6] - dataptr[DCTSIZE*7]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12 + tmp13, + FIX(0.653061224)), /* 32/49 */ + CONST_BITS+PASS1_BITS); + tmp13 += tmp13; + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp13, FIX(0.832106052)) + /* c4 */ + MULTIPLY(tmp11 - tmp13, FIX(0.205513223)) - /* c12 */ + MULTIPLY(tmp12 - tmp13, FIX(0.575835255)), /* c8 */ + CONST_BITS+PASS1_BITS); + + tmp10 = MULTIPLY(tmp14 + tmp15, FIX(0.722074570)); /* c6 */ + + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp14, FIX(0.178337691)) /* c2-c6 */ + + MULTIPLY(tmp16, FIX(0.400721155)), /* c10 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp15, FIX(1.122795725)) /* c6+c10 */ + - MULTIPLY(tmp16, FIX(0.900412262)), /* c2 */ + CONST_BITS+PASS1_BITS); + + /* Odd part */ + + tmp10 = tmp1 + tmp2; + tmp11 = tmp5 - tmp4; + dataptr[DCTSIZE*7] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 - tmp10 + tmp3 - tmp11 - tmp6, + FIX(0.653061224)), /* 32/49 */ + CONST_BITS+PASS1_BITS); + tmp3 = MULTIPLY(tmp3 , FIX(0.653061224)); /* 32/49 */ + tmp10 = MULTIPLY(tmp10, - FIX(0.103406812)); /* -c13 */ + tmp11 = MULTIPLY(tmp11, FIX(0.917760839)); /* c1 */ + tmp10 += tmp11 - tmp3; + tmp11 = MULTIPLY(tmp0 + tmp2, FIX(0.782007410)) + /* c5 */ + MULTIPLY(tmp4 + tmp6, FIX(0.491367823)); /* c9 */ + dataptr[DCTSIZE*5] = (DCTELEM) + DESCALE(tmp10 + tmp11 - MULTIPLY(tmp2, FIX(1.550341076)) /* c3+c5-c13 */ + + MULTIPLY(tmp4, FIX(0.731428202)), /* c1+c11-c9 */ + CONST_BITS+PASS1_BITS); + tmp12 = MULTIPLY(tmp0 + tmp1, FIX(0.871740478)) + /* c3 */ + MULTIPLY(tmp5 - tmp6, FIX(0.305035186)); /* c11 */ + dataptr[DCTSIZE*3] = (DCTELEM) + DESCALE(tmp10 + tmp12 - MULTIPLY(tmp1, FIX(0.276965844)) /* c3-c9-c13 */ + - MULTIPLY(tmp5, FIX(2.004803435)), /* c1+c5+c11 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(tmp11 + tmp12 + tmp3 + - MULTIPLY(tmp0, FIX(0.735987049)) /* c3+c5-c1 */ + - MULTIPLY(tmp6, FIX(0.082925825)), /* c9-c11-c13 */ + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 6x12 sample block. + * + * 6-point FDCT in pass 1 (rows), 12-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_6x12 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; + DCTELEM workspace[8*4]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * 6-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/12). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[5]); + tmp11 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[4]); + tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[3]); + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[5]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[4]); + tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[3]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp11 - 6 * CENTERJSAMPLE) << PASS1_BITS); + dataptr[2] = (DCTELEM) + DESCALE(MULTIPLY(tmp12, FIX(1.224744871)), /* c2 */ + CONST_BITS-PASS1_BITS); + dataptr[4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(0.707106781)), /* c4 */ + CONST_BITS-PASS1_BITS); + + /* Odd part */ + + tmp10 = DESCALE(MULTIPLY(tmp0 + tmp2, FIX(0.366025404)), /* c5 */ + CONST_BITS-PASS1_BITS); + + dataptr[1] = (DCTELEM) (tmp10 + ((tmp0 + tmp1) << PASS1_BITS)); + dataptr[3] = (DCTELEM) ((tmp0 - tmp1 - tmp2) << PASS1_BITS); + dataptr[5] = (DCTELEM) (tmp10 + ((tmp2 - tmp1) << PASS1_BITS)); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == 12) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/6)*(8/12) = 8/9, which we + * fold into the constant multipliers: + * 12-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/24) * 8/9. + */ + + dataptr = data; + wsptr = workspace; + for (ctr = 0; ctr < 6; ctr++) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*3]; + tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*2]; + tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*1]; + tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*0]; + tmp4 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*7]; + tmp5 = dataptr[DCTSIZE*5] + dataptr[DCTSIZE*6]; + + tmp10 = tmp0 + tmp5; + tmp13 = tmp0 - tmp5; + tmp11 = tmp1 + tmp4; + tmp14 = tmp1 - tmp4; + tmp12 = tmp2 + tmp3; + tmp15 = tmp2 - tmp3; + + tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*3]; + tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*2]; + tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*1]; + tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*0]; + tmp4 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*7]; + tmp5 = dataptr[DCTSIZE*5] - dataptr[DCTSIZE*6]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12, FIX(0.888888889)), /* 8/9 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(MULTIPLY(tmp13 - tmp14 - tmp15, FIX(0.888888889)), /* 8/9 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.088662108)), /* c4 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(MULTIPLY(tmp14 - tmp15, FIX(0.888888889)) + /* 8/9 */ + MULTIPLY(tmp13 + tmp15, FIX(1.214244803)), /* c2 */ + CONST_BITS+PASS1_BITS); + + /* Odd part */ + + tmp10 = MULTIPLY(tmp1 + tmp4, FIX(0.481063200)); /* c9 */ + tmp14 = tmp10 + MULTIPLY(tmp1, FIX(0.680326102)); /* c3-c9 */ + tmp15 = tmp10 - MULTIPLY(tmp4, FIX(1.642452502)); /* c3+c9 */ + tmp12 = MULTIPLY(tmp0 + tmp2, FIX(0.997307603)); /* c5 */ + tmp13 = MULTIPLY(tmp0 + tmp3, FIX(0.765261039)); /* c7 */ + tmp10 = tmp12 + tmp13 + tmp14 - MULTIPLY(tmp0, FIX(0.516244403)) /* c5+c7-c1 */ + + MULTIPLY(tmp5, FIX(0.164081699)); /* c11 */ + tmp11 = MULTIPLY(tmp2 + tmp3, - FIX(0.164081699)); /* -c11 */ + tmp12 += tmp11 - tmp15 - MULTIPLY(tmp2, FIX(2.079550144)) /* c1+c5-c11 */ + + MULTIPLY(tmp5, FIX(0.765261039)); /* c7 */ + tmp13 += tmp11 - tmp14 + MULTIPLY(tmp3, FIX(0.645144899)) /* c1+c11-c7 */ + - MULTIPLY(tmp5, FIX(0.997307603)); /* c5 */ + tmp11 = tmp15 + MULTIPLY(tmp0 - tmp3, FIX(1.161389302)) /* c3 */ + - MULTIPLY(tmp2 + tmp5, FIX(0.481063200)); /* c9 */ + + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp10, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp11, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp13, CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 5x10 sample block. + * + * 5-point FDCT in pass 1 (rows), 10-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_5x10 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4; + INT32 tmp10, tmp11, tmp12, tmp13, tmp14; + DCTELEM workspace[8*2]; + DCTELEM *dataptr; + DCTELEM *wsptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * 5-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/10). + */ + + dataptr = data; + ctr = 0; + for (;;) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[4]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[3]); + tmp2 = GETJSAMPLE(elemptr[2]); + + tmp10 = tmp0 + tmp1; + tmp11 = tmp0 - tmp1; + + tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[4]); + tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[3]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp10 + tmp2 - 5 * CENTERJSAMPLE) << PASS1_BITS); + tmp11 = MULTIPLY(tmp11, FIX(0.790569415)); /* (c2+c4)/2 */ + tmp10 -= tmp2 << 2; + tmp10 = MULTIPLY(tmp10, FIX(0.353553391)); /* (c2-c4)/2 */ + dataptr[2] = (DCTELEM) DESCALE(tmp11 + tmp10, CONST_BITS-PASS1_BITS); + dataptr[4] = (DCTELEM) DESCALE(tmp11 - tmp10, CONST_BITS-PASS1_BITS); + + /* Odd part */ + + tmp10 = MULTIPLY(tmp0 + tmp1, FIX(0.831253876)); /* c3 */ + + dataptr[1] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp0, FIX(0.513743148)), /* c1-c3 */ + CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp1, FIX(2.176250899)), /* c1+c3 */ + CONST_BITS-PASS1_BITS); + + ctr++; + + if (ctr != DCTSIZE) { + if (ctr == 10) + break; /* Done. */ + dataptr += DCTSIZE; /* advance pointer to next row */ + } else + dataptr = workspace; /* switch pointer to extended workspace */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/5)*(8/10) = 32/25, which we + * fold into the constant multipliers: + * 10-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/20) * 32/25. + */ + + dataptr = data; + wsptr = workspace; + for (ctr = 0; ctr < 5; ctr++) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*1]; + tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*0]; + tmp12 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*7]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*6]; + tmp4 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*5]; + + tmp10 = tmp0 + tmp4; + tmp13 = tmp0 - tmp4; + tmp11 = tmp1 + tmp3; + tmp14 = tmp1 - tmp3; + + tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*1]; + tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*0]; + tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*7]; + tmp3 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*6]; + tmp4 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*5]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12, FIX(1.28)), /* 32/25 */ + CONST_BITS+PASS1_BITS); + tmp12 += tmp12; + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.464477191)) - /* c4 */ + MULTIPLY(tmp11 - tmp12, FIX(0.559380511)), /* c8 */ + CONST_BITS+PASS1_BITS); + tmp10 = MULTIPLY(tmp13 + tmp14, FIX(1.064004961)); /* c6 */ + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp13, FIX(0.657591230)), /* c2-c6 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*6] = (DCTELEM) + DESCALE(tmp10 - MULTIPLY(tmp14, FIX(2.785601151)), /* c2+c6 */ + CONST_BITS+PASS1_BITS); + + /* Odd part */ + + tmp10 = tmp0 + tmp4; + tmp11 = tmp1 - tmp3; + dataptr[DCTSIZE*5] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp11 - tmp2, FIX(1.28)), /* 32/25 */ + CONST_BITS+PASS1_BITS); + tmp2 = MULTIPLY(tmp2, FIX(1.28)); /* 32/25 */ + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(MULTIPLY(tmp0, FIX(1.787906876)) + /* c1 */ + MULTIPLY(tmp1, FIX(1.612894094)) + tmp2 + /* c3 */ + MULTIPLY(tmp3, FIX(0.821810588)) + /* c7 */ + MULTIPLY(tmp4, FIX(0.283176630)), /* c9 */ + CONST_BITS+PASS1_BITS); + tmp12 = MULTIPLY(tmp0 - tmp4, FIX(1.217352341)) - /* (c3+c7)/2 */ + MULTIPLY(tmp1 + tmp3, FIX(0.752365123)); /* (c1-c9)/2 */ + tmp13 = MULTIPLY(tmp10 + tmp11, FIX(0.395541753)) + /* (c3-c7)/2 */ + MULTIPLY(tmp11, FIX(0.64)) - tmp2; /* 16/25 */ + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp12 + tmp13, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp12 - tmp13, CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + wsptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 4x8 sample block. + * + * 4-point FDCT in pass 1 (rows), 8-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_4x8 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * We must also scale the output by 8/4 = 2, which we add here. + * 4-point FDCT kernel, + * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT]. + */ + + dataptr = data; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]); + tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]); + + tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]); + tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp0 + tmp1 - 4 * CENTERJSAMPLE) << (PASS1_BITS+1)); + dataptr[2] = (DCTELEM) ((tmp0 - tmp1) << (PASS1_BITS+1)); + + /* Odd part */ + + tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS-PASS1_BITS-2); + + dataptr[1] = (DCTELEM) + RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */ + CONST_BITS-PASS1_BITS-1); + dataptr[3] = (DCTELEM) + RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */ + CONST_BITS-PASS1_BITS-1); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * 8-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/16). + */ + + dataptr = data; + for (ctr = 0; ctr < 4; ctr++) { + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "c1" should be "c6". + */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + + /* Add fudge factor here for final descale. */ + tmp10 = tmp0 + tmp3 + (ONE << (PASS1_BITS-1)); + tmp12 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp13 = tmp1 - tmp2; + + tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp10 + tmp11, PASS1_BITS); + dataptr[DCTSIZE*4] = (DCTELEM) RIGHT_SHIFT(tmp10 - tmp11, PASS1_BITS); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS+PASS1_BITS-1); + + dataptr[DCTSIZE*2] = (DCTELEM) + RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*6] = (DCTELEM) + RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */ + CONST_BITS+PASS1_BITS); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * i0..i3 in the paper are tmp0..tmp3 here. + */ + + tmp12 = tmp0 + tmp2; + tmp13 = tmp1 + tmp3; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */ + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS+PASS1_BITS-1); + + tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */ + tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */ + tmp12 += z1; + tmp13 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp0 += z1 + tmp12; + tmp3 += z1 + tmp13; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp1 += z1 + tmp13; + tmp2 += z1 + tmp12; + + dataptr[DCTSIZE*1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 3x6 sample block. + * + * 3-point FDCT in pass 1 (rows), 6-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_3x6 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1, tmp2; + INT32 tmp10, tmp11, tmp12; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * We scale the results further by 2 as part of output adaption + * scaling for different DCT size. + * 3-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/6). + */ + + dataptr = data; + for (ctr = 0; ctr < 6; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[2]); + tmp1 = GETJSAMPLE(elemptr[1]); + + tmp2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[2]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) + ((tmp0 + tmp1 - 3 * CENTERJSAMPLE) << (PASS1_BITS+1)); + dataptr[2] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 - tmp1 - tmp1, FIX(0.707106781)), /* c2 */ + CONST_BITS-PASS1_BITS-1); + + /* Odd part */ + + dataptr[1] = (DCTELEM) + DESCALE(MULTIPLY(tmp2, FIX(1.224744871)), /* c1 */ + CONST_BITS-PASS1_BITS-1); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + * We must also scale the output by (8/6)*(8/3) = 32/9, which we partially + * fold into the constant multipliers (other part was done in pass 1): + * 6-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/12) * 16/9. + */ + + dataptr = data; + for (ctr = 0; ctr < 3; ctr++) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*5]; + tmp11 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*4]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*3]; + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*5]; + tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*4]; + tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*3]; + + dataptr[DCTSIZE*0] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 + tmp11, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*2] = (DCTELEM) + DESCALE(MULTIPLY(tmp12, FIX(2.177324216)), /* c2 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*4] = (DCTELEM) + DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(1.257078722)), /* c4 */ + CONST_BITS+PASS1_BITS); + + /* Odd part */ + + tmp10 = MULTIPLY(tmp0 + tmp2, FIX(0.650711829)); /* c5 */ + + dataptr[DCTSIZE*1] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp0 + tmp1, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) + DESCALE(MULTIPLY(tmp0 - tmp1 - tmp2, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*5] = (DCTELEM) + DESCALE(tmp10 + MULTIPLY(tmp2 - tmp1, FIX(1.777777778)), /* 16/9 */ + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 2x4 sample block. + * + * 2-point FDCT in pass 1 (rows), 4-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_2x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + INT32 tmp0, tmp1; + INT32 tmp10, tmp11; + DCTELEM *dataptr; + JSAMPROW elemptr; + int ctr; + SHIFT_TEMPS + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: process rows. + * Note results are scaled up by sqrt(8) compared to a true DCT. + */ + + dataptr = data; + for (ctr = 0; ctr < 4; ctr++) { + elemptr = sample_data[ctr] + start_col; + + /* Even part */ + + tmp0 = GETJSAMPLE(elemptr[0]); + tmp1 = GETJSAMPLE(elemptr[1]); + + /* Apply unsigned->signed conversion. */ + dataptr[0] = (DCTELEM) (tmp0 + tmp1 - 2 * CENTERJSAMPLE); + + /* Odd part */ + + dataptr[1] = (DCTELEM) (tmp0 - tmp1); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/2)*(8/4) = 2**3. + * 4-point FDCT kernel, + * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT]. + */ + + dataptr = data; + for (ctr = 0; ctr < 2; ctr++) { + /* Even part */ + + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*3]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*2]; + + tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*3]; + tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*2]; + + dataptr[DCTSIZE*0] = (DCTELEM) ((tmp0 + tmp1) << 3); + dataptr[DCTSIZE*2] = (DCTELEM) ((tmp0 - tmp1) << 3); + + /* Odd part */ + + tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS-3-1); + + dataptr[DCTSIZE*1] = (DCTELEM) + RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */ + CONST_BITS-3); + dataptr[DCTSIZE*3] = (DCTELEM) + RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */ + CONST_BITS-3); + + dataptr++; /* advance pointer to next column */ + } +} + + +/* + * Perform the forward DCT on a 1x2 sample block. + * + * 1-point FDCT in pass 1 (rows), 2-point in pass 2 (columns). + */ + +GLOBAL(void) +jpeg_fdct_1x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) +{ + DCTELEM tmp0, tmp1; + + /* Pre-zero output coefficient block. */ + MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2); + + /* Pass 1: empty. */ + + /* Pass 2: process columns. + * We leave the results scaled up by an overall factor of 8. + * We must also scale the output by (8/1)*(8/2) = 2**5. + */ + + /* Even part */ + + tmp0 = GETJSAMPLE(sample_data[0][start_col]); + tmp1 = GETJSAMPLE(sample_data[1][start_col]); + + /* Apply unsigned->signed conversion. */ + data[DCTSIZE*0] = (tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 5; + + /* Odd part */ + + data[DCTSIZE*1] = (tmp0 - tmp1) << 5; +} + +#endif /* DCT_SCALING_SUPPORTED */ +#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/jidctflt.c b/thirdparty/jpeg-9e/jidctflt.c new file mode 100644 index 0000000..e33a2b5 --- /dev/null +++ b/thirdparty/jpeg-9e/jidctflt.c @@ -0,0 +1,238 @@ +/* + * jidctflt.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * Modified 2010-2017 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a floating-point implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * This implementation should be more accurate than either of the integer + * IDCT implementations. However, it may not give the same results on all + * machines because of differences in roundoff behavior. Speed will depend + * on the hardware's floating point capacity. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with a fixed-point + * implementation, accuracy is lost due to imprecise representation of the + * scaled quantization values. However, that problem does not arise if + * we use floating point arithmetic. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_FLOAT_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */ +#endif + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce a float result. + */ + +#define DEQUANTIZE(coef,quantval) (((FAST_FLOAT) (coef)) * (quantval)) + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + * + * cK represents cos(K*pi/16). + */ + +GLOBAL(void) +jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + FAST_FLOAT tmp10, tmp11, tmp12, tmp13; + FAST_FLOAT z5, z10, z11, z12, z13; + JCOEFPTR inptr; + FLOAT_MULT_TYPE * quantptr; + FAST_FLOAT * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */ + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && + inptr[DCTSIZE*7] == 0) { + /* AC terms all zero */ + FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp10 = tmp0 + tmp2; /* phase 3 */ + tmp11 = tmp0 - tmp2; + + tmp13 = tmp1 + tmp3; /* phases 5-3 */ + tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */ + + tmp0 = tmp10 + tmp13; /* phase 2 */ + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + z13 = tmp6 + tmp5; /* phase 6 */ + z10 = tmp6 - tmp5; + z11 = tmp4 + tmp7; + z12 = tmp4 - tmp7; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */ + + z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ + tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */ + tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 - tmp5; + + wsptr[DCTSIZE*0] = tmp0 + tmp7; + wsptr[DCTSIZE*7] = tmp0 - tmp7; + wsptr[DCTSIZE*1] = tmp1 + tmp6; + wsptr[DCTSIZE*6] = tmp1 - tmp6; + wsptr[DCTSIZE*2] = tmp2 + tmp5; + wsptr[DCTSIZE*5] = tmp2 - tmp5; + wsptr[DCTSIZE*3] = tmp3 + tmp4; + wsptr[DCTSIZE*4] = tmp3 - tmp4; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * And testing floats for zero is relatively expensive, so we don't bother. + */ + + /* Even part */ + + /* Prepare range-limit and float->int conversion */ + z5 = wsptr[0] + (((FAST_FLOAT) RANGE_CENTER) + ((FAST_FLOAT) 0.5)); + tmp10 = z5 + wsptr[4]; + tmp11 = z5 - wsptr[4]; + + tmp13 = wsptr[2] + wsptr[6]; + tmp12 = (wsptr[2] - wsptr[6]) * + ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */ + + tmp0 = tmp10 + tmp13; + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + z13 = wsptr[5] + wsptr[3]; + z10 = wsptr[5] - wsptr[3]; + z11 = wsptr[1] + wsptr[7]; + z12 = wsptr[1] - wsptr[7]; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */ + + z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ + tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */ + tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 - tmp5; + + /* Final output stage: float->int conversion and range-limit */ + + outptr[0] = range_limit[(int) (tmp0 + tmp7) & RANGE_MASK]; + outptr[7] = range_limit[(int) (tmp0 - tmp7) & RANGE_MASK]; + outptr[1] = range_limit[(int) (tmp1 + tmp6) & RANGE_MASK]; + outptr[6] = range_limit[(int) (tmp1 - tmp6) & RANGE_MASK]; + outptr[2] = range_limit[(int) (tmp2 + tmp5) & RANGE_MASK]; + outptr[5] = range_limit[(int) (tmp2 - tmp5) & RANGE_MASK]; + outptr[3] = range_limit[(int) (tmp3 + tmp4) & RANGE_MASK]; + outptr[4] = range_limit[(int) (tmp3 - tmp4) & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/jidctfst.c b/thirdparty/jpeg-9e/jidctfst.c new file mode 100644 index 0000000..1ac3e39 --- /dev/null +++ b/thirdparty/jpeg-9e/jidctfst.c @@ -0,0 +1,351 @@ +/* + * jidctfst.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * Modified 2015-2017 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a fast, not so accurate integer implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with fixed-point math, + * accuracy is lost due to imprecise representation of the scaled + * quantization values. The smaller the quantization table entry, the less + * precise the scaled value, so this implementation does worse with high- + * quality-setting files than with low-quality ones. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_IFAST_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */ +#endif + + +/* Scaling decisions are generally the same as in the LL&M algorithm; + * see jidctint.c for more details. However, we choose to descale + * (right shift) multiplication products as soon as they are formed, + * rather than carrying additional fractional bits into subsequent additions. + * This compromises accuracy slightly, but it lets us save a few shifts. + * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) + * everywhere except in the multiplications proper; this saves a good deal + * of work on 16-bit-int machines. + * + * The dequantized coefficients are not integers because the AA&N scaling + * factors have been incorporated. We represent them scaled up by PASS1_BITS, + * so that the first and second IDCT rounds have the same input scaling. + * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to + * avoid a descaling shift; this compromises accuracy rather drastically + * for small quantization table entries, but it saves a lot of shifts. + * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway, + * so we use a much larger scaling factor to preserve accuracy. + * + * A final compromise is to represent the multiplicative constants to only + * 8 fractional bits, rather than 13. This saves some shifting work on some + * machines, and may also reduce the cost of multiplication (since there + * are fewer one-bits in the constants). + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 8 +#define PASS1_BITS 2 +#else +#define CONST_BITS 8 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 8 +#define FIX_1_082392200 ((INT32) 277) /* FIX(1.082392200) */ +#define FIX_1_414213562 ((INT32) 362) /* FIX(1.414213562) */ +#define FIX_1_847759065 ((INT32) 473) /* FIX(1.847759065) */ +#define FIX_2_613125930 ((INT32) 669) /* FIX(2.613125930) */ +#else +#define FIX_1_082392200 FIX(1.082392200) +#define FIX_1_414213562 FIX(1.414213562) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_2_613125930 FIX(2.613125930) +#endif + + +/* We can gain a little more speed, with a further compromise in accuracy, + * by omitting the addition in a descaling shift. This yields an incorrectly + * rounded result half the time... + */ + +#ifndef USE_ACCURATE_ROUNDING +#undef DESCALE +#define DESCALE(x,n) RIGHT_SHIFT(x, n) +#endif + + +/* Multiply a DCTELEM variable by an INT32 constant, and immediately + * descale to yield a DCTELEM result. + */ + +#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce a DCTELEM result. For 8-bit data a 16x16->16 + * multiplication will do. For 12-bit data, the multiplier table is + * declared INT32, so a 32-bit multiply will be used. + */ + +#if BITS_IN_JSAMPLE == 8 +#define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval)) +#else +#define DEQUANTIZE(coef,quantval) \ + DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS) +#endif + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + * + * cK represents cos(K*pi/16). + */ + +GLOBAL(void) +jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + DCTELEM tmp10, tmp11, tmp12, tmp13; + DCTELEM z5, z10, z11, z12, z13; + JCOEFPTR inptr; + IFAST_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE2]; /* buffers data between passes */ + SHIFT_TEMPS /* for DESCALE */ + ISHIFT_TEMPS /* for IRIGHT_SHIFT */ + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && + inptr[DCTSIZE*7] == 0) { + /* AC terms all zero */ + int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp10 = tmp0 + tmp2; /* phase 3 */ + tmp11 = tmp0 - tmp2; + + tmp13 = tmp1 + tmp3; /* phases 5-3 */ + tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ + + tmp0 = tmp10 + tmp13; /* phase 2 */ + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + z13 = tmp6 + tmp5; /* phase 6 */ + z10 = tmp6 - tmp5; + z11 = tmp4 + tmp7; + z12 = tmp4 - tmp7; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ + + z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ + tmp10 = z5 - MULTIPLY(z12, FIX_1_082392200); /* 2*(c2-c6) */ + tmp12 = z5 - MULTIPLY(z10, FIX_2_613125930); /* 2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 - tmp5; + + wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); + wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); + wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); + wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); + wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); + wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); + wsptr[DCTSIZE*3] = (int) (tmp3 + tmp4); + wsptr[DCTSIZE*4] = (int) (tmp3 - tmp4); + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. + * Note that we must descale the results by a factor of 8 == 2**3, + * and also undo the PASS1_BITS scaling. + */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Add range center and fudge factor for final descale and range-limit. */ + z5 = (DCTELEM) wsptr[0] + + ((((DCTELEM) RANGE_CENTER) << (PASS1_BITS+3)) + + (1 << (PASS1_BITS+2))); + + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * On machines with very fast multiplication, it's possible that the + * test takes more time than it's worth. In that case this section + * may be commented out. + */ + +#ifndef NO_ZERO_ROW_TEST + if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && + wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[(int) IRIGHT_SHIFT(z5, PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + outptr[2] = dcval; + outptr[3] = dcval; + outptr[4] = dcval; + outptr[5] = dcval; + outptr[6] = dcval; + outptr[7] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part */ + + tmp10 = z5 + (DCTELEM) wsptr[4]; + tmp11 = z5 - (DCTELEM) wsptr[4]; + + tmp13 = (DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]; + tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], + FIX_1_414213562) - tmp13; /* 2*c4 */ + + tmp0 = tmp10 + tmp13; + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; + z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; + z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; + z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ + + z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ + tmp10 = z5 - MULTIPLY(z12, FIX_1_082392200); /* 2*(c2-c6) */ + tmp12 = z5 - MULTIPLY(z10, FIX_2_613125930); /* 2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 - tmp5; + + /* Final output stage: scale down by a factor of 8 and range-limit */ + + outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp7, PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp7, PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp1 + tmp6, PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) IRIGHT_SHIFT(tmp1 - tmp6, PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) IRIGHT_SHIFT(tmp2 + tmp5, PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) IRIGHT_SHIFT(tmp2 - tmp5, PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) IRIGHT_SHIFT(tmp3 + tmp4, PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) IRIGHT_SHIFT(tmp3 - tmp4, PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#endif /* DCT_IFAST_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/jidctint.c b/thirdparty/jpeg-9e/jidctint.c new file mode 100644 index 0000000..e30ec8c --- /dev/null +++ b/thirdparty/jpeg-9e/jidctint.c @@ -0,0 +1,5240 @@ +/* + * jidctint.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * Modification developed 2002-2018 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a slow-but-accurate integer implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on an algorithm described in + * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT + * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, + * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. + * The primary algorithm described there uses 11 multiplies and 29 adds. + * We use their alternate method with 12 multiplies and 32 adds. + * The advantage of this method is that no data path contains more than one + * multiplication; this allows a very simple and accurate implementation in + * scaled fixed-point arithmetic, with a minimal number of shifts. + * + * We also provide IDCT routines with various output sample block sizes for + * direct resolution reduction or enlargement and for direct resolving the + * common 2x1 and 1x2 subsampling cases without additional resampling: NxN + * (N=1...16), 2NxN, and Nx2N (N=1...8) pixels for one 8x8 input DCT block. + * + * For N<8 we simply take the corresponding low-frequency coefficients of + * the 8x8 input DCT block and apply an NxN point IDCT on the sub-block + * to yield the downscaled outputs. + * This can be seen as direct low-pass downsampling from the DCT domain + * point of view rather than the usual spatial domain point of view, + * yielding significant computational savings and results at least + * as good as common bilinear (averaging) spatial downsampling. + * + * For N>8 we apply a partial NxN IDCT on the 8 input coefficients as + * lower frequencies and higher frequencies assumed to be zero. + * It turns out that the computational effort is similar to the 8x8 IDCT + * regarding the output size. + * Furthermore, the scaling and descaling is the same for all IDCT sizes. + * + * CAUTION: We rely on the FIX() macro except for the N=1,2,4,8 cases + * since there would be too many additional constants to pre-calculate. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_ISLOW_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */ +#endif + + +/* + * The poop on this scaling stuff is as follows: + * + * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) + * larger than the true IDCT outputs. The final outputs are therefore + * a factor of N larger than desired; since N=8 this can be cured by + * a simple right shift at the end of the algorithm. The advantage of + * this arrangement is that we save two multiplications per 1-D IDCT, + * because the y0 and y4 inputs need not be divided by sqrt(N). + * + * We have to do addition and subtraction of the integer inputs, which + * is no problem, and multiplication by fractional constants, which is + * a problem to do in integer arithmetic. We multiply all the constants + * by CONST_SCALE and convert them to integer constants (thus retaining + * CONST_BITS bits of precision in the constants). After doing a + * multiplication we have to divide the product by CONST_SCALE, with proper + * rounding, to produce the correct output. This division can be done + * cheaply as a right shift of CONST_BITS bits. We postpone shifting + * as long as possible so that partial sums can be added together with + * full fractional precision. + * + * The outputs of the first pass are scaled up by PASS1_BITS bits so that + * they are represented to better-than-integral precision. These outputs + * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word + * with the recommended scaling. (To scale up 12-bit sample data further, an + * intermediate INT32 array would be needed.) + * + * To avoid overflow of the 32-bit intermediate results in pass 2, we must + * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis + * shows that the values given below are the most effective. + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 2 +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ +#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ +#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ +#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ +#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ +#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ +#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ +#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ +#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ +#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ +#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ +#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ +#else +#define FIX_0_298631336 FIX(0.298631336) +#define FIX_0_390180644 FIX(0.390180644) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_175875602 FIX(1.175875602) +#define FIX_1_501321110 FIX(1.501321110) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_1_961570560 FIX(1.961570560) +#define FIX_2_053119869 FIX(2.053119869) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_072711026 FIX(3.072711026) +#endif + + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce an int result. In this module, both inputs and result + * are 16 bits or less, so either int or short multiply will work. + */ + +#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + * + * Optimized algorithm with 12 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/16). + */ + +GLOBAL(void) +jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1, z2, z3; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE2]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * Note results are scaled up by sqrt(8) compared to a true IDCT; + * furthermore, we scale the results by 2**PASS1_BITS. + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && + inptr[DCTSIZE*7] == 0) { + /* AC terms all zero */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part: reverse the even part of the forward DCT. + * The rotator is c(-6). + */ + + z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z2 <<= CONST_BITS; + z3 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + z2 += ONE << (CONST_BITS-PASS1_BITS-1); + + tmp0 = z2 + z3; + tmp1 = z2 - z3; + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + tmp10 = tmp0 + tmp2; + tmp13 = tmp0 - tmp2; + tmp11 = tmp1 + tmp3; + tmp12 = tmp1 - tmp3; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + + z2 = tmp0 + tmp2; + z3 = tmp1 + tmp3; + + z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ + z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ + z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ + z2 += z1; + z3 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp0 += z1 + z2; + tmp3 += z1 + z3; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp1 += z1 + z3; + tmp2 += z1 + z2; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + wsptr[DCTSIZE*0] = (int) RIGHT_SHIFT(tmp10 + tmp3, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*7] = (int) RIGHT_SHIFT(tmp10 - tmp3, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*1] = (int) RIGHT_SHIFT(tmp11 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*6] = (int) RIGHT_SHIFT(tmp11 - tmp2, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*2] = (int) RIGHT_SHIFT(tmp12 + tmp1, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*5] = (int) RIGHT_SHIFT(tmp12 - tmp1, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*3] = (int) RIGHT_SHIFT(tmp13 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*4] = (int) RIGHT_SHIFT(tmp13 - tmp0, CONST_BITS-PASS1_BITS); + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. + * Note that we must descale the results by a factor of 8 == 2**3, + * and also undo the PASS1_BITS scaling. + */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Add range center and fudge factor for final descale and range-limit. */ + z2 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * On machines with very fast multiplication, it's possible that the + * test takes more time than it's worth. In that case this section + * may be commented out. + */ + +#ifndef NO_ZERO_ROW_TEST + if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && + wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[(int) RIGHT_SHIFT(z2, PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + outptr[2] = dcval; + outptr[3] = dcval; + outptr[4] = dcval; + outptr[5] = dcval; + outptr[6] = dcval; + outptr[7] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part: reverse the even part of the forward DCT. + * The rotator is c(-6). + */ + + z3 = (INT32) wsptr[4]; + + tmp0 = (z2 + z3) << CONST_BITS; + tmp1 = (z2 - z3) << CONST_BITS; + + z2 = (INT32) wsptr[2]; + z3 = (INT32) wsptr[6]; + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + tmp10 = tmp0 + tmp2; + tmp13 = tmp0 - tmp2; + tmp11 = tmp1 + tmp3; + tmp12 = tmp1 - tmp3; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = (INT32) wsptr[7]; + tmp1 = (INT32) wsptr[5]; + tmp2 = (INT32) wsptr[3]; + tmp3 = (INT32) wsptr[1]; + + z2 = tmp0 + tmp2; + z3 = tmp1 + tmp3; + + z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ + z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ + z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ + z2 += z1; + z3 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp0 += z1 + z2; + tmp3 += z1 + z3; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp1 += z1 + z3; + tmp2 += z1 + z2; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp13 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#ifdef IDCT_SCALING_SUPPORTED + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 7x7 output block. + * + * Optimized algorithm with 12 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/14). + */ + +GLOBAL(void) +jpeg_idct_7x7 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp10, tmp11, tmp12, tmp13; + INT32 z1, z2, z3; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[7*7]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 7; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp13 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp13 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp13 += ONE << (CONST_BITS-PASS1_BITS-1); + + z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp10 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */ + tmp12 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */ + tmp11 = tmp10 + tmp12 + tmp13 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */ + tmp0 = z1 + z3; + z2 -= tmp0; + tmp0 = MULTIPLY(tmp0, FIX(1.274162392)) + tmp13; /* c2 */ + tmp10 += tmp0 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */ + tmp12 += tmp0 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */ + tmp13 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */ + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + + tmp1 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */ + tmp2 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */ + tmp0 = tmp1 - tmp2; + tmp1 += tmp2; + tmp2 = MULTIPLY(z2 + z3, - FIX(1.378756276)); /* -c1 */ + tmp1 += tmp2; + z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */ + tmp0 += z2; + tmp2 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */ + + /* Final output stage */ + + wsptr[7*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[7*6] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); + wsptr[7*1] = (int) RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS-PASS1_BITS); + wsptr[7*5] = (int) RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS-PASS1_BITS); + wsptr[7*2] = (int) RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[7*4] = (int) RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS-PASS1_BITS); + wsptr[7*3] = (int) RIGHT_SHIFT(tmp13, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 7 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 7; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp13 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp13 <<= CONST_BITS; + + z1 = (INT32) wsptr[2]; + z2 = (INT32) wsptr[4]; + z3 = (INT32) wsptr[6]; + + tmp10 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */ + tmp12 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */ + tmp11 = tmp10 + tmp12 + tmp13 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */ + tmp0 = z1 + z3; + z2 -= tmp0; + tmp0 = MULTIPLY(tmp0, FIX(1.274162392)) + tmp13; /* c2 */ + tmp10 += tmp0 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */ + tmp12 += tmp0 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */ + tmp13 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */ + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + + tmp1 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */ + tmp2 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */ + tmp0 = tmp1 - tmp2; + tmp1 += tmp2; + tmp2 = MULTIPLY(z2 + z3, - FIX(1.378756276)); /* -c1 */ + tmp1 += tmp2; + z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */ + tmp0 += z2; + tmp2 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 7; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 6x6 output block. + * + * Optimized algorithm with 3 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/12). + */ + +GLOBAL(void) +jpeg_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp10, tmp11, tmp12; + INT32 z1, z2, z3; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[6*6]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 6; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp0 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */ + tmp1 = tmp0 + tmp10; + tmp11 = RIGHT_SHIFT(tmp0 - tmp10 - tmp10, CONST_BITS-PASS1_BITS); + tmp10 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */ + tmp10 = tmp1 + tmp0; + tmp12 = tmp1 - tmp0; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ + tmp0 = tmp1 + ((z1 + z2) << CONST_BITS); + tmp2 = tmp1 + ((z3 - z2) << CONST_BITS); + tmp1 = (z1 - z2 - z3) << PASS1_BITS; + + /* Final output stage */ + + wsptr[6*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[6*5] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); + wsptr[6*1] = (int) (tmp11 + tmp1); + wsptr[6*4] = (int) (tmp11 - tmp1); + wsptr[6*2] = (int) RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[6*3] = (int) RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 6 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 6; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp0 <<= CONST_BITS; + tmp2 = (INT32) wsptr[4]; + tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */ + tmp1 = tmp0 + tmp10; + tmp11 = tmp0 - tmp10 - tmp10; + tmp10 = (INT32) wsptr[2]; + tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */ + tmp10 = tmp1 + tmp0; + tmp12 = tmp1 - tmp0; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ + tmp0 = tmp1 + ((z1 + z2) << CONST_BITS); + tmp2 = tmp1 + ((z3 - z2) << CONST_BITS); + tmp1 = (z1 - z2 - z3) << CONST_BITS; + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 6; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 5x5 output block. + * + * Optimized algorithm with 5 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/10). + */ + +GLOBAL(void) +jpeg_idct_5x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp10, tmp11, tmp12; + INT32 z1, z2, z3; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[5*5]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 5; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp12 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp12 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp12 += ONE << (CONST_BITS-PASS1_BITS-1); + tmp0 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z1 = MULTIPLY(tmp0 + tmp1, FIX(0.790569415)); /* (c2+c4)/2 */ + z2 = MULTIPLY(tmp0 - tmp1, FIX(0.353553391)); /* (c2-c4)/2 */ + z3 = tmp12 + z2; + tmp10 = z3 + z1; + tmp11 = z3 - z1; + tmp12 -= z2 << 2; + + /* Odd part */ + + z2 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + + z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */ + tmp0 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */ + tmp1 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */ + + /* Final output stage */ + + wsptr[5*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[5*4] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); + wsptr[5*1] = (int) RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS-PASS1_BITS); + wsptr[5*3] = (int) RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS-PASS1_BITS); + wsptr[5*2] = (int) RIGHT_SHIFT(tmp12, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 5 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 5; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp12 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp12 <<= CONST_BITS; + tmp0 = (INT32) wsptr[2]; + tmp1 = (INT32) wsptr[4]; + z1 = MULTIPLY(tmp0 + tmp1, FIX(0.790569415)); /* (c2+c4)/2 */ + z2 = MULTIPLY(tmp0 - tmp1, FIX(0.353553391)); /* (c2-c4)/2 */ + z3 = tmp12 + z2; + tmp10 = z3 + z1; + tmp11 = z3 - z1; + tmp12 -= z2 << 2; + + /* Odd part */ + + z2 = (INT32) wsptr[1]; + z3 = (INT32) wsptr[3]; + + z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */ + tmp0 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */ + tmp1 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 5; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 4x4 output block. + * + * Optimized algorithm with 3 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT]. + */ + +GLOBAL(void) +jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp2, tmp10, tmp12; + INT32 z1, z2, z3; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[4*4]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 4; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + + tmp10 = (tmp0 + tmp2) << PASS1_BITS; + tmp12 = (tmp0 - tmp2) << PASS1_BITS; + + /* Odd part */ + /* Same rotation as in the even part of the 8x8 LL&M IDCT */ + + z2 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS-PASS1_BITS-1); + tmp0 = RIGHT_SHIFT(z1 + MULTIPLY(z2, FIX_0_765366865), /* c2-c6 */ + CONST_BITS-PASS1_BITS); + tmp2 = RIGHT_SHIFT(z1 - MULTIPLY(z3, FIX_1_847759065), /* c2+c6 */ + CONST_BITS-PASS1_BITS); + + /* Final output stage */ + + wsptr[4*0] = (int) (tmp10 + tmp0); + wsptr[4*3] = (int) (tmp10 - tmp0); + wsptr[4*1] = (int) (tmp12 + tmp2); + wsptr[4*2] = (int) (tmp12 - tmp2); + } + + /* Pass 2: process 4 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 4; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp2 = (INT32) wsptr[2]; + + tmp10 = (tmp0 + tmp2) << CONST_BITS; + tmp12 = (tmp0 - tmp2) << CONST_BITS; + + /* Odd part */ + /* Same rotation as in the even part of the 8x8 LL&M IDCT */ + + z2 = (INT32) wsptr[1]; + z3 = (INT32) wsptr[3]; + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + tmp0 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp2 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 4; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 3x3 output block. + * + * Optimized algorithm with 2 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/6). + */ + +GLOBAL(void) +jpeg_idct_3x3 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp2, tmp10, tmp12; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[3*3]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 3; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp0 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */ + tmp10 = tmp0 + tmp12; + tmp2 = tmp0 - tmp12 - tmp12; + + /* Odd part */ + + tmp12 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */ + + /* Final output stage */ + + wsptr[3*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[3*2] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); + wsptr[3*1] = (int) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 3 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 3; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp0 <<= CONST_BITS; + tmp2 = (INT32) wsptr[2]; + tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */ + tmp10 = tmp0 + tmp12; + tmp2 = tmp0 - tmp12 - tmp12; + + /* Odd part */ + + tmp12 = (INT32) wsptr[1]; + tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 3; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 2x2 output block. + * + * Multiplication-less algorithm. + */ + +GLOBAL(void) +jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + ISLOW_MULT_TYPE * quantptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + ISHIFT_TEMPS + + /* Pass 1: process columns from input. */ + + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + + /* Column 0 */ + tmp4 = DEQUANTIZE(coef_block[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp5 = DEQUANTIZE(coef_block[DCTSIZE*1], quantptr[DCTSIZE*1]); + /* Add range center and fudge factor for final descale and range-limit. */ + tmp4 += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2); + + tmp0 = tmp4 + tmp5; + tmp2 = tmp4 - tmp5; + + /* Column 1 */ + tmp4 = DEQUANTIZE(coef_block[DCTSIZE*0+1], quantptr[DCTSIZE*0+1]); + tmp5 = DEQUANTIZE(coef_block[DCTSIZE*1+1], quantptr[DCTSIZE*1+1]); + + tmp1 = tmp4 + tmp5; + tmp3 = tmp4 - tmp5; + + /* Pass 2: process 2 rows, store into output array. */ + + /* Row 0 */ + outptr = output_buf[0] + output_col; + + outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp1, 3) & RANGE_MASK]; + outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp1, 3) & RANGE_MASK]; + + /* Row 1 */ + outptr = output_buf[1] + output_col; + + outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp2 + tmp3, 3) & RANGE_MASK]; + outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp2 - tmp3, 3) & RANGE_MASK]; +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 1x1 output block. + * + * We hardly need an inverse DCT routine for this: just take the + * average pixel value, which is one-eighth of the DC coefficient. + */ + +GLOBAL(void) +jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + DCTELEM dcval; + ISLOW_MULT_TYPE * quantptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + ISHIFT_TEMPS + + /* 1x1 is trivial: just take the DC coefficient divided by 8. */ + + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + + dcval = DEQUANTIZE(coef_block[0], quantptr[0]); + /* Add range center and fudge factor for descale and range-limit. */ + dcval += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2); + + output_buf[0][output_col] = + range_limit[(int) IRIGHT_SHIFT(dcval, 3) & RANGE_MASK]; +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 9x9 output block. + * + * Optimized algorithm with 10 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/18). + */ + +GLOBAL(void) +jpeg_idct_9x9 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13, tmp14; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*9]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp0 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); + + z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp3 = MULTIPLY(z3, FIX(0.707106781)); /* c6 */ + tmp1 = tmp0 + tmp3; + tmp2 = tmp0 - tmp3 - tmp3; + + tmp0 = MULTIPLY(z1 - z2, FIX(0.707106781)); /* c6 */ + tmp11 = tmp2 + tmp0; + tmp14 = tmp2 - tmp0 - tmp0; + + tmp0 = MULTIPLY(z1 + z2, FIX(1.328926049)); /* c2 */ + tmp2 = MULTIPLY(z1, FIX(1.083350441)); /* c4 */ + tmp3 = MULTIPLY(z2, FIX(0.245575608)); /* c8 */ + + tmp10 = tmp1 + tmp0 - tmp3; + tmp12 = tmp1 - tmp0 + tmp2; + tmp13 = tmp1 - tmp2 + tmp3; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + z2 = MULTIPLY(z2, - FIX(1.224744871)); /* -c3 */ + + tmp2 = MULTIPLY(z1 + z3, FIX(0.909038955)); /* c5 */ + tmp3 = MULTIPLY(z1 + z4, FIX(0.483689525)); /* c7 */ + tmp0 = tmp2 + tmp3 - z2; + tmp1 = MULTIPLY(z3 - z4, FIX(1.392728481)); /* c1 */ + tmp2 += z2 - tmp1; + tmp3 += z2 + tmp1; + tmp1 = MULTIPLY(z1 - z3 - z4, FIX(1.224744871)); /* c3 */ + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[8*8] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS-PASS1_BITS); + wsptr[8*7] = (int) RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS-PASS1_BITS); + wsptr[8*2] = (int) RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[8*6] = (int) RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS-PASS1_BITS); + wsptr[8*3] = (int) RIGHT_SHIFT(tmp13 + tmp3, CONST_BITS-PASS1_BITS); + wsptr[8*5] = (int) RIGHT_SHIFT(tmp13 - tmp3, CONST_BITS-PASS1_BITS); + wsptr[8*4] = (int) RIGHT_SHIFT(tmp14, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 9 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 9; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp0 <<= CONST_BITS; + + z1 = (INT32) wsptr[2]; + z2 = (INT32) wsptr[4]; + z3 = (INT32) wsptr[6]; + + tmp3 = MULTIPLY(z3, FIX(0.707106781)); /* c6 */ + tmp1 = tmp0 + tmp3; + tmp2 = tmp0 - tmp3 - tmp3; + + tmp0 = MULTIPLY(z1 - z2, FIX(0.707106781)); /* c6 */ + tmp11 = tmp2 + tmp0; + tmp14 = tmp2 - tmp0 - tmp0; + + tmp0 = MULTIPLY(z1 + z2, FIX(1.328926049)); /* c2 */ + tmp2 = MULTIPLY(z1, FIX(1.083350441)); /* c4 */ + tmp3 = MULTIPLY(z2, FIX(0.245575608)); /* c8 */ + + tmp10 = tmp1 + tmp0 - tmp3; + tmp12 = tmp1 - tmp0 + tmp2; + tmp13 = tmp1 - tmp2 + tmp3; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + z4 = (INT32) wsptr[7]; + + z2 = MULTIPLY(z2, - FIX(1.224744871)); /* -c3 */ + + tmp2 = MULTIPLY(z1 + z3, FIX(0.909038955)); /* c5 */ + tmp3 = MULTIPLY(z1 + z4, FIX(0.483689525)); /* c7 */ + tmp0 = tmp2 + tmp3 - z2; + tmp1 = MULTIPLY(z3 - z4, FIX(1.392728481)); /* c1 */ + tmp2 += z2 - tmp1; + tmp3 += z2 + tmp1; + tmp1 = MULTIPLY(z1 - z3 - z4, FIX(1.224744871)); /* c3 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13 + tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp13 - tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 10x10 output block. + * + * Optimized algorithm with 12 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/20). + */ + +GLOBAL(void) +jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24; + INT32 z1, z2, z3, z4, z5; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*10]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z3 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + z3 += ONE << (CONST_BITS-PASS1_BITS-1); + z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */ + z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */ + tmp10 = z3 + z1; + tmp11 = z3 - z2; + + tmp22 = RIGHT_SHIFT(z3 - ((z1 - z2) << 1), /* c0 = (c4-c8)*2 */ + CONST_BITS-PASS1_BITS); + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */ + tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */ + tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */ + + tmp20 = tmp10 + tmp12; + tmp24 = tmp10 - tmp12; + tmp21 = tmp11 + tmp13; + tmp23 = tmp11 - tmp13; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + tmp11 = z2 + z4; + tmp13 = z2 - z4; + + tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */ + z5 = z3 << CONST_BITS; + + z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */ + z4 = z5 + tmp12; + + tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */ + tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */ + + z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */ + z4 = z5 - tmp12 - (tmp13 << (CONST_BITS - 1)); + + tmp12 = (z1 - tmp13 - z3) << PASS1_BITS; + + tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */ + tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */ + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*9] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*8] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*2] = (int) (tmp22 + tmp12); + wsptr[8*7] = (int) (tmp22 - tmp12); + wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*6] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*5] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 10 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 10; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + z3 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + z3 <<= CONST_BITS; + z4 = (INT32) wsptr[4]; + z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */ + z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */ + tmp10 = z3 + z1; + tmp11 = z3 - z2; + + tmp22 = z3 - ((z1 - z2) << 1); /* c0 = (c4-c8)*2 */ + + z2 = (INT32) wsptr[2]; + z3 = (INT32) wsptr[6]; + + z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */ + tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */ + tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */ + + tmp20 = tmp10 + tmp12; + tmp24 = tmp10 - tmp12; + tmp21 = tmp11 + tmp13; + tmp23 = tmp11 - tmp13; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + z3 <<= CONST_BITS; + z4 = (INT32) wsptr[7]; + + tmp11 = z2 + z4; + tmp13 = z2 - z4; + + tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */ + + z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */ + z4 = z3 + tmp12; + + tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */ + tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */ + + z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */ + z4 = z3 - tmp12 - (tmp13 << (CONST_BITS - 1)); + + tmp12 = ((z1 - tmp13) << CONST_BITS) - z3; + + tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */ + tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing an 11x11 output block. + * + * Optimized algorithm with 24 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/22). + */ + +GLOBAL(void) +jpeg_idct_11x11 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*11]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp10 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp10 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp10 += ONE << (CONST_BITS-PASS1_BITS-1); + + z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp20 = MULTIPLY(z2 - z3, FIX(2.546640132)); /* c2+c4 */ + tmp23 = MULTIPLY(z2 - z1, FIX(0.430815045)); /* c2-c6 */ + z4 = z1 + z3; + tmp24 = MULTIPLY(z4, - FIX(1.155664402)); /* -(c2-c10) */ + z4 -= z2; + tmp25 = tmp10 + MULTIPLY(z4, FIX(1.356927976)); /* c2 */ + tmp21 = tmp20 + tmp23 + tmp25 - + MULTIPLY(z2, FIX(1.821790775)); /* c2+c4+c10-c6 */ + tmp20 += tmp25 + MULTIPLY(z3, FIX(2.115825087)); /* c4+c6 */ + tmp23 += tmp25 - MULTIPLY(z1, FIX(1.513598477)); /* c6+c8 */ + tmp24 += tmp25; + tmp22 = tmp24 - MULTIPLY(z3, FIX(0.788749120)); /* c8+c10 */ + tmp24 += MULTIPLY(z2, FIX(1.944413522)) - /* c2+c8 */ + MULTIPLY(z1, FIX(1.390975730)); /* c4+c10 */ + tmp25 = tmp10 - MULTIPLY(z4, FIX(1.414213562)); /* c0 */ + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + tmp11 = z1 + z2; + tmp14 = MULTIPLY(tmp11 + z3 + z4, FIX(0.398430003)); /* c9 */ + tmp11 = MULTIPLY(tmp11, FIX(0.887983902)); /* c3-c9 */ + tmp12 = MULTIPLY(z1 + z3, FIX(0.670361295)); /* c5-c9 */ + tmp13 = tmp14 + MULTIPLY(z1 + z4, FIX(0.366151574)); /* c7-c9 */ + tmp10 = tmp11 + tmp12 + tmp13 - + MULTIPLY(z1, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */ + z1 = tmp14 - MULTIPLY(z2 + z3, FIX(1.163011579)); /* c7+c9 */ + tmp11 += z1 + MULTIPLY(z2, FIX(2.073276588)); /* c1+c7+3*c9-c3 */ + tmp12 += z1 - MULTIPLY(z3, FIX(1.192193623)); /* c3+c5-c7-c9 */ + z1 = MULTIPLY(z2 + z4, - FIX(1.798248910)); /* -(c1+c9) */ + tmp11 += z1; + tmp13 += z1 + MULTIPLY(z4, FIX(2.102458632)); /* c1+c5+c9-c7 */ + tmp14 += MULTIPLY(z2, - FIX(1.467221301)) + /* -(c5+c9) */ + MULTIPLY(z3, FIX(1.001388905)) - /* c1-c9 */ + MULTIPLY(z4, FIX(1.684843907)); /* c3+c9 */ + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*10] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*9] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*8] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*7] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*6] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*5] = (int) RIGHT_SHIFT(tmp25, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 11 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 11; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp10 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp10 <<= CONST_BITS; + + z1 = (INT32) wsptr[2]; + z2 = (INT32) wsptr[4]; + z3 = (INT32) wsptr[6]; + + tmp20 = MULTIPLY(z2 - z3, FIX(2.546640132)); /* c2+c4 */ + tmp23 = MULTIPLY(z2 - z1, FIX(0.430815045)); /* c2-c6 */ + z4 = z1 + z3; + tmp24 = MULTIPLY(z4, - FIX(1.155664402)); /* -(c2-c10) */ + z4 -= z2; + tmp25 = tmp10 + MULTIPLY(z4, FIX(1.356927976)); /* c2 */ + tmp21 = tmp20 + tmp23 + tmp25 - + MULTIPLY(z2, FIX(1.821790775)); /* c2+c4+c10-c6 */ + tmp20 += tmp25 + MULTIPLY(z3, FIX(2.115825087)); /* c4+c6 */ + tmp23 += tmp25 - MULTIPLY(z1, FIX(1.513598477)); /* c6+c8 */ + tmp24 += tmp25; + tmp22 = tmp24 - MULTIPLY(z3, FIX(0.788749120)); /* c8+c10 */ + tmp24 += MULTIPLY(z2, FIX(1.944413522)) - /* c2+c8 */ + MULTIPLY(z1, FIX(1.390975730)); /* c4+c10 */ + tmp25 = tmp10 - MULTIPLY(z4, FIX(1.414213562)); /* c0 */ + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + z4 = (INT32) wsptr[7]; + + tmp11 = z1 + z2; + tmp14 = MULTIPLY(tmp11 + z3 + z4, FIX(0.398430003)); /* c9 */ + tmp11 = MULTIPLY(tmp11, FIX(0.887983902)); /* c3-c9 */ + tmp12 = MULTIPLY(z1 + z3, FIX(0.670361295)); /* c5-c9 */ + tmp13 = tmp14 + MULTIPLY(z1 + z4, FIX(0.366151574)); /* c7-c9 */ + tmp10 = tmp11 + tmp12 + tmp13 - + MULTIPLY(z1, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */ + z1 = tmp14 - MULTIPLY(z2 + z3, FIX(1.163011579)); /* c7+c9 */ + tmp11 += z1 + MULTIPLY(z2, FIX(2.073276588)); /* c1+c7+3*c9-c3 */ + tmp12 += z1 - MULTIPLY(z3, FIX(1.192193623)); /* c3+c5-c7-c9 */ + z1 = MULTIPLY(z2 + z4, - FIX(1.798248910)); /* -(c1+c9) */ + tmp11 += z1; + tmp13 += z1 + MULTIPLY(z4, FIX(2.102458632)); /* c1+c5+c9-c7 */ + tmp14 += MULTIPLY(z2, - FIX(1.467221301)) + /* -(c5+c9) */ + MULTIPLY(z3, FIX(1.001388905)) - /* c1-c9 */ + MULTIPLY(z4, FIX(1.684843907)); /* c3+c9 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 12x12 output block. + * + * Optimized algorithm with 15 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/24). + */ + +GLOBAL(void) +jpeg_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*12]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z3 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + z3 += ONE << (CONST_BITS-PASS1_BITS-1); + + z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */ + + tmp10 = z3 + z4; + tmp11 = z3 - z4; + + z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */ + z1 <<= CONST_BITS; + z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + z2 <<= CONST_BITS; + + tmp12 = z1 - z2; + + tmp21 = z3 + tmp12; + tmp24 = z3 - tmp12; + + tmp12 = z4 + z2; + + tmp20 = tmp10 + tmp12; + tmp25 = tmp10 - tmp12; + + tmp12 = z4 - z1 - z2; + + tmp22 = tmp11 + tmp12; + tmp23 = tmp11 - tmp12; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */ + tmp14 = MULTIPLY(z2, - FIX_0_541196100); /* -c9 */ + + tmp10 = z1 + z3; + tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */ + tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */ + tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */ + tmp13 = MULTIPLY(z3 + z4, - FIX(1.045510580)); /* -(c7+c11) */ + tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */ + tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */ + tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */ + MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */ + + z1 -= z4; + z2 -= z3; + z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */ + tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */ + tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */ + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*11] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*10] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*9] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*8] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*7] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); + wsptr[8*6] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 12 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 12; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + z3 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + z3 <<= CONST_BITS; + + z4 = (INT32) wsptr[4]; + z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */ + + tmp10 = z3 + z4; + tmp11 = z3 - z4; + + z1 = (INT32) wsptr[2]; + z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */ + z1 <<= CONST_BITS; + z2 = (INT32) wsptr[6]; + z2 <<= CONST_BITS; + + tmp12 = z1 - z2; + + tmp21 = z3 + tmp12; + tmp24 = z3 - tmp12; + + tmp12 = z4 + z2; + + tmp20 = tmp10 + tmp12; + tmp25 = tmp10 - tmp12; + + tmp12 = z4 - z1 - z2; + + tmp22 = tmp11 + tmp12; + tmp23 = tmp11 - tmp12; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + z4 = (INT32) wsptr[7]; + + tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */ + tmp14 = MULTIPLY(z2, - FIX_0_541196100); /* -c9 */ + + tmp10 = z1 + z3; + tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */ + tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */ + tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */ + tmp13 = MULTIPLY(z3 + z4, - FIX(1.045510580)); /* -(c7+c11) */ + tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */ + tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */ + tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */ + MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */ + + z1 -= z4; + z2 -= z3; + z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */ + tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */ + tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 13x13 output block. + * + * Optimized algorithm with 29 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/26). + */ + +GLOBAL(void) +jpeg_idct_13x13 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*13]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z1 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS-PASS1_BITS-1); + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z4 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp10 = z3 + z4; + tmp11 = z3 - z4; + + tmp12 = MULTIPLY(tmp10, FIX(1.155388986)); /* (c4+c6)/2 */ + tmp13 = MULTIPLY(tmp11, FIX(0.096834934)) + z1; /* (c4-c6)/2 */ + + tmp20 = MULTIPLY(z2, FIX(1.373119086)) + tmp12 + tmp13; /* c2 */ + tmp22 = MULTIPLY(z2, FIX(0.501487041)) - tmp12 + tmp13; /* c10 */ + + tmp12 = MULTIPLY(tmp10, FIX(0.316450131)); /* (c8-c12)/2 */ + tmp13 = MULTIPLY(tmp11, FIX(0.486914739)) + z1; /* (c8+c12)/2 */ + + tmp21 = MULTIPLY(z2, FIX(1.058554052)) - tmp12 + tmp13; /* c6 */ + tmp25 = MULTIPLY(z2, - FIX(1.252223920)) + tmp12 + tmp13; /* c4 */ + + tmp12 = MULTIPLY(tmp10, FIX(0.435816023)); /* (c2-c10)/2 */ + tmp13 = MULTIPLY(tmp11, FIX(0.937303064)) - z1; /* (c2+c10)/2 */ + + tmp23 = MULTIPLY(z2, - FIX(0.170464608)) - tmp12 - tmp13; /* c12 */ + tmp24 = MULTIPLY(z2, - FIX(0.803364869)) + tmp12 - tmp13; /* c8 */ + + tmp26 = MULTIPLY(tmp11 - z2, FIX(1.414213562)) + z1; /* c0 */ + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + tmp11 = MULTIPLY(z1 + z2, FIX(1.322312651)); /* c3 */ + tmp12 = MULTIPLY(z1 + z3, FIX(1.163874945)); /* c5 */ + tmp15 = z1 + z4; + tmp13 = MULTIPLY(tmp15, FIX(0.937797057)); /* c7 */ + tmp10 = tmp11 + tmp12 + tmp13 - + MULTIPLY(z1, FIX(2.020082300)); /* c7+c5+c3-c1 */ + tmp14 = MULTIPLY(z2 + z3, - FIX(0.338443458)); /* -c11 */ + tmp11 += tmp14 + MULTIPLY(z2, FIX(0.837223564)); /* c5+c9+c11-c3 */ + tmp12 += tmp14 - MULTIPLY(z3, FIX(1.572116027)); /* c1+c5-c9-c11 */ + tmp14 = MULTIPLY(z2 + z4, - FIX(1.163874945)); /* -c5 */ + tmp11 += tmp14; + tmp13 += tmp14 + MULTIPLY(z4, FIX(2.205608352)); /* c3+c5+c9-c7 */ + tmp14 = MULTIPLY(z3 + z4, - FIX(0.657217813)); /* -c9 */ + tmp12 += tmp14; + tmp13 += tmp14; + tmp15 = MULTIPLY(tmp15, FIX(0.338443458)); /* c11 */ + tmp14 = tmp15 + MULTIPLY(z1, FIX(0.318774355)) - /* c9-c11 */ + MULTIPLY(z2, FIX(0.466105296)); /* c1-c7 */ + z1 = MULTIPLY(z3 - z2, FIX(0.937797057)); /* c7 */ + tmp14 += z1; + tmp15 += z1 + MULTIPLY(z3, FIX(0.384515595)) - /* c3-c7 */ + MULTIPLY(z4, FIX(1.742345811)); /* c1+c11 */ + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*12] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*11] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*10] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*9] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*8] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); + wsptr[8*7] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); + wsptr[8*6] = (int) RIGHT_SHIFT(tmp26, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 13 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 13; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + z1 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + z1 <<= CONST_BITS; + + z2 = (INT32) wsptr[2]; + z3 = (INT32) wsptr[4]; + z4 = (INT32) wsptr[6]; + + tmp10 = z3 + z4; + tmp11 = z3 - z4; + + tmp12 = MULTIPLY(tmp10, FIX(1.155388986)); /* (c4+c6)/2 */ + tmp13 = MULTIPLY(tmp11, FIX(0.096834934)) + z1; /* (c4-c6)/2 */ + + tmp20 = MULTIPLY(z2, FIX(1.373119086)) + tmp12 + tmp13; /* c2 */ + tmp22 = MULTIPLY(z2, FIX(0.501487041)) - tmp12 + tmp13; /* c10 */ + + tmp12 = MULTIPLY(tmp10, FIX(0.316450131)); /* (c8-c12)/2 */ + tmp13 = MULTIPLY(tmp11, FIX(0.486914739)) + z1; /* (c8+c12)/2 */ + + tmp21 = MULTIPLY(z2, FIX(1.058554052)) - tmp12 + tmp13; /* c6 */ + tmp25 = MULTIPLY(z2, - FIX(1.252223920)) + tmp12 + tmp13; /* c4 */ + + tmp12 = MULTIPLY(tmp10, FIX(0.435816023)); /* (c2-c10)/2 */ + tmp13 = MULTIPLY(tmp11, FIX(0.937303064)) - z1; /* (c2+c10)/2 */ + + tmp23 = MULTIPLY(z2, - FIX(0.170464608)) - tmp12 - tmp13; /* c12 */ + tmp24 = MULTIPLY(z2, - FIX(0.803364869)) + tmp12 - tmp13; /* c8 */ + + tmp26 = MULTIPLY(tmp11 - z2, FIX(1.414213562)) + z1; /* c0 */ + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + z4 = (INT32) wsptr[7]; + + tmp11 = MULTIPLY(z1 + z2, FIX(1.322312651)); /* c3 */ + tmp12 = MULTIPLY(z1 + z3, FIX(1.163874945)); /* c5 */ + tmp15 = z1 + z4; + tmp13 = MULTIPLY(tmp15, FIX(0.937797057)); /* c7 */ + tmp10 = tmp11 + tmp12 + tmp13 - + MULTIPLY(z1, FIX(2.020082300)); /* c7+c5+c3-c1 */ + tmp14 = MULTIPLY(z2 + z3, - FIX(0.338443458)); /* -c11 */ + tmp11 += tmp14 + MULTIPLY(z2, FIX(0.837223564)); /* c5+c9+c11-c3 */ + tmp12 += tmp14 - MULTIPLY(z3, FIX(1.572116027)); /* c1+c5-c9-c11 */ + tmp14 = MULTIPLY(z2 + z4, - FIX(1.163874945)); /* -c5 */ + tmp11 += tmp14; + tmp13 += tmp14 + MULTIPLY(z4, FIX(2.205608352)); /* c3+c5+c9-c7 */ + tmp14 = MULTIPLY(z3 + z4, - FIX(0.657217813)); /* -c9 */ + tmp12 += tmp14; + tmp13 += tmp14; + tmp15 = MULTIPLY(tmp15, FIX(0.338443458)); /* c11 */ + tmp14 = tmp15 + MULTIPLY(z1, FIX(0.318774355)) - /* c9-c11 */ + MULTIPLY(z2, FIX(0.466105296)); /* c1-c7 */ + z1 = MULTIPLY(z3 - z2, FIX(0.937797057)); /* c7 */ + tmp14 += z1; + tmp15 += z1 + MULTIPLY(z3, FIX(0.384515595)) - /* c3-c7 */ + MULTIPLY(z4, FIX(1.742345811)); /* c1+c11 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 14x14 output block. + * + * Optimized algorithm with 20 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/28). + */ + +GLOBAL(void) +jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*14]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z1 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS-PASS1_BITS-1); + z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */ + z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */ + z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */ + + tmp10 = z1 + z2; + tmp11 = z1 + z3; + tmp12 = z1 - z4; + + tmp23 = RIGHT_SHIFT(z1 - ((z2 + z3 - z4) << 1), /* c0 = (c4+c12-c8)*2 */ + CONST_BITS-PASS1_BITS); + + z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */ + + tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */ + tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */ + tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */ + MULTIPLY(z2, FIX(1.378756276)); /* c2 */ + + tmp20 = tmp10 + tmp13; + tmp26 = tmp10 - tmp13; + tmp21 = tmp11 + tmp14; + tmp25 = tmp11 - tmp14; + tmp22 = tmp12 + tmp15; + tmp24 = tmp12 - tmp15; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + tmp13 = z4 << CONST_BITS; + + tmp14 = z1 + z3; + tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */ + tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */ + tmp10 = tmp11 + tmp12 + tmp13 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */ + tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */ + tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */ + z1 -= z2; + tmp15 = MULTIPLY(z1, FIX(0.467085129)) - tmp13; /* c11 */ + tmp16 += tmp15; + z1 += z4; + z4 = MULTIPLY(z2 + z3, - FIX(0.158341681)) - tmp13; /* -c13 */ + tmp11 += z4 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */ + tmp12 += z4 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */ + z4 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */ + tmp14 += z4 + tmp13 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */ + tmp15 += z4 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */ + + tmp13 = (z1 - z3) << PASS1_BITS; + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*13] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*12] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*11] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*3] = (int) (tmp23 + tmp13); + wsptr[8*10] = (int) (tmp23 - tmp13); + wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*9] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); + wsptr[8*8] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); + wsptr[8*6] = (int) RIGHT_SHIFT(tmp26 + tmp16, CONST_BITS-PASS1_BITS); + wsptr[8*7] = (int) RIGHT_SHIFT(tmp26 - tmp16, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 14 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 14; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + z1 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + z1 <<= CONST_BITS; + z4 = (INT32) wsptr[4]; + z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */ + z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */ + z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */ + + tmp10 = z1 + z2; + tmp11 = z1 + z3; + tmp12 = z1 - z4; + + tmp23 = z1 - ((z2 + z3 - z4) << 1); /* c0 = (c4+c12-c8)*2 */ + + z1 = (INT32) wsptr[2]; + z2 = (INT32) wsptr[6]; + + z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */ + + tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */ + tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */ + tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */ + MULTIPLY(z2, FIX(1.378756276)); /* c2 */ + + tmp20 = tmp10 + tmp13; + tmp26 = tmp10 - tmp13; + tmp21 = tmp11 + tmp14; + tmp25 = tmp11 - tmp14; + tmp22 = tmp12 + tmp15; + tmp24 = tmp12 - tmp15; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + z4 = (INT32) wsptr[7]; + z4 <<= CONST_BITS; + + tmp14 = z1 + z3; + tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */ + tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */ + tmp10 = tmp11 + tmp12 + z4 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */ + tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */ + tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */ + z1 -= z2; + tmp15 = MULTIPLY(z1, FIX(0.467085129)) - z4; /* c11 */ + tmp16 += tmp15; + tmp13 = MULTIPLY(z2 + z3, - FIX(0.158341681)) - z4; /* -c13 */ + tmp11 += tmp13 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */ + tmp12 += tmp13 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */ + tmp13 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */ + tmp14 += tmp13 + z4 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */ + tmp15 += tmp13 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */ + + tmp13 = ((z1 - z3) << CONST_BITS) + z4; + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp16, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp16, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 15x15 output block. + * + * Optimized algorithm with 22 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/30). + */ + +GLOBAL(void) +jpeg_idct_15x15 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*15]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z1 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS-PASS1_BITS-1); + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z4 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp10 = MULTIPLY(z4, FIX(0.437016024)); /* c12 */ + tmp11 = MULTIPLY(z4, FIX(1.144122806)); /* c6 */ + + tmp12 = z1 - tmp10; + tmp13 = z1 + tmp11; + z1 -= (tmp11 - tmp10) << 1; /* c0 = (c6-c12)*2 */ + + z4 = z2 - z3; + z3 += z2; + tmp10 = MULTIPLY(z3, FIX(1.337628990)); /* (c2+c4)/2 */ + tmp11 = MULTIPLY(z4, FIX(0.045680613)); /* (c2-c4)/2 */ + z2 = MULTIPLY(z2, FIX(1.439773946)); /* c4+c14 */ + + tmp20 = tmp13 + tmp10 + tmp11; + tmp23 = tmp12 - tmp10 + tmp11 + z2; + + tmp10 = MULTIPLY(z3, FIX(0.547059574)); /* (c8+c14)/2 */ + tmp11 = MULTIPLY(z4, FIX(0.399234004)); /* (c8-c14)/2 */ + + tmp25 = tmp13 - tmp10 - tmp11; + tmp26 = tmp12 + tmp10 - tmp11 - z2; + + tmp10 = MULTIPLY(z3, FIX(0.790569415)); /* (c6+c12)/2 */ + tmp11 = MULTIPLY(z4, FIX(0.353553391)); /* (c6-c12)/2 */ + + tmp21 = tmp12 + tmp10 + tmp11; + tmp24 = tmp13 - tmp10 + tmp11; + tmp11 += tmp11; + tmp22 = z1 + tmp11; /* c10 = c6-c12 */ + tmp27 = z1 - tmp11 - tmp11; /* c0 = (c6-c12)*2 */ + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z4 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z3 = MULTIPLY(z4, FIX(1.224744871)); /* c5 */ + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + tmp13 = z2 - z4; + tmp15 = MULTIPLY(z1 + tmp13, FIX(0.831253876)); /* c9 */ + tmp11 = tmp15 + MULTIPLY(z1, FIX(0.513743148)); /* c3-c9 */ + tmp14 = tmp15 - MULTIPLY(tmp13, FIX(2.176250899)); /* c3+c9 */ + + tmp13 = MULTIPLY(z2, - FIX(0.831253876)); /* -c9 */ + tmp15 = MULTIPLY(z2, - FIX(1.344997024)); /* -c3 */ + z2 = z1 - z4; + tmp12 = z3 + MULTIPLY(z2, FIX(1.406466353)); /* c1 */ + + tmp10 = tmp12 + MULTIPLY(z4, FIX(2.457431844)) - tmp15; /* c1+c7 */ + tmp16 = tmp12 - MULTIPLY(z1, FIX(1.112434820)) + tmp13; /* c1-c13 */ + tmp12 = MULTIPLY(z2, FIX(1.224744871)) - z3; /* c5 */ + z2 = MULTIPLY(z1 + z4, FIX(0.575212477)); /* c11 */ + tmp13 += z2 + MULTIPLY(z1, FIX(0.475753014)) - z3; /* c7-c11 */ + tmp15 += z2 - MULTIPLY(z4, FIX(0.869244010)) + z3; /* c11+c13 */ + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*14] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*13] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*12] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*11] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*10] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); + wsptr[8*9] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); + wsptr[8*6] = (int) RIGHT_SHIFT(tmp26 + tmp16, CONST_BITS-PASS1_BITS); + wsptr[8*8] = (int) RIGHT_SHIFT(tmp26 - tmp16, CONST_BITS-PASS1_BITS); + wsptr[8*7] = (int) RIGHT_SHIFT(tmp27, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 15 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 15; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + z1 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + z1 <<= CONST_BITS; + + z2 = (INT32) wsptr[2]; + z3 = (INT32) wsptr[4]; + z4 = (INT32) wsptr[6]; + + tmp10 = MULTIPLY(z4, FIX(0.437016024)); /* c12 */ + tmp11 = MULTIPLY(z4, FIX(1.144122806)); /* c6 */ + + tmp12 = z1 - tmp10; + tmp13 = z1 + tmp11; + z1 -= (tmp11 - tmp10) << 1; /* c0 = (c6-c12)*2 */ + + z4 = z2 - z3; + z3 += z2; + tmp10 = MULTIPLY(z3, FIX(1.337628990)); /* (c2+c4)/2 */ + tmp11 = MULTIPLY(z4, FIX(0.045680613)); /* (c2-c4)/2 */ + z2 = MULTIPLY(z2, FIX(1.439773946)); /* c4+c14 */ + + tmp20 = tmp13 + tmp10 + tmp11; + tmp23 = tmp12 - tmp10 + tmp11 + z2; + + tmp10 = MULTIPLY(z3, FIX(0.547059574)); /* (c8+c14)/2 */ + tmp11 = MULTIPLY(z4, FIX(0.399234004)); /* (c8-c14)/2 */ + + tmp25 = tmp13 - tmp10 - tmp11; + tmp26 = tmp12 + tmp10 - tmp11 - z2; + + tmp10 = MULTIPLY(z3, FIX(0.790569415)); /* (c6+c12)/2 */ + tmp11 = MULTIPLY(z4, FIX(0.353553391)); /* (c6-c12)/2 */ + + tmp21 = tmp12 + tmp10 + tmp11; + tmp24 = tmp13 - tmp10 + tmp11; + tmp11 += tmp11; + tmp22 = z1 + tmp11; /* c10 = c6-c12 */ + tmp27 = z1 - tmp11 - tmp11; /* c0 = (c6-c12)*2 */ + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z4 = (INT32) wsptr[5]; + z3 = MULTIPLY(z4, FIX(1.224744871)); /* c5 */ + z4 = (INT32) wsptr[7]; + + tmp13 = z2 - z4; + tmp15 = MULTIPLY(z1 + tmp13, FIX(0.831253876)); /* c9 */ + tmp11 = tmp15 + MULTIPLY(z1, FIX(0.513743148)); /* c3-c9 */ + tmp14 = tmp15 - MULTIPLY(tmp13, FIX(2.176250899)); /* c3+c9 */ + + tmp13 = MULTIPLY(z2, - FIX(0.831253876)); /* -c9 */ + tmp15 = MULTIPLY(z2, - FIX(1.344997024)); /* -c3 */ + z2 = z1 - z4; + tmp12 = z3 + MULTIPLY(z2, FIX(1.406466353)); /* c1 */ + + tmp10 = tmp12 + MULTIPLY(z4, FIX(2.457431844)) - tmp15; /* c1+c7 */ + tmp16 = tmp12 - MULTIPLY(z1, FIX(1.112434820)) + tmp13; /* c1-c13 */ + tmp12 = MULTIPLY(z2, FIX(1.224744871)) - z3; /* c5 */ + z2 = MULTIPLY(z1 + z4, FIX(0.575212477)); /* c11 */ + tmp13 += z2 + MULTIPLY(z1, FIX(0.475753014)) - z3; /* c7-c11 */ + tmp15 += z2 - MULTIPLY(z4, FIX(0.869244010)) + z3; /* c11+c13 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[14] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp16, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp16, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp27, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 16x16 output block. + * + * Optimized algorithm with 28 multiplications in the 1-D kernel. + * cK represents sqrt(2) * cos(K*pi/32). + */ + +GLOBAL(void) +jpeg_idct_16x16 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*16]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp0 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); + + z1 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */ + tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */ + + tmp10 = tmp0 + tmp1; + tmp11 = tmp0 - tmp1; + tmp12 = tmp0 + tmp2; + tmp13 = tmp0 - tmp2; + + z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + z3 = z1 - z2; + z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */ + z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */ + + tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */ + tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */ + tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */ + tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */ + + tmp20 = tmp10 + tmp0; + tmp27 = tmp10 - tmp0; + tmp21 = tmp12 + tmp1; + tmp26 = tmp12 - tmp1; + tmp22 = tmp13 + tmp2; + tmp25 = tmp13 - tmp2; + tmp23 = tmp11 + tmp3; + tmp24 = tmp11 - tmp3; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + tmp11 = z1 + z3; + + tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */ + tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */ + tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */ + tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */ + tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */ + tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */ + tmp0 = tmp1 + tmp2 + tmp3 - + MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */ + tmp13 = tmp10 + tmp11 + tmp12 - + MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */ + z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */ + tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */ + tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */ + z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */ + tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */ + tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */ + z2 += z4; + z1 = MULTIPLY(z2, - FIX(0.666655658)); /* -c11 */ + tmp1 += z1; + tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */ + z2 = MULTIPLY(z2, - FIX(1.247225013)); /* -c5 */ + tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */ + tmp12 += z2; + z2 = MULTIPLY(z3 + z4, - FIX(1.353318001)); /* -c3 */ + tmp2 += z2; + tmp3 += z2; + z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */ + tmp10 += z2; + tmp11 += z2; + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[8*15] = (int) RIGHT_SHIFT(tmp20 - tmp0, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp1, CONST_BITS-PASS1_BITS); + wsptr[8*14] = (int) RIGHT_SHIFT(tmp21 - tmp1, CONST_BITS-PASS1_BITS); + wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[8*13] = (int) RIGHT_SHIFT(tmp22 - tmp2, CONST_BITS-PASS1_BITS); + wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp3, CONST_BITS-PASS1_BITS); + wsptr[8*12] = (int) RIGHT_SHIFT(tmp23 - tmp3, CONST_BITS-PASS1_BITS); + wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*11] = (int) RIGHT_SHIFT(tmp24 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*10] = (int) RIGHT_SHIFT(tmp25 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*6] = (int) RIGHT_SHIFT(tmp26 + tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*9] = (int) RIGHT_SHIFT(tmp26 - tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*7] = (int) RIGHT_SHIFT(tmp27 + tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*8] = (int) RIGHT_SHIFT(tmp27 - tmp13, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 16 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 16; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp0 <<= CONST_BITS; + + z1 = (INT32) wsptr[4]; + tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */ + tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */ + + tmp10 = tmp0 + tmp1; + tmp11 = tmp0 - tmp1; + tmp12 = tmp0 + tmp2; + tmp13 = tmp0 - tmp2; + + z1 = (INT32) wsptr[2]; + z2 = (INT32) wsptr[6]; + z3 = z1 - z2; + z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */ + z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */ + + tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */ + tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */ + tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */ + tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */ + + tmp20 = tmp10 + tmp0; + tmp27 = tmp10 - tmp0; + tmp21 = tmp12 + tmp1; + tmp26 = tmp12 - tmp1; + tmp22 = tmp13 + tmp2; + tmp25 = tmp13 - tmp2; + tmp23 = tmp11 + tmp3; + tmp24 = tmp11 - tmp3; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + z4 = (INT32) wsptr[7]; + + tmp11 = z1 + z3; + + tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */ + tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */ + tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */ + tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */ + tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */ + tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */ + tmp0 = tmp1 + tmp2 + tmp3 - + MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */ + tmp13 = tmp10 + tmp11 + tmp12 - + MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */ + z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */ + tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */ + tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */ + z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */ + tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */ + tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */ + z2 += z4; + z1 = MULTIPLY(z2, - FIX(0.666655658)); /* -c11 */ + tmp1 += z1; + tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */ + z2 = MULTIPLY(z2, - FIX(1.247225013)); /* -c5 */ + tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */ + tmp12 += z2; + z2 = MULTIPLY(z3 + z4, - FIX(1.353318001)); /* -c3 */ + tmp2 += z2; + tmp3 += z2; + z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */ + tmp10 += z2; + tmp11 += z2; + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[15] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[14] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp27 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp27 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 16x8 output block. + * + * 8-point IDCT in pass 1 (columns), 16-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_16x8 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*8]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * Note results are scaled up by sqrt(8) compared to a true IDCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16). + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && + inptr[DCTSIZE*7] == 0) { + /* AC terms all zero */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part: reverse the even part of the forward DCT. + * The rotator is c(-6). + */ + + z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z2 <<= CONST_BITS; + z3 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + z2 += ONE << (CONST_BITS-PASS1_BITS-1); + + tmp0 = z2 + z3; + tmp1 = z2 - z3; + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + tmp10 = tmp0 + tmp2; + tmp13 = tmp0 - tmp2; + tmp11 = tmp1 + tmp3; + tmp12 = tmp1 - tmp3; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + + z2 = tmp0 + tmp2; + z3 = tmp1 + tmp3; + + z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ + z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ + z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ + z2 += z1; + z3 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp0 += z1 + z2; + tmp3 += z1 + z3; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp1 += z1 + z3; + tmp2 += z1 + z2; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + wsptr[DCTSIZE*0] = (int) RIGHT_SHIFT(tmp10 + tmp3, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*7] = (int) RIGHT_SHIFT(tmp10 - tmp3, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*1] = (int) RIGHT_SHIFT(tmp11 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*6] = (int) RIGHT_SHIFT(tmp11 - tmp2, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*2] = (int) RIGHT_SHIFT(tmp12 + tmp1, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*5] = (int) RIGHT_SHIFT(tmp12 - tmp1, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*3] = (int) RIGHT_SHIFT(tmp13 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*4] = (int) RIGHT_SHIFT(tmp13 - tmp0, CONST_BITS-PASS1_BITS); + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process 8 rows from work array, store into output array. + * 16-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/32). + */ + + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp0 <<= CONST_BITS; + + z1 = (INT32) wsptr[4]; + tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */ + tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */ + + tmp10 = tmp0 + tmp1; + tmp11 = tmp0 - tmp1; + tmp12 = tmp0 + tmp2; + tmp13 = tmp0 - tmp2; + + z1 = (INT32) wsptr[2]; + z2 = (INT32) wsptr[6]; + z3 = z1 - z2; + z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */ + z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */ + + tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */ + tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */ + tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */ + tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */ + + tmp20 = tmp10 + tmp0; + tmp27 = tmp10 - tmp0; + tmp21 = tmp12 + tmp1; + tmp26 = tmp12 - tmp1; + tmp22 = tmp13 + tmp2; + tmp25 = tmp13 - tmp2; + tmp23 = tmp11 + tmp3; + tmp24 = tmp11 - tmp3; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + z4 = (INT32) wsptr[7]; + + tmp11 = z1 + z3; + + tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */ + tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */ + tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */ + tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */ + tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */ + tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */ + tmp0 = tmp1 + tmp2 + tmp3 - + MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */ + tmp13 = tmp10 + tmp11 + tmp12 - + MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */ + z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */ + tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */ + tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */ + z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */ + tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */ + tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */ + z2 += z4; + z1 = MULTIPLY(z2, - FIX(0.666655658)); /* -c11 */ + tmp1 += z1; + tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */ + z2 = MULTIPLY(z2, - FIX(1.247225013)); /* -c5 */ + tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */ + tmp12 += z2; + z2 = MULTIPLY(z3 + z4, - FIX(1.353318001)); /* -c3 */ + tmp2 += z2; + tmp3 += z2; + z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */ + tmp10 += z2; + tmp11 += z2; + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[15] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[14] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp27 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp27 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 14x7 output block. + * + * 7-point IDCT in pass 1 (columns), 14-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_14x7 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*7]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * 7-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/14). + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp23 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp23 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp23 += ONE << (CONST_BITS-PASS1_BITS-1); + + z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp20 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */ + tmp22 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */ + tmp21 = tmp20 + tmp22 + tmp23 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */ + tmp10 = z1 + z3; + z2 -= tmp10; + tmp10 = MULTIPLY(tmp10, FIX(1.274162392)) + tmp23; /* c2 */ + tmp20 += tmp10 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */ + tmp22 += tmp10 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */ + tmp23 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */ + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + + tmp11 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */ + tmp12 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */ + tmp10 = tmp11 - tmp12; + tmp11 += tmp12; + tmp12 = MULTIPLY(z2 + z3, - FIX(1.378756276)); /* -c1 */ + tmp11 += tmp12; + z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */ + tmp10 += z2; + tmp12 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */ + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*6] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*5] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*4] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*3] = (int) RIGHT_SHIFT(tmp23, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 7 rows from work array, store into output array. + * 14-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/28). + */ + + wsptr = workspace; + for (ctr = 0; ctr < 7; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + z1 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + z1 <<= CONST_BITS; + z4 = (INT32) wsptr[4]; + z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */ + z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */ + z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */ + + tmp10 = z1 + z2; + tmp11 = z1 + z3; + tmp12 = z1 - z4; + + tmp23 = z1 - ((z2 + z3 - z4) << 1); /* c0 = (c4+c12-c8)*2 */ + + z1 = (INT32) wsptr[2]; + z2 = (INT32) wsptr[6]; + + z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */ + + tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */ + tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */ + tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */ + MULTIPLY(z2, FIX(1.378756276)); /* c2 */ + + tmp20 = tmp10 + tmp13; + tmp26 = tmp10 - tmp13; + tmp21 = tmp11 + tmp14; + tmp25 = tmp11 - tmp14; + tmp22 = tmp12 + tmp15; + tmp24 = tmp12 - tmp15; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + z4 = (INT32) wsptr[7]; + z4 <<= CONST_BITS; + + tmp14 = z1 + z3; + tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */ + tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */ + tmp10 = tmp11 + tmp12 + z4 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */ + tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */ + tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */ + z1 -= z2; + tmp15 = MULTIPLY(z1, FIX(0.467085129)) - z4; /* c11 */ + tmp16 += tmp15; + tmp13 = MULTIPLY(z2 + z3, - FIX(0.158341681)) - z4; /* -c13 */ + tmp11 += tmp13 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */ + tmp12 += tmp13 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */ + tmp13 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */ + tmp14 += tmp13 + z4 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */ + tmp15 += tmp13 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */ + + tmp13 = ((z1 - z3) << CONST_BITS) + z4; + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp16, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp16, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 12x6 output block. + * + * 6-point IDCT in pass 1 (columns), 12-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_12x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*6]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12). + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp10 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp10 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp10 += ONE << (CONST_BITS-PASS1_BITS-1); + tmp12 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp20 = MULTIPLY(tmp12, FIX(0.707106781)); /* c4 */ + tmp11 = tmp10 + tmp20; + tmp21 = RIGHT_SHIFT(tmp10 - tmp20 - tmp20, CONST_BITS-PASS1_BITS); + tmp20 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp10 = MULTIPLY(tmp20, FIX(1.224744871)); /* c2 */ + tmp20 = tmp11 + tmp10; + tmp22 = tmp11 - tmp10; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp11 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ + tmp10 = tmp11 + ((z1 + z2) << CONST_BITS); + tmp12 = tmp11 + ((z3 - z2) << CONST_BITS); + tmp11 = (z1 - z2 - z3) << PASS1_BITS; + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*5] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) (tmp21 + tmp11); + wsptr[8*4] = (int) (tmp21 - tmp11); + wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*3] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 6 rows from work array, store into output array. + * 12-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/24). + */ + + wsptr = workspace; + for (ctr = 0; ctr < 6; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + z3 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + z3 <<= CONST_BITS; + + z4 = (INT32) wsptr[4]; + z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */ + + tmp10 = z3 + z4; + tmp11 = z3 - z4; + + z1 = (INT32) wsptr[2]; + z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */ + z1 <<= CONST_BITS; + z2 = (INT32) wsptr[6]; + z2 <<= CONST_BITS; + + tmp12 = z1 - z2; + + tmp21 = z3 + tmp12; + tmp24 = z3 - tmp12; + + tmp12 = z4 + z2; + + tmp20 = tmp10 + tmp12; + tmp25 = tmp10 - tmp12; + + tmp12 = z4 - z1 - z2; + + tmp22 = tmp11 + tmp12; + tmp23 = tmp11 - tmp12; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + z4 = (INT32) wsptr[7]; + + tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */ + tmp14 = MULTIPLY(z2, - FIX_0_541196100); /* -c9 */ + + tmp10 = z1 + z3; + tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */ + tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */ + tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */ + tmp13 = MULTIPLY(z3 + z4, - FIX(1.045510580)); /* -(c7+c11) */ + tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */ + tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */ + tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */ + MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */ + + z1 -= z4; + z2 -= z3; + z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */ + tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */ + tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 10x5 output block. + * + * 5-point IDCT in pass 1 (columns), 10-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_10x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*5]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * 5-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/10). + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp12 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp12 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp12 += ONE << (CONST_BITS-PASS1_BITS-1); + tmp13 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp14 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z1 = MULTIPLY(tmp13 + tmp14, FIX(0.790569415)); /* (c2+c4)/2 */ + z2 = MULTIPLY(tmp13 - tmp14, FIX(0.353553391)); /* (c2-c4)/2 */ + z3 = tmp12 + z2; + tmp10 = z3 + z1; + tmp11 = z3 - z1; + tmp12 -= z2 << 2; + + /* Odd part */ + + z2 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + + z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */ + tmp13 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */ + tmp14 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */ + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp10 + tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*4] = (int) RIGHT_SHIFT(tmp10 - tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) RIGHT_SHIFT(tmp11 + tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*3] = (int) RIGHT_SHIFT(tmp11 - tmp14, CONST_BITS-PASS1_BITS); + wsptr[8*2] = (int) RIGHT_SHIFT(tmp12, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 5 rows from work array, store into output array. + * 10-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/20). + */ + + wsptr = workspace; + for (ctr = 0; ctr < 5; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + z3 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + z3 <<= CONST_BITS; + z4 = (INT32) wsptr[4]; + z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */ + z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */ + tmp10 = z3 + z1; + tmp11 = z3 - z2; + + tmp22 = z3 - ((z1 - z2) << 1); /* c0 = (c4-c8)*2 */ + + z2 = (INT32) wsptr[2]; + z3 = (INT32) wsptr[6]; + + z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */ + tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */ + tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */ + + tmp20 = tmp10 + tmp12; + tmp24 = tmp10 - tmp12; + tmp21 = tmp11 + tmp13; + tmp23 = tmp11 - tmp13; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + z3 <<= CONST_BITS; + z4 = (INT32) wsptr[7]; + + tmp11 = z2 + z4; + tmp13 = z2 - z4; + + tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */ + + z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */ + z4 = z3 + tmp12; + + tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */ + tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */ + + z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */ + z4 = z3 - tmp12 - (tmp13 << (CONST_BITS - 1)); + + tmp12 = ((z1 - tmp13) << CONST_BITS) - z3; + + tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */ + tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 8; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing an 8x4 output block. + * + * 4-point IDCT in pass 1 (columns), 8-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_8x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1, z2, z3; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*4]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * 4-point IDCT kernel, + * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT]. + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + + tmp10 = (tmp0 + tmp2) << PASS1_BITS; + tmp12 = (tmp0 - tmp2) << PASS1_BITS; + + /* Odd part */ + /* Same rotation as in the even part of the 8x8 LL&M IDCT */ + + z2 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS-PASS1_BITS-1); + tmp0 = RIGHT_SHIFT(z1 + MULTIPLY(z2, FIX_0_765366865), /* c2-c6 */ + CONST_BITS-PASS1_BITS); + tmp2 = RIGHT_SHIFT(z1 - MULTIPLY(z3, FIX_1_847759065), /* c2+c6 */ + CONST_BITS-PASS1_BITS); + + /* Final output stage */ + + wsptr[8*0] = (int) (tmp10 + tmp0); + wsptr[8*3] = (int) (tmp10 - tmp0); + wsptr[8*1] = (int) (tmp12 + tmp2); + wsptr[8*2] = (int) (tmp12 - tmp2); + } + + /* Pass 2: process rows from work array, store into output array. + * Note that we must descale the results by a factor of 8 == 2**3, + * and also undo the PASS1_BITS scaling. + * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16). + */ + + wsptr = workspace; + for (ctr = 0; ctr < 4; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part: reverse the even part of the forward DCT. + * The rotator is c(-6). + */ + + /* Add range center and fudge factor for final descale and range-limit. */ + z2 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + z3 = (INT32) wsptr[4]; + + tmp0 = (z2 + z3) << CONST_BITS; + tmp1 = (z2 - z3) << CONST_BITS; + + z2 = (INT32) wsptr[2]; + z3 = (INT32) wsptr[6]; + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + tmp10 = tmp0 + tmp2; + tmp13 = tmp0 - tmp2; + tmp11 = tmp1 + tmp3; + tmp12 = tmp1 - tmp3; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = (INT32) wsptr[7]; + tmp1 = (INT32) wsptr[5]; + tmp2 = (INT32) wsptr[3]; + tmp3 = (INT32) wsptr[1]; + + z2 = tmp0 + tmp2; + z3 = tmp1 + tmp3; + + z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ + z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ + z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ + z2 += z1; + z3 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp0 += z1 + z2; + tmp3 += z1 + z3; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp1 += z1 + z3; + tmp2 += z1 + z2; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp13 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 6x3 output block. + * + * 3-point IDCT in pass 1 (columns), 6-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_6x3 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp10, tmp11, tmp12; + INT32 z1, z2, z3; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[6*3]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * 3-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/6). + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 6; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp0 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */ + tmp10 = tmp0 + tmp12; + tmp2 = tmp0 - tmp12 - tmp12; + + /* Odd part */ + + tmp12 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */ + + /* Final output stage */ + + wsptr[6*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[6*2] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); + wsptr[6*1] = (int) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 3 rows from work array, store into output array. + * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12). + */ + + wsptr = workspace; + for (ctr = 0; ctr < 3; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp0 <<= CONST_BITS; + tmp2 = (INT32) wsptr[4]; + tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */ + tmp1 = tmp0 + tmp10; + tmp11 = tmp0 - tmp10 - tmp10; + tmp10 = (INT32) wsptr[2]; + tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */ + tmp10 = tmp1 + tmp0; + tmp12 = tmp1 - tmp0; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ + tmp0 = tmp1 + ((z1 + z2) << CONST_BITS); + tmp2 = tmp1 + ((z3 - z2) << CONST_BITS); + tmp1 = (z1 - z2 - z3) << CONST_BITS; + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 6; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 4x2 output block. + * + * 2-point IDCT in pass 1 (columns), 4-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_4x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp2, tmp10, tmp12; + INT32 z1, z2, z3; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + INT32 * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + INT32 workspace[4*2]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 4; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp10 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + + /* Odd part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + + /* Final output stage */ + + wsptr[4*0] = tmp10 + tmp0; + wsptr[4*1] = tmp10 - tmp0; + } + + /* Pass 2: process 2 rows from work array, store into output array. + * 4-point IDCT kernel, + * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT]. + */ + + wsptr = workspace; + for (ctr = 0; ctr < 2; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 = wsptr[0] + ((((INT32) RANGE_CENTER) << 3) + (ONE << 2)); + tmp2 = wsptr[2]; + + tmp10 = (tmp0 + tmp2) << CONST_BITS; + tmp12 = (tmp0 - tmp2) << CONST_BITS; + + /* Odd part */ + /* Same rotation as in the even part of the 8x8 LL&M IDCT */ + + z2 = wsptr[1]; + z3 = wsptr[3]; + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + tmp0 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp2 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, + CONST_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, + CONST_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, + CONST_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, + CONST_BITS+3) + & RANGE_MASK]; + + wsptr += 4; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 2x1 output block. + * + * 1-point IDCT in pass 1 (columns), 2-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_2x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + DCTELEM tmp0, tmp1; + ISLOW_MULT_TYPE * quantptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + ISHIFT_TEMPS + + /* Pass 1: empty. */ + + /* Pass 2: process 1 row from input, store into output array. */ + + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + outptr = output_buf[0] + output_col; + + /* Even part */ + + tmp0 = DEQUANTIZE(coef_block[0], quantptr[0]); + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2); + + /* Odd part */ + + tmp1 = DEQUANTIZE(coef_block[1], quantptr[1]); + + /* Final output stage */ + + outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp1, 3) & RANGE_MASK]; + outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp1, 3) & RANGE_MASK]; +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing an 8x16 output block. + * + * 16-point IDCT in pass 1 (columns), 8-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_8x16 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[8*16]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * 16-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/32). + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp0 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); + + z1 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */ + tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */ + + tmp10 = tmp0 + tmp1; + tmp11 = tmp0 - tmp1; + tmp12 = tmp0 + tmp2; + tmp13 = tmp0 - tmp2; + + z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + z3 = z1 - z2; + z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */ + z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */ + + tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */ + tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */ + tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */ + tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */ + + tmp20 = tmp10 + tmp0; + tmp27 = tmp10 - tmp0; + tmp21 = tmp12 + tmp1; + tmp26 = tmp12 - tmp1; + tmp22 = tmp13 + tmp2; + tmp25 = tmp13 - tmp2; + tmp23 = tmp11 + tmp3; + tmp24 = tmp11 - tmp3; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + tmp11 = z1 + z3; + + tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */ + tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */ + tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */ + tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */ + tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */ + tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */ + tmp0 = tmp1 + tmp2 + tmp3 - + MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */ + tmp13 = tmp10 + tmp11 + tmp12 - + MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */ + z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */ + tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */ + tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */ + z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */ + tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */ + tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */ + z2 += z4; + z1 = MULTIPLY(z2, - FIX(0.666655658)); /* -c11 */ + tmp1 += z1; + tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */ + z2 = MULTIPLY(z2, - FIX(1.247225013)); /* -c5 */ + tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */ + tmp12 += z2; + z2 = MULTIPLY(z3 + z4, - FIX(1.353318001)); /* -c3 */ + tmp2 += z2; + tmp3 += z2; + z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */ + tmp10 += z2; + tmp11 += z2; + + /* Final output stage */ + + wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[8*15] = (int) RIGHT_SHIFT(tmp20 - tmp0, CONST_BITS-PASS1_BITS); + wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp1, CONST_BITS-PASS1_BITS); + wsptr[8*14] = (int) RIGHT_SHIFT(tmp21 - tmp1, CONST_BITS-PASS1_BITS); + wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[8*13] = (int) RIGHT_SHIFT(tmp22 - tmp2, CONST_BITS-PASS1_BITS); + wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp3, CONST_BITS-PASS1_BITS); + wsptr[8*12] = (int) RIGHT_SHIFT(tmp23 - tmp3, CONST_BITS-PASS1_BITS); + wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*11] = (int) RIGHT_SHIFT(tmp24 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*10] = (int) RIGHT_SHIFT(tmp25 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[8*6] = (int) RIGHT_SHIFT(tmp26 + tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*9] = (int) RIGHT_SHIFT(tmp26 - tmp12, CONST_BITS-PASS1_BITS); + wsptr[8*7] = (int) RIGHT_SHIFT(tmp27 + tmp13, CONST_BITS-PASS1_BITS); + wsptr[8*8] = (int) RIGHT_SHIFT(tmp27 - tmp13, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process rows from work array, store into output array. + * Note that we must descale the results by a factor of 8 == 2**3, + * and also undo the PASS1_BITS scaling. + * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16). + */ + + wsptr = workspace; + for (ctr = 0; ctr < 16; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part: reverse the even part of the forward DCT. + * The rotator is c(-6). + */ + + /* Add range center and fudge factor for final descale and range-limit. */ + z2 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + z3 = (INT32) wsptr[4]; + + tmp0 = (z2 + z3) << CONST_BITS; + tmp1 = (z2 - z3) << CONST_BITS; + + z2 = (INT32) wsptr[2]; + z3 = (INT32) wsptr[6]; + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + tmp10 = tmp0 + tmp2; + tmp13 = tmp0 - tmp2; + tmp11 = tmp1 + tmp3; + tmp12 = tmp1 - tmp3; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = (INT32) wsptr[7]; + tmp1 = (INT32) wsptr[5]; + tmp2 = (INT32) wsptr[3]; + tmp3 = (INT32) wsptr[1]; + + z2 = tmp0 + tmp2; + z3 = tmp1 + tmp3; + + z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ + z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ + z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ + z2 += z1; + z3 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp0 += z1 + z2; + tmp3 += z1 + z3; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp1 += z1 + z3; + tmp2 += z1 + z2; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp13 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 7x14 output block. + * + * 14-point IDCT in pass 1 (columns), 7-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_7x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[7*14]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * 14-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/28). + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 7; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z1 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + z1 += ONE << (CONST_BITS-PASS1_BITS-1); + z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */ + z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */ + z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */ + + tmp10 = z1 + z2; + tmp11 = z1 + z3; + tmp12 = z1 - z4; + + tmp23 = RIGHT_SHIFT(z1 - ((z2 + z3 - z4) << 1), /* c0 = (c4+c12-c8)*2 */ + CONST_BITS-PASS1_BITS); + + z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */ + + tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */ + tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */ + tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */ + MULTIPLY(z2, FIX(1.378756276)); /* c2 */ + + tmp20 = tmp10 + tmp13; + tmp26 = tmp10 - tmp13; + tmp21 = tmp11 + tmp14; + tmp25 = tmp11 - tmp14; + tmp22 = tmp12 + tmp15; + tmp24 = tmp12 - tmp15; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + tmp13 = z4 << CONST_BITS; + + tmp14 = z1 + z3; + tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */ + tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */ + tmp10 = tmp11 + tmp12 + tmp13 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */ + tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */ + tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */ + z1 -= z2; + tmp15 = MULTIPLY(z1, FIX(0.467085129)) - tmp13; /* c11 */ + tmp16 += tmp15; + z1 += z4; + z4 = MULTIPLY(z2 + z3, - FIX(0.158341681)) - tmp13; /* -c13 */ + tmp11 += z4 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */ + tmp12 += z4 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */ + z4 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */ + tmp14 += z4 + tmp13 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */ + tmp15 += z4 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */ + + tmp13 = (z1 - z3) << PASS1_BITS; + + /* Final output stage */ + + wsptr[7*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[7*13] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[7*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[7*12] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[7*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); + wsptr[7*11] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); + wsptr[7*3] = (int) (tmp23 + tmp13); + wsptr[7*10] = (int) (tmp23 - tmp13); + wsptr[7*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); + wsptr[7*9] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); + wsptr[7*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); + wsptr[7*8] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); + wsptr[7*6] = (int) RIGHT_SHIFT(tmp26 + tmp16, CONST_BITS-PASS1_BITS); + wsptr[7*7] = (int) RIGHT_SHIFT(tmp26 - tmp16, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 14 rows from work array, store into output array. + * 7-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/14). + */ + + wsptr = workspace; + for (ctr = 0; ctr < 14; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp23 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp23 <<= CONST_BITS; + + z1 = (INT32) wsptr[2]; + z2 = (INT32) wsptr[4]; + z3 = (INT32) wsptr[6]; + + tmp20 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */ + tmp22 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */ + tmp21 = tmp20 + tmp22 + tmp23 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */ + tmp10 = z1 + z3; + z2 -= tmp10; + tmp10 = MULTIPLY(tmp10, FIX(1.274162392)) + tmp23; /* c2 */ + tmp20 += tmp10 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */ + tmp22 += tmp10 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */ + tmp23 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */ + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + + tmp11 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */ + tmp12 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */ + tmp10 = tmp11 - tmp12; + tmp11 += tmp12; + tmp12 = MULTIPLY(z2 + z3, - FIX(1.378756276)); /* -c1 */ + tmp11 += tmp12; + z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */ + tmp10 += z2; + tmp12 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 7; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 6x12 output block. + * + * 12-point IDCT in pass 1 (columns), 6-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_6x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[6*12]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * 12-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/24). + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 6; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z3 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + z3 += ONE << (CONST_BITS-PASS1_BITS-1); + + z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */ + + tmp10 = z3 + z4; + tmp11 = z3 - z4; + + z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */ + z1 <<= CONST_BITS; + z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + z2 <<= CONST_BITS; + + tmp12 = z1 - z2; + + tmp21 = z3 + tmp12; + tmp24 = z3 - tmp12; + + tmp12 = z4 + z2; + + tmp20 = tmp10 + tmp12; + tmp25 = tmp10 - tmp12; + + tmp12 = z4 - z1 - z2; + + tmp22 = tmp11 + tmp12; + tmp23 = tmp11 - tmp12; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */ + tmp14 = MULTIPLY(z2, - FIX_0_541196100); /* -c9 */ + + tmp10 = z1 + z3; + tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */ + tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */ + tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */ + tmp13 = MULTIPLY(z3 + z4, - FIX(1.045510580)); /* -(c7+c11) */ + tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */ + tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */ + tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */ + MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */ + + z1 -= z4; + z2 -= z3; + z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */ + tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */ + tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */ + + /* Final output stage */ + + wsptr[6*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[6*11] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[6*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[6*10] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[6*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); + wsptr[6*9] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); + wsptr[6*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); + wsptr[6*8] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); + wsptr[6*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); + wsptr[6*7] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); + wsptr[6*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); + wsptr[6*6] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 12 rows from work array, store into output array. + * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12). + */ + + wsptr = workspace; + for (ctr = 0; ctr < 12; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp10 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp10 <<= CONST_BITS; + tmp12 = (INT32) wsptr[4]; + tmp20 = MULTIPLY(tmp12, FIX(0.707106781)); /* c4 */ + tmp11 = tmp10 + tmp20; + tmp21 = tmp10 - tmp20 - tmp20; + tmp20 = (INT32) wsptr[2]; + tmp10 = MULTIPLY(tmp20, FIX(1.224744871)); /* c2 */ + tmp20 = tmp11 + tmp10; + tmp22 = tmp11 - tmp10; + + /* Odd part */ + + z1 = (INT32) wsptr[1]; + z2 = (INT32) wsptr[3]; + z3 = (INT32) wsptr[5]; + tmp11 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ + tmp10 = tmp11 + ((z1 + z2) << CONST_BITS); + tmp12 = tmp11 + ((z3 - z2) << CONST_BITS); + tmp11 = (z1 - z2 - z3) << CONST_BITS; + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 6; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 5x10 output block. + * + * 10-point IDCT in pass 1 (columns), 5-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_5x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp10, tmp11, tmp12, tmp13, tmp14; + INT32 tmp20, tmp21, tmp22, tmp23, tmp24; + INT32 z1, z2, z3, z4, z5; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[5*10]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * 10-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/20). + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 5; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z3 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + z3 += ONE << (CONST_BITS-PASS1_BITS-1); + z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */ + z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */ + tmp10 = z3 + z1; + tmp11 = z3 - z2; + + tmp22 = RIGHT_SHIFT(z3 - ((z1 - z2) << 1), /* c0 = (c4-c8)*2 */ + CONST_BITS-PASS1_BITS); + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */ + tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */ + tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */ + + tmp20 = tmp10 + tmp12; + tmp24 = tmp10 - tmp12; + tmp21 = tmp11 + tmp13; + tmp23 = tmp11 - tmp13; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + tmp11 = z2 + z4; + tmp13 = z2 - z4; + + tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */ + z5 = z3 << CONST_BITS; + + z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */ + z4 = z5 + tmp12; + + tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */ + tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */ + + z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */ + z4 = z5 - tmp12 - (tmp13 << (CONST_BITS - 1)); + + tmp12 = (z1 - tmp13 - z3) << PASS1_BITS; + + tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */ + tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */ + + /* Final output stage */ + + wsptr[5*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); + wsptr[5*9] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); + wsptr[5*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); + wsptr[5*8] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); + wsptr[5*2] = (int) (tmp22 + tmp12); + wsptr[5*7] = (int) (tmp22 - tmp12); + wsptr[5*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); + wsptr[5*6] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); + wsptr[5*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); + wsptr[5*5] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 10 rows from work array, store into output array. + * 5-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/10). + */ + + wsptr = workspace; + for (ctr = 0; ctr < 10; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp12 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp12 <<= CONST_BITS; + tmp13 = (INT32) wsptr[2]; + tmp14 = (INT32) wsptr[4]; + z1 = MULTIPLY(tmp13 + tmp14, FIX(0.790569415)); /* (c2+c4)/2 */ + z2 = MULTIPLY(tmp13 - tmp14, FIX(0.353553391)); /* (c2-c4)/2 */ + z3 = tmp12 + z2; + tmp10 = z3 + z1; + tmp11 = z3 - z1; + tmp12 -= z2 << 2; + + /* Odd part */ + + z2 = (INT32) wsptr[1]; + z3 = (INT32) wsptr[3]; + + z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */ + tmp13 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */ + tmp14 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp13, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp14, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 5; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 4x8 output block. + * + * 8-point IDCT in pass 1 (columns), 4-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_4x8 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1, z2, z3; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[4*8]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * Note results are scaled up by sqrt(8) compared to a true IDCT; + * furthermore, we scale the results by 2**PASS1_BITS. + * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16). + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 4; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && + inptr[DCTSIZE*7] == 0) { + /* AC terms all zero */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[4*0] = dcval; + wsptr[4*1] = dcval; + wsptr[4*2] = dcval; + wsptr[4*3] = dcval; + wsptr[4*4] = dcval; + wsptr[4*5] = dcval; + wsptr[4*6] = dcval; + wsptr[4*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part: reverse the even part of the forward DCT. + * The rotator is c(-6). + */ + + z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + z2 <<= CONST_BITS; + z3 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + z2 += ONE << (CONST_BITS-PASS1_BITS-1); + + tmp0 = z2 + z3; + tmp1 = z2 - z3; + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + tmp10 = tmp0 + tmp2; + tmp13 = tmp0 - tmp2; + tmp11 = tmp1 + tmp3; + tmp12 = tmp1 - tmp3; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + + z2 = tmp0 + tmp2; + z3 = tmp1 + tmp3; + + z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ + z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ + z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ + z2 += z1; + z3 += z1; + + z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ + tmp0 += z1 + z2; + tmp3 += z1 + z3; + + z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ + tmp1 += z1 + z3; + tmp2 += z1 + z2; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + wsptr[4*0] = (int) RIGHT_SHIFT(tmp10 + tmp3, CONST_BITS-PASS1_BITS); + wsptr[4*7] = (int) RIGHT_SHIFT(tmp10 - tmp3, CONST_BITS-PASS1_BITS); + wsptr[4*1] = (int) RIGHT_SHIFT(tmp11 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[4*6] = (int) RIGHT_SHIFT(tmp11 - tmp2, CONST_BITS-PASS1_BITS); + wsptr[4*2] = (int) RIGHT_SHIFT(tmp12 + tmp1, CONST_BITS-PASS1_BITS); + wsptr[4*5] = (int) RIGHT_SHIFT(tmp12 - tmp1, CONST_BITS-PASS1_BITS); + wsptr[4*3] = (int) RIGHT_SHIFT(tmp13 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[4*4] = (int) RIGHT_SHIFT(tmp13 - tmp0, CONST_BITS-PASS1_BITS); + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process 8 rows from work array, store into output array. + * 4-point IDCT kernel, + * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT]. + */ + + wsptr = workspace; + for (ctr = 0; ctr < 8; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp2 = (INT32) wsptr[2]; + + tmp10 = (tmp0 + tmp2) << CONST_BITS; + tmp12 = (tmp0 - tmp2) << CONST_BITS; + + /* Odd part */ + /* Same rotation as in the even part of the 8x8 LL&M IDCT */ + + z2 = (INT32) wsptr[1]; + z3 = (INT32) wsptr[3]; + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + tmp0 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp2 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 4; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 3x6 output block. + * + * 6-point IDCT in pass 1 (columns), 3-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_3x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp10, tmp11, tmp12; + INT32 z1, z2, z3; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[3*6]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12). + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 3; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp0 <<= CONST_BITS; + /* Add fudge factor here for final descale. */ + tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */ + tmp1 = tmp0 + tmp10; + tmp11 = RIGHT_SHIFT(tmp0 - tmp10 - tmp10, CONST_BITS-PASS1_BITS); + tmp10 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */ + tmp10 = tmp1 + tmp0; + tmp12 = tmp1 - tmp0; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ + tmp0 = tmp1 + ((z1 + z2) << CONST_BITS); + tmp2 = tmp1 + ((z3 - z2) << CONST_BITS); + tmp1 = (z1 - z2 - z3) << PASS1_BITS; + + /* Final output stage */ + + wsptr[3*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[3*5] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); + wsptr[3*1] = (int) (tmp11 + tmp1); + wsptr[3*4] = (int) (tmp11 - tmp1); + wsptr[3*2] = (int) RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[3*3] = (int) RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS-PASS1_BITS); + } + + /* Pass 2: process 6 rows from work array, store into output array. + * 3-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/6). + */ + + wsptr = workspace; + for (ctr = 0; ctr < 6; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 = (INT32) wsptr[0] + + ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + + (ONE << (PASS1_BITS+2))); + tmp0 <<= CONST_BITS; + tmp2 = (INT32) wsptr[2]; + tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */ + tmp10 = tmp0 + tmp12; + tmp2 = tmp0 - tmp12 - tmp12; + + /* Odd part */ + + tmp12 = (INT32) wsptr[1]; + tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += 3; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 2x4 output block. + * + * 4-point IDCT in pass 1 (columns), 2-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_2x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp2, tmp10, tmp12; + INT32 z1, z2, z3; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + INT32 * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + INT32 workspace[2*4]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. + * 4-point IDCT kernel, + * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT]. + */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = 0; ctr < 2; ctr++, inptr++, quantptr++, wsptr++) { + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + + tmp10 = (tmp0 + tmp2) << CONST_BITS; + tmp12 = (tmp0 - tmp2) << CONST_BITS; + + /* Odd part */ + /* Same rotation as in the even part of the 8x8 LL&M IDCT */ + + z2 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ + tmp0 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ + tmp2 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ + + /* Final output stage */ + + wsptr[2*0] = tmp10 + tmp0; + wsptr[2*3] = tmp10 - tmp0; + wsptr[2*1] = tmp12 + tmp2; + wsptr[2*2] = tmp12 - tmp2; + } + + /* Pass 2: process 4 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 4; ctr++) { + outptr = output_buf[ctr] + output_col; + + /* Even part */ + + /* Add range center and fudge factor for final descale and range-limit. */ + tmp10 = wsptr[0] + + ((((INT32) RANGE_CENTER) << (CONST_BITS+3)) + + (ONE << (CONST_BITS+2))); + + /* Odd part */ + + tmp0 = wsptr[1]; + + /* Final output stage */ + + outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS+3) + & RANGE_MASK]; + + wsptr += 2; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a 1x2 output block. + * + * 2-point IDCT in pass 1 (columns), 1-point in pass 2 (rows). + */ + +GLOBAL(void) +jpeg_idct_1x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + DCTELEM tmp0, tmp1; + ISLOW_MULT_TYPE * quantptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + ISHIFT_TEMPS + + /* Process 1 column from input, store into output array. */ + + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + + /* Even part */ + + tmp0 = DEQUANTIZE(coef_block[DCTSIZE*0], quantptr[DCTSIZE*0]); + /* Add range center and fudge factor for final descale and range-limit. */ + tmp0 += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2); + + /* Odd part */ + + tmp1 = DEQUANTIZE(coef_block[DCTSIZE*1], quantptr[DCTSIZE*1]); + + /* Final output stage */ + + output_buf[0][output_col] = + range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp1, 3) & RANGE_MASK]; + output_buf[1][output_col] = + range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp1, 3) & RANGE_MASK]; +} + +#endif /* IDCT_SCALING_SUPPORTED */ +#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/jinclude.h b/thirdparty/jpeg-9e/jinclude.h new file mode 100644 index 0000000..20ed4ef --- /dev/null +++ b/thirdparty/jpeg-9e/jinclude.h @@ -0,0 +1,97 @@ +/* + * jinclude.h + * + * Copyright (C) 1991-1994, Thomas G. Lane. + * Modified 2017 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file exists to provide a single place to fix any problems with + * including the wrong system include files. (Common problems are taken + * care of by the standard jconfig symbols, but on really weird systems + * you may have to edit this file.) + * + * NOTE: this file is NOT intended to be included by applications using the + * JPEG library. Most applications need only include jpeglib.h. + */ + + +/* Include auto-config file to find out which system include files we need. */ + +#include "jconfig.h" /* auto configuration options */ +#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ + +/* + * We need the NULL macro and size_t typedef. + * On an ANSI-conforming system it is sufficient to include . + * Otherwise, we get them from or ; we may have to + * pull in as well. + * Note that the core JPEG library does not require ; + * only the default error handler and data source/destination modules do. + * But we must pull it in because of the references to FILE in jpeglib.h. + * You can remove those references if you want to compile without . + */ + +#ifdef HAVE_STDDEF_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef NEED_SYS_TYPES_H +#include +#endif + +#include + +/* + * We need memory copying and zeroing functions, plus strncpy(). + * ANSI and System V implementations declare these in . + * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). + * Some systems may declare memset and memcpy in . + * + * NOTE: we assume the size parameters to these functions are of type size_t. + * Change the casts in these macros if not! + */ + +#ifdef NEED_BSD_STRINGS + +#include +#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) +#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) + +#else /* not BSD, assume ANSI/SysV string lib */ + +#include +#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) +#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) + +#endif + +/* + * In ANSI C, and indeed any rational implementation, size_t is also the + * type returned by sizeof(). However, it seems there are some irrational + * implementations out there, in which sizeof() returns an int even though + * size_t is defined as long or unsigned long. To ensure consistent results + * we always use this SIZEOF() macro in place of using sizeof() directly. + */ + +#define SIZEOF(object) ((size_t) sizeof(object)) + +/* + * The modules that use fread() and fwrite() always invoke them through + * these macros. On some systems you may need to twiddle the argument casts. + * CAUTION: argument order is different from underlying functions! + * + * Furthermore, macros are provided for fflush() and ferror() in order + * to facilitate adaption by applications using an own FILE class. + */ + +#define JFREAD(file,buf,sizeofbuf) \ + ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) +#define JFWRITE(file,buf,sizeofbuf) \ + ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) +#define JFFLUSH(file) fflush(file) +#define JFERROR(file) ferror(file) diff --git a/thirdparty/jpeg-9e/jmemansi.c b/thirdparty/jpeg-9e/jmemansi.c new file mode 100644 index 0000000..2d93e49 --- /dev/null +++ b/thirdparty/jpeg-9e/jmemansi.c @@ -0,0 +1,167 @@ +/* + * jmemansi.c + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a simple generic implementation of the system- + * dependent portion of the JPEG memory manager. This implementation + * assumes that you have the ANSI-standard library routine tmpfile(). + * Also, the problem of determining the amount of memory available + * is shoved onto the user. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + +#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ +#define SEEK_SET 0 /* if not, assume 0 is correct */ +#endif + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFREAD(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFWRITE(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + fclose(info->temp_file); + /* Since this implementation uses tmpfile() to create the file, + * no explicit file deletion is needed. + */ +} + + +/* + * Initial opening of a backing-store object. + * + * This version uses tmpfile(), which constructs a suitable file name + * behind the scenes. We don't have to use info->temp_name[] at all; + * indeed, we can't even find out the actual name of the temp file. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + if ((info->temp_file = tmpfile()) == NULL) + ERREXITS(cinfo, JERR_TFILE_CREATE, ""); + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/thirdparty/jpeg-9e/jmemdos.c b/thirdparty/jpeg-9e/jmemdos.c new file mode 100644 index 0000000..60b45c6 --- /dev/null +++ b/thirdparty/jpeg-9e/jmemdos.c @@ -0,0 +1,638 @@ +/* + * jmemdos.c + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides an MS-DOS-compatible implementation of the system- + * dependent portion of the JPEG memory manager. Temporary data can be + * stored in extended or expanded memory as well as in regular DOS files. + * + * If you use this file, you must be sure that NEED_FAR_POINTERS is defined + * if you compile in a small-data memory model; it should NOT be defined if + * you use a large-data memory model. This file is not recommended if you + * are using a flat-memory-space 386 environment such as DJGCC or Watcom C. + * Also, this code will NOT work if struct fields are aligned on greater than + * 2-byte boundaries. + * + * Based on code contributed by Ge' Weijers. + */ + +/* + * If you have both extended and expanded memory, you may want to change the + * order in which they are tried in jopen_backing_store. On a 286 machine + * expanded memory is usually faster, since extended memory access involves + * an expensive protected-mode-and-back switch. On 386 and better, extended + * memory is usually faster. As distributed, the code tries extended memory + * first (what? not everyone has a 386? :-). + * + * You can disable use of extended/expanded memory entirely by altering these + * definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0). + */ + +#ifndef XMS_SUPPORTED +#define XMS_SUPPORTED 1 +#endif +#ifndef EMS_SUPPORTED +#define EMS_SUPPORTED 1 +#endif + + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare these */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +extern char * getenv JPP((const char * name)); +#endif + +#ifdef NEED_FAR_POINTERS + +#ifdef __TURBOC__ +/* These definitions work for Borland C (Turbo C) */ +#include /* need farmalloc(), farfree() */ +#define far_malloc(x) farmalloc(x) +#define far_free(x) farfree(x) +#else +/* These definitions work for Microsoft C and compatible compilers */ +#include /* need _fmalloc(), _ffree() */ +#define far_malloc(x) _fmalloc(x) +#define far_free(x) _ffree(x) +#endif + +#else /* not NEED_FAR_POINTERS */ + +#define far_malloc(x) malloc(x) +#define far_free(x) free(x) + +#endif /* NEED_FAR_POINTERS */ + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#else +#define READ_BINARY "rb" +#endif + +#ifndef USE_MSDOS_MEMMGR /* make sure user got configuration right */ + You forgot to define USE_MSDOS_MEMMGR in jconfig.h. /* deliberate syntax error */ +#endif + +#if MAX_ALLOC_CHUNK >= 65535L /* make sure jconfig.h got this right */ + MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */ +#endif + + +/* + * Declarations for assembly-language support routines (see jmemdosa.asm). + * + * The functions are declared "far" as are all their pointer arguments; + * this ensures the assembly source code will work regardless of the + * compiler memory model. We assume "short" is 16 bits, "long" is 32. + */ + +typedef void far * XMSDRIVER; /* actually a pointer to code */ +typedef struct { /* registers for calling XMS driver */ + unsigned short ax, dx, bx; + void far * ds_si; + } XMScontext; +typedef struct { /* registers for calling EMS driver */ + unsigned short ax, dx, bx; + void far * ds_si; + } EMScontext; + +extern short far jdos_open JPP((short far * handle, char far * filename)); +extern short far jdos_close JPP((short handle)); +extern short far jdos_seek JPP((short handle, long offset)); +extern short far jdos_read JPP((short handle, void far * buffer, + unsigned short count)); +extern short far jdos_write JPP((short handle, void far * buffer, + unsigned short count)); +extern void far jxms_getdriver JPP((XMSDRIVER far *)); +extern void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *)); +extern short far jems_available JPP((void)); +extern void far jems_calldriver JPP((EMScontext far *)); + + +/* + * Selection of a file name for a temporary file. + * This is highly system-dependent, and you may want to customize it. + */ + +static int next_file_num; /* to distinguish among several temp files */ + +LOCAL(void) +select_file_name (char * fname) +{ + const char * env; + char * ptr; + FILE * tfile; + + /* Keep generating file names till we find one that's not in use */ + for (;;) { + /* Get temp directory name from environment TMP or TEMP variable; + * if none, use "." + */ + if ((env = (const char *) getenv("TMP")) == NULL) + if ((env = (const char *) getenv("TEMP")) == NULL) + env = "."; + if (*env == '\0') /* null string means "." */ + env = "."; + ptr = fname; /* copy name to fname */ + while (*env != '\0') + *ptr++ = *env++; + if (ptr[-1] != '\\' && ptr[-1] != '/') + *ptr++ = '\\'; /* append backslash if not in env variable */ + /* Append a suitable file name */ + next_file_num++; /* advance counter */ + sprintf(ptr, "JPG%03d.TMP", next_file_num); + /* Probe to see if file name is already in use */ + if ((tfile = fopen(fname, READ_BINARY)) == NULL) + break; + fclose(tfile); /* oops, it's there; close tfile & try again */ + } +} + + +/* + * Near-memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are allocated in far memory, if possible + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) far_malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + far_free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 300000L /* for total usage about 450K */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + +/* + * For MS-DOS we support three types of backing storage: + * 1. Conventional DOS files. We access these by direct DOS calls rather + * than via the stdio package. This provides a bit better performance, + * but the real reason is that the buffers to be read or written are FAR. + * The stdio library for small-data memory models can't cope with that. + * 2. Extended memory, accessed per the XMS V2.0 specification. + * 3. Expanded memory, accessed per the LIM/EMS 4.0 specification. + * You'll need copies of those specs to make sense of the related code. + * The specs are available by Internet FTP from the SIMTEL archives + * (oak.oakland.edu and its various mirror sites). See files + * pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip. + */ + + +/* + * Access methods for a DOS file. + */ + + +METHODDEF(void) +read_file_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (jdos_seek(info->handle.file_handle, file_offset)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ + if (byte_count > 65535L) /* safety check */ + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + if (jdos_read(info->handle.file_handle, buffer_address, + (unsigned short) byte_count)) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_file_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (jdos_seek(info->handle.file_handle, file_offset)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ + if (byte_count > 65535L) /* safety check */ + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + if (jdos_write(info->handle.file_handle, buffer_address, + (unsigned short) byte_count)) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_file_store (j_common_ptr cinfo, backing_store_ptr info) +{ + jdos_close(info->handle.file_handle); /* close the file */ + remove(info->temp_name); /* delete the file */ +/* If your system doesn't have remove(), try unlink() instead. + * remove() is the ANSI-standard name for this function, but + * unlink() was more common in pre-ANSI systems. + */ + TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); +} + + +LOCAL(boolean) +open_file_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + short handle; + + select_file_name(info->temp_name); + if (jdos_open((short far *) & handle, (char far *) info->temp_name)) { + /* might as well exit since jpeg_open_backing_store will fail anyway */ + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + return FALSE; + } + info->handle.file_handle = handle; + info->read_backing_store = read_file_store; + info->write_backing_store = write_file_store; + info->close_backing_store = close_file_store; + TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); + return TRUE; /* succeeded */ +} + + +/* + * Access methods for extended memory. + */ + +#if XMS_SUPPORTED + +static XMSDRIVER xms_driver; /* saved address of XMS driver */ + +typedef union { /* either long offset or real-mode pointer */ + long offset; + void far * ptr; + } XMSPTR; + +typedef struct { /* XMS move specification structure */ + long length; + XMSH src_handle; + XMSPTR src; + XMSH dst_handle; + XMSPTR dst; + } XMSspec; + +#define ODD(X) (((X) & 1L) != 0) + + +METHODDEF(void) +read_xms_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + XMScontext ctx; + XMSspec spec; + char endbuffer[2]; + + /* The XMS driver can't cope with an odd length, so handle the last byte + * specially if byte_count is odd. We don't expect this to be common. + */ + + spec.length = byte_count & (~ 1L); + spec.src_handle = info->handle.xms_handle; + spec.src.offset = file_offset; + spec.dst_handle = 0; + spec.dst.ptr = buffer_address; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x0b00; /* EMB move */ + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + ERREXIT(cinfo, JERR_XMS_READ); + + if (ODD(byte_count)) { + read_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0]; + } +} + + +METHODDEF(void) +write_xms_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + XMScontext ctx; + XMSspec spec; + char endbuffer[2]; + + /* The XMS driver can't cope with an odd length, so handle the last byte + * specially if byte_count is odd. We don't expect this to be common. + */ + + spec.length = byte_count & (~ 1L); + spec.src_handle = 0; + spec.src.ptr = buffer_address; + spec.dst_handle = info->handle.xms_handle; + spec.dst.offset = file_offset; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x0b00; /* EMB move */ + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + ERREXIT(cinfo, JERR_XMS_WRITE); + + if (ODD(byte_count)) { + read_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L]; + write_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + } +} + + +METHODDEF(void) +close_xms_store (j_common_ptr cinfo, backing_store_ptr info) +{ + XMScontext ctx; + + ctx.dx = info->handle.xms_handle; + ctx.ax = 0x0a00; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle); + /* we ignore any error return from the driver */ +} + + +LOCAL(boolean) +open_xms_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + XMScontext ctx; + + /* Get address of XMS driver */ + jxms_getdriver((XMSDRIVER far *) & xms_driver); + if (xms_driver == NULL) + return FALSE; /* no driver to be had */ + + /* Get version number, must be >= 2.00 */ + ctx.ax = 0x0000; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax < (unsigned short) 0x0200) + return FALSE; + + /* Try to get space (expressed in kilobytes) */ + ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10); + ctx.ax = 0x0900; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + return FALSE; + + /* Succeeded, save the handle and away we go */ + info->handle.xms_handle = ctx.dx; + info->read_backing_store = read_xms_store; + info->write_backing_store = write_xms_store; + info->close_backing_store = close_xms_store; + TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx); + return TRUE; /* succeeded */ +} + +#endif /* XMS_SUPPORTED */ + + +/* + * Access methods for expanded memory. + */ + +#if EMS_SUPPORTED + +/* The EMS move specification structure requires word and long fields aligned + * at odd byte boundaries. Some compilers will align struct fields at even + * byte boundaries. While it's usually possible to force byte alignment, + * that causes an overall performance penalty and may pose problems in merging + * JPEG into a larger application. Instead we accept some rather dirty code + * here. Note this code would fail if the hardware did not allow odd-byte + * word & long accesses, but all 80x86 CPUs do. + */ + +typedef void far * EMSPTR; + +typedef union { /* EMS move specification structure */ + long length; /* It's easy to access first 4 bytes */ + char bytes[18]; /* Misaligned fields in here! */ + } EMSspec; + +/* Macros for accessing misaligned fields */ +#define FIELD_AT(spec,offset,type) (*((type *) &(spec.bytes[offset]))) +#define SRC_TYPE(spec) FIELD_AT(spec,4,char) +#define SRC_HANDLE(spec) FIELD_AT(spec,5,EMSH) +#define SRC_OFFSET(spec) FIELD_AT(spec,7,unsigned short) +#define SRC_PAGE(spec) FIELD_AT(spec,9,unsigned short) +#define SRC_PTR(spec) FIELD_AT(spec,7,EMSPTR) +#define DST_TYPE(spec) FIELD_AT(spec,11,char) +#define DST_HANDLE(spec) FIELD_AT(spec,12,EMSH) +#define DST_OFFSET(spec) FIELD_AT(spec,14,unsigned short) +#define DST_PAGE(spec) FIELD_AT(spec,16,unsigned short) +#define DST_PTR(spec) FIELD_AT(spec,14,EMSPTR) + +#define EMSPAGESIZE 16384L /* gospel, see the EMS specs */ + +#define HIBYTE(W) (((W) >> 8) & 0xFF) +#define LOBYTE(W) ((W) & 0xFF) + + +METHODDEF(void) +read_ems_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + EMScontext ctx; + EMSspec spec; + + spec.length = byte_count; + SRC_TYPE(spec) = 1; + SRC_HANDLE(spec) = info->handle.ems_handle; + SRC_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); + SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); + DST_TYPE(spec) = 0; + DST_HANDLE(spec) = 0; + DST_PTR(spec) = buffer_address; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x5700; /* move memory region */ + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + ERREXIT(cinfo, JERR_EMS_READ); +} + + +METHODDEF(void) +write_ems_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + EMScontext ctx; + EMSspec spec; + + spec.length = byte_count; + SRC_TYPE(spec) = 0; + SRC_HANDLE(spec) = 0; + SRC_PTR(spec) = buffer_address; + DST_TYPE(spec) = 1; + DST_HANDLE(spec) = info->handle.ems_handle; + DST_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); + DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x5700; /* move memory region */ + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + ERREXIT(cinfo, JERR_EMS_WRITE); +} + + +METHODDEF(void) +close_ems_store (j_common_ptr cinfo, backing_store_ptr info) +{ + EMScontext ctx; + + ctx.ax = 0x4500; + ctx.dx = info->handle.ems_handle; + jems_calldriver((EMScontext far *) & ctx); + TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle); + /* we ignore any error return from the driver */ +} + + +LOCAL(boolean) +open_ems_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + EMScontext ctx; + + /* Is EMS driver there? */ + if (! jems_available()) + return FALSE; + + /* Get status, make sure EMS is OK */ + ctx.ax = 0x4000; + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + return FALSE; + + /* Get version, must be >= 4.0 */ + ctx.ax = 0x4600; + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40) + return FALSE; + + /* Try to allocate requested space */ + ctx.ax = 0x4300; + ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE); + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + return FALSE; + + /* Succeeded, save the handle and away we go */ + info->handle.ems_handle = ctx.dx; + info->read_backing_store = read_ems_store; + info->write_backing_store = write_ems_store; + info->close_backing_store = close_ems_store; + TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx); + return TRUE; /* succeeded */ +} + +#endif /* EMS_SUPPORTED */ + + +/* + * Initial opening of a backing-store object. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + /* Try extended memory, then expanded memory, then regular file. */ +#if XMS_SUPPORTED + if (open_xms_store(cinfo, info, total_bytes_needed)) + return; +#endif +#if EMS_SUPPORTED + if (open_ems_store(cinfo, info, total_bytes_needed)) + return; +#endif + if (open_file_store(cinfo, info, total_bytes_needed)) + return; + ERREXITS(cinfo, JERR_TFILE_CREATE, ""); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + next_file_num = 0; /* initialize temp file name generator */ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* Microsoft C, at least in v6.00A, will not successfully reclaim freed + * blocks of size > 32Kbytes unless we give it a kick in the rear, like so: + */ +#ifdef NEED_FHEAPMIN + _fheapmin(); +#endif +} diff --git a/thirdparty/jpeg-9e/jmemdosa.asm b/thirdparty/jpeg-9e/jmemdosa.asm new file mode 100644 index 0000000..ecd4372 --- /dev/null +++ b/thirdparty/jpeg-9e/jmemdosa.asm @@ -0,0 +1,379 @@ +; +; jmemdosa.asm +; +; Copyright (C) 1992, Thomas G. Lane. +; This file is part of the Independent JPEG Group's software. +; For conditions of distribution and use, see the accompanying README file. +; +; This file contains low-level interface routines to support the MS-DOS +; backing store manager (jmemdos.c). Routines are provided to access disk +; files through direct DOS calls, and to access XMS and EMS drivers. +; +; This file should assemble with Microsoft's MASM or any compatible +; assembler (including Borland's Turbo Assembler). If you haven't got +; a compatible assembler, better fall back to jmemansi.c or jmemname.c. +; +; To minimize dependence on the C compiler's register usage conventions, +; we save and restore all 8086 registers, even though most compilers only +; require SI,DI,DS to be preserved. Also, we use only 16-bit-wide return +; values, which everybody returns in AX. +; +; Based on code contributed by Ge' Weijers. +; + +JMEMDOSA_TXT segment byte public 'CODE' + + assume cs:JMEMDOSA_TXT + + public _jdos_open + public _jdos_close + public _jdos_seek + public _jdos_read + public _jdos_write + public _jxms_getdriver + public _jxms_calldriver + public _jems_available + public _jems_calldriver + +; +; short far jdos_open (short far * handle, char far * filename) +; +; Create and open a temporary file +; +_jdos_open proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov cx,0 ; normal file attributes + lds dx,dword ptr [bp+10] ; get filename pointer + mov ah,3ch ; create file + int 21h + jc open_err ; if failed, return error code + lds bx,dword ptr [bp+6] ; get handle pointer + mov word ptr [bx],ax ; save the handle + xor ax,ax ; return zero for OK +open_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_open endp + + +; +; short far jdos_close (short handle) +; +; Close the file handle +; +_jdos_close proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + mov ah,3eh ; close file + int 21h + jc close_err ; if failed, return error code + xor ax,ax ; return zero for OK +close_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_close endp + + +; +; short far jdos_seek (short handle, long offset) +; +; Set file position +; +_jdos_seek proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + mov dx,word ptr [bp+8] ; LS offset + mov cx,word ptr [bp+10] ; MS offset + mov ax,4200h ; absolute seek + int 21h + jc seek_err ; if failed, return error code + xor ax,ax ; return zero for OK +seek_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_seek endp + + +; +; short far jdos_read (short handle, void far * buffer, unsigned short count) +; +; Read from file +; +_jdos_read proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + lds dx,dword ptr [bp+8] ; buffer address + mov cx,word ptr [bp+12] ; number of bytes + mov ah,3fh ; read file + int 21h + jc read_err ; if failed, return error code + cmp ax,word ptr [bp+12] ; make sure all bytes were read + je read_ok + mov ax,1 ; else return 1 for not OK + jmp short read_err +read_ok: xor ax,ax ; return zero for OK +read_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_read endp + + +; +; short far jdos_write (short handle, void far * buffer, unsigned short count) +; +; Write to file +; +_jdos_write proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + lds dx,dword ptr [bp+8] ; buffer address + mov cx,word ptr [bp+12] ; number of bytes + mov ah,40h ; write file + int 21h + jc write_err ; if failed, return error code + cmp ax,word ptr [bp+12] ; make sure all bytes written + je write_ok + mov ax,1 ; else return 1 for not OK + jmp short write_err +write_ok: xor ax,ax ; return zero for OK +write_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_write endp + + +; +; void far jxms_getdriver (XMSDRIVER far *) +; +; Get the address of the XMS driver, or NULL if not available +; +_jxms_getdriver proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov ax,4300h ; call multiplex interrupt with + int 2fh ; a magic cookie, hex 4300 + cmp al,80h ; AL should contain hex 80 + je xmsavail + xor dx,dx ; no XMS driver available + xor ax,ax ; return a nil pointer + jmp short xmsavail_done +xmsavail: mov ax,4310h ; fetch driver address with + int 2fh ; another magic cookie + mov dx,es ; copy address to dx:ax + mov ax,bx +xmsavail_done: les bx,dword ptr [bp+6] ; get pointer to return value + mov word ptr es:[bx],ax + mov word ptr es:[bx+2],dx + pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jxms_getdriver endp + + +; +; void far jxms_calldriver (XMSDRIVER, XMScontext far *) +; +; The XMScontext structure contains values for the AX,DX,BX,SI,DS registers. +; These are loaded, the XMS call is performed, and the new values of the +; AX,DX,BX registers are written back to the context structure. +; +_jxms_calldriver proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + les bx,dword ptr [bp+10] ; get XMScontext pointer + mov ax,word ptr es:[bx] ; load registers + mov dx,word ptr es:[bx+2] + mov si,word ptr es:[bx+6] + mov ds,word ptr es:[bx+8] + mov bx,word ptr es:[bx+4] + call dword ptr [bp+6] ; call the driver + mov cx,bx ; save returned BX for a sec + les bx,dword ptr [bp+10] ; get XMScontext pointer + mov word ptr es:[bx],ax ; put back ax,dx,bx + mov word ptr es:[bx+2],dx + mov word ptr es:[bx+4],cx + pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jxms_calldriver endp + + +; +; short far jems_available (void) +; +; Have we got an EMS driver? (this comes straight from the EMS 4.0 specs) +; +_jems_available proc far + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov ax,3567h ; get interrupt vector 67h + int 21h + push cs + pop ds + mov di,000ah ; check offs 10 in returned seg + lea si,ASCII_device_name ; against literal string + mov cx,8 + cld + repe cmpsb + jne no_ems + mov ax,1 ; match, it's there + jmp short avail_done +no_ems: xor ax,ax ; it's not there +avail_done: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + ret + +ASCII_device_name db "EMMXXXX0" + +_jems_available endp + + +; +; void far jems_calldriver (EMScontext far *) +; +; The EMScontext structure contains values for the AX,DX,BX,SI,DS registers. +; These are loaded, the EMS trap is performed, and the new values of the +; AX,DX,BX registers are written back to the context structure. +; +_jems_calldriver proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + les bx,dword ptr [bp+6] ; get EMScontext pointer + mov ax,word ptr es:[bx] ; load registers + mov dx,word ptr es:[bx+2] + mov si,word ptr es:[bx+6] + mov ds,word ptr es:[bx+8] + mov bx,word ptr es:[bx+4] + int 67h ; call the EMS driver + mov cx,bx ; save returned BX for a sec + les bx,dword ptr [bp+6] ; get EMScontext pointer + mov word ptr es:[bx],ax ; put back ax,dx,bx + mov word ptr es:[bx+2],dx + mov word ptr es:[bx+4],cx + pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jems_calldriver endp + +JMEMDOSA_TXT ends + + end diff --git a/thirdparty/jpeg-9e/jmemmac.c b/thirdparty/jpeg-9e/jmemmac.c new file mode 100644 index 0000000..106f9be --- /dev/null +++ b/thirdparty/jpeg-9e/jmemmac.c @@ -0,0 +1,289 @@ +/* + * jmemmac.c + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * jmemmac.c provides an Apple Macintosh implementation of the system- + * dependent portion of the JPEG memory manager. + * + * If you use jmemmac.c, then you must define USE_MAC_MEMMGR in the + * JPEG_INTERNALS part of jconfig.h. + * + * jmemmac.c uses the Macintosh toolbox routines NewPtr and DisposePtr + * instead of malloc and free. It accurately determines the amount of + * memory available by using CompactMem. Notice that if left to its + * own devices, this code can chew up all available space in the + * application's zone, with the exception of the rather small "slop" + * factor computed in jpeg_mem_available(). The application can ensure + * that more space is left over by reducing max_memory_to_use. + * + * Large images are swapped to disk using temporary files and System 7.0+'s + * temporary folder functionality. + * + * Note that jmemmac.c depends on two features of MacOS that were first + * introduced in System 7: FindFolder and the FSSpec-based calls. + * If your application uses jmemmac.c and is run under System 6 or earlier, + * and the jpeg library decides it needs a temporary file, it will abort, + * printing error messages about requiring System 7. (If no temporary files + * are created, it will run fine.) + * + * If you want to use jmemmac.c in an application that might be used with + * System 6 or earlier, then you should remove dependencies on FindFolder + * and the FSSpec calls. You will need to replace FindFolder with some + * other mechanism for finding a place to put temporary files, and you + * should replace the FSSpec calls with their HFS equivalents: + * + * FSpDelete -> HDelete + * FSpGetFInfo -> HGetFInfo + * FSpCreate -> HCreate + * FSpOpenDF -> HOpen *** Note: not HOpenDF *** + * FSMakeFSSpec -> (fill in spec by hand.) + * + * (Use HOpen instead of HOpenDF. HOpen is just a glue-interface to PBHOpen, + * which is on all HFS macs. HOpenDF is a System 7 addition which avoids the + * ages-old problem of names starting with a period.) + * + * Contributed by Sam Bushell (jsam@iagu.on.net) and + * Dan Gildor (gyld@in-touch.com). + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef USE_MAC_MEMMGR /* make sure user got configuration right */ + You forgot to define USE_MAC_MEMMGR in jconfig.h. /* deliberate syntax error */ +#endif + +#include /* we use the MacOS memory manager */ +#include /* we use the MacOS File stuff */ +#include /* we use the MacOS HFS stuff */ +#include /* for smSystemScript */ +#include /* we use Gestalt to test for specific functionality */ + +#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ +#define TEMP_FILE_NAME "JPG%03d.TMP" +#endif + +static int next_file_num; /* to distinguish among several temp files */ + + +/* + * Memory allocation and freeing are controlled by the MacOS library + * routines NewPtr() and DisposePtr(), which allocate fixed-address + * storage. Unfortunately, the IJG library isn't smart enough to cope + * with relocatable storage. + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) NewPtr(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + DisposePtr((Ptr) object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: we include FAR keywords in the routine declarations simply for + * consistency with the rest of the IJG code; FAR should expand to empty + * on rational architectures like the Mac. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) NewPtr(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + DisposePtr((Ptr) object); +} + + +/* + * This routine computes the total memory space available for allocation. + */ + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + long limit = cinfo->mem->max_memory_to_use - already_allocated; + long slop, mem; + + /* Don't ask for more than what application has told us we may use */ + if (max_bytes_needed > limit && limit > 0) + max_bytes_needed = limit; + /* Find whether there's a big enough free block in the heap. + * CompactMem tries to create a contiguous block of the requested size, + * and then returns the size of the largest free block (which could be + * much more or much less than we asked for). + * We add some slop to ensure we don't use up all available memory. + */ + slop = max_bytes_needed / 16 + 32768L; + mem = CompactMem(max_bytes_needed + slop) - slop; + if (mem < 0) + mem = 0; /* sigh, couldn't even get the slop */ + /* Don't take more than the application says we can have */ + if (mem > limit && limit > 0) + mem = limit; + return mem; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + long bytes = byte_count; + long retVal; + + if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) + ERREXIT(cinfo, JERR_TFILE_SEEK); + + retVal = FSRead ( info->temp_file, &bytes, + (unsigned char *) buffer_address ); + if ( retVal != noErr || bytes != byte_count ) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + long bytes = byte_count; + long retVal; + + if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) + ERREXIT(cinfo, JERR_TFILE_SEEK); + + retVal = FSWrite ( info->temp_file, &bytes, + (unsigned char *) buffer_address ); + if ( retVal != noErr || bytes != byte_count ) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + FSClose ( info->temp_file ); + FSpDelete ( &(info->tempSpec) ); +} + + +/* + * Initial opening of a backing-store object. + * + * This version uses FindFolder to find the Temporary Items folder, + * and puts the temporary file in there. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + short tmpRef, vRefNum; + long dirID; + FInfo finderInfo; + FSSpec theSpec; + Str255 fName; + OSErr osErr; + long gestaltResponse = 0; + + /* Check that FSSpec calls are available. */ + osErr = Gestalt( gestaltFSAttr, &gestaltResponse ); + if ( ( osErr != noErr ) + || !( gestaltResponse & (1<temp_name, TEMP_FILE_NAME, next_file_num); + strcpy ( (Ptr)fName+1, info->temp_name ); + *fName = strlen (info->temp_name); + osErr = FSMakeFSSpec ( vRefNum, dirID, fName, &theSpec ); + + if ( (osErr = FSpGetFInfo ( &theSpec, &finderInfo ) ) != noErr ) + break; + } + + osErr = FSpCreate ( &theSpec, '????', '????', smSystemScript ); + if ( osErr != noErr ) + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + + osErr = FSpOpenDF ( &theSpec, fsRdWrPerm, &(info->temp_file) ); + if ( osErr != noErr ) + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + + info->tempSpec = theSpec; + + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; + TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + next_file_num = 0; + + /* max_memory_to_use will be initialized to FreeMem()'s result; + * the calling application might later reduce it, for example + * to leave room to invoke multiple JPEG objects. + * Note that FreeMem returns the total number of free bytes; + * it may not be possible to allocate a single block of this size. + */ + return FreeMem(); +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/thirdparty/jpeg-9e/jmemmgr.c b/thirdparty/jpeg-9e/jmemmgr.c new file mode 100644 index 0000000..40377de --- /dev/null +++ b/thirdparty/jpeg-9e/jmemmgr.c @@ -0,0 +1,1115 @@ +/* + * jmemmgr.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 2011-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the JPEG system-independent memory management + * routines. This code is usable across a wide variety of machines; most + * of the system dependencies have been isolated in a separate file. + * The major functions provided here are: + * * pool-based allocation and freeing of memory; + * * policy decisions about how to divide available memory among the + * virtual arrays; + * * control logic for swapping virtual arrays between main memory and + * backing storage. + * The separate system-dependent file provides the actual backing-storage + * access code, and it contains the policy decision about how much total + * main memory to use. + * This file is system-dependent in the sense that some of its functions + * are unnecessary in some systems. For example, if there is enough virtual + * memory so that backing storage will never be used, much of the virtual + * array control logic could be removed. (Of course, if you have that much + * memory then you shouldn't care about a little bit of unused code...) + */ + +#define JPEG_INTERNALS +#define AM_MEMORY_MANAGER /* we define jvirt_Xarray_control structs */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef NO_GETENV +#ifndef HAVE_STDLIB_H /* should declare getenv() */ +extern char * getenv JPP((const char * name)); +#endif +#endif + + +/* + * Some important notes: + * The allocation routines provided here must never return NULL. + * They should exit to error_exit if unsuccessful. + * + * It's not a good idea to try to merge the sarray and barray routines, + * even though they are textually almost the same, because samples are + * usually stored as bytes while coefficients are shorts or ints. Thus, + * in machines where byte pointers have a different representation from + * word pointers, the resulting machine code could not be the same. + */ + + +/* + * Many machines require storage alignment: longs must start on 4-byte + * boundaries, doubles on 8-byte boundaries, etc. On such machines, malloc() + * always returns pointers that are multiples of the worst-case alignment + * requirement, and we had better do so too. + * There isn't any really portable way to determine the worst-case alignment + * requirement. This module assumes that the alignment requirement is + * multiples of sizeof(ALIGN_TYPE). + * By default, we define ALIGN_TYPE as double. This is necessary on some + * workstations (where doubles really do need 8-byte alignment) and will work + * fine on nearly everything. If your machine has lesser alignment needs, + * you can save a few bytes by making ALIGN_TYPE smaller. + * The only place I know of where this will NOT work is certain Macintosh + * 680x0 compilers that define double as a 10-byte IEEE extended float. + * Doing 10-byte alignment is counterproductive because longwords won't be + * aligned well. Put "#define ALIGN_TYPE long" in jconfig.h if you have + * such a compiler. + */ + +#ifndef ALIGN_TYPE /* so can override from jconfig.h */ +#define ALIGN_TYPE double +#endif + + +/* + * We allocate objects from "pools", where each pool is gotten with a single + * request to jpeg_get_small() or jpeg_get_large(). There is no per-object + * overhead within a pool, except for alignment padding. Each pool has a + * header with a link to the next pool of the same class. + * Small and large pool headers are identical except that the latter's + * link pointer must be FAR on 80x86 machines. + * Notice that the "real" header fields are union'ed with a dummy ALIGN_TYPE + * field. This forces the compiler to make SIZEOF(small_pool_hdr) a multiple + * of the alignment requirement of ALIGN_TYPE. + */ + +typedef union small_pool_struct * small_pool_ptr; + +typedef union small_pool_struct { + struct { + small_pool_ptr next; /* next in list of pools */ + size_t bytes_used; /* how many bytes already used within pool */ + size_t bytes_left; /* bytes still available in this pool */ + } hdr; + ALIGN_TYPE dummy; /* included in union to ensure alignment */ +} small_pool_hdr; + +typedef union large_pool_struct FAR * large_pool_ptr; + +typedef union large_pool_struct { + struct { + large_pool_ptr next; /* next in list of pools */ + size_t bytes_used; /* how many bytes already used within pool */ + size_t bytes_left; /* bytes still available in this pool */ + } hdr; + ALIGN_TYPE dummy; /* included in union to ensure alignment */ +} large_pool_hdr; + + +/* + * Here is the full definition of a memory manager object. + */ + +typedef struct { + struct jpeg_memory_mgr pub; /* public fields */ + + /* Each pool identifier (lifetime class) names a linked list of pools. */ + small_pool_ptr small_list[JPOOL_NUMPOOLS]; + large_pool_ptr large_list[JPOOL_NUMPOOLS]; + + /* Since we only have one lifetime class of virtual arrays, only one + * linked list is necessary (for each datatype). Note that the virtual + * array control blocks being linked together are actually stored somewhere + * in the small-pool list. + */ + jvirt_sarray_ptr virt_sarray_list; + jvirt_barray_ptr virt_barray_list; + + /* This counts total space obtained from jpeg_get_small/large */ + size_t total_space_allocated; + + /* alloc_sarray and alloc_barray set this value for use by virtual + * array routines. + */ + JDIMENSION last_rowsperchunk; /* from most recent alloc_sarray/barray */ +} my_memory_mgr; + +typedef my_memory_mgr * my_mem_ptr; + + +/* + * The control blocks for virtual arrays. + * Note that these blocks are allocated in the "small" pool area. + * System-dependent info for the associated backing store (if any) is hidden + * inside the backing_store_info struct. + */ + +struct jvirt_sarray_control { + JSAMPARRAY mem_buffer; /* => the in-memory buffer */ + JDIMENSION rows_in_array; /* total virtual array height */ + JDIMENSION samplesperrow; /* width of array (and of memory buffer) */ + JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */ + JDIMENSION rows_in_mem; /* height of memory buffer */ + JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ + JDIMENSION cur_start_row; /* first logical row # in the buffer */ + JDIMENSION first_undef_row; /* row # of first uninitialized row */ + boolean pre_zero; /* pre-zero mode requested? */ + boolean dirty; /* do current buffer contents need written? */ + boolean b_s_open; /* is backing-store data valid? */ + jvirt_sarray_ptr next; /* link to next virtual sarray control block */ + backing_store_info b_s_info; /* System-dependent control info */ +}; + +struct jvirt_barray_control { + JBLOCKARRAY mem_buffer; /* => the in-memory buffer */ + JDIMENSION rows_in_array; /* total virtual array height */ + JDIMENSION blocksperrow; /* width of array (and of memory buffer) */ + JDIMENSION maxaccess; /* max rows accessed by access_virt_barray */ + JDIMENSION rows_in_mem; /* height of memory buffer */ + JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ + JDIMENSION cur_start_row; /* first logical row # in the buffer */ + JDIMENSION first_undef_row; /* row # of first uninitialized row */ + boolean pre_zero; /* pre-zero mode requested? */ + boolean dirty; /* do current buffer contents need written? */ + boolean b_s_open; /* is backing-store data valid? */ + jvirt_barray_ptr next; /* link to next virtual barray control block */ + backing_store_info b_s_info; /* System-dependent control info */ +}; + + +#ifdef MEM_STATS /* optional extra stuff for statistics */ + +LOCAL(void) +print_mem_stats (j_common_ptr cinfo, int pool_id) +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr shdr_ptr; + large_pool_ptr lhdr_ptr; + + /* Since this is only a debugging stub, we can cheat a little by using + * fprintf directly rather than going through the trace message code. + * This is helpful because message parm array can't handle longs. + */ + fprintf(stderr, "Freeing pool %d, total space = %ld\n", + pool_id, (long) mem->total_space_allocated); + + for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; + lhdr_ptr = lhdr_ptr->hdr.next) { + fprintf(stderr, " Large chunk used %ld\n", + (long) lhdr_ptr->hdr.bytes_used); + } + + for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL; + shdr_ptr = shdr_ptr->hdr.next) { + fprintf(stderr, " Small chunk used %ld free %ld\n", + (long) shdr_ptr->hdr.bytes_used, + (long) shdr_ptr->hdr.bytes_left); + } +} + +#endif /* MEM_STATS */ + + +LOCAL(noreturn_t) +out_of_memory (j_common_ptr cinfo, int which) +/* Report an out-of-memory error and stop execution */ +/* If we compiled MEM_STATS support, report alloc requests before dying */ +{ +#ifdef MEM_STATS + cinfo->err->trace_level = 2; /* force self_destruct to report stats */ +#endif + ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which); +} + + +/* + * Allocation of "small" objects. + * + * For these, we use pooled storage. When a new pool must be created, + * we try to get enough space for the current request plus a "slop" factor, + * where the slop will be the amount of leftover space in the new pool. + * The speed vs. space tradeoff is largely determined by the slop values. + * A different slop value is provided for each pool class (lifetime), + * and we also distinguish the first pool of a class from later ones. + * NOTE: the values given work fairly well on both 16- and 32-bit-int + * machines, but may be too small if longs are 64 bits or more. + */ + +static const size_t first_pool_slop[JPOOL_NUMPOOLS] = +{ + 1600, /* first PERMANENT pool */ + 16000 /* first IMAGE pool */ +}; + +static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = +{ + 0, /* additional PERMANENT pools */ + 5000 /* additional IMAGE pools */ +}; + +#define MIN_SLOP 50 /* greater than 0 to avoid futile looping */ + + +METHODDEF(void *) +alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) +/* Allocate a "small" object */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr hdr_ptr, prev_hdr_ptr; + size_t odd_bytes, min_request, slop; + char * data_ptr; + + /* Check for unsatisfiable request (do now to ensure no overflow below) */ + if (sizeofobject > (size_t) MAX_ALLOC_CHUNK - SIZEOF(small_pool_hdr)) + out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ + + /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ + odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); + if (odd_bytes > 0) + sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; + + /* See if space is available in any existing pool */ + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + prev_hdr_ptr = NULL; + hdr_ptr = mem->small_list[pool_id]; + while (hdr_ptr != NULL) { + if (hdr_ptr->hdr.bytes_left >= sizeofobject) + break; /* found pool with enough space */ + prev_hdr_ptr = hdr_ptr; + hdr_ptr = hdr_ptr->hdr.next; + } + + /* Time to make a new pool? */ + if (hdr_ptr == NULL) { + /* min_request is what we need now, slop is what will be leftover */ + min_request = sizeofobject + SIZEOF(small_pool_hdr); + if (prev_hdr_ptr == NULL) /* first pool in class? */ + slop = first_pool_slop[pool_id]; + else + slop = extra_pool_slop[pool_id]; + /* Don't ask for more than MAX_ALLOC_CHUNK */ + if (slop > (size_t) MAX_ALLOC_CHUNK - min_request) + slop = (size_t) MAX_ALLOC_CHUNK - min_request; + /* Try to get space, if fail reduce slop and try again */ + for (;;) { + hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop); + if (hdr_ptr != NULL) + break; + slop /= 2; + if (slop < MIN_SLOP) /* give up when it gets real small */ + out_of_memory(cinfo, 2); /* jpeg_get_small failed */ + } + mem->total_space_allocated += min_request + slop; + /* Success, initialize the new pool header and add to end of list */ + hdr_ptr->hdr.next = NULL; + hdr_ptr->hdr.bytes_used = 0; + hdr_ptr->hdr.bytes_left = sizeofobject + slop; + if (prev_hdr_ptr == NULL) /* first pool in class? */ + mem->small_list[pool_id] = hdr_ptr; + else + prev_hdr_ptr->hdr.next = hdr_ptr; + } + + /* OK, allocate the object from the current pool */ + data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */ + data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */ + hdr_ptr->hdr.bytes_used += sizeofobject; + hdr_ptr->hdr.bytes_left -= sizeofobject; + + return (void *) data_ptr; +} + + +/* + * Allocation of "large" objects. + * + * The external semantics of these are the same as "small" objects, + * except that FAR pointers are used on 80x86. However the pool + * management heuristics are quite different. We assume that each + * request is large enough that it may as well be passed directly to + * jpeg_get_large; the pool management just links everything together + * so that we can free it all on demand. + * Note: the major use of "large" objects is in JSAMPARRAY and JBLOCKARRAY + * structures. The routines that create these structures (see below) + * deliberately bunch rows together to ensure a large request size. + */ + +METHODDEF(void FAR *) +alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) +/* Allocate a "large" object */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + large_pool_ptr hdr_ptr; + size_t odd_bytes; + + /* Check for unsatisfiable request (do now to ensure no overflow below) */ + if (sizeofobject > (size_t) MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr)) + out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ + + /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ + odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); + if (odd_bytes > 0) + sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; + + /* Always make a new pool */ + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject + + SIZEOF(large_pool_hdr)); + if (hdr_ptr == NULL) + out_of_memory(cinfo, 4); /* jpeg_get_large failed */ + mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr); + + /* Success, initialize the new pool header and add to list */ + hdr_ptr->hdr.next = mem->large_list[pool_id]; + /* We maintain space counts in each pool header for statistical purposes, + * even though they are not needed for allocation. + */ + hdr_ptr->hdr.bytes_used = sizeofobject; + hdr_ptr->hdr.bytes_left = 0; + mem->large_list[pool_id] = hdr_ptr; + + return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */ +} + + +/* + * Creation of 2-D sample arrays. + * The pointers are in near heap, the samples themselves in FAR heap. + * + * To minimize allocation overhead and to allow I/O of large contiguous + * blocks, we allocate the sample rows in groups of as many rows as possible + * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request. + * NB: the virtual array control routines, later in this file, know about + * this chunking of rows. The rowsperchunk value is left in the mem manager + * object so that it can be saved away if this sarray is the workspace for + * a virtual array. + */ + +METHODDEF(JSAMPARRAY) +alloc_sarray (j_common_ptr cinfo, int pool_id, + JDIMENSION samplesperrow, JDIMENSION numrows) +/* Allocate a 2-D sample array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + JSAMPARRAY result; + JSAMPROW workspace; + JDIMENSION rowsperchunk, currow, i; + long ltemp; + + /* Calculate max # of rows allowed in one allocation chunk */ + ltemp = (MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr)) / + ((long) samplesperrow * SIZEOF(JSAMPLE)); + if (ltemp <= 0) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + if (ltemp < (long) numrows) + rowsperchunk = (JDIMENSION) ltemp; + else + rowsperchunk = numrows; + mem->last_rowsperchunk = rowsperchunk; + + /* Get space for row pointers (small object) */ + result = (JSAMPARRAY) alloc_small(cinfo, pool_id, + (size_t) numrows * SIZEOF(JSAMPROW)); + + /* Get the rows themselves (large objects) */ + currow = 0; + while (currow < numrows) { + rowsperchunk = MIN(rowsperchunk, numrows - currow); + workspace = (JSAMPROW) alloc_large(cinfo, pool_id, + (size_t) rowsperchunk * (size_t) samplesperrow * SIZEOF(JSAMPLE)); + for (i = rowsperchunk; i > 0; i--) { + result[currow++] = workspace; + workspace += samplesperrow; + } + } + + return result; +} + + +/* + * Creation of 2-D coefficient-block arrays. + * This is essentially the same as the code for sample arrays, above. + */ + +METHODDEF(JBLOCKARRAY) +alloc_barray (j_common_ptr cinfo, int pool_id, + JDIMENSION blocksperrow, JDIMENSION numrows) +/* Allocate a 2-D coefficient-block array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + JBLOCKARRAY result; + JBLOCKROW workspace; + JDIMENSION rowsperchunk, currow, i; + long ltemp; + + /* Calculate max # of rows allowed in one allocation chunk */ + ltemp = (MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr)) / + ((long) blocksperrow * SIZEOF(JBLOCK)); + if (ltemp <= 0) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + if (ltemp < (long) numrows) + rowsperchunk = (JDIMENSION) ltemp; + else + rowsperchunk = numrows; + mem->last_rowsperchunk = rowsperchunk; + + /* Get space for row pointers (small object) */ + result = (JBLOCKARRAY) alloc_small(cinfo, pool_id, + (size_t) numrows * SIZEOF(JBLOCKROW)); + + /* Get the rows themselves (large objects) */ + currow = 0; + while (currow < numrows) { + rowsperchunk = MIN(rowsperchunk, numrows - currow); + workspace = (JBLOCKROW) alloc_large(cinfo, pool_id, + (size_t) rowsperchunk * (size_t) blocksperrow * SIZEOF(JBLOCK)); + for (i = rowsperchunk; i > 0; i--) { + result[currow++] = workspace; + workspace += blocksperrow; + } + } + + return result; +} + + +/* + * About virtual array management: + * + * The above "normal" array routines are only used to allocate strip buffers + * (as wide as the image, but just a few rows high). Full-image-sized buffers + * are handled as "virtual" arrays. The array is still accessed a strip at a + * time, but the memory manager must save the whole array for repeated + * accesses. The intended implementation is that there is a strip buffer in + * memory (as high as is possible given the desired memory limit), plus a + * backing file that holds the rest of the array. + * + * The request_virt_array routines are told the total size of the image and + * the maximum number of rows that will be accessed at once. The in-memory + * buffer must be at least as large as the maxaccess value. + * + * The request routines create control blocks but not the in-memory buffers. + * That is postponed until realize_virt_arrays is called. At that time the + * total amount of space needed is known (approximately, anyway), so free + * memory can be divided up fairly. + * + * The access_virt_array routines are responsible for making a specific strip + * area accessible (after reading or writing the backing file, if necessary). + * Note that the access routines are told whether the caller intends to modify + * the accessed strip; during a read-only pass this saves having to rewrite + * data to disk. The access routines are also responsible for pre-zeroing + * any newly accessed rows, if pre-zeroing was requested. + * + * In current usage, the access requests are usually for nonoverlapping + * strips; that is, successive access start_row numbers differ by exactly + * num_rows = maxaccess. This means we can get good performance with simple + * buffer dump/reload logic, by making the in-memory buffer be a multiple + * of the access height; then there will never be accesses across bufferload + * boundaries. The code will still work with overlapping access requests, + * but it doesn't handle bufferload overlaps very efficiently. + */ + + +METHODDEF(jvirt_sarray_ptr) +request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero, + JDIMENSION samplesperrow, JDIMENSION numrows, + JDIMENSION maxaccess) +/* Request a virtual 2-D sample array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + jvirt_sarray_ptr result; + + /* Only IMAGE-lifetime virtual arrays are currently supported */ + if (pool_id != JPOOL_IMAGE) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + /* get control block */ + result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id, + SIZEOF(struct jvirt_sarray_control)); + + result->mem_buffer = NULL; /* marks array not yet realized */ + result->rows_in_array = numrows; + result->samplesperrow = samplesperrow; + result->maxaccess = maxaccess; + result->pre_zero = pre_zero; + result->b_s_open = FALSE; /* no associated backing-store object */ + result->next = mem->virt_sarray_list; /* add to list of virtual arrays */ + mem->virt_sarray_list = result; + + return result; +} + + +METHODDEF(jvirt_barray_ptr) +request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero, + JDIMENSION blocksperrow, JDIMENSION numrows, + JDIMENSION maxaccess) +/* Request a virtual 2-D coefficient-block array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + jvirt_barray_ptr result; + + /* Only IMAGE-lifetime virtual arrays are currently supported */ + if (pool_id != JPOOL_IMAGE) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + /* get control block */ + result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id, + SIZEOF(struct jvirt_barray_control)); + + result->mem_buffer = NULL; /* marks array not yet realized */ + result->rows_in_array = numrows; + result->blocksperrow = blocksperrow; + result->maxaccess = maxaccess; + result->pre_zero = pre_zero; + result->b_s_open = FALSE; /* no associated backing-store object */ + result->next = mem->virt_barray_list; /* add to list of virtual arrays */ + mem->virt_barray_list = result; + + return result; +} + + +METHODDEF(void) +realize_virt_arrays (j_common_ptr cinfo) +/* Allocate the in-memory buffers for any unrealized virtual arrays */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + long bytesperrow, space_per_minheight, maximum_space; + long avail_mem, minheights, max_minheights; + jvirt_sarray_ptr sptr; + jvirt_barray_ptr bptr; + + /* Compute the minimum space needed (maxaccess rows in each buffer) + * and the maximum space needed (full image height in each buffer). + * These may be of use to the system-dependent jpeg_mem_available routine. + */ + space_per_minheight = 0; + maximum_space = 0; + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->mem_buffer == NULL) { /* if not realized yet */ + bytesperrow = (long) sptr->samplesperrow * SIZEOF(JSAMPLE); + space_per_minheight += (long) sptr->maxaccess * bytesperrow; + maximum_space += (long) sptr->rows_in_array * bytesperrow; + } + } + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->mem_buffer == NULL) { /* if not realized yet */ + bytesperrow = (long) bptr->blocksperrow * SIZEOF(JBLOCK); + space_per_minheight += (long) bptr->maxaccess * bytesperrow; + maximum_space += (long) bptr->rows_in_array * bytesperrow; + } + } + + if (space_per_minheight <= 0) + return; /* no unrealized arrays, no work */ + + /* Determine amount of memory to actually use; this is system-dependent. */ + avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space, + (long) mem->total_space_allocated); + + /* If the maximum space needed is available, make all the buffers full + * height; otherwise parcel it out with the same number of minheights + * in each buffer. + */ + if (avail_mem >= maximum_space) + max_minheights = 1000000000L; + else { + max_minheights = avail_mem / space_per_minheight; + /* If there doesn't seem to be enough space, try to get the minimum + * anyway. This allows a "stub" implementation of jpeg_mem_available(). + */ + if (max_minheights <= 0) + max_minheights = 1; + } + + /* Allocate the in-memory buffers and initialize backing store as needed. */ + + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->mem_buffer == NULL) { /* if not realized yet */ + minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L; + if (minheights <= max_minheights) { + /* This buffer fits in memory */ + sptr->rows_in_mem = sptr->rows_in_array; + } else { + /* It doesn't fit in memory, create backing store. */ + sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess); + jpeg_open_backing_store(cinfo, & sptr->b_s_info, + (long) sptr->rows_in_array * + (long) sptr->samplesperrow * + (long) SIZEOF(JSAMPLE)); + sptr->b_s_open = TRUE; + } + sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE, + sptr->samplesperrow, sptr->rows_in_mem); + sptr->rowsperchunk = mem->last_rowsperchunk; + sptr->cur_start_row = 0; + sptr->first_undef_row = 0; + sptr->dirty = FALSE; + } + } + + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->mem_buffer == NULL) { /* if not realized yet */ + minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L; + if (minheights <= max_minheights) { + /* This buffer fits in memory */ + bptr->rows_in_mem = bptr->rows_in_array; + } else { + /* It doesn't fit in memory, create backing store. */ + bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess); + jpeg_open_backing_store(cinfo, & bptr->b_s_info, + (long) bptr->rows_in_array * + (long) bptr->blocksperrow * + (long) SIZEOF(JBLOCK)); + bptr->b_s_open = TRUE; + } + bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE, + bptr->blocksperrow, bptr->rows_in_mem); + bptr->rowsperchunk = mem->last_rowsperchunk; + bptr->cur_start_row = 0; + bptr->first_undef_row = 0; + bptr->dirty = FALSE; + } + } +} + + +LOCAL(void) +do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing) +/* Do backing store read or write of a virtual sample array */ +{ + long bytesperrow, file_offset, byte_count, rows, thisrow, i; + + bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE); + file_offset = (long) ptr->cur_start_row * bytesperrow; + /* Loop to read or write each allocation chunk in mem_buffer */ + for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { + /* One chunk, but check for short chunk at end of buffer */ + rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); + /* Transfer no more than is currently defined */ + thisrow = (long) ptr->cur_start_row + i; + rows = MIN(rows, (long) ptr->first_undef_row - thisrow); + /* Transfer no more than fits in file */ + rows = MIN(rows, (long) ptr->rows_in_array - thisrow); + if (rows <= 0) /* this chunk might be past end of file! */ + break; + byte_count = rows * bytesperrow; + if (writing) + (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + else + (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + file_offset += byte_count; + } +} + + +LOCAL(void) +do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing) +/* Do backing store read or write of a virtual coefficient-block array */ +{ + long bytesperrow, file_offset, byte_count, rows, thisrow, i; + + bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK); + file_offset = (long) ptr->cur_start_row * bytesperrow; + /* Loop to read or write each allocation chunk in mem_buffer */ + for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { + /* One chunk, but check for short chunk at end of buffer */ + rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); + /* Transfer no more than is currently defined */ + thisrow = (long) ptr->cur_start_row + i; + rows = MIN(rows, (long) ptr->first_undef_row - thisrow); + /* Transfer no more than fits in file */ + rows = MIN(rows, (long) ptr->rows_in_array - thisrow); + if (rows <= 0) /* this chunk might be past end of file! */ + break; + byte_count = rows * bytesperrow; + if (writing) + (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + else + (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + file_offset += byte_count; + } +} + + +METHODDEF(JSAMPARRAY) +access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr, + JDIMENSION start_row, JDIMENSION num_rows, + boolean writable) +/* Access the part of a virtual sample array starting at start_row */ +/* and extending for num_rows rows. writable is true if */ +/* caller intends to modify the accessed area. */ +{ + JDIMENSION end_row = start_row + num_rows; + JDIMENSION undef_row; + + /* debugging check */ + if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || + ptr->mem_buffer == NULL) + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + + /* Make the desired part of the virtual array accessible */ + if (start_row < ptr->cur_start_row || + end_row > ptr->cur_start_row + ptr->rows_in_mem) { + if (! ptr->b_s_open) + ERREXIT(cinfo, JERR_VIRTUAL_BUG); + /* Flush old buffer contents if necessary */ + if (ptr->dirty) { + do_sarray_io(cinfo, ptr, TRUE); + ptr->dirty = FALSE; + } + /* Decide what part of virtual array to access. + * Algorithm: if target address > current window, assume forward scan, + * load starting at target address. If target address < current window, + * assume backward scan, load so that target area is top of window. + * Note that when switching from forward write to forward read, will have + * start_row = 0, so the limiting case applies and we load from 0 anyway. + */ + if (start_row > ptr->cur_start_row) { + ptr->cur_start_row = start_row; + } else { + /* use long arithmetic here to avoid overflow & unsigned problems */ + long ltemp; + + ltemp = (long) end_row - (long) ptr->rows_in_mem; + if (ltemp < 0) + ltemp = 0; /* don't fall off front end of file */ + ptr->cur_start_row = (JDIMENSION) ltemp; + } + /* Read in the selected part of the array. + * During the initial write pass, we will do no actual read + * because the selected part is all undefined. + */ + do_sarray_io(cinfo, ptr, FALSE); + } + /* Ensure the accessed part of the array is defined; prezero if needed. + * To improve locality of access, we only prezero the part of the array + * that the caller is about to access, not the entire in-memory array. + */ + if (ptr->first_undef_row < end_row) { + if (ptr->first_undef_row < start_row) { + if (writable) /* writer skipped over a section of array */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + undef_row = start_row; /* but reader is allowed to read ahead */ + } else { + undef_row = ptr->first_undef_row; + } + if (writable) + ptr->first_undef_row = end_row; + if (ptr->pre_zero) { + size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE); + undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ + end_row -= ptr->cur_start_row; + while (undef_row < end_row) { + FMEMZERO((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); + undef_row++; + } + } else { + if (! writable) /* reader looking at undefined data */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + } + } + /* Flag the buffer dirty if caller will write in it */ + if (writable) + ptr->dirty = TRUE; + /* Return address of proper part of the buffer */ + return ptr->mem_buffer + (start_row - ptr->cur_start_row); +} + + +METHODDEF(JBLOCKARRAY) +access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr, + JDIMENSION start_row, JDIMENSION num_rows, + boolean writable) +/* Access the part of a virtual block array starting at start_row */ +/* and extending for num_rows rows. writable is true if */ +/* caller intends to modify the accessed area. */ +{ + JDIMENSION end_row = start_row + num_rows; + JDIMENSION undef_row; + + /* debugging check */ + if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || + ptr->mem_buffer == NULL) + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + + /* Make the desired part of the virtual array accessible */ + if (start_row < ptr->cur_start_row || + end_row > ptr->cur_start_row + ptr->rows_in_mem) { + if (! ptr->b_s_open) + ERREXIT(cinfo, JERR_VIRTUAL_BUG); + /* Flush old buffer contents if necessary */ + if (ptr->dirty) { + do_barray_io(cinfo, ptr, TRUE); + ptr->dirty = FALSE; + } + /* Decide what part of virtual array to access. + * Algorithm: if target address > current window, assume forward scan, + * load starting at target address. If target address < current window, + * assume backward scan, load so that target area is top of window. + * Note that when switching from forward write to forward read, will have + * start_row = 0, so the limiting case applies and we load from 0 anyway. + */ + if (start_row > ptr->cur_start_row) { + ptr->cur_start_row = start_row; + } else { + /* use long arithmetic here to avoid overflow & unsigned problems */ + long ltemp; + + ltemp = (long) end_row - (long) ptr->rows_in_mem; + if (ltemp < 0) + ltemp = 0; /* don't fall off front end of file */ + ptr->cur_start_row = (JDIMENSION) ltemp; + } + /* Read in the selected part of the array. + * During the initial write pass, we will do no actual read + * because the selected part is all undefined. + */ + do_barray_io(cinfo, ptr, FALSE); + } + /* Ensure the accessed part of the array is defined; prezero if needed. + * To improve locality of access, we only prezero the part of the array + * that the caller is about to access, not the entire in-memory array. + */ + if (ptr->first_undef_row < end_row) { + if (ptr->first_undef_row < start_row) { + if (writable) /* writer skipped over a section of array */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + undef_row = start_row; /* but reader is allowed to read ahead */ + } else { + undef_row = ptr->first_undef_row; + } + if (writable) + ptr->first_undef_row = end_row; + if (ptr->pre_zero) { + size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK); + undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ + end_row -= ptr->cur_start_row; + while (undef_row < end_row) { + FMEMZERO((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); + undef_row++; + } + } else { + if (! writable) /* reader looking at undefined data */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + } + } + /* Flag the buffer dirty if caller will write in it */ + if (writable) + ptr->dirty = TRUE; + /* Return address of proper part of the buffer */ + return ptr->mem_buffer + (start_row - ptr->cur_start_row); +} + + +/* + * Release all objects belonging to a specified pool. + */ + +METHODDEF(void) +free_pool (j_common_ptr cinfo, int pool_id) +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr shdr_ptr; + large_pool_ptr lhdr_ptr; + size_t space_freed; + + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + +#ifdef MEM_STATS + if (cinfo->err->trace_level > 1) + print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */ +#endif + + /* If freeing IMAGE pool, close any virtual arrays first */ + if (pool_id == JPOOL_IMAGE) { + jvirt_sarray_ptr sptr; + jvirt_barray_ptr bptr; + + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->b_s_open) { /* there may be no backing store */ + sptr->b_s_open = FALSE; /* prevent recursive close if error */ + (*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info); + } + } + mem->virt_sarray_list = NULL; + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->b_s_open) { /* there may be no backing store */ + bptr->b_s_open = FALSE; /* prevent recursive close if error */ + (*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info); + } + } + mem->virt_barray_list = NULL; + } + + /* Release large objects */ + lhdr_ptr = mem->large_list[pool_id]; + mem->large_list[pool_id] = NULL; + + while (lhdr_ptr != NULL) { + large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next; + space_freed = lhdr_ptr->hdr.bytes_used + + lhdr_ptr->hdr.bytes_left + + SIZEOF(large_pool_hdr); + jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); + mem->total_space_allocated -= space_freed; + lhdr_ptr = next_lhdr_ptr; + } + + /* Release small objects */ + shdr_ptr = mem->small_list[pool_id]; + mem->small_list[pool_id] = NULL; + + while (shdr_ptr != NULL) { + small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next; + space_freed = shdr_ptr->hdr.bytes_used + + shdr_ptr->hdr.bytes_left + + SIZEOF(small_pool_hdr); + jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); + mem->total_space_allocated -= space_freed; + shdr_ptr = next_shdr_ptr; + } +} + + +/* + * Close up shop entirely. + * Note that this cannot be called unless cinfo->mem is non-NULL. + */ + +METHODDEF(void) +self_destruct (j_common_ptr cinfo) +{ + int pool; + + /* Close all backing store, release all memory. + * Releasing pools in reverse order might help avoid fragmentation + * with some (brain-damaged) malloc libraries. + */ + for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { + free_pool(cinfo, pool); + } + + /* Release the memory manager control block too. */ + jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr)); + cinfo->mem = NULL; /* ensures I will be called only once */ + + jpeg_mem_term(cinfo); /* system-dependent cleanup */ +} + + +/* + * Memory manager initialization. + * When this is called, only the error manager pointer is valid in cinfo! + */ + +GLOBAL(void) +jinit_memory_mgr (j_common_ptr cinfo) +{ + my_mem_ptr mem; + long max_to_use; + int pool; + size_t test_mac; + + cinfo->mem = NULL; /* for safety if init fails */ + + /* Check for configuration errors. + * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably + * doesn't reflect any real hardware alignment requirement. + * The test is a little tricky: for X>0, X and X-1 have no one-bits + * in common if and only if X is a power of 2, ie has only one one-bit. + * Some compilers may give an "unreachable code" warning here; ignore it. + */ + if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0) + ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE); + /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be + * a multiple of SIZEOF(ALIGN_TYPE). + * Again, an "unreachable code" warning may be ignored here. + * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. + */ + test_mac = (size_t) MAX_ALLOC_CHUNK; + if ((long) test_mac != MAX_ALLOC_CHUNK || + (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + + max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ + + /* Attempt to allocate memory manager's control block */ + mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr)); + + if (mem == NULL) { + jpeg_mem_term(cinfo); /* system-dependent cleanup */ + ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0); + } + + /* OK, fill in the method pointers */ + mem->pub.alloc_small = alloc_small; + mem->pub.alloc_large = alloc_large; + mem->pub.alloc_sarray = alloc_sarray; + mem->pub.alloc_barray = alloc_barray; + mem->pub.request_virt_sarray = request_virt_sarray; + mem->pub.request_virt_barray = request_virt_barray; + mem->pub.realize_virt_arrays = realize_virt_arrays; + mem->pub.access_virt_sarray = access_virt_sarray; + mem->pub.access_virt_barray = access_virt_barray; + mem->pub.free_pool = free_pool; + mem->pub.self_destruct = self_destruct; + + /* Make MAX_ALLOC_CHUNK accessible to other modules */ + mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK; + + /* Initialize working state */ + mem->pub.max_memory_to_use = max_to_use; + + for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { + mem->small_list[pool] = NULL; + mem->large_list[pool] = NULL; + } + mem->virt_sarray_list = NULL; + mem->virt_barray_list = NULL; + + mem->total_space_allocated = SIZEOF(my_memory_mgr); + + /* Declare ourselves open for business */ + cinfo->mem = &mem->pub; + + /* Check for an environment variable JPEGMEM; if found, override the + * default max_memory setting from jpeg_mem_init. Note that the + * surrounding application may again override this value. + * If your system doesn't support getenv(), define NO_GETENV to disable + * this feature. + */ +#ifndef NO_GETENV + { char * memenv; + + if ((memenv = getenv("JPEGMEM")) != NULL) { + char ch = 'x'; + + if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) { + if (ch == 'm' || ch == 'M') + max_to_use *= 1000L; + mem->pub.max_memory_to_use = max_to_use * 1000L; + } + } + } +#endif + +} diff --git a/thirdparty/jpeg-9e/jmemname.c b/thirdparty/jpeg-9e/jmemname.c new file mode 100644 index 0000000..ed96dee --- /dev/null +++ b/thirdparty/jpeg-9e/jmemname.c @@ -0,0 +1,276 @@ +/* + * jmemname.c + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a generic implementation of the system-dependent + * portion of the JPEG memory manager. This implementation assumes that + * you must explicitly construct a name for each temp file. + * Also, the problem of determining the amount of memory available + * is shoved onto the user. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + +#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ +#define SEEK_SET 0 /* if not, assume 0 is correct */ +#endif + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#define RW_BINARY "w+" +#else +#ifdef VMS /* VMS is very nonstandard */ +#define READ_BINARY "rb", "ctx=stm" +#define RW_BINARY "w+b", "ctx=stm" +#else /* standard ANSI-compliant case */ +#define READ_BINARY "rb" +#define RW_BINARY "w+b" +#endif +#endif + + +/* + * Selection of a file name for a temporary file. + * This is system-dependent! + * + * The code as given is suitable for most Unix systems, and it is easily + * modified for most non-Unix systems. Some notes: + * 1. The temp file is created in the directory named by TEMP_DIRECTORY. + * The default value is /usr/tmp, which is the conventional place for + * creating large temp files on Unix. On other systems you'll probably + * want to change the file location. You can do this by editing the + * #define, or (preferred) by defining TEMP_DIRECTORY in jconfig.h. + * + * 2. If you need to change the file name as well as its location, + * you can override the TEMP_FILE_NAME macro. (Note that this is + * actually a printf format string; it must contain %s and %d.) + * Few people should need to do this. + * + * 3. mktemp() is used to ensure that multiple processes running + * simultaneously won't select the same file names. If your system + * doesn't have mktemp(), define NO_MKTEMP to do it the hard way. + * (If you don't have , also define NO_ERRNO_H.) + * + * 4. You probably want to define NEED_SIGNAL_CATCHER so that cjpeg.c/djpeg.c + * will cause the temp files to be removed if you stop the program early. + */ + +#ifndef TEMP_DIRECTORY /* can override from jconfig.h or Makefile */ +#define TEMP_DIRECTORY "/usr/tmp/" /* recommended setting for Unix */ +#endif + +static int next_file_num; /* to distinguish among several temp files */ + +#ifdef NO_MKTEMP + +#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ +#define TEMP_FILE_NAME "%sJPG%03d.TMP" +#endif + +#ifndef NO_ERRNO_H +#include /* to define ENOENT */ +#endif + +/* ANSI C specifies that errno is a macro, but on older systems it's more + * likely to be a plain int variable. And not all versions of errno.h + * bother to declare it, so we have to in order to be most portable. Thus: + */ +#ifndef errno +extern int errno; +#endif + + +LOCAL(void) +select_file_name (char * fname) +{ + FILE * tfile; + + /* Keep generating file names till we find one that's not in use */ + for (;;) { + next_file_num++; /* advance counter */ + sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); + if ((tfile = fopen(fname, READ_BINARY)) == NULL) { + /* fopen could have failed for a reason other than the file not + * being there; for example, file there but unreadable. + * If isn't available, then we cannot test the cause. + */ +#ifdef ENOENT + if (errno != ENOENT) + continue; +#endif + break; + } + fclose(tfile); /* oops, it's there; close tfile & try again */ + } +} + +#else /* ! NO_MKTEMP */ + +/* Note that mktemp() requires the initial filename to end in six X's */ +#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ +#define TEMP_FILE_NAME "%sJPG%dXXXXXX" +#endif + +LOCAL(void) +select_file_name (char * fname) +{ + next_file_num++; /* advance counter */ + sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); + mktemp(fname); /* make sure file name is unique */ + /* mktemp replaces the trailing XXXXXX with a unique string of characters */ +} + +#endif /* NO_MKTEMP */ + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFREAD(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFWRITE(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + fclose(info->temp_file); /* close the file */ + unlink(info->temp_name); /* delete the file */ +/* If your system doesn't have unlink(), use remove() instead. + * remove() is the ANSI-standard name for this function, but if + * your system was ANSI you'd be using jmemansi.c, right? + */ + TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); +} + + +/* + * Initial opening of a backing-store object. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + select_file_name(info->temp_name); + if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL) + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; + TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + next_file_num = 0; /* initialize temp file name generator */ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/thirdparty/jpeg-9e/jmemnobs.c b/thirdparty/jpeg-9e/jmemnobs.c new file mode 100644 index 0000000..a364cd8 --- /dev/null +++ b/thirdparty/jpeg-9e/jmemnobs.c @@ -0,0 +1,113 @@ +/* + * jmemnobs.c + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * Modified 2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a really simple implementation of the system- + * dependent portion of the JPEG memory manager. This implementation + * assumes that no backing-store files are needed: all required space + * can be obtained from malloc(). + * This is very portable in the sense that it'll compile on almost anything, + * but you'd better have lots of main memory (or virtual memory) if you want + * to process big images. + * Note that the max_memory_to_use option is respected by this implementation. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + */ + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + if (cinfo->mem->max_memory_to_use) + return cinfo->mem->max_memory_to_use - already_allocated; + + /* Here we say, "we got all you want bud!" */ + return max_bytes_needed; +} + + +/* + * Backing store (temporary file) management. + * Since jpeg_mem_available always promised the moon, + * this should never be called and we can just error out. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + ERREXIT(cinfo, JERR_NO_BACKING_STORE); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. Here, there isn't any. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + return 0; /* just set max_memory_to_use to 0 */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/thirdparty/jpeg-9e/jmemsys.h b/thirdparty/jpeg-9e/jmemsys.h new file mode 100644 index 0000000..6c3c6d3 --- /dev/null +++ b/thirdparty/jpeg-9e/jmemsys.h @@ -0,0 +1,198 @@ +/* + * jmemsys.h + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This include file defines the interface between the system-independent + * and system-dependent portions of the JPEG memory manager. No other + * modules need include it. (The system-independent portion is jmemmgr.c; + * there are several different versions of the system-dependent portion.) + * + * This file works as-is for the system-dependent memory managers supplied + * in the IJG distribution. You may need to modify it if you write a + * custom memory manager. If system-dependent changes are needed in + * this file, the best method is to #ifdef them based on a configuration + * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR + * and USE_MAC_MEMMGR. + */ + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_get_small jGetSmall +#define jpeg_free_small jFreeSmall +#define jpeg_get_large jGetLarge +#define jpeg_free_large jFreeLarge +#define jpeg_mem_available jMemAvail +#define jpeg_open_backing_store jOpenBackStore +#define jpeg_mem_init jMemInit +#define jpeg_mem_term jMemTerm +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* + * These two functions are used to allocate and release small chunks of + * memory. (Typically the total amount requested through jpeg_get_small is + * no more than 20K or so; this will be requested in chunks of a few K each.) + * Behavior should be the same as for the standard library functions malloc + * and free; in particular, jpeg_get_small must return NULL on failure. + * On most systems, these ARE malloc and free. jpeg_free_small is passed the + * size of the object being freed, just in case it's needed. + * On an 80x86 machine using small-data memory model, these manage near heap. + */ + +EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject)); +EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object, + size_t sizeofobject)); + +/* + * These two functions are used to allocate and release large chunks of + * memory (up to the total free space designated by jpeg_mem_available). + * The interface is the same as above, except that on an 80x86 machine, + * far pointers are used. On most other machines these are identical to + * the jpeg_get/free_small routines; but we keep them separate anyway, + * in case a different allocation strategy is desirable for large chunks. + */ + +EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo, + size_t sizeofobject)); +EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object, + size_t sizeofobject)); + +/* + * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may + * be requested in a single call to jpeg_get_large (and jpeg_get_small for that + * matter, but that case should never come into play). This macro is needed + * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. + * On those machines, we expect that jconfig.h will provide a proper value. + * On machines with 32-bit flat address spaces, any large constant may be used. + * + * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type + * size_t and will be a multiple of sizeof(align_type). + */ + +#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */ +#define MAX_ALLOC_CHUNK 1000000000L +#endif + +/* + * This routine computes the total space still available for allocation by + * jpeg_get_large. If more space than this is needed, backing store will be + * used. NOTE: any memory already allocated must not be counted. + * + * There is a minimum space requirement, corresponding to the minimum + * feasible buffer sizes; jmemmgr.c will request that much space even if + * jpeg_mem_available returns zero. The maximum space needed, enough to hold + * all working storage in memory, is also passed in case it is useful. + * Finally, the total space already allocated is passed. If no better + * method is available, cinfo->mem->max_memory_to_use - already_allocated + * is often a suitable calculation. + * + * It is OK for jpeg_mem_available to underestimate the space available + * (that'll just lead to more backing-store access than is really necessary). + * However, an overestimate will lead to failure. Hence it's wise to subtract + * a slop factor from the true available space. 5% should be enough. + * + * On machines with lots of virtual memory, any large constant may be returned. + * Conversely, zero may be returned to always use the minimum amount of memory. + */ + +EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, + long min_bytes_needed, + long max_bytes_needed, + long already_allocated)); + + +/* + * This structure holds whatever state is needed to access a single + * backing-store object. The read/write/close method pointers are called + * by jmemmgr.c to manipulate the backing-store object; all other fields + * are private to the system-dependent backing store routines. + */ + +#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */ + + +#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */ + +typedef unsigned short XMSH; /* type of extended-memory handles */ +typedef unsigned short EMSH; /* type of expanded-memory handles */ + +typedef union { + short file_handle; /* DOS file handle if it's a temp file */ + XMSH xms_handle; /* handle if it's a chunk of XMS */ + EMSH ems_handle; /* handle if it's a chunk of EMS */ +} handle_union; + +#endif /* USE_MSDOS_MEMMGR */ + +#ifdef USE_MAC_MEMMGR /* Mac-specific junk */ +#include +#endif /* USE_MAC_MEMMGR */ + + +typedef struct backing_store_struct * backing_store_ptr; + +typedef struct backing_store_struct { + /* Methods for reading/writing/closing this backing-store object */ + JMETHOD(void, read_backing_store, (j_common_ptr cinfo, + backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count)); + JMETHOD(void, write_backing_store, (j_common_ptr cinfo, + backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count)); + JMETHOD(void, close_backing_store, (j_common_ptr cinfo, + backing_store_ptr info)); + + /* Private fields for system-dependent backing-store management */ +#ifdef USE_MSDOS_MEMMGR + /* For the MS-DOS manager (jmemdos.c), we need: */ + handle_union handle; /* reference to backing-store storage object */ + char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ +#else +#ifdef USE_MAC_MEMMGR + /* For the Mac manager (jmemmac.c), we need: */ + short temp_file; /* file reference number to temp file */ + FSSpec tempSpec; /* the FSSpec for the temp file */ + char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ +#else + /* For a typical implementation with temp files, we need: */ + FILE * temp_file; /* stdio reference to temp file */ + char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */ +#endif +#endif +} backing_store_info; + + +/* + * Initial opening of a backing-store object. This must fill in the + * read/write/close pointers in the object. The read/write routines + * may take an error exit if the specified maximum file size is exceeded. + * (If jpeg_mem_available always returns a large value, this routine can + * just take an error exit.) + */ + +EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, + backing_store_ptr info, + long total_bytes_needed)); + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. jpeg_mem_init will be called before anything is + * allocated (and, therefore, nothing in cinfo is of use except the error + * manager pointer). It should return a suitable default value for + * max_memory_to_use; this may subsequently be overridden by the surrounding + * application. (Note that max_memory_to_use is only important if + * jpeg_mem_available chooses to consult it ... no one else will.) + * jpeg_mem_term may assume that all requested memory has been freed and that + * all opened backing-store objects have been closed. + */ + +EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); +EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); diff --git a/thirdparty/jpeg-9e/jmorecfg.h b/thirdparty/jpeg-9e/jmorecfg.h new file mode 100644 index 0000000..679d68b --- /dev/null +++ b/thirdparty/jpeg-9e/jmorecfg.h @@ -0,0 +1,446 @@ +/* + * jmorecfg.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 1997-2013 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains additional configuration options that customize the + * JPEG software for special applications or support machine-dependent + * optimizations. Most users will not need to touch this file. + */ + + +/* + * Define BITS_IN_JSAMPLE as either + * 8 for 8-bit sample values (the usual setting) + * 9 for 9-bit sample values + * 10 for 10-bit sample values + * 11 for 11-bit sample values + * 12 for 12-bit sample values + * Only 8, 9, 10, 11, and 12 bits sample data precision are supported for + * full-feature DCT processing. Further depths up to 16-bit may be added + * later for the lossless modes of operation. + * Run-time selection and conversion of data precision will be added later + * and are currently not supported, sorry. + * Exception: The transcoding part (jpegtran) supports all settings in a + * single instance, since it operates on the level of DCT coefficients and + * not sample values. The DCT coefficients are of the same type (16 bits) + * in all cases (see below). + */ + +#define BITS_IN_JSAMPLE 8 /* use 8, 9, 10, 11, or 12 */ + + +/* + * Maximum number of components (color channels) allowed in JPEG image. + * To meet the letter of the JPEG spec, set this to 255. However, darn + * few applications need more than 4 channels (maybe 5 for CMYK + alpha + * mask). We recommend 10 as a reasonable compromise; use 4 if you are + * really short on memory. (Each allowed component costs a hundred or so + * bytes of storage, whether actually used in an image or not.) + */ + +#define MAX_COMPONENTS 10 /* maximum number of image components */ + + +/* + * Basic data types. + * You may need to change these if you have a machine with unusual data + * type sizes; for example, "char" not 8 bits, "short" not 16 bits, + * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, + * but it had better be at least 16. + */ + +/* Representation of a single sample (pixel element value). + * We frequently allocate large arrays of these, so it's important to keep + * them small. But if you have memory to burn and access to char or short + * arrays is very slow on your hardware, you might want to change these. + */ + +#if BITS_IN_JSAMPLE == 8 +/* JSAMPLE should be the smallest type that will hold the values 0..255. + * You can use a signed char by having GETJSAMPLE mask it with 0xFF. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JSAMPLE; +#ifdef CHAR_IS_UNSIGNED +#define GETJSAMPLE(value) ((int) (value)) +#else +#define GETJSAMPLE(value) ((int) (value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + +#define MAXJSAMPLE 255 +#define CENTERJSAMPLE 128 + +#endif /* BITS_IN_JSAMPLE == 8 */ + + +#if BITS_IN_JSAMPLE == 9 +/* JSAMPLE should be the smallest type that will hold the values 0..511. + * On nearly all machines "short" will do nicely. + */ + +typedef short JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#define MAXJSAMPLE 511 +#define CENTERJSAMPLE 256 + +#endif /* BITS_IN_JSAMPLE == 9 */ + + +#if BITS_IN_JSAMPLE == 10 +/* JSAMPLE should be the smallest type that will hold the values 0..1023. + * On nearly all machines "short" will do nicely. + */ + +typedef short JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#define MAXJSAMPLE 1023 +#define CENTERJSAMPLE 512 + +#endif /* BITS_IN_JSAMPLE == 10 */ + + +#if BITS_IN_JSAMPLE == 11 +/* JSAMPLE should be the smallest type that will hold the values 0..2047. + * On nearly all machines "short" will do nicely. + */ + +typedef short JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#define MAXJSAMPLE 2047 +#define CENTERJSAMPLE 1024 + +#endif /* BITS_IN_JSAMPLE == 11 */ + + +#if BITS_IN_JSAMPLE == 12 +/* JSAMPLE should be the smallest type that will hold the values 0..4095. + * On nearly all machines "short" will do nicely. + */ + +typedef short JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#define MAXJSAMPLE 4095 +#define CENTERJSAMPLE 2048 + +#endif /* BITS_IN_JSAMPLE == 12 */ + + +/* Representation of a DCT frequency coefficient. + * This should be a signed value of at least 16 bits; "short" is usually OK. + * Again, we allocate large arrays of these, but you can change to int + * if you have memory to burn and "short" is really slow. + */ + +typedef short JCOEF; + + +/* Compressed datastreams are represented as arrays of JOCTET. + * These must be EXACTLY 8 bits wide, at least once they are written to + * external storage. Note that when using the stdio data source/destination + * managers, this is also the data type passed to fread/fwrite. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JOCTET; +#define GETJOCTET(value) (value) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JOCTET; +#ifdef CHAR_IS_UNSIGNED +#define GETJOCTET(value) (value) +#else +#define GETJOCTET(value) ((value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + + +/* These typedefs are used for various table entries and so forth. + * They must be at least as wide as specified; but making them too big + * won't cost a huge amount of memory, so we don't provide special + * extraction code like we did for JSAMPLE. (In other words, these + * typedefs live at a different point on the speed/space tradeoff curve.) + */ + +/* UINT8 must hold at least the values 0..255. */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char UINT8; +#else /* not HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char UINT8; +#else /* not CHAR_IS_UNSIGNED */ +typedef short UINT8; +#endif /* CHAR_IS_UNSIGNED */ +#endif /* HAVE_UNSIGNED_CHAR */ + +/* UINT16 must hold at least the values 0..65535. */ + +#ifdef HAVE_UNSIGNED_SHORT +typedef unsigned short UINT16; +#else /* not HAVE_UNSIGNED_SHORT */ +typedef unsigned int UINT16; +#endif /* HAVE_UNSIGNED_SHORT */ + +/* INT16 must hold at least the values -32768..32767. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ +typedef short INT16; +#endif + +/* INT32 must hold at least signed 32-bit values. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ +#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */ +#ifndef _BASETSD_H /* MinGW is slightly different */ +#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */ +typedef long INT32; +#endif +#endif +#endif +#endif + +/* Datatype used for image dimensions. The JPEG standard only supports + * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore + * "unsigned int" is sufficient on all machines. However, if you need to + * handle larger images and you don't mind deviating from the spec, you + * can change this datatype. + */ + +typedef unsigned int JDIMENSION; + +#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ + + +/* These macros are used in all function definitions and extern declarations. + * You could modify them if you need to change function linkage conventions; + * in particular, you'll need to do that to make the library a Windows DLL. + * Another application is to make all functions global for use with debuggers + * or code profilers that require it. + */ + +/* a function called through method pointers: */ +#define METHODDEF(type) static type +/* a function used only in its module: */ +#define LOCAL(type) static type +/* a function referenced thru EXTERNs: */ +#define GLOBAL(type) type +/* a reference to a GLOBAL function: */ +#define EXTERN(type) extern type + + +/* This macro is used to declare a "method", that is, a function pointer. + * We want to supply prototype parameters if the compiler can cope. + * Note that the arglist parameter must be parenthesized! + * Again, you can customize this if you need special linkage keywords. + */ + +#ifdef HAVE_PROTOTYPES +#define JMETHOD(type,methodname,arglist) type (*methodname) arglist +#else +#define JMETHOD(type,methodname,arglist) type (*methodname) () +#endif + + +/* The noreturn type identifier is used to declare functions + * which cannot return. + * Compilers can thus create more optimized code and perform + * better checks for warnings and errors. + * Static analyzer tools can make improved inferences about + * execution paths and are prevented from giving false alerts. + * + * Unfortunately, the proposed specifications of corresponding + * extensions in the Dec 2011 ISO C standard revision (C11), + * GCC, MSVC, etc. are not viable. + * Thus we introduce a user defined type to declare noreturn + * functions at least for clarity. A proper compiler would + * have a suitable noreturn type to match in place of void. + */ + +#ifndef HAVE_NORETURN_T +typedef void noreturn_t; +#endif + + +/* Here is the pseudo-keyword for declaring pointers that must be "far" + * on 80x86 machines. Most of the specialized coding for 80x86 is handled + * by just saying "FAR *" where such a pointer is needed. In a few places + * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. + */ + +#ifndef FAR +#ifdef NEED_FAR_POINTERS +#define FAR far +#else +#define FAR +#endif +#endif + + +/* + * On a few systems, type boolean and/or its values FALSE, TRUE may appear + * in standard header files. Or you may have conflicts with application- + * specific header files that you want to include together with these files. + * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. + */ + +#ifndef HAVE_BOOLEAN +#if defined FALSE || defined TRUE || defined QGLOBAL_H +/* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */ +typedef int boolean; +#ifndef FALSE /* in case these macros already exist */ +#define FALSE 0 /* values of boolean */ +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#else +typedef enum { FALSE = 0, TRUE = 1 } boolean; +#endif +#endif + + +/* + * The remaining options affect code selection within the JPEG library, + * but they don't need to be visible to most applications using the library. + * To minimize application namespace pollution, the symbols won't be + * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. + */ + +#ifdef JPEG_INTERNALS +#define JPEG_INTERNAL_OPTIONS +#endif + +#ifdef JPEG_INTERNAL_OPTIONS + + +/* + * These defines indicate whether to include various optional functions. + * Undefining some of these symbols will produce a smaller but less capable + * library. Note that you can leave certain source files out of the + * compilation/linking process if you've #undef'd the corresponding symbols. + * (You may HAVE to do that if your compiler doesn't like null source files.) + */ + +/* Capability options common to encoder and decoder: */ + +#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ +#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ +#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ + +/* Encoder capability options: */ + +#define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/ +#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ +/* Note: if you selected more than 8-bit data precision, it is dangerous to + * turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only + * good for 8-bit precision, so arithmetic coding is recommended for higher + * precision. The Huffman encoder normally uses entropy optimization to + * compute usable tables for higher precision. Otherwise, you'll have to + * supply different default Huffman tables. + * The exact same statements apply for progressive JPEG: the default tables + * don't work for progressive mode. (This may get fixed, however.) + */ +#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ + +/* Decoder capability options: */ + +#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW)*/ +#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ +#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ +#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ +#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ +#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ +#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ + +/* more capability options later, no doubt */ + + +/* + * Ordering of RGB data in scanlines passed to or from the application. + * If your application wants to deal with data in the order B,G,R, just + * change these macros. You can also deal with formats such as R,G,B,X + * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing + * the offsets will also change the order in which colormap data is organized. + * RESTRICTIONS: + * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. + * 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE + * is not 3 (they don't understand about dummy color components!). So you + * can't use color quantization if you change that value. + */ + +#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ +#define RGB_GREEN 1 /* Offset of Green */ +#define RGB_BLUE 2 /* Offset of Blue */ +#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ + + +/* Definitions for speed-related optimizations. */ + + +/* If your compiler supports inline functions, define INLINE + * as the inline keyword; otherwise define it as empty. + */ + +#ifndef INLINE +#ifdef __GNUC__ /* for instance, GNU C knows about inline */ +#define INLINE __inline__ +#endif +#ifndef INLINE +#define INLINE /* default is to define it as empty */ +#endif +#endif + + +/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying + * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER + * as short on such a machine. MULTIPLIER must be at least 16 bits wide. + */ + +#ifndef MULTIPLIER +#define MULTIPLIER int /* type for fastest integer multiply */ +#endif + + +/* FAST_FLOAT should be either float or double, whichever is done faster + * by your compiler. (Note that this type is only used in the floating point + * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) + * Typically, float is faster in ANSI C compilers, while double is faster in + * pre-ANSI compilers (because they insist on converting to double anyway). + * The code below therefore chooses float if we have ANSI-style prototypes. + */ + +#ifndef FAST_FLOAT +#ifdef HAVE_PROTOTYPES +#define FAST_FLOAT float +#else +#define FAST_FLOAT double +#endif +#endif + +#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/thirdparty/jpeg-9e/jpegint.h b/thirdparty/jpeg-9e/jpegint.h new file mode 100644 index 0000000..3528bff --- /dev/null +++ b/thirdparty/jpeg-9e/jpegint.h @@ -0,0 +1,445 @@ +/* + * jpegint.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 1997-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides common declarations for the various JPEG modules. + * These declarations are considered internal to the JPEG library; most + * applications using the library shouldn't need to include this file. + */ + + +/* Declarations for both compression & decompression */ + +typedef enum { /* Operating modes for buffer controllers */ + JBUF_PASS_THRU, /* Plain stripwise operation */ + /* Remaining modes require a full-image buffer to have been created */ + JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ + JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ + JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ +} J_BUF_MODE; + +/* Values of global_state field (jdapi.c has some dependencies on ordering!) */ +#define CSTATE_START 100 /* after create_compress */ +#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ +#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ +#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ +#define DSTATE_START 200 /* after create_decompress */ +#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ +#define DSTATE_READY 202 /* found SOS, ready for start_decompress */ +#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ +#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ +#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ +#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ +#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ +#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ +#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ +#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ + + +/* Declarations for compression modules */ + +/* Master control module */ +struct jpeg_comp_master { + JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo)); + JMETHOD(void, pass_startup, (j_compress_ptr cinfo)); + JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean call_pass_startup; /* True if pass_startup must be called */ + boolean is_last_pass; /* True during last pass */ +}; + +/* Main buffer control (downsampled-data buffer) */ +struct jpeg_c_main_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, process_data, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail)); +}; + +/* Compression preprocessing (downsampling input buffer control) */ +struct jpeg_c_prep_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, pre_process_data, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, + JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail)); +}; + +/* Coefficient buffer control */ +struct jpeg_c_coef_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(boolean, compress_data, (j_compress_ptr cinfo, + JSAMPIMAGE input_buf)); +}; + +/* Colorspace conversion */ +struct jpeg_color_converter { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + JMETHOD(void, color_convert, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows)); +}; + +/* Downsampling */ +struct jpeg_downsampler { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + JMETHOD(void, downsample, (j_compress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_index, + JSAMPIMAGE output_buf, + JDIMENSION out_row_group_index)); + + boolean need_context_rows; /* TRUE if need rows above & below */ +}; + +/* Forward DCT (also controls coefficient quantization) */ +typedef JMETHOD(void, forward_DCT_ptr, + (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_col, JDIMENSION num_blocks)); + +struct jpeg_forward_dct { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + /* It is useful to allow each component to have a separate FDCT method. */ + forward_DCT_ptr forward_DCT[MAX_COMPONENTS]; +}; + +/* Entropy encoding */ +struct jpeg_entropy_encoder { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); + JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)); + JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); +}; + +/* Marker writing */ +struct jpeg_marker_writer { + JMETHOD(void, write_file_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_frame_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_scan_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo)); + JMETHOD(void, write_tables_only, (j_compress_ptr cinfo)); + /* These routines are exported to allow insertion of extra markers */ + /* Probably only COM and APPn markers should be written this way */ + JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker, + unsigned int datalen)); + JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val)); +}; + + +/* Declarations for decompression modules */ + +/* Master control module */ +struct jpeg_decomp_master { + JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ +}; + +/* Input control module */ +struct jpeg_input_controller { + JMETHOD(int, consume_input, (j_decompress_ptr cinfo)); + JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo)); + JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean has_multiple_scans; /* True if file has multiple scans */ + boolean eoi_reached; /* True when EOI has been consumed */ +}; + +/* Main buffer control (downsampled-data buffer) */ +struct jpeg_d_main_controller { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, process_data, (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +}; + +/* Coefficient buffer control */ +struct jpeg_d_coef_controller { + JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); + JMETHOD(int, consume_data, (j_decompress_ptr cinfo)); + JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo)); + JMETHOD(int, decompress_data, (j_decompress_ptr cinfo, + JSAMPIMAGE output_buf)); + /* Pointer to array of coefficient virtual arrays, or NULL if none */ + jvirt_barray_ptr *coef_arrays; +}; + +/* Decompression postprocessing (color quantization buffer control) */ +struct jpeg_d_post_controller { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, post_process_data, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, + JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +}; + +/* Marker reading & parsing */ +struct jpeg_marker_reader { + JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo)); + /* Read markers until SOS or EOI. + * Returns same codes as are defined for jpeg_consume_input: + * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + */ + JMETHOD(int, read_markers, (j_decompress_ptr cinfo)); + /* Read a restart marker --- exported for use by entropy decoder only */ + jpeg_marker_parser_method read_restart_marker; + + /* State of marker reader --- nominally internal, but applications + * supplying COM or APPn handlers might like to know the state. + */ + boolean saw_SOI; /* found SOI? */ + boolean saw_SOF; /* found SOF? */ + int next_restart_num; /* next restart number expected (0-7) */ + unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ +}; + +/* Entropy decoding */ +struct jpeg_entropy_decoder { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)); + JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); +}; + +/* Inverse DCT (also performs dequantization) */ +typedef JMETHOD(void, inverse_DCT_method_ptr, + (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col)); + +struct jpeg_inverse_dct { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + /* It is useful to allow each component to have a separate IDCT method. */ + inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; +}; + +/* Upsampling (note that upsampler must also call color converter) */ +struct jpeg_upsampler { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, upsample, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, + JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); + + boolean need_context_rows; /* TRUE if need rows above & below */ +}; + +/* Colorspace conversion */ +struct jpeg_color_deconverter { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, color_convert, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows)); +}; + +/* Color quantization or color precision reduction */ +struct jpeg_color_quantizer { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan)); + JMETHOD(void, color_quantize, (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, + int num_rows)); + JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, new_color_map, (j_decompress_ptr cinfo)); +}; + + +/* Definition of range extension bits for decompression processes. + * See the comments with prepare_range_limit_table (in jdmaster.c) + * for more info. + * The recommended default value for normal applications is 2. + * Applications with special requirements may use a different value. + * For example, Ghostscript wants to use 3 for proper handling of + * wacky images with oversize coefficient values. + */ + +#define RANGE_BITS 2 +#define RANGE_CENTER (CENTERJSAMPLE << RANGE_BITS) + + +/* Miscellaneous useful macros */ + +#undef MAX +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#undef MIN +#define MIN(a,b) ((a) < (b) ? (a) : (b)) + + +/* We assume that right shift corresponds to signed division by 2 with + * rounding towards minus infinity. This is correct for typical "arithmetic + * shift" instructions that shift in copies of the sign bit. But some + * C compilers implement >> with an unsigned shift. For these machines you + * must define RIGHT_SHIFT_IS_UNSIGNED. + * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity. + * It is only applied with constant shift counts. SHIFT_TEMPS must be + * included in the variables of any routine using RIGHT_SHIFT. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define SHIFT_TEMPS INT32 shift_temp; +#define RIGHT_SHIFT(x,shft) \ + ((shift_temp = (x)) < 0 ? \ + (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \ + (shift_temp >> (shft))) +#else +#define SHIFT_TEMPS +#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + +/* Descale and correctly round an INT32 value that's scaled by N bits. + * We assume RIGHT_SHIFT rounds towards minus infinity, so adding + * the fudge factor is correct for either sign of X. + */ + +#define DESCALE(x,n) RIGHT_SHIFT((x) + ((INT32) 1 << ((n)-1)), n) + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jinit_compress_master jICompress +#define jinit_c_master_control jICMaster +#define jinit_c_main_controller jICMainC +#define jinit_c_prep_controller jICPrepC +#define jinit_c_coef_controller jICCoefC +#define jinit_color_converter jICColor +#define jinit_downsampler jIDownsampler +#define jinit_forward_dct jIFDCT +#define jinit_huff_encoder jIHEncoder +#define jinit_arith_encoder jIAEncoder +#define jinit_marker_writer jIMWriter +#define jinit_master_decompress jIDMaster +#define jinit_d_main_controller jIDMainC +#define jinit_d_coef_controller jIDCoefC +#define jinit_d_post_controller jIDPostC +#define jinit_input_controller jIInCtlr +#define jinit_marker_reader jIMReader +#define jinit_huff_decoder jIHDecoder +#define jinit_arith_decoder jIADecoder +#define jinit_inverse_dct jIIDCT +#define jinit_upsampler jIUpsampler +#define jinit_color_deconverter jIDColor +#define jinit_1pass_quantizer jI1Quant +#define jinit_2pass_quantizer jI2Quant +#define jinit_merged_upsampler jIMUpsampler +#define jinit_memory_mgr jIMemMgr +#define jdiv_round_up jDivRound +#define jround_up jRound +#define jzero_far jZeroFar +#define jcopy_sample_rows jCopySamples +#define jcopy_block_row jCopyBlocks +#define jpeg_zigzag_order jZIGTable +#define jpeg_natural_order jZAGTable +#define jpeg_natural_order7 jZAG7Table +#define jpeg_natural_order6 jZAG6Table +#define jpeg_natural_order5 jZAG5Table +#define jpeg_natural_order4 jZAG4Table +#define jpeg_natural_order3 jZAG3Table +#define jpeg_natural_order2 jZAG2Table +#define jpeg_aritab jAriTab +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays + * and coefficient-block arrays. This won't work on 80x86 because the arrays + * are FAR and we're assuming a small-pointer memory model. However, some + * DOS compilers provide far-pointer versions of memcpy() and memset() even + * in the small-model libraries. These will be used if USE_FMEM is defined. + * Otherwise, the routines in jutils.c do it the hard way. + */ + +#ifndef NEED_FAR_POINTERS /* normal case, same as regular macro */ +#define FMEMZERO(target,size) MEMZERO(target,size) +#else /* 80x86 case */ +#ifdef USE_FMEM +#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) +#else +EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); +#define FMEMZERO(target,size) jzero_far(target, size) +#endif +#endif + + +/* Compression module initialization routines */ +EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, + boolean transcode_only)); +EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_arith_encoder JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); +/* Decompression module initialization routines */ +EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_arith_decoder JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); +/* Memory manager initialization */ +EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); + +/* Utility routines in jutils.c */ +EXTERN(long) jdiv_round_up JPP((long a, long b)); +EXTERN(long) jround_up JPP((long a, long b)); +EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, + JSAMPARRAY output_array, + int num_rows, JDIMENSION num_cols)); +EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, + JDIMENSION num_blocks)); +/* Constant tables in jutils.c */ +#if 0 /* This table is not actually needed in v6a */ +extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ +#endif +extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ +extern const int jpeg_natural_order7[]; /* zz to natural order for 7x7 block */ +extern const int jpeg_natural_order6[]; /* zz to natural order for 6x6 block */ +extern const int jpeg_natural_order5[]; /* zz to natural order for 5x5 block */ +extern const int jpeg_natural_order4[]; /* zz to natural order for 4x4 block */ +extern const int jpeg_natural_order3[]; /* zz to natural order for 3x3 block */ +extern const int jpeg_natural_order2[]; /* zz to natural order for 2x2 block */ + +/* Arithmetic coding probability estimation tables in jaricom.c */ +extern const INT32 jpeg_aritab[]; + +/* Suppress undefined-structure complaints if necessary. */ + +#ifdef INCOMPLETE_TYPES_BROKEN +#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */ +struct jvirt_sarray_control { long dummy; }; +struct jvirt_barray_control { long dummy; }; +#endif +#endif /* INCOMPLETE_TYPES_BROKEN */ diff --git a/thirdparty/jpeg-9e/jpeglib.h b/thirdparty/jpeg-9e/jpeglib.h new file mode 100644 index 0000000..b1fa8ea --- /dev/null +++ b/thirdparty/jpeg-9e/jpeglib.h @@ -0,0 +1,1183 @@ +/* + * jpeglib.h + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * Modified 2002-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the application interface for the JPEG library. + * Most applications using the library need only include this file, + * and perhaps jerror.h if they want to know the exact error codes. + */ + +#ifndef JPEGLIB_H +#define JPEGLIB_H + +/* + * First we include the configuration files that record how this + * installation of the JPEG library is set up. jconfig.h can be + * generated automatically for many systems. jmorecfg.h contains + * manual configuration options that most people need not worry about. + */ + +#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ +#include "jconfig.h" /* widely used configuration options */ +#endif +#include "jmorecfg.h" /* seldom changed options */ + + +#ifdef __cplusplus +#ifndef DONT_USE_EXTERN_C +extern "C" { +#endif +#endif + +/* Version IDs for the JPEG library. + * Might be useful for tests like "#if JPEG_LIB_VERSION >= 90". + */ + +#define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */ +#define JPEG_LIB_VERSION_MAJOR 9 +#define JPEG_LIB_VERSION_MINOR 5 + + +/* Various constants determining the sizes of things. + * All of these are specified by the JPEG standard, + * so don't change them if you want to be compatible. + */ + +#define DCTSIZE 8 /* The basic DCT block is 8x8 coefficients */ +#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ +#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ +#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ +#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ +#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ +#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ +/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; + * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. + * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU + * to handle it. We even let you do this from the jconfig.h file. However, + * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe + * sometimes emits noncompliant files doesn't mean you should too. + */ +#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ +#ifndef D_MAX_BLOCKS_IN_MCU +#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ +#endif + + +/* Data structures for images (arrays of samples and of DCT coefficients). + * On 80x86 machines, the image arrays are too big for near pointers, + * but the pointer arrays can fit in near memory. + */ + +typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ +typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ +typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ + +typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ +typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ +typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ +typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ + +typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ + + +/* Types for JPEG compression parameters and working tables. */ + + +/* DCT coefficient quantization tables. */ + +typedef struct { + /* This array gives the coefficient quantizers in natural array order + * (not the zigzag order in which they are stored in a JPEG DQT marker). + * CAUTION: IJG versions prior to v6a kept this array in zigzag order. + */ + UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JQUANT_TBL; + + +/* Huffman coding tables. */ + +typedef struct { + /* These two fields directly represent the contents of a JPEG DHT marker */ + UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ + /* length k bits; bits[0] is unused */ + UINT8 huffval[256]; /* The symbols, in order of incr code length */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JHUFF_TBL; + + +/* Basic info about one component (color channel). */ + +typedef struct { + /* These values are fixed over the whole image. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOF marker. */ + int component_id; /* identifier for this component (0..255) */ + int component_index; /* its index in SOF or cinfo->comp_info[] */ + int h_samp_factor; /* horizontal sampling factor (1..4) */ + int v_samp_factor; /* vertical sampling factor (1..4) */ + int quant_tbl_no; /* quantization table selector (0..3) */ + /* These values may vary between scans. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOS marker. */ + /* The decompressor output side may not use these variables. */ + int dc_tbl_no; /* DC entropy table selector (0..3) */ + int ac_tbl_no; /* AC entropy table selector (0..3) */ + + /* Remaining fields should be treated as private by applications. */ + + /* These values are computed during compression or decompression startup: */ + /* Component's size in DCT blocks. + * Any dummy blocks added to complete an MCU are not counted; therefore + * these values do not depend on whether a scan is interleaved or not. + */ + JDIMENSION width_in_blocks; + JDIMENSION height_in_blocks; + /* Size of a DCT block in samples, + * reflecting any scaling we choose to apply during the DCT step. + * Values from 1 to 16 are supported. + * Note that different components may receive different DCT scalings. + */ + int DCT_h_scaled_size; + int DCT_v_scaled_size; + /* The downsampled dimensions are the component's actual, unpadded number + * of samples at the main buffer (preprocessing/compression interface); + * DCT scaling is included, so + * downsampled_width = + * ceil(image_width * Hi/Hmax * DCT_h_scaled_size/block_size) + * and similarly for height. + */ + JDIMENSION downsampled_width; /* actual width in samples */ + JDIMENSION downsampled_height; /* actual height in samples */ + /* For decompression, in cases where some of the components will be + * ignored (eg grayscale output from YCbCr image), we can skip most + * computations for the unused components. + * For compression, some of the components will need further quantization + * scale by factor of 2 after DCT (eg BG_YCC output from normal RGB input). + * The field is first set TRUE for decompression, FALSE for compression + * in initial_setup, and then adapted in color conversion setup. + */ + boolean component_needed; + + /* These values are computed before starting a scan of the component. */ + /* The decompressor output side may not use these variables. */ + int MCU_width; /* number of blocks per MCU, horizontally */ + int MCU_height; /* number of blocks per MCU, vertically */ + int MCU_blocks; /* MCU_width * MCU_height */ + int MCU_sample_width; /* MCU width in samples: MCU_width * DCT_h_scaled_size */ + int last_col_width; /* # of non-dummy blocks across in last MCU */ + int last_row_height; /* # of non-dummy blocks down in last MCU */ + + /* Saved quantization table for component; NULL if none yet saved. + * See jdinput.c comments about the need for this information. + * This field is currently used only for decompression. + */ + JQUANT_TBL * quant_table; + + /* Private per-component storage for DCT or IDCT subsystem. */ + void * dct_table; +} jpeg_component_info; + + +/* The script for encoding a multiple-scan file is an array of these: */ + +typedef struct { + int comps_in_scan; /* number of components encoded in this scan */ + int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ + int Ss, Se; /* progressive JPEG spectral selection parms */ + int Ah, Al; /* progressive JPEG successive approx. parms */ +} jpeg_scan_info; + +/* The decompressor can save APPn and COM markers in a list of these: */ + +typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; + +struct jpeg_marker_struct { + jpeg_saved_marker_ptr next; /* next in list, or NULL */ + UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ + unsigned int original_length; /* # bytes of data in the file */ + unsigned int data_length; /* # bytes of data saved at data[] */ + JOCTET FAR * data; /* the data contained in the marker */ + /* the marker length word is not counted in data_length or original_length */ +}; + +/* Known color spaces. */ + +typedef enum { + JCS_UNKNOWN, /* error/unspecified */ + JCS_GRAYSCALE, /* monochrome */ + JCS_RGB, /* red/green/blue, standard RGB (sRGB) */ + JCS_YCbCr, /* Y/Cb/Cr (also known as YUV), standard YCC */ + JCS_CMYK, /* C/M/Y/K */ + JCS_YCCK, /* Y/Cb/Cr/K */ + JCS_BG_RGB, /* big gamut red/green/blue, bg-sRGB */ + JCS_BG_YCC /* big gamut Y/Cb/Cr, bg-sYCC */ +} J_COLOR_SPACE; + +/* Supported color transforms. */ + +typedef enum { + JCT_NONE = 0, + JCT_SUBTRACT_GREEN = 1 +} J_COLOR_TRANSFORM; + +/* DCT/IDCT algorithm options. */ + +typedef enum { + JDCT_ISLOW, /* slow but accurate integer algorithm */ + JDCT_IFAST, /* faster, less accurate integer method */ + JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ +} J_DCT_METHOD; + +#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ +#define JDCT_DEFAULT JDCT_ISLOW +#endif +#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ +#define JDCT_FASTEST JDCT_IFAST +#endif + +/* Dithering options for decompression. */ + +typedef enum { + JDITHER_NONE, /* no dithering */ + JDITHER_ORDERED, /* simple ordered dither */ + JDITHER_FS /* Floyd-Steinberg error diffusion dither */ +} J_DITHER_MODE; + + +/* Common fields between JPEG compression and decompression master structs. */ + +#define jpeg_common_fields \ + struct jpeg_error_mgr * err; /* Error handler module */\ + struct jpeg_memory_mgr * mem; /* Memory manager module */\ + struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ + void * client_data; /* Available for use by application */\ + boolean is_decompressor; /* So common code can tell which is which */\ + int global_state /* For checking call sequence validity */ + +/* Routines that are to be used by both halves of the library are declared + * to receive a pointer to this structure. There are no actual instances of + * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. + */ +struct jpeg_common_struct { + jpeg_common_fields; /* Fields common to both master struct types */ + /* Additional fields follow in an actual jpeg_compress_struct or + * jpeg_decompress_struct. All three structs must agree on these + * initial fields! (This would be a lot cleaner in C++.) + */ +}; + +typedef struct jpeg_common_struct * j_common_ptr; +typedef struct jpeg_compress_struct * j_compress_ptr; +typedef struct jpeg_decompress_struct * j_decompress_ptr; + + +/* Master record for a compression instance */ + +struct jpeg_compress_struct { + jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ + + /* Destination for compressed data */ + struct jpeg_destination_mgr * dest; + + /* Description of source image --- these fields must be filled in by + * outer application before starting compression. in_color_space must + * be correct before you can even call jpeg_set_defaults(). + */ + + JDIMENSION image_width; /* input image width */ + JDIMENSION image_height; /* input image height */ + int input_components; /* # of color components in input image */ + J_COLOR_SPACE in_color_space; /* colorspace of input image */ + + double input_gamma; /* image gamma of input image */ + + /* Compression parameters --- these fields must be set before calling + * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to + * initialize everything to reasonable defaults, then changing anything + * the application specifically wants to change. That way you won't get + * burnt when new parameters are added. Also note that there are several + * helper routines to simplify changing parameters. + */ + + unsigned int scale_num, scale_denom; /* fraction by which to scale image */ + + JDIMENSION jpeg_width; /* scaled JPEG image width */ + JDIMENSION jpeg_height; /* scaled JPEG image height */ + /* Dimensions of actual JPEG image that will be written to file, + * derived from input dimensions by scaling factors above. + * These fields are computed by jpeg_start_compress(). + * You can also use jpeg_calc_jpeg_dimensions() to determine these values + * in advance of calling jpeg_start_compress(). + */ + + int data_precision; /* bits of precision in image data */ + + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + int q_scale_factor[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined, + * and corresponding scale factors (percentage, initialized 100). + */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + int num_scans; /* # of entries in scan_info array */ + const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ + /* The default value of scan_info is NULL, which causes a single-scan + * sequential JPEG file to be emitted. To create a multi-scan file, + * set num_scans and scan_info to point to an array of scan definitions. + */ + + boolean raw_data_in; /* TRUE=caller supplies downsampled data */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */ + int smoothing_factor; /* 1..100, or 0 for no input smoothing */ + J_DCT_METHOD dct_method; /* DCT algorithm selector */ + + /* The restart interval can be specified in absolute MCUs by setting + * restart_interval, or in MCU rows by setting restart_in_rows + * (in which case the correct restart_interval will be figured + * for each scan). + */ + unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ + int restart_in_rows; /* if > 0, MCU rows per restart interval */ + + /* Parameters controlling emission of special markers. */ + + boolean write_JFIF_header; /* should a JFIF marker be written? */ + UINT8 JFIF_major_version; /* What to write for the JFIF version number */ + UINT8 JFIF_minor_version; + /* These three values are not used by the JPEG code, merely copied */ + /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ + /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ + /* ratio is defined by X_density/Y_density even when density_unit=0. */ + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean write_Adobe_marker; /* should an Adobe marker be written? */ + + J_COLOR_TRANSFORM color_transform; + /* Color transform identifier, writes LSE marker if nonzero */ + + /* State variable: index of next scanline to be written to + * jpeg_write_scanlines(). Application may use this to control its + * processing loop, e.g., "while (next_scanline < image_height)". + */ + + JDIMENSION next_scanline; /* 0 .. image_height-1 */ + + /* Remaining fields are known throughout compressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during compression startup + */ + boolean progressive_mode; /* TRUE if scan script uses progressive mode */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */ + int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ + /* The coefficient controller receives data in units of MCU rows as defined + * for fully interleaved scans (whether the JPEG file is interleaved or not). + * There are v_samp_factor * DCT_v_scaled_size sample rows of each component + * in an "iMCU" (interleaved MCU) row. + */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[C_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + int block_size; /* the basic DCT block size: 1..16 */ + const int * natural_order; /* natural-order position array */ + int lim_Se; /* min( Se, DCTSIZE2-1 ) */ + + /* + * Links to compression subobjects (methods and private variables of modules) + */ + struct jpeg_comp_master * master; + struct jpeg_c_main_controller * main; + struct jpeg_c_prep_controller * prep; + struct jpeg_c_coef_controller * coef; + struct jpeg_marker_writer * marker; + struct jpeg_color_converter * cconvert; + struct jpeg_downsampler * downsample; + struct jpeg_forward_dct * fdct; + struct jpeg_entropy_encoder * entropy; + jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ + int script_space_size; +}; + + +/* Master record for a decompression instance */ + +struct jpeg_decompress_struct { + jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ + + /* Source of compressed data */ + struct jpeg_source_mgr * src; + + /* Basic description of image --- filled in by jpeg_read_header(). */ + /* Application may inspect these values to decide how to process image. */ + + JDIMENSION image_width; /* nominal image width (from SOF marker) */ + JDIMENSION image_height; /* nominal image height */ + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + /* Decompression processing parameters --- these fields must be set before + * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes + * them to default values. + */ + + J_COLOR_SPACE out_color_space; /* colorspace for output */ + + unsigned int scale_num, scale_denom; /* fraction by which to scale image */ + + double output_gamma; /* image gamma wanted in output */ + + boolean buffered_image; /* TRUE=multiple output passes */ + boolean raw_data_out; /* TRUE=downsampled data wanted */ + + J_DCT_METHOD dct_method; /* IDCT algorithm selector */ + boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ + boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ + + boolean quantize_colors; /* TRUE=colormapped output wanted */ + /* the following are ignored if not quantize_colors: */ + J_DITHER_MODE dither_mode; /* type of color dithering to use */ + boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ + int desired_number_of_colors; /* max # colors to use in created colormap */ + /* these are significant only in buffered-image mode: */ + boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ + boolean enable_external_quant;/* enable future use of external colormap */ + boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ + + /* Description of actual output image that will be returned to application. + * These fields are computed by jpeg_start_decompress(). + * You can also use jpeg_calc_output_dimensions() to determine these values + * in advance of calling jpeg_start_decompress(). + */ + + JDIMENSION output_width; /* scaled image width */ + JDIMENSION output_height; /* scaled image height */ + int out_color_components; /* # of color components in out_color_space */ + int output_components; /* # of color components returned */ + /* output_components is 1 (a colormap index) when quantizing colors; + * otherwise it equals out_color_components. + */ + int rec_outbuf_height; /* min recommended height of scanline buffer */ + /* If the buffer passed to jpeg_read_scanlines() is less than this many rows + * high, space and time will be wasted due to unnecessary data copying. + * Usually rec_outbuf_height will be 1 or 2, at most 4. + */ + + /* When quantizing colors, the output colormap is described by these fields. + * The application can supply a colormap by setting colormap non-NULL before + * calling jpeg_start_decompress; otherwise a colormap is created during + * jpeg_start_decompress or jpeg_start_output. + * The map has out_color_components rows and actual_number_of_colors columns. + */ + int actual_number_of_colors; /* number of entries in use */ + JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ + + /* State variables: these variables indicate the progress of decompression. + * The application may examine these but must not modify them. + */ + + /* Row index of next scanline to be read from jpeg_read_scanlines(). + * Application may use this to control its processing loop, e.g., + * "while (output_scanline < output_height)". + */ + JDIMENSION output_scanline; /* 0 .. output_height-1 */ + + /* Current input scan number and number of iMCU rows completed in scan. + * These indicate the progress of the decompressor input side. + */ + int input_scan_number; /* Number of SOS markers seen so far */ + JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ + + /* The "output scan number" is the notional scan being displayed by the + * output side. The decompressor will not allow output scan/row number + * to get ahead of input scan/row, but it can fall arbitrarily far behind. + */ + int output_scan_number; /* Nominal scan number being displayed */ + JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ + + /* Current progression status. coef_bits[c][i] indicates the precision + * with which component c's DCT coefficient i (in zigzag order) is known. + * It is -1 when no data has yet been received, otherwise it is the point + * transform (shift) value for the most recent scan of the coefficient + * (thus, 0 at completion of the progression). + * This pointer is NULL when reading a non-progressive file. + */ + int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ + + /* Internal JPEG parameters --- the application usually need not look at + * these fields. Note that the decompressor output side may not use + * any parameters that can change between scans. + */ + + /* Quantization and Huffman tables are carried forward across input + * datastreams when processing abbreviated JPEG datastreams. + */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + /* These parameters are never carried across datastreams, since they + * are given in SOF/SOS markers or defined to be reset by SOI. + */ + + int data_precision; /* bits of precision in image data */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + boolean is_baseline; /* TRUE if Baseline SOF0 encountered */ + boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ + + /* These fields record data obtained from optional markers recognized by + * the JPEG library. + */ + boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ + /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ + UINT8 JFIF_major_version; /* JFIF version number */ + UINT8 JFIF_minor_version; + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ + UINT8 Adobe_transform; /* Color transform code from Adobe marker */ + + J_COLOR_TRANSFORM color_transform; + /* Color transform identifier derived from LSE marker, otherwise zero */ + + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + + /* Aside from the specific data retained from APPn markers known to the + * library, the uninterpreted contents of any or all APPn and COM markers + * can be saved in a list for examination by the application. + */ + jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ + + /* Remaining fields are known throughout decompressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during decompression startup + */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */ + int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ + /* The coefficient controller's input and output progress is measured in + * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows + * in fully interleaved JPEG scans, but are used whether the scan is + * interleaved or not. We define an iMCU row as v_samp_factor DCT block + * rows of each component. Therefore, the IDCT output contains + * v_samp_factor * DCT_v_scaled_size sample rows of a component per iMCU row. + */ + + JSAMPLE * sample_range_limit; /* table for fast range-limiting */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + * Note that the decompressor output side must not use these fields. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[D_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + /* These fields are derived from Se of first SOS marker. + */ + int block_size; /* the basic DCT block size: 1..16 */ + const int * natural_order; /* natural-order position array for entropy decode */ + int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */ + + /* This field is shared between entropy decoder and marker parser. + * It is either zero or the code of a JPEG marker that has been + * read from the data source, but has not yet been processed. + */ + int unread_marker; + + /* + * Links to decompression subobjects (methods, private variables of modules) + */ + struct jpeg_decomp_master * master; + struct jpeg_d_main_controller * main; + struct jpeg_d_coef_controller * coef; + struct jpeg_d_post_controller * post; + struct jpeg_input_controller * inputctl; + struct jpeg_marker_reader * marker; + struct jpeg_entropy_decoder * entropy; + struct jpeg_inverse_dct * idct; + struct jpeg_upsampler * upsample; + struct jpeg_color_deconverter * cconvert; + struct jpeg_color_quantizer * cquantize; +}; + + +/* "Object" declarations for JPEG modules that may be supplied or called + * directly by the surrounding application. + * As with all objects in the JPEG library, these structs only define the + * publicly visible methods and state variables of a module. Additional + * private fields may exist after the public ones. + */ + + +/* Error handler object */ + +struct jpeg_error_mgr { + /* Error exit handler: does not return to caller */ + JMETHOD(noreturn_t, error_exit, (j_common_ptr cinfo)); + /* Conditionally emit a trace or warning message */ + JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); + /* Routine that actually outputs a trace or error message */ + JMETHOD(void, output_message, (j_common_ptr cinfo)); + /* Format a message string for the most recent JPEG error or message */ + JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); +#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ + /* Reset error state variables at start of a new image */ + JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); + + /* The message ID code and any parameters are saved here. + * A message can have one string parameter or up to 8 int parameters. + */ + int msg_code; +#define JMSG_STR_PARM_MAX 80 + union { + int i[8]; + char s[JMSG_STR_PARM_MAX]; + } msg_parm; + + /* Standard state variables for error facility */ + + int trace_level; /* max msg_level that will be displayed */ + + /* For recoverable corrupt-data errors, we emit a warning message, + * but keep going unless emit_message chooses to abort. emit_message + * should count warnings in num_warnings. The surrounding application + * can check for bad data by seeing if num_warnings is nonzero at the + * end of processing. + */ + long num_warnings; /* number of corrupt-data warnings */ + + /* These fields point to the table(s) of error message strings. + * An application can change the table pointer to switch to a different + * message list (typically, to change the language in which errors are + * reported). Some applications may wish to add additional error codes + * that will be handled by the JPEG library error mechanism; the second + * table pointer is used for this purpose. + * + * First table includes all errors generated by JPEG library itself. + * Error code 0 is reserved for a "no such error string" message. + */ + const char * const * jpeg_message_table; /* Library errors */ + int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ + /* Second table can be added by application (see cjpeg/djpeg for example). + * It contains strings numbered first_addon_message..last_addon_message. + */ + const char * const * addon_message_table; /* Non-library errors */ + int first_addon_message; /* code for first string in addon table */ + int last_addon_message; /* code for last string in addon table */ +}; + + +/* Progress monitor object */ + +struct jpeg_progress_mgr { + JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); + + long pass_counter; /* work units completed in this pass */ + long pass_limit; /* total number of work units in this pass */ + int completed_passes; /* passes completed so far */ + int total_passes; /* total number of passes expected */ +}; + + +/* Data destination object for compression */ + +struct jpeg_destination_mgr { + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + + JMETHOD(void, init_destination, (j_compress_ptr cinfo)); + JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); + JMETHOD(void, term_destination, (j_compress_ptr cinfo)); +}; + + +/* Data source object for decompression */ + +struct jpeg_source_mgr { + const JOCTET * next_input_byte; /* => next byte to read from buffer */ + size_t bytes_in_buffer; /* # of bytes remaining in buffer */ + + JMETHOD(void, init_source, (j_decompress_ptr cinfo)); + JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); + JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); + JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); + JMETHOD(void, term_source, (j_decompress_ptr cinfo)); +}; + + +/* Memory manager object. + * Allocates "small" objects (a few K total), "large" objects (tens of K), + * and "really big" objects (virtual arrays with backing store if needed). + * The memory manager does not allow individual objects to be freed; rather, + * each created object is assigned to a pool, and whole pools can be freed + * at once. This is faster and more convenient than remembering exactly what + * to free, especially where malloc()/free() are not too speedy. + * NB: alloc routines never return NULL. They exit to error_exit if not + * successful. + */ + +#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ +#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ +#define JPOOL_NUMPOOLS 2 + +typedef struct jvirt_sarray_control * jvirt_sarray_ptr; +typedef struct jvirt_barray_control * jvirt_barray_ptr; + + +struct jpeg_memory_mgr { + /* Method pointers */ + JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, + JDIMENSION samplesperrow, + JDIMENSION numrows)); + JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, + JDIMENSION blocksperrow, + JDIMENSION numrows)); + JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION samplesperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION blocksperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); + JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, + jvirt_sarray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, + jvirt_barray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); + JMETHOD(void, self_destruct, (j_common_ptr cinfo)); + + /* Limit on memory allocation for this JPEG object. (Note that this is + * merely advisory, not a guaranteed maximum; it only affects the space + * used for virtual-array buffers.) May be changed by outer application + * after creating the JPEG object. + */ + long max_memory_to_use; + + /* Maximum allocation request accepted by alloc_large. */ + long max_alloc_chunk; +}; + + +/* Routine signature for application-supplied marker processing methods. + * Need not pass marker code since it is stored in cinfo->unread_marker. + */ +typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); + + +/* Declarations for routines called by application. + * The JPP macro hides prototype parameters from compilers that can't cope. + * Note JPP requires double parentheses. + */ + +#ifdef HAVE_PROTOTYPES +#define JPP(arglist) arglist +#else +#define JPP(arglist) () +#endif + + +/* Short forms of external names for systems with brain-damaged linkers. + * We shorten external names to be unique in the first six letters, which + * is good enough for all known systems. + * (If your compiler itself needs names to be unique in less than 15 + * characters, you are out of luck. Get a better compiler.) + */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_std_error jStdError +#define jpeg_CreateCompress jCreaCompress +#define jpeg_CreateDecompress jCreaDecompress +#define jpeg_destroy_compress jDestCompress +#define jpeg_destroy_decompress jDestDecompress +#define jpeg_stdio_dest jStdDest +#define jpeg_stdio_src jStdSrc +#define jpeg_mem_dest jMemDest +#define jpeg_mem_src jMemSrc +#define jpeg_set_defaults jSetDefaults +#define jpeg_set_colorspace jSetColorspace +#define jpeg_default_colorspace jDefColorspace +#define jpeg_set_quality jSetQuality +#define jpeg_set_linear_quality jSetLQuality +#define jpeg_default_qtables jDefQTables +#define jpeg_add_quant_table jAddQuantTable +#define jpeg_quality_scaling jQualityScaling +#define jpeg_simple_progression jSimProgress +#define jpeg_suppress_tables jSuppressTables +#define jpeg_alloc_quant_table jAlcQTable +#define jpeg_alloc_huff_table jAlcHTable +#define jpeg_std_huff_table jStdHTable +#define jpeg_start_compress jStrtCompress +#define jpeg_write_scanlines jWrtScanlines +#define jpeg_finish_compress jFinCompress +#define jpeg_calc_jpeg_dimensions jCjpegDimensions +#define jpeg_write_raw_data jWrtRawData +#define jpeg_write_marker jWrtMarker +#define jpeg_write_m_header jWrtMHeader +#define jpeg_write_m_byte jWrtMByte +#define jpeg_write_tables jWrtTables +#define jpeg_read_header jReadHeader +#define jpeg_start_decompress jStrtDecompress +#define jpeg_read_scanlines jReadScanlines +#define jpeg_finish_decompress jFinDecompress +#define jpeg_read_raw_data jReadRawData +#define jpeg_has_multiple_scans jHasMultScn +#define jpeg_start_output jStrtOutput +#define jpeg_finish_output jFinOutput +#define jpeg_input_complete jInComplete +#define jpeg_new_colormap jNewCMap +#define jpeg_consume_input jConsumeInput +#define jpeg_core_output_dimensions jCoreDimensions +#define jpeg_calc_output_dimensions jCalcDimensions +#define jpeg_save_markers jSaveMarkers +#define jpeg_set_marker_processor jSetMarker +#define jpeg_read_coefficients jReadCoefs +#define jpeg_write_coefficients jWrtCoefs +#define jpeg_copy_critical_parameters jCopyCrit +#define jpeg_abort_compress jAbrtCompress +#define jpeg_abort_decompress jAbrtDecompress +#define jpeg_abort jAbort +#define jpeg_destroy jDestroy +#define jpeg_resync_to_restart jResyncRestart +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Default error-management setup */ +EXTERN(struct jpeg_error_mgr *) jpeg_std_error + JPP((struct jpeg_error_mgr * err)); + +/* Initialization of JPEG compression objects. + * jpeg_create_compress() and jpeg_create_decompress() are the exported + * names that applications should call. These expand to calls on + * jpeg_CreateCompress and jpeg_CreateDecompress with additional information + * passed for version mismatch checking. + * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. + */ +#define jpeg_create_compress(cinfo) \ + jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_compress_struct)) +#define jpeg_create_decompress(cinfo) \ + jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_decompress_struct)) +EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, + int version, size_t structsize)); +EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, + int version, size_t structsize)); +/* Destruction of JPEG compression objects */ +EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); + +/* Standard data source and destination managers: stdio streams. */ +/* Caller is responsible for opening the file before and closing after. */ +EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); +EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); + +/* Data source and destination managers: memory buffers. */ +EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo, + unsigned char ** outbuffer, + size_t * outsize)); +EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo, + const unsigned char * inbuffer, + size_t insize)); + +/* Default parameter setup for compression */ +EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); +/* Compression parameter setup aids */ +EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, + J_COLOR_SPACE colorspace)); +EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, + boolean force_baseline)); +EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, + int scale_factor, + boolean force_baseline)); +EXTERN(void) jpeg_default_qtables JPP((j_compress_ptr cinfo, + boolean force_baseline)); +EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, + boolean force_baseline)); +EXTERN(int) jpeg_quality_scaling JPP((int quality)); +EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, + boolean suppress)); +EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); +EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); +EXTERN(JHUFF_TBL *) jpeg_std_huff_table JPP((j_common_ptr cinfo, + boolean isDC, int tblno)); + +/* Main entry points for compression */ +EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, + boolean write_all_tables)); +EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION num_lines)); +EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); + +/* Precalculate JPEG dimensions for current compression parameters. */ +EXTERN(void) jpeg_calc_jpeg_dimensions JPP((j_compress_ptr cinfo)); + +/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION num_lines)); + +/* Write a special marker. See libjpeg.txt concerning safe usage. */ +EXTERN(void) jpeg_write_marker + JPP((j_compress_ptr cinfo, int marker, + const JOCTET * dataptr, unsigned int datalen)); +/* Same, but piecemeal. */ +EXTERN(void) jpeg_write_m_header + JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); +EXTERN(void) jpeg_write_m_byte + JPP((j_compress_ptr cinfo, int val)); + +/* Alternate compression function: just write an abbreviated table file */ +EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); + +/* Decompression startup: read start of JPEG datastream to see what's there */ +EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, + boolean require_image)); +/* Return value is one of: */ +#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ +#define JPEG_HEADER_OK 1 /* Found valid image datastream */ +#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ +/* If you pass require_image = TRUE (normal case), you need not check for + * a TABLES_ONLY return code; an abbreviated file will cause an error exit. + * JPEG_SUSPENDED is only possible if you use a data source module that can + * give a suspension return (the stdio source module doesn't). + */ + +/* Main entry points for decompression */ +EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); +EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION max_lines)); +EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); + +/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION max_lines)); + +/* Additional entry points for buffered-image mode. */ +EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, + int scan_number)); +EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); +EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); +/* Return value is one of: */ +/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ +#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ +#define JPEG_REACHED_EOI 2 /* Reached end of image */ +#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ +#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ + +/* Precalculate output dimensions for current decompression parameters. */ +EXTERN(void) jpeg_core_output_dimensions JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); + +/* Control saving of COM and APPn markers into marker_list. */ +EXTERN(void) jpeg_save_markers + JPP((j_decompress_ptr cinfo, int marker_code, + unsigned int length_limit)); + +/* Install a special processing method for COM or APPn markers. */ +EXTERN(void) jpeg_set_marker_processor + JPP((j_decompress_ptr cinfo, int marker_code, + jpeg_marker_parser_method routine)); + +/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ +EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays)); +EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, + j_compress_ptr dstinfo)); + +/* If you choose to abort compression or decompression before completing + * jpeg_finish_(de)compress, then you need to clean up to release memory, + * temporary files, etc. You can just call jpeg_destroy_(de)compress + * if you're done with the JPEG object, but if you want to clean it up and + * reuse it, call this: + */ +EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); + +/* Generic versions of jpeg_abort and jpeg_destroy that work on either + * flavor of JPEG object. These may be more convenient in some places. + */ +EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); +EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); + +/* Default restart-marker-resync procedure for use by data source modules */ +EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, + int desired)); + + +/* These marker codes are exported since applications and data source modules + * are likely to want to use them. + */ + +#define JPEG_RST0 0xD0 /* RST0 marker code */ +#define JPEG_EOI 0xD9 /* EOI marker code */ +#define JPEG_APP0 0xE0 /* APP0 marker code */ +#define JPEG_COM 0xFE /* COM marker code */ + + +/* If we have a brain-damaged compiler that emits warnings (or worse, errors) + * for structure definitions that are never filled in, keep it quiet by + * supplying dummy definitions for the various substructures. + */ + +#ifdef INCOMPLETE_TYPES_BROKEN +#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ +struct jvirt_sarray_control { long dummy; }; +struct jvirt_barray_control { long dummy; }; +struct jpeg_comp_master { long dummy; }; +struct jpeg_c_main_controller { long dummy; }; +struct jpeg_c_prep_controller { long dummy; }; +struct jpeg_c_coef_controller { long dummy; }; +struct jpeg_marker_writer { long dummy; }; +struct jpeg_color_converter { long dummy; }; +struct jpeg_downsampler { long dummy; }; +struct jpeg_forward_dct { long dummy; }; +struct jpeg_entropy_encoder { long dummy; }; +struct jpeg_decomp_master { long dummy; }; +struct jpeg_d_main_controller { long dummy; }; +struct jpeg_d_coef_controller { long dummy; }; +struct jpeg_d_post_controller { long dummy; }; +struct jpeg_input_controller { long dummy; }; +struct jpeg_marker_reader { long dummy; }; +struct jpeg_entropy_decoder { long dummy; }; +struct jpeg_inverse_dct { long dummy; }; +struct jpeg_upsampler { long dummy; }; +struct jpeg_color_deconverter { long dummy; }; +struct jpeg_color_quantizer { long dummy; }; +#endif /* JPEG_INTERNALS */ +#endif /* INCOMPLETE_TYPES_BROKEN */ + + +/* + * The JPEG library modules define JPEG_INTERNALS before including this file. + * The internal structure declarations are read only when that is true. + * Applications using the library should not include jpegint.h, but may wish + * to include jerror.h. + */ + +#ifdef JPEG_INTERNALS +#include "jpegint.h" /* fetch private declarations */ +#include "jerror.h" /* fetch error codes too */ +#endif + +#ifdef __cplusplus +#ifndef DONT_USE_EXTERN_C +} +#endif +#endif + +#endif /* JPEGLIB_H */ diff --git a/thirdparty/jpeg-9e/jpegtran.1 b/thirdparty/jpeg-9e/jpegtran.1 new file mode 100644 index 0000000..7929afd --- /dev/null +++ b/thirdparty/jpeg-9e/jpegtran.1 @@ -0,0 +1,328 @@ +.TH JPEGTRAN 1 "28 August 2019" +.SH NAME +jpegtran \- lossless transformation of JPEG files +.SH SYNOPSIS +.B jpegtran +[ +.I options +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B jpegtran +performs various useful transformations of JPEG files. +It can translate the coded representation from one variant of JPEG to another, +for example from baseline JPEG to progressive JPEG or vice versa. It can also +perform some rearrangements of the image data, for example turning an image +from landscape to portrait format by rotation. +.PP +For EXIF files and JPEG files containing Exif data, you may prefer to use +.B exiftran +instead. +.PP +.B jpegtran +works by rearranging the compressed data (DCT coefficients), without +ever fully decoding the image. Therefore, its transformations are lossless: +there is no image degradation at all, which would not be true if you used +.B djpeg +followed by +.B cjpeg +to accomplish the same conversion. But by the same token, +.B jpegtran +cannot perform lossy operations such as changing the image quality. However, +while the image data is losslessly transformed, metadata can be removed. See +the +.B \-copy +option for specifics. +.PP +.B jpegtran +reads the named JPEG/JFIF file, or the standard input if no file is +named, and produces a JPEG/JFIF file on the standard output. +.SH OPTIONS +All switch names may be abbreviated; for example, +.B \-optimize +may be written +.B \-opt +or +.BR \-o . +Upper and lower case are equivalent. +British spellings are also accepted (e.g., +.BR \-optimise ), +though for brevity these are not mentioned below. +.PP +To specify the coded JPEG representation used in the output file, +.B jpegtran +accepts a subset of the switches recognized by +.BR cjpeg : +.TP +.B \-optimize +Perform optimization of entropy encoding parameters. +.TP +.B \-progressive +Create progressive JPEG file. +.TP +.BI \-restart " N" +Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is +attached to the number. +.TP +.B \-arithmetic +Use arithmetic coding. +.TP +.BI \-scans " file" +Use the scan script given in the specified text file. +.PP +See +.BR cjpeg (1) +for more details about these switches. +If you specify none of these switches, you get a plain baseline-JPEG output +file. The quality setting and so forth are determined by the input file. +.PP +The image can be losslessly transformed by giving one of these switches: +.TP +.B \-flip horizontal +Mirror image horizontally (left-right). +.TP +.B \-flip vertical +Mirror image vertically (top-bottom). +.TP +.B \-rotate 90 +Rotate image 90 degrees clockwise. +.TP +.B \-rotate 180 +Rotate image 180 degrees. +.TP +.B \-rotate 270 +Rotate image 270 degrees clockwise (or 90 ccw). +.TP +.B \-transpose +Transpose image (across UL-to-LR axis). +.TP +.B \-transverse +Transverse transpose (across UR-to-LL axis). +.IP +The transpose transformation has no restrictions regarding image dimensions. +The other transformations operate rather oddly if the image dimensions are not +a multiple of the iMCU size (usually 8 or 16 pixels), because they can only +transform complete blocks of DCT coefficient data in the desired way. +.IP +.BR jpegtran 's +default behavior when transforming an odd-size image is designed +to preserve exact reversibility and mathematical consistency of the +transformation set. As stated, transpose is able to flip the entire image +area. Horizontal mirroring leaves any partial iMCU column at the right edge +untouched, but is able to flip all rows of the image. Similarly, vertical +mirroring leaves any partial iMCU row at the bottom edge untouched, but is +able to flip all columns. The other transforms can be built up as sequences +of transpose and flip operations; for consistency, their actions on edge +pixels are defined to be the same as the end result of the corresponding +transpose-and-flip sequence. +.IP +For practical use, you may prefer to discard any untransformable edge pixels +rather than having a strange-looking strip along the right and/or bottom edges +of a transformed image. To do this, add the +.B \-trim +switch: +.TP +.B \-trim +Drop non-transformable edge blocks. +.IP +Obviously, a transformation with +.B \-trim +is not reversible, so strictly speaking +.B jpegtran +with this switch is not lossless. Also, the expected mathematical +equivalences between the transformations no longer hold. For example, +.B \-rot 270 -trim +trims only the bottom edge, but +.B \-rot 90 -trim +followed by +.B \-rot 180 -trim +trims both edges. +.IP +If you are only interested in perfect transformation, add the +.B \-perfect +switch: +.TP +.B \-perfect +Fails with an error if the transformation is not perfect. +.IP +For example you may want to do +.IP +.B (jpegtran \-rot 90 -perfect +.I foo.jpg +.B || djpeg +.I foo.jpg +.B | pnmflip \-r90 | cjpeg) +.IP +to do a perfect rotation if available or an approximated one if not. +.PP +We also offer a lossless-crop option, which discards data outside a given +image region but losslessly preserves what is inside. Like the rotate and +flip transforms, lossless crop is restricted by the current JPEG format: the +upper left corner of the selected region must fall on an iMCU boundary. If +this does not hold for the given crop parameters, we silently move the upper +left corner up and/or left to make it so, simultaneously increasing the +region dimensions to keep the lower right crop corner unchanged. (Thus, the +output image covers at least the requested region, but may cover more.) +The adjustment of the region dimensions may be optionally disabled by +attaching an 'f' character ("force") to the width or height number. +.PP +The image can be losslessly cropped by giving the switch: +.TP +.B \-crop WxH+X+Y +Crop to a rectangular subarea of width W, height H starting at point X,Y. +.PP +Crop extension: The width or height parameters can be made larger than the +source image. In this case the extra area is filled in with zero (neutral +gray). A larger width parameter has two more options: Attaching an 'f' +character ("flatten") to the width number will fill in the extra area with +the DC of the adjacent block, instead of gray out. Attaching an 'r' +character ("reflect") to the width number will fill in the extra area with +repeated reflections of the source region, instead of gray out. +.PP +A complementary lossless-wipe option is provided to discard (gray out) data +inside a given image region while losslessly preserving what is outside: +.TP +.B \-wipe WxH+X+Y +Wipe (gray out) a rectangular subarea of width W, height H starting at point +X,Y. +.PP +Attaching an 'f' character ("flatten") to the width number will fill the +region with the average of adjacent blocks, instead of gray out. In case +the wipe region and outside area form two horizontally adjacent rectangles, +attaching an 'r' character ("reflect") to the width number will fill the +region with repeated reflections of the outside area, instead of gray out. +.PP +Another option is lossless-drop, which replaces data at a given image +position by another image: +.TP +.B \-drop +X+Y filename +Drop another image +.PP +Both source images must have the same subsampling values. It is best if +they also have the same quantization, otherwise quantization adaption occurs. +The trim option can be used with the drop option to requantize the drop file +to the source file. +.PP +Other not-strictly-lossless transformation switches are: +.TP +.B \-grayscale +Force grayscale output. +.IP +This option discards the chrominance channels if the input image is YCbCr +(ie, a standard color JPEG), resulting in a grayscale JPEG file. The +luminance channel is preserved exactly, so this is a better method of reducing +to grayscale than decompression, conversion, and recompression. This switch +is particularly handy for fixing a monochrome picture that was mistakenly +encoded as a color JPEG. (In such a case, the space savings from getting rid +of the near-empty chroma channels won't be large; but the decoding time for +a grayscale JPEG is substantially less than that for a color JPEG.) +.TP +.BI \-scale " M/N" +Scale the output image by a factor M/N. +.IP +Currently supported scale factors are M/N with all M from 1 to 16, where N is +the source DCT size, which is 8 for baseline JPEG. If the /N part is omitted, +then M specifies the DCT scaled size to be applied on the given input. For +baseline JPEG this is equivalent to M/8 scaling, since the source DCT size +for baseline JPEG is 8. +.B Caution: +An implementation of the JPEG SmartScale extension is required for this +feature. SmartScale enabled JPEG is not yet widely implemented, so many +decoders will be unable to view a SmartScale extended JPEG file at all. +.PP +.B jpegtran +also recognizes these switches that control what to do with "extra" markers, +such as comment blocks: +.TP +.B \-copy none +Copy no extra markers from source file. This setting suppresses all +comments and other metadata in the source file. +.TP +.B \-copy comments +Copy only comment markers. This setting copies comments from the source file, +but discards any other metadata. +.TP +.B \-copy all +Copy all extra markers. This setting preserves metadata +found in the source file, such as JFIF thumbnails, Exif data, and Photoshop +settings. In some files these extra markers can be sizable. Note that this +option will copy thumbnails as-is; they will not be transformed. +.IP +The default behavior is +.BR "\-copy comments" . +(Note: in IJG releases v6 and v6a, +.B jpegtran +always did the equivalent of +.BR "\-copy none" .) +.PP +Additional switches recognized by jpegtran are: +.TP +.BI \-maxmemory " N" +Set limit for amount of memory to use in processing large images. Value is +in thousands of bytes, or millions of bytes if "M" is attached to the +number. For example, +.B \-max 4m +selects 4000000 bytes. If more space is needed, temporary files will be used. +.TP +.BI \-outfile " name" +Send output image to the named file, not to standard output. +.TP +.B \-verbose +Enable debug printout. More +.BR \-v 's +give more output. Also, version information is printed at startup. +.TP +.B \-debug +Same as +.BR \-verbose . +.SH EXAMPLES +.LP +This example converts a baseline JPEG file to progressive form: +.IP +.B jpegtran \-progressive +.I foo.jpg +.B > +.I fooprog.jpg +.PP +This example rotates an image 90 degrees clockwise, discarding any +unrotatable edge pixels: +.IP +.B jpegtran \-rot 90 -trim +.I foo.jpg +.B > +.I foo90.jpg +.SH ENVIRONMENT +.TP +.B JPEGMEM +If this environment variable is set, its value is the default memory limit. +The value is specified as described for the +.B \-maxmemory +switch. +.B JPEGMEM +overrides the default value specified when the program was compiled, and +itself is overridden by an explicit +.BR \-maxmemory . +.SH SEE ALSO +.BR cjpeg (1), +.BR djpeg (1), +.BR rdjpgcom (1), +.BR wrjpgcom (1) +.br +Wallace, Gregory K. "The JPEG Still Picture Compression Standard", +Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. +.SH AUTHOR +Independent JPEG Group +.SH BUGS +The transform options can't transform odd-size images perfectly. Use +.B \-trim +or +.B \-perfect +if you don't like the results. +.PP +The entire image is read into memory and then written out again, even in +cases where this isn't really necessary. Expect swapping on large images, +especially when using the more complex transform options. diff --git a/thirdparty/jpeg-9e/jpegtran.c b/thirdparty/jpeg-9e/jpegtran.c new file mode 100644 index 0000000..bfaa8ac --- /dev/null +++ b/thirdparty/jpeg-9e/jpegtran.c @@ -0,0 +1,654 @@ +/* + * jpegtran.c + * + * Copyright (C) 1995-2019, Thomas G. Lane, Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a command-line user interface for JPEG transcoding. + * It is very similar to cjpeg.c, and partly to djpeg.c, but provides + * lossless transcoding between different JPEG file formats. It also + * provides some lossless and sort-of-lossless transformations of JPEG data. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "transupp.h" /* Support routines for jpegtran */ +#include "jversion.h" /* for version message */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + * The main program in this file doesn't actually use this capability... + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ +static char * dropfilename; /* for -drop switch */ +static char * scaleoption; /* -scale switch */ +static JCOPY_OPTION copyoption; /* -copy switch */ +static jpeg_transform_info transformoption; /* image transformation options */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -copy none Copy no extra markers from source file\n"); + fprintf(stderr, " -copy comments Copy only comment markers (default)\n"); + fprintf(stderr, " -copy all Copy all extra markers\n"); +#ifdef ENTROPY_OPT_SUPPORTED + fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); +#endif +#ifdef C_PROGRESSIVE_SUPPORTED + fprintf(stderr, " -progressive Create progressive JPEG file\n"); +#endif + fprintf(stderr, "Switches for modifying the image:\n"); +#if TRANSFORMS_SUPPORTED + fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular subarea\n"); + fprintf(stderr, " -drop +X+Y filename Drop another image\n"); + fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); + fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); + fprintf(stderr, " -perfect Fail if there is non-transformable edge blocks\n"); + fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n"); +#endif + fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n"); +#if TRANSFORMS_SUPPORTED + fprintf(stderr, " -transpose Transpose image\n"); + fprintf(stderr, " -transverse Transverse transpose image\n"); + fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); + fprintf(stderr, " with -drop: Requantize drop file to source file\n"); + fprintf(stderr, " -wipe WxH+X+Y Wipe (gray out) a rectangular subarea\n"); +#endif + fprintf(stderr, "Switches for advanced users:\n"); +#ifdef C_ARITH_CODING_SUPPORTED + fprintf(stderr, " -arithmetic Use arithmetic coding\n"); +#endif + fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + fprintf(stderr, "Switches for wizards:\n"); +#ifdef C_MULTISCAN_FILES_SUPPORTED + fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); +#endif + exit(EXIT_FAILURE); +} + + +LOCAL(void) +select_transform (JXFORM_CODE transform) +/* Silly little routine to detect multiple transform options, + * which we can't handle. + */ +{ +#if TRANSFORMS_SUPPORTED + if (transformoption.transform == JXFORM_NONE || + transformoption.transform == transform) { + transformoption.transform = transform; + } else { + fprintf(stderr, "%s: can only do one image transformation at a time\n", + progname); + usage(); + } +#else + fprintf(stderr, "%s: sorry, image transformation was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif +} + + +LOCAL(int) +parse_switches (j_compress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + boolean simple_progressive; + char * scansarg = NULL; /* saves -scans parm if any */ + + /* Set up default JPEG parameters. */ + simple_progressive = FALSE; + outfilename = NULL; + scaleoption = NULL; + copyoption = JCOPYOPT_DEFAULT; + transformoption.transform = JXFORM_NONE; + transformoption.perfect = FALSE; + transformoption.trim = FALSE; + transformoption.force_grayscale = FALSE; + transformoption.crop = FALSE; + cinfo->err->trace_level = 0; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "arithmetic", 1)) { + /* Use arithmetic coding. */ +#ifdef C_ARITH_CODING_SUPPORTED + cinfo->arith_code = TRUE; +#else + fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "copy", 2)) { + /* Select which extra markers to copy. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "none", 1)) { + copyoption = JCOPYOPT_NONE; + } else if (keymatch(argv[argn], "comments", 1)) { + copyoption = JCOPYOPT_COMMENTS; + } else if (keymatch(argv[argn], "all", 1)) { + copyoption = JCOPYOPT_ALL; + } else + usage(); + + } else if (keymatch(arg, "crop", 2)) { + /* Perform lossless cropping. */ +#if TRANSFORMS_SUPPORTED + if (++argn >= argc) /* advance to next argument */ + usage(); + if (transformoption.crop /* reject multiple crop/drop/wipe requests */ || + ! jtransform_parse_crop_spec(&transformoption, argv[argn])) { + fprintf(stderr, "%s: bogus -crop argument '%s'\n", + progname, argv[argn]); + exit(EXIT_FAILURE); + } +#else + select_transform(JXFORM_NONE); /* force an error */ +#endif + + } else if (keymatch(arg, "drop", 2)) { +#if TRANSFORMS_SUPPORTED + if (++argn >= argc) /* advance to next argument */ + usage(); + if (transformoption.crop /* reject multiple crop/drop/wipe requests */ || + ! jtransform_parse_crop_spec(&transformoption, argv[argn]) || + transformoption.crop_width_set != JCROP_UNSET || + transformoption.crop_height_set != JCROP_UNSET) { + fprintf(stderr, "%s: bogus -drop argument '%s'\n", + progname, argv[argn]); + exit(EXIT_FAILURE); + } + if (++argn >= argc) /* advance to next argument */ + usage(); + dropfilename = argv[argn]; + select_transform(JXFORM_DROP); +#else + select_transform(JXFORM_NONE); /* force an error */ +#endif + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "flip", 1)) { + /* Mirror left-right or top-bottom. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "horizontal", 1)) + select_transform(JXFORM_FLIP_H); + else if (keymatch(argv[argn], "vertical", 1)) + select_transform(JXFORM_FLIP_V); + else + usage(); + + } else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) { + /* Force to grayscale. */ +#if TRANSFORMS_SUPPORTED + transformoption.force_grayscale = TRUE; +#else + select_transform(JXFORM_NONE); /* force an error */ +#endif + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { + /* Enable entropy parm optimization. */ +#ifdef ENTROPY_OPT_SUPPORTED + cinfo->optimize_coding = TRUE; +#else + fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "perfect", 2)) { + /* Fail if there is any partial edge MCUs that the transform can't + * handle. */ + transformoption.perfect = TRUE; + + } else if (keymatch(arg, "progressive", 2)) { + /* Select simple progressive mode. */ +#ifdef C_PROGRESSIVE_SUPPORTED + simple_progressive = TRUE; + /* We must postpone execution until num_components is known. */ +#else + fprintf(stderr, "%s: sorry, progressive output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "restart", 1)) { + /* Restart interval in MCU rows (or in MCUs with 'b'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (lval < 0 || lval > 65535L) + usage(); + if (ch == 'b' || ch == 'B') { + cinfo->restart_interval = (unsigned int) lval; + cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ + } else { + cinfo->restart_in_rows = (int) lval; + /* restart_interval will be computed during startup */ + } + + } else if (keymatch(arg, "rotate", 2)) { + /* Rotate 90, 180, or 270 degrees (measured clockwise). */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "90", 2)) + select_transform(JXFORM_ROT_90); + else if (keymatch(argv[argn], "180", 3)) + select_transform(JXFORM_ROT_180); + else if (keymatch(argv[argn], "270", 3)) + select_transform(JXFORM_ROT_270); + else + usage(); + + } else if (keymatch(arg, "scale", 4)) { + /* Scale the output image by a fraction M/N. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + scaleoption = argv[argn]; + /* We must postpone processing until decompression startup. */ + + } else if (keymatch(arg, "scans", 1)) { + /* Set scan script. */ +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (++argn >= argc) /* advance to next argument */ + usage(); + scansarg = argv[argn]; + /* We must postpone reading the file in case -progressive appears. */ +#else + fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "transpose", 1)) { + /* Transpose (across UL-to-LR axis). */ + select_transform(JXFORM_TRANSPOSE); + + } else if (keymatch(arg, "transverse", 6)) { + /* Transverse transpose (across UR-to-LL axis). */ + select_transform(JXFORM_TRANSVERSE); + + } else if (keymatch(arg, "trim", 3)) { + /* Trim off any partial edge MCUs that the transform can't handle. */ + transformoption.trim = TRUE; + + } else if (keymatch(arg, "wipe", 1)) { +#if TRANSFORMS_SUPPORTED + if (++argn >= argc) /* advance to next argument */ + usage(); + if (transformoption.crop /* reject multiple crop/drop/wipe requests */ || + ! jtransform_parse_crop_spec(&transformoption, argv[argn])) { + fprintf(stderr, "%s: bogus -wipe argument '%s'\n", + progname, argv[argn]); + exit(EXIT_FAILURE); + } + select_transform(JXFORM_WIPE); +#else + select_transform(JXFORM_NONE); /* force an error */ +#endif + + } else { + usage(); /* bogus switch */ + } + } + + /* Post-switch-scanning cleanup */ + + if (for_real) { + +#ifdef C_PROGRESSIVE_SUPPORTED + if (simple_progressive) /* process -progressive; -scans can override */ + jpeg_simple_progression(cinfo); +#endif + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (scansarg != NULL) /* process -scans if it was present */ + if (! read_scan_script(cinfo, scansarg)) + usage(); +#endif + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + struct jpeg_decompress_struct srcinfo; + struct jpeg_error_mgr jsrcerr; +#if TRANSFORMS_SUPPORTED + struct jpeg_decompress_struct dropinfo; + struct jpeg_error_mgr jdroperr; + FILE * drop_file; +#endif + struct jpeg_compress_struct dstinfo; + struct jpeg_error_mgr jdsterr; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + jvirt_barray_ptr * src_coef_arrays; + jvirt_barray_ptr * dst_coef_arrays; + int file_index; + /* We assume all-in-memory processing and can therefore use only a + * single file pointer for sequential input and output operation. + */ + FILE * fp; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "jpegtran"; /* in case C library doesn't provide it */ + + /* Initialize the JPEG decompression object with default error handling. */ + srcinfo.err = jpeg_std_error(&jsrcerr); + jpeg_create_decompress(&srcinfo); + /* Initialize the JPEG compression object with default error handling. */ + dstinfo.err = jpeg_std_error(&jdsterr); + jpeg_create_compress(&dstinfo); + + /* Now safe to enable signal catcher. + * Note: we assume only the decompression object will have virtual arrays. + */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &srcinfo); +#endif + + /* Scan command line to find file names. + * It is convenient to use just one switch-parsing routine, but the switch + * values read here are mostly ignored; we will rescan the switches after + * opening the input file. Also note that most of the switches affect the + * destination JPEG object, so we parse into that and then copy over what + * needs to affect the source too. + */ + + file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE); + jsrcerr.trace_level = jdsterr.trace_level; + srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use; + +#ifdef TWO_FILE_COMMANDLINE + /* Must have either -outfile switch or explicit output file name */ + if (outfilename == NULL) { + if (file_index != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + outfilename = argv[file_index+1]; + } else { + if (file_index != argc-1) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + } +#else + /* Unix style: expect zero or one file name */ + if (file_index < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } +#endif /* TWO_FILE_COMMANDLINE */ + + /* Open the input file. */ + if (file_index < argc) { + if ((fp = fopen(argv[file_index], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s for reading\n", progname, argv[file_index]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ + fp = read_stdin(); + } + +#if TRANSFORMS_SUPPORTED + /* Open the drop file. */ + if (dropfilename != NULL) { + if ((drop_file = fopen(dropfilename, READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s for reading\n", progname, dropfilename); + exit(EXIT_FAILURE); + } + dropinfo.err = jpeg_std_error(&jdroperr); + jpeg_create_decompress(&dropinfo); + jpeg_stdio_src(&dropinfo, drop_file); + } else { + drop_file = NULL; + } +#endif + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &dstinfo, &progress); +#endif + + /* Specify data source for decompression */ + jpeg_stdio_src(&srcinfo, fp); + + /* Enable saving of extra markers that we want to copy */ + jcopy_markers_setup(&srcinfo, copyoption); + + /* Read file header */ + (void) jpeg_read_header(&srcinfo, TRUE); + + /* Adjust default decompression parameters */ + if (scaleoption != NULL) + if (sscanf(scaleoption, "%u/%u", + &srcinfo.scale_num, &srcinfo.scale_denom) < 1) + usage(); + +#if TRANSFORMS_SUPPORTED + if (dropfilename != NULL) { + (void) jpeg_read_header(&dropinfo, TRUE); + transformoption.crop_width = dropinfo.image_width; + transformoption.crop_width_set = JCROP_POS; + transformoption.crop_height = dropinfo.image_height; + transformoption.crop_height_set = JCROP_POS; + transformoption.drop_ptr = &dropinfo; + } +#endif + + /* Any space needed by a transform option must be requested before + * jpeg_read_coefficients so that memory allocation will be done right. + */ +#if TRANSFORMS_SUPPORTED + /* Fail right away if -perfect is given and transformation is not perfect. + */ + if (!jtransform_request_workspace(&srcinfo, &transformoption)) { + fprintf(stderr, "%s: transformation is not perfect\n", progname); + exit(EXIT_FAILURE); + } +#endif + + /* Read source file as DCT coefficients */ + src_coef_arrays = jpeg_read_coefficients(&srcinfo); + +#if TRANSFORMS_SUPPORTED + if (dropfilename != NULL) { + transformoption.drop_coef_arrays = jpeg_read_coefficients(&dropinfo); + } +#endif + + /* Initialize destination compression parameters from source values */ + jpeg_copy_critical_parameters(&srcinfo, &dstinfo); + + /* Adjust destination parameters if required by transform options; + * also find out which set of coefficient arrays will hold the output. + */ +#if TRANSFORMS_SUPPORTED + dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo, + src_coef_arrays, + &transformoption); +#else + dst_coef_arrays = src_coef_arrays; +#endif + + /* Close input file, if we opened it. + * Note: we assume that jpeg_read_coefficients consumed all input + * until JPEG_REACHED_EOI, and that jpeg_finish_decompress will + * only consume more while (! cinfo->inputctl->eoi_reached). + * We cannot call jpeg_finish_decompress here since we still need the + * virtual arrays allocated from the source object for processing. + */ + if (fp != stdin) + fclose(fp); + + /* Open the output file. */ + if (outfilename != NULL) { + if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s for writing\n", progname, outfilename); + exit(EXIT_FAILURE); + } + } else { + /* default output file is stdout */ + fp = write_stdout(); + } + + /* Adjust default compression parameters by re-parsing the options */ + file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); + + /* Specify data destination for compression */ + jpeg_stdio_dest(&dstinfo, fp); + + /* Start compressor (note no image data is actually written here) */ + jpeg_write_coefficients(&dstinfo, dst_coef_arrays); + + /* Copy to the output file any extra markers that we want to preserve */ + jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); + + /* Execute image transformation, if any */ +#if TRANSFORMS_SUPPORTED + jtransform_execute_transformation(&srcinfo, &dstinfo, + src_coef_arrays, + &transformoption); +#endif + + /* Finish compression and release memory */ + jpeg_finish_compress(&dstinfo); + jpeg_destroy_compress(&dstinfo); +#if TRANSFORMS_SUPPORTED + if (dropfilename != NULL) { + (void) jpeg_finish_decompress(&dropinfo); + jpeg_destroy_decompress(&dropinfo); + } +#endif + (void) jpeg_finish_decompress(&srcinfo); + jpeg_destroy_decompress(&srcinfo); + + /* Close output file, if we opened it */ + if (fp != stdout) + fclose(fp); +#if TRANSFORMS_SUPPORTED + if (drop_file != NULL) + fclose(drop_file); +#endif + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &dstinfo); +#endif + + /* All done. */ +#if TRANSFORMS_SUPPORTED + if (dropfilename != NULL) + exit(jsrcerr.num_warnings + jdroperr.num_warnings + + jdsterr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); +#endif + exit(jsrcerr.num_warnings + jdsterr.num_warnings ? + EXIT_WARNING : EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/thirdparty/jpeg-9e/jquant1.c b/thirdparty/jpeg-9e/jquant1.c new file mode 100644 index 0000000..60b1843 --- /dev/null +++ b/thirdparty/jpeg-9e/jquant1.c @@ -0,0 +1,851 @@ +/* + * jquant1.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2011-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains 1-pass color quantization (color mapping) routines. + * These routines provide mapping to a fixed color map using equally spaced + * color values. Optional Floyd-Steinberg or ordered dithering is available. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef QUANT_1PASS_SUPPORTED + + +/* + * The main purpose of 1-pass quantization is to provide a fast, if not very + * high quality, colormapped output capability. A 2-pass quantizer usually + * gives better visual quality; however, for quantized grayscale output this + * quantizer is perfectly adequate. Dithering is highly recommended with this + * quantizer, though you can turn it off if you really want to. + * + * In 1-pass quantization the colormap must be chosen in advance of seeing the + * image. We use a map consisting of all combinations of Ncolors[i] color + * values for the i'th component. The Ncolors[] values are chosen so that + * their product, the total number of colors, is no more than that requested. + * (In most cases, the product will be somewhat less.) + * + * Since the colormap is orthogonal, the representative value for each color + * component can be determined without considering the other components; + * then these indexes can be combined into a colormap index by a standard + * N-dimensional-array-subscript calculation. Most of the arithmetic involved + * can be precalculated and stored in the lookup table colorindex[]. + * colorindex[i][j] maps pixel value j in component i to the nearest + * representative value (grid plane) for that component; this index is + * multiplied by the array stride for component i, so that the + * index of the colormap entry closest to a given pixel value is just + * sum( colorindex[component-number][pixel-component-value] ) + * Aside from being fast, this scheme allows for variable spacing between + * representative values with no additional lookup cost. + * + * If gamma correction has been applied in color conversion, it might be wise + * to adjust the color grid spacing so that the representative colors are + * equidistant in linear space. At this writing, gamma correction is not + * implemented by jdcolor, so nothing is done here. + */ + + +/* Declarations for ordered dithering. + * + * We use a standard 16x16 ordered dither array. The basic concept of ordered + * dithering is described in many references, for instance Dale Schumacher's + * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991). + * In place of Schumacher's comparisons against a "threshold" value, we add a + * "dither" value to the input pixel and then round the result to the nearest + * output value. The dither value is equivalent to (0.5 - threshold) times + * the distance between output values. For ordered dithering, we assume that + * the output colors are equally spaced; if not, results will probably be + * worse, since the dither may be too much or too little at a given point. + * + * The normal calculation would be to form pixel value + dither, range-limit + * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual. + * We can skip the separate range-limiting step by extending the colorindex + * table in both directions. + */ + +#define ODITHER_SIZE 16 /* dimension of dither matrix */ +/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */ +#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE) /* # cells in matrix */ +#define ODITHER_MASK (ODITHER_SIZE-1) /* mask for wrapping around counters */ + +typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE]; +typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE]; + +static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = { + /* Bayer's order-4 dither array. Generated by the code given in + * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I. + * The values in this array must range from 0 to ODITHER_CELLS-1. + */ + { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }, + { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 }, + { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 }, + { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 }, + { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 }, + { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 }, + { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 }, + { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 }, + { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 }, + { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 }, + { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 }, + { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 }, + { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 }, + { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 }, + { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 }, + { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 } +}; + + +/* Declarations for Floyd-Steinberg dithering. + * + * Errors are accumulated into the array fserrors[], at a resolution of + * 1/16th of a pixel count. The error at a given pixel is propagated + * to its not-yet-processed neighbors using the standard F-S fractions, + * ... (here) 7/16 + * 3/16 5/16 1/16 + * We work left-to-right on even rows, right-to-left on odd rows. + * + * We can get away with a single array (holding one row's worth of errors) + * by using it to store the current row's errors at pixel columns not yet + * processed, but the next row's errors at columns already processed. We + * need only a few extra variables to hold the errors immediately around the + * current column. (If we are lucky, those variables are in registers, but + * even if not, they're probably cheaper to access than array elements are.) + * + * The fserrors[] array is indexed [component#][position]. + * We provide (#columns + 2) entries per component; the extra entry at each + * end saves us from special-casing the first and last pixels. + * + * Note: on a wide image, we might not have enough room in a PC's near data + * segment to hold the error array; so it is allocated with alloc_large. + */ + +#if BITS_IN_JSAMPLE == 8 +typedef INT16 FSERROR; /* 16 bits should be enough */ +typedef int LOCFSERROR; /* use 'int' for calculation temps */ +#else +typedef INT32 FSERROR; /* may need more than 16 bits */ +typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ +#endif + +typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ + + +/* Private subobject */ + +#define MAX_Q_COMPS 4 /* max components I can handle */ + +typedef struct { + struct jpeg_color_quantizer pub; /* public fields */ + + /* Initially allocated colormap is saved here */ + JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */ + int sv_actual; /* number of entries in use */ + + JSAMPARRAY colorindex; /* Precomputed mapping for speed */ + /* colorindex[i][j] = index of color closest to pixel value j in component i, + * premultiplied as described above. Since colormap indexes must fit into + * JSAMPLEs, the entries of this array will too. + */ + boolean is_padded; /* is the colorindex padded for odither? */ + + int Ncolors[MAX_Q_COMPS]; /* # of values alloced to each component */ + + /* Variables for ordered dithering */ + int row_index; /* cur row's vertical index in dither matrix */ + ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */ + + /* Variables for Floyd-Steinberg dithering */ + FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */ + boolean on_odd_row; /* flag to remember which row we are on */ +} my_cquantizer; + +typedef my_cquantizer * my_cquantize_ptr; + + +/* + * Policy-making subroutines for create_colormap and create_colorindex. + * These routines determine the colormap to be used. The rest of the module + * only assumes that the colormap is orthogonal. + * + * * select_ncolors decides how to divvy up the available colors + * among the components. + * * output_value defines the set of representative values for a component. + * * largest_input_value defines the mapping from input values to + * representative values for a component. + * Note that the latter two routines may impose different policies for + * different components, though this is not currently done. + */ + + +LOCAL(int) +select_ncolors (j_decompress_ptr cinfo, int Ncolors[]) +/* Determine allocation of desired colors to components, */ +/* and fill in Ncolors[] array to indicate choice. */ +/* Return value is total number of colors (product of Ncolors[] values). */ +{ + int nc = cinfo->out_color_components; /* number of color components */ + int max_colors = cinfo->desired_number_of_colors; + int total_colors, iroot, i, j; + boolean changed; + long temp; + static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE }; + + /* We can allocate at least the nc'th root of max_colors per component. */ + /* Compute floor(nc'th root of max_colors). */ + iroot = 1; + do { + iroot++; + temp = iroot; /* set temp = iroot ** nc */ + for (i = 1; i < nc; i++) + temp *= iroot; + } while (temp <= (long) max_colors); /* repeat till iroot exceeds root */ + iroot--; /* now iroot = floor(root) */ + + /* Must have at least 2 color values per component */ + if (iroot < 2) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp); + + /* Initialize to iroot color values for each component */ + total_colors = 1; + for (i = 0; i < nc; i++) { + Ncolors[i] = iroot; + total_colors *= iroot; + } + /* We may be able to increment the count for one or more components without + * exceeding max_colors, though we know not all can be incremented. + * Sometimes, the first component can be incremented more than once! + * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.) + * In RGB colorspace, try to increment G first, then R, then B. + */ + do { + changed = FALSE; + for (i = 0; i < nc; i++) { + j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i); + /* calculate new total_colors if Ncolors[j] is incremented */ + temp = total_colors / Ncolors[j]; + temp *= Ncolors[j]+1; /* done in long arith to avoid oflo */ + if (temp > (long) max_colors) + break; /* won't fit, done with this pass */ + Ncolors[j]++; /* OK, apply the increment */ + total_colors = (int) temp; + changed = TRUE; + } + } while (changed); + + return total_colors; +} + + +LOCAL(int) +output_value (j_decompress_ptr cinfo, int ci, int j, int maxj) +/* Return j'th output value, where j will range from 0 to maxj */ +/* The output values must fall in 0..MAXJSAMPLE in increasing order */ +{ + /* We always provide values 0 and MAXJSAMPLE for each component; + * any additional values are equally spaced between these limits. + * (Forcing the upper and lower values to the limits ensures that + * dithering can't produce a color outside the selected gamut.) + */ + return (int) (((INT32) j * MAXJSAMPLE + maxj/2) / maxj); +} + + +LOCAL(int) +largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj) +/* Return largest input value that should map to j'th output value */ +/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */ +{ + /* Breakpoints are halfway between values returned by output_value */ + return (int) (((INT32) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj)); +} + + +/* + * Create the colormap. + */ + +LOCAL(void) +create_colormap (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPARRAY colormap; /* Created colormap */ + int total_colors; /* Number of distinct output colors */ + int i,j,k, nci, blksize, blkdist, ptr, val; + + /* Select number of colors for each component */ + total_colors = select_ncolors(cinfo, cquantize->Ncolors); + + /* Report selected color counts */ + if (cinfo->out_color_components == 3) + TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS, + total_colors, cquantize->Ncolors[0], + cquantize->Ncolors[1], cquantize->Ncolors[2]); + else + TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors); + + /* Allocate and fill in the colormap. */ + /* The colors are ordered in the map in standard row-major order, */ + /* i.e. rightmost (highest-indexed) color changes most rapidly. */ + + colormap = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components); + + /* blksize is number of adjacent repeated entries for a component */ + /* blkdist is distance between groups of identical entries for a component */ + blkdist = total_colors; + + for (i = 0; i < cinfo->out_color_components; i++) { + /* fill in colormap entries for i'th color component */ + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + blksize = blkdist / nci; + for (j = 0; j < nci; j++) { + /* Compute j'th output value (out of nci) for component */ + val = output_value(cinfo, i, j, nci-1); + /* Fill in all colormap entries that have this value of this component */ + for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) { + /* fill in blksize entries beginning at ptr */ + for (k = 0; k < blksize; k++) + colormap[i][ptr+k] = (JSAMPLE) val; + } + } + blkdist = blksize; /* blksize of this color is blkdist of next */ + } + + /* Save the colormap in private storage, + * where it will survive color quantization mode changes. + */ + cquantize->sv_colormap = colormap; + cquantize->sv_actual = total_colors; +} + + +/* + * Create the color index table. + */ + +LOCAL(void) +create_colorindex (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPROW indexptr; + int i,j,k, nci, blksize, val, pad; + + /* For ordered dither, we pad the color index tables by MAXJSAMPLE in + * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE). + * This is not necessary in the other dithering modes. However, we + * flag whether it was done in case user changes dithering mode. + */ + if (cinfo->dither_mode == JDITHER_ORDERED) { + pad = MAXJSAMPLE*2; + cquantize->is_padded = TRUE; + } else { + pad = 0; + cquantize->is_padded = FALSE; + } + + cquantize->colorindex = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (MAXJSAMPLE+1 + pad), + (JDIMENSION) cinfo->out_color_components); + + /* blksize is number of adjacent repeated entries for a component */ + blksize = cquantize->sv_actual; + + for (i = 0; i < cinfo->out_color_components; i++) { + /* fill in colorindex entries for i'th color component */ + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + blksize = blksize / nci; + + /* adjust colorindex pointers to provide padding at negative indexes. */ + if (pad) + cquantize->colorindex[i] += MAXJSAMPLE; + + /* in loop, val = index of current output value, */ + /* and k = largest j that maps to current val */ + indexptr = cquantize->colorindex[i]; + val = 0; + k = largest_input_value(cinfo, i, 0, nci-1); + for (j = 0; j <= MAXJSAMPLE; j++) { + while (j > k) /* advance val if past boundary */ + k = largest_input_value(cinfo, i, ++val, nci-1); + /* premultiply so that no multiplication needed in main processing */ + indexptr[j] = (JSAMPLE) (val * blksize); + } + /* Pad at both ends if necessary */ + if (pad) + for (j = 1; j <= MAXJSAMPLE; j++) { + indexptr[-j] = indexptr[0]; + indexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE]; + } + } +} + + +/* + * Create an ordered-dither array for a component having ncolors + * distinct output values. + */ + +LOCAL(ODITHER_MATRIX_PTR) +make_odither_array (j_decompress_ptr cinfo, int ncolors) +{ + ODITHER_MATRIX_PTR odither; + int j,k; + INT32 num,den; + + odither = (ODITHER_MATRIX_PTR) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(ODITHER_MATRIX)); + /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1). + * Hence the dither value for the matrix cell with fill order f + * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1). + * On 16-bit-int machine, be careful to avoid overflow. + */ + den = 2 * ODITHER_CELLS * ((INT32) (ncolors - 1)); + for (j = 0; j < ODITHER_SIZE; j++) { + for (k = 0; k < ODITHER_SIZE; k++) { + num = ((INT32) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k]))) + * MAXJSAMPLE; + /* Ensure round towards zero despite C's lack of consistency + * about rounding negative values in integer division... + */ + odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den); + } + } + return odither; +} + + +/* + * Create the ordered-dither tables. + * Components having the same number of representative colors may + * share a dither table. + */ + +LOCAL(void) +create_odither_tables (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + ODITHER_MATRIX_PTR odither; + int i, j, nci; + + for (i = 0; i < cinfo->out_color_components; i++) { + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + odither = NULL; /* search for matching prior component */ + for (j = 0; j < i; j++) { + if (nci == cquantize->Ncolors[j]) { + odither = cquantize->odither[j]; + break; + } + } + if (odither == NULL) /* need a new table? */ + odither = make_odither_array(cinfo, nci); + cquantize->odither[i] = odither; + } +} + + +/* + * Map some rows of pixels to the output colormapped representation. + */ + +METHODDEF(void) +color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPARRAY colorindex = cquantize->colorindex; + register int pixcode, ci; + register JSAMPROW ptrin, ptrout; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + register int nc = cinfo->out_color_components; + + for (row = 0; row < num_rows; row++) { + ptrin = input_buf[row]; + ptrout = output_buf[row]; + for (col = width; col > 0; col--) { + pixcode = 0; + for (ci = 0; ci < nc; ci++) { + pixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]); + } + *ptrout++ = (JSAMPLE) pixcode; + } + } +} + + +METHODDEF(void) +color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* Fast path for out_color_components==3, no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register int pixcode; + register JSAMPROW ptrin, ptrout; + JSAMPROW colorindex0 = cquantize->colorindex[0]; + JSAMPROW colorindex1 = cquantize->colorindex[1]; + JSAMPROW colorindex2 = cquantize->colorindex[2]; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + ptrin = input_buf[row]; + ptrout = output_buf[row]; + for (col = width; col > 0; col--) { + pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]); + pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]); + pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]); + *ptrout++ = (JSAMPLE) pixcode; + } + } +} + + +METHODDEF(void) +quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, with ordered dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex_ci; + int * dither; /* points to active row of dither matrix */ + int row_index, col_index; /* current indexes into dither matrix */ + int nc = cinfo->out_color_components; + int ci; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + /* Initialize output values to 0 so can process components separately */ + FMEMZERO((void FAR *) output_buf[row], (size_t) width * SIZEOF(JSAMPLE)); + row_index = cquantize->row_index; + for (ci = 0; ci < nc; ci++) { + input_ptr = input_buf[row] + ci; + output_ptr = output_buf[row]; + colorindex_ci = cquantize->colorindex[ci]; + dither = cquantize->odither[ci][row_index]; + col_index = 0; + + for (col = width; col > 0; col--) { + /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE, + * select output value, accumulate into output code for this pixel. + * Range-limiting need not be done explicitly, as we have extended + * the colorindex table to produce the right answers for out-of-range + * inputs. The maximum dither is +- MAXJSAMPLE; this sets the + * required amount of padding. + */ + *output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]]; + input_ptr += nc; + output_ptr++; + col_index = (col_index + 1) & ODITHER_MASK; + } + } + /* Advance row index for next row */ + row_index = (row_index + 1) & ODITHER_MASK; + cquantize->row_index = row_index; + } +} + + +METHODDEF(void) +quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* Fast path for out_color_components==3, with ordered dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register int pixcode; + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex0 = cquantize->colorindex[0]; + JSAMPROW colorindex1 = cquantize->colorindex[1]; + JSAMPROW colorindex2 = cquantize->colorindex[2]; + int * dither0; /* points to active row of dither matrix */ + int * dither1; + int * dither2; + int row_index, col_index; /* current indexes into dither matrix */ + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + row_index = cquantize->row_index; + input_ptr = input_buf[row]; + output_ptr = output_buf[row]; + dither0 = cquantize->odither[0][row_index]; + dither1 = cquantize->odither[1][row_index]; + dither2 = cquantize->odither[2][row_index]; + col_index = 0; + + for (col = width; col > 0; col--) { + pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) + + dither0[col_index]]); + pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) + + dither1[col_index]]); + pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) + + dither2[col_index]]); + *output_ptr++ = (JSAMPLE) pixcode; + col_index = (col_index + 1) & ODITHER_MASK; + } + row_index = (row_index + 1) & ODITHER_MASK; + cquantize->row_index = row_index; + } +} + + +METHODDEF(void) +quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, with Floyd-Steinberg dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register LOCFSERROR cur; /* current error or pixel value */ + LOCFSERROR belowerr; /* error for pixel below cur */ + LOCFSERROR bpreverr; /* error for below/prev col */ + LOCFSERROR bnexterr; /* error for below/next col */ + LOCFSERROR delta; + register FSERRPTR errorptr; /* => fserrors[] at column before current */ + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex_ci; + JSAMPROW colormap_ci; + int pixcode; + int nc = cinfo->out_color_components; + int dir; /* 1 for left-to-right, -1 for right-to-left */ + int dirnc; /* dir * nc */ + int ci; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + JSAMPLE *range_limit = cinfo->sample_range_limit; + SHIFT_TEMPS + + for (row = 0; row < num_rows; row++) { + /* Initialize output values to 0 so can process components separately */ + FMEMZERO((void FAR *) output_buf[row], (size_t) width * SIZEOF(JSAMPLE)); + for (ci = 0; ci < nc; ci++) { + input_ptr = input_buf[row] + ci; + output_ptr = output_buf[row]; + if (cquantize->on_odd_row) { + /* work right to left in this row */ + input_ptr += (width-1) * nc; /* so point to rightmost pixel */ + output_ptr += width-1; + dir = -1; + dirnc = -nc; + errorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */ + } else { + /* work left to right in this row */ + dir = 1; + dirnc = nc; + errorptr = cquantize->fserrors[ci]; /* => entry before first column */ + } + colorindex_ci = cquantize->colorindex[ci]; + colormap_ci = cquantize->sv_colormap[ci]; + /* Preset error values: no error propagated to first pixel from left */ + cur = 0; + /* and no error propagated to row below yet */ + belowerr = bpreverr = 0; + + for (col = width; col > 0; col--) { + /* cur holds the error propagated from the previous pixel on the + * current line. Add the error propagated from the previous line + * to form the complete error correction term for this pixel, and + * round the error term (which is expressed * 16) to an integer. + * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct + * for either sign of the error value. + * Note: errorptr points to *previous* column's array entry. + */ + cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4); + /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. + * The maximum error is +- MAXJSAMPLE; this sets the required size + * of the range_limit array. + */ + cur += GETJSAMPLE(*input_ptr); + cur = GETJSAMPLE(range_limit[cur]); + /* Select output value, accumulate into output code for this pixel */ + pixcode = GETJSAMPLE(colorindex_ci[cur]); + *output_ptr += (JSAMPLE) pixcode; + /* Compute actual representation error at this pixel */ + /* Note: we can do this even though we don't have the final */ + /* pixel code, because the colormap is orthogonal. */ + cur -= GETJSAMPLE(colormap_ci[pixcode]); + /* Compute error fractions to be propagated to adjacent pixels. + * Add these into the running sums, and simultaneously shift the + * next-line error sums left by 1 column. + */ + bnexterr = cur; + delta = cur * 2; + cur += delta; /* form error * 3 */ + errorptr[0] = (FSERROR) (bpreverr + cur); + cur += delta; /* form error * 5 */ + bpreverr = belowerr + cur; + belowerr = bnexterr; + cur += delta; /* form error * 7 */ + /* At this point cur contains the 7/16 error value to be propagated + * to the next pixel on the current line, and all the errors for the + * next line have been shifted over. We are therefore ready to move on. + */ + input_ptr += dirnc; /* advance input ptr to next column */ + output_ptr += dir; /* advance output ptr to next column */ + errorptr += dir; /* advance errorptr to current column */ + } + /* Post-loop cleanup: we must unload the final error value into the + * final fserrors[] entry. Note we need not unload belowerr because + * it is for the dummy column before or after the actual array. + */ + errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */ + } + cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE); + } +} + + +/* + * Allocate workspace for Floyd-Steinberg errors. + */ + +LOCAL(void) +alloc_fs_workspace (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + size_t arraysize; + int i; + + arraysize = ((size_t) cinfo->output_width + (size_t) 2) * SIZEOF(FSERROR); + for (i = 0; i < cinfo->out_color_components; i++) { + cquantize->fserrors[i] = (FSERRPTR) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); + } +} + + +/* + * Initialize for one-pass color quantization. + */ + +METHODDEF(void) +start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + size_t arraysize; + int i; + + /* Install my colormap. */ + cinfo->colormap = cquantize->sv_colormap; + cinfo->actual_number_of_colors = cquantize->sv_actual; + + /* Initialize for desired dithering mode. */ + switch (cinfo->dither_mode) { + case JDITHER_NONE: + if (cinfo->out_color_components == 3) + cquantize->pub.color_quantize = color_quantize3; + else + cquantize->pub.color_quantize = color_quantize; + break; + case JDITHER_ORDERED: + if (cinfo->out_color_components == 3) + cquantize->pub.color_quantize = quantize3_ord_dither; + else + cquantize->pub.color_quantize = quantize_ord_dither; + cquantize->row_index = 0; /* initialize state for ordered dither */ + /* If user changed to ordered dither from another mode, + * we must recreate the color index table with padding. + * This will cost extra space, but probably isn't very likely. + */ + if (! cquantize->is_padded) + create_colorindex(cinfo); + /* Create ordered-dither tables if we didn't already. */ + if (cquantize->odither[0] == NULL) + create_odither_tables(cinfo); + break; + case JDITHER_FS: + cquantize->pub.color_quantize = quantize_fs_dither; + cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */ + /* Allocate Floyd-Steinberg workspace if didn't already. */ + if (cquantize->fserrors[0] == NULL) + alloc_fs_workspace(cinfo); + /* Initialize the propagated errors to zero. */ + arraysize = ((size_t) cinfo->output_width + (size_t) 2) * SIZEOF(FSERROR); + for (i = 0; i < cinfo->out_color_components; i++) + FMEMZERO((void FAR *) cquantize->fserrors[i], arraysize); + break; + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + } +} + + +/* + * Finish up at the end of the pass. + */ + +METHODDEF(void) +finish_pass_1_quant (j_decompress_ptr cinfo) +{ + /* no work in 1-pass case */ +} + + +/* + * Switch to a new external colormap between output passes. + * Shouldn't get to this module! + */ + +METHODDEF(void) +new_color_map_1_quant (j_decompress_ptr cinfo) +{ + ERREXIT(cinfo, JERR_MODE_CHANGE); +} + + +/* + * Module initialization routine for 1-pass color quantization. + */ + +GLOBAL(void) +jinit_1pass_quantizer (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize; + + cquantize = (my_cquantize_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_cquantizer)); + cinfo->cquantize = &cquantize->pub; + cquantize->pub.start_pass = start_pass_1_quant; + cquantize->pub.finish_pass = finish_pass_1_quant; + cquantize->pub.new_color_map = new_color_map_1_quant; + cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */ + cquantize->odither[0] = NULL; /* Also flag odither arrays not allocated */ + + /* Make sure my internal arrays won't overflow */ + if (cinfo->out_color_components > MAX_Q_COMPS) + ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS); + /* Make sure colormap indexes can be represented by JSAMPLEs */ + if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1)) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1); + + /* Create the colormap and color index table. */ + create_colormap(cinfo); + create_colorindex(cinfo); + + /* Allocate Floyd-Steinberg workspace now if requested. + * We do this now since it is FAR storage and may affect the memory + * manager's space calculations. If the user changes to FS dither + * mode in a later pass, we will allocate the space then, and will + * possibly overrun the max_memory_to_use setting. + */ + if (cinfo->dither_mode == JDITHER_FS) + alloc_fs_workspace(cinfo); +} + +#endif /* QUANT_1PASS_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/jquant2.c b/thirdparty/jpeg-9e/jquant2.c new file mode 100644 index 0000000..662b9bc --- /dev/null +++ b/thirdparty/jpeg-9e/jquant2.c @@ -0,0 +1,1311 @@ +/* + * jquant2.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2011-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains 2-pass color quantization (color mapping) routines. + * These routines provide selection of a custom color map for an image, + * followed by mapping of the image to that color map, with optional + * Floyd-Steinberg dithering. + * It is also possible to use just the second pass to map to an arbitrary + * externally-given color map. + * + * Note: ordered dithering is not supported, since there isn't any fast + * way to compute intercolor distances; it's unclear that ordered dither's + * fundamental assumptions even hold with an irregularly spaced color map. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef QUANT_2PASS_SUPPORTED + + +/* + * This module implements the well-known Heckbert paradigm for color + * quantization. Most of the ideas used here can be traced back to + * Heckbert's seminal paper + * Heckbert, Paul. "Color Image Quantization for Frame Buffer Display", + * Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304. + * + * In the first pass over the image, we accumulate a histogram showing the + * usage count of each possible color. To keep the histogram to a reasonable + * size, we reduce the precision of the input; typical practice is to retain + * 5 or 6 bits per color, so that 8 or 4 different input values are counted + * in the same histogram cell. + * + * Next, the color-selection step begins with a box representing the whole + * color space, and repeatedly splits the "largest" remaining box until we + * have as many boxes as desired colors. Then the mean color in each + * remaining box becomes one of the possible output colors. + * + * The second pass over the image maps each input pixel to the closest output + * color (optionally after applying a Floyd-Steinberg dithering correction). + * This mapping is logically trivial, but making it go fast enough requires + * considerable care. + * + * Heckbert-style quantizers vary a good deal in their policies for choosing + * the "largest" box and deciding where to cut it. The particular policies + * used here have proved out well in experimental comparisons, but better ones + * may yet be found. + * + * In earlier versions of the IJG code, this module quantized in YCbCr color + * space, processing the raw upsampled data without a color conversion step. + * This allowed the color conversion math to be done only once per colormap + * entry, not once per pixel. However, that optimization precluded other + * useful optimizations (such as merging color conversion with upsampling) + * and it also interfered with desired capabilities such as quantizing to an + * externally-supplied colormap. We have therefore abandoned that approach. + * The present code works in the post-conversion color space, typically RGB. + * + * To improve the visual quality of the results, we actually work in scaled + * RGB space, giving G distances more weight than R, and R in turn more than + * B. To do everything in integer math, we must use integer scale factors. + * The 2/3/1 scale factors used here correspond loosely to the relative + * weights of the colors in the NTSC grayscale equation. + * If you want to use this code to quantize a non-RGB color space, you'll + * probably need to change these scale factors. + */ + +#define R_SCALE 2 /* scale R distances by this much */ +#define G_SCALE 3 /* scale G distances by this much */ +#define B_SCALE 1 /* and B by this much */ + +/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined + * in jmorecfg.h. As the code stands, it will do the right thing for R,G,B + * and B,G,R orders. If you define some other weird order in jmorecfg.h, + * you'll get compile errors until you extend this logic. In that case + * you'll probably want to tweak the histogram sizes too. + */ + +#if RGB_RED == 0 +#define C0_SCALE R_SCALE +#endif +#if RGB_BLUE == 0 +#define C0_SCALE B_SCALE +#endif +#if RGB_GREEN == 1 +#define C1_SCALE G_SCALE +#endif +#if RGB_RED == 2 +#define C2_SCALE R_SCALE +#endif +#if RGB_BLUE == 2 +#define C2_SCALE B_SCALE +#endif + + +/* + * First we have the histogram data structure and routines for creating it. + * + * The number of bits of precision can be adjusted by changing these symbols. + * We recommend keeping 6 bits for G and 5 each for R and B. + * If you have plenty of memory and cycles, 6 bits all around gives marginally + * better results; if you are short of memory, 5 bits all around will save + * some space but degrade the results. + * To maintain a fully accurate histogram, we'd need to allocate a "long" + * (preferably unsigned long) for each cell. In practice this is overkill; + * we can get by with 16 bits per cell. Few of the cell counts will overflow, + * and clamping those that do overflow to the maximum value will give close- + * enough results. This reduces the recommended histogram size from 256Kb + * to 128Kb, which is a useful savings on PC-class machines. + * (In the second pass the histogram space is re-used for pixel mapping data; + * in that capacity, each cell must be able to store zero to the number of + * desired colors. 16 bits/cell is plenty for that too.) + * Since the JPEG code is intended to run in small memory model on 80x86 + * machines, we can't just allocate the histogram in one chunk. Instead + * of a true 3-D array, we use a row of pointers to 2-D arrays. Each + * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and + * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that + * on 80x86 machines, the pointer row is in near memory but the actual + * arrays are in far memory (same arrangement as we use for image arrays). + */ + +#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */ + +/* These will do the right thing for either R,G,B or B,G,R color order, + * but you may not like the results for other color orders. + */ +#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */ +#define HIST_C1_BITS 6 /* bits of precision in G histogram */ +#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */ + +/* Number of elements along histogram axes. */ +#define HIST_C0_ELEMS (1<cquantize; + register JSAMPROW ptr; + register histptr histp; + register hist3d histogram = cquantize->histogram; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + ptr = input_buf[row]; + for (col = width; col > 0; col--) { + /* get pixel value and index into the histogram */ + histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT] + [GETJSAMPLE(ptr[1]) >> C1_SHIFT] + [GETJSAMPLE(ptr[2]) >> C2_SHIFT]; + /* increment, check for overflow and undo increment if so. */ + if (++(*histp) <= 0) + (*histp)--; + ptr += 3; + } + } +} + + +/* + * Next we have the really interesting routines: selection of a colormap + * given the completed histogram. + * These routines work with a list of "boxes", each representing a rectangular + * subset of the input color space (to histogram precision). + */ + +typedef struct { + /* The bounds of the box (inclusive); expressed as histogram indexes */ + int c0min, c0max; + int c1min, c1max; + int c2min, c2max; + /* The volume (actually 2-norm) of the box */ + INT32 volume; + /* The number of nonzero histogram cells within this box */ + long colorcount; +} box; + +typedef box * boxptr; + + +LOCAL(boxptr) +find_biggest_color_pop (boxptr boxlist, int numboxes) +/* Find the splittable box with the largest color population */ +/* Returns NULL if no splittable boxes remain */ +{ + register boxptr boxp; + register int i; + register long maxc = 0; + boxptr which = NULL; + + for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { + if (boxp->colorcount > maxc && boxp->volume > 0) { + which = boxp; + maxc = boxp->colorcount; + } + } + return which; +} + + +LOCAL(boxptr) +find_biggest_volume (boxptr boxlist, int numboxes) +/* Find the splittable box with the largest (scaled) volume */ +/* Returns NULL if no splittable boxes remain */ +{ + register boxptr boxp; + register int i; + register INT32 maxv = 0; + boxptr which = NULL; + + for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { + if (boxp->volume > maxv) { + which = boxp; + maxv = boxp->volume; + } + } + return which; +} + + +LOCAL(void) +update_box (j_decompress_ptr cinfo, boxptr boxp) +/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ +/* and recompute its volume and population */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + histptr histp; + int c0,c1,c2; + int c0min,c0max,c1min,c1max,c2min,c2max; + INT32 dist0,dist1,dist2; + long ccount; + + c0min = boxp->c0min; c0max = boxp->c0max; + c1min = boxp->c1min; c1max = boxp->c1max; + c2min = boxp->c2min; c2max = boxp->c2max; + + if (c0max > c0min) + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c0min = c0min = c0; + goto have_c0min; + } + } + have_c0min: + if (c0max > c0min) + for (c0 = c0max; c0 >= c0min; c0--) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c0max = c0max = c0; + goto have_c0max; + } + } + have_c0max: + if (c1max > c1min) + for (c1 = c1min; c1 <= c1max; c1++) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c1min = c1min = c1; + goto have_c1min; + } + } + have_c1min: + if (c1max > c1min) + for (c1 = c1max; c1 >= c1min; c1--) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c1max = c1max = c1; + goto have_c1max; + } + } + have_c1max: + if (c2max > c2min) + for (c2 = c2min; c2 <= c2max; c2++) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1min][c2]; + for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) + if (*histp != 0) { + boxp->c2min = c2min = c2; + goto have_c2min; + } + } + have_c2min: + if (c2max > c2min) + for (c2 = c2max; c2 >= c2min; c2--) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1min][c2]; + for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) + if (*histp != 0) { + boxp->c2max = c2max = c2; + goto have_c2max; + } + } + have_c2max: + + /* Update box volume. + * We use 2-norm rather than real volume here; this biases the method + * against making long narrow boxes, and it has the side benefit that + * a box is splittable iff norm > 0. + * Since the differences are expressed in histogram-cell units, + * we have to shift back to JSAMPLE units to get consistent distances; + * after which, we scale according to the selected distance scale factors. + */ + dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE; + dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; + dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; + boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; + + /* Now scan remaining volume of box and compute population */ + ccount = 0; + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++, histp++) + if (*histp != 0) { + ccount++; + } + } + boxp->colorcount = ccount; +} + + +LOCAL(int) +median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes, + int desired_colors) +/* Repeatedly select and split the largest box until we have enough boxes */ +{ + int n,lb; + int c0,c1,c2,cmax; + register boxptr b1,b2; + + while (numboxes < desired_colors) { + /* Select box to split. + * Current algorithm: by population for first half, then by volume. + */ + if (numboxes*2 <= desired_colors) { + b1 = find_biggest_color_pop(boxlist, numboxes); + } else { + b1 = find_biggest_volume(boxlist, numboxes); + } + if (b1 == NULL) /* no splittable boxes left! */ + break; + b2 = &boxlist[numboxes]; /* where new box will go */ + /* Copy the color bounds to the new box. */ + b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max; + b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min; + /* Choose which axis to split the box on. + * Current algorithm: longest scaled axis. + * See notes in update_box about scaling distances. + */ + c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE; + c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE; + c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE; + /* We want to break any ties in favor of green, then red, blue last. + * This code does the right thing for R,G,B or B,G,R color orders only. + */ +#if RGB_RED == 0 + cmax = c1; n = 1; + if (c0 > cmax) { cmax = c0; n = 0; } + if (c2 > cmax) { n = 2; } +#else + cmax = c1; n = 1; + if (c2 > cmax) { cmax = c2; n = 2; } + if (c0 > cmax) { n = 0; } +#endif + /* Choose split point along selected axis, and update box bounds. + * Current algorithm: split at halfway point. + * (Since the box has been shrunk to minimum volume, + * any split will produce two nonempty subboxes.) + * Note that lb value is max for lower box, so must be < old max. + */ + switch (n) { + case 0: + lb = (b1->c0max + b1->c0min) / 2; + b1->c0max = lb; + b2->c0min = lb+1; + break; + case 1: + lb = (b1->c1max + b1->c1min) / 2; + b1->c1max = lb; + b2->c1min = lb+1; + break; + case 2: + lb = (b1->c2max + b1->c2min) / 2; + b1->c2max = lb; + b2->c2min = lb+1; + break; + } + /* Update stats for boxes */ + update_box(cinfo, b1); + update_box(cinfo, b2); + numboxes++; + } + return numboxes; +} + + +LOCAL(void) +compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor) +/* Compute representative color for a box, put it in colormap[icolor] */ +{ + /* Current algorithm: mean weighted by pixels (not colors) */ + /* Note it is important to get the rounding correct! */ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + histptr histp; + int c0,c1,c2; + int c0min,c0max,c1min,c1max,c2min,c2max; + long count; + long total = 0; + long c0total = 0; + long c1total = 0; + long c2total = 0; + + c0min = boxp->c0min; c0max = boxp->c0max; + c1min = boxp->c1min; c1max = boxp->c1max; + c2min = boxp->c2min; c2max = boxp->c2max; + + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) { + if ((count = *histp++) != 0) { + total += count; + c0total += ((c0 << C0_SHIFT) + ((1<>1)) * count; + c1total += ((c1 << C1_SHIFT) + ((1<>1)) * count; + c2total += ((c2 << C2_SHIFT) + ((1<>1)) * count; + } + } + } + + cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); + cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); + cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); +} + + +LOCAL(void) +select_colors (j_decompress_ptr cinfo, int desired_colors) +/* Master routine for color selection */ +{ + boxptr boxlist; + int numboxes; + int i; + + /* Allocate workspace for box list */ + boxlist = (boxptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box)); + /* Initialize one box containing whole space */ + numboxes = 1; + boxlist[0].c0min = 0; + boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT; + boxlist[0].c1min = 0; + boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT; + boxlist[0].c2min = 0; + boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT; + /* Shrink it to actually-used volume and set its statistics */ + update_box(cinfo, & boxlist[0]); + /* Perform median-cut to produce final box list */ + numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors); + /* Compute the representative color for each box, fill colormap */ + for (i = 0; i < numboxes; i++) + compute_color(cinfo, & boxlist[i], i); + cinfo->actual_number_of_colors = numboxes; + TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes); +} + + +/* + * These routines are concerned with the time-critical task of mapping input + * colors to the nearest color in the selected colormap. + * + * We re-use the histogram space as an "inverse color map", essentially a + * cache for the results of nearest-color searches. All colors within a + * histogram cell will be mapped to the same colormap entry, namely the one + * closest to the cell's center. This may not be quite the closest entry to + * the actual input color, but it's almost as good. A zero in the cache + * indicates we haven't found the nearest color for that cell yet; the array + * is cleared to zeroes before starting the mapping pass. When we find the + * nearest color for a cell, its colormap index plus one is recorded in the + * cache for future use. The pass2 scanning routines call fill_inverse_cmap + * when they need to use an unfilled entry in the cache. + * + * Our method of efficiently finding nearest colors is based on the "locally + * sorted search" idea described by Heckbert and on the incremental distance + * calculation described by Spencer W. Thomas in chapter III.1 of Graphics + * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that + * the distances from a given colormap entry to each cell of the histogram can + * be computed quickly using an incremental method: the differences between + * distances to adjacent cells themselves differ by a constant. This allows a + * fairly fast implementation of the "brute force" approach of computing the + * distance from every colormap entry to every histogram cell. Unfortunately, + * it needs a work array to hold the best-distance-so-far for each histogram + * cell (because the inner loop has to be over cells, not colormap entries). + * The work array elements have to be INT32s, so the work array would need + * 256Kb at our recommended precision. This is not feasible in DOS machines. + * + * To get around these problems, we apply Thomas' method to compute the + * nearest colors for only the cells within a small subbox of the histogram. + * The work array need be only as big as the subbox, so the memory usage + * problem is solved. Furthermore, we need not fill subboxes that are never + * referenced in pass2; many images use only part of the color gamut, so a + * fair amount of work is saved. An additional advantage of this + * approach is that we can apply Heckbert's locality criterion to quickly + * eliminate colormap entries that are far away from the subbox; typically + * three-fourths of the colormap entries are rejected by Heckbert's criterion, + * and we need not compute their distances to individual cells in the subbox. + * The speed of this approach is heavily influenced by the subbox size: too + * small means too much overhead, too big loses because Heckbert's criterion + * can't eliminate as many colormap entries. Empirically the best subbox + * size seems to be about 1/512th of the histogram (1/8th in each direction). + * + * Thomas' article also describes a refined method which is asymptotically + * faster than the brute-force method, but it is also far more complex and + * cannot efficiently be applied to small subboxes. It is therefore not + * useful for programs intended to be portable to DOS machines. On machines + * with plenty of memory, filling the whole histogram in one shot with Thomas' + * refined method might be faster than the present code --- but then again, + * it might not be any faster, and it's certainly more complicated. + */ + + +/* log2(histogram cells in update box) for each axis; this can be adjusted */ +#define BOX_C0_LOG (HIST_C0_BITS-3) +#define BOX_C1_LOG (HIST_C1_BITS-3) +#define BOX_C2_LOG (HIST_C2_BITS-3) + +#define BOX_C0_ELEMS (1<actual_number_of_colors; + int maxc0, maxc1, maxc2; + int centerc0, centerc1, centerc2; + int i, x, ncolors; + INT32 minmaxdist, min_dist, max_dist, tdist; + INT32 mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */ + + /* Compute true coordinates of update box's upper corner and center. + * Actually we compute the coordinates of the center of the upper-corner + * histogram cell, which are the upper bounds of the volume we care about. + * Note that since ">>" rounds down, the "center" values may be closer to + * min than to max; hence comparisons to them must be "<=", not "<". + */ + maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT)); + centerc0 = (minc0 + maxc0) >> 1; + maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT)); + centerc1 = (minc1 + maxc1) >> 1; + maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT)); + centerc2 = (minc2 + maxc2) >> 1; + + /* For each color in colormap, find: + * 1. its minimum squared-distance to any point in the update box + * (zero if color is within update box); + * 2. its maximum squared-distance to any point in the update box. + * Both of these can be found by considering only the corners of the box. + * We save the minimum distance for each color in mindist[]; + * only the smallest maximum distance is of interest. + */ + minmaxdist = 0x7FFFFFFFL; + + for (i = 0; i < numcolors; i++) { + /* We compute the squared-c0-distance term, then add in the other two. */ + x = GETJSAMPLE(cinfo->colormap[0][i]); + if (x < minc0) { + tdist = (x - minc0) * C0_SCALE; + min_dist = tdist*tdist; + tdist = (x - maxc0) * C0_SCALE; + max_dist = tdist*tdist; + } else if (x > maxc0) { + tdist = (x - maxc0) * C0_SCALE; + min_dist = tdist*tdist; + tdist = (x - minc0) * C0_SCALE; + max_dist = tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + min_dist = 0; + if (x <= centerc0) { + tdist = (x - maxc0) * C0_SCALE; + max_dist = tdist*tdist; + } else { + tdist = (x - minc0) * C0_SCALE; + max_dist = tdist*tdist; + } + } + + x = GETJSAMPLE(cinfo->colormap[1][i]); + if (x < minc1) { + tdist = (x - minc1) * C1_SCALE; + min_dist += tdist*tdist; + tdist = (x - maxc1) * C1_SCALE; + max_dist += tdist*tdist; + } else if (x > maxc1) { + tdist = (x - maxc1) * C1_SCALE; + min_dist += tdist*tdist; + tdist = (x - minc1) * C1_SCALE; + max_dist += tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + if (x <= centerc1) { + tdist = (x - maxc1) * C1_SCALE; + max_dist += tdist*tdist; + } else { + tdist = (x - minc1) * C1_SCALE; + max_dist += tdist*tdist; + } + } + + x = GETJSAMPLE(cinfo->colormap[2][i]); + if (x < minc2) { + tdist = (x - minc2) * C2_SCALE; + min_dist += tdist*tdist; + tdist = (x - maxc2) * C2_SCALE; + max_dist += tdist*tdist; + } else if (x > maxc2) { + tdist = (x - maxc2) * C2_SCALE; + min_dist += tdist*tdist; + tdist = (x - minc2) * C2_SCALE; + max_dist += tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + if (x <= centerc2) { + tdist = (x - maxc2) * C2_SCALE; + max_dist += tdist*tdist; + } else { + tdist = (x - minc2) * C2_SCALE; + max_dist += tdist*tdist; + } + } + + mindist[i] = min_dist; /* save away the results */ + if (max_dist < minmaxdist) + minmaxdist = max_dist; + } + + /* Now we know that no cell in the update box is more than minmaxdist + * away from some colormap entry. Therefore, only colors that are + * within minmaxdist of some part of the box need be considered. + */ + ncolors = 0; + for (i = 0; i < numcolors; i++) { + if (mindist[i] <= minmaxdist) + colorlist[ncolors++] = (JSAMPLE) i; + } + return ncolors; +} + + +LOCAL(void) +find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2, + int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[]) +/* Find the closest colormap entry for each cell in the update box, + * given the list of candidate colors prepared by find_nearby_colors. + * Return the indexes of the closest entries in the bestcolor[] array. + * This routine uses Thomas' incremental distance calculation method to + * find the distance from a colormap entry to successive cells in the box. + */ +{ + int ic0, ic1, ic2; + int i, icolor; + register INT32 * bptr; /* pointer into bestdist[] array */ + JSAMPLE * cptr; /* pointer into bestcolor[] array */ + INT32 dist0, dist1; /* initial distance values */ + register INT32 dist2; /* current distance in inner loop */ + INT32 xx0, xx1; /* distance increments */ + register INT32 xx2; + INT32 inc0, inc1, inc2; /* initial values for increments */ + /* This array holds the distance to the nearest-so-far color for each cell */ + INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; + + /* Initialize best-distance for each cell of the update box */ + bptr = bestdist; + for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) + *bptr++ = 0x7FFFFFFFL; + + /* For each color selected by find_nearby_colors, + * compute its distance to the center of each cell in the box. + * If that's less than best-so-far, update best distance and color number. + */ + + /* Nominal steps between cell centers ("x" in Thomas article) */ +#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) +#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) +#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) + + for (i = 0; i < numcolors; i++) { + icolor = GETJSAMPLE(colorlist[i]); + /* Compute (square of) distance from minc0/c1/c2 to this color */ + inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE; + dist0 = inc0*inc0; + inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE; + dist0 += inc1*inc1; + inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE; + dist0 += inc2*inc2; + /* Form the initial difference increments */ + inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0; + inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1; + inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2; + /* Now loop over all cells in box, updating distance per Thomas method */ + bptr = bestdist; + cptr = bestcolor; + xx0 = inc0; + for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) { + dist1 = dist0; + xx1 = inc1; + for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) { + dist2 = dist1; + xx2 = inc2; + for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) { + if (dist2 < *bptr) { + *bptr = dist2; + *cptr = (JSAMPLE) icolor; + } + dist2 += xx2; + xx2 += 2 * STEP_C2 * STEP_C2; + bptr++; + cptr++; + } + dist1 += xx1; + xx1 += 2 * STEP_C1 * STEP_C1; + } + dist0 += xx0; + xx0 += 2 * STEP_C0 * STEP_C0; + } + } +} + + +LOCAL(void) +fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2) +/* Fill the inverse-colormap entries in the update box that contains */ +/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */ +/* we can fill as many others as we wish.) */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + int minc0, minc1, minc2; /* lower left corner of update box */ + int ic0, ic1, ic2; + register JSAMPLE * cptr; /* pointer into bestcolor[] array */ + register histptr cachep; /* pointer into main cache array */ + /* This array lists the candidate colormap indexes. */ + JSAMPLE colorlist[MAXNUMCOLORS]; + int numcolors; /* number of candidate colors */ + /* This array holds the actually closest colormap index for each cell. */ + JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; + + /* Convert cell coordinates to update box ID */ + c0 >>= BOX_C0_LOG; + c1 >>= BOX_C1_LOG; + c2 >>= BOX_C2_LOG; + + /* Compute true coordinates of update box's origin corner. + * Actually we compute the coordinates of the center of the corner + * histogram cell, which are the lower bounds of the volume we care about. + */ + minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); + minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); + minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); + + /* Determine which colormap entries are close enough to be candidates + * for the nearest entry to some cell in the update box. + */ + numcolors = find_nearby_colors(cinfo, minc0, minc1, minc2, colorlist); + + /* Determine the actually nearest colors. */ + find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist, + bestcolor); + + /* Save the best color numbers (plus 1) in the main cache array */ + c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */ + c1 <<= BOX_C1_LOG; + c2 <<= BOX_C2_LOG; + cptr = bestcolor; + for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) { + for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) { + cachep = & histogram[c0+ic0][c1+ic1][c2]; + for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) { + *cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1); + } + } + } +} + + +/* + * Map some rows of pixels to the output colormapped representation. + */ + +METHODDEF(void) +pass2_no_dither (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) +/* This version performs no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + register JSAMPROW inptr, outptr; + register histptr cachep; + register int c0, c1, c2; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + inptr = input_buf[row]; + outptr = output_buf[row]; + for (col = width; col > 0; col--) { + /* get pixel value and index into the cache */ + c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT; + c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT; + c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT; + cachep = & histogram[c0][c1][c2]; + /* If we have not seen this color before, find nearest colormap entry */ + /* and update the cache */ + if (*cachep == 0) + fill_inverse_cmap(cinfo, c0,c1,c2); + /* Now emit the colormap index for this cell */ + *outptr++ = (JSAMPLE) (*cachep - 1); + } + } +} + + +METHODDEF(void) +pass2_fs_dither (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) +/* This version performs Floyd-Steinberg dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ + LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ + LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ + register FSERRPTR errorptr; /* => fserrors[] at column before current */ + JSAMPROW inptr; /* => current input pixel */ + JSAMPROW outptr; /* => current output pixel */ + histptr cachep; + int dir; /* +1 or -1 depending on direction */ + int dir3; /* 3*dir, for advancing inptr & errorptr */ + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + JSAMPLE *range_limit = cinfo->sample_range_limit; + int *error_limit = cquantize->error_limiter; + JSAMPROW colormap0 = cinfo->colormap[0]; + JSAMPROW colormap1 = cinfo->colormap[1]; + JSAMPROW colormap2 = cinfo->colormap[2]; + SHIFT_TEMPS + + for (row = 0; row < num_rows; row++) { + inptr = input_buf[row]; + outptr = output_buf[row]; + if (cquantize->on_odd_row) { + /* work right to left in this row */ + inptr += (width-1) * 3; /* so point to rightmost pixel */ + outptr += width-1; + dir = -1; + dir3 = -3; + errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */ + cquantize->on_odd_row = FALSE; /* flip for next time */ + } else { + /* work left to right in this row */ + dir = 1; + dir3 = 3; + errorptr = cquantize->fserrors; /* => entry before first real column */ + cquantize->on_odd_row = TRUE; /* flip for next time */ + } + /* Preset error values: no error propagated to first pixel from left */ + cur0 = cur1 = cur2 = 0; + /* and no error propagated to row below yet */ + belowerr0 = belowerr1 = belowerr2 = 0; + bpreverr0 = bpreverr1 = bpreverr2 = 0; + + for (col = width; col > 0; col--) { + /* curN holds the error propagated from the previous pixel on the + * current line. Add the error propagated from the previous line + * to form the complete error correction term for this pixel, and + * round the error term (which is expressed * 16) to an integer. + * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct + * for either sign of the error value. + * Note: errorptr points to *previous* column's array entry. + */ + cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4); + cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4); + cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4); + /* Limit the error using transfer function set by init_error_limit. + * See comments with init_error_limit for rationale. + */ + cur0 = error_limit[cur0]; + cur1 = error_limit[cur1]; + cur2 = error_limit[cur2]; + /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. + * The maximum error is +- MAXJSAMPLE (or less with error limiting); + * this sets the required size of the range_limit array. + */ + cur0 += GETJSAMPLE(inptr[0]); + cur1 += GETJSAMPLE(inptr[1]); + cur2 += GETJSAMPLE(inptr[2]); + cur0 = GETJSAMPLE(range_limit[cur0]); + cur1 = GETJSAMPLE(range_limit[cur1]); + cur2 = GETJSAMPLE(range_limit[cur2]); + /* Index into the cache with adjusted pixel value */ + cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT]; + /* If we have not seen this color before, find nearest colormap */ + /* entry and update the cache */ + if (*cachep == 0) + fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT); + /* Now emit the colormap index for this cell */ + { register int pixcode = *cachep - 1; + *outptr = (JSAMPLE) pixcode; + /* Compute representation error for this pixel */ + cur0 -= GETJSAMPLE(colormap0[pixcode]); + cur1 -= GETJSAMPLE(colormap1[pixcode]); + cur2 -= GETJSAMPLE(colormap2[pixcode]); + } + /* Compute error fractions to be propagated to adjacent pixels. + * Add these into the running sums, and simultaneously shift the + * next-line error sums left by 1 column. + */ + { register LOCFSERROR bnexterr, delta; + + bnexterr = cur0; /* Process component 0 */ + delta = cur0 * 2; + cur0 += delta; /* form error * 3 */ + errorptr[0] = (FSERROR) (bpreverr0 + cur0); + cur0 += delta; /* form error * 5 */ + bpreverr0 = belowerr0 + cur0; + belowerr0 = bnexterr; + cur0 += delta; /* form error * 7 */ + bnexterr = cur1; /* Process component 1 */ + delta = cur1 * 2; + cur1 += delta; /* form error * 3 */ + errorptr[1] = (FSERROR) (bpreverr1 + cur1); + cur1 += delta; /* form error * 5 */ + bpreverr1 = belowerr1 + cur1; + belowerr1 = bnexterr; + cur1 += delta; /* form error * 7 */ + bnexterr = cur2; /* Process component 2 */ + delta = cur2 * 2; + cur2 += delta; /* form error * 3 */ + errorptr[2] = (FSERROR) (bpreverr2 + cur2); + cur2 += delta; /* form error * 5 */ + bpreverr2 = belowerr2 + cur2; + belowerr2 = bnexterr; + cur2 += delta; /* form error * 7 */ + } + /* At this point curN contains the 7/16 error value to be propagated + * to the next pixel on the current line, and all the errors for the + * next line have been shifted over. We are therefore ready to move on. + */ + inptr += dir3; /* Advance pixel pointers to next column */ + outptr += dir; + errorptr += dir3; /* advance errorptr to current column */ + } + /* Post-loop cleanup: we must unload the final error values into the + * final fserrors[] entry. Note we need not unload belowerrN because + * it is for the dummy column before or after the actual array. + */ + errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */ + errorptr[1] = (FSERROR) bpreverr1; + errorptr[2] = (FSERROR) bpreverr2; + } +} + + +/* + * Initialize the error-limiting transfer function (lookup table). + * The raw F-S error computation can potentially compute error values of up to + * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be + * much less, otherwise obviously wrong pixels will be created. (Typical + * effects include weird fringes at color-area boundaries, isolated bright + * pixels in a dark area, etc.) The standard advice for avoiding this problem + * is to ensure that the "corners" of the color cube are allocated as output + * colors; then repeated errors in the same direction cannot cause cascading + * error buildup. However, that only prevents the error from getting + * completely out of hand; Aaron Giles reports that error limiting improves + * the results even with corner colors allocated. + * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty + * well, but the smoother transfer function used below is even better. Thanks + * to Aaron Giles for this idea. + */ + +LOCAL(void) +init_error_limit (j_decompress_ptr cinfo) +/* Allocate and fill in the error_limiter table */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + int * table; + int in, out; + + table = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int)); + table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */ + cquantize->error_limiter = table; + +#define STEPSIZE ((MAXJSAMPLE+1)/16) + /* Map errors 1:1 up to +- MAXJSAMPLE/16 */ + out = 0; + for (in = 0; in < STEPSIZE; in++, out++) { + table[in] = out; table[-in] = -out; + } + /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */ + for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) { + table[in] = out; table[-in] = -out; + } + /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */ + for (; in <= MAXJSAMPLE; in++) { + table[in] = out; table[-in] = -out; + } +#undef STEPSIZE +} + + +/* + * Finish up at the end of each pass. + */ + +METHODDEF(void) +finish_pass1 (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + + /* Select the representative colors and fill in cinfo->colormap */ + cinfo->colormap = cquantize->sv_colormap; + select_colors(cinfo, cquantize->desired); + /* Force next pass to zero the color index table */ + cquantize->needs_zeroed = TRUE; +} + + +METHODDEF(void) +finish_pass2 (j_decompress_ptr cinfo) +{ + /* no work */ +} + + +/* + * Initialize for each processing pass. + */ + +METHODDEF(void) +start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + int i; + + /* Only F-S dithering or no dithering is supported. */ + /* If user asks for ordered dither, give him F-S. */ + if (cinfo->dither_mode != JDITHER_NONE) + cinfo->dither_mode = JDITHER_FS; + + if (is_pre_scan) { + /* Set up method pointers */ + cquantize->pub.color_quantize = prescan_quantize; + cquantize->pub.finish_pass = finish_pass1; + cquantize->needs_zeroed = TRUE; /* Always zero histogram */ + } else { + /* Set up method pointers */ + if (cinfo->dither_mode == JDITHER_FS) + cquantize->pub.color_quantize = pass2_fs_dither; + else + cquantize->pub.color_quantize = pass2_no_dither; + cquantize->pub.finish_pass = finish_pass2; + + /* Make sure color count is acceptable */ + i = cinfo->actual_number_of_colors; + if (i < 1) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 1); + if (i > MAXNUMCOLORS) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); + + if (cinfo->dither_mode == JDITHER_FS) { + size_t arraysize = ((size_t) cinfo->output_width + (size_t) 2) + * (3 * SIZEOF(FSERROR)); + /* Allocate Floyd-Steinberg workspace if we didn't already. */ + if (cquantize->fserrors == NULL) + cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); + /* Initialize the propagated errors to zero. */ + FMEMZERO((void FAR *) cquantize->fserrors, arraysize); + /* Make the error-limit table if we didn't already. */ + if (cquantize->error_limiter == NULL) + init_error_limit(cinfo); + cquantize->on_odd_row = FALSE; + } + + } + /* Zero the histogram or inverse color map, if necessary */ + if (cquantize->needs_zeroed) { + for (i = 0; i < HIST_C0_ELEMS; i++) { + FMEMZERO((void FAR *) histogram[i], + HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); + } + cquantize->needs_zeroed = FALSE; + } +} + + +/* + * Switch to a new external colormap between output passes. + */ + +METHODDEF(void) +new_color_map_2_quant (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + + /* Reset the inverse color map */ + cquantize->needs_zeroed = TRUE; +} + + +/* + * Module initialization routine for 2-pass color quantization. + */ + +GLOBAL(void) +jinit_2pass_quantizer (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize; + int i; + + cquantize = (my_cquantize_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_cquantizer)); + cinfo->cquantize = &cquantize->pub; + cquantize->pub.start_pass = start_pass_2_quant; + cquantize->pub.new_color_map = new_color_map_2_quant; + cquantize->fserrors = NULL; /* flag optional arrays not allocated */ + cquantize->error_limiter = NULL; + + /* Make sure jdmaster didn't give me a case I can't handle */ + if (cinfo->out_color_components != 3) + ERREXIT(cinfo, JERR_NOTIMPL); + + /* Allocate the histogram/inverse colormap storage */ + cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d)); + for (i = 0; i < HIST_C0_ELEMS; i++) { + cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); + } + cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ + + /* Allocate storage for the completed colormap, if required. + * We do this now since it is FAR storage and may affect + * the memory manager's space calculations. + */ + if (cinfo->enable_2pass_quant) { + /* Make sure color count is acceptable */ + int desired = cinfo->desired_number_of_colors; + /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */ + if (desired < 8) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 8); + /* Make sure colormap indexes can be represented by JSAMPLEs */ + if (desired > MAXNUMCOLORS) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); + cquantize->sv_colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) desired, (JDIMENSION) 3); + cquantize->desired = desired; + } else + cquantize->sv_colormap = NULL; + + /* Only F-S dithering or no dithering is supported. */ + /* If user asks for ordered dither, give him F-S. */ + if (cinfo->dither_mode != JDITHER_NONE) + cinfo->dither_mode = JDITHER_FS; + + /* Allocate Floyd-Steinberg workspace if necessary. + * This isn't really needed until pass 2, but again it is FAR storage. + * Although we will cope with a later change in dither_mode, + * we do not promise to honor max_memory_to_use if dither_mode changes. + */ + if (cinfo->dither_mode == JDITHER_FS) { + cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + ((size_t) cinfo->output_width + (size_t) 2) * (3 * SIZEOF(FSERROR))); + /* Might as well create the error-limiting table too. */ + init_error_limit(cinfo); + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/jutils.c b/thirdparty/jpeg-9e/jutils.c new file mode 100644 index 0000000..31e16df --- /dev/null +++ b/thirdparty/jpeg-9e/jutils.c @@ -0,0 +1,224 @@ +/* + * jutils.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2009-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains tables and miscellaneous utility routines needed + * for both compression and decompression. + * Note we prefix all global names with "j" to minimize conflicts with + * a surrounding application. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element + * of a DCT block read in natural order (left to right, top to bottom). + */ + +#if 0 /* This table is not actually needed in v6a */ + +const int jpeg_zigzag_order[DCTSIZE2] = { + 0, 1, 5, 6, 14, 15, 27, 28, + 2, 4, 7, 13, 16, 26, 29, 42, + 3, 8, 12, 17, 25, 30, 41, 43, + 9, 11, 18, 24, 31, 40, 44, 53, + 10, 19, 23, 32, 39, 45, 52, 54, + 20, 22, 33, 38, 46, 51, 55, 60, + 21, 34, 37, 47, 50, 56, 59, 61, + 35, 36, 48, 49, 57, 58, 62, 63 +}; + +#endif + +/* + * jpeg_natural_order[i] is the natural-order position of the i'th element + * of zigzag order. + * + * When reading corrupted data, the Huffman decoders could attempt + * to reference an entry beyond the end of this array (if the decoded + * zero run length reaches past the end of the block). To prevent + * wild stores without adding an inner-loop test, we put some extra + * "63"s after the real entries. This will cause the extra coefficient + * to be stored in location 63 of the block, not somewhere random. + * The worst case would be a run-length of 15, which means we need 16 + * fake entries. + */ + +const int jpeg_natural_order[DCTSIZE2+16] = { + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, + 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ + 63, 63, 63, 63, 63, 63, 63, 63 +}; + +const int jpeg_natural_order7[7*7+16] = { + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 14, 21, 28, 35, + 42, 49, 50, 43, 36, 29, 22, 30, + 37, 44, 51, 52, 45, 38, 46, 53, + 54, + 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ + 63, 63, 63, 63, 63, 63, 63, 63 +}; + +const int jpeg_natural_order6[6*6+16] = { + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 41, 34, 27, + 20, 13, 21, 28, 35, 42, 43, 36, + 29, 37, 44, 45, + 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ + 63, 63, 63, 63, 63, 63, 63, 63 +}; + +const int jpeg_natural_order5[5*5+16] = { + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 12, + 19, 26, 33, 34, 27, 20, 28, 35, + 36, + 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ + 63, 63, 63, 63, 63, 63, 63, 63 +}; + +const int jpeg_natural_order4[4*4+16] = { + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 25, 18, 11, 19, 26, 27, + 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ + 63, 63, 63, 63, 63, 63, 63, 63 +}; + +const int jpeg_natural_order3[3*3+16] = { + 0, 1, 8, 16, 9, 2, 10, 17, + 18, + 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ + 63, 63, 63, 63, 63, 63, 63, 63 +}; + +const int jpeg_natural_order2[2*2+16] = { + 0, 1, 8, 9, + 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ + 63, 63, 63, 63, 63, 63, 63, 63 +}; + + +/* + * Arithmetic utilities + */ + +GLOBAL(long) +jdiv_round_up (long a, long b) +/* Compute a/b rounded up to next integer, ie, ceil(a/b) */ +/* Assumes a >= 0, b > 0 */ +{ + return (a + b - 1L) / b; +} + + +GLOBAL(long) +jround_up (long a, long b) +/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ +/* Assumes a >= 0, b > 0 */ +{ + a += b - 1L; + return a - (a % b); +} + + +/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays + * and coefficient-block arrays. This won't work on 80x86 because the arrays + * are FAR and we're assuming a small-pointer memory model. However, some + * DOS compilers provide far-pointer versions of memcpy() and memset() even + * in the small-model libraries. These will be used if USE_FMEM is defined. + * Otherwise, the routines below do it the hard way. (The performance cost + * is not all that great, because these routines aren't very heavily used.) + */ + +#ifndef NEED_FAR_POINTERS /* normal case, same as regular macro */ +#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) +#else /* 80x86 case, define if we can */ +#ifdef USE_FMEM +#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) +#else +/* This function is for use by the FMEMZERO macro defined in jpegint.h. + * Do not call this function directly, use the FMEMZERO macro instead. + */ +GLOBAL(void) +jzero_far (void FAR * target, size_t bytestozero) +/* Zero out a chunk of FAR memory. */ +/* This might be sample-array data, block-array data, or alloc_large data. */ +{ + register char FAR * ptr = (char FAR *) target; + register size_t count; + + for (count = bytestozero; count > 0; count--) { + *ptr++ = 0; + } +} +#endif +#endif + + +GLOBAL(void) +jcopy_sample_rows (JSAMPARRAY input_array, + JSAMPARRAY output_array, + int num_rows, JDIMENSION num_cols) +/* Copy some rows of samples from one place to another. + * num_rows rows are copied from *input_array++ to *output_array++; + * these areas may overlap for duplication. + * The source and destination arrays must be at least as wide as num_cols. + */ +{ + register JSAMPROW inptr, outptr; +#ifdef FMEMCOPY + register size_t count = (size_t) num_cols * SIZEOF(JSAMPLE); +#else + register JDIMENSION count; +#endif + register int row; + + for (row = num_rows; row > 0; row--) { + inptr = *input_array++; + outptr = *output_array++; +#ifdef FMEMCOPY + FMEMCOPY(outptr, inptr, count); +#else + for (count = num_cols; count > 0; count--) + *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ +#endif + } +} + + +GLOBAL(void) +jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, + JDIMENSION num_blocks) +/* Copy a row of coefficient blocks from one place to another. */ +{ +#ifdef FMEMCOPY + FMEMCOPY(output_row, input_row, (size_t) num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); +#else + register JCOEFPTR inptr, outptr; + register long count; + + inptr = (JCOEFPTR) input_row; + outptr = (JCOEFPTR) output_row; + for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { + *outptr++ = *inptr++; + } +#endif +} diff --git a/thirdparty/jpeg-9e/jversion.h b/thirdparty/jpeg-9e/jversion.h new file mode 100644 index 0000000..17134b7 --- /dev/null +++ b/thirdparty/jpeg-9e/jversion.h @@ -0,0 +1,14 @@ +/* + * jversion.h + * + * Copyright (C) 1991-2022, Thomas G. Lane, Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains software version identification. + */ + + +#define JVERSION "9e 16-Jan-2022" + +#define JCOPYRIGHT "Copyright (C) 2022, Thomas G. Lane, Guido Vollbeding" diff --git a/thirdparty/jpeg-9e/libjpeg.map b/thirdparty/jpeg-9e/libjpeg.map new file mode 100644 index 0000000..fa70b1f --- /dev/null +++ b/thirdparty/jpeg-9e/libjpeg.map @@ -0,0 +1,4 @@ +LIBJPEG_9.0 { + global: + *; +}; diff --git a/thirdparty/jpeg-9e/libjpeg.pc b/thirdparty/jpeg-9e/libjpeg.pc new file mode 100644 index 0000000..8057c1d --- /dev/null +++ b/thirdparty/jpeg-9e/libjpeg.pc @@ -0,0 +1,10 @@ +prefix=/home/scott/code/gui/installed/linux +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: libjpeg +Description: Reads and writes JPEG files +Version: 9.5.0 +Libs: -L${libdir} -ljpeg +Cflags: -I${includedir} diff --git a/thirdparty/jpeg-9e/libjpeg.pc.in b/thirdparty/jpeg-9e/libjpeg.pc.in new file mode 100644 index 0000000..d8e738f --- /dev/null +++ b/thirdparty/jpeg-9e/libjpeg.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libjpeg +Description: Reads and writes JPEG files +Version: @JPEG_LIB_VERSION_MAJOR@.@JPEG_LIB_VERSION_MINOR@.0 +Libs: -L${libdir} -ljpeg +Cflags: -I${includedir} diff --git a/thirdparty/jpeg-9e/libjpeg.txt b/thirdparty/jpeg-9e/libjpeg.txt new file mode 100644 index 0000000..546a86e --- /dev/null +++ b/thirdparty/jpeg-9e/libjpeg.txt @@ -0,0 +1,3110 @@ +USING THE IJG JPEG LIBRARY + +Copyright (C) 1994-2019, Thomas G. Lane, Guido Vollbeding. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file describes how to use the IJG JPEG library within an application +program. Read it if you want to write a program that uses the library. + +The file example.c provides heavily commented skeleton code for calling the +JPEG library. Also see jpeglib.h (the include file to be used by application +programs) for full details about data structures and function parameter lists. +The library source code, of course, is the ultimate reference. + +Note that there have been *major* changes from the application interface +presented by IJG version 4 and earlier versions. The old design had several +inherent limitations, and it had accumulated a lot of cruft as we added +features while trying to minimize application-interface changes. We have +sacrificed backward compatibility in the version 5 rewrite, but we think the +improvements justify this. + + +TABLE OF CONTENTS +----------------- + +Overview: + Functions provided by the library + Outline of typical usage +Basic library usage: + Data formats + Compression details + Decompression details + Mechanics of usage: include files, linking, etc +Advanced features: + Compression parameter selection + Decompression parameter selection + Special color spaces + Error handling + Compressed data handling (source and destination managers) + I/O suspension + Progressive JPEG support + Buffered-image mode + Abbreviated datastreams and multiple images + Special markers + Raw (downsampled) image data + Really raw data: DCT coefficients + Progress monitoring + Memory management + Memory usage + Library compile-time options + Portability considerations + Notes for MS-DOS implementors + +You should read at least the overview and basic usage sections before trying +to program with the library. The sections on advanced features can be read +if and when you need them. + + +OVERVIEW +======== + +Functions provided by the library +--------------------------------- + +The IJG JPEG library provides C code to read and write JPEG-compressed image +files. The surrounding application program receives or supplies image data a +scanline at a time, using a straightforward uncompressed image format. All +details of color conversion and other preprocessing/postprocessing can be +handled by the library. + +The library includes a substantial amount of code that is not covered by the +JPEG standard but is necessary for typical applications of JPEG. These +functions preprocess the image before JPEG compression or postprocess it after +decompression. They include colorspace conversion, downsampling/upsampling, +and color quantization. The application indirectly selects use of this code +by specifying the format in which it wishes to supply or receive image data. +For example, if colormapped output is requested, then the decompression +library automatically invokes color quantization. + +A wide range of quality vs. speed tradeoffs are possible in JPEG processing, +and even more so in decompression postprocessing. The decompression library +provides multiple implementations that cover most of the useful tradeoffs, +ranging from very-high-quality down to fast-preview operation. On the +compression side we have generally not provided low-quality choices, since +compression is normally less time-critical. It should be understood that the +low-quality modes may not meet the JPEG standard's accuracy requirements; +nonetheless, they are useful for viewers. + +A word about functions *not* provided by the library. We handle a subset of +the ISO JPEG standard; most baseline, extended-sequential, and progressive +JPEG processes are supported. (Our subset includes all features now in common +use.) Unsupported ISO options include: + * Hierarchical storage + * Lossless JPEG + * DNL marker + * Nonintegral subsampling ratios +We support 8-bit to 12-bit data precision, but this is a compile-time choice +rather than a run-time choice; hence it is difficult to use different +precisions in a single application. + +By itself, the library handles only interchange JPEG datastreams --- in +particular the widely used JFIF file format. The library can be used by +surrounding code to process interchange or abbreviated JPEG datastreams that +are embedded in more complex file formats. (For example, this library is +used by the free LIBTIFF library to support JPEG compression in TIFF.) + + +Outline of typical usage +------------------------ + +The rough outline of a JPEG compression operation is: + + Allocate and initialize a JPEG compression object + Specify the destination for the compressed data (eg, a file) + Set parameters for compression, including image size & colorspace + jpeg_start_compress(...); + while (scan lines remain to be written) + jpeg_write_scanlines(...); + jpeg_finish_compress(...); + Release the JPEG compression object + +A JPEG compression object holds parameters and working state for the JPEG +library. We make creation/destruction of the object separate from starting +or finishing compression of an image; the same object can be re-used for a +series of image compression operations. This makes it easy to re-use the +same parameter settings for a sequence of images. Re-use of a JPEG object +also has important implications for processing abbreviated JPEG datastreams, +as discussed later. + +The image data to be compressed is supplied to jpeg_write_scanlines() from +in-memory buffers. If the application is doing file-to-file compression, +reading image data from the source file is the application's responsibility. +The library emits compressed data by calling a "data destination manager", +which typically will write the data into a file; but the application can +provide its own destination manager to do something else. + +Similarly, the rough outline of a JPEG decompression operation is: + + Allocate and initialize a JPEG decompression object + Specify the source of the compressed data (eg, a file) + Call jpeg_read_header() to obtain image info + Set parameters for decompression + jpeg_start_decompress(...); + while (scan lines remain to be read) + jpeg_read_scanlines(...); + jpeg_finish_decompress(...); + Release the JPEG decompression object + +This is comparable to the compression outline except that reading the +datastream header is a separate step. This is helpful because information +about the image's size, colorspace, etc is available when the application +selects decompression parameters. For example, the application can choose an +output scaling ratio that will fit the image into the available screen size. + +The decompression library obtains compressed data by calling a data source +manager, which typically will read the data from a file; but other behaviors +can be obtained with a custom source manager. Decompressed data is delivered +into in-memory buffers passed to jpeg_read_scanlines(). + +It is possible to abort an incomplete compression or decompression operation +by calling jpeg_abort(); or, if you do not need to retain the JPEG object, +simply release it by calling jpeg_destroy(). + +JPEG compression and decompression objects are two separate struct types. +However, they share some common fields, and certain routines such as +jpeg_destroy() can work on either type of object. + +The JPEG library has no static variables: all state is in the compression +or decompression object. Therefore it is possible to process multiple +compression and decompression operations concurrently, using multiple JPEG +objects. + +Both compression and decompression can be done in an incremental memory-to- +memory fashion, if suitable source/destination managers are used. See the +section on "I/O suspension" for more details. + + +BASIC LIBRARY USAGE +=================== + +Data formats +------------ + +Before diving into procedural details, it is helpful to understand the +image data format that the JPEG library expects or returns. + +The standard input image format is a rectangular array of pixels, with each +pixel having the same number of "component" or "sample" values (color +channels). You must specify how many components there are and the colorspace +interpretation of the components. Most applications will use RGB data +(three components per pixel) or grayscale data (one component per pixel). +PLEASE NOTE THAT RGB DATA IS THREE SAMPLES PER PIXEL, GRAYSCALE ONLY ONE. +A remarkable number of people manage to miss this, only to find that their +programs don't work with grayscale JPEG files. + +There is no provision for colormapped input. JPEG files are always full-color +or full grayscale (or sometimes another colorspace such as CMYK). You can +feed in a colormapped image by expanding it to full-color format. However +JPEG often doesn't work very well with source data that has been colormapped, +because of dithering noise. This is discussed in more detail in the JPEG FAQ +and the other references mentioned in the README file. + +Pixels are stored by scanlines, with each scanline running from left to +right. The component values for each pixel are adjacent in the row; for +example, R,G,B,R,G,B,R,G,B,... for 24-bit RGB color. Each scanline is an +array of data type JSAMPLE --- which is typically "unsigned char", unless +you've changed jmorecfg.h. (You can also change the RGB pixel layout, say +to B,G,R order, by modifying jmorecfg.h. But see the restrictions listed in +that file before doing so.) + +A 2-D array of pixels is formed by making a list of pointers to the starts of +scanlines; so the scanlines need not be physically adjacent in memory. Even +if you process just one scanline at a time, you must make a one-element +pointer array to conform to this structure. Pointers to JSAMPLE rows are of +type JSAMPROW, and the pointer to the pointer array is of type JSAMPARRAY. + +The library accepts or supplies one or more complete scanlines per call. +It is not possible to process part of a row at a time. Scanlines are always +processed top-to-bottom. You can process an entire image in one call if you +have it all in memory, but usually it's simplest to process one scanline at +a time. + +For best results, source data values should have the precision specified by +BITS_IN_JSAMPLE (normally 8 bits). For instance, if you choose to compress +data that's only 6 bits/channel, you should left-justify each value in a +byte before passing it to the compressor. If you need to compress data +that has more than 8 bits/channel, compile with BITS_IN_JSAMPLE = 9 to 12. +(See "Library compile-time options", later.) + + +The data format returned by the decompressor is the same in all details, +except that colormapped output is supported. (Again, a JPEG file is never +colormapped. But you can ask the decompressor to perform on-the-fly color +quantization to deliver colormapped output.) If you request colormapped +output then the returned data array contains a single JSAMPLE per pixel; +its value is an index into a color map. The color map is represented as +a 2-D JSAMPARRAY in which each row holds the values of one color component, +that is, colormap[i][j] is the value of the i'th color component for pixel +value (map index) j. Note that since the colormap indexes are stored in +JSAMPLEs, the maximum number of colors is limited by the size of JSAMPLE +(ie, at most 256 colors for an 8-bit JPEG library). + + +Compression details +------------------- + +Here we revisit the JPEG compression outline given in the overview. + +1. Allocate and initialize a JPEG compression object. + +A JPEG compression object is a "struct jpeg_compress_struct". (It also has +a bunch of subsidiary structures which are allocated via malloc(), but the +application doesn't control those directly.) This struct can be just a local +variable in the calling routine, if a single routine is going to execute the +whole JPEG compression sequence. Otherwise it can be static or allocated +from malloc(). + +You will also need a structure representing a JPEG error handler. The part +of this that the library cares about is a "struct jpeg_error_mgr". If you +are providing your own error handler, you'll typically want to embed the +jpeg_error_mgr struct in a larger structure; this is discussed later under +"Error handling". For now we'll assume you are just using the default error +handler. The default error handler will print JPEG error/warning messages +on stderr, and it will call exit() if a fatal error occurs. + +You must initialize the error handler structure, store a pointer to it into +the JPEG object's "err" field, and then call jpeg_create_compress() to +initialize the rest of the JPEG object. + +Typical code for this step, if you are using the default error handler, is + + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + ... + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + +jpeg_create_compress allocates a small amount of memory, so it could fail +if you are out of memory. In that case it will exit via the error handler; +that's why the error handler must be initialized first. + + +2. Specify the destination for the compressed data (eg, a file). + +As previously mentioned, the JPEG library delivers compressed data to a +"data destination" module. The library includes one data destination +module which knows how to write to a stdio stream. You can use your own +destination module if you want to do something else, as discussed later. + +If you use the standard destination module, you must open the target stdio +stream beforehand. Typical code for this step looks like: + + FILE * outfile; + ... + if ((outfile = fopen(filename, "wb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_dest(&cinfo, outfile); + +where the last line invokes the standard destination module. + +WARNING: it is critical that the binary compressed data be delivered to the +output file unchanged. On non-Unix systems the stdio library may perform +newline translation or otherwise corrupt binary data. To suppress this +behavior, you may need to use a "b" option to fopen (as shown above), or use +setmode() or another routine to put the stdio stream in binary mode. See +cjpeg.c and djpeg.c for code that has been found to work on many systems. + +You can select the data destination after setting other parameters (step 3), +if that's more convenient. You may not change the destination between +calling jpeg_start_compress() and jpeg_finish_compress(). + + +3. Set parameters for compression, including image size & colorspace. + +You must supply information about the source image by setting the following +fields in the JPEG object (cinfo structure): + + image_width Width of image, in pixels + image_height Height of image, in pixels + input_components Number of color channels (samples per pixel) + in_color_space Color space of source image + +The image dimensions are, hopefully, obvious. JPEG supports image dimensions +of 1 to 64K pixels in either direction. The input color space is typically +RGB or grayscale, and input_components is 3 or 1 accordingly. (See "Special +color spaces", later, for more info.) The in_color_space field must be +assigned one of the J_COLOR_SPACE enum constants, typically JCS_RGB or +JCS_GRAYSCALE. + +JPEG has a large number of compression parameters that determine how the +image is encoded. Most applications don't need or want to know about all +these parameters. You can set all the parameters to reasonable defaults by +calling jpeg_set_defaults(); then, if there are particular values you want +to change, you can do so after that. The "Compression parameter selection" +section tells about all the parameters. + +You must set in_color_space correctly before calling jpeg_set_defaults(), +because the defaults depend on the source image colorspace. However the +other three source image parameters need not be valid until you call +jpeg_start_compress(). There's no harm in calling jpeg_set_defaults() more +than once, if that happens to be convenient. + +Typical code for a 24-bit RGB source image is + + cinfo.image_width = Width; /* image width and height, in pixels */ + cinfo.image_height = Height; + cinfo.input_components = 3; /* # of color components per pixel */ + cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ + + jpeg_set_defaults(&cinfo); + /* Make optional parameter settings here */ + + +4. jpeg_start_compress(...); + +After you have established the data destination and set all the necessary +source image info and other parameters, call jpeg_start_compress() to begin +a compression cycle. This will initialize internal state, allocate working +storage, and emit the first few bytes of the JPEG datastream header. + +Typical code: + + jpeg_start_compress(&cinfo, TRUE); + +The "TRUE" parameter ensures that a complete JPEG interchange datastream +will be written. This is appropriate in most cases. If you think you might +want to use an abbreviated datastream, read the section on abbreviated +datastreams, below. + +Once you have called jpeg_start_compress(), you may not alter any JPEG +parameters or other fields of the JPEG object until you have completed +the compression cycle. + + +5. while (scan lines remain to be written) + jpeg_write_scanlines(...); + +Now write all the required image data by calling jpeg_write_scanlines() +one or more times. You can pass one or more scanlines in each call, up +to the total image height. In most applications it is convenient to pass +just one or a few scanlines at a time. The expected format for the passed +data is discussed under "Data formats", above. + +Image data should be written in top-to-bottom scanline order. The JPEG spec +contains some weasel wording about how top and bottom are application-defined +terms (a curious interpretation of the English language...) but if you want +your files to be compatible with everyone else's, you WILL use top-to-bottom +order. If the source data must be read in bottom-to-top order, you can use +the JPEG library's virtual array mechanism to invert the data efficiently. +Examples of this can be found in the sample application cjpeg. + +The library maintains a count of the number of scanlines written so far +in the next_scanline field of the JPEG object. Usually you can just use +this variable as the loop counter, so that the loop test looks like +"while (cinfo.next_scanline < cinfo.image_height)". + +Code for this step depends heavily on the way that you store the source data. +example.c shows the following code for the case of a full-size 2-D source +array containing 3-byte RGB pixels: + + JSAMPROW row_pointer[1]; /* pointer to a single row */ + int row_stride; /* physical row width in buffer */ + + row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ + + while (cinfo.next_scanline < cinfo.image_height) { + row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; + jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + +jpeg_write_scanlines() returns the number of scanlines actually written. +This will normally be equal to the number passed in, so you can usually +ignore the return value. It is different in just two cases: + * If you try to write more scanlines than the declared image height, + the additional scanlines are ignored. + * If you use a suspending data destination manager, output buffer overrun + will cause the compressor to return before accepting all the passed lines. + This feature is discussed under "I/O suspension", below. The normal + stdio destination manager will NOT cause this to happen. +In any case, the return value is the same as the change in the value of +next_scanline. + + +6. jpeg_finish_compress(...); + +After all the image data has been written, call jpeg_finish_compress() to +complete the compression cycle. This step is ESSENTIAL to ensure that the +last bufferload of data is written to the data destination. +jpeg_finish_compress() also releases working memory associated with the JPEG +object. + +Typical code: + + jpeg_finish_compress(&cinfo); + +If using the stdio destination manager, don't forget to close the output +stdio stream (if necessary) afterwards. + +If you have requested a multi-pass operating mode, such as Huffman code +optimization, jpeg_finish_compress() will perform the additional passes using +data buffered by the first pass. In this case jpeg_finish_compress() may take +quite a while to complete. With the default compression parameters, this will +not happen. + +It is an error to call jpeg_finish_compress() before writing the necessary +total number of scanlines. If you wish to abort compression, call +jpeg_abort() as discussed below. + +After completing a compression cycle, you may dispose of the JPEG object +as discussed next, or you may use it to compress another image. In that case +return to step 2, 3, or 4 as appropriate. If you do not change the +destination manager, the new datastream will be written to the same target. +If you do not change any JPEG parameters, the new datastream will be written +with the same parameters as before. Note that you can change the input image +dimensions freely between cycles, but if you change the input colorspace, you +should call jpeg_set_defaults() to adjust for the new colorspace; and then +you'll need to repeat all of step 3. + + +7. Release the JPEG compression object. + +When you are done with a JPEG compression object, destroy it by calling +jpeg_destroy_compress(). This will free all subsidiary memory (regardless of +the previous state of the object). Or you can call jpeg_destroy(), which +works for either compression or decompression objects --- this may be more +convenient if you are sharing code between compression and decompression +cases. (Actually, these routines are equivalent except for the declared type +of the passed pointer. To avoid gripes from ANSI C compilers, jpeg_destroy() +should be passed a j_common_ptr.) + +If you allocated the jpeg_compress_struct structure from malloc(), freeing +it is your responsibility --- jpeg_destroy() won't. Ditto for the error +handler structure. + +Typical code: + + jpeg_destroy_compress(&cinfo); + + +8. Aborting. + +If you decide to abort a compression cycle before finishing, you can clean up +in either of two ways: + +* If you don't need the JPEG object any more, just call + jpeg_destroy_compress() or jpeg_destroy() to release memory. This is + legitimate at any point after calling jpeg_create_compress() --- in fact, + it's safe even if jpeg_create_compress() fails. + +* If you want to re-use the JPEG object, call jpeg_abort_compress(), or call + jpeg_abort() which works on both compression and decompression objects. + This will return the object to an idle state, releasing any working memory. + jpeg_abort() is allowed at any time after successful object creation. + +Note that cleaning up the data destination, if required, is your +responsibility; neither of these routines will call term_destination(). +(See "Compressed data handling", below, for more about that.) + +jpeg_destroy() and jpeg_abort() are the only safe calls to make on a JPEG +object that has reported an error by calling error_exit (see "Error handling" +for more info). The internal state of such an object is likely to be out of +whack. Either of these two routines will return the object to a known state. + + +Decompression details +--------------------- + +Here we revisit the JPEG decompression outline given in the overview. + +1. Allocate and initialize a JPEG decompression object. + +This is just like initialization for compression, as discussed above, +except that the object is a "struct jpeg_decompress_struct" and you +call jpeg_create_decompress(). Error handling is exactly the same. + +Typical code: + + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + ... + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + +(Both here and in the IJG code, we usually use variable name "cinfo" for +both compression and decompression objects.) + + +2. Specify the source of the compressed data (eg, a file). + +As previously mentioned, the JPEG library reads compressed data from a "data +source" module. The library includes one data source module which knows how +to read from a stdio stream. You can use your own source module if you want +to do something else, as discussed later. + +If you use the standard source module, you must open the source stdio stream +beforehand. Typical code for this step looks like: + + FILE * infile; + ... + if ((infile = fopen(filename, "rb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_src(&cinfo, infile); + +where the last line invokes the standard source module. + +WARNING: it is critical that the binary compressed data be read unchanged. +On non-Unix systems the stdio library may perform newline translation or +otherwise corrupt binary data. To suppress this behavior, you may need to use +a "b" option to fopen (as shown above), or use setmode() or another routine to +put the stdio stream in binary mode. See cjpeg.c and djpeg.c for code that +has been found to work on many systems. + +You may not change the data source between calling jpeg_read_header() and +jpeg_finish_decompress(). If you wish to read a series of JPEG images from +a single source file, you should repeat the jpeg_read_header() to +jpeg_finish_decompress() sequence without reinitializing either the JPEG +object or the data source module; this prevents buffered input data from +being discarded. + + +3. Call jpeg_read_header() to obtain image info. + +Typical code for this step is just + + jpeg_read_header(&cinfo, TRUE); + +This will read the source datastream header markers, up to the beginning +of the compressed data proper. On return, the image dimensions and other +info have been stored in the JPEG object. The application may wish to +consult this information before selecting decompression parameters. + +More complex code is necessary if + * A suspending data source is used --- in that case jpeg_read_header() + may return before it has read all the header data. See "I/O suspension", + below. The normal stdio source manager will NOT cause this to happen. + * Abbreviated JPEG files are to be processed --- see the section on + abbreviated datastreams. Standard applications that deal only in + interchange JPEG files need not be concerned with this case either. + +It is permissible to stop at this point if you just wanted to find out the +image dimensions and other header info for a JPEG file. In that case, +call jpeg_destroy() when you are done with the JPEG object, or call +jpeg_abort() to return it to an idle state before selecting a new data +source and reading another header. + + +4. Set parameters for decompression. + +jpeg_read_header() sets appropriate default decompression parameters based on +the properties of the image (in particular, its colorspace). However, you +may well want to alter these defaults before beginning the decompression. +For example, the default is to produce full color output from a color file. +If you want colormapped output you must ask for it. Other options allow the +returned image to be scaled and allow various speed/quality tradeoffs to be +selected. "Decompression parameter selection", below, gives details. + +If the defaults are appropriate, nothing need be done at this step. + +Note that all default values are set by each call to jpeg_read_header(). +If you reuse a decompression object, you cannot expect your parameter +settings to be preserved across cycles, as you can for compression. +You must set desired parameter values each time. + + +5. jpeg_start_decompress(...); + +Once the parameter values are satisfactory, call jpeg_start_decompress() to +begin decompression. This will initialize internal state, allocate working +memory, and prepare for returning data. + +Typical code is just + + jpeg_start_decompress(&cinfo); + +If you have requested a multi-pass operating mode, such as 2-pass color +quantization, jpeg_start_decompress() will do everything needed before data +output can begin. In this case jpeg_start_decompress() may take quite a while +to complete. With a single-scan (non progressive) JPEG file and default +decompression parameters, this will not happen; jpeg_start_decompress() will +return quickly. + +After this call, the final output image dimensions, including any requested +scaling, are available in the JPEG object; so is the selected colormap, if +colormapped output has been requested. Useful fields include + + output_width image width and height, as scaled + output_height + out_color_components # of color components in out_color_space + output_components # of color components returned per pixel + colormap the selected colormap, if any + actual_number_of_colors number of entries in colormap + +output_components is 1 (a colormap index) when quantizing colors; otherwise it +equals out_color_components. It is the number of JSAMPLE values that will be +emitted per pixel in the output arrays. + +Typically you will need to allocate data buffers to hold the incoming image. +You will need output_width * output_components JSAMPLEs per scanline in your +output buffer, and a total of output_height scanlines will be returned. + +Note: if you are using the JPEG library's internal memory manager to allocate +data buffers (as djpeg does), then the manager's protocol requires that you +request large buffers *before* calling jpeg_start_decompress(). This is a +little tricky since the output_XXX fields are not normally valid then. You +can make them valid by calling jpeg_calc_output_dimensions() after setting the +relevant parameters (scaling, output color space, and quantization flag). + + +6. while (scan lines remain to be read) + jpeg_read_scanlines(...); + +Now you can read the decompressed image data by calling jpeg_read_scanlines() +one or more times. At each call, you pass in the maximum number of scanlines +to be read (ie, the height of your working buffer); jpeg_read_scanlines() +will return up to that many lines. The return value is the number of lines +actually read. The format of the returned data is discussed under "Data +formats", above. Don't forget that grayscale and color JPEGs will return +different data formats! + +Image data is returned in top-to-bottom scanline order. If you must write +out the image in bottom-to-top order, you can use the JPEG library's virtual +array mechanism to invert the data efficiently. Examples of this can be +found in the sample application djpeg. + +The library maintains a count of the number of scanlines returned so far +in the output_scanline field of the JPEG object. Usually you can just use +this variable as the loop counter, so that the loop test looks like +"while (cinfo.output_scanline < cinfo.output_height)". (Note that the test +should NOT be against image_height, unless you never use scaling. The +image_height field is the height of the original unscaled image.) +The return value always equals the change in the value of output_scanline. + +If you don't use a suspending data source, it is safe to assume that +jpeg_read_scanlines() reads at least one scanline per call, until the +bottom of the image has been reached. + +If you use a buffer larger than one scanline, it is NOT safe to assume that +jpeg_read_scanlines() fills it. (The current implementation returns only a +few scanlines per call, no matter how large a buffer you pass.) So you must +always provide a loop that calls jpeg_read_scanlines() repeatedly until the +whole image has been read. + + +7. jpeg_finish_decompress(...); + +After all the image data has been read, call jpeg_finish_decompress() to +complete the decompression cycle. This causes working memory associated +with the JPEG object to be released. + +Typical code: + + jpeg_finish_decompress(&cinfo); + +If using the stdio source manager, don't forget to close the source stdio +stream if necessary. + +It is an error to call jpeg_finish_decompress() before reading the correct +total number of scanlines. If you wish to abort decompression, call +jpeg_abort() as discussed below. + +After completing a decompression cycle, you may dispose of the JPEG object as +discussed next, or you may use it to decompress another image. In that case +return to step 2 or 3 as appropriate. If you do not change the source +manager, the next image will be read from the same source. + + +8. Release the JPEG decompression object. + +When you are done with a JPEG decompression object, destroy it by calling +jpeg_destroy_decompress() or jpeg_destroy(). The previous discussion of +destroying compression objects applies here too. + +Typical code: + + jpeg_destroy_decompress(&cinfo); + + +9. Aborting. + +You can abort a decompression cycle by calling jpeg_destroy_decompress() or +jpeg_destroy() if you don't need the JPEG object any more, or +jpeg_abort_decompress() or jpeg_abort() if you want to reuse the object. +The previous discussion of aborting compression cycles applies here too. + + +Mechanics of usage: include files, linking, etc +----------------------------------------------- + +Applications using the JPEG library should include the header file jpeglib.h +to obtain declarations of data types and routines. Before including +jpeglib.h, include system headers that define at least the typedefs FILE and +size_t. On ANSI-conforming systems, including is sufficient; on +older Unix systems, you may need to define size_t. + +If the application needs to refer to individual JPEG library error codes, also +include jerror.h to define those symbols. + +jpeglib.h indirectly includes the files jconfig.h and jmorecfg.h. If you are +installing the JPEG header files in a system directory, you will want to +install all four files: jpeglib.h, jerror.h, jconfig.h, jmorecfg.h. + +The most convenient way to include the JPEG code into your executable program +is to prepare a library file ("libjpeg.a", or a corresponding name on non-Unix +machines) and reference it at your link step. If you use only half of the +library (only compression or only decompression), only that much code will be +included from the library, unless your linker is hopelessly brain-damaged. +The supplied makefiles build libjpeg.a automatically (see install.txt). + +While you can build the JPEG library as a shared library if the whim strikes +you, we don't really recommend it. The trouble with shared libraries is that +at some point you'll probably try to substitute a new version of the library +without recompiling the calling applications. That generally doesn't work +because the parameter struct declarations usually change with each new +version. In other words, the library's API is *not* guaranteed binary +compatible across versions; we only try to ensure source-code compatibility. +(In hindsight, it might have been smarter to hide the parameter structs from +applications and introduce a ton of access functions instead. Too late now, +however.) + +On some systems your application may need to set up a signal handler to ensure +that temporary files are deleted if the program is interrupted. This is most +critical if you are on MS-DOS and use the jmemdos.c memory manager back end; +it will try to grab extended memory for temp files, and that space will NOT be +freed automatically. See cjpeg.c or djpeg.c for an example signal handler. + +It may be worth pointing out that the core JPEG library does not actually +require the stdio library: only the default source/destination managers and +error handler need it. You can use the library in a stdio-less environment +if you replace those modules and use jmemnobs.c (or another memory manager of +your own devising). More info about the minimum system library requirements +may be found in jinclude.h. + + +ADVANCED FEATURES +================= + +Compression parameter selection +------------------------------- + +This section describes all the optional parameters you can set for JPEG +compression, as well as the "helper" routines provided to assist in this +task. Proper setting of some parameters requires detailed understanding +of the JPEG standard; if you don't know what a parameter is for, it's best +not to mess with it! See REFERENCES in the README file for pointers to +more info about JPEG. + +It's a good idea to call jpeg_set_defaults() first, even if you plan to set +all the parameters; that way your code is more likely to work with future JPEG +libraries that have additional parameters. For the same reason, we recommend +you use a helper routine where one is provided, in preference to twiddling +cinfo fields directly. + +The helper routines are: + +jpeg_set_defaults (j_compress_ptr cinfo) + This routine sets all JPEG parameters to reasonable defaults, using + only the input image's color space (field in_color_space, which must + already be set in cinfo). Many applications will only need to use + this routine and perhaps jpeg_set_quality(). + +jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) + Sets the JPEG file's colorspace (field jpeg_color_space) as specified, + and sets other color-space-dependent parameters appropriately. See + "Special color spaces", below, before using this. A large number of + parameters, including all per-component parameters, are set by this + routine; if you want to twiddle individual parameters you should call + jpeg_set_colorspace() before rather than after. + +jpeg_default_colorspace (j_compress_ptr cinfo) + Selects an appropriate JPEG colorspace based on cinfo->in_color_space, + and calls jpeg_set_colorspace(). This is actually a subroutine of + jpeg_set_defaults(). It's broken out in case you want to change + just the colorspace-dependent JPEG parameters. + +jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) + Constructs JPEG quantization tables appropriate for the indicated + quality setting. The quality value is expressed on the 0..100 scale + recommended by IJG (cjpeg's "-quality" switch uses this routine). + Note that the exact mapping from quality values to tables may change + in future IJG releases as more is learned about DCT quantization. + If the force_baseline parameter is TRUE, then the quantization table + entries are constrained to the range 1..255 for full JPEG baseline + compatibility. In the current implementation, this only makes a + difference for quality settings below 25, and it effectively prevents + very small/low quality files from being generated. The IJG decoder + is capable of reading the non-baseline files generated at low quality + settings when force_baseline is FALSE, but other decoders may not be. + +jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, + boolean force_baseline) + Same as jpeg_set_quality() except that the generated tables are the + sample tables given in the JPEC spec section K.1, multiplied by the + specified scale factor (which is expressed as a percentage; thus + scale_factor = 100 reproduces the spec's tables). Note that larger + scale factors give lower quality. This entry point is useful for + conforming to the Adobe PostScript DCT conventions, but we do not + recommend linear scaling as a user-visible quality scale otherwise. + force_baseline again constrains the computed table entries to 1..255. + +int jpeg_quality_scaling (int quality) + Converts a value on the IJG-recommended quality scale to a linear + scaling percentage. Note that this routine may change or go away + in future releases --- IJG may choose to adopt a scaling method that + can't be expressed as a simple scalar multiplier, in which case the + premise of this routine collapses. Caveat user. + +jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline) + Set default quantization tables with linear q_scale_factor[] values + (see below). + +jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, boolean force_baseline) + Allows an arbitrary quantization table to be created. which_tbl + indicates which table slot to fill. basic_table points to an array + of 64 unsigned ints given in normal array order. These values are + multiplied by scale_factor/100 and then clamped to the range 1..65535 + (or to 1..255 if force_baseline is TRUE). + CAUTION: prior to library version 6a, jpeg_add_quant_table expected + the basic table to be given in JPEG zigzag order. If you need to + write code that works with either older or newer versions of this + routine, you must check the library version number. Something like + "#if JPEG_LIB_VERSION >= 61" is the right test. + +jpeg_simple_progression (j_compress_ptr cinfo) + Generates a default scan script for writing a progressive-JPEG file. + This is the recommended method of creating a progressive file, + unless you want to make a custom scan sequence. You must ensure that + the JPEG color space is set correctly before calling this routine. + + +Compression parameters (cinfo fields) include: + +boolean arith_code + If TRUE, use arithmetic coding. + If FALSE, use Huffman coding. + +int block_size + Set DCT block size. All N from 1 to 16 are possible. + Default is 8 (baseline format). + Larger values produce higher compression, + smaller values produce higher quality. + An exact DCT stage is possible with 1 or 2. + With the default quality of 75 and default Luminance qtable + the DCT+Quantization stage is lossless for value 1. + Note that values other than 8 require a SmartScale capable decoder, + introduced with IJG JPEG 8. Setting the block_size parameter for + compression works with version 8c and later. + +J_DCT_METHOD dct_method + Selects the algorithm used for the DCT step. Choices are: + JDCT_ISLOW: slow but accurate integer algorithm + JDCT_IFAST: faster, less accurate integer method + JDCT_FLOAT: floating-point method + JDCT_DEFAULT: default method (normally JDCT_ISLOW) + JDCT_FASTEST: fastest method (normally JDCT_IFAST) + The FLOAT method is very slightly more accurate than the ISLOW method, + but may give different results on different machines due to varying + roundoff behavior. The integer methods should give the same results + on all machines. On machines with sufficiently fast FP hardware, the + floating-point method may also be the fastest. The IFAST method is + considerably less accurate than the other two; its use is not + recommended if high quality is a concern. JDCT_DEFAULT and + JDCT_FASTEST are macros configurable by each installation. + +unsigned int scale_num, scale_denom + Scale the image by the fraction scale_num/scale_denom. Default is + 1/1, or no scaling. Currently, the supported scaling ratios are + M/N with all N from 1 to 16, where M is the destination DCT size, + which is 8 by default (see block_size parameter above). + (The library design allows for arbitrary scaling ratios but this + is not likely to be implemented any time soon.) + +J_COLOR_SPACE jpeg_color_space +int num_components + The JPEG color space and corresponding number of components; see + "Special color spaces", below, for more info. We recommend using + jpeg_set_colorspace() if you want to change these. + +J_COLOR_TRANSFORM color_transform + Internal color transform identifier, writes LSE marker if nonzero + (requires decoder with inverse color transform support, introduced + with IJG JPEG 9). + Two values are currently possible: JCT_NONE and JCT_SUBTRACT_GREEN. + Set this value for lossless RGB application *before* calling + jpeg_set_colorspace(), because entropy table assignment in + jpeg_set_colorspace() depends on color_transform. + +boolean optimize_coding + TRUE causes the compressor to compute optimal Huffman coding tables + for the image. This requires an extra pass over the data and + therefore costs a good deal of space and time. The default is + FALSE, which tells the compressor to use the supplied or default + Huffman tables. In most cases optimal tables save only a few percent + of file size compared to the default tables. Note that when this is + TRUE, you need not supply Huffman tables at all, and any you do + supply will be overwritten. + +unsigned int restart_interval +int restart_in_rows + To emit restart markers in the JPEG file, set one of these nonzero. + Set restart_interval to specify the exact interval in MCU blocks. + Set restart_in_rows to specify the interval in MCU rows. (If + restart_in_rows is not 0, then restart_interval is set after the + image width in MCUs is computed.) Defaults are zero (no restarts). + One restart marker per MCU row is often a good choice. + NOTE: the overhead of restart markers is higher in grayscale JPEG + files than in color files, and MUCH higher in progressive JPEGs. + If you use restarts, you may want to use larger intervals in those + cases. + +const jpeg_scan_info * scan_info +int num_scans + By default, scan_info is NULL; this causes the compressor to write a + single-scan sequential JPEG file. If not NULL, scan_info points to + an array of scan definition records of length num_scans. The + compressor will then write a JPEG file having one scan for each scan + definition record. This is used to generate noninterleaved or + progressive JPEG files. The library checks that the scan array + defines a valid JPEG scan sequence. (jpeg_simple_progression creates + a suitable scan definition array for progressive JPEG.) This is + discussed further under "Progressive JPEG support". + +boolean do_fancy_downsampling + If TRUE, use direct DCT scaling with DCT size > 8 for downsampling + of chroma components. + If FALSE, use only DCT size <= 8 and simple separate downsampling. + Default is TRUE. + For better image stability in multiple generation compression cycles + it is preferable that this value matches the corresponding + do_fancy_upsampling value in decompression. + +int smoothing_factor + If non-zero, the input image is smoothed; the value should be 1 for + minimal smoothing to 100 for maximum smoothing. Consult jcsample.c + for details of the smoothing algorithm. The default is zero. + +boolean write_JFIF_header + If TRUE, a JFIF APP0 marker is emitted. jpeg_set_defaults() and + jpeg_set_colorspace() set this TRUE if a JFIF-legal JPEG color space + (ie, YCbCr or grayscale) is selected, otherwise FALSE. + +UINT8 JFIF_major_version +UINT8 JFIF_minor_version + The version number to be written into the JFIF marker. + jpeg_set_defaults() initializes the version to 1.01 (major=minor=1). + You should set it to 1.02 (major=1, minor=2) if you plan to write + any JFIF 1.02 extension markers. + +UINT8 density_unit +UINT16 X_density +UINT16 Y_density + The resolution information to be written into the JFIF marker; + not used otherwise. density_unit may be 0 for unknown, + 1 for dots/inch, or 2 for dots/cm. The default values are 0,1,1 + indicating square pixels of unknown size. + +boolean write_Adobe_marker + If TRUE, an Adobe APP14 marker is emitted. jpeg_set_defaults() and + jpeg_set_colorspace() set this TRUE if JPEG color space RGB, CMYK, + or YCCK is selected, otherwise FALSE. It is generally a bad idea + to set both write_JFIF_header and write_Adobe_marker. In fact, + you probably shouldn't change the default settings at all --- the + default behavior ensures that the JPEG file's color space can be + recognized by the decoder. + +JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS] + Pointers to coefficient quantization tables, one per table slot, + or NULL if no table is defined for a slot. Usually these should + be set via one of the above helper routines; jpeg_add_quant_table() + is general enough to define any quantization table. The other + routines will set up table slot 0 for luminance quality and table + slot 1 for chrominance. + +int q_scale_factor[NUM_QUANT_TBLS] + Linear quantization scaling factors (percentage, initialized 100) + for use with jpeg_default_qtables(). + See rdswitch.c and cjpeg.c for an example of usage. + Note that the q_scale_factor[] fields are the "linear" scales, so you + have to convert from user-defined ratings via jpeg_quality_scaling(). + Here is an example code which corresponds to cjpeg -quality 90,70: + + jpeg_set_defaults(cinfo); + + /* Set luminance quality 90. */ + cinfo->q_scale_factor[0] = jpeg_quality_scaling(90); + /* Set chrominance quality 70. */ + cinfo->q_scale_factor[1] = jpeg_quality_scaling(70); + + jpeg_default_qtables(cinfo, force_baseline); + + CAUTION: You must also set 1x1 subsampling for efficient separate + color quality selection, since the default value used by library + is 2x2: + + cinfo->comp_info[0].v_samp_factor = 1; + cinfo->comp_info[0].h_samp_factor = 1; + +JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS] +JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS] + Pointers to Huffman coding tables, one per table slot, or NULL if + no table is defined for a slot. Slots 0 and 1 are filled with the + JPEG sample tables by jpeg_set_defaults(). If you need to allocate + more table structures, jpeg_alloc_huff_table() may be used. + Note that optimal Huffman tables can be computed for an image + by setting optimize_coding, as discussed above; there's seldom + any need to mess with providing your own Huffman tables. + + +The actual dimensions of the JPEG image that will be written to the file are +given by the following fields. These are computed from the input image +dimensions and the compression parameters by jpeg_start_compress(). You can +also call jpeg_calc_jpeg_dimensions() to obtain the values that will result +from the current parameter settings. This can be useful if you are trying +to pick a scaling ratio that will get close to a desired target size. + +JDIMENSION jpeg_width Actual dimensions of output image. +JDIMENSION jpeg_height + + +Per-component parameters are stored in the struct cinfo.comp_info[i] for +component number i. Note that components here refer to components of the +JPEG color space, *not* the source image color space. A suitably large +comp_info[] array is allocated by jpeg_set_defaults(); if you choose not +to use that routine, it's up to you to allocate the array. + +int component_id + The one-byte identifier code to be recorded in the JPEG file for + this component. For the standard color spaces, we recommend you + leave the default values alone. + +int h_samp_factor +int v_samp_factor + Horizontal and vertical sampling factors for the component; must + be 1..4 according to the JPEG standard. Note that larger sampling + factors indicate a higher-resolution component; many people find + this behavior quite unintuitive. The default values are 2,2 for + luminance components and 1,1 for chrominance components, except + for grayscale where 1,1 is used. + +int quant_tbl_no + Quantization table number for component. The default value is + 0 for luminance components and 1 for chrominance components. + +int dc_tbl_no +int ac_tbl_no + DC and AC entropy coding table numbers. The default values are + 0 for luminance components and 1 for chrominance components. + +int component_index + Must equal the component's index in comp_info[]. (Beginning in + release v6, the compressor library will fill this in automatically; + you don't have to.) + + +Decompression parameter selection +--------------------------------- + +Decompression parameter selection is somewhat simpler than compression +parameter selection, since all of the JPEG internal parameters are +recorded in the source file and need not be supplied by the application. +(Unless you are working with abbreviated files, in which case see +"Abbreviated datastreams", below.) Decompression parameters control +the postprocessing done on the image to deliver it in a format suitable +for the application's use. Many of the parameters control speed/quality +tradeoffs, in which faster decompression may be obtained at the price of +a poorer-quality image. The defaults select the highest quality (slowest) +processing. + +The following fields in the JPEG object are set by jpeg_read_header() and +may be useful to the application in choosing decompression parameters: + +JDIMENSION image_width Width and height of image +JDIMENSION image_height +int num_components Number of color components +J_COLOR_SPACE jpeg_color_space Colorspace of image +boolean saw_JFIF_marker TRUE if a JFIF APP0 marker was seen + UINT8 JFIF_major_version Version information from JFIF marker + UINT8 JFIF_minor_version + UINT8 density_unit Resolution data from JFIF marker + UINT16 X_density + UINT16 Y_density +boolean saw_Adobe_marker TRUE if an Adobe APP14 marker was seen + UINT8 Adobe_transform Color transform code from Adobe marker + +The JPEG color space, unfortunately, is something of a guess since the JPEG +standard proper does not provide a way to record it. In practice most files +adhere to the JFIF or Adobe conventions, and the decoder will recognize these +correctly. See "Special color spaces", below, for more info. + + +The decompression parameters that determine the basic properties of the +returned image are: + +J_COLOR_SPACE out_color_space + Output color space. jpeg_read_header() sets an appropriate default + based on jpeg_color_space; typically it will be RGB or grayscale. + The application can change this field to request output in a different + colorspace. For example, set it to JCS_GRAYSCALE to get grayscale + output from a color file. (This is useful for previewing: grayscale + output is faster than full color since the color components need not + be processed.) Note that not all possible color space transforms are + currently implemented; you may need to extend jdcolor.c if you want an + unusual conversion. + +unsigned int scale_num, scale_denom + Scale the image by the fraction scale_num/scale_denom. Currently, + the supported scaling ratios are M/N with all M from 1 to 16, where + N is the source DCT size, which is 8 for baseline JPEG. (The library + design allows for arbitrary scaling ratios but this is not likely + to be implemented any time soon.) The values are initialized by + jpeg_read_header() with the source DCT size. For baseline JPEG + this is 8/8. If you change only the scale_num value while leaving + the other unchanged, then this specifies the DCT scaled size to be + applied on the given input. For baseline JPEG this is equivalent + to M/8 scaling, since the source DCT size for baseline JPEG is 8. + Smaller scaling ratios permit significantly faster decoding since + fewer pixels need be processed and a simpler IDCT method can be used. + +boolean quantize_colors + If set TRUE, colormapped output will be delivered. Default is FALSE, + meaning that full-color output will be delivered. + +The next three parameters are relevant only if quantize_colors is TRUE. + +int desired_number_of_colors + Maximum number of colors to use in generating a library-supplied color + map (the actual number of colors is returned in a different field). + Default 256. Ignored when the application supplies its own color map. + +boolean two_pass_quantize + If TRUE, an extra pass over the image is made to select a custom color + map for the image. This usually looks a lot better than the one-size- + fits-all colormap that is used otherwise. Default is TRUE. Ignored + when the application supplies its own color map. + +J_DITHER_MODE dither_mode + Selects color dithering method. Supported values are: + JDITHER_NONE no dithering: fast, very low quality + JDITHER_ORDERED ordered dither: moderate speed and quality + JDITHER_FS Floyd-Steinberg dither: slow, high quality + Default is JDITHER_FS. (At present, ordered dither is implemented + only in the single-pass, standard-colormap case. If you ask for + ordered dither when two_pass_quantize is TRUE or when you supply + an external color map, you'll get F-S dithering.) + +When quantize_colors is TRUE, the target color map is described by the next +two fields. colormap is set to NULL by jpeg_read_header(). The application +can supply a color map by setting colormap non-NULL and setting +actual_number_of_colors to the map size. Otherwise, jpeg_start_decompress() +selects a suitable color map and sets these two fields itself. +[Implementation restriction: at present, an externally supplied colormap is +only accepted for 3-component output color spaces.] + +JSAMPARRAY colormap + The color map, represented as a 2-D pixel array of out_color_components + rows and actual_number_of_colors columns. Ignored if not quantizing. + CAUTION: if the JPEG library creates its own colormap, the storage + pointed to by this field is released by jpeg_finish_decompress(). + Copy the colormap somewhere else first, if you want to save it. + +int actual_number_of_colors + The number of colors in the color map. + +Additional decompression parameters that the application may set include: + +J_DCT_METHOD dct_method + Selects the algorithm used for the DCT step. Choices are the same + as described above for compression. + +boolean do_fancy_upsampling + If TRUE, use direct DCT scaling with DCT size > 8 for upsampling + of chroma components. + If FALSE, use only DCT size <= 8 and simple separate upsampling. + Default is TRUE. + For better image stability in multiple generation compression cycles + it is preferable that this value matches the corresponding + do_fancy_downsampling value in compression. + +boolean do_block_smoothing + If TRUE, interblock smoothing is applied in early stages of decoding + progressive JPEG files; if FALSE, not. Default is TRUE. Early + progression stages look "fuzzy" with smoothing, "blocky" without. + In any case, block smoothing ceases to be applied after the first few + AC coefficients are known to full accuracy, so it is relevant only + when using buffered-image mode for progressive images. + +boolean enable_1pass_quant +boolean enable_external_quant +boolean enable_2pass_quant + These are significant only in buffered-image mode, which is + described in its own section below. + + +The output image dimensions are given by the following fields. These are +computed from the source image dimensions and the decompression parameters +by jpeg_start_decompress(). You can also call jpeg_calc_output_dimensions() +to obtain the values that will result from the current parameter settings. +This can be useful if you are trying to pick a scaling ratio that will get +close to a desired target size. It's also important if you are using the +JPEG library's memory manager to allocate output buffer space, because you +are supposed to request such buffers *before* jpeg_start_decompress(). + +JDIMENSION output_width Actual dimensions of output image. +JDIMENSION output_height +int out_color_components Number of color components in out_color_space. +int output_components Number of color components returned. +int rec_outbuf_height Recommended height of scanline buffer. + +When quantizing colors, output_components is 1, indicating a single color map +index per pixel. Otherwise it equals out_color_components. The output arrays +are required to be output_width * output_components JSAMPLEs wide. + +rec_outbuf_height is the recommended minimum height (in scanlines) of the +buffer passed to jpeg_read_scanlines(). If the buffer is smaller, the +library will still work, but time will be wasted due to unnecessary data +copying. In high-quality modes, rec_outbuf_height is always 1, but some +faster, lower-quality modes set it to larger values (typically 2 to 4). +If you are going to ask for a high-speed processing mode, you may as well +go to the trouble of honoring rec_outbuf_height so as to avoid data copying. +(An output buffer larger than rec_outbuf_height lines is OK, but won't +provide any material speed improvement over that height.) + + +Special color spaces +-------------------- + +The JPEG standard itself is "color blind" and doesn't specify any particular +color space. It is customary to convert color data to a luminance/chrominance +color space before compressing, since this permits greater compression. The +existing JPEG file interchange format standards specify YCbCr or GRAYSCALE +data (JFIF version 1), GRAYSCALE, RGB, YCbCr, CMYK, or YCCK (Adobe), or BG_RGB +or BG_YCC (big gamut color spaces, JFIF version 2). For special applications +such as multispectral images, other color spaces can be used, +but it must be understood that such files will be unportable. + +The JPEG library can handle the most common colorspace conversions (namely +RGB <=> YCbCr and CMYK <=> YCCK). It can also deal with data of an unknown +color space, passing it through without conversion. If you deal extensively +with an unusual color space, you can easily extend the library to understand +additional color spaces and perform appropriate conversions. + +For compression, the source data's color space is specified by field +in_color_space. This is transformed to the JPEG file's color space given +by jpeg_color_space. jpeg_set_defaults() chooses a reasonable JPEG color +space depending on in_color_space, but you can override this by calling +jpeg_set_colorspace(). Of course you must select a supported transformation. +jccolor.c currently supports the following transformations: + RGB => YCbCr + RGB => GRAYSCALE + RGB => BG_YCC + YCbCr => GRAYSCALE + YCbCr => BG_YCC + CMYK => YCCK +plus the null transforms: GRAYSCALE => GRAYSCALE, RGB => RGB, +BG_RGB => BG_RGB, YCbCr => YCbCr, BG_YCC => BG_YCC, CMYK => CMYK, +YCCK => YCCK, and UNKNOWN => UNKNOWN. + +The file interchange format standards (JFIF and Adobe) specify APPn markers +that indicate the color space of the JPEG file. It is important to ensure +that these are written correctly, or omitted if the JPEG file's color space +is not one of the ones supported by the interchange standards. +jpeg_set_colorspace() will set the compression parameters to include or omit +the APPn markers properly, so long as it is told the truth about the JPEG +color space. For example, if you are writing some random 3-component color +space without conversion, don't try to fake out the library by setting +in_color_space and jpeg_color_space to JCS_YCbCr; use JCS_UNKNOWN. +You may want to write an APPn marker of your own devising to identify +the colorspace --- see "Special markers", below. + +When told that the color space is UNKNOWN, the library will default to using +luminance-quality compression parameters for all color components. You may +well want to change these parameters. See the source code for +jpeg_set_colorspace(), in jcparam.c, for details. + +For decompression, the JPEG file's color space is given in jpeg_color_space, +and this is transformed to the output color space out_color_space. +jpeg_read_header's setting of jpeg_color_space can be relied on if the file +conforms to JFIF or Adobe conventions, but otherwise it is no better than a +guess. If you know the JPEG file's color space for certain, you can override +jpeg_read_header's guess by setting jpeg_color_space. jpeg_read_header also +selects a default output color space based on (its guess of) jpeg_color_space; +set out_color_space to override this. Again, you must select a supported +transformation. jdcolor.c currently supports + YCbCr => RGB + YCbCr => GRAYSCALE + BG_YCC => RGB + BG_YCC => GRAYSCALE + RGB => GRAYSCALE + GRAYSCALE => RGB + YCCK => CMYK +as well as the null transforms. (Since GRAYSCALE=>RGB is provided, an +application can force grayscale JPEGs to look like color JPEGs if it only +wants to handle one case.) + +The two-pass color quantizer, jquant2.c, is specialized to handle RGB data +(it weights distances appropriately for RGB colors). You'll need to modify +the code if you want to use it for non-RGB output color spaces. Note that +jquant2.c is used to map to an application-supplied colormap as well as for +the normal two-pass colormap selection process. + +CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG +files: 0 represents 100% ink coverage, rather than 0% ink as you'd expect. +This is arguably a bug in Photoshop, but if you need to work with Photoshop +CMYK files, you will have to deal with it in your application. We cannot +"fix" this in the library by inverting the data during the CMYK<=>YCCK +transform, because that would break other applications, notably Ghostscript. +Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK +data in the same inverted-YCCK representation used in bare JPEG files, but +the surrounding PostScript code performs an inversion using the PS image +operator. I am told that Photoshop 3.0 will write uninverted YCCK in +EPS/JPEG files, and will omit the PS-level inversion. (But the data +polarity used in bare JPEG files will not change in 3.0.) In either case, +the JPEG library must not invert the data itself, or else Ghostscript would +read these EPS files incorrectly. + + +Error handling +-------------- + +When the default error handler is used, any error detected inside the JPEG +routines will cause a message to be printed on stderr, followed by exit(). +You can supply your own error handling routines to override this behavior +and to control the treatment of nonfatal warnings and trace/debug messages. +The file example.c illustrates the most common case, which is to have the +application regain control after an error rather than exiting. + +The JPEG library never writes any message directly; it always goes through +the error handling routines. Three classes of messages are recognized: + * Fatal errors: the library cannot continue. + * Warnings: the library can continue, but the data is corrupt, and a + damaged output image is likely to result. + * Trace/informational messages. These come with a trace level indicating + the importance of the message; you can control the verbosity of the + program by adjusting the maximum trace level that will be displayed. + +You may, if you wish, simply replace the entire JPEG error handling module +(jerror.c) with your own code. However, you can avoid code duplication by +only replacing some of the routines depending on the behavior you need. +This is accomplished by calling jpeg_std_error() as usual, but then overriding +some of the method pointers in the jpeg_error_mgr struct, as illustrated by +example.c. + +All of the error handling routines will receive a pointer to the JPEG object +(a j_common_ptr which points to either a jpeg_compress_struct or a +jpeg_decompress_struct; if you need to tell which, test the is_decompressor +field). This struct includes a pointer to the error manager struct in its +"err" field. Frequently, custom error handler routines will need to access +additional data which is not known to the JPEG library or the standard error +handler. The most convenient way to do this is to embed either the JPEG +object or the jpeg_error_mgr struct in a larger structure that contains +additional fields; then casting the passed pointer provides access to the +additional fields. Again, see example.c for one way to do it. (Beginning +with IJG version 6b, there is also a void pointer "client_data" in each +JPEG object, which the application can also use to find related data. +The library does not touch client_data at all.) + +The individual methods that you might wish to override are: + +error_exit (j_common_ptr cinfo) + Receives control for a fatal error. Information sufficient to + generate the error message has been stored in cinfo->err; call + output_message to display it. Control must NOT return to the caller; + generally this routine will exit() or longjmp() somewhere. + Typically you would override this routine to get rid of the exit() + default behavior. Note that if you continue processing, you should + clean up the JPEG object with jpeg_abort() or jpeg_destroy(). + +output_message (j_common_ptr cinfo) + Actual output of any JPEG message. Override this to send messages + somewhere other than stderr. Note that this method does not know + how to generate a message, only where to send it. + +format_message (j_common_ptr cinfo, char * buffer) + Constructs a readable error message string based on the error info + stored in cinfo->err. This method is called by output_message. Few + applications should need to override this method. One possible + reason for doing so is to implement dynamic switching of error message + language. + +emit_message (j_common_ptr cinfo, int msg_level) + Decide whether or not to emit a warning or trace message; if so, + calls output_message. The main reason for overriding this method + would be to abort on warnings. msg_level is -1 for warnings, + 0 and up for trace messages. + +Only error_exit() and emit_message() are called from the rest of the JPEG +library; the other two are internal to the error handler. + +The actual message texts are stored in an array of strings which is pointed to +by the field err->jpeg_message_table. The messages are numbered from 0 to +err->last_jpeg_message, and it is these code numbers that are used in the +JPEG library code. You could replace the message texts (for instance, with +messages in French or German) by changing the message table pointer. See +jerror.h for the default texts. CAUTION: this table will almost certainly +change or grow from one library version to the next. + +It may be useful for an application to add its own message texts that are +handled by the same mechanism. The error handler supports a second "add-on" +message table for this purpose. To define an addon table, set the pointer +err->addon_message_table and the message numbers err->first_addon_message and +err->last_addon_message. If you number the addon messages beginning at 1000 +or so, you won't have to worry about conflicts with the library's built-in +messages. See the sample applications cjpeg/djpeg for an example of using +addon messages (the addon messages are defined in cderror.h). + +Actual invocation of the error handler is done via macros defined in jerror.h: + ERREXITn(...) for fatal errors + WARNMSn(...) for corrupt-data warnings + TRACEMSn(...) for trace and informational messages. +These macros store the message code and any additional parameters into the +error handler struct, then invoke the error_exit() or emit_message() method. +The variants of each macro are for varying numbers of additional parameters. +The additional parameters are inserted into the generated message using +standard printf() format codes. + +See jerror.h and jerror.c for further details. + + +Compressed data handling (source and destination managers) +---------------------------------------------------------- + +The JPEG compression library sends its compressed data to a "destination +manager" module. The default destination manager just writes the data to a +memory buffer or to a stdio stream, but you can provide your own manager to +do something else. Similarly, the decompression library calls a "source +manager" to obtain the compressed data; you can provide your own source +manager if you want the data to come from somewhere other than a memory +buffer or a stdio stream. + +In both cases, compressed data is processed a bufferload at a time: the +destination or source manager provides a work buffer, and the library invokes +the manager only when the buffer is filled or emptied. (You could define a +one-character buffer to force the manager to be invoked for each byte, but +that would be rather inefficient.) The buffer's size and location are +controlled by the manager, not by the library. For example, the memory +source manager just makes the buffer pointer and length point to the original +data in memory. In this case the buffer-reload procedure will be invoked +only if the decompressor ran off the end of the datastream, which would +indicate an erroneous datastream. + +The work buffer is defined as an array of datatype JOCTET, which is generally +"char" or "unsigned char". On a machine where char is not exactly 8 bits +wide, you must define JOCTET as a wider data type and then modify the data +source and destination modules to transcribe the work arrays into 8-bit units +on external storage. + +A data destination manager struct contains a pointer and count defining the +next byte to write in the work buffer and the remaining free space: + + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + +The library increments the pointer and decrements the count until the buffer +is filled. The manager's empty_output_buffer method must reset the pointer +and count. The manager is expected to remember the buffer's starting address +and total size in private fields not visible to the library. + +A data destination manager provides three methods: + +init_destination (j_compress_ptr cinfo) + Initialize destination. This is called by jpeg_start_compress() + before any data is actually written. It must initialize + next_output_byte and free_in_buffer. free_in_buffer must be + initialized to a positive value. + +empty_output_buffer (j_compress_ptr cinfo) + This is called whenever the buffer has filled (free_in_buffer + reaches zero). In typical applications, it should write out the + *entire* buffer (use the saved start address and buffer length; + ignore the current state of next_output_byte and free_in_buffer). + Then reset the pointer & count to the start of the buffer, and + return TRUE indicating that the buffer has been dumped. + free_in_buffer must be set to a positive value when TRUE is + returned. A FALSE return should only be used when I/O suspension is + desired (this operating mode is discussed in the next section). + +term_destination (j_compress_ptr cinfo) + Terminate destination --- called by jpeg_finish_compress() after all + data has been written. In most applications, this must flush any + data remaining in the buffer. Use either next_output_byte or + free_in_buffer to determine how much data is in the buffer. + +term_destination() is NOT called by jpeg_abort() or jpeg_destroy(). If you +want the destination manager to be cleaned up during an abort, you must do it +yourself. + +You will also need code to create a jpeg_destination_mgr struct, fill in its +method pointers, and insert a pointer to the struct into the "dest" field of +the JPEG compression object. This can be done in-line in your setup code if +you like, but it's probably cleaner to provide a separate routine similar to +the jpeg_stdio_dest() or jpeg_mem_dest() routines of the supplied destination +managers. + +Decompression source managers follow a parallel design, but with some +additional frammishes. The source manager struct contains a pointer and count +defining the next byte to read from the work buffer and the number of bytes +remaining: + + const JOCTET * next_input_byte; /* => next byte to read from buffer */ + size_t bytes_in_buffer; /* # of bytes remaining in buffer */ + +The library increments the pointer and decrements the count until the buffer +is emptied. The manager's fill_input_buffer method must reset the pointer and +count. In most applications, the manager must remember the buffer's starting +address and total size in private fields not visible to the library. + +A data source manager provides five methods: + +init_source (j_decompress_ptr cinfo) + Initialize source. This is called by jpeg_read_header() before any + data is actually read. Unlike init_destination(), it may leave + bytes_in_buffer set to 0 (in which case a fill_input_buffer() call + will occur immediately). + +fill_input_buffer (j_decompress_ptr cinfo) + This is called whenever bytes_in_buffer has reached zero and more + data is wanted. In typical applications, it should read fresh data + into the buffer (ignoring the current state of next_input_byte and + bytes_in_buffer), reset the pointer & count to the start of the + buffer, and return TRUE indicating that the buffer has been reloaded. + It is not necessary to fill the buffer entirely, only to obtain at + least one more byte. bytes_in_buffer MUST be set to a positive value + if TRUE is returned. A FALSE return should only be used when I/O + suspension is desired (this mode is discussed in the next section). + +skip_input_data (j_decompress_ptr cinfo, long num_bytes) + Skip num_bytes worth of data. The buffer pointer and count should + be advanced over num_bytes input bytes, refilling the buffer as + needed. This is used to skip over a potentially large amount of + uninteresting data (such as an APPn marker). In some applications + it may be possible to optimize away the reading of the skipped data, + but it's not clear that being smart is worth much trouble; large + skips are uncommon. bytes_in_buffer may be zero on return. + A zero or negative skip count should be treated as a no-op. + +resync_to_restart (j_decompress_ptr cinfo, int desired) + This routine is called only when the decompressor has failed to find + a restart (RSTn) marker where one is expected. Its mission is to + find a suitable point for resuming decompression. For most + applications, we recommend that you just use the default resync + procedure, jpeg_resync_to_restart(). However, if you are able to back + up in the input data stream, or if you have a-priori knowledge about + the likely location of restart markers, you may be able to do better. + Read the read_restart_marker() and jpeg_resync_to_restart() routines + in jdmarker.c if you think you'd like to implement your own resync + procedure. + +term_source (j_decompress_ptr cinfo) + Terminate source --- called by jpeg_finish_decompress() after all + data has been read. Often a no-op. + +For both fill_input_buffer() and skip_input_data(), there is no such thing +as an EOF return. If the end of the file has been reached, the routine has +a choice of exiting via ERREXIT() or inserting fake data into the buffer. +In most cases, generating a warning message and inserting a fake EOI marker +is the best course of action --- this will allow the decompressor to output +however much of the image is there. In pathological cases, the decompressor +may swallow the EOI and again demand data ... just keep feeding it fake EOIs. +jdatasrc.c illustrates the recommended error recovery behavior. + +term_source() is NOT called by jpeg_abort() or jpeg_destroy(). If you want +the source manager to be cleaned up during an abort, you must do it yourself. + +You will also need code to create a jpeg_source_mgr struct, fill in its method +pointers, and insert a pointer to the struct into the "src" field of the JPEG +decompression object. This can be done in-line in your setup code if you +like, but it's probably cleaner to provide a separate routine similar to the +jpeg_stdio_src() or jpeg_mem_src() routines of the supplied source managers. + +For more information, consult the memory and stdio source and destination +managers in jdatasrc.c and jdatadst.c. + + +I/O suspension +-------------- + +Some applications need to use the JPEG library as an incremental memory-to- +memory filter: when the compressed data buffer is filled or emptied, they want +control to return to the outer loop, rather than expecting that the buffer can +be emptied or reloaded within the data source/destination manager subroutine. +The library supports this need by providing an "I/O suspension" mode, which we +describe in this section. + +The I/O suspension mode is not a panacea: nothing is guaranteed about the +maximum amount of time spent in any one call to the library, so it will not +eliminate response-time problems in single-threaded applications. If you +need guaranteed response time, we suggest you "bite the bullet" and implement +a real multi-tasking capability. + +To use I/O suspension, cooperation is needed between the calling application +and the data source or destination manager; you will always need a custom +source/destination manager. (Please read the previous section if you haven't +already.) The basic idea is that the empty_output_buffer() or +fill_input_buffer() routine is a no-op, merely returning FALSE to indicate +that it has done nothing. Upon seeing this, the JPEG library suspends +operation and returns to its caller. The surrounding application is +responsible for emptying or refilling the work buffer before calling the +JPEG library again. + +Compression suspension: + +For compression suspension, use an empty_output_buffer() routine that returns +FALSE; typically it will not do anything else. This will cause the +compressor to return to the caller of jpeg_write_scanlines(), with the return +value indicating that not all the supplied scanlines have been accepted. +The application must make more room in the output buffer, adjust the output +buffer pointer/count appropriately, and then call jpeg_write_scanlines() +again, pointing to the first unconsumed scanline. + +When forced to suspend, the compressor will backtrack to a convenient stopping +point (usually the start of the current MCU); it will regenerate some output +data when restarted. Therefore, although empty_output_buffer() is only +called when the buffer is filled, you should NOT write out the entire buffer +after a suspension. Write only the data up to the current position of +next_output_byte/free_in_buffer. The data beyond that point will be +regenerated after resumption. + +Because of the backtracking behavior, a good-size output buffer is essential +for efficiency; you don't want the compressor to suspend often. (In fact, an +overly small buffer could lead to infinite looping, if a single MCU required +more data than would fit in the buffer.) We recommend a buffer of at least +several Kbytes. You may want to insert explicit code to ensure that you don't +call jpeg_write_scanlines() unless there is a reasonable amount of space in +the output buffer; in other words, flush the buffer before trying to compress +more data. + +The compressor does not allow suspension while it is trying to write JPEG +markers at the beginning and end of the file. This means that: + * At the beginning of a compression operation, there must be enough free + space in the output buffer to hold the header markers (typically 600 or + so bytes). The recommended buffer size is bigger than this anyway, so + this is not a problem as long as you start with an empty buffer. However, + this restriction might catch you if you insert large special markers, such + as a JFIF thumbnail image, without flushing the buffer afterwards. + * When you call jpeg_finish_compress(), there must be enough space in the + output buffer to emit any buffered data and the final EOI marker. In the + current implementation, half a dozen bytes should suffice for this, but + for safety's sake we recommend ensuring that at least 100 bytes are free + before calling jpeg_finish_compress(). + +A more significant restriction is that jpeg_finish_compress() cannot suspend. +This means you cannot use suspension with multi-pass operating modes, namely +Huffman code optimization and multiple-scan output. Those modes write the +whole file during jpeg_finish_compress(), which will certainly result in +buffer overrun. (Note that this restriction applies only to compression, +not decompression. The decompressor supports input suspension in all of its +operating modes.) + +Decompression suspension: + +For decompression suspension, use a fill_input_buffer() routine that simply +returns FALSE (except perhaps during error recovery, as discussed below). +This will cause the decompressor to return to its caller with an indication +that suspension has occurred. This can happen at four places: + * jpeg_read_header(): will return JPEG_SUSPENDED. + * jpeg_start_decompress(): will return FALSE, rather than its usual TRUE. + * jpeg_read_scanlines(): will return the number of scanlines already + completed (possibly 0). + * jpeg_finish_decompress(): will return FALSE, rather than its usual TRUE. +The surrounding application must recognize these cases, load more data into +the input buffer, and repeat the call. In the case of jpeg_read_scanlines(), +increment the passed pointers past any scanlines successfully read. + +Just as with compression, the decompressor will typically backtrack to a +convenient restart point before suspending. When fill_input_buffer() is +called, next_input_byte/bytes_in_buffer point to the current restart point, +which is where the decompressor will backtrack to if FALSE is returned. +The data beyond that position must NOT be discarded if you suspend; it needs +to be re-read upon resumption. In most implementations, you'll need to shift +this data down to the start of your work buffer and then load more data after +it. Again, this behavior means that a several-Kbyte work buffer is essential +for decent performance; furthermore, you should load a reasonable amount of +new data before resuming decompression. (If you loaded, say, only one new +byte each time around, you could waste a LOT of cycles.) + +The skip_input_data() source manager routine requires special care in a +suspension scenario. This routine is NOT granted the ability to suspend the +decompressor; it can decrement bytes_in_buffer to zero, but no more. If the +requested skip distance exceeds the amount of data currently in the input +buffer, then skip_input_data() must set bytes_in_buffer to zero and record the +additional skip distance somewhere else. The decompressor will immediately +call fill_input_buffer(), which should return FALSE, which will cause a +suspension return. The surrounding application must then arrange to discard +the recorded number of bytes before it resumes loading the input buffer. +(Yes, this design is rather baroque, but it avoids complexity in the far more +common case where a non-suspending source manager is used.) + +If the input data has been exhausted, we recommend that you emit a warning +and insert dummy EOI markers just as a non-suspending data source manager +would do. This can be handled either in the surrounding application logic or +within fill_input_buffer(); the latter is probably more efficient. If +fill_input_buffer() knows that no more data is available, it can set the +pointer/count to point to a dummy EOI marker and then return TRUE just as +though it had read more data in a non-suspending situation. + +The decompressor does not attempt to suspend within standard JPEG markers; +instead it will backtrack to the start of the marker and reprocess the whole +marker next time. Hence the input buffer must be large enough to hold the +longest standard marker in the file. Standard JPEG markers should normally +not exceed a few hundred bytes each (DHT tables are typically the longest). +We recommend at least a 2K buffer for performance reasons, which is much +larger than any correct marker is likely to be. For robustness against +damaged marker length counts, you may wish to insert a test in your +application for the case that the input buffer is completely full and yet +the decoder has suspended without consuming any data --- otherwise, if this +situation did occur, it would lead to an endless loop. (The library can't +provide this test since it has no idea whether "the buffer is full", or +even whether there is a fixed-size input buffer.) + +The input buffer would need to be 64K to allow for arbitrary COM or APPn +markers, but these are handled specially: they are either saved into allocated +memory, or skipped over by calling skip_input_data(). In the former case, +suspension is handled correctly, and in the latter case, the problem of +buffer overrun is placed on skip_input_data's shoulders, as explained above. +Note that if you provide your own marker handling routine for large markers, +you should consider how to deal with buffer overflow. + +Multiple-buffer management: + +In some applications it is desirable to store the compressed data in a linked +list of buffer areas, so as to avoid data copying. This can be handled by +having empty_output_buffer() or fill_input_buffer() set the pointer and count +to reference the next available buffer; FALSE is returned only if no more +buffers are available. Although seemingly straightforward, there is a +pitfall in this approach: the backtrack that occurs when FALSE is returned +could back up into an earlier buffer. For example, when fill_input_buffer() +is called, the current pointer & count indicate the backtrack restart point. +Since fill_input_buffer() will set the pointer and count to refer to a new +buffer, the restart position must be saved somewhere else. Suppose a second +call to fill_input_buffer() occurs in the same library call, and no +additional input data is available, so fill_input_buffer must return FALSE. +If the JPEG library has not moved the pointer/count forward in the current +buffer, then *the correct restart point is the saved position in the prior +buffer*. Prior buffers may be discarded only after the library establishes +a restart point within a later buffer. Similar remarks apply for output into +a chain of buffers. + +The library will never attempt to backtrack over a skip_input_data() call, +so any skipped data can be permanently discarded. You still have to deal +with the case of skipping not-yet-received data, however. + +It's much simpler to use only a single buffer; when fill_input_buffer() is +called, move any unconsumed data (beyond the current pointer/count) down to +the beginning of this buffer and then load new data into the remaining buffer +space. This approach requires a little more data copying but is far easier +to get right. + + +Progressive JPEG support +------------------------ + +Progressive JPEG rearranges the stored data into a series of scans of +increasing quality. In situations where a JPEG file is transmitted across a +slow communications link, a decoder can generate a low-quality image very +quickly from the first scan, then gradually improve the displayed quality as +more scans are received. The final image after all scans are complete is +identical to that of a regular (sequential) JPEG file of the same quality +setting. Progressive JPEG files are often slightly smaller than equivalent +sequential JPEG files, but the possibility of incremental display is the main +reason for using progressive JPEG. + +The IJG encoder library generates progressive JPEG files when given a +suitable "scan script" defining how to divide the data into scans. +Creation of progressive JPEG files is otherwise transparent to the encoder. +Progressive JPEG files can also be read transparently by the decoder library. +If the decoding application simply uses the library as defined above, it +will receive a final decoded image without any indication that the file was +progressive. Of course, this approach does not allow incremental display. +To perform incremental display, an application needs to use the decoder +library's "buffered-image" mode, in which it receives a decoded image +multiple times. + +Each displayed scan requires about as much work to decode as a full JPEG +image of the same size, so the decoder must be fairly fast in relation to the +data transmission rate in order to make incremental display useful. However, +it is possible to skip displaying the image and simply add the incoming bits +to the decoder's coefficient buffer. This is fast because only Huffman +decoding need be done, not IDCT, upsampling, colorspace conversion, etc. +The IJG decoder library allows the application to switch dynamically between +displaying the image and simply absorbing the incoming bits. A properly +coded application can automatically adapt the number of display passes to +suit the time available as the image is received. Also, a final +higher-quality display cycle can be performed from the buffered data after +the end of the file is reached. + +Progressive compression: + +To create a progressive JPEG file (or a multiple-scan sequential JPEG file), +set the scan_info cinfo field to point to an array of scan descriptors, and +perform compression as usual. Instead of constructing your own scan list, +you can call the jpeg_simple_progression() helper routine to create a +recommended progression sequence; this method should be used by all +applications that don't want to get involved in the nitty-gritty of +progressive scan sequence design. (If you want to provide user control of +scan sequences, you may wish to borrow the scan script reading code found +in rdswitch.c, so that you can read scan script files just like cjpeg's.) +When scan_info is not NULL, the compression library will store DCT'd data +into a buffer array as jpeg_write_scanlines() is called, and will emit all +the requested scans during jpeg_finish_compress(). This implies that +multiple-scan output cannot be created with a suspending data destination +manager, since jpeg_finish_compress() does not support suspension. We +should also note that the compressor currently forces Huffman optimization +mode when creating a progressive JPEG file, because the default Huffman +tables are unsuitable for progressive files. + +Progressive decompression: + +When buffered-image mode is not used, the decoder library will read all of +a multi-scan file during jpeg_start_decompress(), so that it can provide a +final decoded image. (Here "multi-scan" means either progressive or +multi-scan sequential.) This makes multi-scan files transparent to the +decoding application. However, existing applications that used suspending +input with version 5 of the IJG library will need to be modified to check +for a suspension return from jpeg_start_decompress(). + +To perform incremental display, an application must use the library's +buffered-image mode. This is described in the next section. + + +Buffered-image mode +------------------- + +In buffered-image mode, the library stores the partially decoded image in a +coefficient buffer, from which it can be read out as many times as desired. +This mode is typically used for incremental display of progressive JPEG files, +but it can be used with any JPEG file. Each scan of a progressive JPEG file +adds more data (more detail) to the buffered image. The application can +display in lockstep with the source file (one display pass per input scan), +or it can allow input processing to outrun display processing. By making +input and display processing run independently, it is possible for the +application to adapt progressive display to a wide range of data transmission +rates. + +The basic control flow for buffered-image decoding is + + jpeg_create_decompress() + set data source + jpeg_read_header() + set overall decompression parameters + cinfo.buffered_image = TRUE; /* select buffered-image mode */ + jpeg_start_decompress() + for (each output pass) { + adjust output decompression parameters if required + jpeg_start_output() /* start a new output pass */ + for (all scanlines in image) { + jpeg_read_scanlines() + display scanlines + } + jpeg_finish_output() /* terminate output pass */ + } + jpeg_finish_decompress() + jpeg_destroy_decompress() + +This differs from ordinary unbuffered decoding in that there is an additional +level of looping. The application can choose how many output passes to make +and how to display each pass. + +The simplest approach to displaying progressive images is to do one display +pass for each scan appearing in the input file. In this case the outer loop +condition is typically + while (! jpeg_input_complete(&cinfo)) +and the start-output call should read + jpeg_start_output(&cinfo, cinfo.input_scan_number); +The second parameter to jpeg_start_output() indicates which scan of the input +file is to be displayed; the scans are numbered starting at 1 for this +purpose. (You can use a loop counter starting at 1 if you like, but using +the library's input scan counter is easier.) The library automatically reads +data as necessary to complete each requested scan, and jpeg_finish_output() +advances to the next scan or end-of-image marker (hence input_scan_number +will be incremented by the time control arrives back at jpeg_start_output()). +With this technique, data is read from the input file only as needed, and +input and output processing run in lockstep. + +After reading the final scan and reaching the end of the input file, the +buffered image remains available; it can be read additional times by +repeating the jpeg_start_output()/jpeg_read_scanlines()/jpeg_finish_output() +sequence. For example, a useful technique is to use fast one-pass color +quantization for display passes made while the image is arriving, followed by +a final display pass using two-pass quantization for highest quality. This +is done by changing the library parameters before the final output pass. +Changing parameters between passes is discussed in detail below. + +In general the last scan of a progressive file cannot be recognized as such +until after it is read, so a post-input display pass is the best approach if +you want special processing in the final pass. + +When done with the image, be sure to call jpeg_finish_decompress() to release +the buffered image (or just use jpeg_destroy_decompress()). + +If input data arrives faster than it can be displayed, the application can +cause the library to decode input data in advance of what's needed to produce +output. This is done by calling the routine jpeg_consume_input(). +The return value is one of the following: + JPEG_REACHED_SOS: reached an SOS marker (the start of a new scan) + JPEG_REACHED_EOI: reached the EOI marker (end of image) + JPEG_ROW_COMPLETED: completed reading one MCU row of compressed data + JPEG_SCAN_COMPLETED: completed reading last MCU row of current scan + JPEG_SUSPENDED: suspended before completing any of the above +(JPEG_SUSPENDED can occur only if a suspending data source is used.) This +routine can be called at any time after initializing the JPEG object. It +reads some additional data and returns when one of the indicated significant +events occurs. (If called after the EOI marker is reached, it will +immediately return JPEG_REACHED_EOI without attempting to read more data.) + +The library's output processing will automatically call jpeg_consume_input() +whenever the output processing overtakes the input; thus, simple lockstep +display requires no direct calls to jpeg_consume_input(). But by adding +calls to jpeg_consume_input(), you can absorb data in advance of what is +being displayed. This has two benefits: + * You can limit buildup of unprocessed data in your input buffer. + * You can eliminate extra display passes by paying attention to the + state of the library's input processing. + +The first of these benefits only requires interspersing calls to +jpeg_consume_input() with your display operations and any other processing +you may be doing. To avoid wasting cycles due to backtracking, it's best to +call jpeg_consume_input() only after a hundred or so new bytes have arrived. +This is discussed further under "I/O suspension", above. (Note: the JPEG +library currently is not thread-safe. You must not call jpeg_consume_input() +from one thread of control if a different library routine is working on the +same JPEG object in another thread.) + +When input arrives fast enough that more than one new scan is available +before you start a new output pass, you may as well skip the output pass +corresponding to the completed scan. This occurs for free if you pass +cinfo.input_scan_number as the target scan number to jpeg_start_output(). +The input_scan_number field is simply the index of the scan currently being +consumed by the input processor. You can ensure that this is up-to-date by +emptying the input buffer just before calling jpeg_start_output(): call +jpeg_consume_input() repeatedly until it returns JPEG_SUSPENDED or +JPEG_REACHED_EOI. + +The target scan number passed to jpeg_start_output() is saved in the +cinfo.output_scan_number field. The library's output processing calls +jpeg_consume_input() whenever the current input scan number and row within +that scan is less than or equal to the current output scan number and row. +Thus, input processing can "get ahead" of the output processing but is not +allowed to "fall behind". You can achieve several different effects by +manipulating this interlock rule. For example, if you pass a target scan +number greater than the current input scan number, the output processor will +wait until that scan starts to arrive before producing any output. (To avoid +an infinite loop, the target scan number is automatically reset to the last +scan number when the end of image is reached. Thus, if you specify a large +target scan number, the library will just absorb the entire input file and +then perform an output pass. This is effectively the same as what +jpeg_start_decompress() does when you don't select buffered-image mode.) +When you pass a target scan number equal to the current input scan number, +the image is displayed no faster than the current input scan arrives. The +final possibility is to pass a target scan number less than the current input +scan number; this disables the input/output interlock and causes the output +processor to simply display whatever it finds in the image buffer, without +waiting for input. (However, the library will not accept a target scan +number less than one, so you can't avoid waiting for the first scan.) + +When data is arriving faster than the output display processing can advance +through the image, jpeg_consume_input() will store data into the buffered +image beyond the point at which the output processing is reading data out +again. If the input arrives fast enough, it may "wrap around" the buffer to +the point where the input is more than one whole scan ahead of the output. +If the output processing simply proceeds through its display pass without +paying attention to the input, the effect seen on-screen is that the lower +part of the image is one or more scans better in quality than the upper part. +Then, when the next output scan is started, you have a choice of what target +scan number to use. The recommended choice is to use the current input scan +number at that time, which implies that you've skipped the output scans +corresponding to the input scans that were completed while you processed the +previous output scan. In this way, the decoder automatically adapts its +speed to the arriving data, by skipping output scans as necessary to keep up +with the arriving data. + +When using this strategy, you'll want to be sure that you perform a final +output pass after receiving all the data; otherwise your last display may not +be full quality across the whole screen. So the right outer loop logic is +something like this: + do { + absorb any waiting input by calling jpeg_consume_input() + final_pass = jpeg_input_complete(&cinfo); + adjust output decompression parameters if required + jpeg_start_output(&cinfo, cinfo.input_scan_number); + ... + jpeg_finish_output() + } while (! final_pass); +rather than quitting as soon as jpeg_input_complete() returns TRUE. This +arrangement makes it simple to use higher-quality decoding parameters +for the final pass. But if you don't want to use special parameters for +the final pass, the right loop logic is like this: + for (;;) { + absorb any waiting input by calling jpeg_consume_input() + jpeg_start_output(&cinfo, cinfo.input_scan_number); + ... + jpeg_finish_output() + if (jpeg_input_complete(&cinfo) && + cinfo.input_scan_number == cinfo.output_scan_number) + break; + } +In this case you don't need to know in advance whether an output pass is to +be the last one, so it's not necessary to have reached EOF before starting +the final output pass; rather, what you want to test is whether the output +pass was performed in sync with the final input scan. This form of the loop +will avoid an extra output pass whenever the decoder is able (or nearly able) +to keep up with the incoming data. + +When the data transmission speed is high, you might begin a display pass, +then find that much or all of the file has arrived before you can complete +the pass. (You can detect this by noting the JPEG_REACHED_EOI return code +from jpeg_consume_input(), or equivalently by testing jpeg_input_complete().) +In this situation you may wish to abort the current display pass and start a +new one using the newly arrived information. To do so, just call +jpeg_finish_output() and then start a new pass with jpeg_start_output(). + +A variant strategy is to abort and restart display if more than one complete +scan arrives during an output pass; this can be detected by noting +JPEG_REACHED_SOS returns and/or examining cinfo.input_scan_number. This +idea should be employed with caution, however, since the display process +might never get to the bottom of the image before being aborted, resulting +in the lower part of the screen being several passes worse than the upper. +In most cases it's probably best to abort an output pass only if the whole +file has arrived and you want to begin the final output pass immediately. + +When receiving data across a communication link, we recommend always using +the current input scan number for the output target scan number; if a +higher-quality final pass is to be done, it should be started (aborting any +incomplete output pass) as soon as the end of file is received. However, +many other strategies are possible. For example, the application can examine +the parameters of the current input scan and decide whether to display it or +not. If the scan contains only chroma data, one might choose not to use it +as the target scan, expecting that the scan will be small and will arrive +quickly. To skip to the next scan, call jpeg_consume_input() until it +returns JPEG_REACHED_SOS or JPEG_REACHED_EOI. Or just use the next higher +number as the target scan for jpeg_start_output(); but that method doesn't +let you inspect the next scan's parameters before deciding to display it. + + +In buffered-image mode, jpeg_start_decompress() never performs input and +thus never suspends. An application that uses input suspension with +buffered-image mode must be prepared for suspension returns from these +routines: +* jpeg_start_output() performs input only if you request 2-pass quantization + and the target scan isn't fully read yet. (This is discussed below.) +* jpeg_read_scanlines(), as always, returns the number of scanlines that it + was able to produce before suspending. +* jpeg_finish_output() will read any markers following the target scan, + up to the end of the file or the SOS marker that begins another scan. + (But it reads no input if jpeg_consume_input() has already reached the + end of the file or a SOS marker beyond the target output scan.) +* jpeg_finish_decompress() will read until the end of file, and thus can + suspend if the end hasn't already been reached (as can be tested by + calling jpeg_input_complete()). +jpeg_start_output(), jpeg_finish_output(), and jpeg_finish_decompress() +all return TRUE if they completed their tasks, FALSE if they had to suspend. +In the event of a FALSE return, the application must load more input data +and repeat the call. Applications that use non-suspending data sources need +not check the return values of these three routines. + + +It is possible to change decoding parameters between output passes in the +buffered-image mode. The decoder library currently supports only very +limited changes of parameters. ONLY THE FOLLOWING parameter changes are +allowed after jpeg_start_decompress() is called: +* dct_method can be changed before each call to jpeg_start_output(). + For example, one could use a fast DCT method for early scans, changing + to a higher quality method for the final scan. +* dither_mode can be changed before each call to jpeg_start_output(); + of course this has no impact if not using color quantization. Typically + one would use ordered dither for initial passes, then switch to + Floyd-Steinberg dither for the final pass. Caution: changing dither mode + can cause more memory to be allocated by the library. Although the amount + of memory involved is not large (a scanline or so), it may cause the + initial max_memory_to_use specification to be exceeded, which in the worst + case would result in an out-of-memory failure. +* do_block_smoothing can be changed before each call to jpeg_start_output(). + This setting is relevant only when decoding a progressive JPEG image. + During the first DC-only scan, block smoothing provides a very "fuzzy" look + instead of the very "blocky" look seen without it; which is better seems a + matter of personal taste. But block smoothing is nearly always a win + during later stages, especially when decoding a successive-approximation + image: smoothing helps to hide the slight blockiness that otherwise shows + up on smooth gradients until the lowest coefficient bits are sent. +* Color quantization mode can be changed under the rules described below. + You *cannot* change between full-color and quantized output (because that + would alter the required I/O buffer sizes), but you can change which + quantization method is used. + +When generating color-quantized output, changing quantization method is a +very useful way of switching between high-speed and high-quality display. +The library allows you to change among its three quantization methods: +1. Single-pass quantization to a fixed color cube. + Selected by cinfo.two_pass_quantize = FALSE and cinfo.colormap = NULL. +2. Single-pass quantization to an application-supplied colormap. + Selected by setting cinfo.colormap to point to the colormap (the value of + two_pass_quantize is ignored); also set cinfo.actual_number_of_colors. +3. Two-pass quantization to a colormap chosen specifically for the image. + Selected by cinfo.two_pass_quantize = TRUE and cinfo.colormap = NULL. + (This is the default setting selected by jpeg_read_header, but it is + probably NOT what you want for the first pass of progressive display!) +These methods offer successively better quality and lesser speed. However, +only the first method is available for quantizing in non-RGB color spaces. + +IMPORTANT: because the different quantizer methods have very different +working-storage requirements, the library requires you to indicate which +one(s) you intend to use before you call jpeg_start_decompress(). (If we did +not require this, the max_memory_to_use setting would be a complete fiction.) +You do this by setting one or more of these three cinfo fields to TRUE: + enable_1pass_quant Fixed color cube colormap + enable_external_quant Externally-supplied colormap + enable_2pass_quant Two-pass custom colormap +All three are initialized FALSE by jpeg_read_header(). But +jpeg_start_decompress() automatically sets TRUE the one selected by the +current two_pass_quantize and colormap settings, so you only need to set the +enable flags for any other quantization methods you plan to change to later. + +After setting the enable flags correctly at jpeg_start_decompress() time, you +can change to any enabled quantization method by setting two_pass_quantize +and colormap properly just before calling jpeg_start_output(). The following +special rules apply: +1. You must explicitly set cinfo.colormap to NULL when switching to 1-pass + or 2-pass mode from a different mode, or when you want the 2-pass + quantizer to be re-run to generate a new colormap. +2. To switch to an external colormap, or to change to a different external + colormap than was used on the prior pass, you must call + jpeg_new_colormap() after setting cinfo.colormap. +NOTE: if you want to use the same colormap as was used in the prior pass, +you should not do either of these things. This will save some nontrivial +switchover costs. +(These requirements exist because cinfo.colormap will always be non-NULL +after completing a prior output pass, since both the 1-pass and 2-pass +quantizers set it to point to their output colormaps. Thus you have to +do one of these two things to notify the library that something has changed. +Yup, it's a bit klugy, but it's necessary to do it this way for backwards +compatibility.) + +Note that in buffered-image mode, the library generates any requested colormap +during jpeg_start_output(), not during jpeg_start_decompress(). + +When using two-pass quantization, jpeg_start_output() makes a pass over the +buffered image to determine the optimum color map; it therefore may take a +significant amount of time, whereas ordinarily it does little work. The +progress monitor hook is called during this pass, if defined. It is also +important to realize that if the specified target scan number is greater than +or equal to the current input scan number, jpeg_start_output() will attempt +to consume input as it makes this pass. If you use a suspending data source, +you need to check for a FALSE return from jpeg_start_output() under these +conditions. The combination of 2-pass quantization and a not-yet-fully-read +target scan is the only case in which jpeg_start_output() will consume input. + + +Application authors who support buffered-image mode may be tempted to use it +for all JPEG images, even single-scan ones. This will work, but it is +inefficient: there is no need to create an image-sized coefficient buffer for +single-scan images. Requesting buffered-image mode for such an image wastes +memory. Worse, it can cost time on large images, since the buffered data has +to be swapped out or written to a temporary file. If you are concerned about +maximum performance on baseline JPEG files, you should use buffered-image +mode only when the incoming file actually has multiple scans. This can be +tested by calling jpeg_has_multiple_scans(), which will return a correct +result at any time after jpeg_read_header() completes. + +It is also worth noting that when you use jpeg_consume_input() to let input +processing get ahead of output processing, the resulting pattern of access to +the coefficient buffer is quite nonsequential. It's best to use the memory +manager jmemnobs.c if you can (ie, if you have enough real or virtual main +memory). If not, at least make sure that max_memory_to_use is set as high as +possible. If the JPEG memory manager has to use a temporary file, you will +probably see a lot of disk traffic and poor performance. (This could be +improved with additional work on the memory manager, but we haven't gotten +around to it yet.) + +In some applications it may be convenient to use jpeg_consume_input() for all +input processing, including reading the initial markers; that is, you may +wish to call jpeg_consume_input() instead of jpeg_read_header() during +startup. This works, but note that you must check for JPEG_REACHED_SOS and +JPEG_REACHED_EOI return codes as the equivalent of jpeg_read_header's codes. +Once the first SOS marker has been reached, you must call +jpeg_start_decompress() before jpeg_consume_input() will consume more input; +it'll just keep returning JPEG_REACHED_SOS until you do. If you read a +tables-only file this way, jpeg_consume_input() will return JPEG_REACHED_EOI +without ever returning JPEG_REACHED_SOS; be sure to check for this case. +If this happens, the decompressor will not read any more input until you call +jpeg_abort() to reset it. It is OK to call jpeg_consume_input() even when not +using buffered-image mode, but in that case it's basically a no-op after the +initial markers have been read: it will just return JPEG_SUSPENDED. + + +Abbreviated datastreams and multiple images +------------------------------------------- + +A JPEG compression or decompression object can be reused to process multiple +images. This saves a small amount of time per image by eliminating the +"create" and "destroy" operations, but that isn't the real purpose of the +feature. Rather, reuse of an object provides support for abbreviated JPEG +datastreams. Object reuse can also simplify processing a series of images in +a single input or output file. This section explains these features. + +A JPEG file normally contains several hundred bytes worth of quantization +and Huffman tables. In a situation where many images will be stored or +transmitted with identical tables, this may represent an annoying overhead. +The JPEG standard therefore permits tables to be omitted. The standard +defines three classes of JPEG datastreams: + * "Interchange" datastreams contain an image and all tables needed to decode + the image. These are the usual kind of JPEG file. + * "Abbreviated image" datastreams contain an image, but are missing some or + all of the tables needed to decode that image. + * "Abbreviated table specification" (henceforth "tables-only") datastreams + contain only table specifications. +To decode an abbreviated image, it is necessary to load the missing table(s) +into the decoder beforehand. This can be accomplished by reading a separate +tables-only file. A variant scheme uses a series of images in which the first +image is an interchange (complete) datastream, while subsequent ones are +abbreviated and rely on the tables loaded by the first image. It is assumed +that once the decoder has read a table, it will remember that table until a +new definition for the same table number is encountered. + +It is the application designer's responsibility to figure out how to associate +the correct tables with an abbreviated image. While abbreviated datastreams +can be useful in a closed environment, their use is strongly discouraged in +any situation where data exchange with other applications might be needed. +Caveat designer. + +The JPEG library provides support for reading and writing any combination of +tables-only datastreams and abbreviated images. In both compression and +decompression objects, a quantization or Huffman table will be retained for +the lifetime of the object, unless it is overwritten by a new table definition. + + +To create abbreviated image datastreams, it is only necessary to tell the +compressor not to emit some or all of the tables it is using. Each +quantization and Huffman table struct contains a boolean field "sent_table", +which normally is initialized to FALSE. For each table used by the image, the +header-writing process emits the table and sets sent_table = TRUE unless it is +already TRUE. (In normal usage, this prevents outputting the same table +definition multiple times, as would otherwise occur because the chroma +components typically share tables.) Thus, setting this field to TRUE before +calling jpeg_start_compress() will prevent the table from being written at +all. + +If you want to create a "pure" abbreviated image file containing no tables, +just call "jpeg_suppress_tables(&cinfo, TRUE)" after constructing all the +tables. If you want to emit some but not all tables, you'll need to set the +individual sent_table fields directly. + +To create an abbreviated image, you must also call jpeg_start_compress() +with a second parameter of FALSE, not TRUE. Otherwise jpeg_start_compress() +will force all the sent_table fields to FALSE. (This is a safety feature to +prevent abbreviated images from being created accidentally.) + +To create a tables-only file, perform the same parameter setup that you +normally would, but instead of calling jpeg_start_compress() and so on, call +jpeg_write_tables(&cinfo). This will write an abbreviated datastream +containing only SOI, DQT and/or DHT markers, and EOI. All the quantization +and Huffman tables that are currently defined in the compression object will +be emitted unless their sent_tables flag is already TRUE, and then all the +sent_tables flags will be set TRUE. + +A sure-fire way to create matching tables-only and abbreviated image files +is to proceed as follows: + + create JPEG compression object + set JPEG parameters + set destination to tables-only file + jpeg_write_tables(&cinfo); + set destination to image file + jpeg_start_compress(&cinfo, FALSE); + write data... + jpeg_finish_compress(&cinfo); + +Since the JPEG parameters are not altered between writing the table file and +the abbreviated image file, the same tables are sure to be used. Of course, +you can repeat the jpeg_start_compress() ... jpeg_finish_compress() sequence +many times to produce many abbreviated image files matching the table file. + +You cannot suppress output of the computed Huffman tables when Huffman +optimization is selected. (If you could, there'd be no way to decode the +image...) Generally, you don't want to set optimize_coding = TRUE when +you are trying to produce abbreviated files. + +In some cases you might want to compress an image using tables which are +not stored in the application, but are defined in an interchange or +tables-only file readable by the application. This can be done by setting up +a JPEG decompression object to read the specification file, then copying the +tables into your compression object. See jpeg_copy_critical_parameters() +for an example of copying quantization tables. + + +To read abbreviated image files, you simply need to load the proper tables +into the decompression object before trying to read the abbreviated image. +If the proper tables are stored in the application program, you can just +allocate the table structs and fill in their contents directly. For example, +to load a fixed quantization table into table slot "n": + + if (cinfo.quant_tbl_ptrs[n] == NULL) + cinfo.quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) &cinfo); + quant_ptr = cinfo.quant_tbl_ptrs[n]; /* quant_ptr is JQUANT_TBL* */ + for (i = 0; i < 64; i++) { + /* Qtable[] is desired quantization table, in natural array order */ + quant_ptr->quantval[i] = Qtable[i]; + } + +Code to load a fixed Huffman table is typically (for AC table "n"): + + if (cinfo.ac_huff_tbl_ptrs[n] == NULL) + cinfo.ac_huff_tbl_ptrs[n] = jpeg_alloc_huff_table((j_common_ptr) &cinfo); + huff_ptr = cinfo.ac_huff_tbl_ptrs[n]; /* huff_ptr is JHUFF_TBL* */ + for (i = 1; i <= 16; i++) { + /* counts[i] is number of Huffman codes of length i bits, i=1..16 */ + huff_ptr->bits[i] = counts[i]; + } + for (i = 0; i < 256; i++) { + /* symbols[] is the list of Huffman symbols, in code-length order */ + huff_ptr->huffval[i] = symbols[i]; + } + +(Note that trying to set cinfo.quant_tbl_ptrs[n] to point directly at a +constant JQUANT_TBL object is not safe. If the incoming file happened to +contain a quantization table definition, your master table would get +overwritten! Instead allocate a working table copy and copy the master table +into it, as illustrated above. Ditto for Huffman tables, of course.) + +You might want to read the tables from a tables-only file, rather than +hard-wiring them into your application. The jpeg_read_header() call is +sufficient to read a tables-only file. You must pass a second parameter of +FALSE to indicate that you do not require an image to be present. Thus, the +typical scenario is + + create JPEG decompression object + set source to tables-only file + jpeg_read_header(&cinfo, FALSE); + set source to abbreviated image file + jpeg_read_header(&cinfo, TRUE); + set decompression parameters + jpeg_start_decompress(&cinfo); + read data... + jpeg_finish_decompress(&cinfo); + +In some cases, you may want to read a file without knowing whether it contains +an image or just tables. In that case, pass FALSE and check the return value +from jpeg_read_header(): it will be JPEG_HEADER_OK if an image was found, +JPEG_HEADER_TABLES_ONLY if only tables were found. (A third return value, +JPEG_SUSPENDED, is possible when using a suspending data source manager.) +Note that jpeg_read_header() will not complain if you read an abbreviated +image for which you haven't loaded the missing tables; the missing-table check +occurs later, in jpeg_start_decompress(). + + +It is possible to read a series of images from a single source file by +repeating the jpeg_read_header() ... jpeg_finish_decompress() sequence, +without releasing/recreating the JPEG object or the data source module. +(If you did reinitialize, any partial bufferload left in the data source +buffer at the end of one image would be discarded, causing you to lose the +start of the next image.) When you use this method, stored tables are +automatically carried forward, so some of the images can be abbreviated images +that depend on tables from earlier images. + +If you intend to write a series of images into a single destination file, +you might want to make a specialized data destination module that doesn't +flush the output buffer at term_destination() time. This would speed things +up by some trifling amount. Of course, you'd need to remember to flush the +buffer after the last image. You can make the later images be abbreviated +ones by passing FALSE to jpeg_start_compress(). + + +Special markers +--------------- + +Some applications may need to insert or extract special data in the JPEG +datastream. The JPEG standard provides marker types "COM" (comment) and +"APP0" through "APP15" (application) to hold application-specific data. +Unfortunately, the use of these markers is not specified by the standard. +COM markers are fairly widely used to hold user-supplied text. The JFIF file +format spec uses APP0 markers with specified initial strings to hold certain +data. Adobe applications use APP14 markers beginning with the string "Adobe" +for miscellaneous data. Other APPn markers are rarely seen, but might +contain almost anything. + +If you wish to store user-supplied text, we recommend you use COM markers +and place readable 7-bit ASCII text in them. Newline conventions are not +standardized --- expect to find LF (Unix style), CR/LF (DOS style), or CR +(Mac style). A robust COM reader should be able to cope with random binary +garbage, including nulls, since some applications generate COM markers +containing non-ASCII junk. (But yours should not be one of them.) + +For program-supplied data, use an APPn marker, and be sure to begin it with an +identifying string so that you can tell whether the marker is actually yours. +It's probably best to avoid using APP0 or APP14 for any private markers. +(NOTE: the upcoming SPIFF standard will use APP8 markers; we recommend you +not use APP8 markers for any private purposes, either.) + +Keep in mind that at most 65533 bytes can be put into one marker, but you +can have as many markers as you like. + +By default, the IJG compression library will write a JFIF APP0 marker if the +selected JPEG colorspace is grayscale or YCbCr, or an Adobe APP14 marker if +the selected colorspace is RGB, CMYK, or YCCK. You can disable this, but +we don't recommend it. The decompression library will recognize JFIF and +Adobe markers and will set the JPEG colorspace properly when one is found. + + +You can write special markers immediately following the datastream header by +calling jpeg_write_marker() after jpeg_start_compress() and before the first +call to jpeg_write_scanlines(). When you do this, the markers appear after +the SOI and the JFIF APP0 and Adobe APP14 markers (if written), but before +all else. Specify the marker type parameter as "JPEG_COM" for COM or +"JPEG_APP0 + n" for APPn. (Actually, jpeg_write_marker will let you write +any marker type, but we don't recommend writing any other kinds of marker.) +For example, to write a user comment string pointed to by comment_text: + jpeg_write_marker(cinfo, JPEG_COM, comment_text, strlen(comment_text)); + +If it's not convenient to store all the marker data in memory at once, +you can instead call jpeg_write_m_header() followed by multiple calls to +jpeg_write_m_byte(). If you do it this way, it's your responsibility to +call jpeg_write_m_byte() exactly the number of times given in the length +parameter to jpeg_write_m_header(). (This method lets you empty the +output buffer partway through a marker, which might be important when +using a suspending data destination module. In any case, if you are using +a suspending destination, you should flush its buffer after inserting +any special markers. See "I/O suspension".) + +Or, if you prefer to synthesize the marker byte sequence yourself, +you can just cram it straight into the data destination module. + +If you are writing JFIF 1.02 extension markers (thumbnail images), don't +forget to set cinfo.JFIF_minor_version = 2 so that the encoder will write the +correct JFIF version number in the JFIF header marker. The library's default +is to write version 1.01, but that's wrong if you insert any 1.02 extension +markers. (We could probably get away with just defaulting to 1.02, but there +used to be broken decoders that would complain about unknown minor version +numbers. To reduce compatibility risks it's safest not to write 1.02 unless +you are actually using 1.02 extensions.) + + +When reading, two methods of handling special markers are available: +1. You can ask the library to save the contents of COM and/or APPn markers +into memory, and then examine them at your leisure afterwards. +2. You can supply your own routine to process COM and/or APPn markers +on-the-fly as they are read. +The first method is simpler to use, especially if you are using a suspending +data source; writing a marker processor that copes with input suspension is +not easy (consider what happens if the marker is longer than your available +input buffer). However, the second method conserves memory since the marker +data need not be kept around after it's been processed. + +For either method, you'd normally set up marker handling after creating a +decompression object and before calling jpeg_read_header(), because the +markers of interest will typically be near the head of the file and so will +be scanned by jpeg_read_header. Once you've established a marker handling +method, it will be used for the life of that decompression object +(potentially many datastreams), unless you change it. Marker handling is +determined separately for COM markers and for each APPn marker code. + + +To save the contents of special markers in memory, call + jpeg_save_markers(cinfo, marker_code, length_limit) +where marker_code is the marker type to save, JPEG_COM or JPEG_APP0+n. +(To arrange to save all the special marker types, you need to call this +routine 17 times, for COM and APP0-APP15.) If the incoming marker is longer +than length_limit data bytes, only length_limit bytes will be saved; this +parameter allows you to avoid chewing up memory when you only need to see the +first few bytes of a potentially large marker. If you want to save all the +data, set length_limit to 0xFFFF; that is enough since marker lengths are only +16 bits. As a special case, setting length_limit to 0 prevents that marker +type from being saved at all. (That is the default behavior, in fact.) + +After jpeg_read_header() completes, you can examine the special markers by +following the cinfo->marker_list pointer chain. All the special markers in +the file appear in this list, in order of their occurrence in the file (but +omitting any markers of types you didn't ask for). Both the original data +length and the saved data length are recorded for each list entry; the latter +will not exceed length_limit for the particular marker type. Note that these +lengths exclude the marker length word, whereas the stored representation +within the JPEG file includes it. (Hence the maximum data length is really +only 65533.) + +It is possible that additional special markers appear in the file beyond the +SOS marker at which jpeg_read_header stops; if so, the marker list will be +extended during reading of the rest of the file. This is not expected to be +common, however. If you are short on memory you may want to reset the length +limit to zero for all marker types after finishing jpeg_read_header, to +ensure that the max_memory_to_use setting cannot be exceeded due to addition +of later markers. + +The marker list remains stored until you call jpeg_finish_decompress or +jpeg_abort, at which point the memory is freed and the list is set to empty. +(jpeg_destroy also releases the storage, of course.) + +Note that the library is internally interested in APP0 and APP14 markers; +if you try to set a small nonzero length limit on these types, the library +will silently force the length up to the minimum it wants. (But you can set +a zero length limit to prevent them from being saved at all.) Also, in a +16-bit environment, the maximum length limit may be constrained to less than +65533 by malloc() limitations. It is therefore best not to assume that the +effective length limit is exactly what you set it to be. + + +If you want to supply your own marker-reading routine, you do it by calling +jpeg_set_marker_processor(). A marker processor routine must have the +signature + boolean jpeg_marker_parser_method (j_decompress_ptr cinfo) +Although the marker code is not explicitly passed, the routine can find it +in cinfo->unread_marker. At the time of call, the marker proper has been +read from the data source module. The processor routine is responsible for +reading the marker length word and the remaining parameter bytes, if any. +Return TRUE to indicate success. (FALSE should be returned only if you are +using a suspending data source and it tells you to suspend. See the standard +marker processors in jdmarker.c for appropriate coding methods if you need to +use a suspending data source.) + +If you override the default APP0 or APP14 processors, it is up to you to +recognize JFIF and Adobe markers if you want colorspace recognition to occur +properly. We recommend copying and extending the default processors if you +want to do that. (A better idea is to save these marker types for later +examination by calling jpeg_save_markers(); that method doesn't interfere +with the library's own processing of these markers.) + +jpeg_set_marker_processor() and jpeg_save_markers() are mutually exclusive +--- if you call one it overrides any previous call to the other, for the +particular marker type specified. + +A simple example of an external COM processor can be found in djpeg.c. +Also, see jpegtran.c for an example of using jpeg_save_markers. + + +Raw (downsampled) image data +---------------------------- + +Some applications need to supply already-downsampled image data to the JPEG +compressor, or to receive raw downsampled data from the decompressor. The +library supports this requirement by allowing the application to write or +read raw data, bypassing the normal preprocessing or postprocessing steps. +The interface is different from the standard one and is somewhat harder to +use. If your interest is merely in bypassing color conversion, we recommend +that you use the standard interface and simply set jpeg_color_space = +in_color_space (or jpeg_color_space = out_color_space for decompression). +The mechanism described in this section is necessary only to supply or +receive downsampled image data, in which not all components have the same +dimensions. + + +To compress raw data, you must supply the data in the colorspace to be used +in the JPEG file (please read the earlier section on Special color spaces) +and downsampled to the sampling factors specified in the JPEG parameters. +You must supply the data in the format used internally by the JPEG library, +namely a JSAMPIMAGE array. This is an array of pointers to two-dimensional +arrays, each of type JSAMPARRAY. Each 2-D array holds the values for one +color component. This structure is necessary since the components are of +different sizes. If the image dimensions are not a multiple of the MCU size, +you must also pad the data correctly (usually, this is done by replicating +the last column and/or row). The data must be padded to a multiple of a DCT +block in each component: that is, each downsampled row must contain a +multiple of DCT_h_scaled_size valid samples, and there must be a multiple of +DCT_v_scaled_size sample rows for each component. (For applications such as +conversion of digital TV images, the standard image size is usually a +multiple of the DCT block size, so that no padding need actually be done.) + +The procedure for compression of raw data is basically the same as normal +compression, except that you call jpeg_write_raw_data() in place of +jpeg_write_scanlines(). Before calling jpeg_start_compress(), you must do +the following: + * Set cinfo->raw_data_in to TRUE. (It is set FALSE by jpeg_set_defaults().) + This notifies the library that you will be supplying raw data. + * Ensure jpeg_color_space is correct --- an explicit jpeg_set_colorspace() + call is a good idea. Note that since color conversion is bypassed, + in_color_space is ignored, except that jpeg_set_defaults() uses it to + choose the default jpeg_color_space setting. + * Ensure the sampling factors, cinfo->comp_info[i].h_samp_factor and + cinfo->comp_info[i].v_samp_factor, are correct. Since these indicate the + dimensions of the data you are supplying, it's wise to set them + explicitly, rather than assuming the library's defaults are what you want. + +To pass raw data to the library, call jpeg_write_raw_data() in place of +jpeg_write_scanlines(). The two routines work similarly except that +jpeg_write_raw_data takes a JSAMPIMAGE data array rather than JSAMPARRAY. +The scanlines count passed to and returned from jpeg_write_raw_data is +measured in terms of the component with the largest v_samp_factor. + +jpeg_write_raw_data() processes one MCU row per call, which is to say +v_samp_factor*min_DCT_v_scaled_size sample rows of each component. The passed +num_lines value must be at least max_v_samp_factor*min_DCT_v_scaled_size, and +the return value will be exactly that amount (or possibly some multiple of +that amount, in future library versions). This is true even on the last call +at the bottom of the image; don't forget to pad your data as necessary. + +The required dimensions of the supplied data can be computed for each +component as + cinfo->comp_info[i].width_in_blocks * + cinfo->comp_info[i].DCT_h_scaled_size samples per row + cinfo->comp_info[i].height_in_blocks * + cinfo->comp_info[i].DCT_v_scaled_size rows in image +after jpeg_start_compress() has initialized those fields. If the valid data +is smaller than this, it must be padded appropriately. For some sampling +factors and image sizes, additional dummy DCT blocks are inserted to make +the image a multiple of the MCU dimensions. The library creates such dummy +blocks itself; it does not read them from your supplied data. Therefore you +need never pad by more than DCT_scaled_size samples. +An example may help here. Assume 2h2v downsampling of YCbCr data, that is + cinfo->comp_info[0].h_samp_factor = 2 for Y + cinfo->comp_info[0].v_samp_factor = 2 + cinfo->comp_info[1].h_samp_factor = 1 for Cb + cinfo->comp_info[1].v_samp_factor = 1 + cinfo->comp_info[2].h_samp_factor = 1 for Cr + cinfo->comp_info[2].v_samp_factor = 1 +and suppose that the nominal image dimensions (cinfo->image_width and +cinfo->image_height) are 101x101 pixels. Then jpeg_start_compress() will +compute downsampled_width = 101 and width_in_blocks = 13 for Y, +downsampled_width = 51 and width_in_blocks = 7 for Cb and Cr (and the same +for the height fields). You must pad the Y data to at least 13*8 = 104 +columns and rows, the Cb/Cr data to at least 7*8 = 56 columns and rows. The +MCU height is max_v_samp_factor = 2 DCT rows so you must pass at least 16 +scanlines on each call to jpeg_write_raw_data(), which is to say 16 actual +sample rows of Y and 8 each of Cb and Cr. A total of 7 MCU rows are needed, +so you must pass a total of 7*16 = 112 "scanlines". The last DCT block row +of Y data is dummy, so it doesn't matter what you pass for it in the data +arrays, but the scanlines count must total up to 112 so that all of the Cb +and Cr data gets passed. + +Output suspension is supported with raw-data compression: if the data +destination module suspends, jpeg_write_raw_data() will return 0. +In this case the same data rows must be passed again on the next call. + + +Decompression with raw data output implies bypassing all postprocessing: +you cannot ask for color quantization, for instance. More seriously, you +must deal with the color space and sampling factors present in the incoming +file. If your application only handles, say, 2h1v YCbCr data, you must +check for and fail on other color spaces or other sampling factors. +The library will not convert to a different color space for you. + +To obtain raw data output, set cinfo->raw_data_out = TRUE before +jpeg_start_decompress() (it is set FALSE by jpeg_read_header()). Be sure to +verify that the color space and sampling factors are ones you can handle. +Then call jpeg_read_raw_data() in place of jpeg_read_scanlines(). The +decompression process is otherwise the same as usual. + +jpeg_read_raw_data() returns one MCU row per call, and thus you must pass a +buffer of at least max_v_samp_factor*min_DCT_v_scaled_size scanlines (scanline +counting is the same as for raw-data compression). The buffer you pass must +be large enough to hold the actual data plus padding to DCT-block boundaries. +As with compression, any entirely dummy DCT blocks are not processed so you +need not allocate space for them, but the total scanline count includes them. +The above example of computing buffer dimensions for raw-data compression is +equally valid for decompression. + +Input suspension is supported with raw-data decompression: if the data source +module suspends, jpeg_read_raw_data() will return 0. You can also use +buffered-image mode to read raw data in multiple passes. + + +Really raw data: DCT coefficients +--------------------------------- + +It is possible to read or write the contents of a JPEG file as raw DCT +coefficients. This facility is mainly intended for use in lossless +transcoding between different JPEG file formats. Other possible applications +include lossless cropping of a JPEG image, lossless reassembly of a +multi-strip or multi-tile TIFF/JPEG file into a single JPEG datastream, etc. + +To read the contents of a JPEG file as DCT coefficients, open the file and do +jpeg_read_header() as usual. But instead of calling jpeg_start_decompress() +and jpeg_read_scanlines(), call jpeg_read_coefficients(). This will read the +entire image into a set of virtual coefficient-block arrays, one array per +component. The return value is a pointer to an array of virtual-array +descriptors. Each virtual array can be accessed directly using the JPEG +memory manager's access_virt_barray method (see Memory management, below, +and also read structure.txt's discussion of virtual array handling). Or, +for simple transcoding to a different JPEG file format, the array list can +just be handed directly to jpeg_write_coefficients(). + +Each block in the block arrays contains quantized coefficient values in +normal array order (not JPEG zigzag order). The block arrays contain only +DCT blocks containing real data; any entirely-dummy blocks added to fill out +interleaved MCUs at the right or bottom edges of the image are discarded +during reading and are not stored in the block arrays. (The size of each +block array can be determined from the width_in_blocks and height_in_blocks +fields of the component's comp_info entry.) This is also the data format +expected by jpeg_write_coefficients(). + +When you are done using the virtual arrays, call jpeg_finish_decompress() +to release the array storage and return the decompression object to an idle +state; or just call jpeg_destroy() if you don't need to reuse the object. + +If you use a suspending data source, jpeg_read_coefficients() will return +NULL if it is forced to suspend; a non-NULL return value indicates successful +completion. You need not test for a NULL return value when using a +non-suspending data source. + +It is also possible to call jpeg_read_coefficients() to obtain access to the +decoder's coefficient arrays during a normal decode cycle in buffered-image +mode. This frammish might be useful for progressively displaying an incoming +image and then re-encoding it without loss. To do this, decode in buffered- +image mode as discussed previously, then call jpeg_read_coefficients() after +the last jpeg_finish_output() call. The arrays will be available for your use +until you call jpeg_finish_decompress(). + + +To write the contents of a JPEG file as DCT coefficients, you must provide +the DCT coefficients stored in virtual block arrays. You can either pass +block arrays read from an input JPEG file by jpeg_read_coefficients(), or +allocate virtual arrays from the JPEG compression object and fill them +yourself. In either case, jpeg_write_coefficients() is substituted for +jpeg_start_compress() and jpeg_write_scanlines(). Thus the sequence is + * Create compression object + * Set all compression parameters as necessary + * Request virtual arrays if needed + * jpeg_write_coefficients() + * jpeg_finish_compress() + * Destroy or re-use compression object +jpeg_write_coefficients() is passed a pointer to an array of virtual block +array descriptors; the number of arrays is equal to cinfo.num_components. + +The virtual arrays need only have been requested, not realized, before +jpeg_write_coefficients() is called. A side-effect of +jpeg_write_coefficients() is to realize any virtual arrays that have been +requested from the compression object's memory manager. Thus, when obtaining +the virtual arrays from the compression object, you should fill the arrays +after calling jpeg_write_coefficients(). The data is actually written out +when you call jpeg_finish_compress(); jpeg_write_coefficients() only writes +the file header. + +When writing raw DCT coefficients, it is crucial that the JPEG quantization +tables and sampling factors match the way the data was encoded, or the +resulting file will be invalid. For transcoding from an existing JPEG file, +we recommend using jpeg_copy_critical_parameters(). This routine initializes +all the compression parameters to default values (like jpeg_set_defaults()), +then copies the critical information from a source decompression object. +The decompression object should have just been used to read the entire +JPEG input file --- that is, it should be awaiting jpeg_finish_decompress(). + +jpeg_write_coefficients() marks all tables stored in the compression object +as needing to be written to the output file (thus, it acts like +jpeg_start_compress(cinfo, TRUE)). This is for safety's sake, to avoid +emitting abbreviated JPEG files by accident. If you really want to emit an +abbreviated JPEG file, call jpeg_suppress_tables(), or set the tables' +individual sent_table flags, between calling jpeg_write_coefficients() and +jpeg_finish_compress(). + + +Progress monitoring +------------------- + +Some applications may need to regain control from the JPEG library every so +often. The typical use of this feature is to produce a percent-done bar or +other progress display. (For a simple example, see cjpeg.c or djpeg.c.) +Although you do get control back frequently during the data-transferring pass +(the jpeg_read_scanlines or jpeg_write_scanlines loop), any additional passes +will occur inside jpeg_finish_compress or jpeg_start_decompress; those +routines may take a long time to execute, and you don't get control back +until they are done. + +You can define a progress-monitor routine which will be called periodically +by the library. No guarantees are made about how often this call will occur, +so we don't recommend you use it for mouse tracking or anything like that. +At present, a call will occur once per MCU row, scanline, or sample row +group, whichever unit is convenient for the current processing mode; so the +wider the image, the longer the time between calls. During the data +transferring pass, only one call occurs per call of jpeg_read_scanlines or +jpeg_write_scanlines, so don't pass a large number of scanlines at once if +you want fine resolution in the progress count. (If you really need to use +the callback mechanism for time-critical tasks like mouse tracking, you could +insert additional calls inside some of the library's inner loops.) + +To establish a progress-monitor callback, create a struct jpeg_progress_mgr, +fill in its progress_monitor field with a pointer to your callback routine, +and set cinfo->progress to point to the struct. The callback will be called +whenever cinfo->progress is non-NULL. (This pointer is set to NULL by +jpeg_create_compress or jpeg_create_decompress; the library will not change +it thereafter. So if you allocate dynamic storage for the progress struct, +make sure it will live as long as the JPEG object does. Allocating from the +JPEG memory manager with lifetime JPOOL_PERMANENT will work nicely.) You +can use the same callback routine for both compression and decompression. + +The jpeg_progress_mgr struct contains four fields which are set by the library: + long pass_counter; /* work units completed in this pass */ + long pass_limit; /* total number of work units in this pass */ + int completed_passes; /* passes completed so far */ + int total_passes; /* total number of passes expected */ +During any one pass, pass_counter increases from 0 up to (not including) +pass_limit; the step size is usually but not necessarily 1. The pass_limit +value may change from one pass to another. The expected total number of +passes is in total_passes, and the number of passes already completed is in +completed_passes. Thus the fraction of work completed may be estimated as + completed_passes + (pass_counter/pass_limit) + -------------------------------------------- + total_passes +ignoring the fact that the passes may not be equal amounts of work. + +When decompressing, pass_limit can even change within a pass, because it +depends on the number of scans in the JPEG file, which isn't always known in +advance. The computed fraction-of-work-done may jump suddenly (if the library +discovers it has overestimated the number of scans) or even decrease (in the +opposite case). It is not wise to put great faith in the work estimate. + +When using the decompressor's buffered-image mode, the progress monitor work +estimate is likely to be completely unhelpful, because the library has no way +to know how many output passes will be demanded of it. Currently, the library +sets total_passes based on the assumption that there will be one more output +pass if the input file end hasn't yet been read (jpeg_input_complete() isn't +TRUE), but no more output passes if the file end has been reached when the +output pass is started. This means that total_passes will rise as additional +output passes are requested. If you have a way of determining the input file +size, estimating progress based on the fraction of the file that's been read +will probably be more useful than using the library's value. + + +Memory management +----------------- + +This section covers some key facts about the JPEG library's built-in memory +manager. For more info, please read structure.txt's section about the memory +manager, and consult the source code if necessary. + +All memory and temporary file allocation within the library is done via the +memory manager. If necessary, you can replace the "back end" of the memory +manager to control allocation yourself (for example, if you don't want the +library to use malloc() and free() for some reason). + +Some data is allocated "permanently" and will not be freed until the JPEG +object is destroyed. Most data is allocated "per image" and is freed by +jpeg_finish_compress, jpeg_finish_decompress, or jpeg_abort. You can call the +memory manager yourself to allocate structures that will automatically be +freed at these times. Typical code for this is + ptr = (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, size); +Use JPOOL_PERMANENT to get storage that lasts as long as the JPEG object. +Use alloc_large instead of alloc_small for anything bigger than a few Kbytes. +There are also alloc_sarray and alloc_barray routines that automatically +build 2-D sample or block arrays. + +The library's minimum space requirements to process an image depend on the +image's width, but not on its height, because the library ordinarily works +with "strip" buffers that are as wide as the image but just a few rows high. +Some operating modes (eg, two-pass color quantization) require full-image +buffers. Such buffers are treated as "virtual arrays": only the current strip +need be in memory, and the rest can be swapped out to a temporary file. + +If you use the simplest memory manager back end (jmemnobs.c), then no +temporary files are used; virtual arrays are simply malloc()'d. Images bigger +than memory can be processed only if your system supports virtual memory. +The other memory manager back ends support temporary files of various flavors +and thus work in machines without virtual memory. They may also be useful on +Unix machines if you need to process images that exceed available swap space. + +When using temporary files, the library will make the in-memory buffers for +its virtual arrays just big enough to stay within a "maximum memory" setting. +Your application can set this limit by setting cinfo->mem->max_memory_to_use +after creating the JPEG object. (Of course, there is still a minimum size for +the buffers, so the max-memory setting is effective only if it is bigger than +the minimum space needed.) If you allocate any large structures yourself, you +must allocate them before jpeg_start_compress() or jpeg_start_decompress() in +order to have them counted against the max memory limit. Also keep in mind +that space allocated with alloc_small() is ignored, on the assumption that +it's too small to be worth worrying about; so a reasonable safety margin +should be left when setting max_memory_to_use. + +If you use the jmemname.c or jmemdos.c memory manager back end, it is +important to clean up the JPEG object properly to ensure that the temporary +files get deleted. (This is especially crucial with jmemdos.c, where the +"temporary files" may be extended-memory segments; if they are not freed, +DOS will require a reboot to recover the memory.) Thus, with these memory +managers, it's a good idea to provide a signal handler that will trap any +early exit from your program. The handler should call either jpeg_abort() +or jpeg_destroy() for any active JPEG objects. A handler is not needed with +jmemnobs.c, and shouldn't be necessary with jmemansi.c or jmemmac.c either, +since the C library is supposed to take care of deleting files made with +tmpfile(). + + +Memory usage +------------ + +Working memory requirements while performing compression or decompression +depend on image dimensions, image characteristics (such as colorspace and +JPEG process), and operating mode (application-selected options). + +As of v6b, the decompressor requires: + 1. About 24K in more-or-less-fixed-size data. This varies a bit depending + on operating mode and image characteristics (particularly color vs. + grayscale), but it doesn't depend on image dimensions. + 2. Strip buffers (of size proportional to the image width) for IDCT and + upsampling results. The worst case for commonly used sampling factors + is about 34 bytes * width in pixels for a color image. A grayscale image + only needs about 8 bytes per pixel column. + 3. A full-image DCT coefficient buffer is needed to decode a multi-scan JPEG + file (including progressive JPEGs), or whenever you select buffered-image + mode. This takes 2 bytes/coefficient. At typical 2x2 sampling, that's + 3 bytes per pixel for a color image. Worst case (1x1 sampling) requires + 6 bytes/pixel. For grayscale, figure 2 bytes/pixel. + 4. To perform 2-pass color quantization, the decompressor also needs a + 128K color lookup table and a full-image pixel buffer (3 bytes/pixel). +This does not count any memory allocated by the application, such as a +buffer to hold the final output image. + +The above figures are valid for 8-bit JPEG data precision and a machine with +32-bit ints. For 9-bit to 12-bit JPEG data, double the size of the strip +buffers and quantization pixel buffer. The "fixed-size" data will be +somewhat smaller with 16-bit ints, larger with 64-bit ints. Also, CMYK +or other unusual color spaces will require different amounts of space. + +The full-image coefficient and pixel buffers, if needed at all, do not +have to be fully RAM resident; you can have the library use temporary +files instead when the total memory usage would exceed a limit you set. +(But if your OS supports virtual memory, it's probably better to just use +jmemnobs and let the OS do the swapping.) + +The compressor's memory requirements are similar, except that it has no need +for color quantization. Also, it needs a full-image DCT coefficient buffer +if Huffman-table optimization is asked for, even if progressive mode is not +requested. + +If you need more detailed information about memory usage in a particular +situation, you can enable the MEM_STATS code in jmemmgr.c. + + +Library compile-time options +---------------------------- + +A number of compile-time options are available by modifying jmorecfg.h. + +The IJG code currently supports 8-bit to 12-bit sample data precision by +defining BITS_IN_JSAMPLE as 8, 9, 10, 11, or 12. +Note that a value larger than 8 causes JSAMPLE to be larger than a char, +so it affects the surrounding application's image data. +The sample applications cjpeg and djpeg can support deeper than 8-bit data +only for PPM and GIF file formats; you must disable the other file formats +to compile a 9-bit to 12-bit cjpeg or djpeg. (install.txt has more +information about that.) +Run-time selection and conversion of data precision are currently not +supported and may be added later. +Exception: The transcoding part (jpegtran) supports all settings in a +single instance, since it operates on the level of DCT coefficients and +not sample values. +(If you need to include an 8-bit library and a 9-bit to 12-bit library for +compression or decompression in a single application, you could probably do +it by defining NEED_SHORT_EXTERNAL_NAMES for just one of the copies. You'd +have to access the 8-bit and the 9-bit to 12-bit copies from separate +application source files. This is untested ... if you try it, we'd like to +hear whether it works!) + +Note that the standard Huffman tables are only valid for 8-bit data precision. +If you selected more than 8-bit data precision, cjpeg uses arithmetic coding +by default. The Huffman encoder normally uses entropy optimization to +compute usable tables for higher precision. Otherwise, you'll have to +supply different default Huffman tables. You may also want to supply your +own DCT quantization tables; the existing quality-scaling code has been +developed for 8-bit use, and probably doesn't generate especially good tables +for 9-bit to 12-bit. + +The maximum number of components (color channels) in the image is determined +by MAX_COMPONENTS. The JPEG standard allows up to 255 components, but we +expect that few applications will need more than four or so. + +On machines with unusual data type sizes, you may be able to improve +performance or reduce memory space by tweaking the various typedefs in +jmorecfg.h. In particular, on some RISC CPUs, access to arrays of "short"s +is quite slow; consider trading memory for speed by making JCOEF, INT16, and +UINT16 be "int" or "unsigned int". UINT8 is also a candidate to become int. +You probably don't want to make JSAMPLE be int unless you have lots of memory +to burn. + +You can reduce the size of the library by compiling out various optional +functions. To do this, undefine xxx_SUPPORTED symbols as necessary. + +You can also save a few K by not having text error messages in the library; +the standard error message table occupies about 5Kb. This is particularly +reasonable for embedded applications where there's no good way to display +a message anyway. To do this, remove the creation of the message table +(jpeg_std_message_table[]) from jerror.c, and alter format_message to do +something reasonable without it. You could output the numeric value of the +message code number, for example. If you do this, you can also save a couple +more K by modifying the TRACEMSn() macros in jerror.h to expand to nothing; +you don't need trace capability anyway, right? + + +Portability considerations +-------------------------- + +The JPEG library has been written to be extremely portable; the sample +applications cjpeg and djpeg are slightly less so. This section summarizes +the design goals in this area. (If you encounter any bugs that cause the +library to be less portable than is claimed here, we'd appreciate hearing +about them.) + +The code works fine on ANSI C, C++, and pre-ANSI C compilers, using any of +the popular system include file setups, and some not-so-popular ones too. +See install.txt for configuration procedures. + +The code is not dependent on the exact sizes of the C data types. As +distributed, we make the assumptions that + char is at least 8 bits wide + short is at least 16 bits wide + int is at least 16 bits wide + long is at least 32 bits wide +(These are the minimum requirements of the ANSI C standard.) Wider types will +work fine, although memory may be used inefficiently if char is much larger +than 8 bits or short is much bigger than 16 bits. The code should work +equally well with 16- or 32-bit ints. + +In a system where these assumptions are not met, you may be able to make the +code work by modifying the typedefs in jmorecfg.h. However, you will probably +have difficulty if int is less than 16 bits wide, since references to plain +int abound in the code. + +char can be either signed or unsigned, although the code runs faster if an +unsigned char type is available. If char is wider than 8 bits, you will need +to redefine JOCTET and/or provide custom data source/destination managers so +that JOCTET represents exactly 8 bits of data on external storage. + +The JPEG library proper does not assume ASCII representation of characters. +But some of the image file I/O modules in cjpeg/djpeg do have ASCII +dependencies in file-header manipulation; so does cjpeg's select_file_type() +routine. + +The JPEG library does not rely heavily on the C library. In particular, C +stdio is used only by the data source/destination modules and the error +handler, all of which are application-replaceable. (cjpeg/djpeg are more +heavily dependent on stdio.) malloc and free are called only from the memory +manager "back end" module, so you can use a different memory allocator by +replacing that one file. + +The code generally assumes that C names must be unique in the first 15 +characters. However, global function names can be made unique in the +first 6 characters by defining NEED_SHORT_EXTERNAL_NAMES. + +More info about porting the code may be gleaned by reading jconfig.txt, +jmorecfg.h, and jinclude.h. + + +Notes for MS-DOS implementors +----------------------------- + +The IJG code is designed to work efficiently in 80x86 "small" or "medium" +memory models (i.e., data pointers are 16 bits unless explicitly declared +"far"; code pointers can be either size). You may be able to use small +model to compile cjpeg or djpeg by itself, but you will probably have to use +medium model for any larger application. This won't make much difference in +performance. You *will* take a noticeable performance hit if you use a +large-data memory model (perhaps 10%-25%), and you should avoid "huge" model +if at all possible. + +The JPEG library typically needs 2Kb-3Kb of stack space. It will also +malloc about 20K-30K of near heap space while executing (and lots of far +heap, but that doesn't count in this calculation). This figure will vary +depending on selected operating mode, and to a lesser extent on image size. +There is also about 5Kb-6Kb of constant data which will be allocated in the +near data segment (about 4Kb of this is the error message table). +Thus you have perhaps 20K available for other modules' static data and near +heap space before you need to go to a larger memory model. The C library's +static data will account for several K of this, but that still leaves a good +deal for your needs. (If you are tight on space, you could reduce the sizes +of the I/O buffers allocated by jdatasrc.c and jdatadst.c, say from 4K to +1K. Another possibility is to move the error message table to far memory; +this should be doable with only localized hacking on jerror.c.) + +About 2K of the near heap space is "permanent" memory that will not be +released until you destroy the JPEG object. This is only an issue if you +save a JPEG object between compression or decompression operations. + +Far data space may also be a tight resource when you are dealing with large +images. The most memory-intensive case is decompression with two-pass color +quantization, or single-pass quantization to an externally supplied color +map. This requires a 128Kb color lookup table plus strip buffers amounting +to about 40 bytes per column for typical sampling ratios (eg, about 25600 +bytes for a 640-pixel-wide image). You may not be able to process wide +images if you have large data structures of your own. + +Of course, all of these concerns vanish if you use a 32-bit flat-memory-model +compiler, such as DJGPP or Watcom C. We highly recommend flat model if you +can use it; the JPEG library is significantly faster in flat model. diff --git a/thirdparty/jpeg-9e/libtool b/thirdparty/jpeg-9e/libtool new file mode 100755 index 0000000..ea92550 --- /dev/null +++ b/thirdparty/jpeg-9e/libtool @@ -0,0 +1,11648 @@ +#! /bin/bash +# Generated automatically by config.status (libjpeg) 9.5.0 +# Libtool was configured on host kpdev: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# The names of the tagged configurations supported by this script. +available_tags='' + +# Configured defaults for sys_lib_dlsearch_path munging. +: ${LT_SYS_LIBRARY_PATH=""} + +# ### BEGIN LIBTOOL CONFIG + +# Which release of libtool.m4 was used? +macro_version=2.4.6 +macro_revision=2.4.6 + +# Assembler program. +AS="as" + +# DLL creation program. +DLLTOOL="false" + +# Object dumper program. +OBJDUMP="objdump" + +# Whether or not to build shared libraries. +build_libtool_libs=no + +# Whether or not to build static libraries. +build_old_libs=yes + +# What type of objects to build. +pic_mode=default + +# Whether or not to optimize for fast installation. +fast_install=needless + +# Shared archive member basename,for filename based shared library versioning on AIX. +shared_archive_member_spec= + +# Shell to use when invoking shell scripts. +SHELL="/bin/bash" + +# An echo program that protects backslashes. +ECHO="printf %s\\n" + +# The PATH separator for the build system. +PATH_SEPARATOR=":" + +# The host system. +host_alias= +host=x86_64-pc-linux-gnu +host_os=linux-gnu + +# The build system. +build_alias= +build=x86_64-pc-linux-gnu +build_os=linux-gnu + +# A sed program that does not truncate output. +SED="/usr/bin/sed" + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP="/usr/bin/grep" + +# An ERE matcher. +EGREP="/usr/bin/grep -E" + +# A literal string matcher. +FGREP="/usr/bin/grep -F" + +# A BSD- or MS-compatible name lister. +NM="/usr/bin/nm -B" + +# Whether we need soft or hard links. +LN_S="ln -s" + +# What is the maximum length of a command? +max_cmd_len=1572864 + +# Object file suffix (normally "o"). +objext=o + +# Executable file suffix (normally ""). +exeext= + +# whether the shell understands "unset". +lt_unset=unset + +# turn spaces into newlines. +SP2NL="tr \\040 \\012" + +# turn newlines into spaces. +NL2SP="tr \\015\\012 \\040\\040" + +# convert $build file names to $host format. +to_host_file_cmd=func_convert_file_noop + +# convert $build files to toolchain format. +to_tool_file_cmd=func_convert_file_noop + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method="pass_all" + +# Command to use when deplibs_check_method = "file_magic". +file_magic_cmd="\$MAGIC_CMD" + +# How to find potential files when deplibs_check_method = "file_magic". +file_magic_glob="" + +# Find potential files using nocaseglob when deplibs_check_method = "file_magic". +want_nocaseglob="no" + +# Command to associate shared and link libraries. +sharedlib_from_linklib_cmd="printf %s\\n" + +# The archiver. +AR="ar" + +# Flags to create an archive. +AR_FLAGS="cru" + +# How to feed a file listing to the archiver. +archiver_list_spec="@" + +# A symbol stripping program. +STRIP="strip" + +# Commands used to install an old-style archive. +RANLIB="ranlib" +old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$tool_oldlib" +old_postuninstall_cmds="" + +# Whether to use a lock for old archive extraction. +lock_old_archive_extraction=no + +# A C compiler. +LTCC="gcc" + +# LTCC compiler flags. +LTCFLAGS="-g -O2" + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p' | sed '/ __gnu_lto/d'" + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl="sed -n -e 's/^T .* \\(.*\\)\$/extern int \\1();/p' -e 's/^[ABCDGIRSTW][ABCDGIRSTW]* .* \\(.*\\)\$/extern char \\1;/p'" + +# Transform the output of nm into a list of symbols to manually relocate. +global_symbol_to_import="" + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address="sed -n -e 's/^: \\(.*\\) .*\$/ {\"\\1\", (void *) 0},/p' -e 's/^[ABCDGIRSTW][ABCDGIRSTW]* .* \\(.*\\)\$/ {\"\\1\", (void *) \\&\\1},/p'" + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \\(.*\\) .*\$/ {\"\\1\", (void *) 0},/p' -e 's/^[ABCDGIRSTW][ABCDGIRSTW]* .* \\(lib.*\\)\$/ {\"\\1\", (void *) \\&\\1},/p' -e 's/^[ABCDGIRSTW][ABCDGIRSTW]* .* \\(.*\\)\$/ {\"lib\\1\", (void *) \\&\\1},/p'" + +# The name lister interface. +nm_interface="BSD nm" + +# Specify filename containing input files for $NM. +nm_file_list_spec="@" + +# The root where to search for dependent libraries,and where our libraries should be installed. +lt_sysroot= + +# Command to truncate a binary pipe. +lt_truncate_bin="/usr/bin/dd bs=4096 count=1" + +# The name of the directory that contains temporary libtool files. +objdir=.libs + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=file + +# Must we lock files when doing compilation? +need_locks="no" + +# Manifest tool. +MANIFEST_TOOL=":" + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL="" + +# Tool to change global to local symbols on Mac OS X. +NMEDIT="" + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO="" + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL="" + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64="" + +# Old archive suffix (normally "a"). +libext=a + +# Shared library suffix (normally ".so"). +shrext_cmds=".so" + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds="" + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" + +# Do we need the "lib" prefix for modules? +need_lib_prefix=no + +# Do we need a version for libraries? +need_version=no + +# Library versioning type. +version_type=linux + +# Shared library runtime path variable. +runpath_var=LD_RUN_PATH + +# Shared library path variable. +shlibpath_var=LD_LIBRARY_PATH + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=yes + +# Format of library name prefix. +libname_spec="lib\$name" + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec="\$libname\$release\$shared_ext\$versuffix \$libname\$release\$shared_ext\$major \$libname\$shared_ext" + +# The coded name of the library, if different from the real name. +soname_spec="\$libname\$release\$shared_ext\$major" + +# Permission mode override for installation of shared libraries. +install_override_mode="" + +# Command to use after installation of a shared archive. +postinstall_cmds="" + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds="" + +# Commands used to finish a libtool library installation in a directory. +finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -n \$libdir" + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval="" + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=yes + +# Compile-time system search path for libraries. +sys_lib_search_path_spec="/usr/lib/gcc/x86_64-linux-gnu/9 /usr/lib/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib " + +# Detected run-time system search path for libraries. +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/x86_64-linux-gnu/libfakeroot /usr/local/lib/i386-linux-gnu /lib/i386-linux-gnu /usr/lib/i386-linux-gnu /usr/local/lib/i686-linux-gnu /lib/i686-linux-gnu /usr/lib/i686-linux-gnu /usr/local/lib /usr/local/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /lib32 /usr/lib32 /libx32 /usr/libx32 " + +# Explicit LT_SYS_LIBRARY_PATH set during ./configure time. +configure_time_lt_sys_library_path="" + +# Whether dlopen is supported. +dlopen_support=unknown + +# Whether dlopen of programs is supported. +dlopen_self=unknown + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=unknown + +# Commands to strip libraries. +old_striplib="strip --strip-debug" +striplib="strip --strip-unneeded" + + +# The linker used to build libraries. +LD="/usr/bin/ld -m elf_x86_64" + +# How to create reloadable object files. +reload_flag=" -r" +reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs" + +# Commands used to build an old-style archive. +old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$tool_oldlib" + +# A language specific compiler. +CC="gcc" + +# Is the compiler the GNU compiler? +with_gcc=yes + +# Compiler flag to turn off builtin functions. +no_builtin_flag=" -fno-builtin" + +# Additional compiler flags for building library objects. +pic_flag=" -fPIC -DPIC" + +# How to pass a linker flag through the compiler. +wl="-Wl," + +# Compiler flag to prevent dynamic linking. +link_static_flag="-static" + +# Does compiler simultaneously support -c and -o options? +compiler_c_o="yes" + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=yes + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=no + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec="\$wl--export-dynamic" + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec="\$wl--whole-archive\$convenience \$wl--no-whole-archive" + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object="no" + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds="" + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds="" + +# Commands used to build a shared archive. +archive_cmds="\$CC -shared \$pic_flag \$libobjs \$deplibs \$compiler_flags \$wl-soname \$wl\$soname -o \$lib" +archive_expsym_cmds="echo \\\"{ global:\\\" > \$output_objdir/\$libname.ver~ + cat \$export_symbols | sed -e \\\"s/\\\\(.*\\\\)/\\\\1;/\\\" >> \$output_objdir/\$libname.ver~ + echo \\\"local: *; };\\\" >> \$output_objdir/\$libname.ver~ + \$CC -shared \$pic_flag \$libobjs \$deplibs \$compiler_flags \$wl-soname \$wl\$soname \$wl-version-script \$wl\$output_objdir/\$libname.ver -o \$lib" + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds="" +module_expsym_cmds="" + +# Whether we are building with GNU ld or not. +with_gnu_ld="yes" + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag="" + +# Flag that enforces no undefined symbols. +no_undefined_flag="" + +# Flag to hardcode $libdir into a binary during linking. +# This must work even if $libdir does not exist +hardcode_libdir_flag_spec="\$wl-rpath \$wl\$libdir" + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator="" + +# Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=no + +# Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting $shlibpath_var if the +# library is relocated. +hardcode_direct_absolute=no + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=no + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=unsupported + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=no + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=no + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=unknown + +# Set to "yes" if exported symbols are required. +always_export_symbols=no + +# The commands to list exported symbols. +export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols" + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms="_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*" + +# Symbols that must always be exported. +include_expsyms="" + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds="" + +# Commands necessary for finishing linking programs. +postlink_cmds="" + +# Specify filename containing input files. +file_list_spec="" + +# How to hardcode a shared library path into an executable. +hardcode_action=immediate + +# ### END LIBTOOL CONFIG + + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + + +# ### END FUNCTIONS SHARED WITH CONFIGURE + +#! /bin/sh +## DO NOT EDIT - This file generated from ./build-aux/ltmain.in +## by inline-source v2014-01-03.01 + +# libtool (GNU libtool) 2.4.6 +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit , 1996 + +# Copyright (C) 1996-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +PROGRAM=libtool +PACKAGE=libtool +VERSION=2.4.6 +package_revision=2.4.6 + + +## ------ ## +## Usage. ## +## ------ ## + +# Run './libtool --help' for help with using this script from the +# command line. + + +## ------------------------------- ## +## User overridable command paths. ## +## ------------------------------- ## + +# After configure completes, it has a better idea of some of the +# shell tools we need than the defaults used by the functions shared +# with bootstrap, so set those here where they can still be over- +# ridden by the user, but otherwise take precedence. + +: ${AUTOCONF="autoconf"} +: ${AUTOMAKE="automake"} + + +## -------------------------- ## +## Source external libraries. ## +## -------------------------- ## + +# Much of our low-level functionality needs to be sourced from external +# libraries, which are installed to $pkgauxdir. + +# Set a version string for this script. +scriptversion=2015-01-20.17; # UTC + +# General shell script boiler plate, and helper functions. +# Written by Gary V. Vaughan, 2004 + +# Copyright (C) 2004-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# As a special exception to the GNU General Public License, if you distribute +# this file as part of a program or library that is built using GNU Libtool, +# you may include this file under the same distribution terms that you use +# for the rest of that program. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Please report bugs or propose patches to gary@gnu.org. + + +## ------ ## +## Usage. ## +## ------ ## + +# Evaluate this file near the top of your script to gain access to +# the functions and variables defined here: +# +# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh +# +# If you need to override any of the default environment variable +# settings, do that before evaluating this file. + + +## -------------------- ## +## Shell normalisation. ## +## -------------------- ## + +# Some shells need a little help to be as Bourne compatible as possible. +# Before doing anything else, make sure all that help has been provided! + +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac +fi + +# NLS nuisances: We save the old values in case they are required later. +_G_user_locale= +_G_safe_locale= +for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES +do + eval "if test set = \"\${$_G_var+set}\"; then + save_$_G_var=\$$_G_var + $_G_var=C + export $_G_var + _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" + _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" + fi" +done + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Make sure IFS has a sensible default +sp=' ' +nl=' +' +IFS="$sp $nl" + +# There are apparently some retarded systems that use ';' as a PATH separator! +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + + +## ------------------------- ## +## Locate command utilities. ## +## ------------------------- ## + + +# func_executable_p FILE +# ---------------------- +# Check that FILE is an executable regular file. +func_executable_p () +{ + test -f "$1" && test -x "$1" +} + + +# func_path_progs PROGS_LIST CHECK_FUNC [PATH] +# -------------------------------------------- +# Search for either a program that responds to --version with output +# containing "GNU", or else returned by CHECK_FUNC otherwise, by +# trying all the directories in PATH with each of the elements of +# PROGS_LIST. +# +# CHECK_FUNC should accept the path to a candidate program, and +# set $func_check_prog_result if it truncates its output less than +# $_G_path_prog_max characters. +func_path_progs () +{ + _G_progs_list=$1 + _G_check_func=$2 + _G_PATH=${3-"$PATH"} + + _G_path_prog_max=0 + _G_path_prog_found=false + _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} + for _G_dir in $_G_PATH; do + IFS=$_G_save_IFS + test -z "$_G_dir" && _G_dir=. + for _G_prog_name in $_G_progs_list; do + for _exeext in '' .EXE; do + _G_path_prog=$_G_dir/$_G_prog_name$_exeext + func_executable_p "$_G_path_prog" || continue + case `"$_G_path_prog" --version 2>&1` in + *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; + *) $_G_check_func $_G_path_prog + func_path_progs_result=$func_check_prog_result + ;; + esac + $_G_path_prog_found && break 3 + done + done + done + IFS=$_G_save_IFS + test -z "$func_path_progs_result" && { + echo "no acceptable sed could be found in \$PATH" >&2 + exit 1 + } +} + + +# We want to be able to use the functions in this file before configure +# has figured out where the best binaries are kept, which means we have +# to search for them ourselves - except when the results are already set +# where we skip the searches. + +# Unless the user overrides by setting SED, search the path for either GNU +# sed, or the sed that truncates its output the least. +test -z "$SED" && { + _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for _G_i in 1 2 3 4 5 6 7; do + _G_sed_script=$_G_sed_script$nl$_G_sed_script + done + echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed + _G_sed_script= + + func_check_prog_sed () + { + _G_path_prog=$1 + + _G_count=0 + printf 0123456789 >conftest.in + while : + do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo '' >> conftest.nl + "$_G_path_prog" -f conftest.sed conftest.out 2>/dev/null || break + diff conftest.out conftest.nl >/dev/null 2>&1 || break + _G_count=`expr $_G_count + 1` + if test "$_G_count" -gt "$_G_path_prog_max"; then + # Best one so far, save it but keep looking for a better one + func_check_prog_result=$_G_path_prog + _G_path_prog_max=$_G_count + fi + # 10*(2^10) chars as input seems more than enough + test 10 -lt "$_G_count" && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + + func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin + rm -f conftest.sed + SED=$func_path_progs_result +} + + +# Unless the user overrides by setting GREP, search the path for either GNU +# grep, or the grep that truncates its output the least. +test -z "$GREP" && { + func_check_prog_grep () + { + _G_path_prog=$1 + + _G_count=0 + _G_path_prog_max=0 + printf 0123456789 >conftest.in + while : + do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo 'GREP' >> conftest.nl + "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' conftest.out 2>/dev/null || break + diff conftest.out conftest.nl >/dev/null 2>&1 || break + _G_count=`expr $_G_count + 1` + if test "$_G_count" -gt "$_G_path_prog_max"; then + # Best one so far, save it but keep looking for a better one + func_check_prog_result=$_G_path_prog + _G_path_prog_max=$_G_count + fi + # 10*(2^10) chars as input seems more than enough + test 10 -lt "$_G_count" && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + + func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin + GREP=$func_path_progs_result +} + + +## ------------------------------- ## +## User overridable command paths. ## +## ------------------------------- ## + +# All uppercase variable names are used for environment variables. These +# variables can be overridden by the user before calling a script that +# uses them if a suitable command of that name is not already available +# in the command search PATH. + +: ${CP="cp -f"} +: ${ECHO="printf %s\n"} +: ${EGREP="$GREP -E"} +: ${FGREP="$GREP -F"} +: ${LN_S="ln -s"} +: ${MAKE="make"} +: ${MKDIR="mkdir"} +: ${MV="mv -f"} +: ${RM="rm -f"} +: ${SHELL="${CONFIG_SHELL-/bin/sh}"} + + +## -------------------- ## +## Useful sed snippets. ## +## -------------------- ## + +sed_dirname='s|/[^/]*$||' +sed_basename='s|^.*/||' + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s|\([`"$\\]\)|\\\1|g' + +# Same as above, but do not quote variable references. +sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution that turns a string into a regex matching for the +# string literally. +sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' + +# Sed substitution that converts a w32 file name or path +# that contains forward slashes, into one that contains +# (escaped) backslashes. A very naive implementation. +sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + +# Re-'\' parameter expansions in output of sed_double_quote_subst that +# were '\'-ed in input to the same. If an odd number of '\' preceded a +# '$' in input to sed_double_quote_subst, that '$' was protected from +# expansion. Since each input '\' is now two '\'s, look for any number +# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. +_G_bs='\\' +_G_bs2='\\\\' +_G_bs4='\\\\\\\\' +_G_dollar='\$' +sed_double_backslash="\ + s/$_G_bs4/&\\ +/g + s/^$_G_bs2$_G_dollar/$_G_bs&/ + s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g + s/\n//g" + + +## ----------------- ## +## Global variables. ## +## ----------------- ## + +# Except for the global variables explicitly listed below, the following +# functions in the '^func_' namespace, and the '^require_' namespace +# variables initialised in the 'Resource management' section, sourcing +# this file will not pollute your global namespace with anything +# else. There's no portable way to scope variables in Bourne shell +# though, so actually running these functions will sometimes place +# results into a variable named after the function, and often use +# temporary variables in the '^_G_' namespace. If you are careful to +# avoid using those namespaces casually in your sourcing script, things +# should continue to work as you expect. And, of course, you can freely +# overwrite any of the functions or variables defined here before +# calling anything to customize them. + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. +EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. + +# Allow overriding, eg assuming that you follow the convention of +# putting '$debug_cmd' at the start of all your functions, you can get +# bash to show function call trace with: +# +# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name +debug_cmd=${debug_cmd-":"} +exit_cmd=: + +# By convention, finish your script with: +# +# exit $exit_status +# +# so that you can set exit_status to non-zero if you want to indicate +# something went wrong during execution without actually bailing out at +# the point of failure. +exit_status=$EXIT_SUCCESS + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath=$0 + +# The name of this program. +progname=`$ECHO "$progpath" |$SED "$sed_basename"` + +# Make sure we have an absolute progpath for reexecution: +case $progpath in + [\\/]*|[A-Za-z]:\\*) ;; + *[\\/]*) + progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` + progdir=`cd "$progdir" && pwd` + progpath=$progdir/$progname + ;; + *) + _G_IFS=$IFS + IFS=${PATH_SEPARATOR-:} + for progdir in $PATH; do + IFS=$_G_IFS + test -x "$progdir/$progname" && break + done + IFS=$_G_IFS + test -n "$progdir" || progdir=`pwd` + progpath=$progdir/$progname + ;; +esac + + +## ----------------- ## +## Standard options. ## +## ----------------- ## + +# The following options affect the operation of the functions defined +# below, and should be set appropriately depending on run-time para- +# meters passed on the command line. + +opt_dry_run=false +opt_quiet=false +opt_verbose=false + +# Categories 'all' and 'none' are always available. Append any others +# you will pass as the first argument to func_warning from your own +# code. +warning_categories= + +# By default, display warnings according to 'opt_warning_types'. Set +# 'warning_func' to ':' to elide all warnings, or func_fatal_error to +# treat the next displayed warning as a fatal error. +warning_func=func_warn_and_continue + +# Set to 'all' to display all warnings, 'none' to suppress all +# warnings, or a space delimited list of some subset of +# 'warning_categories' to display only the listed warnings. +opt_warning_types=all + + +## -------------------- ## +## Resource management. ## +## -------------------- ## + +# This section contains definitions for functions that each ensure a +# particular resource (a file, or a non-empty configuration variable for +# example) is available, and if appropriate to extract default values +# from pertinent package files. Call them using their associated +# 'require_*' variable to ensure that they are executed, at most, once. +# +# It's entirely deliberate that calling these functions can set +# variables that don't obey the namespace limitations obeyed by the rest +# of this file, in order that that they be as useful as possible to +# callers. + + +# require_term_colors +# ------------------- +# Allow display of bold text on terminals that support it. +require_term_colors=func_require_term_colors +func_require_term_colors () +{ + $debug_cmd + + test -t 1 && { + # COLORTERM and USE_ANSI_COLORS environment variables take + # precedence, because most terminfo databases neglect to describe + # whether color sequences are supported. + test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} + + if test 1 = "$USE_ANSI_COLORS"; then + # Standard ANSI escape sequences + tc_reset='' + tc_bold=''; tc_standout='' + tc_red=''; tc_green='' + tc_blue=''; tc_cyan='' + else + # Otherwise trust the terminfo database after all. + test -n "`tput sgr0 2>/dev/null`" && { + tc_reset=`tput sgr0` + test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` + tc_standout=$tc_bold + test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` + test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` + test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` + test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` + test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` + } + fi + } + + require_term_colors=: +} + + +## ----------------- ## +## Function library. ## +## ----------------- ## + +# This section contains a variety of useful functions to call in your +# scripts. Take note of the portable wrappers for features provided by +# some modern shells, which will fall back to slower equivalents on +# less featureful shells. + + +# func_append VAR VALUE +# --------------------- +# Append VALUE onto the existing contents of VAR. + + # We should try to minimise forks, especially on Windows where they are + # unreasonably slow, so skip the feature probes when bash or zsh are + # being used: + if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then + : ${_G_HAVE_ARITH_OP="yes"} + : ${_G_HAVE_XSI_OPS="yes"} + # The += operator was introduced in bash 3.1 + case $BASH_VERSION in + [12].* | 3.0 | 3.0*) ;; + *) + : ${_G_HAVE_PLUSEQ_OP="yes"} + ;; + esac + fi + + # _G_HAVE_PLUSEQ_OP + # Can be empty, in which case the shell is probed, "yes" if += is + # useable or anything else if it does not work. + test -z "$_G_HAVE_PLUSEQ_OP" \ + && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ + && _G_HAVE_PLUSEQ_OP=yes + +if test yes = "$_G_HAVE_PLUSEQ_OP" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_append () + { + $debug_cmd + + eval "$1+=\$2" + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_append () + { + $debug_cmd + + eval "$1=\$$1\$2" + } +fi + + +# func_append_quoted VAR VALUE +# ---------------------------- +# Quote VALUE and append to the end of shell variable VAR, separated +# by a space. +if test yes = "$_G_HAVE_PLUSEQ_OP"; then + eval 'func_append_quoted () + { + $debug_cmd + + func_quote_for_eval "$2" + eval "$1+=\\ \$func_quote_for_eval_result" + }' +else + func_append_quoted () + { + $debug_cmd + + func_quote_for_eval "$2" + eval "$1=\$$1\\ \$func_quote_for_eval_result" + } +fi + + +# func_append_uniq VAR VALUE +# -------------------------- +# Append unique VALUE onto the existing contents of VAR, assuming +# entries are delimited by the first character of VALUE. For example: +# +# func_append_uniq options " --another-option option-argument" +# +# will only append to $options if " --another-option option-argument " +# is not already present somewhere in $options already (note spaces at +# each end implied by leading space in second argument). +func_append_uniq () +{ + $debug_cmd + + eval _G_current_value='`$ECHO $'$1'`' + _G_delim=`expr "$2" : '\(.\)'` + + case $_G_delim$_G_current_value$_G_delim in + *"$2$_G_delim"*) ;; + *) func_append "$@" ;; + esac +} + + +# func_arith TERM... +# ------------------ +# Set func_arith_result to the result of evaluating TERMs. + test -z "$_G_HAVE_ARITH_OP" \ + && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ + && _G_HAVE_ARITH_OP=yes + +if test yes = "$_G_HAVE_ARITH_OP"; then + eval 'func_arith () + { + $debug_cmd + + func_arith_result=$(( $* )) + }' +else + func_arith () + { + $debug_cmd + + func_arith_result=`expr "$@"` + } +fi + + +# func_basename FILE +# ------------------ +# Set func_basename_result to FILE with everything up to and including +# the last / stripped. +if test yes = "$_G_HAVE_XSI_OPS"; then + # If this shell supports suffix pattern removal, then use it to avoid + # forking. Hide the definitions single quotes in case the shell chokes + # on unsupported syntax... + _b='func_basename_result=${1##*/}' + _d='case $1 in + */*) func_dirname_result=${1%/*}$2 ;; + * ) func_dirname_result=$3 ;; + esac' + +else + # ...otherwise fall back to using sed. + _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' + _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` + if test "X$func_dirname_result" = "X$1"; then + func_dirname_result=$3 + else + func_append func_dirname_result "$2" + fi' +fi + +eval 'func_basename () +{ + $debug_cmd + + '"$_b"' +}' + + +# func_dirname FILE APPEND NONDIR_REPLACEMENT +# ------------------------------------------- +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +eval 'func_dirname () +{ + $debug_cmd + + '"$_d"' +}' + + +# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT +# -------------------------------------------------------- +# Perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# For efficiency, we do not delegate to the functions above but instead +# duplicate the functionality here. +eval 'func_dirname_and_basename () +{ + $debug_cmd + + '"$_b"' + '"$_d"' +}' + + +# func_echo ARG... +# ---------------- +# Echo program name prefixed message. +func_echo () +{ + $debug_cmd + + _G_message=$* + + func_echo_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_IFS + $ECHO "$progname: $_G_line" + done + IFS=$func_echo_IFS +} + + +# func_echo_all ARG... +# -------------------- +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + + +# func_echo_infix_1 INFIX ARG... +# ------------------------------ +# Echo program name, followed by INFIX on the first line, with any +# additional lines not showing INFIX. +func_echo_infix_1 () +{ + $debug_cmd + + $require_term_colors + + _G_infix=$1; shift + _G_indent=$_G_infix + _G_prefix="$progname: $_G_infix: " + _G_message=$* + + # Strip color escape sequences before counting printable length + for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" + do + test -n "$_G_tc" && { + _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` + _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` + } + done + _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes + + func_echo_infix_1_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_infix_1_IFS + $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 + _G_prefix=$_G_indent + done + IFS=$func_echo_infix_1_IFS +} + + +# func_error ARG... +# ----------------- +# Echo program name prefixed message to standard error. +func_error () +{ + $debug_cmd + + $require_term_colors + + func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 +} + + +# func_fatal_error ARG... +# ----------------------- +# Echo program name prefixed message to standard error, and exit. +func_fatal_error () +{ + $debug_cmd + + func_error "$*" + exit $EXIT_FAILURE +} + + +# func_grep EXPRESSION FILENAME +# ----------------------------- +# Check whether EXPRESSION matches any line of FILENAME, without output. +func_grep () +{ + $debug_cmd + + $GREP "$1" "$2" >/dev/null 2>&1 +} + + +# func_len STRING +# --------------- +# Set func_len_result to the length of STRING. STRING may not +# start with a hyphen. + test -z "$_G_HAVE_XSI_OPS" \ + && (eval 'x=a/b/c; + test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ + && _G_HAVE_XSI_OPS=yes + +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_len () + { + $debug_cmd + + func_len_result=${#1} + }' +else + func_len () + { + $debug_cmd + + func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` + } +fi + + +# func_mkdir_p DIRECTORY-PATH +# --------------------------- +# Make sure the entire path to DIRECTORY-PATH is available. +func_mkdir_p () +{ + $debug_cmd + + _G_directory_path=$1 + _G_dir_list= + + if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then + + # Protect directory names starting with '-' + case $_G_directory_path in + -*) _G_directory_path=./$_G_directory_path ;; + esac + + # While some portion of DIR does not yet exist... + while test ! -d "$_G_directory_path"; do + # ...make a list in topmost first order. Use a colon delimited + # list incase some portion of path contains whitespace. + _G_dir_list=$_G_directory_path:$_G_dir_list + + # If the last portion added has no slash in it, the list is done + case $_G_directory_path in */*) ;; *) break ;; esac + + # ...otherwise throw away the child directory and loop + _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` + done + _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` + + func_mkdir_p_IFS=$IFS; IFS=: + for _G_dir in $_G_dir_list; do + IFS=$func_mkdir_p_IFS + # mkdir can fail with a 'File exist' error if two processes + # try to create one of the directories concurrently. Don't + # stop in that case! + $MKDIR "$_G_dir" 2>/dev/null || : + done + IFS=$func_mkdir_p_IFS + + # Bail out if we (or some other process) failed to create a directory. + test -d "$_G_directory_path" || \ + func_fatal_error "Failed to create '$1'" + fi +} + + +# func_mktempdir [BASENAME] +# ------------------------- +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, BASENAME is the basename for that directory. +func_mktempdir () +{ + $debug_cmd + + _G_template=${TMPDIR-/tmp}/${1-$progname} + + if test : = "$opt_dry_run"; then + # Return a directory name, but don't create it in dry-run mode + _G_tmpdir=$_G_template-$$ + else + + # If mktemp works, use that first and foremost + _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` + + if test ! -d "$_G_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + _G_tmpdir=$_G_template-${RANDOM-0}$$ + + func_mktempdir_umask=`umask` + umask 0077 + $MKDIR "$_G_tmpdir" + umask $func_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$_G_tmpdir" || \ + func_fatal_error "cannot create temporary directory '$_G_tmpdir'" + fi + + $ECHO "$_G_tmpdir" +} + + +# func_normal_abspath PATH +# ------------------------ +# Remove doubled-up and trailing slashes, "." path components, +# and cancel out any ".." path components in PATH after making +# it an absolute path. +func_normal_abspath () +{ + $debug_cmd + + # These SED scripts presuppose an absolute path with a trailing slash. + _G_pathcar='s|^/\([^/]*\).*$|\1|' + _G_pathcdr='s|^/[^/]*||' + _G_removedotparts=':dotsl + s|/\./|/|g + t dotsl + s|/\.$|/|' + _G_collapseslashes='s|/\{1,\}|/|g' + _G_finalslash='s|/*$|/|' + + # Start from root dir and reassemble the path. + func_normal_abspath_result= + func_normal_abspath_tpath=$1 + func_normal_abspath_altnamespace= + case $func_normal_abspath_tpath in + "") + # Empty path, that just means $cwd. + func_stripname '' '/' "`pwd`" + func_normal_abspath_result=$func_stripname_result + return + ;; + # The next three entries are used to spot a run of precisely + # two leading slashes without using negated character classes; + # we take advantage of case's first-match behaviour. + ///*) + # Unusual form of absolute path, do nothing. + ;; + //*) + # Not necessarily an ordinary path; POSIX reserves leading '//' + # and for example Cygwin uses it to access remote file shares + # over CIFS/SMB, so we conserve a leading double slash if found. + func_normal_abspath_altnamespace=/ + ;; + /*) + # Absolute path, do nothing. + ;; + *) + # Relative path, prepend $cwd. + func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath + ;; + esac + + # Cancel out all the simple stuff to save iterations. We also want + # the path to end with a slash for ease of parsing, so make sure + # there is one (and only one) here. + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` + while :; do + # Processed it all yet? + if test / = "$func_normal_abspath_tpath"; then + # If we ascended to the root using ".." the result may be empty now. + if test -z "$func_normal_abspath_result"; then + func_normal_abspath_result=/ + fi + break + fi + func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_pathcar"` + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_pathcdr"` + # Figure out what to do with it + case $func_normal_abspath_tcomponent in + "") + # Trailing empty path component, ignore it. + ;; + ..) + # Parent dir; strip last assembled component from result. + func_dirname "$func_normal_abspath_result" + func_normal_abspath_result=$func_dirname_result + ;; + *) + # Actual path component, append it. + func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" + ;; + esac + done + # Restore leading double-slash if one was found on entry. + func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result +} + + +# func_notquiet ARG... +# -------------------- +# Echo program name prefixed message only when not in quiet mode. +func_notquiet () +{ + $debug_cmd + + $opt_quiet || func_echo ${1+"$@"} + + # A bug in bash halts the script if the last line of a function + # fails when set -e is in force, so we need another command to + # work around that: + : +} + + +# func_relative_path SRCDIR DSTDIR +# -------------------------------- +# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. +func_relative_path () +{ + $debug_cmd + + func_relative_path_result= + func_normal_abspath "$1" + func_relative_path_tlibdir=$func_normal_abspath_result + func_normal_abspath "$2" + func_relative_path_tbindir=$func_normal_abspath_result + + # Ascend the tree starting from libdir + while :; do + # check if we have found a prefix of bindir + case $func_relative_path_tbindir in + $func_relative_path_tlibdir) + # found an exact match + func_relative_path_tcancelled= + break + ;; + $func_relative_path_tlibdir*) + # found a matching prefix + func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" + func_relative_path_tcancelled=$func_stripname_result + if test -z "$func_relative_path_result"; then + func_relative_path_result=. + fi + break + ;; + *) + func_dirname $func_relative_path_tlibdir + func_relative_path_tlibdir=$func_dirname_result + if test -z "$func_relative_path_tlibdir"; then + # Have to descend all the way to the root! + func_relative_path_result=../$func_relative_path_result + func_relative_path_tcancelled=$func_relative_path_tbindir + break + fi + func_relative_path_result=../$func_relative_path_result + ;; + esac + done + + # Now calculate path; take care to avoid doubling-up slashes. + func_stripname '' '/' "$func_relative_path_result" + func_relative_path_result=$func_stripname_result + func_stripname '/' '/' "$func_relative_path_tcancelled" + if test -n "$func_stripname_result"; then + func_append func_relative_path_result "/$func_stripname_result" + fi + + # Normalisation. If bindir is libdir, return '.' else relative path. + if test -n "$func_relative_path_result"; then + func_stripname './' '' "$func_relative_path_result" + func_relative_path_result=$func_stripname_result + fi + + test -n "$func_relative_path_result" || func_relative_path_result=. + + : +} + + +# func_quote_for_eval ARG... +# -------------------------- +# Aesthetically quote ARGs to be evaled later. +# This function returns two values: +# i) func_quote_for_eval_result +# double-quoted, suitable for a subsequent eval +# ii) func_quote_for_eval_unquoted_result +# has all characters that are still active within double +# quotes backslashified. +func_quote_for_eval () +{ + $debug_cmd + + func_quote_for_eval_unquoted_result= + func_quote_for_eval_result= + while test 0 -lt $#; do + case $1 in + *[\\\`\"\$]*) + _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; + *) + _G_unquoted_arg=$1 ;; + esac + if test -n "$func_quote_for_eval_unquoted_result"; then + func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" + else + func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" + fi + + case $_G_unquoted_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting, command substitution and variable expansion + # for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + _G_quoted_arg=\"$_G_unquoted_arg\" + ;; + *) + _G_quoted_arg=$_G_unquoted_arg + ;; + esac + + if test -n "$func_quote_for_eval_result"; then + func_append func_quote_for_eval_result " $_G_quoted_arg" + else + func_append func_quote_for_eval_result "$_G_quoted_arg" + fi + shift + done +} + + +# func_quote_for_expand ARG +# ------------------------- +# Aesthetically quote ARG to be evaled later; same as above, +# but do not quote variable references. +func_quote_for_expand () +{ + $debug_cmd + + case $1 in + *[\\\`\"]*) + _G_arg=`$ECHO "$1" | $SED \ + -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; + *) + _G_arg=$1 ;; + esac + + case $_G_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting and command substitution for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + _G_arg=\"$_G_arg\" + ;; + esac + + func_quote_for_expand_result=$_G_arg +} + + +# func_stripname PREFIX SUFFIX NAME +# --------------------------------- +# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_stripname () + { + $debug_cmd + + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary variable first. + func_stripname_result=$3 + func_stripname_result=${func_stripname_result#"$1"} + func_stripname_result=${func_stripname_result%"$2"} + }' +else + func_stripname () + { + $debug_cmd + + case $2 in + .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; + *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; + esac + } +fi + + +# func_show_eval CMD [FAIL_EXP] +# ----------------------------- +# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. +func_show_eval () +{ + $debug_cmd + + _G_cmd=$1 + _G_fail_exp=${2-':'} + + func_quote_for_expand "$_G_cmd" + eval "func_notquiet $func_quote_for_expand_result" + + $opt_dry_run || { + eval "$_G_cmd" + _G_status=$? + if test 0 -ne "$_G_status"; then + eval "(exit $_G_status); $_G_fail_exp" + fi + } +} + + +# func_show_eval_locale CMD [FAIL_EXP] +# ------------------------------------ +# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. Use the saved locale for evaluation. +func_show_eval_locale () +{ + $debug_cmd + + _G_cmd=$1 + _G_fail_exp=${2-':'} + + $opt_quiet || { + func_quote_for_expand "$_G_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + $opt_dry_run || { + eval "$_G_user_locale + $_G_cmd" + _G_status=$? + eval "$_G_safe_locale" + if test 0 -ne "$_G_status"; then + eval "(exit $_G_status); $_G_fail_exp" + fi + } +} + + +# func_tr_sh +# ---------- +# Turn $1 into a string suitable for a shell variable name. +# Result is stored in $func_tr_sh_result. All characters +# not in the set a-zA-Z0-9_ are replaced with '_'. Further, +# if $1 begins with a digit, a '_' is prepended as well. +func_tr_sh () +{ + $debug_cmd + + case $1 in + [0-9]* | *[!a-zA-Z0-9_]*) + func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` + ;; + * ) + func_tr_sh_result=$1 + ;; + esac +} + + +# func_verbose ARG... +# ------------------- +# Echo program name prefixed message in verbose mode only. +func_verbose () +{ + $debug_cmd + + $opt_verbose && func_echo "$*" + + : +} + + +# func_warn_and_continue ARG... +# ----------------------------- +# Echo program name prefixed warning message to standard error. +func_warn_and_continue () +{ + $debug_cmd + + $require_term_colors + + func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 +} + + +# func_warning CATEGORY ARG... +# ---------------------------- +# Echo program name prefixed warning message to standard error. Warning +# messages can be filtered according to CATEGORY, where this function +# elides messages where CATEGORY is not listed in the global variable +# 'opt_warning_types'. +func_warning () +{ + $debug_cmd + + # CATEGORY must be in the warning_categories list! + case " $warning_categories " in + *" $1 "*) ;; + *) func_internal_error "invalid warning category '$1'" ;; + esac + + _G_category=$1 + shift + + case " $opt_warning_types " in + *" $_G_category "*) $warning_func ${1+"$@"} ;; + esac +} + + +# func_sort_ver VER1 VER2 +# ----------------------- +# 'sort -V' is not generally available. +# Note this deviates from the version comparison in automake +# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a +# but this should suffice as we won't be specifying old +# version formats or redundant trailing .0 in bootstrap.conf. +# If we did want full compatibility then we should probably +# use m4_version_compare from autoconf. +func_sort_ver () +{ + $debug_cmd + + printf '%s\n%s\n' "$1" "$2" \ + | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n +} + +# func_lt_ver PREV CURR +# --------------------- +# Return true if PREV and CURR are in the correct order according to +# func_sort_ver, otherwise false. Use it like this: +# +# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." +func_lt_ver () +{ + $debug_cmd + + test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` +} + + +# Local variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-time-zone: "UTC" +# End: +#! /bin/sh + +# Set a version string for this script. +scriptversion=2014-01-07.03; # UTC + +# A portable, pluggable option parser for Bourne shell. +# Written by Gary V. Vaughan, 2010 + +# Copyright (C) 2010-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Please report bugs or propose patches to gary@gnu.org. + + +## ------ ## +## Usage. ## +## ------ ## + +# This file is a library for parsing options in your shell scripts along +# with assorted other useful supporting features that you can make use +# of too. +# +# For the simplest scripts you might need only: +# +# #!/bin/sh +# . relative/path/to/funclib.sh +# . relative/path/to/options-parser +# scriptversion=1.0 +# func_options ${1+"$@"} +# eval set dummy "$func_options_result"; shift +# ...rest of your script... +# +# In order for the '--version' option to work, you will need to have a +# suitably formatted comment like the one at the top of this file +# starting with '# Written by ' and ending with '# warranty; '. +# +# For '-h' and '--help' to work, you will also need a one line +# description of your script's purpose in a comment directly above the +# '# Written by ' line, like the one at the top of this file. +# +# The default options also support '--debug', which will turn on shell +# execution tracing (see the comment above debug_cmd below for another +# use), and '--verbose' and the func_verbose function to allow your script +# to display verbose messages only when your user has specified +# '--verbose'. +# +# After sourcing this file, you can plug processing for additional +# options by amending the variables from the 'Configuration' section +# below, and following the instructions in the 'Option parsing' +# section further down. + +## -------------- ## +## Configuration. ## +## -------------- ## + +# You should override these variables in your script after sourcing this +# file so that they reflect the customisations you have added to the +# option parser. + +# The usage line for option parsing errors and the start of '-h' and +# '--help' output messages. You can embed shell variables for delayed +# expansion at the time the message is displayed, but you will need to +# quote other shell meta-characters carefully to prevent them being +# expanded when the contents are evaled. +usage='$progpath [OPTION]...' + +# Short help message in response to '-h' and '--help'. Add to this or +# override it after sourcing this library to reflect the full set of +# options your script accepts. +usage_message="\ + --debug enable verbose shell tracing + -W, --warnings=CATEGORY + report the warnings falling in CATEGORY [all] + -v, --verbose verbosely report processing + --version print version information and exit + -h, --help print short or long help message and exit +" + +# Additional text appended to 'usage_message' in response to '--help'. +long_help_message=" +Warning categories include: + 'all' show all warnings + 'none' turn off all the warnings + 'error' warnings are treated as fatal errors" + +# Help message printed before fatal option parsing errors. +fatal_help="Try '\$progname --help' for more information." + + + +## ------------------------- ## +## Hook function management. ## +## ------------------------- ## + +# This section contains functions for adding, removing, and running hooks +# to the main code. A hook is just a named list of of function, that can +# be run in order later on. + +# func_hookable FUNC_NAME +# ----------------------- +# Declare that FUNC_NAME will run hooks added with +# 'func_add_hook FUNC_NAME ...'. +func_hookable () +{ + $debug_cmd + + func_append hookable_fns " $1" +} + + +# func_add_hook FUNC_NAME HOOK_FUNC +# --------------------------------- +# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must +# first have been declared "hookable" by a call to 'func_hookable'. +func_add_hook () +{ + $debug_cmd + + case " $hookable_fns " in + *" $1 "*) ;; + *) func_fatal_error "'$1' does not accept hook functions." ;; + esac + + eval func_append ${1}_hooks '" $2"' +} + + +# func_remove_hook FUNC_NAME HOOK_FUNC +# ------------------------------------ +# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. +func_remove_hook () +{ + $debug_cmd + + eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' +} + + +# func_run_hooks FUNC_NAME [ARG]... +# --------------------------------- +# Run all hook functions registered to FUNC_NAME. +# It is assumed that the list of hook functions contains nothing more +# than a whitespace-delimited list of legal shell function names, and +# no effort is wasted trying to catch shell meta-characters or preserve +# whitespace. +func_run_hooks () +{ + $debug_cmd + + case " $hookable_fns " in + *" $1 "*) ;; + *) func_fatal_error "'$1' does not support hook funcions.n" ;; + esac + + eval _G_hook_fns=\$$1_hooks; shift + + for _G_hook in $_G_hook_fns; do + eval $_G_hook '"$@"' + + # store returned options list back into positional + # parameters for next 'cmd' execution. + eval _G_hook_result=\$${_G_hook}_result + eval set dummy "$_G_hook_result"; shift + done + + func_quote_for_eval ${1+"$@"} + func_run_hooks_result=$func_quote_for_eval_result +} + + + +## --------------- ## +## Option parsing. ## +## --------------- ## + +# In order to add your own option parsing hooks, you must accept the +# full positional parameter list in your hook function, remove any +# options that you action, and then pass back the remaining unprocessed +# options in '_result', escaped suitably for +# 'eval'. Like this: +# +# my_options_prep () +# { +# $debug_cmd +# +# # Extend the existing usage message. +# usage_message=$usage_message' +# -s, --silent don'\''t print informational messages +# ' +# +# func_quote_for_eval ${1+"$@"} +# my_options_prep_result=$func_quote_for_eval_result +# } +# func_add_hook func_options_prep my_options_prep +# +# +# my_silent_option () +# { +# $debug_cmd +# +# # Note that for efficiency, we parse as many options as we can +# # recognise in a loop before passing the remainder back to the +# # caller on the first unrecognised argument we encounter. +# while test $# -gt 0; do +# opt=$1; shift +# case $opt in +# --silent|-s) opt_silent=: ;; +# # Separate non-argument short options: +# -s*) func_split_short_opt "$_G_opt" +# set dummy "$func_split_short_opt_name" \ +# "-$func_split_short_opt_arg" ${1+"$@"} +# shift +# ;; +# *) set dummy "$_G_opt" "$*"; shift; break ;; +# esac +# done +# +# func_quote_for_eval ${1+"$@"} +# my_silent_option_result=$func_quote_for_eval_result +# } +# func_add_hook func_parse_options my_silent_option +# +# +# my_option_validation () +# { +# $debug_cmd +# +# $opt_silent && $opt_verbose && func_fatal_help "\ +# '--silent' and '--verbose' options are mutually exclusive." +# +# func_quote_for_eval ${1+"$@"} +# my_option_validation_result=$func_quote_for_eval_result +# } +# func_add_hook func_validate_options my_option_validation +# +# You'll alse need to manually amend $usage_message to reflect the extra +# options you parse. It's preferable to append if you can, so that +# multiple option parsing hooks can be added safely. + + +# func_options [ARG]... +# --------------------- +# All the functions called inside func_options are hookable. See the +# individual implementations for details. +func_hookable func_options +func_options () +{ + $debug_cmd + + func_options_prep ${1+"$@"} + eval func_parse_options \ + ${func_options_prep_result+"$func_options_prep_result"} + eval func_validate_options \ + ${func_parse_options_result+"$func_parse_options_result"} + + eval func_run_hooks func_options \ + ${func_validate_options_result+"$func_validate_options_result"} + + # save modified positional parameters for caller + func_options_result=$func_run_hooks_result +} + + +# func_options_prep [ARG]... +# -------------------------- +# All initialisations required before starting the option parse loop. +# Note that when calling hook functions, we pass through the list of +# positional parameters. If a hook function modifies that list, and +# needs to propogate that back to rest of this script, then the complete +# modified list must be put in 'func_run_hooks_result' before +# returning. +func_hookable func_options_prep +func_options_prep () +{ + $debug_cmd + + # Option defaults: + opt_verbose=false + opt_warning_types= + + func_run_hooks func_options_prep ${1+"$@"} + + # save modified positional parameters for caller + func_options_prep_result=$func_run_hooks_result +} + + +# func_parse_options [ARG]... +# --------------------------- +# The main option parsing loop. +func_hookable func_parse_options +func_parse_options () +{ + $debug_cmd + + func_parse_options_result= + + # this just eases exit handling + while test $# -gt 0; do + # Defer to hook functions for initial option parsing, so they + # get priority in the event of reusing an option name. + func_run_hooks func_parse_options ${1+"$@"} + + # Adjust func_parse_options positional parameters to match + eval set dummy "$func_run_hooks_result"; shift + + # Break out of the loop if we already parsed every option. + test $# -gt 0 || break + + _G_opt=$1 + shift + case $_G_opt in + --debug|-x) debug_cmd='set -x' + func_echo "enabling shell trace mode" + $debug_cmd + ;; + + --no-warnings|--no-warning|--no-warn) + set dummy --warnings none ${1+"$@"} + shift + ;; + + --warnings|--warning|-W) + test $# = 0 && func_missing_arg $_G_opt && break + case " $warning_categories $1" in + *" $1 "*) + # trailing space prevents matching last $1 above + func_append_uniq opt_warning_types " $1" + ;; + *all) + opt_warning_types=$warning_categories + ;; + *none) + opt_warning_types=none + warning_func=: + ;; + *error) + opt_warning_types=$warning_categories + warning_func=func_fatal_error + ;; + *) + func_fatal_error \ + "unsupported warning category: '$1'" + ;; + esac + shift + ;; + + --verbose|-v) opt_verbose=: ;; + --version) func_version ;; + -\?|-h) func_usage ;; + --help) func_help ;; + + # Separate optargs to long options (plugins may need this): + --*=*) func_split_equals "$_G_opt" + set dummy "$func_split_equals_lhs" \ + "$func_split_equals_rhs" ${1+"$@"} + shift + ;; + + # Separate optargs to short options: + -W*) + func_split_short_opt "$_G_opt" + set dummy "$func_split_short_opt_name" \ + "$func_split_short_opt_arg" ${1+"$@"} + shift + ;; + + # Separate non-argument short options: + -\?*|-h*|-v*|-x*) + func_split_short_opt "$_G_opt" + set dummy "$func_split_short_opt_name" \ + "-$func_split_short_opt_arg" ${1+"$@"} + shift + ;; + + --) break ;; + -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; + *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + esac + done + + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + func_parse_options_result=$func_quote_for_eval_result +} + + +# func_validate_options [ARG]... +# ------------------------------ +# Perform any sanity checks on option settings and/or unconsumed +# arguments. +func_hookable func_validate_options +func_validate_options () +{ + $debug_cmd + + # Display all warnings if -W was not given. + test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" + + func_run_hooks func_validate_options ${1+"$@"} + + # Bail if the options were screwed! + $exit_cmd $EXIT_FAILURE + + # save modified positional parameters for caller + func_validate_options_result=$func_run_hooks_result +} + + + +## ----------------- ## +## Helper functions. ## +## ----------------- ## + +# This section contains the helper functions used by the rest of the +# hookable option parser framework in ascii-betical order. + + +# func_fatal_help ARG... +# ---------------------- +# Echo program name prefixed message to standard error, followed by +# a help hint, and exit. +func_fatal_help () +{ + $debug_cmd + + eval \$ECHO \""Usage: $usage"\" + eval \$ECHO \""$fatal_help"\" + func_error ${1+"$@"} + exit $EXIT_FAILURE +} + + +# func_help +# --------- +# Echo long help message to standard output and exit. +func_help () +{ + $debug_cmd + + func_usage_message + $ECHO "$long_help_message" + exit 0 +} + + +# func_missing_arg ARGNAME +# ------------------------ +# Echo program name prefixed message to standard error and set global +# exit_cmd. +func_missing_arg () +{ + $debug_cmd + + func_error "Missing argument for '$1'." + exit_cmd=exit +} + + +# func_split_equals STRING +# ------------------------ +# Set func_split_equals_lhs and func_split_equals_rhs shell variables after +# splitting STRING at the '=' sign. +test -z "$_G_HAVE_XSI_OPS" \ + && (eval 'x=a/b/c; + test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ + && _G_HAVE_XSI_OPS=yes + +if test yes = "$_G_HAVE_XSI_OPS" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_split_equals () + { + $debug_cmd + + func_split_equals_lhs=${1%%=*} + func_split_equals_rhs=${1#*=} + test "x$func_split_equals_lhs" = "x$1" \ + && func_split_equals_rhs= + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_split_equals () + { + $debug_cmd + + func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` + func_split_equals_rhs= + test "x$func_split_equals_lhs" = "x$1" \ + || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` + } +fi #func_split_equals + + +# func_split_short_opt SHORTOPT +# ----------------------------- +# Set func_split_short_opt_name and func_split_short_opt_arg shell +# variables after splitting SHORTOPT after the 2nd character. +if test yes = "$_G_HAVE_XSI_OPS" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_split_short_opt () + { + $debug_cmd + + func_split_short_opt_arg=${1#??} + func_split_short_opt_name=${1%"$func_split_short_opt_arg"} + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_split_short_opt () + { + $debug_cmd + + func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` + func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` + } +fi #func_split_short_opt + + +# func_usage +# ---------- +# Echo short help message to standard output and exit. +func_usage () +{ + $debug_cmd + + func_usage_message + $ECHO "Run '$progname --help |${PAGER-more}' for full usage" + exit 0 +} + + +# func_usage_message +# ------------------ +# Echo short help message to standard output. +func_usage_message () +{ + $debug_cmd + + eval \$ECHO \""Usage: $usage"\" + echo + $SED -n 's|^# || + /^Written by/{ + x;p;x + } + h + /^Written by/q' < "$progpath" + echo + eval \$ECHO \""$usage_message"\" +} + + +# func_version +# ------------ +# Echo version message to standard output and exit. +func_version () +{ + $debug_cmd + + printf '%s\n' "$progname $scriptversion" + $SED -n ' + /(C)/!b go + :more + /\./!{ + N + s|\n# | | + b more + } + :go + /^# Written by /,/# warranty; / { + s|^# || + s|^# *$|| + s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| + p + } + /^# Written by / { + s|^# || + p + } + /^warranty; /q' < "$progpath" + + exit $? +} + + +# Local variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-time-zone: "UTC" +# End: + +# Set a version string. +scriptversion='(GNU libtool) 2.4.6' + + +# func_echo ARG... +# ---------------- +# Libtool also displays the current mode in messages, so override +# funclib.sh func_echo with this custom definition. +func_echo () +{ + $debug_cmd + + _G_message=$* + + func_echo_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_IFS + $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" + done + IFS=$func_echo_IFS +} + + +# func_warning ARG... +# ------------------- +# Libtool warnings are not categorized, so override funclib.sh +# func_warning with this simpler definition. +func_warning () +{ + $debug_cmd + + $warning_func ${1+"$@"} +} + + +## ---------------- ## +## Options parsing. ## +## ---------------- ## + +# Hook in the functions to make sure our own options are parsed during +# the option parsing loop. + +usage='$progpath [OPTION]... [MODE-ARG]...' + +# Short help message in response to '-h'. +usage_message="Options: + --config show all configuration variables + --debug enable verbose shell tracing + -n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --mode=MODE use operation mode MODE + --no-warnings equivalent to '-Wnone' + --preserve-dup-deps don't remove duplicate dependency libraries + --quiet, --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG + -v, --verbose print more informational messages than default + --version print version information + -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] + -h, --help, --help-all print short, long, or detailed help message +" + +# Additional text appended to 'usage_message' in response to '--help'. +func_help () +{ + $debug_cmd + + func_usage_message + $ECHO "$long_help_message + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. When passed as first option, +'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. +Try '$progname --help --mode=MODE' for a more detailed description of MODE. + +When reporting a bug, please describe a test case to reproduce it and +include the following information: + + host-triplet: $host + shell: $SHELL + compiler: $LTCC + compiler flags: $LTCFLAGS + linker: $LD (gnu? $with_gnu_ld) + version: $progname (GNU libtool) 2.4.6 + automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` + autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` + +Report bugs to . +GNU libtool home page: . +General help using GNU software: ." + exit 0 +} + + +# func_lo2o OBJECT-NAME +# --------------------- +# Transform OBJECT-NAME from a '.lo' suffix to the platform specific +# object suffix. + +lo2o=s/\\.lo\$/.$objext/ +o2lo=s/\\.$objext\$/.lo/ + +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_lo2o () + { + case $1 in + *.lo) func_lo2o_result=${1%.lo}.$objext ;; + * ) func_lo2o_result=$1 ;; + esac + }' + + # func_xform LIBOBJ-OR-SOURCE + # --------------------------- + # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) + # suffix to a '.lo' libtool-object suffix. + eval 'func_xform () + { + func_xform_result=${1%.*}.lo + }' +else + # ...otherwise fall back to using sed. + func_lo2o () + { + func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` + } + + func_xform () + { + func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` + } +fi + + +# func_fatal_configuration ARG... +# ------------------------------- +# Echo program name prefixed message to standard error, followed by +# a configuration failure hint, and exit. +func_fatal_configuration () +{ + func__fatal_error ${1+"$@"} \ + "See the $PACKAGE documentation for more information." \ + "Fatal configuration error." +} + + +# func_config +# ----------- +# Display the configuration for all the tags in this script. +func_config () +{ + re_begincf='^# ### BEGIN LIBTOOL' + re_endcf='^# ### END LIBTOOL' + + # Default configuration. + $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" + + # Now print the configurations for the tags. + for tagname in $taglist; do + $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" + done + + exit $? +} + + +# func_features +# ------------- +# Display the features supported by this script. +func_features () +{ + echo "host: $host" + if test yes = "$build_libtool_libs"; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test yes = "$build_old_libs"; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + + exit $? +} + + +# func_enable_tag TAGNAME +# ----------------------- +# Verify that TAGNAME is valid, and either flag an error and exit, or +# enable the TAGNAME tag. We also add TAGNAME to the global $taglist +# variable here. +func_enable_tag () +{ + # Global variable: + tagname=$1 + + re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" + re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" + sed_extractcf=/$re_begincf/,/$re_endcf/p + + # Validate tagname. + case $tagname in + *[!-_A-Za-z0-9,/]*) + func_fatal_error "invalid tag name: $tagname" + ;; + esac + + # Don't test for the "default" C tag, as we know it's + # there but not specially marked. + case $tagname in + CC) ;; + *) + if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then + taglist="$taglist $tagname" + + # Evaluate the configuration. Be careful to quote the path + # and the sed script, to avoid splitting on whitespace, but + # also don't use non-portable quotes within backquotes within + # quotes we have to do it in 2 steps: + extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` + eval "$extractedcf" + else + func_error "ignoring unknown tag $tagname" + fi + ;; + esac +} + + +# func_check_version_match +# ------------------------ +# Ensure that we are using m4 macros, and libtool script from the same +# release of libtool. +func_check_version_match () +{ + if test "$package_revision" != "$macro_revision"; then + if test "$VERSION" != "$macro_version"; then + if test -z "$macro_version"; then + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from an older release. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + fi + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, +$progname: but the definition of this LT_INIT comes from revision $macro_revision. +$progname: You should recreate aclocal.m4 with macros from revision $package_revision +$progname: of $PACKAGE $VERSION and run autoconf again. +_LT_EOF + fi + + exit $EXIT_MISMATCH + fi +} + + +# libtool_options_prep [ARG]... +# ----------------------------- +# Preparation for options parsed by libtool. +libtool_options_prep () +{ + $debug_mode + + # Option defaults: + opt_config=false + opt_dlopen= + opt_dry_run=false + opt_help=false + opt_mode= + opt_preserve_dup_deps=false + opt_quiet=false + + nonopt= + preserve_args= + + # Shorthand for --mode=foo, only valid as the first argument + case $1 in + clean|clea|cle|cl) + shift; set dummy --mode clean ${1+"$@"}; shift + ;; + compile|compil|compi|comp|com|co|c) + shift; set dummy --mode compile ${1+"$@"}; shift + ;; + execute|execut|execu|exec|exe|ex|e) + shift; set dummy --mode execute ${1+"$@"}; shift + ;; + finish|finis|fini|fin|fi|f) + shift; set dummy --mode finish ${1+"$@"}; shift + ;; + install|instal|insta|inst|ins|in|i) + shift; set dummy --mode install ${1+"$@"}; shift + ;; + link|lin|li|l) + shift; set dummy --mode link ${1+"$@"}; shift + ;; + uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) + shift; set dummy --mode uninstall ${1+"$@"}; shift + ;; + esac + + # Pass back the list of options. + func_quote_for_eval ${1+"$@"} + libtool_options_prep_result=$func_quote_for_eval_result +} +func_add_hook func_options_prep libtool_options_prep + + +# libtool_parse_options [ARG]... +# --------------------------------- +# Provide handling for libtool specific options. +libtool_parse_options () +{ + $debug_cmd + + # Perform our own loop to consume as many options as possible in + # each iteration. + while test $# -gt 0; do + _G_opt=$1 + shift + case $_G_opt in + --dry-run|--dryrun|-n) + opt_dry_run=: + ;; + + --config) func_config ;; + + --dlopen|-dlopen) + opt_dlopen="${opt_dlopen+$opt_dlopen +}$1" + shift + ;; + + --preserve-dup-deps) + opt_preserve_dup_deps=: ;; + + --features) func_features ;; + + --finish) set dummy --mode finish ${1+"$@"}; shift ;; + + --help) opt_help=: ;; + + --help-all) opt_help=': help-all' ;; + + --mode) test $# = 0 && func_missing_arg $_G_opt && break + opt_mode=$1 + case $1 in + # Valid mode arguments: + clean|compile|execute|finish|install|link|relink|uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $_G_opt" + exit_cmd=exit + break + ;; + esac + shift + ;; + + --no-silent|--no-quiet) + opt_quiet=false + func_append preserve_args " $_G_opt" + ;; + + --no-warnings|--no-warning|--no-warn) + opt_warning=false + func_append preserve_args " $_G_opt" + ;; + + --no-verbose) + opt_verbose=false + func_append preserve_args " $_G_opt" + ;; + + --silent|--quiet) + opt_quiet=: + opt_verbose=false + func_append preserve_args " $_G_opt" + ;; + + --tag) test $# = 0 && func_missing_arg $_G_opt && break + opt_tag=$1 + func_append preserve_args " $_G_opt $1" + func_enable_tag "$1" + shift + ;; + + --verbose|-v) opt_quiet=false + opt_verbose=: + func_append preserve_args " $_G_opt" + ;; + + # An option not handled by this hook function: + *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + esac + done + + + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + libtool_parse_options_result=$func_quote_for_eval_result +} +func_add_hook func_parse_options libtool_parse_options + + + +# libtool_validate_options [ARG]... +# --------------------------------- +# Perform any sanity checks on option settings and/or unconsumed +# arguments. +libtool_validate_options () +{ + # save first non-option argument + if test 0 -lt $#; then + nonopt=$1 + shift + fi + + # preserve --debug + test : = "$debug_cmd" || func_append preserve_args " --debug" + + case $host in + # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 + # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 + *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; + *) + opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps + ;; + esac + + $opt_help || { + # Sanity checks first: + func_check_version_match + + test yes != "$build_libtool_libs" \ + && test yes != "$build_old_libs" \ + && func_fatal_configuration "not configured to build any kind of library" + + # Darwin sucks + eval std_shrext=\"$shrext_cmds\" + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$opt_dlopen" && test execute != "$opt_mode"; then + func_error "unrecognized option '-dlopen'" + $ECHO "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help=$help + help="Try '$progname --help --mode=$opt_mode' for more information." + } + + # Pass back the unparsed argument list + func_quote_for_eval ${1+"$@"} + libtool_validate_options_result=$func_quote_for_eval_result +} +func_add_hook func_validate_options libtool_validate_options + + +# Process options as early as possible so that --help and --version +# can return quickly. +func_options ${1+"$@"} +eval set dummy "$func_options_result"; shift + + + +## ----------- ## +## Main. ## +## ----------- ## + +magic='%%%MAGIC variable%%%' +magic_exe='%%%MAGIC EXE variable%%%' + +# Global variables. +extracted_archives= +extracted_serial=0 + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + +# func_generated_by_libtool +# True iff stdin has been generated by Libtool. This function is only +# a basic sanity check; it will hardly flush out determined imposters. +func_generated_by_libtool_p () +{ + $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 +} + +# func_lalib_p file +# True iff FILE is a libtool '.la' library or '.lo' object file. +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_lalib_p () +{ + test -f "$1" && + $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p +} + +# func_lalib_unsafe_p file +# True iff FILE is a libtool '.la' library or '.lo' object file. +# This function implements the same check as func_lalib_p without +# resorting to external programs. To this end, it redirects stdin and +# closes it afterwards, without saving the original file descriptor. +# As a safety measure, use it only where a negative result would be +# fatal anyway. Works if 'file' does not exist. +func_lalib_unsafe_p () +{ + lalib_p=no + if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then + for lalib_p_l in 1 2 3 4 + do + read lalib_p_line + case $lalib_p_line in + \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; + esac + done + exec 0<&5 5<&- + fi + test yes = "$lalib_p" +} + +# func_ltwrapper_script_p file +# True iff FILE is a libtool wrapper script +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_script_p () +{ + test -f "$1" && + $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p +} + +# func_ltwrapper_executable_p file +# True iff FILE is a libtool wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_executable_p () +{ + func_ltwrapper_exec_suffix= + case $1 in + *.exe) ;; + *) func_ltwrapper_exec_suffix=.exe ;; + esac + $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 +} + +# func_ltwrapper_scriptname file +# Assumes file is an ltwrapper_executable +# uses $file to determine the appropriate filename for a +# temporary ltwrapper_script. +func_ltwrapper_scriptname () +{ + func_dirname_and_basename "$1" "" "." + func_stripname '' '.exe' "$func_basename_result" + func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper +} + +# func_ltwrapper_p file +# True iff FILE is a libtool wrapper script or wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_p () +{ + func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" +} + + +# func_execute_cmds commands fail_cmd +# Execute tilde-delimited COMMANDS. +# If FAIL_CMD is given, eval that upon failure. +# FAIL_CMD may read-access the current command in variable CMD! +func_execute_cmds () +{ + $debug_cmd + + save_ifs=$IFS; IFS='~' + for cmd in $1; do + IFS=$sp$nl + eval cmd=\"$cmd\" + IFS=$save_ifs + func_show_eval "$cmd" "${2-:}" + done + IFS=$save_ifs +} + + +# func_source file +# Source FILE, adding directory component if necessary. +# Note that it is not necessary on cygwin/mingw to append a dot to +# FILE even if both FILE and FILE.exe exist: automatic-append-.exe +# behavior happens only for exec(3), not for open(2)! Also, sourcing +# 'FILE.' does not work on cygwin managed mounts. +func_source () +{ + $debug_cmd + + case $1 in + */* | *\\*) . "$1" ;; + *) . "./$1" ;; + esac +} + + +# func_resolve_sysroot PATH +# Replace a leading = in PATH with a sysroot. Store the result into +# func_resolve_sysroot_result +func_resolve_sysroot () +{ + func_resolve_sysroot_result=$1 + case $func_resolve_sysroot_result in + =*) + func_stripname '=' '' "$func_resolve_sysroot_result" + func_resolve_sysroot_result=$lt_sysroot$func_stripname_result + ;; + esac +} + +# func_replace_sysroot PATH +# If PATH begins with the sysroot, replace it with = and +# store the result into func_replace_sysroot_result. +func_replace_sysroot () +{ + case $lt_sysroot:$1 in + ?*:"$lt_sysroot"*) + func_stripname "$lt_sysroot" '' "$1" + func_replace_sysroot_result='='$func_stripname_result + ;; + *) + # Including no sysroot. + func_replace_sysroot_result=$1 + ;; + esac +} + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () +{ + $debug_cmd + + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + func_append_quoted CC_quoted "$arg" + done + CC_expanded=`func_echo_all $CC` + CC_quoted_expanded=`func_echo_all $CC_quoted` + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ + " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + func_append_quoted CC_quoted "$arg" + done + CC_expanded=`func_echo_all $CC` + CC_quoted_expanded=`func_echo_all $CC_quoted` + case "$@ " in + " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ + " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + func_echo "unable to infer tagged configuration" + func_fatal_error "specify a tag with '--tag'" +# else +# func_verbose "using $tagname tagged configuration" + fi + ;; + esac + fi +} + + + +# func_write_libtool_object output_name pic_name nonpic_name +# Create a libtool object file (analogous to a ".la" file), +# but don't create it if we're doing a dry run. +func_write_libtool_object () +{ + write_libobj=$1 + if test yes = "$build_libtool_libs"; then + write_lobj=\'$2\' + else + write_lobj=none + fi + + if test yes = "$build_old_libs"; then + write_oldobj=\'$3\' + else + write_oldobj=none + fi + + $opt_dry_run || { + cat >${write_libobj}T </dev/null` + if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then + func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | + $SED -e "$sed_naive_backslashify"` + else + func_convert_core_file_wine_to_w32_result= + fi + fi +} +# end: func_convert_core_file_wine_to_w32 + + +# func_convert_core_path_wine_to_w32 ARG +# Helper function used by path conversion functions when $build is *nix, and +# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly +# configured wine environment available, with the winepath program in $build's +# $PATH. Assumes ARG has no leading or trailing path separator characters. +# +# ARG is path to be converted from $build format to win32. +# Result is available in $func_convert_core_path_wine_to_w32_result. +# Unconvertible file (directory) names in ARG are skipped; if no directory names +# are convertible, then the result may be empty. +func_convert_core_path_wine_to_w32 () +{ + $debug_cmd + + # unfortunately, winepath doesn't convert paths, only file names + func_convert_core_path_wine_to_w32_result= + if test -n "$1"; then + oldIFS=$IFS + IFS=: + for func_convert_core_path_wine_to_w32_f in $1; do + IFS=$oldIFS + func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" + if test -n "$func_convert_core_file_wine_to_w32_result"; then + if test -z "$func_convert_core_path_wine_to_w32_result"; then + func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result + else + func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" + fi + fi + done + IFS=$oldIFS + fi +} +# end: func_convert_core_path_wine_to_w32 + + +# func_cygpath ARGS... +# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when +# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) +# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or +# (2), returns the Cygwin file name or path in func_cygpath_result (input +# file name or path is assumed to be in w32 format, as previously converted +# from $build's *nix or MSYS format). In case (3), returns the w32 file name +# or path in func_cygpath_result (input file name or path is assumed to be in +# Cygwin format). Returns an empty string on error. +# +# ARGS are passed to cygpath, with the last one being the file name or path to +# be converted. +# +# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH +# environment variable; do not put it in $PATH. +func_cygpath () +{ + $debug_cmd + + if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then + func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` + if test "$?" -ne 0; then + # on failure, ensure result is empty + func_cygpath_result= + fi + else + func_cygpath_result= + func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" + fi +} +#end: func_cygpath + + +# func_convert_core_msys_to_w32 ARG +# Convert file name or path ARG from MSYS format to w32 format. Return +# result in func_convert_core_msys_to_w32_result. +func_convert_core_msys_to_w32 () +{ + $debug_cmd + + # awkward: cmd appends spaces to result + func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | + $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` +} +#end: func_convert_core_msys_to_w32 + + +# func_convert_file_check ARG1 ARG2 +# Verify that ARG1 (a file name in $build format) was converted to $host +# format in ARG2. Otherwise, emit an error message, but continue (resetting +# func_to_host_file_result to ARG1). +func_convert_file_check () +{ + $debug_cmd + + if test -z "$2" && test -n "$1"; then + func_error "Could not determine host file name corresponding to" + func_error " '$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback: + func_to_host_file_result=$1 + fi +} +# end func_convert_file_check + + +# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH +# Verify that FROM_PATH (a path in $build format) was converted to $host +# format in TO_PATH. Otherwise, emit an error message, but continue, resetting +# func_to_host_file_result to a simplistic fallback value (see below). +func_convert_path_check () +{ + $debug_cmd + + if test -z "$4" && test -n "$3"; then + func_error "Could not determine the host path corresponding to" + func_error " '$3'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback. This is a deliberately simplistic "conversion" and + # should not be "improved". See libtool.info. + if test "x$1" != "x$2"; then + lt_replace_pathsep_chars="s|$1|$2|g" + func_to_host_path_result=`echo "$3" | + $SED -e "$lt_replace_pathsep_chars"` + else + func_to_host_path_result=$3 + fi + fi +} +# end func_convert_path_check + + +# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG +# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT +# and appending REPL if ORIG matches BACKPAT. +func_convert_path_front_back_pathsep () +{ + $debug_cmd + + case $4 in + $1 ) func_to_host_path_result=$3$func_to_host_path_result + ;; + esac + case $4 in + $2 ) func_append func_to_host_path_result "$3" + ;; + esac +} +# end func_convert_path_front_back_pathsep + + +################################################## +# $build to $host FILE NAME CONVERSION FUNCTIONS # +################################################## +# invoked via '$to_host_file_cmd ARG' +# +# In each case, ARG is the path to be converted from $build to $host format. +# Result will be available in $func_to_host_file_result. + + +# func_to_host_file ARG +# Converts the file name ARG from $build format to $host format. Return result +# in func_to_host_file_result. +func_to_host_file () +{ + $debug_cmd + + $to_host_file_cmd "$1" +} +# end func_to_host_file + + +# func_to_tool_file ARG LAZY +# converts the file name ARG from $build format to toolchain format. Return +# result in func_to_tool_file_result. If the conversion in use is listed +# in (the comma separated) LAZY, no conversion takes place. +func_to_tool_file () +{ + $debug_cmd + + case ,$2, in + *,"$to_tool_file_cmd",*) + func_to_tool_file_result=$1 + ;; + *) + $to_tool_file_cmd "$1" + func_to_tool_file_result=$func_to_host_file_result + ;; + esac +} +# end func_to_tool_file + + +# func_convert_file_noop ARG +# Copy ARG to func_to_host_file_result. +func_convert_file_noop () +{ + func_to_host_file_result=$1 +} +# end func_convert_file_noop + + +# func_convert_file_msys_to_w32 ARG +# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic +# conversion to w32 is not available inside the cwrapper. Returns result in +# func_to_host_file_result. +func_convert_file_msys_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_msys_to_w32 "$1" + func_to_host_file_result=$func_convert_core_msys_to_w32_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_msys_to_w32 + + +# func_convert_file_cygwin_to_w32 ARG +# Convert file name ARG from Cygwin to w32 format. Returns result in +# func_to_host_file_result. +func_convert_file_cygwin_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + # because $build is cygwin, we call "the" cygpath in $PATH; no need to use + # LT_CYGPATH in this case. + func_to_host_file_result=`cygpath -m "$1"` + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_cygwin_to_w32 + + +# func_convert_file_nix_to_w32 ARG +# Convert file name ARG from *nix to w32 format. Requires a wine environment +# and a working winepath. Returns result in func_to_host_file_result. +func_convert_file_nix_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_file_wine_to_w32 "$1" + func_to_host_file_result=$func_convert_core_file_wine_to_w32_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_nix_to_w32 + + +# func_convert_file_msys_to_cygwin ARG +# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. +# Returns result in func_to_host_file_result. +func_convert_file_msys_to_cygwin () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_msys_to_w32 "$1" + func_cygpath -u "$func_convert_core_msys_to_w32_result" + func_to_host_file_result=$func_cygpath_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_msys_to_cygwin + + +# func_convert_file_nix_to_cygwin ARG +# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed +# in a wine environment, working winepath, and LT_CYGPATH set. Returns result +# in func_to_host_file_result. +func_convert_file_nix_to_cygwin () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. + func_convert_core_file_wine_to_w32 "$1" + func_cygpath -u "$func_convert_core_file_wine_to_w32_result" + func_to_host_file_result=$func_cygpath_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_nix_to_cygwin + + +############################################# +# $build to $host PATH CONVERSION FUNCTIONS # +############################################# +# invoked via '$to_host_path_cmd ARG' +# +# In each case, ARG is the path to be converted from $build to $host format. +# The result will be available in $func_to_host_path_result. +# +# Path separators are also converted from $build format to $host format. If +# ARG begins or ends with a path separator character, it is preserved (but +# converted to $host format) on output. +# +# All path conversion functions are named using the following convention: +# file name conversion function : func_convert_file_X_to_Y () +# path conversion function : func_convert_path_X_to_Y () +# where, for any given $build/$host combination the 'X_to_Y' value is the +# same. If conversion functions are added for new $build/$host combinations, +# the two new functions must follow this pattern, or func_init_to_host_path_cmd +# will break. + + +# func_init_to_host_path_cmd +# Ensures that function "pointer" variable $to_host_path_cmd is set to the +# appropriate value, based on the value of $to_host_file_cmd. +to_host_path_cmd= +func_init_to_host_path_cmd () +{ + $debug_cmd + + if test -z "$to_host_path_cmd"; then + func_stripname 'func_convert_file_' '' "$to_host_file_cmd" + to_host_path_cmd=func_convert_path_$func_stripname_result + fi +} + + +# func_to_host_path ARG +# Converts the path ARG from $build format to $host format. Return result +# in func_to_host_path_result. +func_to_host_path () +{ + $debug_cmd + + func_init_to_host_path_cmd + $to_host_path_cmd "$1" +} +# end func_to_host_path + + +# func_convert_path_noop ARG +# Copy ARG to func_to_host_path_result. +func_convert_path_noop () +{ + func_to_host_path_result=$1 +} +# end func_convert_path_noop + + +# func_convert_path_msys_to_w32 ARG +# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic +# conversion to w32 is not available inside the cwrapper. Returns result in +# func_to_host_path_result. +func_convert_path_msys_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # Remove leading and trailing path separator characters from ARG. MSYS + # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; + # and winepath ignores them completely. + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" + func_to_host_path_result=$func_convert_core_msys_to_w32_result + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_msys_to_w32 + + +# func_convert_path_cygwin_to_w32 ARG +# Convert path ARG from Cygwin to w32 format. Returns result in +# func_to_host_file_result. +func_convert_path_cygwin_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_cygwin_to_w32 + + +# func_convert_path_nix_to_w32 ARG +# Convert path ARG from *nix to w32 format. Requires a wine environment and +# a working winepath. Returns result in func_to_host_file_result. +func_convert_path_nix_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" + func_to_host_path_result=$func_convert_core_path_wine_to_w32_result + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_nix_to_w32 + + +# func_convert_path_msys_to_cygwin ARG +# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. +# Returns result in func_to_host_file_result. +func_convert_path_msys_to_cygwin () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" + func_cygpath -u -p "$func_convert_core_msys_to_w32_result" + func_to_host_path_result=$func_cygpath_result + func_convert_path_check : : \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" : "$1" + fi +} +# end func_convert_path_msys_to_cygwin + + +# func_convert_path_nix_to_cygwin ARG +# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a +# a wine environment, working winepath, and LT_CYGPATH set. Returns result in +# func_to_host_file_result. +func_convert_path_nix_to_cygwin () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # Remove leading and trailing path separator characters from + # ARG. msys behavior is inconsistent here, cygpath turns them + # into '.;' and ';.', and winepath ignores them completely. + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" + func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" + func_to_host_path_result=$func_cygpath_result + func_convert_path_check : : \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" : "$1" + fi +} +# end func_convert_path_nix_to_cygwin + + +# func_dll_def_p FILE +# True iff FILE is a Windows DLL '.def' file. +# Keep in sync with _LT_DLL_DEF_P in libtool.m4 +func_dll_def_p () +{ + $debug_cmd + + func_dll_def_p_tmp=`$SED -n \ + -e 's/^[ ]*//' \ + -e '/^\(;.*\)*$/d' \ + -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ + -e q \ + "$1"` + test DEF = "$func_dll_def_p_tmp" +} + + +# func_mode_compile arg... +func_mode_compile () +{ + $debug_cmd + + # Get the compilation command and the source file. + base_compile= + srcfile=$nonopt # always keep a non-empty value in "srcfile" + suppress_opt=yes + suppress_output= + arg_mode=normal + libobj= + later= + pie_flag= + + for arg + do + case $arg_mode in + arg ) + # do not "continue". Instead, add this to base_compile + lastarg=$arg + arg_mode=normal + ;; + + target ) + libobj=$arg + arg_mode=normal + continue + ;; + + normal ) + # Accept any command-line options. + case $arg in + -o) + test -n "$libobj" && \ + func_fatal_error "you cannot specify '-o' more than once" + arg_mode=target + continue + ;; + + -pie | -fpie | -fPIE) + func_append pie_flag " $arg" + continue + ;; + + -shared | -static | -prefer-pic | -prefer-non-pic) + func_append later " $arg" + continue + ;; + + -no-suppress) + suppress_opt=no + continue + ;; + + -Xcompiler) + arg_mode=arg # the next one goes into the "base_compile" arg list + continue # The current "srcfile" will either be retained or + ;; # replaced later. I would guess that would be a bug. + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + lastarg= + save_ifs=$IFS; IFS=, + for arg in $args; do + IFS=$save_ifs + func_append_quoted lastarg "$arg" + done + IFS=$save_ifs + func_stripname ' ' '' "$lastarg" + lastarg=$func_stripname_result + + # Add the arguments to base_compile. + func_append base_compile " $lastarg" + continue + ;; + + *) + # Accept the current argument as the source file. + # The previous "srcfile" becomes the current argument. + # + lastarg=$srcfile + srcfile=$arg + ;; + esac # case $arg + ;; + esac # case $arg_mode + + # Aesthetically quote the previous argument. + func_append_quoted base_compile "$lastarg" + done # for arg + + case $arg_mode in + arg) + func_fatal_error "you must specify an argument for -Xcompile" + ;; + target) + func_fatal_error "you must specify a target with '-o'" + ;; + *) + # Get the name of the library object. + test -z "$libobj" && { + func_basename "$srcfile" + libobj=$func_basename_result + } + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + case $libobj in + *.[cCFSifmso] | \ + *.ada | *.adb | *.ads | *.asm | \ + *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ + *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) + func_xform "$libobj" + libobj=$func_xform_result + ;; + esac + + case $libobj in + *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; + *) + func_fatal_error "cannot determine name of library object from '$libobj'" + ;; + esac + + func_infer_tag $base_compile + + for arg in $later; do + case $arg in + -shared) + test yes = "$build_libtool_libs" \ + || func_fatal_configuration "cannot build a shared library" + build_old_libs=no + continue + ;; + + -static) + build_libtool_libs=no + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + esac + done + + func_quote_for_eval "$libobj" + test "X$libobj" != "X$func_quote_for_eval_result" \ + && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ + && func_warning "libobj name '$libobj' may not contain shell special characters." + func_dirname_and_basename "$obj" "/" "" + objname=$func_basename_result + xdir=$func_dirname_result + lobj=$xdir$objdir/$objname + + test -z "$base_compile" && \ + func_fatal_help "you must specify a compilation command" + + # Delete any leftover library objects. + if test yes = "$build_old_libs"; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2* | cegcc*) + pic_mode=default + ;; + esac + if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test no = "$compiler_c_o"; then + output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext + lockfile=$output_obj.lock + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test yes = "$need_locks"; then + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + elif test warn = "$need_locks"; then + if test -f "$lockfile"; then + $ECHO "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + func_append removelist " $output_obj" + $ECHO "$srcfile" > "$lockfile" + fi + + $opt_dry_run || $RM $removelist + func_append removelist " $lockfile" + trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 + + func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 + srcfile=$func_to_tool_file_result + func_quote_for_eval "$srcfile" + qsrcfile=$func_quote_for_eval_result + + # Only build a PIC object if we are building libtool libraries. + if test yes = "$build_libtool_libs"; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test no != "$pic_mode"; then + command="$base_compile $qsrcfile $pic_flag" + else + # Don't build PIC code + command="$base_compile $qsrcfile" + fi + + func_mkdir_p "$xdir$objdir" + + if test -z "$output_obj"; then + # Place PIC objects in $objdir + func_append command " -o $lobj" + fi + + func_show_eval_locale "$command" \ + 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' + + if test warn = "$need_locks" && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + func_show_eval '$MV "$output_obj" "$lobj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + + # Allow error messages only from the first compilation. + if test yes = "$suppress_opt"; then + suppress_output=' >/dev/null 2>&1' + fi + fi + + # Only build a position-dependent object if we build old libraries. + if test yes = "$build_old_libs"; then + if test yes != "$pic_mode"; then + # Don't build PIC code + command="$base_compile $qsrcfile$pie_flag" + else + command="$base_compile $qsrcfile $pic_flag" + fi + if test yes = "$compiler_c_o"; then + func_append command " -o $obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + func_append command "$suppress_output" + func_show_eval_locale "$command" \ + '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' + + if test warn = "$need_locks" && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + func_show_eval '$MV "$output_obj" "$obj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + fi + + $opt_dry_run || { + func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" + + # Unlock the critical section if it was locked + if test no != "$need_locks"; then + removelist=$lockfile + $RM "$lockfile" + fi + } + + exit $EXIT_SUCCESS +} + +$opt_help || { + test compile = "$opt_mode" && func_mode_compile ${1+"$@"} +} + +func_mode_help () +{ + # We need to display help for each of the modes. + case $opt_mode in + "") + # Generic help is extracted from the usage comments + # at the start of this file. + func_help + ;; + + clean) + $ECHO \ +"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + + compile) + $ECHO \ +"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -no-suppress do not suppress compiler output for multiple passes + -prefer-pic try to build PIC objects only + -prefer-non-pic try to build non-PIC objects only + -shared do not build a '.o' file suitable for static linking + -static only build a '.o' file suitable for static linking + -Wc,FLAG pass FLAG directly to the compiler + +COMPILE-COMMAND is a command to be used in creating a 'standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix '.c' with the +library object suffix, '.lo'." + ;; + + execute) + $ECHO \ +"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to '-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + + finish) + $ECHO \ +"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the '--dry-run' option if you just want to see what would be executed." + ;; + + install) + $ECHO \ +"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the 'install' or 'cp' program. + +The following components of INSTALL-COMMAND are treated specially: + + -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + + link) + $ECHO \ +"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -bindir BINDIR specify path to binaries directory (for systems where + libraries must be found in the PATH setting at runtime) + -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE use a list of object files found in FILE to specify objects + -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -shared only do dynamic linking of libtool libraries + -shrext SUFFIX override the standard shared library file extension + -static do not do any dynamic linking of uninstalled libtool libraries + -static-libtool-libs + do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + -weak LIBNAME declare that the target provides the LIBNAME interface + -Wc,FLAG + -Xcompiler FLAG pass linker-specific FLAG directly to the compiler + -Wl,FLAG + -Xlinker FLAG pass linker-specific FLAG directly to the linker + -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) + +All other options (arguments beginning with '-') are ignored. + +Every other argument is treated as a filename. Files ending in '.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in '.la', then a libtool library is created, +only library objects ('.lo' files) may be specified, and '-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created +using 'ar' and 'ranlib', or on Windows using 'lib'. + +If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file +is created, otherwise an executable program is created." + ;; + + uninstall) + $ECHO \ +"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + + *) + func_fatal_help "invalid operation mode '$opt_mode'" + ;; + esac + + echo + $ECHO "Try '$progname --help' for more information about other modes." +} + +# Now that we've collected a possible --mode arg, show help if necessary +if $opt_help; then + if test : = "$opt_help"; then + func_mode_help + else + { + func_help noexit + for opt_mode in compile link execute install finish uninstall clean; do + func_mode_help + done + } | $SED -n '1p; 2,$s/^Usage:/ or: /p' + { + func_help noexit + for opt_mode in compile link execute install finish uninstall clean; do + echo + func_mode_help + done + } | + $SED '1d + /^When reporting/,/^Report/{ + H + d + } + $x + /information about other modes/d + /more detailed .*MODE/d + s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' + fi + exit $? +fi + + +# func_mode_execute arg... +func_mode_execute () +{ + $debug_cmd + + # The first argument is the command name. + cmd=$nonopt + test -z "$cmd" && \ + func_fatal_help "you must specify a COMMAND" + + # Handle -dlopen flags immediately. + for file in $opt_dlopen; do + test -f "$file" \ + || func_fatal_help "'$file' is not a file" + + dir= + case $file in + *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "'$lib' is not a valid libtool archive" + + # Read the libtool library. + dlname= + library_names= + func_source "$file" + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && \ + func_warning "'$file' was not linked with '-export-dynamic'" + continue + fi + + func_dirname "$file" "" "." + dir=$func_dirname_result + + if test -f "$dir/$objdir/$dlname"; then + func_append dir "/$objdir" + else + if test ! -f "$dir/$dlname"; then + func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" + fi + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + func_dirname "$file" "" "." + dir=$func_dirname_result + ;; + + *) + func_warning "'-dlopen' is ignored for non-libtool libraries and objects" + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir=$absdir + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic=$magic + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -* | *.la | *.lo ) ;; + *) + # Do a test to see if this is really a libtool program. + if func_ltwrapper_script_p "$file"; then + func_source "$file" + # Transform arg to wrapped name. + file=$progdir/$program + elif func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + func_source "$func_ltwrapper_scriptname_result" + # Transform arg to wrapped name. + file=$progdir/$program + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + func_append_quoted args "$file" + done + + if $opt_dry_run; then + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" + echo "export $shlibpath_var" + fi + $ECHO "$cmd$args" + exit $EXIT_SUCCESS + else + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES + do + eval "if test \"\${save_$lt_var+set}\" = set; then + $lt_var=\$save_$lt_var; export $lt_var + else + $lt_unset $lt_var + fi" + done + + # Now prepare to actually exec the command. + exec_cmd=\$cmd$args + fi +} + +test execute = "$opt_mode" && func_mode_execute ${1+"$@"} + + +# func_mode_finish arg... +func_mode_finish () +{ + $debug_cmd + + libs= + libdirs= + admincmds= + + for opt in "$nonopt" ${1+"$@"} + do + if test -d "$opt"; then + func_append libdirs " $opt" + + elif test -f "$opt"; then + if func_lalib_unsafe_p "$opt"; then + func_append libs " $opt" + else + func_warning "'$opt' is not a valid libtool archive" + fi + + else + func_fatal_error "invalid argument '$opt'" + fi + done + + if test -n "$libs"; then + if test -n "$lt_sysroot"; then + sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` + sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" + else + sysroot_cmd= + fi + + # Remove sysroot references + if $opt_dry_run; then + for lib in $libs; do + echo "removing references to $lt_sysroot and '=' prefixes from $lib" + done + else + tmpdir=`func_mktempdir` + for lib in $libs; do + $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ + > $tmpdir/tmp-la + mv -f $tmpdir/tmp-la $lib + done + ${RM}r "$tmpdir" + fi + fi + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + func_execute_cmds "$finish_cmds" 'admincmds="$admincmds +'"$cmd"'"' + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $opt_dry_run || eval "$cmds" || func_append admincmds " + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + $opt_quiet && exit $EXIT_SUCCESS + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + $ECHO " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use the '-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the '$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the '$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $ECHO " - use the '$flag' linker flag" + fi + if test -n "$admincmds"; then + $ECHO " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" + fi + echo + + echo "See any operating system documentation about shared libraries for" + case $host in + solaris2.[6789]|solaris2.1[0-9]) + echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" + echo "pages." + ;; + *) + echo "more information, such as the ld(1) and ld.so(8) manual pages." + ;; + esac + echo "----------------------------------------------------------------------" + fi + exit $EXIT_SUCCESS +} + +test finish = "$opt_mode" && func_mode_finish ${1+"$@"} + + +# func_mode_install arg... +func_mode_install () +{ + $debug_cmd + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || + # Allow the use of GNU shtool's install command. + case $nonopt in *shtool*) :;; *) false;; esac + then + # Aesthetically quote it. + func_quote_for_eval "$nonopt" + install_prog="$func_quote_for_eval_result " + arg=$1 + shift + else + install_prog= + arg=$nonopt + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + func_quote_for_eval "$arg" + func_append install_prog "$func_quote_for_eval_result" + install_shared_prog=$install_prog + case " $install_prog " in + *[\\\ /]cp\ *) install_cp=: ;; + *) install_cp=false ;; + esac + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=false + stripme= + no_mode=: + for arg + do + arg2= + if test -n "$dest"; then + func_append files " $dest" + dest=$arg + continue + fi + + case $arg in + -d) isdir=: ;; + -f) + if $install_cp; then :; else + prev=$arg + fi + ;; + -g | -m | -o) + prev=$arg + ;; + -s) + stripme=" -s" + continue + ;; + -*) + ;; + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + if test X-m = "X$prev" && test -n "$install_override_mode"; then + arg2=$install_override_mode + no_mode=false + fi + prev= + else + dest=$arg + continue + fi + ;; + esac + + # Aesthetically quote the argument. + func_quote_for_eval "$arg" + func_append install_prog " $func_quote_for_eval_result" + if test -n "$arg2"; then + func_quote_for_eval "$arg2" + fi + func_append install_shared_prog " $func_quote_for_eval_result" + done + + test -z "$install_prog" && \ + func_fatal_help "you must specify an install program" + + test -n "$prev" && \ + func_fatal_help "the '$prev' option requires an argument" + + if test -n "$install_override_mode" && $no_mode; then + if $install_cp; then :; else + func_quote_for_eval "$install_override_mode" + func_append install_shared_prog " -m $func_quote_for_eval_result" + fi + fi + + if test -z "$files"; then + if test -z "$dest"; then + func_fatal_help "no file or destination specified" + else + func_fatal_help "you must specify a destination" + fi + fi + + # Strip any trailing slash from the destination. + func_stripname '' '/' "$dest" + dest=$func_stripname_result + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=: + if $isdir; then + destdir=$dest + destname= + else + func_dirname_and_basename "$dest" "" "." + destdir=$func_dirname_result + destname=$func_basename_result + + # Not a directory, so check to see that there is only one file specified. + set dummy $files; shift + test "$#" -gt 1 && \ + func_fatal_help "'$dest' is not a directory" + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + func_fatal_help "'$destdir' must be an absolute directory name" + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic=$magic + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + func_append staticlibs " $file" + ;; + + *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "'$file' is not a valid libtool archive" + + library_names= + old_library= + relink_command= + func_source "$file" + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) func_append current_libdirs " $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) func_append future_libdirs " $libdir" ;; + esac + fi + + func_dirname "$file" "/" "" + dir=$func_dirname_result + func_append dir "$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + test "$inst_prefix_dir" = "$destdir" && \ + func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` + fi + + func_warning "relinking '$file'" + func_show_eval "$relink_command" \ + 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' + fi + + # See the names of the shared library. + set dummy $library_names; shift + if test -n "$1"; then + realname=$1 + shift + + srcname=$realname + test -n "$relink_command" && srcname=${realname}T + + # Install the shared library and build the symlinks. + func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ + 'exit $?' + tstripme=$stripme + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + case $realname in + *.dll.a) + tstripme= + ;; + esac + ;; + os2*) + case $realname in + *_dll.a) + tstripme= + ;; + esac + ;; + esac + if test -n "$tstripme" && test -n "$striplib"; then + func_show_eval "$striplib $destdir/$realname" 'exit $?' + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + # Try 'ln -sf' first, because the 'ln' binary might depend on + # the symlink we replace! Solaris /bin/ln does not understand -f, + # so we also need to try rm && ln -s. + for linkname + do + test "$linkname" != "$realname" \ + && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" + done + fi + + # Do each command in the postinstall commands. + lib=$destdir/$realname + func_execute_cmds "$postinstall_cmds" 'exit $?' + fi + + # Install the pseudo-library for information purposes. + func_basename "$file" + name=$func_basename_result + instname=$dir/${name}i + func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' + + # Maybe install the static library, too. + test -n "$old_library" && func_append staticlibs " $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile=$destdir/$destname + else + func_basename "$file" + destfile=$func_basename_result + destfile=$destdir/$destfile + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + func_lo2o "$destfile" + staticdest=$func_lo2o_result + ;; + *.$objext) + staticdest=$destfile + destfile= + ;; + *) + func_fatal_help "cannot copy a libtool object to '$destfile'" + ;; + esac + + # Install the libtool object if requested. + test -n "$destfile" && \ + func_show_eval "$install_prog $file $destfile" 'exit $?' + + # Install the old object if enabled. + if test yes = "$build_old_libs"; then + # Deduce the name of the old-style object file. + func_lo2o "$file" + staticobj=$func_lo2o_result + func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile=$destdir/$destname + else + func_basename "$file" + destfile=$func_basename_result + destfile=$destdir/$destfile + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext= + case $file in + *.exe) + if test ! -f "$file"; then + func_stripname '' '.exe' "$file" + file=$func_stripname_result + stripped_ext=.exe + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin* | *mingw*) + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + wrapper=$func_ltwrapper_scriptname_result + else + func_stripname '' '.exe' "$file" + wrapper=$func_stripname_result + fi + ;; + *) + wrapper=$file + ;; + esac + if func_ltwrapper_script_p "$wrapper"; then + notinst_deplibs= + relink_command= + + func_source "$wrapper" + + # Check the variables that should have been set. + test -z "$generated_by_libtool_version" && \ + func_fatal_error "invalid libtool wrapper script '$wrapper'" + + finalize=: + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + func_source "$lib" + fi + libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` + if test -n "$libdir" && test ! -f "$libfile"; then + func_warning "'$lib' has not been installed in '$libdir'" + finalize=false + fi + done + + relink_command= + func_source "$wrapper" + + outputname= + if test no = "$fast_install" && test -n "$relink_command"; then + $opt_dry_run || { + if $finalize; then + tmpdir=`func_mktempdir` + func_basename "$file$stripped_ext" + file=$func_basename_result + outputname=$tmpdir/$file + # Replace the output file specification. + relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` + + $opt_quiet || { + func_quote_for_expand "$relink_command" + eval "func_echo $func_quote_for_expand_result" + } + if eval "$relink_command"; then : + else + func_error "error: relink '$file' with the above command before installing it" + $opt_dry_run || ${RM}r "$tmpdir" + continue + fi + file=$outputname + else + func_warning "cannot relink '$file'" + fi + } + else + # Install the binary that we compiled earlier. + file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + func_stripname '' '.exe' "$destfile" + destfile=$func_stripname_result + ;; + esac + ;; + esac + func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' + $opt_dry_run || if test -n "$outputname"; then + ${RM}r "$tmpdir" + fi + ;; + esac + done + + for file in $staticlibs; do + func_basename "$file" + name=$func_basename_result + + # Set up the ranlib parameters. + oldlib=$destdir/$name + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result + + func_show_eval "$install_prog \$file \$oldlib" 'exit $?' + + if test -n "$stripme" && test -n "$old_striplib"; then + func_show_eval "$old_striplib $tool_oldlib" 'exit $?' + fi + + # Do each command in the postinstall commands. + func_execute_cmds "$old_postinstall_cmds" 'exit $?' + done + + test -n "$future_libdirs" && \ + func_warning "remember to run '$progname --finish$future_libdirs'" + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + $opt_dry_run && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi +} + +test install = "$opt_mode" && func_mode_install ${1+"$@"} + + +# func_generate_dlsyms outputname originator pic_p +# Extract symbols from dlprefiles and create ${outputname}S.o with +# a dlpreopen symbol table. +func_generate_dlsyms () +{ + $debug_cmd + + my_outputname=$1 + my_originator=$2 + my_pic_p=${3-false} + my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` + my_dlsyms= + + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + my_dlsyms=${my_outputname}S.c + else + func_error "not configured to extract global symbols from dlpreopened files" + fi + fi + + if test -n "$my_dlsyms"; then + case $my_dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist=$output_objdir/$my_outputname.nm + + func_show_eval "$RM $nlist ${nlist}S ${nlist}T" + + # Parse the name list into a source file. + func_verbose "creating $output_objdir/$my_dlsyms" + + $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ +/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ +/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) +#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" +#endif + +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + +#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) + +/* External symbol declarations for the compiler. */\ +" + + if test yes = "$dlself"; then + func_verbose "generating symbol list for '$output'" + + $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` + for progfile in $progfiles; do + func_to_tool_file "$progfile" func_convert_file_msys_to_w32 + func_verbose "extracting global C symbols from '$func_to_tool_file_result'" + $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $opt_dry_run || { + eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + if test -n "$export_symbols_regex"; then + $opt_dry_run || { + eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols=$output_objdir/$outputname.exp + $opt_dry_run || { + $RM $export_symbols + eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; + esac + } + else + $opt_dry_run || { + eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + case $host in + *cygwin* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; + esac + } + fi + fi + + for dlprefile in $dlprefiles; do + func_verbose "extracting global C symbols from '$dlprefile'" + func_basename "$dlprefile" + name=$func_basename_result + case $host in + *cygwin* | *mingw* | *cegcc* ) + # if an import library, we need to obtain dlname + if func_win32_import_lib_p "$dlprefile"; then + func_tr_sh "$dlprefile" + eval "curr_lafile=\$libfile_$func_tr_sh_result" + dlprefile_dlbasename= + if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then + # Use subshell, to avoid clobbering current variable values + dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` + if test -n "$dlprefile_dlname"; then + func_basename "$dlprefile_dlname" + dlprefile_dlbasename=$func_basename_result + else + # no lafile. user explicitly requested -dlpreopen . + $sharedlib_from_linklib_cmd "$dlprefile" + dlprefile_dlbasename=$sharedlib_from_linklib_result + fi + fi + $opt_dry_run || { + if test -n "$dlprefile_dlbasename"; then + eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' + else + func_warning "Could not compute DLL name from $name" + eval '$ECHO ": $name " >> "$nlist"' + fi + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | + $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" + } + else # not an import lib + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + fi + ;; + *) + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + ;; + esac + done + + $opt_dry_run || { + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $MV "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if $GREP -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + $GREP -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' + else + echo '/* NONE */' >> "$output_objdir/$my_dlsyms" + fi + + func_show_eval '$RM "${nlist}I"' + if test -n "$global_symbol_to_import"; then + eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' + fi + + echo >> "$output_objdir/$my_dlsyms" "\ + +/* The mapping between symbol names and symbols. */ +typedef struct { + const char *name; + void *address; +} lt_dlsymlist; +extern LT_DLSYM_CONST lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[];\ +" + + if test -s "$nlist"I; then + echo >> "$output_objdir/$my_dlsyms" "\ +static void lt_syminit(void) +{ + LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; + for (; symbol->name; ++symbol) + {" + $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" + echo >> "$output_objdir/$my_dlsyms" "\ + } +}" + fi + echo >> "$output_objdir/$my_dlsyms" "\ +LT_DLSYM_CONST lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[] = +{ {\"$my_originator\", (void *) 0}," + + if test -s "$nlist"I; then + echo >> "$output_objdir/$my_dlsyms" "\ + {\"@INIT@\", (void *) <_syminit}," + fi + + case $need_lib_prefix in + no) + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + *) + eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + esac + echo >> "$output_objdir/$my_dlsyms" "\ + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_${my_prefix}_LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + } # !$opt_dry_run + + pic_flag_for_symtable= + case "$compile_command " in + *" -static "*) ;; + *) + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; + *-*-hpux*) + pic_flag_for_symtable=" $pic_flag" ;; + *) + $my_pic_p && pic_flag_for_symtable=" $pic_flag" + ;; + esac + ;; + esac + symtab_cflags= + for arg in $LTCFLAGS; do + case $arg in + -pie | -fpie | -fPIE) ;; + *) func_append symtab_cflags " $arg" ;; + esac + done + + # Now compile the dynamic symbol file. + func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' + + # Clean up the generated files. + func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' + + # Transform the symbol file into the correct name. + symfileobj=$output_objdir/${my_outputname}S.$objext + case $host in + *cygwin* | *mingw* | *cegcc* ) + if test -f "$output_objdir/$my_outputname.def"; then + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + else + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + fi + ;; + *) + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + ;; + esac + ;; + *) + func_fatal_error "unknown suffix for '$my_dlsyms'" + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` + fi +} + +# func_cygming_gnu_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is a GNU/binutils-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_gnu_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` + test -n "$func_cygming_gnu_implib_tmp" +} + +# func_cygming_ms_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is an MS-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_ms_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` + test -n "$func_cygming_ms_implib_tmp" +} + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +# Despite the name, also deal with 64 bit binaries. +func_win32_libid () +{ + $debug_cmd + + win32_libid_type=unknown + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | + $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then + case $nm_interface in + "MS dumpbin") + if func_cygming_ms_implib_p "$1" || + func_cygming_gnu_implib_p "$1" + then + win32_nmres=import + else + win32_nmres= + fi + ;; + *) + func_to_tool_file "$1" func_convert_file_msys_to_w32 + win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | + $SED -n -e ' + 1,100{ + / I /{ + s|.*|import| + p + q + } + }'` + ;; + esac + case $win32_nmres in + import*) win32_libid_type="x86 archive import";; + *) win32_libid_type="x86 archive static";; + esac + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $ECHO "$win32_libid_type" +} + +# func_cygming_dll_for_implib ARG +# +# Platform-specific function to extract the +# name of the DLL associated with the specified +# import library ARG. +# Invoked by eval'ing the libtool variable +# $sharedlib_from_linklib_cmd +# Result is available in the variable +# $sharedlib_from_linklib_result +func_cygming_dll_for_implib () +{ + $debug_cmd + + sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` +} + +# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs +# +# The is the core of a fallback implementation of a +# platform-specific function to extract the name of the +# DLL associated with the specified import library LIBNAME. +# +# SECTION_NAME is either .idata$6 or .idata$7, depending +# on the platform and compiler that created the implib. +# +# Echos the name of the DLL associated with the +# specified import library. +func_cygming_dll_for_implib_fallback_core () +{ + $debug_cmd + + match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` + $OBJDUMP -s --section "$1" "$2" 2>/dev/null | + $SED '/^Contents of section '"$match_literal"':/{ + # Place marker at beginning of archive member dllname section + s/.*/====MARK====/ + p + d + } + # These lines can sometimes be longer than 43 characters, but + # are always uninteresting + /:[ ]*file format pe[i]\{,1\}-/d + /^In archive [^:]*:/d + # Ensure marker is printed + /^====MARK====/p + # Remove all lines with less than 43 characters + /^.\{43\}/!d + # From remaining lines, remove first 43 characters + s/^.\{43\}//' | + $SED -n ' + # Join marker and all lines until next marker into a single line + /^====MARK====/ b para + H + $ b para + b + :para + x + s/\n//g + # Remove the marker + s/^====MARK====// + # Remove trailing dots and whitespace + s/[\. \t]*$// + # Print + /./p' | + # we now have a list, one entry per line, of the stringified + # contents of the appropriate section of all members of the + # archive that possess that section. Heuristic: eliminate + # all those that have a first or second character that is + # a '.' (that is, objdump's representation of an unprintable + # character.) This should work for all archives with less than + # 0x302f exports -- but will fail for DLLs whose name actually + # begins with a literal '.' or a single character followed by + # a '.'. + # + # Of those that remain, print the first one. + $SED -e '/^\./d;/^.\./d;q' +} + +# func_cygming_dll_for_implib_fallback ARG +# Platform-specific function to extract the +# name of the DLL associated with the specified +# import library ARG. +# +# This fallback implementation is for use when $DLLTOOL +# does not support the --identify-strict option. +# Invoked by eval'ing the libtool variable +# $sharedlib_from_linklib_cmd +# Result is available in the variable +# $sharedlib_from_linklib_result +func_cygming_dll_for_implib_fallback () +{ + $debug_cmd + + if func_cygming_gnu_implib_p "$1"; then + # binutils import library + sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` + elif func_cygming_ms_implib_p "$1"; then + # ms-generated import library + sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` + else + # unknown + sharedlib_from_linklib_result= + fi +} + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + $debug_cmd + + f_ex_an_ar_dir=$1; shift + f_ex_an_ar_oldlib=$1 + if test yes = "$lock_old_archive_extraction"; then + lockfile=$f_ex_an_ar_oldlib.lock + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + fi + func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ + 'stat=$?; rm -f "$lockfile"; exit $stat' + if test yes = "$lock_old_archive_extraction"; then + $opt_dry_run || rm -f "$lockfile" + fi + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" + fi +} + + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + $debug_cmd + + my_gentop=$1; shift + my_oldlibs=${1+"$@"} + my_oldobjs= + my_xlib= + my_xabs= + my_xdir= + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + func_basename "$my_xlib" + my_xlib=$func_basename_result + my_xlib_u=$my_xlib + while :; do + case " $extracted_archives " in + *" $my_xlib_u "*) + func_arith $extracted_serial + 1 + extracted_serial=$func_arith_result + my_xlib_u=lt$extracted_serial-$my_xlib ;; + *) break ;; + esac + done + extracted_archives="$extracted_archives $my_xlib_u" + my_xdir=$my_gentop/$my_xlib_u + + func_mkdir_p "$my_xdir" + + case $host in + *-darwin*) + func_verbose "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + $opt_dry_run || { + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + func_basename "$darwin_archive" + darwin_base_archive=$func_basename_result + darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` + if test -n "$darwin_arches"; then + darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches; do + func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" + $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" + cd "unfat-$$/$darwin_base_archive-$darwin_arch" + func_extract_an_archive "`pwd`" "$darwin_base_archive" + cd "$darwin_curdir" + $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" + done # $darwin_arches + ## Okay now we've a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` + $LIPO -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + $RM -rf unfat-$$ + cd "$darwin_orig_dir" + else + cd $darwin_orig_dir + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + } # !$opt_dry_run + ;; + *) + func_extract_an_archive "$my_xdir" "$my_xabs" + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` + done + + func_extract_archives_result=$my_oldobjs +} + + +# func_emit_wrapper [arg=no] +# +# Emit a libtool wrapper script on stdout. +# Don't directly open a file because we may want to +# incorporate the script contents within a cygwin/mingw +# wrapper executable. Must ONLY be called from within +# func_mode_link because it depends on a number of variables +# set therein. +# +# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR +# variable will take. If 'yes', then the emitted script +# will assume that the directory where it is stored is +# the $objdir directory. This is a cygwin/mingw-specific +# behavior. +func_emit_wrapper () +{ + func_emit_wrapper_arg1=${1-no} + + $ECHO "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM (GNU $PACKAGE) $VERSION +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='$sed_quote_subst' + +# Be Bourne compatible +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variables: + generated_by_libtool_version='$macro_version' + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$ECHO are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + file=\"\$0\"" + + qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` + $ECHO "\ + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF' +} + ECHO=\"$qECHO\" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ that is used only on +# windows platforms, and (c) all begin with the string "--lt-" +# (application programs are unlikely to have options that match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's $0 value, followed by "$@". +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=\$0 + shift + for lt_opt + do + case \"\$lt_opt\" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` + test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. + lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` + cat \"\$lt_dump_D/\$lt_dump_F\" + exit 0 + ;; + --lt-*) + \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n \"\$lt_option_debug\"; then + echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" + lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2* | *-cegcc*) + $ECHO "\ + if test -n \"\$lt_option_debug\"; then + \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 + func_lt_dump_args \${1+\"\$@\"} 1>&2 + fi + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $ECHO "\ + if test -n \"\$lt_option_debug\"; then + \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 + func_lt_dump_args \${1+\"\$@\"} 1>&2 + fi + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $ECHO "\ + \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from \$@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case \" \$* \" in + *\\ --lt-*) + for lt_wr_arg + do + case \$lt_wr_arg in + --lt-*) ;; + *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; + esac + shift + done ;; + esac + func_exec_program_core \${1+\"\$@\"} +} + + # Parse options + func_parse_lt_options \"\$0\" \${1+\"\$@\"} + + # Find the directory that this script lives in. + thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 + if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then + # special case for '.' + if test \"\$thisdir\" = \".\"; then + thisdir=\`pwd\` + fi + # remove .libs from thisdir + case \"\$thisdir\" in + *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; + $objdir ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test yes = "$fast_install"; then + $ECHO "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $MKDIR \"\$progdir\" + else + $RM \"\$progdir/\$file\" + fi" + + $ECHO "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + \$ECHO \"\$relink_command_output\" >&2 + $RM \"\$progdir/\$file\" + exit 1 + fi + fi + + $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $RM \"\$progdir/\$program\"; + $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $RM \"\$progdir/\$file\" + fi" + else + $ECHO "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $ECHO "\ + + if test -f \"\$progdir/\$program\"; then" + + # fixup the dll searchpath if we need to. + # + # Fix the DLL searchpath if we need to. Do this before prepending + # to shlibpath, because on Windows, both are PATH and uninstalled + # libraries must come first. + if test -n "$dllsearchpath"; then + $ECHO "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + # Export our shlibpath_var if we have one. + if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $ECHO "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` + + export $shlibpath_var +" + fi + + $ECHO "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. + func_exec_program \${1+\"\$@\"} + fi + else + # The program doesn't exist. + \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 + \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 + \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" +} + + +# func_emit_cwrapperexe_src +# emit the source code for a wrapper executable on stdout +# Must ONLY be called from within func_mode_link because +# it depends on a number of variable set therein. +func_emit_cwrapperexe_src () +{ + cat < +#include +#ifdef _MSC_VER +# include +# include +# include +#else +# include +# include +# ifdef __CYGWIN__ +# include +# endif +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) + +/* declarations of non-ANSI functions */ +#if defined __MINGW32__ +# ifdef __STRICT_ANSI__ +int _putenv (const char *); +# endif +#elif defined __CYGWIN__ +# ifdef __STRICT_ANSI__ +char *realpath (const char *, char *); +int putenv (char *); +int setenv (const char *, const char *, int); +# endif +/* #elif defined other_platform || defined ... */ +#endif + +/* portability defines, excluding path handling macros */ +#if defined _MSC_VER +# define setmode _setmode +# define stat _stat +# define chmod _chmod +# define getcwd _getcwd +# define putenv _putenv +# define S_IXUSR _S_IEXEC +#elif defined __MINGW32__ +# define setmode _setmode +# define stat _stat +# define chmod _chmod +# define getcwd _getcwd +# define putenv _putenv +#elif defined __CYGWIN__ +# define HAVE_SETENV +# define FOPEN_WB "wb" +/* #elif defined other platforms ... */ +#endif + +#if defined PATH_MAX +# define LT_PATHMAX PATH_MAX +#elif defined MAXPATHLEN +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef S_IXOTH +# define S_IXOTH 0 +#endif +#ifndef S_IXGRP +# define S_IXGRP 0 +#endif + +/* path handling portability macros */ +#ifndef DIR_SEPARATOR +# define DIR_SEPARATOR '/' +# define PATH_SEPARATOR ':' +#endif + +#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ + defined __OS2__ +# define HAVE_DOS_BASED_FILE_SYSTEM +# define FOPEN_WB "wb" +# ifndef DIR_SEPARATOR_2 +# define DIR_SEPARATOR_2 '\\' +# endif +# ifndef PATH_SEPARATOR_2 +# define PATH_SEPARATOR_2 ';' +# endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#ifndef PATH_SEPARATOR_2 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) +#else /* PATH_SEPARATOR_2 */ +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) +#endif /* PATH_SEPARATOR_2 */ + +#ifndef FOPEN_WB +# define FOPEN_WB "w" +#endif +#ifndef _O_BINARY +# define _O_BINARY 0 +#endif + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free (stale); stale = 0; } \ +} while (0) + +#if defined LT_DEBUGWRAPPER +static int lt_debug = 1; +#else +static int lt_debug = 0; +#endif + +const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ + +void *xmalloc (size_t num); +char *xstrdup (const char *string); +const char *base_name (const char *name); +char *find_executable (const char *wrapper); +char *chase_symlinks (const char *pathspec); +int make_executable (const char *path); +int check_executable (const char *path); +char *strendzap (char *str, const char *pat); +void lt_debugprintf (const char *file, int line, const char *fmt, ...); +void lt_fatal (const char *file, int line, const char *message, ...); +static const char *nonnull (const char *s); +static const char *nonempty (const char *s); +void lt_setenv (const char *name, const char *value); +char *lt_extend_str (const char *orig_value, const char *add, int to_end); +void lt_update_exe_path (const char *name, const char *value); +void lt_update_lib_path (const char *name, const char *value); +char **prepare_spawn (char **argv); +void lt_dump_script (FILE *f); +EOF + + cat <= 0) + && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) + return 1; + else + return 0; +} + +int +make_executable (const char *path) +{ + int rval = 0; + struct stat st; + + lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", + nonempty (path)); + if ((!path) || (!*path)) + return 0; + + if (stat (path, &st) >= 0) + { + rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); + } + return rval; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise + Does not chase symlinks, even on platforms that support them. +*/ +char * +find_executable (const char *wrapper) +{ + int has_slash = 0; + const char *p; + const char *p_next; + /* static buffer for getcwd */ + char tmp[LT_PATHMAX + 1]; + size_t tmp_len; + char *concat_name; + + lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", + nonempty (wrapper)); + + if ((wrapper == NULL) || (*wrapper == '\0')) + return NULL; + + /* Absolute path? */ +#if defined HAVE_DOS_BASED_FILE_SYSTEM + if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + else + { +#endif + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } +#if defined HAVE_DOS_BASED_FILE_SYSTEM + } +#endif + + for (p = wrapper; *p; p++) + if (*p == '/') + { + has_slash = 1; + break; + } + if (!has_slash) + { + /* no slashes; search PATH */ + const char *path = getenv ("PATH"); + if (path != NULL) + { + for (p = path; *p; p = p_next) + { + const char *q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR (*q)) + break; + p_len = (size_t) (q - p); + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", + nonnull (strerror (errno))); + tmp_len = strlen (tmp); + concat_name = + XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = + XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + } + /* not found in PATH; assume curdir */ + } + /* Relative path | not found in path: prepend cwd */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", + nonnull (strerror (errno))); + tmp_len = strlen (tmp); + concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + return NULL; +} + +char * +chase_symlinks (const char *pathspec) +{ +#ifndef S_ISLNK + return xstrdup (pathspec); +#else + char buf[LT_PATHMAX]; + struct stat s; + char *tmp_pathspec = xstrdup (pathspec); + char *p; + int has_symlinks = 0; + while (strlen (tmp_pathspec) && !has_symlinks) + { + lt_debugprintf (__FILE__, __LINE__, + "checking path component for symlinks: %s\n", + tmp_pathspec); + if (lstat (tmp_pathspec, &s) == 0) + { + if (S_ISLNK (s.st_mode) != 0) + { + has_symlinks = 1; + break; + } + + /* search backwards for last DIR_SEPARATOR */ + p = tmp_pathspec + strlen (tmp_pathspec) - 1; + while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + p--; + if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + { + /* no more DIR_SEPARATORS left */ + break; + } + *p = '\0'; + } + else + { + lt_fatal (__FILE__, __LINE__, + "error accessing file \"%s\": %s", + tmp_pathspec, nonnull (strerror (errno))); + } + } + XFREE (tmp_pathspec); + + if (!has_symlinks) + { + return xstrdup (pathspec); + } + + tmp_pathspec = realpath (pathspec, buf); + if (tmp_pathspec == 0) + { + lt_fatal (__FILE__, __LINE__, + "could not follow symlinks for %s", pathspec); + } + return xstrdup (tmp_pathspec); +#endif +} + +char * +strendzap (char *str, const char *pat) +{ + size_t len, patlen; + + assert (str != NULL); + assert (pat != NULL); + + len = strlen (str); + patlen = strlen (pat); + + if (patlen <= len) + { + str += len - patlen; + if (STREQ (str, pat)) + *str = '\0'; + } + return str; +} + +void +lt_debugprintf (const char *file, int line, const char *fmt, ...) +{ + va_list args; + if (lt_debug) + { + (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); + va_start (args, fmt); + (void) vfprintf (stderr, fmt, args); + va_end (args); + } +} + +static void +lt_error_core (int exit_status, const char *file, + int line, const char *mode, + const char *message, va_list ap) +{ + fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *file, int line, const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); + va_end (ap); +} + +static const char * +nonnull (const char *s) +{ + return s ? s : "(null)"; +} + +static const char * +nonempty (const char *s) +{ + return (s && !*s) ? "(empty)" : nonnull (s); +} + +void +lt_setenv (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_setenv) setting '%s' to '%s'\n", + nonnull (name), nonnull (value)); + { +#ifdef HAVE_SETENV + /* always make a copy, for consistency with !HAVE_SETENV */ + char *str = xstrdup (value); + setenv (name, str, 1); +#else + size_t len = strlen (name) + 1 + strlen (value) + 1; + char *str = XMALLOC (char, len); + sprintf (str, "%s=%s", name, value); + if (putenv (str) != EXIT_SUCCESS) + { + XFREE (str); + } +#endif + } +} + +char * +lt_extend_str (const char *orig_value, const char *add, int to_end) +{ + char *new_value; + if (orig_value && *orig_value) + { + size_t orig_value_len = strlen (orig_value); + size_t add_len = strlen (add); + new_value = XMALLOC (char, add_len + orig_value_len + 1); + if (to_end) + { + strcpy (new_value, orig_value); + strcpy (new_value + orig_value_len, add); + } + else + { + strcpy (new_value, add); + strcpy (new_value + add_len, orig_value); + } + } + else + { + new_value = xstrdup (add); + } + return new_value; +} + +void +lt_update_exe_path (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", + nonnull (name), nonnull (value)); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + /* some systems can't cope with a ':'-terminated path #' */ + size_t len = strlen (new_value); + while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) + { + new_value[--len] = '\0'; + } + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +void +lt_update_lib_path (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", + nonnull (name), nonnull (value)); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +EOF + case $host_os in + mingw*) + cat <<"EOF" + +/* Prepares an argument vector before calling spawn(). + Note that spawn() does not by itself call the command interpreter + (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : + ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&v); + v.dwPlatformId == VER_PLATFORM_WIN32_NT; + }) ? "cmd.exe" : "command.com"). + Instead it simply concatenates the arguments, separated by ' ', and calls + CreateProcess(). We must quote the arguments since Win32 CreateProcess() + interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a + special way: + - Space and tab are interpreted as delimiters. They are not treated as + delimiters if they are surrounded by double quotes: "...". + - Unescaped double quotes are removed from the input. Their only effect is + that within double quotes, space and tab are treated like normal + characters. + - Backslashes not followed by double quotes are not special. + - But 2*n+1 backslashes followed by a double quote become + n backslashes followed by a double quote (n >= 0): + \" -> " + \\\" -> \" + \\\\\" -> \\" + */ +#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +char ** +prepare_spawn (char **argv) +{ + size_t argc; + char **new_argv; + size_t i; + + /* Count number of arguments. */ + for (argc = 0; argv[argc] != NULL; argc++) + ; + + /* Allocate new argument vector. */ + new_argv = XMALLOC (char *, argc + 1); + + /* Put quoted arguments into the new argument vector. */ + for (i = 0; i < argc; i++) + { + const char *string = argv[i]; + + if (string[0] == '\0') + new_argv[i] = xstrdup ("\"\""); + else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) + { + int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); + size_t length; + unsigned int backslashes; + const char *s; + char *quoted_string; + char *p; + + length = 0; + backslashes = 0; + if (quote_around) + length++; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + length += backslashes + 1; + length++; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + length += backslashes + 1; + + quoted_string = XMALLOC (char, length + 1); + + p = quoted_string; + backslashes = 0; + if (quote_around) + *p++ = '"'; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + { + unsigned int j; + for (j = backslashes + 1; j > 0; j--) + *p++ = '\\'; + } + *p++ = c; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + { + unsigned int j; + for (j = backslashes; j > 0; j--) + *p++ = '\\'; + *p++ = '"'; + } + *p = '\0'; + + new_argv[i] = quoted_string; + } + else + new_argv[i] = (char *) string; + } + new_argv[argc] = NULL; + + return new_argv; +} +EOF + ;; + esac + + cat <<"EOF" +void lt_dump_script (FILE* f) +{ +EOF + func_emit_wrapper yes | + $SED -n -e ' +s/^\(.\{79\}\)\(..*\)/\1\ +\2/ +h +s/\([\\"]\)/\\\1/g +s/$/\\n/ +s/\([^\n]*\).*/ fputs ("\1", f);/p +g +D' + cat <<"EOF" +} +EOF +} +# end: func_emit_cwrapperexe_src + +# func_win32_import_lib_p ARG +# True if ARG is an import lib, as indicated by $file_magic_cmd +func_win32_import_lib_p () +{ + $debug_cmd + + case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in + *import*) : ;; + *) false ;; + esac +} + +# func_suncc_cstd_abi +# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! +# Several compiler flags select an ABI that is incompatible with the +# Cstd library. Avoid specifying it if any are in CXXFLAGS. +func_suncc_cstd_abi () +{ + $debug_cmd + + case " $compile_command " in + *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) + suncc_use_cstd_abi=no + ;; + *) + suncc_use_cstd_abi=yes + ;; + esac +} + +# func_mode_link arg... +func_mode_link () +{ + $debug_cmd + + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # what system we are compiling for in order to pass an extra + # flag for every libtool invocation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll that has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args=$nonopt + base_compile="$nonopt $@" + compile_command=$nonopt + finalize_command=$nonopt + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + inst_prefix_dir= + new_inherited_linker_flags= + + avoid_version=no + bindir= + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + no_install=no + objs= + os2dllname= + non_pic_objects= + precious_files_regex= + prefer_static_libs=no + preload=false + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + vinfo_number=no + weak_libs= + single_module=$wl-single_module + func_infer_tag $base_compile + + # We need to know -static, to get the right output filenames. + for arg + do + case $arg in + -shared) + test yes != "$build_libtool_libs" \ + && func_fatal_configuration "cannot build a shared library" + build_old_libs=no + break + ;; + -all-static | -static | -static-libtool-libs) + case $arg in + -all-static) + if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then + func_warning "complete static linking is impossible in this configuration" + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + -static) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=built + ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + esac + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg=$1 + shift + func_quote_for_eval "$arg" + qarg=$func_quote_for_eval_unquoted_result + func_append libtool_args " $func_quote_for_eval_result" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + func_append compile_command " @OUTPUT@" + func_append finalize_command " @OUTPUT@" + ;; + esac + + case $prev in + bindir) + bindir=$arg + prev= + continue + ;; + dlfiles|dlprefiles) + $preload || { + # Add the symbol object into the linking commands. + func_append compile_command " @SYMFILE@" + func_append finalize_command " @SYMFILE@" + preload=: + } + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test no = "$dlself"; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test dlprefiles = "$prev"; then + dlself=yes + elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test dlfiles = "$prev"; then + func_append dlfiles " $arg" + else + func_append dlprefiles " $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols=$arg + test -f "$arg" \ + || func_fatal_error "symbol file '$arg' does not exist" + prev= + continue + ;; + expsyms_regex) + export_symbols_regex=$arg + prev= + continue + ;; + framework) + case $host in + *-*-darwin*) + case "$deplibs " in + *" $qarg.ltframework "*) ;; + *) func_append deplibs " $qarg.ltframework" # this is fixed later + ;; + esac + ;; + esac + prev= + continue + ;; + inst_prefix) + inst_prefix_dir=$arg + prev= + continue + ;; + mllvm) + # Clang does not use LLVM to link, so we can simply discard any + # '-mllvm $arg' options when doing the link step. + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat "$save_arg"` + do +# func_append moreargs " $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test none = "$pic_object" && + test none = "$non_pic_object"; then + func_fatal_error "cannot find name of object for '$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + if test none != "$pic_object"; then + # Prepend the subdirectory the object is found in. + pic_object=$xdir$pic_object + + if test dlfiles = "$prev"; then + if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then + func_append dlfiles " $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test dlprefiles = "$prev"; then + # Preload the old-style object. + func_append dlprefiles " $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg=$pic_object + fi + + # Non-PIC object. + if test none != "$non_pic_object"; then + # Prepend the subdirectory the object is found in. + non_pic_object=$xdir$non_pic_object + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test none = "$pic_object"; then + arg=$non_pic_object + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object=$pic_object + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "'$arg' is not a valid libtool object" + fi + fi + done + else + func_fatal_error "link input file '$arg' does not exist" + fi + arg=$save_arg + prev= + continue + ;; + os2dllname) + os2dllname=$arg + prev= + continue + ;; + precious_regex) + precious_files_regex=$arg + prev= + continue + ;; + release) + release=-$arg + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + if test rpath = "$prev"; then + case "$rpath " in + *" $arg "*) ;; + *) func_append rpath " $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) func_append xrpath " $arg" ;; + esac + fi + prev= + continue + ;; + shrext) + shrext_cmds=$arg + prev= + continue + ;; + weak) + func_append weak_libs " $arg" + prev= + continue + ;; + xcclinker) + func_append linker_flags " $qarg" + func_append compiler_flags " $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xcompiler) + func_append compiler_flags " $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xlinker) + func_append linker_flags " $qarg" + func_append compiler_flags " $wl$qarg" + prev= + func_append compile_command " $wl$qarg" + func_append finalize_command " $wl$qarg" + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg=$arg + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + # See comment for -static flag below, for more details. + func_append compile_command " $link_static_flag" + func_append finalize_command " $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + func_fatal_error "'-allow-undefined' must not be used because it is the default" + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -bindir) + prev=bindir + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + func_fatal_error "more than one -exported-symbols argument is not allowed" + fi + if test X-export-symbols = "X$arg"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -framework) + prev=framework + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + func_append compile_command " $arg" + func_append finalize_command " $arg" + ;; + esac + continue + ;; + + -L*) + func_stripname "-L" '' "$arg" + if test -z "$func_stripname_result"; then + if test "$#" -gt 0; then + func_fatal_error "require no space between '-L' and '$1'" + else + func_fatal_error "need path for '-L' option" + fi + fi + func_resolve_sysroot "$func_stripname_result" + dir=$func_resolve_sysroot_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + test -z "$absdir" && \ + func_fatal_error "cannot determine absolute directory name of '$dir'" + dir=$absdir + ;; + esac + case "$deplibs " in + *" -L$dir "* | *" $arg "*) + # Will only happen for absolute or sysroot arguments + ;; + *) + # Preserve sysroot, but never include relative directories + case $dir in + [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; + *) func_append deplibs " -L$dir" ;; + esac + func_append lib_search_path " $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; + ::) dllsearchpath=$dir;; + *) func_append dllsearchpath ":$dir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) func_append dllsearchpath ":$testbindir";; + esac + ;; + esac + continue + ;; + + -l*) + if test X-lc = "X$arg" || test X-lm = "X$arg"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-os2*) + # These systems don't actually have a C library (as such) + test X-lc = "X$arg" && continue + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + # Do not include libc due to us having libc/libc_r. + test X-lc = "X$arg" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + func_append deplibs " System.ltframework" + continue + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + test X-lc = "X$arg" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test X-lc = "X$arg" && continue + ;; + esac + elif test X-lc_r = "X$arg"; then + case $host in + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + func_append deplibs " $arg" + continue + ;; + + -mllvm) + prev=mllvm + continue + ;; + + -module) + module=yes + continue + ;; + + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + # Darwin uses the -arch flag to determine output architecture. + -model|-arch|-isysroot|--sysroot) + func_append compiler_flags " $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + prev=xcompiler + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + func_append compiler_flags " $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case "$new_inherited_linker_flags " in + *" $arg "*) ;; + * ) func_append new_inherited_linker_flags " $arg" ;; + esac + continue + ;; + + -multi_module) + single_module=$wl-multi_module + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + func_warning "'-no-install' is ignored for $host" + func_warning "assuming '-no-fast-install' instead" + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -os2dllname) + prev=os2dllname + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + func_stripname '-R' '' "$arg" + dir=$func_stripname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + =*) + func_stripname '=' '' "$dir" + dir=$lt_sysroot$func_stripname_result + ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) func_append xrpath " $dir" ;; + esac + continue + ;; + + -shared) + # The effects of -shared are defined in a previous loop. + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -static | -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -weak) + prev=weak + continue + ;; + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs=$IFS; IFS=, + for flag in $args; do + IFS=$save_ifs + func_quote_for_eval "$flag" + func_append arg " $func_quote_for_eval_result" + func_append compiler_flags " $func_quote_for_eval_result" + done + IFS=$save_ifs + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Wl,*) + func_stripname '-Wl,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs=$IFS; IFS=, + for flag in $args; do + IFS=$save_ifs + func_quote_for_eval "$flag" + func_append arg " $wl$func_quote_for_eval_result" + func_append compiler_flags " $wl$func_quote_for_eval_result" + func_append linker_flags " $func_quote_for_eval_result" + done + IFS=$save_ifs + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # -msg_* for osf cc + -msg_*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + + # Flags to be passed through unchanged, with rationale: + # -64, -mips[0-9] enable 64-bit mode for the SGI compiler + # -r[0-9][0-9]* specify processor for the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler + # +DA*, +DD* enable 64-bit mode for the HP compiler + # -q* compiler args for the IBM compiler + # -m*, -t[45]*, -txscale* architecture-specific flags for GCC + # -F/path path to uninstalled frameworks, gcc on darwin + # -p, -pg, --coverage, -fprofile-* profiling flags for GCC + # -fstack-protector* stack protector flags for GCC + # @file GCC response files + # -tp=* Portland pgcc target processor selection + # --sysroot=* for sysroot support + # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + # -stdlib=* select c++ std lib with clang + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + func_append compile_command " $arg" + func_append finalize_command " $arg" + func_append compiler_flags " $arg" + continue + ;; + + -Z*) + if test os2 = "`expr $host : '.*\(os2\)'`"; then + # OS/2 uses -Zxxx to specify OS/2-specific options + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case $arg in + -Zlinker | -Zstack) + prev=xcompiler + ;; + esac + continue + else + # Otherwise treat like 'Some other compiler flag' below + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + fi + ;; + + # Some other compiler flag. + -* | +*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + + *.$objext) + # A standard object. + func_append objs " $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test none = "$pic_object" && + test none = "$non_pic_object"; then + func_fatal_error "cannot find name of object for '$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + test none = "$pic_object" || { + # Prepend the subdirectory the object is found in. + pic_object=$xdir$pic_object + + if test dlfiles = "$prev"; then + if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then + func_append dlfiles " $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test dlprefiles = "$prev"; then + # Preload the old-style object. + func_append dlprefiles " $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg=$pic_object + } + + # Non-PIC object. + if test none != "$non_pic_object"; then + # Prepend the subdirectory the object is found in. + non_pic_object=$xdir$non_pic_object + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test none = "$pic_object"; then + arg=$non_pic_object + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object=$pic_object + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "'$arg' is not a valid libtool object" + fi + fi + ;; + + *.$libext) + # An archive. + func_append deplibs " $arg" + func_append old_deplibs " $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + func_resolve_sysroot "$arg" + if test dlfiles = "$prev"; then + # This library was specified with -dlopen. + func_append dlfiles " $func_resolve_sysroot_result" + prev= + elif test dlprefiles = "$prev"; then + # The library was specified with -dlpreopen. + func_append dlprefiles " $func_resolve_sysroot_result" + prev= + else + func_append deplibs " $func_resolve_sysroot_result" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + done # argument parsing loop + + test -n "$prev" && \ + func_fatal_help "the '$prevarg' option requires an argument" + + if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + func_basename "$output" + outputname=$func_basename_result + libobjs_save=$libobjs + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + # Definition is injected by LT_CONFIG during libtool generation. + func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" + + func_dirname "$output" "/" "" + output_objdir=$func_dirname_result$objdir + func_to_tool_file "$output_objdir/" + tool_output_objdir=$func_to_tool_file_result + # Create the object directory. + func_mkdir_p "$output_objdir" + + # Determine the type of output + case $output in + "") + func_fatal_help "you must specify an output file" + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if $opt_preserve_dup_deps; then + case "$libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append libs " $deplib" + done + + if test lib = "$linkmode"; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if $opt_duplicate_compiler_generated_deps; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; + esac + func_append pre_post_deps " $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + + case $linkmode in + lib) + passes="conv dlpreopen link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=false + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + + for pass in $passes; do + # The preopen pass in lib mode reverses $deplibs; put it back here + # so that -L comes before libs that need it for instance... + if test lib,link = "$linkmode,$pass"; then + ## FIXME: Find the place where the list is rebuilt in the wrong + ## order, and fix it there properly + tmp_deplibs= + for deplib in $deplibs; do + tmp_deplibs="$deplib $tmp_deplibs" + done + deplibs=$tmp_deplibs + fi + + if test lib,link = "$linkmode,$pass" || + test prog,scan = "$linkmode,$pass"; then + libs=$deplibs + deplibs= + fi + if test prog = "$linkmode"; then + case $pass in + dlopen) libs=$dlfiles ;; + dlpreopen) libs=$dlprefiles ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test lib,dlpreopen = "$linkmode,$pass"; then + # Collect and forward deplibs of preopened libtool libs + for lib in $dlprefiles; do + # Ignore non-libtool-libs + dependency_libs= + func_resolve_sysroot "$lib" + case $lib in + *.la) func_source "$func_resolve_sysroot_result" ;; + esac + + # Collect preopened libtool deplibs, except any this library + # has declared as weak libs + for deplib in $dependency_libs; do + func_basename "$deplib" + deplib_base=$func_basename_result + case " $weak_libs " in + *" $deplib_base "*) ;; + *) func_append deplibs " $deplib" ;; + esac + done + done + libs=$dlprefiles + fi + if test dlopen = "$pass"; then + # Collect dlpreopened libraries + save_deplibs=$deplibs + deplibs= + fi + + for deplib in $libs; do + lib= + found=false + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + func_append compiler_flags " $deplib" + if test lib = "$linkmode"; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) func_append new_inherited_linker_flags " $deplib" ;; + esac + fi + fi + continue + ;; + -l*) + if test lib != "$linkmode" && test prog != "$linkmode"; then + func_warning "'-l' is ignored for archives/objects" + continue + fi + func_stripname '-l' '' "$deplib" + name=$func_stripname_result + if test lib = "$linkmode"; then + searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" + else + searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" + fi + for searchdir in $searchdirs; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib=$searchdir/lib$name$search_ext + if test -f "$lib"; then + if test .la = "$search_ext"; then + found=: + else + found=false + fi + break 2 + fi + done + done + if $found; then + # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + case " $predeps $postdeps " in + *" $deplib "*) + if func_lalib_p "$lib"; then + library_names= + old_library= + func_source "$lib" + for l in $old_library $library_names; do + ll=$l + done + if test "X$ll" = "X$old_library"; then # only static version available + found=false + func_dirname "$lib" "" "." + ladir=$func_dirname_result + lib=$ladir/$old_library + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + else + # deplib doesn't seem to be a libtool library + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + ;; # -l + *.ltframework) + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + if test lib = "$linkmode"; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) func_append new_inherited_linker_flags " $deplib" ;; + esac + fi + fi + continue + ;; + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test conv = "$pass" && continue + newdependency_libs="$deplib $newdependency_libs" + func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + prog) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + continue + fi + if test scan = "$pass"; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + *) + func_warning "'-L' is ignored for archives/objects" + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test link = "$pass"; then + func_stripname '-R' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + dir=$func_resolve_sysroot_result + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) func_append xrpath " $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) + func_resolve_sysroot "$deplib" + lib=$func_resolve_sysroot_result + ;; + *.$libext) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + # Linking convenience modules into shared libraries is allowed, + # but linking other static libraries is non-portable. + case " $dlpreconveniencelibs " in + *" $deplib "*) ;; + *) + valid_a_lib=false + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=: + fi + ;; + pass_all) + valid_a_lib=: + ;; + esac + if $valid_a_lib; then + echo + $ECHO "*** Warning: Linking the shared library $output against the" + $ECHO "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + else + echo + $ECHO "*** Warning: Trying to link with static lib archive $deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because the file extensions .$libext of this argument makes me believe" + echo "*** that it is just a static archive that I should not use here." + fi + ;; + esac + continue + ;; + prog) + if test link != "$pass"; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + elif test prog = "$linkmode"; then + if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + func_append newdlprefiles " $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + func_append newdlfiles " $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=: + continue + ;; + esac # case $deplib + + $found || test -f "$lib" \ + || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$lib" \ + || func_fatal_error "'$lib' is not a valid libtool archive" + + func_dirname "$lib" "" "." + ladir=$func_dirname_result + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + inherited_linker_flags= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + avoidtemprpath= + + + # Read the .la file + func_source "$lib" + + # Convert "-framework foo" to "foo.ltframework" + if test -n "$inherited_linker_flags"; then + tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` + for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do + case " $new_inherited_linker_flags " in + *" $tmp_inherited_linker_flag "*) ;; + *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; + esac + done + fi + dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + if test lib,link = "$linkmode,$pass" || + test prog,scan = "$linkmode,$pass" || + { test prog != "$linkmode" && test lib != "$linkmode"; }; then + test -n "$dlopen" && func_append dlfiles " $dlopen" + test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" + fi + + if test conv = "$pass"; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + func_fatal_error "cannot find name of link library for '$lib'" + fi + # It is a libtool convenience library, so add in its objects. + func_append convenience " $ladir/$objdir/$old_library" + func_append old_convenience " $ladir/$objdir/$old_library" + elif test prog != "$linkmode" && test lib != "$linkmode"; then + func_fatal_error "'$lib' is not a convenience library" + fi + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append tmp_libs " $deplib" + done + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + if test -n "$old_library" && + { test yes = "$prefer_static_libs" || + test built,no = "$prefer_static_libs,$installed"; }; then + linklib=$old_library + else + for l in $old_library $library_names; do + linklib=$l + done + fi + if test -z "$linklib"; then + func_fatal_error "cannot find name of link library for '$lib'" + fi + + # This library was specified with -dlopen. + if test dlopen = "$pass"; then + test -z "$libdir" \ + && func_fatal_error "cannot -dlopen a convenience library: '$lib'" + if test -z "$dlname" || + test yes != "$dlopen_support" || + test no = "$build_libtool_libs" + then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + func_append dlprefiles " $lib $dependency_libs" + else + func_append newdlfiles " $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + func_warning "cannot determine absolute directory name of '$ladir'" + func_warning "passing it literally to the linker, although it might fail" + abs_ladir=$ladir + fi + ;; + esac + func_basename "$lib" + laname=$func_basename_result + + # Find the relevant object directory and library name. + if test yes = "$installed"; then + if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + func_warning "library '$lib' was moved." + dir=$ladir + absdir=$abs_ladir + libdir=$abs_ladir + else + dir=$lt_sysroot$libdir + absdir=$lt_sysroot$libdir + fi + test yes = "$hardcode_automatic" && avoidtemprpath=yes + else + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir=$ladir + absdir=$abs_ladir + # Remove this search path later + func_append notinst_path " $abs_ladir" + else + dir=$ladir/$objdir + absdir=$abs_ladir/$objdir + # Remove this search path later + func_append notinst_path " $abs_ladir" + fi + fi # $installed = yes + func_stripname 'lib' '.la' "$laname" + name=$func_stripname_result + + # This library was specified with -dlpreopen. + if test dlpreopen = "$pass"; then + if test -z "$libdir" && test prog = "$linkmode"; then + func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" + fi + case $host in + # special handling for platforms with PE-DLLs. + *cygwin* | *mingw* | *cegcc* ) + # Linker will automatically link against shared library if both + # static and shared are present. Therefore, ensure we extract + # symbols from the import library if a shared library is present + # (otherwise, the dlopen module name will be incorrect). We do + # this by putting the import library name into $newdlprefiles. + # We recover the dlopen module name by 'saving' the la file + # name in a special purpose variable, and (later) extracting the + # dlname from the la file. + if test -n "$dlname"; then + func_tr_sh "$dir/$linklib" + eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" + func_append newdlprefiles " $dir/$linklib" + else + func_append newdlprefiles " $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + func_append dlpreconveniencelibs " $dir/$old_library" + fi + ;; + * ) + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + func_append newdlprefiles " $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + func_append dlpreconveniencelibs " $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + func_append newdlprefiles " $dir/$dlname" + else + func_append newdlprefiles " $dir/$linklib" + fi + ;; + esac + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test lib = "$linkmode"; then + deplibs="$dir/$old_library $deplibs" + elif test prog,link = "$linkmode,$pass"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test prog = "$linkmode" && test link != "$pass"; then + func_append newlib_search_path " $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=false + if test no != "$link_all_deplibs" || test -z "$library_names" || + test no = "$build_libtool_libs"; then + linkalldeplibs=: + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + esac + # Need to link against all dependency_libs? + if $linkalldeplibs; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append tmp_libs " $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test prog,link = "$linkmode,$pass"; then + if test -n "$library_names" && + { { test no = "$prefer_static_libs" || + test built,yes = "$prefer_static_libs,$installed"; } || + test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then + # Make sure the rpath contains only unique directories. + case $temp_rpath: in + *"$absdir:"*) ;; + *) func_append temp_rpath "$absdir:" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) func_append compile_rpath " $absdir" ;; + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if $alldeplibs && + { test pass_all = "$deplibs_check_method" || + { test yes = "$build_libtool_libs" && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + use_static_libs=$prefer_static_libs + if test built = "$use_static_libs" && test yes = "$installed"; then + use_static_libs=no + fi + if test -n "$library_names" && + { test no = "$use_static_libs" || test -z "$old_library"; }; then + case $host in + *cygwin* | *mingw* | *cegcc* | *os2*) + # No point in relinking DLLs because paths are not encoded + func_append notinst_deplibs " $lib" + need_relink=no + ;; + *) + if test no = "$installed"; then + func_append notinst_deplibs " $lib" + need_relink=yes + fi + ;; + esac + # This is a shared library + + # Warn about portability, can't link against -module's on some + # systems (darwin). Don't bleat about dlopened modules though! + dlopenmodule= + for dlpremoduletest in $dlprefiles; do + if test "X$dlpremoduletest" = "X$lib"; then + dlopenmodule=$dlpremoduletest + break + fi + done + if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then + echo + if test prog = "$linkmode"; then + $ECHO "*** Warning: Linking the executable $output against the loadable module" + else + $ECHO "*** Warning: Linking the shared library $output against the loadable module" + fi + $ECHO "*** $linklib is not portable!" + fi + if test lib = "$linkmode" && + test yes = "$hardcode_into_libs"; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) func_append compile_rpath " $absdir" ;; + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + shift + realname=$1 + shift + libname=`eval "\\$ECHO \"$libname_spec\""` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname=$dlname + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw* | *cegcc* | *os2*) + func_arith $current - $age + major=$func_arith_result + versuffix=-$major + ;; + esac + eval soname=\"$soname_spec\" + else + soname=$realname + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot=$soname + func_basename "$soroot" + soname=$func_basename_result + func_stripname 'lib' '.dll' "$soname" + newlib=libimp-$func_stripname_result.a + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + func_verbose "extracting exported symbol list from '$soname'" + func_execute_cmds "$extract_expsyms_cmds" 'exit $?' + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + func_verbose "generating import library for '$soname'" + func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test prog = "$linkmode" || test relink != "$opt_mode"; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test no = "$hardcode_direct"; then + add=$dir/$linklib + case $host in + *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; + *-*-sysv4*uw2*) add_dir=-L$dir ;; + *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ + *-*-unixware7*) add_dir=-L$dir ;; + *-*-darwin* ) + # if the lib is a (non-dlopened) module then we cannot + # link against it, someone is ignoring the earlier warnings + if /usr/bin/file -L $add 2> /dev/null | + $GREP ": [^:]* bundle" >/dev/null; then + if test "X$dlopenmodule" != "X$lib"; then + $ECHO "*** Warning: lib $linklib is a module, not a shared library" + if test -z "$old_library"; then + echo + echo "*** And there doesn't seem to be a static archive available" + echo "*** The link will probably fail, sorry" + else + add=$dir/$old_library + fi + elif test -n "$old_library"; then + add=$dir/$old_library + fi + fi + esac + elif test no = "$hardcode_minus_L"; then + case $host in + *-*-sunos*) add_shlibpath=$dir ;; + esac + add_dir=-L$dir + add=-l$name + elif test no = "$hardcode_shlibpath_var"; then + add_shlibpath=$dir + add=-l$name + else + lib_linked=no + fi + ;; + relink) + if test yes = "$hardcode_direct" && + test no = "$hardcode_direct_absolute"; then + add=$dir/$linklib + elif test yes = "$hardcode_minus_L"; then + add_dir=-L$absdir + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + func_append add_dir " -L$inst_prefix_dir$libdir" + ;; + esac + fi + add=-l$name + elif test yes = "$hardcode_shlibpath_var"; then + add_shlibpath=$dir + add=-l$name + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test yes != "$lib_linked"; then + func_fatal_configuration "unsupported hardcode properties" + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) func_append compile_shlibpath "$add_shlibpath:" ;; + esac + fi + if test prog = "$linkmode"; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test yes != "$hardcode_direct" && + test yes != "$hardcode_minus_L" && + test yes = "$hardcode_shlibpath_var"; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) func_append finalize_shlibpath "$libdir:" ;; + esac + fi + fi + fi + + if test prog = "$linkmode" || test relink = "$opt_mode"; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test yes = "$hardcode_direct" && + test no = "$hardcode_direct_absolute"; then + add=$libdir/$linklib + elif test yes = "$hardcode_minus_L"; then + add_dir=-L$libdir + add=-l$name + elif test yes = "$hardcode_shlibpath_var"; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) func_append finalize_shlibpath "$libdir:" ;; + esac + add=-l$name + elif test yes = "$hardcode_automatic"; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib"; then + add=$inst_prefix_dir$libdir/$linklib + else + add=$libdir/$linklib + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir=-L$libdir + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + func_append add_dir " -L$inst_prefix_dir$libdir" + ;; + esac + fi + add=-l$name + fi + + if test prog = "$linkmode"; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test prog = "$linkmode"; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test unsupported != "$hardcode_direct"; then + test -n "$old_library" && linklib=$old_library + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test yes = "$build_libtool_libs"; then + # Not a shared library + if test pass_all != "$deplibs_check_method"; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + echo + $ECHO "*** Warning: This system cannot link to static lib archive $lib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + if test yes = "$module"; then + echo "*** But as you try to build a module library, libtool will still create " + echo "*** a static module, that should work as long as the dlopening application" + echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using 'nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** 'nm' from GNU binutils and a full rebuild may help." + fi + if test no = "$build_old_libs"; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test lib = "$linkmode"; then + if test -n "$dependency_libs" && + { test yes != "$hardcode_into_libs" || + test yes = "$build_old_libs" || + test yes = "$link_static"; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) func_stripname '-R' '' "$libdir" + temp_xrpath=$func_stripname_result + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) func_append xrpath " $temp_xrpath";; + esac;; + *) func_append temp_deplibs " $libdir";; + esac + done + dependency_libs=$temp_deplibs + fi + + func_append newlib_search_path " $absdir" + # Link against this library + test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result";; + *) func_resolve_sysroot "$deplib" ;; + esac + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $func_resolve_sysroot_result "*) + func_append specialdeplibs " $func_resolve_sysroot_result" ;; + esac + fi + func_append tmp_libs " $func_resolve_sysroot_result" + done + + if test no != "$link_all_deplibs"; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + path= + case $deplib in + -L*) path=$deplib ;; + *.la) + func_resolve_sysroot "$deplib" + deplib=$func_resolve_sysroot_result + func_dirname "$deplib" "" "." + dir=$func_dirname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + func_warning "cannot determine absolute directory name of '$dir'" + absdir=$dir + fi + ;; + esac + if $GREP "^installed=no" $deplib > /dev/null; then + case $host in + *-*-darwin*) + depdepl= + eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names"; then + for tmp in $deplibrary_names; do + depdepl=$tmp + done + if test -f "$absdir/$objdir/$depdepl"; then + depdepl=$absdir/$objdir/$depdepl + darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + if test -z "$darwin_install_name"; then + darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + fi + func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" + func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" + path= + fi + fi + ;; + *) + path=-L$absdir/$objdir + ;; + esac + else + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "'$deplib' is not a valid libtool archive" + test "$absdir" != "$libdir" && \ + func_warning "'$deplib' seems to be moved" + + path=-L$absdir + fi + ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + if test link = "$pass"; then + if test prog = "$linkmode"; then + compile_deplibs="$new_inherited_linker_flags $compile_deplibs" + finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" + else + compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + fi + fi + dependency_libs=$newdependency_libs + if test dlpreopen = "$pass"; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test dlopen != "$pass"; then + test conv = "$pass" || { + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) func_append lib_search_path " $dir" ;; + esac + done + newlib_search_path= + } + + if test prog,link = "$linkmode,$pass"; then + vars="compile_deplibs finalize_deplibs" + else + vars=deplibs + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) func_append tmp_libs " $deplib" ;; + esac + ;; + *) func_append tmp_libs " $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + + # Add Sun CC postdeps if required: + test CXX = "$tagname" && { + case $host_os in + linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C++ 5.9 + func_suncc_cstd_abi + + if test no != "$suncc_use_cstd_abi"; then + func_append postdeps ' -library=Cstd -library=Crun' + fi + ;; + esac + ;; + + solaris*) + func_cc_basename "$CC" + case $func_cc_basename_result in + CC* | sunCC*) + func_suncc_cstd_abi + + if test no != "$suncc_use_cstd_abi"; then + func_append postdeps ' -library=Cstd -library=Crun' + fi + ;; + esac + ;; + esac + } + + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i= + ;; + esac + if test -n "$i"; then + func_append tmp_libs " $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test prog = "$linkmode"; then + dlfiles=$newdlfiles + fi + if test prog = "$linkmode" || test lib = "$linkmode"; then + dlprefiles=$newdlprefiles + fi + + case $linkmode in + oldlib) + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + func_warning "'-dlopen' is ignored for archives" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "'-l' and '-L' are ignored for archives" ;; + esac + + test -n "$rpath" && \ + func_warning "'-rpath' is ignored for archives" + + test -n "$xrpath" && \ + func_warning "'-R' is ignored for archives" + + test -n "$vinfo" && \ + func_warning "'-version-info/-version-number' is ignored for archives" + + test -n "$release" && \ + func_warning "'-release' is ignored for archives" + + test -n "$export_symbols$export_symbols_regex" && \ + func_warning "'-export-symbols' is ignored for archives" + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs=$output + func_append objs "$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form 'libNAME.la'. + case $outputname in + lib*) + func_stripname 'lib' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + test no = "$module" \ + && func_fatal_help "libtool library '$output' must begin with 'lib'" + + if test no != "$need_lib_prefix"; then + # Add the "lib" prefix for modules if required + func_stripname '' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + func_stripname '' '.la' "$outputname" + libname=$func_stripname_result + fi + ;; + esac + + if test -n "$objs"; then + if test pass_all != "$deplibs_check_method"; then + func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" + else + echo + $ECHO "*** Warning: Linking the shared library $output against the non-libtool" + $ECHO "*** objects $objs is not portable!" + func_append libobjs " $objs" + fi + fi + + test no = "$dlself" \ + || func_warning "'-dlopen self' is ignored for libtool libraries" + + set dummy $rpath + shift + test 1 -lt "$#" \ + && func_warning "ignoring multiple '-rpath's for a libtool library" + + install_libdir=$1 + + oldlibs= + if test -z "$rpath"; then + if test yes = "$build_libtool_libs"; then + # Building a libtool convenience library. + # Some compilers have problems with a '.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + test -n "$vinfo" && \ + func_warning "'-version-info/-version-number' is ignored for convenience libraries" + + test -n "$release" && \ + func_warning "'-release' is ignored for convenience libraries" + else + + # Parse the version information argument. + save_ifs=$IFS; IFS=: + set dummy $vinfo 0 0 0 + shift + IFS=$save_ifs + + test -n "$7" && \ + func_fatal_help "too many parameters to '-version-info'" + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major=$1 + number_minor=$2 + number_revision=$3 + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # that has an extra 1 added just for fun + # + case $version_type in + # correct linux to gnu/linux during the next big refactor + darwin|freebsd-elf|linux|osf|windows|none) + func_arith $number_major + $number_minor + current=$func_arith_result + age=$number_minor + revision=$number_revision + ;; + freebsd-aout|qnx|sunos) + current=$number_major + revision=$number_minor + age=0 + ;; + irix|nonstopux) + func_arith $number_major + $number_minor + current=$func_arith_result + age=$number_minor + revision=$number_minor + lt_irix_increment=no + ;; + esac + ;; + no) + current=$1 + revision=$2 + age=$3 + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "CURRENT '$current' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + case $revision in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "REVISION '$revision' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + case $age in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "AGE '$age' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + if test "$age" -gt "$current"; then + func_error "AGE '$age' is greater than the current interface number '$current'" + func_fatal_error "'$vinfo' is not valid version information" + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + # Darwin ld doesn't like 0 for these options... + func_arith $current + 1 + minor_current=$func_arith_result + xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + # On Darwin other compilers + case $CC in + nagfor*) + verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + ;; + *) + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + esac + ;; + + freebsd-aout) + major=.$current + versuffix=.$current.$revision + ;; + + freebsd-elf) + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + ;; + + irix | nonstopux) + if test no = "$lt_irix_increment"; then + func_arith $current - $age + else + func_arith $current - $age + 1 + fi + major=$func_arith_result + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring=$verstring_prefix$major.$revision + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test 0 -ne "$loop"; do + func_arith $revision - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring=$verstring_prefix$major.$iface:$verstring + done + + # Before this point, $major must not contain '.'. + major=.$major + versuffix=$major.$revision + ;; + + linux) # correct to gnu/linux during the next big refactor + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + ;; + + osf) + func_arith $current - $age + major=.$func_arith_result + versuffix=.$current.$age.$revision + verstring=$current.$age.$revision + + # Add in all the interfaces that we are compatible with. + loop=$age + while test 0 -ne "$loop"; do + func_arith $current - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring=$verstring:$iface.0 + done + + # Make executables depend on our current version. + func_append verstring ":$current.0" + ;; + + qnx) + major=.$current + versuffix=.$current + ;; + + sco) + major=.$current + versuffix=.$current + ;; + + sunos) + major=.$current + versuffix=.$current.$revision + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 file systems. + func_arith $current - $age + major=$func_arith_result + versuffix=-$major + ;; + + *) + func_fatal_configuration "unknown library version type '$version_type'" + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring=0.0 + ;; + esac + if test no = "$need_version"; then + versuffix= + else + versuffix=.0.0 + fi + fi + + # Remove version info from name if versioning should be avoided + if test yes,no = "$avoid_version,$need_version"; then + major= + versuffix= + verstring= + fi + + # Check to see if the archive will have undefined symbols. + if test yes = "$allow_undefined"; then + if test unsupported = "$allow_undefined_flag"; then + if test yes = "$build_old_libs"; then + func_warning "undefined symbols not allowed in $host shared libraries; building static only" + build_libtool_libs=no + else + func_fatal_error "can't build $host shared library unless -no-undefined is specified" + fi + fi + else + # Don't allow undefined symbols. + allow_undefined_flag=$no_undefined_flag + fi + + fi + + func_generate_dlsyms "$libname" "$libname" : + func_append libobjs " $symfileobj" + test " " = "$libobjs" && libobjs= + + if test relink != "$opt_mode"; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$ECHO "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext | *.gcno) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) + if test -n "$precious_files_regex"; then + if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + func_append removelist " $p" + ;; + *) ;; + esac + done + test -n "$removelist" && \ + func_show_eval "${RM}r \$removelist" + fi + + # Now set the variables for building old libraries. + if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then + func_append oldlibs " $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + #for path in $notinst_path; do + # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` + # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` + # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` + #done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + func_replace_sysroot "$libdir" + func_append temp_xrpath " -R$func_replace_sysroot_result" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + done + if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles=$dlfiles + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) func_append dlfiles " $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles=$dlprefiles + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) func_append dlprefiles " $lib" ;; + esac + done + + if test yes = "$build_libtool_libs"; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + func_append deplibs " System.ltframework" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test yes = "$build_libtool_need_lc"; then + func_append deplibs " -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release= + versuffix= + major= + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $opt_dry_run || $RM conftest.c + cat > conftest.c </dev/null` + $nocaseglob + else + potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` + fi + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null | + $GREP " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib=$potent_lib + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | $SED 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; + *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | + $SED -e 10q | + $EGREP "$file_magic_regex" > /dev/null; then + func_append newdeplibs " $a_deplib" + a_deplib= + break 2 + fi + done + done + fi + if test -n "$a_deplib"; then + droppeddeps=yes + echo + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib"; then + $ECHO "*** with $libname but no candidates were found. (...for file magic test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a file magic. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + func_append newdeplibs " $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + for a_deplib in $deplibs; do + case $a_deplib in + -l*) + func_stripname -l '' "$a_deplib" + name=$func_stripname_result + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + case " $predeps $postdeps " in + *" $a_deplib "*) + func_append newdeplibs " $a_deplib" + a_deplib= + ;; + esac + fi + if test -n "$a_deplib"; then + libname=`eval "\\$ECHO \"$libname_spec\""` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib=$potent_lib # see symlink-check above in file_magic test + if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ + $EGREP "$match_pattern_regex" > /dev/null; then + func_append newdeplibs " $a_deplib" + a_deplib= + break 2 + fi + done + done + fi + if test -n "$a_deplib"; then + droppeddeps=yes + echo + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib"; then + $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a regex pattern. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + func_append newdeplibs " $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs= + tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + for i in $predeps $postdeps; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` + done + fi + case $tmp_deplibs in + *[!\ \ ]*) + echo + if test none = "$deplibs_check_method"; then + echo "*** Warning: inter-library dependencies are not supported in this platform." + else + echo "*** Warning: inter-library dependencies are not known to be supported." + fi + echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + ;; + esac + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library with the System framework + newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` + ;; + esac + + if test yes = "$droppeddeps"; then + if test yes = "$module"; then + echo + echo "*** Warning: libtool could not satisfy all declared inter-library" + $ECHO "*** dependencies of module $libname. Therefore, libtool will create" + echo "*** a static module, that should work as long as the dlopening" + echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using 'nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** 'nm' from GNU binutils and a full rebuild may help." + fi + if test no = "$build_old_libs"; then + oldlibs=$output_objdir/$libname.$libext + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + echo "*** The inter-library dependencies that have been dropped here will be" + echo "*** automatically added whenever a program is linked with this library" + echo "*** or is declared to -dlopen it." + + if test no = "$allow_undefined"; then + echo + echo "*** Since this library must not contain undefined symbols," + echo "*** because either the platform does not support them or" + echo "*** it was explicitly requested with -no-undefined," + echo "*** libtool will only create a static version of it." + if test no = "$build_old_libs"; then + oldlibs=$output_objdir/$libname.$libext + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + case $host in + *-*-darwin*) + newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $deplibs " in + *" -L$path/$objdir "*) + func_append new_libs " -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) func_append new_libs " $deplib" ;; + esac + ;; + *) func_append new_libs " $deplib" ;; + esac + done + deplibs=$new_libs + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test yes = "$build_libtool_libs"; then + # Remove $wl instances when linking with ld. + # FIXME: should test the right _cmds variable. + case $archive_cmds in + *\$LD\ *) wl= ;; + esac + if test yes = "$hardcode_into_libs"; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath=$finalize_rpath + test relink = "$opt_mode" || rpath=$compile_rpath$rpath + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + func_replace_sysroot "$libdir" + libdir=$func_replace_sysroot_result + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append dep_rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) func_append perm_rpath " $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + func_append rpath "$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath=$finalize_shlibpath + test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext_cmds\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + shift + realname=$1 + shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname=$realname + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib=$output_objdir/$realname + linknames= + for link + do + func_append linknames " $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` + test "X$libobjs" = "X " && libobjs= + + delfiles= + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" + export_symbols=$output_objdir/$libname.uexp + func_append delfiles " $export_symbols" + fi + + orig_export_symbols= + case $host_os in + cygwin* | mingw* | cegcc*) + if test -n "$export_symbols" && test -z "$export_symbols_regex"; then + # exporting using user supplied symfile + func_dll_def_p "$export_symbols" || { + # and it's NOT already a .def file. Must figure out + # which of the given symbols are data symbols and tag + # them as such. So, trigger use of export_symbols_cmds. + # export_symbols gets reassigned inside the "prepare + # the list of exported symbols" if statement, so the + # include_expsyms logic still works. + orig_export_symbols=$export_symbols + export_symbols= + always_export_symbols=yes + } + fi + ;; + esac + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then + func_verbose "generating symbol list for '$libname.la'" + export_symbols=$output_objdir/$libname.exp + $opt_dry_run || $RM $export_symbols + cmds=$export_symbols_cmds + save_ifs=$IFS; IFS='~' + for cmd1 in $cmds; do + IFS=$save_ifs + # Take the normal branch if the nm_file_list_spec branch + # doesn't work or if tool conversion is not needed. + case $nm_file_list_spec~$to_tool_file_cmd in + *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) + try_normal_branch=yes + eval cmd=\"$cmd1\" + func_len " $cmd" + len=$func_len_result + ;; + *) + try_normal_branch=no + ;; + esac + if test yes = "$try_normal_branch" \ + && { test "$len" -lt "$max_cmd_len" \ + || test "$max_cmd_len" -le -1; } + then + func_show_eval "$cmd" 'exit $?' + skipped_export=false + elif test -n "$nm_file_list_spec"; then + func_basename "$output" + output_la=$func_basename_result + save_libobjs=$libobjs + save_output=$output + output=$output_objdir/$output_la.nm + func_to_tool_file "$output" + libobjs=$nm_file_list_spec$func_to_tool_file_result + func_append delfiles " $output" + func_verbose "creating $NM input file list: $output" + for obj in $save_libobjs; do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" + done > "$output" + eval cmd=\"$cmd1\" + func_show_eval "$cmd" 'exit $?' + output=$save_output + libobjs=$save_libobjs + skipped_export=false + else + # The command line is too long to execute in one step. + func_verbose "using reloadable object file for export list..." + skipped_export=: + # Break out early, otherwise skipped_export may be + # set to false by a later but shorter cmd. + break + fi + done + IFS=$save_ifs + if test -n "$export_symbols_regex" && test : != "$skipped_export"; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols=$export_symbols + test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols + $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' + fi + + if test : != "$skipped_export" && test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for '$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands, which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + func_append delfiles " $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + func_append tmp_deplibs " $test_deplib" + ;; + esac + done + deplibs=$tmp_deplibs + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec" && + test yes = "$compiler_needs_object" && + test -z "$libobjs"; then + # extract the archives, so we have objects to list. + # TODO: could optimize this to just extract one archive. + whole_archive_flag_spec= + fi + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + else + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $convenience + func_append libobjs " $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + fi + + if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + func_append linker_flags " $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test relink = "$opt_mode"; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test yes = "$module" && test -n "$module_cmds"; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test : != "$skipped_export" && + func_len " $test_cmds" && + len=$func_len_result && + test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise + # or, if using GNU ld and skipped_export is not :, use a linker + # script. + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + func_basename "$output" + output_la=$func_basename_result + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + last_robj= + k=1 + + if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then + output=$output_objdir/$output_la.lnkscript + func_verbose "creating GNU ld script: $output" + echo 'INPUT (' > $output + for obj in $save_libobjs + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" >> $output + done + echo ')' >> $output + func_append delfiles " $output" + func_to_tool_file "$output" + output=$func_to_tool_file_result + elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then + output=$output_objdir/$output_la.lnk + func_verbose "creating linker input file list: $output" + : > $output + set x $save_libobjs + shift + firstobj= + if test yes = "$compiler_needs_object"; then + firstobj="$1 " + shift + fi + for obj + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" >> $output + done + func_append delfiles " $output" + func_to_tool_file "$output" + output=$firstobj\"$file_list_spec$func_to_tool_file_result\" + else + if test -n "$save_libobjs"; then + func_verbose "creating reloadable object files..." + output=$output_objdir/$output_la-$k.$objext + eval test_cmds=\"$reload_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + if test -z "$objlist" || + test "$len" -lt "$max_cmd_len"; then + func_append objlist " $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test 1 -eq "$k"; then + # The first file doesn't have a previous command to add. + reload_objs=$objlist + eval concat_cmds=\"$reload_cmds\" + else + # All subsequent reloadable object files will link in + # the last one created. + reload_objs="$objlist $last_robj" + eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" + fi + last_robj=$output_objdir/$output_la-$k.$objext + func_arith $k + 1 + k=$func_arith_result + output=$output_objdir/$output_la-$k.$objext + objlist=" $obj" + func_len " $last_robj" + func_arith $len0 + $func_len_result + len=$func_arith_result + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + reload_objs="$objlist $last_robj" + eval concat_cmds=\"\$concat_cmds$reload_cmds\" + if test -n "$last_robj"; then + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" + fi + func_append delfiles " $output" + + else + output= + fi + + ${skipped_export-false} && { + func_verbose "generating symbol list for '$libname.la'" + export_symbols=$output_objdir/$libname.exp + $opt_dry_run || $RM $export_symbols + libobjs=$output + # Append the command to create the export file. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" + if test -n "$last_robj"; then + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" + fi + } + + test -n "$save_libobjs" && + func_verbose "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs=$IFS; IFS='~' + for cmd in $concat_cmds; do + IFS=$save_ifs + $opt_quiet || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS=$save_ifs + + if test -n "$export_symbols_regex" && ${skipped_export-false}; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + + ${skipped_export-false} && { + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols=$export_symbols + test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols + $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' + fi + + if test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for '$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands, which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + func_append delfiles " $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + } + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test yes = "$module" && test -n "$module_cmds"; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + fi + + if test -n "$delfiles"; then + # Append the command to remove temporary files to $cmds. + eval cmds=\"\$cmds~\$RM $delfiles\" + fi + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $dlprefiles + func_append libobjs " $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + + save_ifs=$IFS; IFS='~' + for cmd in $cmds; do + IFS=$sp$nl + eval cmd=\"$cmd\" + IFS=$save_ifs + $opt_quiet || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS=$save_ifs + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? + + if test -n "$convenience"; then + if test -z "$whole_archive_flag_spec"; then + func_show_eval '${RM}r "$gentop"' + fi + fi + + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test yes = "$module" || test yes = "$export_dynamic"; then + # On all known operating systems, these are identical. + dlname=$soname + fi + fi + ;; + + obj) + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + func_warning "'-dlopen' is ignored for objects" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "'-l' and '-L' are ignored for objects" ;; + esac + + test -n "$rpath" && \ + func_warning "'-rpath' is ignored for objects" + + test -n "$xrpath" && \ + func_warning "'-R' is ignored for objects" + + test -n "$vinfo" && \ + func_warning "'-version-info' is ignored for objects" + + test -n "$release" && \ + func_warning "'-release' is ignored for objects" + + case $output in + *.lo) + test -n "$objs$old_deplibs" && \ + func_fatal_error "cannot build library object '$output' from non-libtool objects" + + libobj=$output + func_lo2o "$libobj" + obj=$func_lo2o_result + ;; + *) + libobj= + obj=$output + ;; + esac + + # Delete the old objects. + $opt_dry_run || $RM $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # if reload_cmds runs $LD directly, get rid of -Wl from + # whole_archive_flag_spec and hope we can get by with turning comma + # into space. + case $reload_cmds in + *\$LD[\ \$]*) wl= ;; + esac + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" + test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` + reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags + else + gentop=$output_objdir/${obj}x + func_append generated " $gentop" + + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" + fi + fi + + # If we're not building shared, we need to use non_pic_objs + test yes = "$build_libtool_libs" || libobjs=$non_pic_objects + + # Create the old-style object. + reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs + + output=$obj + func_execute_cmds "$reload_cmds" 'exit $?' + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + fi + + test yes = "$build_libtool_libs" || { + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? + exit $EXIT_SUCCESS + } + + if test -n "$pic_flag" || test default != "$pic_mode"; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output=$libobj + func_execute_cmds "$reload_cmds" 'exit $?' + fi + + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) func_stripname '' '.exe' "$output" + output=$func_stripname_result.exe;; + esac + test -n "$vinfo" && \ + func_warning "'-version-info' is ignored for programs" + + test -n "$release" && \ + func_warning "'-release' is ignored for programs" + + $preload \ + && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ + && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` + finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` + ;; + esac + + case $host in + *-*-darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + # But is supposedly fixed on 10.4 or later (yay!). + if test CXX = "$tagname"; then + case ${MACOSX_DEPLOYMENT_TARGET-10.0} in + 10.[0123]) + func_append compile_command " $wl-bind_at_load" + func_append finalize_command " $wl-bind_at_load" + ;; + esac + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $compile_deplibs " in + *" -L$path/$objdir "*) + func_append new_libs " -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $compile_deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) func_append new_libs " $deplib" ;; + esac + ;; + *) func_append new_libs " $deplib" ;; + esac + done + compile_deplibs=$new_libs + + + func_append compile_command " $compile_deplibs" + func_append finalize_command " $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) func_append perm_rpath " $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; + ::) dllsearchpath=$libdir;; + *) func_append dllsearchpath ":$libdir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) func_append dllsearchpath ":$testbindir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath=$rpath + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) func_append finalize_perm_rpath " $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath=$rpath + + if test -n "$libobjs" && test yes = "$build_old_libs"; then + # Transform all the library objects into standard objects. + compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` + finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` + fi + + func_generate_dlsyms "$outputname" "@PROGRAM@" false + + # template prelinking step + if test -n "$prelink_cmds"; then + func_execute_cmds "$prelink_cmds" 'exit $?' + fi + + wrappers_required=: + case $host in + *cegcc* | *mingw32ce*) + # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. + wrappers_required=false + ;; + *cygwin* | *mingw* ) + test yes = "$build_libtool_libs" || wrappers_required=false + ;; + *) + if test no = "$need_relink" || test yes != "$build_libtool_libs"; then + wrappers_required=false + fi + ;; + esac + $wrappers_required || { + # Replace the output file specification. + compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + link_command=$compile_command$compile_rpath + + # We have no uninstalled library dependencies, so finalize right now. + exit_status=0 + func_show_eval "$link_command" 'exit_status=$?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + # Delete the generated files. + if test -f "$output_objdir/${outputname}S.$objext"; then + func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' + fi + + exit $exit_status + } + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + func_append rpath "$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + func_append rpath "$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test yes = "$no_install"; then + # We don't need to create a wrapper script. + link_command=$compile_var$compile_command$compile_rpath + # Replace the output file specification. + link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $opt_dry_run || $RM $output + # Link the executable and exit + func_show_eval "$link_command" 'exit $?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + exit $EXIT_SUCCESS + fi + + case $hardcode_action,$fast_install in + relink,*) + # Fast installation is not supported + link_command=$compile_var$compile_command$compile_rpath + relink_command=$finalize_var$finalize_command$finalize_rpath + + func_warning "this platform does not like uninstalled shared libraries" + func_warning "'$output' will be relinked during installation" + ;; + *,yes) + link_command=$finalize_var$compile_command$finalize_rpath + relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` + ;; + *,no) + link_command=$compile_var$compile_command$compile_rpath + relink_command=$finalize_var$finalize_command$finalize_rpath + ;; + *,needless) + link_command=$finalize_var$compile_command$finalize_rpath + relink_command= + ;; + esac + + # Replace the output file specification. + link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname + + func_show_eval "$link_command" 'exit $?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output_objdir/$outputname" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + # Now create the wrapper script. + func_verbose "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + fi + + # Only actually do things if not in dry run mode. + $opt_dry_run || { + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) func_stripname '' '.exe' "$output" + output=$func_stripname_result ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + func_stripname '' '.exe' "$outputname" + outputname=$func_stripname_result ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + func_dirname_and_basename "$output" "" "." + output_name=$func_basename_result + output_path=$func_dirname_result + cwrappersource=$output_path/$objdir/lt-$output_name.c + cwrapper=$output_path/$output_name.exe + $RM $cwrappersource $cwrapper + trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + func_emit_cwrapperexe_src > $cwrappersource + + # The wrapper executable is built using the $host compiler, + # because it contains $host paths and files. If cross- + # compiling, it, like the target executable, must be + # executed on the $host or under an emulation environment. + $opt_dry_run || { + $LTCC $LTCFLAGS -o $cwrapper $cwrappersource + $STRIP $cwrapper + } + + # Now, create the wrapper script for func_source use: + func_ltwrapper_scriptname $cwrapper + $RM $func_ltwrapper_scriptname_result + trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 + $opt_dry_run || { + # note: this script will not be executed, so do not chmod. + if test "x$build" = "x$host"; then + $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result + else + func_emit_wrapper no > $func_ltwrapper_scriptname_result + fi + } + ;; + * ) + $RM $output + trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 + + func_emit_wrapper no > $output + chmod +x $output + ;; + esac + } + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + case $build_libtool_libs in + convenience) + oldobjs="$libobjs_save $symfileobj" + addlibs=$convenience + build_libtool_libs=no + ;; + module) + oldobjs=$libobjs_save + addlibs=$old_convenience + build_libtool_libs=no + ;; + *) + oldobjs="$old_deplibs $non_pic_objects" + $preload && test -f "$symfileobj" \ + && func_append oldobjs " $symfileobj" + addlibs=$old_convenience + ;; + esac + + if test -n "$addlibs"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $addlibs + func_append oldobjs " $func_extract_archives_result" + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then + cmds=$old_archive_from_new_cmds + else + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $dlprefiles + func_append oldobjs " $func_extract_archives_result" + fi + + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + func_basename "$obj" + $ECHO "$func_basename_result" + done | sort | sort -uc >/dev/null 2>&1); then + : + else + echo "copying selected object files to avoid basename conflicts..." + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + func_mkdir_p "$gentop" + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + func_basename "$obj" + objbase=$func_basename_result + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + func_arith $counter + 1 + counter=$func_arith_result + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + func_append oldobjs " $gentop/$newobj" + ;; + *) func_append oldobjs " $obj" ;; + esac + done + fi + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result + eval cmds=\"$old_archive_cmds\" + + func_len " $cmds" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + elif test -n "$archiver_list_spec"; then + func_verbose "using command file archive linking..." + for obj in $oldobjs + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" + done > $output_objdir/$libname.libcmd + func_to_tool_file "$output_objdir/$libname.libcmd" + oldobjs=" $archiver_list_spec$func_to_tool_file_result" + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + func_verbose "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + oldobjs= + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + eval test_cmds=\"$old_archive_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + for obj in $save_oldobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + func_append objlist " $obj" + if test "$len" -lt "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj"; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" + objlist= + len=$len0 + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test -z "$oldobjs"; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + func_execute_cmds "$cmds" 'exit $?' + done + + test -n "$generated" && \ + func_show_eval "${RM}r$generated" + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test yes = "$build_old_libs" && old_library=$libname.$libext + func_verbose "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + if test yes = "$hardcode_automatic"; then + relink_command= + fi + + # Only create the output if not a dry run. + $opt_dry_run || { + for installed in no yes; do + if test yes = "$installed"; then + if test -z "$install_libdir"; then + break + fi + output=$output_objdir/${outputname}i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + func_basename "$deplib" + name=$func_basename_result + func_resolve_sysroot "$deplib" + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` + test -z "$libdir" && \ + func_fatal_error "'$deplib' is not a valid libtool archive" + func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" + ;; + -L*) + func_stripname -L '' "$deplib" + func_replace_sysroot "$func_stripname_result" + func_append newdependency_libs " -L$func_replace_sysroot_result" + ;; + -R*) + func_stripname -R '' "$deplib" + func_replace_sysroot "$func_stripname_result" + func_append newdependency_libs " -R$func_replace_sysroot_result" + ;; + *) func_append newdependency_libs " $deplib" ;; + esac + done + dependency_libs=$newdependency_libs + newdlfiles= + + for lib in $dlfiles; do + case $lib in + *.la) + func_basename "$lib" + name=$func_basename_result + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "'$lib' is not a valid libtool archive" + func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" + ;; + *) func_append newdlfiles " $lib" ;; + esac + done + dlfiles=$newdlfiles + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + *.la) + # Only pass preopened files to the pseudo-archive (for + # eventual linking with the app. that links it) if we + # didn't already link the preopened objects directly into + # the library: + func_basename "$lib" + name=$func_basename_result + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "'$lib' is not a valid libtool archive" + func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" + ;; + esac + done + dlprefiles=$newdlprefiles + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; + *) abs=`pwd`"/$lib" ;; + esac + func_append newdlfiles " $abs" + done + dlfiles=$newdlfiles + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; + *) abs=`pwd`"/$lib" ;; + esac + func_append newdlprefiles " $abs" + done + dlprefiles=$newdlprefiles + fi + $RM $output + # place dlname in correct position for cygwin + # In fact, it would be nice if we could use this code for all target + # systems that can't hard-code library paths into their executables + # and that have no shared library path variable independent of PATH, + # but it turns out we can't easily determine that from inspecting + # libtool variables, so we have to hard-code the OSs to which it + # applies here; at the moment, that means platforms that use the PE + # object format with DLL files. See the long comment at the top of + # tests/bindir.at for full details. + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) + # If a -bindir argument was supplied, place the dll there. + if test -n "$bindir"; then + func_relative_path "$install_libdir" "$bindir" + tdlname=$func_relative_path_result/$dlname + else + # Otherwise fall back on heuristic. + tdlname=../bin/$dlname + fi + ;; + esac + $ECHO > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM (GNU $PACKAGE) $VERSION +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags='$new_inherited_linker_flags' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Names of additional weak libraries provided by this library +weak_library_names='$weak_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test no,yes = "$installed,$need_relink"; then + $ECHO >> $output "\ +relink_command=\"$relink_command\"" + fi + done + } + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' + ;; + esac + exit $EXIT_SUCCESS +} + +if test link = "$opt_mode" || test relink = "$opt_mode"; then + func_mode_link ${1+"$@"} +fi + + +# func_mode_uninstall arg... +func_mode_uninstall () +{ + $debug_cmd + + RM=$nonopt + files= + rmforce=false + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic=$magic + + for arg + do + case $arg in + -f) func_append RM " $arg"; rmforce=: ;; + -*) func_append RM " $arg" ;; + *) func_append files " $arg" ;; + esac + done + + test -z "$RM" && \ + func_fatal_help "you must specify an RM program" + + rmdirs= + + for file in $files; do + func_dirname "$file" "" "." + dir=$func_dirname_result + if test . = "$dir"; then + odir=$objdir + else + odir=$dir/$objdir + fi + func_basename "$file" + name=$func_basename_result + test uninstall = "$opt_mode" && odir=$dir + + # Remember odir for removal later, being careful to avoid duplicates + if test clean = "$opt_mode"; then + case " $rmdirs " in + *" $odir "*) ;; + *) func_append rmdirs " $odir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if { test -L "$file"; } >/dev/null 2>&1 || + { test -h "$file"; } >/dev/null 2>&1 || + test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif $rmforce; then + continue + fi + + rmfiles=$file + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if func_lalib_p "$file"; then + func_source $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + func_append rmfiles " $odir/$n" + done + test -n "$old_library" && func_append rmfiles " $odir/$old_library" + + case $opt_mode in + clean) + case " $library_names " in + *" $dlname "*) ;; + *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; + esac + test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" + ;; + uninstall) + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' + fi + # FIXME: should reinstall the best remaining shared library. + ;; + esac + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if func_lalib_p "$file"; then + + # Read the .lo file + func_source $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" && test none != "$pic_object"; then + func_append rmfiles " $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" && test none != "$non_pic_object"; then + func_append rmfiles " $dir/$non_pic_object" + fi + fi + ;; + + *) + if test clean = "$opt_mode"; then + noexename=$name + case $file in + *.exe) + func_stripname '' '.exe' "$file" + file=$func_stripname_result + func_stripname '' '.exe' "$name" + noexename=$func_stripname_result + # $file with .exe has already been added to rmfiles, + # add $file without .exe + func_append rmfiles " $file" + ;; + esac + # Do a test to see if this is a libtool program. + if func_ltwrapper_p "$file"; then + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + relink_command= + func_source $func_ltwrapper_scriptname_result + func_append rmfiles " $func_ltwrapper_scriptname_result" + else + relink_command= + func_source $dir/$noexename + fi + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + func_append rmfiles " $odir/$name $odir/${name}S.$objext" + if test yes = "$fast_install" && test -n "$relink_command"; then + func_append rmfiles " $odir/lt-$name" + fi + if test "X$noexename" != "X$name"; then + func_append rmfiles " $odir/lt-$noexename.c" + fi + fi + fi + ;; + esac + func_show_eval "$RM $rmfiles" 'exit_status=1' + done + + # Try to remove the $objdir's in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + func_show_eval "rmdir $dir >/dev/null 2>&1" + fi + done + + exit $exit_status +} + +if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then + func_mode_uninstall ${1+"$@"} +fi + +test -z "$opt_mode" && { + help=$generic_help + func_fatal_help "you must specify a MODE" +} + +test -z "$exec_cmd" && \ + func_fatal_help "invalid operation mode '$opt_mode'" + +if test -n "$exec_cmd"; then + eval exec "$exec_cmd" + exit $EXIT_FAILURE +fi + +exit $exit_status + + +# The TAGs below are defined such that we never get into a situation +# where we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/thirdparty/jpeg-9e/ltmain.sh b/thirdparty/jpeg-9e/ltmain.sh new file mode 100644 index 0000000..0f0a2da --- /dev/null +++ b/thirdparty/jpeg-9e/ltmain.sh @@ -0,0 +1,11147 @@ +#! /bin/sh +## DO NOT EDIT - This file generated from ./build-aux/ltmain.in +## by inline-source v2014-01-03.01 + +# libtool (GNU libtool) 2.4.6 +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit , 1996 + +# Copyright (C) 1996-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +PROGRAM=libtool +PACKAGE=libtool +VERSION=2.4.6 +package_revision=2.4.6 + + +## ------ ## +## Usage. ## +## ------ ## + +# Run './libtool --help' for help with using this script from the +# command line. + + +## ------------------------------- ## +## User overridable command paths. ## +## ------------------------------- ## + +# After configure completes, it has a better idea of some of the +# shell tools we need than the defaults used by the functions shared +# with bootstrap, so set those here where they can still be over- +# ridden by the user, but otherwise take precedence. + +: ${AUTOCONF="autoconf"} +: ${AUTOMAKE="automake"} + + +## -------------------------- ## +## Source external libraries. ## +## -------------------------- ## + +# Much of our low-level functionality needs to be sourced from external +# libraries, which are installed to $pkgauxdir. + +# Set a version string for this script. +scriptversion=2015-01-20.17; # UTC + +# General shell script boiler plate, and helper functions. +# Written by Gary V. Vaughan, 2004 + +# Copyright (C) 2004-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# As a special exception to the GNU General Public License, if you distribute +# this file as part of a program or library that is built using GNU Libtool, +# you may include this file under the same distribution terms that you use +# for the rest of that program. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Please report bugs or propose patches to gary@gnu.org. + + +## ------ ## +## Usage. ## +## ------ ## + +# Evaluate this file near the top of your script to gain access to +# the functions and variables defined here: +# +# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh +# +# If you need to override any of the default environment variable +# settings, do that before evaluating this file. + + +## -------------------- ## +## Shell normalisation. ## +## -------------------- ## + +# Some shells need a little help to be as Bourne compatible as possible. +# Before doing anything else, make sure all that help has been provided! + +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac +fi + +# NLS nuisances: We save the old values in case they are required later. +_G_user_locale= +_G_safe_locale= +for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES +do + eval "if test set = \"\${$_G_var+set}\"; then + save_$_G_var=\$$_G_var + $_G_var=C + export $_G_var + _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" + _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" + fi" +done + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Make sure IFS has a sensible default +sp=' ' +nl=' +' +IFS="$sp $nl" + +# There are apparently some retarded systems that use ';' as a PATH separator! +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + + +## ------------------------- ## +## Locate command utilities. ## +## ------------------------- ## + + +# func_executable_p FILE +# ---------------------- +# Check that FILE is an executable regular file. +func_executable_p () +{ + test -f "$1" && test -x "$1" +} + + +# func_path_progs PROGS_LIST CHECK_FUNC [PATH] +# -------------------------------------------- +# Search for either a program that responds to --version with output +# containing "GNU", or else returned by CHECK_FUNC otherwise, by +# trying all the directories in PATH with each of the elements of +# PROGS_LIST. +# +# CHECK_FUNC should accept the path to a candidate program, and +# set $func_check_prog_result if it truncates its output less than +# $_G_path_prog_max characters. +func_path_progs () +{ + _G_progs_list=$1 + _G_check_func=$2 + _G_PATH=${3-"$PATH"} + + _G_path_prog_max=0 + _G_path_prog_found=false + _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} + for _G_dir in $_G_PATH; do + IFS=$_G_save_IFS + test -z "$_G_dir" && _G_dir=. + for _G_prog_name in $_G_progs_list; do + for _exeext in '' .EXE; do + _G_path_prog=$_G_dir/$_G_prog_name$_exeext + func_executable_p "$_G_path_prog" || continue + case `"$_G_path_prog" --version 2>&1` in + *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; + *) $_G_check_func $_G_path_prog + func_path_progs_result=$func_check_prog_result + ;; + esac + $_G_path_prog_found && break 3 + done + done + done + IFS=$_G_save_IFS + test -z "$func_path_progs_result" && { + echo "no acceptable sed could be found in \$PATH" >&2 + exit 1 + } +} + + +# We want to be able to use the functions in this file before configure +# has figured out where the best binaries are kept, which means we have +# to search for them ourselves - except when the results are already set +# where we skip the searches. + +# Unless the user overrides by setting SED, search the path for either GNU +# sed, or the sed that truncates its output the least. +test -z "$SED" && { + _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for _G_i in 1 2 3 4 5 6 7; do + _G_sed_script=$_G_sed_script$nl$_G_sed_script + done + echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed + _G_sed_script= + + func_check_prog_sed () + { + _G_path_prog=$1 + + _G_count=0 + printf 0123456789 >conftest.in + while : + do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo '' >> conftest.nl + "$_G_path_prog" -f conftest.sed conftest.out 2>/dev/null || break + diff conftest.out conftest.nl >/dev/null 2>&1 || break + _G_count=`expr $_G_count + 1` + if test "$_G_count" -gt "$_G_path_prog_max"; then + # Best one so far, save it but keep looking for a better one + func_check_prog_result=$_G_path_prog + _G_path_prog_max=$_G_count + fi + # 10*(2^10) chars as input seems more than enough + test 10 -lt "$_G_count" && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + + func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin + rm -f conftest.sed + SED=$func_path_progs_result +} + + +# Unless the user overrides by setting GREP, search the path for either GNU +# grep, or the grep that truncates its output the least. +test -z "$GREP" && { + func_check_prog_grep () + { + _G_path_prog=$1 + + _G_count=0 + _G_path_prog_max=0 + printf 0123456789 >conftest.in + while : + do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo 'GREP' >> conftest.nl + "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' conftest.out 2>/dev/null || break + diff conftest.out conftest.nl >/dev/null 2>&1 || break + _G_count=`expr $_G_count + 1` + if test "$_G_count" -gt "$_G_path_prog_max"; then + # Best one so far, save it but keep looking for a better one + func_check_prog_result=$_G_path_prog + _G_path_prog_max=$_G_count + fi + # 10*(2^10) chars as input seems more than enough + test 10 -lt "$_G_count" && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + + func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin + GREP=$func_path_progs_result +} + + +## ------------------------------- ## +## User overridable command paths. ## +## ------------------------------- ## + +# All uppercase variable names are used for environment variables. These +# variables can be overridden by the user before calling a script that +# uses them if a suitable command of that name is not already available +# in the command search PATH. + +: ${CP="cp -f"} +: ${ECHO="printf %s\n"} +: ${EGREP="$GREP -E"} +: ${FGREP="$GREP -F"} +: ${LN_S="ln -s"} +: ${MAKE="make"} +: ${MKDIR="mkdir"} +: ${MV="mv -f"} +: ${RM="rm -f"} +: ${SHELL="${CONFIG_SHELL-/bin/sh}"} + + +## -------------------- ## +## Useful sed snippets. ## +## -------------------- ## + +sed_dirname='s|/[^/]*$||' +sed_basename='s|^.*/||' + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s|\([`"$\\]\)|\\\1|g' + +# Same as above, but do not quote variable references. +sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution that turns a string into a regex matching for the +# string literally. +sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' + +# Sed substitution that converts a w32 file name or path +# that contains forward slashes, into one that contains +# (escaped) backslashes. A very naive implementation. +sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + +# Re-'\' parameter expansions in output of sed_double_quote_subst that +# were '\'-ed in input to the same. If an odd number of '\' preceded a +# '$' in input to sed_double_quote_subst, that '$' was protected from +# expansion. Since each input '\' is now two '\'s, look for any number +# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. +_G_bs='\\' +_G_bs2='\\\\' +_G_bs4='\\\\\\\\' +_G_dollar='\$' +sed_double_backslash="\ + s/$_G_bs4/&\\ +/g + s/^$_G_bs2$_G_dollar/$_G_bs&/ + s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g + s/\n//g" + + +## ----------------- ## +## Global variables. ## +## ----------------- ## + +# Except for the global variables explicitly listed below, the following +# functions in the '^func_' namespace, and the '^require_' namespace +# variables initialised in the 'Resource management' section, sourcing +# this file will not pollute your global namespace with anything +# else. There's no portable way to scope variables in Bourne shell +# though, so actually running these functions will sometimes place +# results into a variable named after the function, and often use +# temporary variables in the '^_G_' namespace. If you are careful to +# avoid using those namespaces casually in your sourcing script, things +# should continue to work as you expect. And, of course, you can freely +# overwrite any of the functions or variables defined here before +# calling anything to customize them. + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. +EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. + +# Allow overriding, eg assuming that you follow the convention of +# putting '$debug_cmd' at the start of all your functions, you can get +# bash to show function call trace with: +# +# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name +debug_cmd=${debug_cmd-":"} +exit_cmd=: + +# By convention, finish your script with: +# +# exit $exit_status +# +# so that you can set exit_status to non-zero if you want to indicate +# something went wrong during execution without actually bailing out at +# the point of failure. +exit_status=$EXIT_SUCCESS + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath=$0 + +# The name of this program. +progname=`$ECHO "$progpath" |$SED "$sed_basename"` + +# Make sure we have an absolute progpath for reexecution: +case $progpath in + [\\/]*|[A-Za-z]:\\*) ;; + *[\\/]*) + progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` + progdir=`cd "$progdir" && pwd` + progpath=$progdir/$progname + ;; + *) + _G_IFS=$IFS + IFS=${PATH_SEPARATOR-:} + for progdir in $PATH; do + IFS=$_G_IFS + test -x "$progdir/$progname" && break + done + IFS=$_G_IFS + test -n "$progdir" || progdir=`pwd` + progpath=$progdir/$progname + ;; +esac + + +## ----------------- ## +## Standard options. ## +## ----------------- ## + +# The following options affect the operation of the functions defined +# below, and should be set appropriately depending on run-time para- +# meters passed on the command line. + +opt_dry_run=false +opt_quiet=false +opt_verbose=false + +# Categories 'all' and 'none' are always available. Append any others +# you will pass as the first argument to func_warning from your own +# code. +warning_categories= + +# By default, display warnings according to 'opt_warning_types'. Set +# 'warning_func' to ':' to elide all warnings, or func_fatal_error to +# treat the next displayed warning as a fatal error. +warning_func=func_warn_and_continue + +# Set to 'all' to display all warnings, 'none' to suppress all +# warnings, or a space delimited list of some subset of +# 'warning_categories' to display only the listed warnings. +opt_warning_types=all + + +## -------------------- ## +## Resource management. ## +## -------------------- ## + +# This section contains definitions for functions that each ensure a +# particular resource (a file, or a non-empty configuration variable for +# example) is available, and if appropriate to extract default values +# from pertinent package files. Call them using their associated +# 'require_*' variable to ensure that they are executed, at most, once. +# +# It's entirely deliberate that calling these functions can set +# variables that don't obey the namespace limitations obeyed by the rest +# of this file, in order that that they be as useful as possible to +# callers. + + +# require_term_colors +# ------------------- +# Allow display of bold text on terminals that support it. +require_term_colors=func_require_term_colors +func_require_term_colors () +{ + $debug_cmd + + test -t 1 && { + # COLORTERM and USE_ANSI_COLORS environment variables take + # precedence, because most terminfo databases neglect to describe + # whether color sequences are supported. + test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} + + if test 1 = "$USE_ANSI_COLORS"; then + # Standard ANSI escape sequences + tc_reset='' + tc_bold=''; tc_standout='' + tc_red=''; tc_green='' + tc_blue=''; tc_cyan='' + else + # Otherwise trust the terminfo database after all. + test -n "`tput sgr0 2>/dev/null`" && { + tc_reset=`tput sgr0` + test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` + tc_standout=$tc_bold + test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` + test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` + test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` + test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` + test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` + } + fi + } + + require_term_colors=: +} + + +## ----------------- ## +## Function library. ## +## ----------------- ## + +# This section contains a variety of useful functions to call in your +# scripts. Take note of the portable wrappers for features provided by +# some modern shells, which will fall back to slower equivalents on +# less featureful shells. + + +# func_append VAR VALUE +# --------------------- +# Append VALUE onto the existing contents of VAR. + + # We should try to minimise forks, especially on Windows where they are + # unreasonably slow, so skip the feature probes when bash or zsh are + # being used: + if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then + : ${_G_HAVE_ARITH_OP="yes"} + : ${_G_HAVE_XSI_OPS="yes"} + # The += operator was introduced in bash 3.1 + case $BASH_VERSION in + [12].* | 3.0 | 3.0*) ;; + *) + : ${_G_HAVE_PLUSEQ_OP="yes"} + ;; + esac + fi + + # _G_HAVE_PLUSEQ_OP + # Can be empty, in which case the shell is probed, "yes" if += is + # useable or anything else if it does not work. + test -z "$_G_HAVE_PLUSEQ_OP" \ + && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ + && _G_HAVE_PLUSEQ_OP=yes + +if test yes = "$_G_HAVE_PLUSEQ_OP" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_append () + { + $debug_cmd + + eval "$1+=\$2" + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_append () + { + $debug_cmd + + eval "$1=\$$1\$2" + } +fi + + +# func_append_quoted VAR VALUE +# ---------------------------- +# Quote VALUE and append to the end of shell variable VAR, separated +# by a space. +if test yes = "$_G_HAVE_PLUSEQ_OP"; then + eval 'func_append_quoted () + { + $debug_cmd + + func_quote_for_eval "$2" + eval "$1+=\\ \$func_quote_for_eval_result" + }' +else + func_append_quoted () + { + $debug_cmd + + func_quote_for_eval "$2" + eval "$1=\$$1\\ \$func_quote_for_eval_result" + } +fi + + +# func_append_uniq VAR VALUE +# -------------------------- +# Append unique VALUE onto the existing contents of VAR, assuming +# entries are delimited by the first character of VALUE. For example: +# +# func_append_uniq options " --another-option option-argument" +# +# will only append to $options if " --another-option option-argument " +# is not already present somewhere in $options already (note spaces at +# each end implied by leading space in second argument). +func_append_uniq () +{ + $debug_cmd + + eval _G_current_value='`$ECHO $'$1'`' + _G_delim=`expr "$2" : '\(.\)'` + + case $_G_delim$_G_current_value$_G_delim in + *"$2$_G_delim"*) ;; + *) func_append "$@" ;; + esac +} + + +# func_arith TERM... +# ------------------ +# Set func_arith_result to the result of evaluating TERMs. + test -z "$_G_HAVE_ARITH_OP" \ + && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ + && _G_HAVE_ARITH_OP=yes + +if test yes = "$_G_HAVE_ARITH_OP"; then + eval 'func_arith () + { + $debug_cmd + + func_arith_result=$(( $* )) + }' +else + func_arith () + { + $debug_cmd + + func_arith_result=`expr "$@"` + } +fi + + +# func_basename FILE +# ------------------ +# Set func_basename_result to FILE with everything up to and including +# the last / stripped. +if test yes = "$_G_HAVE_XSI_OPS"; then + # If this shell supports suffix pattern removal, then use it to avoid + # forking. Hide the definitions single quotes in case the shell chokes + # on unsupported syntax... + _b='func_basename_result=${1##*/}' + _d='case $1 in + */*) func_dirname_result=${1%/*}$2 ;; + * ) func_dirname_result=$3 ;; + esac' + +else + # ...otherwise fall back to using sed. + _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' + _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` + if test "X$func_dirname_result" = "X$1"; then + func_dirname_result=$3 + else + func_append func_dirname_result "$2" + fi' +fi + +eval 'func_basename () +{ + $debug_cmd + + '"$_b"' +}' + + +# func_dirname FILE APPEND NONDIR_REPLACEMENT +# ------------------------------------------- +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +eval 'func_dirname () +{ + $debug_cmd + + '"$_d"' +}' + + +# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT +# -------------------------------------------------------- +# Perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# For efficiency, we do not delegate to the functions above but instead +# duplicate the functionality here. +eval 'func_dirname_and_basename () +{ + $debug_cmd + + '"$_b"' + '"$_d"' +}' + + +# func_echo ARG... +# ---------------- +# Echo program name prefixed message. +func_echo () +{ + $debug_cmd + + _G_message=$* + + func_echo_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_IFS + $ECHO "$progname: $_G_line" + done + IFS=$func_echo_IFS +} + + +# func_echo_all ARG... +# -------------------- +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + + +# func_echo_infix_1 INFIX ARG... +# ------------------------------ +# Echo program name, followed by INFIX on the first line, with any +# additional lines not showing INFIX. +func_echo_infix_1 () +{ + $debug_cmd + + $require_term_colors + + _G_infix=$1; shift + _G_indent=$_G_infix + _G_prefix="$progname: $_G_infix: " + _G_message=$* + + # Strip color escape sequences before counting printable length + for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" + do + test -n "$_G_tc" && { + _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` + _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` + } + done + _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes + + func_echo_infix_1_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_infix_1_IFS + $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 + _G_prefix=$_G_indent + done + IFS=$func_echo_infix_1_IFS +} + + +# func_error ARG... +# ----------------- +# Echo program name prefixed message to standard error. +func_error () +{ + $debug_cmd + + $require_term_colors + + func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 +} + + +# func_fatal_error ARG... +# ----------------------- +# Echo program name prefixed message to standard error, and exit. +func_fatal_error () +{ + $debug_cmd + + func_error "$*" + exit $EXIT_FAILURE +} + + +# func_grep EXPRESSION FILENAME +# ----------------------------- +# Check whether EXPRESSION matches any line of FILENAME, without output. +func_grep () +{ + $debug_cmd + + $GREP "$1" "$2" >/dev/null 2>&1 +} + + +# func_len STRING +# --------------- +# Set func_len_result to the length of STRING. STRING may not +# start with a hyphen. + test -z "$_G_HAVE_XSI_OPS" \ + && (eval 'x=a/b/c; + test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ + && _G_HAVE_XSI_OPS=yes + +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_len () + { + $debug_cmd + + func_len_result=${#1} + }' +else + func_len () + { + $debug_cmd + + func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` + } +fi + + +# func_mkdir_p DIRECTORY-PATH +# --------------------------- +# Make sure the entire path to DIRECTORY-PATH is available. +func_mkdir_p () +{ + $debug_cmd + + _G_directory_path=$1 + _G_dir_list= + + if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then + + # Protect directory names starting with '-' + case $_G_directory_path in + -*) _G_directory_path=./$_G_directory_path ;; + esac + + # While some portion of DIR does not yet exist... + while test ! -d "$_G_directory_path"; do + # ...make a list in topmost first order. Use a colon delimited + # list incase some portion of path contains whitespace. + _G_dir_list=$_G_directory_path:$_G_dir_list + + # If the last portion added has no slash in it, the list is done + case $_G_directory_path in */*) ;; *) break ;; esac + + # ...otherwise throw away the child directory and loop + _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` + done + _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` + + func_mkdir_p_IFS=$IFS; IFS=: + for _G_dir in $_G_dir_list; do + IFS=$func_mkdir_p_IFS + # mkdir can fail with a 'File exist' error if two processes + # try to create one of the directories concurrently. Don't + # stop in that case! + $MKDIR "$_G_dir" 2>/dev/null || : + done + IFS=$func_mkdir_p_IFS + + # Bail out if we (or some other process) failed to create a directory. + test -d "$_G_directory_path" || \ + func_fatal_error "Failed to create '$1'" + fi +} + + +# func_mktempdir [BASENAME] +# ------------------------- +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, BASENAME is the basename for that directory. +func_mktempdir () +{ + $debug_cmd + + _G_template=${TMPDIR-/tmp}/${1-$progname} + + if test : = "$opt_dry_run"; then + # Return a directory name, but don't create it in dry-run mode + _G_tmpdir=$_G_template-$$ + else + + # If mktemp works, use that first and foremost + _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` + + if test ! -d "$_G_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + _G_tmpdir=$_G_template-${RANDOM-0}$$ + + func_mktempdir_umask=`umask` + umask 0077 + $MKDIR "$_G_tmpdir" + umask $func_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$_G_tmpdir" || \ + func_fatal_error "cannot create temporary directory '$_G_tmpdir'" + fi + + $ECHO "$_G_tmpdir" +} + + +# func_normal_abspath PATH +# ------------------------ +# Remove doubled-up and trailing slashes, "." path components, +# and cancel out any ".." path components in PATH after making +# it an absolute path. +func_normal_abspath () +{ + $debug_cmd + + # These SED scripts presuppose an absolute path with a trailing slash. + _G_pathcar='s|^/\([^/]*\).*$|\1|' + _G_pathcdr='s|^/[^/]*||' + _G_removedotparts=':dotsl + s|/\./|/|g + t dotsl + s|/\.$|/|' + _G_collapseslashes='s|/\{1,\}|/|g' + _G_finalslash='s|/*$|/|' + + # Start from root dir and reassemble the path. + func_normal_abspath_result= + func_normal_abspath_tpath=$1 + func_normal_abspath_altnamespace= + case $func_normal_abspath_tpath in + "") + # Empty path, that just means $cwd. + func_stripname '' '/' "`pwd`" + func_normal_abspath_result=$func_stripname_result + return + ;; + # The next three entries are used to spot a run of precisely + # two leading slashes without using negated character classes; + # we take advantage of case's first-match behaviour. + ///*) + # Unusual form of absolute path, do nothing. + ;; + //*) + # Not necessarily an ordinary path; POSIX reserves leading '//' + # and for example Cygwin uses it to access remote file shares + # over CIFS/SMB, so we conserve a leading double slash if found. + func_normal_abspath_altnamespace=/ + ;; + /*) + # Absolute path, do nothing. + ;; + *) + # Relative path, prepend $cwd. + func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath + ;; + esac + + # Cancel out all the simple stuff to save iterations. We also want + # the path to end with a slash for ease of parsing, so make sure + # there is one (and only one) here. + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` + while :; do + # Processed it all yet? + if test / = "$func_normal_abspath_tpath"; then + # If we ascended to the root using ".." the result may be empty now. + if test -z "$func_normal_abspath_result"; then + func_normal_abspath_result=/ + fi + break + fi + func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_pathcar"` + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_pathcdr"` + # Figure out what to do with it + case $func_normal_abspath_tcomponent in + "") + # Trailing empty path component, ignore it. + ;; + ..) + # Parent dir; strip last assembled component from result. + func_dirname "$func_normal_abspath_result" + func_normal_abspath_result=$func_dirname_result + ;; + *) + # Actual path component, append it. + func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" + ;; + esac + done + # Restore leading double-slash if one was found on entry. + func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result +} + + +# func_notquiet ARG... +# -------------------- +# Echo program name prefixed message only when not in quiet mode. +func_notquiet () +{ + $debug_cmd + + $opt_quiet || func_echo ${1+"$@"} + + # A bug in bash halts the script if the last line of a function + # fails when set -e is in force, so we need another command to + # work around that: + : +} + + +# func_relative_path SRCDIR DSTDIR +# -------------------------------- +# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. +func_relative_path () +{ + $debug_cmd + + func_relative_path_result= + func_normal_abspath "$1" + func_relative_path_tlibdir=$func_normal_abspath_result + func_normal_abspath "$2" + func_relative_path_tbindir=$func_normal_abspath_result + + # Ascend the tree starting from libdir + while :; do + # check if we have found a prefix of bindir + case $func_relative_path_tbindir in + $func_relative_path_tlibdir) + # found an exact match + func_relative_path_tcancelled= + break + ;; + $func_relative_path_tlibdir*) + # found a matching prefix + func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" + func_relative_path_tcancelled=$func_stripname_result + if test -z "$func_relative_path_result"; then + func_relative_path_result=. + fi + break + ;; + *) + func_dirname $func_relative_path_tlibdir + func_relative_path_tlibdir=$func_dirname_result + if test -z "$func_relative_path_tlibdir"; then + # Have to descend all the way to the root! + func_relative_path_result=../$func_relative_path_result + func_relative_path_tcancelled=$func_relative_path_tbindir + break + fi + func_relative_path_result=../$func_relative_path_result + ;; + esac + done + + # Now calculate path; take care to avoid doubling-up slashes. + func_stripname '' '/' "$func_relative_path_result" + func_relative_path_result=$func_stripname_result + func_stripname '/' '/' "$func_relative_path_tcancelled" + if test -n "$func_stripname_result"; then + func_append func_relative_path_result "/$func_stripname_result" + fi + + # Normalisation. If bindir is libdir, return '.' else relative path. + if test -n "$func_relative_path_result"; then + func_stripname './' '' "$func_relative_path_result" + func_relative_path_result=$func_stripname_result + fi + + test -n "$func_relative_path_result" || func_relative_path_result=. + + : +} + + +# func_quote_for_eval ARG... +# -------------------------- +# Aesthetically quote ARGs to be evaled later. +# This function returns two values: +# i) func_quote_for_eval_result +# double-quoted, suitable for a subsequent eval +# ii) func_quote_for_eval_unquoted_result +# has all characters that are still active within double +# quotes backslashified. +func_quote_for_eval () +{ + $debug_cmd + + func_quote_for_eval_unquoted_result= + func_quote_for_eval_result= + while test 0 -lt $#; do + case $1 in + *[\\\`\"\$]*) + _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; + *) + _G_unquoted_arg=$1 ;; + esac + if test -n "$func_quote_for_eval_unquoted_result"; then + func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" + else + func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" + fi + + case $_G_unquoted_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting, command substitution and variable expansion + # for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + _G_quoted_arg=\"$_G_unquoted_arg\" + ;; + *) + _G_quoted_arg=$_G_unquoted_arg + ;; + esac + + if test -n "$func_quote_for_eval_result"; then + func_append func_quote_for_eval_result " $_G_quoted_arg" + else + func_append func_quote_for_eval_result "$_G_quoted_arg" + fi + shift + done +} + + +# func_quote_for_expand ARG +# ------------------------- +# Aesthetically quote ARG to be evaled later; same as above, +# but do not quote variable references. +func_quote_for_expand () +{ + $debug_cmd + + case $1 in + *[\\\`\"]*) + _G_arg=`$ECHO "$1" | $SED \ + -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; + *) + _G_arg=$1 ;; + esac + + case $_G_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting and command substitution for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + _G_arg=\"$_G_arg\" + ;; + esac + + func_quote_for_expand_result=$_G_arg +} + + +# func_stripname PREFIX SUFFIX NAME +# --------------------------------- +# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_stripname () + { + $debug_cmd + + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary variable first. + func_stripname_result=$3 + func_stripname_result=${func_stripname_result#"$1"} + func_stripname_result=${func_stripname_result%"$2"} + }' +else + func_stripname () + { + $debug_cmd + + case $2 in + .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; + *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; + esac + } +fi + + +# func_show_eval CMD [FAIL_EXP] +# ----------------------------- +# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. +func_show_eval () +{ + $debug_cmd + + _G_cmd=$1 + _G_fail_exp=${2-':'} + + func_quote_for_expand "$_G_cmd" + eval "func_notquiet $func_quote_for_expand_result" + + $opt_dry_run || { + eval "$_G_cmd" + _G_status=$? + if test 0 -ne "$_G_status"; then + eval "(exit $_G_status); $_G_fail_exp" + fi + } +} + + +# func_show_eval_locale CMD [FAIL_EXP] +# ------------------------------------ +# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. Use the saved locale for evaluation. +func_show_eval_locale () +{ + $debug_cmd + + _G_cmd=$1 + _G_fail_exp=${2-':'} + + $opt_quiet || { + func_quote_for_expand "$_G_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + $opt_dry_run || { + eval "$_G_user_locale + $_G_cmd" + _G_status=$? + eval "$_G_safe_locale" + if test 0 -ne "$_G_status"; then + eval "(exit $_G_status); $_G_fail_exp" + fi + } +} + + +# func_tr_sh +# ---------- +# Turn $1 into a string suitable for a shell variable name. +# Result is stored in $func_tr_sh_result. All characters +# not in the set a-zA-Z0-9_ are replaced with '_'. Further, +# if $1 begins with a digit, a '_' is prepended as well. +func_tr_sh () +{ + $debug_cmd + + case $1 in + [0-9]* | *[!a-zA-Z0-9_]*) + func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` + ;; + * ) + func_tr_sh_result=$1 + ;; + esac +} + + +# func_verbose ARG... +# ------------------- +# Echo program name prefixed message in verbose mode only. +func_verbose () +{ + $debug_cmd + + $opt_verbose && func_echo "$*" + + : +} + + +# func_warn_and_continue ARG... +# ----------------------------- +# Echo program name prefixed warning message to standard error. +func_warn_and_continue () +{ + $debug_cmd + + $require_term_colors + + func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 +} + + +# func_warning CATEGORY ARG... +# ---------------------------- +# Echo program name prefixed warning message to standard error. Warning +# messages can be filtered according to CATEGORY, where this function +# elides messages where CATEGORY is not listed in the global variable +# 'opt_warning_types'. +func_warning () +{ + $debug_cmd + + # CATEGORY must be in the warning_categories list! + case " $warning_categories " in + *" $1 "*) ;; + *) func_internal_error "invalid warning category '$1'" ;; + esac + + _G_category=$1 + shift + + case " $opt_warning_types " in + *" $_G_category "*) $warning_func ${1+"$@"} ;; + esac +} + + +# func_sort_ver VER1 VER2 +# ----------------------- +# 'sort -V' is not generally available. +# Note this deviates from the version comparison in automake +# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a +# but this should suffice as we won't be specifying old +# version formats or redundant trailing .0 in bootstrap.conf. +# If we did want full compatibility then we should probably +# use m4_version_compare from autoconf. +func_sort_ver () +{ + $debug_cmd + + printf '%s\n%s\n' "$1" "$2" \ + | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n +} + +# func_lt_ver PREV CURR +# --------------------- +# Return true if PREV and CURR are in the correct order according to +# func_sort_ver, otherwise false. Use it like this: +# +# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." +func_lt_ver () +{ + $debug_cmd + + test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` +} + + +# Local variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-time-zone: "UTC" +# End: +#! /bin/sh + +# Set a version string for this script. +scriptversion=2014-01-07.03; # UTC + +# A portable, pluggable option parser for Bourne shell. +# Written by Gary V. Vaughan, 2010 + +# Copyright (C) 2010-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Please report bugs or propose patches to gary@gnu.org. + + +## ------ ## +## Usage. ## +## ------ ## + +# This file is a library for parsing options in your shell scripts along +# with assorted other useful supporting features that you can make use +# of too. +# +# For the simplest scripts you might need only: +# +# #!/bin/sh +# . relative/path/to/funclib.sh +# . relative/path/to/options-parser +# scriptversion=1.0 +# func_options ${1+"$@"} +# eval set dummy "$func_options_result"; shift +# ...rest of your script... +# +# In order for the '--version' option to work, you will need to have a +# suitably formatted comment like the one at the top of this file +# starting with '# Written by ' and ending with '# warranty; '. +# +# For '-h' and '--help' to work, you will also need a one line +# description of your script's purpose in a comment directly above the +# '# Written by ' line, like the one at the top of this file. +# +# The default options also support '--debug', which will turn on shell +# execution tracing (see the comment above debug_cmd below for another +# use), and '--verbose' and the func_verbose function to allow your script +# to display verbose messages only when your user has specified +# '--verbose'. +# +# After sourcing this file, you can plug processing for additional +# options by amending the variables from the 'Configuration' section +# below, and following the instructions in the 'Option parsing' +# section further down. + +## -------------- ## +## Configuration. ## +## -------------- ## + +# You should override these variables in your script after sourcing this +# file so that they reflect the customisations you have added to the +# option parser. + +# The usage line for option parsing errors and the start of '-h' and +# '--help' output messages. You can embed shell variables for delayed +# expansion at the time the message is displayed, but you will need to +# quote other shell meta-characters carefully to prevent them being +# expanded when the contents are evaled. +usage='$progpath [OPTION]...' + +# Short help message in response to '-h' and '--help'. Add to this or +# override it after sourcing this library to reflect the full set of +# options your script accepts. +usage_message="\ + --debug enable verbose shell tracing + -W, --warnings=CATEGORY + report the warnings falling in CATEGORY [all] + -v, --verbose verbosely report processing + --version print version information and exit + -h, --help print short or long help message and exit +" + +# Additional text appended to 'usage_message' in response to '--help'. +long_help_message=" +Warning categories include: + 'all' show all warnings + 'none' turn off all the warnings + 'error' warnings are treated as fatal errors" + +# Help message printed before fatal option parsing errors. +fatal_help="Try '\$progname --help' for more information." + + + +## ------------------------- ## +## Hook function management. ## +## ------------------------- ## + +# This section contains functions for adding, removing, and running hooks +# to the main code. A hook is just a named list of of function, that can +# be run in order later on. + +# func_hookable FUNC_NAME +# ----------------------- +# Declare that FUNC_NAME will run hooks added with +# 'func_add_hook FUNC_NAME ...'. +func_hookable () +{ + $debug_cmd + + func_append hookable_fns " $1" +} + + +# func_add_hook FUNC_NAME HOOK_FUNC +# --------------------------------- +# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must +# first have been declared "hookable" by a call to 'func_hookable'. +func_add_hook () +{ + $debug_cmd + + case " $hookable_fns " in + *" $1 "*) ;; + *) func_fatal_error "'$1' does not accept hook functions." ;; + esac + + eval func_append ${1}_hooks '" $2"' +} + + +# func_remove_hook FUNC_NAME HOOK_FUNC +# ------------------------------------ +# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. +func_remove_hook () +{ + $debug_cmd + + eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' +} + + +# func_run_hooks FUNC_NAME [ARG]... +# --------------------------------- +# Run all hook functions registered to FUNC_NAME. +# It is assumed that the list of hook functions contains nothing more +# than a whitespace-delimited list of legal shell function names, and +# no effort is wasted trying to catch shell meta-characters or preserve +# whitespace. +func_run_hooks () +{ + $debug_cmd + + case " $hookable_fns " in + *" $1 "*) ;; + *) func_fatal_error "'$1' does not support hook funcions.n" ;; + esac + + eval _G_hook_fns=\$$1_hooks; shift + + for _G_hook in $_G_hook_fns; do + eval $_G_hook '"$@"' + + # store returned options list back into positional + # parameters for next 'cmd' execution. + eval _G_hook_result=\$${_G_hook}_result + eval set dummy "$_G_hook_result"; shift + done + + func_quote_for_eval ${1+"$@"} + func_run_hooks_result=$func_quote_for_eval_result +} + + + +## --------------- ## +## Option parsing. ## +## --------------- ## + +# In order to add your own option parsing hooks, you must accept the +# full positional parameter list in your hook function, remove any +# options that you action, and then pass back the remaining unprocessed +# options in '_result', escaped suitably for +# 'eval'. Like this: +# +# my_options_prep () +# { +# $debug_cmd +# +# # Extend the existing usage message. +# usage_message=$usage_message' +# -s, --silent don'\''t print informational messages +# ' +# +# func_quote_for_eval ${1+"$@"} +# my_options_prep_result=$func_quote_for_eval_result +# } +# func_add_hook func_options_prep my_options_prep +# +# +# my_silent_option () +# { +# $debug_cmd +# +# # Note that for efficiency, we parse as many options as we can +# # recognise in a loop before passing the remainder back to the +# # caller on the first unrecognised argument we encounter. +# while test $# -gt 0; do +# opt=$1; shift +# case $opt in +# --silent|-s) opt_silent=: ;; +# # Separate non-argument short options: +# -s*) func_split_short_opt "$_G_opt" +# set dummy "$func_split_short_opt_name" \ +# "-$func_split_short_opt_arg" ${1+"$@"} +# shift +# ;; +# *) set dummy "$_G_opt" "$*"; shift; break ;; +# esac +# done +# +# func_quote_for_eval ${1+"$@"} +# my_silent_option_result=$func_quote_for_eval_result +# } +# func_add_hook func_parse_options my_silent_option +# +# +# my_option_validation () +# { +# $debug_cmd +# +# $opt_silent && $opt_verbose && func_fatal_help "\ +# '--silent' and '--verbose' options are mutually exclusive." +# +# func_quote_for_eval ${1+"$@"} +# my_option_validation_result=$func_quote_for_eval_result +# } +# func_add_hook func_validate_options my_option_validation +# +# You'll alse need to manually amend $usage_message to reflect the extra +# options you parse. It's preferable to append if you can, so that +# multiple option parsing hooks can be added safely. + + +# func_options [ARG]... +# --------------------- +# All the functions called inside func_options are hookable. See the +# individual implementations for details. +func_hookable func_options +func_options () +{ + $debug_cmd + + func_options_prep ${1+"$@"} + eval func_parse_options \ + ${func_options_prep_result+"$func_options_prep_result"} + eval func_validate_options \ + ${func_parse_options_result+"$func_parse_options_result"} + + eval func_run_hooks func_options \ + ${func_validate_options_result+"$func_validate_options_result"} + + # save modified positional parameters for caller + func_options_result=$func_run_hooks_result +} + + +# func_options_prep [ARG]... +# -------------------------- +# All initialisations required before starting the option parse loop. +# Note that when calling hook functions, we pass through the list of +# positional parameters. If a hook function modifies that list, and +# needs to propogate that back to rest of this script, then the complete +# modified list must be put in 'func_run_hooks_result' before +# returning. +func_hookable func_options_prep +func_options_prep () +{ + $debug_cmd + + # Option defaults: + opt_verbose=false + opt_warning_types= + + func_run_hooks func_options_prep ${1+"$@"} + + # save modified positional parameters for caller + func_options_prep_result=$func_run_hooks_result +} + + +# func_parse_options [ARG]... +# --------------------------- +# The main option parsing loop. +func_hookable func_parse_options +func_parse_options () +{ + $debug_cmd + + func_parse_options_result= + + # this just eases exit handling + while test $# -gt 0; do + # Defer to hook functions for initial option parsing, so they + # get priority in the event of reusing an option name. + func_run_hooks func_parse_options ${1+"$@"} + + # Adjust func_parse_options positional parameters to match + eval set dummy "$func_run_hooks_result"; shift + + # Break out of the loop if we already parsed every option. + test $# -gt 0 || break + + _G_opt=$1 + shift + case $_G_opt in + --debug|-x) debug_cmd='set -x' + func_echo "enabling shell trace mode" + $debug_cmd + ;; + + --no-warnings|--no-warning|--no-warn) + set dummy --warnings none ${1+"$@"} + shift + ;; + + --warnings|--warning|-W) + test $# = 0 && func_missing_arg $_G_opt && break + case " $warning_categories $1" in + *" $1 "*) + # trailing space prevents matching last $1 above + func_append_uniq opt_warning_types " $1" + ;; + *all) + opt_warning_types=$warning_categories + ;; + *none) + opt_warning_types=none + warning_func=: + ;; + *error) + opt_warning_types=$warning_categories + warning_func=func_fatal_error + ;; + *) + func_fatal_error \ + "unsupported warning category: '$1'" + ;; + esac + shift + ;; + + --verbose|-v) opt_verbose=: ;; + --version) func_version ;; + -\?|-h) func_usage ;; + --help) func_help ;; + + # Separate optargs to long options (plugins may need this): + --*=*) func_split_equals "$_G_opt" + set dummy "$func_split_equals_lhs" \ + "$func_split_equals_rhs" ${1+"$@"} + shift + ;; + + # Separate optargs to short options: + -W*) + func_split_short_opt "$_G_opt" + set dummy "$func_split_short_opt_name" \ + "$func_split_short_opt_arg" ${1+"$@"} + shift + ;; + + # Separate non-argument short options: + -\?*|-h*|-v*|-x*) + func_split_short_opt "$_G_opt" + set dummy "$func_split_short_opt_name" \ + "-$func_split_short_opt_arg" ${1+"$@"} + shift + ;; + + --) break ;; + -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; + *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + esac + done + + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + func_parse_options_result=$func_quote_for_eval_result +} + + +# func_validate_options [ARG]... +# ------------------------------ +# Perform any sanity checks on option settings and/or unconsumed +# arguments. +func_hookable func_validate_options +func_validate_options () +{ + $debug_cmd + + # Display all warnings if -W was not given. + test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" + + func_run_hooks func_validate_options ${1+"$@"} + + # Bail if the options were screwed! + $exit_cmd $EXIT_FAILURE + + # save modified positional parameters for caller + func_validate_options_result=$func_run_hooks_result +} + + + +## ----------------- ## +## Helper functions. ## +## ----------------- ## + +# This section contains the helper functions used by the rest of the +# hookable option parser framework in ascii-betical order. + + +# func_fatal_help ARG... +# ---------------------- +# Echo program name prefixed message to standard error, followed by +# a help hint, and exit. +func_fatal_help () +{ + $debug_cmd + + eval \$ECHO \""Usage: $usage"\" + eval \$ECHO \""$fatal_help"\" + func_error ${1+"$@"} + exit $EXIT_FAILURE +} + + +# func_help +# --------- +# Echo long help message to standard output and exit. +func_help () +{ + $debug_cmd + + func_usage_message + $ECHO "$long_help_message" + exit 0 +} + + +# func_missing_arg ARGNAME +# ------------------------ +# Echo program name prefixed message to standard error and set global +# exit_cmd. +func_missing_arg () +{ + $debug_cmd + + func_error "Missing argument for '$1'." + exit_cmd=exit +} + + +# func_split_equals STRING +# ------------------------ +# Set func_split_equals_lhs and func_split_equals_rhs shell variables after +# splitting STRING at the '=' sign. +test -z "$_G_HAVE_XSI_OPS" \ + && (eval 'x=a/b/c; + test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ + && _G_HAVE_XSI_OPS=yes + +if test yes = "$_G_HAVE_XSI_OPS" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_split_equals () + { + $debug_cmd + + func_split_equals_lhs=${1%%=*} + func_split_equals_rhs=${1#*=} + test "x$func_split_equals_lhs" = "x$1" \ + && func_split_equals_rhs= + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_split_equals () + { + $debug_cmd + + func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` + func_split_equals_rhs= + test "x$func_split_equals_lhs" = "x$1" \ + || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` + } +fi #func_split_equals + + +# func_split_short_opt SHORTOPT +# ----------------------------- +# Set func_split_short_opt_name and func_split_short_opt_arg shell +# variables after splitting SHORTOPT after the 2nd character. +if test yes = "$_G_HAVE_XSI_OPS" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_split_short_opt () + { + $debug_cmd + + func_split_short_opt_arg=${1#??} + func_split_short_opt_name=${1%"$func_split_short_opt_arg"} + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_split_short_opt () + { + $debug_cmd + + func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` + func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` + } +fi #func_split_short_opt + + +# func_usage +# ---------- +# Echo short help message to standard output and exit. +func_usage () +{ + $debug_cmd + + func_usage_message + $ECHO "Run '$progname --help |${PAGER-more}' for full usage" + exit 0 +} + + +# func_usage_message +# ------------------ +# Echo short help message to standard output. +func_usage_message () +{ + $debug_cmd + + eval \$ECHO \""Usage: $usage"\" + echo + $SED -n 's|^# || + /^Written by/{ + x;p;x + } + h + /^Written by/q' < "$progpath" + echo + eval \$ECHO \""$usage_message"\" +} + + +# func_version +# ------------ +# Echo version message to standard output and exit. +func_version () +{ + $debug_cmd + + printf '%s\n' "$progname $scriptversion" + $SED -n ' + /(C)/!b go + :more + /\./!{ + N + s|\n# | | + b more + } + :go + /^# Written by /,/# warranty; / { + s|^# || + s|^# *$|| + s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| + p + } + /^# Written by / { + s|^# || + p + } + /^warranty; /q' < "$progpath" + + exit $? +} + + +# Local variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-time-zone: "UTC" +# End: + +# Set a version string. +scriptversion='(GNU libtool) 2.4.6' + + +# func_echo ARG... +# ---------------- +# Libtool also displays the current mode in messages, so override +# funclib.sh func_echo with this custom definition. +func_echo () +{ + $debug_cmd + + _G_message=$* + + func_echo_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_IFS + $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" + done + IFS=$func_echo_IFS +} + + +# func_warning ARG... +# ------------------- +# Libtool warnings are not categorized, so override funclib.sh +# func_warning with this simpler definition. +func_warning () +{ + $debug_cmd + + $warning_func ${1+"$@"} +} + + +## ---------------- ## +## Options parsing. ## +## ---------------- ## + +# Hook in the functions to make sure our own options are parsed during +# the option parsing loop. + +usage='$progpath [OPTION]... [MODE-ARG]...' + +# Short help message in response to '-h'. +usage_message="Options: + --config show all configuration variables + --debug enable verbose shell tracing + -n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --mode=MODE use operation mode MODE + --no-warnings equivalent to '-Wnone' + --preserve-dup-deps don't remove duplicate dependency libraries + --quiet, --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG + -v, --verbose print more informational messages than default + --version print version information + -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] + -h, --help, --help-all print short, long, or detailed help message +" + +# Additional text appended to 'usage_message' in response to '--help'. +func_help () +{ + $debug_cmd + + func_usage_message + $ECHO "$long_help_message + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. When passed as first option, +'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. +Try '$progname --help --mode=MODE' for a more detailed description of MODE. + +When reporting a bug, please describe a test case to reproduce it and +include the following information: + + host-triplet: $host + shell: $SHELL + compiler: $LTCC + compiler flags: $LTCFLAGS + linker: $LD (gnu? $with_gnu_ld) + version: $progname (GNU libtool) 2.4.6 + automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` + autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` + +Report bugs to . +GNU libtool home page: . +General help using GNU software: ." + exit 0 +} + + +# func_lo2o OBJECT-NAME +# --------------------- +# Transform OBJECT-NAME from a '.lo' suffix to the platform specific +# object suffix. + +lo2o=s/\\.lo\$/.$objext/ +o2lo=s/\\.$objext\$/.lo/ + +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_lo2o () + { + case $1 in + *.lo) func_lo2o_result=${1%.lo}.$objext ;; + * ) func_lo2o_result=$1 ;; + esac + }' + + # func_xform LIBOBJ-OR-SOURCE + # --------------------------- + # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) + # suffix to a '.lo' libtool-object suffix. + eval 'func_xform () + { + func_xform_result=${1%.*}.lo + }' +else + # ...otherwise fall back to using sed. + func_lo2o () + { + func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` + } + + func_xform () + { + func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` + } +fi + + +# func_fatal_configuration ARG... +# ------------------------------- +# Echo program name prefixed message to standard error, followed by +# a configuration failure hint, and exit. +func_fatal_configuration () +{ + func__fatal_error ${1+"$@"} \ + "See the $PACKAGE documentation for more information." \ + "Fatal configuration error." +} + + +# func_config +# ----------- +# Display the configuration for all the tags in this script. +func_config () +{ + re_begincf='^# ### BEGIN LIBTOOL' + re_endcf='^# ### END LIBTOOL' + + # Default configuration. + $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" + + # Now print the configurations for the tags. + for tagname in $taglist; do + $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" + done + + exit $? +} + + +# func_features +# ------------- +# Display the features supported by this script. +func_features () +{ + echo "host: $host" + if test yes = "$build_libtool_libs"; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test yes = "$build_old_libs"; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + + exit $? +} + + +# func_enable_tag TAGNAME +# ----------------------- +# Verify that TAGNAME is valid, and either flag an error and exit, or +# enable the TAGNAME tag. We also add TAGNAME to the global $taglist +# variable here. +func_enable_tag () +{ + # Global variable: + tagname=$1 + + re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" + re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" + sed_extractcf=/$re_begincf/,/$re_endcf/p + + # Validate tagname. + case $tagname in + *[!-_A-Za-z0-9,/]*) + func_fatal_error "invalid tag name: $tagname" + ;; + esac + + # Don't test for the "default" C tag, as we know it's + # there but not specially marked. + case $tagname in + CC) ;; + *) + if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then + taglist="$taglist $tagname" + + # Evaluate the configuration. Be careful to quote the path + # and the sed script, to avoid splitting on whitespace, but + # also don't use non-portable quotes within backquotes within + # quotes we have to do it in 2 steps: + extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` + eval "$extractedcf" + else + func_error "ignoring unknown tag $tagname" + fi + ;; + esac +} + + +# func_check_version_match +# ------------------------ +# Ensure that we are using m4 macros, and libtool script from the same +# release of libtool. +func_check_version_match () +{ + if test "$package_revision" != "$macro_revision"; then + if test "$VERSION" != "$macro_version"; then + if test -z "$macro_version"; then + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from an older release. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + fi + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, +$progname: but the definition of this LT_INIT comes from revision $macro_revision. +$progname: You should recreate aclocal.m4 with macros from revision $package_revision +$progname: of $PACKAGE $VERSION and run autoconf again. +_LT_EOF + fi + + exit $EXIT_MISMATCH + fi +} + + +# libtool_options_prep [ARG]... +# ----------------------------- +# Preparation for options parsed by libtool. +libtool_options_prep () +{ + $debug_mode + + # Option defaults: + opt_config=false + opt_dlopen= + opt_dry_run=false + opt_help=false + opt_mode= + opt_preserve_dup_deps=false + opt_quiet=false + + nonopt= + preserve_args= + + # Shorthand for --mode=foo, only valid as the first argument + case $1 in + clean|clea|cle|cl) + shift; set dummy --mode clean ${1+"$@"}; shift + ;; + compile|compil|compi|comp|com|co|c) + shift; set dummy --mode compile ${1+"$@"}; shift + ;; + execute|execut|execu|exec|exe|ex|e) + shift; set dummy --mode execute ${1+"$@"}; shift + ;; + finish|finis|fini|fin|fi|f) + shift; set dummy --mode finish ${1+"$@"}; shift + ;; + install|instal|insta|inst|ins|in|i) + shift; set dummy --mode install ${1+"$@"}; shift + ;; + link|lin|li|l) + shift; set dummy --mode link ${1+"$@"}; shift + ;; + uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) + shift; set dummy --mode uninstall ${1+"$@"}; shift + ;; + esac + + # Pass back the list of options. + func_quote_for_eval ${1+"$@"} + libtool_options_prep_result=$func_quote_for_eval_result +} +func_add_hook func_options_prep libtool_options_prep + + +# libtool_parse_options [ARG]... +# --------------------------------- +# Provide handling for libtool specific options. +libtool_parse_options () +{ + $debug_cmd + + # Perform our own loop to consume as many options as possible in + # each iteration. + while test $# -gt 0; do + _G_opt=$1 + shift + case $_G_opt in + --dry-run|--dryrun|-n) + opt_dry_run=: + ;; + + --config) func_config ;; + + --dlopen|-dlopen) + opt_dlopen="${opt_dlopen+$opt_dlopen +}$1" + shift + ;; + + --preserve-dup-deps) + opt_preserve_dup_deps=: ;; + + --features) func_features ;; + + --finish) set dummy --mode finish ${1+"$@"}; shift ;; + + --help) opt_help=: ;; + + --help-all) opt_help=': help-all' ;; + + --mode) test $# = 0 && func_missing_arg $_G_opt && break + opt_mode=$1 + case $1 in + # Valid mode arguments: + clean|compile|execute|finish|install|link|relink|uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $_G_opt" + exit_cmd=exit + break + ;; + esac + shift + ;; + + --no-silent|--no-quiet) + opt_quiet=false + func_append preserve_args " $_G_opt" + ;; + + --no-warnings|--no-warning|--no-warn) + opt_warning=false + func_append preserve_args " $_G_opt" + ;; + + --no-verbose) + opt_verbose=false + func_append preserve_args " $_G_opt" + ;; + + --silent|--quiet) + opt_quiet=: + opt_verbose=false + func_append preserve_args " $_G_opt" + ;; + + --tag) test $# = 0 && func_missing_arg $_G_opt && break + opt_tag=$1 + func_append preserve_args " $_G_opt $1" + func_enable_tag "$1" + shift + ;; + + --verbose|-v) opt_quiet=false + opt_verbose=: + func_append preserve_args " $_G_opt" + ;; + + # An option not handled by this hook function: + *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + esac + done + + + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + libtool_parse_options_result=$func_quote_for_eval_result +} +func_add_hook func_parse_options libtool_parse_options + + + +# libtool_validate_options [ARG]... +# --------------------------------- +# Perform any sanity checks on option settings and/or unconsumed +# arguments. +libtool_validate_options () +{ + # save first non-option argument + if test 0 -lt $#; then + nonopt=$1 + shift + fi + + # preserve --debug + test : = "$debug_cmd" || func_append preserve_args " --debug" + + case $host in + # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 + # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 + *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; + *) + opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps + ;; + esac + + $opt_help || { + # Sanity checks first: + func_check_version_match + + test yes != "$build_libtool_libs" \ + && test yes != "$build_old_libs" \ + && func_fatal_configuration "not configured to build any kind of library" + + # Darwin sucks + eval std_shrext=\"$shrext_cmds\" + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$opt_dlopen" && test execute != "$opt_mode"; then + func_error "unrecognized option '-dlopen'" + $ECHO "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help=$help + help="Try '$progname --help --mode=$opt_mode' for more information." + } + + # Pass back the unparsed argument list + func_quote_for_eval ${1+"$@"} + libtool_validate_options_result=$func_quote_for_eval_result +} +func_add_hook func_validate_options libtool_validate_options + + +# Process options as early as possible so that --help and --version +# can return quickly. +func_options ${1+"$@"} +eval set dummy "$func_options_result"; shift + + + +## ----------- ## +## Main. ## +## ----------- ## + +magic='%%%MAGIC variable%%%' +magic_exe='%%%MAGIC EXE variable%%%' + +# Global variables. +extracted_archives= +extracted_serial=0 + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + +# func_generated_by_libtool +# True iff stdin has been generated by Libtool. This function is only +# a basic sanity check; it will hardly flush out determined imposters. +func_generated_by_libtool_p () +{ + $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 +} + +# func_lalib_p file +# True iff FILE is a libtool '.la' library or '.lo' object file. +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_lalib_p () +{ + test -f "$1" && + $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p +} + +# func_lalib_unsafe_p file +# True iff FILE is a libtool '.la' library or '.lo' object file. +# This function implements the same check as func_lalib_p without +# resorting to external programs. To this end, it redirects stdin and +# closes it afterwards, without saving the original file descriptor. +# As a safety measure, use it only where a negative result would be +# fatal anyway. Works if 'file' does not exist. +func_lalib_unsafe_p () +{ + lalib_p=no + if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then + for lalib_p_l in 1 2 3 4 + do + read lalib_p_line + case $lalib_p_line in + \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; + esac + done + exec 0<&5 5<&- + fi + test yes = "$lalib_p" +} + +# func_ltwrapper_script_p file +# True iff FILE is a libtool wrapper script +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_script_p () +{ + test -f "$1" && + $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p +} + +# func_ltwrapper_executable_p file +# True iff FILE is a libtool wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_executable_p () +{ + func_ltwrapper_exec_suffix= + case $1 in + *.exe) ;; + *) func_ltwrapper_exec_suffix=.exe ;; + esac + $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 +} + +# func_ltwrapper_scriptname file +# Assumes file is an ltwrapper_executable +# uses $file to determine the appropriate filename for a +# temporary ltwrapper_script. +func_ltwrapper_scriptname () +{ + func_dirname_and_basename "$1" "" "." + func_stripname '' '.exe' "$func_basename_result" + func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper +} + +# func_ltwrapper_p file +# True iff FILE is a libtool wrapper script or wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_p () +{ + func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" +} + + +# func_execute_cmds commands fail_cmd +# Execute tilde-delimited COMMANDS. +# If FAIL_CMD is given, eval that upon failure. +# FAIL_CMD may read-access the current command in variable CMD! +func_execute_cmds () +{ + $debug_cmd + + save_ifs=$IFS; IFS='~' + for cmd in $1; do + IFS=$sp$nl + eval cmd=\"$cmd\" + IFS=$save_ifs + func_show_eval "$cmd" "${2-:}" + done + IFS=$save_ifs +} + + +# func_source file +# Source FILE, adding directory component if necessary. +# Note that it is not necessary on cygwin/mingw to append a dot to +# FILE even if both FILE and FILE.exe exist: automatic-append-.exe +# behavior happens only for exec(3), not for open(2)! Also, sourcing +# 'FILE.' does not work on cygwin managed mounts. +func_source () +{ + $debug_cmd + + case $1 in + */* | *\\*) . "$1" ;; + *) . "./$1" ;; + esac +} + + +# func_resolve_sysroot PATH +# Replace a leading = in PATH with a sysroot. Store the result into +# func_resolve_sysroot_result +func_resolve_sysroot () +{ + func_resolve_sysroot_result=$1 + case $func_resolve_sysroot_result in + =*) + func_stripname '=' '' "$func_resolve_sysroot_result" + func_resolve_sysroot_result=$lt_sysroot$func_stripname_result + ;; + esac +} + +# func_replace_sysroot PATH +# If PATH begins with the sysroot, replace it with = and +# store the result into func_replace_sysroot_result. +func_replace_sysroot () +{ + case $lt_sysroot:$1 in + ?*:"$lt_sysroot"*) + func_stripname "$lt_sysroot" '' "$1" + func_replace_sysroot_result='='$func_stripname_result + ;; + *) + # Including no sysroot. + func_replace_sysroot_result=$1 + ;; + esac +} + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () +{ + $debug_cmd + + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + func_append_quoted CC_quoted "$arg" + done + CC_expanded=`func_echo_all $CC` + CC_quoted_expanded=`func_echo_all $CC_quoted` + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ + " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + func_append_quoted CC_quoted "$arg" + done + CC_expanded=`func_echo_all $CC` + CC_quoted_expanded=`func_echo_all $CC_quoted` + case "$@ " in + " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ + " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + func_echo "unable to infer tagged configuration" + func_fatal_error "specify a tag with '--tag'" +# else +# func_verbose "using $tagname tagged configuration" + fi + ;; + esac + fi +} + + + +# func_write_libtool_object output_name pic_name nonpic_name +# Create a libtool object file (analogous to a ".la" file), +# but don't create it if we're doing a dry run. +func_write_libtool_object () +{ + write_libobj=$1 + if test yes = "$build_libtool_libs"; then + write_lobj=\'$2\' + else + write_lobj=none + fi + + if test yes = "$build_old_libs"; then + write_oldobj=\'$3\' + else + write_oldobj=none + fi + + $opt_dry_run || { + cat >${write_libobj}T </dev/null` + if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then + func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | + $SED -e "$sed_naive_backslashify"` + else + func_convert_core_file_wine_to_w32_result= + fi + fi +} +# end: func_convert_core_file_wine_to_w32 + + +# func_convert_core_path_wine_to_w32 ARG +# Helper function used by path conversion functions when $build is *nix, and +# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly +# configured wine environment available, with the winepath program in $build's +# $PATH. Assumes ARG has no leading or trailing path separator characters. +# +# ARG is path to be converted from $build format to win32. +# Result is available in $func_convert_core_path_wine_to_w32_result. +# Unconvertible file (directory) names in ARG are skipped; if no directory names +# are convertible, then the result may be empty. +func_convert_core_path_wine_to_w32 () +{ + $debug_cmd + + # unfortunately, winepath doesn't convert paths, only file names + func_convert_core_path_wine_to_w32_result= + if test -n "$1"; then + oldIFS=$IFS + IFS=: + for func_convert_core_path_wine_to_w32_f in $1; do + IFS=$oldIFS + func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" + if test -n "$func_convert_core_file_wine_to_w32_result"; then + if test -z "$func_convert_core_path_wine_to_w32_result"; then + func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result + else + func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" + fi + fi + done + IFS=$oldIFS + fi +} +# end: func_convert_core_path_wine_to_w32 + + +# func_cygpath ARGS... +# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when +# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) +# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or +# (2), returns the Cygwin file name or path in func_cygpath_result (input +# file name or path is assumed to be in w32 format, as previously converted +# from $build's *nix or MSYS format). In case (3), returns the w32 file name +# or path in func_cygpath_result (input file name or path is assumed to be in +# Cygwin format). Returns an empty string on error. +# +# ARGS are passed to cygpath, with the last one being the file name or path to +# be converted. +# +# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH +# environment variable; do not put it in $PATH. +func_cygpath () +{ + $debug_cmd + + if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then + func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` + if test "$?" -ne 0; then + # on failure, ensure result is empty + func_cygpath_result= + fi + else + func_cygpath_result= + func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" + fi +} +#end: func_cygpath + + +# func_convert_core_msys_to_w32 ARG +# Convert file name or path ARG from MSYS format to w32 format. Return +# result in func_convert_core_msys_to_w32_result. +func_convert_core_msys_to_w32 () +{ + $debug_cmd + + # awkward: cmd appends spaces to result + func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | + $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` +} +#end: func_convert_core_msys_to_w32 + + +# func_convert_file_check ARG1 ARG2 +# Verify that ARG1 (a file name in $build format) was converted to $host +# format in ARG2. Otherwise, emit an error message, but continue (resetting +# func_to_host_file_result to ARG1). +func_convert_file_check () +{ + $debug_cmd + + if test -z "$2" && test -n "$1"; then + func_error "Could not determine host file name corresponding to" + func_error " '$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback: + func_to_host_file_result=$1 + fi +} +# end func_convert_file_check + + +# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH +# Verify that FROM_PATH (a path in $build format) was converted to $host +# format in TO_PATH. Otherwise, emit an error message, but continue, resetting +# func_to_host_file_result to a simplistic fallback value (see below). +func_convert_path_check () +{ + $debug_cmd + + if test -z "$4" && test -n "$3"; then + func_error "Could not determine the host path corresponding to" + func_error " '$3'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback. This is a deliberately simplistic "conversion" and + # should not be "improved". See libtool.info. + if test "x$1" != "x$2"; then + lt_replace_pathsep_chars="s|$1|$2|g" + func_to_host_path_result=`echo "$3" | + $SED -e "$lt_replace_pathsep_chars"` + else + func_to_host_path_result=$3 + fi + fi +} +# end func_convert_path_check + + +# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG +# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT +# and appending REPL if ORIG matches BACKPAT. +func_convert_path_front_back_pathsep () +{ + $debug_cmd + + case $4 in + $1 ) func_to_host_path_result=$3$func_to_host_path_result + ;; + esac + case $4 in + $2 ) func_append func_to_host_path_result "$3" + ;; + esac +} +# end func_convert_path_front_back_pathsep + + +################################################## +# $build to $host FILE NAME CONVERSION FUNCTIONS # +################################################## +# invoked via '$to_host_file_cmd ARG' +# +# In each case, ARG is the path to be converted from $build to $host format. +# Result will be available in $func_to_host_file_result. + + +# func_to_host_file ARG +# Converts the file name ARG from $build format to $host format. Return result +# in func_to_host_file_result. +func_to_host_file () +{ + $debug_cmd + + $to_host_file_cmd "$1" +} +# end func_to_host_file + + +# func_to_tool_file ARG LAZY +# converts the file name ARG from $build format to toolchain format. Return +# result in func_to_tool_file_result. If the conversion in use is listed +# in (the comma separated) LAZY, no conversion takes place. +func_to_tool_file () +{ + $debug_cmd + + case ,$2, in + *,"$to_tool_file_cmd",*) + func_to_tool_file_result=$1 + ;; + *) + $to_tool_file_cmd "$1" + func_to_tool_file_result=$func_to_host_file_result + ;; + esac +} +# end func_to_tool_file + + +# func_convert_file_noop ARG +# Copy ARG to func_to_host_file_result. +func_convert_file_noop () +{ + func_to_host_file_result=$1 +} +# end func_convert_file_noop + + +# func_convert_file_msys_to_w32 ARG +# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic +# conversion to w32 is not available inside the cwrapper. Returns result in +# func_to_host_file_result. +func_convert_file_msys_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_msys_to_w32 "$1" + func_to_host_file_result=$func_convert_core_msys_to_w32_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_msys_to_w32 + + +# func_convert_file_cygwin_to_w32 ARG +# Convert file name ARG from Cygwin to w32 format. Returns result in +# func_to_host_file_result. +func_convert_file_cygwin_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + # because $build is cygwin, we call "the" cygpath in $PATH; no need to use + # LT_CYGPATH in this case. + func_to_host_file_result=`cygpath -m "$1"` + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_cygwin_to_w32 + + +# func_convert_file_nix_to_w32 ARG +# Convert file name ARG from *nix to w32 format. Requires a wine environment +# and a working winepath. Returns result in func_to_host_file_result. +func_convert_file_nix_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_file_wine_to_w32 "$1" + func_to_host_file_result=$func_convert_core_file_wine_to_w32_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_nix_to_w32 + + +# func_convert_file_msys_to_cygwin ARG +# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. +# Returns result in func_to_host_file_result. +func_convert_file_msys_to_cygwin () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_msys_to_w32 "$1" + func_cygpath -u "$func_convert_core_msys_to_w32_result" + func_to_host_file_result=$func_cygpath_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_msys_to_cygwin + + +# func_convert_file_nix_to_cygwin ARG +# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed +# in a wine environment, working winepath, and LT_CYGPATH set. Returns result +# in func_to_host_file_result. +func_convert_file_nix_to_cygwin () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. + func_convert_core_file_wine_to_w32 "$1" + func_cygpath -u "$func_convert_core_file_wine_to_w32_result" + func_to_host_file_result=$func_cygpath_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_nix_to_cygwin + + +############################################# +# $build to $host PATH CONVERSION FUNCTIONS # +############################################# +# invoked via '$to_host_path_cmd ARG' +# +# In each case, ARG is the path to be converted from $build to $host format. +# The result will be available in $func_to_host_path_result. +# +# Path separators are also converted from $build format to $host format. If +# ARG begins or ends with a path separator character, it is preserved (but +# converted to $host format) on output. +# +# All path conversion functions are named using the following convention: +# file name conversion function : func_convert_file_X_to_Y () +# path conversion function : func_convert_path_X_to_Y () +# where, for any given $build/$host combination the 'X_to_Y' value is the +# same. If conversion functions are added for new $build/$host combinations, +# the two new functions must follow this pattern, or func_init_to_host_path_cmd +# will break. + + +# func_init_to_host_path_cmd +# Ensures that function "pointer" variable $to_host_path_cmd is set to the +# appropriate value, based on the value of $to_host_file_cmd. +to_host_path_cmd= +func_init_to_host_path_cmd () +{ + $debug_cmd + + if test -z "$to_host_path_cmd"; then + func_stripname 'func_convert_file_' '' "$to_host_file_cmd" + to_host_path_cmd=func_convert_path_$func_stripname_result + fi +} + + +# func_to_host_path ARG +# Converts the path ARG from $build format to $host format. Return result +# in func_to_host_path_result. +func_to_host_path () +{ + $debug_cmd + + func_init_to_host_path_cmd + $to_host_path_cmd "$1" +} +# end func_to_host_path + + +# func_convert_path_noop ARG +# Copy ARG to func_to_host_path_result. +func_convert_path_noop () +{ + func_to_host_path_result=$1 +} +# end func_convert_path_noop + + +# func_convert_path_msys_to_w32 ARG +# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic +# conversion to w32 is not available inside the cwrapper. Returns result in +# func_to_host_path_result. +func_convert_path_msys_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # Remove leading and trailing path separator characters from ARG. MSYS + # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; + # and winepath ignores them completely. + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" + func_to_host_path_result=$func_convert_core_msys_to_w32_result + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_msys_to_w32 + + +# func_convert_path_cygwin_to_w32 ARG +# Convert path ARG from Cygwin to w32 format. Returns result in +# func_to_host_file_result. +func_convert_path_cygwin_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_cygwin_to_w32 + + +# func_convert_path_nix_to_w32 ARG +# Convert path ARG from *nix to w32 format. Requires a wine environment and +# a working winepath. Returns result in func_to_host_file_result. +func_convert_path_nix_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" + func_to_host_path_result=$func_convert_core_path_wine_to_w32_result + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_nix_to_w32 + + +# func_convert_path_msys_to_cygwin ARG +# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. +# Returns result in func_to_host_file_result. +func_convert_path_msys_to_cygwin () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" + func_cygpath -u -p "$func_convert_core_msys_to_w32_result" + func_to_host_path_result=$func_cygpath_result + func_convert_path_check : : \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" : "$1" + fi +} +# end func_convert_path_msys_to_cygwin + + +# func_convert_path_nix_to_cygwin ARG +# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a +# a wine environment, working winepath, and LT_CYGPATH set. Returns result in +# func_to_host_file_result. +func_convert_path_nix_to_cygwin () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # Remove leading and trailing path separator characters from + # ARG. msys behavior is inconsistent here, cygpath turns them + # into '.;' and ';.', and winepath ignores them completely. + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" + func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" + func_to_host_path_result=$func_cygpath_result + func_convert_path_check : : \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" : "$1" + fi +} +# end func_convert_path_nix_to_cygwin + + +# func_dll_def_p FILE +# True iff FILE is a Windows DLL '.def' file. +# Keep in sync with _LT_DLL_DEF_P in libtool.m4 +func_dll_def_p () +{ + $debug_cmd + + func_dll_def_p_tmp=`$SED -n \ + -e 's/^[ ]*//' \ + -e '/^\(;.*\)*$/d' \ + -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ + -e q \ + "$1"` + test DEF = "$func_dll_def_p_tmp" +} + + +# func_mode_compile arg... +func_mode_compile () +{ + $debug_cmd + + # Get the compilation command and the source file. + base_compile= + srcfile=$nonopt # always keep a non-empty value in "srcfile" + suppress_opt=yes + suppress_output= + arg_mode=normal + libobj= + later= + pie_flag= + + for arg + do + case $arg_mode in + arg ) + # do not "continue". Instead, add this to base_compile + lastarg=$arg + arg_mode=normal + ;; + + target ) + libobj=$arg + arg_mode=normal + continue + ;; + + normal ) + # Accept any command-line options. + case $arg in + -o) + test -n "$libobj" && \ + func_fatal_error "you cannot specify '-o' more than once" + arg_mode=target + continue + ;; + + -pie | -fpie | -fPIE) + func_append pie_flag " $arg" + continue + ;; + + -shared | -static | -prefer-pic | -prefer-non-pic) + func_append later " $arg" + continue + ;; + + -no-suppress) + suppress_opt=no + continue + ;; + + -Xcompiler) + arg_mode=arg # the next one goes into the "base_compile" arg list + continue # The current "srcfile" will either be retained or + ;; # replaced later. I would guess that would be a bug. + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + lastarg= + save_ifs=$IFS; IFS=, + for arg in $args; do + IFS=$save_ifs + func_append_quoted lastarg "$arg" + done + IFS=$save_ifs + func_stripname ' ' '' "$lastarg" + lastarg=$func_stripname_result + + # Add the arguments to base_compile. + func_append base_compile " $lastarg" + continue + ;; + + *) + # Accept the current argument as the source file. + # The previous "srcfile" becomes the current argument. + # + lastarg=$srcfile + srcfile=$arg + ;; + esac # case $arg + ;; + esac # case $arg_mode + + # Aesthetically quote the previous argument. + func_append_quoted base_compile "$lastarg" + done # for arg + + case $arg_mode in + arg) + func_fatal_error "you must specify an argument for -Xcompile" + ;; + target) + func_fatal_error "you must specify a target with '-o'" + ;; + *) + # Get the name of the library object. + test -z "$libobj" && { + func_basename "$srcfile" + libobj=$func_basename_result + } + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + case $libobj in + *.[cCFSifmso] | \ + *.ada | *.adb | *.ads | *.asm | \ + *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ + *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) + func_xform "$libobj" + libobj=$func_xform_result + ;; + esac + + case $libobj in + *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; + *) + func_fatal_error "cannot determine name of library object from '$libobj'" + ;; + esac + + func_infer_tag $base_compile + + for arg in $later; do + case $arg in + -shared) + test yes = "$build_libtool_libs" \ + || func_fatal_configuration "cannot build a shared library" + build_old_libs=no + continue + ;; + + -static) + build_libtool_libs=no + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + esac + done + + func_quote_for_eval "$libobj" + test "X$libobj" != "X$func_quote_for_eval_result" \ + && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ + && func_warning "libobj name '$libobj' may not contain shell special characters." + func_dirname_and_basename "$obj" "/" "" + objname=$func_basename_result + xdir=$func_dirname_result + lobj=$xdir$objdir/$objname + + test -z "$base_compile" && \ + func_fatal_help "you must specify a compilation command" + + # Delete any leftover library objects. + if test yes = "$build_old_libs"; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2* | cegcc*) + pic_mode=default + ;; + esac + if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test no = "$compiler_c_o"; then + output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext + lockfile=$output_obj.lock + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test yes = "$need_locks"; then + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + elif test warn = "$need_locks"; then + if test -f "$lockfile"; then + $ECHO "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + func_append removelist " $output_obj" + $ECHO "$srcfile" > "$lockfile" + fi + + $opt_dry_run || $RM $removelist + func_append removelist " $lockfile" + trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 + + func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 + srcfile=$func_to_tool_file_result + func_quote_for_eval "$srcfile" + qsrcfile=$func_quote_for_eval_result + + # Only build a PIC object if we are building libtool libraries. + if test yes = "$build_libtool_libs"; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test no != "$pic_mode"; then + command="$base_compile $qsrcfile $pic_flag" + else + # Don't build PIC code + command="$base_compile $qsrcfile" + fi + + func_mkdir_p "$xdir$objdir" + + if test -z "$output_obj"; then + # Place PIC objects in $objdir + func_append command " -o $lobj" + fi + + func_show_eval_locale "$command" \ + 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' + + if test warn = "$need_locks" && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + func_show_eval '$MV "$output_obj" "$lobj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + + # Allow error messages only from the first compilation. + if test yes = "$suppress_opt"; then + suppress_output=' >/dev/null 2>&1' + fi + fi + + # Only build a position-dependent object if we build old libraries. + if test yes = "$build_old_libs"; then + if test yes != "$pic_mode"; then + # Don't build PIC code + command="$base_compile $qsrcfile$pie_flag" + else + command="$base_compile $qsrcfile $pic_flag" + fi + if test yes = "$compiler_c_o"; then + func_append command " -o $obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + func_append command "$suppress_output" + func_show_eval_locale "$command" \ + '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' + + if test warn = "$need_locks" && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + func_show_eval '$MV "$output_obj" "$obj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + fi + + $opt_dry_run || { + func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" + + # Unlock the critical section if it was locked + if test no != "$need_locks"; then + removelist=$lockfile + $RM "$lockfile" + fi + } + + exit $EXIT_SUCCESS +} + +$opt_help || { + test compile = "$opt_mode" && func_mode_compile ${1+"$@"} +} + +func_mode_help () +{ + # We need to display help for each of the modes. + case $opt_mode in + "") + # Generic help is extracted from the usage comments + # at the start of this file. + func_help + ;; + + clean) + $ECHO \ +"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + + compile) + $ECHO \ +"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -no-suppress do not suppress compiler output for multiple passes + -prefer-pic try to build PIC objects only + -prefer-non-pic try to build non-PIC objects only + -shared do not build a '.o' file suitable for static linking + -static only build a '.o' file suitable for static linking + -Wc,FLAG pass FLAG directly to the compiler + +COMPILE-COMMAND is a command to be used in creating a 'standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix '.c' with the +library object suffix, '.lo'." + ;; + + execute) + $ECHO \ +"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to '-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + + finish) + $ECHO \ +"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the '--dry-run' option if you just want to see what would be executed." + ;; + + install) + $ECHO \ +"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the 'install' or 'cp' program. + +The following components of INSTALL-COMMAND are treated specially: + + -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + + link) + $ECHO \ +"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -bindir BINDIR specify path to binaries directory (for systems where + libraries must be found in the PATH setting at runtime) + -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE use a list of object files found in FILE to specify objects + -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -shared only do dynamic linking of libtool libraries + -shrext SUFFIX override the standard shared library file extension + -static do not do any dynamic linking of uninstalled libtool libraries + -static-libtool-libs + do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + -weak LIBNAME declare that the target provides the LIBNAME interface + -Wc,FLAG + -Xcompiler FLAG pass linker-specific FLAG directly to the compiler + -Wl,FLAG + -Xlinker FLAG pass linker-specific FLAG directly to the linker + -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) + +All other options (arguments beginning with '-') are ignored. + +Every other argument is treated as a filename. Files ending in '.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in '.la', then a libtool library is created, +only library objects ('.lo' files) may be specified, and '-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created +using 'ar' and 'ranlib', or on Windows using 'lib'. + +If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file +is created, otherwise an executable program is created." + ;; + + uninstall) + $ECHO \ +"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + + *) + func_fatal_help "invalid operation mode '$opt_mode'" + ;; + esac + + echo + $ECHO "Try '$progname --help' for more information about other modes." +} + +# Now that we've collected a possible --mode arg, show help if necessary +if $opt_help; then + if test : = "$opt_help"; then + func_mode_help + else + { + func_help noexit + for opt_mode in compile link execute install finish uninstall clean; do + func_mode_help + done + } | $SED -n '1p; 2,$s/^Usage:/ or: /p' + { + func_help noexit + for opt_mode in compile link execute install finish uninstall clean; do + echo + func_mode_help + done + } | + $SED '1d + /^When reporting/,/^Report/{ + H + d + } + $x + /information about other modes/d + /more detailed .*MODE/d + s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' + fi + exit $? +fi + + +# func_mode_execute arg... +func_mode_execute () +{ + $debug_cmd + + # The first argument is the command name. + cmd=$nonopt + test -z "$cmd" && \ + func_fatal_help "you must specify a COMMAND" + + # Handle -dlopen flags immediately. + for file in $opt_dlopen; do + test -f "$file" \ + || func_fatal_help "'$file' is not a file" + + dir= + case $file in + *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "'$lib' is not a valid libtool archive" + + # Read the libtool library. + dlname= + library_names= + func_source "$file" + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && \ + func_warning "'$file' was not linked with '-export-dynamic'" + continue + fi + + func_dirname "$file" "" "." + dir=$func_dirname_result + + if test -f "$dir/$objdir/$dlname"; then + func_append dir "/$objdir" + else + if test ! -f "$dir/$dlname"; then + func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" + fi + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + func_dirname "$file" "" "." + dir=$func_dirname_result + ;; + + *) + func_warning "'-dlopen' is ignored for non-libtool libraries and objects" + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir=$absdir + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic=$magic + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -* | *.la | *.lo ) ;; + *) + # Do a test to see if this is really a libtool program. + if func_ltwrapper_script_p "$file"; then + func_source "$file" + # Transform arg to wrapped name. + file=$progdir/$program + elif func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + func_source "$func_ltwrapper_scriptname_result" + # Transform arg to wrapped name. + file=$progdir/$program + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + func_append_quoted args "$file" + done + + if $opt_dry_run; then + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" + echo "export $shlibpath_var" + fi + $ECHO "$cmd$args" + exit $EXIT_SUCCESS + else + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES + do + eval "if test \"\${save_$lt_var+set}\" = set; then + $lt_var=\$save_$lt_var; export $lt_var + else + $lt_unset $lt_var + fi" + done + + # Now prepare to actually exec the command. + exec_cmd=\$cmd$args + fi +} + +test execute = "$opt_mode" && func_mode_execute ${1+"$@"} + + +# func_mode_finish arg... +func_mode_finish () +{ + $debug_cmd + + libs= + libdirs= + admincmds= + + for opt in "$nonopt" ${1+"$@"} + do + if test -d "$opt"; then + func_append libdirs " $opt" + + elif test -f "$opt"; then + if func_lalib_unsafe_p "$opt"; then + func_append libs " $opt" + else + func_warning "'$opt' is not a valid libtool archive" + fi + + else + func_fatal_error "invalid argument '$opt'" + fi + done + + if test -n "$libs"; then + if test -n "$lt_sysroot"; then + sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` + sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" + else + sysroot_cmd= + fi + + # Remove sysroot references + if $opt_dry_run; then + for lib in $libs; do + echo "removing references to $lt_sysroot and '=' prefixes from $lib" + done + else + tmpdir=`func_mktempdir` + for lib in $libs; do + $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ + > $tmpdir/tmp-la + mv -f $tmpdir/tmp-la $lib + done + ${RM}r "$tmpdir" + fi + fi + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + func_execute_cmds "$finish_cmds" 'admincmds="$admincmds +'"$cmd"'"' + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $opt_dry_run || eval "$cmds" || func_append admincmds " + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + $opt_quiet && exit $EXIT_SUCCESS + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + $ECHO " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use the '-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the '$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the '$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $ECHO " - use the '$flag' linker flag" + fi + if test -n "$admincmds"; then + $ECHO " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" + fi + echo + + echo "See any operating system documentation about shared libraries for" + case $host in + solaris2.[6789]|solaris2.1[0-9]) + echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" + echo "pages." + ;; + *) + echo "more information, such as the ld(1) and ld.so(8) manual pages." + ;; + esac + echo "----------------------------------------------------------------------" + fi + exit $EXIT_SUCCESS +} + +test finish = "$opt_mode" && func_mode_finish ${1+"$@"} + + +# func_mode_install arg... +func_mode_install () +{ + $debug_cmd + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || + # Allow the use of GNU shtool's install command. + case $nonopt in *shtool*) :;; *) false;; esac + then + # Aesthetically quote it. + func_quote_for_eval "$nonopt" + install_prog="$func_quote_for_eval_result " + arg=$1 + shift + else + install_prog= + arg=$nonopt + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + func_quote_for_eval "$arg" + func_append install_prog "$func_quote_for_eval_result" + install_shared_prog=$install_prog + case " $install_prog " in + *[\\\ /]cp\ *) install_cp=: ;; + *) install_cp=false ;; + esac + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=false + stripme= + no_mode=: + for arg + do + arg2= + if test -n "$dest"; then + func_append files " $dest" + dest=$arg + continue + fi + + case $arg in + -d) isdir=: ;; + -f) + if $install_cp; then :; else + prev=$arg + fi + ;; + -g | -m | -o) + prev=$arg + ;; + -s) + stripme=" -s" + continue + ;; + -*) + ;; + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + if test X-m = "X$prev" && test -n "$install_override_mode"; then + arg2=$install_override_mode + no_mode=false + fi + prev= + else + dest=$arg + continue + fi + ;; + esac + + # Aesthetically quote the argument. + func_quote_for_eval "$arg" + func_append install_prog " $func_quote_for_eval_result" + if test -n "$arg2"; then + func_quote_for_eval "$arg2" + fi + func_append install_shared_prog " $func_quote_for_eval_result" + done + + test -z "$install_prog" && \ + func_fatal_help "you must specify an install program" + + test -n "$prev" && \ + func_fatal_help "the '$prev' option requires an argument" + + if test -n "$install_override_mode" && $no_mode; then + if $install_cp; then :; else + func_quote_for_eval "$install_override_mode" + func_append install_shared_prog " -m $func_quote_for_eval_result" + fi + fi + + if test -z "$files"; then + if test -z "$dest"; then + func_fatal_help "no file or destination specified" + else + func_fatal_help "you must specify a destination" + fi + fi + + # Strip any trailing slash from the destination. + func_stripname '' '/' "$dest" + dest=$func_stripname_result + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=: + if $isdir; then + destdir=$dest + destname= + else + func_dirname_and_basename "$dest" "" "." + destdir=$func_dirname_result + destname=$func_basename_result + + # Not a directory, so check to see that there is only one file specified. + set dummy $files; shift + test "$#" -gt 1 && \ + func_fatal_help "'$dest' is not a directory" + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + func_fatal_help "'$destdir' must be an absolute directory name" + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic=$magic + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + func_append staticlibs " $file" + ;; + + *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "'$file' is not a valid libtool archive" + + library_names= + old_library= + relink_command= + func_source "$file" + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) func_append current_libdirs " $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) func_append future_libdirs " $libdir" ;; + esac + fi + + func_dirname "$file" "/" "" + dir=$func_dirname_result + func_append dir "$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + test "$inst_prefix_dir" = "$destdir" && \ + func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` + fi + + func_warning "relinking '$file'" + func_show_eval "$relink_command" \ + 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' + fi + + # See the names of the shared library. + set dummy $library_names; shift + if test -n "$1"; then + realname=$1 + shift + + srcname=$realname + test -n "$relink_command" && srcname=${realname}T + + # Install the shared library and build the symlinks. + func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ + 'exit $?' + tstripme=$stripme + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + case $realname in + *.dll.a) + tstripme= + ;; + esac + ;; + os2*) + case $realname in + *_dll.a) + tstripme= + ;; + esac + ;; + esac + if test -n "$tstripme" && test -n "$striplib"; then + func_show_eval "$striplib $destdir/$realname" 'exit $?' + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + # Try 'ln -sf' first, because the 'ln' binary might depend on + # the symlink we replace! Solaris /bin/ln does not understand -f, + # so we also need to try rm && ln -s. + for linkname + do + test "$linkname" != "$realname" \ + && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" + done + fi + + # Do each command in the postinstall commands. + lib=$destdir/$realname + func_execute_cmds "$postinstall_cmds" 'exit $?' + fi + + # Install the pseudo-library for information purposes. + func_basename "$file" + name=$func_basename_result + instname=$dir/${name}i + func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' + + # Maybe install the static library, too. + test -n "$old_library" && func_append staticlibs " $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile=$destdir/$destname + else + func_basename "$file" + destfile=$func_basename_result + destfile=$destdir/$destfile + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + func_lo2o "$destfile" + staticdest=$func_lo2o_result + ;; + *.$objext) + staticdest=$destfile + destfile= + ;; + *) + func_fatal_help "cannot copy a libtool object to '$destfile'" + ;; + esac + + # Install the libtool object if requested. + test -n "$destfile" && \ + func_show_eval "$install_prog $file $destfile" 'exit $?' + + # Install the old object if enabled. + if test yes = "$build_old_libs"; then + # Deduce the name of the old-style object file. + func_lo2o "$file" + staticobj=$func_lo2o_result + func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile=$destdir/$destname + else + func_basename "$file" + destfile=$func_basename_result + destfile=$destdir/$destfile + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext= + case $file in + *.exe) + if test ! -f "$file"; then + func_stripname '' '.exe' "$file" + file=$func_stripname_result + stripped_ext=.exe + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin* | *mingw*) + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + wrapper=$func_ltwrapper_scriptname_result + else + func_stripname '' '.exe' "$file" + wrapper=$func_stripname_result + fi + ;; + *) + wrapper=$file + ;; + esac + if func_ltwrapper_script_p "$wrapper"; then + notinst_deplibs= + relink_command= + + func_source "$wrapper" + + # Check the variables that should have been set. + test -z "$generated_by_libtool_version" && \ + func_fatal_error "invalid libtool wrapper script '$wrapper'" + + finalize=: + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + func_source "$lib" + fi + libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` + if test -n "$libdir" && test ! -f "$libfile"; then + func_warning "'$lib' has not been installed in '$libdir'" + finalize=false + fi + done + + relink_command= + func_source "$wrapper" + + outputname= + if test no = "$fast_install" && test -n "$relink_command"; then + $opt_dry_run || { + if $finalize; then + tmpdir=`func_mktempdir` + func_basename "$file$stripped_ext" + file=$func_basename_result + outputname=$tmpdir/$file + # Replace the output file specification. + relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` + + $opt_quiet || { + func_quote_for_expand "$relink_command" + eval "func_echo $func_quote_for_expand_result" + } + if eval "$relink_command"; then : + else + func_error "error: relink '$file' with the above command before installing it" + $opt_dry_run || ${RM}r "$tmpdir" + continue + fi + file=$outputname + else + func_warning "cannot relink '$file'" + fi + } + else + # Install the binary that we compiled earlier. + file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + func_stripname '' '.exe' "$destfile" + destfile=$func_stripname_result + ;; + esac + ;; + esac + func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' + $opt_dry_run || if test -n "$outputname"; then + ${RM}r "$tmpdir" + fi + ;; + esac + done + + for file in $staticlibs; do + func_basename "$file" + name=$func_basename_result + + # Set up the ranlib parameters. + oldlib=$destdir/$name + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result + + func_show_eval "$install_prog \$file \$oldlib" 'exit $?' + + if test -n "$stripme" && test -n "$old_striplib"; then + func_show_eval "$old_striplib $tool_oldlib" 'exit $?' + fi + + # Do each command in the postinstall commands. + func_execute_cmds "$old_postinstall_cmds" 'exit $?' + done + + test -n "$future_libdirs" && \ + func_warning "remember to run '$progname --finish$future_libdirs'" + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + $opt_dry_run && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi +} + +test install = "$opt_mode" && func_mode_install ${1+"$@"} + + +# func_generate_dlsyms outputname originator pic_p +# Extract symbols from dlprefiles and create ${outputname}S.o with +# a dlpreopen symbol table. +func_generate_dlsyms () +{ + $debug_cmd + + my_outputname=$1 + my_originator=$2 + my_pic_p=${3-false} + my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` + my_dlsyms= + + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + my_dlsyms=${my_outputname}S.c + else + func_error "not configured to extract global symbols from dlpreopened files" + fi + fi + + if test -n "$my_dlsyms"; then + case $my_dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist=$output_objdir/$my_outputname.nm + + func_show_eval "$RM $nlist ${nlist}S ${nlist}T" + + # Parse the name list into a source file. + func_verbose "creating $output_objdir/$my_dlsyms" + + $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ +/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ +/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) +#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" +#endif + +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + +#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) + +/* External symbol declarations for the compiler. */\ +" + + if test yes = "$dlself"; then + func_verbose "generating symbol list for '$output'" + + $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` + for progfile in $progfiles; do + func_to_tool_file "$progfile" func_convert_file_msys_to_w32 + func_verbose "extracting global C symbols from '$func_to_tool_file_result'" + $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $opt_dry_run || { + eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + if test -n "$export_symbols_regex"; then + $opt_dry_run || { + eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols=$output_objdir/$outputname.exp + $opt_dry_run || { + $RM $export_symbols + eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; + esac + } + else + $opt_dry_run || { + eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + case $host in + *cygwin* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; + esac + } + fi + fi + + for dlprefile in $dlprefiles; do + func_verbose "extracting global C symbols from '$dlprefile'" + func_basename "$dlprefile" + name=$func_basename_result + case $host in + *cygwin* | *mingw* | *cegcc* ) + # if an import library, we need to obtain dlname + if func_win32_import_lib_p "$dlprefile"; then + func_tr_sh "$dlprefile" + eval "curr_lafile=\$libfile_$func_tr_sh_result" + dlprefile_dlbasename= + if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then + # Use subshell, to avoid clobbering current variable values + dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` + if test -n "$dlprefile_dlname"; then + func_basename "$dlprefile_dlname" + dlprefile_dlbasename=$func_basename_result + else + # no lafile. user explicitly requested -dlpreopen . + $sharedlib_from_linklib_cmd "$dlprefile" + dlprefile_dlbasename=$sharedlib_from_linklib_result + fi + fi + $opt_dry_run || { + if test -n "$dlprefile_dlbasename"; then + eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' + else + func_warning "Could not compute DLL name from $name" + eval '$ECHO ": $name " >> "$nlist"' + fi + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | + $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" + } + else # not an import lib + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + fi + ;; + *) + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + ;; + esac + done + + $opt_dry_run || { + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $MV "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if $GREP -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + $GREP -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' + else + echo '/* NONE */' >> "$output_objdir/$my_dlsyms" + fi + + func_show_eval '$RM "${nlist}I"' + if test -n "$global_symbol_to_import"; then + eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' + fi + + echo >> "$output_objdir/$my_dlsyms" "\ + +/* The mapping between symbol names and symbols. */ +typedef struct { + const char *name; + void *address; +} lt_dlsymlist; +extern LT_DLSYM_CONST lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[];\ +" + + if test -s "$nlist"I; then + echo >> "$output_objdir/$my_dlsyms" "\ +static void lt_syminit(void) +{ + LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; + for (; symbol->name; ++symbol) + {" + $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" + echo >> "$output_objdir/$my_dlsyms" "\ + } +}" + fi + echo >> "$output_objdir/$my_dlsyms" "\ +LT_DLSYM_CONST lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[] = +{ {\"$my_originator\", (void *) 0}," + + if test -s "$nlist"I; then + echo >> "$output_objdir/$my_dlsyms" "\ + {\"@INIT@\", (void *) <_syminit}," + fi + + case $need_lib_prefix in + no) + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + *) + eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + esac + echo >> "$output_objdir/$my_dlsyms" "\ + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_${my_prefix}_LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + } # !$opt_dry_run + + pic_flag_for_symtable= + case "$compile_command " in + *" -static "*) ;; + *) + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; + *-*-hpux*) + pic_flag_for_symtable=" $pic_flag" ;; + *) + $my_pic_p && pic_flag_for_symtable=" $pic_flag" + ;; + esac + ;; + esac + symtab_cflags= + for arg in $LTCFLAGS; do + case $arg in + -pie | -fpie | -fPIE) ;; + *) func_append symtab_cflags " $arg" ;; + esac + done + + # Now compile the dynamic symbol file. + func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' + + # Clean up the generated files. + func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' + + # Transform the symbol file into the correct name. + symfileobj=$output_objdir/${my_outputname}S.$objext + case $host in + *cygwin* | *mingw* | *cegcc* ) + if test -f "$output_objdir/$my_outputname.def"; then + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + else + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + fi + ;; + *) + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + ;; + esac + ;; + *) + func_fatal_error "unknown suffix for '$my_dlsyms'" + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` + fi +} + +# func_cygming_gnu_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is a GNU/binutils-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_gnu_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` + test -n "$func_cygming_gnu_implib_tmp" +} + +# func_cygming_ms_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is an MS-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_ms_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` + test -n "$func_cygming_ms_implib_tmp" +} + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +# Despite the name, also deal with 64 bit binaries. +func_win32_libid () +{ + $debug_cmd + + win32_libid_type=unknown + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | + $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then + case $nm_interface in + "MS dumpbin") + if func_cygming_ms_implib_p "$1" || + func_cygming_gnu_implib_p "$1" + then + win32_nmres=import + else + win32_nmres= + fi + ;; + *) + func_to_tool_file "$1" func_convert_file_msys_to_w32 + win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | + $SED -n -e ' + 1,100{ + / I /{ + s|.*|import| + p + q + } + }'` + ;; + esac + case $win32_nmres in + import*) win32_libid_type="x86 archive import";; + *) win32_libid_type="x86 archive static";; + esac + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $ECHO "$win32_libid_type" +} + +# func_cygming_dll_for_implib ARG +# +# Platform-specific function to extract the +# name of the DLL associated with the specified +# import library ARG. +# Invoked by eval'ing the libtool variable +# $sharedlib_from_linklib_cmd +# Result is available in the variable +# $sharedlib_from_linklib_result +func_cygming_dll_for_implib () +{ + $debug_cmd + + sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` +} + +# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs +# +# The is the core of a fallback implementation of a +# platform-specific function to extract the name of the +# DLL associated with the specified import library LIBNAME. +# +# SECTION_NAME is either .idata$6 or .idata$7, depending +# on the platform and compiler that created the implib. +# +# Echos the name of the DLL associated with the +# specified import library. +func_cygming_dll_for_implib_fallback_core () +{ + $debug_cmd + + match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` + $OBJDUMP -s --section "$1" "$2" 2>/dev/null | + $SED '/^Contents of section '"$match_literal"':/{ + # Place marker at beginning of archive member dllname section + s/.*/====MARK====/ + p + d + } + # These lines can sometimes be longer than 43 characters, but + # are always uninteresting + /:[ ]*file format pe[i]\{,1\}-/d + /^In archive [^:]*:/d + # Ensure marker is printed + /^====MARK====/p + # Remove all lines with less than 43 characters + /^.\{43\}/!d + # From remaining lines, remove first 43 characters + s/^.\{43\}//' | + $SED -n ' + # Join marker and all lines until next marker into a single line + /^====MARK====/ b para + H + $ b para + b + :para + x + s/\n//g + # Remove the marker + s/^====MARK====// + # Remove trailing dots and whitespace + s/[\. \t]*$// + # Print + /./p' | + # we now have a list, one entry per line, of the stringified + # contents of the appropriate section of all members of the + # archive that possess that section. Heuristic: eliminate + # all those that have a first or second character that is + # a '.' (that is, objdump's representation of an unprintable + # character.) This should work for all archives with less than + # 0x302f exports -- but will fail for DLLs whose name actually + # begins with a literal '.' or a single character followed by + # a '.'. + # + # Of those that remain, print the first one. + $SED -e '/^\./d;/^.\./d;q' +} + +# func_cygming_dll_for_implib_fallback ARG +# Platform-specific function to extract the +# name of the DLL associated with the specified +# import library ARG. +# +# This fallback implementation is for use when $DLLTOOL +# does not support the --identify-strict option. +# Invoked by eval'ing the libtool variable +# $sharedlib_from_linklib_cmd +# Result is available in the variable +# $sharedlib_from_linklib_result +func_cygming_dll_for_implib_fallback () +{ + $debug_cmd + + if func_cygming_gnu_implib_p "$1"; then + # binutils import library + sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` + elif func_cygming_ms_implib_p "$1"; then + # ms-generated import library + sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` + else + # unknown + sharedlib_from_linklib_result= + fi +} + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + $debug_cmd + + f_ex_an_ar_dir=$1; shift + f_ex_an_ar_oldlib=$1 + if test yes = "$lock_old_archive_extraction"; then + lockfile=$f_ex_an_ar_oldlib.lock + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + fi + func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ + 'stat=$?; rm -f "$lockfile"; exit $stat' + if test yes = "$lock_old_archive_extraction"; then + $opt_dry_run || rm -f "$lockfile" + fi + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" + fi +} + + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + $debug_cmd + + my_gentop=$1; shift + my_oldlibs=${1+"$@"} + my_oldobjs= + my_xlib= + my_xabs= + my_xdir= + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + func_basename "$my_xlib" + my_xlib=$func_basename_result + my_xlib_u=$my_xlib + while :; do + case " $extracted_archives " in + *" $my_xlib_u "*) + func_arith $extracted_serial + 1 + extracted_serial=$func_arith_result + my_xlib_u=lt$extracted_serial-$my_xlib ;; + *) break ;; + esac + done + extracted_archives="$extracted_archives $my_xlib_u" + my_xdir=$my_gentop/$my_xlib_u + + func_mkdir_p "$my_xdir" + + case $host in + *-darwin*) + func_verbose "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + $opt_dry_run || { + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + func_basename "$darwin_archive" + darwin_base_archive=$func_basename_result + darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` + if test -n "$darwin_arches"; then + darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches; do + func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" + $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" + cd "unfat-$$/$darwin_base_archive-$darwin_arch" + func_extract_an_archive "`pwd`" "$darwin_base_archive" + cd "$darwin_curdir" + $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" + done # $darwin_arches + ## Okay now we've a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` + $LIPO -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + $RM -rf unfat-$$ + cd "$darwin_orig_dir" + else + cd $darwin_orig_dir + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + } # !$opt_dry_run + ;; + *) + func_extract_an_archive "$my_xdir" "$my_xabs" + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` + done + + func_extract_archives_result=$my_oldobjs +} + + +# func_emit_wrapper [arg=no] +# +# Emit a libtool wrapper script on stdout. +# Don't directly open a file because we may want to +# incorporate the script contents within a cygwin/mingw +# wrapper executable. Must ONLY be called from within +# func_mode_link because it depends on a number of variables +# set therein. +# +# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR +# variable will take. If 'yes', then the emitted script +# will assume that the directory where it is stored is +# the $objdir directory. This is a cygwin/mingw-specific +# behavior. +func_emit_wrapper () +{ + func_emit_wrapper_arg1=${1-no} + + $ECHO "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM (GNU $PACKAGE) $VERSION +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='$sed_quote_subst' + +# Be Bourne compatible +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variables: + generated_by_libtool_version='$macro_version' + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$ECHO are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + file=\"\$0\"" + + qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` + $ECHO "\ + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF' +} + ECHO=\"$qECHO\" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ that is used only on +# windows platforms, and (c) all begin with the string "--lt-" +# (application programs are unlikely to have options that match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's $0 value, followed by "$@". +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=\$0 + shift + for lt_opt + do + case \"\$lt_opt\" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` + test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. + lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` + cat \"\$lt_dump_D/\$lt_dump_F\" + exit 0 + ;; + --lt-*) + \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n \"\$lt_option_debug\"; then + echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" + lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2* | *-cegcc*) + $ECHO "\ + if test -n \"\$lt_option_debug\"; then + \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 + func_lt_dump_args \${1+\"\$@\"} 1>&2 + fi + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $ECHO "\ + if test -n \"\$lt_option_debug\"; then + \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 + func_lt_dump_args \${1+\"\$@\"} 1>&2 + fi + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $ECHO "\ + \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from \$@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case \" \$* \" in + *\\ --lt-*) + for lt_wr_arg + do + case \$lt_wr_arg in + --lt-*) ;; + *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; + esac + shift + done ;; + esac + func_exec_program_core \${1+\"\$@\"} +} + + # Parse options + func_parse_lt_options \"\$0\" \${1+\"\$@\"} + + # Find the directory that this script lives in. + thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 + if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then + # special case for '.' + if test \"\$thisdir\" = \".\"; then + thisdir=\`pwd\` + fi + # remove .libs from thisdir + case \"\$thisdir\" in + *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; + $objdir ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test yes = "$fast_install"; then + $ECHO "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $MKDIR \"\$progdir\" + else + $RM \"\$progdir/\$file\" + fi" + + $ECHO "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + \$ECHO \"\$relink_command_output\" >&2 + $RM \"\$progdir/\$file\" + exit 1 + fi + fi + + $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $RM \"\$progdir/\$program\"; + $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $RM \"\$progdir/\$file\" + fi" + else + $ECHO "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $ECHO "\ + + if test -f \"\$progdir/\$program\"; then" + + # fixup the dll searchpath if we need to. + # + # Fix the DLL searchpath if we need to. Do this before prepending + # to shlibpath, because on Windows, both are PATH and uninstalled + # libraries must come first. + if test -n "$dllsearchpath"; then + $ECHO "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + # Export our shlibpath_var if we have one. + if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $ECHO "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` + + export $shlibpath_var +" + fi + + $ECHO "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. + func_exec_program \${1+\"\$@\"} + fi + else + # The program doesn't exist. + \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 + \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 + \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" +} + + +# func_emit_cwrapperexe_src +# emit the source code for a wrapper executable on stdout +# Must ONLY be called from within func_mode_link because +# it depends on a number of variable set therein. +func_emit_cwrapperexe_src () +{ + cat < +#include +#ifdef _MSC_VER +# include +# include +# include +#else +# include +# include +# ifdef __CYGWIN__ +# include +# endif +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) + +/* declarations of non-ANSI functions */ +#if defined __MINGW32__ +# ifdef __STRICT_ANSI__ +int _putenv (const char *); +# endif +#elif defined __CYGWIN__ +# ifdef __STRICT_ANSI__ +char *realpath (const char *, char *); +int putenv (char *); +int setenv (const char *, const char *, int); +# endif +/* #elif defined other_platform || defined ... */ +#endif + +/* portability defines, excluding path handling macros */ +#if defined _MSC_VER +# define setmode _setmode +# define stat _stat +# define chmod _chmod +# define getcwd _getcwd +# define putenv _putenv +# define S_IXUSR _S_IEXEC +#elif defined __MINGW32__ +# define setmode _setmode +# define stat _stat +# define chmod _chmod +# define getcwd _getcwd +# define putenv _putenv +#elif defined __CYGWIN__ +# define HAVE_SETENV +# define FOPEN_WB "wb" +/* #elif defined other platforms ... */ +#endif + +#if defined PATH_MAX +# define LT_PATHMAX PATH_MAX +#elif defined MAXPATHLEN +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef S_IXOTH +# define S_IXOTH 0 +#endif +#ifndef S_IXGRP +# define S_IXGRP 0 +#endif + +/* path handling portability macros */ +#ifndef DIR_SEPARATOR +# define DIR_SEPARATOR '/' +# define PATH_SEPARATOR ':' +#endif + +#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ + defined __OS2__ +# define HAVE_DOS_BASED_FILE_SYSTEM +# define FOPEN_WB "wb" +# ifndef DIR_SEPARATOR_2 +# define DIR_SEPARATOR_2 '\\' +# endif +# ifndef PATH_SEPARATOR_2 +# define PATH_SEPARATOR_2 ';' +# endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#ifndef PATH_SEPARATOR_2 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) +#else /* PATH_SEPARATOR_2 */ +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) +#endif /* PATH_SEPARATOR_2 */ + +#ifndef FOPEN_WB +# define FOPEN_WB "w" +#endif +#ifndef _O_BINARY +# define _O_BINARY 0 +#endif + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free (stale); stale = 0; } \ +} while (0) + +#if defined LT_DEBUGWRAPPER +static int lt_debug = 1; +#else +static int lt_debug = 0; +#endif + +const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ + +void *xmalloc (size_t num); +char *xstrdup (const char *string); +const char *base_name (const char *name); +char *find_executable (const char *wrapper); +char *chase_symlinks (const char *pathspec); +int make_executable (const char *path); +int check_executable (const char *path); +char *strendzap (char *str, const char *pat); +void lt_debugprintf (const char *file, int line, const char *fmt, ...); +void lt_fatal (const char *file, int line, const char *message, ...); +static const char *nonnull (const char *s); +static const char *nonempty (const char *s); +void lt_setenv (const char *name, const char *value); +char *lt_extend_str (const char *orig_value, const char *add, int to_end); +void lt_update_exe_path (const char *name, const char *value); +void lt_update_lib_path (const char *name, const char *value); +char **prepare_spawn (char **argv); +void lt_dump_script (FILE *f); +EOF + + cat <= 0) + && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) + return 1; + else + return 0; +} + +int +make_executable (const char *path) +{ + int rval = 0; + struct stat st; + + lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", + nonempty (path)); + if ((!path) || (!*path)) + return 0; + + if (stat (path, &st) >= 0) + { + rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); + } + return rval; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise + Does not chase symlinks, even on platforms that support them. +*/ +char * +find_executable (const char *wrapper) +{ + int has_slash = 0; + const char *p; + const char *p_next; + /* static buffer for getcwd */ + char tmp[LT_PATHMAX + 1]; + size_t tmp_len; + char *concat_name; + + lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", + nonempty (wrapper)); + + if ((wrapper == NULL) || (*wrapper == '\0')) + return NULL; + + /* Absolute path? */ +#if defined HAVE_DOS_BASED_FILE_SYSTEM + if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + else + { +#endif + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } +#if defined HAVE_DOS_BASED_FILE_SYSTEM + } +#endif + + for (p = wrapper; *p; p++) + if (*p == '/') + { + has_slash = 1; + break; + } + if (!has_slash) + { + /* no slashes; search PATH */ + const char *path = getenv ("PATH"); + if (path != NULL) + { + for (p = path; *p; p = p_next) + { + const char *q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR (*q)) + break; + p_len = (size_t) (q - p); + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", + nonnull (strerror (errno))); + tmp_len = strlen (tmp); + concat_name = + XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = + XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + } + /* not found in PATH; assume curdir */ + } + /* Relative path | not found in path: prepend cwd */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", + nonnull (strerror (errno))); + tmp_len = strlen (tmp); + concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + return NULL; +} + +char * +chase_symlinks (const char *pathspec) +{ +#ifndef S_ISLNK + return xstrdup (pathspec); +#else + char buf[LT_PATHMAX]; + struct stat s; + char *tmp_pathspec = xstrdup (pathspec); + char *p; + int has_symlinks = 0; + while (strlen (tmp_pathspec) && !has_symlinks) + { + lt_debugprintf (__FILE__, __LINE__, + "checking path component for symlinks: %s\n", + tmp_pathspec); + if (lstat (tmp_pathspec, &s) == 0) + { + if (S_ISLNK (s.st_mode) != 0) + { + has_symlinks = 1; + break; + } + + /* search backwards for last DIR_SEPARATOR */ + p = tmp_pathspec + strlen (tmp_pathspec) - 1; + while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + p--; + if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + { + /* no more DIR_SEPARATORS left */ + break; + } + *p = '\0'; + } + else + { + lt_fatal (__FILE__, __LINE__, + "error accessing file \"%s\": %s", + tmp_pathspec, nonnull (strerror (errno))); + } + } + XFREE (tmp_pathspec); + + if (!has_symlinks) + { + return xstrdup (pathspec); + } + + tmp_pathspec = realpath (pathspec, buf); + if (tmp_pathspec == 0) + { + lt_fatal (__FILE__, __LINE__, + "could not follow symlinks for %s", pathspec); + } + return xstrdup (tmp_pathspec); +#endif +} + +char * +strendzap (char *str, const char *pat) +{ + size_t len, patlen; + + assert (str != NULL); + assert (pat != NULL); + + len = strlen (str); + patlen = strlen (pat); + + if (patlen <= len) + { + str += len - patlen; + if (STREQ (str, pat)) + *str = '\0'; + } + return str; +} + +void +lt_debugprintf (const char *file, int line, const char *fmt, ...) +{ + va_list args; + if (lt_debug) + { + (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); + va_start (args, fmt); + (void) vfprintf (stderr, fmt, args); + va_end (args); + } +} + +static void +lt_error_core (int exit_status, const char *file, + int line, const char *mode, + const char *message, va_list ap) +{ + fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *file, int line, const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); + va_end (ap); +} + +static const char * +nonnull (const char *s) +{ + return s ? s : "(null)"; +} + +static const char * +nonempty (const char *s) +{ + return (s && !*s) ? "(empty)" : nonnull (s); +} + +void +lt_setenv (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_setenv) setting '%s' to '%s'\n", + nonnull (name), nonnull (value)); + { +#ifdef HAVE_SETENV + /* always make a copy, for consistency with !HAVE_SETENV */ + char *str = xstrdup (value); + setenv (name, str, 1); +#else + size_t len = strlen (name) + 1 + strlen (value) + 1; + char *str = XMALLOC (char, len); + sprintf (str, "%s=%s", name, value); + if (putenv (str) != EXIT_SUCCESS) + { + XFREE (str); + } +#endif + } +} + +char * +lt_extend_str (const char *orig_value, const char *add, int to_end) +{ + char *new_value; + if (orig_value && *orig_value) + { + size_t orig_value_len = strlen (orig_value); + size_t add_len = strlen (add); + new_value = XMALLOC (char, add_len + orig_value_len + 1); + if (to_end) + { + strcpy (new_value, orig_value); + strcpy (new_value + orig_value_len, add); + } + else + { + strcpy (new_value, add); + strcpy (new_value + add_len, orig_value); + } + } + else + { + new_value = xstrdup (add); + } + return new_value; +} + +void +lt_update_exe_path (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", + nonnull (name), nonnull (value)); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + /* some systems can't cope with a ':'-terminated path #' */ + size_t len = strlen (new_value); + while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) + { + new_value[--len] = '\0'; + } + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +void +lt_update_lib_path (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", + nonnull (name), nonnull (value)); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +EOF + case $host_os in + mingw*) + cat <<"EOF" + +/* Prepares an argument vector before calling spawn(). + Note that spawn() does not by itself call the command interpreter + (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : + ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&v); + v.dwPlatformId == VER_PLATFORM_WIN32_NT; + }) ? "cmd.exe" : "command.com"). + Instead it simply concatenates the arguments, separated by ' ', and calls + CreateProcess(). We must quote the arguments since Win32 CreateProcess() + interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a + special way: + - Space and tab are interpreted as delimiters. They are not treated as + delimiters if they are surrounded by double quotes: "...". + - Unescaped double quotes are removed from the input. Their only effect is + that within double quotes, space and tab are treated like normal + characters. + - Backslashes not followed by double quotes are not special. + - But 2*n+1 backslashes followed by a double quote become + n backslashes followed by a double quote (n >= 0): + \" -> " + \\\" -> \" + \\\\\" -> \\" + */ +#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +char ** +prepare_spawn (char **argv) +{ + size_t argc; + char **new_argv; + size_t i; + + /* Count number of arguments. */ + for (argc = 0; argv[argc] != NULL; argc++) + ; + + /* Allocate new argument vector. */ + new_argv = XMALLOC (char *, argc + 1); + + /* Put quoted arguments into the new argument vector. */ + for (i = 0; i < argc; i++) + { + const char *string = argv[i]; + + if (string[0] == '\0') + new_argv[i] = xstrdup ("\"\""); + else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) + { + int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); + size_t length; + unsigned int backslashes; + const char *s; + char *quoted_string; + char *p; + + length = 0; + backslashes = 0; + if (quote_around) + length++; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + length += backslashes + 1; + length++; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + length += backslashes + 1; + + quoted_string = XMALLOC (char, length + 1); + + p = quoted_string; + backslashes = 0; + if (quote_around) + *p++ = '"'; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + { + unsigned int j; + for (j = backslashes + 1; j > 0; j--) + *p++ = '\\'; + } + *p++ = c; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + { + unsigned int j; + for (j = backslashes; j > 0; j--) + *p++ = '\\'; + *p++ = '"'; + } + *p = '\0'; + + new_argv[i] = quoted_string; + } + else + new_argv[i] = (char *) string; + } + new_argv[argc] = NULL; + + return new_argv; +} +EOF + ;; + esac + + cat <<"EOF" +void lt_dump_script (FILE* f) +{ +EOF + func_emit_wrapper yes | + $SED -n -e ' +s/^\(.\{79\}\)\(..*\)/\1\ +\2/ +h +s/\([\\"]\)/\\\1/g +s/$/\\n/ +s/\([^\n]*\).*/ fputs ("\1", f);/p +g +D' + cat <<"EOF" +} +EOF +} +# end: func_emit_cwrapperexe_src + +# func_win32_import_lib_p ARG +# True if ARG is an import lib, as indicated by $file_magic_cmd +func_win32_import_lib_p () +{ + $debug_cmd + + case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in + *import*) : ;; + *) false ;; + esac +} + +# func_suncc_cstd_abi +# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! +# Several compiler flags select an ABI that is incompatible with the +# Cstd library. Avoid specifying it if any are in CXXFLAGS. +func_suncc_cstd_abi () +{ + $debug_cmd + + case " $compile_command " in + *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) + suncc_use_cstd_abi=no + ;; + *) + suncc_use_cstd_abi=yes + ;; + esac +} + +# func_mode_link arg... +func_mode_link () +{ + $debug_cmd + + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # what system we are compiling for in order to pass an extra + # flag for every libtool invocation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll that has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args=$nonopt + base_compile="$nonopt $@" + compile_command=$nonopt + finalize_command=$nonopt + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + inst_prefix_dir= + new_inherited_linker_flags= + + avoid_version=no + bindir= + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + no_install=no + objs= + os2dllname= + non_pic_objects= + precious_files_regex= + prefer_static_libs=no + preload=false + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + vinfo_number=no + weak_libs= + single_module=$wl-single_module + func_infer_tag $base_compile + + # We need to know -static, to get the right output filenames. + for arg + do + case $arg in + -shared) + test yes != "$build_libtool_libs" \ + && func_fatal_configuration "cannot build a shared library" + build_old_libs=no + break + ;; + -all-static | -static | -static-libtool-libs) + case $arg in + -all-static) + if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then + func_warning "complete static linking is impossible in this configuration" + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + -static) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=built + ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + esac + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg=$1 + shift + func_quote_for_eval "$arg" + qarg=$func_quote_for_eval_unquoted_result + func_append libtool_args " $func_quote_for_eval_result" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + func_append compile_command " @OUTPUT@" + func_append finalize_command " @OUTPUT@" + ;; + esac + + case $prev in + bindir) + bindir=$arg + prev= + continue + ;; + dlfiles|dlprefiles) + $preload || { + # Add the symbol object into the linking commands. + func_append compile_command " @SYMFILE@" + func_append finalize_command " @SYMFILE@" + preload=: + } + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test no = "$dlself"; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test dlprefiles = "$prev"; then + dlself=yes + elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test dlfiles = "$prev"; then + func_append dlfiles " $arg" + else + func_append dlprefiles " $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols=$arg + test -f "$arg" \ + || func_fatal_error "symbol file '$arg' does not exist" + prev= + continue + ;; + expsyms_regex) + export_symbols_regex=$arg + prev= + continue + ;; + framework) + case $host in + *-*-darwin*) + case "$deplibs " in + *" $qarg.ltframework "*) ;; + *) func_append deplibs " $qarg.ltframework" # this is fixed later + ;; + esac + ;; + esac + prev= + continue + ;; + inst_prefix) + inst_prefix_dir=$arg + prev= + continue + ;; + mllvm) + # Clang does not use LLVM to link, so we can simply discard any + # '-mllvm $arg' options when doing the link step. + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat "$save_arg"` + do +# func_append moreargs " $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test none = "$pic_object" && + test none = "$non_pic_object"; then + func_fatal_error "cannot find name of object for '$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + if test none != "$pic_object"; then + # Prepend the subdirectory the object is found in. + pic_object=$xdir$pic_object + + if test dlfiles = "$prev"; then + if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then + func_append dlfiles " $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test dlprefiles = "$prev"; then + # Preload the old-style object. + func_append dlprefiles " $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg=$pic_object + fi + + # Non-PIC object. + if test none != "$non_pic_object"; then + # Prepend the subdirectory the object is found in. + non_pic_object=$xdir$non_pic_object + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test none = "$pic_object"; then + arg=$non_pic_object + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object=$pic_object + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "'$arg' is not a valid libtool object" + fi + fi + done + else + func_fatal_error "link input file '$arg' does not exist" + fi + arg=$save_arg + prev= + continue + ;; + os2dllname) + os2dllname=$arg + prev= + continue + ;; + precious_regex) + precious_files_regex=$arg + prev= + continue + ;; + release) + release=-$arg + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + if test rpath = "$prev"; then + case "$rpath " in + *" $arg "*) ;; + *) func_append rpath " $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) func_append xrpath " $arg" ;; + esac + fi + prev= + continue + ;; + shrext) + shrext_cmds=$arg + prev= + continue + ;; + weak) + func_append weak_libs " $arg" + prev= + continue + ;; + xcclinker) + func_append linker_flags " $qarg" + func_append compiler_flags " $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xcompiler) + func_append compiler_flags " $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xlinker) + func_append linker_flags " $qarg" + func_append compiler_flags " $wl$qarg" + prev= + func_append compile_command " $wl$qarg" + func_append finalize_command " $wl$qarg" + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg=$arg + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + # See comment for -static flag below, for more details. + func_append compile_command " $link_static_flag" + func_append finalize_command " $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + func_fatal_error "'-allow-undefined' must not be used because it is the default" + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -bindir) + prev=bindir + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + func_fatal_error "more than one -exported-symbols argument is not allowed" + fi + if test X-export-symbols = "X$arg"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -framework) + prev=framework + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + func_append compile_command " $arg" + func_append finalize_command " $arg" + ;; + esac + continue + ;; + + -L*) + func_stripname "-L" '' "$arg" + if test -z "$func_stripname_result"; then + if test "$#" -gt 0; then + func_fatal_error "require no space between '-L' and '$1'" + else + func_fatal_error "need path for '-L' option" + fi + fi + func_resolve_sysroot "$func_stripname_result" + dir=$func_resolve_sysroot_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + test -z "$absdir" && \ + func_fatal_error "cannot determine absolute directory name of '$dir'" + dir=$absdir + ;; + esac + case "$deplibs " in + *" -L$dir "* | *" $arg "*) + # Will only happen for absolute or sysroot arguments + ;; + *) + # Preserve sysroot, but never include relative directories + case $dir in + [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; + *) func_append deplibs " -L$dir" ;; + esac + func_append lib_search_path " $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; + ::) dllsearchpath=$dir;; + *) func_append dllsearchpath ":$dir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) func_append dllsearchpath ":$testbindir";; + esac + ;; + esac + continue + ;; + + -l*) + if test X-lc = "X$arg" || test X-lm = "X$arg"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-os2*) + # These systems don't actually have a C library (as such) + test X-lc = "X$arg" && continue + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + # Do not include libc due to us having libc/libc_r. + test X-lc = "X$arg" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + func_append deplibs " System.ltframework" + continue + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + test X-lc = "X$arg" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test X-lc = "X$arg" && continue + ;; + esac + elif test X-lc_r = "X$arg"; then + case $host in + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + func_append deplibs " $arg" + continue + ;; + + -mllvm) + prev=mllvm + continue + ;; + + -module) + module=yes + continue + ;; + + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + # Darwin uses the -arch flag to determine output architecture. + -model|-arch|-isysroot|--sysroot) + func_append compiler_flags " $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + prev=xcompiler + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + func_append compiler_flags " $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case "$new_inherited_linker_flags " in + *" $arg "*) ;; + * ) func_append new_inherited_linker_flags " $arg" ;; + esac + continue + ;; + + -multi_module) + single_module=$wl-multi_module + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + func_warning "'-no-install' is ignored for $host" + func_warning "assuming '-no-fast-install' instead" + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -os2dllname) + prev=os2dllname + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + func_stripname '-R' '' "$arg" + dir=$func_stripname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + =*) + func_stripname '=' '' "$dir" + dir=$lt_sysroot$func_stripname_result + ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) func_append xrpath " $dir" ;; + esac + continue + ;; + + -shared) + # The effects of -shared are defined in a previous loop. + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -static | -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -weak) + prev=weak + continue + ;; + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs=$IFS; IFS=, + for flag in $args; do + IFS=$save_ifs + func_quote_for_eval "$flag" + func_append arg " $func_quote_for_eval_result" + func_append compiler_flags " $func_quote_for_eval_result" + done + IFS=$save_ifs + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Wl,*) + func_stripname '-Wl,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs=$IFS; IFS=, + for flag in $args; do + IFS=$save_ifs + func_quote_for_eval "$flag" + func_append arg " $wl$func_quote_for_eval_result" + func_append compiler_flags " $wl$func_quote_for_eval_result" + func_append linker_flags " $func_quote_for_eval_result" + done + IFS=$save_ifs + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # -msg_* for osf cc + -msg_*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + + # Flags to be passed through unchanged, with rationale: + # -64, -mips[0-9] enable 64-bit mode for the SGI compiler + # -r[0-9][0-9]* specify processor for the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler + # +DA*, +DD* enable 64-bit mode for the HP compiler + # -q* compiler args for the IBM compiler + # -m*, -t[45]*, -txscale* architecture-specific flags for GCC + # -F/path path to uninstalled frameworks, gcc on darwin + # -p, -pg, --coverage, -fprofile-* profiling flags for GCC + # -fstack-protector* stack protector flags for GCC + # @file GCC response files + # -tp=* Portland pgcc target processor selection + # --sysroot=* for sysroot support + # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + # -stdlib=* select c++ std lib with clang + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + func_append compile_command " $arg" + func_append finalize_command " $arg" + func_append compiler_flags " $arg" + continue + ;; + + -Z*) + if test os2 = "`expr $host : '.*\(os2\)'`"; then + # OS/2 uses -Zxxx to specify OS/2-specific options + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case $arg in + -Zlinker | -Zstack) + prev=xcompiler + ;; + esac + continue + else + # Otherwise treat like 'Some other compiler flag' below + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + fi + ;; + + # Some other compiler flag. + -* | +*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + + *.$objext) + # A standard object. + func_append objs " $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test none = "$pic_object" && + test none = "$non_pic_object"; then + func_fatal_error "cannot find name of object for '$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + test none = "$pic_object" || { + # Prepend the subdirectory the object is found in. + pic_object=$xdir$pic_object + + if test dlfiles = "$prev"; then + if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then + func_append dlfiles " $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test dlprefiles = "$prev"; then + # Preload the old-style object. + func_append dlprefiles " $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg=$pic_object + } + + # Non-PIC object. + if test none != "$non_pic_object"; then + # Prepend the subdirectory the object is found in. + non_pic_object=$xdir$non_pic_object + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test none = "$pic_object"; then + arg=$non_pic_object + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object=$pic_object + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "'$arg' is not a valid libtool object" + fi + fi + ;; + + *.$libext) + # An archive. + func_append deplibs " $arg" + func_append old_deplibs " $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + func_resolve_sysroot "$arg" + if test dlfiles = "$prev"; then + # This library was specified with -dlopen. + func_append dlfiles " $func_resolve_sysroot_result" + prev= + elif test dlprefiles = "$prev"; then + # The library was specified with -dlpreopen. + func_append dlprefiles " $func_resolve_sysroot_result" + prev= + else + func_append deplibs " $func_resolve_sysroot_result" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + done # argument parsing loop + + test -n "$prev" && \ + func_fatal_help "the '$prevarg' option requires an argument" + + if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + func_basename "$output" + outputname=$func_basename_result + libobjs_save=$libobjs + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + # Definition is injected by LT_CONFIG during libtool generation. + func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" + + func_dirname "$output" "/" "" + output_objdir=$func_dirname_result$objdir + func_to_tool_file "$output_objdir/" + tool_output_objdir=$func_to_tool_file_result + # Create the object directory. + func_mkdir_p "$output_objdir" + + # Determine the type of output + case $output in + "") + func_fatal_help "you must specify an output file" + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if $opt_preserve_dup_deps; then + case "$libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append libs " $deplib" + done + + if test lib = "$linkmode"; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if $opt_duplicate_compiler_generated_deps; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; + esac + func_append pre_post_deps " $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + + case $linkmode in + lib) + passes="conv dlpreopen link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=false + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + + for pass in $passes; do + # The preopen pass in lib mode reverses $deplibs; put it back here + # so that -L comes before libs that need it for instance... + if test lib,link = "$linkmode,$pass"; then + ## FIXME: Find the place where the list is rebuilt in the wrong + ## order, and fix it there properly + tmp_deplibs= + for deplib in $deplibs; do + tmp_deplibs="$deplib $tmp_deplibs" + done + deplibs=$tmp_deplibs + fi + + if test lib,link = "$linkmode,$pass" || + test prog,scan = "$linkmode,$pass"; then + libs=$deplibs + deplibs= + fi + if test prog = "$linkmode"; then + case $pass in + dlopen) libs=$dlfiles ;; + dlpreopen) libs=$dlprefiles ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test lib,dlpreopen = "$linkmode,$pass"; then + # Collect and forward deplibs of preopened libtool libs + for lib in $dlprefiles; do + # Ignore non-libtool-libs + dependency_libs= + func_resolve_sysroot "$lib" + case $lib in + *.la) func_source "$func_resolve_sysroot_result" ;; + esac + + # Collect preopened libtool deplibs, except any this library + # has declared as weak libs + for deplib in $dependency_libs; do + func_basename "$deplib" + deplib_base=$func_basename_result + case " $weak_libs " in + *" $deplib_base "*) ;; + *) func_append deplibs " $deplib" ;; + esac + done + done + libs=$dlprefiles + fi + if test dlopen = "$pass"; then + # Collect dlpreopened libraries + save_deplibs=$deplibs + deplibs= + fi + + for deplib in $libs; do + lib= + found=false + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + func_append compiler_flags " $deplib" + if test lib = "$linkmode"; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) func_append new_inherited_linker_flags " $deplib" ;; + esac + fi + fi + continue + ;; + -l*) + if test lib != "$linkmode" && test prog != "$linkmode"; then + func_warning "'-l' is ignored for archives/objects" + continue + fi + func_stripname '-l' '' "$deplib" + name=$func_stripname_result + if test lib = "$linkmode"; then + searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" + else + searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" + fi + for searchdir in $searchdirs; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib=$searchdir/lib$name$search_ext + if test -f "$lib"; then + if test .la = "$search_ext"; then + found=: + else + found=false + fi + break 2 + fi + done + done + if $found; then + # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + case " $predeps $postdeps " in + *" $deplib "*) + if func_lalib_p "$lib"; then + library_names= + old_library= + func_source "$lib" + for l in $old_library $library_names; do + ll=$l + done + if test "X$ll" = "X$old_library"; then # only static version available + found=false + func_dirname "$lib" "" "." + ladir=$func_dirname_result + lib=$ladir/$old_library + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + else + # deplib doesn't seem to be a libtool library + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + ;; # -l + *.ltframework) + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + if test lib = "$linkmode"; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) func_append new_inherited_linker_flags " $deplib" ;; + esac + fi + fi + continue + ;; + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test conv = "$pass" && continue + newdependency_libs="$deplib $newdependency_libs" + func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + prog) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + continue + fi + if test scan = "$pass"; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + *) + func_warning "'-L' is ignored for archives/objects" + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test link = "$pass"; then + func_stripname '-R' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + dir=$func_resolve_sysroot_result + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) func_append xrpath " $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) + func_resolve_sysroot "$deplib" + lib=$func_resolve_sysroot_result + ;; + *.$libext) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + # Linking convenience modules into shared libraries is allowed, + # but linking other static libraries is non-portable. + case " $dlpreconveniencelibs " in + *" $deplib "*) ;; + *) + valid_a_lib=false + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=: + fi + ;; + pass_all) + valid_a_lib=: + ;; + esac + if $valid_a_lib; then + echo + $ECHO "*** Warning: Linking the shared library $output against the" + $ECHO "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + else + echo + $ECHO "*** Warning: Trying to link with static lib archive $deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because the file extensions .$libext of this argument makes me believe" + echo "*** that it is just a static archive that I should not use here." + fi + ;; + esac + continue + ;; + prog) + if test link != "$pass"; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + elif test prog = "$linkmode"; then + if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + func_append newdlprefiles " $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + func_append newdlfiles " $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=: + continue + ;; + esac # case $deplib + + $found || test -f "$lib" \ + || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$lib" \ + || func_fatal_error "'$lib' is not a valid libtool archive" + + func_dirname "$lib" "" "." + ladir=$func_dirname_result + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + inherited_linker_flags= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + avoidtemprpath= + + + # Read the .la file + func_source "$lib" + + # Convert "-framework foo" to "foo.ltframework" + if test -n "$inherited_linker_flags"; then + tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` + for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do + case " $new_inherited_linker_flags " in + *" $tmp_inherited_linker_flag "*) ;; + *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; + esac + done + fi + dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + if test lib,link = "$linkmode,$pass" || + test prog,scan = "$linkmode,$pass" || + { test prog != "$linkmode" && test lib != "$linkmode"; }; then + test -n "$dlopen" && func_append dlfiles " $dlopen" + test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" + fi + + if test conv = "$pass"; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + func_fatal_error "cannot find name of link library for '$lib'" + fi + # It is a libtool convenience library, so add in its objects. + func_append convenience " $ladir/$objdir/$old_library" + func_append old_convenience " $ladir/$objdir/$old_library" + elif test prog != "$linkmode" && test lib != "$linkmode"; then + func_fatal_error "'$lib' is not a convenience library" + fi + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append tmp_libs " $deplib" + done + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + if test -n "$old_library" && + { test yes = "$prefer_static_libs" || + test built,no = "$prefer_static_libs,$installed"; }; then + linklib=$old_library + else + for l in $old_library $library_names; do + linklib=$l + done + fi + if test -z "$linklib"; then + func_fatal_error "cannot find name of link library for '$lib'" + fi + + # This library was specified with -dlopen. + if test dlopen = "$pass"; then + test -z "$libdir" \ + && func_fatal_error "cannot -dlopen a convenience library: '$lib'" + if test -z "$dlname" || + test yes != "$dlopen_support" || + test no = "$build_libtool_libs" + then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + func_append dlprefiles " $lib $dependency_libs" + else + func_append newdlfiles " $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + func_warning "cannot determine absolute directory name of '$ladir'" + func_warning "passing it literally to the linker, although it might fail" + abs_ladir=$ladir + fi + ;; + esac + func_basename "$lib" + laname=$func_basename_result + + # Find the relevant object directory and library name. + if test yes = "$installed"; then + if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + func_warning "library '$lib' was moved." + dir=$ladir + absdir=$abs_ladir + libdir=$abs_ladir + else + dir=$lt_sysroot$libdir + absdir=$lt_sysroot$libdir + fi + test yes = "$hardcode_automatic" && avoidtemprpath=yes + else + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir=$ladir + absdir=$abs_ladir + # Remove this search path later + func_append notinst_path " $abs_ladir" + else + dir=$ladir/$objdir + absdir=$abs_ladir/$objdir + # Remove this search path later + func_append notinst_path " $abs_ladir" + fi + fi # $installed = yes + func_stripname 'lib' '.la' "$laname" + name=$func_stripname_result + + # This library was specified with -dlpreopen. + if test dlpreopen = "$pass"; then + if test -z "$libdir" && test prog = "$linkmode"; then + func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" + fi + case $host in + # special handling for platforms with PE-DLLs. + *cygwin* | *mingw* | *cegcc* ) + # Linker will automatically link against shared library if both + # static and shared are present. Therefore, ensure we extract + # symbols from the import library if a shared library is present + # (otherwise, the dlopen module name will be incorrect). We do + # this by putting the import library name into $newdlprefiles. + # We recover the dlopen module name by 'saving' the la file + # name in a special purpose variable, and (later) extracting the + # dlname from the la file. + if test -n "$dlname"; then + func_tr_sh "$dir/$linklib" + eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" + func_append newdlprefiles " $dir/$linklib" + else + func_append newdlprefiles " $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + func_append dlpreconveniencelibs " $dir/$old_library" + fi + ;; + * ) + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + func_append newdlprefiles " $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + func_append dlpreconveniencelibs " $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + func_append newdlprefiles " $dir/$dlname" + else + func_append newdlprefiles " $dir/$linklib" + fi + ;; + esac + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test lib = "$linkmode"; then + deplibs="$dir/$old_library $deplibs" + elif test prog,link = "$linkmode,$pass"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test prog = "$linkmode" && test link != "$pass"; then + func_append newlib_search_path " $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=false + if test no != "$link_all_deplibs" || test -z "$library_names" || + test no = "$build_libtool_libs"; then + linkalldeplibs=: + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + esac + # Need to link against all dependency_libs? + if $linkalldeplibs; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append tmp_libs " $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test prog,link = "$linkmode,$pass"; then + if test -n "$library_names" && + { { test no = "$prefer_static_libs" || + test built,yes = "$prefer_static_libs,$installed"; } || + test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then + # Make sure the rpath contains only unique directories. + case $temp_rpath: in + *"$absdir:"*) ;; + *) func_append temp_rpath "$absdir:" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) func_append compile_rpath " $absdir" ;; + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if $alldeplibs && + { test pass_all = "$deplibs_check_method" || + { test yes = "$build_libtool_libs" && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + use_static_libs=$prefer_static_libs + if test built = "$use_static_libs" && test yes = "$installed"; then + use_static_libs=no + fi + if test -n "$library_names" && + { test no = "$use_static_libs" || test -z "$old_library"; }; then + case $host in + *cygwin* | *mingw* | *cegcc* | *os2*) + # No point in relinking DLLs because paths are not encoded + func_append notinst_deplibs " $lib" + need_relink=no + ;; + *) + if test no = "$installed"; then + func_append notinst_deplibs " $lib" + need_relink=yes + fi + ;; + esac + # This is a shared library + + # Warn about portability, can't link against -module's on some + # systems (darwin). Don't bleat about dlopened modules though! + dlopenmodule= + for dlpremoduletest in $dlprefiles; do + if test "X$dlpremoduletest" = "X$lib"; then + dlopenmodule=$dlpremoduletest + break + fi + done + if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then + echo + if test prog = "$linkmode"; then + $ECHO "*** Warning: Linking the executable $output against the loadable module" + else + $ECHO "*** Warning: Linking the shared library $output against the loadable module" + fi + $ECHO "*** $linklib is not portable!" + fi + if test lib = "$linkmode" && + test yes = "$hardcode_into_libs"; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) func_append compile_rpath " $absdir" ;; + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + shift + realname=$1 + shift + libname=`eval "\\$ECHO \"$libname_spec\""` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname=$dlname + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw* | *cegcc* | *os2*) + func_arith $current - $age + major=$func_arith_result + versuffix=-$major + ;; + esac + eval soname=\"$soname_spec\" + else + soname=$realname + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot=$soname + func_basename "$soroot" + soname=$func_basename_result + func_stripname 'lib' '.dll' "$soname" + newlib=libimp-$func_stripname_result.a + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + func_verbose "extracting exported symbol list from '$soname'" + func_execute_cmds "$extract_expsyms_cmds" 'exit $?' + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + func_verbose "generating import library for '$soname'" + func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test prog = "$linkmode" || test relink != "$opt_mode"; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test no = "$hardcode_direct"; then + add=$dir/$linklib + case $host in + *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; + *-*-sysv4*uw2*) add_dir=-L$dir ;; + *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ + *-*-unixware7*) add_dir=-L$dir ;; + *-*-darwin* ) + # if the lib is a (non-dlopened) module then we cannot + # link against it, someone is ignoring the earlier warnings + if /usr/bin/file -L $add 2> /dev/null | + $GREP ": [^:]* bundle" >/dev/null; then + if test "X$dlopenmodule" != "X$lib"; then + $ECHO "*** Warning: lib $linklib is a module, not a shared library" + if test -z "$old_library"; then + echo + echo "*** And there doesn't seem to be a static archive available" + echo "*** The link will probably fail, sorry" + else + add=$dir/$old_library + fi + elif test -n "$old_library"; then + add=$dir/$old_library + fi + fi + esac + elif test no = "$hardcode_minus_L"; then + case $host in + *-*-sunos*) add_shlibpath=$dir ;; + esac + add_dir=-L$dir + add=-l$name + elif test no = "$hardcode_shlibpath_var"; then + add_shlibpath=$dir + add=-l$name + else + lib_linked=no + fi + ;; + relink) + if test yes = "$hardcode_direct" && + test no = "$hardcode_direct_absolute"; then + add=$dir/$linklib + elif test yes = "$hardcode_minus_L"; then + add_dir=-L$absdir + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + func_append add_dir " -L$inst_prefix_dir$libdir" + ;; + esac + fi + add=-l$name + elif test yes = "$hardcode_shlibpath_var"; then + add_shlibpath=$dir + add=-l$name + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test yes != "$lib_linked"; then + func_fatal_configuration "unsupported hardcode properties" + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) func_append compile_shlibpath "$add_shlibpath:" ;; + esac + fi + if test prog = "$linkmode"; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test yes != "$hardcode_direct" && + test yes != "$hardcode_minus_L" && + test yes = "$hardcode_shlibpath_var"; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) func_append finalize_shlibpath "$libdir:" ;; + esac + fi + fi + fi + + if test prog = "$linkmode" || test relink = "$opt_mode"; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test yes = "$hardcode_direct" && + test no = "$hardcode_direct_absolute"; then + add=$libdir/$linklib + elif test yes = "$hardcode_minus_L"; then + add_dir=-L$libdir + add=-l$name + elif test yes = "$hardcode_shlibpath_var"; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) func_append finalize_shlibpath "$libdir:" ;; + esac + add=-l$name + elif test yes = "$hardcode_automatic"; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib"; then + add=$inst_prefix_dir$libdir/$linklib + else + add=$libdir/$linklib + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir=-L$libdir + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + func_append add_dir " -L$inst_prefix_dir$libdir" + ;; + esac + fi + add=-l$name + fi + + if test prog = "$linkmode"; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test prog = "$linkmode"; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test unsupported != "$hardcode_direct"; then + test -n "$old_library" && linklib=$old_library + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test yes = "$build_libtool_libs"; then + # Not a shared library + if test pass_all != "$deplibs_check_method"; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + echo + $ECHO "*** Warning: This system cannot link to static lib archive $lib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + if test yes = "$module"; then + echo "*** But as you try to build a module library, libtool will still create " + echo "*** a static module, that should work as long as the dlopening application" + echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using 'nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** 'nm' from GNU binutils and a full rebuild may help." + fi + if test no = "$build_old_libs"; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test lib = "$linkmode"; then + if test -n "$dependency_libs" && + { test yes != "$hardcode_into_libs" || + test yes = "$build_old_libs" || + test yes = "$link_static"; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) func_stripname '-R' '' "$libdir" + temp_xrpath=$func_stripname_result + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) func_append xrpath " $temp_xrpath";; + esac;; + *) func_append temp_deplibs " $libdir";; + esac + done + dependency_libs=$temp_deplibs + fi + + func_append newlib_search_path " $absdir" + # Link against this library + test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result";; + *) func_resolve_sysroot "$deplib" ;; + esac + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $func_resolve_sysroot_result "*) + func_append specialdeplibs " $func_resolve_sysroot_result" ;; + esac + fi + func_append tmp_libs " $func_resolve_sysroot_result" + done + + if test no != "$link_all_deplibs"; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + path= + case $deplib in + -L*) path=$deplib ;; + *.la) + func_resolve_sysroot "$deplib" + deplib=$func_resolve_sysroot_result + func_dirname "$deplib" "" "." + dir=$func_dirname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + func_warning "cannot determine absolute directory name of '$dir'" + absdir=$dir + fi + ;; + esac + if $GREP "^installed=no" $deplib > /dev/null; then + case $host in + *-*-darwin*) + depdepl= + eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names"; then + for tmp in $deplibrary_names; do + depdepl=$tmp + done + if test -f "$absdir/$objdir/$depdepl"; then + depdepl=$absdir/$objdir/$depdepl + darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + if test -z "$darwin_install_name"; then + darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + fi + func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" + func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" + path= + fi + fi + ;; + *) + path=-L$absdir/$objdir + ;; + esac + else + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "'$deplib' is not a valid libtool archive" + test "$absdir" != "$libdir" && \ + func_warning "'$deplib' seems to be moved" + + path=-L$absdir + fi + ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + if test link = "$pass"; then + if test prog = "$linkmode"; then + compile_deplibs="$new_inherited_linker_flags $compile_deplibs" + finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" + else + compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + fi + fi + dependency_libs=$newdependency_libs + if test dlpreopen = "$pass"; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test dlopen != "$pass"; then + test conv = "$pass" || { + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) func_append lib_search_path " $dir" ;; + esac + done + newlib_search_path= + } + + if test prog,link = "$linkmode,$pass"; then + vars="compile_deplibs finalize_deplibs" + else + vars=deplibs + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) func_append tmp_libs " $deplib" ;; + esac + ;; + *) func_append tmp_libs " $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + + # Add Sun CC postdeps if required: + test CXX = "$tagname" && { + case $host_os in + linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C++ 5.9 + func_suncc_cstd_abi + + if test no != "$suncc_use_cstd_abi"; then + func_append postdeps ' -library=Cstd -library=Crun' + fi + ;; + esac + ;; + + solaris*) + func_cc_basename "$CC" + case $func_cc_basename_result in + CC* | sunCC*) + func_suncc_cstd_abi + + if test no != "$suncc_use_cstd_abi"; then + func_append postdeps ' -library=Cstd -library=Crun' + fi + ;; + esac + ;; + esac + } + + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i= + ;; + esac + if test -n "$i"; then + func_append tmp_libs " $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test prog = "$linkmode"; then + dlfiles=$newdlfiles + fi + if test prog = "$linkmode" || test lib = "$linkmode"; then + dlprefiles=$newdlprefiles + fi + + case $linkmode in + oldlib) + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + func_warning "'-dlopen' is ignored for archives" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "'-l' and '-L' are ignored for archives" ;; + esac + + test -n "$rpath" && \ + func_warning "'-rpath' is ignored for archives" + + test -n "$xrpath" && \ + func_warning "'-R' is ignored for archives" + + test -n "$vinfo" && \ + func_warning "'-version-info/-version-number' is ignored for archives" + + test -n "$release" && \ + func_warning "'-release' is ignored for archives" + + test -n "$export_symbols$export_symbols_regex" && \ + func_warning "'-export-symbols' is ignored for archives" + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs=$output + func_append objs "$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form 'libNAME.la'. + case $outputname in + lib*) + func_stripname 'lib' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + test no = "$module" \ + && func_fatal_help "libtool library '$output' must begin with 'lib'" + + if test no != "$need_lib_prefix"; then + # Add the "lib" prefix for modules if required + func_stripname '' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + func_stripname '' '.la' "$outputname" + libname=$func_stripname_result + fi + ;; + esac + + if test -n "$objs"; then + if test pass_all != "$deplibs_check_method"; then + func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" + else + echo + $ECHO "*** Warning: Linking the shared library $output against the non-libtool" + $ECHO "*** objects $objs is not portable!" + func_append libobjs " $objs" + fi + fi + + test no = "$dlself" \ + || func_warning "'-dlopen self' is ignored for libtool libraries" + + set dummy $rpath + shift + test 1 -lt "$#" \ + && func_warning "ignoring multiple '-rpath's for a libtool library" + + install_libdir=$1 + + oldlibs= + if test -z "$rpath"; then + if test yes = "$build_libtool_libs"; then + # Building a libtool convenience library. + # Some compilers have problems with a '.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + test -n "$vinfo" && \ + func_warning "'-version-info/-version-number' is ignored for convenience libraries" + + test -n "$release" && \ + func_warning "'-release' is ignored for convenience libraries" + else + + # Parse the version information argument. + save_ifs=$IFS; IFS=: + set dummy $vinfo 0 0 0 + shift + IFS=$save_ifs + + test -n "$7" && \ + func_fatal_help "too many parameters to '-version-info'" + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major=$1 + number_minor=$2 + number_revision=$3 + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # that has an extra 1 added just for fun + # + case $version_type in + # correct linux to gnu/linux during the next big refactor + darwin|freebsd-elf|linux|osf|windows|none) + func_arith $number_major + $number_minor + current=$func_arith_result + age=$number_minor + revision=$number_revision + ;; + freebsd-aout|qnx|sunos) + current=$number_major + revision=$number_minor + age=0 + ;; + irix|nonstopux) + func_arith $number_major + $number_minor + current=$func_arith_result + age=$number_minor + revision=$number_minor + lt_irix_increment=no + ;; + esac + ;; + no) + current=$1 + revision=$2 + age=$3 + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "CURRENT '$current' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + case $revision in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "REVISION '$revision' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + case $age in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "AGE '$age' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + if test "$age" -gt "$current"; then + func_error "AGE '$age' is greater than the current interface number '$current'" + func_fatal_error "'$vinfo' is not valid version information" + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + # Darwin ld doesn't like 0 for these options... + func_arith $current + 1 + minor_current=$func_arith_result + xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + # On Darwin other compilers + case $CC in + nagfor*) + verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + ;; + *) + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + esac + ;; + + freebsd-aout) + major=.$current + versuffix=.$current.$revision + ;; + + freebsd-elf) + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + ;; + + irix | nonstopux) + if test no = "$lt_irix_increment"; then + func_arith $current - $age + else + func_arith $current - $age + 1 + fi + major=$func_arith_result + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring=$verstring_prefix$major.$revision + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test 0 -ne "$loop"; do + func_arith $revision - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring=$verstring_prefix$major.$iface:$verstring + done + + # Before this point, $major must not contain '.'. + major=.$major + versuffix=$major.$revision + ;; + + linux) # correct to gnu/linux during the next big refactor + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + ;; + + osf) + func_arith $current - $age + major=.$func_arith_result + versuffix=.$current.$age.$revision + verstring=$current.$age.$revision + + # Add in all the interfaces that we are compatible with. + loop=$age + while test 0 -ne "$loop"; do + func_arith $current - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring=$verstring:$iface.0 + done + + # Make executables depend on our current version. + func_append verstring ":$current.0" + ;; + + qnx) + major=.$current + versuffix=.$current + ;; + + sco) + major=.$current + versuffix=.$current + ;; + + sunos) + major=.$current + versuffix=.$current.$revision + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 file systems. + func_arith $current - $age + major=$func_arith_result + versuffix=-$major + ;; + + *) + func_fatal_configuration "unknown library version type '$version_type'" + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring=0.0 + ;; + esac + if test no = "$need_version"; then + versuffix= + else + versuffix=.0.0 + fi + fi + + # Remove version info from name if versioning should be avoided + if test yes,no = "$avoid_version,$need_version"; then + major= + versuffix= + verstring= + fi + + # Check to see if the archive will have undefined symbols. + if test yes = "$allow_undefined"; then + if test unsupported = "$allow_undefined_flag"; then + if test yes = "$build_old_libs"; then + func_warning "undefined symbols not allowed in $host shared libraries; building static only" + build_libtool_libs=no + else + func_fatal_error "can't build $host shared library unless -no-undefined is specified" + fi + fi + else + # Don't allow undefined symbols. + allow_undefined_flag=$no_undefined_flag + fi + + fi + + func_generate_dlsyms "$libname" "$libname" : + func_append libobjs " $symfileobj" + test " " = "$libobjs" && libobjs= + + if test relink != "$opt_mode"; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$ECHO "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext | *.gcno) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) + if test -n "$precious_files_regex"; then + if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + func_append removelist " $p" + ;; + *) ;; + esac + done + test -n "$removelist" && \ + func_show_eval "${RM}r \$removelist" + fi + + # Now set the variables for building old libraries. + if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then + func_append oldlibs " $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + #for path in $notinst_path; do + # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` + # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` + # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` + #done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + func_replace_sysroot "$libdir" + func_append temp_xrpath " -R$func_replace_sysroot_result" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + done + if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles=$dlfiles + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) func_append dlfiles " $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles=$dlprefiles + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) func_append dlprefiles " $lib" ;; + esac + done + + if test yes = "$build_libtool_libs"; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + func_append deplibs " System.ltframework" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test yes = "$build_libtool_need_lc"; then + func_append deplibs " -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release= + versuffix= + major= + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $opt_dry_run || $RM conftest.c + cat > conftest.c </dev/null` + $nocaseglob + else + potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` + fi + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null | + $GREP " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib=$potent_lib + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | $SED 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; + *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | + $SED -e 10q | + $EGREP "$file_magic_regex" > /dev/null; then + func_append newdeplibs " $a_deplib" + a_deplib= + break 2 + fi + done + done + fi + if test -n "$a_deplib"; then + droppeddeps=yes + echo + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib"; then + $ECHO "*** with $libname but no candidates were found. (...for file magic test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a file magic. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + func_append newdeplibs " $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + for a_deplib in $deplibs; do + case $a_deplib in + -l*) + func_stripname -l '' "$a_deplib" + name=$func_stripname_result + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + case " $predeps $postdeps " in + *" $a_deplib "*) + func_append newdeplibs " $a_deplib" + a_deplib= + ;; + esac + fi + if test -n "$a_deplib"; then + libname=`eval "\\$ECHO \"$libname_spec\""` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib=$potent_lib # see symlink-check above in file_magic test + if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ + $EGREP "$match_pattern_regex" > /dev/null; then + func_append newdeplibs " $a_deplib" + a_deplib= + break 2 + fi + done + done + fi + if test -n "$a_deplib"; then + droppeddeps=yes + echo + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib"; then + $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a regex pattern. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + func_append newdeplibs " $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs= + tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + for i in $predeps $postdeps; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` + done + fi + case $tmp_deplibs in + *[!\ \ ]*) + echo + if test none = "$deplibs_check_method"; then + echo "*** Warning: inter-library dependencies are not supported in this platform." + else + echo "*** Warning: inter-library dependencies are not known to be supported." + fi + echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + ;; + esac + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library with the System framework + newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` + ;; + esac + + if test yes = "$droppeddeps"; then + if test yes = "$module"; then + echo + echo "*** Warning: libtool could not satisfy all declared inter-library" + $ECHO "*** dependencies of module $libname. Therefore, libtool will create" + echo "*** a static module, that should work as long as the dlopening" + echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using 'nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** 'nm' from GNU binutils and a full rebuild may help." + fi + if test no = "$build_old_libs"; then + oldlibs=$output_objdir/$libname.$libext + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + echo "*** The inter-library dependencies that have been dropped here will be" + echo "*** automatically added whenever a program is linked with this library" + echo "*** or is declared to -dlopen it." + + if test no = "$allow_undefined"; then + echo + echo "*** Since this library must not contain undefined symbols," + echo "*** because either the platform does not support them or" + echo "*** it was explicitly requested with -no-undefined," + echo "*** libtool will only create a static version of it." + if test no = "$build_old_libs"; then + oldlibs=$output_objdir/$libname.$libext + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + case $host in + *-*-darwin*) + newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $deplibs " in + *" -L$path/$objdir "*) + func_append new_libs " -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) func_append new_libs " $deplib" ;; + esac + ;; + *) func_append new_libs " $deplib" ;; + esac + done + deplibs=$new_libs + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test yes = "$build_libtool_libs"; then + # Remove $wl instances when linking with ld. + # FIXME: should test the right _cmds variable. + case $archive_cmds in + *\$LD\ *) wl= ;; + esac + if test yes = "$hardcode_into_libs"; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath=$finalize_rpath + test relink = "$opt_mode" || rpath=$compile_rpath$rpath + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + func_replace_sysroot "$libdir" + libdir=$func_replace_sysroot_result + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append dep_rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) func_append perm_rpath " $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + func_append rpath "$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath=$finalize_shlibpath + test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext_cmds\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + shift + realname=$1 + shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname=$realname + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib=$output_objdir/$realname + linknames= + for link + do + func_append linknames " $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` + test "X$libobjs" = "X " && libobjs= + + delfiles= + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" + export_symbols=$output_objdir/$libname.uexp + func_append delfiles " $export_symbols" + fi + + orig_export_symbols= + case $host_os in + cygwin* | mingw* | cegcc*) + if test -n "$export_symbols" && test -z "$export_symbols_regex"; then + # exporting using user supplied symfile + func_dll_def_p "$export_symbols" || { + # and it's NOT already a .def file. Must figure out + # which of the given symbols are data symbols and tag + # them as such. So, trigger use of export_symbols_cmds. + # export_symbols gets reassigned inside the "prepare + # the list of exported symbols" if statement, so the + # include_expsyms logic still works. + orig_export_symbols=$export_symbols + export_symbols= + always_export_symbols=yes + } + fi + ;; + esac + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then + func_verbose "generating symbol list for '$libname.la'" + export_symbols=$output_objdir/$libname.exp + $opt_dry_run || $RM $export_symbols + cmds=$export_symbols_cmds + save_ifs=$IFS; IFS='~' + for cmd1 in $cmds; do + IFS=$save_ifs + # Take the normal branch if the nm_file_list_spec branch + # doesn't work or if tool conversion is not needed. + case $nm_file_list_spec~$to_tool_file_cmd in + *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) + try_normal_branch=yes + eval cmd=\"$cmd1\" + func_len " $cmd" + len=$func_len_result + ;; + *) + try_normal_branch=no + ;; + esac + if test yes = "$try_normal_branch" \ + && { test "$len" -lt "$max_cmd_len" \ + || test "$max_cmd_len" -le -1; } + then + func_show_eval "$cmd" 'exit $?' + skipped_export=false + elif test -n "$nm_file_list_spec"; then + func_basename "$output" + output_la=$func_basename_result + save_libobjs=$libobjs + save_output=$output + output=$output_objdir/$output_la.nm + func_to_tool_file "$output" + libobjs=$nm_file_list_spec$func_to_tool_file_result + func_append delfiles " $output" + func_verbose "creating $NM input file list: $output" + for obj in $save_libobjs; do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" + done > "$output" + eval cmd=\"$cmd1\" + func_show_eval "$cmd" 'exit $?' + output=$save_output + libobjs=$save_libobjs + skipped_export=false + else + # The command line is too long to execute in one step. + func_verbose "using reloadable object file for export list..." + skipped_export=: + # Break out early, otherwise skipped_export may be + # set to false by a later but shorter cmd. + break + fi + done + IFS=$save_ifs + if test -n "$export_symbols_regex" && test : != "$skipped_export"; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols=$export_symbols + test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols + $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' + fi + + if test : != "$skipped_export" && test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for '$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands, which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + func_append delfiles " $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + func_append tmp_deplibs " $test_deplib" + ;; + esac + done + deplibs=$tmp_deplibs + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec" && + test yes = "$compiler_needs_object" && + test -z "$libobjs"; then + # extract the archives, so we have objects to list. + # TODO: could optimize this to just extract one archive. + whole_archive_flag_spec= + fi + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + else + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $convenience + func_append libobjs " $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + fi + + if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + func_append linker_flags " $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test relink = "$opt_mode"; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test yes = "$module" && test -n "$module_cmds"; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test : != "$skipped_export" && + func_len " $test_cmds" && + len=$func_len_result && + test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise + # or, if using GNU ld and skipped_export is not :, use a linker + # script. + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + func_basename "$output" + output_la=$func_basename_result + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + last_robj= + k=1 + + if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then + output=$output_objdir/$output_la.lnkscript + func_verbose "creating GNU ld script: $output" + echo 'INPUT (' > $output + for obj in $save_libobjs + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" >> $output + done + echo ')' >> $output + func_append delfiles " $output" + func_to_tool_file "$output" + output=$func_to_tool_file_result + elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then + output=$output_objdir/$output_la.lnk + func_verbose "creating linker input file list: $output" + : > $output + set x $save_libobjs + shift + firstobj= + if test yes = "$compiler_needs_object"; then + firstobj="$1 " + shift + fi + for obj + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" >> $output + done + func_append delfiles " $output" + func_to_tool_file "$output" + output=$firstobj\"$file_list_spec$func_to_tool_file_result\" + else + if test -n "$save_libobjs"; then + func_verbose "creating reloadable object files..." + output=$output_objdir/$output_la-$k.$objext + eval test_cmds=\"$reload_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + if test -z "$objlist" || + test "$len" -lt "$max_cmd_len"; then + func_append objlist " $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test 1 -eq "$k"; then + # The first file doesn't have a previous command to add. + reload_objs=$objlist + eval concat_cmds=\"$reload_cmds\" + else + # All subsequent reloadable object files will link in + # the last one created. + reload_objs="$objlist $last_robj" + eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" + fi + last_robj=$output_objdir/$output_la-$k.$objext + func_arith $k + 1 + k=$func_arith_result + output=$output_objdir/$output_la-$k.$objext + objlist=" $obj" + func_len " $last_robj" + func_arith $len0 + $func_len_result + len=$func_arith_result + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + reload_objs="$objlist $last_robj" + eval concat_cmds=\"\$concat_cmds$reload_cmds\" + if test -n "$last_robj"; then + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" + fi + func_append delfiles " $output" + + else + output= + fi + + ${skipped_export-false} && { + func_verbose "generating symbol list for '$libname.la'" + export_symbols=$output_objdir/$libname.exp + $opt_dry_run || $RM $export_symbols + libobjs=$output + # Append the command to create the export file. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" + if test -n "$last_robj"; then + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" + fi + } + + test -n "$save_libobjs" && + func_verbose "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs=$IFS; IFS='~' + for cmd in $concat_cmds; do + IFS=$save_ifs + $opt_quiet || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS=$save_ifs + + if test -n "$export_symbols_regex" && ${skipped_export-false}; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + + ${skipped_export-false} && { + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols=$export_symbols + test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols + $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' + fi + + if test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for '$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands, which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + func_append delfiles " $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + } + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test yes = "$module" && test -n "$module_cmds"; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + fi + + if test -n "$delfiles"; then + # Append the command to remove temporary files to $cmds. + eval cmds=\"\$cmds~\$RM $delfiles\" + fi + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $dlprefiles + func_append libobjs " $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + + save_ifs=$IFS; IFS='~' + for cmd in $cmds; do + IFS=$sp$nl + eval cmd=\"$cmd\" + IFS=$save_ifs + $opt_quiet || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS=$save_ifs + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? + + if test -n "$convenience"; then + if test -z "$whole_archive_flag_spec"; then + func_show_eval '${RM}r "$gentop"' + fi + fi + + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test yes = "$module" || test yes = "$export_dynamic"; then + # On all known operating systems, these are identical. + dlname=$soname + fi + fi + ;; + + obj) + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + func_warning "'-dlopen' is ignored for objects" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "'-l' and '-L' are ignored for objects" ;; + esac + + test -n "$rpath" && \ + func_warning "'-rpath' is ignored for objects" + + test -n "$xrpath" && \ + func_warning "'-R' is ignored for objects" + + test -n "$vinfo" && \ + func_warning "'-version-info' is ignored for objects" + + test -n "$release" && \ + func_warning "'-release' is ignored for objects" + + case $output in + *.lo) + test -n "$objs$old_deplibs" && \ + func_fatal_error "cannot build library object '$output' from non-libtool objects" + + libobj=$output + func_lo2o "$libobj" + obj=$func_lo2o_result + ;; + *) + libobj= + obj=$output + ;; + esac + + # Delete the old objects. + $opt_dry_run || $RM $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # if reload_cmds runs $LD directly, get rid of -Wl from + # whole_archive_flag_spec and hope we can get by with turning comma + # into space. + case $reload_cmds in + *\$LD[\ \$]*) wl= ;; + esac + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" + test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` + reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags + else + gentop=$output_objdir/${obj}x + func_append generated " $gentop" + + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" + fi + fi + + # If we're not building shared, we need to use non_pic_objs + test yes = "$build_libtool_libs" || libobjs=$non_pic_objects + + # Create the old-style object. + reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs + + output=$obj + func_execute_cmds "$reload_cmds" 'exit $?' + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + fi + + test yes = "$build_libtool_libs" || { + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? + exit $EXIT_SUCCESS + } + + if test -n "$pic_flag" || test default != "$pic_mode"; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output=$libobj + func_execute_cmds "$reload_cmds" 'exit $?' + fi + + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) func_stripname '' '.exe' "$output" + output=$func_stripname_result.exe;; + esac + test -n "$vinfo" && \ + func_warning "'-version-info' is ignored for programs" + + test -n "$release" && \ + func_warning "'-release' is ignored for programs" + + $preload \ + && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ + && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` + finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` + ;; + esac + + case $host in + *-*-darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + # But is supposedly fixed on 10.4 or later (yay!). + if test CXX = "$tagname"; then + case ${MACOSX_DEPLOYMENT_TARGET-10.0} in + 10.[0123]) + func_append compile_command " $wl-bind_at_load" + func_append finalize_command " $wl-bind_at_load" + ;; + esac + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $compile_deplibs " in + *" -L$path/$objdir "*) + func_append new_libs " -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $compile_deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) func_append new_libs " $deplib" ;; + esac + ;; + *) func_append new_libs " $deplib" ;; + esac + done + compile_deplibs=$new_libs + + + func_append compile_command " $compile_deplibs" + func_append finalize_command " $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) func_append perm_rpath " $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; + ::) dllsearchpath=$libdir;; + *) func_append dllsearchpath ":$libdir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) func_append dllsearchpath ":$testbindir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath=$rpath + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) func_append finalize_perm_rpath " $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath=$rpath + + if test -n "$libobjs" && test yes = "$build_old_libs"; then + # Transform all the library objects into standard objects. + compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` + finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` + fi + + func_generate_dlsyms "$outputname" "@PROGRAM@" false + + # template prelinking step + if test -n "$prelink_cmds"; then + func_execute_cmds "$prelink_cmds" 'exit $?' + fi + + wrappers_required=: + case $host in + *cegcc* | *mingw32ce*) + # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. + wrappers_required=false + ;; + *cygwin* | *mingw* ) + test yes = "$build_libtool_libs" || wrappers_required=false + ;; + *) + if test no = "$need_relink" || test yes != "$build_libtool_libs"; then + wrappers_required=false + fi + ;; + esac + $wrappers_required || { + # Replace the output file specification. + compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + link_command=$compile_command$compile_rpath + + # We have no uninstalled library dependencies, so finalize right now. + exit_status=0 + func_show_eval "$link_command" 'exit_status=$?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + # Delete the generated files. + if test -f "$output_objdir/${outputname}S.$objext"; then + func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' + fi + + exit $exit_status + } + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + func_append rpath "$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + func_append rpath "$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test yes = "$no_install"; then + # We don't need to create a wrapper script. + link_command=$compile_var$compile_command$compile_rpath + # Replace the output file specification. + link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $opt_dry_run || $RM $output + # Link the executable and exit + func_show_eval "$link_command" 'exit $?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + exit $EXIT_SUCCESS + fi + + case $hardcode_action,$fast_install in + relink,*) + # Fast installation is not supported + link_command=$compile_var$compile_command$compile_rpath + relink_command=$finalize_var$finalize_command$finalize_rpath + + func_warning "this platform does not like uninstalled shared libraries" + func_warning "'$output' will be relinked during installation" + ;; + *,yes) + link_command=$finalize_var$compile_command$finalize_rpath + relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` + ;; + *,no) + link_command=$compile_var$compile_command$compile_rpath + relink_command=$finalize_var$finalize_command$finalize_rpath + ;; + *,needless) + link_command=$finalize_var$compile_command$finalize_rpath + relink_command= + ;; + esac + + # Replace the output file specification. + link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname + + func_show_eval "$link_command" 'exit $?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output_objdir/$outputname" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + # Now create the wrapper script. + func_verbose "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + fi + + # Only actually do things if not in dry run mode. + $opt_dry_run || { + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) func_stripname '' '.exe' "$output" + output=$func_stripname_result ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + func_stripname '' '.exe' "$outputname" + outputname=$func_stripname_result ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + func_dirname_and_basename "$output" "" "." + output_name=$func_basename_result + output_path=$func_dirname_result + cwrappersource=$output_path/$objdir/lt-$output_name.c + cwrapper=$output_path/$output_name.exe + $RM $cwrappersource $cwrapper + trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + func_emit_cwrapperexe_src > $cwrappersource + + # The wrapper executable is built using the $host compiler, + # because it contains $host paths and files. If cross- + # compiling, it, like the target executable, must be + # executed on the $host or under an emulation environment. + $opt_dry_run || { + $LTCC $LTCFLAGS -o $cwrapper $cwrappersource + $STRIP $cwrapper + } + + # Now, create the wrapper script for func_source use: + func_ltwrapper_scriptname $cwrapper + $RM $func_ltwrapper_scriptname_result + trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 + $opt_dry_run || { + # note: this script will not be executed, so do not chmod. + if test "x$build" = "x$host"; then + $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result + else + func_emit_wrapper no > $func_ltwrapper_scriptname_result + fi + } + ;; + * ) + $RM $output + trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 + + func_emit_wrapper no > $output + chmod +x $output + ;; + esac + } + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + case $build_libtool_libs in + convenience) + oldobjs="$libobjs_save $symfileobj" + addlibs=$convenience + build_libtool_libs=no + ;; + module) + oldobjs=$libobjs_save + addlibs=$old_convenience + build_libtool_libs=no + ;; + *) + oldobjs="$old_deplibs $non_pic_objects" + $preload && test -f "$symfileobj" \ + && func_append oldobjs " $symfileobj" + addlibs=$old_convenience + ;; + esac + + if test -n "$addlibs"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $addlibs + func_append oldobjs " $func_extract_archives_result" + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then + cmds=$old_archive_from_new_cmds + else + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $dlprefiles + func_append oldobjs " $func_extract_archives_result" + fi + + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + func_basename "$obj" + $ECHO "$func_basename_result" + done | sort | sort -uc >/dev/null 2>&1); then + : + else + echo "copying selected object files to avoid basename conflicts..." + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + func_mkdir_p "$gentop" + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + func_basename "$obj" + objbase=$func_basename_result + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + func_arith $counter + 1 + counter=$func_arith_result + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + func_append oldobjs " $gentop/$newobj" + ;; + *) func_append oldobjs " $obj" ;; + esac + done + fi + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result + eval cmds=\"$old_archive_cmds\" + + func_len " $cmds" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + elif test -n "$archiver_list_spec"; then + func_verbose "using command file archive linking..." + for obj in $oldobjs + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" + done > $output_objdir/$libname.libcmd + func_to_tool_file "$output_objdir/$libname.libcmd" + oldobjs=" $archiver_list_spec$func_to_tool_file_result" + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + func_verbose "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + oldobjs= + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + eval test_cmds=\"$old_archive_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + for obj in $save_oldobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + func_append objlist " $obj" + if test "$len" -lt "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj"; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" + objlist= + len=$len0 + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test -z "$oldobjs"; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + func_execute_cmds "$cmds" 'exit $?' + done + + test -n "$generated" && \ + func_show_eval "${RM}r$generated" + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test yes = "$build_old_libs" && old_library=$libname.$libext + func_verbose "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + if test yes = "$hardcode_automatic"; then + relink_command= + fi + + # Only create the output if not a dry run. + $opt_dry_run || { + for installed in no yes; do + if test yes = "$installed"; then + if test -z "$install_libdir"; then + break + fi + output=$output_objdir/${outputname}i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + func_basename "$deplib" + name=$func_basename_result + func_resolve_sysroot "$deplib" + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` + test -z "$libdir" && \ + func_fatal_error "'$deplib' is not a valid libtool archive" + func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" + ;; + -L*) + func_stripname -L '' "$deplib" + func_replace_sysroot "$func_stripname_result" + func_append newdependency_libs " -L$func_replace_sysroot_result" + ;; + -R*) + func_stripname -R '' "$deplib" + func_replace_sysroot "$func_stripname_result" + func_append newdependency_libs " -R$func_replace_sysroot_result" + ;; + *) func_append newdependency_libs " $deplib" ;; + esac + done + dependency_libs=$newdependency_libs + newdlfiles= + + for lib in $dlfiles; do + case $lib in + *.la) + func_basename "$lib" + name=$func_basename_result + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "'$lib' is not a valid libtool archive" + func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" + ;; + *) func_append newdlfiles " $lib" ;; + esac + done + dlfiles=$newdlfiles + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + *.la) + # Only pass preopened files to the pseudo-archive (for + # eventual linking with the app. that links it) if we + # didn't already link the preopened objects directly into + # the library: + func_basename "$lib" + name=$func_basename_result + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "'$lib' is not a valid libtool archive" + func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" + ;; + esac + done + dlprefiles=$newdlprefiles + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; + *) abs=`pwd`"/$lib" ;; + esac + func_append newdlfiles " $abs" + done + dlfiles=$newdlfiles + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; + *) abs=`pwd`"/$lib" ;; + esac + func_append newdlprefiles " $abs" + done + dlprefiles=$newdlprefiles + fi + $RM $output + # place dlname in correct position for cygwin + # In fact, it would be nice if we could use this code for all target + # systems that can't hard-code library paths into their executables + # and that have no shared library path variable independent of PATH, + # but it turns out we can't easily determine that from inspecting + # libtool variables, so we have to hard-code the OSs to which it + # applies here; at the moment, that means platforms that use the PE + # object format with DLL files. See the long comment at the top of + # tests/bindir.at for full details. + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) + # If a -bindir argument was supplied, place the dll there. + if test -n "$bindir"; then + func_relative_path "$install_libdir" "$bindir" + tdlname=$func_relative_path_result/$dlname + else + # Otherwise fall back on heuristic. + tdlname=../bin/$dlname + fi + ;; + esac + $ECHO > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM (GNU $PACKAGE) $VERSION +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags='$new_inherited_linker_flags' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Names of additional weak libraries provided by this library +weak_library_names='$weak_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test no,yes = "$installed,$need_relink"; then + $ECHO >> $output "\ +relink_command=\"$relink_command\"" + fi + done + } + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' + ;; + esac + exit $EXIT_SUCCESS +} + +if test link = "$opt_mode" || test relink = "$opt_mode"; then + func_mode_link ${1+"$@"} +fi + + +# func_mode_uninstall arg... +func_mode_uninstall () +{ + $debug_cmd + + RM=$nonopt + files= + rmforce=false + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic=$magic + + for arg + do + case $arg in + -f) func_append RM " $arg"; rmforce=: ;; + -*) func_append RM " $arg" ;; + *) func_append files " $arg" ;; + esac + done + + test -z "$RM" && \ + func_fatal_help "you must specify an RM program" + + rmdirs= + + for file in $files; do + func_dirname "$file" "" "." + dir=$func_dirname_result + if test . = "$dir"; then + odir=$objdir + else + odir=$dir/$objdir + fi + func_basename "$file" + name=$func_basename_result + test uninstall = "$opt_mode" && odir=$dir + + # Remember odir for removal later, being careful to avoid duplicates + if test clean = "$opt_mode"; then + case " $rmdirs " in + *" $odir "*) ;; + *) func_append rmdirs " $odir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if { test -L "$file"; } >/dev/null 2>&1 || + { test -h "$file"; } >/dev/null 2>&1 || + test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif $rmforce; then + continue + fi + + rmfiles=$file + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if func_lalib_p "$file"; then + func_source $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + func_append rmfiles " $odir/$n" + done + test -n "$old_library" && func_append rmfiles " $odir/$old_library" + + case $opt_mode in + clean) + case " $library_names " in + *" $dlname "*) ;; + *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; + esac + test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" + ;; + uninstall) + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' + fi + # FIXME: should reinstall the best remaining shared library. + ;; + esac + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if func_lalib_p "$file"; then + + # Read the .lo file + func_source $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" && test none != "$pic_object"; then + func_append rmfiles " $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" && test none != "$non_pic_object"; then + func_append rmfiles " $dir/$non_pic_object" + fi + fi + ;; + + *) + if test clean = "$opt_mode"; then + noexename=$name + case $file in + *.exe) + func_stripname '' '.exe' "$file" + file=$func_stripname_result + func_stripname '' '.exe' "$name" + noexename=$func_stripname_result + # $file with .exe has already been added to rmfiles, + # add $file without .exe + func_append rmfiles " $file" + ;; + esac + # Do a test to see if this is a libtool program. + if func_ltwrapper_p "$file"; then + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + relink_command= + func_source $func_ltwrapper_scriptname_result + func_append rmfiles " $func_ltwrapper_scriptname_result" + else + relink_command= + func_source $dir/$noexename + fi + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + func_append rmfiles " $odir/$name $odir/${name}S.$objext" + if test yes = "$fast_install" && test -n "$relink_command"; then + func_append rmfiles " $odir/lt-$name" + fi + if test "X$noexename" != "X$name"; then + func_append rmfiles " $odir/lt-$noexename.c" + fi + fi + fi + ;; + esac + func_show_eval "$RM $rmfiles" 'exit_status=1' + done + + # Try to remove the $objdir's in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + func_show_eval "rmdir $dir >/dev/null 2>&1" + fi + done + + exit $exit_status +} + +if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then + func_mode_uninstall ${1+"$@"} +fi + +test -z "$opt_mode" && { + help=$generic_help + func_fatal_help "you must specify a MODE" +} + +test -z "$exec_cmd" && \ + func_fatal_help "invalid operation mode '$opt_mode'" + +if test -n "$exec_cmd"; then + eval exec "$exec_cmd" + exit $EXIT_FAILURE +fi + +exit $exit_status + + +# The TAGs below are defined such that we never get into a situation +# where we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/thirdparty/jpeg-9e/makcjpeg.st b/thirdparty/jpeg-9e/makcjpeg.st new file mode 100644 index 0000000..628f533 --- /dev/null +++ b/thirdparty/jpeg-9e/makcjpeg.st @@ -0,0 +1,36 @@ +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle, B. Setzepfandt, and Guido Vollbeding. +; +; To use this file, rename it to cjpeg.prj. +; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +cjpeg.ttp +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost += +; * * * * List of modules * * * * +pcstart.o +cjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) +cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +libjpeg.lib ; built by libjpeg.prj +pcfltlib.lib ; floating point library +; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED +pcstdlib.lib ; standard library +pcextlib.lib ; extended library diff --git a/thirdparty/jpeg-9e/makdjpeg.st b/thirdparty/jpeg-9e/makdjpeg.st new file mode 100644 index 0000000..4b61404 --- /dev/null +++ b/thirdparty/jpeg-9e/makdjpeg.st @@ -0,0 +1,36 @@ +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle, B. Setzepfandt, and Guido Vollbeding. +; +; To use this file, rename it to djpeg.prj. +; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +djpeg.ttp +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost += +; * * * * List of modules * * * * +pcstart.o +djpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) +cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdcolmap.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +libjpeg.lib ; built by libjpeg.prj +pcfltlib.lib ; floating point library +; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED +pcstdlib.lib ; standard library +pcextlib.lib ; extended library diff --git a/thirdparty/jpeg-9e/makeadsw.vc6 b/thirdparty/jpeg-9e/makeadsw.vc6 new file mode 100644 index 0000000..80459c5 --- /dev/null +++ b/thirdparty/jpeg-9e/makeadsw.vc6 @@ -0,0 +1,77 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GEL™SCHT WERDEN! + +############################################################################### + +Project: "cjpeg"=".\cjpeg.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "djpeg"=".\djpeg.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "jpegtran"=".\jpegtran.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "rdjpgcom"=".\rdjpgcom.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "wrjpgcom"=".\wrjpgcom.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/thirdparty/jpeg-9e/makeasln.v16 b/thirdparty/jpeg-9e/makeasln.v16 new file mode 100644 index 0000000..3880c9f --- /dev/null +++ b/thirdparty/jpeg-9e/makeasln.v16 @@ -0,0 +1,71 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31402.337 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cjpeg", "cjpeg.vcxproj", "{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "djpeg", "djpeg.vcxproj", "{11043137-B453-4DFA-9010-4D2B9DC1545C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpegtran", "jpegtran.vcxproj", "{025BAC50-51B5-4FFE-BC47-3F920BB4047E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rdjpgcom", "rdjpgcom.vcxproj", "{C81513DB-78DC-46BC-BC98-82E745203976}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wrjpgcom", "wrjpgcom.vcxproj", "{B57065D4-DDDA-4668-BAF5-2D49270C973C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|ARM.ActiveCfg = Release|ARM + {2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|ARM.Build.0 = Release|ARM + {2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|ARM64.ActiveCfg = Release|ARM64 + {2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|ARM64.Build.0 = Release|ARM64 + {2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|Win32.ActiveCfg = Release|Win32 + {2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|Win32.Build.0 = Release|Win32 + {2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|x64.ActiveCfg = Release|x64 + {2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|x64.Build.0 = Release|x64 + {11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|ARM.ActiveCfg = Release|ARM + {11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|ARM.Build.0 = Release|ARM + {11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|ARM64.ActiveCfg = Release|ARM64 + {11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|ARM64.Build.0 = Release|ARM64 + {11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|Win32.ActiveCfg = Release|Win32 + {11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|Win32.Build.0 = Release|Win32 + {11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|x64.ActiveCfg = Release|x64 + {11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|x64.Build.0 = Release|x64 + {025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|ARM.ActiveCfg = Release|ARM + {025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|ARM.Build.0 = Release|ARM + {025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|ARM64.ActiveCfg = Release|ARM64 + {025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|ARM64.Build.0 = Release|ARM64 + {025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|Win32.ActiveCfg = Release|Win32 + {025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|Win32.Build.0 = Release|Win32 + {025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|x64.ActiveCfg = Release|x64 + {025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|x64.Build.0 = Release|x64 + {C81513DB-78DC-46BC-BC98-82E745203976}.Release|ARM.ActiveCfg = Release|ARM + {C81513DB-78DC-46BC-BC98-82E745203976}.Release|ARM.Build.0 = Release|ARM + {C81513DB-78DC-46BC-BC98-82E745203976}.Release|ARM64.ActiveCfg = Release|ARM64 + {C81513DB-78DC-46BC-BC98-82E745203976}.Release|ARM64.Build.0 = Release|ARM64 + {C81513DB-78DC-46BC-BC98-82E745203976}.Release|Win32.ActiveCfg = Release|Win32 + {C81513DB-78DC-46BC-BC98-82E745203976}.Release|Win32.Build.0 = Release|Win32 + {C81513DB-78DC-46BC-BC98-82E745203976}.Release|x64.ActiveCfg = Release|x64 + {C81513DB-78DC-46BC-BC98-82E745203976}.Release|x64.Build.0 = Release|x64 + {B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|ARM.ActiveCfg = Release|ARM + {B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|ARM.Build.0 = Release|ARM + {B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|ARM64.ActiveCfg = Release|ARM64 + {B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|ARM64.Build.0 = Release|ARM64 + {B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|Win32.ActiveCfg = Release|Win32 + {B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|Win32.Build.0 = Release|Win32 + {B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|x64.ActiveCfg = Release|x64 + {B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2F6B4B1E-5D02-475F-B2FE-EA2D9E697E54} + EndGlobalSection +EndGlobal diff --git a/thirdparty/jpeg-9e/makecdep.vc6 b/thirdparty/jpeg-9e/makecdep.vc6 new file mode 100644 index 0000000..11dff77 --- /dev/null +++ b/thirdparty/jpeg-9e/makecdep.vc6 @@ -0,0 +1,82 @@ +# Microsoft Developer Studio erstellte Abh„ngigkeitsdatei, einbezogen von cjpeg.mak + +.\cdjpeg.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\cjpeg.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + ".\jversion.h"\ + + +.\rdbmp.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\rdgif.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\rdppm.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\rdrle.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\rdswitch.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\rdtarga.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + diff --git a/thirdparty/jpeg-9e/makecdsp.vc6 b/thirdparty/jpeg-9e/makecdsp.vc6 new file mode 100644 index 0000000..68fea83 --- /dev/null +++ b/thirdparty/jpeg-9e/makecdsp.vc6 @@ -0,0 +1,130 @@ +# Microsoft Developer Studio Project File - Name="cjpeg" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=cjpeg - Win32 +!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "cjpeg.mak". +!MESSAGE +!MESSAGE Sie k÷nnen beim Ausfhren von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "cjpeg.mak" CFG="cjpeg - Win32" +!MESSAGE +!MESSAGE Fr die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "cjpeg - Win32" (basierend auf "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir ".\cjpeg\Release" +# PROP BASE Intermediate_Dir ".\cjpeg\Release" +# PROP BASE Target_Dir ".\cjpeg" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir ".\Release" +# PROP Intermediate_Dir ".\Release\cjpeg" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir ".\cjpeg" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# Begin Target + +# Name "cjpeg - Win32" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90" +# Begin Source File + +SOURCE=.\cdjpeg.c +# End Source File +# Begin Source File + +SOURCE=.\cjpeg.c +# End Source File +# Begin Source File + +SOURCE=.\rdbmp.c +# End Source File +# Begin Source File + +SOURCE=.\rdgif.c +# End Source File +# Begin Source File + +SOURCE=.\rdppm.c +# End Source File +# Begin Source File + +SOURCE=.\rdrle.c +# End Source File +# Begin Source File + +SOURCE=.\rdswitch.c +# End Source File +# Begin Source File + +SOURCE=.\rdtarga.c +# End Source File +# End Group +# Begin Group "Header-Dateien" + +# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" +# Begin Source File + +SOURCE=.\cderror.h +# End Source File +# Begin Source File + +SOURCE=.\cdjpeg.h +# End Source File +# Begin Source File + +SOURCE=.\jconfig.h +# End Source File +# Begin Source File + +SOURCE=.\jerror.h +# End Source File +# Begin Source File + +SOURCE=.\jinclude.h +# End Source File +# Begin Source File + +SOURCE=.\jmorecfg.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib.h +# End Source File +# Begin Source File + +SOURCE=.\jversion.h +# End Source File +# End Group +# Begin Group "Ressourcendateien" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/thirdparty/jpeg-9e/makecfil.v16 b/thirdparty/jpeg-9e/makecfil.v16 new file mode 100644 index 0000000..2c00239 --- /dev/null +++ b/thirdparty/jpeg-9e/makecfil.v16 @@ -0,0 +1,69 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makecmak.vc6 b/thirdparty/jpeg-9e/makecmak.vc6 new file mode 100644 index 0000000..bee03bf --- /dev/null +++ b/thirdparty/jpeg-9e/makecmak.vc6 @@ -0,0 +1,159 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on cjpeg.dsp +!IF "$(CFG)" == "" +CFG=cjpeg - Win32 +!MESSAGE Keine Konfiguration angegeben. cjpeg - Win32 wird als Standard verwendet. +!ENDIF + +!IF "$(CFG)" != "cjpeg - Win32" +!MESSAGE Ungültige Konfiguration "$(CFG)" angegeben. +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "cjpeg.mak" CFG="cjpeg - Win32" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "cjpeg - Win32" (basierend auf "Win32 (x86) Console Application") +!MESSAGE +!ERROR Eine ungültige Konfiguration wurde angegeben. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +CPP=cl.exe +RSC=rc.exe +OUTDIR=.\cjpeg\Release +INTDIR=.\cjpeg\Release +# Begin Custom Macros +OutDir=.\cjpeg\Release +# End Custom Macros + +ALL : "$(OUTDIR)\cjpeg.exe" + + +CLEAN : + -@erase "$(INTDIR)\cdjpeg.obj" + -@erase "$(INTDIR)\cjpeg.obj" + -@erase "$(INTDIR)\rdbmp.obj" + -@erase "$(INTDIR)\rdgif.obj" + -@erase "$(INTDIR)\rdppm.obj" + -@erase "$(INTDIR)\rdrle.obj" + -@erase "$(INTDIR)\rdswitch.obj" + -@erase "$(INTDIR)\rdtarga.obj" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(OUTDIR)\cjpeg.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\cjpeg.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\cjpeg.pdb" /machine:I386 /out:"$(OUTDIR)\cjpeg.exe" +LINK32_OBJS= \ + "$(INTDIR)\cdjpeg.obj" \ + "$(INTDIR)\cjpeg.obj" \ + "$(INTDIR)\rdbmp.obj" \ + "$(INTDIR)\rdgif.obj" \ + "$(INTDIR)\rdppm.obj" \ + "$(INTDIR)\rdrle.obj" \ + "$(INTDIR)\rdswitch.obj" \ + "$(INTDIR)\rdtarga.obj" + +"$(OUTDIR)\cjpeg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +CPP_PROJ=/nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /Fp"$(INTDIR)\cjpeg.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("cjpeg.dep") +!INCLUDE "cjpeg.dep" +!ELSE +!MESSAGE Warning: cannot find "cjpeg.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "cjpeg - Win32" +SOURCE=.\cdjpeg.c + +"$(INTDIR)\cdjpeg.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\cjpeg.c + +"$(INTDIR)\cjpeg.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\rdbmp.c + +"$(INTDIR)\rdbmp.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\rdgif.c + +"$(INTDIR)\rdgif.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\rdppm.c + +"$(INTDIR)\rdppm.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\rdrle.c + +"$(INTDIR)\rdrle.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\rdswitch.c + +"$(INTDIR)\rdswitch.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\rdtarga.c + +"$(INTDIR)\rdtarga.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + diff --git a/thirdparty/jpeg-9e/makecvcx.v16 b/thirdparty/jpeg-9e/makecvcx.v16 new file mode 100644 index 0000000..ee6bd4e --- /dev/null +++ b/thirdparty/jpeg-9e/makecvcx.v16 @@ -0,0 +1,195 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57} + Win32Proj + cjpeg + 10.0 + + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + + + + + + + + + + + + + + + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makecvcx.v17 b/thirdparty/jpeg-9e/makecvcx.v17 new file mode 100644 index 0000000..b55fd90 --- /dev/null +++ b/thirdparty/jpeg-9e/makecvcx.v17 @@ -0,0 +1,195 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57} + Win32Proj + cjpeg + 10.0 + + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + + + + + + + + + + + + + + + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makeddep.vc6 b/thirdparty/jpeg-9e/makeddep.vc6 new file mode 100644 index 0000000..f911eba --- /dev/null +++ b/thirdparty/jpeg-9e/makeddep.vc6 @@ -0,0 +1,82 @@ +# Microsoft Developer Studio erstellte Abh„ngigkeitsdatei, einbezogen von djpeg.mak + +.\cdjpeg.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\djpeg.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + ".\jversion.h"\ + + +.\rdcolmap.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\wrbmp.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\wrgif.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\wrppm.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\wrrle.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\wrtarga.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + diff --git a/thirdparty/jpeg-9e/makeddsp.vc6 b/thirdparty/jpeg-9e/makeddsp.vc6 new file mode 100644 index 0000000..5ff61ef --- /dev/null +++ b/thirdparty/jpeg-9e/makeddsp.vc6 @@ -0,0 +1,130 @@ +# Microsoft Developer Studio Project File - Name="djpeg" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=djpeg - Win32 +!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "djpeg.mak". +!MESSAGE +!MESSAGE Sie k÷nnen beim Ausfhren von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "djpeg.mak" CFG="djpeg - Win32" +!MESSAGE +!MESSAGE Fr die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "djpeg - Win32" (basierend auf "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir ".\djpeg\Release" +# PROP BASE Intermediate_Dir ".\djpeg\Release" +# PROP BASE Target_Dir ".\djpeg" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir ".\Release" +# PROP Intermediate_Dir ".\Release\djpeg" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir ".\djpeg" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# Begin Target + +# Name "djpeg - Win32" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90" +# Begin Source File + +SOURCE=.\cdjpeg.c +# End Source File +# Begin Source File + +SOURCE=.\djpeg.c +# End Source File +# Begin Source File + +SOURCE=.\rdcolmap.c +# End Source File +# Begin Source File + +SOURCE=.\wrbmp.c +# End Source File +# Begin Source File + +SOURCE=.\wrgif.c +# End Source File +# Begin Source File + +SOURCE=.\wrppm.c +# End Source File +# Begin Source File + +SOURCE=.\wrrle.c +# End Source File +# Begin Source File + +SOURCE=.\wrtarga.c +# End Source File +# End Group +# Begin Group "Header-Dateien" + +# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" +# Begin Source File + +SOURCE=.\cderror.h +# End Source File +# Begin Source File + +SOURCE=.\cdjpeg.h +# End Source File +# Begin Source File + +SOURCE=.\jconfig.h +# End Source File +# Begin Source File + +SOURCE=.\jerror.h +# End Source File +# Begin Source File + +SOURCE=.\jinclude.h +# End Source File +# Begin Source File + +SOURCE=.\jmorecfg.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib.h +# End Source File +# Begin Source File + +SOURCE=.\jversion.h +# End Source File +# End Group +# Begin Group "Ressourcendateien" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/thirdparty/jpeg-9e/makedfil.v16 b/thirdparty/jpeg-9e/makedfil.v16 new file mode 100644 index 0000000..d190e15 --- /dev/null +++ b/thirdparty/jpeg-9e/makedfil.v16 @@ -0,0 +1,69 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makedmak.vc6 b/thirdparty/jpeg-9e/makedmak.vc6 new file mode 100644 index 0000000..e16487f --- /dev/null +++ b/thirdparty/jpeg-9e/makedmak.vc6 @@ -0,0 +1,159 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on djpeg.dsp +!IF "$(CFG)" == "" +CFG=djpeg - Win32 +!MESSAGE Keine Konfiguration angegeben. djpeg - Win32 wird als Standard verwendet. +!ENDIF + +!IF "$(CFG)" != "djpeg - Win32" +!MESSAGE Ungültige Konfiguration "$(CFG)" angegeben. +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "djpeg.mak" CFG="djpeg - Win32" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "djpeg - Win32" (basierend auf "Win32 (x86) Console Application") +!MESSAGE +!ERROR Eine ungültige Konfiguration wurde angegeben. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +CPP=cl.exe +RSC=rc.exe +OUTDIR=.\djpeg\Release +INTDIR=.\djpeg\Release +# Begin Custom Macros +OutDir=.\djpeg\Release +# End Custom Macros + +ALL : "$(OUTDIR)\djpeg.exe" + + +CLEAN : + -@erase "$(INTDIR)\cdjpeg.obj" + -@erase "$(INTDIR)\djpeg.obj" + -@erase "$(INTDIR)\rdcolmap.obj" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(INTDIR)\wrbmp.obj" + -@erase "$(INTDIR)\wrgif.obj" + -@erase "$(INTDIR)\wrppm.obj" + -@erase "$(INTDIR)\wrrle.obj" + -@erase "$(INTDIR)\wrtarga.obj" + -@erase "$(OUTDIR)\djpeg.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\djpeg.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\djpeg.pdb" /machine:I386 /out:"$(OUTDIR)\djpeg.exe" +LINK32_OBJS= \ + "$(INTDIR)\cdjpeg.obj" \ + "$(INTDIR)\djpeg.obj" \ + "$(INTDIR)\rdcolmap.obj" \ + "$(INTDIR)\wrbmp.obj" \ + "$(INTDIR)\wrgif.obj" \ + "$(INTDIR)\wrppm.obj" \ + "$(INTDIR)\wrrle.obj" \ + "$(INTDIR)\wrtarga.obj" + +"$(OUTDIR)\djpeg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +CPP_PROJ=/nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /Fp"$(INTDIR)\djpeg.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("djpeg.dep") +!INCLUDE "djpeg.dep" +!ELSE +!MESSAGE Warning: cannot find "djpeg.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "djpeg - Win32" +SOURCE=.\cdjpeg.c + +"$(INTDIR)\cdjpeg.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\djpeg.c + +"$(INTDIR)\djpeg.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\rdcolmap.c + +"$(INTDIR)\rdcolmap.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\wrbmp.c + +"$(INTDIR)\wrbmp.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\wrgif.c + +"$(INTDIR)\wrgif.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\wrppm.c + +"$(INTDIR)\wrppm.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\wrrle.c + +"$(INTDIR)\wrrle.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\wrtarga.c + +"$(INTDIR)\wrtarga.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + diff --git a/thirdparty/jpeg-9e/makedvcx.v16 b/thirdparty/jpeg-9e/makedvcx.v16 new file mode 100644 index 0000000..199bbf3 --- /dev/null +++ b/thirdparty/jpeg-9e/makedvcx.v16 @@ -0,0 +1,195 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {11043137-B453-4DFA-9010-4D2B9DC1545C} + Win32Proj + djpeg + 10.0 + + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + + + + + + + + + + + + + + + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makedvcx.v17 b/thirdparty/jpeg-9e/makedvcx.v17 new file mode 100644 index 0000000..3745536 --- /dev/null +++ b/thirdparty/jpeg-9e/makedvcx.v17 @@ -0,0 +1,195 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {11043137-B453-4DFA-9010-4D2B9DC1545C} + Win32Proj + djpeg + 10.0 + + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + + + + + + + + + + + + + + + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makefile.ansi b/thirdparty/jpeg-9e/makefile.ansi new file mode 100644 index 0000000..703882c --- /dev/null +++ b/thirdparty/jpeg-9e/makefile.ansi @@ -0,0 +1,226 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is suitable for Unix-like systems with ANSI-capable compilers. +# If you have a non-ANSI compiler, makefile.unix is a better starting point. + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= cc + +# You may need to adjust these cc options: +CFLAGS= -O +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +LDFLAGS= + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= + +# Put here the object file name for the correct system-dependent memory +# manager file. For Unix this is usually jmemnobs.o, but you may want +# to use jmemansi.o or jmemname.o if you have limited swap space. +SYSDEPMEM= jmemnobs.o + +# miscellaneous OS-dependent stuff +# linker +LN= $(CC) +# file deletion command +RM= rm -f +# library (.a) file creation command +AR= ar rc +# second step in .a creation (use "touch" if not needed) +AR2= ranlib + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h \ + jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.txt usage.txt cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.txt example.c libjpeg.txt structure.txt \ + coderules.txt filelist.txt cdaltui.txt change.log +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jaricom.o jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jcarith.o jctrans.o jcparam.o \ + jdatadst.o jcinit.o jcmaster.o jcmarker.o jcmainct.o jcprepct.o \ + jccoefct.o jccolor.o jcsample.o jchuff.o jcdctmgr.o jfdctfst.o \ + jfdctflt.o jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdarith.o jdtrans.o jdatasrc.o \ + jdmaster.o jdinput.o jdmarker.o jdhuff.o jdmainct.o \ + jdcoefct.o jdpostct.o jddctmgr.o jidctfst.o jidctflt.o \ + jidctint.o jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.a +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o + + +all: libjpeg.a cjpeg djpeg jpegtran rdjpgcom wrjpgcom + +libjpeg.a: $(LIBOBJECTS) + $(RM) libjpeg.a + $(AR) libjpeg.a $(LIBOBJECTS) + $(AR2) libjpeg.a + +cjpeg: $(COBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.a $(LDLIBS) + +djpeg: $(DOBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.a $(LDLIBS) + +jpegtran: $(TROBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.a $(LDLIBS) + +rdjpgcom: rdjpgcom.o + $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) + +wrjpgcom: wrjpgcom.o + $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) + +jconfig.h: jconfig.txt + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.txt. + exit 1 + +clean: + $(RM) *.o cjpeg djpeg jpegtran libjpeg.a rdjpgcom wrjpgcom + $(RM) core testout* + +test: cjpeg djpeg jpegtran + $(RM) testout* + ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + ./djpeg -dct int -gif -outfile testout.gif testorig.jpg + ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + ./cjpeg -dct int -outfile testout.jpg testimg.ppm + ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + ./jpegtran -outfile testoutt.jpg testprog.jpg + cmp testimg.ppm testout.ppm + cmp testimg.gif testout.gif + cmp testimg.bmp testout.bmp + cmp testimg.jpg testout.jpg + cmp testimg.ppm testoutp.ppm + cmp testimgp.jpg testoutp.jpg + cmp testorig.jpg testoutt.jpg + + +jaricom.o: jaricom.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcarith.o: jcarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdarith.o: jdarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/thirdparty/jpeg-9e/makefile.b32 b/thirdparty/jpeg-9e/makefile.b32 new file mode 100644 index 0000000..9812aee --- /dev/null +++ b/thirdparty/jpeg-9e/makefile.b32 @@ -0,0 +1,248 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is suitable for Borland C on MS-DOS. +# It works with Borland C++ 32-bit for DOS, revision 5.0 or later. +# Thanks to Tom Wright and Ge' Weijers (original DOS) and +# Joe Slater for adding 32-bit additions (needed for Borland +# revision 5.5). + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= bcc32 + +# You may need to adjust these cc options: +CFLAGS= -O2 -w-par -w-stu -w-ccc -w-rch -w-aus +# -w-par suppresses warnings about unused function parameters +# -w-stu suppresses warnings about incomplete structures +# -w-ccc suppresses warnings about compile-time-constant conditions +# -w-rch suppresses warnings about unreachable code +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +LDFLAGS= +# -lc case-significant link + +# Put here the object file name for the correct system-dependent memory +# manager file. +# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. +SYSDEPMEM= jmemnobs.obj +SYSDEPMEMLIB= +jmemnobs.obj + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h \ + jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.txt usage.txt cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.txt example.c libjpeg.txt structure.txt \ + coderules.txt filelist.txt cdaltui.txt change.log +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jaricom.obj jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jcarith.obj jctrans.obj jcparam.obj \ + jdatadst.obj jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj \ + jcprepct.obj jccoefct.obj jccolor.obj jcsample.obj jchuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdarith.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdmainct.obj \ + jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj jidctflt.obj \ + jidctint.obj jdsample.obj jdcolor.obj jquant1.obj jquant2.obj \ + jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) + - del libjpeg.lib + tlib libjpeg.lib /E /C @&&| ++jcapimin.obj +jcapistd.obj +jcarith.obj +jctrans.obj +jcparam.obj & ++jdatadst.obj +jcinit.obj +jcmaster.obj +jcmarker.obj +jcmainct.obj & ++jcprepct.obj +jccoefct.obj +jccolor.obj +jcsample.obj +jchuff.obj & ++jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj +jfdctint.obj +jdapimin.obj & ++jdapistd.obj +jdarith.obj +jdtrans.obj +jdatasrc.obj +jdmaster.obj & ++jdinput.obj +jdmarker.obj +jdhuff.obj +jdmainct.obj +jdcoefct.obj & ++jdpostct.obj +jddctmgr.obj +jidctfst.obj +jidctflt.obj +jidctint.obj & ++jdsample.obj +jdcolor.obj +jquant1.obj +jquant2.obj +jdmerge.obj & ++jaricom.obj +jcomapi.obj +jutils.obj +jerror.obj +jmemmgr.obj & +$(SYSDEPMEMLIB) +| + +cjpeg.exe: $(COBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -ecjpeg.exe $(COBJECTS) libjpeg.lib + +djpeg.exe: $(DOBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -edjpeg.exe $(DOBJECTS) libjpeg.lib + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -ejpegtran.exe $(TROBJECTS) libjpeg.lib + +rdjpgcom.exe: rdjpgcom.c + $(CC) $(CFLAGS) rdjpgcom.c + +wrjpgcom.exe: wrjpgcom.c + $(CC) $(CFLAGS) wrjpgcom.c + +# This "{}" syntax allows Borland Make to "batch" source files. +# In this way, each run of the compiler can build many modules. +.c.obj: + $(CC) $(CFLAGS) -c{ $<} + +jconfig.h: jconfig.txt + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.txt. + exit 1 + +clean: + - del *.obj + - del libjpeg.lib + - del cjpeg.exe + - del djpeg.exe + - del jpegtran.exe + - del rdjpgcom.exe + - del wrjpgcom.exe + - del testout*.* + +test: cjpeg.exe djpeg.exe jpegtran.exe + - del testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -gif -outfile testout.gif testorig.jpg + djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg + echo n > n.tmp + comp testimg.ppm testout.ppm < n.tmp + comp testimg.gif testout.gif < n.tmp + comp testimg.bmp testout.bmp < n.tmp + comp testimg.jpg testout.jpg < n.tmp + comp testimg.ppm testoutp.ppm < n.tmp + comp testimgp.jpg testoutp.jpg < n.tmp + comp testorig.jpg testoutt.jpg < n.tmp + del n.tmp + + +jaricom.obj: jaricom.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcarith.obj: jcarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdarith.obj: jdarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +jmemdosa.obj: jmemdosa.asm + tasm /mx jmemdosa.asm diff --git a/thirdparty/jpeg-9e/makefile.bcc b/thirdparty/jpeg-9e/makefile.bcc new file mode 100644 index 0000000..237a3e6 --- /dev/null +++ b/thirdparty/jpeg-9e/makefile.bcc @@ -0,0 +1,298 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is suitable for Borland C on MS-DOS or OS/2. +# It works with Borland C++ for DOS, revision 3.0 or later, +# and has been tested with Borland C++ for OS/2. +# Watch out for optimization bugs in the OS/2 compilers --- see notes below! +# Thanks to Tom Wright and Ge' Weijers (original DOS) and +# Ken Porter (OS/2) for this file. + +# Read installation instructions before saying "make" !! + +# Are we under DOS or OS/2? +!if !$d(DOS) && !$d(OS2) +!if $d(__OS2__) +OS2=1 +!else +DOS=1 +!endif +!endif + +# The name of your C compiler: +CC= bcc + +# You may need to adjust these cc options: +!if $d(DOS) +CFLAGS= -O2 -mm -w-par -w-stu -w-ccc -w-rch +!else +CFLAGS= -O1 -w-par -w-stu -w-ccc -w-rch +!endif +# -O2 enables full code optimization (for pre-3.0 Borland C++, use -O -G -Z). +# -O2 is buggy in Borland OS/2 C++ revision 2.0, so use -O1 there for now. +# If you have Borland OS/2 C++ revision 1.0, use -O or no optimization at all. +# -mm selects medium memory model (near data, far code pointers; DOS only!) +# -w-par suppresses warnings about unused function parameters +# -w-stu suppresses warnings about incomplete structures +# -w-ccc suppresses warnings about compile-time-constant conditions +# -w-rch suppresses warnings about unreachable code +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +!if $d(DOS) +LDFLAGS= -mm +# memory model option here must match CFLAGS! +!else +LDFLAGS= +# -lai full-screen app +# -lc case-significant link +!endif + +# Put here the object file name for the correct system-dependent memory +# manager file. +# For DOS, we recommend jmemdos.c and jmemdosa.asm. +# For OS/2, we recommend jmemnobs.c (flat memory!) +# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. +!if $d(DOS) +SYSDEPMEM= jmemdos.obj jmemdosa.obj +SYSDEPMEMLIB= +jmemdos.obj +jmemdosa.obj +!else +SYSDEPMEM= jmemnobs.obj +SYSDEPMEMLIB= +jmemnobs.obj +!endif + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h \ + jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.txt usage.txt cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.txt example.c libjpeg.txt structure.txt \ + coderules.txt filelist.txt cdaltui.txt change.log +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jaricom.obj jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jcarith.obj jctrans.obj jcparam.obj \ + jdatadst.obj jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj \ + jcprepct.obj jccoefct.obj jccolor.obj jcsample.obj jchuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdarith.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdmainct.obj \ + jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj jidctflt.obj \ + jidctint.obj jdsample.obj jdcolor.obj jquant1.obj jquant2.obj \ + jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) + - del libjpeg.lib + tlib libjpeg.lib /E /C @&&| ++jcapimin.obj +jcapistd.obj +jcarith.obj +jctrans.obj +jcparam.obj & ++jdatadst.obj +jcinit.obj +jcmaster.obj +jcmarker.obj +jcmainct.obj & ++jcprepct.obj +jccoefct.obj +jccolor.obj +jcsample.obj +jchuff.obj & ++jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj +jfdctint.obj +jdapimin.obj & ++jdapistd.obj +jdarith.obj +jdtrans.obj +jdatasrc.obj +jdmaster.obj & ++jdinput.obj +jdmarker.obj +jdhuff.obj +jdmainct.obj +jdcoefct.obj & ++jdpostct.obj +jddctmgr.obj +jidctfst.obj +jidctflt.obj +jidctint.obj & ++jdsample.obj +jdcolor.obj +jquant1.obj +jquant2.obj +jdmerge.obj & ++jaricom.obj +jcomapi.obj +jutils.obj +jerror.obj +jmemmgr.obj & +$(SYSDEPMEMLIB) +| + +cjpeg.exe: $(COBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -ecjpeg.exe $(COBJECTS) libjpeg.lib + +djpeg.exe: $(DOBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -edjpeg.exe $(DOBJECTS) libjpeg.lib + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -ejpegtran.exe $(TROBJECTS) libjpeg.lib + +rdjpgcom.exe: rdjpgcom.c +!if $d(DOS) + $(CC) -ms -O rdjpgcom.c +!else + $(CC) $(CFLAGS) rdjpgcom.c +!endif + +# On DOS, wrjpgcom needs large model so it can malloc a 64K chunk +wrjpgcom.exe: wrjpgcom.c +!if $d(DOS) + $(CC) -ml -O wrjpgcom.c +!else + $(CC) $(CFLAGS) wrjpgcom.c +!endif + +# This "{}" syntax allows Borland Make to "batch" source files. +# In this way, each run of the compiler can build many modules. +.c.obj: + $(CC) $(CFLAGS) -c{ $<} + +jconfig.h: jconfig.txt + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.txt. + exit 1 + +clean: + - del *.obj + - del libjpeg.lib + - del cjpeg.exe + - del djpeg.exe + - del jpegtran.exe + - del rdjpgcom.exe + - del wrjpgcom.exe + - del testout*.* + +test: cjpeg.exe djpeg.exe jpegtran.exe + - del testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -gif -outfile testout.gif testorig.jpg + djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg +!if $d(DOS) + fc /b testimg.ppm testout.ppm + fc /b testimg.gif testout.gif + fc /b testimg.bmp testout.bmp + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg +!else + echo n > n.tmp + comp testimg.ppm testout.ppm < n.tmp + comp testimg.gif testout.gif < n.tmp + comp testimg.bmp testout.bmp < n.tmp + comp testimg.jpg testout.jpg < n.tmp + comp testimg.ppm testoutp.ppm < n.tmp + comp testimgp.jpg testoutp.jpg < n.tmp + comp testorig.jpg testoutt.jpg < n.tmp + del n.tmp +!endif + + +jaricom.obj: jaricom.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcarith.obj: jcarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdarith.obj: jdarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +jmemdosa.obj: jmemdosa.asm + tasm /mx jmemdosa.asm diff --git a/thirdparty/jpeg-9e/makefile.dj b/thirdparty/jpeg-9e/makefile.dj new file mode 100644 index 0000000..9d205f0 --- /dev/null +++ b/thirdparty/jpeg-9e/makefile.dj @@ -0,0 +1,232 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is for DJGPP (Delorie's GNU C port on MS-DOS), v2.0 or later. +# Thanks to Frank J. Donahoe for this version. + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= gcc + +# You may need to adjust these cc options: +CFLAGS= -O2 -Wall -I. +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +LDFLAGS= -s + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= + +# Put here the object file name for the correct system-dependent memory +# manager file. For DJGPP this is usually jmemnobs.o, but you could +# use jmemname.o if you want to use named temp files instead of swap space. +SYSDEPMEM= jmemnobs.o + +# miscellaneous OS-dependent stuff +# linker +LN= $(CC) +# file deletion command +RM= rm +# library (.a) file creation command +AR= ar rc +# second step in .a creation (use "touch" if not needed) +AR2= ranlib + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h \ + jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.txt usage.txt cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.txt example.c libjpeg.txt structure.txt \ + coderules.txt filelist.txt cdaltui.txt change.log +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jaricom.o jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jcarith.o jctrans.o jcparam.o \ + jdatadst.o jcinit.o jcmaster.o jcmarker.o jcmainct.o jcprepct.o \ + jccoefct.o jccolor.o jcsample.o jchuff.o jcdctmgr.o jfdctfst.o \ + jfdctflt.o jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdarith.o jdtrans.o jdatasrc.o \ + jdmaster.o jdinput.o jdmarker.o jdhuff.o jdmainct.o \ + jdcoefct.o jdpostct.o jddctmgr.o jidctfst.o jidctflt.o \ + jidctint.o jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.a +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o + + +all: libjpeg.a cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.a: $(LIBOBJECTS) + $(RM) libjpeg.a + $(AR) libjpeg.a $(LIBOBJECTS) + $(AR2) libjpeg.a + +cjpeg.exe: $(COBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o cjpeg.exe $(COBJECTS) libjpeg.a $(LDLIBS) + +djpeg.exe: $(DOBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o djpeg.exe $(DOBJECTS) libjpeg.a $(LDLIBS) + +jpegtran.exe: $(TROBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o jpegtran.exe $(TROBJECTS) libjpeg.a $(LDLIBS) + +rdjpgcom.exe: rdjpgcom.o + $(LN) $(LDFLAGS) -o rdjpgcom.exe rdjpgcom.o $(LDLIBS) + +wrjpgcom.exe: wrjpgcom.o + $(LN) $(LDFLAGS) -o wrjpgcom.exe wrjpgcom.o $(LDLIBS) + +jconfig.h: jconfig.txt + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.txt. + exit 1 + +clean: + $(RM) *.o + $(RM) cjpeg.exe + $(RM) djpeg.exe + $(RM) jpegtran.exe + $(RM) rdjpgcom.exe + $(RM) wrjpgcom.exe + $(RM) libjpeg.a + $(RM) testout*.* + +test: cjpeg.exe djpeg.exe jpegtran.exe + $(RM) testout*.* + ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + ./djpeg -dct int -gif -outfile testout.gif testorig.jpg + ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + ./cjpeg -dct int -outfile testout.jpg testimg.ppm + ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + ./jpegtran -outfile testoutt.jpg testprog.jpg + fc /b testimg.ppm testout.ppm + fc /b testimg.gif testout.gif + fc /b testimg.bmp testout.bmp + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg + + +jaricom.o: jaricom.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcarith.o: jcarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdarith.o: jdarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/thirdparty/jpeg-9e/makefile.manx b/thirdparty/jpeg-9e/makefile.manx new file mode 100644 index 0000000..87e92b1 --- /dev/null +++ b/thirdparty/jpeg-9e/makefile.manx @@ -0,0 +1,226 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is for Amiga systems using Manx Aztec C ver 5.x. +# Thanks to D.J. James (djjames@cup.portal.com) for this version. + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= cc + +# You may need to adjust these cc options: +# Uncomment for generic 68000 code (will work on any Amiga) +ARCHFLAGS= -sn + +# Uncomment for 68020/68030 code (faster, but won't run on 68000 CPU) +#ARCHFLAGS= -c2 + +CFLAGS= -MC -MD $(ARCHFLAGS) -spfam -r4 + +# Link-time cc options: +LDFLAGS= -g + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= -lml -lcl + +# Put here the object file name for the correct system-dependent memory +# manager file. For Amiga we recommend jmemname.o. +SYSDEPMEM= jmemname.o + +# miscellaneous OS-dependent stuff +# linker +LN= ln +# file deletion command +RM= delete quiet +# library (.lib) file creation command +AR= lb + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h \ + jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.txt usage.txt cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.txt example.c libjpeg.txt structure.txt \ + coderules.txt filelist.txt cdaltui.txt change.log +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jaricom.o jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jcarith.o jctrans.o jcparam.o \ + jdatadst.o jcinit.o jcmaster.o jcmarker.o jcmainct.o jcprepct.o \ + jccoefct.o jccolor.o jcsample.o jchuff.o jcdctmgr.o jfdctfst.o \ + jfdctflt.o jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdarith.o jdtrans.o jdatasrc.o \ + jdmaster.o jdinput.o jdmarker.o jdhuff.o jdmainct.o \ + jdcoefct.o jdpostct.o jddctmgr.o jidctfst.o jidctflt.o \ + jidctint.o jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o + + +all: libjpeg.lib cjpeg djpeg jpegtran rdjpgcom wrjpgcom + +libjpeg.lib: $(LIBOBJECTS) + -$(RM) libjpeg.lib + $(AR) libjpeg.lib $(LIBOBJECTS) + +cjpeg: $(COBJECTS) libjpeg.lib + $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.lib $(LDLIBS) + +djpeg: $(DOBJECTS) libjpeg.lib + $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.lib $(LDLIBS) + +jpegtran: $(TROBJECTS) libjpeg.lib + $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.lib $(LDLIBS) + +rdjpgcom: rdjpgcom.o + $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) + +wrjpgcom: wrjpgcom.o + $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) + +jconfig.h: jconfig.txt + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.txt. + exit 1 + +clean: + -$(RM) *.o cjpeg djpeg jpegtran libjpeg.lib rdjpgcom wrjpgcom + -$(RM) core testout*.* + +test: cjpeg djpeg jpegtran + -$(RM) testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -gif -outfile testout.gif testorig.jpg + djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg + cmp testimg.ppm testout.ppm + cmp testimg.gif testout.gif + cmp testimg.bmp testout.bmp + cmp testimg.jpg testout.jpg + cmp testimg.ppm testoutp.ppm + cmp testimgp.jpg testoutp.jpg + cmp testorig.jpg testoutt.jpg + + +jaricom.o: jaricom.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcarith.o: jcarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdarith.o: jdarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/thirdparty/jpeg-9e/makefile.mc6 b/thirdparty/jpeg-9e/makefile.mc6 new file mode 100644 index 0000000..0419134 --- /dev/null +++ b/thirdparty/jpeg-9e/makefile.mc6 @@ -0,0 +1,261 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is for Microsoft C for MS-DOS, version 6.00A and up. +# Use NMAKE, not Microsoft's brain-damaged MAKE. +# Thanks to Alan Wright and Chris Turner of Olivetti Research Ltd. + +# Read installation instructions before saying "nmake" !! + +# You may need to adjust these compiler options: +CFLAGS = -AM -Oecigt -Gs -W3 +# -AM medium memory model (or use -AS for small model, if you remove features) +# -Oecigt -Gs maximum safe optimisation (-Ol has bugs in MSC 6.00A) +# -W3 warning level 3 +# You might also want to add -G2 if you have an 80286, etc. +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Jan-Herman Buining suggests the following switches for MS C 8.0 and a 486: +# CFLAGS = /AM /f- /FPi87 /G3 /Gs /Gy /Ob1 /Oc /Oe /Og /Oi /Ol /On /Oo /Ot \ +# /OV4 /W3 +# except for jquant1.c, which must be compiled with /Oo- to avoid a compiler +# crash. + +# Ingar Steinsland suggests the following switches when building +# a 16-bit Windows DLL: +# CFLAGS = -ALw -Gsw -Zpe -W3 -O2 -Zi -Zd + +# Put here the object file name for the correct system-dependent memory +# manager file. For DOS, we recommend jmemdos.c and jmemdosa.asm. +# (But not for Windows; see install.txt if you use this makefile for Windows.) +SYSDEPMEM= jmemdos.obj jmemdosa.obj +# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. +SYSDEPMEMLIB= +jmemdos.obj +jmemdosa.obj + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h \ + jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.txt usage.txt cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.txt example.c libjpeg.txt structure.txt \ + coderules.txt filelist.txt cdaltui.txt change.log +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jaricom.obj jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jcarith.obj jctrans.obj jcparam.obj \ + jdatadst.obj jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj \ + jcprepct.obj jccoefct.obj jccolor.obj jcsample.obj jchuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdarith.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdmainct.obj \ + jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj jidctflt.obj \ + jidctint.obj jdsample.obj jdcolor.obj jquant1.obj jquant2.obj \ + jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj + +# need linker response file because file list > 128 chars +RFILE = libjpeg.ans + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) $(RFILE) + del libjpeg.lib + lib @$(RFILE) + +# linker response file for building libjpeg.lib +$(RFILE) : makefile + del $(RFILE) + echo libjpeg.lib >$(RFILE) +# silly want-to-create-it prompt: + echo y >>$(RFILE) + echo +jcapimin.obj +jcapistd.obj +jcarith.obj +jctrans.obj & >>$(RFILE) + echo +jcparam.obj +jdatadst.obj +jcinit.obj +jcmaster.obj & >>$(RFILE) + echo +jcmarker.obj +jcmainct.obj +jcprepct.obj & >>$(RFILE) + echo +jccoefct.obj +jccolor.obj +jcsample.obj +jchuff.obj & >>$(RFILE) + echo +jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj & >>$(RFILE) + echo +jfdctint.obj +jdapimin.obj +jdapistd.obj & >>$(RFILE) + echo +jdarith.obj +jdtrans.obj +jdatasrc.obj +jdmaster.obj & >>$(RFILE) + echo +jdinput.obj +jdmarker.obj +jdhuff.obj +jdmainct.obj & >>$(RFILE) + echo +jdcoefct.obj +jdpostct.obj +jddctmgr.obj & >>$(RFILE) + echo +jidctfst.obj +jidctflt.obj +jidctint.obj & >>$(RFILE) + echo +jdsample.obj +jdcolor.obj +jquant1.obj & >>$(RFILE) + echo +jquant2.obj +jdmerge.obj +jaricom.obj +jcomapi.obj & >>$(RFILE) + echo +jutils.obj +jerror.obj +jmemmgr.obj & >>$(RFILE) + echo $(SYSDEPMEMLIB) ; >>$(RFILE) + +cjpeg.exe: $(COBJECTS) libjpeg.lib + echo $(COBJECTS) >cjpeg.lst + link /STACK:4096 /EXEPACK @cjpeg.lst, cjpeg.exe, , libjpeg.lib, ; + del cjpeg.lst + +djpeg.exe: $(DOBJECTS) libjpeg.lib + echo $(DOBJECTS) >djpeg.lst + link /STACK:4096 /EXEPACK @djpeg.lst, djpeg.exe, , libjpeg.lib, ; + del djpeg.lst + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + link /STACK:4096 /EXEPACK $(TROBJECTS), jpegtran.exe, , libjpeg.lib, ; + +rdjpgcom.exe: rdjpgcom.c + $(CC) -AS -O -W3 rdjpgcom.c + +# wrjpgcom needs large model so it can malloc a 64K chunk +wrjpgcom.exe: wrjpgcom.c + $(CC) -AL -O -W3 wrjpgcom.c + +jconfig.h: jconfig.txt + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.txt. + exit 1 + +clean: + del *.obj + del libjpeg.lib + del cjpeg.exe + del djpeg.exe + del jpegtran.exe + del rdjpgcom.exe + del wrjpgcom.exe + del testout*.* + +test: cjpeg.exe djpeg.exe jpegtran.exe + del testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -gif -outfile testout.gif testorig.jpg + djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg + fc /b testimg.ppm testout.ppm + fc /b testimg.gif testout.gif + fc /b testimg.bmp testout.bmp + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg + + +jaricom.obj: jaricom.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcarith.obj: jcarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdarith.obj: jdarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +jmemdosa.obj : jmemdosa.asm + masm /mx $*; diff --git a/thirdparty/jpeg-9e/makefile.mms b/thirdparty/jpeg-9e/makefile.mms new file mode 100644 index 0000000..1a64028 --- /dev/null +++ b/thirdparty/jpeg-9e/makefile.mms @@ -0,0 +1,230 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is for use with MMS on Digital VMS systems. +# Thanks to Rick Dyson (dyson@iowasp.physics.uiowa.edu) +# and Tim Bell (tbell@netcom.com) for their help. + +# Read installation instructions before saying "MMS" !! + +# You may need to adjust these cc options: +CFLAGS= $(CFLAGS) /NoDebug /Optimize +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via /Define switches here. +.ifdef ALPHA +OPT= +.else +OPT= ,Sys$Disk:[]MAKVMS.OPT/Option +.endif + +# Put here the object file name for the correct system-dependent memory +# manager file. For Unix this is usually jmemnobs.o, but you may want +# to use jmemansi.o or jmemname.o if you have limited swap space. +SYSDEPMEM= jmemnobs.obj + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h \ + jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.txt usage.txt cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.txt example.c libjpeg.txt structure.txt \ + coderules.txt filelist.txt cdaltui.txt change.log +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jaricom.obj jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jcarith.obj jctrans.obj jcparam.obj \ + jdatadst.obj jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj \ + jcprepct.obj jccoefct.obj jccolor.obj jcsample.obj jchuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdarith.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdmainct.obj \ + jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj jidctflt.obj \ + jidctint.obj jdsample.obj jdcolor.obj jquant1.obj jquant2.obj \ + jdmerge.obj +# These objectfiles are included in libjpeg.olb +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj +# objectfile lists with commas --- what a crock +COBJLIST= cjpeg.obj,rdppm.obj,rdgif.obj,rdtarga.obj,rdrle.obj,rdbmp.obj,\ + rdswitch.obj,cdjpeg.obj +DOBJLIST= djpeg.obj,wrppm.obj,wrgif.obj,wrtarga.obj,wrrle.obj,wrbmp.obj,\ + rdcolmap.obj,cdjpeg.obj +TROBJLIST= jpegtran.obj,rdswitch.obj,cdjpeg.obj,transupp.obj +LIBOBJLIST= jaricom.obj,jcapimin.obj,jcapistd.obj,jcarith.obj,jctrans.obj,\ + jcparam.obj,jdatadst.obj,jcinit.obj,jcmaster.obj,jcmarker.obj,\ + jcmainct.obj,jcprepct.obj,jccoefct.obj,jccolor.obj,jcsample.obj,\ + jchuff.obj,jcdctmgr.obj,jfdctfst.obj,jfdctflt.obj,jfdctint.obj,\ + jdapimin.obj,jdapistd.obj,jdarith.obj,jdtrans.obj,jdatasrc.obj,\ + jdmaster.obj,jdinput.obj,jdmarker.obj,jdhuff.obj,jdmainct.obj,\ + jdcoefct.obj,jdpostct.obj,jddctmgr.obj,jidctfst.obj,jidctflt.obj,\ + jidctint.obj,jdsample.obj,jdcolor.obj,jquant1.obj,jquant2.obj,\ + jdmerge.obj,jcomapi.obj,jutils.obj,jerror.obj,jmemmgr.obj,$(SYSDEPMEM) + + +.first + @- Define /NoLog Sys Sys$Library + +ALL : libjpeg.olb cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + @ Continue + +libjpeg.olb : $(LIBOBJECTS) + Library /Create libjpeg.olb $(LIBOBJLIST) + +cjpeg.exe : $(COBJECTS) libjpeg.olb + $(LINK) $(LFLAGS) /Executable = cjpeg.exe $(COBJLIST),libjpeg.olb/Library$(OPT) + +djpeg.exe : $(DOBJECTS) libjpeg.olb + $(LINK) $(LFLAGS) /Executable = djpeg.exe $(DOBJLIST),libjpeg.olb/Library$(OPT) + +jpegtran.exe : $(TROBJECTS) libjpeg.olb + $(LINK) $(LFLAGS) /Executable = jpegtran.exe $(TROBJLIST),libjpeg.olb/Library$(OPT) + +rdjpgcom.exe : rdjpgcom.obj + $(LINK) $(LFLAGS) /Executable = rdjpgcom.exe rdjpgcom.obj$(OPT) + +wrjpgcom.exe : wrjpgcom.obj + $(LINK) $(LFLAGS) /Executable = wrjpgcom.exe wrjpgcom.obj$(OPT) + +jconfig.h : jconfig.vms + @- Copy jconfig.vms jconfig.h + +clean : + @- Set Protection = Owner:RWED *.*;-1 + @- Set Protection = Owner:RWED *.OBJ + - Purge /NoLog /NoConfirm *.* + - Delete /NoLog /NoConfirm *.OBJ; + +test : cjpeg.exe djpeg.exe jpegtran.exe + mcr sys$disk:[]djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + mcr sys$disk:[]djpeg -dct int -gif -outfile testout.gif testorig.jpg + mcr sys$disk:[]djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + mcr sys$disk:[]cjpeg -dct int -outfile testout.jpg testimg.ppm + mcr sys$disk:[]djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + mcr sys$disk:[]cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + mcr sys$disk:[]jpegtran -outfile testoutt.jpg testprog.jpg + - Backup /Compare/Log testimg.ppm testout.ppm + - Backup /Compare/Log testimg.gif testout.gif + - Backup /Compare/Log testimg.bmp testout.bmp + - Backup /Compare/Log testimg.jpg testout.jpg + - Backup /Compare/Log testimg.ppm testoutp.ppm + - Backup /Compare/Log testimgp.jpg testoutp.jpg + - Backup /Compare/Log testorig.jpg testoutt.jpg + + +jaricom.obj : jaricom.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapimin.obj : jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj : jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcarith.obj : jcarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj : jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj : jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj : jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj : jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcinit.obj : jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj : jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj : jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj : jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj : jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj : jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcprepct.obj : jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj : jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj : jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj : jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj : jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdarith.obj : jdarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj : jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj : jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj : jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj : jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj : jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj : jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdinput.obj : jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj : jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj : jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj : jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj : jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdpostct.obj : jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj : jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj : jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj : jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj : jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj : jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj : jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj : jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj : jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj : jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj : jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj : jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj : jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj : jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj : jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj : jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj : jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj : jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj : jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj : cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj : djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj : jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj : rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj : wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj : cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj : rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj : rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj : transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj : rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj : wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj : rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj : wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj : rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj : wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj : rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj : wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj : rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj : wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/thirdparty/jpeg-9e/makefile.sas b/thirdparty/jpeg-9e/makefile.sas new file mode 100644 index 0000000..f1a82cb --- /dev/null +++ b/thirdparty/jpeg-9e/makefile.sas @@ -0,0 +1,264 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is for Amiga systems using SAS C 6.0 and up. +# Thanks to Ed Hanway, Mark Rinfret, and Jim Zepeda. + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= sc + +# You may need to adjust these cc options: +# Uncomment the following lines for generic 680x0 version +ARCHFLAGS= cpu=any +SUFFIX= + +# Uncomment the following lines for 68030-only version +#ARCHFLAGS= cpu=68030 +#SUFFIX=.030 + +CFLAGS= nostackcheck data=near parms=register optimize $(ARCHFLAGS) \ + ignore=104 ignore=304 ignore=306 +# ignore=104 disables warnings for mismatched const qualifiers +# ignore=304 disables warnings for variables being optimized out +# ignore=306 disables warnings for the inlining of functions +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via define switches here. + +# Link-time cc options: +LDFLAGS= SC SD ND BATCH + +# To link any special libraries, add the necessary commands here. +LDLIBS= LIB:scm.lib LIB:sc.lib + +# Put here the object file name for the correct system-dependent memory +# manager file. For Amiga we recommend jmemname.o. +SYSDEPMEM= jmemname.o + +# miscellaneous OS-dependent stuff +# linker +LN= slink +# file deletion command +RM= delete quiet +# library (.lib) file creation command +AR= oml + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h \ + jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.txt usage.txt cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.txt example.c libjpeg.txt structure.txt \ + coderules.txt filelist.txt cdaltui.txt change.log +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jaricom.o jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jcarith.o jctrans.o jcparam.o \ + jdatadst.o jcinit.o jcmaster.o jcmarker.o jcmainct.o jcprepct.o \ + jccoefct.o jccolor.o jcsample.o jchuff.o jcdctmgr.o jfdctfst.o \ + jfdctflt.o jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdarith.o jdtrans.o jdatasrc.o \ + jdmaster.o jdinput.o jdmarker.o jdhuff.o jdmainct.o \ + jdcoefct.o jdpostct.o jddctmgr.o jidctfst.o jidctflt.o \ + jidctint.o jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o + + +all: libjpeg.lib cjpeg$(SUFFIX) djpeg$(SUFFIX) jpegtran$(SUFFIX) rdjpgcom$(SUFFIX) wrjpgcom$(SUFFIX) + +# note: do several AR steps to avoid command line length limitations + +libjpeg.lib: $(LIBOBJECTS) + -$(RM) libjpeg.lib + $(AR) libjpeg.lib r $(CLIBOBJECTS) + $(AR) libjpeg.lib r $(DLIBOBJECTS) + $(AR) libjpeg.lib r $(COMOBJECTS) + +cjpeg$(SUFFIX): $(COBJECTS) libjpeg.lib + $(LN) + +# You may want to adjust these compiler options: +CFLAGS= $(cflags) $(cdebug) $(cvars) -I. +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time options: +LDFLAGS= $(ldebug) $(conlflags) + +# To link any special libraries, add the necessary commands here. +LDLIBS= $(conlibs) + +# Put here the object file name for the correct system-dependent memory +# manager file. For NT we suggest jmemnobs.obj, which expects the OS to +# provide adequate virtual memory. +SYSDEPMEM= jmemnobs.obj + +# miscellaneous OS-dependent stuff +# file deletion command +RM= del + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h \ + jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.txt usage.txt cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.txt example.c libjpeg.txt structure.txt \ + coderules.txt filelist.txt cdaltui.txt change.log +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jaricom.obj jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jcarith.obj jctrans.obj jcparam.obj \ + jdatadst.obj jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj \ + jcprepct.obj jccoefct.obj jccolor.obj jcsample.obj jchuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdarith.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdmainct.obj \ + jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj jidctflt.obj \ + jidctint.obj jdsample.obj jdcolor.obj jquant1.obj jquant2.obj \ + jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj + +# Template command for compiling .c to .obj +.c.obj: + $(cc) $(CFLAGS) $*.c + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) + $(RM) libjpeg.lib + lib -out:libjpeg.lib $(LIBOBJECTS) + +cjpeg.exe: $(COBJECTS) libjpeg.lib + $(link) $(LDFLAGS) -out:cjpeg.exe $(COBJECTS) libjpeg.lib $(LDLIBS) + +djpeg.exe: $(DOBJECTS) libjpeg.lib + $(link) $(LDFLAGS) -out:djpeg.exe $(DOBJECTS) libjpeg.lib $(LDLIBS) + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + $(link) $(LDFLAGS) -out:jpegtran.exe $(TROBJECTS) libjpeg.lib $(LDLIBS) + +rdjpgcom.exe: rdjpgcom.obj + $(link) $(LDFLAGS) -out:rdjpgcom.exe rdjpgcom.obj $(LDLIBS) + +wrjpgcom.exe: wrjpgcom.obj + $(link) $(LDFLAGS) -out:wrjpgcom.exe wrjpgcom.obj $(LDLIBS) + + +clean: + $(RM) *.obj *.exe libjpeg.lib + $(RM) testout* + +setup-vc6: + ren jconfig.vc jconfig.h + ren makejdsw.vc6 jpeg.dsw + ren makeadsw.vc6 apps.dsw + ren makejmak.vc6 jpeg.mak + ren makejdep.vc6 jpeg.dep + ren makejdsp.vc6 jpeg.dsp + ren makecmak.vc6 cjpeg.mak + ren makecdep.vc6 cjpeg.dep + ren makecdsp.vc6 cjpeg.dsp + ren makedmak.vc6 djpeg.mak + ren makeddep.vc6 djpeg.dep + ren makeddsp.vc6 djpeg.dsp + ren maketmak.vc6 jpegtran.mak + ren maketdep.vc6 jpegtran.dep + ren maketdsp.vc6 jpegtran.dsp + ren makermak.vc6 rdjpgcom.mak + ren makerdep.vc6 rdjpgcom.dep + ren makerdsp.vc6 rdjpgcom.dsp + ren makewmak.vc6 wrjpgcom.mak + ren makewdep.vc6 wrjpgcom.dep + ren makewdsp.vc6 wrjpgcom.dsp + +setupcopy-vc6: + copy /y jconfig.vc jconfig.h + copy /y makejdsw.vc6 jpeg.dsw + copy /y makeadsw.vc6 apps.dsw + copy /y makejmak.vc6 jpeg.mak + copy /y makejdep.vc6 jpeg.dep + copy /y makejdsp.vc6 jpeg.dsp + copy /y makecmak.vc6 cjpeg.mak + copy /y makecdep.vc6 cjpeg.dep + copy /y makecdsp.vc6 cjpeg.dsp + copy /y makedmak.vc6 djpeg.mak + copy /y makeddep.vc6 djpeg.dep + copy /y makeddsp.vc6 djpeg.dsp + copy /y maketmak.vc6 jpegtran.mak + copy /y maketdep.vc6 jpegtran.dep + copy /y maketdsp.vc6 jpegtran.dsp + copy /y makermak.vc6 rdjpgcom.mak + copy /y makerdep.vc6 rdjpgcom.dep + copy /y makerdsp.vc6 rdjpgcom.dsp + copy /y makewmak.vc6 wrjpgcom.mak + copy /y makewdep.vc6 wrjpgcom.dep + copy /y makewdsp.vc6 wrjpgcom.dsp + +setup-v16: + ren jconfig.vc jconfig.h + ren makejsln.v16 jpeg.sln + ren makeasln.v16 apps.sln + ren makejvcx.v16 jpeg.vcxproj + ren makejfil.v16 jpeg.vcxproj.filters + ren makecvcx.v16 cjpeg.vcxproj + ren makecfil.v16 cjpeg.vcxproj.filters + ren makedvcx.v16 djpeg.vcxproj + ren makedfil.v16 djpeg.vcxproj.filters + ren maketvcx.v16 jpegtran.vcxproj + ren maketfil.v16 jpegtran.vcxproj.filters + ren makervcx.v16 rdjpgcom.vcxproj + ren makerfil.v16 rdjpgcom.vcxproj.filters + ren makewvcx.v16 wrjpgcom.vcxproj + ren makewfil.v16 wrjpgcom.vcxproj.filters + +setupcopy-v16: + copy /y jconfig.vc jconfig.h + copy /y makejsln.v16 jpeg.sln + copy /y makeasln.v16 apps.sln + copy /y makejvcx.v16 jpeg.vcxproj + copy /y makejfil.v16 jpeg.vcxproj.filters + copy /y makecvcx.v16 cjpeg.vcxproj + copy /y makecfil.v16 cjpeg.vcxproj.filters + copy /y makedvcx.v16 djpeg.vcxproj + copy /y makedfil.v16 djpeg.vcxproj.filters + copy /y maketvcx.v16 jpegtran.vcxproj + copy /y maketfil.v16 jpegtran.vcxproj.filters + copy /y makervcx.v16 rdjpgcom.vcxproj + copy /y makerfil.v16 rdjpgcom.vcxproj.filters + copy /y makewvcx.v16 wrjpgcom.vcxproj + copy /y makewfil.v16 wrjpgcom.vcxproj.filters + +setup-v17: + ren jconfig.vc jconfig.h + ren makejsln.v16 jpeg.sln + ren makeasln.v16 apps.sln + ren makejvcx.v17 jpeg.vcxproj + ren makejfil.v16 jpeg.vcxproj.filters + ren makecvcx.v17 cjpeg.vcxproj + ren makecfil.v16 cjpeg.vcxproj.filters + ren makedvcx.v17 djpeg.vcxproj + ren makedfil.v16 djpeg.vcxproj.filters + ren maketvcx.v17 jpegtran.vcxproj + ren maketfil.v16 jpegtran.vcxproj.filters + ren makervcx.v17 rdjpgcom.vcxproj + ren makerfil.v16 rdjpgcom.vcxproj.filters + ren makewvcx.v17 wrjpgcom.vcxproj + ren makewfil.v16 wrjpgcom.vcxproj.filters + +setupcopy-v17: + copy /y jconfig.vc jconfig.h + copy /y makejsln.v16 jpeg.sln + copy /y makeasln.v16 apps.sln + copy /y makejvcx.v17 jpeg.vcxproj + copy /y makejfil.v16 jpeg.vcxproj.filters + copy /y makecvcx.v17 cjpeg.vcxproj + copy /y makecfil.v16 cjpeg.vcxproj.filters + copy /y makedvcx.v17 djpeg.vcxproj + copy /y makedfil.v16 djpeg.vcxproj.filters + copy /y maketvcx.v17 jpegtran.vcxproj + copy /y maketfil.v16 jpegtran.vcxproj.filters + copy /y makervcx.v17 rdjpgcom.vcxproj + copy /y makerfil.v16 rdjpgcom.vcxproj.filters + copy /y makewvcx.v17 wrjpgcom.vcxproj + copy /y makewfil.v16 wrjpgcom.vcxproj.filters + +test: + IF EXIST testout* $(RM) testout* + .\djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + .\djpeg -dct int -gif -outfile testout.gif testorig.jpg + .\djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + .\cjpeg -dct int -outfile testout.jpg testimg.ppm + .\djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + .\cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + .\jpegtran -outfile testoutt.jpg testprog.jpg + fc /b testimg.ppm testout.ppm + fc /b testimg.gif testout.gif + fc /b testimg.bmp testout.bmp + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg + +test-build: + IF EXIST .\Release\testout* $(RM) .\Release\testout* + .\Release\djpeg -dct int -ppm -outfile .\Release\testout.ppm testorig.jpg + .\Release\djpeg -dct int -gif -outfile .\Release\testout.gif testorig.jpg + .\Release\djpeg -dct int -bmp -colors 256 -outfile .\Release\testout.bmp testorig.jpg + .\Release\cjpeg -dct int -outfile .\Release\testout.jpg testimg.ppm + .\Release\djpeg -dct int -ppm -outfile .\Release\testoutp.ppm testprog.jpg + .\Release\cjpeg -dct int -progressive -opt -outfile .\Release\testoutp.jpg testimg.ppm + .\Release\jpegtran -outfile .\Release\testoutt.jpg testprog.jpg + fc /b testimg.ppm .\Release\testout.ppm + fc /b testimg.gif .\Release\testout.gif + fc /b testimg.bmp .\Release\testout.bmp + fc /b testimg.jpg .\Release\testout.jpg + fc /b testimg.ppm .\Release\testoutp.ppm + fc /b testimgp.jpg .\Release\testoutp.jpg + fc /b testorig.jpg .\Release\testoutt.jpg + +test-32: + IF EXIST .\Release\testout* $(RM) .\Release\testout* + .\Release\Win32\djpeg -dct int -ppm -outfile .\Release\testout.ppm testorig.jpg + .\Release\Win32\djpeg -dct int -gif -outfile .\Release\testout.gif testorig.jpg + .\Release\Win32\djpeg -dct int -bmp -colors 256 -outfile .\Release\testout.bmp testorig.jpg + .\Release\Win32\cjpeg -dct int -outfile .\Release\testout.jpg testimg.ppm + .\Release\Win32\djpeg -dct int -ppm -outfile .\Release\testoutp.ppm testprog.jpg + .\Release\Win32\cjpeg -dct int -progressive -opt -outfile .\Release\testoutp.jpg testimg.ppm + .\Release\Win32\jpegtran -outfile .\Release\testoutt.jpg testprog.jpg + fc /b testimg.ppm .\Release\testout.ppm + fc /b testimg.gif .\Release\testout.gif + fc /b testimg.bmp .\Release\testout.bmp + fc /b testimg.jpg .\Release\testout.jpg + fc /b testimg.ppm .\Release\testoutp.ppm + fc /b testimgp.jpg .\Release\testoutp.jpg + fc /b testorig.jpg .\Release\testoutt.jpg + +test-64: + IF EXIST .\Release\testout* $(RM) .\Release\testout* + .\Release\x64\djpeg -dct int -ppm -outfile .\Release\testout.ppm testorig.jpg + .\Release\x64\djpeg -dct int -gif -outfile .\Release\testout.gif testorig.jpg + .\Release\x64\djpeg -dct int -bmp -colors 256 -outfile .\Release\testout.bmp testorig.jpg + .\Release\x64\cjpeg -dct int -outfile .\Release\testout.jpg testimg.ppm + .\Release\x64\djpeg -dct int -ppm -outfile .\Release\testoutp.ppm testprog.jpg + .\Release\x64\cjpeg -dct int -progressive -opt -outfile .\Release\testoutp.jpg testimg.ppm + .\Release\x64\jpegtran -outfile .\Release\testoutt.jpg testprog.jpg + fc /b testimg.ppm .\Release\testout.ppm + fc /b testimg.gif .\Release\testout.gif + fc /b testimg.bmp .\Release\testout.bmp + fc /b testimg.jpg .\Release\testout.jpg + fc /b testimg.ppm .\Release\testoutp.ppm + fc /b testimgp.jpg .\Release\testoutp.jpg + fc /b testorig.jpg .\Release\testoutt.jpg + + +jaricom.obj: jaricom.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcarith.obj: jcarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdarith.obj: jdarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/thirdparty/jpeg-9e/makefile.vms b/thirdparty/jpeg-9e/makefile.vms new file mode 100644 index 0000000..fe0fb0e --- /dev/null +++ b/thirdparty/jpeg-9e/makefile.vms @@ -0,0 +1,144 @@ +$! Makefile for Independent JPEG Group's software +$! +$! This is a command procedure for Digital VMS systems that do not have MMS. +$! It builds the JPEG software by brute force, recompiling everything whether +$! or not it is necessary. It then runs the basic self-test. +$! Thanks to Rick Dyson (dyson@iowasp.physics.uiowa.edu) +$! and Tim Bell (tbell@netcom.com) for their help. +$! +$! Read installation instructions before running this!! +$! +$ If F$Mode () .eqs. "INTERACTIVE" +$ Then +$ VERIFY = F$Verify (0) +$ Else +$ VERIFY = F$Verify (1) +$ EndIf +$ On Control_Y Then GoTo End +$ On Error Then GoTo End +$ +$ If F$GetSyi ("HW_MODEL") .gt. 1023 +$ Then +$ OPT = "" +$ Else +$ OPT = ",Sys$Disk:[]makvms.opt/Option" +$ EndIf +$ +$ DoCompile := CC /NoDebug /Optimize /NoList +$! +$ DoCompile jaricom.c +$ DoCompile jcapimin.c +$ DoCompile jcapistd.c +$ DoCompile jcarith.c +$ DoCompile jctrans.c +$ DoCompile jcparam.c +$ DoCompile jdatadst.c +$ DoCompile jcinit.c +$ DoCompile jcmaster.c +$ DoCompile jcmarker.c +$ DoCompile jcmainct.c +$ DoCompile jcprepct.c +$ DoCompile jccoefct.c +$ DoCompile jccolor.c +$ DoCompile jcsample.c +$ DoCompile jchuff.c +$ DoCompile jcdctmgr.c +$ DoCompile jfdctfst.c +$ DoCompile jfdctflt.c +$ DoCompile jfdctint.c +$ DoCompile jdapimin.c +$ DoCompile jdapistd.c +$ DoCompile jdarith.c +$ DoCompile jdtrans.c +$ DoCompile jdatasrc.c +$ DoCompile jdmaster.c +$ DoCompile jdinput.c +$ DoCompile jdmarker.c +$ DoCompile jdhuff.c +$ DoCompile jdmainct.c +$ DoCompile jdcoefct.c +$ DoCompile jdpostct.c +$ DoCompile jddctmgr.c +$ DoCompile jidctfst.c +$ DoCompile jidctflt.c +$ DoCompile jidctint.c +$ DoCompile jdsample.c +$ DoCompile jdcolor.c +$ DoCompile jquant1.c +$ DoCompile jquant2.c +$ DoCompile jdmerge.c +$ DoCompile jcomapi.c +$ DoCompile jutils.c +$ DoCompile jerror.c +$ DoCompile jmemmgr.c +$ DoCompile jmemnobs.c +$! +$ Library /Create libjpeg.olb jaricom.obj,jcapimin.obj,jcapistd.obj, - + jcarith.obj,jctrans.obj,jcparam.obj,jdatadst.obj,jcinit.obj, - + jcmaster.obj,jcmarker.obj,jcmainct.obj,jcprepct.obj,jccoefct.obj, - + jccolor.obj,jcsample.obj,jchuff.obj,jcdctmgr.obj,jfdctfst.obj, - + jfdctflt.obj,jfdctint.obj,jdapimin.obj,jdapistd.obj,jdarith.obj, - + jdtrans.obj,jdatasrc.obj,jdmaster.obj,jdinput.obj,jdmarker.obj, - + jdhuff.obj,jdmainct.obj,jdcoefct.obj,jdpostct.obj,jddctmgr.obj, - + jidctfst.obj,jidctflt.obj,jidctint.obj,jdsample.obj,jdcolor.obj, - + jquant1.obj,jquant2.obj,jdmerge.obj,jcomapi.obj,jutils.obj, - + jerror.obj,jmemmgr.obj,jmemnobs.obj +$! +$ DoCompile cjpeg.c +$ DoCompile rdppm.c +$ DoCompile rdgif.c +$ DoCompile rdtarga.c +$ DoCompile rdrle.c +$ DoCompile rdbmp.c +$ DoCompile rdswitch.c +$ DoCompile cdjpeg.c +$! +$ Link /NoMap /Executable = cjpeg.exe cjpeg.obj,rdppm.obj,rdgif.obj, - + rdtarga.obj,rdrle.obj,rdbmp.obj,rdswitch.obj,cdjpeg.obj,libjpeg.olb/Library'OPT' +$! +$ DoCompile djpeg.c +$ DoCompile wrppm.c +$ DoCompile wrgif.c +$ DoCompile wrtarga.c +$ DoCompile wrrle.c +$ DoCompile wrbmp.c +$ DoCompile rdcolmap.c +$ DoCompile cdjpeg.c +$! +$ Link /NoMap /Executable = djpeg.exe djpeg.obj,wrppm.obj,wrgif.obj, - + wrtarga.obj,wrrle.obj,wrbmp.obj,rdcolmap.obj,cdjpeg.obj,libjpeg.olb/Library'OPT' +$! +$ DoCompile jpegtran.c +$ DoCompile rdswitch.c +$ DoCompile cdjpeg.c +$ DoCompile transupp.c +$! +$ Link /NoMap /Executable = jpegtran.exe jpegtran.obj,rdswitch.obj, - + cdjpeg.obj,transupp.obj,libjpeg.olb/Library'OPT' +$! +$ DoCompile rdjpgcom.c +$ Link /NoMap /Executable = rdjpgcom.exe rdjpgcom.obj'OPT' +$! +$ DoCompile wrjpgcom.c +$ Link /NoMap /Executable = wrjpgcom.exe wrjpgcom.obj'OPT' +$! +$! Run the self-test +$! +$ mcr sys$disk:[]djpeg -dct int -ppm -outfile testout.ppm testorig.jpg +$ mcr sys$disk:[]djpeg -dct int -gif -outfile testout.gif testorig.jpg +$ mcr sys$disk:[]djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg +$ mcr sys$disk:[]cjpeg -dct int -outfile testout.jpg testimg.ppm +$ mcr sys$disk:[]djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg +$ mcr sys$disk:[]cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm +$ mcr sys$disk:[]jpegtran -outfile testoutt.jpg testprog.jpg +$ Backup /Compare/Log testimg.ppm testout.ppm +$ Backup /Compare/Log testimg.gif testout.gif +$ Backup /Compare/Log testimg.bmp testout.bmp +$ Backup /Compare/Log testimg.jpg testout.jpg +$ Backup /Compare/Log testimg.ppm testoutp.ppm +$ Backup /Compare/Log testimgp.jpg testoutp.jpg +$ Backup /Compare/Log testorig.jpg testoutt.jpg +$! +$End: +$ If Verify Then Set Verify +$ Exit diff --git a/thirdparty/jpeg-9e/makefile.vs b/thirdparty/jpeg-9e/makefile.vs new file mode 100644 index 0000000..15419d5 --- /dev/null +++ b/thirdparty/jpeg-9e/makefile.vs @@ -0,0 +1,388 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is for Microsoft Visual C++ on Windows NT (and 95?). +# It builds the IJG library as a statically linkable library (.LIB), +# and builds the sample applications as console-mode apps. +# Thanks to Xingong Chang, Raymond Everly and others. + +# Read installation instructions before saying "nmake" !! +# To build an optimized library without debug info, say "nmake nodebug=1". + +# Pull in standard variable definitions +#!include + +# You may want to adjust these compiler options: +CFLAGS= $(cflags) $(cdebug) $(cvars) -I. +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time options: +LDFLAGS= $(ldebug) $(conlflags) + +# To link any special libraries, add the necessary commands here. +LDLIBS= $(conlibs) + +# Put here the object file name for the correct system-dependent memory +# manager file. For NT we suggest jmemnobs.obj, which expects the OS to +# provide adequate virtual memory. +SYSDEPMEM= jmemnobs.obj + +# miscellaneous OS-dependent stuff +# file deletion command +RM= del + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \ + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \ + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \ + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h \ + jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.txt usage.txt cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.txt example.c libjpeg.txt structure.txt \ + coderules.txt filelist.txt cdaltui.txt change.log +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \ + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \ + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \ + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \ + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \ + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \ + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \ + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \ + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \ + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 \ + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \ + missing ar-lib +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in \ + cjpegalt.c djpegalt.c +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \ + testprog.jpg testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jaricom.obj jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jcarith.obj jctrans.obj jcparam.obj \ + jdatadst.obj jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj \ + jcprepct.obj jccoefct.obj jccolor.obj jcsample.obj jchuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdarith.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdmainct.obj \ + jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj jidctflt.obj \ + jidctint.obj jdsample.obj jdcolor.obj jquant1.obj jquant2.obj \ + jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj + +# Template command for compiling .c to .obj +.c.obj: + $(cc) $(CFLAGS) $*.c + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) + $(RM) libjpeg.lib + lib -out:libjpeg.lib $(LIBOBJECTS) + +cjpeg.exe: $(COBJECTS) libjpeg.lib + $(link) $(LDFLAGS) -out:cjpeg.exe $(COBJECTS) libjpeg.lib $(LDLIBS) + +djpeg.exe: $(DOBJECTS) libjpeg.lib + $(link) $(LDFLAGS) -out:djpeg.exe $(DOBJECTS) libjpeg.lib $(LDLIBS) + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + $(link) $(LDFLAGS) -out:jpegtran.exe $(TROBJECTS) libjpeg.lib $(LDLIBS) + +rdjpgcom.exe: rdjpgcom.obj + $(link) $(LDFLAGS) -out:rdjpgcom.exe rdjpgcom.obj $(LDLIBS) + +wrjpgcom.exe: wrjpgcom.obj + $(link) $(LDFLAGS) -out:wrjpgcom.exe wrjpgcom.obj $(LDLIBS) + + +clean: + $(RM) *.obj *.exe libjpeg.lib + $(RM) testout* + +setup-vc6: + ren jconfig.vc jconfig.h + ren makejdsw.vc6 jpeg.dsw + ren makeadsw.vc6 apps.dsw + ren makejmak.vc6 jpeg.mak + ren makejdep.vc6 jpeg.dep + ren makejdsp.vc6 jpeg.dsp + ren makecmak.vc6 cjpeg.mak + ren makecdep.vc6 cjpeg.dep + ren makecdsp.vc6 cjpeg.dsp + ren makedmak.vc6 djpeg.mak + ren makeddep.vc6 djpeg.dep + ren makeddsp.vc6 djpeg.dsp + ren maketmak.vc6 jpegtran.mak + ren maketdep.vc6 jpegtran.dep + ren maketdsp.vc6 jpegtran.dsp + ren makermak.vc6 rdjpgcom.mak + ren makerdep.vc6 rdjpgcom.dep + ren makerdsp.vc6 rdjpgcom.dsp + ren makewmak.vc6 wrjpgcom.mak + ren makewdep.vc6 wrjpgcom.dep + ren makewdsp.vc6 wrjpgcom.dsp + +setupcopy-vc6: + copy /y jconfig.vc jconfig.h + copy /y makejdsw.vc6 jpeg.dsw + copy /y makeadsw.vc6 apps.dsw + copy /y makejmak.vc6 jpeg.mak + copy /y makejdep.vc6 jpeg.dep + copy /y makejdsp.vc6 jpeg.dsp + copy /y makecmak.vc6 cjpeg.mak + copy /y makecdep.vc6 cjpeg.dep + copy /y makecdsp.vc6 cjpeg.dsp + copy /y makedmak.vc6 djpeg.mak + copy /y makeddep.vc6 djpeg.dep + copy /y makeddsp.vc6 djpeg.dsp + copy /y maketmak.vc6 jpegtran.mak + copy /y maketdep.vc6 jpegtran.dep + copy /y maketdsp.vc6 jpegtran.dsp + copy /y makermak.vc6 rdjpgcom.mak + copy /y makerdep.vc6 rdjpgcom.dep + copy /y makerdsp.vc6 rdjpgcom.dsp + copy /y makewmak.vc6 wrjpgcom.mak + copy /y makewdep.vc6 wrjpgcom.dep + copy /y makewdsp.vc6 wrjpgcom.dsp + +setup-v16: + ren jconfig.vc jconfig.h + ren makejsln.v16 jpeg.sln + ren makeasln.v16 apps.sln + ren makejvcx.v16 jpeg.vcxproj + ren makejfil.v16 jpeg.vcxproj.filters + ren makecvcx.v16 cjpeg.vcxproj + ren makecfil.v16 cjpeg.vcxproj.filters + ren makedvcx.v16 djpeg.vcxproj + ren makedfil.v16 djpeg.vcxproj.filters + ren maketvcx.v16 jpegtran.vcxproj + ren maketfil.v16 jpegtran.vcxproj.filters + ren makervcx.v16 rdjpgcom.vcxproj + ren makerfil.v16 rdjpgcom.vcxproj.filters + ren makewvcx.v16 wrjpgcom.vcxproj + ren makewfil.v16 wrjpgcom.vcxproj.filters + +setupcopy-v16: + copy /y jconfig.vc jconfig.h + copy /y makejsln.v16 jpeg.sln + copy /y makeasln.v16 apps.sln + copy /y makejvcx.v16 jpeg.vcxproj + copy /y makejfil.v16 jpeg.vcxproj.filters + copy /y makecvcx.v16 cjpeg.vcxproj + copy /y makecfil.v16 cjpeg.vcxproj.filters + copy /y makedvcx.v16 djpeg.vcxproj + copy /y makedfil.v16 djpeg.vcxproj.filters + copy /y maketvcx.v16 jpegtran.vcxproj + copy /y maketfil.v16 jpegtran.vcxproj.filters + copy /y makervcx.v16 rdjpgcom.vcxproj + copy /y makerfil.v16 rdjpgcom.vcxproj.filters + copy /y makewvcx.v16 wrjpgcom.vcxproj + copy /y makewfil.v16 wrjpgcom.vcxproj.filters + +setup-v17: + ren jconfig.vc jconfig.h + ren makejsln.v16 jpeg.sln + ren makeasln.v16 apps.sln + ren makejvcx.v17 jpeg.vcxproj + ren makejfil.v16 jpeg.vcxproj.filters + ren makecvcx.v17 cjpeg.vcxproj + ren makecfil.v16 cjpeg.vcxproj.filters + ren makedvcx.v17 djpeg.vcxproj + ren makedfil.v16 djpeg.vcxproj.filters + ren maketvcx.v17 jpegtran.vcxproj + ren maketfil.v16 jpegtran.vcxproj.filters + ren makervcx.v17 rdjpgcom.vcxproj + ren makerfil.v16 rdjpgcom.vcxproj.filters + ren makewvcx.v17 wrjpgcom.vcxproj + ren makewfil.v16 wrjpgcom.vcxproj.filters + +setupcopy-v17: + copy /y jconfig.vc jconfig.h + copy /y makejsln.v16 jpeg.sln + copy /y makeasln.v16 apps.sln + copy /y makejvcx.v17 jpeg.vcxproj + copy /y makejfil.v16 jpeg.vcxproj.filters + copy /y makecvcx.v17 cjpeg.vcxproj + copy /y makecfil.v16 cjpeg.vcxproj.filters + copy /y makedvcx.v17 djpeg.vcxproj + copy /y makedfil.v16 djpeg.vcxproj.filters + copy /y maketvcx.v17 jpegtran.vcxproj + copy /y maketfil.v16 jpegtran.vcxproj.filters + copy /y makervcx.v17 rdjpgcom.vcxproj + copy /y makerfil.v16 rdjpgcom.vcxproj.filters + copy /y makewvcx.v17 wrjpgcom.vcxproj + copy /y makewfil.v16 wrjpgcom.vcxproj.filters + +test: + IF EXIST testout* $(RM) testout* + .\djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + .\djpeg -dct int -gif -outfile testout.gif testorig.jpg + .\djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + .\cjpeg -dct int -outfile testout.jpg testimg.ppm + .\djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + .\cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + .\jpegtran -outfile testoutt.jpg testprog.jpg + fc /b testimg.ppm testout.ppm + fc /b testimg.gif testout.gif + fc /b testimg.bmp testout.bmp + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg + +test-build: + IF EXIST .\Release\testout* $(RM) .\Release\testout* + .\Release\djpeg -dct int -ppm -outfile .\Release\testout.ppm testorig.jpg + .\Release\djpeg -dct int -gif -outfile .\Release\testout.gif testorig.jpg + .\Release\djpeg -dct int -bmp -colors 256 -outfile .\Release\testout.bmp testorig.jpg + .\Release\cjpeg -dct int -outfile .\Release\testout.jpg testimg.ppm + .\Release\djpeg -dct int -ppm -outfile .\Release\testoutp.ppm testprog.jpg + .\Release\cjpeg -dct int -progressive -opt -outfile .\Release\testoutp.jpg testimg.ppm + .\Release\jpegtran -outfile .\Release\testoutt.jpg testprog.jpg + fc /b testimg.ppm .\Release\testout.ppm + fc /b testimg.gif .\Release\testout.gif + fc /b testimg.bmp .\Release\testout.bmp + fc /b testimg.jpg .\Release\testout.jpg + fc /b testimg.ppm .\Release\testoutp.ppm + fc /b testimgp.jpg .\Release\testoutp.jpg + fc /b testorig.jpg .\Release\testoutt.jpg + +test-32: + IF EXIST .\Release\testout* $(RM) .\Release\testout* + .\Release\Win32\djpeg -dct int -ppm -outfile .\Release\testout.ppm testorig.jpg + .\Release\Win32\djpeg -dct int -gif -outfile .\Release\testout.gif testorig.jpg + .\Release\Win32\djpeg -dct int -bmp -colors 256 -outfile .\Release\testout.bmp testorig.jpg + .\Release\Win32\cjpeg -dct int -outfile .\Release\testout.jpg testimg.ppm + .\Release\Win32\djpeg -dct int -ppm -outfile .\Release\testoutp.ppm testprog.jpg + .\Release\Win32\cjpeg -dct int -progressive -opt -outfile .\Release\testoutp.jpg testimg.ppm + .\Release\Win32\jpegtran -outfile .\Release\testoutt.jpg testprog.jpg + fc /b testimg.ppm .\Release\testout.ppm + fc /b testimg.gif .\Release\testout.gif + fc /b testimg.bmp .\Release\testout.bmp + fc /b testimg.jpg .\Release\testout.jpg + fc /b testimg.ppm .\Release\testoutp.ppm + fc /b testimgp.jpg .\Release\testoutp.jpg + fc /b testorig.jpg .\Release\testoutt.jpg + +test-64: + IF EXIST .\Release\testout* $(RM) .\Release\testout* + .\Release\x64\djpeg -dct int -ppm -outfile .\Release\testout.ppm testorig.jpg + .\Release\x64\djpeg -dct int -gif -outfile .\Release\testout.gif testorig.jpg + .\Release\x64\djpeg -dct int -bmp -colors 256 -outfile .\Release\testout.bmp testorig.jpg + .\Release\x64\cjpeg -dct int -outfile .\Release\testout.jpg testimg.ppm + .\Release\x64\djpeg -dct int -ppm -outfile .\Release\testoutp.ppm testprog.jpg + .\Release\x64\cjpeg -dct int -progressive -opt -outfile .\Release\testoutp.jpg testimg.ppm + .\Release\x64\jpegtran -outfile .\Release\testoutt.jpg testprog.jpg + fc /b testimg.ppm .\Release\testout.ppm + fc /b testimg.gif .\Release\testout.gif + fc /b testimg.bmp .\Release\testout.bmp + fc /b testimg.jpg .\Release\testout.jpg + fc /b testimg.ppm .\Release\testoutp.ppm + fc /b testimgp.jpg .\Release\testoutp.jpg + fc /b testorig.jpg .\Release\testoutt.jpg + + +jaricom.obj: jaricom.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcarith.obj: jcarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdarith.obj: jdarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/thirdparty/jpeg-9e/makefile.wat b/thirdparty/jpeg-9e/makefile.wat new file mode 100644 index 0000000..a04e96d --- /dev/null +++ b/thirdparty/jpeg-9e/makefile.wat @@ -0,0 +1,246 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is suitable for Watcom C/C++ 10.0 on MS-DOS (using +# dos4g extender), OS/2, and Windows NT console mode. +# Thanks to Janos Haide, jhaide@btrvtech.com. + +# Read installation instructions before saying "wmake" !! + +# Uncomment line for desired system +SYSTEM=DOS +#SYSTEM=OS2 +#SYSTEM=NT + +# The name of your C compiler: +CC= wcl386 + +# You may need to adjust these cc options: +CFLAGS= -4r -ort -wx -zq -bt=$(SYSTEM) +# Caution: avoid -ol or -ox; these generate bad code with 10.0 or 10.0a. +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +!ifeq SYSTEM DOS +LDFLAGS= -zq -l=dos4g +!else ifeq SYSTEM OS2 +LDFLAGS= -zq -l=os2v2 +!else ifeq SYSTEM NT +LDFLAGS= -zq -l=nt +!endif + +# Put here the object file name for the correct system-dependent memory +# manager file. jmemnobs should work fine for dos4g or OS/2 environment. +SYSDEPMEM= jmemnobs.obj + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c & + jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c & + jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c & + jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c & + jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c & + jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c & + jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c & + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c & + rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c & + rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h & + jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h +# documentation, test, and support files +DOCS= README install.txt usage.txt cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 & + wrjpgcom.1 wizard.txt example.c libjpeg.txt structure.txt & + coderules.txt filelist.txt cdaltui.txt change.log +MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 & + makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc & + makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 & + makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 & + makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 & + makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 & + makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 & + makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 & + maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 & + makejvcx.v17 makecvcx.v17 makedvcx.v17 maketvcx.v17 makervcx.v17 & + makewvcx.v17 makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st & + maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms & + makvms.opt +CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat & + jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas & + jconfig.vms +CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp & + missing ar-lib +OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in & + cjpegalt.c djpegalt.c +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg & + testprog.jpg testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) & + $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jaricom.obj jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jcarith.obj jctrans.obj jcparam.obj & + jdatadst.obj jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj & + jcprepct.obj jccoefct.obj jccolor.obj jcsample.obj jchuff.obj & + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdarith.obj jdtrans.obj jdatasrc.obj & + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdmainct.obj & + jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj jidctflt.obj & + jidctint.obj jdsample.obj jdcolor.obj jquant1.obj jquant2.obj & + jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj & + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj & + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) + - del libjpeg.lib + * wlib -n libjpeg.lib $(LIBOBJECTS) + +cjpeg.exe: $(COBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) $(COBJECTS) libjpeg.lib + +djpeg.exe: $(DOBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) $(DOBJECTS) libjpeg.lib + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) $(TROBJECTS) libjpeg.lib + +rdjpgcom.exe: rdjpgcom.c + $(CC) $(CFLAGS) $(LDFLAGS) rdjpgcom.c + +wrjpgcom.exe: wrjpgcom.c + $(CC) $(CFLAGS) $(LDFLAGS) wrjpgcom.c + +.c.obj: + $(CC) $(CFLAGS) -c $< + +jconfig.h: jconfig.txt + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.txt. + exit 1 + +clean: .SYMBOLIC + - del *.obj + - del libjpeg.lib + - del cjpeg.exe + - del djpeg.exe + - del jpegtran.exe + - del rdjpgcom.exe + - del wrjpgcom.exe + - del testout*.* + +test: cjpeg.exe djpeg.exe jpegtran.exe .SYMBOLIC + - del testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -gif -outfile testout.gif testorig.jpg + djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg +!ifeq SYSTEM DOS + fc /b testimg.ppm testout.ppm + fc /b testimg.gif testout.gif + fc /b testimg.bmp testout.bmp + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg +!else + echo n > n.tmp + comp testimg.ppm testout.ppm < n.tmp + comp testimg.gif testout.gif < n.tmp + comp testimg.bmp testout.bmp < n.tmp + comp testimg.jpg testout.jpg < n.tmp + comp testimg.ppm testoutp.ppm < n.tmp + comp testimgp.jpg testoutp.jpg < n.tmp + comp testorig.jpg testoutt.jpg < n.tmp + del n.tmp +!endif + + +jaricom.obj: jaricom.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcarith.obj: jcarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdarith.obj: jdarith.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/thirdparty/jpeg-9e/makejdep.vc6 b/thirdparty/jpeg-9e/makejdep.vc6 new file mode 100644 index 0000000..1065b21 --- /dev/null +++ b/thirdparty/jpeg-9e/makejdep.vc6 @@ -0,0 +1,423 @@ +# Microsoft Developer Studio erstellte Abh„ngigkeitsdatei, einbezogen von jpeg.mak + +.\jaricom.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcapimin.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcapistd.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcarith.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jccoefct.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jccolor.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcdctmgr.c : \ + ".\jconfig.h"\ + ".\jdct.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jchuff.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcinit.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcmainct.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcmarker.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcmaster.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcomapi.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcparam.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcprepct.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jcsample.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jctrans.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdapimin.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdapistd.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdarith.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdatadst.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\jdatasrc.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\jdcoefct.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdcolor.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jddctmgr.c : \ + ".\jconfig.h"\ + ".\jdct.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdhuff.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdinput.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdmainct.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdmarker.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdmaster.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdmerge.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdpostct.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdsample.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jdtrans.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jerror.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + ".\jversion.h"\ + + +.\jfdctflt.c : \ + ".\jconfig.h"\ + ".\jdct.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jfdctfst.c : \ + ".\jconfig.h"\ + ".\jdct.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jfdctint.c : \ + ".\jconfig.h"\ + ".\jdct.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jidctflt.c : \ + ".\jconfig.h"\ + ".\jdct.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jidctfst.c : \ + ".\jconfig.h"\ + ".\jdct.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jidctint.c : \ + ".\jconfig.h"\ + ".\jdct.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jmemmgr.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmemsys.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jmemnobs.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmemsys.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jquant1.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jquant2.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + + +.\jutils.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + diff --git a/thirdparty/jpeg-9e/makejdsp.vc6 b/thirdparty/jpeg-9e/makejdsp.vc6 new file mode 100644 index 0000000..8cd27bd --- /dev/null +++ b/thirdparty/jpeg-9e/makejdsp.vc6 @@ -0,0 +1,285 @@ +# Microsoft Developer Studio Project File - Name="jpeg" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=jpeg - Win32 +!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "jpeg.mak". +!MESSAGE +!MESSAGE Sie k÷nnen beim Ausfhren von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "jpeg.mak" CFG="jpeg - Win32" +!MESSAGE +!MESSAGE Fr die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "jpeg - Win32" (basierend auf "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir ".\Release" +# PROP BASE Intermediate_Dir ".\Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir ".\Release" +# PROP Intermediate_Dir ".\Release\jpeg" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD BASE RSC /l 0x407 +# ADD RSC /l 0x407 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Target + +# Name "jpeg - Win32" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90" +# Begin Source File + +SOURCE=.\jaricom.c +# End Source File +# Begin Source File + +SOURCE=.\jcapimin.c +# End Source File +# Begin Source File + +SOURCE=.\jcapistd.c +# End Source File +# Begin Source File + +SOURCE=.\jcarith.c +# End Source File +# Begin Source File + +SOURCE=.\jccoefct.c +# End Source File +# Begin Source File + +SOURCE=.\jccolor.c +# End Source File +# Begin Source File + +SOURCE=.\jcdctmgr.c +# End Source File +# Begin Source File + +SOURCE=.\jchuff.c +# End Source File +# Begin Source File + +SOURCE=.\jcinit.c +# End Source File +# Begin Source File + +SOURCE=.\jcmainct.c +# End Source File +# Begin Source File + +SOURCE=.\jcmarker.c +# End Source File +# Begin Source File + +SOURCE=.\jcmaster.c +# End Source File +# Begin Source File + +SOURCE=.\jcomapi.c +# End Source File +# Begin Source File + +SOURCE=.\jcparam.c +# End Source File +# Begin Source File + +SOURCE=.\jcprepct.c +# End Source File +# Begin Source File + +SOURCE=.\jcsample.c +# End Source File +# Begin Source File + +SOURCE=.\jctrans.c +# End Source File +# Begin Source File + +SOURCE=.\jdapimin.c +# End Source File +# Begin Source File + +SOURCE=.\jdapistd.c +# End Source File +# Begin Source File + +SOURCE=.\jdarith.c +# End Source File +# Begin Source File + +SOURCE=.\jdatadst.c +# End Source File +# Begin Source File + +SOURCE=.\jdatasrc.c +# End Source File +# Begin Source File + +SOURCE=.\jdcoefct.c +# End Source File +# Begin Source File + +SOURCE=.\jdcolor.c +# End Source File +# Begin Source File + +SOURCE=.\jddctmgr.c +# End Source File +# Begin Source File + +SOURCE=.\jdhuff.c +# End Source File +# Begin Source File + +SOURCE=.\jdinput.c +# End Source File +# Begin Source File + +SOURCE=.\jdmainct.c +# End Source File +# Begin Source File + +SOURCE=.\jdmarker.c +# End Source File +# Begin Source File + +SOURCE=.\jdmaster.c +# End Source File +# Begin Source File + +SOURCE=.\jdmerge.c +# End Source File +# Begin Source File + +SOURCE=.\jdpostct.c +# End Source File +# Begin Source File + +SOURCE=.\jdsample.c +# End Source File +# Begin Source File + +SOURCE=.\jdtrans.c +# End Source File +# Begin Source File + +SOURCE=.\jerror.c +# End Source File +# Begin Source File + +SOURCE=.\jfdctflt.c +# End Source File +# Begin Source File + +SOURCE=.\jfdctfst.c +# End Source File +# Begin Source File + +SOURCE=.\jfdctint.c +# End Source File +# Begin Source File + +SOURCE=.\jidctflt.c +# End Source File +# Begin Source File + +SOURCE=.\jidctfst.c +# End Source File +# Begin Source File + +SOURCE=.\jidctint.c +# End Source File +# Begin Source File + +SOURCE=.\jmemmgr.c +# End Source File +# Begin Source File + +SOURCE=.\jmemnobs.c +# End Source File +# Begin Source File + +SOURCE=.\jquant1.c +# End Source File +# Begin Source File + +SOURCE=.\jquant2.c +# End Source File +# Begin Source File + +SOURCE=.\jutils.c +# End Source File +# End Group +# Begin Group "Header-Dateien" + +# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" +# Begin Source File + +SOURCE=.\jconfig.h +# End Source File +# Begin Source File + +SOURCE=.\jdct.h +# End Source File +# Begin Source File + +SOURCE=.\jerror.h +# End Source File +# Begin Source File + +SOURCE=.\jinclude.h +# End Source File +# Begin Source File + +SOURCE=.\jmemsys.h +# End Source File +# Begin Source File + +SOURCE=.\jmorecfg.h +# End Source File +# Begin Source File + +SOURCE=.\jpegint.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib.h +# End Source File +# Begin Source File + +SOURCE=.\jversion.h +# End Source File +# End Group +# Begin Group "Ressourcendateien" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/thirdparty/jpeg-9e/makejdsw.vc6 b/thirdparty/jpeg-9e/makejdsw.vc6 new file mode 100644 index 0000000..d11fab1 --- /dev/null +++ b/thirdparty/jpeg-9e/makejdsw.vc6 @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GEL™SCHT WERDEN! + +############################################################################### + +Project: "jpeg"=".\jpeg.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/thirdparty/jpeg-9e/makejfil.v16 b/thirdparty/jpeg-9e/makejfil.v16 new file mode 100644 index 0000000..4cd1d07 --- /dev/null +++ b/thirdparty/jpeg-9e/makejfil.v16 @@ -0,0 +1,186 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makejmak.vc6 b/thirdparty/jpeg-9e/makejmak.vc6 new file mode 100644 index 0000000..1107336 --- /dev/null +++ b/thirdparty/jpeg-9e/makejmak.vc6 @@ -0,0 +1,425 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on jpeg.dsp +!IF "$(CFG)" == "" +CFG=jpeg - Win32 +!MESSAGE Keine Konfiguration angegeben. jpeg - Win32 wird als Standard verwendet. +!ENDIF + +!IF "$(CFG)" != "jpeg - Win32" +!MESSAGE Ungültige Konfiguration "$(CFG)" angegeben. +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "jpeg.mak" CFG="jpeg - Win32" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "jpeg - Win32" (basierend auf "Win32 (x86) Static Library") +!MESSAGE +!ERROR Eine ungültige Konfiguration wurde angegeben. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +OUTDIR=.\Release +INTDIR=.\Release +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +ALL : "$(OUTDIR)\jpeg.lib" + + +CLEAN : + -@erase "$(INTDIR)\jaricom.obj" + -@erase "$(INTDIR)\jcapimin.obj" + -@erase "$(INTDIR)\jcapistd.obj" + -@erase "$(INTDIR)\jcarith.obj" + -@erase "$(INTDIR)\jccoefct.obj" + -@erase "$(INTDIR)\jccolor.obj" + -@erase "$(INTDIR)\jcdctmgr.obj" + -@erase "$(INTDIR)\jchuff.obj" + -@erase "$(INTDIR)\jcinit.obj" + -@erase "$(INTDIR)\jcmainct.obj" + -@erase "$(INTDIR)\jcmarker.obj" + -@erase "$(INTDIR)\jcmaster.obj" + -@erase "$(INTDIR)\jcomapi.obj" + -@erase "$(INTDIR)\jcparam.obj" + -@erase "$(INTDIR)\jcprepct.obj" + -@erase "$(INTDIR)\jcsample.obj" + -@erase "$(INTDIR)\jctrans.obj" + -@erase "$(INTDIR)\jdapimin.obj" + -@erase "$(INTDIR)\jdapistd.obj" + -@erase "$(INTDIR)\jdarith.obj" + -@erase "$(INTDIR)\jdatadst.obj" + -@erase "$(INTDIR)\jdatasrc.obj" + -@erase "$(INTDIR)\jdcoefct.obj" + -@erase "$(INTDIR)\jdcolor.obj" + -@erase "$(INTDIR)\jddctmgr.obj" + -@erase "$(INTDIR)\jdhuff.obj" + -@erase "$(INTDIR)\jdinput.obj" + -@erase "$(INTDIR)\jdmainct.obj" + -@erase "$(INTDIR)\jdmarker.obj" + -@erase "$(INTDIR)\jdmaster.obj" + -@erase "$(INTDIR)\jdmerge.obj" + -@erase "$(INTDIR)\jdpostct.obj" + -@erase "$(INTDIR)\jdsample.obj" + -@erase "$(INTDIR)\jdtrans.obj" + -@erase "$(INTDIR)\jerror.obj" + -@erase "$(INTDIR)\jfdctflt.obj" + -@erase "$(INTDIR)\jfdctfst.obj" + -@erase "$(INTDIR)\jfdctint.obj" + -@erase "$(INTDIR)\jidctflt.obj" + -@erase "$(INTDIR)\jidctfst.obj" + -@erase "$(INTDIR)\jidctint.obj" + -@erase "$(INTDIR)\jmemmgr.obj" + -@erase "$(INTDIR)\jmemnobs.obj" + -@erase "$(INTDIR)\jquant1.obj" + -@erase "$(INTDIR)\jquant2.obj" + -@erase "$(INTDIR)\jutils.obj" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(OUTDIR)\jpeg.lib" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\jpeg.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +RSC=rc.exe +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\jpeg.bsc" +BSC32_SBRS= \ + +LIB32=link.exe -lib +LIB32_FLAGS=/nologo /out:"$(OUTDIR)\jpeg.lib" +LIB32_OBJS= \ + "$(INTDIR)\jaricom.obj" \ + "$(INTDIR)\jcapimin.obj" \ + "$(INTDIR)\jcapistd.obj" \ + "$(INTDIR)\jcarith.obj" \ + "$(INTDIR)\jccoefct.obj" \ + "$(INTDIR)\jccolor.obj" \ + "$(INTDIR)\jcdctmgr.obj" \ + "$(INTDIR)\jchuff.obj" \ + "$(INTDIR)\jcinit.obj" \ + "$(INTDIR)\jcmainct.obj" \ + "$(INTDIR)\jcmarker.obj" \ + "$(INTDIR)\jcmaster.obj" \ + "$(INTDIR)\jcomapi.obj" \ + "$(INTDIR)\jcparam.obj" \ + "$(INTDIR)\jcprepct.obj" \ + "$(INTDIR)\jcsample.obj" \ + "$(INTDIR)\jctrans.obj" \ + "$(INTDIR)\jdapimin.obj" \ + "$(INTDIR)\jdapistd.obj" \ + "$(INTDIR)\jdarith.obj" \ + "$(INTDIR)\jdatadst.obj" \ + "$(INTDIR)\jdatasrc.obj" \ + "$(INTDIR)\jdcoefct.obj" \ + "$(INTDIR)\jdcolor.obj" \ + "$(INTDIR)\jddctmgr.obj" \ + "$(INTDIR)\jdhuff.obj" \ + "$(INTDIR)\jdinput.obj" \ + "$(INTDIR)\jdmainct.obj" \ + "$(INTDIR)\jdmarker.obj" \ + "$(INTDIR)\jdmaster.obj" \ + "$(INTDIR)\jdmerge.obj" \ + "$(INTDIR)\jdpostct.obj" \ + "$(INTDIR)\jdsample.obj" \ + "$(INTDIR)\jdtrans.obj" \ + "$(INTDIR)\jerror.obj" \ + "$(INTDIR)\jfdctflt.obj" \ + "$(INTDIR)\jfdctfst.obj" \ + "$(INTDIR)\jfdctint.obj" \ + "$(INTDIR)\jidctflt.obj" \ + "$(INTDIR)\jidctfst.obj" \ + "$(INTDIR)\jidctint.obj" \ + "$(INTDIR)\jmemmgr.obj" \ + "$(INTDIR)\jmemnobs.obj" \ + "$(INTDIR)\jquant1.obj" \ + "$(INTDIR)\jquant2.obj" \ + "$(INTDIR)\jutils.obj" + +"$(OUTDIR)\jpeg.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) + $(LIB32) @<< + $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) +<< + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("jpeg.dep") +!INCLUDE "jpeg.dep" +!ELSE +!MESSAGE Warning: cannot find "jpeg.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "jpeg - Win32" +SOURCE=.\jaricom.c + +"$(INTDIR)\jaricom.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcapimin.c + +"$(INTDIR)\jcapimin.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcapistd.c + +"$(INTDIR)\jcapistd.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcarith.c + +"$(INTDIR)\jcarith.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jccoefct.c + +"$(INTDIR)\jccoefct.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jccolor.c + +"$(INTDIR)\jccolor.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcdctmgr.c + +"$(INTDIR)\jcdctmgr.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jchuff.c + +"$(INTDIR)\jchuff.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcinit.c + +"$(INTDIR)\jcinit.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcmainct.c + +"$(INTDIR)\jcmainct.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcmarker.c + +"$(INTDIR)\jcmarker.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcmaster.c + +"$(INTDIR)\jcmaster.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcomapi.c + +"$(INTDIR)\jcomapi.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcparam.c + +"$(INTDIR)\jcparam.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcprepct.c + +"$(INTDIR)\jcprepct.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jcsample.c + +"$(INTDIR)\jcsample.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jctrans.c + +"$(INTDIR)\jctrans.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdapimin.c + +"$(INTDIR)\jdapimin.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdapistd.c + +"$(INTDIR)\jdapistd.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdarith.c + +"$(INTDIR)\jdarith.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdatadst.c + +"$(INTDIR)\jdatadst.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdatasrc.c + +"$(INTDIR)\jdatasrc.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdcoefct.c + +"$(INTDIR)\jdcoefct.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdcolor.c + +"$(INTDIR)\jdcolor.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jddctmgr.c + +"$(INTDIR)\jddctmgr.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdhuff.c + +"$(INTDIR)\jdhuff.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdinput.c + +"$(INTDIR)\jdinput.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdmainct.c + +"$(INTDIR)\jdmainct.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdmarker.c + +"$(INTDIR)\jdmarker.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdmaster.c + +"$(INTDIR)\jdmaster.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdmerge.c + +"$(INTDIR)\jdmerge.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdpostct.c + +"$(INTDIR)\jdpostct.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdsample.c + +"$(INTDIR)\jdsample.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jdtrans.c + +"$(INTDIR)\jdtrans.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jerror.c + +"$(INTDIR)\jerror.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jfdctflt.c + +"$(INTDIR)\jfdctflt.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jfdctfst.c + +"$(INTDIR)\jfdctfst.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jfdctint.c + +"$(INTDIR)\jfdctint.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jidctflt.c + +"$(INTDIR)\jidctflt.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jidctfst.c + +"$(INTDIR)\jidctfst.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jidctint.c + +"$(INTDIR)\jidctint.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jmemmgr.c + +"$(INTDIR)\jmemmgr.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jmemnobs.c + +"$(INTDIR)\jmemnobs.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jquant1.c + +"$(INTDIR)\jquant1.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jquant2.c + +"$(INTDIR)\jquant2.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jutils.c + +"$(INTDIR)\jutils.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + diff --git a/thirdparty/jpeg-9e/makejsln.v16 b/thirdparty/jpeg-9e/makejsln.v16 new file mode 100644 index 0000000..344f799 --- /dev/null +++ b/thirdparty/jpeg-9e/makejsln.v16 @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31402.337 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpeg", "jpeg.vcxproj", "{019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|ARM.ActiveCfg = Release|ARM + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|ARM.Build.0 = Release|ARM + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|ARM64.ActiveCfg = Release|ARM64 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|ARM64.Build.0 = Release|ARM64 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|Win32.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|Win32.Build.0 = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|x64.ActiveCfg = Release|x64 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F3829CB8-BF87-4A30-B5D3-E3ADB548485D} + EndGlobalSection +EndGlobal diff --git a/thirdparty/jpeg-9e/makejvcx.v16 b/thirdparty/jpeg-9e/makejvcx.v16 new file mode 100644 index 0000000..55f98cb --- /dev/null +++ b/thirdparty/jpeg-9e/makejvcx.v16 @@ -0,0 +1,222 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} + Win32Proj + jpeg + 10.0 + + + + StaticLibrary + false + true + Unicode + v142 + + + StaticLibrary + false + true + Unicode + v142 + + + StaticLibrary + false + true + Unicode + v142 + + + StaticLibrary + false + true + Unicode + v142 + + + + + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + + + Windows + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + + + Windows + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + + + Windows + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + + + Windows + true + true + true + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makejvcx.v17 b/thirdparty/jpeg-9e/makejvcx.v17 new file mode 100644 index 0000000..e4000a9 --- /dev/null +++ b/thirdparty/jpeg-9e/makejvcx.v17 @@ -0,0 +1,222 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} + Win32Proj + jpeg + 10.0 + + + + StaticLibrary + false + true + Unicode + v143 + + + StaticLibrary + false + true + Unicode + v143 + + + StaticLibrary + false + true + Unicode + v143 + + + StaticLibrary + false + true + Unicode + v143 + + + + + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + + + Windows + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + + + Windows + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + + + Windows + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + + + Windows + true + true + true + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makeproj.mac b/thirdparty/jpeg-9e/makeproj.mac new file mode 100644 index 0000000..e5b5102 --- /dev/null +++ b/thirdparty/jpeg-9e/makeproj.mac @@ -0,0 +1,213 @@ +-- +-- makeproj.mac +-- +-- This AppleScript builds Code Warrior PRO Release 2 project files for the +-- libjpeg library as well as the test programs 'cjpeg', 'djpeg', 'jpegtran'. +-- (We'd distribute real project files, except they're not text +-- and would create maintenance headaches.) +-- +-- The script then compiles and links the library and the test programs. +-- NOTE: if you haven't already created a 'jconfig.h' file, the script +-- automatically copies 'jconfig.mac' to 'jconfig.h'. +-- +-- To use this script, you must have AppleScript 1.1 or later installed +-- and a suitable AppleScript editor like Script Editor or Script Debugger +-- (http://www.latenightsw.com). Open this file with your AppleScript +-- editor and execute the "run" command to build the projects. +-- +-- Thanks to Dan Sears and Don Agro for this script. +-- Questions about this script can be addressed to dogpark@interlog.com +-- + +on run + + choose folder with prompt ">>> Select IJG source folder <<<" + set ijg_folder to result + + choose folder with prompt ">>> Select MetroWerks folder <<<" + set cw_folder to result + + -- if jconfig.h doesn't already exist, copy jconfig.mac + + tell application "Finder" + if not (exists file "jconfig.h" of ijg_folder) then + duplicate {file "jconfig.mac" of folder ijg_folder} + select file "jconfig.mac copy" of folder ijg_folder + set name of selection to "jconfig.h" + end if + end tell + + tell application "CodeWarrior IDE 2.1" + with timeout of 10000 seconds + + -- create libjpeg project + + activate + Create Project (ijg_folder as string) & "libjpeg.proj" + Set Preferences of panel "Target Settings" to {Target Name:"libjpeg"} + Set Preferences of panel "PPC Project" to {File Name:"libjpeg"} + Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} + Set Preferences of panel "PPC Project" to {Project Type:library} + Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} + Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} + Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} + Set Preferences of panel "PPC Linker" to {Generate SYM File:false} + + Add Files (ijg_folder as string) & "jaricom.c" To Segment 1 + Add Files (ijg_folder as string) & "jcapimin.c" To Segment 1 + Add Files (ijg_folder as string) & "jcapistd.c" To Segment 1 + Add Files (ijg_folder as string) & "jcarith.c" To Segment 1 + Add Files (ijg_folder as string) & "jctrans.c" To Segment 1 + Add Files (ijg_folder as string) & "jcparam.c" To Segment 1 + Add Files (ijg_folder as string) & "jdatadst.c" To Segment 1 + Add Files (ijg_folder as string) & "jcinit.c" To Segment 1 + Add Files (ijg_folder as string) & "jcmaster.c" To Segment 1 + Add Files (ijg_folder as string) & "jcmarker.c" To Segment 1 + Add Files (ijg_folder as string) & "jcmainct.c" To Segment 1 + Add Files (ijg_folder as string) & "jcprepct.c" To Segment 1 + Add Files (ijg_folder as string) & "jccoefct.c" To Segment 1 + Add Files (ijg_folder as string) & "jccolor.c" To Segment 1 + Add Files (ijg_folder as string) & "jcsample.c" To Segment 1 + Add Files (ijg_folder as string) & "jchuff.c" To Segment 1 + Add Files (ijg_folder as string) & "jcdctmgr.c" To Segment 1 + Add Files (ijg_folder as string) & "jfdctfst.c" To Segment 1 + Add Files (ijg_folder as string) & "jfdctflt.c" To Segment 1 + Add Files (ijg_folder as string) & "jfdctint.c" To Segment 1 + Add Files (ijg_folder as string) & "jdapimin.c" To Segment 1 + Add Files (ijg_folder as string) & "jdapistd.c" To Segment 1 + Add Files (ijg_folder as string) & "jdarith.c" To Segment 1 + Add Files (ijg_folder as string) & "jdtrans.c" To Segment 1 + Add Files (ijg_folder as string) & "jdatasrc.c" To Segment 1 + Add Files (ijg_folder as string) & "jdmaster.c" To Segment 1 + Add Files (ijg_folder as string) & "jdinput.c" To Segment 1 + Add Files (ijg_folder as string) & "jdmarker.c" To Segment 1 + Add Files (ijg_folder as string) & "jdhuff.c" To Segment 1 + Add Files (ijg_folder as string) & "jdmainct.c" To Segment 1 + Add Files (ijg_folder as string) & "jdcoefct.c" To Segment 1 + Add Files (ijg_folder as string) & "jdpostct.c" To Segment 1 + Add Files (ijg_folder as string) & "jddctmgr.c" To Segment 1 + Add Files (ijg_folder as string) & "jidctfst.c" To Segment 1 + Add Files (ijg_folder as string) & "jidctflt.c" To Segment 1 + Add Files (ijg_folder as string) & "jidctint.c" To Segment 1 + Add Files (ijg_folder as string) & "jdsample.c" To Segment 1 + Add Files (ijg_folder as string) & "jdcolor.c" To Segment 1 + Add Files (ijg_folder as string) & "jquant1.c" To Segment 1 + Add Files (ijg_folder as string) & "jquant2.c" To Segment 1 + Add Files (ijg_folder as string) & "jdmerge.c" To Segment 1 + Add Files (ijg_folder as string) & "jcomapi.c" To Segment 1 + Add Files (ijg_folder as string) & "jutils.c" To Segment 1 + Add Files (ijg_folder as string) & "jerror.c" To Segment 1 + Add Files (ijg_folder as string) & "jmemmgr.c" To Segment 1 + Add Files (ijg_folder as string) & "jmemmac.c" To Segment 1 + + -- compile and link the library + + Make Project + Close Project + + -- create cjpeg project + + activate + Create Project (ijg_folder as string) & "cjpeg.proj" + Set Preferences of panel "Target Settings" to {Target Name:"cjpeg"} + Set Preferences of panel "PPC Project" to {File Name:"cjpeg"} + Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} + Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} + Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} + Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} + Set Preferences of panel "PPC Linker" to {Generate SYM File:false} + + Add Files (ijg_folder as string) & "cjpeg.c" To Segment 1 + Add Files (ijg_folder as string) & "rdppm.c" To Segment 1 + Add Files (ijg_folder as string) & "rdgif.c" To Segment 1 + Add Files (ijg_folder as string) & "rdtarga.c" To Segment 1 + Add Files (ijg_folder as string) & "rdrle.c" To Segment 1 + Add Files (ijg_folder as string) & "rdbmp.c" To Segment 1 + Add Files (ijg_folder as string) & "rdswitch.c" To Segment 1 + Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 + + Add Files (ijg_folder as string) & "libjpeg" To Segment 2 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 + + -- compile and link cjpeg + + Make Project + Close Project + + -- create djpeg project + + activate + Create Project (ijg_folder as string) & "djpeg.proj" + Set Preferences of panel "Target Settings" to {Target Name:"djpeg"} + Set Preferences of panel "PPC Project" to {File Name:"djpeg"} + Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} + Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} + Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} + Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} + Set Preferences of panel "PPC Linker" to {Generate SYM File:false} + + Add Files (ijg_folder as string) & "djpeg.c" To Segment 1 + Add Files (ijg_folder as string) & "wrppm.c" To Segment 1 + Add Files (ijg_folder as string) & "wrgif.c" To Segment 1 + Add Files (ijg_folder as string) & "wrtarga.c" To Segment 1 + Add Files (ijg_folder as string) & "wrrle.c" To Segment 1 + Add Files (ijg_folder as string) & "wrbmp.c" To Segment 1 + Add Files (ijg_folder as string) & "rdcolmap.c" To Segment 1 + Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 + + Add Files (ijg_folder as string) & "libjpeg" To Segment 2 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 + + -- compile and link djpeg + + Make Project + Close Project + + -- create jpegtran project + + activate + Create Project (ijg_folder as string) & "jpegtran.proj" + Set Preferences of panel "Target Settings" to {Target Name:"jpegtran"} + Set Preferences of panel "PPC Project" to {File Name:"jpegtran"} + Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} + Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} + Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} + Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} + Set Preferences of panel "PPC Linker" to {Generate SYM File:false} + + Add Files (ijg_folder as string) & "jpegtran.c" To Segment 1 + Add Files (ijg_folder as string) & "rdswitch.c" To Segment 1 + Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 + Add Files (ijg_folder as string) & "transupp.c" To Segment 1 + + Add Files (ijg_folder as string) & "libjpeg" To Segment 2 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 + + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 + Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 + + -- compile and link jpegtran + + Make Project + Close Project + + quit + + end timeout + end tell +end run diff --git a/thirdparty/jpeg-9e/makerdep.vc6 b/thirdparty/jpeg-9e/makerdep.vc6 new file mode 100644 index 0000000..94748d0 --- /dev/null +++ b/thirdparty/jpeg-9e/makerdep.vc6 @@ -0,0 +1,6 @@ +# Microsoft Developer Studio erstellte Abh„ngigkeitsdatei, einbezogen von rdjpgcom.mak + +.\rdjpgcom.c : \ + ".\jconfig.h"\ + ".\jinclude.h"\ + diff --git a/thirdparty/jpeg-9e/makerdsp.vc6 b/thirdparty/jpeg-9e/makerdsp.vc6 new file mode 100644 index 0000000..8eaf446 --- /dev/null +++ b/thirdparty/jpeg-9e/makerdsp.vc6 @@ -0,0 +1,78 @@ +# Microsoft Developer Studio Project File - Name="rdjpgcom" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=rdjpgcom - Win32 +!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "rdjpgcom.mak". +!MESSAGE +!MESSAGE Sie k÷nnen beim Ausfhren von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "rdjpgcom.mak" CFG="rdjpgcom - Win32" +!MESSAGE +!MESSAGE Fr die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "rdjpgcom - Win32" (basierend auf "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir ".\rdjpgcom\Release" +# PROP BASE Intermediate_Dir ".\rdjpgcom\Release" +# PROP BASE Target_Dir ".\rdjpgcom" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir ".\Release" +# PROP Intermediate_Dir ".\Release\rdjpgcom" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir ".\rdjpgcom" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# Begin Target + +# Name "rdjpgcom - Win32" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90" +# Begin Source File + +SOURCE=.\rdjpgcom.c +# End Source File +# End Group +# Begin Group "Header-Dateien" + +# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" +# Begin Source File + +SOURCE=.\jconfig.h +# End Source File +# Begin Source File + +SOURCE=.\jinclude.h +# End Source File +# End Group +# Begin Group "Ressourcendateien" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/thirdparty/jpeg-9e/makerfil.v16 b/thirdparty/jpeg-9e/makerfil.v16 new file mode 100644 index 0000000..be828f5 --- /dev/null +++ b/thirdparty/jpeg-9e/makerfil.v16 @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + + + Source Files + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makermak.vc6 b/thirdparty/jpeg-9e/makermak.vc6 new file mode 100644 index 0000000..6d2d4c7 --- /dev/null +++ b/thirdparty/jpeg-9e/makermak.vc6 @@ -0,0 +1,110 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on rdjpgcom.dsp +!IF "$(CFG)" == "" +CFG=rdjpgcom - Win32 +!MESSAGE Keine Konfiguration angegeben. rdjpgcom - Win32 wird als Standard verwendet. +!ENDIF + +!IF "$(CFG)" != "rdjpgcom - Win32" +!MESSAGE Ungültige Konfiguration "$(CFG)" angegeben. +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "rdjpgcom.mak" CFG="rdjpgcom - Win32" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "rdjpgcom - Win32" (basierend auf "Win32 (x86) Console Application") +!MESSAGE +!ERROR Eine ungültige Konfiguration wurde angegeben. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +CPP=cl.exe +RSC=rc.exe +OUTDIR=.\rdjpgcom\Release +INTDIR=.\rdjpgcom\Release +# Begin Custom Macros +OutDir=.\rdjpgcom\Release +# End Custom Macros + +ALL : "$(OUTDIR)\rdjpgcom.exe" + + +CLEAN : + -@erase "$(INTDIR)\rdjpgcom.obj" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(OUTDIR)\rdjpgcom.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\rdjpgcom.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\rdjpgcom.pdb" /machine:I386 /out:"$(OUTDIR)\rdjpgcom.exe" +LINK32_OBJS= \ + "$(INTDIR)\rdjpgcom.obj" + +"$(OUTDIR)\rdjpgcom.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +CPP_PROJ=/nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /Fp"$(INTDIR)\rdjpgcom.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("rdjpgcom.dep") +!INCLUDE "rdjpgcom.dep" +!ELSE +!MESSAGE Warning: cannot find "rdjpgcom.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "rdjpgcom - Win32" +SOURCE=.\rdjpgcom.c + +"$(INTDIR)\rdjpgcom.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + diff --git a/thirdparty/jpeg-9e/makervcx.v16 b/thirdparty/jpeg-9e/makervcx.v16 new file mode 100644 index 0000000..21e412e --- /dev/null +++ b/thirdparty/jpeg-9e/makervcx.v16 @@ -0,0 +1,178 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {C81513DB-78DC-46BC-BC98-82E745203976} + Win32Proj + rdjpgcom + 10.0 + + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + + + + + + + + + + + + + + + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makervcx.v17 b/thirdparty/jpeg-9e/makervcx.v17 new file mode 100644 index 0000000..bf20038 --- /dev/null +++ b/thirdparty/jpeg-9e/makervcx.v17 @@ -0,0 +1,178 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {C81513DB-78DC-46BC-BC98-82E745203976} + Win32Proj + rdjpgcom + 10.0 + + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + + + + + + + + + + + + + + + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/maketdep.vc6 b/thirdparty/jpeg-9e/maketdep.vc6 new file mode 100644 index 0000000..e177ecb --- /dev/null +++ b/thirdparty/jpeg-9e/maketdep.vc6 @@ -0,0 +1,43 @@ +# Microsoft Developer Studio erstellte Abh„ngigkeitsdatei, einbezogen von jpegtran.mak + +.\cdjpeg.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\jpegtran.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + ".\jversion.h"\ + ".\transupp.h"\ + + +.\rdswitch.c : \ + ".\cderror.h"\ + ".\cdjpeg.h"\ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpeglib.h"\ + + +.\transupp.c : \ + ".\jconfig.h"\ + ".\jerror.h"\ + ".\jinclude.h"\ + ".\jmorecfg.h"\ + ".\jpegint.h"\ + ".\jpeglib.h"\ + ".\transupp.h"\ + diff --git a/thirdparty/jpeg-9e/maketdsp.vc6 b/thirdparty/jpeg-9e/maketdsp.vc6 new file mode 100644 index 0000000..00df01a --- /dev/null +++ b/thirdparty/jpeg-9e/maketdsp.vc6 @@ -0,0 +1,122 @@ +# Microsoft Developer Studio Project File - Name="jpegtran" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=jpegtran - Win32 +!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "jpegtran.mak". +!MESSAGE +!MESSAGE Sie k÷nnen beim Ausfhren von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "jpegtran.mak" CFG="jpegtran - Win32" +!MESSAGE +!MESSAGE Fr die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "jpegtran - Win32" (basierend auf "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir ".\jpegtran\Release" +# PROP BASE Intermediate_Dir ".\jpegtran\Release" +# PROP BASE Target_Dir ".\jpegtran" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir ".\Release" +# PROP Intermediate_Dir ".\Release\jpegtran" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir ".\jpegtran" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# Begin Target + +# Name "jpegtran - Win32" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90" +# Begin Source File + +SOURCE=.\cdjpeg.c +# End Source File +# Begin Source File + +SOURCE=.\jpegtran.c +# End Source File +# Begin Source File + +SOURCE=.\rdswitch.c +# End Source File +# Begin Source File + +SOURCE=.\transupp.c +# End Source File +# End Group +# Begin Group "Header-Dateien" + +# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" +# Begin Source File + +SOURCE=.\cderror.h +# End Source File +# Begin Source File + +SOURCE=.\cdjpeg.h +# End Source File +# Begin Source File + +SOURCE=.\jconfig.h +# End Source File +# Begin Source File + +SOURCE=.\jerror.h +# End Source File +# Begin Source File + +SOURCE=.\jinclude.h +# End Source File +# Begin Source File + +SOURCE=.\jmorecfg.h +# End Source File +# Begin Source File + +SOURCE=.\jpegint.h +# End Source File +# Begin Source File + +SOURCE=.\jpeglib.h +# End Source File +# Begin Source File + +SOURCE=.\jversion.h +# End Source File +# Begin Source File + +SOURCE=.\transupp.h +# End Source File +# End Group +# Begin Group "Ressourcendateien" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/thirdparty/jpeg-9e/maketfil.v16 b/thirdparty/jpeg-9e/maketfil.v16 new file mode 100644 index 0000000..4fcb210 --- /dev/null +++ b/thirdparty/jpeg-9e/maketfil.v16 @@ -0,0 +1,63 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/maketmak.vc6 b/thirdparty/jpeg-9e/maketmak.vc6 new file mode 100644 index 0000000..a0de38c --- /dev/null +++ b/thirdparty/jpeg-9e/maketmak.vc6 @@ -0,0 +1,131 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on jpegtran.dsp +!IF "$(CFG)" == "" +CFG=jpegtran - Win32 +!MESSAGE Keine Konfiguration angegeben. jpegtran - Win32 wird als Standard verwendet. +!ENDIF + +!IF "$(CFG)" != "jpegtran - Win32" +!MESSAGE Ungültige Konfiguration "$(CFG)" angegeben. +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "jpegtran.mak" CFG="jpegtran - Win32" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "jpegtran - Win32" (basierend auf "Win32 (x86) Console Application") +!MESSAGE +!ERROR Eine ungültige Konfiguration wurde angegeben. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +CPP=cl.exe +RSC=rc.exe +OUTDIR=.\jpegtran\Release +INTDIR=.\jpegtran\Release +# Begin Custom Macros +OutDir=.\jpegtran\Release +# End Custom Macros + +ALL : "$(OUTDIR)\jpegtran.exe" + + +CLEAN : + -@erase "$(INTDIR)\cdjpeg.obj" + -@erase "$(INTDIR)\jpegtran.obj" + -@erase "$(INTDIR)\rdswitch.obj" + -@erase "$(INTDIR)\transupp.obj" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(OUTDIR)\jpegtran.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\jpegtran.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\jpegtran.pdb" /machine:I386 /out:"$(OUTDIR)\jpegtran.exe" +LINK32_OBJS= \ + "$(INTDIR)\cdjpeg.obj" \ + "$(INTDIR)\jpegtran.obj" \ + "$(INTDIR)\rdswitch.obj" \ + "$(INTDIR)\transupp.obj" + +"$(OUTDIR)\jpegtran.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +CPP_PROJ=/nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /Fp"$(INTDIR)\jpegtran.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("jpegtran.dep") +!INCLUDE "jpegtran.dep" +!ELSE +!MESSAGE Warning: cannot find "jpegtran.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "jpegtran - Win32" +SOURCE=.\cdjpeg.c + +"$(INTDIR)\cdjpeg.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\jpegtran.c + +"$(INTDIR)\jpegtran.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\rdswitch.c + +"$(INTDIR)\rdswitch.obj" : $(SOURCE) "$(INTDIR)" + + +SOURCE=.\transupp.c + +"$(INTDIR)\transupp.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + diff --git a/thirdparty/jpeg-9e/maketvcx.v16 b/thirdparty/jpeg-9e/maketvcx.v16 new file mode 100644 index 0000000..0a90ae4 --- /dev/null +++ b/thirdparty/jpeg-9e/maketvcx.v16 @@ -0,0 +1,193 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {025BAC50-51B5-4FFE-BC47-3F920BB4047E} + Win32Proj + jpegtran + 10.0 + + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + + + + + + + + + + + + + + + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/maketvcx.v17 b/thirdparty/jpeg-9e/maketvcx.v17 new file mode 100644 index 0000000..4d41415 --- /dev/null +++ b/thirdparty/jpeg-9e/maketvcx.v17 @@ -0,0 +1,193 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {025BAC50-51B5-4FFE-BC47-3F920BB4047E} + Win32Proj + jpegtran + 10.0 + + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + + + + + + + + + + + + + + + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + $(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makewdep.vc6 b/thirdparty/jpeg-9e/makewdep.vc6 new file mode 100644 index 0000000..15929bf --- /dev/null +++ b/thirdparty/jpeg-9e/makewdep.vc6 @@ -0,0 +1,6 @@ +# Microsoft Developer Studio erstellte Abh„ngigkeitsdatei, einbezogen von wrjpgcom.mak + +.\wrjpgcom.c : \ + ".\jconfig.h"\ + ".\jinclude.h"\ + diff --git a/thirdparty/jpeg-9e/makewdsp.vc6 b/thirdparty/jpeg-9e/makewdsp.vc6 new file mode 100644 index 0000000..d2f3887 --- /dev/null +++ b/thirdparty/jpeg-9e/makewdsp.vc6 @@ -0,0 +1,78 @@ +# Microsoft Developer Studio Project File - Name="wrjpgcom" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=wrjpgcom - Win32 +!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "wrjpgcom.mak". +!MESSAGE +!MESSAGE Sie k÷nnen beim Ausfhren von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "wrjpgcom.mak" CFG="wrjpgcom - Win32" +!MESSAGE +!MESSAGE Fr die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "wrjpgcom - Win32" (basierend auf "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir ".\wrjpgcom\Release" +# PROP BASE Intermediate_Dir ".\wrjpgcom\Release" +# PROP BASE Target_Dir ".\wrjpgcom" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir ".\Release" +# PROP Intermediate_Dir ".\Release\wrjpgcom" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir ".\wrjpgcom" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# Begin Target + +# Name "wrjpgcom - Win32" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90" +# Begin Source File + +SOURCE=.\wrjpgcom.c +# End Source File +# End Group +# Begin Group "Header-Dateien" + +# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" +# Begin Source File + +SOURCE=.\jconfig.h +# End Source File +# Begin Source File + +SOURCE=.\jinclude.h +# End Source File +# End Group +# Begin Group "Ressourcendateien" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/thirdparty/jpeg-9e/makewfil.v16 b/thirdparty/jpeg-9e/makewfil.v16 new file mode 100644 index 0000000..c6ea74d --- /dev/null +++ b/thirdparty/jpeg-9e/makewfil.v16 @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + + + Source Files + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makewmak.vc6 b/thirdparty/jpeg-9e/makewmak.vc6 new file mode 100644 index 0000000..22b9086 --- /dev/null +++ b/thirdparty/jpeg-9e/makewmak.vc6 @@ -0,0 +1,110 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on wrjpgcom.dsp +!IF "$(CFG)" == "" +CFG=wrjpgcom - Win32 +!MESSAGE Keine Konfiguration angegeben. wrjpgcom - Win32 wird als Standard verwendet. +!ENDIF + +!IF "$(CFG)" != "wrjpgcom - Win32" +!MESSAGE Ungültige Konfiguration "$(CFG)" angegeben. +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "wrjpgcom.mak" CFG="wrjpgcom - Win32" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "wrjpgcom - Win32" (basierend auf "Win32 (x86) Console Application") +!MESSAGE +!ERROR Eine ungültige Konfiguration wurde angegeben. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +CPP=cl.exe +RSC=rc.exe +OUTDIR=.\wrjpgcom\Release +INTDIR=.\wrjpgcom\Release +# Begin Custom Macros +OutDir=.\wrjpgcom\Release +# End Custom Macros + +ALL : "$(OUTDIR)\wrjpgcom.exe" + + +CLEAN : + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(INTDIR)\wrjpgcom.obj" + -@erase "$(OUTDIR)\wrjpgcom.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\wrjpgcom.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\wrjpgcom.pdb" /machine:I386 /out:"$(OUTDIR)\wrjpgcom.exe" +LINK32_OBJS= \ + "$(INTDIR)\wrjpgcom.obj" + +"$(OUTDIR)\wrjpgcom.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +CPP_PROJ=/nologo /G6 /MT /W3 /GX /Ox /Oa /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /Fp"$(INTDIR)\wrjpgcom.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("wrjpgcom.dep") +!INCLUDE "wrjpgcom.dep" +!ELSE +!MESSAGE Warning: cannot find "wrjpgcom.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "wrjpgcom - Win32" +SOURCE=.\wrjpgcom.c + +"$(INTDIR)\wrjpgcom.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + diff --git a/thirdparty/jpeg-9e/makewvcx.v16 b/thirdparty/jpeg-9e/makewvcx.v16 new file mode 100644 index 0000000..2ecbb2c --- /dev/null +++ b/thirdparty/jpeg-9e/makewvcx.v16 @@ -0,0 +1,178 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {B57065D4-DDDA-4668-BAF5-2D49270C973C} + Win32Proj + wrjpgcom + 10.0 + + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + Application + false + true + Unicode + v142 + + + + + + + + + + + + + + + + + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makewvcx.v17 b/thirdparty/jpeg-9e/makewvcx.v17 new file mode 100644 index 0000000..542b4ad --- /dev/null +++ b/thirdparty/jpeg-9e/makewvcx.v17 @@ -0,0 +1,178 @@ + + + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {B57065D4-DDDA-4668-BAF5-2D49270C973C} + Win32Proj + wrjpgcom + 10.0 + + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + + + + + + + + + + + + + + + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + false + $(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)\ + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + Level3 + NotUsing + Full + true + false + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS + true + true + 4996 + + + Console + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/jpeg-9e/makljpeg.st b/thirdparty/jpeg-9e/makljpeg.st new file mode 100644 index 0000000..cc1ba01 --- /dev/null +++ b/thirdparty/jpeg-9e/makljpeg.st @@ -0,0 +1,68 @@ +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle, B. Setzepfandt, and Guido Vollbeding. +; +; To use this file, rename it to libjpeg.prj. +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +libjpeg.lib +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost +.L[-J] ; link new Obj-format (so we get a library) += +; * * * * List of modules * * * * +jaricom.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcapimin.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcapistd.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcarith.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jccoefct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jccolor.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcdctmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jchuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcinit.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcmainct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcmarker.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcmaster.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcomapi.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcparam.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcprepct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcsample.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jctrans.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdapimin.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdapistd.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdarith.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdatadst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h) +jdatasrc.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h) +jdcoefct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdcolor.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jddctmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jdhuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdinput.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmainct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmarker.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmaster.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmerge.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdpostct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdsample.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdtrans.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jerror.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jversion.h,jerror.h) +jfdctflt.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jfdctfst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jfdctint.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jidctflt.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jidctfst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jidctint.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jquant1.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jquant2.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jutils.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jmemmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jmemsys.h) +jmemansi.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jmemsys.h) diff --git a/thirdparty/jpeg-9e/maktjpeg.st b/thirdparty/jpeg-9e/maktjpeg.st new file mode 100644 index 0000000..43f078a --- /dev/null +++ b/thirdparty/jpeg-9e/maktjpeg.st @@ -0,0 +1,30 @@ +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle, B. Setzepfandt, and Guido Vollbeding. +; +; To use this file, rename it to jpegtran.prj. +; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +jpegtran.ttp +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost += +; * * * * List of modules * * * * +pcstart.o +jpegtran.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,transupp.h,jversion.h) +cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +transupp.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,transupp.h) +libjpeg.lib ; built by libjpeg.prj +pcstdlib.lib ; standard library +pcextlib.lib ; extended library diff --git a/thirdparty/jpeg-9e/makvms.opt b/thirdparty/jpeg-9e/makvms.opt new file mode 100644 index 0000000..675e8fe --- /dev/null +++ b/thirdparty/jpeg-9e/makvms.opt @@ -0,0 +1,4 @@ +! A pointer to the VAX/VMS C Run-Time Shareable Library. +! This file is needed by makefile.mms and makefile.vms, +! but only for the older VAX C compiler. DEC C does not need it. +Sys$Library:VAXCRTL.EXE /Share diff --git a/thirdparty/jpeg-9e/missing b/thirdparty/jpeg-9e/missing new file mode 100755 index 0000000..1fe1611 --- /dev/null +++ b/thirdparty/jpeg-9e/missing @@ -0,0 +1,215 @@ +#! /bin/sh +# Common wrapper for a few potentially missing GNU programs. + +scriptversion=2018-03-07.03; # UTC + +# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# Originally written by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try '$0 --help' for more information" + exit 1 +fi + +case $1 in + + --is-lightweight) + # Used by our autoconf macros to check whether the available missing + # script is modern enough. + exit 0 + ;; + + --run) + # Back-compat with the calling convention used by older automake. + shift + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due +to PROGRAM being missing or too old. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal autoconf autoheader autom4te automake makeinfo + bison yacc flex lex help2man + +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and +'g' are ignored when checking the name. + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: unknown '$1' option" + echo 1>&2 "Try '$0 --help' for more information" + exit 1 + ;; + +esac + +# Run the given program, remember its exit status. +"$@"; st=$? + +# If it succeeded, we are done. +test $st -eq 0 && exit 0 + +# Also exit now if we it failed (or wasn't found), and '--version' was +# passed; such an option is passed most likely to detect whether the +# program is present and works. +case $2 in --version|--help) exit $st;; esac + +# Exit code 63 means version mismatch. This often happens when the user +# tries to use an ancient version of a tool on a file that requires a +# minimum version. +if test $st -eq 63; then + msg="probably too old" +elif test $st -eq 127; then + # Program was missing. + msg="missing on your system" +else + # Program was found and executed, but failed. Give up. + exit $st +fi + +perl_URL=https://www.perl.org/ +flex_URL=https://github.com/westes/flex +gnu_software_URL=https://www.gnu.org/software + +program_details () +{ + case $1 in + aclocal|automake) + echo "The '$1' program is part of the GNU Automake package:" + echo "<$gnu_software_URL/automake>" + echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/autoconf>" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + autoconf|autom4te|autoheader) + echo "The '$1' program is part of the GNU Autoconf package:" + echo "<$gnu_software_URL/autoconf/>" + echo "It also requires GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + esac +} + +give_advice () +{ + # Normalize program name to check for. + normalized_program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + + printf '%s\n' "'$1' is $msg." + + configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + case $normalized_program in + autoconf*) + echo "You should only need it if you modified 'configure.ac'," + echo "or m4 files included by it." + program_details 'autoconf' + ;; + autoheader*) + echo "You should only need it if you modified 'acconfig.h' or" + echo "$configure_deps." + program_details 'autoheader' + ;; + automake*) + echo "You should only need it if you modified 'Makefile.am' or" + echo "$configure_deps." + program_details 'automake' + ;; + aclocal*) + echo "You should only need it if you modified 'acinclude.m4' or" + echo "$configure_deps." + program_details 'aclocal' + ;; + autom4te*) + echo "You might have modified some maintainer files that require" + echo "the 'autom4te' program to be rebuilt." + program_details 'autom4te' + ;; + bison*|yacc*) + echo "You should only need it if you modified a '.y' file." + echo "You may want to install the GNU Bison package:" + echo "<$gnu_software_URL/bison/>" + ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; + help2man*) + echo "You should only need it if you modified a dependency" \ + "of a man page." + echo "You may want to install the GNU Help2man package:" + echo "<$gnu_software_URL/help2man/>" + ;; + makeinfo*) + echo "You should only need it if you modified a '.texi' file, or" + echo "any other file indirectly affecting the aspect of the manual." + echo "You might want to install the Texinfo package:" + echo "<$gnu_software_URL/texinfo/>" + echo "The spurious makeinfo call might also be the consequence of" + echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" + echo "want to install GNU make:" + echo "<$gnu_software_URL/make/>" + ;; + *) + echo "You might have modified some files without having the proper" + echo "tools for further handling them. Check the 'README' file, it" + echo "often tells you about the needed prerequisites for installing" + echo "this package. You may also peek at any GNU archive site, in" + echo "case some other package contains this missing '$1' program." + ;; + esac +} + +give_advice "$1" | sed -e '1s/^/WARNING: /' \ + -e '2,$s/^/ /' >&2 + +# Propagate the correct exit status (expected to be 127 for a program +# not found, 63 for a program that failed due to version mismatch). +exit $st + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/thirdparty/jpeg-9e/rdbmp.c b/thirdparty/jpeg-9e/rdbmp.c new file mode 100644 index 0000000..6749ea0 --- /dev/null +++ b/thirdparty/jpeg-9e/rdbmp.c @@ -0,0 +1,469 @@ +/* + * rdbmp.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2009-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in Microsoft "BMP" + * format (MS Windows 3.x, OS/2 1.x, and OS/2 2.x flavors). + * Currently, only 8-, 24-, and 32-bit images are supported, not 1-bit or + * 4-bit (feeding such low-depth images into JPEG would be silly anyway). + * Also, we don't support RLE-compressed files. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed BMP format). + * + * This code contributed by James Arthur Boucher. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef BMP_SUPPORTED + + +/* Macros to deal with unsigned chars as efficiently as compiler allows */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char U_CHAR; +#define UCH(x) ((int) (x)) +#else /* !HAVE_UNSIGNED_CHAR */ +typedef char U_CHAR; +#ifdef CHAR_IS_UNSIGNED +#define UCH(x) ((int) (x)) +#else +#define UCH(x) ((int) (x) & 0xFF) +#endif +#endif /* HAVE_UNSIGNED_CHAR */ + + +#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) + + +/* Private version of data source object */ + +typedef struct _bmp_source_struct * bmp_source_ptr; + +typedef struct _bmp_source_struct { + struct cjpeg_source_struct pub; /* public fields */ + + j_compress_ptr cinfo; /* back link saves passing separate parm */ + + JSAMPARRAY colormap; /* BMP colormap (converted to my format) */ + + jvirt_sarray_ptr whole_image; /* Needed to reverse row order */ + JDIMENSION source_row; /* Current source row number */ + JDIMENSION row_width; /* Physical width of scanlines in file */ + + int bits_per_pixel; /* remembers 8-, 24-, or 32-bit format */ + int cmap_length; /* colormap length */ +} bmp_source_struct; + + +LOCAL(int) +read_byte (bmp_source_ptr sinfo) +/* Read next byte from BMP file */ +{ + register FILE *infile = sinfo->pub.input_file; + register int c; + + if ((c = getc(infile)) == EOF) + ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); + return c; +} + + +LOCAL(void) +read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize) +/* Read the colormap from a BMP file */ +{ + int i; + + switch (mapentrysize) { + case 3: + /* BGR format (occurs in OS/2 files) */ + for (i = 0; i < cmaplen; i++) { + sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); + } + break; + case 4: + /* BGR0 format (occurs in MS Windows files) */ + for (i = 0; i < cmaplen; i++) { + sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); + (void) read_byte(sinfo); + } + break; + default: + ERREXIT(sinfo->cinfo, JERR_BMP_BADCMAP); + } +} + + +/* + * Read one row of pixels. + * The image has been read into the whole_image array, but is otherwise + * unprocessed. We must read it out in top-to-bottom row order, and if + * it is an 8-bit image, we must expand colormapped pixels to 24bit format. + */ + +METHODDEF(JDIMENSION) +get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 8-bit colormap indexes */ +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + register JSAMPROW inptr, outptr; + register JSAMPARRAY colormap; + register JDIMENSION col; + register int t; + int cmaplen; + + /* Fetch next row from virtual array */ + source->source_row--; + inptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, + source->whole_image, source->source_row, (JDIMENSION) 1, FALSE); + + /* Expand the colormap indexes to real data */ + outptr = source->pub.buffer[0]; + colormap = source->colormap; + cmaplen = source->cmap_length; + for (col = cinfo->image_width; col > 0; col--) { + t = GETJSAMPLE(*inptr++); + if (t >= cmaplen) + ERREXIT(cinfo, JERR_BMP_OUTOFRANGE); + *outptr++ = colormap[0][t]; /* can omit GETJSAMPLE() safely */ + *outptr++ = colormap[1][t]; + *outptr++ = colormap[2][t]; + } + + return 1; +} + +METHODDEF(JDIMENSION) +get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 24-bit pixels */ +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + + /* Fetch next row from virtual array */ + source->source_row--; + inptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, + source->whole_image, source->source_row, (JDIMENSION) 1, FALSE); + + /* Transfer data. Note source values are in BGR order + * (even though Microsoft's own documents say the opposite). + */ + outptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ + outptr[1] = *inptr++; + outptr[0] = *inptr++; + outptr += 3; + } + + return 1; +} + +METHODDEF(JDIMENSION) +get_32bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 32-bit pixels */ +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + + /* Fetch next row from virtual array */ + source->source_row--; + inptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, + source->whole_image, source->source_row, (JDIMENSION) 1, FALSE); + + /* Transfer data. Note source values are in BGR order + * (even though Microsoft's own documents say the opposite). + */ + outptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ + outptr[1] = *inptr++; + outptr[0] = *inptr++; + inptr++; /* skip the 4th byte (Alpha channel) */ + outptr += 3; + } + + return 1; +} + + +/* + * This method loads the image into whole_image during the first call on + * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call + * get_8bit_row, get_24bit_row, or get_32bit_row on subsequent calls. + */ + +METHODDEF(JDIMENSION) +preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + register FILE *infile = source->pub.input_file; + register int c; + register JSAMPROW out_ptr; + JDIMENSION row, col; + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + + /* Read the data into a virtual array in input-file row order. */ + for (row = 0; row < cinfo->image_height; row++) { + if (progress != NULL) { + progress->pub.pass_counter = (long) row; + progress->pub.pass_limit = (long) cinfo->image_height; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } + out_ptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, + source->whole_image, row, (JDIMENSION) 1, TRUE); + for (col = source->row_width; col > 0; col--) { + /* inline copy of read_byte() for speed */ + if ((c = getc(infile)) == EOF) + ERREXIT(cinfo, JERR_INPUT_EOF); + *out_ptr++ = (JSAMPLE) c; + } + } + if (progress != NULL) + progress->completed_extra_passes++; + + /* Set up to read from the virtual array in top-to-bottom order */ + switch (source->bits_per_pixel) { + case 8: + source->pub.get_pixel_rows = get_8bit_row; + break; + case 24: + source->pub.get_pixel_rows = get_24bit_row; + break; + case 32: + source->pub.get_pixel_rows = get_32bit_row; + break; + default: + ERREXIT(cinfo, JERR_BMP_BADDEPTH); + } + source->source_row = cinfo->image_height; + + /* And read the first row */ + return (*source->pub.get_pixel_rows) (cinfo, sinfo); +} + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + U_CHAR bmpfileheader[14]; + U_CHAR bmpinfoheader[64]; +#define GET_2B(array, offset) ((unsigned int) UCH(array[offset]) + \ + (((unsigned int) UCH(array[offset+1])) << 8)) +#define GET_4B(array, offset) ((INT32) UCH(array[offset]) + \ + (((INT32) UCH(array[offset+1])) << 8) + \ + (((INT32) UCH(array[offset+2])) << 16) + \ + (((INT32) UCH(array[offset+3])) << 24)) + INT32 bfOffBits; + INT32 headerSize; + INT32 biWidth; + INT32 biHeight; + unsigned int biPlanes; + INT32 biCompression; + INT32 biXPelsPerMeter,biYPelsPerMeter; + INT32 biClrUsed = 0; + int mapentrysize = 0; /* 0 indicates no colormap */ + INT32 bPad; + JDIMENSION row_width; + + /* Read and verify the bitmap file header */ + if (! ReadOK(source->pub.input_file, bmpfileheader, 14)) + ERREXIT(cinfo, JERR_INPUT_EOF); + if (GET_2B(bmpfileheader, 0) != 0x4D42) /* 'BM' */ + ERREXIT(cinfo, JERR_BMP_NOT); + bfOffBits = GET_4B(bmpfileheader, 10); + /* We ignore the remaining fileheader fields */ + + /* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows), + * or 64 bytes (OS/2 2.x). Check the first 4 bytes to find out which. + */ + if (! ReadOK(source->pub.input_file, bmpinfoheader, 4)) + ERREXIT(cinfo, JERR_INPUT_EOF); + headerSize = GET_4B(bmpinfoheader, 0); + if (headerSize < 12 || headerSize > 64) + ERREXIT(cinfo, JERR_BMP_BADHEADER); + if (! ReadOK(source->pub.input_file, bmpinfoheader + 4, headerSize - 4)) + ERREXIT(cinfo, JERR_INPUT_EOF); + + switch ((int) headerSize) { + case 12: + /* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */ + biWidth = (INT32) GET_2B(bmpinfoheader, 4); + biHeight = (INT32) GET_2B(bmpinfoheader, 6); + biPlanes = GET_2B(bmpinfoheader, 8); + source->bits_per_pixel = (int) GET_2B(bmpinfoheader, 10); + + switch (source->bits_per_pixel) { + case 8: /* colormapped image */ + mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */ + TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (int) biWidth, (int) biHeight); + break; + case 24: /* RGB image */ + case 32: /* RGB image + Alpha channel */ + TRACEMS3(cinfo, 1, JTRC_BMP_OS2, (int) biWidth, (int) biHeight, + source->bits_per_pixel); + break; + default: + ERREXIT(cinfo, JERR_BMP_BADDEPTH); + } + break; + case 40: + case 64: + /* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */ + /* or OS/2 2.x header, which has additional fields that we ignore */ + biWidth = GET_4B(bmpinfoheader, 4); + biHeight = GET_4B(bmpinfoheader, 8); + biPlanes = GET_2B(bmpinfoheader, 12); + source->bits_per_pixel = (int) GET_2B(bmpinfoheader, 14); + biCompression = GET_4B(bmpinfoheader, 16); + biXPelsPerMeter = GET_4B(bmpinfoheader, 24); + biYPelsPerMeter = GET_4B(bmpinfoheader, 28); + biClrUsed = GET_4B(bmpinfoheader, 32); + /* biSizeImage, biClrImportant fields are ignored */ + + switch (source->bits_per_pixel) { + case 8: /* colormapped image */ + mapentrysize = 4; /* Windows uses RGBQUAD colormap */ + TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (int) biWidth, (int) biHeight); + break; + case 24: /* RGB image */ + case 32: /* RGB image + Alpha channel */ + TRACEMS3(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight, + source->bits_per_pixel); + break; + default: + ERREXIT(cinfo, JERR_BMP_BADDEPTH); + } + if (biCompression != 0) + ERREXIT(cinfo, JERR_BMP_COMPRESSED); + + if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) { + /* Set JFIF density parameters from the BMP data */ + cinfo->X_density = (UINT16) (biXPelsPerMeter/100); /* 100 cm per meter */ + cinfo->Y_density = (UINT16) (biYPelsPerMeter/100); + cinfo->density_unit = 2; /* dots/cm */ + } + break; + default: + ERREXIT(cinfo, JERR_BMP_BADHEADER); + return; /* avoid compiler warnings for uninitialized variables */ + } + + if (biPlanes != 1) + ERREXIT(cinfo, JERR_BMP_BADPLANES); + /* Sanity check for buffer allocation below */ + if (biWidth <= 0 || biHeight <= 0 || (biWidth >> 24) || (biHeight >> 24)) + ERREXIT(cinfo, JERR_BMP_OUTOFRANGE); + + /* Compute distance to bitmap data --- will adjust for colormap below */ + bPad = bfOffBits - (headerSize + 14); + + /* Read the colormap, if any */ + if (mapentrysize > 0) { + if (biClrUsed <= 0) + biClrUsed = 256; /* assume it's 256 */ + else if (biClrUsed > 256) + ERREXIT(cinfo, JERR_BMP_BADCMAP); + /* Allocate space to store the colormap */ + source->colormap = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, + JPOOL_IMAGE, (JDIMENSION) biClrUsed, (JDIMENSION) 3); + source->cmap_length = (int) biClrUsed; + /* and read it from the file */ + read_colormap(source, (int) biClrUsed, mapentrysize); + /* account for size of colormap */ + bPad -= biClrUsed * mapentrysize; + } + + /* Skip any remaining pad bytes */ + if (bPad < 0) /* incorrect bfOffBits value? */ + ERREXIT(cinfo, JERR_BMP_BADHEADER); + while (--bPad >= 0) { + (void) read_byte(source); + } + + /* Compute row width in file, including padding to 4-byte boundary */ + if (source->bits_per_pixel == 24) + row_width = (JDIMENSION) (biWidth * 3); + else if (source->bits_per_pixel == 32) + row_width = (JDIMENSION) (biWidth * 4); + else + row_width = (JDIMENSION) biWidth; + while ((row_width & 3) != 0) row_width++; + source->row_width = row_width; + + /* Allocate space for inversion array, prepare for preload pass */ + source->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + row_width, (JDIMENSION) biHeight, (JDIMENSION) 1); + source->pub.get_pixel_rows = preload_image; + if (cinfo->progress != NULL) { + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + progress->total_extra_passes++; /* count file input as separate pass */ + } + + /* Allocate one-row buffer for returned data */ + source->pub.buffer = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, + JPOOL_IMAGE, (JDIMENSION) (biWidth * 3), (JDIMENSION) 1); + source->pub.buffer_height = 1; + + cinfo->in_color_space = JCS_RGB; + cinfo->input_components = 3; + cinfo->data_precision = 8; + cinfo->image_width = (JDIMENSION) biWidth; + cinfo->image_height = (JDIMENSION) biHeight; +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for BMP format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_bmp (j_compress_ptr cinfo) +{ + bmp_source_ptr source; + + /* Create module interface object */ + source = (bmp_source_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(bmp_source_struct)); + source->cinfo = cinfo; /* make back link for subroutines */ + /* Fill in method ptrs, except get_pixel_rows which start_input sets */ + source->pub.start_input = start_input_bmp; + source->pub.finish_input = finish_input_bmp; + + return &source->pub; +} + +#endif /* BMP_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/rdcolmap.c b/thirdparty/jpeg-9e/rdcolmap.c new file mode 100644 index 0000000..42b3437 --- /dev/null +++ b/thirdparty/jpeg-9e/rdcolmap.c @@ -0,0 +1,253 @@ +/* + * rdcolmap.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file implements djpeg's "-map file" switch. It reads a source image + * and constructs a colormap to be supplied to the JPEG decompressor. + * + * Currently, these file formats are supported for the map file: + * GIF: the contents of the GIF's global colormap are used. + * PPM (either text or raw flavor): the entire file is read and + * each unique pixel value is entered in the map. + * Note that reading a large PPM file will be horrendously slow. + * Typically, a PPM-format map file should contain just one pixel + * of each desired color. Such a file can be extracted from an + * ordinary image PPM file with ppmtomap(1). + * + * Rescaling a PPM that has a maxval unequal to MAXJSAMPLE is not + * currently implemented. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ + +/* Portions of this code are based on the PBMPLUS library, which is: +** +** Copyright (C) 1988 by Jef Poskanzer. +** +** Permission to use, copy, modify, and distribute this software and its +** documentation for any purpose and without fee is hereby granted, provided +** that the above copyright notice appear in all copies and that both that +** copyright notice and this permission notice appear in supporting +** documentation. This software is provided "as is" without express or +** implied warranty. +*/ + + +/* + * Add a (potentially) new color to the color map. + */ + +LOCAL(void) +add_map_entry (j_decompress_ptr cinfo, int R, int G, int B) +{ + JSAMPROW colormap0 = cinfo->colormap[0]; + JSAMPROW colormap1 = cinfo->colormap[1]; + JSAMPROW colormap2 = cinfo->colormap[2]; + int ncolors = cinfo->actual_number_of_colors; + int index; + + /* Check for duplicate color. */ + for (index = 0; index < ncolors; index++) { + if (GETJSAMPLE(colormap0[index]) == R && + GETJSAMPLE(colormap1[index]) == G && + GETJSAMPLE(colormap2[index]) == B) + return; /* color is already in map */ + } + + /* Check for map overflow. */ + if (ncolors >= (MAXJSAMPLE+1)) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE+1)); + + /* OK, add color to map. */ + colormap0[ncolors] = (JSAMPLE) R; + colormap1[ncolors] = (JSAMPLE) G; + colormap2[ncolors] = (JSAMPLE) B; + cinfo->actual_number_of_colors++; +} + + +/* + * Extract color map from a GIF file. + */ + +LOCAL(void) +read_gif_map (j_decompress_ptr cinfo, FILE * infile) +{ + int header[13]; + int i, colormaplen; + int R, G, B; + + /* Initial 'G' has already been read by read_color_map */ + /* Read the rest of the GIF header and logical screen descriptor */ + for (i = 1; i < 13; i++) { + if ((header[i] = getc(infile)) == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + } + + /* Verify GIF Header */ + if (header[1] != 'I' || header[2] != 'F') + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + /* There must be a global color map. */ + if ((header[10] & 0x80) == 0) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + /* OK, fetch it. */ + colormaplen = 2 << (header[10] & 0x07); + + for (i = 0; i < colormaplen; i++) { + R = getc(infile); + G = getc(infile); + B = getc(infile); + if (R == EOF || G == EOF || B == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + add_map_entry(cinfo, + R << (BITS_IN_JSAMPLE-8), + G << (BITS_IN_JSAMPLE-8), + B << (BITS_IN_JSAMPLE-8)); + } +} + + +/* Support routines for reading PPM */ + + +LOCAL(int) +pbm_getc (FILE * infile) +/* Read next char, skipping over any comments */ +/* A comment/newline sequence is returned as a newline */ +{ + register int ch; + + ch = getc(infile); + if (ch == '#') { + do { + ch = getc(infile); + } while (ch != '\n' && ch != EOF); + } + return ch; +} + + +LOCAL(unsigned int) +read_pbm_integer (j_decompress_ptr cinfo, FILE * infile) +/* Read an unsigned decimal integer from the PPM file */ +/* Swallows one trailing character after the integer */ +/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ +/* This should not be a problem in practice. */ +{ + register int ch; + register unsigned int val; + + /* Skip any leading whitespace */ + do { + ch = pbm_getc(infile); + if (ch == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); + + if (ch < '0' || ch > '9') + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + val = ch - '0'; + while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { + val *= 10; + val += ch - '0'; + } + return val; +} + + +/* + * Extract color map from a PPM file. + */ + +LOCAL(void) +read_ppm_map (j_decompress_ptr cinfo, FILE * infile) +{ + int c; + unsigned int w, h, maxval, row, col; + int R, G, B; + + /* Initial 'P' has already been read by read_color_map */ + c = getc(infile); /* save format discriminator for a sec */ + + /* while we fetch the remaining header info */ + w = read_pbm_integer(cinfo, infile); + h = read_pbm_integer(cinfo, infile); + maxval = read_pbm_integer(cinfo, infile); + + if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + /* For now, we don't support rescaling from an unusual maxval. */ + if (maxval != (unsigned int) MAXJSAMPLE) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + switch (c) { + case '3': /* it's a text-format PPM file */ + for (row = 0; row < h; row++) { + for (col = 0; col < w; col++) { + R = read_pbm_integer(cinfo, infile); + G = read_pbm_integer(cinfo, infile); + B = read_pbm_integer(cinfo, infile); + add_map_entry(cinfo, R, G, B); + } + } + break; + + case '6': /* it's a raw-format PPM file */ + for (row = 0; row < h; row++) { + for (col = 0; col < w; col++) { + R = getc(infile); + G = getc(infile); + B = getc(infile); + if (R == EOF || G == EOF || B == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + add_map_entry(cinfo, R, G, B); + } + } + break; + + default: + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + break; + } +} + + +/* + * Main entry point from djpeg.c. + * Input: opened input file (from file name argument on command line). + * Output: colormap and actual_number_of_colors fields are set in cinfo. + */ + +GLOBAL(void) +read_color_map (j_decompress_ptr cinfo, FILE * infile) +{ + /* Allocate space for a color map of maximum supported size. */ + cinfo->colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (MAXJSAMPLE+1), (JDIMENSION) 3); + cinfo->actual_number_of_colors = 0; /* initialize map to empty */ + + /* Read first byte to determine file format */ + switch (getc(infile)) { + case 'G': + read_gif_map(cinfo, infile); + break; + case 'P': + read_ppm_map(cinfo, infile); + break; + default: + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + break; + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/rdgif.c b/thirdparty/jpeg-9e/rdgif.c new file mode 100644 index 0000000..5d2339c --- /dev/null +++ b/thirdparty/jpeg-9e/rdgif.c @@ -0,0 +1,679 @@ +/* + * rdgif.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2019-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in GIF format. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed GIF format). + */ + +/* + * This code is loosely based on giftoppm from the PBMPLUS distribution + * of Feb. 1991. That file contains the following copyright notice: + * +-------------------------------------------------------------------+ + * | Copyright 1990, David Koblas. | + * | Permission to use, copy, modify, and distribute this software | + * | and its documentation for any purpose and without fee is hereby | + * | granted, provided that the above copyright notice appear in all | + * | copies and that both that copyright notice and this permission | + * | notice appear in supporting documentation. This software is | + * | provided "as is" without express or implied warranty. | + * +-------------------------------------------------------------------+ + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef GIF_SUPPORTED + + +/* Macros to deal with unsigned chars as efficiently as compiler allows */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char U_CHAR; +#define UCH(x) ((int) (x)) +#else /* !HAVE_UNSIGNED_CHAR */ +typedef char U_CHAR; +#ifdef CHAR_IS_UNSIGNED +#define UCH(x) ((int) (x)) +#else +#define UCH(x) ((int) (x) & 0xFF) +#endif +#endif /* HAVE_UNSIGNED_CHAR */ + + +#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) + + +#define MAXCOLORMAPSIZE 256 /* max # of colors in a GIF colormap */ +#define NUMCOLORS 3 /* # of colors */ +#define CM_RED 0 /* color component numbers */ +#define CM_GREEN 1 +#define CM_BLUE 2 + +#define MAX_LZW_BITS 12 /* maximum LZW code size */ +#define LZW_TABLE_SIZE (1< table of prefix symbols */ + UINT8 FAR *symbol_tail; /* => table of suffix bytes */ + UINT8 FAR *symbol_stack; /* => stack for symbol expansions */ + UINT8 FAR *sp; /* stack pointer */ + + /* State for interlaced image processing */ + boolean is_interlaced; /* TRUE if have interlaced image */ + jvirt_sarray_ptr interlaced_image; /* full image in interlaced order */ + JDIMENSION cur_row_number; /* need to know actual row number */ + JDIMENSION pass2_offset; /* # of pixel rows in pass 1 */ + JDIMENSION pass3_offset; /* # of pixel rows in passes 1&2 */ + JDIMENSION pass4_offset; /* # of pixel rows in passes 1,2,3 */ +} gif_source_struct; + +typedef gif_source_struct * gif_source_ptr; + + +/* Forward declarations */ +METHODDEF(JDIMENSION) get_pixel_rows + JPP((j_compress_ptr cinfo, cjpeg_source_ptr sinfo)); +METHODDEF(JDIMENSION) load_interlaced_image + JPP((j_compress_ptr cinfo, cjpeg_source_ptr sinfo)); +METHODDEF(JDIMENSION) get_interlaced_row + JPP((j_compress_ptr cinfo, cjpeg_source_ptr sinfo)); + + +LOCAL(int) +ReadByte (gif_source_ptr sinfo) +/* Read next byte from GIF file */ +{ + register FILE *infile = sinfo->pub.input_file; + register int c; + + if ((c = getc(infile)) == EOF) + ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); + return c; +} + + +LOCAL(int) +GetDataBlock (gif_source_ptr sinfo, U_CHAR *buf) +/* Read a GIF data block, which has a leading count byte */ +/* A zero-length block marks the end of a data block sequence */ +{ + int count; + + count = ReadByte(sinfo); + if (count > 0) { + if (! ReadOK(sinfo->pub.input_file, buf, count)) + ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); + } + return count; +} + + +LOCAL(void) +SkipDataBlocks (gif_source_ptr sinfo) +/* Skip a series of data blocks, until a block terminator is found */ +{ + U_CHAR buf[256]; + + while (GetDataBlock(sinfo, buf) > 0) + /* skip */; +} + + +LOCAL(void) +ReInitLZW (gif_source_ptr sinfo) +/* (Re)initialize LZW state; shared code for startup and Clear processing */ +{ + sinfo->code_size = sinfo->input_code_size + 1; + sinfo->limit_code = sinfo->clear_code << 1; /* 2^code_size */ + sinfo->max_code = sinfo->clear_code + 2; /* first unused code value */ + sinfo->sp = sinfo->symbol_stack; /* init stack to empty */ +} + + +LOCAL(void) +InitLZWCode (gif_source_ptr sinfo) +/* Initialize for a series of LZWReadByte (and hence GetCode) calls */ +{ + /* GetCode initialization */ + sinfo->last_byte = 2; /* make safe to "recopy last two bytes" */ + sinfo->code_buf[0] = 0; + sinfo->code_buf[1] = 0; + sinfo->last_bit = 0; /* nothing in the buffer */ + sinfo->cur_bit = 0; /* force buffer load on first call */ + sinfo->first_time = TRUE; + sinfo->out_of_blocks = FALSE; + + /* LZWReadByte initialization: */ + /* compute special code values (note that these do not change later) */ + sinfo->clear_code = 1 << sinfo->input_code_size; + sinfo->end_code = sinfo->clear_code + 1; + ReInitLZW(sinfo); +} + + +LOCAL(int) +GetCode (gif_source_ptr sinfo) +/* Fetch the next code_size bits from the GIF data */ +/* We assume code_size is less than 16 */ +{ + register INT32 accum; + int offs, count; + + while (sinfo->cur_bit + sinfo->code_size > sinfo->last_bit) { + /* Time to reload the buffer */ + /* First time, share code with Clear case */ + if (sinfo->first_time) { + sinfo->first_time = FALSE; + return sinfo->clear_code; + } + if (sinfo->out_of_blocks) { + WARNMS(sinfo->cinfo, JWRN_GIF_NOMOREDATA); + return sinfo->end_code; /* fake something useful */ + } + /* preserve last two bytes of what we have -- assume code_size <= 16 */ + sinfo->code_buf[0] = sinfo->code_buf[sinfo->last_byte-2]; + sinfo->code_buf[1] = sinfo->code_buf[sinfo->last_byte-1]; + /* Load more bytes; set flag if we reach the terminator block */ + if ((count = GetDataBlock(sinfo, &sinfo->code_buf[2])) == 0) { + sinfo->out_of_blocks = TRUE; + WARNMS(sinfo->cinfo, JWRN_GIF_NOMOREDATA); + return sinfo->end_code; /* fake something useful */ + } + /* Reset counters */ + sinfo->cur_bit = (sinfo->cur_bit - sinfo->last_bit) + 16; + sinfo->last_byte = 2 + count; + sinfo->last_bit = sinfo->last_byte * 8; + } + + /* Form up next 24 bits in accum */ + offs = sinfo->cur_bit >> 3; /* byte containing cur_bit */ + accum = (INT32) UCH(sinfo->code_buf[offs+2]); + accum <<= 8; + accum |= (INT32) UCH(sinfo->code_buf[offs+1]); + accum <<= 8; + accum |= (INT32) UCH(sinfo->code_buf[offs]); + + /* Right-align cur_bit in accum, then mask off desired number of bits */ + accum >>= (sinfo->cur_bit & 7); + sinfo->cur_bit += sinfo->code_size; + return ((int) accum) & ((1 << sinfo->code_size) - 1); +} + + +LOCAL(int) +LZWReadByte (gif_source_ptr sinfo) +/* Read an LZW-compressed byte */ +{ + register int code; /* current working code */ + int incode; /* saves actual input code */ + + /* If any codes are stacked from a previously read symbol, return them */ + if (sinfo->sp > sinfo->symbol_stack) + return (int) *(-- sinfo->sp); + + /* Time to read a new symbol */ + code = GetCode(sinfo); + + if (code == sinfo->clear_code) { + /* Reinit state, swallow any extra Clear codes, and */ + /* return next code, which is expected to be a raw byte. */ + ReInitLZW(sinfo); + do { + code = GetCode(sinfo); + } while (code == sinfo->clear_code); + if (code > sinfo->clear_code) { /* make sure it is a raw byte */ + WARNMS(sinfo->cinfo, JWRN_GIF_BADDATA); + code = 0; /* use something valid */ + } + /* make firstcode, oldcode valid! */ + sinfo->firstcode = sinfo->oldcode = code; + return code; + } + + if (code == sinfo->end_code) { + /* Skip the rest of the image, unless GetCode already read terminator */ + if (! sinfo->out_of_blocks) { + SkipDataBlocks(sinfo); + sinfo->out_of_blocks = TRUE; + } + /* Complain that there's not enough data */ + WARNMS(sinfo->cinfo, JWRN_GIF_ENDCODE); + /* Pad data with 0's */ + return 0; /* fake something usable */ + } + + /* Got normal raw byte or LZW symbol */ + incode = code; /* save for a moment */ + + if (code >= sinfo->max_code) { /* special case for not-yet-defined symbol */ + /* code == max_code is OK; anything bigger is bad data */ + if (code > sinfo->max_code) { + WARNMS(sinfo->cinfo, JWRN_GIF_BADDATA); + incode = 0; /* prevent creation of loops in symbol table */ + } + /* this symbol will be defined as oldcode/firstcode */ + *(sinfo->sp++) = (UINT8) sinfo->firstcode; + code = sinfo->oldcode; + } + + /* If it's a symbol, expand it into the stack */ + while (code >= sinfo->clear_code) { + *(sinfo->sp++) = sinfo->symbol_tail[code]; /* tail is a byte value */ + code = sinfo->symbol_head[code]; /* head is another LZW symbol */ + } + /* At this point code just represents a raw byte */ + sinfo->firstcode = code; /* save for possible future use */ + + /* If there's room in table... */ + if ((code = sinfo->max_code) < LZW_TABLE_SIZE) { + /* Define a new symbol = prev sym + head of this sym's expansion */ + sinfo->symbol_head[code] = (UINT16) sinfo->oldcode; + sinfo->symbol_tail[code] = (UINT8) sinfo->firstcode; + sinfo->max_code++; + /* Is it time to increase code_size? */ + if (sinfo->max_code >= sinfo->limit_code && + sinfo->code_size < MAX_LZW_BITS) { + sinfo->code_size++; + sinfo->limit_code <<= 1; /* keep equal to 2^code_size */ + } + } + + sinfo->oldcode = incode; /* save last input symbol for future use */ + return sinfo->firstcode; /* return first byte of symbol's expansion */ +} + + +LOCAL(void) +ReadColorMap (gif_source_ptr sinfo, int cmaplen, JSAMPARRAY cmap) +/* Read a GIF colormap */ +{ + int i; + + for (i = 0; i < cmaplen; i++) { +#if BITS_IN_JSAMPLE == 8 +#define UPSCALE(x) (x) +#else +#define UPSCALE(x) ((x) << (BITS_IN_JSAMPLE-8)) +#endif + cmap[CM_RED ][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo)); + cmap[CM_GREEN][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo)); + cmap[CM_BLUE ][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo)); + } +} + + +LOCAL(void) +DoExtension (gif_source_ptr sinfo) +/* Process an extension block */ +/* Currently we ignore 'em all */ +{ + int extlabel; + + /* Read extension label byte */ + extlabel = ReadByte(sinfo); + TRACEMS1(sinfo->cinfo, 1, JTRC_GIF_EXTENSION, extlabel); + /* Skip the data block(s) associated with the extension */ + SkipDataBlocks(sinfo); +} + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_gif (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + gif_source_ptr source = (gif_source_ptr) sinfo; + U_CHAR hdrbuf[10]; /* workspace for reading control blocks */ + unsigned int width, height; /* image dimensions */ + int colormaplen, aspectRatio; + int c; + + /* Read and verify GIF Header */ + if (! ReadOK(source->pub.input_file, hdrbuf, 6)) + ERREXIT(cinfo, JERR_GIF_NOT); + if (hdrbuf[0] != 'G' || hdrbuf[1] != 'I' || hdrbuf[2] != 'F') + ERREXIT(cinfo, JERR_GIF_NOT); + /* Check for expected version numbers. + * If unknown version, give warning and try to process anyway; + * this is per recommendation in GIF89a standard. + */ + if ((hdrbuf[3] != '8' || hdrbuf[4] != '7' || hdrbuf[5] != 'a') && + (hdrbuf[3] != '8' || hdrbuf[4] != '9' || hdrbuf[5] != 'a')) + TRACEMS3(cinfo, 1, JTRC_GIF_BADVERSION, hdrbuf[3], hdrbuf[4], hdrbuf[5]); + + /* Read and decipher Logical Screen Descriptor */ + if (! ReadOK(source->pub.input_file, hdrbuf, 7)) + ERREXIT(cinfo, JERR_INPUT_EOF); + width = LM_to_uint(hdrbuf, 0); + height = LM_to_uint(hdrbuf, 2); + /* we ignore the color resolution, sort flag, and background color index */ + aspectRatio = UCH(hdrbuf[6]); + if (aspectRatio != 0 && aspectRatio != 49) + TRACEMS(cinfo, 1, JTRC_GIF_NONSQUARE); + + /* Allocate space to store the colormap */ + source->colormap = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, + JPOOL_IMAGE, (JDIMENSION) MAXCOLORMAPSIZE, (JDIMENSION) NUMCOLORS); + colormaplen = 0; /* indicate initialization */ + + /* Read global colormap if header indicates it is present */ + if (BitSet(hdrbuf[4], COLORMAPFLAG)) { + colormaplen = 2 << (hdrbuf[4] & 0x07); + ReadColorMap(source, colormaplen, source->colormap); + } + + /* Scan until we reach start of desired image. + * We don't currently support skipping images, but could add it easily. + */ + for (;;) { + c = ReadByte(source); + + if (c == ';') /* GIF terminator?? */ + ERREXIT(cinfo, JERR_GIF_IMAGENOTFOUND); + + if (c == '!') { /* Extension */ + DoExtension(source); + continue; + } + + if (c != ',') { /* Not an image separator? */ + WARNMS1(cinfo, JWRN_GIF_CHAR, c); + continue; + } + + /* Read and decipher Local Image Descriptor */ + if (! ReadOK(source->pub.input_file, hdrbuf, 9)) + ERREXIT(cinfo, JERR_INPUT_EOF); + /* we ignore top/left position info, also sort flag */ + width = LM_to_uint(hdrbuf, 4); + height = LM_to_uint(hdrbuf, 6); + if (width <= 0 || height <= 0) + ERREXIT(cinfo, JERR_GIF_OUTOFRANGE); + source->is_interlaced = (BitSet(hdrbuf[8], INTERLACE) != 0); + + /* Read local colormap if header indicates it is present */ + /* Note: if we wanted to support skipping images, */ + /* we'd need to skip rather than read colormap for ignored images */ + if (BitSet(hdrbuf[8], COLORMAPFLAG)) { + colormaplen = 2 << (hdrbuf[8] & 0x07); + ReadColorMap(source, colormaplen, source->colormap); + } + + source->input_code_size = ReadByte(source); /* get min-code-size byte */ + if (source->input_code_size < 2 || source->input_code_size > 8) + ERREXIT1(cinfo, JERR_GIF_CODESIZE, source->input_code_size); + + /* Reached desired image, so break out of loop */ + /* If we wanted to skip this image, */ + /* we'd call SkipDataBlocks and then continue the loop */ + break; + } + + /* Prepare to read selected image: first initialize LZW decompressor */ + source->symbol_head = (UINT16 FAR *) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, LZW_TABLE_SIZE * SIZEOF(UINT16)); + source->symbol_tail = (UINT8 FAR *) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, LZW_TABLE_SIZE * SIZEOF(UINT8)); + source->symbol_stack = (UINT8 FAR *) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, LZW_TABLE_SIZE * SIZEOF(UINT8)); + InitLZWCode(source); + + /* + * If image is interlaced, we read it into a full-size sample array, + * decompressing as we go; then get_interlaced_row selects rows from the + * sample array in the proper order. + */ + if (source->is_interlaced) { + /* We request the virtual array now, but can't access it until virtual + * arrays have been allocated. Hence, the actual work of reading the + * image is postponed until the first call to get_pixel_rows. + */ + source->interlaced_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) width, (JDIMENSION) height, (JDIMENSION) 1); + if (cinfo->progress != NULL) { + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + progress->total_extra_passes++; /* count file input as separate pass */ + } + source->pub.get_pixel_rows = load_interlaced_image; + } else { + source->pub.get_pixel_rows = get_pixel_rows; + } + + /* Create compressor input buffer. */ + source->pub.buffer = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, + JPOOL_IMAGE, (JDIMENSION) width * NUMCOLORS, (JDIMENSION) 1); + source->pub.buffer_height = 1; + + /* Pad colormap for safety. */ + for (c = colormaplen; c < source->clear_code; c++) { + source->colormap[CM_RED ][c] = + source->colormap[CM_GREEN][c] = + source->colormap[CM_BLUE ][c] = CENTERJSAMPLE; + } + + /* Return info about the image. */ + cinfo->in_color_space = JCS_RGB; + cinfo->input_components = NUMCOLORS; + cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ + cinfo->image_width = width; + cinfo->image_height = height; + + TRACEMS3(cinfo, 1, JTRC_GIF, width, height, colormaplen); +} + + +/* + * Read one row of pixels. + * This version is used for noninterlaced GIF images: + * we read directly from the GIF file. + */ + +METHODDEF(JDIMENSION) +get_pixel_rows (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + gif_source_ptr source = (gif_source_ptr) sinfo; + register int c; + register JSAMPROW ptr; + register JDIMENSION col; + register JSAMPARRAY colormap = source->colormap; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + c = LZWReadByte(source); + *ptr++ = colormap[CM_RED ][c]; + *ptr++ = colormap[CM_GREEN][c]; + *ptr++ = colormap[CM_BLUE ][c]; + } + return 1; +} + + +/* + * Read one row of pixels. + * This version is used for the first call on get_pixel_rows when + * reading an interlaced GIF file: we read the whole image into memory. + */ + +METHODDEF(JDIMENSION) +load_interlaced_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + gif_source_ptr source = (gif_source_ptr) sinfo; + register JSAMPROW sptr; + register JDIMENSION col; + JDIMENSION row; + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + + /* Read the interlaced image into the virtual array we've created. */ + for (row = 0; row < cinfo->image_height; row++) { + if (progress != NULL) { + progress->pub.pass_counter = (long) row; + progress->pub.pass_limit = (long) cinfo->image_height; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } + sptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, + source->interlaced_image, row, (JDIMENSION) 1, TRUE); + for (col = cinfo->image_width; col > 0; col--) { + *sptr++ = (JSAMPLE) LZWReadByte(source); + } + } + if (progress != NULL) + progress->completed_extra_passes++; + + /* Replace method pointer so subsequent calls don't come here. */ + source->pub.get_pixel_rows = get_interlaced_row; + /* Initialize for get_interlaced_row, and perform first call on it. */ + source->cur_row_number = 0; + source->pass2_offset = (cinfo->image_height + 7) / 8; + source->pass3_offset = source->pass2_offset + (cinfo->image_height + 3) / 8; + source->pass4_offset = source->pass3_offset + (cinfo->image_height + 1) / 4; + + return get_interlaced_row(cinfo, sinfo); +} + + +/* + * Read one row of pixels. + * This version is used for interlaced GIF images: + * we read from the virtual array. + */ + +METHODDEF(JDIMENSION) +get_interlaced_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + gif_source_ptr source = (gif_source_ptr) sinfo; + register int c; + register JSAMPROW sptr, ptr; + register JDIMENSION col; + register JSAMPARRAY colormap = source->colormap; + JDIMENSION irow; + + /* Figure out which row of interlaced image is needed, and access it. */ + switch ((int) (source->cur_row_number & 7)) { + case 0: /* first-pass row */ + irow = source->cur_row_number >> 3; + break; + case 4: /* second-pass row */ + irow = (source->cur_row_number >> 3) + source->pass2_offset; + break; + case 2: /* third-pass row */ + case 6: + irow = (source->cur_row_number >> 2) + source->pass3_offset; + break; + default: /* fourth-pass row */ + irow = (source->cur_row_number >> 1) + source->pass4_offset; + } + sptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, + source->interlaced_image, irow, (JDIMENSION) 1, FALSE); + /* Scan the row, expand colormap, and output */ + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + c = GETJSAMPLE(*sptr++); + *ptr++ = colormap[CM_RED ][c]; + *ptr++ = colormap[CM_GREEN][c]; + *ptr++ = colormap[CM_BLUE ][c]; + } + source->cur_row_number++; /* for next time */ + return 1; +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_gif (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for GIF format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_gif (j_compress_ptr cinfo) +{ + gif_source_ptr source; + + /* Create module interface object */ + source = (gif_source_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(gif_source_struct)); + source->cinfo = cinfo; /* make back link for subroutines */ + /* Fill in method ptrs, except get_pixel_rows which start_input sets */ + source->pub.start_input = start_input_gif; + source->pub.finish_input = finish_input_gif; + + return &source->pub; +} + +#endif /* GIF_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/rdjpgcom.1 b/thirdparty/jpeg-9e/rdjpgcom.1 new file mode 100644 index 0000000..d7741fb --- /dev/null +++ b/thirdparty/jpeg-9e/rdjpgcom.1 @@ -0,0 +1,63 @@ +.TH RDJPGCOM 1 "13 September 2013" +.SH NAME +rdjpgcom \- display text comments from a JPEG file +.SH SYNOPSIS +.B rdjpgcom +[ +.B \-raw +] +[ +.B \-verbose +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B rdjpgcom +reads the named JPEG/JFIF file, or the standard input if no file is named, +and prints any text comments found in the file on the standard output. +.PP +The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. +Although the standard doesn't actually define what COM blocks are for, they +are widely used to hold user-supplied text strings. This lets you add +annotations, titles, index terms, etc to your JPEG files, and later retrieve +them as text. COM blocks do not interfere with the image stored in the JPEG +file. The maximum size of a COM block is 64K, but you can have as many of +them as you like in one JPEG file. +.SH OPTIONS +.TP +.B \-raw +Normally +.B rdjpgcom +escapes non-printable characters in comments, for security reasons. +This option avoids that. +.PP +.B \-verbose +Causes +.B rdjpgcom +to also display the JPEG image dimensions. +.PP +Switch names may be abbreviated, and are not case sensitive. +.SH HINTS +.B rdjpgcom +does not depend on the IJG JPEG library. Its source code is intended as an +illustration of the minimum amount of code required to parse a JPEG file +header correctly. +.PP +In +.B \-verbose +mode, +.B rdjpgcom +will also attempt to print the contents of any "APP12" markers as text. +Some digital cameras produce APP12 markers containing useful textual +information. If you like, you can modify the source code to print +other APPn marker types as well. +.SH SEE ALSO +.BR cjpeg (1), +.BR djpeg (1), +.BR jpegtran (1), +.BR wrjpgcom (1) +.SH AUTHOR +Independent JPEG Group diff --git a/thirdparty/jpeg-9e/rdjpgcom.c b/thirdparty/jpeg-9e/rdjpgcom.c new file mode 100644 index 0000000..3719154 --- /dev/null +++ b/thirdparty/jpeg-9e/rdjpgcom.c @@ -0,0 +1,515 @@ +/* + * rdjpgcom.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * Modified 2009 by Bill Allombert, Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a very simple stand-alone application that displays + * the text in COM (comment) markers in a JFIF file. + * This may be useful as an example of the minimum logic needed to parse + * JPEG markers. + */ + +#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ +#include "jinclude.h" /* get auto-config symbols, */ + +#ifdef HAVE_LOCALE_H +#include /* Bill Allombert: use locale for isprint */ +#endif +#include /* to declare isupper(), tolower() */ +#ifdef USE_SETMODE +#include /* to declare setmode()'s parameter macros */ +/* If you have setmode() but not , just delete this line: */ +#include /* to declare setmode() */ +#endif + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#else +#ifdef VMS /* VMS is very nonstandard */ +#define READ_BINARY "rb", "ctx=stm" +#else /* standard ANSI-compliant case */ +#define READ_BINARY "rb" +#endif +#endif + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif +#ifndef EXIT_SUCCESS +#ifdef VMS +#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ +#else +#define EXIT_SUCCESS 0 +#endif +#endif + + +/* + * These macros are used to read the input file. + * To reuse this code in another application, you might need to change these. + */ + +static FILE * infile; /* input JPEG file */ + +/* Return next input byte, or EOF if no more */ +#define NEXTBYTE() getc(infile) + + +/* Error exit handler */ +#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) + + +/* Read one byte, testing for EOF */ +static int +read_1_byte (void) +{ + int c; + + c = NEXTBYTE(); + if (c == EOF) + ERREXIT("Premature EOF in JPEG file"); + return c; +} + +/* Read 2 bytes, convert to unsigned int */ +/* All 2-byte quantities in JPEG markers are MSB first */ +static unsigned int +read_2_bytes (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + if (c1 == EOF) + ERREXIT("Premature EOF in JPEG file"); + c2 = NEXTBYTE(); + if (c2 == EOF) + ERREXIT("Premature EOF in JPEG file"); + return (((unsigned int) c1) << 8) + ((unsigned int) c2); +} + + +/* + * JPEG markers consist of one or more 0xFF bytes, followed by a marker + * code byte (which is not an FF). Here are the marker codes of interest + * in this program. (See jdmarker.c for a more complete list.) + */ + +#define M_SOF0 0xC0 /* Start Of Frame N */ +#define M_SOF1 0xC1 /* N indicates which compression process */ +#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ +#define M_SOF3 0xC3 +#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ +#define M_SOF6 0xC6 +#define M_SOF7 0xC7 +#define M_SOF9 0xC9 +#define M_SOF10 0xCA +#define M_SOF11 0xCB +#define M_SOF13 0xCD +#define M_SOF14 0xCE +#define M_SOF15 0xCF +#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ +#define M_EOI 0xD9 /* End Of Image (end of datastream) */ +#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ +#define M_APP0 0xE0 /* Application-specific marker, type N */ +#define M_APP12 0xEC /* (we don't bother to list all 16 APPn's) */ +#define M_COM 0xFE /* COMment */ + + +/* + * Find the next JPEG marker and return its marker code. + * We expect at least one FF byte, possibly more if the compressor used FFs + * to pad the file. + * There could also be non-FF garbage between markers. The treatment of such + * garbage is unspecified; we choose to skip over it but emit a warning msg. + * NB: this routine must not be used after seeing SOS marker, since it will + * not deal correctly with FF/00 sequences in the compressed image data... + */ + +static int +next_marker (void) +{ + int c; + int discarded_bytes = 0; + + /* Find 0xFF byte; count and skip any non-FFs. */ + c = read_1_byte(); + while (c != 0xFF) { + discarded_bytes++; + c = read_1_byte(); + } + /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs + * are legal as pad bytes, so don't count them in discarded_bytes. + */ + do { + c = read_1_byte(); + } while (c == 0xFF); + + if (discarded_bytes != 0) { + fprintf(stderr, "Warning: garbage data found in JPEG file\n"); + } + + return c; +} + + +/* + * Read the initial marker, which should be SOI. + * For a JFIF file, the first two bytes of the file should be literally + * 0xFF M_SOI. To be more general, we could use next_marker, but if the + * input file weren't actually JPEG at all, next_marker might read the whole + * file and then return a misleading error message... + */ + +static int +first_marker (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + c2 = NEXTBYTE(); + if (c1 != 0xFF || c2 != M_SOI) + ERREXIT("Not a JPEG file"); + return c2; +} + + +/* + * Most types of marker are followed by a variable-length parameter segment. + * This routine skips over the parameters for any marker we don't otherwise + * want to process. + * Note that we MUST skip the parameter segment explicitly in order not to + * be fooled by 0xFF bytes that might appear within the parameter segment; + * such bytes do NOT introduce new markers. + */ + +static void +skip_variable (void) +/* Skip over an unknown or uninteresting variable-length marker */ +{ + unsigned int length; + + /* Get the marker parameter length count */ + length = read_2_bytes(); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + /* Skip over the remaining bytes */ + while (length > 0) { + (void) read_1_byte(); + length--; + } +} + + +/* + * Process a COM marker. + * We want to print out the marker contents as legible text; + * we must guard against non-text junk and varying newline representations. + */ + +static void +process_COM (int raw) +{ + unsigned int length; + int ch; + int lastch = 0; + + /* Bill Allombert: set locale properly for isprint */ +#ifdef HAVE_LOCALE_H + setlocale(LC_CTYPE, ""); +#endif + + /* Get the marker parameter length count */ + length = read_2_bytes(); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + + while (length > 0) { + ch = read_1_byte(); + if (raw) { + putc(ch, stdout); + /* Emit the character in a readable form. + * Nonprintables are converted to \nnn form, + * while \ is converted to \\. + * Newlines in CR, CR/LF, or LF form will be printed as one newline. + */ + } else if (ch == '\r') { + printf("\n"); + } else if (ch == '\n') { + if (lastch != '\r') + printf("\n"); + } else if (ch == '\\') { + printf("\\\\"); + } else if (isprint(ch)) { + putc(ch, stdout); + } else { + printf("\\%03o", ch); + } + lastch = ch; + length--; + } + printf("\n"); + + /* Bill Allombert: revert to C locale */ +#ifdef HAVE_LOCALE_H + setlocale(LC_CTYPE, "C"); +#endif +} + + +/* + * Process a SOFn marker. + * This code is only needed if you want to know the image dimensions... + */ + +static void +process_SOFn (int marker) +{ + unsigned int length; + unsigned int image_height, image_width; + int data_precision, num_components; + const char * process; + int ci; + + length = read_2_bytes(); /* usual parameter length count */ + + data_precision = read_1_byte(); + image_height = read_2_bytes(); + image_width = read_2_bytes(); + num_components = read_1_byte(); + + switch (marker) { + case M_SOF0: process = "Baseline"; break; + case M_SOF1: process = "Extended sequential"; break; + case M_SOF2: process = "Progressive"; break; + case M_SOF3: process = "Lossless"; break; + case M_SOF5: process = "Differential sequential"; break; + case M_SOF6: process = "Differential progressive"; break; + case M_SOF7: process = "Differential lossless"; break; + case M_SOF9: process = "Extended sequential, arithmetic coding"; break; + case M_SOF10: process = "Progressive, arithmetic coding"; break; + case M_SOF11: process = "Lossless, arithmetic coding"; break; + case M_SOF13: process = "Differential sequential, arithmetic coding"; break; + case M_SOF14: process = "Differential progressive, arithmetic coding"; break; + case M_SOF15: process = "Differential lossless, arithmetic coding"; break; + default: process = "Unknown"; break; + } + + printf("JPEG image is %uw * %uh, %d color components, %d bits per sample\n", + image_width, image_height, num_components, data_precision); + printf("JPEG process: %s\n", process); + + if (length != (unsigned int) (8 + num_components * 3)) + ERREXIT("Bogus SOF marker length"); + + for (ci = 0; ci < num_components; ci++) { + (void) read_1_byte(); /* Component ID code */ + (void) read_1_byte(); /* H, V sampling factors */ + (void) read_1_byte(); /* Quantization table number */ + } +} + + +/* + * Parse the marker stream until SOS or EOI is seen; + * display any COM markers. + * While the companion program wrjpgcom will always insert COM markers before + * SOFn, other implementations might not, so we scan to SOS before stopping. + * If we were only interested in the image dimensions, we would stop at SOFn. + * (Conversely, if we only cared about COM markers, there would be no need + * for special code to handle SOFn; we could treat it like other markers.) + */ + +static int +scan_JPEG_header (int verbose, int raw) +{ + int marker; + + /* Expect SOI at start of file */ + if (first_marker() != M_SOI) + ERREXIT("Expected SOI marker first"); + + /* Scan miscellaneous markers until we reach SOS. */ + for (;;) { + marker = next_marker(); + switch (marker) { + /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, + * treated as SOFn. C4 in particular is actually DHT. + */ + case M_SOF0: /* Baseline */ + case M_SOF1: /* Extended sequential, Huffman */ + case M_SOF2: /* Progressive, Huffman */ + case M_SOF3: /* Lossless, Huffman */ + case M_SOF5: /* Differential sequential, Huffman */ + case M_SOF6: /* Differential progressive, Huffman */ + case M_SOF7: /* Differential lossless, Huffman */ + case M_SOF9: /* Extended sequential, arithmetic */ + case M_SOF10: /* Progressive, arithmetic */ + case M_SOF11: /* Lossless, arithmetic */ + case M_SOF13: /* Differential sequential, arithmetic */ + case M_SOF14: /* Differential progressive, arithmetic */ + case M_SOF15: /* Differential lossless, arithmetic */ + if (verbose) + process_SOFn(marker); + else + skip_variable(); + break; + + case M_SOS: /* stop before hitting compressed data */ + return marker; + + case M_EOI: /* in case it's a tables-only JPEG stream */ + return marker; + + case M_COM: + process_COM(raw); + break; + + case M_APP12: + /* Some digital camera makers put useful textual information into + * APP12 markers, so we print those out too when in -verbose mode. + */ + if (verbose) { + printf("APP12 contains:\n"); + process_COM(raw); + } else + skip_variable(); + break; + + default: /* Anything else just gets skipped */ + skip_variable(); /* we assume it has a parameter count... */ + break; + } + } /* end loop */ +} + + +/* Command line parsing code */ + +static const char * progname; /* program name for error messages */ + + +static void +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "rdjpgcom displays any textual comments in a JPEG file.\n"); + + fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname); + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -raw Display non-printable characters in comments (unsafe)\n"); + fprintf(stderr, " -verbose Also display dimensions of JPEG image\n"); + + exit(EXIT_FAILURE); +} + + +static int +keymatch (char * arg, const char * keyword, int minchars) +/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ +/* keyword is the constant keyword (must be lower case already), */ +/* minchars is length of minimum legal abbreviation. */ +{ + register int ca, ck; + register int nmatched = 0; + + while ((ca = *arg++) != '\0') { + if ((ck = *keyword++) == '\0') + return 0; /* arg longer than keyword, no good */ + if (isupper(ca)) /* force arg to lcase (assume ck is already) */ + ca = tolower(ca); + if (ca != ck) + return 0; /* no good */ + nmatched++; /* count matched characters */ + } + /* reached end of argument; fail if it's too short for unique abbrev */ + if (nmatched < minchars) + return 0; + return 1; /* A-OK */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + int argn; + char * arg; + int verbose = 0, raw = 0; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "rdjpgcom"; /* in case C library doesn't provide it */ + + /* Parse switches, if any */ + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (arg[0] != '-') + break; /* not switch, must be file name */ + arg++; /* advance over '-' */ + if (keymatch(arg, "verbose", 1)) { + verbose++; + } else if (keymatch(arg, "raw", 1)) { + raw = 1; + } else + usage(); + } + + /* Open the input file. */ + /* Unix style: expect zero or one file name */ + if (argn < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } + if (argn < argc) { + if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdin), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open stdin\n", progname); + exit(EXIT_FAILURE); + } +#else + infile = stdin; +#endif + } + + /* Scan the JPEG headers. */ + (void) scan_JPEG_header(verbose, raw); + + /* All done. */ + exit(EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/thirdparty/jpeg-9e/rdppm.c b/thirdparty/jpeg-9e/rdppm.c new file mode 100644 index 0000000..ca63867 --- /dev/null +++ b/thirdparty/jpeg-9e/rdppm.c @@ -0,0 +1,501 @@ +/* + * rdppm.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * Modified 2009-2020 by Bill Allombert, Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in PPM/PGM format. + * The extended 2-byte-per-sample raw PPM/PGM formats are supported. + * The PBMPLUS library is NOT required to compile this software + * (but it is highly useful as a set of PPM image manipulation programs). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed PPM format). + */ + +/* Portions of this code are based on the PBMPLUS library, which is: +** +** Copyright (C) 1988 by Jef Poskanzer. +** +** Permission to use, copy, modify, and distribute this software and its +** documentation for any purpose and without fee is hereby granted, provided +** that the above copyright notice appear in all copies and that both that +** copyright notice and this permission notice appear in supporting +** documentation. This software is provided "as is" without express or +** implied warranty. +*/ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef PPM_SUPPORTED + + +/* Macros to deal with unsigned chars as efficiently as compiler allows */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char U_CHAR; +#define UCH(x) ((int) (x)) +#else /* !HAVE_UNSIGNED_CHAR */ +typedef char U_CHAR; +#ifdef CHAR_IS_UNSIGNED +#define UCH(x) ((int) (x)) +#else +#define UCH(x) ((int) (x) & 0xFF) +#endif +#endif /* HAVE_UNSIGNED_CHAR */ + + +#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) + + +/* + * On most systems, reading individual bytes with getc() is drastically less + * efficient than buffering a row at a time with fread(). On PCs, we must + * allocate the buffer in near data space, because we are assuming small-data + * memory model, wherein fread() can't reach far memory. If you need to + * process very wide images on a PC, you might have to compile in large-memory + * model, or else replace fread() with a getc() loop --- which will be much + * slower. + */ + + +/* Private version of data source object */ + +typedef struct { + struct cjpeg_source_struct pub; /* public fields */ + + /* Usually these two pointers point to the same place: */ + U_CHAR *iobuffer; /* fread's I/O buffer */ + JSAMPROW pixrow; /* compressor input buffer */ + size_t buffer_width; /* width of I/O buffer */ + JSAMPLE *rescale; /* => maxval-remapping array, or NULL */ + unsigned int maxval; +} ppm_source_struct; + +typedef ppm_source_struct * ppm_source_ptr; + + +LOCAL(int) +pbm_getc (FILE * infile) +/* Read next char, skipping over any comments */ +/* A comment/newline sequence is returned as a newline */ +{ + register int ch; + + ch = getc(infile); + if (ch == '#') { + do { + ch = getc(infile); + } while (ch != '\n' && ch != EOF); + } + return ch; +} + + +LOCAL(unsigned int) +read_pbm_integer (j_compress_ptr cinfo, FILE * infile) +/* Read an unsigned decimal integer from the PPM file */ +/* Swallows one trailing character after the integer */ +/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ +/* This should not be a problem in practice. */ +{ + register int ch; + register unsigned int val; + + /* Skip any leading whitespace */ + do { + ch = pbm_getc(infile); + if (ch == EOF) + ERREXIT(cinfo, JERR_INPUT_EOF); + } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); + + if (ch < '0' || ch > '9') + ERREXIT(cinfo, JERR_PPM_NONNUMERIC); + + val = ch - '0'; + while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { + val *= 10; + val += ch - '0'; + } + return val; +} + + +/* + * Read one row of pixels. + * + * We provide several different versions depending on input file format. + * In all cases, input is scaled to the size of JSAMPLE. + * + * A really fast path is provided for reading byte/sample raw files with + * maxval = MAXJSAMPLE, which is the normal case for 8-bit data. + */ + + +METHODDEF(JDIMENSION) +get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading text-format PGM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + FILE * infile = source->pub.input_file; + register JSAMPROW ptr; + register JSAMPLE *rescale = source->rescale; + unsigned int maxval = source->maxval; + JDIMENSION col; + + ptr = source->pixrow; + for (col = cinfo->image_width; col > 0; col--) { + register unsigned int temp; + temp = read_pbm_integer(cinfo, infile); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_text_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading text-format PPM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + FILE * infile = source->pub.input_file; + register JSAMPROW ptr; + register JSAMPLE *rescale = source->rescale; + unsigned int maxval = source->maxval; + JDIMENSION col; + + ptr = source->pixrow; + for (col = cinfo->image_width; col > 0; col--) { + register unsigned int temp; + temp = read_pbm_integer(cinfo, infile); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + temp = read_pbm_integer(cinfo, infile); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + temp = read_pbm_integer(cinfo, infile); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_scaled_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-byte-format PGM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + unsigned int maxval = source->maxval; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pixrow; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + register unsigned int temp; + temp = (unsigned int) UCH(*bufferptr++); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_scaled_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-byte-format PPM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + unsigned int maxval = source->maxval; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pixrow; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + register unsigned int temp; + temp = (unsigned int) UCH(*bufferptr++); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + temp = (unsigned int) UCH(*bufferptr++); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + temp = (unsigned int) UCH(*bufferptr++); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_raw_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE. + * In this case we just read right into the JSAMPLE buffer! + * Note that same code works for PPM and PGM files. + */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + return 1; +} + + +METHODDEF(JDIMENSION) +get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-word-format PGM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + unsigned int maxval = source->maxval; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pixrow; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + register unsigned int temp; + temp = ((unsigned int) UCH(*bufferptr++)) << 8; + temp |= (unsigned int) UCH(*bufferptr++); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-word-format PPM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + unsigned int maxval = source->maxval; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pixrow; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + register unsigned int temp; + temp = ((unsigned int) UCH(*bufferptr++)) << 8; + temp |= (unsigned int) UCH(*bufferptr++); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + temp = ((unsigned int) UCH(*bufferptr++)) << 8; + temp |= (unsigned int) UCH(*bufferptr++); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + temp = ((unsigned int) UCH(*bufferptr++)) << 8; + temp |= (unsigned int) UCH(*bufferptr++); + if (temp > maxval) + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + *ptr++ = rescale[temp]; + } + return 1; +} + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + int c; + unsigned int w, h, maxval; + boolean need_iobuffer, use_raw_buffer, need_rescale; + + if (getc(source->pub.input_file) != 'P') + ERREXIT(cinfo, JERR_PPM_NOT); + + c = getc(source->pub.input_file); /* subformat discriminator character */ + + /* detect unsupported variants (ie, PBM) before trying to read header */ + switch (c) { + case '2': /* it's a text-format PGM file */ + case '3': /* it's a text-format PPM file */ + case '5': /* it's a raw-format PGM file */ + case '6': /* it's a raw-format PPM file */ + break; + default: + ERREXIT(cinfo, JERR_PPM_NOT); + } + + /* fetch the remaining header info */ + w = read_pbm_integer(cinfo, source->pub.input_file); + h = read_pbm_integer(cinfo, source->pub.input_file); + maxval = read_pbm_integer(cinfo, source->pub.input_file); + + if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ + ERREXIT(cinfo, JERR_PPM_NOT); + + if (((long) w >> 24) || /* sanity check for buffer allocation below */ + ((long) maxval >> 16)) /* support max 16-bit (2-byte) sample values */ + ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); + + cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ + cinfo->image_width = (JDIMENSION) w; + cinfo->image_height = (JDIMENSION) h; + source->maxval = maxval; + + /* initialize flags to most common settings */ + need_iobuffer = TRUE; /* do we need an I/O buffer? */ + use_raw_buffer = FALSE; /* do we map input buffer onto I/O buffer? */ + need_rescale = TRUE; /* do we need a rescale array? */ + + switch (c) { + case '2': /* it's a text-format PGM file */ + cinfo->input_components = 1; + cinfo->in_color_space = JCS_GRAYSCALE; + TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h); + source->pub.get_pixel_rows = get_text_gray_row; + need_iobuffer = FALSE; + break; + + case '3': /* it's a text-format PPM file */ + cinfo->input_components = 3; + cinfo->in_color_space = JCS_RGB; + TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h); + source->pub.get_pixel_rows = get_text_rgb_row; + need_iobuffer = FALSE; + break; + + case '5': /* it's a raw-format PGM file */ + cinfo->input_components = 1; + cinfo->in_color_space = JCS_GRAYSCALE; + TRACEMS2(cinfo, 1, JTRC_PGM, w, h); + if (maxval > 255) { + source->pub.get_pixel_rows = get_word_gray_row; + } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { + source->pub.get_pixel_rows = get_raw_row; + use_raw_buffer = TRUE; + need_rescale = FALSE; + } else { + source->pub.get_pixel_rows = get_scaled_gray_row; + } + break; + + case '6': /* it's a raw-format PPM file */ + cinfo->input_components = 3; + cinfo->in_color_space = JCS_RGB; + TRACEMS2(cinfo, 1, JTRC_PPM, w, h); + if (maxval > 255) { + source->pub.get_pixel_rows = get_word_rgb_row; + } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { + source->pub.get_pixel_rows = get_raw_row; + use_raw_buffer = TRUE; + need_rescale = FALSE; + } else { + source->pub.get_pixel_rows = get_scaled_rgb_row; + } + break; + } + + /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */ + if (need_iobuffer) { + source->buffer_width = (size_t) w * (size_t) cinfo->input_components * + ((maxval <= 255) ? SIZEOF(U_CHAR) : (2 * SIZEOF(U_CHAR))); + source->iobuffer = (U_CHAR *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, source->buffer_width); + } + + /* Create compressor input buffer. */ + if (use_raw_buffer) { + /* For unscaled raw-input case, we can just map it onto the I/O buffer. */ + /* Cast here implies near->far pointer conversion on PCs */ + source->pixrow = (JSAMPROW) source->iobuffer; + } else { + /* Need to translate anyway, so make a separate sample buffer. */ + source->pixrow = (JSAMPROW) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (size_t) w * + (size_t) cinfo->input_components * SIZEOF(JSAMPLE)); + } + /* Synthesize a JSAMPARRAY pointer structure */ + source->pub.buffer = & source->pixrow; + source->pub.buffer_height = 1; + + /* Compute the rescaling array if required. */ + if (need_rescale) { + INT32 val, half_maxval; + + /* On 16-bit-int machines we have to be careful of maxval = 65535 */ + source->rescale = (JSAMPLE *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, + JPOOL_IMAGE, ((size_t) maxval + (size_t) 1) * SIZEOF(JSAMPLE)); + half_maxval = maxval / 2; + for (val = 0; val <= (INT32) maxval; val++) { + /* The multiplication here must be done in 32 bits to avoid overflow */ + source->rescale[val] = (JSAMPLE) ((val * MAXJSAMPLE + half_maxval) / maxval); + } + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for PPM format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_ppm (j_compress_ptr cinfo) +{ + ppm_source_ptr source; + + /* Create module interface object */ + source = (ppm_source_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(ppm_source_struct)); + /* Fill in method ptrs, except get_pixel_rows which start_input sets */ + source->pub.start_input = start_input_ppm; + source->pub.finish_input = finish_input_ppm; + + return &source->pub; +} + +#endif /* PPM_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/rdrle.c b/thirdparty/jpeg-9e/rdrle.c new file mode 100644 index 0000000..06f2e8a --- /dev/null +++ b/thirdparty/jpeg-9e/rdrle.c @@ -0,0 +1,380 @@ +/* + * rdrle.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in Utah RLE format. + * The Utah Raster Toolkit library is required (version 3.1 or later). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed RLE format). + * + * Based on code contributed by Mike Lijewski, + * with updates from Robert Hutchinson. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef RLE_SUPPORTED + +/* rle.h is provided by the Utah Raster Toolkit. */ + +#include + +/* + * We assume that JSAMPLE has the same representation as rle_pixel, + * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + +/* + * We support the following types of RLE files: + * + * GRAYSCALE - 8 bits, no colormap + * MAPPEDGRAY - 8 bits, 1 channel colomap + * PSEUDOCOLOR - 8 bits, 3 channel colormap + * TRUECOLOR - 24 bits, 3 channel colormap + * DIRECTCOLOR - 24 bits, no colormap + * + * For now, we ignore any alpha channel in the image. + */ + +typedef enum + { GRAYSCALE, MAPPEDGRAY, PSEUDOCOLOR, TRUECOLOR, DIRECTCOLOR } rle_kind; + + +/* + * Since RLE stores scanlines bottom-to-top, we have to invert the image + * to conform to JPEG's top-to-bottom order. To do this, we read the + * incoming image into a virtual array on the first get_pixel_rows call, + * then fetch the required row from the virtual array on subsequent calls. + */ + +typedef struct _rle_source_struct * rle_source_ptr; + +typedef struct _rle_source_struct { + struct cjpeg_source_struct pub; /* public fields */ + + rle_kind visual; /* actual type of input file */ + jvirt_sarray_ptr image; /* virtual array to hold the image */ + JDIMENSION row; /* current row # in the virtual array */ + rle_hdr header; /* Input file information */ + rle_pixel **rle_row; /* holds a row returned by rle_getrow() */ + +} rle_source_struct; + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + JDIMENSION width, height; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + /* Use RLE library routine to get the header info */ + source->header = *rle_hdr_init(NULL); + source->header.rle_file = source->pub.input_file; + switch (rle_get_setup(&(source->header))) { + case RLE_SUCCESS: + /* A-OK */ + break; + case RLE_NOT_RLE: + ERREXIT(cinfo, JERR_RLE_NOT); + case RLE_NO_SPACE: + ERREXIT(cinfo, JERR_RLE_MEM); + case RLE_EMPTY: + ERREXIT(cinfo, JERR_RLE_EMPTY); + case RLE_EOF: + ERREXIT(cinfo, JERR_RLE_EOF); + default: + ERREXIT(cinfo, JERR_RLE_BADERROR); + } + + /* Figure out what we have, set private vars and return values accordingly */ + + width = source->header.xmax - source->header.xmin + 1; + height = source->header.ymax - source->header.ymin + 1; + source->header.xmin = 0; /* realign horizontally */ + source->header.xmax = width-1; + + cinfo->image_width = width; + cinfo->image_height = height; + cinfo->data_precision = 8; /* we can only handle 8 bit data */ + + if (source->header.ncolors == 1 && source->header.ncmap == 0) { + source->visual = GRAYSCALE; + TRACEMS2(cinfo, 1, JTRC_RLE_GRAY, width, height); + } else if (source->header.ncolors == 1 && source->header.ncmap == 1) { + source->visual = MAPPEDGRAY; + TRACEMS3(cinfo, 1, JTRC_RLE_MAPGRAY, width, height, + 1 << source->header.cmaplen); + } else if (source->header.ncolors == 1 && source->header.ncmap == 3) { + source->visual = PSEUDOCOLOR; + TRACEMS3(cinfo, 1, JTRC_RLE_MAPPED, width, height, + 1 << source->header.cmaplen); + } else if (source->header.ncolors == 3 && source->header.ncmap == 3) { + source->visual = TRUECOLOR; + TRACEMS3(cinfo, 1, JTRC_RLE_FULLMAP, width, height, + 1 << source->header.cmaplen); + } else if (source->header.ncolors == 3 && source->header.ncmap == 0) { + source->visual = DIRECTCOLOR; + TRACEMS2(cinfo, 1, JTRC_RLE, width, height); + } else + ERREXIT(cinfo, JERR_RLE_UNSUPPORTED); + + if (source->visual == GRAYSCALE || source->visual == MAPPEDGRAY) { + cinfo->in_color_space = JCS_GRAYSCALE; + cinfo->input_components = 1; + } else { + cinfo->in_color_space = JCS_RGB; + cinfo->input_components = 3; + } + + /* + * A place to hold each scanline while it's converted. + * (GRAYSCALE scanlines don't need converting) + */ + if (source->visual != GRAYSCALE) { + source->rle_row = (rle_pixel **) (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + width, (JDIMENSION) cinfo->input_components); + } + + /* request a virtual array to hold the image */ + source->image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + width * (JDIMENSION) source->header.ncolors, height, (JDIMENSION) 1); + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + /* count file input as separate pass */ + progress->total_extra_passes++; + } +#endif + + source->pub.buffer_height = 1; +} + + +/* + * Read one row of pixels. + * Called only after load_image has read the image into the virtual array. + * Used for GRAYSCALE, MAPPEDGRAY, TRUECOLOR, and DIRECTCOLOR images. + */ + +METHODDEF(JDIMENSION) +get_rle_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + + source->row--; + source->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); + + return 1; +} + +/* + * Read one row of pixels. + * Called only after load_image has read the image into the virtual array. + * Used for PSEUDOCOLOR images. + */ + +METHODDEF(JDIMENSION) +get_pseudocolor_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + JSAMPROW src_row, dest_row; + JDIMENSION col; + rle_map *colormap; + int val; + + colormap = source->header.cmap; + dest_row = source->pub.buffer[0]; + source->row--; + src_row = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); + + for (col = cinfo->image_width; col > 0; col--) { + val = GETJSAMPLE(*src_row++); + *dest_row++ = (JSAMPLE) (colormap[val ] >> 8); + *dest_row++ = (JSAMPLE) (colormap[val + 256] >> 8); + *dest_row++ = (JSAMPLE) (colormap[val + 512] >> 8); + } + + return 1; +} + + +/* + * Load the image into a virtual array. We have to do this because RLE + * files start at the lower left while the JPEG standard has them starting + * in the upper left. This is called the first time we want to get a row + * of input. What we do is load the RLE data into the array and then call + * the appropriate routine to read one row from the array. Before returning, + * we set source->pub.get_pixel_rows so that subsequent calls go straight to + * the appropriate row-reading routine. + */ + +METHODDEF(JDIMENSION) +load_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + JDIMENSION row, col; + JSAMPROW scanline, red_ptr, green_ptr, blue_ptr; + rle_pixel **rle_row; + rle_map *colormap; + char channel; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + /* Read the RLE data into our virtual array. + * We assume here that (a) rle_pixel is represented the same as JSAMPLE, + * and (b) we are not on a machine where FAR pointers differ from regular. + */ + RLE_CLR_BIT(source->header, RLE_ALPHA); /* don't read the alpha channel */ + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_limit = cinfo->image_height; + progress->pub.pass_counter = 0; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + + switch (source->visual) { + + case GRAYSCALE: + case PSEUDOCOLOR: + for (row = 0; row < cinfo->image_height; row++) { + rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); + rle_getrow(&source->header, rle_row); +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + break; + + case MAPPEDGRAY: + case TRUECOLOR: + rle_row = source->rle_row; + colormap = source->header.cmap; + for (row = 0; row < cinfo->image_height; row++) { + rle_getrow(&source->header, rle_row); + scanline = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); + + for (col = 0; col < cinfo->image_width; col++) { + for (channel = 0; channel < source->header.ncolors; channel++) { + *scanline++ = (JSAMPLE) + (colormap[GETJSAMPLE(rle_row[channel][col]) + 256 * channel] >> 8); + } + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + break; + + case DIRECTCOLOR: + rle_row = source->rle_row; + for (row = 0; row < cinfo->image_height; row++) { + rle_getrow(&source->header, rle_row); + scanline = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); + + red_ptr = rle_row[0]; + green_ptr = rle_row[1]; + blue_ptr = rle_row[2]; + + for (col = cinfo->image_width; col > 0; col--) { + *scanline++ = *red_ptr++; + *scanline++ = *green_ptr++; + *scanline++ = *blue_ptr++; + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) + progress->completed_extra_passes++; +#endif + + /* Set up to call proper row-extraction routine in future */ + if (source->visual == PSEUDOCOLOR) { + source->pub.buffer = source->rle_row; + source->pub.get_pixel_rows = get_pseudocolor_row; + } else { + source->pub.get_pixel_rows = get_rle_row; + } + source->row = cinfo->image_height; + + /* And fetch the topmost (bottommost) row */ + return (*source->pub.get_pixel_rows) (cinfo, sinfo); +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for RLE format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_rle (j_compress_ptr cinfo) +{ + rle_source_ptr source; + + /* Create module interface object */ + source = (rle_source_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(rle_source_struct)); + /* Fill in method ptrs */ + source->pub.start_input = start_input_rle; + source->pub.finish_input = finish_input_rle; + source->pub.get_pixel_rows = load_image; + + return &source->pub; +} + +#endif /* RLE_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/rdswitch.c b/thirdparty/jpeg-9e/rdswitch.c new file mode 100644 index 0000000..8a6675d --- /dev/null +++ b/thirdparty/jpeg-9e/rdswitch.c @@ -0,0 +1,363 @@ +/* + * rdswitch.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2003-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to process some of cjpeg's more complicated + * command-line switches. Switches processed here are: + * -qtables file Read quantization tables from text file + * -scans file Read scan script from text file + * -quality N[,N,...] Set quality ratings + * -qslots N[,N,...] Set component quantization table selectors + * -sample HxV[,HxV,...] Set component sampling factors + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include /* to declare isdigit(), isspace() */ + + +LOCAL(int) +text_getc (FILE * file) +/* Read next char, skipping over any comments (# to end of line) */ +/* A comment/newline sequence is returned as a newline */ +{ + register int ch; + + ch = getc(file); + if (ch == '#') { + do { + ch = getc(file); + } while (ch != '\n' && ch != EOF); + } + return ch; +} + + +LOCAL(boolean) +read_text_integer (FILE * file, long * result, int * termchar) +/* Read an unsigned decimal integer from a file, store it in result */ +/* Reads one trailing character after the integer; returns it in termchar */ +{ + register int ch; + register long val; + + /* Skip any leading whitespace, detect EOF */ + do { + ch = text_getc(file); + if (ch == EOF) { + *termchar = ch; + return FALSE; + } + } while (isspace(ch)); + + if (! isdigit(ch)) { + *termchar = ch; + return FALSE; + } + + val = ch - '0'; + while ((ch = text_getc(file)) != EOF) { + if (! isdigit(ch)) + break; + val *= 10; + val += ch - '0'; + } + *result = val; + *termchar = ch; + return TRUE; +} + + +GLOBAL(boolean) +read_quant_tables (j_compress_ptr cinfo, char * filename, boolean force_baseline) +/* Read a set of quantization tables from the specified file. + * The file is plain ASCII text: decimal numbers with whitespace between. + * Comments preceded by '#' may be included in the file. + * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values. + * The tables are implicitly numbered 0,1,etc. + * NOTE: does not affect the qslots mapping, which will default to selecting + * table 0 for luminance (or primary) components, 1 for chrominance components. + * You must use -qslots if you want a different component->table mapping. + */ +{ + FILE * fp; + int tblno, i, termchar; + long val; + unsigned int table[DCTSIZE2]; + + if ((fp = fopen(filename, "r")) == NULL) { + fprintf(stderr, "Can't open table file %s\n", filename); + return FALSE; + } + tblno = 0; + + while (read_text_integer(fp, &val, &termchar)) { /* read 1st element of table */ + if (tblno >= NUM_QUANT_TBLS) { + fprintf(stderr, "Too many tables in file %s\n", filename); + fclose(fp); + return FALSE; + } + table[0] = (unsigned int) val; + for (i = 1; i < DCTSIZE2; i++) { + if (! read_text_integer(fp, &val, &termchar)) { + fprintf(stderr, "Invalid table data in file %s\n", filename); + fclose(fp); + return FALSE; + } + table[i] = (unsigned int) val; + } + jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno], + force_baseline); + tblno++; + } + + if (termchar != EOF) { + fprintf(stderr, "Non-numeric data in file %s\n", filename); + fclose(fp); + return FALSE; + } + + fclose(fp); + return TRUE; +} + + +#ifdef C_MULTISCAN_FILES_SUPPORTED + +LOCAL(boolean) +read_scan_integer (FILE * file, long * result, int * termchar) +/* Variant of read_text_integer that always looks for a non-space termchar; + * this simplifies parsing of punctuation in scan scripts. + */ +{ + register int ch; + + if (! read_text_integer(file, result, termchar)) + return FALSE; + ch = *termchar; + while (ch != EOF && isspace(ch)) + ch = text_getc(file); + if (isdigit(ch)) { /* oops, put it back */ + if (ungetc(ch, file) == EOF) + return FALSE; + ch = ' '; + } else { + /* Any separators other than ';' and ':' are ignored; + * this allows user to insert commas, etc, if desired. + */ + if (ch != EOF && ch != ';' && ch != ':') + ch = ' '; + } + *termchar = ch; + return TRUE; +} + + +GLOBAL(boolean) +read_scan_script (j_compress_ptr cinfo, char * filename) +/* Read a scan script from the specified text file. + * Each entry in the file defines one scan to be emitted. + * Entries are separated by semicolons ';'. + * An entry contains one to four component indexes, + * optionally followed by a colon ':' and four progressive-JPEG parameters. + * The component indexes denote which component(s) are to be transmitted + * in the current scan. The first component has index 0. + * Sequential JPEG is used if the progressive-JPEG parameters are omitted. + * The file is free format text: any whitespace may appear between numbers + * and the ':' and ';' punctuation marks. Also, other punctuation (such + * as commas or dashes) can be placed between numbers if desired. + * Comments preceded by '#' may be included in the file. + * Note: we do very little validity checking here; + * jcmaster.c will validate the script parameters. + */ +{ + FILE * fp; + int scanno, ncomps, termchar; + long val; + jpeg_scan_info * scanptr; +#define MAX_SCANS 100 /* quite arbitrary limit */ + jpeg_scan_info scans[MAX_SCANS]; + + if ((fp = fopen(filename, "r")) == NULL) { + fprintf(stderr, "Can't open scan definition file %s\n", filename); + return FALSE; + } + scanptr = scans; + scanno = 0; + + while (read_scan_integer(fp, &val, &termchar)) { + if (scanno >= MAX_SCANS) { + fprintf(stderr, "Too many scans defined in file %s\n", filename); + fclose(fp); + return FALSE; + } + scanptr->component_index[0] = (int) val; + ncomps = 1; + while (termchar == ' ') { + if (ncomps >= MAX_COMPS_IN_SCAN) { + fprintf(stderr, "Too many components in one scan in file %s\n", + filename); + fclose(fp); + return FALSE; + } + if (! read_scan_integer(fp, &val, &termchar)) + goto bogus; + scanptr->component_index[ncomps] = (int) val; + ncomps++; + } + scanptr->comps_in_scan = ncomps; + if (termchar == ':') { + if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') + goto bogus; + scanptr->Ss = (int) val; + if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') + goto bogus; + scanptr->Se = (int) val; + if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') + goto bogus; + scanptr->Ah = (int) val; + if (! read_scan_integer(fp, &val, &termchar)) + goto bogus; + scanptr->Al = (int) val; + } else { + /* set non-progressive parameters */ + scanptr->Ss = 0; + scanptr->Se = DCTSIZE2-1; + scanptr->Ah = 0; + scanptr->Al = 0; + } + if (termchar != ';' && termchar != EOF) { +bogus: + fprintf(stderr, "Invalid scan entry format in file %s\n", filename); + fclose(fp); + return FALSE; + } + scanptr++, scanno++; + } + + if (termchar != EOF) { + fprintf(stderr, "Non-numeric data in file %s\n", filename); + fclose(fp); + return FALSE; + } + + if (scanno > 0) { + /* Stash completed scan list in cinfo structure. + * NOTE: for cjpeg's use, JPOOL_IMAGE is the right lifetime for this data, + * but if you want to compress multiple images you'd want JPOOL_PERMANENT. + */ + scanptr = (jpeg_scan_info *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, scanno * SIZEOF(jpeg_scan_info)); + MEMCOPY(scanptr, scans, scanno * SIZEOF(jpeg_scan_info)); + cinfo->scan_info = scanptr; + cinfo->num_scans = scanno; + } + + fclose(fp); + return TRUE; +} + +#endif /* C_MULTISCAN_FILES_SUPPORTED */ + + +GLOBAL(boolean) +set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline) +/* Process a quality-ratings parameter string, of the form + * N[,N,...] + * If there are more q-table slots than parameters, the last value is replicated. + */ +{ + int val = 75; /* default value */ + int tblno; + char ch; + + for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { + if (*arg) { + ch = ','; /* if not set by sscanf, will be ',' */ + if (sscanf(arg, "%d%c", &val, &ch) < 1) + return FALSE; + if (ch != ',') /* syntax check */ + return FALSE; + /* Convert user 0-100 rating to percentage scaling */ + cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val); + while (*arg && *arg++ != ','); /* advance to next segment of arg string */ + } else { + /* reached end of parameter, set remaining factors to last value */ + cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val); + } + } + jpeg_default_qtables(cinfo, force_baseline); + return TRUE; +} + + +GLOBAL(boolean) +set_quant_slots (j_compress_ptr cinfo, char *arg) +/* Process a quantization-table-selectors parameter string, of the form + * N[,N,...] + * If there are more components than parameters, the last value is replicated. + */ +{ + int val = 0; /* default table # */ + int ci; + char ch; + + for (ci = 0; ci < MAX_COMPONENTS; ci++) { + if (*arg) { + ch = ','; /* if not set by sscanf, will be ',' */ + if (sscanf(arg, "%d%c", &val, &ch) < 1) + return FALSE; + if (ch != ',') /* syntax check */ + return FALSE; + if (val < 0 || val >= NUM_QUANT_TBLS) { + fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n", + NUM_QUANT_TBLS-1); + return FALSE; + } + cinfo->comp_info[ci].quant_tbl_no = val; + while (*arg && *arg++ != ','); /* advance to next segment of arg string */ + } else { + /* reached end of parameter, set remaining components to last table */ + cinfo->comp_info[ci].quant_tbl_no = val; + } + } + return TRUE; +} + + +GLOBAL(boolean) +set_sample_factors (j_compress_ptr cinfo, char *arg) +/* Process a sample-factors parameter string, of the form + * HxV[,HxV,...] + * If there are more components than parameters, "1x1" is assumed for the rest. + */ +{ + int ci, val1, val2; + char ch1, ch2; + + for (ci = 0; ci < MAX_COMPONENTS; ci++) { + if (*arg) { + ch2 = ','; /* if not set by sscanf, will be ',' */ + if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3) + return FALSE; + if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */ + return FALSE; + if (val1 <= 0 || val1 > MAX_SAMP_FACTOR || + val2 <= 0 || val2 > MAX_SAMP_FACTOR) { + fprintf(stderr, "JPEG sampling factors must be 1..%d\n", MAX_SAMP_FACTOR); + return FALSE; + } + cinfo->comp_info[ci].h_samp_factor = val1; + cinfo->comp_info[ci].v_samp_factor = val2; + while (*arg && *arg++ != ','); /* advance to next segment of arg string */ + } else { + /* reached end of parameter, set remaining components to 1x1 sampling */ + cinfo->comp_info[ci].h_samp_factor = 1; + cinfo->comp_info[ci].v_samp_factor = 1; + } + } + return TRUE; +} diff --git a/thirdparty/jpeg-9e/rdtarga.c b/thirdparty/jpeg-9e/rdtarga.c new file mode 100644 index 0000000..c72ad73 --- /dev/null +++ b/thirdparty/jpeg-9e/rdtarga.c @@ -0,0 +1,500 @@ +/* + * rdtarga.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2017-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in Targa format. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed Targa format). + * + * Based on code contributed by Lee Daniel Crocker. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef TARGA_SUPPORTED + + +/* Macros to deal with unsigned chars as efficiently as compiler allows */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char U_CHAR; +#define UCH(x) ((int) (x)) +#else /* !HAVE_UNSIGNED_CHAR */ +typedef char U_CHAR; +#ifdef CHAR_IS_UNSIGNED +#define UCH(x) ((int) (x)) +#else +#define UCH(x) ((int) (x) & 0xFF) +#endif +#endif /* HAVE_UNSIGNED_CHAR */ + + +#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) + + +/* Private version of data source object */ + +typedef struct _tga_source_struct * tga_source_ptr; + +typedef struct _tga_source_struct { + struct cjpeg_source_struct pub; /* public fields */ + + j_compress_ptr cinfo; /* back link saves passing separate parm */ + + JSAMPARRAY colormap; /* Targa colormap (converted to my format) */ + + jvirt_sarray_ptr whole_image; /* Needed if funny input row order */ + JDIMENSION current_row; /* Current logical row number to read */ + + /* Pointer to routine to extract next Targa pixel from input file */ + JMETHOD(void, read_pixel, (tga_source_ptr sinfo)); + + /* Result of read_pixel is delivered here: */ + U_CHAR tga_pixel[4]; + + int pixel_size; /* Bytes per Targa pixel (1 to 4) */ + int cmap_length; /* colormap length */ + + /* State info for reading RLE-coded pixels; both counts must be init to 0 */ + int block_count; /* # of pixels remaining in RLE block */ + int dup_pixel_count; /* # of times to duplicate previous pixel */ + + /* This saves the correct pixel-row-expansion method for preload_image */ + JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); +} tga_source_struct; + + +/* For expanding 5-bit pixel values to 8-bit with best rounding */ + +static const UINT8 c5to8bits[32] = { + 0, 8, 16, 25, 33, 41, 49, 58, + 66, 74, 82, 90, 99, 107, 115, 123, + 132, 140, 148, 156, 165, 173, 181, 189, + 197, 206, 214, 222, 230, 239, 247, 255 +}; + + + +LOCAL(int) +read_byte (tga_source_ptr sinfo) +/* Read next byte from Targa file */ +{ + register FILE *infile = sinfo->pub.input_file; + register int c; + + if ((c = getc(infile)) == EOF) + ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); + return c; +} + + +LOCAL(void) +read_colormap (tga_source_ptr sinfo, int cmaplen, int mapentrysize) +/* Read the colormap from a Targa file */ +{ + int i; + + /* Presently only handles 24-bit BGR format */ + if (mapentrysize != 24) + ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP); + + for (i = 0; i < cmaplen; i++) { + sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); + } +} + + +/* + * read_pixel methods: get a single pixel from Targa file into tga_pixel[] + */ + +METHODDEF(void) +read_non_rle_pixel (tga_source_ptr sinfo) +/* Read one Targa pixel from the input file; no RLE expansion */ +{ + register int i; + + for (i = 0; i < sinfo->pixel_size; i++) { + sinfo->tga_pixel[i] = (U_CHAR) read_byte(sinfo); + } +} + +METHODDEF(void) +read_rle_pixel (tga_source_ptr sinfo) +/* Read one Targa pixel from the input file, expanding RLE data as needed */ +{ + register int i; + + /* Duplicate previously read pixel? */ + if (sinfo->dup_pixel_count > 0) { + sinfo->dup_pixel_count--; + return; + } + + /* Time to read RLE block header? */ + if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */ + i = read_byte(sinfo); + if (i & 0x80) { /* Start of duplicate-pixel block? */ + sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */ + sinfo->block_count = 0; /* then read new block header */ + } else { + sinfo->block_count = i & 0x7F; /* number of pixels after this one */ + } + } + + /* Read next pixel */ + for (i = 0; i < sinfo->pixel_size; i++) { + sinfo->tga_pixel[i] = (U_CHAR) read_byte(sinfo); + } +} + + +/* + * Read one row of pixels. + * + * We provide several different versions depending on input file format. + */ + +METHODDEF(JDIMENSION) +get_8bit_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 8-bit grayscale pixels */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); + } + return 1; +} + +METHODDEF(JDIMENSION) +get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 8-bit colormap indexes */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register JSAMPROW ptr; + register JSAMPARRAY colormap; + register JDIMENSION col; + register int t; + int cmaplen; + + ptr = source->pub.buffer[0]; + colormap = source->colormap; + cmaplen = source->cmap_length; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + t = UCH(source->tga_pixel[0]); + if (t >= cmaplen) + ERREXIT(cinfo, JERR_TGA_BADPARMS); + *ptr++ = colormap[0][t]; + *ptr++ = colormap[1][t]; + *ptr++ = colormap[2][t]; + } + return 1; +} + +METHODDEF(JDIMENSION) +get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 16-bit pixels */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register int t; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + t = UCH(source->tga_pixel[0]); + t += UCH(source->tga_pixel[1]) << 8; + /* We expand 5 bit data to 8 bit sample width. + * The format of the 16-bit (LSB first) input word is + * xRRRRRGGGGGBBBBB + */ + ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F]; + t >>= 5; + ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F]; + t >>= 5; + ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F]; + ptr += 3; + } + return 1; +} + +METHODDEF(JDIMENSION) +get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 24-bit pixels */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[2]); /* change BGR to RGB order */ + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[1]); + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); + } + return 1; +} + +/* + * Targa also defines a 32-bit pixel format with order B,G,R,A. + * We presently ignore the attribute byte, so the code for reading + * these pixels is identical to the 24-bit routine above. + * This works because the actual pixel length is only known to read_pixel. + */ + +#define get_32bit_row get_24bit_row + + +/* + * This method is for re-reading the input data in standard top-down + * row order. The entire image has already been read into whole_image + * with proper conversion of pixel format, but it's in a funny row order. + */ + +METHODDEF(JDIMENSION) +get_memory_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + JDIMENSION source_row; + + /* Compute row of source that maps to current_row of normal order */ + /* For now, assume image is bottom-up and not interlaced. */ + /* NEEDS WORK to support interlaced images! */ + source_row = cinfo->image_height - source->current_row - 1; + + /* Fetch that row from virtual array */ + source->pub.buffer = (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, + source->whole_image, source_row, (JDIMENSION) 1, FALSE); + + source->current_row++; + return 1; +} + + +/* + * This method loads the image into whole_image during the first call on + * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call + * get_memory_row on subsequent calls. + */ + +METHODDEF(JDIMENSION) +preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + JDIMENSION row; + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + + /* Read the data into a virtual array in input-file row order. */ + for (row = 0; row < cinfo->image_height; row++) { + if (progress != NULL) { + progress->pub.pass_counter = (long) row; + progress->pub.pass_limit = (long) cinfo->image_height; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } + source->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->whole_image, row, (JDIMENSION) 1, TRUE); + (*source->get_pixel_rows) (cinfo, sinfo); + } + if (progress != NULL) + progress->completed_extra_passes++; + + /* Set up to read from the virtual array in unscrambled order */ + source->pub.get_pixel_rows = get_memory_row; + source->current_row = 0; + /* And read the first row */ + return get_memory_row(cinfo, sinfo); +} + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + U_CHAR targaheader[18]; + int idlen, cmaptype, subtype, flags, interlace_type, components; + unsigned int width, height, maplen; + boolean is_bottom_up; + +#define GET_2B(offset) ((unsigned int) UCH(targaheader[offset]) + \ + (((unsigned int) UCH(targaheader[offset+1])) << 8)) + + if (! ReadOK(source->pub.input_file, targaheader, 18)) + ERREXIT(cinfo, JERR_INPUT_EOF); + + /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */ + if (targaheader[16] == 15) + targaheader[16] = 16; + + idlen = UCH(targaheader[0]); + cmaptype = UCH(targaheader[1]); + subtype = UCH(targaheader[2]); + maplen = GET_2B(5); + width = GET_2B(12); + height = GET_2B(14); + source->pixel_size = UCH(targaheader[16]) >> 3; + flags = UCH(targaheader[17]); /* Image Descriptor byte */ + + is_bottom_up = ((flags & 0x20) == 0); /* bit 5 set => top-down */ + interlace_type = flags >> 6; /* bits 6/7 are interlace code */ + + if (cmaptype > 1 || /* cmaptype must be 0 or 1 */ + width <= 0 || height <= 0 || + source->pixel_size < 1 || source->pixel_size > 4 || + (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */ + interlace_type != 0) /* currently don't allow interlaced image */ + ERREXIT(cinfo, JERR_TGA_BADPARMS); + + if (subtype > 8) { + /* It's an RLE-coded file */ + source->read_pixel = read_rle_pixel; + source->block_count = source->dup_pixel_count = 0; + subtype -= 8; + } else { + /* Non-RLE file */ + source->read_pixel = read_non_rle_pixel; + } + + /* Now should have subtype 1, 2, or 3 */ + components = 3; /* until proven different */ + cinfo->in_color_space = JCS_RGB; + + switch (subtype) { + case 1: /* Colormapped image */ + if (source->pixel_size == 1 && cmaptype == 1) + source->get_pixel_rows = get_8bit_row; + else + ERREXIT(cinfo, JERR_TGA_BADPARMS); + TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height); + break; + case 2: /* RGB image */ + switch (source->pixel_size) { + case 2: + source->get_pixel_rows = get_16bit_row; + break; + case 3: + source->get_pixel_rows = get_24bit_row; + break; + case 4: + source->get_pixel_rows = get_32bit_row; + break; + default: + ERREXIT(cinfo, JERR_TGA_BADPARMS); + } + TRACEMS2(cinfo, 1, JTRC_TGA, width, height); + break; + case 3: /* Grayscale image */ + components = 1; + cinfo->in_color_space = JCS_GRAYSCALE; + if (source->pixel_size == 1) + source->get_pixel_rows = get_8bit_gray_row; + else + ERREXIT(cinfo, JERR_TGA_BADPARMS); + TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height); + break; + default: + ERREXIT(cinfo, JERR_TGA_BADPARMS); + } + + if (is_bottom_up) { + /* Create a virtual array to buffer the upside-down image. */ + source->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1); + if (cinfo->progress != NULL) { + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + progress->total_extra_passes++; /* count file input as separate pass */ + } + /* source->pub.buffer will point to the virtual array. */ + source->pub.buffer_height = 1; /* in case anyone looks at it */ + source->pub.get_pixel_rows = preload_image; + } else { + /* Don't need a virtual array, but do need a one-row input buffer. */ + source->whole_image = NULL; + source->pub.buffer = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, + JPOOL_IMAGE, (JDIMENSION) width * components, (JDIMENSION) 1); + source->pub.buffer_height = 1; + source->pub.get_pixel_rows = source->get_pixel_rows; + } + + while (idlen--) /* Throw away ID field */ + (void) read_byte(source); + + if (maplen > 0) { + if (maplen > 256 || GET_2B(3) != 0) + ERREXIT(cinfo, JERR_TGA_BADCMAP); + /* Allocate space to store the colormap */ + source->colormap = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, + JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3); + source->cmap_length = (int) maplen; + /* and read it from the file */ + read_colormap(source, (int) maplen, UCH(targaheader[7])); + } else { + if (cmaptype) /* but you promised a cmap! */ + ERREXIT(cinfo, JERR_TGA_BADPARMS); + source->colormap = NULL; + source->cmap_length = 0; + } + + cinfo->input_components = components; + cinfo->data_precision = 8; + cinfo->image_width = width; + cinfo->image_height = height; +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for Targa format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_targa (j_compress_ptr cinfo) +{ + tga_source_ptr source; + + /* Create module interface object */ + source = (tga_source_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(tga_source_struct)); + source->cinfo = cinfo; /* make back link for subroutines */ + /* Fill in method ptrs, except get_pixel_rows which start_input sets */ + source->pub.start_input = start_input_tga; + source->pub.finish_input = finish_input_tga; + + return &source->pub; +} + +#endif /* TARGA_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/stamp-h1 b/thirdparty/jpeg-9e/stamp-h1 new file mode 100644 index 0000000..47553f4 --- /dev/null +++ b/thirdparty/jpeg-9e/stamp-h1 @@ -0,0 +1 @@ +timestamp for jconfig.h diff --git a/thirdparty/jpeg-9e/structure.txt b/thirdparty/jpeg-9e/structure.txt new file mode 100644 index 0000000..98e20c7 --- /dev/null +++ b/thirdparty/jpeg-9e/structure.txt @@ -0,0 +1,942 @@ +IJG JPEG LIBRARY: SYSTEM ARCHITECTURE + +Copyright (C) 1991-2013, Thomas G. Lane, Guido Vollbeding. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file provides an overview of the architecture of the IJG JPEG software; +that is, the functions of the various modules in the system and the interfaces +between modules. For more precise details about any data structure or calling +convention, see the include files and comments in the source code. + +We assume that the reader is already somewhat familiar with the JPEG standard. +The README file includes references for learning about JPEG. The file +libjpeg.txt describes the library from the viewpoint of an application +programmer using the library; it's best to read that file before this one. +Also, the file coderules.txt describes the coding style conventions we use. + +In this document, JPEG-specific terminology follows the JPEG standard: + A "component" means a color channel, e.g., Red or Luminance. + A "sample" is a single component value (i.e., one number in the image data). + A "coefficient" is a frequency coefficient (a DCT transform output number). + A "block" is an array of samples or coefficients. + An "MCU" (minimum coded unit) is an interleaved set of blocks of size + determined by the sampling factors, or a single block in a + noninterleaved scan. +We do not use the terms "pixel" and "sample" interchangeably. When we say +pixel, we mean an element of the full-size image, while a sample is an element +of the downsampled image. Thus the number of samples may vary across +components while the number of pixels does not. (This terminology is not used +rigorously throughout the code, but it is used in places where confusion would +otherwise result.) + + +*** System features *** + +The IJG distribution contains two parts: + * A subroutine library for JPEG compression and decompression. + * cjpeg/djpeg, two sample applications that use the library to transform + JFIF JPEG files to and from several other image formats. +cjpeg/djpeg are of no great intellectual complexity: they merely add a simple +command-line user interface and I/O routines for several uncompressed image +formats. This document concentrates on the library itself. + +We desire the library to be capable of supporting all JPEG baseline, extended +sequential, and progressive DCT processes. The library does not support the +hierarchical or lossless processes defined in the standard. + +Within these limits, any set of compression parameters allowed by the JPEG +spec should be readable for decompression. (We can be more restrictive about +what formats we can generate.) Although the system design allows for all +parameter values, some uncommon settings are not yet implemented and may +never be; nonintegral sampling ratios are the prime example. Furthermore, +we treat 8-bit vs. 12-bit data precision as a compile-time switch, not a +run-time option, because most machines can store 8-bit pixels much more +compactly than 12-bit. + +By itself, the library handles only interchange JPEG datastreams --- in +particular the widely used JFIF file format. The library can be used by +surrounding code to process interchange or abbreviated JPEG datastreams that +are embedded in more complex file formats. (For example, libtiff uses this +library to implement JPEG compression within the TIFF file format.) + +The library includes a substantial amount of code that is not covered by the +JPEG standard but is necessary for typical applications of JPEG. These +functions preprocess the image before JPEG compression or postprocess it after +decompression. They include colorspace conversion, downsampling/upsampling, +and color quantization. This code can be omitted if not needed. + +A wide range of quality vs. speed tradeoffs are possible in JPEG processing, +and even more so in decompression postprocessing. The decompression library +provides multiple implementations that cover most of the useful tradeoffs, +ranging from very-high-quality down to fast-preview operation. On the +compression side we have generally not provided low-quality choices, since +compression is normally less time-critical. It should be understood that the +low-quality modes may not meet the JPEG standard's accuracy requirements; +nonetheless, they are useful for viewers. + + +*** Portability issues *** + +Portability is an essential requirement for the library. The key portability +issues that show up at the level of system architecture are: + +1. Memory usage. We want the code to be able to run on PC-class machines +with limited memory. Images should therefore be processed sequentially (in +strips), to avoid holding the whole image in memory at once. Where a +full-image buffer is necessary, we should be able to use either virtual memory +or temporary files. + +2. Near/far pointer distinction. To run efficiently on 80x86 machines, the +code should distinguish "small" objects (kept in near data space) from +"large" ones (kept in far data space). This is an annoying restriction, but +fortunately it does not impact code quality for less brain-damaged machines, +and the source code clutter turns out to be minimal with sufficient use of +pointer typedefs. + +3. Data precision. We assume that "char" is at least 8 bits, "short" and +"int" at least 16, "long" at least 32. The code will work fine with larger +data sizes, although memory may be used inefficiently in some cases. However, +the JPEG compressed datastream must ultimately appear on external storage as a +sequence of 8-bit bytes if it is to conform to the standard. This may pose a +problem on machines where char is wider than 8 bits. The library represents +compressed data as an array of values of typedef JOCTET. If no data type +exactly 8 bits wide is available, custom data source and data destination +modules must be written to unpack and pack the chosen JOCTET datatype into +8-bit external representation. + + +*** System overview *** + +The compressor and decompressor are each divided into two main sections: +the JPEG compressor or decompressor proper, and the preprocessing or +postprocessing functions. The interface between these two sections is the +image data that the official JPEG spec regards as its input or output: this +data is in the colorspace to be used for compression, and it is downsampled +to the sampling factors to be used. The preprocessing and postprocessing +steps are responsible for converting a normal image representation to or from +this form. (Those few applications that want to deal with YCbCr downsampled +data can skip the preprocessing or postprocessing step.) + +Looking more closely, the compressor library contains the following main +elements: + + Preprocessing: + * Color space conversion (e.g., RGB to YCbCr). + * Edge expansion and downsampling. Optionally, this step can do simple + smoothing --- this is often helpful for low-quality source data. + JPEG proper: + * MCU assembly, DCT, quantization. + * Entropy coding (sequential or progressive, Huffman or arithmetic). + +In addition to these modules we need overall control, marker generation, +and support code (memory management & error handling). There is also a +module responsible for physically writing the output data --- typically +this is just an interface to fwrite(), but some applications may need to +do something else with the data. + +The decompressor library contains the following main elements: + + JPEG proper: + * Entropy decoding (sequential or progressive, Huffman or arithmetic). + * Dequantization, inverse DCT, MCU disassembly. + Postprocessing: + * Upsampling. Optionally, this step may be able to do more general + rescaling of the image. + * Color space conversion (e.g., YCbCr to RGB). This step may also + provide gamma adjustment [ currently it does not ]. + * Optional color quantization (e.g., reduction to 256 colors). + * Optional color precision reduction (e.g., 24-bit to 15-bit color). + [This feature is not currently implemented.] + +We also need overall control, marker parsing, and a data source module. +The support code (memory management & error handling) can be shared with +the compression half of the library. + +There may be several implementations of each of these elements, particularly +in the decompressor, where a wide range of speed/quality tradeoffs is very +useful. It must be understood that some of the best speedups involve +merging adjacent steps in the pipeline. For example, upsampling, color space +conversion, and color quantization might all be done at once when using a +low-quality ordered-dither technique. The system architecture is designed to +allow such merging where appropriate. + + +Note: it is convenient to regard edge expansion (padding to block boundaries) +as a preprocessing/postprocessing function, even though the JPEG spec includes +it in compression/decompression. We do this because downsampling/upsampling +can be simplified a little if they work on padded data: it's not necessary to +have special cases at the right and bottom edges. Therefore the interface +buffer is always an integral number of blocks wide and high, and we expect +compression preprocessing to pad the source data properly. Padding will occur +only to the next block (block_size-sample) boundary. In an interleaved-scan +situation, additional dummy blocks may be used to fill out MCUs, but the MCU +assembly and disassembly logic will create or discard these blocks internally. +(This is advantageous for speed reasons, since we avoid DCTing the dummy +blocks. It also permits a small reduction in file size, because the +compressor can choose dummy block contents so as to minimize their size +in compressed form. Finally, it makes the interface buffer specification +independent of whether the file is actually interleaved or not.) +Applications that wish to deal directly with the downsampled data must +provide similar buffering and padding for odd-sized images. + + +*** Poor man's object-oriented programming *** + +It should be clear by now that we have a lot of quasi-independent processing +steps, many of which have several possible behaviors. To avoid cluttering the +code with lots of switch statements, we use a simple form of object-style +programming to separate out the different possibilities. + +For example, two different color quantization algorithms could be implemented +as two separate modules that present the same external interface; at runtime, +the calling code will access the proper module indirectly through an "object". + +We can get the limited features we need while staying within portable C. +The basic tool is a function pointer. An "object" is just a struct +containing one or more function pointer fields, each of which corresponds to +a method name in real object-oriented languages. During initialization we +fill in the function pointers with references to whichever module we have +determined we need to use in this run. Then invocation of the module is done +by indirecting through a function pointer; on most machines this is no more +expensive than a switch statement, which would be the only other way of +making the required run-time choice. The really significant benefit, of +course, is keeping the source code clean and well structured. + +We can also arrange to have private storage that varies between different +implementations of the same kind of object. We do this by making all the +module-specific object structs be separately allocated entities, which will +be accessed via pointers in the master compression or decompression struct. +The "public" fields or methods for a given kind of object are specified by +a commonly known struct. But a module's initialization code can allocate +a larger struct that contains the common struct as its first member, plus +additional private fields. With appropriate pointer casting, the module's +internal functions can access these private fields. (For a simple example, +see jdatadst.c, which implements the external interface specified by struct +jpeg_destination_mgr, but adds extra fields.) + +(Of course this would all be a lot easier if we were using C++, but we are +not yet prepared to assume that everyone has a C++ compiler.) + +An important benefit of this scheme is that it is easy to provide multiple +versions of any method, each tuned to a particular case. While a lot of +precalculation might be done to select an optimal implementation of a method, +the cost per invocation is constant. For example, the upsampling step might +have a "generic" method, plus one or more "hardwired" methods for the most +popular sampling factors; the hardwired methods would be faster because they'd +use straight-line code instead of for-loops. The cost to determine which +method to use is paid only once, at startup, and the selection criteria are +hidden from the callers of the method. + +This plan differs a little bit from usual object-oriented structures, in that +only one instance of each object class will exist during execution. The +reason for having the class structure is that on different runs we may create +different instances (choose to execute different modules). You can think of +the term "method" as denoting the common interface presented by a particular +set of interchangeable functions, and "object" as denoting a group of related +methods, or the total shared interface behavior of a group of modules. + + +*** Overall control structure *** + +We previously mentioned the need for overall control logic in the compression +and decompression libraries. In IJG implementations prior to v5, overall +control was mostly provided by "pipeline control" modules, which proved to be +large, unwieldy, and hard to understand. To improve the situation, the +control logic has been subdivided into multiple modules. The control modules +consist of: + +1. Master control for module selection and initialization. This has two +responsibilities: + + 1A. Startup initialization at the beginning of image processing. + The individual processing modules to be used in this run are selected + and given initialization calls. + + 1B. Per-pass control. This determines how many passes will be performed + and calls each active processing module to configure itself + appropriately at the beginning of each pass. End-of-pass processing, + where necessary, is also invoked from the master control module. + + Method selection is partially distributed, in that a particular processing + module may contain several possible implementations of a particular method, + which it will select among when given its initialization call. The master + control code need only be concerned with decisions that affect more than + one module. + +2. Data buffering control. A separate control module exists for each + inter-processing-step data buffer. This module is responsible for + invoking the processing steps that write or read that data buffer. + +Each buffer controller sees the world as follows: + +input data => processing step A => buffer => processing step B => output data + | | | + ------------------ controller ------------------ + +The controller knows the dataflow requirements of steps A and B: how much data +they want to accept in one chunk and how much they output in one chunk. Its +function is to manage its buffer and call A and B at the proper times. + +A data buffer control module may itself be viewed as a processing step by a +higher-level control module; thus the control modules form a binary tree with +elementary processing steps at the leaves of the tree. + +The control modules are objects. A considerable amount of flexibility can +be had by replacing implementations of a control module. For example: +* Merging of adjacent steps in the pipeline is done by replacing a control + module and its pair of processing-step modules with a single processing- + step module. (Hence the possible merges are determined by the tree of + control modules.) +* In some processing modes, a given interstep buffer need only be a "strip" + buffer large enough to accommodate the desired data chunk sizes. In other + modes, a full-image buffer is needed and several passes are required. + The control module determines which kind of buffer is used and manipulates + virtual array buffers as needed. One or both processing steps may be + unaware of the multi-pass behavior. + +In theory, we might be able to make all of the data buffer controllers +interchangeable and provide just one set of implementations for all. In +practice, each one contains considerable special-case processing for its +particular job. The buffer controller concept should be regarded as an +overall system structuring principle, not as a complete description of the +task performed by any one controller. + + +*** Compression object structure *** + +Here is a sketch of the logical structure of the JPEG compression library: + + |-- Colorspace conversion + |-- Preprocessing controller --| + | |-- Downsampling +Main controller --| + | |-- Forward DCT, quantize + |-- Coefficient controller --| + |-- Entropy encoding + +This sketch also describes the flow of control (subroutine calls) during +typical image data processing. Each of the components shown in the diagram is +an "object" which may have several different implementations available. One +or more source code files contain the actual implementation(s) of each object. + +The objects shown above are: + +* Main controller: buffer controller for the subsampled-data buffer, which + holds the preprocessed input data. This controller invokes preprocessing to + fill the subsampled-data buffer, and JPEG compression to empty it. There is + usually no need for a full-image buffer here; a strip buffer is adequate. + +* Preprocessing controller: buffer controller for the downsampling input data + buffer, which lies between colorspace conversion and downsampling. Note + that a unified conversion/downsampling module would probably replace this + controller entirely. + +* Colorspace conversion: converts application image data into the desired + JPEG color space; also changes the data from pixel-interleaved layout to + separate component planes. Processes one pixel row at a time. + +* Downsampling: performs reduction of chroma components as required. + Optionally may perform pixel-level smoothing as well. Processes a "row + group" at a time, where a row group is defined as Vmax pixel rows of each + component before downsampling, and Vk sample rows afterwards (remember Vk + differs across components). Some downsampling or smoothing algorithms may + require context rows above and below the current row group; the + preprocessing controller is responsible for supplying these rows via proper + buffering. The downsampler is responsible for edge expansion at the right + edge (i.e., extending each sample row to a multiple of block_size samples); + but the preprocessing controller is responsible for vertical edge expansion + (i.e., duplicating the bottom sample row as needed to make a multiple of + block_size rows). + +* Coefficient controller: buffer controller for the DCT-coefficient data. + This controller handles MCU assembly, including insertion of dummy DCT + blocks when needed at the right or bottom edge. When performing + Huffman-code optimization or emitting a multiscan JPEG file, this + controller is responsible for buffering the full image. The equivalent of + one fully interleaved MCU row of subsampled data is processed per call, + even when the JPEG file is noninterleaved. + +* Forward DCT and quantization: Perform DCT, quantize, and emit coefficients. + Works on one or more DCT blocks at a time. (Note: the coefficients are now + emitted in normal array order, which the entropy encoder is expected to + convert to zigzag order as necessary. Prior versions of the IJG code did + the conversion to zigzag order within the quantization step.) + +* Entropy encoding: Perform Huffman or arithmetic entropy coding and emit the + coded data to the data destination module. Works on one MCU per call. + For progressive JPEG, the same DCT blocks are fed to the entropy coder + during each pass, and the coder must emit the appropriate subset of + coefficients. + +In addition to the above objects, the compression library includes these +objects: + +* Master control: determines the number of passes required, controls overall + and per-pass initialization of the other modules. + +* Marker writing: generates JPEG markers (except for RSTn, which is emitted + by the entropy encoder when needed). + +* Data destination manager: writes the output JPEG datastream to its final + destination (e.g., a file). The destination manager supplied with the + library knows how to write to a stdio stream or to a memory buffer; + for other behaviors, the surrounding application may provide its own + destination manager. + +* Memory manager: allocates and releases memory, controls virtual arrays + (with backing store management, where required). + +* Error handler: performs formatting and output of error and trace messages; + determines handling of nonfatal errors. The surrounding application may + override some or all of this object's methods to change error handling. + +* Progress monitor: supports output of "percent-done" progress reports. + This object represents an optional callback to the surrounding application: + if wanted, it must be supplied by the application. + +The error handler, destination manager, and progress monitor objects are +defined as separate objects in order to simplify application-specific +customization of the JPEG library. A surrounding application may override +individual methods or supply its own all-new implementation of one of these +objects. The object interfaces for these objects are therefore treated as +part of the application interface of the library, whereas the other objects +are internal to the library. + +The error handler and memory manager are shared by JPEG compression and +decompression; the progress monitor, if used, may be shared as well. + + +*** Decompression object structure *** + +Here is a sketch of the logical structure of the JPEG decompression library: + + |-- Entropy decoding + |-- Coefficient controller --| + | |-- Dequantize, Inverse DCT +Main controller --| + | |-- Upsampling + |-- Postprocessing controller --| |-- Colorspace conversion + |-- Color quantization + |-- Color precision reduction + +As before, this diagram also represents typical control flow. The objects +shown are: + +* Main controller: buffer controller for the subsampled-data buffer, which + holds the output of JPEG decompression proper. This controller's primary + task is to feed the postprocessing procedure. Some upsampling algorithms + may require context rows above and below the current row group; when this + is true, the main controller is responsible for managing its buffer so as + to make context rows available. In the current design, the main buffer is + always a strip buffer; a full-image buffer is never required. + +* Coefficient controller: buffer controller for the DCT-coefficient data. + This controller handles MCU disassembly, including deletion of any dummy + DCT blocks at the right or bottom edge. When reading a multiscan JPEG + file, this controller is responsible for buffering the full image. + (Buffering DCT coefficients, rather than samples, is necessary to support + progressive JPEG.) The equivalent of one fully interleaved MCU row of + subsampled data is processed per call, even when the source JPEG file is + noninterleaved. + +* Entropy decoding: Read coded data from the data source module and perform + Huffman or arithmetic entropy decoding. Works on one MCU per call. + For progressive JPEG decoding, the coefficient controller supplies the prior + coefficients of each MCU (initially all zeroes), which the entropy decoder + modifies in each scan. + +* Dequantization and inverse DCT: like it says. Note that the coefficients + buffered by the coefficient controller have NOT been dequantized; we + merge dequantization and inverse DCT into a single step for speed reasons. + When scaled-down output is asked for, simplified DCT algorithms may be used + that need fewer coefficients and emit fewer samples per DCT block, not the + full 8x8. Works on one DCT block at a time. + +* Postprocessing controller: buffer controller for the color quantization + input buffer, when quantization is in use. (Without quantization, this + controller just calls the upsampler.) For two-pass quantization, this + controller is responsible for buffering the full-image data. + +* Upsampling: restores chroma components to full size. (May support more + general output rescaling, too. Note that if undersized DCT outputs have + been emitted by the DCT module, this module must adjust so that properly + sized outputs are created.) Works on one row group at a time. This module + also calls the color conversion module, so its top level is effectively a + buffer controller for the upsampling->color conversion buffer. However, in + all but the highest-quality operating modes, upsampling and color + conversion are likely to be merged into a single step. + +* Colorspace conversion: convert from JPEG color space to output color space, + and change data layout from separate component planes to pixel-interleaved. + Works on one pixel row at a time. + +* Color quantization: reduce the data to colormapped form, using either an + externally specified colormap or an internally generated one. This module + is not used for full-color output. Works on one pixel row at a time; may + require two passes to generate a color map. Note that the output will + always be a single component representing colormap indexes. In the current + design, the output values are JSAMPLEs, so an 8-bit compilation cannot + quantize to more than 256 colors. This is unlikely to be a problem in + practice. + +* Color reduction: this module handles color precision reduction, e.g., + generating 15-bit color (5 bits/primary) from JPEG's 24-bit output. + Not quite clear yet how this should be handled... should we merge it with + colorspace conversion??? + +Note that some high-speed operating modes might condense the entire +postprocessing sequence to a single module (upsample, color convert, and +quantize in one step). + +In addition to the above objects, the decompression library includes these +objects: + +* Master control: determines the number of passes required, controls overall + and per-pass initialization of the other modules. This is subdivided into + input and output control: jdinput.c controls only input-side processing, + while jdmaster.c handles overall initialization and output-side control. + +* Marker reading: decodes JPEG markers (except for RSTn). + +* Data source manager: supplies the input JPEG datastream. The source + manager supplied with the library knows how to read from a stdio stream + or from a memory buffer; for other behaviors, the surrounding application + may provide its own source manager. + +* Memory manager: same as for compression library. + +* Error handler: same as for compression library. + +* Progress monitor: same as for compression library. + +As with compression, the data source manager, error handler, and progress +monitor are candidates for replacement by a surrounding application. + + +*** Decompression input and output separation *** + +To support efficient incremental display of progressive JPEG files, the +decompressor is divided into two sections that can run independently: + +1. Data input includes marker parsing, entropy decoding, and input into the + coefficient controller's DCT coefficient buffer. Note that this + processing is relatively cheap and fast. + +2. Data output reads from the DCT coefficient buffer and performs the IDCT + and all postprocessing steps. + +For a progressive JPEG file, the data input processing is allowed to get +arbitrarily far ahead of the data output processing. (This occurs only +if the application calls jpeg_consume_input(); otherwise input and output +run in lockstep, since the input section is called only when the output +section needs more data.) In this way the application can avoid making +extra display passes when data is arriving faster than the display pass +can run. Furthermore, it is possible to abort an output pass without +losing anything, since the coefficient buffer is read-only as far as the +output section is concerned. See libjpeg.txt for more detail. + +A full-image coefficient array is only created if the JPEG file has multiple +scans (or if the application specifies buffered-image mode anyway). When +reading a single-scan file, the coefficient controller normally creates only +a one-MCU buffer, so input and output processing must run in lockstep in this +case. jpeg_consume_input() is effectively a no-op in this situation. + +The main impact of dividing the decompressor in this fashion is that we must +be very careful with shared variables in the cinfo data structure. Each +variable that can change during the course of decompression must be +classified as belonging to data input or data output, and each section must +look only at its own variables. For example, the data output section may not +depend on any of the variables that describe the current scan in the JPEG +file, because these may change as the data input section advances into a new +scan. + +The progress monitor is (somewhat arbitrarily) defined to treat input of the +file as one pass when buffered-image mode is not used, and to ignore data +input work completely when buffered-image mode is used. Note that the +library has no reliable way to predict the number of passes when dealing +with a progressive JPEG file, nor can it predict the number of output passes +in buffered-image mode. So the work estimate is inherently bogus anyway. + +No comparable division is currently made in the compression library, because +there isn't any real need for it. + + +*** Data formats *** + +Arrays of pixel sample values use the following data structure: + + typedef something JSAMPLE; a pixel component value, 0..MAXJSAMPLE + typedef JSAMPLE *JSAMPROW; ptr to a row of samples + typedef JSAMPROW *JSAMPARRAY; ptr to a list of rows + typedef JSAMPARRAY *JSAMPIMAGE; ptr to a list of color-component arrays + +The basic element type JSAMPLE will typically be one of unsigned char, +(signed) char, or short. Short will be used if samples wider than 8 bits are +to be supported (this is a compile-time option). Otherwise, unsigned char is +used if possible. If the compiler only supports signed chars, then it is +necessary to mask off the value when reading. Thus, all reads of JSAMPLE +values must be coded as "GETJSAMPLE(value)", where the macro will be defined +as "((value) & 0xFF)" on signed-char machines and "((int) (value))" elsewhere. + +With these conventions, JSAMPLE values can be assumed to be >= 0. This helps +simplify correct rounding during downsampling, etc. The JPEG standard's +specification that sample values run from -128..127 is accommodated by +subtracting 128 from the sample value in the DCT step. Similarly, during +decompression the output of the IDCT step will be immediately shifted back to +0..255. (NB: different values are required when 12-bit samples are in use. +The code is written in terms of MAXJSAMPLE and CENTERJSAMPLE, which will be +defined as 255 and 128 respectively in an 8-bit implementation, and as 4095 +and 2048 in a 12-bit implementation.) + +We use a pointer per row, rather than a two-dimensional JSAMPLE array. This +choice costs only a small amount of memory and has several benefits: +* Code using the data structure doesn't need to know the allocated width of + the rows. This simplifies edge expansion/compression, since we can work + in an array that's wider than the logical picture width. +* Indexing doesn't require multiplication; this is a performance win on many + machines. +* Arrays with more than 64K total elements can be supported even on machines + where malloc() cannot allocate chunks larger than 64K. +* The rows forming a component array may be allocated at different times + without extra copying. This trick allows some speedups in smoothing steps + that need access to the previous and next rows. + +Note that each color component is stored in a separate array; we don't use the +traditional layout in which the components of a pixel are stored together. +This simplifies coding of modules that work on each component independently, +because they don't need to know how many components there are. Furthermore, +we can read or write each component to a temporary file independently, which +is helpful when dealing with noninterleaved JPEG files. + +In general, a specific sample value is accessed by code such as + GETJSAMPLE(image[colorcomponent][row][col]) +where col is measured from the image left edge, but row is measured from the +first sample row currently in memory. Either of the first two indexings can +be precomputed by copying the relevant pointer. + + +Since most image-processing applications prefer to work on images in which +the components of a pixel are stored together, the data passed to or from the +surrounding application uses the traditional convention: a single pixel is +represented by N consecutive JSAMPLE values, and an image row is an array of +(# of color components)*(image width) JSAMPLEs. One or more rows of data can +be represented by a pointer of type JSAMPARRAY in this scheme. This scheme is +converted to component-wise storage inside the JPEG library. (Applications +that want to skip JPEG preprocessing or postprocessing will have to contend +with component-wise storage.) + + +Arrays of DCT-coefficient values use the following data structure: + + typedef short JCOEF; a 16-bit signed integer + typedef JCOEF JBLOCK[DCTSIZE2]; an 8x8 block of coefficients + typedef JBLOCK *JBLOCKROW; ptr to one horizontal row of 8x8 blocks + typedef JBLOCKROW *JBLOCKARRAY; ptr to a list of such rows + typedef JBLOCKARRAY *JBLOCKIMAGE; ptr to a list of color component arrays + +The underlying type is at least a 16-bit signed integer; while "short" is big +enough on all machines of interest, on some machines it is preferable to use +"int" for speed reasons, despite the storage cost. Coefficients are grouped +into 8x8 blocks (but we always use #defines DCTSIZE and DCTSIZE2 rather than +"8" and "64"). + +The contents of a coefficient block may be in either "natural" or zigzagged +order, and may be true values or divided by the quantization coefficients, +depending on where the block is in the processing pipeline. In the current +library, coefficient blocks are kept in natural order everywhere; the entropy +codecs zigzag or dezigzag the data as it is written or read. The blocks +contain quantized coefficients everywhere outside the DCT/IDCT subsystems. +(This latter decision may need to be revisited to support variable +quantization a la JPEG Part 3.) + +Notice that the allocation unit is now a row of 8x8 coefficient blocks, +corresponding to block_size rows of samples. Otherwise the structure +is much the same as for samples, and for the same reasons. + +On machines where malloc() can't handle a request bigger than 64Kb, this data +structure limits us to rows of less than 512 JBLOCKs, or a picture width of +4000+ pixels. This seems an acceptable restriction. + + +On 80x86 machines, the bottom-level pointer types (JSAMPROW and JBLOCKROW) +must be declared as "far" pointers, but the upper levels can be "near" +(implying that the pointer lists are allocated in the DS segment). +We use a #define symbol FAR, which expands to the "far" keyword when +compiling on 80x86 machines and to nothing elsewhere. + + +*** Suspendable processing *** + +In some applications it is desirable to use the JPEG library as an +incremental, memory-to-memory filter. In this situation the data source or +destination may be a limited-size buffer, and we can't rely on being able to +empty or refill the buffer at arbitrary times. Instead the application would +like to have control return from the library at buffer overflow/underrun, and +then resume compression or decompression at a later time. + +This scenario is supported for simple cases. (For anything more complex, we +recommend that the application "bite the bullet" and develop real multitasking +capability.) The libjpeg.txt file goes into more detail about the usage and +limitations of this capability; here we address the implications for library +structure. + +The essence of the problem is that the entropy codec (coder or decoder) must +be prepared to stop at arbitrary times. In turn, the controllers that call +the entropy codec must be able to stop before having produced or consumed all +the data that they normally would handle in one call. That part is reasonably +straightforward: we make the controller call interfaces include "progress +counters" which indicate the number of data chunks successfully processed, and +we require callers to test the counter rather than just assume all of the data +was processed. + +Rather than trying to restart at an arbitrary point, the current Huffman +codecs are designed to restart at the beginning of the current MCU after a +suspension due to buffer overflow/underrun. At the start of each call, the +codec's internal state is loaded from permanent storage (in the JPEG object +structures) into local variables. On successful completion of the MCU, the +permanent state is updated. (This copying is not very expensive, and may even +lead to *improved* performance if the local variables can be registerized.) +If a suspension occurs, the codec simply returns without updating the state, +thus effectively reverting to the start of the MCU. Note that this implies +leaving some data unprocessed in the source/destination buffer (ie, the +compressed partial MCU). The data source/destination module interfaces are +specified so as to make this possible. This also implies that the data buffer +must be large enough to hold a worst-case compressed MCU; a couple thousand +bytes should be enough. + +In a successive-approximation AC refinement scan, the progressive Huffman +decoder has to be able to undo assignments of newly nonzero coefficients if it +suspends before the MCU is complete, since decoding requires distinguishing +previously-zero and previously-nonzero coefficients. This is a bit tedious +but probably won't have much effect on performance. Other variants of Huffman +decoding need not worry about this, since they will just store the same values +again if forced to repeat the MCU. + +This approach would probably not work for an arithmetic codec, since its +modifiable state is quite large and couldn't be copied cheaply. Instead it +would have to suspend and resume exactly at the point of the buffer end. + +The JPEG marker reader is designed to cope with suspension at an arbitrary +point. It does so by backing up to the start of the marker parameter segment, +so the data buffer must be big enough to hold the largest marker of interest. +Again, a couple KB should be adequate. (A special "skip" convention is used +to bypass COM and APPn markers, so these can be larger than the buffer size +without causing problems; otherwise a 64K buffer would be needed in the worst +case.) + +The JPEG marker writer currently does *not* cope with suspension. +We feel that this is not necessary; it is much easier simply to require +the application to ensure there is enough buffer space before starting. (An +empty 2K buffer is more than sufficient for the header markers; and ensuring +there are a dozen or two bytes available before calling jpeg_finish_compress() +will suffice for the trailer.) This would not work for writing multi-scan +JPEG files, but we simply do not intend to support that capability with +suspension. + + +*** Memory manager services *** + +The JPEG library's memory manager controls allocation and deallocation of +memory, and it manages large "virtual" data arrays on machines where the +operating system does not provide virtual memory. Note that the same +memory manager serves both compression and decompression operations. + +In all cases, allocated objects are tied to a particular compression or +decompression master record, and they will be released when that master +record is destroyed. + +The memory manager does not provide explicit deallocation of objects. +Instead, objects are created in "pools" of free storage, and a whole pool +can be freed at once. This approach helps prevent storage-leak bugs, and +it speeds up operations whenever malloc/free are slow (as they often are). +The pools can be regarded as lifetime identifiers for objects. Two +pools/lifetimes are defined: + * JPOOL_PERMANENT lasts until master record is destroyed + * JPOOL_IMAGE lasts until done with image (JPEG datastream) +Permanent lifetime is used for parameters and tables that should be carried +across from one datastream to another; this includes all application-visible +parameters. Image lifetime is used for everything else. (A third lifetime, +JPOOL_PASS = one processing pass, was originally planned. However it was +dropped as not being worthwhile. The actual usage patterns are such that the +peak memory usage would be about the same anyway; and having per-pass storage +substantially complicates the virtual memory allocation rules --- see below.) + +The memory manager deals with three kinds of object: +1. "Small" objects. Typically these require no more than 10K-20K total. +2. "Large" objects. These may require tens to hundreds of K depending on + image size. Semantically they behave the same as small objects, but we + distinguish them for two reasons: + * On MS-DOS machines, large objects are referenced by FAR pointers, + small objects by NEAR pointers. + * Pool allocation heuristics may differ for large and small objects. + Note that individual "large" objects cannot exceed the size allowed by + type size_t, which may be 64K or less on some machines. +3. "Virtual" objects. These are large 2-D arrays of JSAMPLEs or JBLOCKs + (typically large enough for the entire image being processed). The + memory manager provides stripwise access to these arrays. On machines + without virtual memory, the rest of the array may be swapped out to a + temporary file. + +(Note: JSAMPARRAY and JBLOCKARRAY data structures are a combination of large +objects for the data proper and small objects for the row pointers. For +convenience and speed, the memory manager provides single routines to create +these structures. Similarly, virtual arrays include a small control block +and a JSAMPARRAY or JBLOCKARRAY working buffer, all created with one call.) + +In the present implementation, virtual arrays are only permitted to have image +lifespan. (Permanent lifespan would not be reasonable, and pass lifespan is +not very useful since a virtual array's raison d'etre is to store data for +multiple passes through the image.) We also expect that only "small" objects +will be given permanent lifespan, though this restriction is not required by +the memory manager. + +In a non-virtual-memory machine, some performance benefit can be gained by +making the in-memory buffers for virtual arrays be as large as possible. +(For small images, the buffers might fit entirely in memory, so blind +swapping would be very wasteful.) The memory manager will adjust the height +of the buffers to fit within a prespecified maximum memory usage. In order +to do this in a reasonably optimal fashion, the manager needs to allocate all +of the virtual arrays at once. Therefore, there isn't a one-step allocation +routine for virtual arrays; instead, there is a "request" routine that simply +allocates the control block, and a "realize" routine (called just once) that +determines space allocation and creates all of the actual buffers. The +realize routine must allow for space occupied by non-virtual large objects. +(We don't bother to factor in the space needed for small objects, on the +grounds that it isn't worth the trouble.) + +To support all this, we establish the following protocol for doing business +with the memory manager: + 1. Modules must request virtual arrays (which may have only image lifespan) + during the initial setup phase, i.e., in their jinit_xxx routines. + 2. All "large" objects (including JSAMPARRAYs and JBLOCKARRAYs) must also be + allocated during initial setup. + 3. realize_virt_arrays will be called at the completion of initial setup. + The above conventions ensure that sufficient information is available + for it to choose a good size for virtual array buffers. +Small objects of any lifespan may be allocated at any time. We expect that +the total space used for small objects will be small enough to be negligible +in the realize_virt_arrays computation. + +In a virtual-memory machine, we simply pretend that the available space is +infinite, thus causing realize_virt_arrays to decide that it can allocate all +the virtual arrays as full-size in-memory buffers. The overhead of the +virtual-array access protocol is very small when no swapping occurs. + +A virtual array can be specified to be "pre-zeroed"; when this flag is set, +never-yet-written sections of the array are set to zero before being made +available to the caller. If this flag is not set, never-written sections +of the array contain garbage. (This feature exists primarily because the +equivalent logic would otherwise be needed in jdcoefct.c for progressive +JPEG mode; we may as well make it available for possible other uses.) + +The first write pass on a virtual array is required to occur in top-to-bottom +order; read passes, as well as any write passes after the first one, may +access the array in any order. This restriction exists partly to simplify +the virtual array control logic, and partly because some file systems may not +support seeking beyond the current end-of-file in a temporary file. The main +implication of this restriction is that rearrangement of rows (such as +converting top-to-bottom data order to bottom-to-top) must be handled while +reading data out of the virtual array, not while putting it in. + + +*** Memory manager internal structure *** + +To isolate system dependencies as much as possible, we have broken the +memory manager into two parts. There is a reasonably system-independent +"front end" (jmemmgr.c) and a "back end" that contains only the code +likely to change across systems. All of the memory management methods +outlined above are implemented by the front end. The back end provides +the following routines for use by the front end (none of these routines +are known to the rest of the JPEG code): + +jpeg_mem_init, jpeg_mem_term system-dependent initialization/shutdown + +jpeg_get_small, jpeg_free_small interface to malloc and free library routines + (or their equivalents) + +jpeg_get_large, jpeg_free_large interface to FAR malloc/free in MSDOS machines; + else usually the same as + jpeg_get_small/jpeg_free_small + +jpeg_mem_available estimate available memory + +jpeg_open_backing_store create a backing-store object + +read_backing_store, manipulate a backing-store object +write_backing_store, +close_backing_store + +On some systems there will be more than one type of backing-store object +(specifically, in MS-DOS a backing store file might be an area of extended +memory as well as a disk file). jpeg_open_backing_store is responsible for +choosing how to implement a given object. The read/write/close routines +are method pointers in the structure that describes a given object; this +lets them be different for different object types. + +It may be necessary to ensure that backing store objects are explicitly +released upon abnormal program termination. For example, MS-DOS won't free +extended memory by itself. To support this, we will expect the main program +or surrounding application to arrange to call self_destruct (typically via +jpeg_destroy) upon abnormal termination. This may require a SIGINT signal +handler or equivalent. We don't want to have the back end module install its +own signal handler, because that would pre-empt the surrounding application's +ability to control signal handling. + +The IJG distribution includes several memory manager back end implementations. +Usually the same back end should be suitable for all applications on a given +system, but it is possible for an application to supply its own back end at +need. + + +*** Implications of DNL marker *** + +Some JPEG files may use a DNL marker to postpone definition of the image +height (this would be useful for a fax-like scanner's output, for instance). +In these files the SOF marker claims the image height is 0, and you only +find out the true image height at the end of the first scan. + +We could read these files as follows: +1. Upon seeing zero image height, replace it by 65535 (the maximum allowed). +2. When the DNL is found, update the image height in the global image + descriptor. +This implies that control modules must avoid making copies of the image +height, and must re-test for termination after each MCU row. This would +be easy enough to do. + +In cases where image-size data structures are allocated, this approach will +result in very inefficient use of virtual memory or much-larger-than-necessary +temporary files. This seems acceptable for something that probably won't be a +mainstream usage. People might have to forgo use of memory-hogging options +(such as two-pass color quantization or noninterleaved JPEG files) if they +want efficient conversion of such files. (One could improve efficiency by +demanding a user-supplied upper bound for the height, less than 65536; in most +cases it could be much less.) + +The standard also permits the SOF marker to overestimate the image height, +with a DNL to give the true, smaller height at the end of the first scan. +This would solve the space problems if the overestimate wasn't too great. +However, it implies that you don't even know whether DNL will be used. + +This leads to a couple of very serious objections: +1. Testing for a DNL marker must occur in the inner loop of the decompressor's + Huffman decoder; this implies a speed penalty whether the feature is used + or not. +2. There is no way to hide the last-minute change in image height from an + application using the decoder. Thus *every* application using the IJG + library would suffer a complexity penalty whether it cared about DNL or + not. +We currently do not support DNL because of these problems. + +A different approach is to insist that DNL-using files be preprocessed by a +separate program that reads ahead to the DNL, then goes back and fixes the SOF +marker. This is a much simpler solution and is probably far more efficient. +Even if one wants piped input, buffering the first scan of the JPEG file needs +a lot smaller temp file than is implied by the maximum-height method. For +this approach we'd simply treat DNL as a no-op in the decompressor (at most, +check that it matches the SOF image height). + +We will not worry about making the compressor capable of outputting DNL. +Something similar to the first scheme above could be applied if anyone ever +wants to make that work. diff --git a/thirdparty/jpeg-9e/testimg.bmp b/thirdparty/jpeg-9e/testimg.bmp new file mode 100644 index 0000000..11aa0cb Binary files /dev/null and b/thirdparty/jpeg-9e/testimg.bmp differ diff --git a/thirdparty/jpeg-9e/testimg.gif b/thirdparty/jpeg-9e/testimg.gif new file mode 100644 index 0000000..db8f744 --- /dev/null +++ b/thirdparty/jpeg-9e/testimg.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b2d4a598fd6520e739e95293cb60c8b6e9af5e33c0b9ee635e6ffa1a2b8b3b68 +size 21718 diff --git a/thirdparty/jpeg-9e/testimg.jpg b/thirdparty/jpeg-9e/testimg.jpg new file mode 100644 index 0000000..0585333 --- /dev/null +++ b/thirdparty/jpeg-9e/testimg.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b7ea0b521397c20176b809eb19fd4b51ea83368a3d8becb89ff430dcf8ea4e57 +size 5770 diff --git a/thirdparty/jpeg-9e/testimg.ppm b/thirdparty/jpeg-9e/testimg.ppm new file mode 100644 index 0000000..1377eef --- /dev/null +++ b/thirdparty/jpeg-9e/testimg.ppm @@ -0,0 +1,4 @@ +P6 +227 149 +255 +0/-0/-10.21/51.51.62/72.83/83/83/:3-:3-:3-:3-:3-:2/91.91.80-80-91.91.:2/80-80-80-80-80-80-80-80-6.+6.+6.+5-*5-*4,)4,)4,)4,)4,)4,)4,)4,)4,)4,)4,).+$/,%/,%0-&1.'2/(30)30)63,63,74-85.85.96/:70:70A;/B<0D>2F@2IA4JB5KC6KD4MD5MD5MD3NB2OC3OC3PD4QE5T>1Y?2b@4nB5}E6ŒG8šG9¥E7²F9ºF9¿E8ÆF;ÉF>ËF?ÌG@ÌG@íCNíCLíCLíDKíDIïBFñ>Bõ@â?@×?<Ñ=;µ@.µ@.µ@.´?-´?-³@-²?-°?-­@,ªA.¦A-¢B,A*›A)˜@*—A*’?/’?/’?/‘>,‘>,’<+’<+’<+”?+”?+”=*”=*”=*•>+–?+—@,”?:•>7—=4Ÿ?1©B3³D3¼D3¿D4º?/¶@2­E8žH;‡H9mB2T8*D3#:659549547326216005//50-72/72/72/61-61-50,50,50,.0-.0-.0-//-//-0/-2.-3--5,-4+,4*+4(*7(+=.1E69LUPdUPdUPd0/-0/-10.10.40-51.62/72.83/83/83/:3-:3-:3-:3-:3-91.91.80-80-80-80-91.91.80-80-80-80-80-80-80-80-6.+6.+5-*5-*5-*4,)4,)4,)5-*5-*5-*5-*5-*5-*5-*5-*/,%0-&0-&1.'2/(30)41*41*63,63,74-74-85.96/:70:70@:.A;/C=1E?3H@3IA4JB5JC3LC4LC4KB3MA1MA1NB2OC3PD4P>0U?1^A3jC4xD6†D4“D5žB3¨B3°@2¶@4¼B7ÂC:ÄE<ÆF=ÇG>èAKèAIèCIêDHíDGïBDó@D÷>Cø;Aø9@ö9?ð.‘>.‘>,=+’<+’<+”>-“>*“>*”=*”=*•>+–?,—@-“@8•>5˜>3Ÿ?1«A3µD4½D3ÁC4¼A2¸B6­E8œI;…G:kA3S9*D4$<66;55:4493382271161.61.72/72/72/61-61-50,50,50,.0-.0-.0-//-//-0/-2.-2.-3--5,-4*+4(*5)+<-0C47I:=h<;vDC†JI’LJST§`h¨k{rŽ‘{¢„°|†»y†½lv«[\ŒQHsQBkOFaOFaNI_RN_[Yfnotƒ‡ˆ”™•™ž—š ”™‘ƒ~ojk[]\JVUCXQaXQaXQa/.,/.,0/-10.40-40-51.51.72.72.72.92,92,92,92,92,91.80-7/,7/,7/,7/,80-91.80-80-80-80-80-80-80-80-6.+5-*5-*5-*4,)4,)4,)4,)5-*5-*5-*5-*5-*5-*5-*5-*1.'1.'2/(30)30)41*41*52+63,63,63,74-85.96/96/:70?9-@:.B<0D>2G?4H@3H@3H@3I@1I@1I@1K?1K?/L@0MA1NB2MA1QA2YB2dC2qC3|C2‰A2“@0™<+ :+©;,¯>0¶@4¼C8¿F=ÀG>à?Eá@FãBGæCFêDFðCEõADù?Dú;@û:?÷:@ñ=@è@@ÜA=Ñ@;É>7³@-³@-³@-²?,²?,²?-¯>,®?,ª?-©@-¥@,¡A+A,˜@*—A*–@)’?/‘>.‘>.‘>.=+=+=+’<+“=,“=,’<+’=)“>*“>*”?+•@,”B7–?5š>3£>2­A4¹C5¿D5ÂC4ÂD6ºF9¯I=›I=‚F;gA4P:,B6&=77=77<66:4493383072/72/62/62/62/52-52-41,41,41,,1-,1-.0-.0-//-//-0/-2.-5//4..5,-4*+4*+9-/>24C79_83l?:|E@ˆIB’NK›Z^œft”n‡Œwž€~¯zƒºs¹dm¤UU‰NEtO?lMBbPEcQHcMH^NK\[[estx…‰ˆ‡Œ†Š†…†Š|xzlghXZ[KVTEZT`ZT`ZT`.-+/.,/.,0/-10.40-40-40-51.61-61-61-81+81+81+81+50-50-4/,4/,4/,4/,50-50-61.61.61.61.61.61.61.61.3.+3.+3.+2-*2-*2-*1,)1,)4/,4/,4/,4/,4/,4/,4/,4/,30+30+30+41,41,52-52-52-52-52-63.74/850850961961>8,?9-@:.B<0E=2E=2F>1F>1G=1G>/F=.I=/I=/J>0L@0L@0JD4NE4TD4^D3hE2sB1~A/‡>-Œ9'”9'9)£<-¬@3³E8·I<ºJ>Ù@CÚACÝCEâDEçCDîACô@Cø>Aü;@û:?÷:>ð=@åA?ÚB=ËA7Ã>5°@,°@,°@,°?-¯>,¯>,®?,¬>-ª?-¦?,£@-Ÿ@,œ@+˜@*–@)”@(‘>.‘>.‘>.=-=-=-<*<*=+=+<*<*=+“=,”>-”>-”B6–?5›?2¦@2²B4½C6ÂB5ÄB5ÄF:½H>­K@˜J@|F:aA4K;.?9+@86@86?75>64:5294183073062/62/62/32.32-21,21,21,-2.-2.-2./1./1.00.00.10.5106005//5,-4+,6,-:01>45W6-b<3qA7}D9„H@ŒRQŽ_i‹iƒs˜|z¬u~·myµ^g¢RQŠMDyM?rN@dPEgQFfLC^GBVNLZ^^fjnquzvx}vz€vwzokoa`bUWYKTUG]V^]V^]V^.-+.-+.-+/.,0/-10.3/,40-3/,4/+4/+4/+4/+6/)6/)6/)4/,4/,3.+3.+3.+3.+4/,4/,50-50-50-50-50-50-50-50-3.+3.+2-*2-*2-*1,)1,)1,)4/,4/,4/,4/,4/,4/,4/,4/,41,41,41,41,41,52-52-52-52-52-63.63.74/850961961<5+=6,?8.@9/B:/C;0C;0C;.D:.D:.D:.G;-H<.I=/J>0K?1GH6KH7PG6XG5aF3jD1uB/|?,‚;)‹:'’;(š=,£B2«G7±K<´M>ÒDBÔDCØDBÝEBâC@ê@@ð>>÷:>û:=ú9<õ;>í?>áB>ÓC:ÅA5º?0¯@-®?,®?,®?,­>+­>+¬>-ª?-¨?,¤?-¢?,ž?+š?*–?+”?*“>)?.?.>->->-Ž=,Ž=,Ž=,Ž=,Ž=,Ž=,Ž=,<,=-‘>.‘>.”B4—A4@1ª@3¶B5ÁC7ÆA8Å@7ÁB;¸G?©KCJ@uE;Y>3C9-78*@86@86?75>64=53:5294173062/43/43/32.23.12-12,12,,2.-2.-2.-2./1./1.00.00.3205105104..2,,4+,7./901P5*Y9,e>/n@1tB7|KGƒYcƒg~p—xx¬s{¹js¶]e¦TT”OG‚LAyPAjPAhMAeJA`GBYHEXKKWMPU^bc`fbcha`f\Z`TWZOUYKWYL`WZ`WZ`WZ,,,,,,---.-+/.,0/-10.3/,2.+2.+3.*3.*3.*3.*3.*3.*3.+3.+2-*1,)1,)2-*3.+3.+3.+3.+3.+3.+3.+3.+3.+3.+2-*2-*2-*2-*1,)1,)1,)0+(3.+3.+3.+3.+3.+3.+3.+3.+41,41,41,41,41,41,41,41,41,52-52-63.74/850850850;4*<5+=6,>7-@7.A8/A9.A9.C9/C9-C9-F:.G;/H<.J>0K?1FI8GH6MH5TG6[F3dC0lA.t?-{<*‚;)Š;*“=,šA1£F5ªJ:­M=ÉE@ËFAÑFAÖE@ÞC?å@>í==ó9<ø:<÷9;ó;=ë?=ÝB=ÌD8¼A2±>,«@,«@,¬?+¬>-¬>-©>,©>,¨>.¥>-¢?, ?,›>,—?+•>*“>)‘?)>->->->-Ž=,Ž=,Ž=,<+Ž=,<+‹<+‹<+‹<+Œ=.>/Ž?0’C2—A2 @2­A5»B9ÃC:Ç@:Å@9»@9³H@¥NGNEoG=R@4?;039-A75A75@64>63<4194083/74/63.43.34/23.13.02-02-02--3/-3/-3/.3/.3/02/02/11/11/32032040/2.-1-,4..5//H4)M5)X8+a<,f>2nGBzYb‚lƒ€uŸ{|´u|Àmu¾bi±[[¡SLLBQAnN?jI=cH>`HB^FCX@BO2K?3DG6EF6KE5PD4VC2^C2e@.m>,v=,|;)ƒ:)Š;*“=.›B2¢F7¦I:¿D<ÂF>ÇG>ÏF>ØE>âC?ì@>ó<>õ9:ó9:ï;<å@<×B;ÆD6´A/¨=)©@-©@-©@-¨?,¨?,¨>.§=-¥>-£>, ?.ž?-š?,—>,“>*‘?*>)>->->-Œ=,Œ=,Œ=,‹<-‹<-‹<-‹<-‰<,‰<,Š=-‹=0‹=0Œ>1‘D2–C1¡A3®B6¼C:ÅA<ÇB=ÃB=»EA³PJ¥XPŽZOqSIVI@BD97A6A83@72?61=60<4194083/63.43.43.34.13.13.02-.3-.3--3/-3/-3/.3/.3/.3/02/02/00.11/22021/0/-/.,2.-3/.?0)C1'K3'T8,Z<2dGCw]hƒsˆ­„„À|ƒËszÈkq¿ed°VSšJC‡N>kK5.>5.>5.>5,B8/B8/C9/E8/G:1I<3J=4K?3EC6FB6IC5NB4TA3\@2b>0h=-q<.w9*}8)…7*Œ:,•=/›B2 D5µE9¸F;ÀG<ÈH=ÒH>ßF@èC?ð@@î:9î:9é=;àA;ÑD:¾E4¬A-¢?(¦A-¦A-¥@.¥@.¦?.¥>-¤?-¤>/¢>.Ÿ@.œ?.˜?-•>+‘?*>)>+>->->-Œ=,Œ=.Š=-Š=-Š=-Š1‹?2‘D2–C1¢B4®B6¼C;ÄC>ÄC>¾D?»PJ²[T¥e\‘f]s_TYUJFNC>KA@70@72>71=6094.83-63,63.43.34.34.13.13..3-.3-.3--3/-3/-3/.3/.3/.3/.3/02/.0-00.22022000.0/-0/-10.8,,;,)B1*K7.S<4^IHtbn‡z–Џ‹Ê‚ˆÒy€ÐrwÈik¸XV¡GD‹I^C@[ABV>DP>EMGQSKWUQ^WU`XS_UR^TT^SV`UaZHaZHaZH,-/,-/------------.-+.-+/.,/.,1-*0,)0,)0,)/+(0+'/+*/+*/+*/+*/+*/+*/+*0,+/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+1-,1-,2.-1-,1-,1-,1-,1-,1-,1-,1-,0,)1-*2.+3/,3/,3/,3/,3/,3/,3/,3/,3/,40-51.62/73081+92,:3-;4.=4/>5.>5.>5.?4.?5,@6-C6.D7.F90G:1H;2F?5H@5J@6N@5R>3W<1\:0a7+k9.t8-|8+…9,;/“=0˜?1›?2¨@3¬B5´D8¾E:ÊG=ÕF>ßD?çB>ë?=íA?çD?ÜE>ÉC8¶C1§B.¡B,¢A.¡@-¢?,¢?,¡=-¡=-¢>. ?.œ<,š=,˜=+•>-“=,=+Ž=*Œ>*‹<+‹<+‹<+‰<,‰<,‰<,‡;-‡;-‰=/†½F@¾C>¾DA»KG·XR¯f]£qfth|rfik^S_SCSHQJBLE=D=5<8/95,74-63,33+43.34.23-13.02--2,,1+,1+-2.-2.-2.-2.-2.-2./1./1.02/02/11/11/11/11/11/11/5*2;/3A32C4/J;6]OOymy‹…Ÿ’‘½”–Ӕ݂‰×tzÈjn¸_b©YZPHmHBdA>]>>X?AVBHVLU^U`bbqnn}xv†|p€ulyoguh_k_T`Ta[Eb\Fc]G,-/,-/,-/,-/---------.-+/.,.-+.-+0,)/+(/+(/+(/+(.*).*).*).*)/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+0,+1-,1-,1-,1-,1-,1-,1-,1-,1-,1-,0,)0,)1-*2.+3/,3/,2.+2.+2.+2.+2.+2.+3/,40-51.62/80-91.:2/;30=4/>50>50=4-?4.?4.?4.B5-C6.E80G:2H;3H>5J=5L=6O>6Q=4V;2Z90_7/h8.p7.y6-‚8-‰9.’;1–<1š>1¢@3¦A5ªB5³E8¾E:ÉF<ÔE=ÜC=âC?ãD@ßF@ÕF>ÄF8±C2£B/›C-ŸB0 A/Ÿ@.ž?-ž?-Ÿ>-ž>.ž>.š=,™=.–=-“=,=+>-Œ=,‹>,Š=+Š=+‰<,‰<,‰<,‡;-‡;-…<-†4†@6‡A7ˆB8‘H7•F7£G:±I@¹HB¹FAºJFµTM²dZªreŸ~op~|mlteYgZJZOPLAKI=EC7@>2=:1:7.44*11)23+23-12,/1,/1,.0+.0+.0-/1./1./1./1./1./1./1./1.02/11/11/11/11/11/11/11/5*:9-9<15?53H?:^VTxszŠˆž‘“º”—Εׄ‹ÓxÆpyºkt¯en¥__yXZsSUjRWjU]j\gmguvr‚v‡€‘‡ƒ•‰}v†yp€sfteXfW_YA`ZBb\D,-/,-/,-/,-/,-/---------.-+.-+.-+-,*/+(.*'.*'.*'.*+.*+.*+.*+-)*-)*-)*-)*/+,/+,/+,/+,/+,/+,/+,/+,.*+.*+/+,/+,/+,0,-0,-0,-0,-0,-0,-1-.1-.1-.1-.1-.0,+0,+1-,2.-2.-2.-2.-1-,1-,1-,1-,1-,2.-3/.40/51080-91.:2/;30=31=31=4/=4/?40?4.?4.A4.C60D7/F91G:2H;5J;6K<7N=6P;6S:5V72[60c60k6.t5,}7/‡9/Ž:0”<0˜<1œ@3ž@4¢@3§A3±C6¼C8ÇD:ÎC<ÖF>ÚG@×HBÍH?¾E:­C3ŸB0™B.B/œA.›@-›>-›>-›>-›>-œ?0˜<-–=-”=,“=.>-Œ=,Š=+Š=+‰<*‰<,‰<,‡;+‡;+…<-„;,ƒ;-„<0‚<0‚<2‚>3ƒ?4…A8†C:‡D;“K<–H; H>­JDµIF´KG´SM¯_V®rg¥qœz{Šwr€ocqbVdWPQCMN@HI;DD8@@4::055+/0(01)01+/0*/0+./*./*//-//-//-//-//-//-//-//-//-//-00.00.00.00.00.00.00.00.6*>6+;8.6;63HE>_^Yyz|Šœ“²’–ÃŽ•Ë„Æ}ˆ¾{‰¸|‹´|Œ°ˆ—yƒq~‡o|‚n}€o‚€yއƒ™‹¡”‘¨˜¦”ˆŠƒ–ƒ|{j{iXiW\V<^X>`Z@-.0-.0-.0-.0-.0-.0......---.-+-,*-,*,+).*'.*'.*',*++)*+)*+)*+)**()*()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+-+,-+,-+,-+,.,-.,-.,-.,-/-./-./-./+*0,+1-,1-,1-,1-,0,+0,+0,+0,+0,+0,+1-,2.-3/.40/91/:20;31<42=31=31=31=31>3/>3/>3/@3-A4.C60D71E82G83H94I:5L:6M:6N94Q83T50^72e60o6/x8/ƒ90Š:/’;1•=1™?4™?4›?2@1¥A2­C5¸D7ÀD:ÉF<ÌG>ÌIAÄH>¶F:©C4B0—B.˜A.˜A.˜?-—>,™>,™=.™=.™=.•<,”<.“=.=-Ž<.Š=-Š=-ˆ<,ˆ;)ˆ;+‡;+‡;+„;,„;,ƒ;-‚:,;/€<1€<1>5ƒ@7ƒC:…E<†F=’M>•I<œH>¨IC¯LG¯PL¯\Tªj^§€o y˜š‚Žœƒ„–€z‹ym{lam_UYHQUDKO@EI:@D6;=057,13(01)/0*/.).-).-).-+/.,0/-/.,/.,/.,/.,/.,/.,/.,/.,0/-0/-0/-0/-0/-0/-0/-0/-8*A6):3-1961HJ=bfX{€y‰‘“Œ“£–²Œ”¸ƒ³±…™²¤¶ªµ•§§¤£Œ ž‡ž–‚™}˜‰œ‹ˆ£”°š–²›”­—‹£‹…›†’~k|iUfSXT7ZV9^Z=+/2+/2-.0-.0-.0-.0-.0...------.-+-,*-,*,+),+),+),*+,*+,*++)*+)**()*()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*++)*+)*+)*,*+-+,-+,.,-.,-/-./-./-./+*0,+0,+0,+0,+0,+/+*.*)/+*/+*/+*/+*0,+1-,3/.40/91/:20;31<42=32=32<20<20=20=2.=2.?1.@2/A4.B5/C60D63C84D95G96G96H94K84N51V72_60h70r7/}:1†<1=2>2˜?7—?5—?5—?3šA3£C5ªD6³E8ºE;¿F=ÀG>»F=°D8¤B5™@0–@/–A-–A-–?,•>+•<,•<,–=-–=/”<.’<-=-Ž<.‹<-‰<,ˆ<,ˆ<,‡;+†:*†:*†:*ƒ:+‚:+‚:,€:.;0€<1€=4?6‚B9ƒD;†G@‡HALA’H?˜HA¤KGªOLªWQªf]¥wh¡Œw˜›€’¥‰Š¤‡„ž…|’}t‚qlte\eRV_LMVCEL0-?1.@2/A30A30?61@72@93A96A96B94E74G51O61W6/a6/j8/u9.€0•>7•>5“?5’@4•B4™C4ŸC4¥D4ªB5²C8´E:±E;©C7 @4˜?1•?2“A,’?-“=,“=,“<+“<+”<.”<.“;-’E5:@29<134,22*1.)/+(/*'0**3*+4+,1++1++1++1++1++1++1++0,+1-,1-,1-,1-,1-,1-,1-,/.,;(;5(23+(56$CL-\hDt„`…”wŽ›‰’ž”Ÿšž–¥—•µ¡Æ¤¦Ð¨¥É¯¦Ê°§Ë¯¢Éª—¿‹³ˆ°‹³ŽŽ²Ž²¬Š„¢€€™{wŽrdx]MaHQQ5QQ5RR6,03,03,03,03./1./1./1./1/////////0/-/.,/.,.-+.-+/-..,-.,--+,,*++)*+)**()+)*+)*+)*+)*+)*+)*+)*+)*+)*+)*+)**()*()*())'()'(+)*+)*,*+-+,.,-.,-/-./-./+*/+*/+*/+*/+*.*)-)(,('0,+0,+0,+0,+1-,2.-40/40/:12;23;23<34=32<21<21;10<1/<1/<1/=/,>0->0-?1.@2/;60;62;83<94=:5=:5?82A60F5.O4-W5+b6+n8,x:-<,„<.’:6‘<5=5Ž@4A4‘B3•B2™@0Ÿ?1¦@4ªB7ªB9¥@6?5—=2•?2‘@-’?-‘>,’<+‘;*‘;,“;-“;-‘;,<.;-‹<-‰;.‡;-„;,„;,…9)…9)…9)‚9*‚9*9+~8,}9,=1€=4€@7B9„E>…HCˆKFŠMHŒIAŽGA˜JF¢SOª\X«h`©{n£Žy—Ž©ˆ…¯‹«ˆ~£„€˜€‹w{nixacr[ZhQP]IIUACL;>D60-?1.?1.96/:729839839:4:94;83>71A2+I2*S2)^4(j6)s8*|:*~;+84:5=4Œ@3‹B3A1@/”>-˜<-Ÿ=0¥@4¦A7¢@7œ>4—=4•=3‘@-?,=+<*‘;*‘;,‘;,’<-‘;.<.;-Š;,ˆ:-‡;-„;,„;,…9)…9)‚9(‚9*9*€8*~8,}9,€>2?5€@7‚C<ƒG?†IDˆMGŠOIŒICHD˜MJ¥UT¬a^­ng«s¤•€–¡ƒŠ¬‰‚°‹|«‡|£„™y‚ql{dgv__nWXeQP\HIRAAG9=@579.66.41,1,)1)'2()3)*4*+2)*2)*2)*2)*2)*2)*2)*0**1++1++1++0,+0,+0,+0,+0,+:&27(+4."47=HRb1l~J€’b‰™rŽ|Ÿ‚ŠŸ~Ч{·€˜Æ…œÎ…œÉ¢šÉŸ™Èž”׉¸Š®€‚°‹¶ˆ‚¬~ˆ¯ƒ‡ª€~œvuml„dZnRG[?IL/GJ-DG*/0*/0*/0*01+01+01+21,21,32-63.63.63.52-50,4/+4/+8.,7/,6.+5-+4,*2-*1++0,-0,-.,/--/-,1,+0*+/)*.()./(0/(//(//(//(//)-.)-.*+/+,-,*-,(.-).-)-.(./)./)--/--/---.../-.0/-2.+3.+2-)4,)5.(7.)8/(;0*;1(<2)<5+=4+>5.>5.>5.=4-<3.<1-=2.<1-<1/;0.=/.>0/>0/?11H-&C1';5)2:++=-(=.-;.45-?-+H()R%(X((Z.+Z8.[A2\G6wC-{B.„C1A3’?1•;0–:/”8+“;-‘>.‘B1‘D0‘D0B.?,<*Ÿ63›83”:2Œ<1…@1B0|A/|A/‚C2„A1ˆ>1‰=0‰;/ˆ:.‡9-‡9-v:/|@5u=0n9)s@/s@/t<+{@0{<-ƒ?4ˆD9‹H?ˆLA„NBQC€RC—HK•TRd]…ue{…lw’sz|€£ƒ‰¦ˆŽ¥‰’¤Œ‘¥Œ‡¤ˆy¢‚kŸ{awhŽea†]\zV[sS]mR[cLVTEPH=J;6G53B,/=&,:#+:#-9#/8".#/-#-,$-,&*+))+-(.1'/2'/4'06&14'14'13'32(32(30(3.)-0,-0,)//'=>0WZErx\‹gœs‹žpŒ¢qŒ§r‹¨r‰ªs³{›¾†£¿Ž ¾Œ›¹‡’²€‹­{†ªz„ª{…ª~„§}…¥€€ž|z“vr‰oi{e[jWLZIKO@CG8>B3/0*01+01+01+12,12,21,32-43.63.74/74/63.61-50,50,7/,7/,6.+6.,5-+2-*1++0,+0,-/-./-0--/-,1+*/)*.()-/(//(//(//(//)-/)-.*+.*+/+*-,*.-).-)/.*./)./)./)..0....../-./.,/.,1-*3.+3.*5.(6/)8/(90);0*<2)=3*>5,>5,>5.>5.>5.=4-<3,=2.=2.<1-;0.;0.;0.=/.>0/?10F/'D0)A3*=4+96-85.83-<1-?-+D*)K)(P*'U.)[4-_:1c?3s@+xA-€A0‰?2‘?4”;3”:1“;19.‹<-Š>.ŠA0‹B1B/ŽA/@/š93—:3’;2‹=1„?0‚@0@/?/„A1†>0‰=0‰;/‡;.„:-‚:,‚:,w9.x<1s9-n9)r?.s>.q9*u:,}=1„@5‰E:‹H?‰K@†MB„PCQC›DJ›QR–d]vfƒ‡p}”w~ ƒ¦…ˆ§ˆŽ§Š’¦‹“¥Œ£‰‚Ÿƒwœ}o˜xa•g\`VƒZU}XWyXWpSPbJKVECI;@A998340-0,+/+,.)--(,*,+)+***,+),-(,/)-2(03(03(02(02(10)1/*1-*1,+3,+32-12./0,)--%9:,TWBox[€‹i‡–o†™l†žnˆ£p†¤p„¥pŠ­w“¶€›¹‡˜¶„“³Œ®{†«xƒ§w‚¨yƒ¨|ƒ¦|„¤{x’uqˆnh{eYjWL[HGK<@D5:>/12,12,12,12,23-23-43.43.54/74/85085085083/72.61-80-80-7/,6.,6.,3.+2,,1-,1-./-.0.1..0--/,+0+*/*).1'//(//(//)-/)-/)-.*+.*+0,+0,+/.*/.*/.*0/*/0*/0*/////////0./0/-1-,1-*2-)4/+70*90+:1*<1+=3*>4+?5,?6-?6-@7.@70?6/>5.=4->3/=2.<1-;0.;0.;0.;0.<1/=20C2*E0+H/+L,-N+/M*.J*/E+.A-,@.*@/(C/(M/'Y0*d1-j30i;+o;-w;0=4‰<4Ž;5Ž94:4‹;2‡=2†>2…@1†A2‰A3ŒB5C6‘=2=1Œ>1Š>0†>/…=.…=.†=.ˆ<.‰;.ˆ:-‡9,„;,€;+~=+z=*}=3z<1v:/u;-x@1x@1v<.v;-?3„B6ŠF=‹H?ŠJA‡KA‡NC†PDDHQQšc^’ug‰„n‘t~}€¥ƒ„©‡ˆª‰©Œ“§Œ‘£‰‹ƒ„˜€”{a›k[•eXaV‰`W…`W]QtVMiPC[E=RA6F9/<2*5-&1+%.)$-(1&*1&*1&*1&*1&*1(-2).1+//*0-+0,+0+,0),1(-1&.1&.14.24.0.*'**"66*PUAmv[~‰i€k~“h™jƒŸn€ n~ m€¥q‡¬xŽ®|‹­zˆªw„©v§t€¦u¦w€¥y¤y€¢}}›yw’sp‡mh{eYkUL[HEG:=?28:-23-23-34.34.34.45/54/54/650961961:72:72:51940940:2/91.91.80-7/-4/,4/,3/.3/.3/01/01/00.1..0--/,,.2).2).2).0*.0*,0*,0*,/+*1-,1-*0/+0/+10+10+10+10+11111100010.10.2.+2.+3.*91.92,;2+<3,>4+@6-@6-A7.A8/A8/B90A8/A81@70>5.?4.=2.=2.<1-;0.;0.<1/=20=20?5,E2.O-.W(0]#/\"0W#/L'.C/.:3-55);5)E1(U.'c+*l*+e;/j;1s=3}<6…;8‰;9Š;7ˆ:6‰>9†?9…B9ƒC9…B9†B9‡A9‰@7†B/†B/‡@.‡@.‡>-ˆ<,‰:+‹9+‹8*‹8*ˆ9*…9)€<)z=(w?(t@(ƒ=3{7,x8,z3/>3/=2.=2.=20=20>31>31>7/C41O/2Y*2_%3`#2Y%1N+1B3077-39+68*?5)N1)]-)e+)c;3h<3r=7z=:‚<<†<=‡;;…;:‚;9>8€A:C;‚C<ƒB<…@9„?8E/D/C.ƒ@-†=,‰<,‹9+Œ9+Œ6)Š7)†9)‚;)~=)w?(sA(qB(…6/|/'8/ƒ?4w5)s5*}A6}C7E9G<ƒI>„J?…K@‡LDŠOGŒSJycL~hSoYu]}bˆi„•u‚ |¥~|©€~¬…­†€ª„¥€|ž}{˜yn}ŽlyŒlwŒkwŒmt‰joƒgl~dbqZ[hTSZHIK=B@4=6,8/&5+":&(8%'6&'2&&0(&-)(++)).*'+*&,*&,*'+*'+,)*,**,**,-#$2*(50,85,BC5UZFfpWn}^tˆcqŠbt‘ex˜iw›ks™hs›iwŸmz¢mx lwŸkv¡ly£q{¥u{¥w|£wxžuzœww–tqŽom†hd{_WkPJ^CFB9>:195,560560671671782782872872983<94=:5>;6>;6?:6>95>95?74?74>63=52;62:5294194184184195484373243132021/6-.6-.6-.6-.6-.4..4/,4/,40-40-40-52-32-32-43.43.431431542540841850940:5/=60?6/@7.B8/C9/F90G:1H;2F<3F<3F<3F<3E;2C90B71A60@5/@51>50=4/=4/>42?53?53=82A64I35Q16V.6U-5R/5J22A62::08<.9;-?9)H6*P4)U3)]2+c4.k62t76}77‚89ƒ7978}75{:6|=8{?7@9ƒ@:…@;†?;|E0}D0€C0‚A/…=.‡;-‰:-ˆ9,‡8+…9+‚:+<+{>+x?+uA+tB+‹2,‹2,¡LE§XQŠA8|90‚F;€J>yH:zJ<{M@|NA~NB‚PE‡UJYN_uNgwRtzX€{^Š|b“i›s›—|™zˆ |ƒ¨¬ƒ|¬‚x¨~t£yq vŠpˆo†nƒŽp€p}px‹ms‡kk~bgu\_iQWZGPM0%:,+7,*5+)1,(-,'+.').((/().(+-*,,*/+*3)*6',7&,9&,2)$<3,E>4JF:QR@]bLgqVizXmƒ]j…\j‰]p‘bq•eo•do—eršhu krhq›itžlx¢rz¤vy¢vyŸvvštw™tu”rokj…fc|^UlOJ^BHA9@91;4,671782782782893893983:94:94=:5>;6?<7?<7@;7@;7@;7B:7B:7A96@85=84=84<73<73<74<74<74;74:6395284173080.80.80.80.80.80.61.61.61-52-52-52-63.63.54/54/540540651952:72=84=82@93?80A8/C90D:0E;1H;2I=1I=1H>4H>4H>4G=4F<3D:1B8/A60B71@70@72?61?61@72@72A83=84@85B86D97E:8G96G96E:4C90B90B:/B:-D;,F:*H;*H;*].&b0)n3/x73ƒ98‰;;Š<<‰>;‹A>†A<?6}=4~;3‚;5ˆ=8Œ>:~C3€B3€A2ƒ?2ƒ=1„<0ƒ;/;/;.|=.{=.|>/|>/|>/}>/}>/—.*£;8ÎkfÙ~y­ZTŒC<ˆLAN@tJ:qM=pQ?qR@tSB{VD‚[J‰_OUOe€Uz~[‘y_¥ra³of»rk»xo¶…vªz ›~•£€Œ¦ƒ¦~}¢yyŸvŒr‹rˆ‘r„“r€•t|–sv”ps’pl‹ig„eby\\lQU_GMP;ED0A<)>3-<3,92*41(01).1(+1'+0)/0*2/*6,*:*+@'+D%+G$+H#+A7+LC4WP@[XE`bLgmQiwVj{Wl‚[g‚Wf†WjŽ^n”an”an–bršfržko›hnšiqœnw¡sy¢vxžuu›ts—su—ts’pn‹li„cb{[TmMH`@MD=E<5@707827828938938939:4:94:94;:5>;6?<7@=8@=8A<8A<8A<8A<8A<8A<8@;7?:6>95>95=84>95>95>95>95=84<73:51940:0.:0.:0.91.91.91.91.72.61-61-63.63.63.74/74/74/540651961;83<94?:4@;5B;3A8/B90C9/E;1H<0I=1J>2K=2K>5K>5J=4J=4F<3E;2C90B8/B92B92A81@72@72@93A:4A:4?74>95=<7>?7?@8@@6D@5J=4J70N5.Q6-Q6+O8*M:+I<)H=)l3(r6,~;3‰@:•DA›HDŸJGŸLH QJ—MDD;„;2‚8-…7-Œ91;4…?7…?7†=6…<5ƒ=5€=4|>3y?3vA3uA3uA3y?3}=3ƒ:3‡83Š73Ÿ%$´<;í{zþ•’Åhc–G@‰K@wI:mNfW@jX@r\E}aL„eQj{O{{U™w\´l`Ì^_ÚR\áM[àO^êmuÜxxÎ…~¿€²–€§—}ž•x˜“u•Žr”r‘‘u”u‡–u—s{–sx–rq‘lp‹hiadtW]gLVX@LJ3GB.L40H3.D3,?2*:1(70&40'40'81):/+?-+C++H(+M%-O$-Q#-PE1[P:d^FgfJilOnuTm{Wl~Vk„Zg„Vg‡Vm]p•ap—br™dvhrœlo™km—ip™mwtyŸxw›wt–us•tu”tsqoŠki„cb{[TmMGa>SJCKB;F=69:49:49:49:49:4:;5=<7=<7=<7?<7@=8@=8A>9C>:D?;D?;E@8C>8D=7B;5B;5B;5B;5B;5B;5A:4A:4A83A83A83@72@72>71>71>71<71<71;60:5/85085074/74/761961961:72<71=82A:2B;1C:1E;1F<2J>2K?3L@2N@3N@3M@7M@7L?6K>5I<3F<2E;2E;2B90A81A81?80?80?82@93@93<5/LE?IB:E<5OB:K:2J3+\>6Z5-`5.`4+^/'\0%b8,g@1gB2‹I;G;–I?žLAŸF>›>7š=6žD;¥ND£QE¨VH«YK£PBš@5˜:0ž=4’9;9:Œ67†54„96ƒ@:{@8o?3oC6lB4m?2u:274Œ35’-3–(1ÏEEèbaÅEDÍWUáyv«VO†F<‚WGlS=f\CedFgfHgbEm_DyeL†nVŽdK­p]ÍphÞW]å8Kð(Dü&Hþ+Lþd02b22\31L)'D'#I2,J70F5.E2,E0+H0.I-,I)*O+-V24VK/`W:f_BgdEkoLu}Xu„]oWj„WlˆXnŽ]q“`s•bu˜bušdv›eq–ks˜ms˜oq•os•rw™xz™zy–zx•yqŽrm‡jj„ghƒdazZTnKIc@TKBSJAPG>9:49:49:49:4:;5;<6>=8?>9>=8@=8A>9A>9B?:D?;D?;D?;FA;E@:E@:E@:D?9D?9E>8E>8E>8E>6E>6D=5C<4D;4D;4C:3B92B92B92B92A81A81@91@93>71<71;60;60:5/85.74-74-96196/96/;60<8/>:1A:0C:1C;0E;1G=1J>0L@2M?2NA1NA1N@5N@5M?6J=4I<3H;2E;1E;2C:1B90A81@91@91@91?;2?;2C:3G81I0,V..j68u99{;;†ECƒD?„H@…I?†G>ŽJA›NH£PL¥MK’E3”C2šB4 B6 >36-7+¡<0£C5›@.™@. E3¦F6©E5¯H9¸N@´KR¯GN¥@F™9=‘8:Š?<€A:r@5k?2uK=€NC@:‚,-“(0µ8FÒK\àJIáMMÌ>=Ã>?Ò_\µXQ„@5€UDvbJa]@Z_?ekIonOshJ{fK†kPÌ]VÚ][êSZó7SD=]P.dY9ga?ifCnrMz‚[z‰bt†^r‰]oŠ]oŒ^qŽ^u’bw•cw•cw•cr’mw—rz˜vy–w~˜}ƒ„…‡ƒ›…™ƒz’|q‰ql„jhc`yYTnKJdAWQEVPDUOC8938938939:4;<6<=7?>9@?:@?:B?:C@;C@;C@;D?;D?;D?;FA;FA;FA;E@:E@:G@:G@8F?7IB:HA9H?8G>5F=4E<3E<3D;2D:1D:1D:1C:1D;2D;4D;4C<4?80?80<71;60:5/:5/94.94.96/96/96/;7.<8/@9/A:0C;0E;1F<0I=/K?1M@0M@0NA1M@0N@5M?4L>3K=2I<3H;2E;1D:0C:1C:1A:0A:2?;2@<3@<3A=4SE–I?•MA›OB¬RJÃSRÏNSÒENœE2B0 @0¥?1¦:-¥7*¦8+§=/¬E4¡>+˜7$:%¥>+®@/³B2¹C5§/8±9B¹DL¾KR¸NRªLL“B>}:1u;/q9,s5*2-›47º8@?:A@;BA4G=3F<2E;1D:0D:0E;1E;1D;2E<3E<3E<3@91?80?80<71;60:5/:5/:5/96/96-;7.;7.=9.@9/C;0D<1F<0F=.J>0L?/M@0M@0O?/O?/O>4O>4N=3K=2J<1G:1G:1D:0D;2D;2B;1B;1@<3A=4A>5A>5Q9/X+&‰:?ÅP`ãOeñOfíPcÐGO¢20”:/Ž?.–C3®F=ËFGÞ>Hã2B§H6§F5©B3®@3°?1²>1³B4´D6²G5«B/£<)¤;&©<(­:(¯5&®3$¸7<»8>½7>½6=¿9@?:BA4G=1H<0G;/E;/E;/E;/E;1E;1D<1D;2D;2@9/@91@91?82<71;60;60:5/;7.;7.;7.<8-?8.A;/C;0D4N=3N=3J<1I;0G;/F90D:0D<1D;2B;1@<1A=2A>5B?6C@7_4-t42¯KSâYiðH_ð:Qá2C½#+¬/)š9(;&•=)¬@3ÈA=Ý:?ä0;¨D4¨B3«?2®>2´?5¹C7½G;»J<¬>/ª?-¨=+¨:)ª9'²:*¹;-¼ÃLDËTLÑTNÙKJÝ>Cã3>è.<Ù5+Û7.Ò0+Ò94Á82µ@9µ[P”UDxO9~dI„lPbF]F®eTÍqdÛsjübÿ?eÿAiÿBkÿBmÿAmÿ@oÿ@oÿ@qÿAqÿBnÿ=hÿEmÿJpöGhíMièZrÛbs½YcŒ@D]($M-"PC2PR=CO76H.WH1eYCujT€{gŽy˜œ‹”Œ‡”ƒ~‰—ˆŽœŒ™ˆ‡’‚Š“‚—žŽ¤¨—²¶§¸¼®¿Á¶ÀÁ¹ÂþÅÅÃÃÃþ¾¾²´³¢©¢—Žy‡vh{e\sWTmONiHTYBUZCW\E560560671782893:;5=<7>=8@?:B?:C@;DAGB>GD=GD=HC=ID>IE0I=/G>/G>/F<0F<0E;/E;1D<1C:1B90A:2@91@91?82<71;60;60;7.;7.;7,<8-?8.A;/D0K?/M@0NA0P@0O?/O@-P>2N>1M<2L;1I;0H:/F90C9/C;0B<0B;1@<1A=2A?3B@4C@7t50–FEÆY_ßUbã@Qä5FÚ0;À*+¯1%Ÿ9#•;!”: ¡=&·=.Æ90Ê2- :,¢:-¥9-¨6,°91¸A9»E;·E:­?2«@0§<,¤6'ª6)·=0ÄD9ÊG=¾9*Î@4áD=ïA@öDâ<@×?>ÎC>ÍJB×RMåZWéPRìELï;Gõ6F÷2Dø/Bû1Gÿ6Lø:Tø:Tø:Tû:Wþ=\ÿ?aÿBeÿDiûhú?júAm÷@nõ?oò>mï=mÿFnÿ:aÿ>dÿInÿJløMmòSoæXnëp‚Å_j˜ILt:6\6-O9+OD2SN:`PArdWˆ|p”Ž‚Ÿœ“¦§¡¡¦ ”˜”Ÿ›¨¤¦¯¬¦¬ª¤¦¥§§¥µ´°ÄÀ½ÍÉÀÒÍÇÕÐÌ×ÏÍÖÍÐ×ÎÓÑÊÑËÆÌ¿½À°²±˜Ÿ˜€Œ€m~k^u[VoQSlNU_DV`EWaF560560560560671893:94;:5=<7@=8A>9C@;DAHC?HC?GD=HE>ID>ID>JF=LE=MF2G=1F<0D<1D<1C:1B;1A:2@91?82?82<71<71<8/<8-<8->7-@:.B:/D2B@4@@4+)¨JKÁSV¾=BÀ/6Ç.3Ä./»0)ª1 £9!›=!–=˜= ¡=#¥;#¦6"6- 8/¢5.¦3,®71·@:¹B<²@6±B7­A5¨7È`UÑq¤eSŽWC‡N:¡XGÊe[ãa_ëPTëBIùDKí@DÞ@?ÑB<ÅB8ÁB9ÌIAßPLìKPô@Kù9Hý7Hþ5Hø3Eö7G÷=K÷9R÷9Rø7Rú7Uý7Xÿ9]ÿHC?ID@HE>HE>ID>JE?JF=MF>MF2G=1E=2D<1C:1C:1A:2A:2@93?82<71<71<8-<8-<8-?8.@:.B:/D2??3@@4”67Á]_ÈZ[¯78®,,µ/,±,#°0#¯8$®B(©G* G'šF$šF$–C!”? Ÿ81£;2¦92¨50°:6¹B>¹D=±>7«<3¨<2¦»72»:Ê<$á:*ñ.(ÿ$&ÿ'ÿ'ÿ%ÿ%(ù,)ñ2*ë5*è3(è2'ê/&ì-%Ü=(Ñ2Þ>0Ñ5)Ê7/Â?7¯C9Çqd²m]–YF™VE¿i\ÝlfãSSë@Hù?Lï4¹6,½4.Î44ïBHø8Gÿ2Fÿ3Hÿ5Iú7GöYÿ=Xÿ:Wÿ6Wÿ5Yÿ5\ÿ6_ÿ7eÿ;kÿ:mÿ;oÿtû>vôEbýNkÿTqúIfð?\ÿRqÿfƒÿf€ô^wêbváky×s{Ärvªfe”ZV‰TN’€~¨™–¾°°Ä»¼ÆÁÅÈÇÍÅÈÑÀÄÏÆÌØÈËÚËÍÜÓÐáÚÖåäÜëêßïîáòòäãõççöçêóâèñàêïßêìÜéå×äÓÉÒþά©—y‡vi|f`w[\uWbqRapQ`oP201312423653875984984983;:5<<4==5??5AA7CC9EE9EE9HH@HH>HH3B90E<5C:5@85?74@86?67>56:44F85E76B87@78>:;<:=<<>==????A@,§B0©D2©D0©B/¨?,«>*­<*µ=-¾C4ÅF7À>0·3&Í6+Ì8,Ì:-Ì=/Ï=.Ô(Þ9%Ô4Ï4 Î9%Å8&¾6&Æ@4ÕQEÒIAÜMIïUUüVXýJPø9Aü4?ÿ9DäCHßCFÓAAÆ?;¹=3®=/ª?/ª@0¿Q@ÉQCÑLCØC=å??÷@Eÿ>Gÿ8CúGMúENûEQþESüARú=Sü>XÿCbÿGiÿBhùHH7H?8F=6C:5C<6A:4?74?74@85>95=84;63>3/=4/>42<74=98<;9=<:>=;@?;C@9G@6J@4L@0O@-P?+P>(=B,?A,E=0H92K63J46F35A57>=;8=69?5?A4C=-J9)^B4sRC¼K=¬;- 2#¡6&£:'8$ž9%£?(¡;%¦=(­@,³@-¶=,·9*¸6(¹5(¦;+¤:*£9)¥;+¦?.©B/«B/«@.­?.«:(±<+¿E6ÆH9Á?1¼8+½7+Ï5+Ï7,Î:.Ï;/Ó=/×;/ß8/ç4/ð0-õ--÷-+ò/+ê4)ß8(Ö;'Ï=&á:'Ù7"×8%Ô=*Ì;*Á5&Ã;/ÍG<ÐG?ÙJFèPOóPQôGKò;@÷:Aÿ?GàDGÜDCÓB?Å>8·;1¬;-ª<-©>.µF5ÅM?ÓNEÜGCã?@ñ>Bý>Fÿ>H÷DJ÷CLúDPÿFTýBSú=Sü>XÿBaÿFhÿCiü?iù@lùBpûGvüJzþL|ÿIxÿHtõKpðRsò]zö`{ùXwýMqÿCkÿAlóCjÝJgÉ^p®pugNI†‚v´”‡Ì²¥äÔÇëäÜèéäéêîéçòíáõöâûýàüÿâýÿçþÿìÿÿòþÿ÷üþúûþûöýúõü÷ôúôôøïðôëîñèëïæëäÞâÜÖØÊÆÅ²²°ž ›Ž“Œˆ…ˆ…–†‰€†}/.,0/-10.21/43/540762761:94::2<<4>>4@@6BB8CC9DD8IF=IG;JH;KJ8MJ7NL7NL7OL9KI:NKBTSQ_^dihxmm…lkŠihˆcYd[QZQGPJ@IH>FG>CC=A@::1>:1=90:3-94.;60=82=:3>;4?<5?<3C?4F@4I?3L@2O?0P?-Q>-P>*3@&7?'<=+A;-B8/A62>42;31=85B:7H94O2.[+)o-.Š:= EJª9+¢2$Ÿ1"¤9'¥<)ž7$8$¢<&¤;&¨=)±A-¶A/¹>.»<-¾:-À:.®>0¬<.©9+¨:+ª<+¬>-­>-¬=,²?-®9(¸>/ÊL=ÊH:¼6*º2&Å;0Ó5*Ô6+Ò8,Ô:.×;/Û9.â7/é2,ñ/-õ.+õ.+ñ0)ç2'Ý6&Ó8$Ì:#à7$Ü5#Û8'Û>-Ó=.Æ7)Å8.ËA7Ç<5Ì?8ÙEAåKIìIJëCCí?Að@CÜDC×C?ÏB;Â=4¶:.­9*ª;*«<+ª9)¿E8ÔNEÝIEâ?@ëXÿ@_ÿDfÿCiþDmÿFpÿIwÿK{ÿL|ýK{ÿCvÿGwÿJtúNtþZ|ÿa€ýUvòCdüHkÿRvÞ=\ÎH`Úz†µ}~\F;„r³‹Õ³§óÛÑúíåøóðøøú÷ôýôëüüêÿÿéÿÿëÿÿíÿÿòÿÿ÷ÿÿûÿÿýþÿþúÿýùÿûøÿøöþõöýòöûðôúïóðçêåßáÓÏξ½¹­®¨¢¥œ£™£—¤ªœŸ¥—œ¢”/.,/.,0/-10,21-32.54/650872991;;3==3??5AA7BB8CC9IE<0?=1@<0?<-A;+F?/H?.K?/M@/O?/P?/Q>/P=.<@)=?*?>,?<-?;0=:3;:5:94<94D95N43[*-o&--8¨3C¶7H§7)¥7&§9(ª?-¨?, 9&Ÿ9#¤;&¥:&«<)³>,¹@/½>/Â<0Å=/Ç=0¹@5¶=2²:,®8*¯9+°:,²:,²:*¶;,¹;-ÄB4ËE9Ç?3¾1'À2(Ê:1Ú3+Ø4*Ù7,Ú8-Ü8.ß7,æ3,ì1,ó0,õ.+õ.)ï0(æ1&Ú4$Ñ6 Ê8Ü/Ú0Ú4$Ý;,ØVßetû §Í‘]=2aP@©wlÑ¥œöÔËþêãÿôòÿþÿÿüÿùóÿüïÿÿïÿÿðÿÿòÿÿôÿÿ÷þÿûýÿüûÿýùÿüøÿúøÿù÷ÿö÷ÿôøÿôøþó÷öëïìãäÚÔÔÉź¹´³´¬±´©²µª¶¾³°¸­¬´©10,10,0/+0/+10,21,43.54/77/880991;;1==3??5AA7BB8KD:LF:OG:QJ:RK9SL9RM:QK=OKBVTUfdowx††¨»“ÃŽ‘ÆŠÀ‡‚¸{w©rlœid_[~UPnNJaJGXEBM?=B;7696196-86*86)581692891;;/><-?<+C<)D<'I>*J?+L?,M@/M@0M?2M?4L>3M?4K?3F<2B90=909:25<44>57<5>:1H3.\0/{48œ;D¯9E²2Aª<+ª<+«@.¬A/©@-¥<'¥<'©>*§8%­:'µ<+¼=.Á;/Å;.Ê<0Ì<1ÁA6¾>3º:/·7,·7,¸8+¸8+º8+»7+ÇA5ÍC8Å8.Á1&Æ3)Ë7-Í6-à2+ß3)á5+â6,ã5,ç4-ê2*ð/*ö/,ø.*ô/)ì0'ã1#Ù4!Î6É7Ú/Ù/Ù2"Ù5)Ù9-Ô:0Ö?6ØE=ÕF>Í@9Ç<5Ë@9ÖKDÙNGÐF<Å;1Å=1Ä<0ÀCí>EóBJûJTÿJYýFXúCYýB]ù@_ûBdþFjÿJsÿOxÿOzÿLyýIxÿGwÿRÿQ}ÿIqûImÿStÿVtøNiëD^äF]èYkÿ—¢ÿ¶¼î žˆKFd2)©jcÍ–ôÇÁÿãÞÿòðÿüýÿýÿú÷ÿý÷ÿÿöÿÿöÿÿøÿÿùÿÿüÿÿýýÿýúÿüøÿûøÿúøÿø÷ÿ÷øÿõ÷ÿôøÿôøýñóóéêäÜÚÖÑÍÍÊÃÉÉ¿É˾ËÍÀÇÑȾȿ·Á¸84163.52-30+30+41,52-63,85.96/:70<90>;2@=4B?6B?6KC8ME:PF:SJ9TK:UL;SL<=;:6;8396/267465672880<:-A<)D>(G?(I?&J?)IA,JA0IA4IA6HA9G@:R9?ž46§<*¨=+ª?-ª?-©>,©>*¬?+¯@-«8%²9(¹:+¿:+Ã9,É9.Î:0Ò;2É>7Æ;4Ã81Â8.Â8.Ã9/Â8.Ã6,Ä7-ÑC9Ò?5Ä0&Ã,#Ð7/Ö<4Î4,æ1*æ1*ç2)è3*ê3+í2+ð/*ó.(ø.*÷-)ò/)ì2&ã3$Ø5"Ï7 Ì7Ü5#Ù3#Ø2$Ö2&Õ5)Õ7,Õ;3Ö?8ìYRáRJÓHAÊD;ÉF<ÊJ?ÅG;½?3¼;(¼;(º;*¹:)·:(¸:+¼>0¿A3ÁA6Á<5Å<6ÏA?×EEÝGIãJMèMQëADì?EðCIúJTþN[üJZüF\üF]øA]ùBaýEiÿJpÿNwÿOzÿMxÿKxÿR{ÿR{þOvýOtÿVwÿ]{ÿSoîD^øUjîQd÷dtÿ’žÿ‹“òƒ‰Ç`c­KL²keÏŽˆñ¼¶ÿÞÙÿðìÿúúÿüþýûÿüûÿþûÿÿûÿÿûÿÿüÿÿûýÿûûÿûøÿûøÿüùÿûùÿûúÿøúÿöøÿòõÿðóûìïòææçÝÛߨÒÛ×ÎÝÛÏàÞÑàáÓÚãÞÏØÓÅÎÉ<94;8385052-41*41*52+63,74-85.96/;8/=:1?<3A>5B?6KA7MC7RF8UI9WK;WK;UL=SJASJK[Xcnl‚‚‚¨‘”Çš Þž§ì¡©ò¡¤óž í™›æ•˜ß”•Ö̈‰¿‚ƒ±zz rq‘fd|XWiPN\IGRFCJDBG=?K==G;:?;:8<92A;-D=*F@*F@(GA)GB.ED2CC7BC=AC@>BAG9HH,©>,ª?+­@,¯@-°?-°=*±8'¶8)½9*Ã9,È8-Ì8.Ò91Õ;3Î;4Í:3Ë81Ë81Ì92Í:2Ì70Ë6/Ó<3Õ>5Ò91Ì2*Ð3*Ù;2Ú<3Ó5,è0(é1)ì1*î1+ñ0+ò/)ô-(ö,(÷-)õ.)ñ0)ê2(â5%Ù6#Ò7!Í8 Õ8%Õ8%Õ5%Ñ4%Ò4(Ô6+Ô7.Ð7/ãNGèXPçZQØRIËH>ÃE9¼B5·?1¹<&¹<&¹<(¸;'¸9(º;*À>0Ä@4ÉD;Æ?9É@:ÑFCÕIHÖHG×IHÛJMìCFêADíDIöKSüQZýN]ûL]üJ`öD^÷DaùFfýIlÿNuÿOxÿOxÿNyðYzðWvóVuüYxÿ]{ÿZuûQkòI`ýWköUgêN\ö^kâKZçSaçSaåQ_¸jfÉ‚~窧ÿÓÑÿëèÿôòÿøùÿÿÿùýÿùüÿûüÿüüþüúûýùøüøõü÷ôÿú÷ÿûøÿüúÿûúÿøøÿòõýîñúëîðââëÝÝäÙÕâÙÒæßÕëçÛñîßóñâêóðÜåâÏØÕ@=6=:3:7074-52+52+52+63,74-74-96/;8/=:1?<3@=4A>5M@7OC7RF8WJ:XK:YL-C@-CB.BC3AE7>E=€UE’YFL7A+“A+«@,®A-®A-®A-°A.²A/²=+°7&µ7(¼8)Â8+È8-Í6-Ñ7/Õ8/Ù;2Ò73Ñ61Ñ61Ò72Ô94Ô94Õ81Ó6/ÞA:Ö8/Ñ3*Ø7/Þ=5Þ=5Û8/Ù6-ë0'ì0'ï0(ò/)õ.)ø-)ø+(ø+(ø-)ô/)ð1)é4)á5'Ù8&Ó8$Ï8#Í8$Î9%Î7$Ï6&Ð7)Ô8,Ó7+Î4*Ì3+ãNGôd\ë`YÔOFÂB9¸<2´:/·?&¸>&·=&¸;%º9&½9*Á;/Ä>3ÌC9ÊA9ÎE?ÕKHÓLIÎGDÌFEÐJIéFGæCDéDHòMSùRZùR\ùN^úOaõG^õGbøGdûIiÿNrÿRvÿRyÿRyå[uë\xõ`}ü_|øUpõMgùPgÿYnÿ[mÿbsóL]úSdøM_ÿRgüI_ýE]³d`¾tqÚš˜ûÈÅÿåãÿîëÿõôÿÿÿûÿÿùÿÿùÿÿúÿÿüþýýüúýùöýøõÿøõÿùöÿúøÿúùÿööþððøêêõåæìÜÝèÚÙæØÕèÞÕðèÝùóåþûêÿþíòûúâëêÔÝÜA>5@=4?<3=:1;8/96-74+63*52)52)63*74-:70=:3@=6B?8J@6OC7RF8VI9WJ9XK;ZL?[NHTIMXR`gd|}©’Ì—Ÿçž©ù¤°ÿª³ÿª³ÿ¬³ÿ«³þª±ùª®õ¨«î§«êŸ¡Ü™šÒÁ±ur¡he’]Z…XR~YP{YQxVOpOG_E?M?:@?;8@@6>>2@B5@F:>E=:C>9CB*®?,±@.³@.´?-¶=,¹;,º6'¿5(Ä6*Ë7-Ñ7-Ö8/Ú91Û81×84Ø95Ù:6Ú85Ø61Ø61Û83Ý:3æC<à=6Ú70ã@7þ[Rÿlcÿ]Tã@7é1'î2)ò1*ô/)õ*&÷'%ø(&ú*(ø-)ó0*í2)ã1%Ú0#Ó1"Ò5$Õ:(É=&É=&Ë=)Ï<*Ñ;,Ò9+Ô8,Ó6-Ú@8Ð71ÜGAôc^ãXQÉB<Å@9·3.´<#¶<$¹<&º<&½:(¿:)Ä<.Ç=2È>4ÌC;ÙPJßXTÓOJÁ@;¿@:ÊKEäFEäFEèJKïPTòQWïNVïKVñL\ùRdøOf÷Ke÷JfüMnÿRsÿRvÿPtê[wêZuðZuú[wÿ]xÿZsÿWnÿViÿctþVgÿ\mÿYlõDXùBXÿMeÿIb·nh­hcËŽ‹èµ²ùÑÏÿêéýïîúù÷øþüøÿÿøÿÿøÿþúþýþþüÿûøþöôþùõÿû÷ÿùöÿöôÿööÿõõöèèçרäÔÔÞÐÍãÖÐñçÝüôçÿøèÿüéÿÿí÷ÿÿèñðØáàC?4B>3A=2?;0=90;7.:6-95,73*73*73*83-:5/=82@;5B=7I?5LB6QE7UH8VI8YI9YK>ZMEUKLXP_ebyz¦‰É”œäš§ö ¯ÿ«´ÿ¬µÿ­·ÿ¯·ÿ¯·ÿ¯¶ü¯³ú¯²÷§ªí¢£ä˜˜ØŒŠÉ€~½uq®ie¢b^›cVŽbU‹]TƒWOtNHdFCTBAIAAA;=8@C9ß<7ß<7â=9æA=èC=éB<èA;ç@:èA9ä@7Ü8/Õ1'Ø6+ëI>þ\Qô?4î6,ê+#î)#ù,)ÿ./þ,-ø((ú0.õ4/ï7/ç6,Ü4)Ö2&Ó3%Ò5&Å='Ç<'É<(Ì;(Í:(Ï7)Ï6(Ð4(Õ8/Ï5-Õ<6åPJçSOÛLHÏA?º/,¹=%º>&»='½<'¾9(À8(Ã9,Ä:/È>4ËB:ÕOFÜWPÒQKÃD=¿B<ÆKDáIFáIFåMLëSRíTVëPVéNVìOZ÷VføUhùSiúRküRmÿSqÿStÿRsïNoøTvÿ\|ÿ^{ÿ[vÿUoýQgûReüUføQbÿZhÿZjôM^úRcÿWiôI\§ha™\W·€{Ù©¥ïÇÅýáÞùêçýøõøýùøÿÿ÷ÿÿöÿýùÿýÿÿýÿûûÿö÷üùòþùõþùõþöóÿ÷õÿõõøêéêÜÛäÖÓÝÐÊáÔÌïåÙüõåÿùçÿýéÿÿì÷ÿýèñîÙâßEA5EA6C?4A=2?;0=9.<8-;7.84+84+73*83-:5/=82?:4A<6G>5JB7ND8RF6TG6WG7YI:YKBWKKXP[b^wsuž…ŠÂ™Þ—¤ó¬ÿª´û¬¶ý®¸ÿ±¹ÿ²ºÿ´»ÿ³ºÿµ¹ÿ¯²ùª­ô££ë™—àŽŒÕ‚€Éxt¾qm·l`¢i]dY“^V‡VQyNKhEDV@@J76;?=>HBBKABN?BYFJmX_}fnt¤}¬§‚®¬}§´w ¾p—Âc…ÃRpÅE^ÔI\×EPÊ9<¾3,»7(¸;%³; ¯<*¯<*°;)³;*·<,»<-À<-Ä<.Ä6*Ë8.Ô<1Û>5á@8á>7à<3á:2Ü73Ù40Ø3/à93èA;ìE?êA<å<5ã<4Û4,Ø4*Û7-Ô2'Ì, Ö6*èH<÷I>ò@6ï4-ð-)÷+*ý+,ý+,ø*,ñ))ì/+è3,â5.Ü4+Ö2(Ô2'Ô2'Ç:&È;'Ê<(Î;)Ñ;*Ò:,Ô8+Ô8,Ñ4+Ø;4Õ:5Õ<7çONîXYÙEEÅ02¾=(¿<(¿<(¿:'Á9)À8*Á7*Á7,Æ>2ÇA6ÏJAØUKÑRIÄH>¿E:ÃH@ÚIDÙHCÝLGäSPåSSâPQâMQåNWòXdöZhý[pþZrýUoûQlýPnÿRpÿFmÿOvÿZ}ÿ[{ÿVqÿSkÿVkÿ[mûYhúYhü`mö`kî\fñenífmÚT[’cY}ND™lfØ’ß¹¶ñÓÑôàßþöôøú÷÷ÿý÷ÿÿöÿýùÿýÿþÿÿýÿÿ÷ûúúòüùôüùôýøôÿùöÿøöùîìñãâçÙÖÝÐÈÜÒÈîäØýöäÿûèÿýçÿÿè÷ýùêðìÝãßIE9HD8FB6D@4B>2@<1?;0>:/:6-95,95,94.:5/<71>93@;5E>6HA7LD7QE5RE4UF3WG7WIC_@EmDJ€OU•]f¦jrÇe˜ÍkœÏl›Ïf‘Í]…ÎTyÌFgË8UÌ0Hß>PäBMÔ:<Æ7/Ã@.ºB*®/Û?0Ü@3Ü@3Ò6*èKBåJEÎ50àFFóZ\áHKØ?BÆ=-Ä;+Ã:*Ã:*Ã:*Ã9,Á9+À8,Â<0Â>2ÈF9ÏOBÎPDÄH<¿C7¾D7ÑF?ÑF?ÕJCÛPKÝROÙMLÚKMÜKPëX`ó[hüaqÿauûWoõOgõMgúPkÿJuÿOyÿSwÿRqÿSmþ[pÿcuÿixÿguüaoôbmìelàglÔjjÉjh¼c_dVeH:_Tª‡Í«©åÇÇïÚÙÿóóùøöøþü÷ÿÿ÷ÿÿûÿÿÿþÿÿüÿÿ÷þûüôúûóûúõþûöÿýùÿûøþôòøíéêßÙÞÔËÝÓÇíæÖÿøåÿþèÿÿæÿÿçõúóêïèáæßLI:KH9JG8HD8FB6D@4B>3A=2=9.<8/;7.;60;60<71>93?:4B?8EA8JD8NE4PE1TE0VG4XH9ZMEVMR[Whkl‹~‚²‰“Ð’Ÿå™§ò§­÷©¯ù«±û­³ý°´þ°´þ°´þ¯³ý«®û¨«ø¥§ô ¢ïšœé“•⊌ل†Ó…É{u½mk­dd _a”X[†QQsNHbUFY_CRlBLEO˜LV¬U]¼[dÅ]fçJuéNxæPuàLn×FcÒ?YÍ5JÊ+?Ú5EçAMéFKÙ><Í>6ÊH8¿J6°B)·>-¸=-º<-½>/Ã?2ÊB4ÐD7ÕE:ÙE9ÚB7Û>5Û:2Ù6-Ù5,Ú3+Ù2*Ô1*×4-Û60Ý90ß80Þ7/Ý6.Ü5,Ö/&Ù5+Ø6)Ï2#Í1"Ò9)Õ>-Ó<+Ö=-æD7÷KAÿD?û56÷)-÷)-ù.2ø67í55â30Ú1,×/,×/,Ù0-Û/-ã80â:1â:1â<0à<0ß=0Ü?0Ú>1Ñ7+ïWLù`XÓ;6Ó;:èOQÞEHèOTÍ=2Ê:/Æ8,Æ8,Æ:-Å;.Ã;-À:.¾:-¾<.ÁB3ÇH9ÇI:ÂD6¾@2¼>0ÊE<ÊE<ÎI@ÕPI×RMÔNKÓKK×LOçZ`ð^hüfrÿhxü]qóOgóMeùQjÿPzÿQxÿQpûSmø\qûhxûjw÷epüfró_kí_kêkrÝsu¿lh¦f\¡l^ujXVI8kXJ–{t¾ŸœßÁÁïÕØþîïûõõúüûúÿÿùÿÿýþÿÿýÿÿûÿÿ÷ÿýÿ÷ûþõûüöÿþùÿÿúÿþúÿûõÿ÷òñèáäÜÑáÙÌðé×ÿúæÿÿæÿÿãÿÿäöùðíðççêáQK=PJ3Õ;1Ö8/Õ4*Ö3*Ø4+Û4,Ü5-Ú9/Ý<2à=4ß<3Ý90Ü5-Ü5,Ý6-Ò.$Ý;.Ü<.Í1"Å.Í8$Ð=)Ì;&Ë:'Ò9+á:1ó=9ÿ@@ÿ;?ÿ27ô+1ê,.ß+,×+)Ó+(×/.Þ44ä88è:;ó55ò64î73é6/ã7-Ý5*×5(Ñ5&Í5'çPEÿmcÛHAÈ42×CCÓ>BêUYÙB;Ô=6Ì70Æ6-Ç9/Æ<1Ã=1Á=.»9)»<+½@.¿B0¿B0¾?.¼=,»<+ÃC8ÄD9ÈH=ÏPGÒSLÐOIÐOJÔOPç_cîaiûitÿm|ÿdu÷UjõRgýWoÿSxÿUtûWpð_pñoyôy~êmsÞXaïamò`mïaoðs{숊ɂ|¥wjšyhhpYMO:^WGƒqg±•’Ý¿¿ñÔØýéëþôõýûþûÿÿúþÿýþÿÿýÿÿûÿÿöÿüÿøùÿõúýôÿÿúÿÿúÿÿúÿý÷ÿþöùðçíåÚéâÒôïÜÿûåÿþåÿÿãÿÿâøúíòôçîðãSM=RL4D=5B;3A:4@93A:4A96B:7@A;CC;IE:NG7QF2RF.UF/WH5XJ=RHFXR\jh€}§‹’Æ’žÚ–¤å¥¦ù¦§ú©ªý«¬þ¬­ÿ­®þ¬­ý«®û¨¬ö¦ªó¤¨ñ£§î¡¨î §ë¤è›¢æ™žâ’šÛŠ”Ò…Ê‚ŽÂ‚‰·‚©‡yšŽmˆšczªWi¾P]ÓKWäGPí?Hñ9Aî;6é<5âB6ÙH7ÎJ5ÅG1ÂD.Å@/ãUGàG?Ú;7Ø64Ø88Ö:;Ï98Ê66¼=.¾<.¿;.À;,Â8+Ä6*Æ3)È1&Í5*Ð3*Ñ3(Õ2)×3*Ù5,Ý6.Þ7/Ü>3Ý<2Ü;1Û8/Û7.Ú6,Ø4*×3)Õ3&Ó3%Ñ4%Ï6&Ò=)Ñ>*Ê9$À2Æ;(È5%Ó3'ç60ü;<ÿ=@ÿ7=ù27ê-1à..×--Õ0.Ü44ã9:é;=ë;>ý.4ú/3ö01î1/æ1*Þ2(Õ1%Ï3$È2#Ð>/új_ãTLÈ95Ð@@Ë:=ãRUçJEÝB=Ò93Ê5.Æ8.Å;0Â<0¿=-¹<*¼?-½@.¼?-º;(º;(½<)¾=*º>2º>2ÀD8ÈLBÌPFÊNFÌMGÐNLçbcêbføhqÿo{ÿhxøYm÷Ujþ[pÿXsü\tìbqãktç€í‰‡ãyyØ_dñhrÿl|öcsíkwø‘•餟À–Š¥‹z\pWFRRLÿ4:èB*âD)ÙH)ÎN+ÃO(¹L%¶H%»D&ÛWBÚF8Ú;5æ>>íBHé>Fß5>×08ÈF8ÇE7ÈD7ÉA3Ç=0Æ8,Æ3)Ç0%Ê0&Î1(Ó2(Ö3*Ù5,Ù5,Û4,Û4,áC8Û=2Ø7-Ø7-Ü:/Ý9/Ù5+Õ1'Ù7*Ð0"Ì0!Ð9&Ì9%Æ5 Ç9#ÑE.Á:&É:)Õ7+â3.í//÷05þ5;ÿ;BÿIMúGJîDDæ@@ä>>ã9:ã28á.4þ'/û(/ø*.ó-.ë0+ã2*Û5)Ô7(Æ0!¾/óeYê]TÌA<ÓEDÊ;=ÝNRïPMäFCÕ:6Ê5/Æ8.Ä:/À,¼A/½B0º=)·8%º9&¾;)Á>,²8+²8+¸>1ÁG<ÅK@ÄIAÆICÊJGå`aæ^bñdlÿlxÿix÷ZköTiýZoú^tòcuãgqØqrÝ…é”ꋇåruùq{ÿxˆõ`sßXgóŠ‘ý¶´Ö«¢¬•…TnSAS;PTCkaWž†‚Ý¿ÁõÖÛøßåÿóùÿûÿÿþÿüýÿýüÿÿüÿÿúÿÿôÿùÿø÷ÿôöüòüÿøýþøüüôÿýöÿÿöÿþôûõç÷ñáüúåÿþåþýáýþßÿÿãÿÿñýþîüýíXO@XO@WN?VM>TKñ8>æ=@ÙD@ÑHBå;Dà;BÞCGÉ99ÌB@ËD@½/-ÞHIëHKîAGï;Dì8Aé:?â<>Ú<;Ô<9ÏA=É>9ÊC=ÑLCËK@¼>2³7+¹;-¹9,¾8-Å7-Ê3,Ï0,Ô/-Ý11á34çA1à9)Ü1 á1"é8(ê;*ã6%×2Ñ2Ì4Ê5Ç4 É3"Ì3%Ñ3(Ô3)Í.(Ï2+Î6+Ì8*Ë8(Í7&Ð7%Ø6'ß3'é2,ð31ò01ð+2í*2í+4ï-6ú+1÷*/ñ+,î.-ë4.ä8,Ú7(Ð5#Ã.Ä3 çXHèZLÊ<2ÞOGÄ5/ÚIFÝQRÚLKÒDBË<8È80Ç7,È9+Ê;+È;)Å:'À9%½:&»<)º=+¸=+¶=,³9.µ;.¹=1½?1½?1¿@1Â@2ÅA4ïk_õqeêd[ômiùroécbðjiútuÿk|ûivñdmï_hòaføgjõnkîqk÷|wÿ}ƒþYjÿ[wîZpû¬±«°œaŸz]sMIZ6LR6snX£–†Ë·®íÕÓÿîðÿõ÷ÿ÷ûþøüüüþþÿÿþÿÿþÿÿýþÿæÿòàÿëâýêìÿð÷ÿôûÿôþÿóÿþñÿýïÿûîÿùèÿùæÿøãÿùãÿùáþúáýÿþþÿÿþÿÿYPAXO@XO@VM>UL=TKDë:Bè7?ä7;Ü89Õ:8Ð;7ÓF?Ç<5Å<4ÌG>ÌLAÁC7¶;,·9+¹7*½7+Å7-Ë4-Ñ2.Ø3/á53æ66á?0ß<-Þ6)à4&á6%á6%Û4"Ó4Ð:"Ê:"Æ:#Æ;&É<*Í;,Ì8,Ì5*Ö3.Ö5-Ñ7-Î8*É6&Ç4"Ë4!Ð3"Ø2$ß1(å/+ç.,è,-æ,1æ-3ç.4î*,î,-í0.é2.á3*Û5'×7'Ò9'Ó@,»*ÔE5Î?1ÙF>êWPØC?ØBAåWVâRRÛKJÔC>Í=5É9.È9+Ç8(È;)Ä;(Á:'¾;'½>+º?-¹@/¶>-²9.µ;0·=0¹=1º?0½?1ÁB3ÅC6ëi\òmdçb[ðkfõolèbañklûuvÿp€ÿo|öirë^fêY^òadøqnù|vöyuÿx~ùRdÿUríXnö¥«¥¨“X”n[tLN_;QZ;us\ª×úøàÜÿôóÿúûÿúûÿûüüüþúþÿûÿÿúþÿûüþçÿñáÿêáýçéÿìóÿòøÿóýÿòÿÿóÿýïÿýíÿúëÿöåûóàúòÝûõßý÷ßúúøüüúÿÿýZQBYPAYPAWN?VM>UL=TKCß>Câ;CØ7=Õ?AÏA@ÉD?Â=8Ã96ëWWàBCæ=Bé:Aæ7<Þ58Ö66Ñ96Ì;6ÕHAÅ:3¾5+ÅA5ËK>ÆH:»=/¶8)¹7)¿7+Æ8,Î7.Õ60Þ63æ87ë;;Ó5)Ö6*Ú6*Ü6*Ý5(Ý7)Ú:*Ö?,Ã5¼5¸6 ¸7"»9)¼8+¼4(º0&é=;å>8Þ=5Ô*ÓB/Â1 æTEÐ<0ÚA;ÞC?èJIòTSèVVçSSãOMÝIEÖC;Ï<2Ê8+Å6&Ä7&À7%¼7$»:'¹<*·>-µ=,²=,°:.±;/²<.µ=/·=.º?0ÀB4ÃE7Ü\Oêg]äaYñlgöpoçabìfgòkoäP`ï^kôhqòemñ`eödgûqqúzwövsÿnuõJ]ÿMjïUmñœ¡ŸžŠPˆcVoEOd=Va?ww]¯¤’âÐÄÿíæÿ÷óÿûøÿýûÿþüûÿüûÿýûÿýùÿû÷ýùãÿëÜþãÚøÞàúáèûåïüèöýëýþîýúëÿúêÿ÷èúñàòê×ðèÕôìÙùñÜýùöÿûøÿþû\PB\PB[OAZN@YM?YM?XL>XL>UI;TH:SG9RF8RF8RF8RF8RF8JF=KGÓ>@ÐFCÅA<¸71Å>:ê[WÝABä?Cç=@ã:=Û89Ó97Î=8ÌA:ÏE;Ã9/»2(À/¸9(¼8)Â8+É:,Ò:/Ù80á83è;7ì=:Ô3+Ö3,Ù5,Ý4-Þ6-Þ7.Ú:.Ô>/Æ9(Á<)½>-¹>.»=/½=2Á>6Ã>7ó?>î?<æ?7Ù=1Í:*Æ9%Æ;$È<%Ï<(Ï8'Ï2#Ñ1%Ó2(Õ4,Ñ2,Ï0*Ñ3*Ó5*Ñ7+Ï7)Ê7'É8%Ê<(Ì>*Ê<(Î=,ô^PàF<Ò3/Ò.-è?BþUXÿvuÿroÿjgö^YçPIÕA7Ç5(½.Ä8'À9&»8&¹:)¶=,µ=-±>,°<-­<.­<.®=/°<-±;-¶>0¼B3ÁE9ÉMAß`Wâa[ôpløtrå`aä]aå^dÙFVçYeógpôgo÷dlýjpÿstúxvõssûenóCXÿEbðRkë’˜œ—ƒN‚\Ql?Ri?ZhDy|_°ª”èÛËÿôêÿùðÿúóÿýöýÿùûÿúùÿúöÿøòüóîøïÔüÚÎóÒÊëÌÏìÎ×îÒàïØéòÝóöãöõãûõåüõãõìÛíáÑéÝÍíáÑóç×úõïü÷ñþùó\PB\PB[OA[OAZN@YM?YM?YM?WK=VJcî7Uí8IçAEßFAØIAØIAÞFCæAGð;Jõ8JãDI×>AÐ@?ÏJE¾?8²3,ÇD<âTPÜDCáACä>@â>?Ü>=Ô@<ÏE;ÌH<Ç=2Á7,½5'½9*¿=-¿=-»<+½<)À;*Ç;,Î<-Õ;/Û8/à70ç83ë95ã:7â64â22å31æ42ä50Û2+Ò1)É2'Ç9-Ä<0¿90¼5/¿52È<;ÒDCó57î66å61Ø5,Ë5&Ã6"Á9#Ã;#É>'Ê9&Ë5$Í5'Ñ9,Ó;0Ò:/Ï8-Í?1É;-Ä8'Ã7&Ã:'Å<)Å='Æ;&Í>-Í:*Ø>2ãB:Ö.+æ::á14å26Ò73Ö;7ÞC>åJEêQIêSHèTHäUGË?0Æ>.¾<,º<-¶>.³@.°?/®?.«=0«=.¬<.¬<.­<,±=.·A3¼D6ÆLAÞbZâc]ðnlôrrå`cå`eæ`gúixûozõltí`hñ^fÿkqÿw{ÿ{|öpqø^hö@Wý>]óOh懠•ƒX†aXuE\vIgwP‚ˆfµ±–éáÌÿùéÿüíÿýñþÿóûÿôøÿöôÿóíûìäòãÝëÜÁëŻ㾺޺¿Þ¼ÆáÀÍâÃØæÌãëÓìîÙôñÞøñßóêÛìàÒèÚÍìÜÏñáÔòçáòçáóèâ[OA[OA[OAZN@ZN@YM?YM?YM?XL>XL>WK=VJPI?QI>SK>UL;XM9YM7YM7XM;WK=ULGYSWc_nmkƒtt–|~§ƒ†³†‰²‡Š·ŠŒ¿‹ÈŽÏŽŽÔÕÓ”Ó‹Ê‚‰¿{‚¶u|²ov­gp«ck©€n~ey­ZvÏMoê?cú2Vÿ0Lû6Gð@CâGBÙLB×MCÝIGèCJõÍID¸<4¯5*ÉI@ÕLF×CAÜ>=Ý:;Û;;Ù?=ÔE=ÌH<ÇI;Á7*Á7*À8(¾9(¼9'º9&½:(À;(Ä;)Ê=,Ò<-×;.Ü8.á6.ä6/è5.ê24è.1ê+0ð/2ö37÷69î45æ21Ø/,×31Ô63Ï42Î/3Ð/5Û5?ä=Gõ,2ñ.2è2/Ü3,Ñ5(É8'Æ;&Æ>(Ä9$Æ8$Ë8&Ò:,Ø?1ÛA5ÚB5ÙA6ÎI8ÇB1¿<*½:&Á<)Ã?*Å<)Ä9&Ì;*Î6)Î0'çB<Ý1/ñ>Aå.2à'-Ò3-Ó4.Ö71Ö92Ò8.Í5*Æ2&À1#ÎE5ÆA2¼=.µ:+±9)®:+ª:,ª:,ª/«=.«<+¬=,°?/µA4ÉSGàg^ßd_èkiînoæchðjqõoxüp}ýt~õmwîcj÷dlÿqzÿw|ûsuökpöXfûAYÿ:[õKfâ}…©˜†l”ojŠXo‰ZxŠ`—r¶·˜âÜÂúôÞüúåÿÿïûÿïõÿïîÿëçúäÜïÙÐãÍÉÛū٫¨Ó¦¨Ñ¥¯Ô©¶Ô®¼Ö±ÇÚºÒßÁàæÌêéÔòíÚòéÚïáÖìÛÑëØÑíÚÓèÛÒæÙÐåØÏZN>ZN>ZN>ZN>YM=YM=YM=YM=XL@çE@ÝJBÚKCÞHGéBLó8ÏE;ÆF9¿E6Á8(Ã:*Â:*¿:'½8%½:&¿:'Á:&Ä9&Ë:)Ò;*Ù9+Ý7+á5+ä3+ç4-í)-ò)/ù,3ÿ.4ÿ07ÿ18ÿ28ý58ú7;õ8<ò9?ò9Aô9D÷6Gû6Hü5Jø)1õ,2î02ã4/Ø7-Ï9*Í<+Ì=,È7&Ï9*Ø2á?4â>4â?6â?6ÑN<ÍH7ÇB1Â=,¿:'Á:'Å9(È9)Ç3%Ó9/á@8ëD>Þ0/á-.ì38í38×4-×6.Ù80Ø:1Õ;1Ó;0Î:.Ê:/ÖL?ÌF:¿?2´9*¯7)«7*©8*¨8*ª<-¬>/­?0­=/«<+«<+­<,¯>0ÀKAÚc[Ýc^èkiðosëhnõrzüvïer÷oyør{öjsÿlvÿvÿu}öioõfl÷RbÿA[ÿ6YôFaÝt{²›‰€¤~z›f{—f€–h‘u­±ŽÌË­áàÄéëÓî÷ÜåóÙÙíÑÎçÉÅÞÀ¼Õ·´Ë®®Å¨•Ã’”‘˜Ä“¡È™§Ë¬Ë¡µÎ§ÁÒ®ÎÙ»ÙÝÄåãÎìåÕïáÖëÚÒçÒÍäÏÊÞÐÇÚÌÃÕǾ[N>ZM=ZM=ZM=ZM=ZM=YLXL>YNø<=íA=äE?àGBãDHèAKï=Mô:OÒBAÑGDÅA<ÂH=¯;.°5É83È.,Ç)&É.*Í:3ÌC9ÂD6¸@0Ã:(Ã<)Ã<)Á:'À;(Á=(Â;'Ã8%Ä6"Ê7%Ô8)Ù7*Ý5(á3(å3)è3*û03ÿ58ÿ7<ÿ38ÿ,2ÿ&-ÿ'-ÿ)1ÿ,3ù'0ô%/ú'6ÿ+=ÿ(Aÿ:ú2ö".ô&0î+1æ0/Ú1,Ò4+Ï5)Ð6*Ô6+Ü90æ>5ì>7ë:4é61è50é61ØL?×K<ÒF7Ê>/Ä6(Â3%È6)Í9-Í5*Ô6-æC<à74à21Ò ì89ê35Ó2(Ô3)Ò4)Ñ5)Ï5+Ì5*È5+Å7+ãYNØRFÊH;¾@4¶=ê@AéBIêCMëANê>NÌA<Å@9¾?6µ?3®=/±=0¿E8ÒMDÇ61Ô;6Ï1.Í2.ÖC<Ç?3´6'·?.½6#Á:'Ã<)Â;'À9%Á:&Ã:'Ç:&Ë:'Ð9(Ô7(Ö3$Ú."à/%ì7.ô=5ø72ù30ú.-û)(ý%&ÿ#%ÿ"'ÿ"'ÿ$*ù )ú!,ÿ%7ÿ'<ÿ;ÿ4ÿ3ý)7ð".ç"+ä*-Ý--Ó+(Ò-)Ü41â62é54ï64ó55ó12ñ-.ï+,í++Õ<4Ò91Ñ:1ëTK»"Ä+#ßF>È.&Ì/(Þ<7èE@â:7Ø/,Û.*ã41é:7Ý?3×;.Ï5)Ë3&Ì5*Î:.Ë;0Æ8.ìbWàZOÈD8¹6,º:/·9-¯3)²6,¯1%°2&®2&®4'¯7'²:,²<.³=/°:.ºC;Ö\Wìppñsvøv~ûyƒõq|ÿ{„ûx€øu}üs{ÿr~ÿq}ÿlxûisøbmôI\ÿ=\ÿ8[ñ:VÖek²–‡¦}~¡i|šd}•c‡—j”ŸuŸ¥ ¨ƒœ¨„’£Š£|€Ÿvx›qw›o|r t„£w¯uƒ³y‰¹½„“¾†—¾‡œ¾‹¢½§¼“¯½š¾Â§Ï̹ßÓÇãÒËÜÇÄÖ¾¾Ê»´Á²«¹ª£ZM1ÐB6Ü?6è?8ôA=ö=;ø:<÷:@ô7½=4¶<1°õ6;ú3:û06ú-2û.3ý14þ36×4/Ü:5Ù72æDAæDAÎ/+Ñ2.Á"Ö41á?<èE@à=8Ø3-Ù2,Ý60à91Ò<-Ï9*É5'È4&Ê8+Ë;0Ê<2Æ9/ícYáXNÉ@8¼3+À:1Á;2½7.À:1Á4+¾4*½4*»5*¸6(´6(²7(°6)´;0»B9ÓYTèllïqtöw~þ|†øv€ÿ|„ûyøv~þuÿsÿo}ÿiwùeqùanöI]ÿ<\ÿ9\ô=YÕdh«y€œsu˜`t’\w]cŠ•k—p‹•p…”mp†_lˆ_fŠ\g^j_q•ey›i}l€­r„²tЏz»}½‘½‚–½„›»‰›µ†¡³­¶—¾½¨ÏÆ·ØÇ¿ÖÁ¾ÒººÅ·¶º¬«²¤£\L<\L<\L<\L<\L<\L<\L<\L/ÇE5ÐG7ÚC8ä?9ó=<ú9>ü9Aú:Eò>GæAH×@EÏ@B¿<4¸90±8-«:*¨9(«:*»?3ÏF<ÙD>Ø96Ú65Ü:7ÜC=ÝOEÍI<²4%À9&Á:'Ã<)Æ=+Ç>,È=*É:)Ì9)Ï8'Ï2#Ó/#ß4*î=3ô?6ñ91í2+Ú7&Ý6&à3#å/"é-"î+%ñ,&ò+(ó++ð(+ò'-ú(5þ%8ÿ5þ2ÿ3ð(5ô.;ô4?ò8Cï;Dðå+6ñ1<ô/9ù-8ù+5ù,3ø-1ö.1ö01Ù1.ä<9Û64à;9ÿljæBAÒ.-Ð.,Û97á?<àA=Û<6Õ7.Ô6+Ô6+Ó5*Å8&Ã6%Ã6%Ä8)Ç;.Æ<1Æ<2Å;1ëaWáTMÉ<3¿0(Ë;3Ï?6Î;3Ñ>6Ú=8×<7Ô=4Ï<2É;/Â:.»7*¶6)·;/»@8ÏTMãgeíorøz~ÿˆý{…ý{ƒùzúx€ÿwÿsÿl}ÿftøbnø]kõG^ÿ:Zÿ9\÷AZÐ_c›gkŠ^e†Oh…Ol„Rt…X{ˆ\}ˆ^x„\q‚X`yO_P`†UeYm•`uœg{ j€£m­p…±tˆ¶v‹¹y‹¹yŒºz‘º~”º‘±•¬€›©†©­’ºµ¢Ç¹°Ë¸²Ì´²¶­®ª¡¢ —˜[K;[K;[K;[K;[K;[K;[K;[K;ZJ:ZJ:ZJ:[K;[K;\L<\L<\L<]K=]K=]L<^M=^M;^O<^O<^O<`P@^Q@]P@\NC\NE[NF\OI]PJ`NdcSmfX{g^‰ohœzu¯„|¸†{µ™…º¥…´¯€ªºy¡ÈxŸÓušÍc‹¾OyêAFà@@ÕA=ÌF;ÈJ;ÉJ;ÐF9ÜB:î@?ø;Aþ:Dü7õ>8ð50è-&×:)Ú8)Ý5(à2'æ/'é.'é,(é,*ç+*å(,è)1ï+7õ';ö";ú=ÿ"A÷8Gä(6ç/;ÿP\ÿ`lÿP\ò^N>^N?^N?_OB`PC`OEbM\cPdcUodZle‘vr¤~w«‚v¦“~©¬†«Â‰©ÐžÛw“âk‡ÝXuÓFfÿ=MüDPðJNÞJHÌG>ÇG<ÍG<ÙD>èBBó>Cù>Gø@HðCIÞDDÍB=À?9½A5µ=/®:+ª;*©:)­9*º<.Ì?6áFBä<;ïABíAAÞ:8ãJBæXLÔL>È@0À8(»3#Á8(È<-É:*Ë7)Ð8+Î0%×3)à8/é;4ï:3î50ë0+è+'Û4,ß4-ä2.ë31ð43õ45ö58õ6;é/4ç.6ê0=î1Cò.Fõ*Gý,Lÿ1TðPî3Dî2Aî3>ê5<æ89Ü73Ð3*Ç/$Ì2*È-(Ñ61óXT÷\ZóXVÜ@AâHHÜB@Õ<7Î70Í6-Ï8-Í9+Ê7'Æ3!³:%²9$´;(¸=-¹;-¶6)»8.Ä>5ÛNGÙEAÎ50Ð1-á>9è?:ã81ä71ð/0ï11ì42é73â92Ø:/Ð9.È:.¾6*º7-ÈIBÜ_Yënlû}€ÿ…‰ýƒõv}õx~ùzÿx‚ÿsÿj{ÿdtö_nðUeôF]ÿ6Vÿ7ZúF_ÀTRvaBJoRÿ-Hÿ:QþCTéDKÒ@AËA>ÎDAÖEBãEFêAFï@EïBFçDEÚEAÉC:¿?4º@3±;-©8(¨9(©:)®9(º:-Ë;3èIEë??î;>æ68Û2/ÞA:îZPõg[ÙQCÉA3¾4'À6)Ç9+Ê8+Í6+Ò8,Ñ0&Ü5-æ;4ë:4ê40è/,ê-+í-,ó4;õ3;ø3<þ2=ÿ1>þ0=ý0?ù0@ô1Añ2Dò5Kó5Oó0Põ-Qþ1Xÿ:dá7B÷O\ÿanÿ`nþXfùQbòEXé8Jó@Sê:GÝ2;Ò/2È3-Á9-º=+µ>(Æ9/¿2(ÙJBúkcÝLGáPMÍ<9Ï;9àLJÔ@<Ê7/Ê7-Î(«;%­=)²?-±9)®4'º:1ÊC=ÕHAØC?Ô72×2.ç;7ì:6è2.ë2-÷)+÷+,ô.-ð3/é61â:1Ú<1Ò>2Â6)º4)ÅB:×XRçjhú|}ÿ†‰þ€„õv}öyú{‚ÿx„ÿqÿh{ýbtõ^oîSe÷I`ÿ9Xÿ9[ûI_ºQNmZ:Em8ZvCa|InSv†Y|‡]Šbg‚—lœl{ m|¤o}¨p~ªo‚ªnƒ©l…©lˆ«qˆ®qˆ°r†³r„³oƒµn„¸p‡¹t‹µv‰¬tŒ¦wš¨„°´™ÈïØÌ¾àÏŽÃÓ«±Á›¡±ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8[L9[L9\M:\M:\M:`J<`J<^K<_L=^M;_N<_N<^O<^O<_P;_P;aPHÿ$Hÿ0Qÿ;UñÇA6¾>1·?1¯9+¨7'¨:)¬=*²=,À>1Ñ>7ß=:ç79æ/3ã/0á32Û94åNEülaïj[ÙQCÆÍD>Á61É;7ãUQÕF@É91È8-É:,È9(È:&É;%ªB)¦<&¦<&¬=*©8(¬3(¼=4ÒMFÕGCÝEBÛ96Ü30é73í41ì/+ó2-ÿ)/ÿ*/ý--ö0/ï4/è7/ß;1Ø>2É:,¼4(À;2ÏNHßb^÷yzÿˆŠÿ„†ùzú}ƒü}„ÿx„ÿn~ÿdwù^pò[léN`öHaÿ8Wÿ7YøH]²JGcS1Al6ZtDf~NuˆZŽc…f‡’jˆ—n‰žs‡¤t‚§t§r}¨p}©n©mƒ©l…©k†§n‡ªp†¬o…¯o°l³k‚¶n…·p‡´s‡­rŒ¨wœ¬…²¹šÈƱ×οÞÐÅ·¿Ò¤¬¿’š­ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8[L9[L9\M:\M:\M:`J<`J<^K<_L=^M=_N<_N<^O<`Q>aR=bQ=bQ=bR;bP:aO9`N8jNMgNRbQ[cWkjfuv’}}™y‘’{¯ŒËƒ‡ã{|ùqsÿgjÿTXÿAGÿ#Mÿ.Tÿ7Wù9Pé>NàEM×EHÑ?B×BDÚACÜ@AÛA?ØC?ÏB9Å?4¿=0·?1¯9+©8(«=,°A.·B1ÇC7×D=Ú64å57ã,0ç02è88Ó0+Ï5-éUKÿznæ^RÎD7É=0Ê<0É6,Í6+Ö90Ú70ß82ä71ç40é1/í10ò53ø87ÿ=ÿ>ÿ>ÿ>ÿ=ÿ=ÿ<ü=ò:ï@ð$Ið&Nï$Qó%Uÿ0eÿ=sÿgrþalôXeîR_ïQ`îM]â?RÖ1Bß:JÑ4?¿-0±-(¦5'ž>&–C%E"¯7&²9(ÒWHº<0ÁA8º7/º3/ÍC@ãXSÕHAÈ91Ä6*Å6&Ä5$Ä6"Ç9#¦B*¢<%£:%§<*¦7&©3'½A7ØSLØIEáGEÞ:8ß2.ê41î1-ï.)ù4.ÿ'-ÿ',ÿ)+ö*)í-(ä1*Ü5,Õ9-Ð>1½3(¼7.ÉHBÙ\Xôwuÿ‰‰ÿ‡‰ý~…ý€†þ†ÿx„ÿl|ý`sõZlïXiãHZóE^û4Sÿ3RóCX«E@\L*?j4Uo?d|LwŠ\†“h‹–l˜pŽtŽ£xŽ«{†«x©t|¨mz¦i}¥g¥h‚¦h…¤k…¦m„ªm‚¬l®j}±i€´lƒ·oˆ·sˆ°tެxœ®„²¹šÄ«ÐǶÖÈ»²½Óž©¿‹–¬]K7]K7]K7]K7]K7]K7]K7]K7^L8^L8^L8^L8^L8^L8^L8^L8\J>]K?]M@\L=ZM=ZO=\Q?^SA_T@_R?^Q@aQAcRBdQCdNAcM@pKEjKIfOUgZknl„v|ž}†¯ƒŠ´Š…®Ÿ‰­¸Š¦Ìƒ”Þ{~îumøl]ûfRðN[æDQä>LéANïCQí>Ké:Gê4Á;/¼8+ :$¬C0¬=,®6(Â?5ÑD=Ð;5Ó61Û83Ü71Ý6-Ý7)Ü9(Ý='Ù;"Õ7à74õPLõXOÛD9Ç8(Ì?.ÒC3Ñ;-Ò4+ðGDâ.1ï4;ö4?ï+9ÿ@Qí(9þ&+ÿ*-ÿ*-÷"û#$ÿ()þ((òð"ú+1ì )î&1ò.<ç$5ÿYnë+@ÿ`jÿ^iÿYcûT[öPTìHIÛ@;Ê:1ÅA2½F2®D.Ÿ;$”5–7#˜;)œ=+§81«83ÁEC¿;9¾23Æ45È44×CAÜKFÚKEÑD;È:0Ä4+È4*Ì3+Ì2*·?1³9,®.#­'¶,"Æ7/ÓC:ÚG=äPFßE;Ù80Ü1*ç/-ô01ý/3ÿ.4ò14ó12ô01ó/0ó0.î1+é4+à8-Ö=/¾2#¾?0·>3Õ`Wçtqÿù…†ôŠŒþ…Œÿwˆÿe}ÿ[wÿXuÿSoûJgûDcö7Y÷9]ç>[Ú]k„C=PI/F`;Xw^N?^N?[N>ZO=\Q?^SA_TB]QA]P@_OB`NBbPFcOFcOFkLGjMOgS\h_rnoŽw~ª~ˆ»…ŠÁ›–Ì¢Œ»«£»wŽÕx‚í|x÷uhöjYüZgóN\ìFRòHUöJVõERï?Jë;Eä9Aà:>Ú::Õ=:Î?7Ç>4À+ª?-¨9(²:,ÁA6Å<4Ç7/Õ<7Ó40×4-Ø4*Ø4(Ú7&Û:&Û;%Ù;"Þ52æA;ëMDàI>Ð>/Ç8(Ê8)Ó;.Ý<2öJFæ/1ò5<ø6Aò.<ÿ?Pì'8ö$'÷%(û),ý+,ü*+ù'(ø((ø*,ð$'í%(ê%,þ:DÚ'ð4CüATÞ#6ÿluÿblþZcüW]õOSæBCÙ;8Ñ>6¾8,¾E4¹H6¨?,–1)Ž()ž-'°:6ÑTRÎHGÃ54Æ45Ò<=ëWUØGBÖGAÏB9Ç9/Ä4+Ê6,Ð7/Ò5.Â?5À:1À5.Â3+É4.Ð83Ø?9ÞE=ãJBÞA8Ù6/Ü1*æ0-ó11ü03ÿ.3ò14ó12ô01õ/0ó0.î1+é4+à8-×>0¿3$¼=.¶=2Ó^Uévsÿù…†õ‡Šþ‚Šÿu…ÿe|ÿ[vÿWtÿQoþIhúAaö8Zö=_æF`ÅQ\{?7NH.Ga>Yx=e‡Ks•Yx›awbz¢f|¥i}¦j|¥i|¥i|¤h{£e{¡d}¡c}¡c¡d{¤l}¦n}©l}ªi}ªe}­c¯c‚±cƒ±f‡²k‡¯pˆ«u‹«|¬„©‰‹¤†z…‡doqR]_]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8^K<_N>aP@`P@]P?[O?[O?[RC[QE[QE\OF\OG_PKcQOfTRhTUiTQiVXi]kmi„sv¡zƒ¼ŠÍ‰Ö—‘ÙŸ‹Êª‚¶º}ŸÒ‘烅ð~tïveÿ`k÷S\íGQðFQöHR÷EQô@Kî=Gå6=à7:Ù99Ô<7Í@7ÅA4½?0¸=-©@-¨=+ª;*¸B4ÅI?À;2»0)Ì92Í6/Ò5.Õ7,Ù7*Ù7(Ú7$Ü:%Þ<'ß3/Û4.âA9éOCÜH:Ç6%Æ3#Ù@2á>5õHDé13ó4;ú6@ø4@ÿES÷3Añ),í"&î#&û03÷--ï''í%%÷12ì(*ø7:è+1â)1ë3?ÿR^ï=KÿYiúafñV\îOTðMRêEIÞ:;Õ74Ô?9À6,¿?2»C5²>1ª8-¥3)Ÿ,%œ' ˜% §0*ÆFCÂ::¼,,È44×ABô^]Ò>:ÒC;ÐA9Ë=3Ì9/Ô=4Ú@8Ý@9ÙA>×=;Ü>=ãA?ã?>à;9ã?=ëIDàA;Û=4Ø5,Û2+å2-ð31÷12ú/2ó04ô02ö01õ/0õ/.ð0+é4+à8-Ø?1À4%¸9*´;0Ð[Rízwÿ’’û‡ˆøƒ‹ü~‰ÿr‚ÿcyÿZtÿTqÿMmÿFgü=_ø:^ôBbåQg§?Fn<1OK2KcA[z?h‡Lr“Zu˜^tš_wŸc{£gz£gy¢fy¢fy¡cx byŸb{Ÿa| b}Ÿby¢j{¤j{§h{¨e{©azª^|­^®`…³hеnвs‰¬t†¦w‚žvy“pn‡gVb`COM4@>^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^L6`N:aP<`Q>]P?ZN>YPAXPEXOH[RM_UTcWYeX_iYcl\fm]hlbclemolrtšx¶~†Ï„ŒßŠŽç‹‡ÞŠÙ¬‰É³­½y’Í{ßyê†vÿnrÿbgùU\öLUöFPöBMó>Gð;Dæ5;á7:Û97Ò=7ËA6ÄB4»B1·?.©;,­=/¯>0»G:ËRGÇH?¹6.º1)È91Í81Ó;0Ú<0Û;-Ù6%Ü6&à9'á40Û2-à=4ëOCãK=Ñ;,Ð8*àB6Þ7.ð>:é/0ò16÷4<ü8BÿNZÿKWý>Cò38â$&í/1ê,,ð22ç+*é0.ò::Ñæ37Ü-2ç9BïENÿYcôLYÔ?AÚADßCFá>CÞ9=Ü89Ø88Ó:5É83Â91½:2ÀA:ÍNHÖVSÐNNÆAB¯82µ:5ÏKGØNLãQRïYZêRQñYXÉ51Î>6ÑC9Ð@7Ó?5ÚA9àC<àA;íCñ:?é58í=?øLJà93Ú70Ø4+Ü3,ã5.ì30ò21ô01ô04ô02ö01ö.0õ/.ñ0+ê3+à8-Ù@2Â6'µ6'²9.ÉWMî}yÿ“’û‰‰þ€‹ý{‡üoücwÿXqÿNmÿFhÿ?cþ8\ù=`íIdÙYhˆ25d<0SQ8TgG`}Ej‰Ps’Yt•\u˜^wby¡ey¢fw dv awŸavž`xŸ`zž`{Ÿa| by¢hz£g|¦fz§bz¨_z¨]|«]~­_†²eеmŒ³rŠ­s†¦u€œstŽii_RaZDSL8G@^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;_K2_M5aO9_P;\O>ZN@XPEXQKYQO^X\g`hnfsshysg{sg}tfnnzor…rw•v|¬y‚Ã~†×ƒŠåˆ‹ì’뛌ߞƒÆžt¢¡kƒ®mq¾vjÈ{iþllÿklÿfiÿ]`üQWöEMð;Bí5=è59ã68Ý98Õ>7ÎA7ÅC5¼C0¶A-¬8+´@3¯;.°;1ÇRHÓ]SÈNCº;2¾90Á7,Ì9/Ö>1Ý=1Ú6*Ü4'á7(á2-ã60ä=5åE9âF9ÜC3ÝA2á?2Û0&ì62ì0/ð-1ò-4ú7?ÿOYÿZdÿ[_ÿOSá.1ã03ß--÷EEè66Ü,,Û-.ë>@Û25Ù37ÿchÞ=CÊ*2Ê-4¾()Ô;=àAEÚ7:Ù37á8;Ü89Î..Ì43Í<9ÓHEÝSSì`c÷hnõdkî[e¿B<ÆE@å^[÷igÿopÿjjåKK×=;É4.Ñ>7ÕE<ÖC;Ó?5Ö<4Ø93Ø7/ö0=ò,9ó+6õ-8ò*5î+3õ8<þJKà3/Û4.Ø4+Ü4+â5.ê40ï4/ð3/ö/4ö/2÷/1ø-0ö..ñ0+ê3+â7-Û?2Å9*²3$±8-ÃNEî}yÿ’‘üŠŠÿ}‹ÿw…ùl|öatùUmÿHgÿ>bÿ8_þ4\õ@aâMcÂWap/+\A0XX>]lMbIl‰St’\u–_v™_xžcy¡ex buŸ`uŸ`u_vž_wž_zž`{Ÿa| by£d{¥f|¦dz¨`y§^y¨Z{ªZ}¬\€¬_…¯g‡®m‡ªp…¥sƒ t{•nrŠffvi[k^RbU_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<`L1aM2`N6^O:[N>YOE[RMZTT_ZahbprmzuŒ{t“yr“zp“yo”ov’pyšt}¨w€·zƒÈ~…Õƒ‰á‹‹å”ã—ŠÒ™„¼¡ƒ§ª„“«~yŸl[ŽX>ÈH?ÕPIäVRìVUòRRôJMî=Cè38ì7<ç9;à;9Ø=8ÑA8ÈC4¿B0¹@-³9.ºA6«5+£.$¼J?Øh\×eZÊVI·=2¸6)¾4)Î:0Ù;0Ü5,ß3)ä6+á/+å61ã;2Ü:/Ü?0ãF7ãC3ß9+ß1&ê3-ð31ï-.î*.ô17ÿEJÿS[ÿ_dÿ\aâ9<â9<Õ+.ôJKâ89×//Û55Ì()Ë(+÷YZÛ?BÔ9=Ð7:· %Ã))Û=>åBEÝ49Ù,2Þ17Ú/5Í(,Ò37äKNöaeûhnùcl÷_kû_mý_nÒNIÔOJè]ZêVTçMMãGHÑ32Î31ÙA<àKDãPHßKAØA8×:3×50Õ2+ÿ,;þ+:ü(7ø%4÷'4û/:ÿ=CÿILà1.Ü3,Û4,Ü5,á4-ç4-ì5/ï4/ö/4÷/2ù.1ù-0ø..ò/+ë3+â7-Ù=0É;-³1#°7,¹D;ìyvÿþŠ‹ÿyŠþqõhxó`söTlüCcÿ7^ÿ3_ÿ3\óDcÒM^ JMb6+TE0W[@^kMc~Kk‡Tt‘[w•_x™`{ždz cvž`s›]s›\s›\tœ]v^wž_{Ÿa| by¡bz¤b|§b{¦_x¦[x§Yz©Y{ªZ~ª]ƒ­e…¬i†ªm‰§s‰¥u„s|•mv‡unmfwe_P=_P=_P=_P=_P=_P=_P=_P=^O<^O<^O<^O<^O<^O<^O<^OÏcWÔh[ÔfYÁPB¹?2¹5)Ç7,Ô:0Ù5,ß2+ç6.ã0,ã4/â7/Ü8.à>1åC4â?0Þ4'æ4*é1)ò2/ð..ï-.ò14ô68ü?CðOTúY^éFKõRW×47ëFJÝ8<åBEÚ7:Î.0Ð15ãIKÑ8;Î8:¸#%Ñ<>Ü89ä;>ê=Aç6<â-4Þ)2â19çÿ/>ý)7ÿ-:ÿ9CÿAHûABã1/ß4-Ü5,Ý5,á4-æ3,ì5/ð50÷.4ù.2ú.1ù-0ø..ò/+ë3+ã7-Ø:.Ì>0´2$±7,±<3çtqþŠŠþŠ‹ÿr†ýj}ñbtð]pôRjûBbÿ6`ÿ5aÿ8_ïKfÁN[z;6Y?.LH/TZ@]cIbzJj„TrŽ[v”^yšc{ždxžas›\p˜Yp˜Yq™Zq™Zt›\uœ]y_zž`x¡_y¢^z¥^y¤\x¤Wv¥Uw¦V{§X~ª]‚¬d„«h†¨l‡¥o†¢r€šmx‘gr„lk}ecu]_O?_O?_O?_O?_O?_O?_O?_O?^N>^N>^N>^N>^N>^N>^N>^N>eQ6cR8aP<]P@ZPG\TR_Zab^otrŠyx˜€¨ƒ°~~²yx±wv°xw³t}Âw€Ã}…Æ‚ˆÆ…ŠÂÀ—–¾ ¼¬§»¶¬´¾³¯È¸©Ð¿¥Õ¡ϼ”Dz‡·kS®\F¤G5©=0ÂH=áVQðVTòNOì?Aë=?è<<ä<;ß=:×=5Ï;1Ë8.¿82Á<5¹:3·>5ÀPDÅYMÅ]PÎgXÐdWÁM@º:-Å8.Ò91Ø3-ß2,è50æ40á2-à5-ã<3çC7æC4â:-à3%ê5*è-&ð0+ð.,ò21ò44ç.,è00áEIõY]öW\ÿpuåDJéHNÞ=Cü[aÿouÝ>Cÿ~‚ÿmqêQTÔ>@Å02Ñ<>øEIî9>ð7=ø=Fô6@è-8ö>Jÿ\hÿmwÿitÿdl÷]gú^kÿapÿ]nüWhî_YãOKâJGÕ74Ò0.Ù54Ó/.Ø95ßD?ãJDáJAÙ@8Ó6/Ö5-Ü71â94ð$0ý/<ÿ1=ø*6û/:ÿ>Eÿ>Cì44â3.Þ5.Ý6-Ý5,á3*è3,ï4/ò5/÷.4ù.2ú.1ù-0ø..ô.+í2+ä6-×9-Ï@2µ1$²6,°7/èpoþˆˆÿŠŒÿkƒücxð]pïZnôPiýAdÿ7aÿ8dý=bæPi°QW^2'RG3DH/PV`P@`P@_O?_O?_O?aQAbRB_O?]M=]M=aQAcSCbRB`P@eS;aP<_O?^QH[QOZSZeapsq‰xxšz|¥~€±€¹}¼xy¹rs¶no²qwÏv{̓̋Ȗ—䤾²±¹½¸²ÌŲÓÍ­ÙЩÛУÛÑ ÝÑ¡ØÌšÒÆ”Õ¦Š·gŸ_FËzgØte¾G?ØQMøbaìILç>Aä79æ9;ã99Ü75Ù61Û94È95À50ÇB;¹=5¾I?ÄXK·PAËeVÎdVÊYKÃG;Ä:/Í6-Ù6/â5/å3/á/-ß2,â70ä=4à<0Û8)Ý5(å8*å/$ê/(î.)ð0-ï20ë40è51æ40Ó8<åJNõY]ëOS×7?×6>ùX`ÿ~†ÿ~†ÿowÿgoÿipÿfjõ\_ïY[ô^`ÿRYÿCKü8Bü7A÷1>ï+9î/>ñ=IÿS_ÿ`kÿgpÿepþboÿbpÿ`oÿ[lìTOßFA×85×31Ù10×/.Ú21Ü86áD=ÜB:Ø?7Ö<4×90Û81á83ä84ô5=ó4;õ3;÷4<ø5;ó49ë33ã1/Þ3,Ý6-Þ7.à5+ä3+é2,ñ1,õ2.ø/5ø03ú/2ú.1ù//õ/,î3,å7.à@4Ë9,½7+®/&·<5ÒXWÿ˜šù~ÿhÿe|ö]rîRhòHeÿAeÿ9bÿ5`üJlÕRd‰==K. >>&?I.IO5]]EWlAcxMqˆZx’by–`t•\r–Xq˜Wl•Sm–Rn—So˜Vr™Xt›\uœ]uœ]tœVtWv Xw¡Wv¢Uv¢Uu¡Tt S{¥[{£\zŸ\u—Zn‹Uc}MXrCSj>AW1?U/`P@`P@`P@_O?`P@aQAbRB`P@_O?`P@bRBcSCbRB`P@fVF_QD\OF_TRcZ_f`nmkƒwv˜wy¢{}°}¸x|»qt·lo¶ln¸oq»suÙ|}Ù‰ˆÔ˜—Ш§Æ¹¶½ÉƵÓÏ©Ý×£âÜžçßžæÞäÜžâÙ ÙÒœÑʖѼ¸€¦~dÄ‹wÉ}m¶VJÓ`Y÷qnîZZêJLä>@é<>ì>@è:;ã56á34Õ=:Ë73Ê?8¹6.·>3¼L@³I;Å^OÛp`ÒaSÄH<½5)Ä0&Ö5-Ý4-Ü/)â43å95å<7à<3Ü8.Ù5)Ý5(ã5*í6.ï4-î1+ë0+ç0,ã2,á4.Þ5.Ò9;×>AäIMóW[ü\dü\dþ]eÿ`kôR]ïMXñQ[ÿ_gÿjqÿflô[`ëRU÷07ó+5ô+5ù-9ó&5è/ç'6í7DüP\ÿ[dÿclÿemÿepÿdoý[hõP^åFBÞ<9Û64ß63á53Þ20Û2/Û62à>9Û>7Ö<2×:1Ú91ß82å95è96é9;ê7:ë7:î79î79ì57å31Þ3,Û4,Û7-Þ7.á6,å2+ì1*ó0,ø1.÷05÷03ú/2ù.1ù//õ/,î3,ç6.ß=2Ò>2Â8-µ2*·82ØZ[ÿ“õw{ÿa{ÿ^v÷WqöOkøFfý=bÿ:cú=cëLhºJVw<8F5#7=#9C(DH/UP`rJnƒXw_v“]t“Zp”Vn•Tk’Ok”Pl•Qm–Ro˜Vr™Zsš[sš[tœVuWuŸWuŸUtžTržQqPq›Qn˜Pl”NhŒLbFXu?Nh8F]/@W+@W-@W-AX.YL<[N>^QA^QA^QA^QA_RB`SCaTD`SC_RB`SCaTDaTD`SC^QAbUM^QK[QPcYakesqm„vu•y{¤y{®y~¶w}»ns·ei°bf°jn¸rvÀ}zᇃᖔߩ§Ù¼¸ÏÍÊÃÝØ¸çá­êå¡ïéŸðêžíæžéá¢âÛ¤×Ï ËĘ´°“¦œ˜„k§„p¥p`œRG»]UÞmi÷usð^_çHLæ@Dí@Dí=@ë7:ç36Ü>;Ô;6ÔA:Â70·7.µ?3­=/µG8Új\Þj[×\MÊB6Å2(Ñ4+Ú6-Ú1*Þ44éA>ìGCà=6Õ2)Õ1'Ú2'Þ0%è3*é1)ç.)æ/)ã2,â7/á=4âA7Ã-,Ê43ÜCEðVXú^bùYaóS]òP[èFQêHSðNYü\fÿmvÿmtôY_ÜAGó*2õ,4ý1<ÿ1>÷*9ï&6ö6EÿJX÷ISõOY÷W_ü_fÿdkÿai÷Q[éBJÞ95Þ63ã75é<8ë<9ç85â51Ý60Ý:3Ù;2Ö90×90Û81á83ç:6ì:8à;9â:9ã99ç98è88å84à40Ú3+Ú6,Ú8-Ü8,á6,å3)ì/)õ/,ú0.ô15õ13ø02ù.1÷//ó0,î3,ç6.Ý9/ÛD9Æ9/»4.´0,â`bÿƒˆônuÿ_zþWsúPmþLlýDfø8_ö9_ðGf×ReDJi=4K@,7@%8@(ED/LE2N^9YkEg|Qr‰[tZqUmRkMi‘Kh‘Ki’Lk”Pm–To–Up—Xq—ZuWuWtœUrœTpšRm—Mk•Kj”LdGaˆE\~AUt;Li3E_/AX*>U'B\/E_2Ic6WJ:ZM=\O?^QA]P@^QA_RBaTD`SC`SC`SCaTDaTD`SC_RB]P@YNR[PVbXcjcsqm†vu•xz£z|­w|´sy·mr¶bi±]c­ag±lr¾v|È‹‡æ”‘褡淴áÇÄ×ÕÒËáÞ¿èå²ëç¨ïê¦îé¥éã¥ãܨÛÒ§Ëß¾µ–Ÿ§˜š…‰v—‚q—se™cW³i`Ïrmû‹‰õutë[[çKNéCGî?Dî;?í8=ß:8Ý;8ßD?ÓC;Ã:0¹;/¯7)¦2#¾J;ÚbRék]ÛSGÉ9.Í3)Ö5+Ø4+Ù33ñMLý[XíKFÙ80Ö3*Û4+Þ2(à-&á,%á,%ß,'Ý0)Ú6-Ø<0×?2À0(Ä4,Î:6ÙCBßFHàEKäGPìLVñQ]öVbøXdû[gÿgpÿmuôY_Ø=Cñ.2ò-4ô-4ò*4í%2ì(6ûô@?ð<;ç85à72Ü92Ø:1×90Ù80Ü71ã73ê86ì87Þ<9ß;9â:7ä;8æ:8ä84Þ5.Ø4+Ù7,Ú8-Ü8,á7*å3)ì/)ô/)ù/+ó25ô23õ12÷/1÷//ó0,î3,ç6.Ü8.ßG<É90¾3.´-*îfjÿy€ójrÿ`{ýTqþKkÿFjÿ=cö3[î<^äPhÄXe…DBbE7WP=DH1@D-JH3JB/IW4Sc?btLmƒUp‹XoŒRkŽNiŽKgIg‘Ih‘Kj“Mk”Pm–To–Wp–YtœVs›Uq™Sn—Qj”Lg‘IeŽHdG`‡D]AWy=Rq8Mi6Lf6Ne7Pe:Lf6Oi9Sm=UH8WJ:[N>\O?]P@]P@_RBaTD_RB`SCaTDaTD`SC_RB_RB_RBTLY`Xgnf{tp‰xt•xw¡xz«y{´sy·jqµ`g¯\b¬`f°kq»v|Æ~„Ε”äžžè­­é½¼æËÉßÕÓÔÝÜÊãàÁåâ¹çã¶æß³àØ³ÚÑ´ÐůÀ´¤¯¥™”œ‰ˆ†y‰}qwk›sk§ngºoi扄î~ósróedòVYòLNðCEî>Aå95â:7äB=ÞE?Ì<3Æ=3ÂB5­1%¬1"ÇI;ÛYKÖN@Ì=/Î8*Ò6*Ñ3'Ö34õUUÿkhú]XâE>Ü;3ß;2ã80â4-ä1,â1+Ý0)Ö/'Ì0$Æ/$Â0#Ã9,À4'Á3)Ë:5×CAÛEGÛBGÛ@HàDOìOZóVaòVaú^iÿgoóYaÝDIð88í55ï26ð18ò3;÷9CÿHSÿVaä6?Ý4;Ý7;êAFøKOüIMô;@ê05å61ë95ñ;8ó;9ó;9ð:7é73â70ß;2Ü;1Ù;2Û:2ß82ä73è64ì65á<8ã;8ä;8è:9è;7æ95á6/Û4,Ú8-Û9,Ý9-á7*å3)ë0'ò/)÷0+ð45ñ33ô22ô01ö0/ò1,î3,ç6.Þ7.ÞD:Ê7/¿1-¾21÷jpÿrzøhrû]vúPmÿCfÿ_L;_ZFQP;KI4PI6MB0DR1M[8[kFf|Nm…SmŠPlŒMhHfŽGgHg‘Ii’Lj“Ol•Sn•Vo•Xt™Vq˜Un–Pj’LfIcŒFaŠF_ˆDZ@X|?St;Pn8Pj:Tk=XmB[pEUp=Vq>Wr?RE5UH8XK;ZM=[N>\O?^QA`SC`SCaTDaTDaTD`SC`SCbUEdWG]Ulje|yu}yœzy£wyªvx±sw¶lqµcj²[c¬]e®hp¹w}LjІՙܡ¦à¯²å»¿åÆÇãÍÏÞÔÓØ×ÖÑÙ×ËÙÕÉ×ÑÅÒÉÂÌÂÀŹ»´§®¥˜¡‡Œ†xzuwvqulg~mfŒoib[œa[¾sm×zuï{ü|yÿrpýccöSTîHHñB=ê>:ã<6àA;Ñ:1ÒD:ÝTJÂ>2¸6)¼:,Â=.È?/ÏA3×C5×?1Ñ8*Ð23èLMú_]ñXSßD?Ø;4Û81à70æ92ç92ç92â92Ú9/Ñ9.È9+Ä8)®)¸3"È@2ÓI>ÒE>Ë;:Ì7;Ð9@Ï8AâHTïUaðYbõ^g÷`iêU[ØCIè?:ë?;ñAAúGJÿMRÿQYÿT]ÿV^á4:Ú/5Ú03ç7:ô=Aù:?ø48÷/2é61ï95ð95í41í1/ê20ç40á4.ã<4à=4Þ=3Þ;2à93ä73è43ë33æ:8ç98ê88ì89ì87é75ã4/Ü4+Û7-Û9,Ý9-ß7*ã2(è0&ï0(õ0*î45ð43ó32ó11ô1/ò1,î3,è5.à90Ù<3Ì70Á0-ÑAAÿnuýku÷coïSkóIfÿ;cÿ1`ÿ3bÿRJ7QF4MB0AL.GU4Sc>`rHgMj‡MjŠKh‹GeFfŽGfHgJi’Nk”Rl”Um“Vq–So”Qj‘NgŽKcŒH`‰E_ˆF_†G\‚E[~DWxAVr?Uo?YpB]rG_tKYtAYtAXs@NB2QE5UI9WK;XL\P@^RBaUEbVFbVFaUE_SCaUEfZJj^Nkg‚up|x›{y¡wx¨vw­pt±jo±ah®^f¯_g°em¶pxÁ~…͉ؖܙ¡Ï ¨Öª±Û´¹ßº¿ß¾ÂßÂÄÝÅÆÛÆÃÖÅÁÒÁºÌ¼³Æ»¯Å´¨¾¦˜±—‰¢†‡‰qqstpqogevhe†nj`Y”e_š[T·g`×tnî{vÿ{wÿwsÿhfù[ZÿQKöGBè=6èC=Ø;4ÛG=ê\RÅ;0Ä<0½7+¾6(Ç>.ÑD3ÔC2ÔA1×A0Ò8:Ø>@ÜDCÛC@Ö=8Ó91Ø7/Þ7/å:3æ93å:3â;3Û>5ÕA5ÑE6ÌG8¬.¼;%ÌK8ÑL=Æ=3»0+¿10Ë8>ÕBJáKVëU`ðZeð]eìYaßLRÐ?DÑ4+Ö8/ß<7ê@@ñDFôEJñBIî?Fâ5;ß26ã36ï8<õ79ù14þ-2ÿ.4ë40ð95ò64ì0.è,*è/,è2.á2-ä=5à=4ß>4ß<3ã:5ç85ì65í55ì57ì57í57ï56ï56ì42å2.Þ1*Þ7.Ü:-Ý:+Þ8*á3(ç1&í1(ò1*í55î53ñ42ó11ó1/ò1,î3,è5.ã;2Ò4+Ò;4Æ20çUVÿpxùcnñ[gãKbóEfÿ7bÿ+]ÿ1bÿ@hÞKe­RYd8/ZI7SN:UN;[P>VI8M@0MA1=H*CN.K[6Xj@ayGf‚HhˆIgŠFeŠDc‹BcEeŽHgLh‘Oi‘Rj’Tn“Pl‘NhLd‹Jb‰H_ˆF_‡H`‡H_…H_‚H]~I]yH]wH`wKcxOdyP[vA[vAZu@MA1PD4SG7VJ:WK;YM=[O?]QAcWGdXHdXHbVFaUEcWGj^NpdTvq‘yu˜xvtsŸrr¤su®lp¯bg«Za©^f¯em¸lt½u}ƈДڕœâš¤ÈŸ©Í¦°Ô¬´Ù°µÛ±µÚ²´ÚµµÛ³±Ö²®Ñ®¦Ë«¡ÄªžÂ¦˜»™‹®‹{Ÿ|y€dbgidhbY\g[[xeauXRe]ˆOHŸVO»aY×jcóvpÿ}zÿwuÿljÿZUÿPJñD>ôMGàB9ßF>êWOº,"¼2'½5'Ç=0ÑE6Ë>-Á2!É8%ÙF4ÞDFÒ9;Ë32Ë62Ó;6×<7Û<6á<6æ;4å82à5.Ø4+Ï5+Ê8+Ä<.Â>/ÑU;ÅI/»='½;+Ã=2Ä;5Â65Â37ÜKRÞLVâOYåS]éWaæU\ÝLSÒCGÉ5)Ð8-Õ81Ú64Ý55ß58á4:ß28å8<å6;ì9=ö8É53øceÿpyô\hêR_ÞHaõGhÿ:eÿ*]ÿ/aÿ@hÓE]–AFQ-!UJ8PN9OH5\O>YH8L<-NB2:D)?J*GU2Rd:]sBcEf†GeˆDcˆBa‰@a‹CcŒFeŽJfMgPhRlPkOfLcŠIaˆG_‡H_‡H`†I\‚G]€H]~I`|Ka{Ld{Of{Rg|S]xC^yD_zEAC8CE:IF=OH@RGAWI@]M>`O=aQ:aS9`T>_VGaZTfaeljwro€wožzt¢~wªzu«ro¨hf¥a`¢^^¦ba­hg·qoÃ|xÏ…€Ú‰ã—í–ó¢žÙ£ŸÚ¥¡Ü¦¢Ý§¡Ý¦¡Û¥ Ú¦žÙ¥Ö£œÒ¢™Ð¡˜Íž–É—ÁŒ‚´ƒy«mrvghlc_`e[ZlYUtUP€ULVK–RG¨ZN²ZP½\SÔmdç|tò…~üˆðxyõyyæabÜPQ×EEñYVÎ61È1(Ç5(Ä7&Â6%Ã8%Æ9'Ì:+Ð<.Õ?1Ô8+Ö=/Ø?1Ó;-Í5'Í4&Ø:.ã?5à90á90Þ7.×7+Ï7)È;)Ä@+ÁC,Ä;3È?7ÍD<ÏF>ÌC;Å<4»2*µ,$Ä>5ÍG>×QHÞXOá[RßYPÖPGËE<Ìÿ)<ö*6í.6ç48å;;Ü94Ü:5Ý<4à;5ã:5æ93é73é62ì25ì44ë54è64ä71ß7.Ú6,Ø6)Û9*Û:(Û:&Ü9&ß8%á8%â7#â7#í41ï4/ñ4.ó3.ó4,ï5)ê6(å8*à:.Ø7/×96Ý>BÿlyÿasþRlöGdÿIjû5Yÿ5]ÿ;eú=cãPj©LVT)":1 9<)EF4RL>PH;BC39E15K4FGHJ#MQ,U\:\jGcuOf}QeNc…Hb‡BaŠ>cŒ@eDjIl‘Nm‘Qj’IiFgŒFf‹Ff‹Hf‰Ic…Ic‚GdƒJdIc~Gc~Gd€FfFe~Dc|BX}8[€;^ƒ>[K>^M;`O;`Q:^S?^WGa\Vhcinlyrqƒtnšvpžtp¢pm¢gfŸaaŸ]^Ÿ\\¤ed°kjºtrÅ}{φ‚ÙŽˆà”Žè˜’ì›—Òœ˜Ó™Öžš×™Ö—Õœ–Ò•Ñž–Ñœ”Íœ“Ê›’Ç™‘Ä“‰»ˆ®€w¦tmtkdkf]`e[YiZSoWMzVJŠVI›UK°\RºYRÁXRÓf_Þqjãvoêwý‡…ÿˆ‡÷uuðfdäTSíYUÇ2+Â/%Æ7)Ã7&À7%Á8%Ä9&É:*Ï;-Ó=/Ö8,Õ9,Ó:,Ò:,Ñ9+Ñ9+Ô8+Ø8,ß;1à90Ü8.Ø8,Ð8*Ç:(¿;&¼;%¿4-Á80Æ=5É@8ÊA9È?7Å<4Â91¾5-Ç>6ÑH@ØOGÚQI×NFÌC;À7/Ê8Ñ9"Û8)å4,ï./ö*3û(7ÿ(:ÿ+Bÿ*Bÿ)Aÿ&Aÿ$@ÿ >ÿ=ÿ<ÿ8ÿ9ÿ$;ÿ);÷-9ï29ê7;å;;Ü94Ü:5Ý;6à;5ã:5æ93é73é62ì25í36ë54è64ä71ß7.Ü5,Ø6)Û9*Û:(Û:&Ü9&Þ9%á8%â7#â7#é4-ê3-ì4,ì4*ì4*ë5(æ6)á7*ÞcŒ@eDiŽHkMlPl’IjGhGf‹Ff‹Hf‰Id†JdƒHe„KdIc€HdHeGeGfEd}C\<_„?b‡B69.:<1??7E@:KB=OE/Ô>/Î6(Ë/"Ú:.Û7-Ù7,Ö8,Ñ9+É:)Â9&¼8#¾4*À6,Â8.Ä:0Ç=3Ê@6ËA7ÌB8Å;1Ê@6ÏE;ÐF<ÒH>ÑG=Ê@6Â8.Í6!Ô7&ß7,é3/ñ03ø,5ý*9ÿ*<ü'=ü'=û%=ù#;û!:ü8ü7þ7ÿ6ÿ6ÿ#8ý*;ù1<ñ6=é9;ã;:Ü86Ü:5Þ;6à;5ã:5ç85é73é62ï26î47í55ê65å61ß6/Ü5,×5(Ù9)Ù9)Ú9'Û8%Ý8%Þ7$à7$à7$â4+â4)å4*å5(ã6(â7&Þ7'Û8)Ý=1Ï2+×98ÿltÿ]nþPið=[ÿJlÿ5\ÿ=eü4[ô<`êTq«?Oa#(H1+79+-8'18&:;)B=*A<(@>)@B*?GY`4s~T€Œfw‡bi~Ub|MaI`ƒC`…?aŠ>cŒ@hŽEjJkMlPn”Kk‘HhGgŒGgŒIh‹KfˆKf…Je„Ke‚Jc€HeGf‚Hf‚GeFcDb‡BeŠEhH06*58-;<4A>9G@:KB;RE.Ð?.Ë8(Ç/!Ò6)Ó5)Ô4(Ò6)Ñ9+Í<+È=*Ä;(Æ9/Æ9/Æ9/Æ9/Ç:0È;1É<2Ê=3ÒE;ÒE;ÐB8Ë=3Ë=3ÏA7ÏA7Ë=3Ñ4#Ø6)â5.ë31ò/5÷+6û(7ü)<ù&9÷&;÷&;ø'<û&<ý%<ÿ$:ÿ#:ÿ!7ÿ"7ü%7ù-9÷5>ñ:?ç9:à87Ü86Ü:5Þ;6à;5å95ç85ê65ë54ñ27ð37î66ê65æ72á6/Ü5,×5(Ø8*Ø8(Ø9&Ù8&Ú7$Ü7$Ý6#Ý6#Ù6'Ú7(Û8'Ü9(Ü9(Û:(×:'Ö:+Õ;/Î3.éIKÿo{ÿVjøDaö=_ÿCiÿ/[ÿ7`û=cëLlÆOe€0=G >3--3'+8'2=,=B.B@+C;$G="MA'R_*q}MŸp—¨|ƒ˜mj„W_{J]~E_ƒCa†@b‹?fCk‘Hl‘Lm‘Qm‘So•Ll’IiŽHhHhJiŒLhŠMiˆMf…LdƒJdGe‚Hf„Hh„If‚EeDf‹FiŽIl‘L-3'17-7:3<;6B=9G?UOCZUQa_dhgukkƒllˆjg’baXV‡PP†QQXYš`cªfj´orÁuxÉ|Ѓ„Ö†‡×‰ˆØŠ‰×Œ‰ØŒŒÌ‹‹ËŠ‰Í‰‡Ð‰…ш„ÑŠƒÓ‰‚ÐŒ„Ï‹„È…Á†º†²‡¥}x–vpŠ“ScƒQ\qUT`^RVcOTbH_]DvUB’LB¼RRÖPWàPYé\dèejâljâwqâvláphõ~vÿ‚{ÿ‡~ôkaÉ?2À8(À;(¿='¾='¿='Â;'Å:'Ç8(Ê8)Ü8/Ú7.Ô8,Ï9+Ê;+È;*Ç:)É7(Ï9+Ñ7+Ô8,Ó7+Ï7*Ì8*Ë<,Ë>-É=0Ê<0Ê<0É;/È:.Æ8,Å7+Å5*Ð@5Ð@5Í=2Ë8.Ë8.Î;1Í:0É6,Ò.$Ù0)ä2.î23ô/8ù-9û+;ü+>ü-?û.?ú0@ü/@þ/Aÿ.?ÿ-?ÿ->ÿ)9ý)8ø*7õ0:ó6=ì9=ã77Ú53Ü86Ü:5Þ;6â:7å95ç85ê65ë54ò38ñ48ï56í76æ74á6/Ú6,×5*Ö9*Ö9*Ö9(Ø9&Ø9&Ù8&Ú7$Ú7$Ô9%Õ:&Ô<'Õ=(Ô=(Ô=(Ó>*Ó=.Ð8-Ù;8ÿ^eÿaqÿPi÷;\ÿAiû6aÿ/]ÿ.WøIjÛYq•>NX'-?+,730*1)-9-5@/:B+<<"B;VG(iV6v‡P£lª¾‹¨¾Ž¥wo‹[aK^F`…BcˆBeŽBj“Go•Lp•Po“So“Uo•Ll‘KiŽHgŒGiŒJiŒLi‹NhŠNf…Je„IdƒHfƒIg…Ih†Hg…Gf„FgIi‘Kl”N*2%.4*470894<;7B=:HA;KD(À>(Á=(Ä;(È;)Ì9)Î8*Ú3+Ù6-Ö:.Î:,Ç:)Â9'Ä;)É=,Í>.Ö@2ÙA4×=1Ï7*Ê4&Ê8)Ë<,È:,È:,É;-Ê;-Ê;-È9+È6)Ç5(Ê6*Ï;/Ò>2Õ>3Ö?4Õ>3Î7,Å.#Õ)%Ü-*ç02ñ29ø0;ü/>þ/?ý0Aú0@÷1@ö2@ö0=÷/:ù-9ú,8ü*7ý/<ù/;õ0:ñ2:í6;æ68ß55Ù42Ü86Ý:5ß:6â:7æ87é77ê67ë54õ49ó49ð69í76æ74ß6/Ú6-Ö6*Õ7+Ô8)Ô8)Ô9'Õ8'Õ8%×8%×8%Ï:$Î<%Î>&Í?'ÍA(ÍA*Î@,Ï=.Ð71éIKÿgrÿOdÿHfû7]ÿAmý/_ÿ1^ø1XåOj¹Wfh39@*,?994443524925>-2<#29ECl`8Ž}R™±u©Á‡µÎ—­È•’®}v”be†Q_ƒF`…Bc‰@gDo•Jr˜Or—Rq•Up”Vo•Ll‘KhGf‹Fh‹IiŒLi‹Ni‹Og†Kf…Je„If…IhˆIjˆJi‡Gg…EhJk“Mn–P(0#*2'/4-350664<87@<9C>8IEû3>ú0>ú0@ø/?ò.<ï/<í/9í07í.5ï,2ò+2ò)/õ1;õ3<ò5;ì59ç47á55Þ65Û75Ü86Ý97ß:6ã:7æ87é77ê67ë46ö5:ô5:ñ7:î87æ74à72Ù6-Ô6+Ñ8*Ð8*Ð9(Ð9(Ð9(Ñ8&Ñ8&Ó8&È:"Ç;"È>$Ç?%ÇA(Ç@*Ê>-Î;1Õ:6üU\ÿ_oÿGcÿ>bÿ8cÿ6gÿ0cÿ4\òCbÈMa…BIL44:97<<>948>58<7379+3="8DS[,ƒPª£o«Èˆ¯ËŽ¯Ì’¦Ã‘¯}{™ggˆQ^‚E^ƒ@c‰@iDo•Js™Ps˜Sq•Uo“Un“MkJgŒGeŠEgŠHh‹Ki‹Ni‹NfˆLd†Id†Ig‡Hi‰JjŠIi‰FhˆEi“Kl–No™Q&.!(0%-2+130333756:97>;6GD=DD*½<'»8$¾5#ÑB2ãOAäN@ØB4Í7)Ë7)Ð>/Ê;+É:*Ç8(È6'È6'Ê6(Î8*Ð8+Ó;.Õ;/Õ9-Ó5*Õ7,Ü;1Ý<2Ú9/ë7:ñ8=÷:Aü8Bü4A÷.>ò,;ï,:í/;é19è38é58í57ñ48ô36ö45î49ï6;í9<é69â45Ý33Ý86ß;9Ü86Þ97á98å99æ89é69ê67ë46ö5:ô5:ñ7:î79ç85ß82Ø7/Ó7+Ð8+Í9+Í:*Ì;*Í:*Í:*Í:(Ï9(Ä: Â: Ã=$Á?%Â@(Ä@+É=.Í81ßhŽCo•Jr˜Or—Rp”Tn’To“MkIgŠFeˆFf‰Gh‹Ki‹Ni‹NfˆKe‡Jd‡GeˆHgŠHh‹Gh‹GfŠDj”Lm—OpšR(0!'/"(-&+-*.0/333775:94==5?@8DE?JLKQQYVWiZ\s]^|YW†[Y‹^]–ee¥nn¸wxÊ€Ú„„䊌ðŠŒðŠŠì†‡ä‚‚Ü€Ô‚€Óƒ‚Ò€„ĄǃƒÉ„„ΆƒÒˆƒÕ‹ƒÖŒƒÒŠ€ÇŠ€½‰±…~ €xwpxkeec^XpZMm[Mi\Kf^Kd_IcaHfbGl`FlR;„UA£^O¿aYÑYXßPTñQ[ÿXbôkcæYRÔD<Î70Ñ7/×;/Ø/Å@/Á@-¾=*¼9'Â9)¾0"êVJáJ?Å.#Ñ=1Î2Ü<0Ù7,Û7-â>4éE;øAFó8?ð3:ö4?ö2>ñ-;ï,:í2=ì7@æ5;ã68å78é99ð:9ñ86ò65ï==î<<ê:<æ89á77ß76Ü75Ü75Þ97á98ã99æ::é9;ì9<í9<ï8<÷6;ô5:ñ7:í9:è:9à;5×90Ï7,Ë7+È9)Ç:)Ç:)Ç:)Ç:)È;*È;)Á9!Ä>%½;#µ5»:$ÈE3Í@6Ê0.ÿ^eÿVgÿHcÿ;\ú0Xø/[ý5cÿc‡?iDn”Im•Ll”Nk’Qj‘RjŽHfŠDc†Bc†Df‰Gh‹Kg‰LdˆJg‹MhŒNg‹Kf‹HeŠEf‹EjIm“Jp›SrUtŸW*0")/#).'+-(-/.222553782;<4>@5BC;HJGOPTSUaXYm[[s\Z‚^]‰da–kj¦us¼}Ї‡á‹‹íŒòŒ‹ñ‰‰í…„ ڀ~Ò€σ€Ï…†Æ†‡È‡ˆË‰ˆÎ‹‡ÑŒ†Ð…ÎŽ„ÉŠ€½‰³†{£‚x‘{s€tknkd^e\SbaLb`Ke^Kh]Ii\Ij^Hk_Gm_EraG{]CŽ[Fª[LÆWPàQS÷PXÿS`ìWQãKFÛ>9×50Ú5/Ý90Ü8,Ø8*Ó8&Ñ8&Ñ8&Ô8)×7)Ü5,à3,ã2,Ë1'Ë4)È9+Æ=-ÄA/Á@-¾=*¾9(Â9)Ë<.åQEÜH<È4(Ì:-È:,Á5&Ê=+Ê=+Ê;*Ì;*Ë:)Î8)Ï7)Ï6(Ó7*Ö8,Ù7,×3)Õ1'Ø1(ß7.å=4ûBHò7>í07ï/:ò0;î.;ì1<ê6?ã6<Ü36×32ß:8îEB÷JFøEAõ?<è:9æ:8å97â96á85à85á98á98à87â88å99ç9:é9;ì9<í8=ì7<ô5:ò59î68ê88æ:8Ý:5Ó91Ë7-Æ8*Ã:*Â:*À;*À;*Á<+Á<+Á<+½9"Á?)¹;$²5¸;'À>];2@>/3A05?4E=:X;?T-0X51ZI7bjEu[бpšÄ|žÈ|š¹}š¹€™·ƒ©yr`YuESq?\{B_>b†>iCm“Fl”Kk“Mh‘MhQhŒFeˆDc†Bc†DgŠHiŒLhŒNg‹MiOiMiŽKgŒGgŒGfŽGj’Im•LnœQoRr U-1"-1#,/&,.).0-11/34/45-9;0<>1@B5EH?KMLQRWUTbXWi\Yx^]fcŽpm¢zx¹…‚ÏŠáíŽñŽŒïŠˆé‡ƒá~Õ|Í}È}Ç…‡ÄˆˆÆŠŠÊŒŠËŒŠËŒ‡ÇŒ„À‹‚¹‰€¯†|¡€v‘{p€ujpod`i_Ue\MXeK]bKa_Jh[HmZIp[Hq\Go]EtcItZ?‚V= WDÅYMäTSûNTÿIUß@<Þ<9Ý84ß61á6/á6.Þ6+Ú7(Ö6&Ó8&Ó8&Õ8'Ø6)Ý5,á3,ä1,Ç5(Å6(Â9)Á<+Á@-Á@-À=+À8(Ã5'ÜJ=ÜE:ÕA5Îë7@ê=CÜ7;áAAìNK÷ZUüZUùRLïB>è62à72à74à74ß74à85á96ã;8ä::á77ä88æ89è8;é9<ë8<ì7<ì7<ò38î47ì57ç77â:7Ù:4Ï8/Ç7,Â8+¿:+½;+»<+»<+»<+»<+»<+º9$¾@*³9$°7$¶;+´2%Ã40îOTÿZiÿH`ù8Uó6Vó>]ñFfçHfÞEat?9e?6QA2@C04?.29)>5,O61K*#W:,j\Bˆ_«t”½{“ÃyÃv•²|œ¸…™µ…€šm\uKHa7Nh9[xB_}?c„?hŒBl’Ej“Gh’JgLeMe‰Cd‡Cc†BeˆFh‹IjŽNkOjŽNkOkOiMhJgHi‘Hl•Ip™Ms¡Vt¢Wv¤Y25$13&02'01+12-23.34.46+9;-;>-?B1DF9IJBNNNRQWTR]XVd\Zoda~nl”zw®„‚ÄŒ‰Ø‘Žå”‘ì“펋扅ڂÎ{Å}¿‚}¿ƒƒ¿……Á‰ˆÂŠÃ‹ˆ¿‹„¸‡®…}¦…{€vŽzm~sfmoa`k^Vi[NgZJVdJZbJa_JjZJpYIsYJtZIs]FqY?tU9†T;§ZFÌ\PæRNóEGù:AØ3/Ü41á51ä50ã5.â4+à6)Û8)Ö7$Ó8$Ñ8&Ô9'Ø6)Ý5*à3,ã2,Â8+¿7)»7(¼:*¿=-Â>/Ã;-Ä8+Æ3)ëTKÔ;3Ì8.ÑA6¾4'À<-½>-Ã7&Ä8'Æ9(Ç:)Ê8)Ë7)Ì6(Í3'Ó5*Ô3)Ö2)Û4,ã:3é>7ì?9ë>8è47ì59ï6;î5;ê2:æ39ä7=á<@óUVûc`ÿnjÿidóVQäA<ß61à3/Þ71Þ71Þ71ß82á85â96å97æ::å78æ89è8;é9<ë8<ë8<ë8<ë8<ñ48î68ê67æ87à;7Ö<4Ì9/Å8.½9,º;,¶;+µ<+´<+´<+³;*³;*³:'·@,­8&¬9'±;-«+"Ã54ÿ_gÿSdýE]ó;Uí1B2SE*okHŠ“f•¬t´t‹¹q‹½t¡¹‰¡¸Š§}l‚\K_:BV1Lc7Yq?_{@dƒ@i‹Ak‘Di’Fg‘IdJbLc†Bc†Bd‡CgŠHjMkOm‘Qn’Rj‘Pj‘Nj’Li‘Jg‘Gi“Gm—KqœMu¥Yv¦Zx¨\78(78*66,56056156167/68+;>-=@+@C.DG4IK=NNFQPNSQTVUSYY[a_lkius›€}´ˆ†ÈŒ‰Ö•’ã”äÞ‹‡Ó„Æ}º|µ€{±~¸‚º‡„»‰…¸Š„²†¨z›€xs‡znzrfjm_\j[Tk[NjZKjYI^bK_aKe^Kk[KpZLtZKw\Kz[G{WAƒS=—U?³XFÍSFÝF?å76ê01Û2-ß3/â5/å4.ã2*à2'ß5(Ü9(Ô7$Ð9$Ï:$Ñ:'Ô8)Ù7*Ý5,à3,½>-¹:)µ6%·8'½;+Â=.Ç;.É6,Ñ80ö\T×=5Ë4+ÏA5¸3$·:(¹@-Â9)Ã:*Æ:+È:,Ê;-Ì:-Ï8-Ñ7-Ñ3*Ò1)Ö1+Þ71ç;7ë>:è;7æ74é77ï;<ðê7=ê7=ð69î79ê7:ä::ß=:Ö=7Ë;2Ã;/¸9*´;*±<*¯<)­=)¬<(¬<(¬<(«:(¬=*¤9'¥:*©9-«0)ËAAÿgr÷L^÷E[ðBYèF[ÛN^ÈT]´VW§SQSU@LN9JG4JE1FD-AA'>C#@G%MU.^g,?=.==1==5=<7;<6;=2;=/?B-@D+CG,GI1KM8NOASPITQLYXDZ[M_^Zgepqo‡{y¡ƒ€·‡…ƌӋՊъ…ǃ€¹~z­zw¤{u¡zw°|y°€|®~©‚~£y•|t‰zrvkqrffm`Zl[QlZNl[KmZKmZIg^Mi]Mi]Mj]Mn]Ms^My^M€[I“`OšWG§N@¹I=Æ@5Ð6.Ù0)á0*á51â5/ã4/â4-à2)ß3'Ü6&Ú;(Ð9$Í;$Ì<$Í<'Ñ:)Õ9*Ù7,Ü5,ºA.´;(¯6#°5#¹:)Â=.É;/Í6-Û>7ùZTåHAÐ90Ì@3¸6&«4 ±>)¿7'¿7'À7'Ã7(Å7)É7*Î7,Ð8-Ù<3Û:2Þ93å<7ê>:ê=9ç85ã41è96ë<9ê::è8:ì>@øORÿccÿqpùheàUPÈ=8¿2+È5.Ö;7à<:â:9à<3á:2á:4á83ã73ä65å55æ68é69é69ê7;ë8<ë8>è7=è7=ç6<ð8:ì8;è8:ã;:Ý>:Ó>7É<2À+>467>O#Jh4gTt•\„›c‹™dŽ›f‘¢l•¬t•²x„”pn}\Q`C=J09F,BO3O_;Xi=czDgBkŠDk‘Dh’Fe‘F`G`Gf†Ci‰FjKlMlOkOm‘Ql“Rm”Qm”Qm–Pl–Lk—Jm™JržOu¢Qy¬]y¬]x«\CB0DB3DB6EB9CC;CC;BB8AD3CG0EH-GJ-JM0OO7RQ?TREURI[\:\\@\]Kaa_ihvrq{z¦~µ†‚¿ˆƒÃˆ„Á„¸{­ysŸtp•qmŽol£rn¡tq wršwrtoƒskxrilmb^l_Vj\OlZLn[Lo\Kq\Kq\KrZNq[Nn\Nl_Ol`PqaQy_N†[KŸ_S¦OE°A8½:2È5-Ï1(Ø1(Ý5*â70á6/á4-á3*à4(ß5(Ù6%Ô9#Í;"Ê<$È>$Ê>'Í<'Ò;*Õ9,Ø8,·D/±<(¬5!­4!¸9(Ä<.Ì9/Ï5-Ú83ñNIòSMÙB9ÌB5½@.¥2¬?(À;,Á9+À8*À6)Å7+É9.Ï;1Ô;3áD=ãA<ä?;ç>;é=;é;:è88ç77æ93æ95å84é;:ôJJÿ\[ÿdc÷caË=9¿82»4.Ã81ÓB=ÞE@ß=;Ù42â;3â;3â92ä84å84æ66é77é77ê69ë6;ë6;ë8<ë8>è7=è7=ç6<í68ê69æ89à;9Û>9Ñ>6Æ<1¾<.²8)®;)ª;(¦;'¤;&¡;%¡:' 9&ž?-”7%š=,—:)˜3'ÂQKíkmï\fïN^ìI\àHWÎJU·SS¡]RŒfQ‚jP=Sg{Fh‚Cl‹Ek‘Di“Gc‘Fa‘G^Gi‰FlŒImNn‘OlOjŽNkOk’Qp—Tp™SpšRo›Po›NqNv£Rw¦Uz­^z­^y¬]GD3HE6HF9HE±61Á3/Î5/Ö5+Ù7*Û8)ß6/ß4-à3,à4*â6*Þ7'Ø7%Ï7 Ì<"È>"Æ>$Ç?'Ê>'Ï<*Ó:,Õ9,µE/­='¨3¬3 ·8'Å;.Ì9/Ò5.Ò/*ä?;ûYTàI@ÎD7ÆI7¥5®D,ËF7ÉD5ÉA3É?2Í?3ÒB7ÚF<àG?ßB;à>9à;7à74â64ä65ç77é99é>7ç:4ä73è<:ñIHñMLØ=;¹(%¸-(¼5/Å@9ÌC=ÐA;Ö=8Ý>;ã?>á:2á:2â92ä84æ95è96ë99í9:ë7:ë6;ì7<ë8<ë8>è7=ç6<æ7<ì59è58å78ß:8Ù<7Ï<4Ä<0º:-°8(«:(¨;'¤;&¡:'Ÿ:&Ÿ:&ž9%š?,4"—>,“:*“1&Ì\X÷y|æT_ðTbèI[ØDRÃGO®SPšbS†lS{rSC[C?H3B7%O6"_K0prJ€£iˆÇ€yÃt{¾qu¢]oƒHy}J‡†Xy|O\d5:D)3=$4>&WN?XO@YPAZQB\SD]TE]TEcZKbYJbXNcXRg\Zmacsfmwjs|n{~p}s€s€~p}wjtobli\fcb]a`[a^W_\U_[R^ZOa[ObZMe\Kg\Ji\Ii]Gk\El]Fm]Dm]D_gOkiTqZH{M@•RI©WL®TI³WH¦N:¢G2¢?*ª;(¾:.Ò72à23å,1Þ7.Þ7.Þ7.Ü8.Ü8.Û7-Ø6+Ø6+×7+Õ7+Õ7+Õ7+Ô8+Ô8+Ô8+Ô8+¸=.·=.°8(§2!ª2!´;*½>/Â:,Æ6+Í6-Ô:2ÜB8àI>ÖG9Ç;,¹1!ßOGÙIAÔE=ÓE;ØH?ÜG@àC>á<:ã54ê67ï8:í9:ç77à72Ý:3Ü>5ÎKAÈE;½=0µ7)°5&³8)¹>.ÀA2Á;/Ê<2Õ>5ß=8ç;9î79ò67ô68æ7>æ7>æ7<å8:å99å97ã:5ã:3Þ5.ß6/ã81ä84å97ç98ç9:ç9:ë;>ç9;á99Ü<<ÖA=ÌC;ÀB6´@3¦;+¢=+>,™<*–;(•:'”9&“8%‡F2‡>/†/%”-(ÀIKèkoçlqÊWZ¶OP©TQŸVO˜YP•[P–]R™^Vœ`XMb!:O3JOf x’I˜²h¡½r »t™²pƒ›akN\lEWdHS\GHN@=C9;<,AB4=?2:=2,¯:)½9,Ì70Ø42Þ22Ý6-Þ7.Ü8.Ü8.Û7-Ú8-Ù7,×7+×7+Õ7+Õ7+Ô8+Ô8+Ô8+Ô8+Ò9+¸>/·=.®9(¥2 ¦3 ²:)»=.¿;,Æ:-È4*Ì3+Ó;0ÜE:ßPBÞRCÚQAÝE@Ø@;Ñ<6Ð;5Õ>7Ø=8Û96Ý33é69í68ï79í68é77å97â=9á?:ÆC9¿?2¸:,±6'¯5&²8)¸=-¿@1ÅA4ÍA4×@7ß=8å97ê67ï56ô68ç6<ç6<ç7:æ89æ87å97å95ã:3â92ã:3ã:3ä;6æ:8æ:8å99å99æ9;ä:=à<=Ú?=Ñ@;Å?6¸<2¬;-¥;+ <,œ=+—<)–;(’:&‘8&7%z;)€8)‰5*ž;5ÁQPÚceÔ]a¹MM­NL¤SOYP˜\R—^S—^U˜_V™^VSg*Sg(^r3zO—°l¥¾z™²nˆ¡`j‚Fau@Sf9IY5FP7?H59?358/;<,AB4=?2:=2;A5:C2@M3Rc?]uCgƒHqLp”Jm“Hk“Jk“Lh‘Km‘Tn’To“Sm”Qk“Lj”Hl—Hm˜HpJnžJp Ls£Ou¦Tx©Xx©Xx©Zm–\b‹QY‚H]TE]TE]TE]TE]TE]TE]TE]TE[RC\SD]TE^UF_VG`WHaXIaXIe]He]Jd[Jd[Le[Qf[Uh]Yh\\i]]j^`k_ak__i]]f[YbWU`USYVMWTKTQHRNCQMBSOCWQCXRB^WG^WEaYFc[Fg\Hi^Hk`Jk`J^cOmhUy_PˆXN¤[T³VQ´HE¸E>¹@7¸>3·<-·9*¼8+Ã9.Ê:/Ï;1Û7-Û7-Û7-Ü8.Ú8-Ù7,Ø8,×7+Õ7+Õ7+Õ7+Ô8+Ô8+Ô8+Ò9+Ò9+º@1¶>.®9(£2 ¢3ª:&µ=,»=.Ä?0Å7+Æ2(Ê3(Ð<0ØF9ÛM?ÝQBÜ87Ø43Ô20Ô52Ù:7à>;å=<é;<ï8<ï5:ì27ê24é56å97á<8à=8¹;-·9+±6'®4%­5%°8(µ<+»=.ÈD7ÏC6ÖB8Ü=7â96è64í55ò67ê5:é6:é69ç79ç77æ95å:3å:3ã:3ä;4ã<6ã<6ã;8â:9á99à88Ý9:Þ;<Û@>ÕA=É>7º:1­7+¥7(¡;,œ=+˜=*”<(’;(9&8%Ž7$u8%y6%ˆ9,¢E=ºROÂVT¹OO¬HH¤LHœSL˜ZO—^S–bU—aW˜_V˜]UgxB{ŒU“¦n¥¸€«À‡ž³zz‘YYp:?R$AS)AQ-?L0:C.6<.690581:;+@A3=?29<1;A59B1@M3Qb>_wEi…Js’Nr–Lo•Jm•Lm•Nk”Np”Vq•Uo–Sn–Pl”Kk•Il—HmšIpJpJp Lu¤Sx©Xyª[u¦Wq¡U_ˆNVEOx>aXIaXIaXIaXIaXIaXIaXIaXI_VG`WH`WHaXIbYJcZKd[Ld[Le]Ff^Gf^Ig_Lg^Of\Pf\Rf\Sh]Wh]Wh^Uh^Ug]Se[QdZNdZN]YNZVKVRFRNBPL@PM>RO@UO?WQAYTA[VC^WDaZGd]Jf`JgaKadSleUt]O‹[Q«b\»YXºDD¾9:Æ;8É:6Ç80Â8-½8)¼:*½@.¾C1Ù7*Ù7*Ú8+Ú8+Ú8+Ø8*Ø8*Õ8)Õ8)Õ8)Ô8)Ô8)Ô8)Ò9)Ò9)Ò9)»A2¶>.¬9'¡4 2¢8"¬=)µ@.¼>/Á9+Ä6*Ç4*Ë7+Í;.Î0å26á14Ý02Ý34à88å;<ë=?î;?ï6<í38ì/5é05ç47ã77Û64Õ30±7(°6'®6&¬7&¬7&®9'²:)µ:*ÃA3ËA4ÔA7Ü?8â:7ç85í76ð67í6:í6:í68ë76ê86è94ç:4æ;4â92á:2ß:4à;7Þ:8Ý98Û97Û89Ö<:Õ@<ÓB?ÊA;»;2¯6+¥5'ž7(œ;*—<)“<)‘<(:&8$Œ7#Œ6%z@,v5#6'™E;¬OH¬MI©LG¨PLPH–VL“ZO“_R“bT•aV—aW™`W~‹]™©z­½Ž¦·Š¡ts†YN`8/A->3B%:F.=F3;A3:=2;<4<=79:*?@2<>19<1:@49B1?L2Pa=`xFj†Kt“Os—Mq—Lo—No—Pm–Pp—Tq˜Up˜Ro—Pm•Ll–Jn™JoœKqžMrŸNt£Sy¨X|«]w§[mSd”J[„LS|DNw?cZKcZKcZKcZKcZKcZKcZKcZKcZKcZKd[Ld[Le\Mf]Nf]Nf]Nf_Eg`Fh`IiaLiaNi`Oh_Ng^OjaRi`Qi`Qh_Nh`Mh`Mh`KiaLb_P^[LYVGTQBPM>NKTQ>VS@YVC\YF^[H^]I`aSf^QmWJ†[R­hcÁb`ÄLMÌ@CÔ:<×79Ö74Î70Á9+·>)²D+°H-×7)×7)Ø8*Ù9+Ù9+Ö9*Ö9*Õ8)Ô8)Ô8)Ô8)Ò9)Ò9)Ò9)Ò9)Ò9)¼A2¶>.«:( 7"™5š7 ¢>&¯B-±<*º;*Â:,È8-Ë8.Î:.Ð<0Ò>2ò5<î3:é27ã36â46â46â46ä15ì5:ì39ê38ê5:æ8:Ü66Ñ2/Ç,(®9(­:(­:(«:(«:(«:(¬9&¯7&¸:+Á<-Í?3Ø?7à=8æ:6ê86ì87ï56î66î66í74ë84ê93ç:3æ;3á:2ß;2Þ=5Ü=9Û=:Ù><Ø=;×==ÌA<ËB<ÆA:»<3­7-£5(ž7(š;)–;)“<)=(Œ;(Š9&‰8%ˆ7$‡6#}C/s4"y4$“G:¤RG¡NFžNE¡WN˜UL’XL[NŒ\NŽ^R”`U—aW›bYƒŽd˜¤|©ƒ€Žj]kJDS42@&$2-:&0;*5=.9?36:;3::29:*>?1;=08;09?38A0>K1Pa=ayGk‡Lu”Pt˜Nr˜Mq™Pq™Ro˜RršSršSršQp˜Om—Km˜Ip›LržOt Qv¢Sx§Y{©^z¨_qŸVd’JY‡?]†NVGQzBe\Me\Me\Me\Me\Me\Me\Me\Me\Mf]Nf]Nf]Ng^Og^Oh_Ph_Pg`Fh`IiaJjbMjbMjbOjbOjbOjbOiaNh`Kh`Ih`IhaGibHjcGe`Mb]J^XHXRBSM=MJ9KH7IH6KJ8LK9LM;NO=PQ?QTASVESVEYYM]WKcQEzXN¡ha¸eaÇUUÛORÞ=Cã8>à67Õ62È:.¹@+­E*¦I*Ô7(Ô7(Õ8)Ö9*Ö9*Õ9*Õ9*Ô8)Ô8)Ò9)Ò9)Ò9)Ò9)Ò9)Ò9)Ñ:)¼@4µ=/«<+ :$—7’6š<#¦B*°C.¹@/¿;,Ã7*Å2(Ë4+Ó:2Ù@8ó1<ð2<î5=ë8>ç:>å;>ä:=ã9<á48ä5:å8<ä;>Þ;<Ò86Å1-¼-'«<+«=,«>*©>*¨=)©<(©:'«8%¯6%¹7)Å;.Ñ=3Ù<5à;7ä;8è;7ð75ï75ï75î84ì94é;4è;4å=4â>5à?7ÞA:ÚA;ÙA>ÕA?Ñ??Ñ??¾B:»@8µ<3ª8-¡5(›5'˜8(•<*‘;*<)Š<(‡:&†9'„7%ƒ6$‚5#y<)r3!}:*—OA£YLœRG•OE–VJ”ZN[MŒ[M‹[OŽ\Q”^T™`Yœa[s}Xyƒ`r|ZU`B9F,/;'0;+1;03=44;35<4:?8?B9?A6<<277+89)>?1:27@/=J0O`HO?HO?PPDVRGYOChREYM˜UL³RLØXWàGJçï:Aì?CæBCáACÞ@AÚ>?Ï12Ñ56Ô::Ò<;Ê;7¾73µ4.¯3+¥>+¥>+¥>+¦?,¥>+¤>(¥<'¨;'ª7$²7'¼8+Å8.Ì8.Ö92Þ<7ä?;î85î85î84ì94ë:4è;4å=4â>4âA7ÝC9ÚC<ÕB;ÐA=Ê?<Ç=;Ã<9®>3©:/¢8+œ6(˜7'”8)‘:)Œ;(‹=)ˆ=*…<)ƒ:'‚9&€7&6%~5$v4$x5%…B2˜UEœXK“QCPD•ZL’ZM[NŽ]OŽ\Q’\R•\U˜[V™\W`hCX_=JS4>G,6?*2=-4>35?74=88>:=B/;9*78(=>0:26?.=J0N_;`xFk‡Lu”Pu™Os™NršQršSp™SqœMrNqœMp›LošKrNu¡Ry¥X«`~©az¥]qœUf‘L_‰G[ˆE\‰Hb‰RY€ISzCh_Ph_Ph_Ph_Ph_Ph_Ph_Ph_Pg^Oh_Ph_Ph_Ph_Ph_Pi`Qi`QmcWlbVjaRi`Qh_Pg^Og^Mh_NiaNiaLiaLiaJh`IhaGhaGhaGh`Kg_Je_Ib[H\WCUR?PM:ML:EF4DG6DH7BI9BI9BJ;BJ;BJ;JJ@QQERPAUNÄYSÛQOãCEå8:ß55×:3Ê>/¸>)¬<$Ï8'Ï8'Ð9(Ò;*Ò;*Ò;*Ò;*Ò;*Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)½=2¶:.­<,¥>+˜9#Œ59ž@' :$¯<)¾?0È;1Ì8.Ñ7/Ù<5àA;ð;Bï>FëBGãCEÖ@?Ê;7À50»1.·0,¼51¾:5»<6³:2©9.£9,¡9,Ÿ>+Ÿ>+ ?,¡@-¡@-¡A+£>*¤=*©<(­:(²7(¹5)Á4*Ë80Ö?8ÝD>é:5é:5è;4è;4ç<4ä=4á?4Þ@5ÝC9ØD:ÒC;ÊA9Ä?:¼;6¸85´73ž9-™7*•5'’6'‘:)<*‰:)„9&†=*„=+=*€<)~:'|7'{6&{6&y1#€8*ŒG8–RE’PB‹K?ŽSE™_SXKZN’\R–]T—\V˜[V˜YT—XSV^7EM(6@8A&>G27@E>GJ?GI;BC1?>);;#78(=>09;.69.8>26?.E5>F7?G8=H8AE4HK6YS;_F0€K9Àj]Ýf`åSSçDEè@@ã?=Ö=5É=0Â>/É3$Ë5&Ì6'Í7(Í7(Î8)Ñ;,Ó=.Ò<-Ò<-Ò<-Ò<-Ñ;,Ñ;,Ñ;,Ñ;,¸3,·7.±;-¦;)˜8"‘7’8š:"«B-±<+¹7)Á4*Í6/×<7âC?êHCëBGéDHÝCCÉ:6»61´80®8.§5+ª:/¨9.¤8. 8-›9,–:+’<+>-˜=*˜=*™>+š?,›@-œA.žB-¡@-¡<*¥:(«7(°6)¶6+¾8-Å;1Ê=4ß:4á<6â?6ã@7âA7ßA6Ú@4×@5ÚG=ÒE;ÇA6»;2±6.ª3-¤1,¢1+”;-’:,:+:*‰:)ˆ;)…<+„=+~:'|9(|9({:({:(z9'x6&w4$z, A4˜NC“MAŽL>RE‘VHŽRG˜\R˜\R‘UMTL™ZU—XS–WR `^R[0IQ(AK&BK,>H/7@-2=-4>34;3HPEX^RW[LLO?1;=0:=29?34=,;H.Pa=bzHlˆMu”Ps—Mq—Lp˜OršSqšTpJqžKrŸLrŸNsŸPv¢U{§\ªb‚­fx£^i”O_‰G]‡G`ŠJfŽOhRd‰U[€LTyEi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qj^^j_]j_]j_[j_Yj`Wj`Vj`Vj`TjaRjaRjaRjaRjaRjaRjaRj_Kh`Kg_Jg_Jd]J^YEUR?ONE5?E7>F7>F7=E6BF8>E5=F1DN5HK0PB'yS<¹ubÉdXà_YíUTêFGä>>â@=Û>9Ñ82Ì:+Î<-Ï=.Ð<.Ï;-Î:,Í9+Í9+Î:,Î:,Î:,Ð:,Ð:,Ð:,Ð:,Ð:,È?9ÆA:½A7®=/6#•2•2™3¦5#²7(Á;0ÑA8ÞE?æIDéJFìJGÞBCÛEDÎC@¼;5®9/¨>1¢A1œ?.œ@1™@0–>0’?/Œ?-ˆ?.„A.ƒB.‘;*‘;*’<+“=,”?+”?+–?,™>+Ÿ@.¡=-¤:,§9*¬8+±8-¶:0¹:1Ð90Ò;2Õ>5ÕA7×C7ÖD7ÔD9ÑE8ÊB6ÃA4¹=1°:0¨8-¢5.5,œ5.Ž=,Œ=,Š;,ˆ;+†:*„;*<,€=,~;*|;)y:)y:)x9(w8'u6't5&„1)‘C9˜NC‘K?ŒJ>PD’TIRG“SJšWQ˜UO™UR\X”WTŽSO—\XT]0Zc8_j@[eBIT66C)4@*0:-;H.Pa=c{IlˆMu”Pt˜Nq—Lq™PršSqšTq¡Kp LpJqžMt Qx¤W|§_ªc{¦aošUcŒJ]…Fa‰JeNeNc‹Ld‰U[€LTyEi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qj^`j^`j^^j_]j_[j_Yj`Wj`Vj`Vj`Tj`Tj`Tj`Tj`Vj`Vj`VlaMk`LiaLiaNf_La\I[VCTQ@ML:HI9DG6AE6AE6?E7>D6=C5=F57@-?H3EM5AA%QA']E³u`³WHÙbZðebîRSéEFìFHèBDÝ79È9+É:,É:,É:,É:,Ê8+È6)È6)Ê8+Ë7+Ë7+Ë7+Ë7+Ì8,Ì8,Î7,Â3/¾5/¸5-¬3( 0"›0Ÿ1 ¥4$»A2ÇC7ÖG?ãKFçLGéJFåFBâC?ÕCCÏDAÁ@:°;1£=/žC1™F4•G3’E3E2ŒC2‰B0ƒB0B/{B.xD.Š8*‹9+‰:)Š;*‹<+<+Ž=,<*–?.–=-›;+9* 8+¥9-©:/«;/¼7.¾90Á;0Ä>3Å?3Æ@4Ä@3ÁA4¸:,²:,ª9+£7+7+™7,–8.–91‰=-ˆ<,…<+„;,‚:+€;+<+<,};+z;*z;,w9*v8)u7(t6's5&Œ91”F<—MBŽJ?ˆHMKB3;I27C-EJ3IG0K<%mN9—dO§`NŸA5ÆSLçc_ð^^îRUíJMêDHç>CÉ;/Ç9-Å7+Å7+Ç9-Ê:/Ë;0Ë;0Ñ>4Ñ>4Ñ>4Ò>4Ó?5Ó?5Ó?5Ó?5Ó?=ÑB>ÍD>ÆF=ÁG<ÂI>ÆN@ÎPDÙSJÞOGäLGäIEåFCâC?àA=ß@<ÔFDÊC?º?7«<1ž>.—D2“H3‘J6‹G4ŠF3‡D3„C1B0zA.wC.uB/†8+…9+…9+†:,†:,‡;-‡;+ˆ;+‰:+‹:)Ž8)8*•9,™<-=/ž>0«9/­8.®9/°:.°:.²:,¯9+®8*¨7)¥7*ž7(›6*•7+’8-9/;0†=.…<-ƒ;,9*:+~9*}:*};-|:,z;,y;,w9,s8*q6(q7)q7)B8”G=‘K?ŠH<‡I<‹OD“UJ—TL—PLSP˜QO–RO—\X_Xh^žzn™k…’fu‚VYh=CR)?O(P`B'=A&;>#78(:;-79,9<1;A57@/MKH/JH1Q?+e>-”ZL¬`S›>6œ4+µ@9ØXUóigödeëRUèINìKQ×J@ÓF<Í@6Ë>4Í@6ÒD:ÕG=×G>ÚJAÚJAÝJBÝJBÞKCßJCàKDàKDëRTéSTãTPÜSMØSLØSLÛTNàUNàLHâHFäEBäB@äB@äB@ãEBãEBØJHËD@¹>7ª>2žA2–C1F3I6‰F3‡D3†C3ƒ@0@1}?0y@/x@1ƒ9.ƒ9.‚:.‚:.ƒ;/ƒ;-ƒ;-ƒ;-9*‚9*…9+‡9,‰:+;-<.=/›;/œ:/ž9- :.¡9,¢8*¢8*¢8*Ÿ8)œ8)˜8(”8)9*Œ:,ˆ:-‡;-ƒ;-‚:,9+~9*}8)}7+|8+{9+z8*y9-x:-t9+q5*o5)q7+r:-G;ŽH<‰I=„I;…K=ŒRF“WMšWO˜QMžTQ™RP•VQ’`YˆbW‚h[ŠwhivKZi>JY.AR&IZ0Wi?dvLj|TXjDL\8?M,:D)C-=@-:=*89):;-68+8;0H-NC-b=-„D:¯VP¶MJ¡++´:9º=;ÑTPòpnýwvñehêY^ò]cáVOÚOHÒG@ÎC<ÑD=ÔG@ÖGAÖGAÙHCÚIDÚIDÝIEÞJFÞJFàKGàKGãGJáGIÝGHÙGG×HD×HDØGDÝEBàBAåABé@CêBBèBBäB@ßA>ÜA=ÚJIÌB@»<6®>3¢@3—A2B0D3‰A2ˆ@2ˆ>1…=1‚<2€<1=1}=1ƒ:3;3;1;1€<1€<1=/=/=/€.™9)•9*“:*Ž;+Š;,‡;+ƒ;,€;+‚:,9+7)~6*{5){5)z6)z6+x6*x8,w9.s7,o5)o5)r:-u=0ŽL>‰K>„J<‚M=…QC‹VH’XM—WN”MIœRQšTR•[We\y_PcXFb]IBP,?M)?O(K\2_qGk~QcyKVk@M_7@R,6E&7D*=F1=D4:=27:19:*:;-68+8;0G*SA+{E9¦NL¸EH»5<¾19Ë@EÄ?@ÊJIÞb`îrpïopçbeáZ^ÛRJÕLDÏD=ÍB;ÏD=ÒE>ÐC<Î?9ÒC=ÓB=ÔC>×C?×C?ØD@ÙEAÚEAà?Dß@DÞDFßFHßIHàJIãIIæFHçACëADîAEîACéAAâ@>Ù>:Ö=8ÛEGË=<»73°;4¦@4˜?1>0ŽA1‰=/Š<0‰;1‰92‡81†93…:4„;4:4:4€<3€<3<3}=3}=3|<0{=0{=0{=.{<-z;,y:+z8*z8*€:0‚:.„:-ˆ:.Œ:.‘;.”<.–=-’9)‘:):*Š;*‡;+ƒ;,<+}<*€8,€8,~6*}5)|4(z4(z4*y5*u3'v6,v8-r6+n4(n5*s:/v@4‹PB†N?N=R@…VF‰XIŽUJ‘RI“NI™RP”SO‘\VŠfZl\LML7BL3@O.KZ9WgC`rJezOdzLVl=G]/AV+7I#0A!5C*=F5QJ:MG7IC3GA13M*>G*[B.PGºVVº7?»'3ÜBNÐ:CÄ9>»;:ÂHGÓ][ßgf×[]ÇILÓJDÏF@ÌC=ÎC>ÒGBÒGBÐB>Ë=9ÒC?ÓB?ÔC@ÕDAØDBÙECÙECÚFDá>Cà?DÞBEßEGáGGàFFàBCâ=AëADí>Cì;Aê<>æ>>ãA?ßD@ßFAÙ@CÉ78¹30±:4§?4š>1=/Ž?2Š;.‹9.‹80‹61Š71Š73‰84‰:5:3:3:3~;3|<3|<2{=2{=2u9.v;-w<.w<.x=-x=-y;,y;,{;1};/~8,7*„6)‡5'‰6(‹5&7(‹8(‹:)ˆ;)…<+<,~=+{<*€8,7+~6*|4(|4({2)y3)y5*t1(u5+v8-r6+n4)n5*t;0xB6ŒTE„Q@P>‚UB„YHˆYI‰SGNG˜SN˜RPPKˆVO‚bUeZHFK4;K0IX;[jKgxVewQYnCSi;Me5I`28M"-B*;2@):E7;B;8<;7;<<=-<=/79,9<1=C77@/6C)DU1Rj8_{@mŒHp”Jq—LršQtœUr›Uq¢Qt¥Vu¥Ys£Ym›Sd‘N\‰HZ„DdŒNa‰J`‡HcŠIfJiŽIeŠDa‡>`‚PWyGPr@i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTo\Nq_QtdUrdWnbTj`Th`ShbTgaSebQa^K[VBVQ;TN6NH.GA'RD)N=#cI2iV²zm·ng³[W¸PQ¶BEÁ@EÉ@GÑBFÖDGÚEIÜGIÝGIÔBEÔBE×BDÙEEØDBÒC;ÎD:ÌH;ÄF7ÃH9ÆH:ÊG?ÐEB×BDÜ?FÞ=EâBDâBDâBDâDEâDEãEDãEDãEDâDAâC@áB?â@>ã?=ã?=ã?=å@>ÎE?Ä?8¶:2©80Ÿ:0•>4Œ@3ƒ?2A4|@5}?4<3ƒ:3‡83Š73Œ72…<-…<-…<-„;,ƒ;-‚:,‚:,‚:,9-9-9-~:/~:/~:/~:/~:/~80~80}90}90}90}90|90|90|90|90z:0y9/y9/x8.w9.w9.w8/w8/v7.t8.s7-r6,q5+p6+l2'q7,m4)l3(o6+m4)q8-H=ULƒTL†QK‹PJNJ•NL˜NM—PL”SM‹UK†\NdOkaFTW8JX5N_;gT`zMWpFTkARg@O`0CA4B@4@<12:/2:/4:.5;-9=.A,>D*T^4ÉE9ÈF9ÊG=ÍG>ÒGDØCEÜAEß?GáCDáCDáCDâDEâDEáFDáFDáFDàEAáC@àB?ßA>àA=àA=â@=ãA>ÑFAÉB<¼=6¬:0 90“;/‰=0=0A4|@5}?4<3ƒ:3†91Š71Œ72…<-…<-„;,„;,ƒ;-‚:,‚:,‚:,9-9-9-~:/~:/~:/~:/~:/}90}90}90}90}90}90|90|90|90z:0z:0y9/y9/x:/w9.w9.w8/w8/t8.s7-r6,r6,p6+p6+k1&q7,m4)l3(o6+l3(p7,~H<‚SK„TJˆQJ‹PJ‘PL•OM–PN–RO‹OG…SH€[K{ePsiPhkLdrOgxT\uKXoEPf?Ka:K_:K\:GV7CP42><03;03;05;/6<09=/A,>D*Q[9^mDmPpŒRr’Sq™RsSsŸRxža|¢exžak‘T`†I]ƒF]ƒF\‚E`†Ia‡Jc‰Le‹NdŠMbˆK`†I^„G]MRtBIk9i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTtbTo_Pm]Pm_ToeYog\keYhbVfbVpl`{xi~{jzgzuapiVf`JPVÔG@ÖGCÚFFÛEFÝDGáCDßCDßCDßCDàDEßECßECßECÞDBÞE@ÝD?ÜC>ÜC=ÜC=ÝB=ÝB=ÕF@ÎE=ÃC:³>5¢:/’8-ˆ9,<-€A2~@3}?2=1ƒ:1†91ˆ81‹80…<-„;,„;,„;,‚:,‚:,‚:,€:.9-9-9-~:/~:/~:/~:/~:/}90}90}90}90|90{8/{8/{8/{;1{;1z:0y;0x:/x:/x:/x:/t8.t8.s7-s7-r6,q5+o5*o5*k1&o6+m4)k2'n5*i3'm7+}G;†QI‡PIŠQJŽQL‘RM“RN•TP’UPVO‡[P^OtbNoiQnrWjwYfwWPf@K_:EY6BV3EV6GV7FU8ER8?I1*7;*:<.<>0<=/:;-5<45<46<26<09=/<>0=@-=C)MV7Zi@h|KlˆNpOq™RuŸSt Sz cw`n”Wc‰L\‚E\‚E\‚EZ€C_…Ha‡JbˆKdŠMc‰La‡J_…H]ƒF[}KPr@Gi7i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTtdWqaTm_Rk_SkaWlcZle[jf]jf]wuiˆ„y‘•’Œ|‰‚r€ygZfNLV>AI2CF1ED0D?,I=-TD5M:+O8*R6*T7)X8+];/a?3eA5‹KAœSL­UQ¶NK½EDÇABÓCCÛEF×?>Ø@=×B>ØD@ÙEAÚFDÛEDÛEDßCDßCDÞDDÞDDÞDDÝEDÝEBÜGCÛFBÚE?ØE>ØE>×D=×D=ØE=ØE=ÖC<ÔE?ÊE>»@8§;/–8,‹9+…;.‚@2@1~?0=/;/„:/‡9/‰90„;,„;,ƒ;-‚:,‚:,‚:,9+9-9-9-~:/~:/~:/~:/~:/~:/}90|90|90{8/{8/{8/y9/x8.{;1y;0y;0y;0x:/x:/v:/v:/s7-s7-s7-r6,p6+o5*o5*n4)j1&o6+l3(h2&k5)h2&l6*|F:ŠOGŒPHQIRMSN’UPWPŽYQ‰]R…aUy_PiZGd_IciOZgKN]@EU8AQ4=M0G2:A/7>,9=,9=.8<-7;,6=66=66;46<29<1;=/dxGj†LpOs›Tw¡Uw£T{¡dr˜[e‹N\‚EZ€C\‚E\‚EZ€C_…H`†Ia‡JbˆKa‡J`†I^„G]ƒFY{INp>Ef7i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTseXugZsg[mcYjaXle]snhzwp~w† –©¥œ«§œª£™£‘œ”‰v~i`hSLSADK9AJ7>G4>G4BI7GNBÛ?@ÛAAÛC@ÚEAÚEAÚEAÚEAÞDFÞDFÞDFÞDDÝEDÝEDÛEDÙEAÚFB×FAÕF>ÔE=ÓF=ÓF=ÓF=ÔG>×@9ÕB;ÏD=ÁB9®>3œ:-‘;.‰=/„?0?/~?0=/<-„:-†:-ˆ:.ƒ;-ƒ;-‚:,‚:,‚:,9+9-9-9-~:/~:/~:/~:/}:1}:1}:1|90|90|90{8/y9/x8.x8.v8-y;0y;0x:/v:/v:/u9.u9.u9.s7/r6.q6.p5-o4,n3+m4+m4+j1(o6-j4*h2(j4*g1'k5+zF;MGNH‘PJ’SLUOŽWPŠZP…ZQ{YMv\OkZJ]UBYXDY^HOYA>L3;G18D.5A+5A+8D.=I3AM7EN;BK8?H5.5<,4;+5;75<56;56;48;2:-;@)GP1Ra:buGi…Kq‘PuVy£Wx¤Uzcn‘W`ƒIZ}C[~D^G^G]€F`ƒIa„Jb…Kb…Ka„J`ƒI_‚H^GW{KLp@Bf6haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTmaUndXpf\lcZkd\rmg„|‘‹¥¤ ³²®ÄÁ¼ÉÆÁÉľÅÀºÀ¹±¹²ª¤œˆ‚tfcTPQAEI8=F38E18G45F35F44E36D58D6;E:?G<@H=<6(L0–=/Œ=.†>/‚?/€>.=-<-ƒ;,„;,‡;-‚:,‚:,‚:,‚:,9+9-9-~8,~:/~:/~:/~:/}:1}:1}:1}:1z:1z:1y90y90x8/v7.v7.v7.u9/u9/u9/s9.s9.s9.r8-r8-q6.q6.p5-o4,n3+m4+l3*l3*h2(l6,i3)f2'h4)e1&i5*xD9’KE’MF“PJTLVO‡XNYO|\Os\Nk[L_XFUTBPS@JQ?@I64@,3<+2;*09(09(2;*5>-9B1-;@*CL/O^7_rDi„Mr’SwŸXy£Wv¢Us–\f‰OZ}CX{A\E]€F]€F^G`ƒI`ƒI`ƒI`ƒI`ƒI_‚H^G]€FVzLJn@Ae7haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTiaVjbWkdZmf^upjˆ…€Ÿžš°°®ÂÂÀÓÒÐâáßéåäçãàãÞÚÞÖÓ×ÏÌÒº°º¤™˜†zym__YIKL:>F19E1>2J91`94ˆHH²\_È_dÍVZÐOSÕMOÚLKÜJJàHEáFBãDAåA?ÞDFÞDFÞDFÝCEÝCEÜBBÛCBÛCBÚDCØD@ÔE?ÓF?ÐF<ÏF<ÐG=ÎH=Ý>8Ú?:ÒB9ÉC:¼C8«A4™<-Œ9)‡>-ƒ>.>-€=,€=,<,ƒ;,…<-‚:,‚:,‚:,9+9-9-~8,}9.~:/~:/~:/}:1}:1}:1}:1}:1y:1y:1x90x90w8/t8.s7-s7-s9.s9.r8-r8-q8-p7,p7,p7,p5-o6-n5,n5,m4+l3*i3)i3)g1'k7,h4)e1&h4)d0%f4)uC8•JE“LH“PJTL‰WNYOx[Mp]Nj^N]WGPQAKN=CJ:9B12:+08)36-17-06,/5+/5)17+2:-4<-9D4;F6=H7*0640641622716929;0:<.:?)?H+KY5]pChƒLs“TwŸYw¡WržQiŒT^IUx@WzB[~F[~F[~F]€H_‚J_‚J_‚J_‚J^I^I]€H]€HUvKJk@@a6haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcToh^ng_lh_tqj…„¡ ž¼¼ºÏÏÏÎÏÑààâòòòúøùû÷öøòòñìéêåâïÍÃàÀµÅ©¥€sbaZGML7CH2AI4AH6BF7BD7C@9D<9C98C772?5;@9@93H/+c76QR³giÇmmÂ[\ÉYWÑUS×QNÝKKåGFèBBê@AÞCGÞDFÞDFÞBEÞBEÝADÜBBÜBBÜDCÙCB×C?ÔC>ÒE>ÐE>ÏF<ÐG=â@;Ý@9Õ@9ÌC9ÀD:°B5›;-‹5&Š=-…=.>-€=,€=,<,ƒ<*„=+‚:,‚:,€:.9-9-~8,}9.}9.~:/~:/}:1}:1}:1}:1}:1{;2w;1w;1v:0u9/t8.s9.r8-q7,r8-q8-p7,p7,n8,m7+m7+m7+o6-o6-n5,m4+j4*j4*i3)h4)f2'k7,h4)c1&e3(b0%e3(uC8”JG“NIQJ‹TM„XOzZMq[Mh\LXUDHK:=D4=E69A208+/7*5=056157257247005.06,08-19,6A3:E5=J9>K9;J77F12A,0?*.42.420511605818:/:<.:?+WzB[~FY|DY|D\G_‚J_‚J^I^I^I]€H]€H]€HSsJHh?>^5icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUmdUmdUmdUfc\gd]vsn“’ޝ¯­ÄÆÅÚÛÝìíïóôöö÷ùüüþÿÿÿÿþÿÿûúüööùôñÿÞÏöÖÇãÈ·É´Ÿ­ž‡ŠƒicbFGG-EG/DF0GD3IC5H;3F42G34M797@;;@:@;8G85cGF‘kjŔ譩ҋ‡ÇtnÀ]XÆSNÖNNâIKëEIðCGÜFHáHKÜCFÕ:>Ø>@âFIàDGÖ:;Ú@@Ú@@ÙA@ÖB>ÔC>ÑB<ÏB;ÏB;ãA<Ý@9Ô?8ËA7¾B8°@4;.8*‹>.†>/‚?.>-€=,<+=*=*9-9-9-~8,~8,|8-|8-|8-}9.|90|90|90z:1z:1z:1z:1x=5w<4v;3u:2t91r7/p7.p7.o6-m7-m7-m7-m7-l8-l8-l8-i2+m6/p92o81k4-g2*g2*h3+e0(i7.d2)^,#`0&_/%b2(p@6’LJOKŠQJ‚QJ}YMv_QfYIRO>CF5=F58C35@02=/3;04:04:077577566446135016/05..6+.9+2=/6C29H5:I68G42D./A+,20,2.-2..3-36/780:&DR1YkCh‚Ru”[wž_r›Wj•N\}HXyDTu@Tu@WxCZ{F[|GZ{F^JbƒNbƒN^J\}H_€K`L^JTrNFd@:X4icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUmdUmdUmdUed_onj…†¤¤¢ÁÃÂÖÚÛêîï÷ûþ÷ûþøüÿüýÿþþþÿþÿÿýüÿüùÿûøÿïÚüêÒîÞÅØÍ±À»¤£„‚ƒcgkJMP1II/EC,HA/J>2L93M85Q99;;9BA?MHE\RQyjg¢‹Ì³®åÇ¿ÿÙÏ괪̃|Àc\ÌVTÛPSãFMâ=DÕEEÕEEÙGHÞIKÛEGÖ<>Ö<>Ü@CÚ>?Ù??Ú@@ÙA@ÖB>ÓB=ÒA<ÐA;ß@:Û@;Ô?8ÌA:¿C9±A6 ;/‘9+Œ=.‡>/ƒ>.>-€=,<+€=,<,9-9-9-~8,}9.|8-|8-|8-|90|90|90z:1z:1{;2{;2{;2v=4u<3t;2s:1r90p7.m7-m7-m7-l8-l8-l8-l8-j8-j8-j8-l5.n70n91n91l7/i4,g2*e3*c1(e3*_/%^.$b2(^.$`0&n?5„IEˆQLˆWRWOrVKdRDQJ:>?/:A16A14A02>02<14<15;17:388677577557446116005./7,.8-1<.4A07E49H58G44E22D.062.40.3--2,14-45-8:-9=,7?'DQ3YkEh‚Sv”`wbp˜YfNZzHWwETtBTtBVvDYyGYyGYyG[{I_M_M\|J[{I^~L^~L\|JTmOF_A9R4icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUneVneVneVddby{x—™˜²¶µÍÑÒäéìôùüúÿÿûÿÿûÿÿûÿÿýÿþþþüÿÿûÿÿúÿÿúÿüßúùÛïðÐáåÄÒØ´¼Äž©‡’j`hCRW7DG,EC.KD4MC9N?8L=8C:;SJKi`a€xv›“¼µ¯×ÐÈçÝÓúêÝÿôéÿåÛ画Äec¸ACËBIáNVÚVRÒLIËDAÎBAÔFE×EFÙCDÛBD×=?Ø>>Ù??Ø@?×A@ÕA=ÓB=ÒA<Ü?:Ù@:ÔA:ÍD<ÀD<²B7¡<2“9.Œ=0‡=0ƒ>/>.€=-<+€=,€=,9-9-9-}9.}9.|8-|8-{8/}:1}:1{;2{;2{;2{;2{;2{;2t;2s:1p:0o9/n8.m7-k7,k7,l8-l8-j8-j8-j8-j8-i9-i9-n91m80m80m80m80i7.f4+c1(c3)a1']-#_0&c4*\-#_0&sD:OK‚UPXQqSK^J?OC7?<-37(2:+/<+0<.2=/4<15;17:37:388688668557257227016/08-.8-0;-2?.6C27E48G48G48G46=53:2/4-,1*.1(13(57*6:)6>'DQ5[lHk„Zy–fwœfl”X^‡KWwEUuCRr@Rr@TtBVvDWwEWwEXxF[{I]}K[{I[{I]}K\|JXxFPfOAW@3I2icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUneVneVneVneVofWgklƒ‡ˆ£§¨¹¾ÁÐÕØåíðóûþõýÿùÿÿûÿÿüÿÿüþûýþùþýøÿþ÷ÿÿöóÿâñÿÞëùÖäòÎÛêÃÌÛ²³Â™ ¬„}‰cdnKLS4EI0HJ5KI:GE9D@7QEEk__‹€¤š™µ°­ÊÇÂÜÜÔççÝ÷óèÿýñÿøíÿÝÕú·±èŽŽÌbd±>CÃPIÉTMÉOJÃF@ÊFBÔMJØJIÑ??Ò>>Ô>?Õ?>Ö@?ÕA?ÓB?ÓB?ÒC?×>8×?:ÒC=ÌE?ÀE>±B9¢=5•;2Œ<1‡=0ƒ=1=0=-~<,€=-€=-~:/~:/~:/}9.}9.|8-{8/{8/~;2|<3|<3{;2{;2z;4z;4z;4p:0o9/o9/m9.l8-k7,j6+h6+i7,i7,h8,h8,h8,h8,h8,h8,o:4j81h6/i70j81j81e4-a0)e4-b1*].&a2*b3+Y*"_3*zNE~]XvWRiNGWC:J<3@:.:;-8<.08)/:,1<.2=/5=25;169078079468368349338138119.19..9+/:,1<.2?.5B18E4:I6;J7;C87?428.-3)-0%/1&24'48)4<'ER8_pPr‹d}šnwœifXT}EUrBTqASp@Sp@TqAUrBVsCVsCWtD[xH]zJ\yI^{K_|L\yIVsCK\JD8f\Z†|z«¡ŸÁ·µËÃÁÕÐÍãâÞîïé÷øðùöíüòèÿóéÿóíÿäß즤´if«K=³QDÁYNÇ[QÆQH¿D=ÂA<ËD@Ë@=Ï?>Ð@?ÑB>ÒC?ÒC?ÑC?ÑC?Ö>9Ô@<ÒD@ÉE@½D<¯@9 >5•<4Œ<3‡=2ƒ=1=0=/~<.=/€Qn>Qn>Qn>Qn>Qn>Sp@Sp@WtD[xH]zJ]zJ_|L_|LZwGQn>ESF6D7(6)gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUneVneVofWpgXpgXpgXinrz‚…“š «´¹ÄÍÒÜåêì÷ùôþÿôþýöÿüúÿúûÿ÷ûþóøúìõöæòóãòþêôýèôüåóøáòöÛëëÏØ×¹ÅÄ¥±°’ŽregOMP;EL:EM>EODGSG~zqŸ›’ƽ¸ÙÎÌáÓÒçÛÛôêéü÷ôðïëûüöÿÿöÿþôÿúñÿôêÿçÞÿÚÒß‘}·fS¢K:²UF½WKµF;·@8ÈKEÇC>ÊC?ÌB?ÎC@ÎC>ÍD>ÍD>ÌC=Ô@<ÒC=ÎE?ÅD?¸A;ª=8ž;5•<4Œ<3‡=4ƒ=3=2=1~<0=1=/~:/~:/~:/}9.|90{8/{8/{8/|<3{;2{;2y:3y:3x92w81w81m80l7/j8/j8/i7.i7.g7-g7-g7-g7-f7-f7-f7-f7-f7-d8-i70h6/g5.f5.g6/h70g6/e6.a2*e6.^2)\0'`4+a5,i=4|PGQJBE>6:6-85,99/8:/47,36+4:.5;/5;/69.69.68-57,46+19,19,19,19,19,19,19,19,08+.9+.9+/:*0;+3>.6A17B2gw]umv‘nf‰_RwKAh;Mj:Nk;Pm=Pm=Nk;Nk;OlVsCZwG]zJ^{K_|L_|LVsCLi9=H@/:2#.&gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUneVneVofWpgXqhYqhYcjpmtz„’£¬±¾ÉÍÓÞâåðòðüüòüûõþùøÿ÷úÿôüÿòúýìøùçöøãööìù÷ëúöêýöæÿôâøëØçØÁÖÆ¯À±šŸ“}vn[ZWFOQCQWKYcZbme–˜‹²²¦ÕÎÆêÜÙõããüéëÿñôÿ÷ùÿýýýþùøûôõûñúýòÿÿóÿÿóÿÿñÿãÊ¹q[¨WD¬SCµQB¹MA¿JAÂG@ÆE?ÉE@ÊE@ÊE>ÉD=ÈC<ÈC<ÒC?ÒD@ÌEAÂC=³=9¦;5œ;5•<6Œ<5‡<6ƒ=5=4<3~<0=1€<1~:/~:/~:/}9.|90{8/{8/y90{;2{;2z:1x92w81v70v70u6/k90j8/j8/j8/j8/h8.h8.h8.g7-f7-f7-f7-d8-d8-d8-d8-h6/h70i81i81h70i81j;3l=5g80k<4b6-a5,oC:xLCtI@uJA:=647036/7:18;247.14+25,58-58-57,46+46+46+46+46)/7(08)08)08)08)08)08+08+19,08+08+/7*08+19,3;.4e9Jg9Li;Nk=Nk=Li;Li;Mj
      UrDYvH[xJ]zL^{M\yKQn@Eb47@;+4/!*%gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUneVofWpgXpgXqhYriZhowmt|‚‹’¥®µÂÍÑÔßãäïñòþþóýüôÿùöÿ÷úÿôüÿñýÿíýÿêýÿêÿöñÿøóÿ÷ïÿ÷íÿöëÿïáöÜÍäʹƯ§”ƒ€sce]P[YM_bYovo|…€¦­¾À³ÚÖÍñãàÿìíÿñôÿñ÷ÿñ÷ÿ÷ûûúøøÿøøÿúôÿõîÿïòÿï÷ÿóÿñÖÿðÖÿȰÅ}g¢O=®Q@¸RD³C8ÀIAÄH@ÇF@ÇF@ÈE=ÇD<ÆC;ÆC;ÓD@ÐE@ÊE@¾A=±;7£74š93•<6Œ<5‡<6ƒ=5=4<3~;2<3=1~:/~:/~:/}9.|90{8/{8/y90z:1z:1y90w81v70u6/u6/t5.k90k90j8/j8/j8/i9/i9/h8.f7-f7-f7-d8-d8-d8-d8-d8-f5.i81l;4k:3j92j92m>6qB:n?7pD;g;2g;2SJŒaXTKpE<6=52913:27<5492/5+25,9<345-35*24)13(13(35(46)57*,7',7'-8(-8(-8(-8(-8(/7(19*08)08+/7*/7*/7*08+08+7@+9B-=D2=D2=A29;-35'/3$3:*JVBcr[f}a\wVLnICgA=c:He7Kh:Nk=Nk=Kh:Jg9Li;Nk=TqCWtFZwI[xJ]zLZwINk=A^05;9*0.!'%heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheTheVhdYkd\kd\md]meZmfVg`MjeOnlWnl]ff^eeeqqy‡‘“–ž¡«³¶ÃÈËÙÝàìíï÷÷÷ûùúþýûÿþúÿÿûýþøûüöùüóúýôùÿõùúõùúôøúïúûëûýèöùÞäçÈÒÖµ¶¼š”›ymvW\fK`lTq~lƒ‘€žŽ··µËËÉââàïïíôôòøøöúúøùù÷þþüþþüþþüþþüþþüþþüþþüþþüæÿÿðÿÿûÿÿýïîЪ§ a\™D=¸MEÄKBÈC:ÊA7ÎD:ÑH>ÏJAÉI>ÆG>ÁJ2¿K4¹L5¯K4 H2”F2ŒE3‡E5‚D5C6€@4‚>3…;2‡9/Š7/6-~:1~:1}90|8/{7.z7.y6-x5,w7-w7-x8.x8.v8-u7,s5*q3(h91h91h91g80h70g6/g6/g6/f5.h6/i70j81i70h6/f4-g2,k1-k4/n70m80k9.j:.i>.iB1dC2gJ8aJ8raOyn\ƒ|j…‚qOL;4:04:04:039/39/39/28.28.17-17-17-06,06,/5+/5+/5+/4./4./4./4./4./4./4./4.05//4./4..3-.3-/4./4.05/0;32=55A77C98D86B64@22?.3@.DQ=WeN\jSSaHHV=DR8FT:Ic>Ke@Ke@Ke>JeOjAUpGYtK\vO]wR]wTWpPHaC8Q3).2&+/$)-heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheTheVhdYkd\kd\md]meZmfVjcPlgQmkVlj[gg_lll~~†’ž§±³¹ÁÄÏ×Úâçêðô÷ûüþÿÿÿÿþÿþýûÿþúÿÿûþÿùûüôøûòøûò÷ýóøùóøùñøúíøùéùûåòõÚáâÃÌЯ´¸—‘–vkrSYaI_kUtoŒ˜Š›©œÀÀ¾ÓÓÑççåóóñ÷÷õûûùüüúûûùþþüþþüþþüþþüþþüþþüþþüþþüîÿÿôÿÿüÿÿÿüúÿíêñ¿¸Ã}u¢J@³K@»J<ÅK>ÈJ>ÄD9½=2¿?6ÃD;ÂH3ÃJ7½M9³J7¦G5™C4D6‹F7ƒC7C8A7>5‚<4„:1†91‡81}:2}:2|91z:1y90x8/w7.v7.u6-v7.t8.t8.t8.r6,p4*o3)i81i81i81h70h70h70g6/g6/e3,e3,g5.h6/j81j81j81k92k60l71m80l:1k;/l>1j@0iD2hG6kP=gR?ufSvd‹†s†ƒrML:4:039/39/39/28.28.28.17-17-17-17-06,06,/5+/5+/5+/4./4./4./4./4./4./4./4.05//4..3-.3-.3-.3-/4.05/-80/:21=34@66B66B66B45B16C1CPAO6BP7FT:Ic@Jd?Ke@Ke>Ic3L/).2',0$)-heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheTheVhdYkd\kd\md]meZmfVmhTmhRmkVjk[jkcvxw‘‘™¨ª¶¾ÈÊÓÛÞêòõ÷üÿüÿÿþÿÿÿÿÿÿþÿþýûÿþúÿÿúýþøúûóõøïóöëñ÷ëô÷îöøíöøêö÷åõ÷áîîÔÛÛ¿ÉÊ«°±’“–yuy^kpZt{iˆ§œ¬¶­ÎÎÌÞÞÜïïíøøöûûùþþüþþüýýûþþüþþüþþüþþüþþüþþüþþüþþü÷ÿÿùÿÿþÿÿÿüúÿúôÿöíÿÑÄÙž•L=§Q@¬K;ª>1¸G9ÑXMÐTJ¾?6ÆD6ÇH9ÄJ=¹I=ªB7?5•A7’E=‡A9„A9@:>8~>5<4<4€;4x<2x<2w;1w;1v:0u9/t:/t:/s9.r9.r9.r9.q8-n8,l6*k5)j81j81j81j81i70i70i70h6/g5.g5.g5.g6/h70i81k:3k:3l;4k:3i:0j;1k?2lB4iD2fE2fI7lVAjYEviV†l‘Ž{€mEF439/28.28.28.17-17-17-06,17-17-17-06,06,/5+/5+/5+/4./4./4./4./4./4./4./4./4./4..3--2,-2,.3-/4./4.*5-+6.-9//;12>24@46B47D38E3?L:ER>CQ:;I28F->L3ES:H`>Jb@LdBKc?Ia=G`9F_8G`9RkDXpL]uS^vVZqTPgK=T8,C)).2',0%*.heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheTheVjcYkd\kd\md]meZmfVniUljSlkVlm]pqi€‚ž¡¨º¼ÈÃÍÏÜäçóûþûÿÿúþÿüýÿýýýüûùÿþüÿÿûÿþùûüôõöîîñæëîãçíáíñãðôåñôãòôßðòÜêêÐÙØ¼ÈÇ«²±•¡¡‡‘“}‘’€œžª­¢¶»´ÀÅ¿ÜÜÚééçööôûûùýýûÿÿýÿÿýýýûþþüþþüþþüþþüþþüþþüþþüþþüüúÿÿþÿÿþÿöòïûôîÿýóÿûíÿõäêı·ƒn”Q>¡P=¸XH¸L?¸D7ÀG<Ç>4ÉD;ÈH?¿F>°?9¢;6š=8–A>?;‡@<@<}@;z?9y@9x?8v?8v=4v=4v=4u<3s=3r<2r<2q;1o;0o;0o;0l:/k9.j8-j8-i7,n72n72m61l71l71k60i70i70l:3j92h70g6/f7/f7/h91h91j?6f>4e=1f>2hC3iE5gF3cG2cJ6hV@k\GskV‡‚nŽzor_9>*28.28.17-17-17-06,06,06,17-17-17-06,06,/5+/5+/5+.3-.3-.3-.3-.3-.3-.3-.3-.3-.3--2,-2,-2,-2,.3-.3-)4,)4,*6,+7-.:01=14@25A36C2:G5Æ=7ÈA;ÈD?ÀC?´<;©98 9:›==‘==Š>>„@?|A=xA6s>6s>6r=5p>5p>5p>5n>4n>4m=3l<2j;1j;1i:0i:0i:0p62p62p62o51m61m61k60i70l;4k:3h91e90e90e90e:1f;2dB6cA5cC4dD5fG5eH6cH3_I2^L6eV?jbKrmW„ƒn„‡r[`L3;&28.28.17-17-17-06,06,06,17-17-17-06,06,/5+/5+/5+.3-.3-.3-.3-.3-.3-.3-.3--2,-2,,1+,1+,1+,1+-2,-2,,6.+5-*4,*4++5,.8-0:/2=/2=-5@06A05A-1=)1=)5A+9E/=O5AS9FY=I\@J]?J]=K^>L_?TgG\oQcvZbtZYkSK]G6G4$5"&+.$),"'*heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheTheVjcYkd\lc\md]meZlfVlgSljSlnXorasvm…„Ÿ¤ª¸¿ÉÖßäîöùùÿÿûÿÿùýÿþÿÿÿÿÿþýûÿÿûÿÿúüüôóõêëíâãçÙßãÕÜãÓäéÒçìÕéíÖêìÔëëÓèæÏßÚÄÔθÔÍºÍÆ¶ËøÐÉÁÙÒÌàÛØëååòîïòòðùù÷ýýûýýûýýûÿÿýþþüüüúþþüþþüþþüþþüþþüþþüþþüþþüÿøüÿöùÿýýþÿý÷ÿýïÿøëÿõòÿøëúçÿÿíÿïÛ̧”£lX£ZG­VCªM;ÁA8ÃB<ÃD>¿D?·?>­;;£99œ:;–<<Ž>?…?=}@=wB7o>7n?7o@8n?7m>6i=4h<3h<3h<3i=4r73q62q62p62o51m61l71j81h70g80e90e:1d<2f>4f@5gA6]C4aG8cL:dM;cM8`K6]K3]M4]Q9`Y?miPss[€„mt|eFO:2>(39/28.28.28.17-17-17-06,17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,-2,,1++0*+0*+0*+0*,1+-2,,6.,6.*4,*4+*4++5*-7,.9+-8*0;+4?/5@/4?.3>-3?+4@,7F/;J3@P6DT:GWºH=ºH>ºG@·F@°C@¦=:97—<;‘=;ˆ>;€A5i=4j>5j>5k?6s63r73q62p62n72l71j81i81d8/d90c;1d>3d@4cA5cA5bB5VG4^OmmSsw^z‚jcmU2>(5C,4:039/39/39/28.28.28.17-17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1+,1++0**/)*/)+0*,1+,1++5-+5-*4,*4,+5,+5,,6+-7,,7)/:,2=/6A17B27B25@/4?.2?+5B.:G3>L5AO6ES:JX?M[BTbI]kTcqZ_lXUbPERA2>0#/#(..&,,$**heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdTjdVjcYkd\lc\md]lfZlfVomXmmUimVgkZembr{xŽ—œ¨±ºÊÓØäëñöþÿ÷üÿøüÿþÿÿÿÿÿúù÷ÿÿúýýõøøîðòåéëÝåéÚåéØåìÚæíÎèïÐéîÐæéÎèæÏèãÏáÚÈÙÏÃÚÍÄßÒÌìÞÛúììÿôöÿõùÿõûÿøþýýûÿÿýÿÿýþþüþþüÿÿýÿÿýýýûþþüþþüþþüþþüþþüþþüþþüþþüÿüúÿýúÿûøùýüøÿÿôÿÿðÿÿêþüðÿûùÿûÿÿôÿöæÿôßÿãÍ×­”¢sY°SA®Q?®N>°O?±OB¯J@¥C:š<4—<7‘>8‰?6ƒ@7{B7tD6qE8nG8s>:s>:s>:q>:q>:q>:q>:p?:sB=rA8l=7l=7m>8n?9r73r73q73n72m82j81i81f:1f;2d>3d@4bB5`C5]A3\@2[?1QI4[S>f^Gg_H`Y?ZS9ZS7\W:ZV;WW;knSrx^u}eUaI%37E.4:04:04:039/39/39/28.28.17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1++0*+0**/)*/)+0*+0*,1+)3+)3+*4,+5-+5,,6--7.-7,,6+.8-2=/6A39D69D67B46A1/<*2?-5B09F2:u@:s@9o>9o>9n72n72n93m;4l;4j;3g<3d<2c?3^>1dG9cG9T=-O8(M8'D/TR;PN7KI0MK2]Y>ieJeaDVU7XX<]`CosXz€fcmT=I1,:#1?(5;15;14:04:04:039/39/39/39/39/39/28.17-17-17-06,16016005/05//4./4./4./4.,1+,1+,1+,1+,1+,1++0*+0*.5.-4--4-,3,-4--4-.5-.5-+2*-4,08-5=29A6=E:?G7B25@03>-1<+2>*9E/BN8IU?O[EVbN]hWYdTLWIF5F4‰D4…D2}B0yB.s@-o?+v?:t=8u>9v?:t?9q<6r=7sA:q?8q?8q?8o>7o>7n=6n=6n=6l;4m<5m>6k?6j?6h@6eA5cA5dG9[A2^G7\I8N=+F7$G8%A4!IM4GK2DG,BE*MM1[[?abC`aBYY=dgJsw\sy_X`H8D,/;%6D-7=36<26<26<25;15;15;15;15;15;15;14:04:039/39/39/27127127116016016005/05/.3-.3--2,-2,,1+,1++0*+0**1**1*)0))0))0)*1*+2+,3,.5--4,.5-07/4;39@8?F>BIA:G69F56C13@.2?+5B.;I2?M6KXDR_KXeSVcRKWI8p;5q<6vA;sA:p>7r@9xG@n=6n=6n=6m>6l=5l=5l=5l=5g?5h@6gA6gC7eC7cC6`C5^D5aL;UB1ZI7`S@RG3C;&E=(GA+>G,BH.@F*<@%?B%LO2_`AijKaaEnqTvz_gmSHP84<%4=(=F18>48>48>48>47=37=37=36<28>48>47=37=37=36<26<26<25:449349349338238238227105/05//4..3--2,,1++0*+0*(/((/((/((/((/()0)*1*+2+070.5.+2++2+.5.5<5K:4-9/-3/-3/,2.gdUgdUheVheVheVheVifWifWifWifWifWifWifWifWifWifWleUldWlcZmd]md]mf^mg[khWmlWimThpXht`hthm|wˆ—𥴻ÀÉÐÔÛáéðööûÿúþÿýþÿÿÿýÿþúþþöýýñúûí÷úéô÷âîóÝçìÕàèÐÜà¿×Ú»ÖÖ¼Ù×ÂÝ×ÉßÖÍåÛÙìàâøìðüïöÿõûÿùþÿúýÿûûÿûûÿýúþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüöÿþ÷ÿþúÿþþþÿÿüÿÿùÿÿøÿÿ÷þÿøÿÿøüÿùùÿýúÿÿøþÿøúÿõöÿóÿþìÿýéÿòßÿñÛÿðÚñÒ½³zyS3i?3i?3i?3f>2f>2f>2f>2aA4`C5`C5_C5^D5[D4ZE4VE3XI6OB/\T?oiSc^HMK4IG0LJ3;E*?H->G*48>47=37=37=39?58>48>48>48>48>48>48>47<67<67<66;56;56;55:45:438238216005//4.-2,,1+,1++0,+0,*/+*/++0,,1--2.-2.051.3/+0,+0,-2.2738=9'4.:0.5..5.-4-gdUgdUgdUheVheVifWifWifWifWifWifWifWifWifWifWifWleUldWlcZmd]md]mf^mg[khWkmWjnUiqYgs_drejyt…”—¡²¹¾ÇÎÓÚâèïõôùýùýÿýþÿÿÿýÿÿúÿÿøÿÿóþÿñûþë÷úåðõÞèîÔàéÎÛܽÕÕ¹ÑÑ·ÔѾÚÔÈáØÓêàßôéíþóùÿöþÿûÿÿýÿÿþÿÿþúÿþúþÿùþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüøÿÿøÿÿûÿÿþþþÿýþÿûüÿûúÿúúÿùùÿù÷ÿù÷ÿüùÿÿûþÿûûÿüùÿûùôîÿÿöÿþôÿýóÿüîÿ÷çùçÓéӾϴŸ¶š„•u`yVBlI5mH6rM;uP>mF7iB3gB2jE5nI9oJ:pK;oK;eA1eA1cB1cB1cB1cB1cB1bC1\G6\G6\G6ZG6YH6WH5TG4RG3PH3MH2fdM~~fprZVX@IM4HL3;E*A.;>+9?59?59?58>48>47=37=37=38>48>48>48>48>48>48>48>49>89>89>88=78=78=77<67<66;55:449338227105//4./4.-2.-2.,1-+0,+0,,1--2.-2.,1-,1-,1-,1-.21043376598:H7=L9@O<@O:8F91?2,9/.5.-4-,3,fcTfcTgdUheVheVifWjgXjgXifWifWifWifWifWifWifWifWleUldWlcZmd]md]mf^mg[khWkmWioUiqYgs_bpcgxr‚”– ³¹ÁÊÑÕÜäéðöõúþùýÿýÿþÿÿýÿÿúÿÿöÿÿôÿÿñÿÿïúýèò÷àéïÕàéÎÙÚ»ÑѵÍË´Î˺ÖÏÅßÕÓìâãøíóÿöþÿùÿÿüÿÿýÿÿÿýþÿúýÿ÷þÿøþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüýýÿýþÿýþÿýÿþþþüþÿùþÿ÷ÿÿõýýóýýõþýøþýùÿþüÿýÿÿýÿÿþÿþùÿÿüÿÿúþúöõýøôÿþöÿþñÿþïÿûéÿóàöåÓåÓ¿Ò»©¹ŸŸƒuŽrd|]I}^JrVAaE0W;&Y=(Z?*X=(`E0`E0_F0_F0`G1`G1^H1^H1[L9ZM:ZM:XM9XM9UM8RL6QL6NL5QQ9ikS|€glrXSY?DM2>G,:G+48>48>48>47=37=38>48>48>48>49?59?5:?9:?9:?9:?99>89>89>88=78=78=77<66;55:4493382382/40.3/-2.,1-+0,+0,+0,+0,+/.,0/-10.21/32/32/32.210A.5F3;M7>P:=O7:L47I/6H.3E-6H0:L6MJ9EB1;A7;A7;A7;A7:@6:@6:@69?58>48>48>49?59?5:@6:@6:@6;@:;@:;@::?9:?99>89>89>8:?9:?99>89>88=78=77<67<6495273162/40-2.,1-+0,+/.,0/,0/-10.21.21.23-12,01):'/@-6H2;M5=O7?I.9F*?L0=J.AN2DN3HQ4LR6IN0JM0ZY;miLhdIc]C_YA_ZD`[GZUBQN=LI8=C9=C9=C989>89>8;@:;@:;@:;@::?9:?9:?9:?99>:8=95:6384162/40.3/.21.21.21-10-12,01,01-12-12$5"*<&3E/9K3XW9UT6SR3KE/JD.FA-D?,A>/@>1??3>@5<=5;>59?59A67B48C57C57D3:B79A69A68@58@59A69A6:B7:B7:B79A6:B7;C8F;7B:7C97A66A16?.4<-39-270.5./51-7/-9+-<%.B3J7O7Z 8Y$8W+:U2:R8;P==O?>O=:L6@R8EX:EZ;DY:>U93J0(>'.5-,3++2*ZgM[hN\hP_iQakSckTglXhkXghVihVifWifWkeWmeXmeZnf[khWkhYkg[kg^jf]jf]hfZgeVgjWglVfoZerajwnzЉ𫲷ÉÓÑØÞáéìò÷úøþþùþúúÿøûþóúüï÷úé÷øæõôâíìØéæÓåâÏÜ×ÄÑ̹˾­Á´¤º¬Ÿ¼¯§Á¶²ÌÀÀÛÐÖèÞæûóþý÷ÿþûÿÿþÿþýÿüýÿüýÿüýÿþþþþþþþþþþþþþþþþþþÿþüÿþüÿþüÿýúÿýúÿüùÿüùÿýùÿýùÿþúÿþýÿýüÿüûÿýþÿþÿÿþÿÿýþýûüÿþÿÿýýÿüùÿøóøíçòåÝöèßÿïçÿûÿÿýÿÿýþÿÿýÿÿûýÿüýÿþüýÿýþÿþýÿÿýÿÿýþÿý÷ÿþîÿÿæÿÿâ÷÷ßýûââàÇ‹‡lRM0TM0QK+SJ+WN/UO/UN1TO1SO2QP4QP4PP6QM2PO3PN5PP6MO7KO6HM6EM5HQ6EN3BK.AH)BI(GM+JP,KQ-NR/PT1VZ9^aBaaE[[?VVVV>XV=YW>XW;XW9WV8VU7QK5OI3LG3ID1DA2B@3??3>@5<=5;>59?59A67B48C57C57D3:B79A69A68@58@59A69A6:B7:B7:B7:B7:B7;C8F;76<83=51=/3B+9M*BY-Ia1Nq7Mn9Ji=Fa>AY?:L<:K9=O9DV5:@69A67B47B47C57D3:B7:B79A69A69A69A6:B7:B7:B7:B7:B7:B7;C8F;>F;>IA>J@?I>>I9?H7>F7>D8=B;>E>;A=6@85A39H1BV3Pg;ZrB]€F\}HVuIMhEBZ@9N;5G74E3XR6F;?G<>H=>I9?H7>F7>D8=B;=D=;A=6@85A39H1DX5Ri=]uEY|BXyDRqEIdA,6H2@R8L_AQfGShIMdH@W=4J329107/-4,YgMZhN\hP^jRblTemVgoZjo[lo\lm[mk\mj[nhZnhZoi]ph]liXkhYjfZie\ie\ie\ig[igXfiVchRajUerao|s{‹ŠŽŸ¦Ÿ±»ÂËÒÕÜäéðöòúüôúøñöðíðçéëÞáãÕÚÛËÒÑ¿ÌɶÉıþ«¾¹¦»´¢Ë¾®ÓŸÝÏÄæÙÑíâà÷ëíÿôúÿøÿÿ÷ÿÿúÿÿüÿþýÿýüÿûüþüþýþÿÿþþþþþþþþþþþþþþþþþþÿþüÿþüþýûÿüùÿýúÿýúÿýúÿû÷ÿúöþùõÿýüÿûúýùøüúûþüýÿýþÿþÿÿýþÿüýÿüüÿüùÿøó÷ìæòåÝøêáÿóëÿûÿÿýÿÿýþÿÿûÿÿûýÿúýÿüüýÿüýÿþýÿÿþÿÿþýÿþõÿüìÿüãÿúÝþýèÿÿëåãÌŒˆoRL2UN2TM0WN1VM.UO/WP3VQ3UQ4QP2ON2MM1PL1NM1NL3MM3LN6LP7KP9JR:LU:IR7JS6QX9SZ9U[9]c?gmI€”a’¦sŸ±š«’¡xˆ”pr|Z\bFLP7KM7LK6KI4NI5PK7TM:VP:WQ;VP:SN:QL9LI:IG:EE9CE:=>6F;?G<=G<=H8>G6=E6=C7=B;:A:9?;5?75A39H1BV3Ne9Wo?Sv /* to declare isdigit() */ + + +#if TRANSFORMS_SUPPORTED + +/* + * Lossless image transformation routines. These routines work on DCT + * coefficient arrays and thus do not require any lossy decompression + * or recompression of the image. + * Thanks to Guido Vollbeding for the initial design and code of this feature, + * and to Ben Jackson for introducing the cropping feature. + * + * Horizontal flipping is done in-place, using a single top-to-bottom + * pass through the virtual source array. It will thus be much the + * fastest option for images larger than main memory. + * + * The other routines require a set of destination virtual arrays, so they + * need twice as much memory as jpegtran normally does. The destination + * arrays are always written in normal scan order (top to bottom) because + * the virtual array manager expects this. The source arrays will be scanned + * in the corresponding order, which means multiple passes through the source + * arrays for most of the transforms. That could result in much thrashing + * if the image is larger than main memory. + * + * If cropping or trimming is involved, the destination arrays may be smaller + * than the source arrays. Note it is not possible to do horizontal flip + * in-place when a nonzero Y crop offset is specified, since we'd have to move + * data from one block row to another but the virtual array manager doesn't + * guarantee we can touch more than one row at a time. So in that case, + * we have to use a separate destination array. + * + * Some notes about the operating environment of the individual transform + * routines: + * 1. Both the source and destination virtual arrays are allocated from the + * source JPEG object, and therefore should be manipulated by calling the + * source's memory manager. + * 2. The destination's component count should be used. It may be smaller + * than the source's when forcing to grayscale. + * 3. Likewise the destination's sampling factors should be used. When + * forcing to grayscale the destination's sampling factors will be all 1, + * and we may as well take that as the effective iMCU size. + * 4. When "trim" is in effect, the destination's dimensions will be the + * trimmed values but the source's will be untrimmed. + * 5. When "crop" is in effect, the destination's dimensions will be the + * cropped values but the source's will be uncropped. Each transform + * routine is responsible for picking up source data starting at the + * correct X and Y offset for the crop region. (The X and Y offsets + * passed to the transform routines are measured in iMCU blocks of the + * destination.) + * 6. All the routines assume that the source and destination buffers are + * padded out to a full iMCU boundary. This is true, although for the + * source buffer it is an undocumented property of jdcoefct.c. + */ + + +/* Drop code may be used with or without virtual memory adaptation code. + * This code has some dependencies on internal library behavior, so you + * may choose to disable it. For example, it doesn't make a difference + * if you only use jmemnobs anyway. + */ +#ifndef DROP_REQUEST_FROM_SRC +#define DROP_REQUEST_FROM_SRC 1 /* 0 disables adaptation */ +#endif + + +#if DROP_REQUEST_FROM_SRC +/* Force jpeg_read_coefficients to request + * the virtual coefficient arrays from + * the source decompression object. + */ +METHODDEF(jvirt_barray_ptr) +drop_request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero, + JDIMENSION blocksperrow, JDIMENSION numrows, + JDIMENSION maxaccess) +{ + j_common_ptr srcinfo = (j_common_ptr) cinfo->client_data; + + return (*srcinfo->mem->request_virt_barray) + (srcinfo, pool_id, pre_zero, + blocksperrow, numrows, maxaccess); +} + + +/* Force jpeg_read_coefficients to return + * after requesting and before accessing + * the virtual coefficient arrays. + */ +METHODDEF(int) +drop_consume_input (j_decompress_ptr cinfo) +{ + return JPEG_SUSPENDED; +} + + +METHODDEF(void) +drop_start_input_pass (j_decompress_ptr cinfo) +{ + cinfo->inputctl->consume_input = drop_consume_input; +} + + +LOCAL(void) +drop_request_from_src (j_decompress_ptr dropinfo, j_decompress_ptr srcinfo) +{ + void *save_client_data; + JMETHOD(jvirt_barray_ptr, save_request_virt_barray, + (j_common_ptr cinfo, int pool_id, boolean pre_zero, + JDIMENSION blocksperrow, JDIMENSION numrows, JDIMENSION maxaccess)); + JMETHOD(void, save_start_input_pass, (j_decompress_ptr cinfo)); + + /* Set custom method pointers, save original pointers */ + save_client_data = dropinfo->client_data; + dropinfo->client_data = (void *) srcinfo; + save_request_virt_barray = dropinfo->mem->request_virt_barray; + dropinfo->mem->request_virt_barray = drop_request_virt_barray; + save_start_input_pass = dropinfo->inputctl->start_input_pass; + dropinfo->inputctl->start_input_pass = drop_start_input_pass; + + /* Execute only initialization part. + * Requested coefficient arrays will be realized later by the srcinfo object. + * Next call to the same function will then do the actual data reading. + * NB: since we request the coefficient arrays from another object, + * the inherent realization call is effectively a no-op. + */ + (void) jpeg_read_coefficients(dropinfo); + + /* Reset method pointers */ + dropinfo->client_data = save_client_data; + dropinfo->mem->request_virt_barray = save_request_virt_barray; + dropinfo->inputctl->start_input_pass = save_start_input_pass; + /* Do input initialization for first scan now, + * which also resets the consume_input method. + */ + (*save_start_input_pass)(dropinfo); +} +#endif /* DROP_REQUEST_FROM_SRC */ + + +LOCAL(void) +dequant_comp (j_decompress_ptr cinfo, jpeg_component_info *compptr, + jvirt_barray_ptr coef_array, JQUANT_TBL *qtblptr1) +{ + JDIMENSION blk_x, blk_y; + int offset_y, k; + JQUANT_TBL *qtblptr; + JBLOCKARRAY buffer; + JBLOCKROW block; + JCOEFPTR ptr; + + qtblptr = compptr->quant_table; + for (blk_y = 0; blk_y < compptr->height_in_blocks; + blk_y += compptr->v_samp_factor) { + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef_array, blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + block = buffer[offset_y]; + for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) { + ptr = block[blk_x]; + for (k = 0; k < DCTSIZE2; k++) + if (qtblptr->quantval[k] != qtblptr1->quantval[k]) + ptr[k] *= qtblptr->quantval[k] / qtblptr1->quantval[k]; + } + } + } +} + + +LOCAL(void) +requant_comp (j_decompress_ptr cinfo, jpeg_component_info *compptr, + jvirt_barray_ptr coef_array, JQUANT_TBL *qtblptr1) +{ + JDIMENSION blk_x, blk_y; + int offset_y, k; + JQUANT_TBL *qtblptr; + JBLOCKARRAY buffer; + JBLOCKROW block; + JCOEFPTR ptr; + JCOEF temp, qval; + + qtblptr = compptr->quant_table; + for (blk_y = 0; blk_y < compptr->height_in_blocks; + blk_y += compptr->v_samp_factor) { + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef_array, blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + block = buffer[offset_y]; + for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) { + ptr = block[blk_x]; + for (k = 0; k < DCTSIZE2; k++) { + temp = qtblptr->quantval[k]; + qval = qtblptr1->quantval[k]; + if (temp != qval) { + temp *= ptr[k]; + /* The following quantization code is a copy from jcdctmgr.c */ +#ifdef FAST_DIVIDE +#define DIVIDE_BY(a,b) a /= b +#else +#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 +#endif + if (temp < 0) { + temp = -temp; + temp += qval>>1; /* for rounding */ + DIVIDE_BY(temp, qval); + temp = -temp; + } else { + temp += qval>>1; /* for rounding */ + DIVIDE_BY(temp, qval); + } + ptr[k] = temp; + } + } + } + } + } +} + + +/* Calculate largest common denominator with Euclid's algorithm. + */ +LOCAL(JCOEF) +largest_common_denominator(JCOEF a, JCOEF b) +{ + JCOEF c; + + do { + c = a % b; + a = b; + b = c; + } while (c); + + return a; +} + + +LOCAL(void) +adjust_quant(j_decompress_ptr srcinfo, jvirt_barray_ptr *src_coef_arrays, + j_decompress_ptr dropinfo, jvirt_barray_ptr *drop_coef_arrays, + boolean trim, j_compress_ptr dstinfo) +{ + jpeg_component_info *compptr1, *compptr2; + JQUANT_TBL *qtblptr1, *qtblptr2, *qtblptr3; + int ci, k; + + for (ci = 0; ci < dstinfo->num_components && + ci < dropinfo->num_components; ci++) { + compptr1 = srcinfo->comp_info + ci; + compptr2 = dropinfo->comp_info + ci; + qtblptr1 = compptr1->quant_table; + qtblptr2 = compptr2->quant_table; + for (k = 0; k < DCTSIZE2; k++) { + if (qtblptr1->quantval[k] != qtblptr2->quantval[k]) { + if (trim) + requant_comp(dropinfo, compptr2, drop_coef_arrays[ci], qtblptr1); + else { + qtblptr3 = dstinfo->quant_tbl_ptrs[compptr1->quant_tbl_no]; + for (k = 0; k < DCTSIZE2; k++) + if (qtblptr1->quantval[k] != qtblptr2->quantval[k]) + qtblptr3->quantval[k] = largest_common_denominator + (qtblptr1->quantval[k], qtblptr2->quantval[k]); + dequant_comp(srcinfo, compptr1, src_coef_arrays[ci], qtblptr3); + dequant_comp(dropinfo, compptr2, drop_coef_arrays[ci], qtblptr3); + } + break; + } + } + } +} + + +LOCAL(void) +do_drop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + j_decompress_ptr dropinfo, jvirt_barray_ptr *drop_coef_arrays, + JDIMENSION drop_width, JDIMENSION drop_height) +/* Drop. If the dropinfo component number is smaller than the destination's, + * we fill in the remaining components with zero. This provides the feature + * of dropping grayscale into (arbitrarily sampled) color images. + */ +{ + JDIMENSION comp_width, comp_height; + JDIMENSION blk_y, x_drop_blocks, y_drop_blocks; + int ci, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + jpeg_component_info *compptr; + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = drop_width * compptr->h_samp_factor; + comp_height = drop_height * compptr->v_samp_factor; + x_drop_blocks = x_crop_offset * compptr->h_samp_factor; + y_drop_blocks = y_crop_offset * compptr->v_samp_factor; + for (blk_y = 0; blk_y < comp_height; blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y + y_drop_blocks, + (JDIMENSION) compptr->v_samp_factor, TRUE); + if (ci < dropinfo->num_components) { +#if DROP_REQUEST_FROM_SRC + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, drop_coef_arrays[ci], blk_y, +#else + src_buffer = (*dropinfo->mem->access_virt_barray) + ((j_common_ptr) dropinfo, drop_coef_arrays[ci], blk_y, +#endif + (JDIMENSION) compptr->v_samp_factor, FALSE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + jcopy_block_row(src_buffer[offset_y], + dst_buffer[offset_y] + x_drop_blocks, + comp_width); + } + } else { + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + FMEMZERO(dst_buffer[offset_y] + x_drop_blocks, + comp_width * SIZEOF(JBLOCK)); + } + } + } + } +} + + +LOCAL(void) +do_crop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* Crop. This is only used when no rotate/flip is requested with the crop. */ +{ + JDIMENSION dst_blk_y, x_crop_blocks, y_crop_blocks; + int ci, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + jpeg_component_info *compptr; + + /* We simply have to copy the right amount of data (the destination's + * image size) starting at the given X and Y offsets in the source. + */ + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_y + y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + jcopy_block_row(src_buffer[offset_y] + x_crop_blocks, + dst_buffer[offset_y], + compptr->width_in_blocks); + } + } + } +} + + +LOCAL(void) +do_crop_ext_zero (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* Crop. This is only used when no rotate/flip is requested with the crop. + * Extension: If the destination size is larger than the source, we fill in + * the extra area with zero (neutral gray). Note we also have to zero partial + * iMCUs at the right and bottom edge of the source image area in this case. + */ +{ + JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height; + JDIMENSION dst_blk_y, x_crop_blocks, y_crop_blocks; + int ci, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + jpeg_component_info *compptr; + + MCU_cols = srcinfo->output_width / + (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); + MCU_rows = srcinfo->output_height / + (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + comp_height = MCU_rows * compptr->v_samp_factor; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + if (dstinfo->jpeg_height > srcinfo->output_height) { + if (dst_blk_y < y_crop_blocks || + dst_blk_y >= y_crop_blocks + comp_height) { + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + FMEMZERO(dst_buffer[offset_y], + compptr->width_in_blocks * SIZEOF(JBLOCK)); + } + continue; + } + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_y - y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } else { + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_y + y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + if (dstinfo->jpeg_width > srcinfo->output_width) { + if (x_crop_blocks > 0) { + FMEMZERO(dst_buffer[offset_y], + x_crop_blocks * SIZEOF(JBLOCK)); + } + jcopy_block_row(src_buffer[offset_y], + dst_buffer[offset_y] + x_crop_blocks, + comp_width); + if (compptr->width_in_blocks > x_crop_blocks + comp_width) { + FMEMZERO(dst_buffer[offset_y] + + x_crop_blocks + comp_width, + (compptr->width_in_blocks - + x_crop_blocks - comp_width) * SIZEOF(JBLOCK)); + } + } else { + jcopy_block_row(src_buffer[offset_y] + x_crop_blocks, + dst_buffer[offset_y], + compptr->width_in_blocks); + } + } + } + } +} + + +LOCAL(void) +do_crop_ext_flat (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* Crop. This is only used when no rotate/flip is requested with the crop. + * Extension: The destination width is larger than the source and we fill in + * the extra area with the DC of the adjacent block. Note we also have to + * fill partial iMCUs at the right and bottom edge of the source image area + * in this case. + */ +{ + JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height; + JDIMENSION dst_blk_x, dst_blk_y, x_crop_blocks, y_crop_blocks; + int ci, offset_y; + JCOEF dc; + JBLOCKARRAY src_buffer, dst_buffer; + jpeg_component_info *compptr; + + MCU_cols = srcinfo->output_width / + (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); + MCU_rows = srcinfo->output_height / + (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + comp_height = MCU_rows * compptr->v_samp_factor; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + if (dstinfo->jpeg_height > srcinfo->output_height) { + if (dst_blk_y < y_crop_blocks || + dst_blk_y >= y_crop_blocks + comp_height) { + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + FMEMZERO(dst_buffer[offset_y], + compptr->width_in_blocks * SIZEOF(JBLOCK)); + } + continue; + } + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_y - y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } else { + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_y + y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + if (x_crop_blocks > 0) { + FMEMZERO(dst_buffer[offset_y], + x_crop_blocks * SIZEOF(JBLOCK)); + dc = src_buffer[offset_y][0][0]; + for (dst_blk_x = 0; dst_blk_x < x_crop_blocks; dst_blk_x++) { + dst_buffer[offset_y][dst_blk_x][0] = dc; + } + } + jcopy_block_row(src_buffer[offset_y], + dst_buffer[offset_y] + x_crop_blocks, + comp_width); + if (compptr->width_in_blocks > x_crop_blocks + comp_width) { + FMEMZERO(dst_buffer[offset_y] + + x_crop_blocks + comp_width, + (compptr->width_in_blocks - + x_crop_blocks - comp_width) * SIZEOF(JBLOCK)); + dc = src_buffer[offset_y][comp_width - 1][0]; + for (dst_blk_x = x_crop_blocks + comp_width; + dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { + dst_buffer[offset_y][dst_blk_x][0] = dc; + } + } + } + } + } +} + + +LOCAL(void) +do_crop_ext_reflect (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* Crop. This is only used when no rotate/flip is requested with the crop. + * Extension: The destination width is larger than the source and we fill in + * the extra area with repeated reflections of the source region. Note we + * also have to fill partial iMCUs at the right and bottom edge of the source + * image area in this case. + */ +{ + JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, src_blk_x; + JDIMENSION dst_blk_x, dst_blk_y, x_crop_blocks, y_crop_blocks; + int ci, k, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JBLOCKROW src_row_ptr, dst_row_ptr; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + MCU_cols = srcinfo->output_width / + (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); + MCU_rows = srcinfo->output_height / + (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + comp_height = MCU_rows * compptr->v_samp_factor; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + if (dstinfo->jpeg_height > srcinfo->output_height) { + if (dst_blk_y < y_crop_blocks || + dst_blk_y >= y_crop_blocks + comp_height) { + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + FMEMZERO(dst_buffer[offset_y], + compptr->width_in_blocks * SIZEOF(JBLOCK)); + } + continue; + } + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_y - y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } else { + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_y + y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + /* Copy source region */ + jcopy_block_row(src_buffer[offset_y], + dst_buffer[offset_y] + x_crop_blocks, + comp_width); + if (x_crop_blocks > 0) { + /* Reflect to left */ + dst_row_ptr = dst_buffer[offset_y] + x_crop_blocks; + for (dst_blk_x = x_crop_blocks; dst_blk_x > 0;) { + src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */ + for (src_blk_x = comp_width; src_blk_x > 0 && dst_blk_x > 0; + src_blk_x--, dst_blk_x--) { + dst_ptr = *--dst_row_ptr; /* destination goes left */ + src_ptr = *src_row_ptr++; /* source goes right */ + /* this unrolled loop doesn't need to know which row it's on... */ + for (k = 0; k < DCTSIZE2; k += 2) { + *dst_ptr++ = *src_ptr++; /* copy even column */ + *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ + } + } + } + } + if (compptr->width_in_blocks > x_crop_blocks + comp_width) { + /* Reflect to right */ + dst_row_ptr = dst_buffer[offset_y] + x_crop_blocks + comp_width; + for (dst_blk_x = compptr->width_in_blocks - x_crop_blocks - comp_width; + dst_blk_x > 0;) { + src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */ + for (src_blk_x = comp_width; src_blk_x > 0 && dst_blk_x > 0; + src_blk_x--, dst_blk_x--) { + dst_ptr = *dst_row_ptr++; /* destination goes right */ + src_ptr = *--src_row_ptr; /* source goes left */ + /* this unrolled loop doesn't need to know which row it's on... */ + for (k = 0; k < DCTSIZE2; k += 2) { + *dst_ptr++ = *src_ptr++; /* copy even column */ + *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ + } + } + } + } + } + } + } +} + + +LOCAL(void) +do_wipe (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + JDIMENSION drop_width, JDIMENSION drop_height) +/* Wipe - drop content of specified area, fill with zero (neutral gray) */ +{ + JDIMENSION x_wipe_blocks, wipe_width; + JDIMENSION y_wipe_blocks, wipe_bottom; + int ci, offset_y; + JBLOCKARRAY buffer; + jpeg_component_info *compptr; + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + x_wipe_blocks = x_crop_offset * compptr->h_samp_factor; + wipe_width = drop_width * compptr->h_samp_factor; + y_wipe_blocks = y_crop_offset * compptr->v_samp_factor; + wipe_bottom = drop_height * compptr->v_samp_factor + y_wipe_blocks; + for (; y_wipe_blocks < wipe_bottom; + y_wipe_blocks += compptr->v_samp_factor) { + buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], y_wipe_blocks, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + FMEMZERO(buffer[offset_y] + x_wipe_blocks, + wipe_width * SIZEOF(JBLOCK)); + } + } + } +} + + +LOCAL(void) +do_flatten (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + JDIMENSION drop_width, JDIMENSION drop_height) +/* Flatten - drop content of specified area, similar to wipe, + * but fill with average of adjacent blocks, instead of zero. + */ +{ + JDIMENSION x_wipe_blocks, wipe_width, wipe_right; + JDIMENSION y_wipe_blocks, wipe_bottom, blk_x; + int ci, offset_y, dc_left_value, dc_right_value, average; + JBLOCKARRAY buffer; + jpeg_component_info *compptr; + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + x_wipe_blocks = x_crop_offset * compptr->h_samp_factor; + wipe_width = drop_width * compptr->h_samp_factor; + wipe_right = wipe_width + x_wipe_blocks; + y_wipe_blocks = y_crop_offset * compptr->v_samp_factor; + wipe_bottom = drop_height * compptr->v_samp_factor + y_wipe_blocks; + for (; y_wipe_blocks < wipe_bottom; + y_wipe_blocks += compptr->v_samp_factor) { + buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], y_wipe_blocks, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + FMEMZERO(buffer[offset_y] + x_wipe_blocks, + wipe_width * SIZEOF(JBLOCK)); + if (x_wipe_blocks > 0) { + dc_left_value = buffer[offset_y][x_wipe_blocks - 1][0]; + if (wipe_right < compptr->width_in_blocks) { + dc_right_value = buffer[offset_y][wipe_right][0]; + average = (dc_left_value + dc_right_value) >> 1; + } else { + average = dc_left_value; + } + } else if (wipe_right < compptr->width_in_blocks) { + average = buffer[offset_y][wipe_right][0]; + } else continue; + for (blk_x = x_wipe_blocks; blk_x < wipe_right; blk_x++) { + buffer[offset_y][blk_x][0] = (JCOEF) average; + } + } + } + } +} + + +LOCAL(void) +do_reflect (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + JDIMENSION drop_width, JDIMENSION drop_height) +/* Reflect - drop content of specified area, similar to wipe, but + * fill with repeated reflections of the outside area, instead of zero. + * NB: y_crop_offset is assumed to be zero. + */ +{ + JDIMENSION x_wipe_blocks, wipe_width; + JDIMENSION y_wipe_blocks, wipe_bottom; + JDIMENSION src_blk_x, dst_blk_x; + int ci, k, offset_y; + JBLOCKARRAY buffer; + JBLOCKROW src_row_ptr, dst_row_ptr; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + x_wipe_blocks = x_crop_offset * compptr->h_samp_factor; + wipe_width = drop_width * compptr->h_samp_factor; + wipe_bottom = drop_height * compptr->v_samp_factor; + for (y_wipe_blocks = 0; y_wipe_blocks < wipe_bottom; + y_wipe_blocks += compptr->v_samp_factor) { + buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], y_wipe_blocks, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + if (x_wipe_blocks > 0) { + /* Reflect from left */ + dst_row_ptr = buffer[offset_y] + x_wipe_blocks; + for (dst_blk_x = wipe_width; dst_blk_x > 0;) { + src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */ + for (src_blk_x = x_wipe_blocks; + src_blk_x > 0 && dst_blk_x > 0; src_blk_x--, dst_blk_x--) { + dst_ptr = *dst_row_ptr++; /* destination goes right */ + src_ptr = *--src_row_ptr; /* source goes left */ + /* this unrolled loop doesn't need to know which row it's on... */ + for (k = 0; k < DCTSIZE2; k += 2) { + *dst_ptr++ = *src_ptr++; /* copy even column */ + *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ + } + } + } + } else if (compptr->width_in_blocks > x_wipe_blocks + wipe_width) { + /* Reflect from right */ + dst_row_ptr = buffer[offset_y] + x_wipe_blocks + wipe_width; + for (dst_blk_x = wipe_width; dst_blk_x > 0;) { + src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */ + src_blk_x = compptr->width_in_blocks - x_wipe_blocks - wipe_width; + for (; src_blk_x > 0 && dst_blk_x > 0; src_blk_x--, dst_blk_x--) { + dst_ptr = *--dst_row_ptr; /* destination goes left */ + src_ptr = *src_row_ptr++; /* source goes right */ + /* this unrolled loop doesn't need to know which row it's on... */ + for (k = 0; k < DCTSIZE2; k += 2) { + *dst_ptr++ = *src_ptr++; /* copy even column */ + *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ + } + } + } + } else { + FMEMZERO(buffer[offset_y] + x_wipe_blocks, + wipe_width * SIZEOF(JBLOCK)); + } + } + } + } +} + + +LOCAL(void) +do_flip_h_no_crop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, + jvirt_barray_ptr *src_coef_arrays) +/* Horizontal flip; done in-place, so no separate dest array is required. + * NB: this only works when y_crop_offset is zero. + */ +{ + JDIMENSION MCU_cols, comp_width, blk_x, blk_y, x_crop_blocks; + int ci, k, offset_y; + JBLOCKARRAY buffer; + JCOEFPTR ptr1, ptr2; + JCOEF temp1, temp2; + jpeg_component_info *compptr; + + /* Horizontal mirroring of DCT blocks is accomplished by swapping + * pairs of blocks in-place. Within a DCT block, we perform horizontal + * mirroring by changing the signs of odd-numbered columns. + * Partial iMCUs at the right edge are left untouched. + */ + MCU_cols = srcinfo->output_width / + (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + for (blk_y = 0; blk_y < compptr->height_in_blocks; + blk_y += compptr->v_samp_factor) { + buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + /* Do the mirroring */ + for (blk_x = 0; blk_x * 2 < comp_width; blk_x++) { + ptr1 = buffer[offset_y][blk_x]; + ptr2 = buffer[offset_y][comp_width - blk_x - 1]; + /* this unrolled loop doesn't need to know which row it's on... */ + for (k = 0; k < DCTSIZE2; k += 2) { + temp1 = *ptr1; /* swap even column */ + temp2 = *ptr2; + *ptr1++ = temp2; + *ptr2++ = temp1; + temp1 = *ptr1; /* swap odd column with sign change */ + temp2 = *ptr2; + *ptr1++ = -temp2; + *ptr2++ = -temp1; + } + } + if (x_crop_blocks > 0) { + /* Now left-justify the portion of the data to be kept. + * We can't use a single jcopy_block_row() call because that routine + * depends on memcpy(), whose behavior is unspecified for overlapping + * source and destination areas. Sigh. + */ + for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) { + jcopy_block_row(buffer[offset_y] + blk_x + x_crop_blocks, + buffer[offset_y] + blk_x, + (JDIMENSION) 1); + } + } + } + } + } +} + + +LOCAL(void) +do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* Horizontal flip in general cropping case */ +{ + JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; + JDIMENSION x_crop_blocks, y_crop_blocks; + int ci, k, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JBLOCKROW src_row_ptr, dst_row_ptr; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + /* Here we must output into a separate array because we can't touch + * different rows of a single virtual array simultaneously. Otherwise, + * this is essentially the same as the routine above. + */ + MCU_cols = srcinfo->output_width / + (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_y + y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + dst_row_ptr = dst_buffer[offset_y]; + src_row_ptr = src_buffer[offset_y]; + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { + if (x_crop_blocks + dst_blk_x < comp_width) { + /* Do the mirrorable blocks */ + dst_ptr = dst_row_ptr[dst_blk_x]; + src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; + /* this unrolled loop doesn't need to know which row it's on... */ + for (k = 0; k < DCTSIZE2; k += 2) { + *dst_ptr++ = *src_ptr++; /* copy even column */ + *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ + } + } else { + /* Copy last partial block(s) verbatim */ + jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks, + dst_row_ptr + dst_blk_x, + (JDIMENSION) 1); + } + } + } + } + } +} + + +LOCAL(void) +do_flip_v (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* Vertical flip */ +{ + JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; + JDIMENSION x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JBLOCKROW src_row_ptr, dst_row_ptr; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + /* We output into a separate array because we can't touch different + * rows of the source virtual array simultaneously. Otherwise, this + * is a pretty straightforward analog of horizontal flip. + * Within a DCT block, vertical mirroring is done by changing the signs + * of odd-numbered rows. + * Partial iMCUs at the bottom edge are copied verbatim. + */ + MCU_rows = srcinfo->output_height / + (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_height = MCU_rows * compptr->v_samp_factor; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + if (y_crop_blocks + dst_blk_y < comp_height) { + /* Row is within the mirrorable area. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + comp_height - y_crop_blocks - dst_blk_y - + (JDIMENSION) compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } else { + /* Bottom-edge blocks will be copied verbatim. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_y + y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + if (y_crop_blocks + dst_blk_y < comp_height) { + /* Row is within the mirrorable area. */ + dst_row_ptr = dst_buffer[offset_y]; + src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; + src_row_ptr += x_crop_blocks; + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x++) { + dst_ptr = dst_row_ptr[dst_blk_x]; + src_ptr = src_row_ptr[dst_blk_x]; + for (i = 0; i < DCTSIZE; i += 2) { + /* copy even row */ + for (j = 0; j < DCTSIZE; j++) + *dst_ptr++ = *src_ptr++; + /* copy odd row with sign change */ + for (j = 0; j < DCTSIZE; j++) + *dst_ptr++ = - *src_ptr++; + } + } + } else { + /* Just copy row verbatim. */ + jcopy_block_row(src_buffer[offset_y] + x_crop_blocks, + dst_buffer[offset_y], + compptr->width_in_blocks); + } + } + } + } +} + + +LOCAL(void) +do_transpose (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* Transpose source into destination */ +{ + JDIMENSION dst_blk_x, dst_blk_y, x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + /* Transposing pixels within a block just requires transposing the + * DCT coefficients. + * Partial iMCUs at the edges require no special treatment; we simply + * process all the available DCT blocks for every component. + */ + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_x + x_crop_blocks, + (JDIMENSION) compptr->h_samp_factor, FALSE); + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; + src_ptr = src_buffer[offset_x][dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + } + } + } + } + } +} + + +LOCAL(void) +do_rot_90 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* 90 degree rotation is equivalent to + * 1. Transposing the image; + * 2. Horizontal mirroring. + * These two steps are merged into a single processing routine. + */ +{ + JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; + JDIMENSION x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + /* Because of the horizontal mirror step, we can't process partial iMCUs + * at the (output) right edge properly. They just get transposed and + * not mirrored. + */ + MCU_cols = srcinfo->output_height / + (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { + if (x_crop_blocks + dst_blk_x < comp_width) { + /* Block is within the mirrorable area. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + comp_width - x_crop_blocks - dst_blk_x - + (JDIMENSION) compptr->h_samp_factor, + (JDIMENSION) compptr->h_samp_factor, FALSE); + } else { + /* Edge blocks are transposed but not mirrored. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_x + x_crop_blocks, + (JDIMENSION) compptr->h_samp_factor, FALSE); + } + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; + if (x_crop_blocks + dst_blk_x < comp_width) { + /* Block is within the mirrorable area. */ + src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] + [dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + i++; + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + } + } else { + /* Edge blocks are transposed but not mirrored. */ + src_ptr = src_buffer[offset_x] + [dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + } + } + } + } + } + } +} + + +LOCAL(void) +do_rot_270 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* 270 degree rotation is equivalent to + * 1. Horizontal mirroring; + * 2. Transposing the image. + * These two steps are merged into a single processing routine. + */ +{ + JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; + JDIMENSION x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + /* Because of the horizontal mirror step, we can't process partial iMCUs + * at the (output) bottom edge properly. They just get transposed and + * not mirrored. + */ + MCU_rows = srcinfo->output_width / + (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_height = MCU_rows * compptr->v_samp_factor; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_x + x_crop_blocks, + (JDIMENSION) compptr->h_samp_factor, FALSE); + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; + if (y_crop_blocks + dst_blk_y < comp_height) { + /* Block is within the mirrorable area. */ + src_ptr = src_buffer[offset_x] + [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) { + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + j++; + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + } + } + } else { + /* Edge blocks are transposed but not mirrored. */ + src_ptr = src_buffer[offset_x] + [dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + } + } + } + } + } + } +} + + +LOCAL(void) +do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* 180 degree rotation is equivalent to + * 1. Vertical mirroring; + * 2. Horizontal mirroring. + * These two steps are merged into a single processing routine. + */ +{ + JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; + JDIMENSION x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JBLOCKROW src_row_ptr, dst_row_ptr; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + MCU_cols = srcinfo->output_width / + (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); + MCU_rows = srcinfo->output_height / + (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + comp_height = MCU_rows * compptr->v_samp_factor; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + if (y_crop_blocks + dst_blk_y < comp_height) { + /* Row is within the vertically mirrorable area. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + comp_height - y_crop_blocks - dst_blk_y - + (JDIMENSION) compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } else { + /* Bottom-edge rows are only mirrored horizontally. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_y + y_crop_blocks, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + dst_row_ptr = dst_buffer[offset_y]; + if (y_crop_blocks + dst_blk_y < comp_height) { + /* Row is within the mirrorable area. */ + src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { + dst_ptr = dst_row_ptr[dst_blk_x]; + if (x_crop_blocks + dst_blk_x < comp_width) { + /* Process the blocks that can be mirrored both ways. */ + src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; + for (i = 0; i < DCTSIZE; i += 2) { + /* For even row, negate every odd column. */ + for (j = 0; j < DCTSIZE; j += 2) { + *dst_ptr++ = *src_ptr++; + *dst_ptr++ = - *src_ptr++; + } + /* For odd row, negate every even column. */ + for (j = 0; j < DCTSIZE; j += 2) { + *dst_ptr++ = - *src_ptr++; + *dst_ptr++ = *src_ptr++; + } + } + } else { + /* Any remaining right-edge blocks are only mirrored vertically. */ + src_ptr = src_row_ptr[x_crop_blocks + dst_blk_x]; + for (i = 0; i < DCTSIZE; i += 2) { + for (j = 0; j < DCTSIZE; j++) + *dst_ptr++ = *src_ptr++; + for (j = 0; j < DCTSIZE; j++) + *dst_ptr++ = - *src_ptr++; + } + } + } + } else { + /* Remaining rows are just mirrored horizontally. */ + src_row_ptr = src_buffer[offset_y]; + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { + if (x_crop_blocks + dst_blk_x < comp_width) { + /* Process the blocks that can be mirrored. */ + dst_ptr = dst_row_ptr[dst_blk_x]; + src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; + for (i = 0; i < DCTSIZE2; i += 2) { + *dst_ptr++ = *src_ptr++; + *dst_ptr++ = - *src_ptr++; + } + } else { + /* Any remaining right-edge blocks are only copied. */ + jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks, + dst_row_ptr + dst_blk_x, + (JDIMENSION) 1); + } + } + } + } + } + } +} + + +LOCAL(void) +do_transverse (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, + jvirt_barray_ptr *src_coef_arrays, + jvirt_barray_ptr *dst_coef_arrays) +/* Transverse transpose is equivalent to + * 1. 180 degree rotation; + * 2. Transposition; + * or + * 1. Horizontal mirroring; + * 2. Transposition; + * 3. Horizontal mirroring. + * These steps are merged into a single processing routine. + */ +{ + JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; + JDIMENSION x_crop_blocks, y_crop_blocks; + int ci, i, j, offset_x, offset_y; + JBLOCKARRAY src_buffer, dst_buffer; + JCOEFPTR src_ptr, dst_ptr; + jpeg_component_info *compptr; + + MCU_cols = srcinfo->output_height / + (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); + MCU_rows = srcinfo->output_width / + (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + comp_width = MCU_cols * compptr->h_samp_factor; + comp_height = MCU_rows * compptr->v_samp_factor; + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; + dst_blk_y += compptr->v_samp_factor) { + dst_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, + (JDIMENSION) compptr->v_samp_factor, TRUE); + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; + dst_blk_x += compptr->h_samp_factor) { + if (x_crop_blocks + dst_blk_x < comp_width) { + /* Block is within the mirrorable area. */ + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + comp_width - x_crop_blocks - dst_blk_x - + (JDIMENSION) compptr->h_samp_factor, + (JDIMENSION) compptr->h_samp_factor, FALSE); + } else { + src_buffer = (*srcinfo->mem->access_virt_barray) + ((j_common_ptr) srcinfo, src_coef_arrays[ci], + dst_blk_x + x_crop_blocks, + (JDIMENSION) compptr->h_samp_factor, FALSE); + } + for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; + if (y_crop_blocks + dst_blk_y < comp_height) { + if (x_crop_blocks + dst_blk_x < comp_width) { + /* Block is within the mirrorable area. */ + src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] + [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) { + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + j++; + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + } + i++; + for (j = 0; j < DCTSIZE; j++) { + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + j++; + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + } + } + } else { + /* Right-edge blocks are mirrored in y only */ + src_ptr = src_buffer[offset_x] + [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) { + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + j++; + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + } + } + } + } else { + if (x_crop_blocks + dst_blk_x < comp_width) { + /* Bottom-edge blocks are mirrored in x only */ + src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] + [dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + i++; + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; + } + } else { + /* At lower right corner, just transpose, no mirroring */ + src_ptr = src_buffer[offset_x] + [dst_blk_y + offset_y + y_crop_blocks]; + for (i = 0; i < DCTSIZE; i++) + for (j = 0; j < DCTSIZE; j++) + dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; + } + } + } + } + } + } + } +} + + +/* Parse an unsigned integer: subroutine for jtransform_parse_crop_spec. + * Returns TRUE if valid integer found, FALSE if not. + * *strptr is advanced over the digit string, and *result is set to its value. + */ + +LOCAL(boolean) +jt_read_integer (const char ** strptr, JDIMENSION * result) +{ + const char * ptr = *strptr; + JDIMENSION val = 0; + + for (; isdigit(*ptr); ptr++) { + val = val * 10 + (JDIMENSION) (*ptr - '0'); + } + *result = val; + if (ptr == *strptr) + return FALSE; /* oops, no digits */ + *strptr = ptr; + return TRUE; +} + + +/* Parse a crop specification (written in X11 geometry style). + * The routine returns TRUE if the spec string is valid, FALSE if not. + * + * The crop spec string should have the format + * [{fr}]x[{fr}]{+-}{+-} + * where width, height, xoffset, and yoffset are unsigned integers. + * Each of the elements can be omitted to indicate a default value. + * (A weakness of this style is that it is not possible to omit xoffset + * while specifying yoffset, since they look alike.) + * + * This code is loosely based on XParseGeometry from the X11 distribution. + */ + +GLOBAL(boolean) +jtransform_parse_crop_spec (jpeg_transform_info *info, const char *spec) +{ + info->crop = FALSE; + info->crop_width_set = JCROP_UNSET; + info->crop_height_set = JCROP_UNSET; + info->crop_xoffset_set = JCROP_UNSET; + info->crop_yoffset_set = JCROP_UNSET; + + if (isdigit(*spec)) { + /* fetch width */ + if (! jt_read_integer(&spec, &info->crop_width)) + return FALSE; + if (*spec == 'f' || *spec == 'F') { + spec++; + info->crop_width_set = JCROP_FORCE; + } else if (*spec == 'r' || *spec == 'R') { + spec++; + info->crop_width_set = JCROP_REFLECT; + } else + info->crop_width_set = JCROP_POS; + } + if (*spec == 'x' || *spec == 'X') { + /* fetch height */ + spec++; + if (! jt_read_integer(&spec, &info->crop_height)) + return FALSE; + if (*spec == 'f' || *spec == 'F') { + spec++; + info->crop_height_set = JCROP_FORCE; + } else if (*spec == 'r' || *spec == 'R') { + spec++; + info->crop_height_set = JCROP_REFLECT; + } else + info->crop_height_set = JCROP_POS; + } + if (*spec == '+' || *spec == '-') { + /* fetch xoffset */ + info->crop_xoffset_set = (*spec == '-') ? JCROP_NEG : JCROP_POS; + spec++; + if (! jt_read_integer(&spec, &info->crop_xoffset)) + return FALSE; + } + if (*spec == '+' || *spec == '-') { + /* fetch yoffset */ + info->crop_yoffset_set = (*spec == '-') ? JCROP_NEG : JCROP_POS; + spec++; + if (! jt_read_integer(&spec, &info->crop_yoffset)) + return FALSE; + } + /* We had better have gotten to the end of the string. */ + if (*spec != '\0') + return FALSE; + info->crop = TRUE; + return TRUE; +} + + +/* Trim off any partial iMCUs on the indicated destination edge */ + +LOCAL(void) +trim_right_edge (jpeg_transform_info *info, JDIMENSION full_width) +{ + JDIMENSION MCU_cols; + + MCU_cols = info->output_width / info->iMCU_sample_width; + if (MCU_cols > 0 && info->x_crop_offset + MCU_cols == + full_width / info->iMCU_sample_width) + info->output_width = MCU_cols * info->iMCU_sample_width; +} + +LOCAL(void) +trim_bottom_edge (jpeg_transform_info *info, JDIMENSION full_height) +{ + JDIMENSION MCU_rows; + + MCU_rows = info->output_height / info->iMCU_sample_height; + if (MCU_rows > 0 && info->y_crop_offset + MCU_rows == + full_height / info->iMCU_sample_height) + info->output_height = MCU_rows * info->iMCU_sample_height; +} + + +/* Request any required workspace. + * + * This routine figures out the size that the output image will be + * (which implies that all the transform parameters must be set before + * it is called). + * + * We allocate the workspace virtual arrays from the source decompression + * object, so that all the arrays (both the original data and the workspace) + * will be taken into account while making memory management decisions. + * Hence, this routine must be called after jpeg_read_header (which reads + * the image dimensions) and before jpeg_read_coefficients (which realizes + * the source's virtual arrays). + * + * This function returns FALSE right away if -perfect is given + * and transformation is not perfect. Otherwise returns TRUE. + */ + +GLOBAL(boolean) +jtransform_request_workspace (j_decompress_ptr srcinfo, + jpeg_transform_info *info) +{ + jvirt_barray_ptr *coef_arrays; + boolean need_workspace, transpose_it; + jpeg_component_info *compptr; + JDIMENSION xoffset, yoffset, dtemp; + JDIMENSION width_in_iMCUs, height_in_iMCUs; + JDIMENSION width_in_blocks, height_in_blocks; + int itemp, ci, h_samp_factor, v_samp_factor; + + /* Determine number of components in output image */ + if (info->force_grayscale && + (srcinfo->jpeg_color_space == JCS_YCbCr || + srcinfo->jpeg_color_space == JCS_BG_YCC) && + srcinfo->num_components == 3) + /* We'll only process the first component */ + info->num_components = 1; + else + /* Process all the components */ + info->num_components = srcinfo->num_components; + + /* Compute output image dimensions and related values. */ + jpeg_core_output_dimensions(srcinfo); + + /* Return right away if -perfect is given and transformation is not perfect. + */ + if (info->perfect) { + if (info->num_components == 1) { + if (!jtransform_perfect_transform(srcinfo->output_width, + srcinfo->output_height, + srcinfo->min_DCT_h_scaled_size, + srcinfo->min_DCT_v_scaled_size, + info->transform)) + return FALSE; + } else { + if (!jtransform_perfect_transform(srcinfo->output_width, + srcinfo->output_height, + srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size, + srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size, + info->transform)) + return FALSE; + } + } + + /* If there is only one output component, force the iMCU size to be 1; + * else use the source iMCU size. (This allows us to do the right thing + * when reducing color to grayscale, and also provides a handy way of + * cleaning up "funny" grayscale images whose sampling factors are not 1x1.) + */ + switch (info->transform) { + case JXFORM_TRANSPOSE: + case JXFORM_TRANSVERSE: + case JXFORM_ROT_90: + case JXFORM_ROT_270: + info->output_width = srcinfo->output_height; + info->output_height = srcinfo->output_width; + if (info->num_components == 1) { + info->iMCU_sample_width = srcinfo->min_DCT_v_scaled_size; + info->iMCU_sample_height = srcinfo->min_DCT_h_scaled_size; + } else { + info->iMCU_sample_width = + srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size; + info->iMCU_sample_height = + srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size; + } + break; + default: + info->output_width = srcinfo->output_width; + info->output_height = srcinfo->output_height; + if (info->num_components == 1) { + info->iMCU_sample_width = srcinfo->min_DCT_h_scaled_size; + info->iMCU_sample_height = srcinfo->min_DCT_v_scaled_size; + } else { + info->iMCU_sample_width = + srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size; + info->iMCU_sample_height = + srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size; + } + } + + /* If cropping has been requested, compute the crop area's position and + * dimensions, ensuring that its upper left corner falls at an iMCU boundary. + */ + if (info->crop) { + /* Insert default values for unset crop parameters */ + if (info->crop_xoffset_set == JCROP_UNSET) + info->crop_xoffset = 0; /* default to +0 */ + if (info->crop_yoffset_set == JCROP_UNSET) + info->crop_yoffset = 0; /* default to +0 */ + if (info->crop_width_set == JCROP_UNSET) { + if (info->crop_xoffset >= info->output_width) + ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); + info->crop_width = info->output_width - info->crop_xoffset; + } else { + /* Check for crop extension */ + if (info->crop_width > info->output_width) { + /* Crop extension does not work when transforming! */ + if (info->transform != JXFORM_NONE || + info->crop_xoffset >= info->crop_width || + info->crop_xoffset > info->crop_width - info->output_width) + ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); + } else { + if (info->crop_xoffset >= info->output_width || + info->crop_width <= 0 || + info->crop_xoffset > info->output_width - info->crop_width) + ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); + } + } + if (info->crop_height_set == JCROP_UNSET) { + if (info->crop_yoffset >= info->output_height) + ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); + info->crop_height = info->output_height - info->crop_yoffset; + } else { + /* Check for crop extension */ + if (info->crop_height > info->output_height) { + /* Crop extension does not work when transforming! */ + if (info->transform != JXFORM_NONE || + info->crop_yoffset >= info->crop_height || + info->crop_yoffset > info->crop_height - info->output_height) + ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); + } else { + if (info->crop_yoffset >= info->output_height || + info->crop_height <= 0 || + info->crop_yoffset > info->output_height - info->crop_height) + ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); + } + } + /* Convert negative crop offsets into regular offsets */ + if (info->crop_xoffset_set != JCROP_NEG) + xoffset = info->crop_xoffset; + else if (info->crop_width > info->output_width) /* crop extension */ + xoffset = info->crop_width - info->output_width - info->crop_xoffset; + else + xoffset = info->output_width - info->crop_width - info->crop_xoffset; + if (info->crop_yoffset_set != JCROP_NEG) + yoffset = info->crop_yoffset; + else if (info->crop_height > info->output_height) /* crop extension */ + yoffset = info->crop_height - info->output_height - info->crop_yoffset; + else + yoffset = info->output_height - info->crop_height - info->crop_yoffset; + /* Now adjust so that upper left corner falls at an iMCU boundary */ + switch (info->transform) { + case JXFORM_DROP: + /* Ensure the effective drop region will not exceed the requested */ + itemp = info->iMCU_sample_width; + dtemp = itemp - 1 - ((xoffset + itemp - 1) % itemp); + xoffset += dtemp; + if (info->crop_width <= dtemp) + info->drop_width = 0; + else if (xoffset + info->crop_width - dtemp == info->output_width) + /* Matching right edge: include partial iMCU */ + info->drop_width = (info->crop_width - dtemp + itemp - 1) / itemp; + else + info->drop_width = (info->crop_width - dtemp) / itemp; + itemp = info->iMCU_sample_height; + dtemp = itemp - 1 - ((yoffset + itemp - 1) % itemp); + yoffset += dtemp; + if (info->crop_height <= dtemp) + info->drop_height = 0; + else if (yoffset + info->crop_height - dtemp == info->output_height) + /* Matching bottom edge: include partial iMCU */ + info->drop_height = (info->crop_height - dtemp + itemp - 1) / itemp; + else + info->drop_height = (info->crop_height - dtemp) / itemp; + /* Check if sampling factors match for dropping */ + if (info->drop_width != 0 && info->drop_height != 0) + for (ci = 0; ci < info->num_components && + ci < info->drop_ptr->num_components; ci++) { + if (info->drop_ptr->comp_info[ci].h_samp_factor * + srcinfo->max_h_samp_factor != + srcinfo->comp_info[ci].h_samp_factor * + info->drop_ptr->max_h_samp_factor) + ERREXIT6(srcinfo, JERR_BAD_DROP_SAMPLING, ci, + info->drop_ptr->comp_info[ci].h_samp_factor, + info->drop_ptr->max_h_samp_factor, + srcinfo->comp_info[ci].h_samp_factor, + srcinfo->max_h_samp_factor, 'h'); + if (info->drop_ptr->comp_info[ci].v_samp_factor * + srcinfo->max_v_samp_factor != + srcinfo->comp_info[ci].v_samp_factor * + info->drop_ptr->max_v_samp_factor) + ERREXIT6(srcinfo, JERR_BAD_DROP_SAMPLING, ci, + info->drop_ptr->comp_info[ci].v_samp_factor, + info->drop_ptr->max_v_samp_factor, + srcinfo->comp_info[ci].v_samp_factor, + srcinfo->max_v_samp_factor, 'v'); + } + break; + case JXFORM_WIPE: + /* Ensure the effective wipe region will cover the requested */ + info->drop_width = (JDIMENSION) jdiv_round_up + ((long) (info->crop_width + (xoffset % info->iMCU_sample_width)), + (long) info->iMCU_sample_width); + info->drop_height = (JDIMENSION) jdiv_round_up + ((long) (info->crop_height + (yoffset % info->iMCU_sample_height)), + (long) info->iMCU_sample_height); + break; + default: + /* Ensure the effective crop region will cover the requested */ + if (info->crop_width_set == JCROP_FORCE || + info->crop_width > info->output_width) + info->output_width = info->crop_width; + else + info->output_width = + info->crop_width + (xoffset % info->iMCU_sample_width); + if (info->crop_height_set == JCROP_FORCE || + info->crop_height > info->output_height) + info->output_height = info->crop_height; + else + info->output_height = + info->crop_height + (yoffset % info->iMCU_sample_height); + } + /* Save x/y offsets measured in iMCUs */ + info->x_crop_offset = xoffset / info->iMCU_sample_width; + info->y_crop_offset = yoffset / info->iMCU_sample_height; + } else { + info->x_crop_offset = 0; + info->y_crop_offset = 0; + } + + /* Figure out whether we need workspace arrays, + * and if so whether they are transposed relative to the source. + */ + need_workspace = FALSE; + transpose_it = FALSE; + switch (info->transform) { + case JXFORM_NONE: + if (info->x_crop_offset != 0 || info->y_crop_offset != 0 || + info->output_width > srcinfo->output_width || + info->output_height > srcinfo->output_height) + need_workspace = TRUE; + /* No workspace needed if neither cropping nor transforming */ + break; + case JXFORM_FLIP_H: + if (info->trim) + trim_right_edge(info, srcinfo->output_width); + if (info->y_crop_offset != 0) + need_workspace = TRUE; + /* do_flip_h_no_crop doesn't need a workspace array */ + break; + case JXFORM_FLIP_V: + if (info->trim) + trim_bottom_edge(info, srcinfo->output_height); + /* Need workspace arrays having same dimensions as source image. */ + need_workspace = TRUE; + break; + case JXFORM_TRANSPOSE: + /* transpose does NOT have to trim anything */ + /* Need workspace arrays having transposed dimensions. */ + need_workspace = TRUE; + transpose_it = TRUE; + break; + case JXFORM_TRANSVERSE: + if (info->trim) { + trim_right_edge(info, srcinfo->output_height); + trim_bottom_edge(info, srcinfo->output_width); + } + /* Need workspace arrays having transposed dimensions. */ + need_workspace = TRUE; + transpose_it = TRUE; + break; + case JXFORM_ROT_90: + if (info->trim) + trim_right_edge(info, srcinfo->output_height); + /* Need workspace arrays having transposed dimensions. */ + need_workspace = TRUE; + transpose_it = TRUE; + break; + case JXFORM_ROT_180: + if (info->trim) { + trim_right_edge(info, srcinfo->output_width); + trim_bottom_edge(info, srcinfo->output_height); + } + /* Need workspace arrays having same dimensions as source image. */ + need_workspace = TRUE; + break; + case JXFORM_ROT_270: + if (info->trim) + trim_bottom_edge(info, srcinfo->output_width); + /* Need workspace arrays having transposed dimensions. */ + need_workspace = TRUE; + transpose_it = TRUE; + break; + case JXFORM_WIPE: + break; + case JXFORM_DROP: +#if DROP_REQUEST_FROM_SRC + drop_request_from_src(info->drop_ptr, srcinfo); +#endif + break; + } + + /* Allocate workspace if needed. + * Note that we allocate arrays padded out to the next iMCU boundary, + * so that transform routines need not worry about missing edge blocks. + */ + if (need_workspace) { + coef_arrays = (jvirt_barray_ptr *) (*srcinfo->mem->alloc_small) + ((j_common_ptr) srcinfo, JPOOL_IMAGE, + SIZEOF(jvirt_barray_ptr) * info->num_components); + width_in_iMCUs = (JDIMENSION) jdiv_round_up + ((long) info->output_width, (long) info->iMCU_sample_width); + height_in_iMCUs = (JDIMENSION) jdiv_round_up + ((long) info->output_height, (long) info->iMCU_sample_height); + for (ci = 0; ci < info->num_components; ci++) { + compptr = srcinfo->comp_info + ci; + if (info->num_components == 1) { + /* we're going to force samp factors to 1x1 in this case */ + h_samp_factor = v_samp_factor = 1; + } else if (transpose_it) { + h_samp_factor = compptr->v_samp_factor; + v_samp_factor = compptr->h_samp_factor; + } else { + h_samp_factor = compptr->h_samp_factor; + v_samp_factor = compptr->v_samp_factor; + } + width_in_blocks = width_in_iMCUs * h_samp_factor; + height_in_blocks = height_in_iMCUs * v_samp_factor; + coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) + ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, + width_in_blocks, height_in_blocks, (JDIMENSION) v_samp_factor); + } + info->workspace_coef_arrays = coef_arrays; + } else + info->workspace_coef_arrays = NULL; + + return TRUE; +} + + +/* Transpose destination image parameters */ + +LOCAL(void) +transpose_critical_parameters (j_compress_ptr dstinfo) +{ + int tblno, i, j, ci, itemp; + jpeg_component_info *compptr; + JQUANT_TBL *qtblptr; + JDIMENSION jtemp; + UINT16 qtemp; + + /* Transpose image dimensions */ + jtemp = dstinfo->image_width; + dstinfo->image_width = dstinfo->image_height; + dstinfo->image_height = jtemp; + itemp = dstinfo->min_DCT_h_scaled_size; + dstinfo->min_DCT_h_scaled_size = dstinfo->min_DCT_v_scaled_size; + dstinfo->min_DCT_v_scaled_size = itemp; + + /* Transpose sampling factors */ + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; + itemp = compptr->h_samp_factor; + compptr->h_samp_factor = compptr->v_samp_factor; + compptr->v_samp_factor = itemp; + } + + /* Transpose quantization tables */ + for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { + qtblptr = dstinfo->quant_tbl_ptrs[tblno]; + if (qtblptr != NULL) { + for (i = 0; i < DCTSIZE; i++) { + for (j = 0; j < i; j++) { + qtemp = qtblptr->quantval[i*DCTSIZE+j]; + qtblptr->quantval[i*DCTSIZE+j] = qtblptr->quantval[j*DCTSIZE+i]; + qtblptr->quantval[j*DCTSIZE+i] = qtemp; + } + } + } + } +} + + +/* Adjust Exif image parameters. + * + * We try to adjust the Tags ExifImageWidth and ExifImageHeight if possible. + */ + +LOCAL(void) +adjust_exif_parameters (JOCTET FAR * data, unsigned int length, + JDIMENSION new_width, JDIMENSION new_height) +{ + boolean is_motorola; /* Flag for byte order */ + unsigned int number_of_tags, tagnum; + unsigned int firstoffset, offset; + JDIMENSION new_value; + + if (length < 12) return; /* Length of an IFD entry */ + + /* Discover byte order */ + if (GETJOCTET(data[0]) == 0x49 && GETJOCTET(data[1]) == 0x49) + is_motorola = FALSE; + else if (GETJOCTET(data[0]) == 0x4D && GETJOCTET(data[1]) == 0x4D) + is_motorola = TRUE; + else + return; + + /* Check Tag Mark */ + if (is_motorola) { + if (GETJOCTET(data[2]) != 0) return; + if (GETJOCTET(data[3]) != 0x2A) return; + } else { + if (GETJOCTET(data[3]) != 0) return; + if (GETJOCTET(data[2]) != 0x2A) return; + } + + /* Get first IFD offset (offset to IFD0) */ + if (is_motorola) { + if (GETJOCTET(data[4]) != 0) return; + if (GETJOCTET(data[5]) != 0) return; + firstoffset = GETJOCTET(data[6]); + firstoffset <<= 8; + firstoffset += GETJOCTET(data[7]); + } else { + if (GETJOCTET(data[7]) != 0) return; + if (GETJOCTET(data[6]) != 0) return; + firstoffset = GETJOCTET(data[5]); + firstoffset <<= 8; + firstoffset += GETJOCTET(data[4]); + } + if (firstoffset > length - 2) return; /* check end of data segment */ + + /* Get the number of directory entries contained in this IFD */ + if (is_motorola) { + number_of_tags = GETJOCTET(data[firstoffset]); + number_of_tags <<= 8; + number_of_tags += GETJOCTET(data[firstoffset+1]); + } else { + number_of_tags = GETJOCTET(data[firstoffset+1]); + number_of_tags <<= 8; + number_of_tags += GETJOCTET(data[firstoffset]); + } + if (number_of_tags == 0) return; + firstoffset += 2; + + /* Search for ExifSubIFD offset Tag in IFD0 */ + for (;;) { + if (firstoffset > length - 12) return; /* check end of data segment */ + /* Get Tag number */ + if (is_motorola) { + tagnum = GETJOCTET(data[firstoffset]); + tagnum <<= 8; + tagnum += GETJOCTET(data[firstoffset+1]); + } else { + tagnum = GETJOCTET(data[firstoffset+1]); + tagnum <<= 8; + tagnum += GETJOCTET(data[firstoffset]); + } + if (tagnum == 0x8769) break; /* found ExifSubIFD offset Tag */ + if (--number_of_tags == 0) return; + firstoffset += 12; + } + + /* Get the ExifSubIFD offset */ + if (is_motorola) { + if (GETJOCTET(data[firstoffset+8]) != 0) return; + if (GETJOCTET(data[firstoffset+9]) != 0) return; + offset = GETJOCTET(data[firstoffset+10]); + offset <<= 8; + offset += GETJOCTET(data[firstoffset+11]); + } else { + if (GETJOCTET(data[firstoffset+11]) != 0) return; + if (GETJOCTET(data[firstoffset+10]) != 0) return; + offset = GETJOCTET(data[firstoffset+9]); + offset <<= 8; + offset += GETJOCTET(data[firstoffset+8]); + } + if (offset > length - 2) return; /* check end of data segment */ + + /* Get the number of directory entries contained in this SubIFD */ + if (is_motorola) { + number_of_tags = GETJOCTET(data[offset]); + number_of_tags <<= 8; + number_of_tags += GETJOCTET(data[offset+1]); + } else { + number_of_tags = GETJOCTET(data[offset+1]); + number_of_tags <<= 8; + number_of_tags += GETJOCTET(data[offset]); + } + if (number_of_tags < 2) return; + offset += 2; + + /* Search for ExifImageWidth and ExifImageHeight Tags in this SubIFD */ + do { + if (offset > length - 12) return; /* check end of data segment */ + /* Get Tag number */ + if (is_motorola) { + tagnum = GETJOCTET(data[offset]); + tagnum <<= 8; + tagnum += GETJOCTET(data[offset+1]); + } else { + tagnum = GETJOCTET(data[offset+1]); + tagnum <<= 8; + tagnum += GETJOCTET(data[offset]); + } + if (tagnum == 0xA002 || tagnum == 0xA003) { + if (tagnum == 0xA002) + new_value = new_width; /* ExifImageWidth Tag */ + else + new_value = new_height; /* ExifImageHeight Tag */ + if (is_motorola) { + data[offset+2] = 0; /* Format = unsigned long (4 octets) */ + data[offset+3] = 4; + data[offset+4] = 0; /* Number Of Components = 1 */ + data[offset+5] = 0; + data[offset+6] = 0; + data[offset+7] = 1; + data[offset+8] = 0; + data[offset+9] = 0; + data[offset+10] = (JOCTET)((new_value >> 8) & 0xFF); + data[offset+11] = (JOCTET)(new_value & 0xFF); + } else { + data[offset+2] = 4; /* Format = unsigned long (4 octets) */ + data[offset+3] = 0; + data[offset+4] = 1; /* Number Of Components = 1 */ + data[offset+5] = 0; + data[offset+6] = 0; + data[offset+7] = 0; + data[offset+8] = (JOCTET)(new_value & 0xFF); + data[offset+9] = (JOCTET)((new_value >> 8) & 0xFF); + data[offset+10] = 0; + data[offset+11] = 0; + } + } + offset += 12; + } while (--number_of_tags); +} + + +/* Adjust output image parameters as needed. + * + * This must be called after jpeg_copy_critical_parameters() + * and before jpeg_write_coefficients(). + * + * The return value is the set of virtual coefficient arrays to be written + * (either the ones allocated by jtransform_request_workspace, or the + * original source data arrays). The caller will need to pass this value + * to jpeg_write_coefficients(). + */ + +GLOBAL(jvirt_barray_ptr *) +jtransform_adjust_parameters (j_decompress_ptr srcinfo, + j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info) +{ + /* If force-to-grayscale is requested, adjust destination parameters */ + if (info->force_grayscale) { + /* First, ensure we have YCC or grayscale data, and that the source's + * Y channel is full resolution. (No reasonable person would make Y + * be less than full resolution, so actually coping with that case + * isn't worth extra code space. But we check it to avoid crashing.) + */ + if ((((dstinfo->jpeg_color_space == JCS_YCbCr || + dstinfo->jpeg_color_space == JCS_BG_YCC) && + dstinfo->num_components == 3) || + (dstinfo->jpeg_color_space == JCS_GRAYSCALE && + dstinfo->num_components == 1)) && + srcinfo->comp_info[0].h_samp_factor == srcinfo->max_h_samp_factor && + srcinfo->comp_info[0].v_samp_factor == srcinfo->max_v_samp_factor) { + /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed + * properly. Among other things, it sets the target h_samp_factor & + * v_samp_factor to 1, which typically won't match the source. + * We have to preserve the source's quantization table number, however. + */ + int sv_quant_tbl_no = dstinfo->comp_info[0].quant_tbl_no; + jpeg_set_colorspace(dstinfo, JCS_GRAYSCALE); + dstinfo->comp_info[0].quant_tbl_no = sv_quant_tbl_no; + } else { + /* Sorry, can't do it */ + ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL); + } + } else if (info->num_components == 1) { + /* For a single-component source, we force the destination sampling factors + * to 1x1, with or without force_grayscale. This is useful because some + * decoders choke on grayscale images with other sampling factors. + */ + dstinfo->comp_info[0].h_samp_factor = 1; + dstinfo->comp_info[0].v_samp_factor = 1; + } + + /* Correct the destination's image dimensions as necessary + * for rotate/flip, resize, and crop operations. + */ + dstinfo->jpeg_width = info->output_width; + dstinfo->jpeg_height = info->output_height; + + /* Transpose destination image parameters, adjust quantization */ + switch (info->transform) { + case JXFORM_TRANSPOSE: + case JXFORM_TRANSVERSE: + case JXFORM_ROT_90: + case JXFORM_ROT_270: + transpose_critical_parameters(dstinfo); + break; + case JXFORM_DROP: + if (info->drop_width != 0 && info->drop_height != 0) + adjust_quant(srcinfo, src_coef_arrays, + info->drop_ptr, info->drop_coef_arrays, + info->trim, dstinfo); + break; + default: + break; + } + + /* Adjust Exif properties */ + if (srcinfo->marker_list != NULL && + srcinfo->marker_list->marker == JPEG_APP0+1 && + srcinfo->marker_list->data_length >= 6 && + GETJOCTET(srcinfo->marker_list->data[0]) == 0x45 && + GETJOCTET(srcinfo->marker_list->data[1]) == 0x78 && + GETJOCTET(srcinfo->marker_list->data[2]) == 0x69 && + GETJOCTET(srcinfo->marker_list->data[3]) == 0x66 && + GETJOCTET(srcinfo->marker_list->data[4]) == 0 && + GETJOCTET(srcinfo->marker_list->data[5]) == 0) { + /* Suppress output of JFIF marker */ + dstinfo->write_JFIF_header = FALSE; + /* Adjust Exif image parameters */ + if (dstinfo->jpeg_width != srcinfo->image_width || + dstinfo->jpeg_height != srcinfo->image_height) + /* Align data segment to start of TIFF structure for parsing */ + adjust_exif_parameters(srcinfo->marker_list->data + 6, + srcinfo->marker_list->data_length - 6, + dstinfo->jpeg_width, dstinfo->jpeg_height); + } + + /* Return the appropriate output data set */ + if (info->workspace_coef_arrays != NULL) + return info->workspace_coef_arrays; + return src_coef_arrays; +} + + +/* Execute the actual transformation, if any. + * + * This must be called *after* jpeg_write_coefficients, because it depends + * on jpeg_write_coefficients to have computed subsidiary values such as + * the per-component width and height fields in the destination object. + * + * Note that some transformations will modify the source data arrays! + */ + +GLOBAL(void) +jtransform_execute_transform (j_decompress_ptr srcinfo, + j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info) +{ + jvirt_barray_ptr *dst_coef_arrays = info->workspace_coef_arrays; + + /* Note: conditions tested here should match those in switch statement + * in jtransform_request_workspace() + */ + switch (info->transform) { + case JXFORM_NONE: + if (info->output_width > srcinfo->output_width || + info->output_height > srcinfo->output_height) { + if (info->output_width > srcinfo->output_width && + info->crop_width_set == JCROP_REFLECT) + do_crop_ext_reflect(srcinfo, dstinfo, + info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + else if (info->output_width > srcinfo->output_width && + info->crop_width_set == JCROP_FORCE) + do_crop_ext_flat(srcinfo, dstinfo, + info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + else + do_crop_ext_zero(srcinfo, dstinfo, + info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + } else if (info->x_crop_offset != 0 || info->y_crop_offset != 0) + do_crop(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_FLIP_H: + if (info->y_crop_offset != 0) + do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + else + do_flip_h_no_crop(srcinfo, dstinfo, info->x_crop_offset, + src_coef_arrays); + break; + case JXFORM_FLIP_V: + do_flip_v(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_TRANSPOSE: + do_transpose(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_TRANSVERSE: + do_transverse(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_ROT_90: + do_rot_90(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_ROT_180: + do_rot_180(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_ROT_270: + do_rot_270(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_WIPE: + if (info->crop_width_set == JCROP_REFLECT && + info->y_crop_offset == 0 && info->drop_height == + (JDIMENSION) jdiv_round_up + ((long) info->output_height, (long) info->iMCU_sample_height) && + (info->x_crop_offset == 0 || + info->x_crop_offset + info->drop_width == + (JDIMENSION) jdiv_round_up + ((long) info->output_width, (long) info->iMCU_sample_width))) + do_reflect(srcinfo, dstinfo, info->x_crop_offset, + src_coef_arrays, info->drop_width, info->drop_height); + else if (info->crop_width_set == JCROP_FORCE) + do_flatten(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, info->drop_width, info->drop_height); + else + do_wipe(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, info->drop_width, info->drop_height); + break; + case JXFORM_DROP: + if (info->drop_width != 0 && info->drop_height != 0) + do_drop(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, info->drop_ptr, info->drop_coef_arrays, + info->drop_width, info->drop_height); + break; + } +} + +/* jtransform_perfect_transform + * + * Determine whether lossless transformation is perfectly + * possible for a specified image and transformation. + * + * Inputs: + * image_width, image_height: source image dimensions. + * MCU_width, MCU_height: pixel dimensions of MCU. + * transform: transformation identifier. + * Parameter sources from initialized jpeg_struct + * (after reading source header): + * image_width = cinfo.image_width + * image_height = cinfo.image_height + * MCU_width = cinfo.max_h_samp_factor * cinfo.block_size + * MCU_height = cinfo.max_v_samp_factor * cinfo.block_size + * Result: + * TRUE = perfect transformation possible + * FALSE = perfect transformation not possible + * (may use custom action then) + */ + +GLOBAL(boolean) +jtransform_perfect_transform(JDIMENSION image_width, JDIMENSION image_height, + int MCU_width, int MCU_height, + JXFORM_CODE transform) +{ + boolean result = TRUE; /* initialize TRUE */ + + switch (transform) { + case JXFORM_FLIP_H: + case JXFORM_ROT_270: + if (image_width % (JDIMENSION) MCU_width) + result = FALSE; + break; + case JXFORM_FLIP_V: + case JXFORM_ROT_90: + if (image_height % (JDIMENSION) MCU_height) + result = FALSE; + break; + case JXFORM_TRANSVERSE: + case JXFORM_ROT_180: + if (image_width % (JDIMENSION) MCU_width) + result = FALSE; + if (image_height % (JDIMENSION) MCU_height) + result = FALSE; + break; + default: + break; + } + + return result; +} + +#endif /* TRANSFORMS_SUPPORTED */ + + +/* Setup decompression object to save desired markers in memory. + * This must be called before jpeg_read_header() to have the desired effect. + */ + +GLOBAL(void) +jcopy_markers_setup (j_decompress_ptr srcinfo, JCOPY_OPTION option) +{ +#ifdef SAVE_MARKERS_SUPPORTED + int m; + + /* Save comments except under NONE option */ + if (option != JCOPYOPT_NONE) { + jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF); + } + /* Save all types of APPn markers iff ALL option */ + if (option == JCOPYOPT_ALL) { + for (m = 0; m < 16; m++) + jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF); + } +#endif /* SAVE_MARKERS_SUPPORTED */ +} + +/* Copy markers saved in the given source object to the destination object. + * This should be called just after jpeg_start_compress() or + * jpeg_write_coefficients(). + * Note that those routines will have written the SOI, and also the + * JFIF APP0 or Adobe APP14 markers if selected. + */ + +GLOBAL(void) +jcopy_markers_execute (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JCOPY_OPTION option) +{ + jpeg_saved_marker_ptr marker; + + /* In the current implementation, we don't actually need to examine the + * option flag here; we just copy everything that got saved. + * But to avoid confusion, we do not output JFIF and Adobe APP14 markers + * if the encoder library already wrote one. + */ + for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) { + if (dstinfo->write_JFIF_header && + marker->marker == JPEG_APP0 && + marker->data_length >= 5 && + GETJOCTET(marker->data[0]) == 0x4A && + GETJOCTET(marker->data[1]) == 0x46 && + GETJOCTET(marker->data[2]) == 0x49 && + GETJOCTET(marker->data[3]) == 0x46 && + GETJOCTET(marker->data[4]) == 0) + continue; /* reject duplicate JFIF */ + if (dstinfo->write_Adobe_marker && + marker->marker == JPEG_APP0+14 && + marker->data_length >= 5 && + GETJOCTET(marker->data[0]) == 0x41 && + GETJOCTET(marker->data[1]) == 0x64 && + GETJOCTET(marker->data[2]) == 0x6F && + GETJOCTET(marker->data[3]) == 0x62 && + GETJOCTET(marker->data[4]) == 0x65) + continue; /* reject duplicate Adobe */ +#ifdef NEED_FAR_POINTERS + /* We could use jpeg_write_marker if the data weren't FAR... */ + { + unsigned int i; + jpeg_write_m_header(dstinfo, marker->marker, marker->data_length); + for (i = 0; i < marker->data_length; i++) + jpeg_write_m_byte(dstinfo, marker->data[i]); + } +#else + jpeg_write_marker(dstinfo, marker->marker, + marker->data, marker->data_length); +#endif + } +} diff --git a/thirdparty/jpeg-9e/transupp.h b/thirdparty/jpeg-9e/transupp.h new file mode 100644 index 0000000..a8ba16a --- /dev/null +++ b/thirdparty/jpeg-9e/transupp.h @@ -0,0 +1,230 @@ +/* + * transupp.h + * + * Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains declarations for image transformation routines and + * other utility code used by the jpegtran sample application. These are + * NOT part of the core JPEG library. But we keep these routines separate + * from jpegtran.c to ease the task of maintaining jpegtran-like programs + * that have other user interfaces. + * + * NOTE: all the routines declared here have very specific requirements + * about when they are to be executed during the reading and writing of the + * source and destination files. See the comments in transupp.c, or see + * jpegtran.c for an example of correct usage. + */ + +/* If you happen not to want the image transform support, disable it here */ +#ifndef TRANSFORMS_SUPPORTED +#define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ +#endif + +/* + * Although rotating and flipping data expressed as DCT coefficients is not + * hard, there is an asymmetry in the JPEG format specification for images + * whose dimensions aren't multiples of the iMCU size. The right and bottom + * image edges are padded out to the next iMCU boundary with junk data; but + * no padding is possible at the top and left edges. If we were to flip + * the whole image including the pad data, then pad garbage would become + * visible at the top and/or left, and real pixels would disappear into the + * pad margins --- perhaps permanently, since encoders & decoders may not + * bother to preserve DCT blocks that appear to be completely outside the + * nominal image area. So, we have to exclude any partial iMCUs from the + * basic transformation. + * + * Transpose is the only transformation that can handle partial iMCUs at the + * right and bottom edges completely cleanly. flip_h can flip partial iMCUs + * at the bottom, but leaves any partial iMCUs at the right edge untouched. + * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched. + * The other transforms are defined as combinations of these basic transforms + * and process edge blocks in a way that preserves the equivalence. + * + * The "trim" option causes untransformable partial iMCUs to be dropped; + * this is not strictly lossless, but it usually gives the best-looking + * result for odd-size images. Note that when this option is active, + * the expected mathematical equivalences between the transforms may not hold. + * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim + * followed by -rot 180 -trim trims both edges.) + * + * We also offer a lossless-crop option, which discards data outside a given + * image region but losslessly preserves what is inside. Like the rotate and + * flip transforms, lossless crop is restricted by the current JPEG format: the + * upper left corner of the selected region must fall on an iMCU boundary. If + * this does not hold for the given crop parameters, we silently move the upper + * left corner up and/or left to make it so, simultaneously increasing the + * region dimensions to keep the lower right crop corner unchanged. (Thus, the + * output image covers at least the requested region, but may cover more.) + * The adjustment of the region dimensions may be optionally disabled. + * + * A complementary lossless-wipe option is provided to discard (gray out) data + * inside a given image region while losslessly preserving what is outside. + * Another option is lossless-drop, which replaces data at a given image + * position by another image. Both source images must have the same + * subsampling values. It is best if they also have the same quantization, + * otherwise quantization adaption occurs. The trim option can be used with + * the drop option to requantize the drop file to the source file. + * + * We also provide a lossless-resize option, which is kind of a lossless-crop + * operation in the DCT coefficient block domain - it discards higher-order + * coefficients and losslessly preserves lower-order coefficients of a + * sub-block. + * + * Rotate/flip transform, resize, and crop can be requested together in a + * single invocation. The crop is applied last --- that is, the crop region + * is specified in terms of the destination image after transform/resize. + * + * We also offer a "force to grayscale" option, which simply discards the + * chrominance channels of a YCbCr image. This is lossless in the sense that + * the luminance channel is preserved exactly. It's not the same kind of + * thing as the rotate/flip transformations, but it's convenient to handle it + * as part of this package, mainly because the transformation routines have to + * be aware of the option to know how many components to work on. + */ + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jtransform_parse_crop_spec jTrParCrop +#define jtransform_request_workspace jTrRequest +#define jtransform_adjust_parameters jTrAdjust +#define jtransform_execute_transform jTrExec +#define jtransform_perfect_transform jTrPerfect +#define jcopy_markers_setup jCMrkSetup +#define jcopy_markers_execute jCMrkExec +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* + * Codes for supported types of image transformations. + */ + +typedef enum { + JXFORM_NONE, /* no transformation */ + JXFORM_FLIP_H, /* horizontal flip */ + JXFORM_FLIP_V, /* vertical flip */ + JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ + JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ + JXFORM_ROT_90, /* 90-degree clockwise rotation */ + JXFORM_ROT_180, /* 180-degree rotation */ + JXFORM_ROT_270, /* 270-degree clockwise (or 90 ccw) */ + JXFORM_WIPE, /* wipe */ + JXFORM_DROP /* drop */ +} JXFORM_CODE; + +/* + * Codes for crop parameters, which can individually be unspecified, + * positive or negative for xoffset or yoffset, + * positive or force or reflect for width or height. + */ + +typedef enum { + JCROP_UNSET, + JCROP_POS, + JCROP_NEG, + JCROP_FORCE, + JCROP_REFLECT +} JCROP_CODE; + +/* + * Transform parameters struct. + * NB: application must not change any elements of this struct after + * calling jtransform_request_workspace. + */ + +typedef struct { + /* Options: set by caller */ + JXFORM_CODE transform; /* image transform operator */ + boolean perfect; /* if TRUE, fail if partial MCUs are requested */ + boolean trim; /* if TRUE, trim partial MCUs as needed */ + boolean force_grayscale; /* if TRUE, convert color image to grayscale */ + boolean crop; /* if TRUE, crop or wipe source image, or drop */ + + /* Crop parameters: application need not set these unless crop is TRUE. + * These can be filled in by jtransform_parse_crop_spec(). + */ + JDIMENSION crop_width; /* Width of selected region */ + JCROP_CODE crop_width_set; /* (force disables adjustment) */ + JDIMENSION crop_height; /* Height of selected region */ + JCROP_CODE crop_height_set; /* (force disables adjustment) */ + JDIMENSION crop_xoffset; /* X offset of selected region */ + JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */ + JDIMENSION crop_yoffset; /* Y offset of selected region */ + JCROP_CODE crop_yoffset_set; /* (negative measures from bottom edge) */ + + /* Drop parameters: set by caller for drop request */ + j_decompress_ptr drop_ptr; + jvirt_barray_ptr * drop_coef_arrays; + + /* Internal workspace: caller should not touch these */ + int num_components; /* # of components in workspace */ + jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ + JDIMENSION output_width; /* cropped destination dimensions */ + JDIMENSION output_height; + JDIMENSION x_crop_offset; /* destination crop offsets measured in iMCUs */ + JDIMENSION y_crop_offset; + JDIMENSION drop_width; /* drop/wipe dimensions measured in iMCUs */ + JDIMENSION drop_height; + int iMCU_sample_width; /* destination iMCU size */ + int iMCU_sample_height; +} jpeg_transform_info; + + +#if TRANSFORMS_SUPPORTED + +/* Parse a crop specification (written in X11 geometry style) */ +EXTERN(boolean) jtransform_parse_crop_spec + JPP((jpeg_transform_info *info, const char *spec)); +/* Request any required workspace */ +EXTERN(boolean) jtransform_request_workspace + JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info)); +/* Adjust output image parameters */ +EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters + JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info)); +/* Execute the actual transformation, if any */ +EXTERN(void) jtransform_execute_transform + JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + jvirt_barray_ptr *src_coef_arrays, + jpeg_transform_info *info)); +/* Determine whether lossless transformation is perfectly + * possible for a specified image and transformation. + */ +EXTERN(boolean) jtransform_perfect_transform + JPP((JDIMENSION image_width, JDIMENSION image_height, + int MCU_width, int MCU_height, + JXFORM_CODE transform)); + +/* jtransform_execute_transform used to be called + * jtransform_execute_transformation, but some compilers complain about + * routine names that long. This macro is here to avoid breaking any + * old source code that uses the original name... + */ +#define jtransform_execute_transformation jtransform_execute_transform + +#endif /* TRANSFORMS_SUPPORTED */ + + +/* + * Support for copying optional markers from source to destination file. + */ + +typedef enum { + JCOPYOPT_NONE, /* copy no optional markers */ + JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */ + JCOPYOPT_ALL /* copy all optional markers */ +} JCOPY_OPTION; + +#define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */ + +/* Setup decompression object to save desired markers in memory */ +EXTERN(void) jcopy_markers_setup + JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option)); +/* Copy markers saved in the given source object to the destination object */ +EXTERN(void) jcopy_markers_execute + JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, + JCOPY_OPTION option)); diff --git a/thirdparty/jpeg-9e/usage.txt b/thirdparty/jpeg-9e/usage.txt new file mode 100644 index 0000000..b20484b --- /dev/null +++ b/thirdparty/jpeg-9e/usage.txt @@ -0,0 +1,709 @@ +USAGE instructions for the Independent JPEG Group's JPEG software +================================================================= + +This file describes usage of the JPEG conversion programs cjpeg and djpeg, +as well as the utility programs jpegtran, rdjpgcom and wrjpgcom. (See +the other documentation files if you wish to use the JPEG library within +your own programs.) + +If you are on a Unix machine you may prefer to read the Unix-style manual +pages in files cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1. + + +INTRODUCTION + +These programs implement JPEG image encoding, decoding, and transcoding. +JPEG (pronounced "jay-peg") is a standardized compression method for +full-color and grayscale images. + + +GENERAL USAGE + +We provide two programs, cjpeg to compress an image file into JPEG format, +and djpeg to decompress a JPEG file back into a conventional image format. + +On Unix-like systems, you say: + cjpeg [switches] [imagefile] >jpegfile +or + djpeg [switches] [jpegfile] >imagefile +The programs read the specified input file, or standard input if none is +named. They always write to standard output (with trace/error messages to +standard error). These conventions are handy for piping images between +programs. + +On most non-Unix systems, you say: + cjpeg [switches] imagefile jpegfile +or + djpeg [switches] jpegfile imagefile +i.e., both the input and output files are named on the command line. This +style is a little more foolproof, and it loses no functionality if you don't +have pipes. (You can get this style on Unix too, if you prefer, by defining +TWO_FILE_COMMANDLINE when you compile the programs; see install.txt.) + +You can also say: + cjpeg [switches] -outfile jpegfile imagefile +or + djpeg [switches] -outfile imagefile jpegfile +This syntax works on all systems, so it is useful for scripts. + +The currently supported image file formats are: PPM (PBMPLUS color format), +PGM (PBMPLUS grayscale format), BMP, GIF, Targa, and RLE (Utah Raster Toolkit +format). (RLE is supported only if the URT library is available, which it +isn't on most non-Unix systems.) cjpeg recognizes the input image format +automatically, with the exception of some Targa-format files. You have to +tell djpeg which format to generate. + +JPEG files are in the standard JFIF file format. There are other, +less widely used JPEG-based file formats, but we don't support them. + +All switch names may be abbreviated; for example, -grayscale may be written +-gray or -gr. Most of the "basic" switches can be abbreviated to as little as +one letter. Upper and lower case are equivalent (-BMP is the same as -bmp). +British spellings are also accepted (e.g., -greyscale), though for brevity +these are not mentioned below. + + +CJPEG DETAILS + +The basic command line switches for cjpeg are: + + -quality N[,...] Scale quantization tables to adjust image quality. + Quality is 0 (worst) to 100 (best); default is 75. + (See below for more info.) + + -grayscale Create monochrome JPEG file from color input. + Be sure to use this switch when compressing a grayscale + BMP or GIF file, because cjpeg isn't bright enough to + notice whether a BMP or GIF file uses only shades of + gray. By saying -grayscale, you'll get a smaller + JPEG file that takes less time to process. + + -rgb Create RGB JPEG file. + Using this switch suppresses the conversion from RGB + colorspace input to the default YCbCr JPEG colorspace. + You can use this switch in combination with the + -block N switch (see below) for lossless JPEG coding. + See also the -rgb1 switch below. + + -optimize Perform optimization of entropy encoding parameters. + Without this, default encoding parameters are used. + -optimize usually makes the JPEG file a little smaller, + but cjpeg runs somewhat slower and needs much more + memory. Image quality and speed of decompression are + unaffected by -optimize. + + -progressive Create progressive JPEG file (see below). + + -scale M/N Scale the output image by a factor M/N. Currently + supported scale factors are M/N with all N from 1 to + 16, where M is the destination DCT size, which is 8 by + default (see -block N switch below). + + -targa Input file is Targa format. Targa files that contain + an "identification" field will not be automatically + recognized by cjpeg; for such files you must specify + -targa to make cjpeg treat the input as Targa format. + For most Targa files, you won't need this switch. + +The -quality switch lets you trade off compressed file size against quality of +the reconstructed image: the higher the quality setting, the larger the JPEG +file, and the closer the output image will be to the original input. Normally +you want to use the lowest quality setting (smallest file) that decompresses +into something visually indistinguishable from the original image. For this +purpose the quality setting should be between 50 and 95; the default of 75 is +often about right. If you see defects at -quality 75, then go up 5 or 10 +counts at a time until you are happy with the output image. (The optimal +setting will vary from one image to another.) + +-quality 100 will generate a quantization table of all 1's, minimizing loss +in the quantization step (but there is still information loss in subsampling, +as well as roundoff error). This setting is mainly of interest for +experimental purposes. Quality values above about 95 are NOT recommended for +normal use; the compressed file size goes up dramatically for hardly any gain +in output image quality. + +In the other direction, quality values below 50 will produce very small files +of low image quality. Settings around 5 to 10 might be useful in preparing an +index of a large image library, for example. Try -quality 2 (or so) for some +amusing Cubist effects. (Note: quality values below about 25 generate 2-byte +quantization tables, which are considered optional in the JPEG standard. +cjpeg emits a warning message when you give such a quality value, because some +other JPEG programs may be unable to decode the resulting file. Use -baseline +if you need to ensure compatibility at low quality values.) + +The -quality option has been extended in IJG version 7 for support of separate +quality settings for luminance and chrominance (or in general, for every +provided quantization table slot). This feature is useful for high-quality +applications which cannot accept the damage of color data by coarse +subsampling settings. You can now easily reduce the color data amount more +smoothly with finer control without separate subsampling. The resulting file +is fully compliant with standard JPEG decoders. +Note that the -quality ratings refer to the quantization table slots, and that +the last value is replicated if there are more q-table slots than parameters. +The default q-table slots are 0 for luminance and 1 for chrominance with +default tables as given in the JPEG standard. This is compatible with the old +behaviour in case that only one parameter is given, which is then used for +both luminance and chrominance (slots 0 and 1). More or custom quantization +tables can be set with -qtables and assigned to components with -qslots +parameter (see the "wizard" switches below). +CAUTION: You must explicitly add -sample 1x1 for efficient separate color +quality selection, since the default value used by library is 2x2! + +The -progressive switch creates a "progressive JPEG" file. In this type of +JPEG file, the data is stored in multiple scans of increasing quality. If the +file is being transmitted over a slow communications link, the decoder can use +the first scan to display a low-quality image very quickly, and can then +improve the display with each subsequent scan. The final image is exactly +equivalent to a standard JPEG file of the same quality setting, and the total +file size is about the same --- often a little smaller. + +Switches for advanced users: + + -arithmetic Use arithmetic coding. + CAUTION: arithmetic coded JPEG is not yet widely + implemented, so many decoders will be unable to + view an arithmetic coded JPEG file at all. + + -block N Set DCT block size. All N from 1 to 16 are possible. + Default is 8 (baseline format). + Larger values produce higher compression, + smaller values produce higher quality + (exact DCT stage possible with 1 or 2; with the + default quality of 75 and default Luminance qtable + the DCT+Quantization stage is lossless for N=1). + CAUTION: An implementation of the JPEG SmartScale + extension is required for this feature. SmartScale + enabled JPEG is not yet widely implemented, so many + decoders will be unable to view a SmartScale extended + JPEG file at all. + + -rgb1 Create RGB JPEG file with reversible color transform. + Works like the -rgb switch (see above) and inserts a + simple reversible color transform into the processing + which significantly improves the compression. + Use this switch in combination with the -block N + switch (see above) for lossless JPEG coding. + CAUTION: A decoder with inverse color transform + support is required for this feature. Reversible + color transform support is not yet widely implemented, + so many decoders will be unable to view a reversible + color transformed JPEG file at all. + + -bgycc Create big gamut YCC JPEG file. + In this type of encoding the color difference + components are quantized further by a factor of 2 + compared to the normal Cb/Cr values, thus creating + space to allow larger color values with higher + saturation than the normal gamut limits to be encoded. + In order to compensate for the loss of color fidelity + compared to a normal YCC encoded file, the color + quantization tables can be adjusted accordingly. + For example, cjpeg -bgycc -quality 80,90 will give + similar results as cjpeg -quality 80. + CAUTION: For correct decompression a decoder with big + gamut YCC support (JFIF version 2) is required. + An old decoder may or may not display a big gamut YCC + encoded JPEG file, depending on JFIF version check + and corresponding warning/error configuration. + In case of a granted decompression the old decoder + will display the image with half saturated colors. + + -dct int Use integer DCT method (default). + -dct fast Use fast integer DCT (less accurate). + -dct float Use floating-point DCT method. + The float method is very slightly more accurate than + the int method, but is much slower unless your machine + has very fast floating-point hardware. Also note that + results of the floating-point method may vary slightly + across machines, while the integer methods should give + the same results everywhere. The fast integer method + is much less accurate than the other two. + + -nosmooth Don't use high-quality downsampling. + + -restart N Emit a JPEG restart marker every N MCU rows, or every + N MCU blocks if "B" is attached to the number. + -restart 0 (the default) means no restart markers. + + -smooth N Smooth the input image to eliminate dithering noise. + N, ranging from 1 to 100, indicates the strength of + smoothing. 0 (the default) means no smoothing. + + -maxmemory N Set limit for amount of memory to use in processing + large images. Value is in thousands of bytes, or + millions of bytes if "M" is attached to the number. + For example, -max 4m selects 4000000 bytes. If more + space is needed, temporary files will be used. + + -verbose Enable debug printout. More -v's give more printout. + or -debug Also, version information is printed at startup. + +The -restart option inserts extra markers that allow a JPEG decoder to +resynchronize after a transmission error. Without restart markers, any damage +to a compressed file will usually ruin the image from the point of the error +to the end of the image; with restart markers, the damage is usually confined +to the portion of the image up to the next restart marker. Of course, the +restart markers occupy extra space. We recommend -restart 1 for images that +will be transmitted across unreliable networks such as Usenet. + +The -smooth option filters the input to eliminate fine-scale noise. This is +often useful when converting dithered images to JPEG: a moderate smoothing +factor of 10 to 50 gets rid of dithering patterns in the input file, resulting +in a smaller JPEG file and a better-looking image. Too large a smoothing +factor will visibly blur the image, however. + +Switches for wizards: + + -baseline Force baseline-compatible quantization tables to be + generated. This clamps quantization values to 8 bits + even at low quality settings. (This switch is poorly + named, since it does not ensure that the output is + actually baseline JPEG. For example, you can use + -baseline and -progressive together.) + + -qtables file Use the quantization tables given in the specified + text file. + + -qslots N[,...] Select which quantization table to use for each color + component. + + -sample HxV[,...] Set JPEG sampling factors for each color component. + + -scans file Use the scan script given in the specified text file. + +The "wizard" switches are intended for experimentation with JPEG. If you +don't know what you are doing, DON'T USE THEM. These switches are documented +further in the file wizard.txt. + + +DJPEG DETAILS + +The basic command line switches for djpeg are: + + -colors N Reduce image to at most N colors. This reduces the + or -quantize N number of colors used in the output image, so that it + can be displayed on a colormapped display or stored in + a colormapped file format. For example, if you have + an 8-bit display, you'd need to reduce to 256 or fewer + colors. (-colors is the recommended name, -quantize + is provided only for backwards compatibility.) + + -fast Select recommended processing options for fast, low + quality output. (The default options are chosen for + highest quality output.) Currently, this is equivalent + to "-dct fast -nosmooth -onepass -dither ordered". + + -grayscale Force grayscale output even if JPEG file is color. + Useful for viewing on monochrome displays; also, + djpeg runs noticeably faster in this mode. + + -rgb Force RGB output even if JPEG file is grayscale. + This is provided to support applications that don't + want to cope with grayscale as a separate case. + + -scale M/N Scale the output image by a factor M/N. Currently + supported scale factors are M/N with all M from 1 to + 16, where N is the source DCT size, which is 8 for + baseline JPEG. If the /N part is omitted, then M + specifies the DCT scaled size to be applied on the + given input. For baseline JPEG this is equivalent to + M/8 scaling, since the source DCT size for baseline + JPEG is 8. Scaling is handy if the image is larger + than your screen; also, djpeg runs much faster when + scaling down the output. + + -bmp Select BMP output format (Windows flavor). 8-bit + colormapped format is emitted if -colors or -grayscale + is specified, or if the JPEG file is grayscale; + otherwise, 24-bit full-color format is emitted. + + -gif Select GIF output format (LZW compressed). + Since GIF does not support more than 256 colors, + -colors 256 is assumed (unless you specify a smaller + number of colors). If you specify -fast, the default + number of colors is 216. + + -gif0 Select GIF output format (uncompressed). + Since GIF does not support more than 256 colors, + -colors 256 is assumed (unless you specify a smaller + number of colors). If you specify -fast, the default + number of colors is 216. + + -os2 Select BMP output format (OS/2 1.x flavor). 8-bit + colormapped format is emitted if -colors or -grayscale + is specified, or if the JPEG file is grayscale; + otherwise, 24-bit full-color format is emitted. + + -pnm Select PBMPLUS (PPM/PGM) output format (this is the + default format). PGM is emitted if the JPEG file is + grayscale or if -grayscale is specified; otherwise + PPM is emitted. + + -rle Select RLE output format. (Requires URT library.) + + -targa Select Targa output format. Grayscale format is + emitted if the JPEG file is grayscale or if + -grayscale is specified; otherwise, colormapped format + is emitted if -colors is specified; otherwise, 24-bit + full-color format is emitted. + +Switches for advanced users: + + -dct int Use integer DCT method (default). + -dct fast Use fast integer DCT (less accurate). + -dct float Use floating-point DCT method. + The float method is very slightly more accurate than + the int method, but is much slower unless your machine + has very fast floating-point hardware. Also note that + results of the floating-point method may vary slightly + across machines, while the integer methods should give + the same results everywhere. The fast integer method + is much less accurate than the other two. + + -dither fs Use Floyd-Steinberg dithering in color quantization. + -dither ordered Use ordered dithering in color quantization. + -dither none Do not use dithering in color quantization. + By default, Floyd-Steinberg dithering is applied when + quantizing colors; this is slow but usually produces + the best results. Ordered dither is a compromise + between speed and quality; no dithering is fast but + usually looks awful. Note that these switches have + no effect unless color quantization is being done. + Ordered dither is only available in -onepass mode. + + -map FILE Quantize to the colors used in the specified image + file. This is useful for producing multiple files + with identical color maps, or for forcing a predefined + set of colors to be used. The FILE must be a GIF + or PPM file. This option overrides -colors and + -onepass. + + -nosmooth Don't use high-quality upsampling. + + -onepass Use one-pass instead of two-pass color quantization. + The one-pass method is faster and needs less memory, + but it produces a lower-quality image. -onepass is + ignored unless you also say -colors N. Also, + the one-pass method is always used for grayscale + output (the two-pass method is no improvement then). + + -maxmemory N Set limit for amount of memory to use in processing + large images. Value is in thousands of bytes, or + millions of bytes if "M" is attached to the number. + For example, -max 4m selects 4000000 bytes. If more + space is needed, temporary files will be used. + + -verbose Enable debug printout. More -v's give more printout. + or -debug Also, version information is printed at startup. + + +HINTS FOR CJPEG + +Color GIF files are not the ideal input for JPEG; JPEG is really intended for +compressing full-color (24-bit) images. In particular, don't try to convert +cartoons, line drawings, and other images that have only a few distinct +colors. GIF works great on these, JPEG does not. If you want to convert a +GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options +to get a satisfactory conversion. -smooth 10 or so is often helpful. + +Avoid running an image through a series of JPEG compression/decompression +cycles. Image quality loss will accumulate; after ten or so cycles the image +may be noticeably worse than it was after one cycle. It's best to use a +lossless format while manipulating an image, then convert to JPEG format when +you are ready to file the image away. + +The -optimize option to cjpeg is worth using when you are making a "final" +version for posting or archiving. It's also a win when you are using low +quality settings to make very small JPEG files; the percentage improvement +is often a lot more than it is on larger files. (At present, -optimize +mode is always selected when generating progressive JPEG files.) + + +HINTS FOR DJPEG + +To get a quick preview of an image, use the -grayscale and/or -scale switches. +"-grayscale -scale 1/8" is the fastest case. + +Several options are available that trade off image quality to gain speed. +"-fast" turns on the recommended settings. + +"-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality. +When producing a color-quantized image, "-onepass -dither ordered" is fast but +much lower quality than the default behavior. "-dither none" may give +acceptable results in two-pass mode, but is seldom tolerable in one-pass mode. + +If you are fortunate enough to have very fast floating point hardware, +"-dct float" may be even faster than "-dct fast". But on most machines +"-dct float" is slower than "-dct int"; in this case it is not worth using, +because its theoretical accuracy advantage is too small to be significant +in practice. + +Two-pass color quantization requires a good deal of memory; on MS-DOS machines +it may run out of memory even with -maxmemory 0. In that case you can still +decompress, with some loss of image quality, by specifying -onepass for +one-pass quantization. + + +HINTS FOR BOTH PROGRAMS + +If more space is needed than will fit in the available main memory (as +determined by -maxmemory), temporary files will be used. (MS-DOS versions +will try to get extended or expanded memory first.) The temporary files are +often rather large: in typical cases they occupy three bytes per pixel, for +example 3*800*600 = 1.44Mb for an 800x600 image. If you don't have enough +free disk space, leave out -progressive and -optimize (for cjpeg) or specify +-onepass (for djpeg). + +On MS-DOS, the temporary files are created in the directory named by the TMP +or TEMP environment variable, or in the current directory if neither of those +exist. Amiga implementations put the temp files in the directory named by +JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free +space. + +The default memory usage limit (-maxmemory) is set when the software is +compiled. If you get an "insufficient memory" error, try specifying a smaller +-maxmemory value, even -maxmemory 0 to use the absolute minimum space. You +may want to recompile with a smaller default value if this happens often. + +On machines that have "environment" variables, you can define the environment +variable JPEGMEM to set the default memory limit. The value is specified as +described for the -maxmemory switch. JPEGMEM overrides the default value +specified when the program was compiled, and itself is overridden by an +explicit -maxmemory switch. + +On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to +use. (Extended or expanded memory is also used if available.) Most +DOS-specific versions of this software do their own memory space estimation +and do not need you to specify -maxmemory. + + +JPEGTRAN + +jpegtran performs various useful transformations of JPEG files. +It can translate the coded representation from one variant of JPEG to another, +for example from baseline JPEG to progressive JPEG or vice versa. It can also +perform some rearrangements of the image data, for example turning an image +from landscape to portrait format by rotation. For EXIF files and JPEG files +containing Exif data, you may prefer to use exiftran instead. + +jpegtran works by rearranging the compressed data (DCT coefficients), without +ever fully decoding the image. Therefore, its transformations are lossless: +there is no image degradation at all, which would not be true if you used +djpeg followed by cjpeg to accomplish the same conversion. But by the same +token, jpegtran cannot perform lossy operations such as changing the image +quality. However, while the image data is losslessly transformed, metadata +can be removed. See the -copy option for specifics. + +jpegtran uses a command line syntax similar to cjpeg or djpeg. +On Unix-like systems, you say: + jpegtran [switches] [inputfile] >outputfile +On most non-Unix systems, you say: + jpegtran [switches] inputfile outputfile +where both the input and output files are JPEG files. + +To specify the coded JPEG representation used in the output file, +jpegtran accepts a subset of the switches recognized by cjpeg: + -optimize Perform optimization of entropy encoding parameters. + -progressive Create progressive JPEG file. + -arithmetic Use arithmetic coding. + -restart N Emit a JPEG restart marker every N MCU rows, or every + N MCU blocks if "B" is attached to the number. + -scans file Use the scan script given in the specified text file. +See the previous discussion of cjpeg for more details about these switches. +If you specify none of these switches, you get a plain baseline-JPEG output +file. The quality setting and so forth are determined by the input file. + +The image can be losslessly transformed by giving one of these switches: + -flip horizontal Mirror image horizontally (left-right). + -flip vertical Mirror image vertically (top-bottom). + -rotate 90 Rotate image 90 degrees clockwise. + -rotate 180 Rotate image 180 degrees. + -rotate 270 Rotate image 270 degrees clockwise (or 90 ccw). + -transpose Transpose image (across UL-to-LR axis). + -transverse Transverse transpose (across UR-to-LL axis). + +The transpose transformation has no restrictions regarding image dimensions. +The other transformations operate rather oddly if the image dimensions are not +a multiple of the iMCU size (usually 8 or 16 pixels), because they can only +transform complete blocks of DCT coefficient data in the desired way. + +jpegtran's default behavior when transforming an odd-size image is designed +to preserve exact reversibility and mathematical consistency of the +transformation set. As stated, transpose is able to flip the entire image +area. Horizontal mirroring leaves any partial iMCU column at the right edge +untouched, but is able to flip all rows of the image. Similarly, vertical +mirroring leaves any partial iMCU row at the bottom edge untouched, but is +able to flip all columns. The other transforms can be built up as sequences +of transpose and flip operations; for consistency, their actions on edge +pixels are defined to be the same as the end result of the corresponding +transpose-and-flip sequence. + +For practical use, you may prefer to discard any untransformable edge pixels +rather than having a strange-looking strip along the right and/or bottom edges +of a transformed image. To do this, add the -trim switch: + -trim Drop non-transformable edge blocks. +Obviously, a transformation with -trim is not reversible, so strictly speaking +jpegtran with this switch is not lossless. Also, the expected mathematical +equivalences between the transformations no longer hold. For example, +"-rot 270 -trim" trims only the bottom edge, but "-rot 90 -trim" followed by +"-rot 180 -trim" trims both edges. + +If you are only interested in perfect transformation, add the -perfect switch: + -perfect Fails with an error if the transformation is not + perfect. +For example you may want to do + jpegtran -rot 90 -perfect foo.jpg || djpeg foo.jpg | pnmflip -r90 | cjpeg +to do a perfect rotation if available or an approximated one if not. + +We also offer a lossless-crop option, which discards data outside a given +image region but losslessly preserves what is inside. Like the rotate and +flip transforms, lossless crop is restricted by the current JPEG format: the +upper left corner of the selected region must fall on an iMCU boundary. If +this does not hold for the given crop parameters, we silently move the upper +left corner up and/or left to make it so, simultaneously increasing the +region dimensions to keep the lower right crop corner unchanged. (Thus, the +output image covers at least the requested region, but may cover more.) +The adjustment of the region dimensions may be optionally disabled by +attaching an 'f' character ("force") to the width or height number. + +The image can be losslessly cropped by giving the switch: + -crop WxH+X+Y Crop to a rectangular subarea of width W, height H + starting at point X,Y. + +Crop extension: The width or height parameters can be made larger than the +source image. In this case the extra area is filled in with zero (neutral +gray). A larger width parameter has two more options: Attaching an 'f' +character ("flatten") to the width number will fill in the extra area with +the DC of the adjacent block, instead of gray out. Attaching an 'r' +character ("reflect") to the width number will fill in the extra area with +repeated reflections of the source region, instead of gray out. + +A complementary lossless-wipe option is provided to discard (gray out) data +inside a given image region while losslessly preserving what is outside: + -wipe WxH+X+Y Wipe (gray out) a rectangular subarea of + width W, height H starting at point X,Y. + +Attaching an 'f' character ("flatten") to the width number will fill the +region with the average of adjacent blocks, instead of gray out. In case +the wipe region and outside area form two horizontally adjacent rectangles, +attaching an 'r' character ("reflect") to the width number will fill the +region with repeated reflections of the outside area, instead of gray out. + +Another option is lossless-drop, which replaces data at a given image +position by another image: + -drop +X+Y filename Drop another image + +Both source images must have the same subsampling values. It is best if +they also have the same quantization, otherwise quantization adaption occurs. +The trim option can be used with the drop option to requantize the drop file +to the source file. + +Other not-strictly-lossless transformation switches are: + + -grayscale Force grayscale output. +This option discards the chrominance channels if the input image is YCbCr +(ie, a standard color JPEG), resulting in a grayscale JPEG file. The +luminance channel is preserved exactly, so this is a better method of reducing +to grayscale than decompression, conversion, and recompression. This switch +is particularly handy for fixing a monochrome picture that was mistakenly +encoded as a color JPEG. (In such a case, the space savings from getting rid +of the near-empty chroma channels won't be large; but the decoding time for +a grayscale JPEG is substantially less than that for a color JPEG.) + + -scale M/N Scale the output image by a factor M/N. +Currently supported scale factors are M/N with all M from 1 to 16, where N is +the source DCT size, which is 8 for baseline JPEG. If the /N part is omitted, +then M specifies the DCT scaled size to be applied on the given input. For +baseline JPEG this is equivalent to M/8 scaling, since the source DCT size +for baseline JPEG is 8. CAUTION: An implementation of the JPEG SmartScale +extension is required for this feature. SmartScale enabled JPEG is not yet +widely implemented, so many decoders will be unable to view a SmartScale +extended JPEG file at all. + +jpegtran also recognizes these switches that control what to do with "extra" +markers, such as comment blocks: + -copy none Copy no extra markers from source file. + This setting suppresses all comments + and other metadata in the source file. + -copy comments Copy only comment markers. + This setting copies comments from the source file, + but discards any other metadata. + -copy all Copy all extra markers. This setting preserves + metadata found in the source file, such as JFIF + thumbnails, Exif data, and Photoshop settings. + In some files these extra markers can be sizable. + Note that this option will copy thumbnails as-is; + they will not be transformed. +The default behavior is -copy comments. (Note: in IJG releases v6 and v6a, +jpegtran always did the equivalent of -copy none.) + +Additional switches recognized by jpegtran are: + -outfile filename + -maxmemory N + -verbose + -debug +These work the same as in cjpeg or djpeg. + + +THE COMMENT UTILITIES + +The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. +Although the standard doesn't actually define what COM blocks are for, they +are widely used to hold user-supplied text strings. This lets you add +annotations, titles, index terms, etc to your JPEG files, and later retrieve +them as text. COM blocks do not interfere with the image stored in the JPEG +file. The maximum size of a COM block is 64K, but you can have as many of +them as you like in one JPEG file. + +We provide two utility programs to display COM block contents and add COM +blocks to a JPEG file. + +rdjpgcom searches a JPEG file and prints the contents of any COM blocks on +standard output. The command line syntax is + rdjpgcom [-raw] [-verbose] [inputfilename] +The switch "-raw" (or just "-r") causes rdjpgcom to also output non-printable +characters in comments, which are normally escaped for security reasons. +The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG +image dimensions. If you omit the input file name from the command line, +the JPEG file is read from standard input. (This may not work on some +operating systems, if binary data can't be read from stdin.) + +wrjpgcom adds a COM block, containing text you provide, to a JPEG file. +Ordinarily, the COM block is added after any existing COM blocks, but you +can delete the old COM blocks if you wish. wrjpgcom produces a new JPEG +file; it does not modify the input file. DO NOT try to overwrite the input +file by directing wrjpgcom's output back into it; on most systems this will +just destroy your file. + +The command line syntax for wrjpgcom is similar to cjpeg's. On Unix-like +systems, it is + wrjpgcom [switches] [inputfilename] +The output file is written to standard output. The input file comes from +the named file, or from standard input if no input file is named. + +On most non-Unix systems, the syntax is + wrjpgcom [switches] inputfilename outputfilename +where both input and output file names must be given explicitly. + +wrjpgcom understands three switches: + -replace Delete any existing COM blocks from the file. + -comment "Comment text" Supply new COM text on command line. + -cfile name Read text for new COM block from named file. +(Switch names can be abbreviated.) If you have only one line of comment text +to add, you can provide it on the command line with -comment. The comment +text must be surrounded with quotes so that it is treated as a single +argument. Longer comments can be read from a text file. + +If you give neither -comment nor -cfile, then wrjpgcom will read the comment +text from standard input. (In this case an input image file name MUST be +supplied, so that the source JPEG file comes from somewhere else.) You can +enter multiple lines, up to 64KB worth. Type an end-of-file indicator +(usually control-D or control-Z) to terminate the comment text entry. + +wrjpgcom will not add a COM block if the provided comment string is empty. +Therefore -replace -comment "" can be used to delete all COM blocks from a +file. + +These utility programs do not depend on the IJG JPEG library. In +particular, the source code for rdjpgcom is intended as an illustration of +the minimum amount of code required to parse a JPEG file header correctly. diff --git a/thirdparty/jpeg-9e/wizard.txt b/thirdparty/jpeg-9e/wizard.txt new file mode 100644 index 0000000..54170b2 --- /dev/null +++ b/thirdparty/jpeg-9e/wizard.txt @@ -0,0 +1,211 @@ +Advanced usage instructions for the Independent JPEG Group's JPEG software +========================================================================== + +This file describes cjpeg's "switches for wizards". + +The "wizard" switches are intended for experimentation with JPEG by persons +who are reasonably knowledgeable about the JPEG standard. If you don't know +what you are doing, DON'T USE THESE SWITCHES. You'll likely produce files +with worse image quality and/or poorer compression than you'd get from the +default settings. Furthermore, these switches must be used with caution +when making files intended for general use, because not all JPEG decoders +will support unusual JPEG parameter settings. + + +Quantization Table Adjustment +----------------------------- + +Ordinarily, cjpeg starts with a default set of tables (the same ones given +as examples in the JPEG standard) and scales them up or down according to +the -quality setting. The details of the scaling algorithm can be found in +jcparam.c. At very low quality settings, some quantization table entries +can get scaled up to values exceeding 255. Although 2-byte quantization +values are supported by the IJG software, this feature is not in baseline +JPEG and is not supported by all implementations. If you need to ensure +wide compatibility of low-quality files, you can constrain the scaled +quantization values to no more than 255 by giving the -baseline switch. +Note that use of -baseline will result in poorer quality for the same file +size, since more bits than necessary are expended on higher AC coefficients. + +You can substitute a different set of quantization values by using the +-qtables switch: + + -qtables file Use the quantization tables given in the named file. + +The specified file should be a text file containing decimal quantization +values. The file should contain one to four tables, each of 64 elements. +The tables are implicitly numbered 0,1,etc. in order of appearance. Table +entries appear in normal array order (NOT in the zigzag order in which they +will be stored in the JPEG file). + +Quantization table files are free format, in that arbitrary whitespace can +appear between numbers. Also, comments can be included: a comment starts +with '#' and extends to the end of the line. Here is an example file that +duplicates the default quantization tables: + + # Quantization tables given in JPEG spec, section K.1 + + # This is table 0 (the luminance table): + 16 11 10 16 24 40 51 61 + 12 12 14 19 26 58 60 55 + 14 13 16 24 40 57 69 56 + 14 17 22 29 51 87 80 62 + 18 22 37 56 68 109 103 77 + 24 35 55 64 81 104 113 92 + 49 64 78 87 103 121 120 101 + 72 92 95 98 112 100 103 99 + + # This is table 1 (the chrominance table): + 17 18 24 47 99 99 99 99 + 18 21 26 66 99 99 99 99 + 24 26 56 99 99 99 99 99 + 47 66 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + +If the -qtables switch is used without -quality, then the specified tables +are used exactly as-is. If both -qtables and -quality are used, then the +tables taken from the file are scaled in the same fashion that the default +tables would be scaled for that quality setting. If -baseline appears, then +the quantization values are constrained to the range 1-255. + +By default, cjpeg will use quantization table 0 for luminance components and +table 1 for chrominance components. To override this choice, use the -qslots +switch: + + -qslots N[,...] Select which quantization table to use for + each color component. + +The -qslots switch specifies a quantization table number for each color +component, in the order in which the components appear in the JPEG SOF marker. +For example, to create a separate table for each of Y,Cb,Cr, you could +provide a -qtables file that defines three quantization tables and say +"-qslots 0,1,2". If -qslots gives fewer table numbers than there are color +components, then the last table number is repeated as necessary. + + +Sampling Factor Adjustment +-------------------------- + +By default, cjpeg uses 2:1 horizontal and vertical downsampling when +compressing YCbCr data, and no downsampling for all other color spaces. +You can override this default with the -sample switch: + + -sample HxV[,...] Set JPEG sampling factors for each color + component. + +The -sample switch specifies the JPEG sampling factors for each color +component, in the order in which they appear in the JPEG SOF marker. +If you specify fewer HxV pairs than there are components, the remaining +components are set to 1x1 sampling. For example, the default YCbCr setting +is equivalent to "-sample 2x2,1x1,1x1", which can be abbreviated to +"-sample 2x2". + +There are still some JPEG decoders in existence that support only 2x1 +sampling (also called 4:2:2 sampling). Compatibility with such decoders can +be achieved by specifying "-sample 2x1". This is not recommended unless +really necessary, since it increases file size and encoding/decoding time +with very little quality gain. + + +Multiple Scan / Progression Control +----------------------------------- + +By default, cjpeg emits a single-scan sequential JPEG file. The +-progressive switch generates a progressive JPEG file using a default series +of progression parameters. You can create multiple-scan sequential JPEG +files or progressive JPEG files with custom progression parameters by using +the -scans switch: + + -scans file Use the scan sequence given in the named file. + +The specified file should be a text file containing a "scan script". +The script specifies the contents and ordering of the scans to be emitted. +Each entry in the script defines one scan. A scan definition specifies +the components to be included in the scan, and for progressive JPEG it also +specifies the progression parameters Ss,Se,Ah,Al for the scan. Scan +definitions are separated by semicolons (';'). A semicolon after the last +scan definition is optional. + +Each scan definition contains one to four component indexes, optionally +followed by a colon (':') and the four progressive-JPEG parameters. The +component indexes denote which color component(s) are to be transmitted in +the scan. Components are numbered in the order in which they appear in the +JPEG SOF marker, with the first component being numbered 0. (Note that these +indexes are not the "component ID" codes assigned to the components, just +positional indexes.) + +The progression parameters for each scan are: + Ss Zigzag index of first coefficient included in scan + Se Zigzag index of last coefficient included in scan + Ah Zero for first scan of a coefficient, else Al of prior scan + Al Successive approximation low bit position for scan +If the progression parameters are omitted, the values 0,63,0,0 are used, +producing a sequential JPEG file. cjpeg automatically determines whether +the script represents a progressive or sequential file, by observing whether +Ss and Se values other than 0 and 63 appear. (The -progressive switch is +not needed to specify this; in fact, it is ignored when -scans appears.) +The scan script must meet the JPEG restrictions on progression sequences. +(cjpeg checks that the spec's requirements are obeyed.) + +Scan script files are free format, in that arbitrary whitespace can appear +between numbers and around punctuation. Also, comments can be included: a +comment starts with '#' and extends to the end of the line. For additional +legibility, commas or dashes can be placed between values. (Actually, any +single punctuation character other than ':' or ';' can be inserted.) For +example, the following two scan definitions are equivalent: + 0 1 2: 0 63 0 0; + 0,1,2 : 0-63, 0,0 ; + +Here is an example of a scan script that generates a partially interleaved +sequential JPEG file: + + 0; # Y only in first scan + 1 2; # Cb and Cr in second scan + +Here is an example of a progressive scan script using only spectral selection +(no successive approximation): + + # Interleaved DC scan for Y,Cb,Cr: + 0,1,2: 0-0, 0, 0 ; + # AC scans: + 0: 1-2, 0, 0 ; # First two Y AC coefficients + 0: 3-5, 0, 0 ; # Three more + 1: 1-63, 0, 0 ; # All AC coefficients for Cb + 2: 1-63, 0, 0 ; # All AC coefficients for Cr + 0: 6-9, 0, 0 ; # More Y coefficients + 0: 10-63, 0, 0 ; # Remaining Y coefficients + +Here is an example of a successive-approximation script. This is equivalent +to the default script used by "cjpeg -progressive" for YCbCr images: + + # Initial DC scan for Y,Cb,Cr (lowest bit not sent) + 0,1,2: 0-0, 0, 1 ; + # First AC scan: send first 5 Y AC coefficients, minus 2 lowest bits: + 0: 1-5, 0, 2 ; + # Send all Cr,Cb AC coefficients, minus lowest bit: + # (chroma data is usually too small to be worth subdividing further; + # but note we send Cr first since eye is least sensitive to Cb) + 2: 1-63, 0, 1 ; + 1: 1-63, 0, 1 ; + # Send remaining Y AC coefficients, minus 2 lowest bits: + 0: 6-63, 0, 2 ; + # Send next-to-lowest bit of all Y AC coefficients: + 0: 1-63, 2, 1 ; + # At this point we've sent all but the lowest bit of all coefficients. + # Send lowest bit of DC coefficients + 0,1,2: 0-0, 1, 0 ; + # Send lowest bit of AC coefficients + 2: 1-63, 1, 0 ; + 1: 1-63, 1, 0 ; + # Y AC lowest bit scan is last; it's usually the largest scan + 0: 1-63, 1, 0 ; + +It may be worth pointing out that this script is tuned for quality settings +of around 50 to 75. For lower quality settings, you'd probably want to use +a script with fewer stages of successive approximation (otherwise the +initial scans will be really bad). For higher quality settings, you might +want to use more stages of successive approximation (so that the initial +scans are not too large). diff --git a/thirdparty/jpeg-9e/wrbmp.c b/thirdparty/jpeg-9e/wrbmp.c new file mode 100644 index 0000000..bed699f --- /dev/null +++ b/thirdparty/jpeg-9e/wrbmp.c @@ -0,0 +1,437 @@ +/* + * wrbmp.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2017-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in Microsoft "BMP" + * format (MS Windows 3.x and OS/2 1.x flavors). + * Either 8-bit colormapped or 24-bit full-color format can be written. + * No compression is supported. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + * + * This code contributed by James Arthur Boucher. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef BMP_SUPPORTED + + +/* + * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. + * This is not yet implemented. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + +/* + * Since BMP stores scanlines bottom-to-top, we have to invert the image + * from JPEG's top-to-bottom order. To do this, we save the outgoing data + * in a virtual array during put_pixel_row calls, then actually emit the + * BMP file during finish_output. The virtual array contains one JSAMPLE per + * pixel if the output is grayscale or colormapped, three if it is full color. + */ + +/* Private version of data destination object */ + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + boolean is_os2; /* saves the OS2 format request flag */ + + jvirt_sarray_ptr whole_image; /* needed to reverse row order */ + JDIMENSION data_width; /* JSAMPLEs per row */ + JDIMENSION row_width; /* physical width of one row in the BMP file */ + int pad_bytes; /* number of padding bytes needed per row */ + JDIMENSION cur_output_row; /* next row# to write to virtual array */ +} bmp_dest_struct; + +typedef bmp_dest_struct * bmp_dest_ptr; + + +/* Forward declarations */ +LOCAL(void) write_colormap + JPP((j_decompress_ptr cinfo, bmp_dest_ptr dest, + int map_colors, int map_entry_size)); + + +/* + * Write some pixel data. + * In this module rows_supplied will always be 1. + */ + +METHODDEF(void) +put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* This version is for writing 24-bit pixels */ +{ + bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + int pad; + + /* Access next row in virtual array */ + outptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, + dest->whole_image, dest->cur_output_row, (JDIMENSION) 1, TRUE); + dest->cur_output_row++; + + /* Transfer data. Note destination values must be in BGR order + * (even though Microsoft's own documents say the opposite). + */ + inptr = dest->pub.buffer[0]; + for (col = cinfo->output_width; col > 0; col--) { + outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ + outptr[1] = *inptr++; + outptr[0] = *inptr++; + outptr += 3; + } + + /* Zero out the pad bytes. */ + pad = dest->pad_bytes; + while (--pad >= 0) + *outptr++ = 0; +} + +METHODDEF(void) +put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* This version is for grayscale OR quantized color output */ +{ + bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + int pad; + + /* Access next row in virtual array */ + outptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, + dest->whole_image, dest->cur_output_row, (JDIMENSION) 1, TRUE); + dest->cur_output_row++; + + /* Transfer data. */ + inptr = dest->pub.buffer[0]; + for (col = cinfo->output_width; col > 0; col--) { + *outptr++ = *inptr++; /* can omit GETJSAMPLE() safely */ + } + + /* Zero out the pad bytes. */ + pad = dest->pad_bytes; + while (--pad >= 0) + *outptr++ = 0; +} + + +/* + * Startup: normally writes the file header. + * In this module we may as well postpone everything until finish_output. + */ + +METHODDEF(void) +start_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + /* no work here */ +} + + +/* + * Finish up at the end of the file. + * + * Here is where we really output the BMP file. + * + * First, routines to write the Windows and OS/2 variants of the file header. + */ + +LOCAL(void) +write_bmp_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) +/* Write a Windows-style BMP file header, including colormap if needed */ +{ + char bmpfileheader[14]; + char bmpinfoheader[40]; +#define PUT_2B(array, offset, value) \ + (array[offset] = (char) ((value) & 0xFF), \ + array[offset+1] = (char) (((value) >> 8) & 0xFF)) +#define PUT_4B(array, offset, value) \ + (array[offset] = (char) ((value) & 0xFF), \ + array[offset+1] = (char) (((value) >> 8) & 0xFF), \ + array[offset+2] = (char) (((value) >> 16) & 0xFF), \ + array[offset+3] = (char) (((value) >> 24) & 0xFF)) + INT32 headersize, bfSize; + int bits_per_pixel, cmap_entries; + + /* Compute colormap size and total file size */ + if (cinfo->out_color_space == JCS_RGB) { + if (cinfo->quantize_colors) { + /* Colormapped RGB */ + bits_per_pixel = 8; + cmap_entries = 256; + } else { + /* Unquantized, full color RGB */ + bits_per_pixel = 24; + cmap_entries = 0; + } + } else { + /* Grayscale output. We need to fake a 256-entry colormap. */ + bits_per_pixel = 8; + cmap_entries = 256; + } + /* File size */ + headersize = 14 + 40 + cmap_entries * 4; /* Header and colormap */ + bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; + + /* Set unused fields of header to 0 */ + MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); + MEMZERO(bmpinfoheader, SIZEOF(bmpinfoheader)); + + /* Fill the file header */ + bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ + bmpfileheader[1] = 0x4D; + PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ + /* we leave bfReserved1 & bfReserved2 = 0 */ + PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ + + /* Fill the info header (Microsoft calls this a BITMAPINFOHEADER) */ + PUT_2B(bmpinfoheader, 0, 40); /* biSize */ + PUT_4B(bmpinfoheader, 4, cinfo->output_width); /* biWidth */ + PUT_4B(bmpinfoheader, 8, cinfo->output_height); /* biHeight */ + PUT_2B(bmpinfoheader, 12, 1); /* biPlanes - must be 1 */ + PUT_2B(bmpinfoheader, 14, bits_per_pixel); /* biBitCount */ + /* we leave biCompression = 0, for none */ + /* we leave biSizeImage = 0; this is correct for uncompressed data */ + if (cinfo->density_unit == 2) { /* if have density in dots/cm, then */ + PUT_4B(bmpinfoheader, 24, (INT32) (cinfo->X_density*100)); /* XPels/M */ + PUT_4B(bmpinfoheader, 28, (INT32) (cinfo->Y_density*100)); /* XPels/M */ + } + PUT_2B(bmpinfoheader, 32, cmap_entries); /* biClrUsed */ + /* we leave biClrImportant = 0 */ + + if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) + ERREXIT(cinfo, JERR_FILE_WRITE); + if (JFWRITE(dest->pub.output_file, bmpinfoheader, 40) != (size_t) 40) + ERREXIT(cinfo, JERR_FILE_WRITE); + + if (cmap_entries > 0) + write_colormap(cinfo, dest, cmap_entries, 4); +} + + +LOCAL(void) +write_os2_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) +/* Write an OS2-style BMP file header, including colormap if needed */ +{ + char bmpfileheader[14]; + char bmpcoreheader[12]; + INT32 headersize, bfSize; + int bits_per_pixel, cmap_entries; + + /* Compute colormap size and total file size */ + if (cinfo->out_color_space == JCS_RGB) { + if (cinfo->quantize_colors) { + /* Colormapped RGB */ + bits_per_pixel = 8; + cmap_entries = 256; + } else { + /* Unquantized, full color RGB */ + bits_per_pixel = 24; + cmap_entries = 0; + } + } else { + /* Grayscale output. We need to fake a 256-entry colormap. */ + bits_per_pixel = 8; + cmap_entries = 256; + } + /* File size */ + headersize = 14 + 12 + cmap_entries * 3; /* Header and colormap */ + bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; + + /* Set unused fields of header to 0 */ + MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); + MEMZERO(bmpcoreheader, SIZEOF(bmpcoreheader)); + + /* Fill the file header */ + bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ + bmpfileheader[1] = 0x4D; + PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ + /* we leave bfReserved1 & bfReserved2 = 0 */ + PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ + + /* Fill the info header (Microsoft calls this a BITMAPCOREHEADER) */ + PUT_2B(bmpcoreheader, 0, 12); /* bcSize */ + PUT_2B(bmpcoreheader, 4, cinfo->output_width); /* bcWidth */ + PUT_2B(bmpcoreheader, 6, cinfo->output_height); /* bcHeight */ + PUT_2B(bmpcoreheader, 8, 1); /* bcPlanes - must be 1 */ + PUT_2B(bmpcoreheader, 10, bits_per_pixel); /* bcBitCount */ + + if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) + ERREXIT(cinfo, JERR_FILE_WRITE); + if (JFWRITE(dest->pub.output_file, bmpcoreheader, 12) != (size_t) 12) + ERREXIT(cinfo, JERR_FILE_WRITE); + + if (cmap_entries > 0) + write_colormap(cinfo, dest, cmap_entries, 3); +} + + +/* + * Write the colormap. + * Windows uses BGR0 map entries; OS/2 uses BGR entries. + */ + +LOCAL(void) +write_colormap (j_decompress_ptr cinfo, bmp_dest_ptr dest, + int map_colors, int map_entry_size) +{ + JSAMPARRAY colormap = cinfo->colormap; + int num_colors = cinfo->actual_number_of_colors; + FILE * outfile = dest->pub.output_file; + int i; + + if (colormap != NULL) { + if (cinfo->out_color_components == 3) { + /* Normal case with RGB colormap */ + for (i = 0; i < num_colors; i++) { + putc(GETJSAMPLE(colormap[2][i]), outfile); + putc(GETJSAMPLE(colormap[1][i]), outfile); + putc(GETJSAMPLE(colormap[0][i]), outfile); + if (map_entry_size == 4) + putc(0, outfile); + } + } else { + /* Grayscale colormap (only happens with grayscale quantization) */ + for (i = 0; i < num_colors; i++) { + putc(GETJSAMPLE(colormap[0][i]), outfile); + putc(GETJSAMPLE(colormap[0][i]), outfile); + putc(GETJSAMPLE(colormap[0][i]), outfile); + if (map_entry_size == 4) + putc(0, outfile); + } + } + } else { + /* If no colormap, must be grayscale data. Generate a linear "map". */ + for (i = 0; i < 256; i++) { + putc(i, outfile); + putc(i, outfile); + putc(i, outfile); + if (map_entry_size == 4) + putc(0, outfile); + } + } + /* Pad colormap to ensure specified number of colormap entries */ + if (i > map_colors) + ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, i); + for (; i < map_colors; i++) { + putc(CENTERJSAMPLE, outfile); + putc(CENTERJSAMPLE, outfile); + putc(CENTERJSAMPLE, outfile); + if (map_entry_size == 4) + putc(0, outfile); + } +} + + +METHODDEF(void) +finish_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; + register FILE * outfile = dest->pub.output_file; + register JSAMPROW data_ptr; + JDIMENSION row; + register JDIMENSION col; + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + + /* Write the header and colormap */ + if (dest->is_os2) + write_os2_header(cinfo, dest); + else + write_bmp_header(cinfo, dest); + + /* Write the file body from our virtual array */ + for (row = cinfo->output_height; row > 0; row--) { + if (progress != NULL) { + progress->pub.pass_counter = (long) (cinfo->output_height - row); + progress->pub.pass_limit = (long) cinfo->output_height; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } + data_ptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, + dest->whole_image, row - 1, (JDIMENSION) 1, FALSE); + for (col = dest->row_width; col > 0; col--) { + putc(GETJSAMPLE(*data_ptr), outfile); + data_ptr++; + } + } + if (progress != NULL) + progress->completed_extra_passes++; + + /* Make sure we wrote the output file OK */ + JFFLUSH(outfile); + if (JFERROR(outfile)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for BMP format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2) +{ + bmp_dest_ptr dest; + JDIMENSION row_width; + + /* Create module interface object, fill in method pointers */ + dest = (bmp_dest_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(bmp_dest_struct)); + dest->pub.start_output = start_output_bmp; + dest->pub.finish_output = finish_output_bmp; + dest->is_os2 = is_os2; + + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + dest->pub.put_pixel_rows = put_gray_rows; + break; + case JCS_RGB: + if (cinfo->quantize_colors) + dest->pub.put_pixel_rows = put_gray_rows; + else + dest->pub.put_pixel_rows = put_pixel_rows; + break; + default: + ERREXIT(cinfo, JERR_BMP_COLORSPACE); + } + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Determine width of rows in the BMP file (padded to 4-byte boundary). */ + row_width = cinfo->output_width * cinfo->output_components; + dest->data_width = row_width; + while ((row_width & 3) != 0) row_width++; + dest->row_width = row_width; + dest->pad_bytes = (int) (row_width - dest->data_width); + + /* Allocate space for inversion array, prepare for write pass */ + dest->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + row_width, cinfo->output_height, (JDIMENSION) 1); + dest->cur_output_row = 0; + if (cinfo->progress != NULL) { + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + progress->total_extra_passes++; /* count file input as separate pass */ + } + + /* Create decompressor output buffer. */ + dest->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, row_width, (JDIMENSION) 1); + dest->pub.buffer_height = 1; + + return &dest->pub; +} + +#endif /* BMP_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/wrgif.c b/thirdparty/jpeg-9e/wrgif.c new file mode 100644 index 0000000..9d472de --- /dev/null +++ b/thirdparty/jpeg-9e/wrgif.c @@ -0,0 +1,566 @@ +/* + * wrgif.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2015-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in GIF format. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + */ + +/* + * This code is loosely based on ppmtogif from the PBMPLUS distribution + * of Feb. 1991. That file contains the following copyright notice: + * Based on GIFENCODE by David Rowley . + * Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al. + * Copyright (C) 1989 by Jef Poskanzer. + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. This software is provided "as is" without express or + * implied warranty. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef GIF_SUPPORTED + + +#define MAX_LZW_BITS 12 /* maximum LZW code size (4096 symbols) */ + +typedef INT16 code_int; /* must hold -1 .. 2**MAX_LZW_BITS */ + +#define LZW_TABLE_SIZE ((code_int) 1 << MAX_LZW_BITS) + +#define HSIZE 5003 /* hash table size for 80% occupancy */ + +typedef int hash_int; /* must hold -2*HSIZE..2*HSIZE */ + +#define MAXCODE(n_bits) (((code_int) 1 << (n_bits)) - 1) + + +/* + * The LZW hash table consists of two parallel arrays: + * hash_code[i] code of symbol in slot i, or 0 if empty slot + * hash_value[i] symbol's value; undefined if empty slot + * where slot values (i) range from 0 to HSIZE-1. The symbol value is + * its prefix symbol's code concatenated with its suffix character. + * + * Algorithm: use open addressing double hashing (no chaining) on the + * prefix code / suffix character combination. We do a variant of Knuth's + * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime + * secondary probe. + * + * The hash_value[] table is allocated from FAR heap space since it would + * use up rather a lot of the near data space in a PC. + */ + +typedef INT32 hash_entry; /* must hold (code_int<<8) | byte */ + +#define HASH_ENTRY(prefix, suffix) ((((hash_entry) (prefix)) << 8) | (suffix)) + + +/* Private version of data destination object */ + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + j_decompress_ptr cinfo; /* back link saves passing separate parm */ + + /* State for packing variable-width codes into a bitstream */ + int n_bits; /* current number of bits/code */ + code_int maxcode; /* maximum code, given n_bits */ + int init_bits; /* initial n_bits ... restored after clear */ + INT32 cur_accum; /* holds bits not yet output */ + int cur_bits; /* # of bits in cur_accum */ + + /* LZW string construction */ + code_int waiting_code; /* symbol not yet output; may be extendable */ + boolean first_byte; /* if TRUE, waiting_code is not valid */ + + /* State for GIF code assignment */ + code_int ClearCode; /* clear code (doesn't change) */ + code_int EOFCode; /* EOF code (ditto) */ + code_int free_code; /* LZW: first not-yet-used symbol code */ + code_int code_counter; /* not LZW: counts output symbols */ + + /* LZW hash table */ + code_int *hash_code; /* => hash table of symbol codes */ + hash_entry FAR *hash_value; /* => hash table of symbol values */ + + /* GIF data packet construction buffer */ + int bytesinpkt; /* # of bytes in current packet */ + char packetbuf[256]; /* workspace for accumulating packet */ + +} gif_dest_struct; + +typedef gif_dest_struct * gif_dest_ptr; + + +/* + * Routines to package finished data bytes into GIF data blocks. + * A data block consists of a count byte (1..255) and that many data bytes. + */ + +LOCAL(void) +flush_packet (gif_dest_ptr dinfo) +/* flush any accumulated data */ +{ + if (dinfo->bytesinpkt > 0) { /* never write zero-length packet */ + dinfo->packetbuf[0] = (char) dinfo->bytesinpkt++; + if (JFWRITE(dinfo->pub.output_file, dinfo->packetbuf, dinfo->bytesinpkt) + != (size_t) dinfo->bytesinpkt) + ERREXIT(dinfo->cinfo, JERR_FILE_WRITE); + dinfo->bytesinpkt = 0; + } +} + + +/* Add a character to current packet; flush to disk if necessary */ +#define CHAR_OUT(dinfo, c) \ + { (dinfo)->packetbuf[++(dinfo)->bytesinpkt] = (char) (c); \ + if ((dinfo)->bytesinpkt >= 255) \ + flush_packet(dinfo); \ + } + + +/* Routine to convert variable-width codes into a byte stream */ + +LOCAL(void) +output (gif_dest_ptr dinfo, code_int code) +/* Emit a code of n_bits bits */ +/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */ +{ + dinfo->cur_accum |= ((INT32) code) << dinfo->cur_bits; + dinfo->cur_bits += dinfo->n_bits; + + while (dinfo->cur_bits >= 8) { + CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); + dinfo->cur_accum >>= 8; + dinfo->cur_bits -= 8; + } + + /* + * If the next entry is going to be too big for the code size, + * then increase it, if possible. We do this here to ensure + * that it's done in sync with the decoder's codesize increases. + */ + if (dinfo->free_code > dinfo->maxcode) { + dinfo->n_bits++; + if (dinfo->n_bits == MAX_LZW_BITS) + dinfo->maxcode = LZW_TABLE_SIZE; /* free_code will never exceed this */ + else + dinfo->maxcode = MAXCODE(dinfo->n_bits); + } +} + + +/* Compression initialization & termination */ + + +LOCAL(void) +clear_hash (gif_dest_ptr dinfo) +/* Fill the hash table with empty entries */ +{ + /* It's sufficient to zero hash_code[] */ + MEMZERO(dinfo->hash_code, HSIZE * SIZEOF(code_int)); +} + + +LOCAL(void) +clear_block (gif_dest_ptr dinfo) +/* Reset compressor and issue a Clear code */ +{ + clear_hash(dinfo); /* delete all the symbols */ + dinfo->free_code = dinfo->ClearCode + 2; + output(dinfo, dinfo->ClearCode); /* inform decoder */ + dinfo->n_bits = dinfo->init_bits; /* reset code size */ + dinfo->maxcode = MAXCODE(dinfo->n_bits); +} + + +LOCAL(void) +compress_init (gif_dest_ptr dinfo, int i_bits) +/* Initialize compressor */ +{ + /* init all the state variables */ + dinfo->n_bits = dinfo->init_bits = i_bits; + dinfo->maxcode = MAXCODE(dinfo->n_bits); + dinfo->ClearCode = ((code_int) 1 << (i_bits - 1)); + dinfo->EOFCode = dinfo->ClearCode + 1; + dinfo->code_counter = dinfo->free_code = dinfo->ClearCode + 2; + dinfo->first_byte = TRUE; /* no waiting symbol yet */ + /* init output buffering vars */ + dinfo->bytesinpkt = 0; + dinfo->cur_accum = 0; + dinfo->cur_bits = 0; + /* clear hash table */ + if (dinfo->hash_code != NULL) + clear_hash(dinfo); + /* GIF specifies an initial Clear code */ + output(dinfo, dinfo->ClearCode); +} + + +LOCAL(void) +compress_term (gif_dest_ptr dinfo) +/* Clean up at end */ +{ + /* Flush out the buffered LZW code */ + if (! dinfo->first_byte) + output(dinfo, dinfo->waiting_code); + /* Send an EOF code */ + output(dinfo, dinfo->EOFCode); + /* Flush the bit-packing buffer */ + if (dinfo->cur_bits > 0) { + CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); + } + /* Flush the packet buffer */ + flush_packet(dinfo); +} + + +/* GIF header construction */ + + +LOCAL(void) +put_word (gif_dest_ptr dinfo, unsigned int w) +/* Emit a 16-bit word, LSB first */ +{ + putc(w & 0xFF, dinfo->pub.output_file); + putc((w >> 8) & 0xFF, dinfo->pub.output_file); +} + + +LOCAL(void) +put_3bytes (gif_dest_ptr dinfo, int val) +/* Emit 3 copies of same byte value --- handy subr for colormap construction */ +{ + putc(val, dinfo->pub.output_file); + putc(val, dinfo->pub.output_file); + putc(val, dinfo->pub.output_file); +} + + +LOCAL(void) +emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap) +/* Output the GIF file header, including color map */ +/* If colormap == NULL, synthesize a grayscale colormap */ +{ + int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte; + int cshift = dinfo->cinfo->data_precision - 8; + int i; + + if (num_colors > 256) + ERREXIT1(dinfo->cinfo, JERR_TOO_MANY_COLORS, num_colors); + /* Compute bits/pixel and related values */ + BitsPerPixel = 1; + while (num_colors > (1 << BitsPerPixel)) + BitsPerPixel++; + ColorMapSize = 1 << BitsPerPixel; + if (BitsPerPixel <= 1) + InitCodeSize = 2; + else + InitCodeSize = BitsPerPixel; + /* + * Write the GIF header. + * Note that we generate a plain GIF87 header for maximum compatibility. + */ + putc('G', dinfo->pub.output_file); + putc('I', dinfo->pub.output_file); + putc('F', dinfo->pub.output_file); + putc('8', dinfo->pub.output_file); + putc('7', dinfo->pub.output_file); + putc('a', dinfo->pub.output_file); + /* Write the Logical Screen Descriptor */ + put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); + put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); + FlagByte = 0x80; /* Yes, there is a global color table */ + FlagByte |= (BitsPerPixel - 1) << 4; /* color resolution */ + FlagByte |= (BitsPerPixel - 1); /* size of global color table */ + putc(FlagByte, dinfo->pub.output_file); + putc(0, dinfo->pub.output_file); /* Background color index */ + putc(0, dinfo->pub.output_file); /* Reserved (aspect ratio in GIF89) */ + /* Write the Global Color Map */ + /* If the color map is more than 8 bits precision, */ + /* we reduce it to 8 bits by shifting */ + for (i = 0; i < ColorMapSize; i++) { + if (i < num_colors) { + if (colormap != NULL) { + if (dinfo->cinfo->out_color_space == JCS_RGB) { + /* Normal case: RGB color map */ + putc(GETJSAMPLE(colormap[0][i]) >> cshift, dinfo->pub.output_file); + putc(GETJSAMPLE(colormap[1][i]) >> cshift, dinfo->pub.output_file); + putc(GETJSAMPLE(colormap[2][i]) >> cshift, dinfo->pub.output_file); + } else { + /* Grayscale "color map": possible if quantizing grayscale image */ + put_3bytes(dinfo, GETJSAMPLE(colormap[0][i]) >> cshift); + } + } else { + /* Create a grayscale map of num_colors values, range 0..255 */ + put_3bytes(dinfo, (i * 255 + (num_colors - 1) / 2) / (num_colors - 1)); + } + } else { + /* fill out the map to a power of 2 */ + put_3bytes(dinfo, CENTERJSAMPLE >> cshift); + } + } + /* Write image separator and Image Descriptor */ + putc(',', dinfo->pub.output_file); /* separator */ + put_word(dinfo, 0); /* left/top offset */ + put_word(dinfo, 0); + put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); /* image size */ + put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); + /* flag byte: not interlaced, no local color map */ + putc(0x00, dinfo->pub.output_file); + /* Write Initial Code Size byte */ + putc(InitCodeSize, dinfo->pub.output_file); + + /* Initialize for compression of image data */ + compress_init(dinfo, InitCodeSize + 1); +} + + +/* + * Startup: write the file header. + */ + +METHODDEF(void) +start_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + gif_dest_ptr dest = (gif_dest_ptr) dinfo; + + if (cinfo->quantize_colors) + emit_header(dest, cinfo->actual_number_of_colors, cinfo->colormap); + else + emit_header(dest, 256, (JSAMPARRAY) NULL); +} + + +/* + * Write some pixel data. + * In this module rows_supplied will always be 1. + */ + + +/* + * The LZW algorithm proper + */ + +METHODDEF(void) +put_LZW_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + gif_dest_ptr dest = (gif_dest_ptr) dinfo; + register JSAMPROW ptr; + register JDIMENSION col; + code_int c; + register hash_int i; + register hash_int disp; + register hash_entry probe_value; + + ptr = dest->pub.buffer[0]; + for (col = cinfo->output_width; col > 0; col--) { + /* Accept and compress one 8-bit byte */ + c = (code_int) GETJSAMPLE(*ptr++); + + if (dest->first_byte) { /* need to initialize waiting_code */ + dest->waiting_code = c; + dest->first_byte = FALSE; + continue; + } + + /* Probe hash table to see if a symbol exists for + * waiting_code followed by c. + * If so, replace waiting_code by that symbol and continue. + */ + i = ((hash_int) c << (MAX_LZW_BITS-8)) + dest->waiting_code; + /* i is less than twice 2**MAX_LZW_BITS, therefore less than twice HSIZE */ + if (i >= HSIZE) + i -= HSIZE; + + probe_value = HASH_ENTRY(dest->waiting_code, c); + + if (dest->hash_code[i] == 0) { + /* hit empty slot; desired symbol not in table */ + output(dest, dest->waiting_code); + if (dest->free_code < LZW_TABLE_SIZE) { + dest->hash_code[i] = dest->free_code++; /* add symbol to hashtable */ + dest->hash_value[i] = probe_value; + } else + clear_block(dest); + dest->waiting_code = c; + continue; + } + if (dest->hash_value[i] == probe_value) { + dest->waiting_code = dest->hash_code[i]; + continue; + } + + if (i == 0) /* secondary hash (after G. Knott) */ + disp = 1; + else + disp = HSIZE - i; + for (;;) { + i -= disp; + if (i < 0) + i += HSIZE; + if (dest->hash_code[i] == 0) { + /* hit empty slot; desired symbol not in table */ + output(dest, dest->waiting_code); + if (dest->free_code < LZW_TABLE_SIZE) { + dest->hash_code[i] = dest->free_code++; /* add symbol to hashtable */ + dest->hash_value[i] = probe_value; + } else + clear_block(dest); + dest->waiting_code = c; + break; + } + if (dest->hash_value[i] == probe_value) { + dest->waiting_code = dest->hash_code[i]; + break; + } + } + } +} + + +/* + * The pseudo-compression algorithm. + * + * In this version we simply output each pixel value as a separate symbol; + * thus, no compression occurs. In fact, there is expansion of one bit per + * pixel, because we use a symbol width one bit wider than the pixel width. + * + * GIF ordinarily uses variable-width symbols, and the decoder will expect + * to ratchet up the symbol width after a fixed number of symbols. + * To simplify the logic and keep the expansion penalty down, we emit a + * GIF Clear code to reset the decoder just before the width would ratchet up. + * Thus, all the symbols in the output file will have the same bit width. + * Note that emitting the Clear codes at the right times is a mere matter of + * counting output symbols and is in no way dependent on the LZW algorithm. + * + * With a small basic pixel width (low color count), Clear codes will be + * needed very frequently, causing the file to expand even more. So this + * simplistic approach wouldn't work too well on bilevel images, for example. + * But for output of JPEG conversions the pixel width will usually be 8 bits + * (129 to 256 colors), so the overhead added by Clear symbols is only about + * one symbol in every 256. + */ + +METHODDEF(void) +put_raw_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + gif_dest_ptr dest = (gif_dest_ptr) dinfo; + register JSAMPROW ptr; + register JDIMENSION col; + code_int c; + + ptr = dest->pub.buffer[0]; + for (col = cinfo->output_width; col > 0; col--) { + c = (code_int) GETJSAMPLE(*ptr++); + /* Accept and output one pixel value. + * The given value must be less than n_bits wide. + */ + + /* Output the given pixel value as a symbol. */ + output(dest, c); + /* Issue Clear codes often enough to keep the reader from ratcheting up + * its symbol size. + */ + if (dest->code_counter < dest->maxcode) { + dest->code_counter++; + } else { + output(dest, dest->ClearCode); + dest->code_counter = dest->ClearCode + 2; /* reset the counter */ + } + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + gif_dest_ptr dest = (gif_dest_ptr) dinfo; + + /* Flush compression mechanism */ + compress_term(dest); + /* Write a zero-length data block to end the series */ + putc(0, dest->pub.output_file); + /* Write the GIF terminator mark */ + putc(';', dest->pub.output_file); + /* Make sure we wrote the output file OK */ + JFFLUSH(dest->pub.output_file); + if (JFERROR(dest->pub.output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for GIF format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_gif (j_decompress_ptr cinfo, boolean is_lzw) +{ + gif_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (gif_dest_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(gif_dest_struct)); + dest->cinfo = cinfo; /* make back link for subroutines */ + dest->pub.start_output = start_output_gif; + dest->pub.finish_output = finish_output_gif; + + if (cinfo->out_color_space != JCS_GRAYSCALE && + cinfo->out_color_space != JCS_RGB) + ERREXIT(cinfo, JERR_GIF_COLORSPACE); + + /* Force quantization if color or if > 8 bits input */ + if (cinfo->out_color_space != JCS_GRAYSCALE || cinfo->data_precision > 8) { + /* Force quantization to at most 256 colors */ + cinfo->quantize_colors = TRUE; + if (cinfo->desired_number_of_colors > 256) + cinfo->desired_number_of_colors = 256; + } + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + if (cinfo->output_components != 1) /* safety check: just one component? */ + ERREXIT(cinfo, JERR_GIF_BUG); + + /* Create decompressor output buffer. */ + dest->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) 1); + dest->pub.buffer_height = 1; + + if (is_lzw) { + dest->pub.put_pixel_rows = put_LZW_pixel_rows; + /* Allocate space for hash table */ + dest->hash_code = (code_int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, HSIZE * SIZEOF(code_int)); + dest->hash_value = (hash_entry FAR *) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, HSIZE * SIZEOF(hash_entry)); + } else { + dest->pub.put_pixel_rows = put_raw_pixel_rows; + /* Mark tables unused */ + dest->hash_code = NULL; + dest->hash_value = NULL; + } + + return &dest->pub; +} + +#endif /* GIF_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/wrjpgcom.1 b/thirdparty/jpeg-9e/wrjpgcom.1 new file mode 100644 index 0000000..d419a99 --- /dev/null +++ b/thirdparty/jpeg-9e/wrjpgcom.1 @@ -0,0 +1,103 @@ +.TH WRJPGCOM 1 "15 June 1995" +.SH NAME +wrjpgcom \- insert text comments into a JPEG file +.SH SYNOPSIS +.B wrjpgcom +[ +.B \-replace +] +[ +.BI \-comment " text" +] +[ +.BI \-cfile " name" +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B wrjpgcom +reads the named JPEG/JFIF file, or the standard input if no file is named, +and generates a new JPEG/JFIF file on standard output. A comment block is +added to the file. +.PP +The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. +Although the standard doesn't actually define what COM blocks are for, they +are widely used to hold user-supplied text strings. This lets you add +annotations, titles, index terms, etc to your JPEG files, and later retrieve +them as text. COM blocks do not interfere with the image stored in the JPEG +file. The maximum size of a COM block is 64K, but you can have as many of +them as you like in one JPEG file. +.PP +.B wrjpgcom +adds a COM block, containing text you provide, to a JPEG file. +Ordinarily, the COM block is added after any existing COM blocks; but you +can delete the old COM blocks if you wish. +.SH OPTIONS +Switch names may be abbreviated, and are not case sensitive. +.TP +.B \-replace +Delete any existing COM blocks from the file. +.TP +.BI \-comment " text" +Supply text for new COM block on command line. +.TP +.BI \-cfile " name" +Read text for new COM block from named file. +.PP +If you have only one line of comment text to add, you can provide it on the +command line with +.BR \-comment . +The comment text must be surrounded with quotes so that it is treated as a +single argument. Longer comments can be read from a text file. +.PP +If you give neither +.B \-comment +nor +.BR \-cfile , +then +.B wrjpgcom +will read the comment text from standard input. (In this case an input image +file name MUST be supplied, so that the source JPEG file comes from somewhere +else.) You can enter multiple lines, up to 64KB worth. Type an end-of-file +indicator (usually control-D) to terminate the comment text entry. +.PP +.B wrjpgcom +will not add a COM block if the provided comment string is empty. Therefore +\fB\-replace \-comment ""\fR can be used to delete all COM blocks from a file. +.SH EXAMPLES +.LP +Add a short comment to in.jpg, producing out.jpg: +.IP +.B wrjpgcom \-c +\fI"View of my back yard" in.jpg +.B > +.I out.jpg +.PP +Attach a long comment previously stored in comment.txt: +.IP +.B wrjpgcom +.I in.jpg +.B < +.I comment.txt +.B > +.I out.jpg +.PP +or equivalently +.IP +.B wrjpgcom +.B -cfile +.I comment.txt +.B < +.I in.jpg +.B > +.I out.jpg +.SH SEE ALSO +.BR cjpeg (1), +.BR djpeg (1), +.BR jpegtran (1), +.BR rdjpgcom (1) +.SH AUTHOR +Independent JPEG Group diff --git a/thirdparty/jpeg-9e/wrjpgcom.c b/thirdparty/jpeg-9e/wrjpgcom.c new file mode 100644 index 0000000..571e9d0 --- /dev/null +++ b/thirdparty/jpeg-9e/wrjpgcom.c @@ -0,0 +1,599 @@ +/* + * wrjpgcom.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * Modified 2015-2017 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a very simple stand-alone application that inserts + * user-supplied text as a COM (comment) marker in a JFIF file. + * This may be useful as an example of the minimum logic needed to parse + * JPEG markers. + */ + +#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ +#include "jinclude.h" /* get auto-config symbols, */ + +#ifndef HAVE_STDLIB_H /* should declare malloc() */ +extern void * malloc (); +#endif +#include /* to declare isupper(), tolower() */ +#ifdef USE_SETMODE +#include /* to declare setmode()'s parameter macros */ +/* If you have setmode() but not , just delete this line: */ +#include /* to declare setmode() */ +#endif + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#define WRITE_BINARY "w" +#else +#ifdef VMS /* VMS is very nonstandard */ +#define READ_BINARY "rb", "ctx=stm" +#define WRITE_BINARY "wb", "ctx=stm" +#else /* standard ANSI-compliant case */ +#define READ_BINARY "rb" +#define WRITE_BINARY "wb" +#endif +#endif + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif +#ifndef EXIT_SUCCESS +#ifdef VMS +#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ +#else +#define EXIT_SUCCESS 0 +#endif +#endif + +/* Reduce this value if your malloc() can't allocate blocks up to 64K. + * On DOS, compiling in large model is usually a better solution. + */ + +#ifndef MAX_COM_LENGTH +#define MAX_COM_LENGTH 65000L /* must be <= 65533 in any case */ +#endif + + +/* + * These macros are used to read the input file and write the output file. + * To reuse this code in another application, you might need to change these. + */ + +static FILE * infile; /* input JPEG file */ + +/* Return next input byte, or EOF if no more */ +#define NEXTBYTE() getc(infile) + +static FILE * outfile; /* output JPEG file */ + +/* Emit an output byte */ +#define PUTBYTE(x) putc((x), outfile) + + +/* Error exit handler */ +#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) + + +/* Read one byte, testing for EOF */ +static int +read_1_byte (void) +{ + int c; + + c = NEXTBYTE(); + if (c == EOF) + ERREXIT("Premature EOF in JPEG file"); + return c; +} + +/* Read 2 bytes, convert to unsigned int */ +/* All 2-byte quantities in JPEG markers are MSB first */ +static unsigned int +read_2_bytes (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + if (c1 == EOF) + ERREXIT("Premature EOF in JPEG file"); + c2 = NEXTBYTE(); + if (c2 == EOF) + ERREXIT("Premature EOF in JPEG file"); + return (((unsigned int) c1) << 8) + ((unsigned int) c2); +} + + +/* Routines to write data to output file */ + +static void +write_1_byte (int c) +{ + PUTBYTE(c); +} + +static void +write_2_bytes (unsigned int val) +{ + PUTBYTE((val >> 8) & 0xFF); + PUTBYTE(val & 0xFF); +} + +static void +write_marker (int marker) +{ + PUTBYTE(0xFF); + PUTBYTE(marker); +} + +static void +copy_rest_of_file (void) +{ + int c; + + while ((c = NEXTBYTE()) != EOF) + PUTBYTE(c); +} + + +/* + * JPEG markers consist of one or more 0xFF bytes, followed by a marker + * code byte (which is not an FF). Here are the marker codes of interest + * in this program. (See jdmarker.c for a more complete list.) + */ + +#define M_SOF0 0xC0 /* Start Of Frame N */ +#define M_SOF1 0xC1 /* N indicates which compression process */ +#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ +#define M_SOF3 0xC3 +#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ +#define M_SOF6 0xC6 +#define M_SOF7 0xC7 +#define M_SOF9 0xC9 +#define M_SOF10 0xCA +#define M_SOF11 0xCB +#define M_SOF13 0xCD +#define M_SOF14 0xCE +#define M_SOF15 0xCF +#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ +#define M_EOI 0xD9 /* End Of Image (end of datastream) */ +#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ +#define M_COM 0xFE /* COMment */ + + +/* + * Find the next JPEG marker and return its marker code. + * We expect at least one FF byte, possibly more if the compressor used FFs + * to pad the file. (Padding FFs will NOT be replicated in the output file.) + * There could also be non-FF garbage between markers. The treatment of such + * garbage is unspecified; we choose to skip over it but emit a warning msg. + * NB: this routine must not be used after seeing SOS marker, since it will + * not deal correctly with FF/00 sequences in the compressed image data... + */ + +static int +next_marker (void) +{ + int c; + int discarded_bytes = 0; + + /* Find 0xFF byte; count and skip any non-FFs. */ + c = read_1_byte(); + while (c != 0xFF) { + discarded_bytes++; + c = read_1_byte(); + } + /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs + * are legal as pad bytes, so don't count them in discarded_bytes. + */ + do { + c = read_1_byte(); + } while (c == 0xFF); + + if (discarded_bytes != 0) { + fprintf(stderr, "Warning: garbage data found in JPEG file\n"); + } + + return c; +} + + +/* + * Read the initial marker, which should be SOI. + * For a JFIF file, the first two bytes of the file should be literally + * 0xFF M_SOI. To be more general, we could use next_marker, but if the + * input file weren't actually JPEG at all, next_marker might read the whole + * file and then return a misleading error message... + */ + +static int +first_marker (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + c2 = NEXTBYTE(); + if (c1 != 0xFF || c2 != M_SOI) + ERREXIT("Not a JPEG file"); + return c2; +} + + +/* + * Most types of marker are followed by a variable-length parameter segment. + * This routine skips over the parameters for any marker we don't otherwise + * want to process. + * Note that we MUST skip the parameter segment explicitly in order not to + * be fooled by 0xFF bytes that might appear within the parameter segment; + * such bytes do NOT introduce new markers. + */ + +static void +copy_variable (void) +/* Copy an unknown or uninteresting variable-length marker */ +{ + unsigned int length; + + /* Get the marker parameter length count */ + length = read_2_bytes(); + write_2_bytes(length); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + /* Copy the remaining bytes */ + while (length > 0) { + write_1_byte(read_1_byte()); + length--; + } +} + +static void +skip_variable (void) +/* Skip over an unknown or uninteresting variable-length marker */ +{ + unsigned int length; + + /* Get the marker parameter length count */ + length = read_2_bytes(); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + /* Skip over the remaining bytes */ + while (length > 0) { + (void) read_1_byte(); + length--; + } +} + + +/* + * Parse the marker stream until SOFn or EOI is seen; + * copy data to output, but discard COM markers unless keep_COM is true. + */ + +static int +scan_JPEG_header (int keep_COM) +{ + int marker; + + /* Expect SOI at start of file */ + if (first_marker() != M_SOI) + ERREXIT("Expected SOI marker first"); + write_marker(M_SOI); + + /* Scan miscellaneous markers until we reach SOFn. */ + for (;;) { + marker = next_marker(); + switch (marker) { + /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, + * treated as SOFn. C4 in particular is actually DHT. + */ + case M_SOF0: /* Baseline */ + case M_SOF1: /* Extended sequential, Huffman */ + case M_SOF2: /* Progressive, Huffman */ + case M_SOF3: /* Lossless, Huffman */ + case M_SOF5: /* Differential sequential, Huffman */ + case M_SOF6: /* Differential progressive, Huffman */ + case M_SOF7: /* Differential lossless, Huffman */ + case M_SOF9: /* Extended sequential, arithmetic */ + case M_SOF10: /* Progressive, arithmetic */ + case M_SOF11: /* Lossless, arithmetic */ + case M_SOF13: /* Differential sequential, arithmetic */ + case M_SOF14: /* Differential progressive, arithmetic */ + case M_SOF15: /* Differential lossless, arithmetic */ + return marker; + + case M_SOS: /* should not see compressed data before SOF */ + ERREXIT("SOS without prior SOFn"); + break; + + case M_EOI: /* in case it's a tables-only JPEG stream */ + return marker; + + case M_COM: /* Existing COM: conditionally discard */ + if (keep_COM) { + write_marker(marker); + copy_variable(); + } else { + skip_variable(); + } + break; + + default: /* Anything else just gets copied */ + write_marker(marker); + copy_variable(); /* we assume it has a parameter count... */ + break; + } + } /* end loop */ +} + + +/* Command line parsing code */ + +static const char * progname; /* program name for error messages */ + + +static void +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "wrjpgcom inserts a textual comment in a JPEG file.\n"); + fprintf(stderr, "You can add to or replace any existing comment(s).\n"); + + fprintf(stderr, "Usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -replace Delete any existing comments\n"); + fprintf(stderr, " -comment \"text\" Insert comment with given text\n"); + fprintf(stderr, " -cfile name Read comment from named file\n"); + fprintf(stderr, "Notice that you must put quotes around the comment text\n"); + fprintf(stderr, "when you use -comment.\n"); + fprintf(stderr, "If you do not give either -comment or -cfile on the command line,\n"); + fprintf(stderr, "then the comment text is read from standard input.\n"); + fprintf(stderr, "It can be multiple lines, up to %u characters total.\n", + (unsigned int) MAX_COM_LENGTH); +#ifndef TWO_FILE_COMMANDLINE + fprintf(stderr, "You must specify an input JPEG file name when supplying\n"); + fprintf(stderr, "comment text from standard input.\n"); +#endif + + exit(EXIT_FAILURE); +} + + +static int +keymatch (char * arg, const char * keyword, int minchars) +/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ +/* keyword is the constant keyword (must be lower case already), */ +/* minchars is length of minimum legal abbreviation. */ +{ + register int ca, ck; + register int nmatched = 0; + + while ((ca = *arg++) != '\0') { + if ((ck = *keyword++) == '\0') + return 0; /* arg longer than keyword, no good */ + if (isupper(ca)) /* force arg to lcase (assume ck is already) */ + ca = tolower(ca); + if (ca != ck) + return 0; /* no good */ + nmatched++; /* count matched characters */ + } + /* reached end of argument; fail if it's too short for unique abbrev */ + if (nmatched < minchars) + return 0; + return 1; /* A-OK */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + int argn; + char * arg; + int keep_COM = 1; + char * comment_arg = NULL; + FILE * comment_file = NULL; + unsigned int comment_length = 0; + int marker; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "wrjpgcom"; /* in case C library doesn't provide it */ + + /* Parse switches, if any */ + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (arg[0] != '-') + break; /* not switch, must be file name */ + arg++; /* advance over '-' */ + if (keymatch(arg, "replace", 1)) { + keep_COM = 0; + } else if (keymatch(arg, "cfile", 2)) { + if (++argn >= argc) usage(); + if ((comment_file = fopen(argv[argn], "r")) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + } else if (keymatch(arg, "comment", 1)) { + if (++argn >= argc) usage(); + comment_arg = argv[argn]; + /* If the comment text starts with '"', then we are probably running + * under MS-DOG and must parse out the quoted string ourselves. Sigh. + */ + if (comment_arg[0] == '"') { + comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); + if (comment_arg == NULL) + ERREXIT("Insufficient memory"); + if (strlen(argv[argn]+1) >= (size_t) MAX_COM_LENGTH) { + fprintf(stderr, "Comment text may not exceed %u bytes\n", + (unsigned int) MAX_COM_LENGTH); + exit(EXIT_FAILURE); + } + strcpy(comment_arg, argv[argn]+1); + for (;;) { + comment_length = (unsigned int) strlen(comment_arg); + if (comment_length > 0 && comment_arg[comment_length-1] == '"') { + comment_arg[comment_length-1] = '\0'; /* zap terminating quote */ + break; + } + if (++argn >= argc) + ERREXIT("Missing ending quote mark"); + if (strlen(comment_arg) + 1 + strlen(argv[argn]) >= + (size_t) MAX_COM_LENGTH) { + fprintf(stderr, "Comment text may not exceed %u bytes\n", + (unsigned int) MAX_COM_LENGTH); + exit(EXIT_FAILURE); + } + strcat(comment_arg, " "); + strcat(comment_arg, argv[argn]); + } + } else if (strlen(comment_arg) >= (size_t) MAX_COM_LENGTH) { + fprintf(stderr, "Comment text may not exceed %u bytes\n", + (unsigned int) MAX_COM_LENGTH); + exit(EXIT_FAILURE); + } + comment_length = (unsigned int) strlen(comment_arg); + } else + usage(); + } + + /* Cannot use both -comment and -cfile. */ + if (comment_arg != NULL && comment_file != NULL) + usage(); + /* If there is neither -comment nor -cfile, we will read the comment text + * from stdin; in this case there MUST be an input JPEG file name. + */ + if (comment_arg == NULL && comment_file == NULL && argn >= argc) + usage(); + + /* Open the input file. */ + if (argn < argc) { + if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdin), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open stdin\n", progname); + exit(EXIT_FAILURE); + } +#else + infile = stdin; +#endif + } + + /* Open the output file. */ +#ifdef TWO_FILE_COMMANDLINE + /* Must have explicit output file name */ + if (argn != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + if ((outfile = fopen(argv[argn+1], WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn+1]); + exit(EXIT_FAILURE); + } +#else + /* Unix style: expect zero or one file name */ + if (argn < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } + /* default output file is stdout */ +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdout), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open stdout\n", progname); + exit(EXIT_FAILURE); + } +#else + outfile = stdout; +#endif +#endif /* TWO_FILE_COMMANDLINE */ + + /* Collect comment text from comment_file or stdin, if necessary */ + if (comment_arg == NULL) { + FILE * src_file; + int c; + + comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); + if (comment_arg == NULL) + ERREXIT("Insufficient memory"); + comment_length = 0; + src_file = (comment_file != NULL ? comment_file : stdin); + while ((c = getc(src_file)) != EOF) { + if (comment_length >= (unsigned int) MAX_COM_LENGTH) { + fprintf(stderr, "Comment text may not exceed %u bytes\n", + (unsigned int) MAX_COM_LENGTH); + exit(EXIT_FAILURE); + } + comment_arg[comment_length++] = (char) c; + } + if (comment_file != NULL) + fclose(comment_file); + } + + /* Copy JPEG headers until SOFn marker; + * we will insert the new comment marker just before SOFn. + * This (a) causes the new comment to appear after, rather than before, + * existing comments; and (b) ensures that comments come after any JFIF + * or JFXX markers, as required by the JFIF specification. + */ + marker = scan_JPEG_header(keep_COM); + /* Insert the new COM marker, but only if nonempty text has been supplied */ + if (comment_length > 0) { + write_marker(M_COM); + write_2_bytes(comment_length + 2); + while (comment_length > 0) { + write_1_byte(*comment_arg++); + comment_length--; + } + } + /* Duplicate the remainder of the source file. + * Note that any COM markers occuring after SOF will not be touched. + */ + write_marker(marker); + copy_rest_of_file(); + + /* All done. */ + exit(EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/thirdparty/jpeg-9e/wrppm.c b/thirdparty/jpeg-9e/wrppm.c new file mode 100644 index 0000000..c9e03ad --- /dev/null +++ b/thirdparty/jpeg-9e/wrppm.c @@ -0,0 +1,264 @@ +/* + * wrppm.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2009-2020 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in PPM/PGM format. + * The extended 2-byte-per-sample raw PPM/PGM formats are supported. + * The PBMPLUS library is NOT required to compile this software + * (but it is highly useful as a set of PPM image manipulation programs). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef PPM_SUPPORTED + + +/* + * For 12-bit JPEG data, we either downscale the values to 8 bits + * (to write standard byte-per-sample PPM/PGM files), or output + * nonstandard word-per-sample PPM/PGM files. Downscaling is done + * if PPM_NORAWWORD is defined (this can be done in the Makefile + * or in jconfig.h). + * (When the core library supports data precision reduction, a cleaner + * implementation will be to ask for that instead.) + */ + +#if BITS_IN_JSAMPLE == 8 +#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) (v) +#define BYTESPERSAMPLE 1 +#define PPM_MAXVAL 255 +#else +#ifdef PPM_NORAWWORD +#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) ((v) >> (BITS_IN_JSAMPLE-8)) +#define BYTESPERSAMPLE 1 +#define PPM_MAXVAL 255 +#else +/* The word-per-sample format always puts the MSB first. */ +#define PUTPPMSAMPLE(ptr,v) \ + { register int val_ = v; \ + *ptr++ = (char) ((val_ >> 8) & 0xFF); \ + *ptr++ = (char) (val_ & 0xFF); \ + } +#define BYTESPERSAMPLE 2 +#define PPM_MAXVAL ((1<pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * This code is used when we have to copy the data and apply a pixel + * format translation. Typically this only happens in 12-bit mode. + */ + +METHODDEF(void) +copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; + register char * bufferptr; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = dest->pixrow; + bufferptr = dest->iobuffer; + for (col = dest->samples_per_row; col > 0; col--) { + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(*ptr++)); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Write some pixel data when color quantization is in effect. + * We have to demap the color index values to straight data. + */ + +METHODDEF(void) +put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; + register char * bufferptr; + register int pixval; + register JSAMPROW ptr; + register JSAMPROW color_map0 = cinfo->colormap[0]; + register JSAMPROW color_map1 = cinfo->colormap[1]; + register JSAMPROW color_map2 = cinfo->colormap[2]; + register JDIMENSION col; + + ptr = dest->pixrow; + bufferptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + pixval = GETJSAMPLE(*ptr++); + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[pixval])); + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map1[pixval])); + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map2[pixval])); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + +METHODDEF(void) +put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; + register char * bufferptr; + register JSAMPROW ptr; + register JSAMPROW color_map0 = cinfo->colormap[0]; + register JDIMENSION col; + + ptr = dest->pixrow; + bufferptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[GETJSAMPLE(*ptr++)])); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Startup: write the file header. + */ + +METHODDEF(void) +start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + /* Emit file header */ + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + /* emit header for raw PGM format */ + fprintf(dinfo->output_file, "P5\n%ld %ld\n%d\n", + (long) cinfo->output_width, (long) cinfo->output_height, + PPM_MAXVAL); + break; + case JCS_RGB: + /* emit header for raw PPM format */ + fprintf(dinfo->output_file, "P6\n%ld %ld\n%d\n", + (long) cinfo->output_width, (long) cinfo->output_height, + PPM_MAXVAL); + break; + default: + ERREXIT(cinfo, JERR_PPM_COLORSPACE); + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + /* Make sure we wrote the output file OK */ + JFFLUSH(dinfo->output_file); + if (JFERROR(dinfo->output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for PPM format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_ppm (j_decompress_ptr cinfo) +{ + ppm_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (ppm_dest_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(ppm_dest_struct)); + dest->pub.start_output = start_output_ppm; + dest->pub.finish_output = finish_output_ppm; + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Create physical I/O buffer. Note we make this near on a PC. */ + dest->samples_per_row = cinfo->output_width * cinfo->out_color_components; + dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char)); + dest->iobuffer = (char *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width); + + if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 || + SIZEOF(JSAMPLE) != SIZEOF(char)) { + /* When quantizing, we need an output buffer for colormap indexes + * that's separate from the physical I/O buffer. We also need a + * separate buffer if pixel format translation must take place. + */ + dest->pixrow = (JSAMPROW) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (size_t) cinfo->output_width * + (size_t) cinfo->output_components * SIZEOF(JSAMPLE)); + if (! cinfo->quantize_colors) + dest->pub.put_pixel_rows = copy_pixel_rows; + else if (cinfo->out_color_space == JCS_GRAYSCALE) + dest->pub.put_pixel_rows = put_demapped_gray; + else + dest->pub.put_pixel_rows = put_demapped_rgb; + } else { + /* We will fwrite() directly from decompressor output buffer. */ + /* Cast here implies near->far pointer conversion on PCs */ + dest->pixrow = (JSAMPROW) dest->iobuffer; + dest->pub.put_pixel_rows = put_pixel_rows; + } + /* Synthesize a JSAMPARRAY pointer structure */ + dest->pub.buffer = & dest->pixrow; + dest->pub.buffer_height = 1; + + return &dest->pub; +} + +#endif /* PPM_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/wrrle.c b/thirdparty/jpeg-9e/wrrle.c new file mode 100644 index 0000000..dc2fadb --- /dev/null +++ b/thirdparty/jpeg-9e/wrrle.c @@ -0,0 +1,306 @@ +/* + * wrrle.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2017-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in RLE format. + * The Utah Raster Toolkit library is required (version 3.1 or later). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + * + * Based on code contributed by Mike Lijewski, + * with updates from Robert Hutchinson. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef RLE_SUPPORTED + +/* rle.h is provided by the Utah Raster Toolkit. */ + +#include + +/* + * We assume that JSAMPLE has the same representation as rle_pixel, + * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + + +/* + * Since RLE stores scanlines bottom-to-top, we have to invert the image + * from JPEG's top-to-bottom order. To do this, we save the outgoing data + * in a virtual array during put_pixel_row calls, then actually emit the + * RLE file during finish_output. + */ + + +/* + * For now, if we emit an RLE color map then it is always 256 entries long, + * though not all of the entries need be used. + */ + +#define CMAPBITS 8 +#define CMAPLENGTH (1<<(CMAPBITS)) + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + jvirt_sarray_ptr image; /* virtual array to store the output image */ + rle_map *colormap; /* RLE-style color map, or NULL if none */ + rle_pixel **rle_row; /* To pass rows to rle_putrow() */ + +} rle_dest_struct; + +typedef rle_dest_struct * rle_dest_ptr; + + +/* Forward declarations */ +METHODDEF(void) rle_put_pixel_rows + JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied)); + + +/* + * Write the file header. + * + * In this module it's easier to wait till finish_output to write anything. + */ + +METHODDEF(void) +start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + rle_dest_ptr dest = (rle_dest_ptr) dinfo; + size_t cmapsize; + int ci, i; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + /* + * Make sure the image can be stored in RLE format. + * + * - RLE stores image dimensions as *signed* 16 bit integers. JPEG + * uses unsigned, so we have to check the width. + * + * - Colorspace is expected to be grayscale or RGB. + * + * - The number of channels (components) is expected to be 1 (grayscale/ + * pseudocolor) or 3 (truecolor/directcolor). + * (could be 2 or 4 if using an alpha channel, but we aren't) + */ + + if (cinfo->output_width > 32767 || cinfo->output_height > 32767) + ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width, + cinfo->output_height); + + if (cinfo->out_color_space != JCS_GRAYSCALE && + cinfo->out_color_space != JCS_RGB) + ERREXIT(cinfo, JERR_RLE_COLORSPACE); + + if (cinfo->output_components != 1 && cinfo->output_components != 3) + ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components); + + /* Convert colormap, if any, to RLE format. */ + + dest->colormap = NULL; + + if (cinfo->quantize_colors) { + /* Allocate storage for RLE-style cmap, zero any extra entries */ + cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map); + dest->colormap = (rle_map *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize); + MEMZERO(dest->colormap, cmapsize); + + /* Save away data in RLE format --- note 8-bit left shift! */ + /* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */ + for (ci = 0; ci < cinfo->out_color_components; ci++) { + for (i = 0; i < cinfo->actual_number_of_colors; i++) { + dest->colormap[ci * CMAPLENGTH + i] = + GETJSAMPLE(cinfo->colormap[ci][i]) << 8; + } + } + } + + /* Set the output buffer to the first row */ + dest->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, (JDIMENSION) 0, (JDIMENSION) 1, TRUE); + dest->pub.buffer_height = 1; + + dest->pub.put_pixel_rows = rle_put_pixel_rows; + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->total_extra_passes++; /* count file writing as separate pass */ + } +#endif +} + + +/* + * Write some pixel data. + * + * This routine just saves the data away in a virtual array. + */ + +METHODDEF(void) +rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + rle_dest_ptr dest = (rle_dest_ptr) dinfo; + + if (cinfo->output_scanline < cinfo->output_height) { + dest->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, + cinfo->output_scanline, (JDIMENSION) 1, TRUE); + } +} + + +/* + * Finish up at the end of the file. + * + * Here is where we really output the RLE file. + */ + +METHODDEF(void) +finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + rle_dest_ptr dest = (rle_dest_ptr) dinfo; + rle_hdr header; /* Output file information */ + rle_pixel **rle_row, *red_ptr, *green_ptr, *blue_ptr; + JSAMPROW output_row; + char cmapcomment[80]; + int row, col; + int ci; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + /* Initialize the header info */ + header = *rle_hdr_init(NULL); + header.rle_file = dest->pub.output_file; + header.xmin = 0; + header.xmax = cinfo->output_width - 1; + header.ymin = 0; + header.ymax = cinfo->output_height - 1; + header.alpha = 0; + header.ncolors = cinfo->output_components; + for (ci = 0; ci < cinfo->output_components; ci++) { + RLE_SET_BIT(header, ci); + } + if (cinfo->quantize_colors) { + header.ncmap = cinfo->out_color_components; + header.cmaplen = CMAPBITS; + header.cmap = dest->colormap; + /* Add a comment to the output image with the true colormap length. */ + sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors); + rle_putcom(cmapcomment, &header); + } + + /* Emit the RLE header and color map (if any) */ + rle_put_setup(&header); + + /* Now output the RLE data from our virtual array. + * We assume here that (a) rle_pixel is represented the same as JSAMPLE, + * and (b) we are not on a machine where FAR pointers differ from regular. + */ + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_limit = cinfo->output_height; + progress->pub.pass_counter = 0; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + + if (cinfo->output_components == 1) { + for (row = cinfo->output_height - 1; row >= 0; row--) { + rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, + (JDIMENSION) row, (JDIMENSION) 1, FALSE); + rle_putrow(rle_row, (int) cinfo->output_width, &header); +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + } else { + for (row = cinfo->output_height - 1; row >= 0; row--) { + output_row = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, + (JDIMENSION) row, (JDIMENSION) 1, FALSE); + rle_row = dest->rle_row; + red_ptr = rle_row[0]; + green_ptr = rle_row[1]; + blue_ptr = rle_row[2]; + for (col = cinfo->output_width; col > 0; col--) { + *red_ptr++ = GETJSAMPLE(*output_row++); + *green_ptr++ = GETJSAMPLE(*output_row++); + *blue_ptr++ = GETJSAMPLE(*output_row++); + } + rle_putrow(rle_row, (int) cinfo->output_width, &header); +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) + progress->completed_extra_passes++; +#endif + + /* Emit file trailer */ + rle_puteof(&header); + JFFLUSH(dest->pub.output_file); + if (JFERROR(dest->pub.output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for RLE format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_rle (j_decompress_ptr cinfo) +{ + rle_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (rle_dest_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(rle_dest_struct)); + dest->pub.start_output = start_output_rle; + dest->pub.finish_output = finish_output_rle; + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Allocate a work array for output to the RLE library. */ + dest->rle_row = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, + JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) cinfo->output_components); + + /* Allocate a virtual array to hold the image. */ + dest->image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + cinfo->output_width * (JDIMENSION) cinfo->output_components, + cinfo->output_height, (JDIMENSION) 1); + + return &dest->pub; +} + +#endif /* RLE_SUPPORTED */ diff --git a/thirdparty/jpeg-9e/wrtarga.c b/thirdparty/jpeg-9e/wrtarga.c new file mode 100644 index 0000000..8ded518 --- /dev/null +++ b/thirdparty/jpeg-9e/wrtarga.c @@ -0,0 +1,254 @@ +/* + * wrtarga.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * Modified 2015-2019 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in Targa format. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + * + * Based on code contributed by Lee Daniel Crocker. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef TARGA_SUPPORTED + + +/* + * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. + * This is not yet implemented. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + +/* + * The output buffer needs to be writable by fwrite(). On PCs, we must + * allocate the buffer in near data space, because we are assuming small-data + * memory model, wherein fwrite() can't reach far memory. If you need to + * process very wide images on a PC, you might have to compile in large-memory + * model, or else replace fwrite() with a putc() loop --- which will be much + * slower. + */ + + +/* Private version of data destination object */ + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + char *iobuffer; /* physical I/O buffer */ + JDIMENSION buffer_width; /* width of one row */ +} tga_dest_struct; + +typedef tga_dest_struct * tga_dest_ptr; + + +LOCAL(void) +write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors) +/* Create and write a Targa header */ +{ + char targaheader[18]; + + /* Set unused fields of header to 0 */ + MEMZERO(targaheader, SIZEOF(targaheader)); + + if (num_colors > 0) { + targaheader[1] = 1; /* color map type 1 */ + targaheader[5] = (char) (num_colors & 0xFF); + targaheader[6] = (char) (num_colors >> 8); + targaheader[7] = 24; /* 24 bits per cmap entry */ + } + + targaheader[12] = (char) (cinfo->output_width & 0xFF); + targaheader[13] = (char) (cinfo->output_width >> 8); + targaheader[14] = (char) (cinfo->output_height & 0xFF); + targaheader[15] = (char) (cinfo->output_height >> 8); + targaheader[17] = 0x20; /* Top-down, non-interlaced */ + + if (cinfo->out_color_space == JCS_GRAYSCALE) { + targaheader[2] = 3; /* image type = uncompressed grayscale */ + targaheader[16] = 8; /* bits per pixel */ + } else { /* must be RGB */ + if (num_colors > 0) { + targaheader[2] = 1; /* image type = colormapped RGB */ + targaheader[16] = 8; + } else { + targaheader[2] = 2; /* image type = uncompressed RGB */ + targaheader[16] = 24; + } + } + + if (JFWRITE(dinfo->output_file, targaheader, 18) != (size_t) 18) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * Write some pixel data. + * In this module rows_supplied will always be 1. + */ + +METHODDEF(void) +put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* used for unquantized full-color output */ +{ + tga_dest_ptr dest = (tga_dest_ptr) dinfo; + register JSAMPROW inptr; + register char * outptr; + register JDIMENSION col; + + inptr = dest->pub.buffer[0]; + outptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + outptr[0] = (char) GETJSAMPLE(inptr[2]); /* RGB to BGR order */ + outptr[1] = (char) GETJSAMPLE(inptr[1]); + outptr[2] = (char) GETJSAMPLE(inptr[0]); + inptr += 3, outptr += 3; + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + +METHODDEF(void) +put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* used for grayscale OR quantized color output */ +{ + tga_dest_ptr dest = (tga_dest_ptr) dinfo; + register JSAMPROW inptr; + register char * outptr; + register JDIMENSION col; + + inptr = dest->pub.buffer[0]; + outptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + *outptr++ = (char) GETJSAMPLE(*inptr++); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Write some demapped pixel data when color quantization is in effect. + * For Targa, this is only applied to grayscale data. + */ + +METHODDEF(void) +put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + tga_dest_ptr dest = (tga_dest_ptr) dinfo; + register JSAMPROW inptr; + register char * outptr; + register JSAMPROW color_map0 = cinfo->colormap[0]; + register JDIMENSION col; + + inptr = dest->pub.buffer[0]; + outptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + *outptr++ = (char) GETJSAMPLE(color_map0[GETJSAMPLE(*inptr++)]); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Startup: write the file header. + */ + +METHODDEF(void) +start_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + int num_colors, i; + FILE *outfile; + + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + /* Targa doesn't have a mapped grayscale format, so we will */ + /* demap quantized gray output. Never emit a colormap. */ + write_header(cinfo, dinfo, 0); + if (cinfo->quantize_colors) + dinfo->put_pixel_rows = put_demapped_gray; + else + dinfo->put_pixel_rows = put_gray_rows; + break; + case JCS_RGB: + if (cinfo->quantize_colors) { + /* We only support 8-bit colormap indexes, so only 256 colors */ + num_colors = cinfo->actual_number_of_colors; + if (num_colors > 256) + ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors); + write_header(cinfo, dinfo, num_colors); + /* Write the colormap. Note Targa uses BGR byte order */ + outfile = dinfo->output_file; + for (i = 0; i < num_colors; i++) { + putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile); + putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile); + putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile); + } + dinfo->put_pixel_rows = put_gray_rows; + } else { + write_header(cinfo, dinfo, 0); + dinfo->put_pixel_rows = put_pixel_rows; + } + break; + default: + ERREXIT(cinfo, JERR_TGA_COLORSPACE); + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + /* Make sure we wrote the output file OK */ + JFFLUSH(dinfo->output_file); + if (JFERROR(dinfo->output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for Targa format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_targa (j_decompress_ptr cinfo) +{ + tga_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (tga_dest_ptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(tga_dest_struct)); + dest->pub.start_output = start_output_tga; + dest->pub.finish_output = finish_output_tga; + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Create I/O buffer. Note we make this near on a PC. */ + dest->buffer_width = cinfo->output_width * cinfo->output_components; + dest->iobuffer = (char *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, + JPOOL_IMAGE, (size_t) dest->buffer_width * SIZEOF(char)); + + /* Create decompressor output buffer. */ + dest->pub.buffer = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, + JPOOL_IMAGE, dest->buffer_width, (JDIMENSION) 1); + dest->pub.buffer_height = 1; + + return &dest->pub; +} + +#endif /* TARGA_SUPPORTED */ diff --git a/thirdparty/libpng-1.6.37/ANNOUNCE b/thirdparty/libpng-1.6.37/ANNOUNCE new file mode 100644 index 0000000..ecf9c70 --- /dev/null +++ b/thirdparty/libpng-1.6.37/ANNOUNCE @@ -0,0 +1,47 @@ +libpng 1.6.37 - April 14, 2019 +============================== + +This is a public release of libpng, intended for use in production code. + + +Files available for download +---------------------------- + +Source files with LF line endings (for Unix/Linux): + + * libpng-1.6.37.tar.xz (LZMA-compressed, recommended) + * libpng-1.6.37.tar.gz + +Source files with CRLF line endings (for Windows): + + * lp1637.7z (LZMA-compressed, recommended) + * lp1637.zip + +Other information: + + * README.md + * LICENSE.md + * AUTHORS.md + * TRADEMARK.md + + +Changes since the previous public release (version 1.6.36) +---------------------------------------------------------- + + * Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free. + * Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette. + * Fixed a memory leak in pngtest.c. + * Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in + contrib/pngminus; refactor. + * Changed the license of contrib/pngminus to MIT; refresh makefile and docs. + (Contributed by Willem van Schaik) + * Fixed a typo in the libpng license v2. + (Contributed by Miguel Ojeda) + * Added makefiles for AddressSanitizer-enabled builds. + * Cleaned up various makefiles. + + +Send comments/corrections/commendations to png-mng-implement at lists.sf.net. +Subscription is required; visit +https://lists.sourceforge.net/lists/listinfo/png-mng-implement +to subscribe. diff --git a/thirdparty/libpng-1.6.37/AUTHORS b/thirdparty/libpng-1.6.37/AUTHORS new file mode 100644 index 0000000..79a3d10 --- /dev/null +++ b/thirdparty/libpng-1.6.37/AUTHORS @@ -0,0 +1,45 @@ +PNG REFERENCE LIBRARY AUTHORS +============================= + +This is the list of PNG Reference Library ("libpng") Contributing +Authors, for copyright and licensing purposes. + + * Andreas Dilger + * Cosmin Truta + * Dave Martindale + * Eric S. Raymond + * Gilles Vollant + * Glenn Randers-Pehrson + * Greg Roelofs + * Guy Eric Schalnat + * James Yu + * John Bowler + * Kevin Bracey + * Magnus Holmgren + * Mandar Sahastrabuddhe + * Mans Rullgard + * Matt Sarett + * Mike Klein + * Paul Schmidt + * Sam Bushell + * Samuel Williams + * Simon-Pierre Cadieux + * Tim Wegner + * Tom Lane + * Tom Tanner + * Vadim Barkov + * Willem van Schaik + * Zhijie Liang + * Arm Holdings + - Richard Townsend + * Google Inc. + - Matt Sarett + - Mike Klein + +The build projects, the build scripts, the test scripts, and other +files in the "projects", "scripts" and "tests" directories, have other +copyright owners, but are released under the libpng license. + +Some files in the "contrib" directory, and some tools-generated files +that are distributed with libpng, have other copyright owners, and are +released under other open source licenses. diff --git a/thirdparty/libpng-1.6.37/CHANGES b/thirdparty/libpng-1.6.37/CHANGES new file mode 100644 index 0000000..f0b0a93 --- /dev/null +++ b/thirdparty/libpng-1.6.37/CHANGES @@ -0,0 +1,6109 @@ +CHANGES - changes for libpng + +version 0.1 [March 29, 1995] + initial work-in-progress release + +version 0.2 [April 1, 1995] + added reader into png.h + fixed small problems in stub file + +version 0.3 [April 8, 1995] + added pull reader + split up pngwrite.c to several files + added pnglib.txt + added example.c + cleaned up writer, adding a few new transformations + fixed some bugs in writer + interfaced with zlib 0.5 + added K&R support + added check for 64 KB blocks for 16 bit machines + +version 0.4 [April 26, 1995] + cleaned up code and commented code + simplified time handling into png_time + created png_color_16 and png_color_8 to handle color needs + cleaned up color type defines + fixed various bugs + made various names more consistent + interfaced with zlib 0.71 + cleaned up zTXt reader and writer (using zlib's Reset functions) + split transformations into pngrtran.c and pngwtran.c + +version 0.5 [April 30, 1995] + interfaced with zlib 0.8 + fixed many reading and writing bugs + saved using 3 spaces instead of tabs + +version 0.6 [May 1, 1995] + first beta release + added png_large_malloc() and png_large_free() + added png_size_t + cleaned up some compiler warnings + added png_start_read_image() + +version 0.7 [June 24, 1995] + cleaned up lots of bugs + finished dithering and other stuff + added test program + changed name from pnglib to libpng + +version 0.71 [June 26, 1995] + changed pngtest.png for zlib 0.93 + fixed error in libpng.txt and example.c + +version 0.8 [August 20, 1995] + cleaned up some bugs + added png_set_filler() + split up pngstub.c into pngmem.c, pngio.c, and pngerror.c + added #define's to remove unwanted code + moved png_info_init() to png.c + added old_size into png_realloc() + added functions to manually set filtering and compression info + changed compression parameters based on image type + optimized filter selection code + added version info + changed external functions passing floats to doubles (k&r problems?) + put all the configurable stuff in pngconf.h + enabled png_set_shift to work with paletted images on read + added png_read_update_info() - updates info structure with transformations + +Version 0.81 [August, 1995] + incorporated Tim Wegner's medium model code (thanks, Tim) + +Version 0.82 [September, 1995] + [unspecified changes] + +Version 0.85 [December, 1995] + added more medium model code (almost everything's a far) + added i/o, error, and memory callback functions + fixed some bugs (16-bit, 4-bit interlaced, etc.) + added first run progressive reader (barely tested) + +Version 0.86 [January, 1996] + fixed bugs + improved documentation + +Version 0.87 [January, 1996] + fixed medium model bugs + fixed other bugs introduced in 0.85 and 0.86 + added some minor documentation + +Version 0.88 [January, 1996] + fixed progressive bugs + replaced tabs with spaces + cleaned up documentation + added callbacks for read/write and warning/error functions + +Version 0.89 [June 5, 1996] + Added new initialization API to make libpng work better with shared libs + we now have png_create_read_struct(), png_create_write_struct(), + png_create_info_struct(), png_destroy_read_struct(), and + png_destroy_write_struct() instead of the separate calls to + malloc and png_read_init(), png_info_init(), and png_write_init() + Changed warning/error callback functions to fix bug - this means you + should use the new initialization API if you were using the old + png_set_message_fn() calls, and that the old API no longer exists + so that people are aware that they need to change their code + Changed filter selection API to allow selection of multiple filters + since it didn't work in previous versions of libpng anyways + Optimized filter selection code + Fixed png_set_background() to allow using an arbitrary RGB color for + paletted images + Fixed gamma and background correction for paletted images, so + png_correct_palette is not needed unless you are correcting an + external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED + in pngconf.h) - if nobody uses this, it may disappear in the future. + Fixed bug with Borland 64K memory allocation (Alexander Lehmann) + Fixed bug in interlace handling (Smarasderagd, I think) + Added more error checking for writing and image to reduce invalid files + Separated read and write functions so that they won't both be linked + into a binary when only reading or writing functionality is used + New pngtest image also has interlacing and zTXt + Updated documentation to reflect new API + +Version 0.89c [June 17, 1996] + Bug fixes. + +Version 0.90 [January, 1997] + Made CRC errors/warnings on critical and ancillary chunks configurable + libpng will use the zlib CRC routines by (compile-time) default + Changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner) + Added external C++ wrapper statements to png.h (Gilles Dauphin) + Allow PNG file to be read when some or all of file signature has already + been read from the beginning of the stream. ****This affects the size + of info_struct and invalidates all programs that use a shared libpng**** + Fixed png_filler() declarations + Fixed? background color conversions + Fixed order of error function pointers to match documentation + Current chunk name is now available in png_struct to reduce the number + of nearly identical error messages (will simplify multi-lingual + support when available) + Try to get ready for unknown-chunk callback functions: + - previously read critical chunks are flagged, so the chunk handling + routines can determine if the chunk is in the right place + - all chunk handling routines have the same prototypes, so we will + be able to handle all chunks via a callback mechanism + Try to fix Linux "setjmp" buffer size problems + Removed png_large_malloc, png_large_free, and png_realloc functions. + +Version 0.95 [March, 1997] + Fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never + Fixed bug in PNG file signature compares when start != 0 + Changed parameter type of png_set_filler(...filler...) from png_byte + to png_uint_32 + Added test for MACOS to ensure that both math.h and fp.h are not #included + Added macros for libpng to be compiled as a Windows DLL (Andreas Kupries) + Added "packswap" transformation, which changes the endianness of + packed-pixel bytes (Kevin Bracey) + Added "strip_alpha" transformation, which removes the alpha channel of + input images without using it (not necessarily a good idea) + Added "swap_alpha" transformation, which puts the alpha channel in front + of the color bytes instead of after + Removed all implicit variable tests which assume NULL == 0 (I think) + Changed several variables to "png_size_t" to show 16/32-bit limitations + Added new pCAL chunk read/write support + Added experimental filter selection weighting (Greg Roelofs) + Removed old png_set_rgbx() and png_set_xrgb() functions that have been + obsolete for about 2 years now (use png_set_filler() instead) + Added macros to read 16- and 32-bit ints directly from buffer, to be + used only on those systems that support it (namely PowerPC and 680x0) + With some testing, this may become the default for MACOS/PPC systems. + Only calculate CRC on data if we are going to use it + Added macros for zTXt compression type PNG_zTXt_COMPRESSION_??? + Added macros for simple libpng debugging output selectable at compile time + Removed PNG_READ_END_MODE in progressive reader (Smarasderagd) + More description of info_struct in libpng.txt and png.h + More instructions in example.c + More chunk types tested in pngtest.c + Renamed pngrcb.c to pngset.c, and all png_read_ functions to be + png_set_. We now have corresponding png_get_ + functions in pngget.c to get information in info_ptr. This isolates + the application from the internal organization of png_info_struct + (good for shared library implementations). + +Version 0.96 [May, 1997] + Fixed serious bug with < 8bpp images introduced in 0.95 + Fixed 256-color transparency bug (Greg Roelofs) + Fixed up documentation (Greg Roelofs, Laszlo Nyul) + Fixed "error" in pngconf.h for Linux setjmp() behavior + Fixed DOS medium model support (Tim Wegner) + Fixed png_check_keyword() for case with error in static string text + Added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul) + Added typecasts to quiet compiler errors + Added more debugging info + +Version 0.97 [January, 1998] + Removed PNG_USE_OWN_CRC capability + Relocated png_set_crc_action from pngrutil.c to pngrtran.c + Fixed typecasts of "new_key", etc. (Andreas Dilger) + Added RFC 1152 [sic] date support + Fixed bug in gamma handling of 4-bit grayscale + Added 2-bit grayscale gamma handling (Glenn R-P) + Added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P) + Minor corrections in libpng.txt + Added simple sRGB support (Glenn R-P) + Easier conditional compiling, e.g., + define PNG_READ/WRITE_NOT_FULLY_SUPPORTED; + all configurable options can be selected from command-line instead + of having to edit pngconf.h (Glenn R-P) + Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P) + Added more conditions for png_do_background, to avoid changing + black pixels to background when a background is supplied and + no pixels are transparent + Repaired PNG_NO_STDIO behavior + Tested NODIV support and made it default behavior (Greg Roelofs) + Added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler) + Regularized version numbering scheme and bumped shared-library major + version number to 2 to avoid problems with libpng 0.89 apps + (Greg Roelofs) + +Version 0.98 [January, 1998] + Cleaned up some typos in libpng.txt and in code documentation + Fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler) + Cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c + Changed recommendation about file_gamma for PC images to .51 from .45, + in example.c and libpng.txt, added comments to distinguish between + screen_gamma, viewing_gamma, and display_gamma. + Changed all references to RFC1152 to read RFC1123 and changed the + PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED + Added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent) + Changed srgb_intent from png_byte to int to avoid compiler bugs + +Version 0.99 [January 30, 1998] + Free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler) + Fixed a longstanding "packswap" bug in pngtrans.c + Fixed some inconsistencies in pngconf.h that prevented compiling with + PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined + Fixed some typos and made other minor rearrangement of libpng.txt (Andreas) + Changed recommendation about file_gamma for PC images to .50 from .51 in + example.c and libpng.txt, and changed file_gamma for sRGB images to .45 + Added a number of functions to access information from the png structure + png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit) + Added TARGET_MACOS similar to zlib-1.0.8 + Define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined + Added type casting to all png_malloc() function calls + +Version 0.99a [January 31, 1998] + Added type casts and parentheses to all returns that return a value.(Tim W.) + +Version 0.99b [February 4, 1998] + Added type cast png_uint_32 on malloc function calls where needed. + Changed type of num_hist from png_uint_32 to int (same as num_palette). + Added checks for rowbytes overflow, in case png_size_t is less than 32 bits. + Renamed makefile.elf to makefile.lnx. + +Version 0.99c [February 7, 1998] + More type casting. Removed erroneous overflow test in pngmem.c. + Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes. + Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5. + +Version 0.99d [February 11, 1998] + Renamed "far_to_near()" "png_far_to_near()" + Revised libpng.3 + Version 99c "buffered" operations didn't work as intended. Replaced them + with png_memcpy_check() and png_memset_check(). + Added many "if (png_ptr == NULL) return" to quell compiler warnings about + unused png_ptr, mostly in pngget.c and pngset.c. + Check for overlength tRNS chunk present when indexed-color PLTE is read. + Cleaned up spelling errors in libpng.3/libpng.txt + Corrected a problem with png_get_tRNS() which returned undefined trans array + +Version 0.99e [February 28, 1998] + Corrected png_get_tRNS() again. + Add parentheses for easier reading of pngget.c, fixed "||" should be "&&". + Touched up example.c to make more of it compileable, although the entire + file still can't be compiled (Willem van Schaik) + Fixed a bug in png_do_shift() (Bryan Tsai) + Added a space in png.h prototype for png_write_chunk_start() + Replaced pngtest.png with one created with zlib 1.1.1 + Changed pngtest to report PASS even when file size is different (Jean-loup G.) + Corrected some logic errors in png_do_invert_alpha() (Chris Patterson) + +Version 0.99f [March 5, 1998] + Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey) + Moved makefiles into a "scripts" directory, and added INSTALL instruction file + Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok) + Added pointers to "note on libpng versions" in makefile.lnx and README + Added row callback feature when reading and writing nonprogressive rows + and added a test of this feature in pngtest.c + Added user transform callbacks, with test of the feature in pngtest.c + +Version 0.99g [March 6, 1998, morning] + Minor changes to pngtest.c to suppress compiler warnings. + Removed "beta" language from documentation. + +Version 0.99h [March 6, 1998, evening] + Minor changes to previous minor changes to pngtest.c + Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED + and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro + Added user transform capability + +Version 1.00 [March 7, 1998] + Changed several typedefs in pngrutil.c + Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik) + Replaced "while(1)" with "for(;;)" + Added PNGARG() to prototypes in pngtest.c and removed some prototypes + Updated some of the makefiles (Tom Lane) + Changed some typedefs (s_start, etc.) in pngrutil.c + Fixed dimensions of "short_months" array in pngwrite.c + Replaced ansi2knr.c with the one from jpeg-v6 + +Version 1.0.0 [March 8, 1998] + Changed name from 1.00 to 1.0.0 (Adam Costello) + Added smakefile.ppc (with SCOPTIONS.ppc) for Amiga PPC (Andreas Kleinert) + +Version 1.0.0a [March 9, 1998] + Fixed three bugs in pngrtran.c to make gamma+background handling consistent + (Greg Roelofs) + Changed format of the PNG_LIBPNG_VER integer to xyyzz instead of xyz + for major, minor, and bugfix releases. This is 10001. (Adam Costello, + Tom Lane) + Make months range from 1-12 in png_convert_to_rfc1123 + +Version 1.0.0b [March 13, 1998] + Quieted compiler complaints about two empty "for" loops in pngrutil.c + Minor changes to makefile.s2x + Removed #ifdef/#endif around a png_free() in pngread.c + +Version 1.0.1 [March 14, 1998] + Changed makefile.s2x to reduce security risk of using a relative pathname + Fixed some typos in the documentation (Greg). + Fixed a problem with value of "channels" returned by png_read_update_info() + +Version 1.0.1a [April 21, 1998] + Optimized Paeth calculations by replacing abs() function calls with intrinsics + plus other loop optimizations. Improves avg decoding speed by about 20%. + Commented out i386istic "align" compiler flags in makefile.lnx. + Reduced the default warning level in some makefiles, to make them consistent. + Removed references to IJG and JPEG in the ansi2knr.c copyright statement. + Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation. + Added grayscale and 16-bit capability to png_do_read_filler(). + Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes + too large when writing an image with bit_depth < 8 (Bob Dellaca). + Corrected some bugs in the experimental weighted filtering heuristics. + Moved a misplaced pngrutil code block that truncates tRNS if it has more + than num_palette entries -- test was done before num_palette was defined. + Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins). + Changed compiler flags in makefile.wat for better optimization + (Pawel Mrochen). + +Version 1.0.1b [May 2, 1998] + Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg). + Relocated the png_composite macros from pngrtran.c to png.h (Greg). + Added makefile.sco (contributed by Mike Hopkirk). + Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a. + Fixed a bug in pngrtran.c that would set channels=5 under some circumstances. + More work on the Paeth-filtering, achieving imperceptible speedup + (A Kleinert). + More work on loop optimization which may help when compiled with C++ + compilers. + Added warnings when people try to use transforms they've defined out. + Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran. + Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg) + +Version 1.0.1c [May 11, 1998] + Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for + filler bytes should have been 0xff instead of 0xf. + Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images. + Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED + out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h + Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED, + for consistency, in pngconf.h + Added individual "ifndef PNG_NO_[CAPABILITY]" in pngconf.h to make it easier + to remove unwanted capabilities via the compile line + Made some corrections to grammar (which, it's) in documentation (Greg). + Corrected example.c, use of row_pointers in png_write_image(). + +Version 1.0.1d [May 24, 1998] + Corrected several statements that used side effects illegally in pngrutil.c + and pngtrans.c, that were introduced in version 1.0.1b + Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert) + More corrections to example.c, use of row_pointers in png_write_image() + and png_read_rows(). + Added pngdll.mak and pngdef.pas to scripts directory, contributed by + Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5 + Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.) + Changed several loops from count-down to count-up, for consistency. + +Version 1.0.1e [June 6, 1998] + Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and + added warnings when people try to set png_read_fn and png_write_fn in + the same structure. + Added a test such that png_do_gamma will be done when num_trans==0 + for truecolor images that have defined a background. This corrects an + error that was introduced in libpng-0.90 that can cause gamma processing + to be skipped. + Added tests in png.h to include "trans" and "trans_values" in structures + when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined. + Add png_free(png_ptr->time_buffer) in png_destroy_read_struct() + Moved png_convert_to_rfc_1123() from pngwrite.c to png.c + Added capability for user-provided malloc_fn() and free_fn() functions, + and revised pngtest.c to demonstrate their use, replacing the + PNGTEST_DEBUG_MEM feature. + Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner). + +Version 1.0.2 [June 14, 1998] + Fixed two bugs in makefile.bor . + +Version 1.0.2a [December 30, 1998] + Replaced and extended code that was removed from png_set_filler() in 1.0.1a. + Fixed a bug in png_do_filler() that made it fail to write filler bytes in + the left-most pixel of each row (Kevin Bracey). + Changed "static pngcharp tIME_string" to "static char tIME_string[30]" + in pngtest.c (Duncan Simpson). + Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk + even when no tIME chunk was present in the source file. + Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit. + Fixed a problem in png_read_push_finish_row(), which would not skip some + passes that it should skip, for images that are less than 3 pixels high. + Interchanged the order of calls to png_do_swap() and png_do_shift() + in pngwtran.c (John Cromer). + Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h . + Changed "bad adaptive filter type" from error to warning in pngrutil.c . + Fixed a documentation error about default filtering with 8-bit indexed-color. + Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO + (L. Peter Deutsch). + Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions. + Added png_get_copyright() and png_get_header_version() functions. + Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c + Added information about debugging in libpng.txt and libpng.3 . + Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and + makefile.sco. + Removed lines after Dynamic Dependencies" in makefile.aco . + Revised makefile.dec to make a shared library (Jeremie Petit). + Removed trailing blanks from all files. + +Version 1.0.2a [January 6, 1999] + Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h + Added "if" tests to silence complaints about unused png_ptr in png.h and png.c + Changed "check_if_png" function in example.c to return true (nonzero) if PNG. + Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig() + which is obsolete. + +Version 1.0.3 [January 14, 1999] + Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice) + Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO. + +Version 1.0.3a [August 12, 1999] + Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning + if an attempt is made to read an interlaced image when it's not supported. + Added check if png_ptr->trans is defined before freeing it in pngread.c + Modified the Y2K statement to include versions back to version 0.71 + Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c + Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments) + Replaced leading blanks with tab characters in makefile.hux + Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents. + Changed (float)red and (float)green to (double)red, (double)green + in png_set_rgb_to_gray() to avoid "promotion" problems in AIX. + Fixed a bug in pngconf.h that omitted when PNG_DEBUG==0 (K Bracey). + Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt). + Updated documentation to refer to the PNG-1.2 specification. + Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c + in makefile.knr, INSTALL, and README (L. Peter Deutsch) + Fixed bugs in calculation of the length of rowbytes when adding alpha + channels to 16-bit images, in pngrtran.c (Chris Nokleberg) + Added function png_set_user_transform_info() to store user_transform_ptr, + user_depth, and user_channels into the png_struct, and a function + png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg) + Added function png_set_empty_plte_permitted() to make libpng useable + in MNG applications. + Corrected the typedef for png_free_ptr in png.h (Jesse Jones). + Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be + consistent with PNG-1.2, and allow variance of 500 before complaining. + Added assembler code contributed by Intel in file pngvcrd.c and modified + makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, + Gilles Vollant) + Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy. + Added some aliases for png_set_expand() in pngrtran.c, namely + png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS() + (Greg Roelofs, in "PNG: The Definitive Guide"). + Added makefile.beo for BEOS on X86, contributed by Sander Stok. + +Version 1.0.3b [August 26, 1999] + Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h + Changed leading blanks to tabs in all makefiles. + Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code. + Made alternate versions of png_set_expand() in pngrtran.c, namely + png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha + (Greg Roelofs, in "PNG: The Definitive Guide"). Deleted the 1.0.3a aliases. + Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h + Revised calculation of num_blocks in pngmem.c to avoid a potentially + negative shift distance, whose results are undefined in the C language. + Added a check in pngset.c to prevent writing multiple tIME chunks. + Added a check in pngwrite.c to detect invalid small window_bits sizes. + +Version 1.0.3d [September 4, 1999] + Fixed type casting of igamma in pngrutil.c + Added new png_expand functions to scripts/pngdef.pas and pngos2.def + Added a demo read_user_transform_fn that examines the row filters in pngtest.c + +Version 1.0.4 [September 24, 1999, not distributed publicly] + Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined + Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h + Made several minor corrections to pngtest.c + Renamed the makefiles with longer but more user friendly extensions. + Copied the PNG copyright and license to a separate LICENSE file. + Revised documentation, png.h, and example.c to remove reference to + "viewing_gamma" which no longer appears in the PNG specification. + Revised pngvcrd.c to use MMX code for interlacing only on the final pass. + Updated pngvcrd.c to use the faster C filter algorithms from libpng-1.0.1a + Split makefile.win32vc into two versions, makefile.vcawin32 (uses MMX + assembler code) and makefile.vcwin32 (doesn't). + Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING) + Added a copy of pngnow.png to the distribution. + +Version 1.0.4a [September 25, 1999] + Increase max_pixel_depth in pngrutil.c if a user transform needs it. + Changed several division operations to right-shifts in pngvcrd.c + +Version 1.0.4b [September 30, 1999] + Added parentheses in line 3732 of pngvcrd.c + Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1 + +Version 1.0.4c [October 1, 1999] + Added a "png_check_version" function in png.c and pngtest.c that will generate + a helpful compiler error if an old png.h is found in the search path. + Changed type of png_user_transform_depth|channels from int to png_byte. + Added "Libpng is OSI Certified Open Source Software" statement to png.h + +Version 1.0.4d [October 6, 1999] + Changed 0.45 to 0.45455 in png_set_sRGB() + Removed unused PLTE entries from pngnow.png + Re-enabled some parts of pngvcrd.c (png_combine_row) that work properly. + +Version 1.0.4e [October 10, 1999] + Fixed sign error in pngvcrd.c (Greg Roelofs) + Replaced some instances of memcpy with simple assignments in pngvcrd (GR-P) + +Version 1.0.4f [October 15, 1999] + Surrounded example.c code with #if 0 .. #endif to prevent people from + inadvertently trying to compile it. + Changed png_get_header_version() from a function to a macro in png.h + Added type casting mostly in pngrtran.c and pngwtran.c + Removed some pointless "ptr = NULL" in pngmem.c + Added a "contrib" directory containing the source code from Greg's book. + +Version 1.0.5 [October 15, 1999] + Minor editing of the INSTALL and README files. + +Version 1.0.5a [October 23, 1999] + Added contrib/pngsuite and contrib/pngminus (Willem van Schaik) + Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans) + Further optimization and bugfix of pngvcrd.c + Revised pngset.c so that it does not allocate or free memory in the user's + text_ptr structure. Instead, it makes its own copy. + Created separate write_end_info_struct in pngtest.c for a more severe test. + Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak. + +Version 1.0.5b [November 23, 1999] + Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and + PNG_FLAG_WROTE_tIME from flags to mode. + Added png_write_info_before_PLTE() function. + Fixed some typecasting in contrib/gregbook/*.c + Updated scripts/makevms.com and added makevms.com to contrib/gregbook + and contrib/pngminus (Martin Zinser) + +Version 1.0.5c [November 26, 1999] + Moved png_get_header_version from png.h to png.c, to accommodate ansi2knr. + Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to + accommodate making DLL's: Moved usr_png_ver from global variable to function + png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and + eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays + into pngtypes.h. Eliminated use of global png_pass arrays. Declared the + png_CHNK and png_pass arrays to be "const". Made the global arrays + available to applications (although none are used in libpng itself) when + PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined. + Removed some extraneous "-I" from contrib/pngminus/makefile.std + Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2. + Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3 + +Version 1.0.5d [November 29, 1999] + Add type cast (png_const_charp) two places in png.c + Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays. + Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available + to applications a macro "PNG_USE_LOCAL_ARRAYS". + comment out (with #ifdef) all the new declarations when + PNG_USE_GLOBAL_ARRAYS is defined. + Added PNG_EXPORT_VAR macro to accommodate making DLL's. + +Version 1.0.5e [November 30, 1999] + Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text + structure; refactored the inflate/deflate support to make adding new chunks + with trailing compressed parts easier in the future, and added new functions + png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP, + png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond). + NOTE: Applications that write text chunks MUST define png_text->lang + before calling png_set_text(). It must be set to NULL if you want to + write tEXt or zTXt chunks. If you want your application to be able to + run with older versions of libpng, use + + #ifdef PNG_iTXt_SUPPORTED + png_text[i].lang = NULL; + #endif + + Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned + offsets (Eric S. Raymond). + Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into + PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED + macros, leaving the separate macros also available. + Removed comments on #endifs at the end of many short, non-nested #if-blocks. + +Version 1.0.5f [December 6, 1999] + Changed makefile.solaris to issue a warning about potential problems when + the ucb "ld" is in the path ahead of the ccs "ld". + Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3. + Added sCAL chunk support (Eric S. Raymond). + +Version 1.0.5g [December 7, 1999] + Fixed "png_free_spallettes" typo in png.h + Added code to handle new chunks in pngpread.c + Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block + Added "translated_key" to png_text structure and png_write_iTXt(). + Added code in pngwrite.c to work around a newly discovered zlib bug. + +Version 1.0.5h [December 10, 1999] + NOTE: regarding the note for version 1.0.5e, the following must also + be included in your code: + png_text[i].translated_key = NULL; + Unknown chunk handling is now supported. + Option to eliminate all floating point support was added. Some new + fixed-point functions such as png_set_gAMA_fixed() were added. + Expanded tabs and removed trailing blanks in source files. + +Version 1.0.5i [December 13, 1999] + Added some type casts to silence compiler warnings. + Renamed "png_free_spalette" to "png_free_spalettes" for consistency. + Removed leading blanks from a #define in pngvcrd.c + Added some parameters to the new png_set_keep_unknown_chunks() function. + Added a test for up->location != 0 in the first instance of writing + unknown chunks in pngwrite.c + Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to + prevent recursion. + Added png_free_hIST() function. + Various patches to fix bugs in the sCAL and integer cHRM processing, + and to add some convenience macros for use with sCAL. + +Version 1.0.5j [December 21, 1999] + Changed "unit" parameter of png_write_sCAL from png_byte to int, to work + around buggy compilers. + Added new type "png_fixed_point" for integers that hold float*100000 values + Restored backward compatibility of tEXt/zTXt chunk processing: + Restored the first four members of png_text to the same order as v.1.0.5d. + Added members "lang_key" and "itxt_length" to png_text struct. Set + text_length=0 when "text" contains iTXt data. Use the "compression" + member to distinguish among tEXt/zTXt/iTXt types. Added + PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros. + The "Note" above, about backward incompatibility of libpng-1.0.5e, no + longer applies. + Fixed png_read|write_iTXt() to read|write parameters in the right order, + and to write the iTXt chunk after IDAT if it appears in the end_ptr. + Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs) + Reversed the order of trying to write floating-point and fixed-point gAMA. + +Version 1.0.5k [December 27, 1999] + Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))" + Added png_handle_as_unknown() function (Glenn) + Added png_free_chunk_list() function and chunk_list and num_chunk_list members + of png_ptr. + Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE. + Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings + about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored) + Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR). + Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is. + Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP(). + +Version 1.0.5l [January 1, 2000] + Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr() + for setting a callback function to handle unknown chunks and for + retrieving the associated user pointer (Glenn). + +Version 1.0.5m [January 7, 2000] + Added high-level functions png_read_png(), png_write_png(), png_free_pixels(). + +Version 1.0.5n [January 9, 2000] + Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its + own memory for info_ptr->palette. This makes it safe for the calling + application to free its copy of the palette any time after it calls + png_set_PLTE(). + +Version 1.0.5o [January 20, 2000] + Cosmetic changes only (removed some trailing blanks and TABs) + +Version 1.0.5p [January 31, 2000] + Renamed pngdll.mak to makefile.bd32 + Cosmetic changes in pngtest.c + +Version 1.0.5q [February 5, 2000] + Relocated the makefile.solaris warning about PATH problems. + Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg) + Revised makefile.gcmmx + Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros + +Version 1.0.5r [February 7, 2000] + Removed superfluous prototype for png_get_itxt from png.h + Fixed a bug in pngrtran.c that improperly expanded the background color. + Return *num_text=0 from png_get_text() when appropriate, and fix documentation + of png_get_text() in libpng.txt/libpng.3. + +Version 1.0.5s [February 18, 2000] + Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the + new error handler that's planned for the next libpng release, and changed + example.c, pngtest.c, and contrib programs to use this macro. + Revised some of the DLL-export macros in pngconf.h (Greg Roelofs) + Fixed a bug in png_read_png() that caused it to fail to expand some images + that it should have expanded. + Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions + in pngget.c + Changed the allocation of palette, history, and trans arrays back to + the version 1.0.5 method (linking instead of copying) which restores + backward compatibility with version 1.0.5. Added some remarks about + that in example.c. Added "free_me" member to info_ptr and png_ptr + and added png_free_data() function. + Updated makefile.linux and makefile.gccmmx to make directories conditionally. + Made cosmetic changes to pngasmrd.h + Added png_set_rows() and png_get_rows(), for use with png_read|write_png(). + Modified png_read_png() to allocate info_ptr->row_pointers only if it + hasn't already been allocated. + +Version 1.0.5t [March 4, 2000] + Changed png_jmp_env() migration aiding macro to png_jmpbuf(). + Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c + Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when + PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b + Files in contrib/gregbook were revised to use png_jmpbuf() and to select + a 24-bit visual if one is available, and to allow abbreviated options. + Files in contrib/pngminus were revised to use the png_jmpbuf() macro. + Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s + +Version 1.0.5u [March 5, 2000] + Simplified the code that detects old png.h in png.c and pngtest.c + Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp) + Increased precision of rgb_to_gray calculations from 8 to 15 bits and + added png_set_rgb_to_gray_fixed() function. + Added makefile.bc32 (32-bit Borland C++, C mode) + +Version 1.0.5v [March 11, 2000] + Added some parentheses to the png_jmpbuf macro definition. + Updated references to the zlib home page, which has moved to freesoftware.com. + Corrected bugs in documentation regarding png_read_row() and png_write_row(). + Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt. + Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3, + revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin) + +Version 1.0.6 [March 20, 2000] + Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c + Added makefile.sggcc (SGI IRIX with gcc) + +Version 1.0.6d [April 7, 2000] + Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO + Added data_length parameter to png_decompress_chunk() function + Revised documentation to remove reference to abandoned png_free_chnk functions + Fixed an error in png_rgb_to_gray_fixed() + Revised example.c, usage of png_destroy_write_struct(). + Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file + Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c + Simplify png_sig_bytes() function to remove use of non-ISO-C strdup(). + +Version 1.0.6e [April 9, 2000] + Added png_data_freer() function. + In the code that checks for over-length tRNS chunks, added check of + info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann) + Minor revisions of libpng.txt/libpng.3. + Check for existing data and free it if the free_me flag is set, in png_set_*() + and png_handle_*(). + Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED + is defined. + Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c + and mentioned the purposes of the two macros in libpng.txt/libpng.3. + +Version 1.0.6f [April 14, 2000] + Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data. + Add checks in png_set_text() for NULL members of the input text structure. + Revised libpng.txt/libpng.3. + Removed superfluous prototype for png_set_iTXt from png.h + Removed "else" from pngread.c, after png_error(), and changed "0" to "length". + Changed several png_errors about malformed ancillary chunks to png_warnings. + +Version 1.0.6g [April 24, 2000] + Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined. + Relocated paragraph about png_set_background() in libpng.3/libpng.txt + and other revisions (Matthias Benckmann) + Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and + png_ptr members to restore binary compatibility with libpng-1.0.5 + (breaks compatibility with libpng-1.0.6). + +Version 1.0.6h [April 24, 2000] + Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds + libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h) + This is a temporary change for test purposes. + +Version 1.0.6i [May 2, 2000] + Rearranged some members at the end of png_info and png_struct, to put + unknown_chunks_num and free_me within the original size of the png_structs + and free_me, png_read_user_fn, and png_free_fn within the original png_info, + because some old applications allocate the structs directly instead of + using png_create_*(). + Added documentation of user memory functions in libpng.txt/libpng.3 + Modified png_read_png so that it will use user_allocated row_pointers + if present, unless free_me directs that it be freed, and added description + of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3. + Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version + 1.00) members of png_struct and png_info, to regain binary compatibility + when you define this macro. Capabilities lost in this event + are user transforms (new in version 1.0.0),the user transform pointer + (new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT, + the high-level interface, and unknown chunks support (all new in 1.0.6). + This was necessary because of old applications that allocate the structs + directly as authors were instructed to do in libpng-0.88 and earlier, + instead of using png_create_*(). + Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which + can be used to detect codes that directly allocate the structs, and + code to check these modes in png_read_init() and png_write_init() and + generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED + was not defined. + Added makefile.intel and updated makefile.watcom (Pawel Mrochen) + +Version 1.0.6j [May 3, 2000] + Overloaded png_read_init() and png_write_init() with macros that convert + calls to png_read_init_2() or png_write_init_2() that check the version + and structure sizes. + +Version 1.0.7beta11 [May 7, 2000] + Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes + which are no longer used. + Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is + defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXt_SUPPORTED + is defined. + Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory + overrun when old applications fill the info_ptr->text structure directly. + Added PNGAPI macro, and added it to the definitions of all exported functions. + Relocated version macro definitions ahead of the includes of zlib.h and + pngconf.h in png.h. + +Version 1.0.7beta12 [May 12, 2000] + Revised pngset.c to avoid a problem with expanding the png_debug macro. + Deleted some extraneous defines from pngconf.h + Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined. + Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined. + Added png_access_version_number() function. + Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data(). + Expanded libpng.3/libpng.txt information about png_data_freer(). + +Version 1.0.7beta14 [May 17, 2000] (beta13 was not published) + Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as + warnings instead of errors, as pngrutil.c does. + Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png() + will actually write IDATs. + Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32. + Make png_free_data() ignore its final parameter except when freeing data + that can have multiple instances (text, sPLT, unknowns). + Fixed a new bug in png_set_rows(). + Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5. + Added png_set_invalid() function. + Fixed incorrect illustrations of png_destroy_write_struct() in example.c. + +Version 1.0.7beta15 [May 30, 2000] + Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce + fewer error messages. + Rearranged checks for Z_OK to check the most likely path first in pngpread.c + and pngwutil.c. + Added checks in pngtest.c for png_create_*() returning NULL, and mentioned + in libpng.txt/libpng.3 the need for applications to check this. + Changed names of png_default_*() functions in pngtest to pngtest_*(). + Changed return type of png_get_x|y_offset_*() from png_uint_32 to png_int_32. + Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c + Set each pointer to NULL after freeing it in png_free_data(). + Worked around a problem in pngconf.h; AIX's strings.h defines an "index" + macro that conflicts with libpng's png_color_16.index. (Dimitri + Papadapoulos) + Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux). + +Version 1.0.7beta16 [June 4, 2000] + Revised the workaround of AIX string.h "index" bug. + Added a check for overlength PLTE chunk in pngrutil.c. + Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer + indexing in pngrutil.c and pngwutil.c to accommodate a buggy compiler. + Added a warning in png_decompress_chunk() when it runs out of data, e.g. + when it tries to read an erroneous PhotoShop iCCP chunk. + Added PNG_USE_DLL macro. + Revised the copyright/disclaimer/license notice. + Added contrib/msvctest directory + +Version 1.0.7rc1 [June 9, 2000] + Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA (0x0400 not 0x0200) + Added contrib/visupng directory (Willem van Schaik) + +Version 1.0.7beta18 [June 23, 2000] + Revised PNGAPI definition, and pngvcrd.c to work with __GCC__ + and do not redefine PNGAPI if it is passed in via a compiler directive. + Revised visupng/PngFile.c to remove returns from within the Try block. + Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros. + Updated contrib/visupng/cexcept.h to version 1.0.0. + Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks. + +Version 1.0.7rc2 [June 28, 2000] + Updated license to include disclaimers required by UCITA. + Fixed "DJBPP" typo in pnggccrd.c introduced in beta18. + +Version 1.0.7 [July 1, 2000] + Revised the definition of "trans_values" in libpng.3/libpng.txt + +Version 1.0.8beta1 [July 8, 2000] + Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks. + Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and + pngwutil.c. + Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h. + Removed unused "#include " from png.c + Added WindowsCE support. + Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment. + +Version 1.0.8beta2 [July 10, 2000] + Added project files to the wince directory and made further revisions + of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE. + +Version 1.0.8beta3 [July 11, 2000] + Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS() + for indexed-color input files to avoid potential double-freeing trans array + under some unusual conditions; problem was introduced in version 1.0.6f. + Further revisions to pngtest.c and files in the wince subdirectory. + +Version 1.0.8beta4 [July 14, 2000] + Added the files pngbar.png and pngbar.jpg to the distribution. + Added makefile.cygwin, and cygwin support in pngconf.h + Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory) + +Version 1.0.8rc1 [July 16, 2000] + Revised png_debug() macros and statements to eliminate compiler warnings. + +Version 1.0.8 [July 24, 2000] + Added png_flush() in pngwrite.c, after png_write_IEND(). + Updated makefile.hpux to build a shared library. + +Version 1.0.9beta1 [November 10, 2000] + Fixed typo in scripts/makefile.hpux + Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser) + Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser) + Changed "cdrom.com" in documentation to "libpng.org" + Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg). + Changed type of "params" from voidp to png_voidp in png_read|write_png(). + Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h. + Revised the 3 instances of WRITEFILE in pngtest.c. + Relocated "msvc" and "wince" project subdirectories into "dll" subdirectory. + Updated png.rc in dll/msvc project + Revised makefile.dec to define and use LIBPATH and INCPATH + Increased size of global png_libpng_ver[] array from 12 to 18 chars. + Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const. + Removed duplicate png_crc_finish() from png_handle_bKGD() function. + Added a warning when application calls png_read_update_info() multiple times. + Revised makefile.cygwin + Fixed bugs in iCCP support in pngrutil.c and pngwutil.c. + Replaced png_set_empty_plte_permitted() with png_permit_mng_features(). + +Version 1.0.9beta2 [November 19, 2000] + Renamed the "dll" subdirectory "projects". + Added borland project files to "projects" subdirectory. + Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate. + Add error message in png_set_compression_buffer_size() when malloc fails. + +Version 1.0.9beta3 [November 23, 2000] + Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project. + Removed the png_flush() in pngwrite.c that crashes some applications + that don't set png_output_flush_fn. + Added makefile.macosx and makefile.aix to scripts directory. + +Version 1.0.9beta4 [December 1, 2000] + Change png_chunk_warning to png_warning in png_check_keyword(). + Increased the first part of msg buffer from 16 to 18 in png_chunk_error(). + +Version 1.0.9beta5 [December 15, 2000] + Added support for filter method 64 (for PNG datastreams embedded in MNG). + +Version 1.0.9beta6 [December 18, 2000] + Revised png_set_filter() to accept filter method 64 when appropriate. + Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to + help prevent applications from using MNG features in PNG datastreams. + Added png_permit_mng_features() function. + Revised libpng.3/libpng.txt. Changed "filter type" to "filter method". + +Version 1.0.9rc1 [December 23, 2000] + Revised test for PNG_HAVE_PNG_SIGNATURE in pngrutil.c + Fixed error handling of unknown compression type in png_decompress_chunk(). + In pngconf.h, define __cdecl when _MSC_VER is defined. + +Version 1.0.9beta7 [December 28, 2000] + Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places. + Revised memory management in png_set_hIST and png_handle_hIST in a backward + compatible manner. PLTE and tRNS were revised similarly. + Revised the iCCP chunk reader to ignore trailing garbage. + +Version 1.0.9beta8 [January 12, 2001] + Moved pngasmrd.h into pngconf.h. + Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop. + +Version 1.0.9beta9 [January 15, 2001] + Added png_set_invalid, png_permit_mng_features, and png_mmx_supported to + wince and msvc project module definition files. + Minor revision of makefile.cygwin. + Fixed bug with progressive reading of narrow interlaced images in pngpread.c + +Version 1.0.9beta10 [January 16, 2001] + Do not typedef png_FILE_p in pngconf.h when PNG_NO_STDIO is defined. + Fixed "png_mmx_supported" typo in project definition files. + +Version 1.0.9beta11 [January 19, 2001] + Updated makefile.sgi to make shared library. + Removed png_mmx_support() function and disabled PNG_MNG_FEATURES_SUPPORTED + by default, for the benefit of DLL forward compatibility. These will + be re-enabled in version 1.2.0. + +Version 1.0.9rc2 [January 22, 2001] + Revised cygwin support. + +Version 1.0.9 [January 31, 2001] + Added check of cygwin's ALL_STATIC in pngconf.h + Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos. + +Version 1.0.10beta1 [March 14, 2001] + Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc. + Reformatted libpng.3 to eliminate bad line breaks. + Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c + Added prototype for png_mmx_support() near the top of pnggccrd.c + Moved some error checking from png_handle_IHDR to png_set_IHDR. + Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros. + Revised png_mmx_support() function in pnggccrd.c + Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c + Fixed memory leak in contrib/visupng/PngFile.c + Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version) + Added warnings when retrieving or setting gamma=0. + Increased the first part of msg buffer from 16 to 18 in png_chunk_warning(). + +Version 1.0.10rc1 [March 23, 2001] + Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy, + and png_strlen. + Revised png_mmx_supported() function in pnggccrd.c to return proper value. + Fixed bug in progressive reading (pngpread.c) with small images (height < 8). + +Version 1.0.10 [March 30, 2001] + Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin + Added beos project files (Chris Herborth) + +Version 1.0.11beta1 [April 3, 2001] + Added type casts on several png_malloc() calls (Dimitri Papadapoulos). + Removed a no-longer needed AIX work-around from pngconf.h + Changed several "//" single-line comments to C-style in pnggccrd.c + +Version 1.0.11beta2 [April 11, 2001] + Removed PNGAPI from several functions whose prototypes did not have PNGAPI. + Updated scripts/pngos2.def + +Version 1.0.11beta3 [April 14, 2001] + Added checking the results of many instances of png_malloc() for NULL + +Version 1.0.11beta4 [April 20, 2001] + Undid the changes from version 1.0.11beta3. Added a check for NULL return + from user's malloc_fn(). + Removed some useless type casts of the NULL pointer. + Added makefile.netbsd + +Version 1.0.11 [April 27, 2001] + Revised makefile.netbsd + +Version 1.0.12beta1 [May 14, 2001] + Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot) + Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h + Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings. + Eliminated the png_error about apps using png_read|write_init(). Instead, + libpng will reallocate the png_struct and info_struct if they are too small. + This retains future binary compatibility for old applications written for + libpng-0.88 and earlier. + +Version 1.2.0beta1 [May 6, 2001] + Bumped DLLNUM to 2. + Re-enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED + by default. + Added runtime selection of MMX features. + Added png_set_strip_error_numbers function and related macros. + +Version 1.2.0beta2 [May 7, 2001] + Finished merging 1.2.0beta1 with version 1.0.11 + Added a check for attempts to read or write PLTE in grayscale PNG datastreams. + +Version 1.2.0beta3 [May 17, 2001] + Enabled user memory function by default. + Modified png_create_struct so it passes user mem_ptr to user memory allocator. + Increased png_mng_features flag from png_byte to png_uint_32. + Bumped shared-library (so-number) and dll-number to 3. + +Version 1.2.0beta4 [June 23, 2001] + Check for missing profile length field in iCCP chunk and free chunk_data + in case of truncated iCCP chunk. + Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc + Bumped dll-number from 2 to 3 in makefile.cygwin + Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly + if user attempts to run it on an 8-bit display. + Updated contrib/gregbook + Use png_malloc instead of png_zalloc to allocate palette in pngset.c + Updated makefile.ibmc + Added some typecasts to eliminate gcc 3.0 warnings. Changed prototypes + of png_write_oFFS width and height from png_uint_32 to png_int_32. + Updated example.c + Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c + +Version 1.2.0beta5 [August 8, 2001] + Revised contrib/gregbook + Revised makefile.gcmmx + Revised pnggccrd.c to conditionally compile some thread-unsafe code only + when PNG_THREAD_UNSAFE_OK is defined. + Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with + value exceeding 2^bit_depth-1 + Revised makefile.sgi and makefile.sggcc + Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c + Removed restriction that do_invert_mono only operate on 1-bit opaque files + +Version 1.2.0 [September 1, 2001] + Changed a png_warning() to png_debug() in pnggccrd.c + Fixed contrib/gregbook/rpng-x.c, rpng2-x.c to avoid crash with XFreeGC(). + +Version 1.2.1beta1 [October 19, 2001] + Revised makefile.std in contrib/pngminus + Include background_1 in png_struct regardless of gamma support. + Revised makefile.netbsd and makefile.macosx, added makefile.darwin. + Revised example.c to provide more details about using row_callback(). + +Version 1.2.1beta2 [October 25, 2001] + Added type cast to each NULL appearing in a function call, except for + WINCE functions. + Added makefile.so9. + +Version 1.2.1beta3 [October 27, 2001] + Removed type casts from all NULLs. + Simplified png_create_struct_2(). + +Version 1.2.1beta4 [November 7, 2001] + Revised png_create_info_struct() and png_creat_struct_2(). + Added error message if png_write_info() was omitted. + Type cast NULLs appearing in function calls when _NO_PROTO or + PNG_TYPECAST_NULL is defined. + +Version 1.2.1rc1 [November 24, 2001] + Type cast NULLs appearing in function calls except when PNG_NO_TYPECAST_NULL + is defined. + Changed typecast of "size" argument to png_size_t in pngmem.c calls to + the user malloc_fn, to agree with the prototype in png.h + Added a pop/push operation to pnggccrd.c, to preserve Eflag (Maxim Sobolev) + Updated makefile.sgi to recognize LIBPATH and INCPATH. + Updated various makefiles so "make clean" does not remove previous major + version of the shared library. + +Version 1.2.1rc2 [December 4, 2001] + Always allocate 256-entry internal palette, hist, and trans arrays, to + avoid out-of-bounds memory reference caused by invalid PNG datastreams. + Added a check for prefix_length > data_length in iCCP chunk handler. + +Version 1.2.1 [December 7, 2001] + None. + +Version 1.2.2beta1 [February 22, 2002] + Fixed a bug with reading the length of iCCP profiles (Larry Reeves). + Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate + libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h + Revised makefile.darwin to remove "-undefined suppress" option. + Added checks for gamma and chromaticity values over 21474.83, which exceed + the limit for PNG unsigned 32-bit integers when encoded. + Revised calls to png_create_read_struct() and png_create_write_struct() + for simpler debugging. + Revised png_zalloc() so zlib handles errors (uses PNG_FLAG_MALLOC_NULL_MEM_OK) + +Version 1.2.2beta2 [February 23, 2002] + Check chunk_length and idat_size for invalid (over PNG_MAX_UINT) lengths. + Check for invalid image dimensions in png_get_IHDR. + Added missing "fi;" in the install target of the SGI makefiles. + Added install-static to all makefiles that make shared libraries. + Always do gamma compensation when image is partially transparent. + +Version 1.2.2beta3 [March 7, 2002] + Compute background.gray and background_1.gray even when color_type is RGB + in case image gets reduced to gray later. + Modified shared-library makefiles to install pkgconfig/libpngNN.pc. + Export (with PNGAPI) png_zalloc, png_zfree, and png_handle_as_unknown + Removed unused png_write_destroy_info prototype from png.h + Eliminated incorrect use of width_mmx from pnggccrd.c in pixel_bytes == 8 case + Added install-shared target to all makefiles that make shared libraries. + Stopped a double free of palette, hist, and trans when not using free_me. + Added makefile.32sunu for Sun Ultra 32 and makefile.64sunu for Sun Ultra 64. + +Version 1.2.2beta4 [March 8, 2002] + Compute background.gray and background_1.gray even when color_type is RGB + in case image gets reduced to gray later (Jason Summers). + Relocated a misplaced /bin/rm in the "install-shared" makefile targets + Added PNG_1_0_X macro which can be used to build a 1.0.x-compatible library. + +Version 1.2.2beta5 [March 26, 2002] + Added missing PNGAPI to several function definitions. + Check for invalid bit_depth or color_type in png_get_IHDR(), and + check for missing PLTE or IHDR in png_push_read_chunk() (Matthias Clasen). + Revised iTXt support to accept NULL for lang and lang_key. + Compute gamma for color components of background even when color_type is gray. + Changed "()" to "{}" in scripts/libpng.pc.in. + Revised makefiles to put png.h and pngconf.h only in $prefix/include/libpngNN + Revised makefiles to make symlink to libpng.so.NN in addition to libpngNN.so + +Version 1.2.2beta6 [March 31, 2002] + +Version 1.0.13beta1 [March 31, 2002] + Prevent png_zalloc() from trying to memset memory that it failed to acquire. + Add typecasts of PNG_MAX_UINT in pngset_cHRM_fixed() (Matt Holgate). + Ensure that the right function (user or default) is used to free the + png_struct after an error in png_create_read_struct_2(). + +Version 1.2.2rc1 [April 7, 2002] + +Version 1.0.13rc1 [April 7, 2002] + Save the ebx register in pnggccrd.c (Sami Farin) + Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner). + Updated makefiles to put headers in include/libpng and remove old include/*.h. + +Version 1.2.2 [April 15, 2002] + +Version 1.0.13 [April 15, 2002] + Revised description of png_set_filter() in libpng.3/libpng.txt. + Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd + +Version 1.0.13patch01 [April 17, 2002] + +Version 1.2.2patch01 [April 17, 2002] + Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and + makefile.sggcc + Fixed VER -> PNGVER typo in makefile.macosx and added install-static to + install + Added install: target to makefile.32sunu and makefile.64sunu + +Version 1.0.13patch03 [April 18, 2002] + +Version 1.2.2patch03 [April 18, 2002] + Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng + subdirectory to libpngNN subdirectory without the full pathname. + Moved generation of libpng.pc from "install" to "all" in 15 makefiles. + +Version 1.2.3rc1 [April 28, 2002] + Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos). + Added $(DESTDIR) feature to 24 makefiles (Tim Mooney) + Fixed bug with $prefix, should be $(prefix) in makefile.hpux. + Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin + Added a link from libpngNN.pc to libpng.pc in 15 makefiles. + Added links from include/libpngNN/*.h to include/*.h in 24 makefiles. + Revised makefile.darwin to make relative links without full pathname. + Added setjmp() at the end of png_create_*_struct_2() in case user forgets + to put one in their application. + Restored png_zalloc() and png_zfree() prototypes to version 1.2.1 and + removed them from module definition files. + +Version 1.2.3rc2 [May 1, 2002] + Fixed bug in reporting number of channels in pngget.c and pngset.c, + that was introduced in version 1.2.2beta5. + Exported png_zalloc(), png_zfree(), png_default_read(), png_default_write(), + png_default_flush(), and png_push_fill_buffer() and included them in + module definition files. + Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles. + +Version 1.2.3rc3 [May 1, 2002] + Revised prototype for png_default_flush() + Remove old libpng.pc and libpngNN.pc before installing new ones. + +Version 1.2.3rc4 [May 2, 2002] + Typos in *.def files (png_default_read|write -> png_default_read|write_data) + In makefiles, changed rm libpng.NN.pc to rm libpngNN.pc + Added libpng-config and libpngNN-config and modified makefiles to install + them. + Changed $(MANPATH) to $(DESTDIR)$(MANPATH) in makefiles + Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp + +Version 1.2.3rc5 [May 11, 2002] + Changed "error" and "message" in prototypes to "error_message" and + "warning_message" to avoid namespace conflict. + Revised 15 makefiles to build libpng-config from libpng-config-*.in + Once more restored png_zalloc and png_zfree to regular nonexported form. + Restored png_default_read|write_data, png_default_flush, png_read_fill_buffer + to nonexported form, but with PNGAPI, and removed them from module def + files. + +Version 1.2.3rc6 [May 14, 2002] + Removed "PNGAPI" from png_zalloc() and png_zfree() in png.c + Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp. + Removed leftover libpng-config "sed" script from four makefiles. + Revised libpng-config creating script in 16 makefiles. + +Version 1.2.3 [May 22, 2002] + Revised libpng-config target in makefile.cygwin. + Removed description of png_set_mem_fn() from documentation. + Revised makefile.freebsd. + Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR). + Revised projects/msvc/README.txt + Changed -lpng to -lpngNN in LDFLAGS in several makefiles. + +Version 1.2.4beta1 [May 24, 2002] + Added libpng.pc and libpng-config to "all:" target in 16 makefiles. + Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH) + Added missing "\" before closing double quote in makefile.gcmmx. + Plugged various memory leaks; added png_malloc_warn() and png_set_text_2() + functions. + +Version 1.2.4beta2 [June 25, 2002] + Plugged memory leak of png_ptr->current_text (Matt Holgate). + Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison) + Added -soname to the loader flags in makefile.dec, makefile.sgi, and + makefile.sggcc. + Added "test-installed" target to makefile.linux, makefile.gcmmx, + makefile.sgi, and makefile.sggcc. + +Version 1.2.4beta3 [June 28, 2002] + Plugged memory leak of row_buf in pngtest.c when there is a png_error(). + Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data. + Added "test-installed" target to makefile.32sunu, makefile.64sunu, + makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, + makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9. + +Version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002] + Added "test-installed" target to makefile.cygwin and makefile.sco. + Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro. + +Version 1.2.4 and 1.0.14 [July 8, 2002] + Changed png_warning() to png_error() when width is too large to process. + +Version 1.2.4patch01 [July 20, 2002] + Revised makefile.cygwin to use DLL number 12 instead of 13. + +Version 1.2.5beta1 [August 6, 2002] + Added code to contrib/gregbook/readpng2.c to ignore unused chunks. + Replaced toucan.png in contrib/gregbook (it has been corrupt since 1.0.11) + Removed some stray *.o files from contrib/gregbook. + Changed png_error() to png_warning() about "Too much data" in pngpread.c + and about "Extra compressed data" in pngrutil.c. + Prevent png_ptr->pass from exceeding 7 in png_push_finish_row(). + Updated makefile.hpgcc + Updated png.c and pnggccrd.c handling of return from png_mmx_support() + +Version 1.2.5beta2 [August 15, 2002] + Only issue png_warning() about "Too much data" in pngpread.c when avail_in + is nonzero. + Updated makefiles to install a separate libpng.so.3 with its own rpath. + +Version 1.2.5rc1 and 1.0.15rc1 [August 24, 2002] + Revised makefiles to not remove previous minor versions of shared libraries. + +Version 1.2.5rc2 and 1.0.15rc2 [September 16, 2002] + Revised 13 makefiles to remove "-lz" and "-L$(ZLIBLIB)", etc., from shared + library loader directive. + Added missing "$OBJSDLL" line to makefile.gcmmx. + Added missing "; fi" to makefile.32sunu. + +Version 1.2.5rc3 and 1.0.15rc3 [September 18, 2002] + Revised libpng-config script. + +Version 1.2.5 and 1.0.15 [October 3, 2002] + Revised makefile.macosx, makefile.darwin, makefile.hpgcc, and makefile.hpux, + and makefile.aix. + Relocated two misplaced PNGAPI lines in pngtest.c + +Version 1.2.6beta1 [October 22, 2002] + Commented out warning about uninitialized mmx_support in pnggccrd.c. + Changed "IBMCPP__" flag to "__IBMCPP__" in pngconf.h. + Relocated two more misplaced PNGAPI lines in pngtest.c + Fixed memory overrun bug in png_do_read_filler() with 16-bit datastreams, + introduced in version 1.0.2. + Revised makefile.macosx, makefile.dec, makefile.aix, and makefile.32sunu. + +Version 1.2.6beta2 [November 1, 2002] + Added libpng-config "--ldopts" output. + Added "AR=ar" and "ARFLAGS=rc" and changed "ar rc" to "$(AR) $(ARFLAGS)" + in makefiles. + +Version 1.2.6beta3 [July 18, 2004] + Reverted makefile changes from version 1.2.6beta2 and some of the changes + from version 1.2.6beta1; these will be postponed until version 1.2.7. + Version 1.2.6 is going to be a simple bugfix release. + Changed the one instance of "ln -sf" to "ln -f -s" in each Sun makefile. + Fixed potential overrun in pngerror.c by using strncpy instead of memcpy. + Added "#!/bin/sh" at the top of configure, for recognition of the + 'x' flag under Cygwin (Cosmin). + Optimized vacuous tests that silence compiler warnings, in png.c (Cosmin). + Added support for PNG_USER_CONFIG, in pngconf.h (Cosmin). + Fixed the special memory handler for Borland C under DOS, in pngmem.c + (Cosmin). + Removed some spurious assignments in pngrutil.c (Cosmin). + Replaced 65536 with 65536L, and 0xffff with 0xffffL, to silence warnings + on 16-bit platforms (Cosmin). + Enclosed shift op expressions in parentheses, to silence warnings (Cosmin). + Used proper type png_fixed_point, to avoid problems on 16-bit platforms, + in png_handle_sRGB() (Cosmin). + Added compression_type to png_struct, and optimized the window size + inside the deflate stream (Cosmin). + Fixed definition of isnonalpha(), in pngerror.c and pngrutil.c (Cosmin). + Fixed handling of unknown chunks that come after IDAT (Cosmin). + Allowed png_error() and png_warning() to work even if png_ptr == NULL + (Cosmin). + Replaced row_info->rowbytes with row_bytes in png_write_find_filter() + (Cosmin). + Fixed definition of PNG_LIBPNG_VER_DLLNUM (Simon-Pierre). + Used PNG_LIBPNG_VER and PNG_LIBPNG_VER_STRING instead of the hardcoded + values in png.c (Simon-Pierre, Cosmin). + Initialized png_libpng_ver[] with PNG_LIBPNG_VER_STRING (Simon-Pierre). + Replaced PNG_LIBPNG_VER_MAJOR with PNG_LIBPNG_VER_DLLNUM in png.rc + (Simon-Pierre). + Moved the definition of PNG_HEADER_VERSION_STRING near the definitions + of the other PNG_LIBPNG_VER_... symbols in png.h (Cosmin). + Relocated #ifndef PNGAPI guards in pngconf.h (Simon-Pierre, Cosmin). + Updated scripts/makefile.vc(a)win32 (Cosmin). + Updated the MSVC project (Simon-Pierre, Cosmin). + Updated the Borland C++ Builder project (Cosmin). + Avoided access to asm_flags in pngvcrd.c, if PNG_1_0_X is defined (Cosmin). + Commented out warning about uninitialized mmx_support in pngvcrd.c (Cosmin). + Removed scripts/makefile.bd32 and scripts/pngdef.pas (Cosmin). + Added extra guard around inclusion of Turbo C memory headers, in pngconf.h + (Cosmin). + Renamed projects/msvc/ to projects/visualc6/, and projects/borland/ to + projects/cbuilder5/ (Cosmin). + Moved projects/visualc6/png32ms.def to scripts/pngw32.def, + and projects/visualc6/png.rc to scripts/pngw32.rc (Cosmin). + Added projects/visualc6/pngtest.dsp; removed contrib/msvctest/ (Cosmin). + Changed line endings to DOS style in cbuilder5 and visualc6 files, even + in the tar.* distributions (Cosmin). + Updated contrib/visupng/VisualPng.dsp (Cosmin). + Updated contrib/visupng/cexcept.h to version 2.0.0 (Cosmin). + Added a separate distribution with "configure" and supporting files (Junichi). + +Version 1.2.6beta4 [July 28, 2004] + Added user ability to change png_size_t via a PNG_SIZE_T macro. + Added png_sizeof() and png_convert_size() functions. + Added PNG_SIZE_MAX (maximum value of a png_size_t variable. + Added check in png_malloc_default() for (size_t)size != (png_uint_32)size + which would indicate an overflow. + Changed sPLT failure action from png_error to png_warning and abandon chunk. + Changed sCAL and iCCP failures from png_error to png_warning and abandon. + Added png_get_uint_31(png_ptr, buf) function. + Added PNG_UINT_32_MAX macro. + Renamed PNG_MAX_UINT to PNG_UINT_31_MAX. + Made png_zalloc() issue a png_warning and return NULL on potential + overflow. + Turn on PNG_NO_ZALLOC_ZERO by default in version 1.2.x + Revised "clobber list" in pnggccrd.c so it will compile under gcc-3.4. + Revised Borland portion of png_malloc() to return NULL or issue + png_error() according to setting of PNG_FLAG_MALLOC_NULL_MEM_OK. + Added PNG_NO_SEQUENTIAL_READ_SUPPORTED macro to conditionally remove + sequential read support. + Added some "#if PNG_WRITE_SUPPORTED" blocks. + Added #ifdef to remove some redundancy in png_malloc_default(). + Use png_malloc instead of png_zalloc to allocate the palette. + +Version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004] + Fixed buffer overflow vulnerability (CVE-2004-0597) in png_handle_tRNS(). + Fixed NULL dereference vulnerability (CVE-2004-0598) in png_handle_iCCP(). + Fixed integer overflow vulnerability (CVE-2004-0599) in png_read_png(). + Fixed some harmless bugs in png_handle_sBIT, etc, that would cause + duplicate chunk types to go undetected. + Fixed some timestamps in the -config version + Rearranged order of processing of color types in png_handle_tRNS(). + Added ROWBYTES macro to calculate rowbytes without integer overflow. + Updated makefile.darwin and removed makefile.macosx from scripts directory. + Imposed default one million column, one-million row limits on the image + dimensions, and added png_set_user_limits() function to override them. + Revised use of PNG_SET_USER_LIMITS_SUPPORTED macro. + Fixed wrong cast of returns from png_get_user_width|height_max(). + Changed some "keep the compiler happy" from empty statements to returns, + Revised libpng.txt to remove 1.2.x stuff from the 1.0.x distribution + +Version 1.0.16rc2 and 1.2.6rc2 [August 7, 2004] + Revised makefile.darwin and makefile.solaris. Removed makefile.macosx. + Revised pngtest's png_debug_malloc() to use png_malloc() instead of + png_malloc_default() which is not supposed to be exported. + Fixed off-by-one error in one of the conversions to PNG_ROWBYTES() in + pngpread.c. Bug was introduced in 1.2.6rc1. + Fixed bug in RGB to RGBX transformation introduced in 1.2.6rc1. + Fixed old bug in RGB to Gray transformation. + Fixed problem with 64-bit compilers by casting arguments to abs() + to png_int_32. + Changed "ln -sf" to "ln -f -s" in three makefiles (solaris, sco, so9). + Changed "HANDLE_CHUNK_*" to "PNG_HANDLE_CHUNK_*" (Cosmin) + Added "-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)" to 15 *NIX makefiles. + Added code to update the row_info->colortype in png_do_read_filler() (MSB). + +Version 1.0.16rc3 and 1.2.6rc3 [August 9, 2004] + Eliminated use of "abs()" in testing cHRM and gAMA values, to avoid + trouble with some 64-bit compilers. Created PNG_OUT_OF_RANGE() macro. + Revised documentation of png_set_keep_unknown_chunks(). + Check handle_as_unknown status in pngpread.c, as in pngread.c previously. + Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_INTERNAL section of png.h + Added "rim" definitions for CONST4 and CONST6 in pnggccrd.c + +Version 1.0.16rc4 and 1.2.6rc4 [August 10, 2004] + Fixed mistake in pngtest.c introduced in 1.2.6rc2 (declaration of + "pinfo" was out of place). + +Version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004] + Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED + section of png.h where they were inadvertently placed in version rc3. + +Version 1.2.6 and 1.0.16 [August 15, 2004] + Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1. + +Version 1.2.7beta1 [August 26, 2004] + Removed unused pngasmrd.h file. + Removed references to uu.net for archived files. Added references to + PNG Spec (second edition) and the PNG ISO/IEC Standard. + Added "test-dd" target in 15 makefiles, to run pngtest in DESTDIR. + Fixed bug with "optimized window size" in the IDAT datastream, that + causes libpng to write PNG files with incorrect zlib header bytes. + +Version 1.2.7beta2 [August 28, 2004] + Fixed bug with sCAL chunk and big-endian machines (David Munro). + Undid new code added in 1.2.6rc2 to update the color_type in + png_set_filler(). + Added png_set_add_alpha() that updates color type. + +Version 1.0.17rc1 and 1.2.7rc1 [September 4, 2004] + Revised png_set_strip_filler() to not remove alpha if color_type has alpha. + +Version 1.2.7 and 1.0.17 [September 12, 2004] + Added makefile.hp64 + Changed projects/msvc/png32ms.def to scripts/png32ms.def in makefile.cygwin + +Version 1.2.8beta1 [November 1, 2004] + Fixed bug in png_text_compress() that would fail to complete a large block. + Fixed bug, introduced in libpng-1.2.7, that overruns a buffer during + strip alpha operation in png_do_strip_filler(). + Added PNG_1_2_X definition in pngconf.h + Use #ifdef to comment out png_info_init in png.c and png_read_init in + pngread.c (as of 1.3.0) + +Version 1.2.8beta2 [November 2, 2004] + Reduce color_type to a nonalpha type after strip alpha operation in + png_do_strip_filler(). + +Version 1.2.8beta3 [November 3, 2004] + Revised definitions of PNG_MAX_UINT_32, PNG_MAX_SIZE, and PNG_MAXSUM + +Version 1.2.8beta4 [November 12, 2004] + Fixed (again) definition of PNG_LIBPNG_VER_DLLNUM in png.h (Cosmin). + Added PNG_LIBPNG_BUILD_PRIVATE in png.h (Cosmin). + Set png_ptr->zstream.data_type to Z_BINARY, to avoid unnecessary detection + of data type in deflate (Cosmin). + Deprecated but continue to support SPECIALBUILD and PRIVATEBUILD in favor of + PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. + +Version 1.2.8beta5 [November 20, 2004] + Use png_ptr->flags instead of png_ptr->transformations to pass + PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI + compatibility. + Revised handling of SPECIALBUILD, PRIVATEBUILD, + PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. + +Version 1.2.8rc1 [November 24, 2004] + Moved handling of BUILD macros from pngconf.h to png.h + Added definition of PNG_LIBPNG_BASE_TYPE in png.h, inadvertently + omitted from beta5. + Revised scripts/pngw32.rc + Despammed mailing addresses by masking "@" with "at". + Inadvertently installed a supposedly faster test version of pngrutil.c + +Version 1.2.8rc2 [November 26, 2004] + Added two missing "\" in png.h + Change tests in pngread.c and pngpread.c to + if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) + png_do_read_transformations(png_ptr); + +Version 1.2.8rc3 [November 28, 2004] + Reverted pngrutil.c to version libpng-1.2.8beta5. + Added scripts/makefile.elf with supporting code in pngconf.h for symbol + versioning (John Bowler). + +Version 1.2.8rc4 [November 29, 2004] + Added projects/visualc7 (Simon-pierre). + +Version 1.2.8rc5 [November 29, 2004] + Fixed new typo in scripts/pngw32.rc + +Version 1.2.8 [December 3, 2004] + Removed projects/visualc7, added projects/visualc71. + +Version 1.2.9beta1 [February 21, 2006] + Initialized some structure members in pngwutil.c to avoid gcc-4.0.0 complaints + Revised man page and libpng.txt to make it clear that one should not call + png_read_end or png_write_end after png_read_png or png_write_png. + Updated references to png-mng-implement mailing list. + Fixed an incorrect typecast in pngrutil.c + Added PNG_NO_READ_SUPPORTED conditional for making a write-only library. + Added PNG_NO_WRITE_INTERLACING_SUPPORTED conditional. + Optimized alpha-inversion loops in pngwtran.c + Moved test for nonzero gamma outside of png_build_gamma_table() in pngrtran.c + Make sure num_trans is <= 256 before copying data in png_set_tRNS(). + Make sure num_palette is <= 256 before copying data in png_set_PLTE(). + Interchanged order of write_swap_alpha and write_invert_alpha transforms. + Added parentheses in the definition of PNG_LIBPNG_BUILD_TYPE (Cosmin). + Optimized zlib window flag (CINFO) in contrib/pngsuite/*.png (Cosmin). + Updated scripts/makefile.bc32 for Borland C++ 5.6 (Cosmin). + Exported png_get_uint_32, png_save_uint_32, png_get_uint_16, png_save_uint_16, + png_get_int_32, png_save_int_32, png_get_uint_31 (Cosmin). + Added type cast (png_byte) in png_write_sCAL() (Cosmin). + Fixed scripts/makefile.cygwin (Christian Biesinger, Cosmin). + Default iTXt support was inadvertently enabled. + +Version 1.2.9beta2 [February 21, 2006] + Check for png_rgb_to_gray and png_gray_to_rgb read transformations before + checking for png_read_dither in pngrtran.c + Revised checking of chromaticity limits to accommodate extended RGB + colorspace (John Denker). + Changed line endings in some of the project files to CRLF, even in the + "Unix" tar distributions (Cosmin). + Made png_get_int_32 and png_save_int_32 always available (Cosmin). + Updated scripts/pngos2.def, scripts/pngw32.def and projects/wince/png32ce.def + with the newly exported functions. + Eliminated distributions without the "configure" script. + Updated INSTALL instructions. + +Version 1.2.9beta3 [February 24, 2006] + Fixed CRCRLF line endings in contrib/visupng/VisualPng.dsp + Made libpng.pc respect EXEC_PREFIX (D. P. Kreil, J. Bowler) + Removed reference to pngasmrd.h from Makefile.am + Renamed CHANGES to ChangeLog. + Renamed LICENSE to COPYING. + Renamed ANNOUNCE to NEWS. + Created AUTHORS file. + +Version 1.2.9beta4 [March 3, 2006] + Changed definition of PKGCONFIG from $prefix/lib to $libdir in configure.ac + Reverted to filenames LICENSE and ANNOUNCE; removed AUTHORS and COPYING. + Removed newline from the end of some error and warning messages. + Removed test for sqrt() from configure.ac and configure. + Made swap tables in pngtrans.c PNG_CONST (Carlo Bramix). + Disabled default iTXt support that was inadvertently enabled in + libpng-1.2.9beta1. + Added "OS2" to list of systems that don't need underscores, in pnggccrd.c + Removed libpng version and date from *.c files. + +Version 1.2.9beta5 [March 4, 2006] + Removed trailing blanks from source files. + Put version and date of latest change in each source file, and changed + copyright year accordingly. + More cleanup of configure.ac, Makefile.am, and associated scripts. + Restored scripts/makefile.elf which was inadvertently deleted. + +Version 1.2.9beta6 [March 6, 2006] + Fixed typo (RELEASE) in configuration files. + +Version 1.2.9beta7 [March 7, 2006] + Removed libpng.vers and libpng.sym from libpng12_la_SOURCES in Makefile.am + Fixed inconsistent #ifdef's around png_sig_bytes() and png_set_sCAL_s() + in png.h. + Updated makefile.elf as suggested by debian. + Made cosmetic changes to some makefiles, adding LN_SF and other macros. + Made some makefiles accept "exec_prefix". + +Version 1.2.9beta8 [March 9, 2006] + Fixed some "#if defined (..." which should be "#if defined(..." + Bug introduced in libpng-1.2.8. + Fixed inconsistency in definition of png_default_read_data() + Restored blank that was lost from makefile.sggcc "clean" target in beta7. + Revised calculation of "current" and "major" for irix in ltmain.sh + Changed "mkdir" to "MKDIR_P" in some makefiles. + Separated PNG_EXPAND and PNG_EXPAND_tRNS. + Added png_set_expand_gray_1_2_4_to_8() and deprecated + png_set_gray_1_2_4_to_8() which also expands tRNS to alpha. + +Version 1.2.9beta9 [March 10, 2006] + Include "config.h" in pngconf.h when available. + Added some checks for NULL png_ptr or NULL info_ptr (timeless) + +Version 1.2.9beta10 [March 20, 2006] + Removed extra CR from contrib/visualpng/VisualPng.dsw (Cosmin) + Made pnggccrd.c PIC-compliant (Christian Aichinger). + Added makefile.mingw (Wolfgang Glas). + Revised pngconf.h MMX checking. + +Version 1.2.9beta11 [March 22, 2006] + Fixed out-of-order declaration in pngwrite.c that was introduced in beta9 + Simplified some makefiles by using LIBSO, LIBSOMAJ, and LIBSOVER macros. + +Version 1.2.9rc1 [March 31, 2006] + Defined PNG_USER_PRIVATEBUILD when including "pngusr.h" (Cosmin). + Removed nonsensical assertion check from pngtest.c (Cosmin). + +Version 1.2.9 [April 14, 2006] + Revised makefile.beos and added "none" selector in ltmain.sh + +Version 1.2.10beta1 [April 15, 2006] + Renamed "config.h" to "png_conf.h" and revised Makefile.am to add + -DPNG_BUILDING_LIBPNG to compile directive, and modified pngconf.h + to include png_conf.h only when PNG_BUILDING_LIBPNG is defined. + +Version 1.2.10beta2 [April 15, 2006] + Manually updated Makefile.in and configure. Changed png_conf.h.in + back to config.h. + +Version 1.2.10beta3 [April 15, 2006] + Change png_conf.h back to config.h in pngconf.h. + +Version 1.2.10beta4 [April 16, 2006] + Change PNG_BUILDING_LIBPNG to PNG_CONFIGURE_LIBPNG in config/Makefile*. + +Version 1.2.10beta5 [April 16, 2006] + Added a configure check for compiling assembler code in pnggccrd.c + +Version 1.2.10beta6 [April 17, 2006] + Revised the configure check for pnggccrd.c + Moved -DPNG_CONFIGURE_LIBPNG into @LIBPNG_DEFINES@ + Added @LIBPNG_DEFINES@ to arguments when building libpng.sym + +Version 1.2.10beta7 [April 18, 2006] + Change "exec_prefix=$prefix" to "exec_prefix=$(prefix)" in makefiles. + +Version 1.2.10rc1 [April 19, 2006] + Ensure pngconf.h doesn't define both PNG_USE_PNGGCCRD and PNG_USE_PNGVCRD + Fixed "LN_FS" typo in makefile.sco and makefile.solaris. + +Version 1.2.10rc2 [April 20, 2006] + Added a backslash between -DPNG_CONFIGURE_LIBPNG and -DPNG_NO_ASSEMBLER_CODE + in configure.ac and configure + Made the configure warning about versioned symbols less arrogant. + +Version 1.2.10rc3 [April 21, 2006] + Added a note in libpng.txt that png_set_sig_bytes(8) can be used when + writing an embedded PNG without the 8-byte signature. + Revised makefiles and configure to avoid making links to libpng.so.* + +Version 1.2.10 [April 23, 2006] + Reverted configure to "rc2" state. + +Version 1.2.11beta1 [May 31, 2006] + scripts/libpng.pc.in contained "configure" style version info and would + not work with makefiles. + The shared-library makefiles were linking to libpng.so.0 instead of + libpng.so.3 compatibility as the library. + +Version 1.2.11beta2 [June 2, 2006] + Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid + buffer overflow. + Fixed bug in example.c (png_set_palette_rgb -> png_set_palette_to_rgb) + +Version 1.2.11beta3 [June 5, 2006] + Prepended "#! /bin/sh" to ltmail.sh and contrib/pngminus/*.sh (Cosmin). + Removed the accidental leftover Makefile.in~ (Cosmin). + Avoided potential buffer overflow and optimized buffer in + png_write_sCAL(), png_write_sCAL_s() (Cosmin). + Removed the include directories and libraries from CFLAGS and LDFLAGS + in scripts/makefile.gcc (Nelson A. de Oliveira, Cosmin). + +Version 1.2.11beta4 [June 6, 2006] + Allow zero-length IDAT chunks after the entire zlib datastream, but not + after another intervening chunk type. + +Version 1.0.19rc1, 1.2.11rc1 [June 13, 2006] + Deleted extraneous square brackets from [config.h] in configure.ac + +Version 1.0.19rc2, 1.2.11rc2 [June 14, 2006] + Added prototypes for PNG_INCH_CONVERSIONS functions to png.h + Revised INSTALL and autogen.sh + Fixed typo in several makefiles (-W1 should be -Wl) + Added typedef for png_int_32 and png_uint_32 on 64-bit systems. + +Version 1.0.19rc3, 1.2.11rc3 [June 15, 2006] + Removed the new typedefs for 64-bit systems (delay until version 1.4.0) + Added one zero element to png_gamma_shift[] array in pngrtran.c to avoid + reading out of bounds. + +Version 1.0.19rc4, 1.2.11rc4 [June 15, 2006] + Really removed the new typedefs for 64-bit systems. + +Version 1.0.19rc5, 1.2.11rc5 [June 22, 2006] + Removed png_sig_bytes entry from scripts/pngw32.def + +Version 1.0.19, 1.2.11 [June 26, 2006] + None. + +Version 1.0.20, 1.2.12 [June 27, 2006] + Really increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid + buffer overflow. + +Version 1.2.13beta1 [October 2, 2006] + Removed AC_FUNC_MALLOC from configure.ac + Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h + Change "logical" to "bitwise" throughout documentation. + Detect and fix attempt to write wrong iCCP profile length (CVE-2006-7244) + +Version 1.0.21, 1.2.13 [November 14, 2006] + Fix potential buffer overflow in sPLT chunk handler. + Fix Makefile.am to not try to link to noexistent files. + Check all exported functions for NULL png_ptr. + +Version 1.2.14beta1 [November 17, 2006] + Relocated three misplaced tests for NULL png_ptr. + Built Makefile.in with automake-1.9.6 instead of 1.9.2. + Build configure with autoconf-2.60 instead of 2.59 + +Version 1.2.14beta2 [November 17, 2006] + Added some typecasts in png_zalloc(). + +Version 1.2.14rc1 [November 20, 2006] + Changed "strtod" to "png_strtod" in pngrutil.c + +Version 1.0.22, 1.2.14 [November 27, 2006] + Added missing "$(srcdir)" in Makefile.am and Makefile.in + +Version 1.2.15beta1 [December 3, 2006] + Generated configure with autoconf-2.61 instead of 2.60 + Revised configure.ac to update libpng.pc and libpng-config. + +Version 1.2.15beta2 [December 3, 2006] + Always export MMX asm functions, just stubs if not building pnggccrd.c + +Version 1.2.15beta3 [December 4, 2006] + Add "png_bytep" typecast to profile while calculating length in pngwutil.c + +Version 1.2.15beta4 [December 7, 2006] + Added scripts/CMakeLists.txt + Changed PNG_NO_ASSEMBLER_CODE to PNG_NO_MMX_CODE in scripts, like 1.4.0beta + +Version 1.2.15beta5 [December 7, 2006] + Changed some instances of PNG_ASSEMBLER_* to PNG_MMX_* in pnggccrd.c + Revised scripts/CMakeLists.txt + +Version 1.2.15beta6 [December 13, 2006] + Revised scripts/CMakeLists.txt and configure.ac + +Version 1.2.15rc1 [December 18, 2006] + Revised scripts/CMakeLists.txt + +Version 1.2.15rc2 [December 21, 2006] + Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers. + Added scripts/makefile.nommx + +Version 1.2.15rc3 [December 25, 2006] + Fixed shared library numbering error that was introduced in 1.2.15beta6. + +Version 1.2.15rc4 [December 27, 2006] + Fixed handling of rgb_to_gray when png_ptr->color.gray isn't set. + +Version 1.2.15rc5 [December 31, 2006] + Revised handling of rgb_to_gray. + +Version 1.2.15 [January 5, 2007] + Added some (unsigned long) typecasts in pngtest.c to avoid printing errors. + +Version 1.2.16beta1 [January 6, 2007] + Fix bugs in makefile.nommx + +Version 1.2.16beta2 [January 16, 2007] + Revised scripts/CMakeLists.txt + +Version 1.2.16 [January 31, 2007] + No changes. + +Version 1.2.17beta1 [March 6, 2007] + Revised scripts/CMakeLists.txt to install both shared and static libraries. + Deleted a redundant line from pngset.c. + +Version 1.2.17beta2 [April 26, 2007] + Relocated misplaced test for png_ptr == NULL in pngpread.c + Change "==" to "&" for testing PNG_RGB_TO_GRAY_ERR & PNG_RGB_TO_GRAY_WARN + flags. + Changed remaining instances of PNG_ASSEMBLER_* to PNG_MMX_* + Added pngerror() when write_IHDR fails in deflateInit2(). + Added "const" to some array declarations. + Mention examples of libpng usage in the libpng*.txt and libpng.3 documents. + +Version 1.2.17rc1 [May 4, 2007] + No changes. + +Version 1.2.17rc2 [May 8, 2007] + Moved several PNG_HAVE_* macros out of PNG_INTERNAL because applications + calling set_unknown_chunk_location() need them. + Changed transformation flag from PNG_EXPAND_tRNS to PNG_EXPAND in + png_set_expand_gray_1_2_4_to_8(). + Added png_ptr->unknown_chunk to hold working unknown chunk data, so it + can be free'ed in case of error. Revised unknown chunk handling in + pngrutil.c and pngpread.c to use this structure. + +Version 1.2.17rc3 [May 8, 2007] + Revised symbol-handling in configure script. + +Version 1.2.17rc4 [May 10, 2007] + Revised unknown chunk handling to avoid storing unknown critical chunks. + +Version 1.0.25 [May 15, 2007] +Version 1.2.17 [May 15, 2007] + Added "png_ptr->num_trans=0" before error return in png_handle_tRNS, + to eliminate a vulnerability (CVE-2007-2445, CERT VU#684664) + +Version 1.0.26 [May 15, 2007] +Version 1.2.18 [May 15, 2007] + Reverted the libpng-1.2.17rc3 change to symbol-handling in configure script + +Version 1.2.19beta1 [May 18, 2007] + Changed "const static" to "static PNG_CONST" everywhere, mostly undoing + change of libpng-1.2.17beta2. Changed other "const" to "PNG_CONST" + Changed some handling of unused parameters, to avoid compiler warnings. + "if (unused == NULL) return;" becomes "unused = unused". + +Version 1.2.19beta2 [May 18, 2007] + Only use the valid bits of tRNS value in png_do_expand() (Brian Cartier) + +Version 1.2.19beta3 [May 19, 2007] + Add some "png_byte" typecasts in png_check_keyword() and write new_key + instead of key in zTXt chunk (Kevin Ryde). + +Version 1.2.19beta4 [May 21, 2007] + Add png_snprintf() function and use it in place of sprint() for improved + defense against buffer overflows. + +Version 1.2.19beta5 [May 21, 2007] + Fixed png_handle_tRNS() to only use the valid bits of tRNS value. + Changed handling of more unused parameters, to avoid compiler warnings. + Removed some PNG_CONST in pngwutil.c to avoid compiler warnings. + +Version 1.2.19beta6 [May 22, 2007] + Added some #ifdef PNG_MMX_CODE_SUPPORTED where needed in pngvcrd.c + Added a special "_MSC_VER" case that defines png_snprintf to _snprintf + +Version 1.2.19beta7 [May 22, 2007] + Squelched png_squelch_warnings() in pnggccrd.c and added + an #ifdef PNG_MMX_CODE_SUPPORTED block around the declarations that caused + the warnings that png_squelch_warnings was squelching. + +Version 1.2.19beta8 [May 22, 2007] + Removed __MMX__ from test in pngconf.h. + +Version 1.2.19beta9 [May 23, 2007] + Made png_squelch_warnings() available via PNG_SQUELCH_WARNINGS macro. + Revised png_squelch_warnings() so it might work. + Updated makefile.sgcc and makefile.solaris; added makefile.solaris-x86. + +Version 1.2.19beta10 [May 24, 2007] + Resquelched png_squelch_warnings(), use "__attribute__((used))" instead. + +Version 1.4.0beta1 [April 20, 2006] + Enabled iTXt support (changes png_struct, thus requires so-number change). + Cleaned up PNG_ASSEMBLER_CODE_SUPPORTED vs PNG_MMX_CODE_SUPPORTED + Eliminated PNG_1_0_X and PNG_1_2_X macros. + Removed deprecated functions png_read_init, png_write_init, png_info_init, + png_permit_empty_plte, png_set_gray_1_2_4_to_8, png_check_sig, and + removed the deprecated macro PNG_MAX_UINT. + Moved "PNG_INTERNAL" parts of png.h and pngconf.h into pngintrn.h + Removed many WIN32_WCE #ifdefs (Cosmin). + Reduced dependency on C-runtime library when on Windows (Simon-Pierre) + Replaced sprintf() with png_sprintf() (Simon-Pierre) + +Version 1.4.0beta2 [April 20, 2006] + Revised makefiles and configure to avoid making links to libpng.so.* + Moved some leftover MMX-related defines from pngconf.h to pngintrn.h + Updated scripts/pngos2.def, pngw32.def, and projects/wince/png32ce.def + +Version 1.4.0beta3 [May 10, 2006] + Updated scripts/pngw32.def to comment out MMX functions. + Added PNG_NO_GET_INT_32 and PNG_NO_SAVE_INT_32 macros. + Scripts/libpng.pc.in contained "configure" style version info and would + not work with makefiles. + Revised pngconf.h and added pngconf.h.in, so makefiles and configure can + pass defines to libpng and applications. + +Version 1.4.0beta4 [May 11, 2006] + Revised configure.ac, Makefile.am, and many of the makefiles to write + their defines in pngconf.h. + +Version 1.4.0beta5 [May 15, 2006] + Added a missing semicolon in Makefile.am and Makefile.in + Deleted extraneous square brackets from configure.ac + +Version 1.4.0beta6 [June 2, 2006] + Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid + buffer overflow. + Changed sonum from 0 to 1. + Removed unused prototype for png_check_sig() from png.h + +Version 1.4.0beta7 [June 16, 2006] + Exported png_write_sig (Cosmin). + Optimized buffer in png_handle_cHRM() (Cosmin). + Set pHYs = 2835 x 2835 pixels per meter, and added + sCAL = 0.352778e-3 x 0.352778e-3 meters, in pngtest.png (Cosmin). + Added png_set_benign_errors(), png_benign_error(), png_chunk_benign_error(). + Added typedef for png_int_32 and png_uint_32 on 64-bit systems. + Added "(unsigned long)" typecast on png_uint_32 variables in printf lists. + +Version 1.4.0beta8 [June 22, 2006] + Added demonstration of user chunk support in pngtest.c, to support the + public sTER chunk and a private vpAg chunk. + +Version 1.4.0beta9 [July 3, 2006] + Removed ordinals from scripts/pngw32.def and removed png_info_int and + png_set_gray_1_2_4_to_8 entries. + Inline call of png_get_uint_32() in png_get_uint_31(). + Use png_get_uint_31() to get vpAg width and height in pngtest.c + Removed WINCE and Netware projects. + Removed standalone Y2KINFO file. + +Version 1.4.0beta10 [July 12, 2006] + Eliminated automatic copy of pngconf.h to pngconf.h.in from configure and + some makefiles, because it was not working reliably. Instead, distribute + pngconf.h.in along with pngconf.h and cause configure and some of the + makefiles to update pngconf.h from pngconf.h.in. + Added pngconf.h to DEPENDENCIES in Makefile.am + +Version 1.4.0beta11 [August 19, 2006] + Removed AC_FUNC_MALLOC from configure.ac. + Added a warning when writing iCCP profile with mismatched profile length. + Patched pnggccrd.c to assemble on x86_64 platforms. + Moved chunk header reading into a separate function png_read_chunk_header() + in pngrutil.c. The chunk header (len+sig) is now serialized in a single + operation (Cosmin). + Implemented support for I/O states. Added png_ptr member io_state, and + functions png_get_io_chunk_name() and png_get_io_state() in pngget.c + (Cosmin). + Added png_get_io_chunk_name and png_get_io_state to scripts/*.def (Cosmin). + Renamed scripts/pngw32.* to scripts/pngwin.* (Cosmin). + Removed the include directories and libraries from CFLAGS and LDFLAGS + in scripts/makefile.gcc (Cosmin). + Used png_save_uint_32() to set vpAg width and height in pngtest.c (Cosmin). + Cast to proper type when getting/setting vpAg units in pngtest.c (Cosmin). + Added pngintrn.h to the Visual C++ projects (Cosmin). + Removed scripts/list (Cosmin). + Updated copyright year in scripts/pngwin.def (Cosmin). + Removed PNG_TYPECAST_NULL and used standard NULL consistently (Cosmin). + Disallowed the user to redefine png_size_t, and enforced a consistent use + of png_size_t across libpng (Cosmin). + Changed the type of png_ptr->rowbytes, PNG_ROWBYTES() and friends + to png_size_t (Cosmin). + Removed png_convert_size() and replaced png_sizeof with sizeof (Cosmin). + Removed some unnecessary type casts (Cosmin). + Changed prototype of png_get_compression_buffer_size() and + png_set_compression_buffer_size() to work with png_size_t instead of + png_uint_32 (Cosmin). + Removed png_memcpy_check() and png_memset_check() (Cosmin). + Fixed a typo (png_byte --> png_bytep) in libpng.3 and libpng.txt (Cosmin). + Clarified that png_zalloc() does not clear the allocated memory, + and png_zalloc() and png_zfree() cannot be PNGAPI (Cosmin). + Renamed png_mem_size_t to png_alloc_size_t, fixed its definition in + pngconf.h, and used it in all memory allocation functions (Cosmin). + Renamed pngintrn.h to pngpriv.h, added a comment at the top of the file + mentioning that the symbols declared in that file are private, and + updated the scripts and the Visual C++ projects accordingly (Cosmin). + Removed circular references between pngconf.h and pngconf.h.in in + scripts/makefile.vc*win32 (Cosmin). + Removing trailing '.' from the warning and error messages (Cosmin). + Added pngdefs.h that is built by makefile or configure, instead of + pngconf.h.in (Glenn). + Detect and fix attempt to write wrong iCCP profile length. + +Version 1.4.0beta12 [October 19, 2006] + Changed "logical" to "bitwise" in the documentation. + Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h + Add a typecast to stifle compiler warning in pngrutil.c + +Version 1.4.0beta13 [November 10, 2006] + Fix potential buffer overflow in sPLT chunk handler. + Fix Makefile.am to not try to link to noexistent files. + +Version 1.4.0beta14 [November 15, 2006] + Check all exported functions for NULL png_ptr. + +Version 1.4.0beta15 [November 17, 2006] + Relocated two misplaced tests for NULL png_ptr. + Built Makefile.in with automake-1.9.6 instead of 1.9.2. + Build configure with autoconf-2.60 instead of 2.59 + Add "install: all" in Makefile.am so "configure; make install" will work. + +Version 1.4.0beta16 [November 17, 2006] + Added a typecast in png_zalloc(). + +Version 1.4.0beta17 [December 4, 2006] + Changed "new_key[79] = '\0';" to "(*new_key)[79] = '\0';" in pngwutil.c + Add "png_bytep" typecast to profile while calculating length in pngwutil.c + +Version 1.4.0beta18 [December 7, 2006] + Added scripts/CMakeLists.txt + +Version 1.4.0beta19 [May 16, 2007] + Revised scripts/CMakeLists.txt + Rebuilt configure and Makefile.in with newer tools. + Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers. + Added scripts/makefile.nommx + +Version 1.4.0beta20 [July 9, 2008] + Moved several PNG_HAVE_* macros from pngpriv.h to png.h because applications + calling set_unknown_chunk_location() need them. + Moved several macro definitions from pngpriv.h to pngconf.h + Merge with changes to the 1.2.X branch, as of 1.2.30beta04. + Deleted all use of the MMX assembler code and Intel-licensed optimizations. + Revised makefile.mingw + +Version 1.4.0beta21 [July 21, 2008] + Moved local array "chunkdata" from pngrutil.c to the png_struct, so + it will be freed by png_read_destroy() in case of a read error (Kurt + Christensen). + +Version 1.4.0beta22 [July 21, 2008] + Change "purpose" and "buffer" to png_ptr->chunkdata to avoid memory leaking. + +Version 1.4.0beta23 [July 22, 2008] + Change "chunkdata = NULL" to "png_ptr->chunkdata = NULL" several places in + png_decompress_chunk(). + +Version 1.4.0beta24 [July 25, 2008] + Change all remaining "chunkdata" to "png_ptr->chunkdata" in + png_decompress_chunk(), and remove "chunkdata" from parameter list. + Put a call to png_check_chunk_name() in png_read_chunk_header(). + Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte. + Removed two calls to png_check_chunk_name() occurring later in the process. + Define PNG_NO_ERROR_NUMBERS by default in pngconf.h + +Version 1.4.0beta25 [July 30, 2008] + Added a call to png_check_chunk_name() in pngpread.c + Reverted png_check_chunk_name() to accept a name with a lowercase 3rd byte. + Added png_push_have_buffer() function to pngpread.c + Eliminated PNG_BIG_ENDIAN_SUPPORTED and associated png_get_* macros. + Made inline expansion of png_get_*() optional with PNG_USE_READ_MACROS. + Eliminated all PNG_USELESS_TESTS and PNG_CORRECT_PALETTE_SUPPORTED code. + Synced contrib directory and configure files with libpng-1.2.30beta06. + Eliminated no-longer-used pngdefs.h (but it's still built in the makefiles) + Relocated a misplaced "#endif /* PNG_NO_WRITE_FILTER */" in pngwutil.c + +Version 1.4.0beta26 [August 4, 2008] + Removed png_push_have_buffer() function in pngpread.c. It increased the + compiled library size slightly. + Changed "-Wall" to "-W -Wall" in the CFLAGS in all makefiles (Cosmin Truta) + Declared png_ptr "volatile" in pngread.c and pngwrite.c to avoid warnings. + Updated contrib/visupng/cexcept.h to version 2.0.1 + Added PNG_LITERAL_CHARACTER macros for #, [, and ]. + +Version 1.4.0beta27 [August 5, 2008] + Revised usage of PNG_LITERAL_SHARP in pngerror.c. + Moved newline character from individual png_debug messages into the + png_debug macros. + Allow user to #define their own png_debug, png_debug1, and png_debug2. + +Version 1.4.0beta28 [August 5, 2008] + Revised usage of PNG_LITERAL_SHARP in pngerror.c. + Added PNG_STRING_NEWLINE macro + +Version 1.4.0beta29 [August 9, 2008] + Revised usage of PNG_STRING_NEWLINE to work on non-ISO compilers. + Added PNG_STRING_COPYRIGHT macro. + Added non-ISO versions of png_debug macros. + +Version 1.4.0beta30 [August 14, 2008] + Added premultiplied alpha feature (Volker Wiendl). + +Version 1.4.0beta31 [August 18, 2008] + Moved png_set_premultiply_alpha from pngtrans.c to pngrtran.c + Removed extra crc check at the end of png_handle_cHRM(). Bug introduced + in libpng-1.4.0beta20. + +Version 1.4.0beta32 [August 19, 2008] + Added PNG_WRITE_FLUSH_SUPPORTED block around new png_flush() call. + Revised PNG_NO_STDIO version of png_write_flush() + +Version 1.4.0beta33 [August 20, 2008] + Added png_get|set_chunk_cache_max() to limit the total number of sPLT, + text, and unknown chunks that can be stored. + +Version 1.4.0beta34 [September 6, 2008] + Shortened tIME_string to 29 bytes in pngtest.c + Fixed off-by-one error introduced in png_push_read_zTXt() function in + libpng-1.2.30beta04/pngpread.c (Harald van Dijk) + +Version 1.4.0beta35 [October 6, 2008] + Changed "trans_values" to "trans_color". + Changed so-number from 0 to 14. Some OS do not like 0. + Revised makefile.darwin to fix shared library numbering. + Change png_set_gray_1_2_4_to_8() to png_set_expand_gray_1_2_4_to_8() + in example.c (debian bug report) + +Version 1.4.0beta36 [October 25, 2008] + Sync with tEXt vulnerability fix in libpng-1.2.33rc02. + +Version 1.4.0beta37 [November 13, 2008] + Added png_check_cHRM in png.c and moved checking from pngget.c, pngrutil.c, + and pngwrite.c + +Version 1.4.0beta38 [November 22, 2008] + Added check for zero-area RGB cHRM triangle in png_check_cHRM() and + png_check_cHRM_fixed(). + +Version 1.4.0beta39 [November 23, 2008] + Revised png_warning() to write its message on standard output by default + when warning_fn is NULL. + +Version 1.4.0beta40 [November 24, 2008] + Eliminated png_check_cHRM(). Instead, always use png_check_cHRM_fixed(). + In png_check_cHRM_fixed(), ensure white_y is > 0, and removed redundant + check for all-zero coordinates that is detected by the triangle check. + +Version 1.4.0beta41 [November 26, 2008] + Fixed string vs pointer-to-string error in png_check_keyword(). + Rearranged test expressions in png_check_cHRM_fixed() to avoid internal + overflows. + Added PNG_NO_CHECK_cHRM conditional. + +Version 1.4.0beta42, 43 [December 1, 2008] + Merge png_debug with version 1.2.34beta04. + +Version 1.4.0beta44 [December 6, 2008] + Removed redundant check for key==NULL before calling png_check_keyword() + to ensure that new_key gets initialized and removed extra warning + (Merge with version 1.2.34beta05 -- Arvan Pritchard). + +Version 1.4.0beta45 [December 9, 2008] + In png_write_png(), respect the placement of the filler bytes in an earlier + call to png_set_filler() (Jim Barry). + +Version 1.4.0beta46 [December 10, 2008] + Undid previous change and added PNG_TRANSFORM_STRIP_FILLER_BEFORE and + PNG_TRANSFORM_STRIP_FILLER_AFTER conditionals and deprecated + PNG_TRANSFORM_STRIP_FILLER (Jim Barry). + +Version 1.4.0beta47 [December 15, 2008] + Support for dithering was disabled by default, because it has never + been well tested and doesn't work very well. The code has not + been removed, however, and can be enabled by building libpng with + PNG_READ_DITHER_SUPPORTED defined. + +Version 1.4.0beta48 [February 14, 2009] + Added new exported function png_calloc(). + Combined several instances of png_malloc(); png_memset() into png_calloc(). + Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24 + but was never defined. + +Version 1.4.0beta49 [February 28, 2009] + Added png_fileno() macro to pngconf.h, used in pngwio.c + Corrected order of #ifdef's in png_debug definition in png.h + Fixed bug introduced in libpng-1.4.0beta48 with the memset arguments + for pcal_params. + Fixed order of #ifdef directives in the png_debug defines in png.h + (bug introduced in libpng-1.2.34/1.4.0beta29). + Revised comments in png_set_read_fn() and png_set_write_fn(). + +Version 1.4.0beta50 [March 18, 2009] + Use png_calloc() instead of png_malloc() to allocate big_row_buf when + reading an interlaced file, to avoid a possible UMR. + Undid revision of PNG_NO_STDIO version of png_write_flush(). Users + having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined + or supply their own flush_fn() replacement. + Revised libpng*.txt and png.h documentation about use of png_write_flush() + and png_set_write_fn(). + Removed fflush() from pngtest.c. + Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h + +Version 1.4.0beta51 [March 21, 2009] + Removed new png_fileno() macro from pngconf.h . + +Version 1.4.0beta52 [March 27, 2009] + Relocated png_do_chop() ahead of building gamma tables in pngrtran.c + This avoids building 16-bit gamma tables unnecessarily. + Removed fflush() from pngtest.c. + Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h + Added a section on differences between 1.0.x and 1.2.x to libpng.3/libpng.txt + +Version 1.4.0beta53 [April 1, 2009] + Removed some remaining MMX macros from pngpriv.h + Fixed potential memory leak of "new_name" in png_write_iCCP() (Ralph Giles) + +Version 1.4.0beta54 [April 13, 2009] + Added "ifndef PNG_SKIP_SETJMP_CHECK" block in pngconf.h to allow + application code writers to bypass the check for multiple inclusion + of setjmp.h when they know that it is safe to ignore the situation. + Eliminated internal use of setjmp() in pngread.c and pngwrite.c + Reordered ancillary chunks in pngtest.png to be the same as what + pngtest now produces, and made some cosmetic changes to pngtest output. + Eliminated deprecated png_read_init_3() and png_write_init_3() functions. + +Version 1.4.0beta55 [April 15, 2009] + Simplified error handling in pngread.c and pngwrite.c by putting + the new png_read_cleanup() and png_write_cleanup() functions inline. + +Version 1.4.0beta56 [April 25, 2009] + Renamed "user_chunk_data" to "my_user_chunk_data" in pngtest.c to suppress + "shadowed declaration" warning from gcc-4.3.3. + Renamed "gamma" to "png_gamma" in pngset.c to avoid "shadowed declaration" + warning about a global "gamma" variable in math.h on some platforms. + +Version 1.4.0beta57 [May 2, 2009] + Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24 + but was never defined (again). + Rebuilt configure scripts with autoconf-2.63 instead of 2.62 + Removed pngprefs.h and MMX from makefiles + +Version 1.4.0beta58 [May 14, 2009] + Changed pngw32.def to pngwin.def in makefile.mingw (typo was introduced + in beta57). + Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri) + +Version 1.4.0beta59 [May 15, 2009] + Reformated sources in libpng style (3-space intentation, comment format) + Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG) + Added sections about the git repository and our coding style to the + documentation + Relocated misplaced #endif in pngwrite.c, sCAL chunk handler. + +Version 1.4.0beta60 [May 19, 2009] + Conditionally compile png_read_finish_row() which is not used by + progressive readers. + Added contrib/pngminim/preader to demonstrate building minimal progressive + decoder, based on contrib/gregbook with embedded libpng and zlib. + +Version 1.4.0beta61 [May 20, 2009] + In contrib/pngminim/*, renamed "makefile.std" to "makefile", since there + is only one makefile in those directories, and revised the README files + accordingly. + More reformatting of comments, mostly to capitalize sentences. + +Version 1.4.0beta62 [June 2, 2009] + Added "#define PNG_NO_WRITE_SWAP" to contrib/pngminim/encoder/pngusr.h + and "define PNG_NO_READ_SWAP" to decoder/pngusr.h and preader/pngusr.h + Reformatted several remaining "else statement" into two lines. + Added a section to the libpng documentation about using png_get_io_ptr() + in configure scripts to detect the presence of libpng. + +Version 1.4.0beta63 [June 15, 2009] + Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR() + multiple times and to specify the sample order in the tRNS chunk, + because the ISO PNG specification has a typo in the tRNS table. + Changed several PNG_UNKNOWN_CHUNK_SUPPORTED to + PNG_HANDLE_AS_UNKNOWN_SUPPORTED, to make the png_set_keep mechanism + available for ignoring known chunks even when not saving unknown chunks. + Adopted preference for consistent use of "#ifdef" and "#ifndef" versus + "#if defined()" and "if !defined()" where possible. + +Version 1.4.0beta64 [June 24, 2009] + Eliminated PNG_LEGACY_SUPPORTED code. + Moved the various unknown chunk macro definitions outside of the + PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks. + +Version 1.4.0beta65 [June 26, 2009] + Added a reference to the libpng license in each file. + +Version 1.4.0beta66 [June 27, 2009] + Refer to the libpng license instead of the libpng license in each file. + +Version 1.4.0beta67 [July 6, 2009] + Relocated INVERT_ALPHA within png_read_png() and png_write_png(). + Added high-level API transform PNG_TRANSFORM_GRAY_TO_RGB. + Added an "xcode" project to the projects directory (Alam Arias). + +Version 1.4.0beta68 [July 19, 2009] + Avoid some tests in filter selection in pngwutil.c + +Version 1.4.0beta69 [July 25, 2009] + Simplified the new filter-selection test. This runs faster in the + common "PNG_ALL_FILTERS" and PNG_FILTER_NONE cases. + Removed extraneous declaration from the new call to png_read_gray_to_rgb() + (bug introduced in libpng-1.4.0beta67). + Fixed up xcode project (Alam Arias) + Added a prototype for png_64bit_product() in png.c + +Version 1.4.0beta70 [July 27, 2009] + Avoid a possible NULL dereference in debug build, in png_set_text_2(). + (bug introduced in libpng-0.95, discovered by Evan Rouault) + +Version 1.4.0beta71 [July 29, 2009] + Rebuilt configure scripts with autoconf-2.64. + +Version 1.4.0beta72 [August 1, 2009] + Replaced *.tar.lzma with *.tar.xz in distribution. Get the xz codec + from . + +Version 1.4.0beta73 [August 1, 2009] + Reject attempt to write iCCP chunk with negative embedded profile length + (JD Chen) (CVE-2009-5063). + +Version 1.4.0beta74 [August 8, 2009] + Changed png_ptr and info_ptr member "trans" to "trans_alpha". + +Version 1.4.0beta75 [August 21, 2009] + Removed an extra png_debug() recently added to png_write_find_filter(). + Fixed incorrect #ifdef in pngset.c regarding unknown chunk support. + +Version 1.4.0beta76 [August 22, 2009] + Moved an incorrectly located test in png_read_row() in pngread.c + +Version 1.4.0beta77 [August 27, 2009] + Removed lpXYZ.tar.bz2 (with CRLF), KNOWNBUG, libpng-x.y.z-KNOWNBUG.txt, + and the "noconfig" files from the distribution. + Moved CMakeLists.txt from scripts into the main libpng directory. + Various bugfixes and improvements to CMakeLists.txt (Philip Lowman) + +Version 1.4.0beta78 [August 31, 2009] + Converted all PNG_NO_* tests to PNG_*_SUPPORTED everywhere except pngconf.h + Eliminated PNG_NO_FREE_ME and PNG_FREE_ME_SUPPORTED macros. + Use png_malloc plus a loop instead of png_calloc() to initialize + row_pointers in png_read_png(). + +Version 1.4.0beta79 [September 1, 2009] + Eliminated PNG_GLOBAL_ARRAYS and PNG_LOCAL_ARRAYS; always use local arrays. + Eliminated PNG_CALLOC_SUPPORTED macro and always provide png_calloc(). + +Version 1.4.0beta80 [September 17, 2009] + Removed scripts/libpng.icc + Changed typecast of filler from png_byte to png_uint_16 in png_set_filler(). + (Dennis Gustafsson) + Fixed typo introduced in beta78 in pngtest.c ("#if def " should be "#ifdef ") + +Version 1.4.0beta81 [September 23, 2009] + Eliminated unused PNG_FLAG_FREE_* defines from pngpriv.h + Expanded TAB characters in pngrtran.c + Removed PNG_CONST from all "PNG_CONST PNG_CHNK" declarations to avoid + compiler complaints about doubly declaring things "const". + Changed all "#if [!]defined(X)" to "if[n]def X" where possible. + Eliminated unused png_ptr->row_buf_size + +Version 1.4.0beta82 [September 25, 2009] + Moved redundant IHDR checking into new png_check_IHDR() in png.c + and report all errors found in the IHDR data. + Eliminated useless call to png_check_cHRM() from pngset.c + +Version 1.4.0beta83 [September 25, 2009] + Revised png_check_IHDR() to eliminate bogus complaint about filter_type. + +Version 1.4.0beta84 [September 30, 2009] + Fixed some inconsistent indentation in pngconf.h + Revised png_check_IHDR() to add a test for width variable less than 32-bit. + +Version 1.4.0beta85 [October 1, 2009] + Revised png_check_IHDR() again, to check info_ptr members instead of + the contents of the returned parameters. + +Version 1.4.0beta86 [October 9, 2009] + Updated the "xcode" project (Alam Arias). + Eliminated a shadowed declaration of "pp" in png_handle_sPLT(). + +Version 1.4.0rc01 [October 19, 2009] + Trivial cosmetic changes. + +Version 1.4.0beta87 [October 30, 2009] + Moved version 1.4.0 back into beta. + +Version 1.4.0beta88 [October 30, 2009] + Revised libpng*.txt section about differences between 1.2.x and 1.4.0 + because most of the new features have now been ported back to 1.2.41 + +Version 1.4.0beta89 [November 1, 2009] + More bugfixes and improvements to CMakeLists.txt (Philip Lowman) + Removed a harmless extra png_set_invert_alpha() from pngwrite.c + Apply png_user_chunk_cache_max within png_decompress_chunk(). + Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate. + +Version 1.4.0beta90 [November 2, 2009] + Removed all remaining WIN32_WCE #ifdefs except those involving the + time.h "tm" structure + +Version 1.4.0beta91 [November 3, 2009] + Updated scripts/pngw32.def and projects/wince/png32ce.def + Copied projects/wince/png32ce.def to the scripts directory. + Added scripts/makefile.wce + Patched ltmain.sh for wince support. + Added PNG_CONVERT_tIME_SUPPORTED macro. + +Version 1.4.0beta92 [November 4, 2009] + Make inclusion of time.h in pngconf.h depend on PNG_CONVERT_tIME_SUPPORTED + Make #define PNG_CONVERT_tIME_SUPPORTED depend on PNG_WRITE_tIME_SUPPORTED + Revised libpng*.txt to describe differences from 1.2.40 to 1.4.0 (instead + of differences from 1.2.41 to 1.4.0) + +Version 1.4.0beta93 [November 7, 2009] + Added PNG_DEPSTRUCT, PNG_DEPRECATED, PNG_USE_RESULT, PNG_NORETURN, and + PNG_ALLOCATED macros to detect deprecated direct access to the + png_struct or info_struct members and other deprecated usage in + applications (John Bowler). + Updated scripts/makefile* to add "-DPNG_CONFIGURE_LIBPNG" to CFLAGS, + to prevent warnings about direct access to png structs by libpng + functions while building libpng. They need to be tested, especially + those using compilers other than gcc. + Updated projects/visualc6 and visualc71 with "/d PNG_CONFIGURE_LIBPNG". + They should work but still need to be updated to remove + references to pnggccrd.c or pngvcrd.c and ASM building. + Added README.txt to the beos, cbuilder5, netware, and xcode projects warning + that they need to be updated, to remove references to pnggccrd.c and + pngvcrd.c and to depend on pngpriv.h + Removed three direct references to read_info_ptr members in pngtest.c + that were detected by the new PNG_DEPSTRUCT macro. + Moved the png_debug macro definitions and the png_read_destroy(), + png_write_destroy() and png_far_to_near() prototypes from png.h + to pngpriv.h (John Bowler) + Moved the synopsis lines for png_read_destroy(), png_write_destroy() + png_debug(), png_debug1(), and png_debug2() from libpng.3 to libpngpf.3. + +Version 1.4.0beta94 [November 9, 2009] + Removed the obsolete, unused pnggccrd.c and pngvcrd.c files. + Updated CMakeLists.txt to add "-DPNG_CONFIGURE_LIBPNG" to the definitions. + Removed dependency of pngtest.o on pngpriv.h in the makefiles. + Only #define PNG_DEPSTRUCT, etc. in pngconf.h if not already defined. + +Version 1.4.0beta95 [November 10, 2009] + Changed png_check_sig() to !png_sig_cmp() in contrib programs. + Added -DPNG_CONFIGURE_LIBPNG to contrib/pngminm/*/makefile + Changed png_check_sig() to !png_sig_cmp() in contrib programs. + Corrected the png_get_IHDR() call in contrib/gregbook/readpng2.c + Changed pngminim/*/gather.sh to stop trying to remove pnggccrd.c and pngvcrd.c + Added dependency on pngpriv.h in contrib/pngminim/*/makefile + +Version 1.4.0beta96 [November 12, 2009] + Renamed scripts/makefile.wce to scripts/makefile.cegcc + Revised Makefile.am to use libpng.sys while building libpng.so + so that only PNG_EXPORT functions are exported. + Removed the deprecated png_check_sig() function/macro. + Removed recently removed function names from scripts/*.def + Revised pngtest.png to put chunks in the same order written by pngtest + (evidently the same change made in libpng-1.0beta54 was lost). + Added PNG_PRIVATE macro definition in pngconf.h for possible future use. + +Version 1.4.0beta97 [November 13, 2009] + Restored pngtest.png to the libpng-1.4.0beta7 version. + Removed projects/beos and netware.txt; no one seems to be supporting them. + Revised Makefile.in + +Version 1.4.0beta98 [November 13, 2009] + Added the "xcode" project to zip distributions, + Fixed a typo in scripts/pngwin.def introduced in beta97. + +Version 1.4.0beta99 [November 14, 2009] + Moved libpng-config.in and libpng.pc-configure.in out of the scripts + directory, to libpng-config.in and libpng-pc.in, respectively, and + modified Makefile.am and configure.ac accordingly. Now "configure" + needs nothing from the "scripts" directory. + Avoid redefining PNG_CONST in pngconf.h + +Version 1.4.0beta100 [November 14, 2009] + Removed ASM builds from projects/visualc6 and projects/visualc71 + Removed scripts/makefile.nommx and makefile.vcawin32 + Revised CMakeLists.txt to account for new location of libpng-config.in + and libpng-pc.in + Updated INSTALL to reflect removal and relocation of files. + +Version 1.4.0beta101 [November 14, 2009] + Restored the binary files (*.jpg, *.png, some project files) that were + accidentally deleted from the zip and 7z distributions when the xcode + project was added. + +Version 1.4.0beta102 [November 18, 2009] + Added libpng-config.in and libpng-pc.in to the zip and 7z distributions. + Fixed a typo in projects/visualc6/pngtest.dsp, introduced in beta100. + Moved descriptions of makefiles and other scripts out of INSTALL into + scripts/README.txt + Updated the copyright year in scripts/pngwin.rc from 2006 to 2009. + +Version 1.4.0beta103 [November 21, 2009] + Removed obsolete comments about ASM from projects/visualc71/README_zlib.txt + Align row_buf on 16-byte boundary in memory. + Restored the PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED guard around the call + to png_flush() after png_write_IEND(). See 1.4.0beta32, 1.4.0beta50 + changes above and 1.2.30, 1.2.30rc01 and rc03 in 1.2.41 CHANGES. Someone + needs this feature. + Make the 'png_jmpbuf' macro expand to a call that records the correct + longjmp function as well as returning a pointer to the setjmp + jmp_buf buffer, and marked direct access to jmpbuf 'deprecated'. + (John Bowler) + +Version 1.4.0beta104 [November 22, 2009] + Removed png_longjmp_ptr from scripts/*.def and libpng.3 + Rebuilt configure scripts with autoconf-2.65 + +Version 1.4.0beta105 [November 25, 2009] + Use fast integer PNG_DIVIDE_BY_255() or PNG_DIVIDE_BY_65535() + to accomplish alpha premultiplication when + PNG_READ_COMPOSITE_NODIV_SUPPORTED is defined. + Changed "/255" to "/255.0" in background calculations to make it clear + that the 255 is used as a double. + +Version 1.4.0beta106 [November 27, 2009] + Removed premultiplied alpha feature. + +Version 1.4.0beta107 [December 4, 2009] + Updated README + Added "#define PNG_NO_PEDANTIC_WARNINGS" in the libpng source files. + Removed "-DPNG_CONFIGURE_LIBPNG" from the makefiles and projects. + Revised scripts/makefile.netbsd, makefile.openbsd, and makefile.sco + to put png.h and pngconf.h in $prefix/include, like the other scripts, + instead of in $prefix/include/libpng. Also revised makefile.sco + to put them in $prefix/include/libpng15 instead of in + $prefix/include/libpng/libpng15. + +Version 1.4.0beta108 [December 11, 2009] + Removed leftover "-DPNG_CONFIGURE_LIBPNG" from contrib/pngminim/*/makefile + Relocated png_do_chop() to its original position in pngrtran.c; the + change in version 1.2.41beta08 caused transparency to be handled wrong + in some 16-bit datastreams (Yusaku Sugai). + +Version 1.4.0beta109 [December 13, 2009] + Added "bit_depth" parameter to the private png_build_gamma_table() function. + Pass bit_depth=8 to png_build_gamma_table() when bit_depth is 16 but the + PNG_16_TO_8 transform has been set, to avoid unnecessary build of 16-bit + tables. + +Version 1.4.0rc02 [December 20, 2009] + Declared png_cleanup_needed "volatile" in pngread.c and pngwrite.c + +Version 1.4.0rc03 [December 22, 2009] + Renamed libpng-pc.in back to libpng.pc.in and revised CMakeLists.txt + (revising the change in 1.4.0beta99) + +Version 1.4.0rc04 [December 25, 2009] + Swapped PNG_UNKNOWN_CHUNKS_SUPPORTED and PNG_HANDLE_AS_UNKNOWN_SUPPORTED + in pngset.c to be consistent with other changes in version 1.2.38. + +Version 1.4.0rc05 [December 25, 2009] + Changed "libpng-pc.in" to "libpng.pc.in" in configure.ac, configure, and + Makefile.in to be consistent with changes in libpng-1.4.0rc03 + +Version 1.4.0rc06 [December 29, 2009] + Reverted the gamma_table changes from libpng-1.4.0beta109. + Fixed some indentation errors. + +Version 1.4.0rc07 [January 1, 2010] + Revised libpng*.txt and libpng.3 about 1.2.x->1.4.x differences. + Use png_calloc() instead of png_malloc(); png_memset() in pngrutil.c + Update copyright year to 2010. + +Version 1.4.0rc08 [January 2, 2010] + Avoid deprecated references to png_ptr-io_ptr and png_ptr->error_ptr + in pngtest.c + +Version 1.4.0 [January 3, 2010] + No changes. + +Version 1.4.1beta01 [January 8, 2010] + Updated CMakeLists.txt for consistent indentation and to avoid an + unclosed if-statement warning (Philip Lowman). + Revised Makefile.am and Makefile.in to remove references to Y2KINFO, + KNOWNBUG, and libpng.la (Robert Schwebel). + Revised the makefiles to install the same files and symbolic + links as configure, except for libpng.la and libpng14.la. + Make png_set|get_compression_buffer_size() available even when + PNG_WRITE_SUPPORTED is not enabled. + Revised Makefile.am and Makefile.in to simplify their maintenance. + Revised scripts/makefile.linux to install a link to libpng14.so.14.1 + +Version 1.4.1beta02 [January 9, 2010] + Revised the rest of the makefiles to install a link to libpng14.so.14.1 + +Version 1.4.1beta03 [January 10, 2010] + Removed png_set_premultiply_alpha() from scripts/*.def + +Version 1.4.1rc01 [January 16, 2010] + No changes. + +Version 1.4.1beta04 [January 23, 2010] + Revised png_decompress_chunk() to improve speed and memory usage when + decoding large chunks. + Added png_set|get_chunk_malloc_max() functions. + +Version 1.4.1beta05 [January 26, 2010] + Relocated "int k" declaration in pngtest.c to minimize its scope. + +Version 1.4.1beta06 [January 28, 2010] + Revised png_decompress_chunk() to use a two-pass method suggested by + John Bowler. + +Version 1.4.1beta07 [February 6, 2010] + Folded some long lines in the source files. + Added defineable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX, + and a PNG_USER_LIMITS_SUPPORTED flag. + Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as + png_ptr->png_user_chunk_malloc_max. + Revised png_push_save_buffer() to do fewer but larger png_malloc() calls. + +Version 1.4.1beta08 [February 6, 2010] + Minor cleanup and updating of dates and copyright year. + +Version 1.5.0beta01 [February 7, 2010] + Moved declaration of png_struct into private pngstruct.h and png_info + into pnginfo.h + +Version 1.4.1beta09 and 1.5.0beta02 [February 7, 2010] + Reverted to original png_push_save_buffer() code. + +Version 1.4.1beta10 and 1.5.0beta03 [February 8, 2010] + Return allocated "old_buffer" in png_push_save_buffer() before + calling png_error(), to avoid a potential memory leak. + Updated configure script to use SO number 15. + +Version 1.5.0beta04 [February 9, 2010] + Removed malformed "incomplete struct declaration" of png_info from png.h + +Version 1.5.0beta05 [February 12, 2010] + Removed PNG_DEPSTRUCT markup in pngstruct.h and pnginfo.h, and undid the + linewrapping that it entailed. + Revised comments in pngstruct.h and pnginfo.h and added pointers to + the libpng license. + Changed PNG_INTERNAL to PNG_EXPOSE_INTERNAL_STRUCTURES + Removed the cbuilder5 project, which has not been updated to 1.4.0. + +Version 1.4.1beta12 and 1.5.0beta06 [February 14, 2010] + Fixed type declaration of png_get_chunk_malloc_max() in pngget.c (Daisuke + Nishikawa) + +Version 1.5.0beta07 [omitted] + +Version 1.5.0beta08 [February 19, 2010] + Changed #ifdef PNG_NO_STDIO_SUPPORTED to #ifdef PNG_NO_CONSOLE_IO_SUPPORTED + wherever png_snprintf() is used to construct error and warning messages. + Noted in scripts/makefile.mingw that it expects to be run under MSYS. + Removed obsolete unused MMX-querying support from contrib/gregbook + Added exported png_longjmp() function. + Removed the AIX redefinition of jmpbuf in png.h + Added -D_ALLSOURCE in configure.ac, makefile.aix, and CMakeLists.txt + when building on AIX. + +Version 1.5.0beta09 [February 19, 2010] + Removed -D_ALLSOURCE from configure.ac, makefile.aix, and CMakeLists.txt. + Changed the name of png_ptr->jmpbuf to png_ptr->png_jmpbuf in pngstruct.h + +Version 1.5.0beta10 [February 25, 2010] + Removed unused gzio.c from contrib/pngminim gather and makefile scripts + Removed replacement error handlers from contrib/gregbook. Because of + the new png_longjmp() function they are no longer needed. + +Version 1.5.0beta11 [March 6, 2010] + Removed checking for already-included setjmp.h from pngconf.h + Fixed inconsistent indentations and made numerous cosmetic changes. + Revised the "SEE ALSO" style of libpng.3, libpngpf.3, and png.5 + +Version 1.5.0beta12 [March 9, 2010] + Moved "#include png.h" inside pngpriv.h and removed "#include png.h" from + the source files, along with "#define PNG_EXPOSE_INTERNAL_STRUCTURES" + and "#define PNG_NO_PEDANTIC_WARNINGS" (John Bowler). + Created new pngdebug.h and moved debug definitions there. + +Version 1.5.0beta13 [March 10, 2010] + Protect pngstruct.h, pnginfo.h, and pngdebug.h from being included twice. + Revise the "#ifdef" blocks in png_inflate() so it will compile when neither + PNG_USER_CHUNK_MALLOC_MAX nor PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED + is defined. + Removed unused png_measure_compressed_chunk() from pngpriv.h and libpngpf.3 + Moved the 'config.h' support from pngconf.h to pngpriv.h + Removed PNGAPI from the png_longjmp_ptr typedef. + Eliminated dependence of pngtest.c on the private pngdebug.h file. + Make all png_debug macros into *unterminated* statements or + expressions (i.e. a trailing ';' must always be added) and correct + the format statements in various png_debug messages. + +Version 1.5.0beta14 [March 14, 2010] + Removed direct access to png_ptr->io_ptr from the Windows code in pngtest.c + Revised Makefile.am to account for recent additions and replacements. + Corrected CE and OS/2 DEF files (scripts/png*def) for symbols removed and + added ordinal numbers to the Windows DEF file and corrected the duplicated + ordinal numbers on CE symbols that are commented out. + Added back in export symbols that can be present in the Windows build but + are disabled by default. + PNG_EXPORT changed to include an 'ordinal' field for DEF file generation. + PNG_CALLBACK added to make callback definitions uniform. PNGAPI split + into PNGCAPI (base C form), PNGAPI (exports) and PNGCBAPI (callbacks), + and appropriate changes made to all files. Cygwin builds re-hinged to + allow procedure call standard changes and to remove the need for the DEF + file (fixes build on Cygwin). + Enabled 'attribute' warnings that are relevant to library APIs and callbacks. + Changed rules for generation of the various symbol files and added a new + rule for a DEF file (which is also added to the distribution). + Updated the symbol file generation to stop it adding spurious spaces + to EOL (coming from preprocessor macro expansion). Added a facility + to join tokens in the output and rewrite *.dfn to use this. + Eliminated scripts/*.def in favor of libpng.def; updated projects/visualc71 + and removed scripts/makefile.cygwin. + Made PNG_BUILD_DLL safe: it can be set whenever a DLL is being built. + Removed the include of sys/types.h - apparently unnecessary now on the + platforms on which it happened (all but Mac OS and RISC OS). + Moved the Mac OS test into pngpriv.h (the only place it is used.) + +Version 1.5.0beta15 [March 17, 2010] + Added symbols.chk target to Makefile.am to validate the symbols in png.h + against the new DEF file scripts/symbols.def. + Changed the default DEF file back to pngwin.def. + Removed makefile.mingw. + Eliminated PNG_NO_EXTERN and PNG_ALL_EXTERN + +Version 1.5.0beta16 [April 1, 2010] + Make png_text_struct independent of PNG_iTXt_SUPPORTED, so that + fields are initialized in all configurations. The READ/WRITE + macros (PNG_(READ|WRITE)_iTXt_SUPPORTED) still function as + before to disable code to actually read or write iTXt chunks + and iTXt_SUPPORTED can be used to detect presence of either + read or write support (but it is probably better to check for + the one actually required - read or write.) + Combined multiple png_warning() calls for a single error. + Restored the macro definition of png_check_sig(). + +Version 1.5.0beta17 [April 17, 2010] + Added some "(long)" typecasts to printf calls in png_handle_cHRM(). + Documented the fact that png_set_dither() was disabled since libpng-1.4.0. + Reenabled png_set_dither() but renamed it to png_set_quantize() to reflect + more accurately what it actually does. At the same time, renamed + the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros to + PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS. + Added some "(long)" typecasts to printf calls in png_handle_cHRM(). + Freeze build-time only configuration in the build. + In all prior versions of libpng most configuration options + controlled by compiler #defines had to be repeated by the + application code that used libpng. This patch changes this + so that compilation options that can only be changed at build + time are frozen in the build. Options that are compiler + dependent (and those that are system dependent) are evaluated + each time - pngconf.h holds these. Options that can be changed + per-file in the application are in png.h. Frozen options are + in the new installed header file pnglibconf.h (John Bowler) + Removed the xcode project because it has not been updated to work + with libpng-1.5.0. + Removed the ability to include optional pngusr.h + +Version 1.5.0beta18 [April 17, 2010] + Restored the ability to include optional pngusr.h + Moved replacements for png_error() and png_warning() from the + contrib/pngminim project to pngerror.c, for use when warnings or + errors are disabled via PNG_NO_WARN or PNG_NO_ERROR_TEXT, to avoid + storing unneeded error/warning text. + Updated contrib/pngminim project to work with the new pnglibconf.h + Added some PNG_NO_* defines to contrib/pngminim/*/pngusr.h to save space. + +Version 1.5.0beta19 [April 24, 2010] + Added PNG_{READ,WRITE}_INT_FUNCTIONS_SUPPORTED. This allows the functions + to read and write ints to be disabled independently of PNG_USE_READ_MACROS, + which allows libpng to be built with the functions even though the default + is to use the macros - this allows applications to choose at app build + time whether or not to use macros (previously impossible because the + functions weren't in the default build.) + Changed Windows calling convention back to __cdecl for API functions. + For Windows/x86 platforms only: + __stdcall is no longer needed for Visual Basic, so libpng-1.5.0 uses + __cdecl throughout (both API functions and callbacks) on Windows/x86 + platforms. + Replaced visualc6 and visualc71 projects with new vstudio project + Relaxed the overly-restrictive permissions of some files. + +Version 1.5.0beta20 [April 24, 2010] + Relaxed more overly-restrictive permissions of some files. + +Version 1.5.0beta21 [April 27, 2010] + Removed some unwanted binary bytes and changed CRLF to NEWLINE in the new + vstudio project files, and some trivial editing of some files in the + scripts directory. + Set PNG_NO_READ_BGR, PNG_NO_IO_STATE, and PNG_NO_TIME_RFC1123 in + contrib/pngminim/decoder/pngusr.h to make a smaller decoder application. + +Version 1.5.0beta22 [April 28, 2010] + Fixed dependencies of GET_INT_32 - it does not require READ_INT_FUNCTIONS + because it has a macro equivalent. + Improved the options.awk script; added an "everything off" option. + Revised contrib/pngminim to use the "everything off" option in pngusr.dfa. + +Version 1.5.0beta23 [April 29, 2010] + Corrected PNG_REMOVED macro to take five arguments. + The macro was documented with two arguments (name,ordinal), however + the symbol checking .dfn files assumed five arguments. The five + argument form seems more useful so it is changed to that. + Corrected PNG_UNKNOWN_CHUNKS_SUPPORTED to PNG_HANDLE_AS_UNKNOWN_SUPPORTED + in gregbook/readpng2.c + Corrected protection of png_get_user_transform_ptr. The API declaration in + png.h is removed if both READ and WRITE USER_TRANSFORM are turned off + but was left defined in pngtrans.c + Added logunsupported=1 to cause pnglibconf.h to document disabled options. + This makes the installed pnglibconf.h more readable but causes no + other change. The intention is that users of libpng will find it + easier to understand if an API they need is missing. + Include png_reset_zstream() in png.c only when PNG_READ_SUPPORTED is defined. + Removed dummy_inflate.c from contrib/pngminim/encoder + Removed contrib/pngminim/*/gather.sh; gathering is now done in the makefile. + +Version 1.5.0beta24 [May 7, 2010] + Use bitwise "&" instead of arithmetic mod in pngrutil.c calculation of the + offset of the png_ptr->rowbuf pointer into png_ptr->big_row_buf. + Added more blank lines for readability. + +Version 1.5.0beta25 [June 18, 2010] + In pngpread.c: png_push_have_row() add check for new_row > height + Removed the now-redundant check for out-of-bounds new_row from example.c + +Version 1.5.0beta26 [June 18, 2010] + In pngpread.c: png_push_process_row() add check for too many rows. + +Version 1.5.0beta27 [June 18, 2010] + Removed the check added in beta25 as it is now redundant. + +Version 1.5.0beta28 [June 20, 2010] + Rewrote png_process_IDAT_data to consistently treat extra data as warnings + and handle end conditions more cleanly. + Removed the new (beta26) check in png_push_process_row(). + +Version 1.5.0beta29 [June 21, 2010] + Revised scripts/options.awk to work on Sunos (but still doesn't work) + Added comment to options.awk and contrib/pngminim/*/makefile to try nawk. + +Version 1.5.0beta30 [June 22, 2010] + Stop memory leak when reading a malformed sCAL chunk. + +Version 1.5.0beta31 [June 26, 2010] + Revised pngpread.c patch of beta28 to avoid an endless loop. + Removed some trailing blanks. + +Version 1.5.0beta32 [June 26, 2010] + Removed leftover scripts/options.patch and scripts/options.rej + +Version 1.5.0beta33 [July 6, 3010] + Made FIXED and FLOATING options consistent in the APIs they enable and + disable. Corrected scripts/options.awk to handle both command line + options and options specified in the .dfa files. + Changed char *msg to PNG_CONST char *msg in pngrutil.c + Make png_set_sRGB_gAMA_and_cHRM set values using either the fixed or + floating point APIs, but not both. + Reversed patch to remove error handler when the jmp_buf is stored in the + main program structure, not the png_struct. + The error handler is needed because the default handler in libpng will + always use the jmp_buf in the library control structure; this is never + set. The gregbook code is a useful example because, even though it + uses setjmp/longjmp, it shows how error handling can be implemented + using control mechanisms not directly supported by libpng. The + technique will work correctly with mechanisms such as Microsoft + Structure Exceptions or C++ exceptions (compiler willing - note that gcc + does not by default support interworking of C and C++ error handling.) + Reverted changes to call png_longjmp in contrib/gregbook where it is not + appropriate. If mainprog->jmpbuf is used by setjmp, then png_longjmp + cannot be used. + Changed "extern PNG_EXPORT" to "PNG_EXPORT" in png.h (Jan Nijtmans) + Changed "extern" to "PNG_EXTERN" in pngpriv.h (except for the 'extern "C" {') + +Version 1.5.0beta34 [July 12, 2010] + Put #ifndef PNG_EXTERN, #endif around the define PNG_EXTERN in pngpriv.h + +Version 1.5.0beta35 [July 24, 2010] + Removed some newly-added TAB characters. + Added -DNO_PNG_SNPRINTF to CFLAGS in scripts/makefile.dj2 + Moved the definition of png_snprintf() outside of the enclosing + #ifdef blocks in pngconf.h + +Version 1.5.0beta36 [July 29, 2010] + Patches by John Bowler: + Fixed point APIs are now supported throughout (no missing APIs). + Internal fixed point arithmetic support exists for all internal floating + point operations. + sCAL validates the floating point strings it is passed. + Safe, albeit rudimentary, Watcom support is provided by PNG_API_RULE==2 + Two new APIs exist to get the number of passes without turning on the + PNG_INTERLACE transform and to get the number of rows in the current + pass. + A new test program, pngvalid.c, validates the gamma code. + Errors in the 16-bit gamma correction (overflows) have been corrected. + cHRM chunk testing is done consistently (previously the floating point + API bypassed it, because the test really didn't work on FP, now the test + is performed on the actual values to be stored in the PNG file so it + works in the FP case too.) + Most floating point APIs now simply call the fixed point APIs after + converting the values to the fixed point form used in the PNG file. + The standard headers no longer include zlib.h, which is currently only + required for pngstruct.h and can therefore be internal. + Revised png_get_int_32 to undo the PNG two's complement representation of + negative numbers. + +Version 1.5.0beta37 [July 30, 2010] + Added a typecast in png_get_int_32() in png.h and pngrutil.h to avoid + a compiler warning. + Replaced oFFs 0,0 with oFFs -10,20 in pngtest.png + +Version 1.5.0beta38 [July 31, 2010] + Implemented remaining "_fixed" functions. + Corrected a number of recently introduced warnings mostly resulting from + safe but uncast assignments to shorter integers. Also added a zlib + VStudio release library project because the latest zlib Official Windows + build does not include such a thing. + Revised png_get_int_16() to be similar to png_get_int_32(). + Restored projects/visualc71. + +Version 1.5.0beta39 [August 2, 2010] + VisualC/GCC warning fixes, VisualC build fixes + The changes include support for function attributes in VC in addition to + those already present in GCC - necessary because without these some + warnings are unavoidable. Fixes include signed/unsigned fixes in + pngvalid and checks with gcc -Wall -Wextra -Wunused. + VC requires function attributes on function definitions as well as + declarations, PNG_FUNCTION has been added to enable this and the + relevant function definitions changed. + +Version 1.5.0beta40 [August 6, 2010] + Correct use of _WINDOWS_ in pngconf.h + Removed png_mem_ #defines; they are no longer used. + Added the sRGB chunk to pngtest.png + +Version 1.5.0beta41 [August 11, 2010] + Added the cHRM chunk to pngtest.png + Don't try to use version-script with cygwin/mingw. + Revised contrib/gregbook to work under cygwin/mingw. + +Version 1.5.0beta42 [August 18, 2010] + Add .dll.a to the list of extensions to be symlinked by Makefile.am (Yaakov) + Made all API functions that have const arguments and constant string + literal pointers declare them (John Bowler). + +Version 1.5.0beta43 [August 20, 2010] + Removed spurious tabs, shorten long lines (no source change) + Also added scripts/chkfmt to validate the format of all the files that can + reasonably be validated (it is suggested to run "make distclean" before + checking, because some machine generated files have long lines.) + Reformatted the CHANGES file to be more consistent throughout. + Made changes to address various issues identified by GCC, mostly + signed/unsigned and shortening problems on assignment but also a few + difficult to optimize (for GCC) loops. + Fixed non-GCC fixed point builds. In png.c a declaration was misplaced + in an earlier update. Fixed to declare the auto variables at the head. + Use cexcept.h in pngvalid.c. + +Version 1.5.0beta44 [August 24, 2010] + Updated CMakeLists.txt to use CMAKE_INSTALL_LIBDIR variable; useful for + installing libpng in /usr/lib64 (Funda Wang). + Revised CMakeLists.txt to put the man pages in share/man/man* not man/man* + Revised CMakeLists.txt to make symlinks instead of copies when installing. + Changed PNG_LIB_NAME from pngNN to libpngNN in CMakeLists.txt (Philip Lowman) + Implemented memory checks within pngvalid + Reformatted/rearranged pngvalid.c to assist use of progressive reader. + Check interlaced images in pngvalid + Clarified pngusr.h comments in pnglibconf.dfa + Simplified the pngvalid error-handling code now that cexcept.h is in place. + Implemented progressive reader in pngvalid.c for standard tests + Implemented progressive read in pngvalid.c gamma tests + Turn on progressive reader in pngvalid.c by default and tidy code. + +Version 1.5.0beta45 [August 26, 2010] + Added an explicit make step to projects/vstudio for pnglibconf.h + Also corrected zlib.vcxproj into which Visual Studio had introduced + what it calls an "authoring error". The change to make pnglibconf.h + simply copies the file; in the future it may actually generate the + file from scripts/pnglibconf.dfa as the other build systems do. + Changed pngvalid to work when floating point APIs are disabled + Renamed the prebuilt scripts/pnglibconf.h to scripts/pnglibconf.h.prebuilt + Supply default values for PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX + in pngpriv.h in case the user neglected to define them in their pngusr.h + +Version 1.5.0beta46 [August 28, 2010] + Added new private header files to libpng_sources in CMakeLists.txt + Added PNG_READ_16BIT, PNG_WRITE_16BIT, and PNG_16BIT options. + Added reference to scripts/pnglibconf.h.prebuilt in the visualc71 project. + +Version 1.5.0beta47 [September 11, 2010] + Fixed a number of problems with 64-bit compilation reported by Visual + Studio 2010 (John Bowler). + +Version 1.5.0beta48 [October 4, 2010] + Updated CMakeLists.txt (Philip Lowman). + Revised autogen.sh to recognize and use $AUTOCONF, $AUTOMAKE, $AUTOHEADER, + $AUTOPOINT, $ACLOCAL and $LIBTOOLIZE + Fixed problem with symbols creation in Makefile.am which was assuming that + all versions of ccp write to standard output by default (Martin Banky). The + bug was introduced in libpng-1.2.9beta5. + Removed unused mkinstalldirs. + +Version 1.5.0beta49 [October 8, 2010] + Undid Makefile.am revision of 1.5.0beta48. + +Version 1.5.0beta50 [October 14, 2010] + Revised Makefile.in to account for mkinstalldirs being removed. + Added some "(unsigned long)" typecasts in printf statements in pngvalid.c. + Suppressed a compiler warning in png_handle_sPLT(). + Check for out-of-range text compression mode in png_set_text(). + +Version 1.5.0beta51 [October 15, 2010] + Changed embedded dates to "(PENDING RELEASE) in beta releases (and future + rc releases) to minimize the difference between releases. + +Version 1.5.0beta52 [October 16, 2010] + Restored some of the embedded dates (in png.h, png.c, documentation, etc.) + +Version 1.5.0beta53 [October 18, 2010] + Updated INSTALL to mention using "make maintainer-clean" and to remove + obsolete statement about a custom ltmain.sh + Disabled "color-tests" by default in Makefile.am so it will work with + automake versions earlier than 1.11.1 + Use document name "libpng-manual.txt" instead of "libpng-.txt" + to simplify version differences. + Removed obsolete remarks about setjmp handling from INSTALL. + Revised and renamed the typedef in png.h and png.c that was designed + to catch library and header mismatch. + +Version 1.5.0beta54 [November 10, 2010] + Require 48 bytes, not 64 bytes, for big_row_buf in overflow checks. + Used a consistent structure for the pngget.c functions. + +Version 1.5.0beta55 [November 21, 2010] + Revised png_get_uint_32, png_get_int_32, png_get_uint_16 (Cosmin) + Moved reading of file signature into png_read_sig (Cosmin) + Fixed atomicity of chunk header serialization (Cosmin) + Added test for io_state in pngtest.c (Cosmin) + Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts. + Changes to remove gcc warnings (John Bowler) + Certain optional gcc warning flags resulted in warnings in libpng code. + With these changes only -Wconversion and -Wcast-qual cannot be turned on. + Changes are trivial rearrangements of code. -Wconversion is not possible + for pngrutil.c (because of the widespread use of += et al on variables + smaller than (int) or (unsigned int)) and -Wcast-qual is not possible + with pngwio.c and pngwutil.c because the 'write' callback and zlib + compression both fail to declare their input buffers with 'const'. + +Version 1.5.0beta56 [December 7, 2010] + Added the private PNG_UNUSED() macro definition in pngpriv.h. + Added some commentary about PNG_EXPORT in png.h and pngconf.h + Revised PNG_EXPORT() macro and added PNG_EXPORTA() macro, with the + objective of simplifying and improving the cosmetic appearance of png.h. + Fixed some incorrect "=" macro names in pnglibconf.dfa + Included documentation of changes in 1.5.0 from 1.4.x in libpng-manual.txt + +Version 1.5.0beta57 [December 9, 2010] + Documented the pngvalid gamma error summary with additional comments and + print statements. + Improved missing symbol handling in checksym.awk; symbols missing in both + the old and new files can now be optionally ignored, treated as errors + or warnings. + Removed references to pngvcrd.c and pnggccrd.c from the vstudio project. + Updated "libpng14" to "libpng15" in the visualc71 project. + Enabled the strip16 tests in pngvalid.` + Don't display test results (except PASS/FAIL) when running "make test". + Instead put them in pngtest-log.txt + Added "--with-zprefix=" to configure.ac + Updated the prebuilt configuration files to autoconf version 2.68 + +Version 1.5.0beta58 [December 19, 2010] + Fixed interlace image handling and add test cases (John Bowler) + Fixed the clean rule in Makefile.am to remove pngtest-log.txt + Made minor changes to work around warnings in gcc 3.4 + +Version 1.5.0rc01 [December 27, 2010] + No changes. + +Version 1.5.0rc02 [December 27, 2010] + Eliminated references to the scripts/*.def files in project/visualc71. + +Version 1.5.0rc03 [December 28, 2010] + Eliminated scripts/*.def and revised Makefile.am accordingly + +Version 1.5.0rc04 [December 29, 2010] + Fixed bug in background transformation handling in pngrtran.c (it was + looking for the flag in png_ptr->transformations instead of in + png_ptr->flags) (David Raymond). + +Version 1.5.0rc05 [December 31, 2010] + Fixed typo in a comment in CMakeLists.txt (libpng14 => libpng15) (Cosmin) + +Version 1.5.0rc06 [January 4, 2011] + Changed the new configure option "zprefix=string" to "zlib-prefix=string" + +Version 1.5.0rc07 [January 4, 2011] + Updated copyright year. + +Version 1.5.0 [January 6, 2011] + No changes. + +version 1.5.1beta01 [January 8, 2011] + Added description of png_set_crc_action() to the manual. + Added a note in the manual that the type of the iCCP profile was changed + from png_charpp to png_bytepp in png_get_iCCP(). This change happened + in version 1.5.0beta36 but is not noted in the CHANGES. Similarly, + it was changed from png_charpp to png_const_bytepp in png_set_iCCP(). + Ensure that png_rgb_to_gray ignores palette mapped images, if libpng + internally happens to call it with one, and fixed a failure to handle + palette mapped images correctly. This fixes CVE-2690. + +Version 1.5.1beta02 [January 14, 2011] + Fixed a bug in handling of interlaced images (bero at arklinux.org). + Updated CMakeLists.txt (Clifford Yapp) + +Version 1.5.1beta03 [January 14, 2011] + Fixed typecasting of some png_debug() statements (Cosmin) + +Version 1.5.1beta04 [January 16, 2011] + Updated documentation of png_set|get_tRNS() (Thomas Klausner). + Mentioned in the documentation that applications must #include "zlib.h" + if they need access to anything in zlib.h, and that a number of + macros such as png_memset() are no longer accessible by applications. + Corrected pngvalid gamma test "sample" function to access all of the color + samples of each pixel, instead of sampling the red channel three times. + Prefixed variable names index, div, exp, gamma with "png_" to avoid "shadow" + warnings, and (mistakenly) changed png_exp() to exp(). + +Version 1.5.1beta05 [January 16, 2011] + Changed variable names png_index, png_div, png_exp, and png_gamma to + char_index, divisor, exp_b10, and gamma_val, respectively, and + changed exp() back to png_exp(). + +Version 1.5.1beta06 [January 20, 2011] + Prevent png_push_crc_skip() from hanging while reading an unknown chunk + or an over-large compressed zTXt chunk with the progressive reader. + Eliminated more GCC "shadow" warnings. + Revised png_fixed() in png.c to avoid compiler warning about reaching the + end without returning anything. + +Version 1.5.1beta07 [January 22, 2011] + In the manual, describe the png_get_IHDR() arguments in the correct order. + Added const_png_structp and const_png_infop types, and used them in + prototypes for most png_get_*() functions. + +Version 1.5.1beta08 [January 23, 2011] + Added png_get_io_chunk_type() and deprecated png_get_io_chunk_name() + Added synopses for the IO_STATE functions and other missing synopses + to the manual. Removed the synopses from libpngpf.3 because they + were out of date and no longer useful. Better information can be + obtained by reading the prototypes and comments in pngpriv.h + Attempted to fix cpp on Solaris with S. Studio 12 cc, fix build + Added a make macro DFNCPP that is a CPP that will accept the tokens in + a .dfn file and adds configure stuff to test for such a CPP. ./configure + should fail if one is not available. + Corrected const_png_ in png.h to png_const_ to avoid polluting the namespace. + Added png_get_current_row_number and png_get_current_pass_number for the + benefit of the user transform callback. + Added png_process_data_pause and png_process_data_skip for the benefit of + progressive readers that need to stop data processing or want to optimize + skipping of unread data (e.g., if the reader marks a chunk to be skipped.) + +Version 1.5.1beta09 [January 24, 2011] + Enhanced pngvalid, corrected an error in gray_to_rgb, corrected doc error. + pngvalid contains tests of transforms, which tests are currently disabled + because they are incompletely tested. gray_to_rgb was failing to expand + the bit depth for smaller bit depth images; this seems to be a long + standing error and resulted, apparently, in invalid output + (CVE-2011-0408, CERT VU#643140). The documentation did not accurately + describe what libpng really does when converting RGB to gray. + +Version 1.5.1beta10 [January 27, 2010] + Fixed incorrect examples of callback prototypes in the manual, that were + introduced in libpng-1.0.0. + In addition the order of the png_get_uint macros with respect to the + relevant function definitions has been reversed. This helps the + preprocessing of the symbol files be more robust. Furthermore, the + symbol file preprocessing now uses -DPNG_NO_USE_READ_MACROS even when + the library may actually be built with PNG_USE_READ_MACROS; this stops + the read macros interfering with the symbol file format. + Made the manual, synopses, and function prototypes use the function + argument names file_gamma, int_file_gamma, and srgb_intent consistently. + +Version 1.5.1beta11 [January 28, 2011] + Changed PNG_UNUSED from "param=param;" to "{if(param){}}". + Corrected local variable type in new API png_process_data_skip() + The type was self-evidently incorrect but only causes problems on 64-bit + architectures. + Added transform tests to pngvalid and simplified the arguments. + +Version 1.5.1rc01 [January 29, 2011] + No changes. + +Version 1.5.1rc02 [January 31, 2011] + Added a request in the manual that applications do not use "png_" or + "PNG_" to begin any of their own symbols. + Changed PNG_UNUSED to "(void)param;" and updated the commentary in pngpriv.h + +Version 1.5.1 [February 3, 2011] + No changes. + +Version 1.5.2beta01 [February 13, 2011] + More -Wshadow fixes for older gcc compilers. Older gcc versions apparently + check formal parameters names in function declarations (as well as + definitions) to see if they match a name in the global namespace. + Revised PNG_EXPORTA macro to not use an empty parameter, to accommodate the + old VisualC++ preprocessor. + Turned on interlace handling in png_read_png(). + Fixed gcc pedantic warnings. + Handle longjmp in Cygwin. + Fixed png_get_current_row_number() in the interlaced case. + Cleaned up ALPHA flags and transformations. + Implemented expansion to 16 bits. + +Version 1.5.2beta02 [February 19, 2011] + Fixed mistake in the descriptions of user read_transform and write_transform + function prototypes in the manual. The row_info struct is png_row_infop. + Reverted png_get_current_row_number() to previous (1.5.2beta01) behavior. + Corrected png_get_current_row_number documentation + Fixed the read/write row callback documentation. + This documents the current behavior, where the callback is called after + every row with information pertaining to the next row. + +Version 1.5.2beta03 [March 3, 2011] + Fixed scripts/makefile.vcwin32 + Updated contrib/pngsuite/README to add the word "modify". + Define PNG_ALLOCATED to blank when _MSC_VER<1300. + +Version 1.5.2rc01 [March 19, 2011] + Define remaining attributes to blank when MSC_VER<1300. + ifdef out mask arrays in pngread.c when interlacing is not supported. + +Version 1.5.2rc02 [March 22, 2011] + Added a hint to try CPP=/bin/cpp if "cpp -E" fails in scripts/pnglibconf.mak + and in contrib/pngminim/*/makefile, eg., on SunOS 5.10, and removed "strip" + from the makefiles. + Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail + to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill) + +Version 1.5.2rc03 [March 24, 2011] + Don't include standard header files in png.h while building the symbol table, + to avoid cpp failure on SunOS (introduced PNG_BUILDING_SYMBOL_TABLE macro). + +Version 1.5.2 [March 31, 2011] + No changes. + +Version 1.5.3beta01 [April 1, 2011] + Re-initialize the zlib compressor before compressing non-IDAT chunks. + Added API functions (png_set_text_compression_level() and four others) to + set parameters for zlib compression of non-IDAT chunks. + +Version 1.5.3beta02 [April 3, 2011] + Updated scripts/symbols.def with new API functions. + Only compile the new zlib re-initializing code when text or iCCP is + supported, using PNG_WRITE_COMPRESSED_TEXT_SUPPORTED macro. + Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03). + Optimize the zlib CMF byte in non-IDAT compressed chunks + +Version 1.5.3beta03 [April 16, 2011] + Fixed gcc -ansi -pedantic compile. A strict ANSI system does not have + snprintf, and the "__STRICT_ANSI__" detects that condition more reliably + than __STDC__ (John Bowler). + Removed the PNG_PTR_NORETURN attribute because it too dangerous. It tells + the compiler that a user supplied callback (the error handler) does not + return, yet there is no guarantee in practice that the application code + will correctly implement the error handler because the compiler only + issues a warning if there is a mistake (John Bowler). + Removed the no-longer-used PNG_DEPSTRUCT macro. + Updated the zlib version to 1.2.5 in the VStudio project. + Fixed 64-bit builds where png_uint_32 is smaller than png_size_t in + pngwutil.c (John Bowler). + Fixed bug with stripping the filler or alpha channel when writing, that + was introduced in libpng-1.5.2beta01 (bug report by Andrew Church). + +Version 1.5.3beta04 [April 27, 2011] + Updated pngtest.png with the new zlib CMF optimization. + Cleaned up conditional compilation code and of background/gamma handling + Internal changes only except a new option to avoid compiling the + png_build_grayscale_palette API (which is not used at all internally.) + The main change is to move the transform tests (READ_TRANSFORMS, + WRITE_TRANSFORMS) up one level to the caller of the APIs. This avoids + calls to spurious functions if all transforms are disabled and slightly + simplifies those functions. Pngvalid modified to handle this. + A minor change is to stop the strip_16 and expand_16 interfaces from + disabling each other; this allows the future alpha premultiplication + code to use 16-bit intermediate values while still producing 8-bit output. + png_do_background and png_do_gamma have been simplified to take a single + pointer to the png_struct rather than pointers to every item required + from the png_struct. This makes no practical difference to the internal + code. + A serious bug in the pngvalid internal routine 'standard_display_init' has + been fixed - this failed to initialize the red channel and accidentally + initialized the alpha channel twice. + Changed png_struct jmp_buf member name from png_jmpbuf to tmp_jmpbuf to + avoid a possible clash with the png_jmpbuf macro on some platforms. + +Version 1.5.3beta05 [May 6, 2011] + Added the "_POSIX_SOURCE" feature test macro to ensure libpng sees the + correct API. _POSIX_SOURCE is defined in pngpriv.h, pngtest.c and + pngvalid.c to ensure that POSIX conformant systems disable non-POSIX APIs. + Removed png_snprintf and added formatted warning messages. This change adds + internal APIs to allow png_warning messages to have parameters without + requiring the host OS to implement snprintf. As a side effect the + dependency of the tIME-supporting RFC1132 code on stdio is removed and + PNG_NO_WARNINGS does actually work now. + Pass "" instead of '\0' to png_default_error() in png_err(). This mistake + was introduced in libpng-1.2.20beta01. This fixes CVE-2011-2691. + Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte + optimization configurable. + IDAT compression failed if preceded by a compressed text chunk (bug + introduced in libpng-1.5.3beta01-02). This was because the attempt to + reset the zlib stream in png_write_IDAT happened after the first IDAT + chunk had been deflated - much too late. In this change internal + functions were added to claim/release the z_stream and, hopefully, make + the code more robust. Also deflateEnd checking is added - previously + libpng would ignore an error at the end of the stream. + +Version 1.5.3beta06 [May 8, 2011] + Removed the -D_ALL_SOURCE from definitions for AIX in CMakeLists.txt + Implemented premultiplied alpha support: png_set_alpha_mode API + +Version 1.5.3beta07 [May 11, 2011] + Added expand_16 support to the high level interface. + Added named value and 'flag' gamma support to png_set_gamma. Made a minor + change from the previous (unreleased) ABI/API to hide the exact value used + for Macs - it's not a good idea to embed this in the ABI! + Moved macro definitions for PNG_HAVE_IHDR, PNG_HAVE_PLTE, and PNG_AFTER_IDAT + from pngpriv.h to png.h because they must be visible to applications + that call png_set_unknown_chunks(). + Check for up->location !PNG_AFTER_IDAT when writing unknown chunks + before IDAT. + +Version 1.5.3beta08 [May 16, 2011] + Improved "pngvalid --speed" to exclude more of pngvalid from the time. + Documented png_set_alpha_mode(), other changes in libpng.3/libpng-manual.txt + The cHRM chunk now sets the defaults for png_set_rgb_to_gray() (when negative + parameters are supplied by the caller), while in the absence of cHRM + sRGB/Rec 709 values are still used. This introduced a divide-by-zero + bug in png_handle_cHRM(). + The bKGD chunk no longer overwrites the background value set by + png_set_background(), allowing the latter to be used before the file + header is read. It never performed any useful function to override + the default anyway. + Added memory overwrite and palette image checks to pngvalid.c + Previously palette image code was poorly checked. Since the transformation + code has a special palette path in most cases this was a severe weakness. + Minor cleanup and some extra checking in pngrutil.c and pngrtran.c. When + expanding an indexed image, always expand to RGBA if transparency is + present. + +Version 1.5.3beta09 [May 17, 2011] + Reversed earlier 1.5.3 change of transformation order; move png_expand_16 + back where it was. The change doesn't work because it requires 16-bit + gamma tables when the code only generates 8-bit ones. This fails + silently; the libpng code just doesn't do any gamma correction. Moving + the tests back leaves the old, inaccurate, 8-bit gamma calculations, but + these are clearly better than none! + +Version 1.5.3beta10 [May 20, 2011] + + png_set_background() and png_expand_16() did not work together correctly. + This problem is present in 1.5.2; if png_set_background is called with + need_expand false and the matching 16 bit color libpng erroneously just + treats it as an 8-bit color because of where png_do_expand_16 is in the + transform list. This simple fix reduces the supplied colour to 8-bits, + so it gets smashed, but this is better than the current behavior. + Added tests for expand16, more fixes for palette image tests to pngvalid. + Corrects the code for palette image tests and disables attempts to + validate palette colors. + +Version 1.5.3rc01 [June 3, 2011] + No changes. + +Version 1.5.3rc02 [June 8, 2011] + Fixed uninitialized memory read in png_format_buffer() (Bug report by + Frank Busse, CVE-2011-2501, related to CVE-2004-0421). + +Version 1.5.3beta11 [June 11, 2011] + Fixed png_handle_sCAL which is broken in 1.5. This fixes CVE 2011-2692. + Added sCAL to pngtest.png + Revised documentation about png_set_user_limits() to say that it also affects + png writing. + Revised handling of png_set_user_limits() so that it can increase the + limit beyond the PNG_USER_WIDTH|HEIGHT_MAX; previously it could only + reduce it. + Make the 16-to-8 scaling accurate. Dividing by 256 with no rounding is + wrong (high by one) 25% of the time. Dividing by 257 with rounding is + wrong in 128 out of 65536 cases. Getting the right answer all the time + without division is easy. + Added "_SUPPORTED" to the PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION macro. + Added projects/owatcom, an IDE project for OpenWatcom to replace + scripts/makefile.watcom. This project works with OpenWatcom 1.9. The + IDE autogenerates appropriate makefiles (libpng.mk) for batch processing. + The project is configurable, unlike the Visual Studio project, so long + as the developer has an awk. + Changed png_set_gAMA to limit the gamma value range so that the inverse + of the stored value cannot overflow the fixed point representation, + and changed other things OpenWatcom warns about. + Revised pngvalid.c to test PNG_ALPHA_MODE_SUPPORTED correctly. This allows + pngvalid to build when ALPHA_MODE is not supported, which is required if + it is to build on libpng 1.4. + Removed string/memory macros that are no longer used and are not + necessarily fully supportable, particularly png_strncpy and png_snprintf. + Added log option to pngvalid.c and attempted to improve gamma messages. + +Version 1.5.3 [omitted] + People found the presence of a beta release following an rc release + to be confusing; therefore we bump the version to libpng-1.5.4beta01 + and there will be no libpng-1.5.3 release. + +Version 1.5.4beta01 [June 14, 2011] + Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED + to get the same (inaccurate) output as libpng-1.5.2 and earlier. + Moved definitions of PNG_HAVE_IHDR, PNG_AFTER_IDAT, and PNG_HAVE_PLTE + outside of an unknown-chunk block in png.h because they are also + needed for other uses. + +Version 1.5.4beta02 [June 14, 2011] + Fixed and clarified LEGACY 16-to-8 scaling code. + Added png_set_chop_16() API, to match inaccurate results from previous + libpng versions. + Removed the ACCURATE and LEGACY options (they are no longer useable) + Use the old scaling method for background if png_set_chop_16() was + called. + Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED + +Version 1.5.4beta03 [June 15, 2011] + Fixed a problem in png_do_expand_palette() exposed by optimization in + 1.5.3beta06 + Also removed a spurious and confusing "trans" member ("trans") from png_info. + The palette expand optimization prevented expansion to an intermediate RGBA + form if tRNS was present but alpha was marked to be stripped; this exposed + a check for tRNS in png_do_expand_palette() which is inconsistent with the + code elsewhere in libpng. + Correction to the expand_16 code; removed extra instance of + png_set_scale_16_to_8 from pngpriv.h + +Version 1.5.4beta04 [June 16, 2011] + Added a missing "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c + Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms. + Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again. If this is + not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built. + Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8 + +Version 1.5.4beta05 [June 16, 2011] + Renamed png_set_strip_16() to png_set_scale_16() and renamed + png_set_chop_16() to png_set_strip(16) in an attempt to minimize the + behavior changes between libpng14 and libpng15. + +Version 1.5.4beta06 [June 18, 2011] + Fixed new bug that was causing both strip_16 and scale_16 to be applied. + +Version 1.5.4beta07 [June 19, 2011] + Fixed pngvalid, simplified macros, added checking for 0 in sCAL. + The ACCURATE scale macro is no longer defined in 1.5 - call the + png_scale_16_to_8 API. Made sure that PNG_READ_16_TO_8 is still defined + if the png_strip_16_to_8 API is present. png_check_fp_number now + maintains some state so that positive, negative and zero values are + identified. sCAL uses these to be strictly spec conformant. + +Version 1.5.4beta08 [June 23, 2011] + Fixed pngvalid if ACCURATE_SCALE is defined. + Updated scripts/pnglibconf.h.prebuilt. + +Version 1.5.4rc01 [June 30, 2011] + Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400. + +Version 1.5.4 [July 7, 2011] + No changes. + +Version 1.5.5beta01 [July 13, 2011] + Fixed some typos and made other minor changes in the manual. + Updated contrib/pngminus/makefile.std (Samuli Souminen) + +Version 1.5.5beta02 [July 14, 2011] + Revised Makefile.am and Makefile.in to look in the right directory for + pnglibconf.h.prebuilt + +Version 1.5.5beta03 [July 27, 2011] + Enabled compilation with g++ compiler. This compiler does not recognize + the file extension, so it always compiles with C++ rules. Made minor + changes to pngrutil.c to cast results where C++ expects it but C does not. + Minor editing of libpng.3 and libpng-manual.txt. + +Version 1.5.5beta04 [July 29, 2011] + Revised CMakeLists.txt (Clifford Yapp) + Updated commentary about the png_rgb_to_gray() default coefficients + in the manual and in pngrtran.c + +Version 1.5.5beta05 [August 17, 2011] + Prevent unexpected API exports from non-libpng DLLs on Windows. The "_DLL" + is removed from the test of whether a DLL is being built (this erroneously + caused the libpng APIs to be marked as DLL exports in static builds under + Microsoft Visual Studio). Almost all of the libpng building configuration + is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in + pngconf.h, though, so that it is colocated with the import definition (it + is no longer used anywhere in the installed headers). The VStudio project + definitions have been cleaned up: "_USRDLL" has been removed from the + static library builds (this was incorrect), and PNG_USE_DLL has been added + to pngvalid to test the functionality (pngtest does not supply it, + deliberately). The spurious "_EXPORTS" has been removed from the + libpng build (all these errors were a result of copy/paste between project + configurations.) + Added new types and internal functions for CIE RGB end point handling to + pngpriv.h (functions yet to be implemented). + +Version 1.5.5beta06 [August 26, 2011] + Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set in CMakeLists.txt + (Clifford Yap) + Fixes to rgb_to_gray and cHRM XYZ APIs (John Bowler): + The rgb_to_gray code had errors when combined with gamma correction. + Some pixels were treated as true grey when they weren't and such pixels + and true grey ones were not gamma corrected (the original value of the + red component was used instead). APIs to get and set cHRM using color + space end points have been added and the rgb_to_gray code that defaults + based on cHRM, and the divide-by-zero bug in png_handle_cHRM (CERT + VU#477046, CVE-2011-3328, introduced in 1.5.4) have been corrected. + A considerable number of tests has been added to pngvalid for the + rgb_to_gray transform. + Arithmetic errors in rgb_to_gray whereby the calculated gray value was + truncated to the bit depth rather than rounded have been fixed except in + the 8-bit non-gamma-corrected case (where consistency seems more important + than correctness.) The code still has considerable inaccuracies in the + 8-bit case because 8-bit linear arithmetic is used. + +Version 1.5.5beta07 [September 7, 2011] + Added "$(ARCH)" option to makefile.darwin + Added SunOS support to configure.ac and Makefile.am + Changed png_chunk_benign_error() to png_warning() in png.c, in + png_XYZ_from_xy_checked(). + +Version 1.5.5beta08 [September 10, 2011] + Fixed 64-bit compilation errors (gcc). The errors fixed relate + to conditions where types that are 32 bits in the GCC 32-bit + world (uLong and png_size_t) become 64 bits in the 64-bit + world. This produces potential truncation errors which the + compiler correctly flags. + Relocated new HAVE_SOLARIS_LD definition in configure.ac + Constant changes for 64-bit compatibility (removal of L suffixes). The + 16-bit cases still use "L" as we don't have a 16-bit test system. + +Version 1.5.5rc01 [September 15, 2011] + Removed "L" suffixes in pngpriv.h + +Version 1.5.5 [September 22, 2011] + No changes. + +Version 1.5.6beta01 [September 22, 2011] + Fixed some 64-bit type conversion warnings in pngrtran.c + Moved row_info from png_struct to a local variable. + The various interlace mask arrays have been made into arrays of + bytes and made PNG_CONST and static (previously some arrays were + marked PNG_CONST and some weren't). + Additional checks have been added to the transform code to validate the + pixel depths after the transforms on both read and write. + Removed some redundant code from pngwrite.c, in png_destroy_write_struct(). + Changed chunk reading/writing code to use png_uint_32 instead of png_byte[4]. + This removes the need to allocate temporary strings for chunk names on + the stack in the read/write code. Unknown chunk handling still uses the + string form because this is exposed in the API. + +Version 1.5.6beta02 [September 26, 2011] + Added a note in the manual the png_read_update_info() must be called only + once with a particular info_ptr. + Fixed a typo in the definition of the new PNG_STRING_FROM_CHUNK(s,c) macro. + +Version 1.5.6beta03 [September 28, 2011] + Revised test-pngtest.sh to report FAIL when pngtest fails. + Added "--strict" option to pngtest, to report FAIL when the failure is + only because the resulting valid files are different. + Revised CMakeLists.txt to work with mingw and removed some material from + CMakeLists.txt that is no longer useful in libpng-1.5. + +Version 1.5.6beta04 [October 5, 2011] + Fixed typo in Makefile.in and Makefile.am ("-M Wl" should be "-M -Wl")." + +Version 1.5.6beta05 [October 12, 2011] + Speed up png_combine_row() for interlaced images. This reduces the generality + of the code, allowing it to be optimized for Adam7 interlace. The masks + passed to png_combine_row() are now generated internally, avoiding + some code duplication and localizing the interlace handling somewhat. + Align png_struct::row_buf - previously it was always unaligned, caused by + a bug in the code that attempted to align it; the code needs to subtract + one from the pointer to take account of the filter byte prepended to + each row. + Optimized png_combine_row() when rows are aligned. This gains a small + percentage for 16-bit and 32-bit pixels in the typical case where the + output row buffers are appropriately aligned. The optimization was not + previously possible because the png_struct buffer was always misaligned. + Fixed bug in png_write_chunk_header() debug print, introduced in 1.5.6beta01. + +Version 1.5.6beta06 [October 17, 2011] + Removed two redundant tests for uninitialized row. + Fixed a relatively harmless memory overwrite in compressed text writing + with a 1 byte zlib buffer. + Add ability to call png_read_update_info multiple times to pngvalid.c. + Fixes for multiple calls to png_read_update_info. These fixes attend to + most of the errors revealed in pngvalid, however doing the gamma work + twice results in inaccuracies that can't be easily fixed. There is now + a warning in the code if this is going to happen. + Turned on multiple png_read_update_info in pngvalid transform tests. + Prevent libpng from overwriting unused bits at the end of the image when + it is not byte aligned, while reading. Prior to libpng-1.5.6 libpng would + overwrite the partial byte at the end of each row if the row width was not + an exact multiple of 8 bits and the image is not interlaced. + +Version 1.5.6beta07 [October 21, 2011] + Made png_ptr->prev_row an aligned pointer into png_ptr->big_prev_row + (Mans Rullgard). + +Version 1.5.6rc01 [October 26, 2011] + Changed misleading "Missing PLTE before cHRM" warning to "Out of place cHRM" + +Version 1.5.6rc02 [October 27, 2011] + Added LSR() macro to defend against buggy compilers that evaluate non-taken + code branches and complain about out-of-range shifts. + +Version 1.5.6rc03 [October 28, 2011] + Renamed the LSR() macro to PNG_LSR() and added PNG_LSL() macro. + Fixed compiler warnings with Intel and MSYS compilers. The logical shift + fix for Microsoft Visual C is required by other compilers, so this + enables that fix for all compilers when using compile-time constants. + Under MSYS 'byte' is a name declared in a system header file, so we + changed the name of a local variable to avoid the warnings that result. + Added #define PNG_ALIGN_TYPE PNG_ALIGN_NONE to contrib/pngminim/*/pngusr.h + +Version 1.5.6 [November 3, 2011] + No changes. + +Version 1.5.7beta01 [November 4, 2011] + Added support for ARM processor, when decoding all PNG up-filtered rows + and any other-filtered rows with 3 or 4 bytes per pixel (Mans Rullgard). + Fixed bug in pngvalid on early allocation failure; fixed type cast in + pngmem.c; pngvalid would attempt to call png_error() if the allocation + of a png_struct or png_info failed. This would probably have led to a + crash. The pngmem.c implementation of png_malloc() included a cast + to png_size_t which would fail on large allocations on 16-bit systems. + Fix for the preprocessor of the Intel C compiler. The preprocessor + splits adjacent @ signs with a space; this changes the concatenation + token from @-@-@ to PNG_JOIN; that should work with all compiler + preprocessors. + Paeth filter speed improvements from work by Siarhei Siamashka. This + changes the 'Paeth' reconstruction function to improve the GCC code + generation on x86. The changes are only part of the suggested ones; + just the changes that definitely improve speed and remain simple. + The changes also slightly increase the clarity of the code. + +Version 1.5.7beta02 [November 11, 2011] + Check compression_type parameter in png_get_iCCP and remove spurious + casts. The compression_type parameter is always assigned to, so must + be non-NULL. The cast of the profile length potentially truncated the + value unnecessarily on a 16-bit int system, so the cast of the (byte) + compression type to (int) is specified by ANSI-C anyway. + Fixed FP division by zero in pngvalid.c; the 'test_pixel' code left + the sBIT fields in the test pixel as 0, which resulted in a floating + point division by zero which was irrelevant but causes systems where + FP exceptions cause a crash. Added code to pngvalid to turn on FP + exceptions if the appropriate glibc support is there to ensure this is + tested in the future. + Updated scripts/pnglibconf.mak and scripts/makefile.std to handle the + new PNG_JOIN macro. + Added versioning to pnglibconf.h comments. + Simplified read/write API initial version; basic read/write tested on + a variety of images, limited documentation (in the header file.) + Installed more accurate linear to sRGB conversion tables. The slightly + modified tables reduce the number of 16-bit values that + convert to an off-by-one 8-bit value. The "makesRGB.c" code that was used + to generate the tables is now in a contrib/sRGBtables sub-directory. + +Version 1.5.7beta03 [November 17, 2011] + Removed PNG_CONST from the sRGB table declarations in pngpriv.h and png.c + Added run-time detection of NEON support. + Added contrib/libtests; includes simplified API test and timing test and + a color conversion utility for rapid checking of failed 'pngstest' results. + Multiple transform bug fixes plus a work-round for double gamma correction. + libpng does not support more than one transform that requires linear data + at once - if this is tried typically the results is double gamma + correction. Since the simplified APIs can need rgb to gray combined with + a compose operation it is necessary to do one of these outside the main + libpng transform code. This check-in also contains fixes to various bugs + in the simplified APIs themselves and to some bugs in compose and rgb to + gray (on palette) itself. + Fixes for C++ compilation using g++ When libpng source is compiled + using g++. The compiler imposes C++ rules on the C source; thus it + is desirable to make the source work with either C or C++ rules + without throwing away useful error information. This change adds + png_voidcast to allow C semantic (void*) cases or the corresponding + C++ static_cast operation, as appropriate. + Added --noexecstack to assembler file compilation. GCC does not set + this on assembler compilation, even though it does on C compilation. + This creates security issues if assembler code is enabled; the + work-around is to set it by default in the flags for $(CCAS) + Work around compilers that don't support declaration of const data. Some + compilers fault 'extern const' data declarations (because the data is + not initialized); this turns on const-ness only for compilers where + this is known to work. + +Version 1.5.7beta04 [November 17, 2011] + Since the gcc driver does not recognize the --noexecstack flag, we must + use the -Wa prefix to have it passed through to the assembler. + Also removed a duplicate setting of this flag. + Added files that were omitted from the libpng-1.5.7beta03 zip distribution. + +Version 1.5.7beta05 [November 25, 2011] + Removed "zTXt" from warning in generic chunk decompression function. + Validate time settings passed to png_set_tIME() and png_convert_to_rfc1123() + (Frank Busse). Note: This prevented CVE-2015-7981 from affecting + libpng-1.5.7 and later. + Added MINGW support to CMakeLists.txt + Reject invalid compression flag or method when reading the iTXt chunk. + Backed out 'simplified' API changes. The API seems too complex and there + is a lack of consensus or enthusiasm for the proposals. The API also + reveals significant bugs inside libpng (double gamma correction and the + known bug of being unable to retrieve a corrected palette). It seems + better to wait until the bugs, at least, are corrected. + Moved pngvalid.c into contrib/libtests + Rebuilt Makefile.in, configure, etc., with autoconf-2.68 + +Version 1.5.7rc01 [December 1, 2011] + Replaced an "#if" with "#ifdef" in pngrtran.c + Revised #if PNG_DO_BC block in png.c (use #ifdef and add #else) + +Version 1.5.7rc02 [December 5, 2011] + Revised project files and contrib/pngvalid/pngvalid.c to account for + the relocation of pngvalid into contrib/libtests. + Revised pngconf.h to use " __declspec(restrict)" only when MSC_VER >= 1400, + as in libpng-1.5.4. + Put CRLF line endings in the owatcom project files. + +Version 1.5.7rc03 [December 7, 2011] + Updated CMakeLists.txt to account for the relocation of pngvalid.c + +Version 1.5.7 [December 15, 2011] + Minor fixes to pngvalid.c for gcc 4.6.2 compatibility to remove warnings + reported by earlier versions. + Fixed minor memset/sizeof errors in pngvalid.c. + +Version 1.6.0beta01 [December 15, 2011] + Removed machine-generated configure files from the GIT repository (they will + continue to appear in the tarball distributions and in the libpng15 and + earlier GIT branches). + Restored the new 'simplified' API, which was started in libpng-1.5.7beta02 + but later deleted from libpng-1.5.7beta05. + Added example programs for the new 'simplified' API. + Added ANSI-C (C90) headers and require them, and take advantage of the + change. Also fixed some of the projects/* and contrib/* files that needed + updates for libpng16 and the move of pngvalid.c. + With this change the required ANSI-C header files are assumed to exist: the + implementation must provide float.h, limits.h, stdarg.h and stddef.h and + libpng relies on limits.h and stddef.h existing and behaving as defined + (the other two required headers aren't used). Non-ANSI systems that don't + have stddef.h or limits.h will have to provide an appropriate fake + containing the relevant types and #defines. + Dropped support for 16-bit platforms. The use of FAR/far has been eliminated + and the definition of png_alloc_size_t is now controlled by a flag so + that 'small size_t' systems can select it if necessary. Libpng 1.6 may + not currently work on such systems -- it seems likely that it will + ask 'malloc' for more than 65535 bytes with any image that has a + sufficiently large row size (rather than simply failing to read such + images). + New tools directory containing tools used to generate libpng code. + Fixed race conditions in parallel make builds. With higher degrees of + parallelism during 'make' the use of the same temporary file names such + as 'dfn*' can result in a race where a temporary file from one arm of the + build is deleted or overwritten in another arm. This changes the + temporary files for suffix rules to always use $* and ensures that the + non-suffix rules use unique file names. + +Version 1.6.0beta02 [December 21, 2011] + Correct configure builds where build and source directories are separate. + The include path of 'config.h' was erroneously made relative in pngvalid.c + in libpng 1.5.7. + +Version 1.6.0beta03 [December 22, 2011] + Start-up code size improvements, error handler flexibility. These changes + alter how the tricky allocation of the initial png_struct and png_info + structures are handled. png_info is now handled in pretty much the same + way as everything else, except that the allocations handle NULL return + silently. png_struct is changed in a similar way on allocation and on + deallocation a 'safety' error handler is put in place (which should never + be required). The error handler itself is changed to permit mismatches + in the application and libpng error buffer size; however, this means a + silent change to the API to return the jmp_buf if the size doesn't match + the size from the libpng compilation; libpng now allocates the memory and + this may fail. Overall these changes result in slight code size + reductions; however, this is a reduction in code that is always executed + so is particularly valuable. Overall on a 64-bit system the libpng DLL + decreases in code size by 1733 bytes. pngerror.o increases in size by + about 465 bytes because of the new functionality. + Added png_convert_to_rfc1123_buffer() and deprecated png_convert_to_rfc1123() + to avoid including a spurious buffer in the png_struct. + +Version 1.6.0beta04 [December 30, 2011] + Regenerated configure scripts with automake-1.11.2 + Eliminated png_info_destroy(). It is now used only in png.c and only calls + one other internal function and memset(). + Enabled png_get_sCAL_fixed() if floating point APIs are enabled. Previously + it was disabled whenever internal fixed point arithmetic was selected, + which meant it didn't exist even on systems where FP was available but not + preferred. + Added pngvalid.c compile time checks for const APIs. + Implemented 'restrict' for png_info and png_struct. Because of the way + libpng works both png_info and png_struct are always accessed via a + single pointer. This means adding C99 'restrict' to the pointer gives + the compiler some opportunity to optimize the code. This change allows + that. + Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper + location in configure.ac (Gilles Espinasse). + Changed png_memcpy to C assignment where appropriate. Changed all those + uses of png_memcpy that were doing a simple assignment to assignments + (all those cases where the thing being copied is a non-array C L-value). + Added some error checking to png_set_*() routines. + Removed the reference to the non-exported function png_memcpy() from + example.c. + Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but + it had become misaligned. + Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32 + and unsigned long are of different sizes. + +Version 1.6.0beta05 [January 15, 2012] + Updated manual with description of the simplified API (copied from png.h) + Fix bug in pngerror.c: some long warnings were being improperly truncated + (CVE-2011-3464, bug introduced in libpng-1.5.3beta05). + +Version 1.6.0beta06 [January 24, 2012] + Added palette support to the simplified APIs. This commit + changes some of the macro definitions in png.h, app code + may need corresponding changes. + Increased the formatted warning buffer to 192 bytes. + Added color-map support to simplified API. This is an initial version for + review; the documentation has not yet been updated. + Fixed Min/GW uninstall to remove libpng.dll.a + +Version 1.6.0beta07 [January 28, 2012] + Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived) + compiler issues slightly different warnings from those issued by the + current vesions of GCC. This eliminates those warnings by + adding/removing casts and small code rewrites. + Updated configure.ac from autoupdate: added --enable-werror option. + Also some layout regularization and removal of introduced tab characters + (replaced with 3-character indentation). Obsolete macros identified by + autoupdate have been removed; the replacements are all in 2.59 so + the pre-req hasn't been changed. --enable-werror checks for support + for -Werror (or the given argument) in the compiler. This mimics the + gcc configure option by allowing -Werror to be turned on safely; without + the option the tests written in configure itself fail compilation because + they cause compiler warnings. + Rewrote autogen.sh to run autoreconf instead of running tools one-by-one. + Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt and + set CMAKE_LIBRARY_OUTPUT_DIRECTORY to "lib" on all platforms (C. Yapp). + Freeze libtool files in the 'scripts' directory. This version of autogen.sh + attempts to dissuade people from running it when it is not, or should not, + be necessary. In fact, autogen.sh does not work when run in a libpng + directory extracted from a tar distribution anymore. You must run it in + a GIT clone instead. + Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale), + and renamed three whose names were inconsistent with those in + pngsuite/README.txt. + +Version 1.6.0beta08 [February 1, 2012] + Fixed Image::colormap misalignment in pngstest.c + Check libtool/libtoolize version number (2.4.2) in configure.ac + Divide test-pngstest.sh into separate pngstest runs for basic and + transparent images. + Moved automake options to AM_INIT_AUTOMAKE in configure.ac + Added color-tests, silent-rules (Not yet implemented in Makefile.am) and + version checking to configure.ac + Improved pngstest speed by not doing redundant tests and add const to + the background parameter of png_image_finish_read. The --background + option is now done automagically only when required, so that commandline + option no longer exists. + Cleaned up pngpriv.h to consistently declare all functions and data. + Also eliminated PNG_CONST_DATA, which is apparently not needed but we + can't be sure until it is gone. + Added symbol prefixing that allows all the libpng external symbols + to be prefixed (suggested by Reuben Hawkins). + Updated "ftbb*.png" list in the owatcom and vstudio projects. + Fixed 'prefix' builds on clean systems. The generation of pngprefix.h + should not require itself. + Updated INSTALL to explain that autogen.sh must be run in a GIT clone, + not in a libpng directory extracted from a tar distribution. + +Version 1.6.0beta09 [February 1, 2012] + Reverted the prebuilt configure files to libpng-1.6.0beta05 condition. + +Version 1.6.0beta10 [February 3, 2012] + Added Z_SOLO for zlib-1.2.6+ and correct pngstest tests + Updated list of test images in CMakeLists.txt + Updated the prebuilt configure files to current condition. + Revised INSTALL information about autogen.sh; it works in tar distributions. + +Version 1.6.0beta11 [February 16, 2012] + Fix character count in pngstest command in projects/owatcom/pngstest.tgt + Revised test-pngstest.sh to report PASS/FAIL for each image. + Updated documentation about the simplified API. + Corrected estimate of error in libpng png_set_rgb_to_gray API. The API is + extremely inaccurate for sRGB conversions because it uses an 8-bit + intermediate linear value and it does not use the sRGB transform, so it + suffers from the known instability in gamma transforms for values close + to 0 (see Poynton). The net result is that the calculation has a maximum + error of 14.99/255; 0.5/255^(1/2.2). pngstest now uses 15 for the + permitted 8-bit error. This may still not be enough because of arithmetic + error. + Removed some unused arrays (with #ifdef) from png_read_push_finish_row(). + Fixed a memory overwrite bug in simplified read of RGB PNG with + non-linear gamma Also bugs in the error checking in pngread.c and changed + quite a lot of the checks in pngstest.c to be correct; either correctly + written or not over-optimistic. The pngstest changes are insufficient to + allow all possible RGB transforms to be passed; pngstest cmppixel needs + to be rewritten to make it clearer which errors it allows and then changed + to permit known inaccuracies. + Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h + Fixed fixed/float API export conditionals. 1) If FIXED_POINT or + FLOATING_POINT options were switched off, png.h ended up with lone ';' + characters. This is not valid ANSI-C outside a function. The ';' + characters have been moved inside the definition of PNG_FP_EXPORT and + PNG_FIXED_EXPORT. 2) If either option was switched off, the declaration + of the corresponding functions were completely omitted, even though some + of them are still used internally. The result is still valid, but + produces warnings from gcc with some warning options (including -Wall). The + fix is to cause png.h to declare the functions with PNG_INTERNAL_FUNCTION + when png.h is included from pngpriv.h. + Check for invalid palette index while reading paletted PNG. When one is + found, issue a warning and increase png_ptr->num_palette accordingly. + Apps are responsible for checking to see if that happened. + +Version 1.6.0beta12 [February 18, 2012] + Do not increase num_palette on invalid_index. + Relocated check for invalid palette index to pngrtran.c, after unpacking + the sub-8-bit pixels. + Fixed CVE-2011-3026 buffer overrun bug. This bug was introduced when + iCCP chunk support was added at libpng-1.0.6. Deal more correctly with the + test on iCCP chunk length. Also removed spurious casts that may hide + problems on 16-bit systems. + +Version 1.6.0beta13 [February 24, 2012] + Eliminated redundant png_push_read_tEXt|zTXt|iTXt|unknown code from + pngpread.c and use the sequential png_handle_tEXt, etc., in pngrutil.c; + now that png_ptr->buffer is inaccessible to applications, the special + handling is no longer useful. + Added PNG_SAFE_LIMITS feature to pnglibconf.dfa, pngpriv.h, and new + pngusr.dfa to reset the user limits to safe ones if PNG_SAFE_LIMITS is + defined. To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED=1" on the + configure command or put #define PNG_SAFE_LIMITS_SUPPORTED in + pnglibconf.h.prebuilt and pnglibconf.h. + +Version 1.6.0beta14 [February 27, 2012] + Added information about the new limits in the manual. + Updated Makefile.in + +Version 1.6.0beta15 [March 2, 2012] + Removed unused "current_text" members of png_struct and the png_free() + of png_ptr->current_text from pngread.c + Rewrote pngstest.c for substantial speed improvement. + Fixed transparent pixel and 16-bit rgb tests in pngstest and removed a + spurious check in pngwrite.c + Added PNG_IMAGE_FLAG_FAST for the benefit of applications that store + intermediate files, or intermediate in-memory data, while processing + image data with the simplified API. The option makes the files larger + but faster to write and read. pngstest now uses this by default; this + can be disabled with the --slow option. + Improved pngstest fine tuning of error numbers, new test file generator. + The generator generates images that test the full range of sample values, + allow the error numbers in pngstest to be tuned and checked. makepng + also allows generation of images with extra chunks, although this is + still work-in-progress. + Added check for invalid palette index while reading. + Fixed some bugs in ICC profile writing. The code should now accept + all potentially valid ICC profiles and reject obviously invalid ones. + It now uses png_error() to do so rather than casually writing a PNG + without the necessary color data. + Removed whitespace from the end of lines in all source files and scripts. + +Version 1.6.0beta16 [March 6, 2012] + Relocated palette-index checking function from pngrutil.c to pngtrans.c + Added palette-index checking while writing. + Changed png_inflate() and calling routines to avoid overflow problems. + This is an intermediate check-in that solves the immediate problems and + introduces one performance improvement (avoiding a copy via png_ptr->zbuf.) + Further changes will be made to make ICC profile handling more secure. + Fixed build warnings (MSVC, GCC, GCC v3). Cygwin GCC with default options + declares 'index' as a global, causing a warning if it is used as a local + variable. GCC 64-bit warns about assigning a (size_t) (unsigned 64-bit) + to an (int) (signed 32-bit). MSVC, however, warns about using the + unary '-' operator on an unsigned value (even though it is well defined + by ANSI-C to be ~x+1). The padding calculation was changed to use a + different method. Removed the tests on png_ptr->pass. + Added contrib/libtests/tarith.c to test internal arithmetic functions from + png.c. This is a libpng maintainer program used to validate changes to the + internal arithmetic functions. + Made read 'inflate' handling like write 'deflate' handling. The read + code now claims and releases png_ptr->zstream, like the write code. + The bug whereby the progressive reader failed to release the zstream + is now fixed, all initialization is delayed, and the code checks for + changed parameters on deflate rather than always calling + deflatedEnd/deflateInit. + Validate the zTXt strings in pngvalid. + Added code to validate the windowBits value passed to deflateInit2(). + If the call to deflateInit2() is wrong a png_warning will be issued + (in fact this is harmless, but the PNG data produced may be sub-optimal). + +Version 1.6.0beta17 [March 10, 2012] + Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition. + Reject all iCCP chunks after the first, even if the first one is invalid. + Deflate/inflate was reworked to move common zlib calls into single + functions [rw]util.c. A new shared keyword check routine was also added + and the 'zbuf' is no longer allocated on progressive read. It is now + possible to call png_inflate() incrementally. A warning is no longer + issued if the language tag or translated keyword in the iTXt chunk + has zero length. + If benign errors are disabled use maximum window on ancillary inflate. + This works round a bug introduced in 1.5.4 where compressed ancillary + chunks could end up with a too-small windowBits value in the deflate + header. + +Version 1.6.0beta18 [March 16, 2012] + Issue a png_benign_error() instead of png_warning() about bad palette index. + In pngtest, treat benign errors as errors if "-strict" is present. + Fixed an off-by-one error in the palette index checking function. + Fixed a compiler warning under Cygwin (Windows-7, 32-bit system) + Revised example.c to put text strings in a temporary character array + instead of directly assigning string constants to png_textp members. + This avoids compiler warnings when -Wwrite-strings is enabled. + Added output flushing to aid debugging under Visual Studio. Unfortunately + this is necessary because the VS2010 output window otherwise simply loses + the error messages on error (they weren't flushed to the window before + the process exited, apparently!) + Added configuration support for benign errors and changed the read + default. Also changed some warnings in the iCCP and sRGB handling + from to benign errors. Configuration now makes read benign + errors warnings and write benign errors to errors by default (thus + changing the behavior on read). The simplified API always forces + read benign errors to warnings (regardless of the system default, unless + this is disabled in which case the simplified API can't be built.) + +Version 1.6.0beta19 [March 18, 2012] + Work around for duplicate row start calls; added warning messages. + This turns on PNG_FLAG_DETECT_UNINITIALIZED to detect app code that + fails to call one of the 'start' routines (not enabled in libpng-1.5 + because it is technically an API change, since it did normally work + before.) It also makes duplicate calls to png_read_start_row (an + internal function called at the start of the image read) benign, as + they were before changes to use png_inflate_claim. Somehow webkit is + causing this to happen; this is probably a mis-feature in the zlib + changes so this commit is only a work-round. + Removed erroneous setting of DETECT_UNINITIALIZED and added more + checks. The code now does a png_error if an attempt is made to do the + row initialization twice; this is an application error and it has + serious consequences because the transform data in png_struct is + changed by each call. + Added application error reporting and added chunk names to read + benign errors; also added --strict to pngstest - not enabled + yet because a warning is produced. + Avoid the double gamma correction warning in the simplified API. + This allows the --strict option to pass in the pngstest checks + +Version 1.6.0beta20 [March 29, 2012] + Changed chunk handler warnings into benign errors, incrementally load iCCP + Added checksum-icc.c to contrib/tools + Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice. + Recognize known sRGB ICC profiles while reading; prefer writing the + iCCP profile over writing the sRGB chunk, controlled by the + PNG_sRGB_PROFILE_CHECKS option. + Revised png_set_text_2() to avoid potential memory corruption (fixes + CVE-2011-3048, also known as CVE-2012-3425). + +Version 1.6.0beta21 [April 27, 2012] + Revised scripts/makefile.darwin: use system zlib; remove quotes around + architecture list; add missing ppc architecture; add architecture options + to shared library link; don't try to create a shared lib based on missing + RELEASE variable. + Enable png_set_check_for_invalid_index() for both read and write. + Removed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpriv.h around + declaration of png_handle_unknown(). + Added -lssp_nonshared in a comment in scripts/makefile.freebsd + and changed deprecated NOOBJ and NOPROFILE to NO_OBJ and NO_PROFILE. + +Version 1.6.0beta22 [May 23, 2012] + Removed need for -Wno-cast-align with clang. clang correctly warns on + alignment increasing pointer casts when -Wcast-align is passed. This + fixes the cases that clang warns about either by eliminating the + casts from png_bytep to png_uint_16p (pngread.c), or, for pngrutil.c + where the cast is previously verified or pngstest.c where it is OK, by + introducing new png_aligncast macros to do the cast in a way that clang + accepts. + +Version 1.6.0beta23 [June 6, 2012] + Revised CMakeLists.txt to not attempt to make a symlink under mingw. + Made fixes for new optimization warnings from gcc 4.7.0. The compiler + performs an optimization which is safe; however it then warns about it. + Changing the type of 'palette_number' in pngvalid.c removes the warning. + Do not depend upon a GCC feature macro being available for use in generating + the linker mapfile symbol prefix. + Improved performance of new do_check_palette_indexes() function (only + update the value when it actually increases, move test for whether + the check is wanted out of the function. + +Version 1.6.0beta24 [June 7, 2012] + Don't check palette indexes if num_palette is 0 (as it can be in MNG files). + +Version 1.6.0beta25 [June 16, 2012] + Revised png_set_keep_unknown_chunks() so num_chunks < 0 means ignore all + unknown chunks and all known chunks except for IHDR, PLTE, tRNS, IDAT, + and IEND. Previously it only meant ignore all unknown chunks, the + same as num_chunks == 0. Revised png_image_skip_unused_chunks() to + provide a list of chunks to be processed instead of a list of chunks to + ignore. Revised contrib/gregbook/readpng2.c accordingly. + +Version 1.6.0beta26 [July 10, 2012] + Removed scripts/makefile.cegcc from the *.zip and *.7z distributions; it + depends on configure, which is not included in those archives. + Moved scripts/chkfmt to contrib/tools. + Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386. + +Version 1.6.0beta27 [August 11, 2012] + Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3. + Do not use __restrict when GNUC is <= 3.1 + Removed references to png_zalloc() and png_zfree() from the manual. + Fixed configurations where floating point is completely disabled. Because + of the changes to support symbol prefixing PNG_INTERNAL_FUNCTION declares + floating point APIs during libpng builds even if they are completely + disabled. This requires the png floating point types (png_double*) to be + declared even though the functions are never actually defined. This + change provides a dummy definition so that the declarations work, yet any + implementation will fail to compile because of an incomplete type. + Re-eliminated the use of strcpy() in pngtest.c. An unnecessary use of + strcpy() was accidentally re-introduced in libpng16; this change replaces + it with strncpy(). + Eliminated use of png_sizeof(); use sizeof() instead. + Use a consistent style for (sizeof type) and (sizeof (array)) + Cleanup of png_set_filler(). This function does very different things on + read and write. In libpng 1.6 the two cases can be distinguished and + considerable code cleanup, and extra error checking, is possible. This + makes calls on the write side that have no effect be ignored with a + png_app_error(), which can be disabled in the app using + png_set_benign_errors(), and removes the spurious use of usr_channels + on the read side. + Insist on autotools 1.12.1 for git builds because there are security issues + with 1.12 and insisting on anything less would allow 1.12 to be used. + Removed info_ptr->signature[8] from WRITE-only builds. + Add some conditions for compiling png_fixed(). This is a small function + but it requires "-lm" on some platforms. + Cause pngtest --strict to fail on any warning from libpng (not just errors) + and cause it not to fail at the comparison step if libpng lacks support + for writing chunks that it reads from the input (currently only implemented + for compressed text chunks). + Make all three "make check" test programs work without READ or WRITE support. + Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ + or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading + and writing of a PNG file is always tested by one or more of the tests. + Consistently use strlen(), memset(), memcpy(), and memcmp() instead of the + png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros. + Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and + png_memcmp() macros. + Work around gcc 3.x and Microsoft Visual Studio 2010 complaints. Both object + to the split initialization of num_chunks. + +Version 1.6.0beta28 [August 29, 2012] + Unknown handling fixes and clean up. This adds more correct option + control of the unknown handling, corrects the pre-existing bug where + the per-chunk 'keep' setting is ignored and makes it possible to skip + IDAT chunks in the sequential reader (broken in earlier 1.6 versions). + There is a new test program, test-unknown.c, which is a work in progress + (not currently part of the test suite). Comments in the header files now + explain how the unknown handling works. + Allow fine grain control of unknown chunk APIs. This change allows + png_set_keep_unknown_chunks() to be turned off if not required and causes + both read and write to behave appropriately (on read this is only possible + if the user callback is used to handle unknown chunks). The change + also removes the support for storing unknown chunks in the info_struct + if the only unknown handling enabled is via the callback, allowing libpng + to be configured with callback reading and none of the unnecessary code. + Corrected fix for unknown handling in pngtest. This reinstates the + libpng handling of unknown chunks other than vpAg and sTER (including + unsafe-to-copy chunks which were dropped before) and eliminates the + repositioning of vpAg and sTER in pngtest.png by changing pngtest.png + (so the chunks are where libpng would put them). + Added "tunknown" test and corrected a logic error in png_handle_unknown() + when SAVE support is absent. Moved the shell test scripts for + contrib/libtests from the libpng top directory to contrib/libtests. + png_handle_unknown() must always read or skip the chunk, if + SAVE_UNKNOWN_CHUNKS is turned off *and* the application does not set + a user callback an unknown chunk will not be read, leading to a read + error, which was revealed by the "tunknown" test. + Cleaned up and corrected ICC profile handling. + contrib/libtests/makepng: corrected 'rgb' and 'gray' cases. profile_error + messages could be truncated; made a correct buffer size calculation and + adjusted pngerror.c appropriately. png_icc_check_* checking improved; + changed the functions to receive the correct color type of the PNG on read + or write and check that it matches the color space of the profile (despite + what the comments said before, there is danger in assuming the app will + cope correctly with an RGB profile on a grayscale image and, since it + violates the PNG spec, allowing it is certain to produce inconsistent + app behavior and might even cause app crashes.) Check that profiles + contain the tags needed to process the PNG (tags all required by the ICC + spec). Removed unused PNG_STATIC from pngpriv.h. + +Version 1.6.0beta29 [September 4, 2012] + Fixed the simplified API example programs to add the *colormap parameter + to several of he API and improved the error message if the version field + is not set. + Added contrib/examples/* to the *.zip and *.7z distributions. + Updated simplified API synopses and description of the png_image structure + in the manual. + Made makepng and pngtest produce identical PNGs, add "--relaxed" option + to pngtest. The "--relaxed" option turns off the benign errors that are + enabled by default in pre-RC builds. makepng can now write ICC profiles + where the length has not been extended to a multiple of 4, and pngtest + now intercepts all libpng errors, allowing the previously-introduced + "--strict test" on no warnings to actually work. + Improved ICC profile handling including cHRM chunk generation and fixed + Cygwin+MSVC build errors. The ICC profile handling now includes more + checking. Several errors that caused rejection of the profile are now + handled with a warning in such a way that the invalid profiles will be + read by default in release (but not pre-RC) builds but will not be + written by default. The easy part of handling the cHRM chunk is written, + where the ICC profile contains the required data. The more difficult + part plus guessing a gAMA value requires code to pass selected RGB values + through the profile. + +Version 1.6.0beta30 [October 24, 2012] + Changed ICC profile matrix/vector types to not depend on array type rules. + By the ANSI-C standard the new types should be identical to the previous + versions, and all known versions of gcc tested with the previous versions + except for GCC-4.2.1 work with this version. The change makes the ANSI-C + rule that const applied to an array of elements applies instead to the + elements in the array moot by explicitly applying const to the base + elements of the png_icc_matrix and png_icc_vector types. The accidental + (harmless) 'const' previously applied to the parameters of two of the + functions have also been removed. + Added a work around for GCC 4.2 optimization bug. + Marked the broken (bad white point) original HP sRGB profiles correctly and + correct comments. + Added -DZ_SOLO to contrib/pngminim/*/makefile to work with zlib-1.2.7 + Use /MDd for vstudio debug builds. Also added pngunkown to the vstudio + builds, fixed build errors and corrected a minor exit code error in + pngvalid if the 'touch' file name is invalid. + Add updated WARNING file to projects/vstudio from libpng 1.5/vstudio + Fixed build when using #define PNG_NO_READ_GAMMA in png_do_compose() in + pngrtran.c (Domani Hannes). + +Version 1.6.0beta31 [November 1, 2012] + Undid the erroneous change to vstudio/pngvalid build in libpng-1.6.0beta30. + Made pngvalid so that it will build outside the libpng source tree. + Made builds -DPNG_NO_READ_GAMMA compile (the unit tests still fail). + Made PNG_NO_READ_GAMMA switch off interfaces that depend on READ_GAMMA. + Prior to 1.6.0 switching off READ_GAMMA did unpredictable things to the + interfaces that use it (specifically, png_do_background in 1.4 would + simply display composite for grayscale images but do composition + with the incorrect arithmetic for color ones). In 1.6 the semantic + of -DPNG_NO_READ_GAMMA is changed to simply disable any interface that + depends on it; this obliges people who set it to consider whether they + really want it off if they happen to use any of the interfaces in + question (typically most users who disable it won't). + Fixed GUIDs in projects/vstudio. Some were duplicated or missing, + resulting in VS2010 having to update the files. + Removed non-working ICC profile support code that was mostly added to + libpng-1.6.0beta29 and beta30. There was too much code for too little + gain; implementing full ICC color correction may be desirable but is left + up to applications. + +Version 1.6.0beta32 [November 25, 2012] + Fixed an intermittent SEGV in pngstest due to an uninitialized array element. + Added the ability for contrib/libtests/makepng.c to make a PNG with just one + color. This is useful for debugging pngstest color inaccuracy reports. + Fixed error checking in the simplified write API (Olaf van der Spek) + Made png_user_version_check() ok to use with libpng version 1.10.x and later. + +Version 1.6.0beta33 [December 15, 2012] + Fixed typo in png.c (PNG_SET_CHUNK_MALLOC_MAX should be PNG_CHUNK_MALLOC_MAX) + that causes the MALLOC_MAX limit not to work (John Bowler) + Change png_warning() to png_app_error() in pngwrite.c and comment the + fall-through condition. + Change png_warning() to png_app_warning() in png_write_tRNS(). + Rearranged the ARM-NEON optimizations: Isolated the machine specific code + to the hardware subdirectory and added comments to pngrutil.c so that + implementors of other optimizations know what to do. + Fixed cases of unquoted DESTDIR in Makefile.am + Rebuilt Makefile.in, etc., with autoconf-2.69 and automake-1.12.5. + +Version 1.6.0beta34 [December 19, 2012] + Cleaned up whitespace in the synopsis portion of the manpage "libpng.3" + Disassembled the version number in scripts/options.awk (necessary for + building on SunOs). + +Version 1.6.0beta35 [December 23, 2012] + Made default Zlib compression settings be configurable. This adds #defines to + pnglibconf.h to control the defaults. + Fixed Windows build issues, enabled ARM compilation. Various warnings issued + by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old + GCCs.) ARM support is enabled by default in zlib.props (unsupported by + Microsoft) and ARM compilation is made possible by deleting the check for + x86. The test programs cannot be run because they are not signed. + +Version 1.6.0beta36 [January 2, 2013] + Discontinued distributing libpng-1.x.x.tar.bz2. + Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar. + Rebuilt configure with autoconf-2.69 (inadvertently not done in beta33) + Fixed 'make distcheck' on SUN OS - libpng.so was not being removed + +Version 1.6.0beta37 [January 10, 2013] + Fixed conceivable but difficult to repro overflow. Also added two test + programs to generate and test a PNG which should have the problem. + +Version 1.6.0beta39 [January 19, 2013] + Again corrected attempt at overflow detection in png_set_unknown_chunks() + (CVE-2013-7353). Added overflow detection in png_set_sPLT() and + png_set_text_2() (CVE-2013-7354). + +Version 1.6.0beta40 [January 20, 2013] + Use consistent handling of overflows in text, sPLT and unknown png_set_* APIs + +Version 1.6.0rc01 [January 26, 2013] + No changes. + +Version 1.6.0rc02 [February 4, 2013] + Added png_get_palette_max() function. + +Version 1.6.0rc03 [February 5, 2013] + Fixed the png_get_palette_max API. + +Version 1.6.0rc04 [February 7, 2013] + Turn serial tests back on (recently turned off by autotools upgrade). + +Version 1.6.0rc05 [February 8, 2013] + Update manual about png_get_palette_max(). + +Version 1.6.0rc06 [February 9, 2013] + Fixed missing dependency in --prefix builds The intermediate + internal 'prefix.h' file can only be generated correctly after + pnglibconf.h, however the dependency was not in Makefile.am. The + symptoms are unpredictable depending on the order make chooses to + build pngprefix.h and pnglibconf.h, often the error goes unnoticed + because there is a system pnglibconf.h to use instead. + +Version 1.6.0rc07 [February 10, 2013] + Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED + block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly. + +Version 1.6.0rc08 [February 10, 2013] + Fix typo in png.h #ifdef + +Version 1.6.0 [February 14, 2013] + No changes. + +Version 1.6.1beta01 [February 16, 2013] + Made symbol prefixing work with the ARM neon optimizations. Also allow + pngpriv.h to be included for preprocessor definitions only, so it can + be used in non-C/C++ files. Back ported from libpng 1.7. + Made sRGB check numbers consistent. + Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug. + Removed cc -E workround, corrected png_get_palette_max API Tested on + SUN OS cc 5.9, which demonstrates the tokenization problem previously + avoided by using /lib/cpp. Since all .dfn output is now protected in + double quotes unless it is to be macro substituted the fix should + work everywhere. + Enabled parallel tests - back ported from libpng-1.7. + scripts/pnglibconf.dfa formatting improvements back ported from libpng17. + Fixed a race condition in the creation of the build 'scripts' directory + while building with a parallel make. + Use approved/supported Android method to check for NEON, use Linux/POSIX + 1003.1 API to check /proc/self/auxv avoiding buffer allocation and other + library calls (ported from libpng15). + +Version 1.6.1beta02 [February 19, 2013] + Use parentheses more consistently in "#if defined(MACRO)" tests. + Folded long lines. + Reenabled code to allow zero length PLTE chunks for MNG. + +Version 1.6.1beta03 [February 22, 2013] + Fixed ALIGNED_MEMORY support. + Added a new configure option: + --enable-arm-neon=always will stop the run-time checks. New checks + within arm/arm_init.c will cause the code not to be compiled unless + __ARM_NEON__ is set. This should make it fail safe (if someone asks + for it on then the build will fail if it can't be done.) + Updated the INSTALL document. + +Version 1.6.1beta04 [February 27, 2013] + Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES. + Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC. + Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble + with CRLF line endings. + +Version 1.6.1beta05 [March 1, 2013] + Avoid a possible memory leak in contrib/gregbook/readpng.c + +Version 1.6.1beta06 [March 4, 2013] + Better documentation of unknown handling API interactions. + Corrected Android builds and corrected libpng.vers with symbol + prefixing. It also makes those tests compile and link on Android. + Added an API png_set_option() to set optimization options externally, + providing an alternative and general solution for the non-portable + run-time tests used by the ARM Neon code, using the PNG_ARM_NEON option. + The order of settings vs options in pnglibconf.h is reversed to allow + settings to depend on options and options can now set (or override) the + defaults for settings. + +Version 1.6.1beta07 [March 7, 2013] + Corrected simplified API default gamma for color-mapped output, added + a flag to change default. In 1.6.0 when the simplified API was used + to produce color-mapped output from an input image with no gamma + information the gamma assumed for the input could be different from + that assumed for non-color-mapped output. In particular 16-bit depth + input files were assumed to be sRGB encoded, whereas in the 'direct' + case they were assumed to have linear data. This was an error. The + fix makes the simplified API treat all input files the same way and + adds a new flag to the png_image::flags member to allow the + application/user to specify that 16-bit files contain sRGB data + rather than the default linear. + Fixed bugs in the pngpixel and makepng test programs. + +Version 1.6.1beta08 [March 7, 2013] + Fixed CMakelists.txt to allow building a single variant of the library + (Claudio Bley): + Introduced a PNG_LIB_TARGETS variable that lists all activated library + targets. It is an error if this variable ends up empty, ie. you have + to build at least one library variant. + Made the *_COPY targets only depend on library targets actually being build. + Use PNG_LIB_TARGETS to unify a code path. + Changed the CREATE_SYMLINK macro to expect the full path to a file as the + first argument. When symlinking the filename component of that path is + determined and used as the link target. + Use copy_if_different in the CREATE_SYMLINK macro. + +Version 1.6.1beta09 [March 13, 2013] + Eliminated two warnings from the Intel C compiler. The warnings are + technically valid, although a reasonable treatment of division would + show it to be incorrect. + +Version 1.6.1rc01 [March 21, 2013] + No changes. + +Version 1.6.1 [March 28, 2013] + No changes. + +Version 1.6.2beta01 [April 14, 2013] + Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling. + Fixed incorrect warning of excess deflate data. End condition - the + warning would be produced if the end of the deflate stream wasn't read + in the last row. The warning is harmless. + Corrected the test on user transform changes on read. It was in the + png_set of the transform function, but that doesn't matter unless the + transform function changes the rowbuf size, and that is only valid if + transform_info is called. + Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c + (Flavio Medeiros). + Corrected length written to uncompressed iTXt chunks (Samuli Suominen). + Bug was introduced in libpng-1.6.0. + +Version 1.6.2rc01 [April 18, 2013] + Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length + written by libpng-1.6.0 and 1.6.1. + Disallow storing sRGB information when the sRGB is not supported. + +Version 1.6.2rc02 [April 18, 2013] + Merge pngtest.c with libpng-1.7.0 + +Version 1.6.2rc03 [April 22, 2013] + Trivial spelling cleanup. + +Version 1.6.2rc04 and 1.6.2rc05 [omitted] + +Version 1.6.2rc06 [April 24, 2013] + Reverted to version 1.6.2rc03. Recent changes to arm/neon support + have been ported to libpng-1.7.0beta09 and will reappear in version + 1.6.3beta01. + +Version 1.6.2 [April 25, 2013] + No changes. + +Version 1.6.3beta01 [April 25, 2013] + Revised stack marking in arm/filter_neon.S and configure.ac. + Ensure that NEON filter stuff is completely disabled when switched 'off'. + Previously the ARM NEON specific files were still built if the option + was switched 'off' as opposed to being explicitly disabled. + +Version 1.6.3beta02 [April 26, 2013] + Test for 'arm*' not just 'arm' in the host_cpu configure variable. + Rebuilt the configure scripts. + +Version 1.6.3beta03 [April 30, 2013] + Expanded manual paragraph about writing private chunks, particularly + the need to call png_set_keep_unknown_chunks() when writing them. + Avoid dereferencing NULL pointer possibly returned from + png_create_write_struct() (Andrew Church). + +Version 1.6.3beta05 [May 9, 2013] + Calculate our own zlib windowBits when decoding rather than trusting the + CMF bytes in the PNG datastream. + Added an option to force maximum window size for inflating, which was + the behavior of libpng15 and earlier, via a new PNG_MAXIMUM_INFLATE_WINDOW + option for png_set_options(). + Added png-fix-itxt and png-fix-too-far-back to the built programs and + removed warnings from the source code and timepng that are revealed as + a result. + Detect wrong libpng versions linked to png-fix-too-far-back, which currently + only works with libpng versions that can be made to reliably fail when + the deflate data contains an out-of-window reference. This means only + 1.6 and later. + Fixed gnu issues: g++ needs a static_cast, gcc 4.4.7 has a broken warning + message which it is easier to work round than ignore. + Updated contrib/pngminus/pnm2png.c (Paul Stewart): + Check for EOF + Ignore "#" delimited comments in input file to pnm2png.c. + Fixed whitespace handling + Added a call to png_set_packing() + Initialize dimension values so if sscanf fails at least we have known + invalid values. + Attempt to detect configuration issues with png-fix-too-far-back, which + requires both the correct libpng and the correct zlib to function + correctly. + Check ZLIB_VERNUM for mismatches, enclose #error in quotes + Added information in the documentation about problems with and fixes for + the bad CRC and bad iTXt chunk situations. + +Version 1.6.3beta06 [May 12, 2013] + Allow contrib/pngminus/pnm2png.c to compile without WRITE_INVERT and + WRITE_PACK supported (writes error message that it can't read P1 or + P4 PBM files). + Improved png-fix-too-far-back usage message, added --suffix option. + Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the + right zlib header files. + Separated CPPFLAGS and CFLAGS in contrib/pngminim/*/makefile + +Version 1.6.3beta07 [June 8, 2013] + Removed a redundant test in png_set_IHDR(). + Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt) + Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt + Enclose the prototypes for the simplified write API in + #ifdef PNG_STDIO_SUPPORTED/#endif + Make ARM NEON support work at compile time (not just configure time). + This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when + using a compiler that compiles for multiple architectures at one time. + Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from + pnglibconf.h, allowing more of the decisions to be made internally + (pngpriv.h) during the compile. Without this, symbol prefixing is broken + under certain circumstances on ARM platforms. Now only the API parts of + the optimizations ('check' vs 'api') are exposed in the public header files + except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the + decision about whether or not to use the optimizations. + Protect symbol prefixing against CC/CPPFLAGS/CFLAGS usage. + Previous iOS/Xcode fixes for the ARM NEON optimizations moved the test + on __ARM_NEON__ from configure time to compile time. This breaks symbol + prefixing because the definition of the special png_init_filter_functions + call was hidden at configure time if the relevant compiler arguments are + passed in CFLAGS as opposed to CC. This change attempts to avoid all + the confusion that would result by declaring the init function even when + it is not used, so that it will always get prefixed. + +Version 1.6.3beta08 [June 18, 2013] + Revised libpng.3 so that "doclifter" can process it. + +Version 1.6.3beta09 [June 27, 2013] + Revised example.c to illustrate use of PNG_DEFAULT_sRGB and PNG_GAMMA_MAC_18 + as parameters for png_set_gamma(). These have been available since + libpng-1.5.4. + Renamed contrib/tools/png-fix-too-far-back.c to pngfix.c and revised it + to check all compressed chunks known to libpng. + +Version 1.6.3beta10 [July 5, 2013] + Updated documentation to show default behavior of benign errors correctly. + Only compile ARM code when PNG_READ_SUPPORTED is defined. + Fixed undefined behavior in contrib/tools/pngfix.c and added new strip + option. pngfix relied on undefined behavior and even a simple change from + gcc to g++ caused it to fail. The new strip option 'unsafe' has been + implemented and is the default if --max is given. Option names have + been clarified, with --strip=transform now stripping the bKGD chunk, + which was stripped previously with --strip=unused. + Added all documented chunk types to pngpriv.h + Unified pngfix.c source with libpng17. + +Version 1.6.3rc01 [July 11, 2013] + No changes. + +Version 1.6.3 [July 18, 2013] + Revised manual about changes in iTXt chunk handling made in libpng-1.6.0. + Added "/* SAFE */" comments in pngrutil.c and pngrtran.c where warnings + may be erroneously issued by code-checking applications. + +Version 1.6.4beta01 [August 21, 2013] + Added information about png_set_options() to the manual. + Delay calling png_init_filter_functions() until a row with nonzero filter + is found. + +Version 1.6.4beta02 [August 30, 2013] + Fixed inconsistent conditional compilation of png_chunk_unknown_handling() + prototype, definition, and usage. Made it depend on + PNG_HANDLE_AS_UNKNOWN_SUPPORTED everywhere. + +Version 1.6.4rc01 [September 5, 2013] + No changes. + +Version 1.6.4 [September 12, 2013] + No changes. + +Version 1.6.5 [September 14, 2013] + Removed two stray lines of code from arm/arm_init.c. + +Version 1.6.6 [September 16, 2013] + Removed two stray lines of code from arm/arm_init.c, again. + +Version 1.6.7beta01 [September 30, 2013] + Revised unknown chunk code to correct several bugs in the NO_SAVE_/NO_WRITE + combination + Allow HANDLE_AS_UNKNOWN to work when other options are configured off. Also + fixed the pngminim makefiles to work when $(MAKEFLAGS) contains stuff + which terminates the make options (as by default in recent versions of + Gentoo). + Avoid up-cast warnings in pngvalid.c. On ARM the alignment requirements of + png_modifier are greater than that of png_store and as a consequence + compilation of pngvalid.c results in a warning about increased alignment + requirements because of the bare cast to (png_modifier*). The code is safe, + because the pointer is known to point to a stack allocated png_modifier, + but this change avoids the warning. + Fixed default behavior of ARM_NEON_API. If the ARM NEON API option was + compiled without the CHECK option it defaulted to on, not off. + Check user callback behavior in pngunknown.c. Previous versions compiled + if SAVE_UNKNOWN was not available but did nothing since the callback + was never implemented. + Merged pngunknown.c with 1.7 version and back ported 1.7 improvements/fixes + +Version 1.6.7beta02 [October 12, 2013] + Made changes for compatibility with automake 1.14: + 1) Added the 'compile' program to the list of programs that must be cleaned + in autogen.sh + 2) Added 'subdir-objects' which causes .c files in sub-directories to be + compiled such that the corresponding .o files are also in the + sub-directory. This is because automake 1.14 warns that the + current behavior of compiling to the top level directory may be removed + in the future. + 3) Updated dependencies on pnglibconf.h to match the new .o locations and + added all the files in contrib/libtests and contrib/tools that depend + on pnglibconf.h + 4) Added 'BUILD_SOURCES = pnglibconf.h'; this is the automake recommended + way of handling the dependencies of sources that are machine generated; + unfortunately it only works if the user does 'make all' or 'make check', + so the dependencies (3) are still required. + Cleaned up (char*) casts of zlib messages. The latest version of the Intel C + compiler complains about casting a string literal as (char*), so copied the + treatment of z_const from the library code into pngfix.c + Simplified error message code in pngunknown. The simplification has the + useful side effect of avoiding a bogus warning generated by the latest + version of the Intel C compiler (it objects to + condition ? string-literal : string-literal). + Make autogen.sh work with automake 1.13 as well as 1.14. Do this by always + removing the 1.14 'compile' script but never checking for it. + +Version 1.6.7beta03 [October 19, 2013] + Added ARMv8 support (James Yu ). Added file + arm/filter_neon_intrinsics.c; enable with -mfpu=neon. + Revised pngvalid to generate size images with as many filters as it can + manage, limited by the number of rows. + Cleaned up ARM NEON compilation handling. The tests are now in pngpriv.h + and detect the broken GCC compilers. + +Version 1.6.7beta04 [October 26, 2013] + Allow clang derived from older GCC versions to use ARM intrinsics. This + causes all clang builds that use -mfpu=neon to use the intrinsics code, + not the assembler code. This has only been tested on iOS 7. It may be + necessary to exclude some earlier clang versions but this seems unlikely. + Changed NEON implementation selection mechanism. This allows assembler + or intrinsics to be turned on at compile time during the build by defining + PNG_ARM_NEON_IMPLEMENTATION to the correct value (2 or 1). This macro + is undefined by default and the build type is selected in pngpriv.h. + +Version 1.6.7rc01 [November 2, 2013] + No changes. + +Version 1.6.7rc02 [November 7, 2013] + Fixed #include in filter_neon_intrinsics.c and ctype macros. The ctype char + checking macros take an unsigned char argument, not a signed char. + +Version 1.6.7 [November 14, 2013] + No changes. + +Version 1.6.8beta01 [November 24, 2013] + Moved prototype for png_handle_unknown() in pngpriv.h outside of + the #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED/#endif block. + Added "-Wall" to CFLAGS in contrib/pngminim/*/makefile + Conditionally compile some unused functions reported by -Wall in + pngminim. + Fixed 'minimal' builds. Various obviously useful minimal configurations + don't build because of missing contrib/libtests test programs and + overly complex dependencies in scripts/pnglibconf.dfa. This change + adds contrib/conftest/*.dfa files that can be used in automatic build + scripts to ensure that these configurations continue to build. + Enabled WRITE_INVERT and WRITE_PACK in contrib/pngminim/encoder. + Fixed pngvalid 'fail' function declaration on the Intel C Compiler. + This reverts to the previous 'static' implementation and works round + the 'unused static function' warning by using PNG_UNUSED(). + +Version 1.6.8beta02 [November 30, 2013] + Removed or marked PNG_UNUSED some harmless "dead assignments" reported + by clang scan-build. + Changed tabs to 3 spaces in png_debug macros and changed '"%s"m' + to '"%s" m' to improve portability among compilers. + Changed png_free_default() to free() in pngtest.c + +Version 1.6.8rc01 [December 12, 2013] + Tidied up pngfix inits and fixed pngtest no-write builds. + +Version 1.6.8rc02 [December 14, 2013] + Handle zero-length PLTE chunk or NULL palette with png_error() + instead of png_chunk_report(), which by default issues a warning + rather than an error, leading to later reading from a NULL pointer + (png_ptr->palette) in png_do_expand_palette(). This is CVE-2013-6954 + and VU#650142. Libpng-1.6.1 through 1.6.7 are vulnerable. + Libpng-1.6.0 and earlier do not have this bug. + +Version 1.6.8 [December 19, 2013] + No changes. + +Version 1.6.9beta01 [December 26, 2013] + Bookkeeping: Moved functions around (no changes). Moved transform + function definitions before the place where they are called so that + they can be made static. Move the intrapixel functions and the + grayscale palette builder out of the png?tran.c files. The latter + isn't a transform function and is no longer used internally, and the + former MNG specific functions are better placed in pngread/pngwrite.c + Made transform implementation functions static. This makes the internal + functions called by png_do_{read|write}_transformations static. On an + x86-64 DLL build (Gentoo Linux) this reduces the size of the text + segment of the DLL by 1208 bytes, about 0.6%. It also simplifies + maintenance by removing the declarations from pngpriv.h and allowing + easier changes to the internal interfaces. + Rebuilt configure scripts with automake-1.14.1 and autoconf-2.69 + in the tar distributions. + +Version 1.6.9beta02 [January 1, 2014] + Added checks for libpng 1.5 to pngvalid.c. This supports the use of + this version of pngvalid in libpng 1.5 + Merged with pngvalid.c from libpng-1.7 changes to create a single + pngvalid.c + Removed #error macro from contrib/tools/pngfix.c (Thomas Klausner). + Merged pngrio.c, pngtrans.c, pngwio.c, and pngerror.c with libpng-1.7.0 + Merged libpng-1.7.0 changes to make no-interlace configurations work + with test programs. + Revised pngvalid.c to support libpng 1.5, which does not support the + PNG_MAXIMUM_INFLATE_WINDOW option, so #define it out when appropriate in + pngvalid.c + Allow unversioned links created on install to be disabled in configure. + In configure builds 'make install' changes/adds links like png.h + and libpng.a to point to the newly installed, versioned, files (e.g. + libpng17/png.h and libpng17.a). Three new configure options and some + rearrangement of Makefile.am allow creation of these links to be disabled. + +Version 1.6.9beta03 [January 10, 2014] + Removed potentially misleading warning from png_check_IHDR(). + +Version 1.6.9beta04 [January 20, 2014] + Updated scripts/makefile.* to use CPPFLAGS (Cosmin). + Added clang attribute support (Cosmin). + +Version 1.6.9rc01 [January 28, 2014] + No changes. + +Version 1.6.9rc02 [January 30, 2014] + Quiet an uninitialized memory warning from VC2013 in png_get_png(). + +Version 1.6.9 [February 6, 2014] + +Version 1.6.10beta01 [February 9, 2014] + Backported changes from libpng-1.7.0beta30 and beta31: + Fixed a large number of instances where PNGCBAPI was omitted from + function definitions. + Added pngimage test program for png_read_png() and png_write_png() + with two new test scripts. + Removed dependence on !PNG_READ_EXPAND_SUPPORTED for calling + png_set_packing() in png_read_png(). + Fixed combination of ~alpha with shift. On read invert alpha, processing + occurred after shift processing, which causes the final values to be + outside the range that should be produced by the shift. Reversing the + order on read makes the two transforms work together correctly and mirrors + the order used on write. + Do not read invalid sBIT chunks. Previously libpng only checked sBIT + values on write, so a malicious PNG writer could therefore cause + the read code to return an invalid sBIT chunk, which might lead to + application errors or crashes. Such chunks are now skipped (with + chunk_benign_error). + Make png_read_png() and png_write_png() prototypes in png.h depend + upon PNG_READ_SUPPORTED and PNG_WRITE_SUPPORTED. + Support builds with unsupported PNG_TRANSFORM_* values. All of the + PNG_TRANSFORM_* values are always defined in png.h and, because they + are used for both read and write in some cases, it is not reliable + to #if out ones that are totally unsupported. This change adds error + detection in png_read_image() and png_write_image() to do a + png_app_error() if the app requests something that cannot be done + and it adds corresponding code to pngimage.c to handle such options + by not attempting to test them. + +Version 1.6.10beta02 [February 23, 2014] + Moved redefines of png_error(), png_warning(), png_chunk_error(), + and png_chunk_warning() from pngpriv.h to png.h to make them visible + to libpng-calling applications. + Moved OS dependent code from arm/arm_init.c, to allow the included + implementation of the ARM NEON discovery function to be set at + build-time and provide sample implementations from the current code in the + contrib/arm-neon subdirectory. The __linux__ code has also been changed to + compile and link on Android by using /proc/cpuinfo, and the old linux code + is in contrib/arm-neon/linux-auxv.c. The new code avoids POSIX and Linux + dependencies apart from opening /proc/cpuinfo and is C90 compliant. + Check for info_ptr == NULL early in png_read_end() so we don't need to + run all the png_handle_*() and depend on them to return if info_ptr == NULL. + This improves the performance of png_read_end(png_ptr, NULL) and makes + it more robust against future programming errors. + Check for __has_extension before using it in pngconf.h, to + support older Clang versions (Jeremy Sequoia). + Treat CRC error handling with png_set_crc_action(), instead of with + png_set_benign_errors(), which has been the case since libpng-1.6.0beta18. + Use a user warning handler in contrib/gregbook/readpng2.c instead of default, + so warnings will be put on stderr even if libpng has CONSOLE_IO disabled. + Added png_ptr->process_mode = PNG_READ_IDAT_MODE in png_push_read_chunk + after recognizing the IDAT chunk, which avoids an infinite loop while + reading a datastream whose first IDAT chunk is of zero-length. + This fixes CERT VU#684412 and CVE-2014-0333. + Don't recognize known sRGB profiles as sRGB if they have been hacked, + but don't reject them and don't issue a copyright violation warning. + +Version 1.6.10beta03 [February 25, 2014] + Moved some documentation from png.h to libpng.3 and libpng-manual.txt + Minor editing of contrib/arm-neon/README and contrib/examples/*.c + +Version 1.6.10rc01 [February 27, 2014] + Fixed typos in the manual and in scripts/pnglibconf.dfa (CFLAGS -> CPPFLAGS + and PNG_USR_CONFIG -> PNG_USER_CONFIG). + +Version 1.6.10rc02 [February 28, 2014] + Removed unreachable return statement after png_chunk_error() + in pngrutil.c + +Version 1.6.10rc03 [March 4, 2014] + Un-deprecated png_data_freer(). + +Version 1.6.10 [March 6, 2014] + No changes. + +Version 1.6.11beta01 [March 17, 2014] + Use "if (value != 0)" instead of "if (value)" consistently. + Changed ZlibSrcDir from 1.2.5 to 1.2.8 in projects/vstudio. + Moved configuration information from the manual to the INSTALL file. + +Version 1.6.11beta02 [April 6, 2014] + Removed #if/#else/#endif from inside two pow() calls in pngvalid.c because + they were handled improperly by Portland Group's PGI-14.1 - PGI-14.3 + when using its "__builtin_pow()" function. + Silence 'unused parameter' build warnings (Cosmin Truta). + $(CP) is now used alongside $(RM_F). Also, use 'copy' instead of 'cp' + where applicable, and applied other minor makefile changes (Cosmin). + Don't warn about invalid dimensions exceeding user limits (Cosmin). + Allow an easy replacement of the default pre-built configuration + header with a custom header, via the make PNGLIBCONF_H_PREBUILT + macro (Cosmin). + +Version 1.6.11beta03 [April 6, 2014] + Fixed a typo in pngrutil.c, introduced in libpng-1.5.6, that interferes + with "blocky" expansion of sub-8-bit interlaced PNG files (Eric Huss). + Optionally use __builtin_bswap16() in png_do_swap(). + +Version 1.6.11beta04 [April 19, 2014] + Made progressive reading of interlaced images consistent with the + behavior of the sequential reader and consistent with the manual, by + moving some code out of the PNG_READ_INTERLACING_SUPPORTED blocks. The + row_callback now receives the proper pass number and unexpanded rows, when + png_combine_row() isn't built or used, and png_set_interlace_handling() + is not called. + Allow PNG_sRGB_PROFILE_CHECKING = (-1) to mean no sRGB profile checking. + +Version 1.6.11beta05 [April 26, 2014] + Do not reject ICC V2 profiles that lack padding (Kai-Uwe Behrmann). + Relocated closing bracket of the sRGB profile test loop to avoid getting + "Not recognizing known sRGB profile that has been edited" warning for + ICC V2 profiles that lack the MD5 signature in the profile header. + +Version 1.6.11beta06 [May 19, 2014] + Added PNG_SKIP_sRGB_CHECK_PROFILE choice for png_set_option(). + +Version 1.6.11rc01 [May 27, 2014] + No changes. + +Version 1.6.11rc02 [June 3, 2014] + Test ZLIB_VERNUM instead of PNG_ZLIB_VERNUM in contrib/tools/pngfix.c + +Version 1.6.11 [June 5, 2014] + No changes. + +Version 1.6.12rc01 [June 6, 2014] + Relocated new code from 1.6.11beta06 in png.c to a point after the + declarations (Max Stepin). + +Version 1.6.12rc02 [June 7, 2014] + Changed file permissions of contrib/tools/intgamma.sh, + test-driver, and compile from 0644 to 0755 (Cosmin). + +Version 1.6.12rc03 [June 8, 2014] + Ensure "__has_attribute()" macro exists before trying to use it with + old clang compilers (MacPorts Ticket #43939). + +Version 1.6.12 [June 12, 2014] + No changes. + +Version 1.6.13beta01 [July 4, 2014] + Quieted -Wsign-compare and -Wclobber compiler warnings in + contrib/pngminus/*.c + Added "(void) png_ptr;" where needed in contrib/gregbook to quiet + compiler complaints about unused pointers. + Split a long output string in contrib/gregbook/rpng2-x.c. + Added "PNG_SET_OPTION" requirement for sRGB chunk support to pnglibconf.dfa, + Needed for write-only support (John Bowler). + Changed "if defined(__ARM_NEON__)" to + "if (defined(__ARM_NEON__) || defined(__ARM_NEON))" (James Wu). + Fixed clang no-warning builds: png_digit was defined but never used. + +Version 1.6.13beta02 [July 21, 2014] + Fixed an incorrect separator ("/" should be "\") in scripts/makefile.vcwin32 + (bug report from Wolfgang S. Kechel). Bug was introduced in libpng-1.6.11. + Also fixed makefile.bc32, makefile.bor, makefile.msc, makefile.intel, and + makefile.tc3 similarly. + +Version 1.6.13beta03 [August 3, 2014] + Removed scripts/makefile.elf. It has not worked since libpng-1.5.0beta14 + due to elimination of the PNG_FUNCTION_EXPORT and PNG_DATA_EXPORT + definitions from pngconf.h. + Ensure that CMakeLists.txt makes the target "lib" directory before making + symbolic link into it (SourceForge bug report #226 by Rolf Timmermans). + +Version 1.6.13beta04 [August 8, 2014] + Added opinion that the ECCN (Export Control Classification Number) for + libpng is EAR99 to the README file. + Eliminated use of "$<" in makefile explicit rules, when copying + $PNGLIBCONF_H_PREBUILT. This does not work on some versions of make; + bug introduced in libpng version 1.6.11. + +Version 1.6.13rc01 [August 14, 2014] + Made "ccopts" agree with "CFLAGS" in scripts/makefile.hp* and makefile.*sunu + +Version 1.6.13 [August 21, 2014] + No changes. + +Version 1.6.14beta01 [September 14, 2014] + Guard usage of png_ptr->options with #ifdef PNG_SET_OPTION_SUPPORTED. + Do not build contrib/tools/pngfix.c when PNG_SETJMP_NOT_SUPPORTED, + to allow "make" to complete without setjmp support (bug report by + Claudio Fontana) + Add "#include " to contrib/tools/pngfix.c (John Bowler) + +Version 1.6.14beta02 [September 18, 2014] + Use nanosleep() instead of usleep() in contrib/gregbook/rpng2-x.c + because usleep() is deprecated. + Define usleep() in contrib/gregbook/rpng2-x.c if not already defined + in unistd.h and nanosleep() is not available; fixes error introduced + in libpng-1.6.13. + Disable floating point exception handling in pngvalid.c when + PNG_FLOATING_ARITHMETIC is not supported (bug report by "zootus + at users.sourceforge.net"). + +Version 1.6.14beta03 [September 19, 2014] + Define FE_DIVBYZERO, FE_INVALID, and FE_OVERFLOW in pngvalid.c if not + already defined. Revert floating point exception handling in pngvalid.c + to version 1.6.14beta01 behavior. + +Version 1.6.14beta04 [September 27, 2014] + Fixed incorrect handling of the iTXt compression flag in pngrutil.c + (bug report by Shunsaku Hirata). Bug was introduced in libpng-1.6.0. + +Version 1.6.14beta05 [October 1, 2014] + Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa + +Version 1.6.14beta06 [October 5, 2014] + Removed unused "text_len" parameter from private function png_write_zTXt(). + Conditionally compile some code in png_deflate_claim(), when + PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled. + Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL. + Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT" + to pnglibconf.dfa. + Removed "option READ_COMPRESSED_TEXT enables READ_TEXT" from pnglibconf.dfa, + to make it possible to configure a libpng that supports iCCP but not TEXT. + +Version 1.6.14beta07 [October 7, 2014] + Removed "option WRITE_COMPRESSED_TEXT enables WRITE_TEXT" from pnglibconf.dfa + Only mark text chunks as written after successfully writing them. + +Version 1.6.14rc01 [October 15, 2014] + Fixed some typos in comments. + +Version 1.6.14rc02 [October 17, 2014] + Changed png_convert_to_rfc_1123() to png_convert_to_rfc_1123_buffer() + in the manual, to reflect the change made in libpng-1.6.0. + Updated README file to explain that direct access to the png_struct + and info_struct members has not been permitted since libpng-1.5.0. + +Version 1.6.14 [October 23, 2014] + No changes. + +Version 1.6.15beta01 [October 29, 2014] + Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)" + Simplified png_free_data(). + Added missing "ptr = NULL" after some instances of png_free(). + +Version 1.6.15beta02 [November 1, 2014] + Changed remaining "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)" + +Version 1.6.15beta03 [November 3, 2014] + Added PNG_USE_ARM_NEON configuration flag (Marcin Juszkiewicz). + +Version 1.6.15beta04 [November 4, 2014] + Removed new PNG_USE_ARM_NEON configuration flag and made a one-line + revision to configure.ac to support ARM on aarch64 instead (John Bowler). + +Version 1.6.15beta05 [November 5, 2014] + Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in + example.c, pngtest.c, and applications in the contrib directory. + Fixed an out-of-range read in png_user_version_check() (Bug report from + Qixue Xiao, CVE-2015-8540). + Simplified and future-proofed png_user_version_check(). + Fixed GCC unsigned int->float warnings. Various versions of GCC + seem to generate warnings when an unsigned value is implicitly + converted to double. This is probably a GCC bug but this change + avoids the issue by explicitly converting to (int) where safe. + Free all allocated memory in pngimage. The file buffer cache was left + allocated at the end of the program, harmless but it causes memory + leak reports from clang. + Fixed array size calculations to avoid warnings. At various points + in the code the number of elements in an array is calculated using + sizeof. This generates a compile time constant of type (size_t) which + is then typically assigned to an (unsigned int) or (int). Some versions + of GCC on 64-bit systems warn about the apparent narrowing, even though + the same compiler does apparently generate the correct, in-range, + numeric constant. This adds appropriate, safe, casts to make the + warnings go away. + +Version 1.6.15beta06 [November 6, 2014] + Reverted use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING + in the manual, example.c, pngtest.c, and applications in the contrib + directory. It was incorrect advice. + +Version 1.6.15beta07 [November 7, 2014] + Removed #ifdef PNG_16BIT_SUPPORTED/#endif around png_product2(); it is + needed by png_reciprocal2(). + Added #ifdef PNG_16BIT_SUPPORTED/#endif around png_log16bit() and + png_do_swap(). + Changed all "#endif /* PNG_FEATURE_SUPPORTED */" to "#endif /* FEATURE */" + +Version 1.6.15beta08 [November 8, 2014] + More housecleaning in *.h + +Version 1.6.15rc01 [November 13, 2014] + +Version 1.6.15rc02 [November 14, 2014] + The macros passed in the command line to Borland make were ignored if + similarly-named macros were already defined in makefiles. This behavior + is different from POSIX make and other make programs. Surround the + macro definitions with ifndef guards (Cosmin). + +Version 1.6.15rc03 [November 16, 2014] + Added "-D_CRT_SECURE_NO_WARNINGS" to CFLAGS in scripts/makefile.vcwin32. + Removed the obsolete $ARCH variable from scripts/makefile.darwin. + +Version 1.6.15 [November 20, 2014] + No changes. + +Version 1.6.16beta01 [December 14, 2014] + Added ".align 2" to arm/filter_neon.S to support old GAS assemblers that + don't do alignment correctly. + Revised Makefile.am and scripts/symbols.dfn to work with MinGW/MSYS + (Bob Friesenhahn). + +Version 1.6.16beta02 [December 15, 2014] + Revised Makefile.am and scripts/*.dfn again to work with MinGW/MSYS; + renamed scripts/*.dfn to scripts/*.c (John Bowler). + +Version 1.6.16beta03 [December 21, 2014] + Quiet a "comparison always true" warning in pngstest.c (John Bowler). + +Version 1.6.16rc01 [December 21, 2014] + Restored a test on width that was removed from png.c at libpng-1.6.9 + (Bug report by Alex Eubanks, CVE-2015-0973). + +Version 1.6.16rc02 [December 21, 2014] + Undid the update to pngrutil.c in 1.6.16rc01. + +Version 1.6.16rc03 [December 21, 2014] + Fixed an overflow in png_combine_row() with very wide interlaced images + (Bug report and fix by John Bowler, CVE-2014-9495). + +Version 1.6.16 [December 22, 2014] + No changes. + +Version 1.6.17beta01 [January 29, 2015] + Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h + Corrected the width limit calculation in png_check_IHDR(). + Removed user limits from pngfix. Also pass NULL pointers to + png_read_row to skip the unnecessary row de-interlace stuff. + Added testing of png_set_packing() to pngvalid.c + Regenerated configure scripts in the *.tar distributions with libtool-2.4.4 + Implement previously untested cases of libpng transforms in pngvalid.c + Fixed byte order in png_do_read_filler() with 16-bit input. Previously + the high and low bytes of the filler, from png_set_filler() or from + png_set_add_alpha(), were read in the wrong order. + Made the check for out-of-range values in png_set_tRNS() detect + values that are exactly 2^bit_depth, and work on 16-bit platforms. + Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47. + Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and + pngset.c to avoid warnings about dead code. + Added "& 0xff" to many instances of expressions that are typecast + to (png_byte), to avoid Coverity warnings. + +Version 1.6.17beta02 [February 7, 2015] + Work around one more Coverity-scan dead-code warning. + Do not build png_product2() when it is unused. + +Version 1.6.17beta03 [February 17, 2015] + Display user limits in the output from pngtest. + Eliminated the PNG_SAFE_LIMITS macro and restored the 1-million-column + and 1-million-row default limits in pnglibconf.dfa, that can be reset + by the user at build time or run time. This provides a more robust + defense against DOS and as-yet undiscovered overflows. + +Version 1.6.17beta04 [February 21, 2015] + Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default. + Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins). + Rebuilt configure scripts with automake-1.15 and libtool-2.4.6 + +Version 1.6.17beta05 [February 25, 2015] + Restored compiling of png_reciprocal2 with PNG_NO_16BIT. + +Version 1.6.17beta06 [February 27, 2015] + Moved png_set_filter() prototype into a PNG_WRITE_SUPPORTED block + of png.h. + Avoid runtime checks when converting integer to png_byte with + Visual Studio (Sergey Kosarevsky) + +Version 1.6.17rc01 [March 4, 2015] + No changes. + +Version 1.6.17rc02 [March 9, 2015] + Removed some comments that the configure script did not handle + properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt. + Free the unknown_chunks structure even when it contains no data. + +Version 1.6.17rc03 [March 12, 2015] + Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF + for consistency, and remove some useless tests (Alexey Petruchik). + +Version 1.6.17rc04 [March 16, 2015] + Remove pnglibconf.h, pnglibconf.c, and pnglibconf.out instead of + pnglibconf.* in "make clean" (Cosmin). + Fix bug in calculation of maxbits, in png_write_sBIT, introduced + in libpng-1.6.17beta01 (John Bowler). + +Version 1.6.17rc05 [March 21, 2015] + Define PNG_FILTER_* and PNG_FILTER_VALUE_* in png.h even when WRITE + is not supported (John Bowler). This fixes an error introduced in + libpng-1.6.17beta06. + Reverted "& 0xff" additions of version 1.6.17beta01. Libpng passes + the Coverity scan without them. + +Version 1.6.17rc06 [March 23, 2015] + Remove pnglibconf.dfn and pnglibconf.pre with "make clean". + Reformatted some "&0xff" instances to "& 0xff". + Fixed simplified 8-bit-linear to sRGB alpha. The calculated alpha + value was wrong. It's not clear if this affected the final stored + value; in the obvious code path the upper and lower 8-bits of the + alpha value were identical and the alpha was truncated to 8-bits + rather than dividing by 257 (John Bowler). + +Version 1.6.17 [March 26, 2015] + No changes. + +Version 1.6.18beta01 [April 1, 2015] + Removed PNG_SET_CHUNK_[CACHE|MALLOC]_LIMIT_SUPPORTED macros. They + have been combined with PNG_SET_USER_LIMITS_SUPPORTED (resolves + bug report by Andrew Church). + Fixed rgb_to_gray checks and added tRNS checks to pngvalid.c. This + fixes some arithmetic errors that caused some tests to fail on + some 32-bit platforms (Bug reports by Peter Breitenlohner [i686] + and Petr Gajdos [i586]). + +Version 1.6.18beta02 [April 26, 2015] + Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler + (Bug report by Viktor Szakats). + +Version 1.6.18beta03 [May 6, 2015] + Replaced "unexpected" with an integer (0xabadca11) in pngset.c + where a long was expected, to avoid a compiler warning when PNG_DEBUG > 1. + Added contrib/examples/simpleover.c, to demonstrate how to handle + alpha compositing of multiple images, using the "simplified API" + and an example PNG generation tool, contrib/examples/genpng.c + (John Bowler). + +Version 1.6.18beta04 [May 20, 2015] + PNG_RELEASE_BUILD replaces tests where the code depended on the build base + type and can be defined on the command line, allowing testing in beta + builds (John Bowler). + Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c PNG_DEBUG builds. + Avoid a harmless potential integer overflow in png_XYZ_from_xy() (Bug + report from Christopher Ferris). + +Version 1.6.18beta05 [May 31, 2015] + Backport filter selection code from libpng-1.7.0beta51, to combine + sub_row, up_row, avg_row, and paeth_row into try_row and tst_row. + Changed png_voidcast(), etc., to voidcast(), etc., in contrib/tools/pngfix.c + to avoid confusion with the libpng private macros. + Fixed old cut&paste bug in the weighted filter selection code in + pngwutil.c, introduced in libpng-0.95, March 1997. + +Version 1.6.18beta06 [June 1, 2015] + Removed WRITE_WEIGHTED_FILTERED code, to save a few kbytes of the + compiled library size. It never worked properly and as far as we can + tell, no one uses it. The png_set_filter_heuristics() and + png_set_filter_heuristics_fixed() APIs are retained but deprecated + and do nothing. + +Version 1.6.18beta07 [June 6, 2015] + Removed non-working progressive reader 'skip' function. This + function has apparently never been used. It was implemented + to support back-door modification of png_struct in libpng-1.4.x + but (because it does nothing and cannot do anything) was apparently + never tested (John Bowler). + Fixed cexcept.h in which GCC 5 now reports that one of the auto + variables in the Try macro needs to be volatile to prevent value + being lost over the setjmp (John Bowler). + Fixed NO_WRITE_FILTER and -Wconversion build breaks (John Bowler). + Fix g++ build breaks (John Bowler). + Quieted some Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c, + pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt + would only work with iTXt chunks with length 255 or less. + Added #ifdef's to contrib/examples programs so people don't try + to compile them without the minimum required support enabled + (suggested by Flavio Medeiros). + +Version 1.6.18beta08 [June 30, 2015] + Eliminated the final two Coverity defects (insecure temporary file + handling in contrib/libtests/pngstest.c; possible overflow of + unsigned char in contrib/tools/png-fix-itxt.c). To use the "secure" + file handling, define PNG_USE_MKSTEMP, otherwise "tmpfile()" will + be used. + Removed some unused WEIGHTED_FILTER macros from png.h and pngstruct.h + +Version 1.6.18beta09 [July 5, 2015] + Removed some useless typecasts from contrib/tools/png-fix-itxt.c + Fixed a new signed-unsigned comparison in pngrtran.c (Max Stepin). + Replaced arbitrary use of 'extern' with #define PNG_LINKAGE_*. To + preserve API compatibility, the new defines all default to "extern" + (requested by Jan Nijtmans). + +Version 1.6.18rc01 [July 9, 2015] + Belatedly added Mans Rullgard and James Yu to the list of Contributing + Authors. + +Version 1.6.18rc02 [July 12, 2015] + Restored unused FILTER_HEURISTIC macros removed at libpng-1.6.18beta08 + to png.h to avoid compatibility warnings. + +Version 1.6.18rc03 [July 15, 2015] + Minor changes to the man page + +Version 1.6.18 [July 23, 2015] + No changes. + +Version 1.6.19beta01 [July 30, 2015] + Updated obsolete information about the simplified API macros in the + manual pages (Bug report by Arc Riley). + Avoid potentially dereferencing NULL info_ptr in png_info_init_3(). + Rearranged png.h to put the major sections in the same order as + in libpng17. + Eliminated unused PNG_COST_SHIFT, PNG_WEIGHT_SHIFT, PNG_COST_FACTOR, and + PNG_WEIGHT_FACTOR macros. + Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler + (Bug report by Viktor Szakats). Several warnings remain and are + unavoidable, where we test for overflow. + Fixed potential leak of png_pixels in contrib/pngminus/pnm2png.c + Fixed uninitialized variable in contrib/gregbook/rpng2-x.c + +Version 1.6.19beta02 [August 19, 2015] + Moved config.h.in~ from the "libpng_autotools_files" list to the + "libpng_autotools_extra" list in autogen.sh because it was causing a + false positive for missing files (bug report by Robert C. Seacord). + Removed unreachable "break" statements in png.c, pngread.c, and pngrtran.c + to suppress clang warnings (Bug report by Viktor Szakats). + Fixed some bad links in the man page. + Changed "n bit" to "n-bit" in comments. + Added signed/unsigned 16-bit safety net. This removes the dubious + 0x8000 flag definitions on 16-bit systems. They aren't supported + yet the defs *probably* work, however it seems much safer to do this + and be advised if anyone, contrary to advice, is building libpng 1.6 + on a 16-bit system. It also adds back various switch default clauses + for GCC; GCC errors out if they are not present (with an appropriately + high level of warnings). + Safely convert num_bytes to a png_byte in png_set_sig_bytes() (Robert + Seacord). + Fixed the recently reported 1's complement security issue by replacing + the value that is illegal in the PNG spec, in both signed and unsigned + values, with 0. Illegal unsigned values (anything greater than or equal + to 0x80000000) can still pass through, but since these are not illegal + in ANSI-C (unlike 0x80000000 in the signed case) the checking that + occurs later can catch them (John Bowler). + +Version 1.6.19beta03 [September 26, 2015] + Fixed png_save_int_32 when int is not 2's complement (John Bowler). + Updated libpng16 with all the recent test changes from libpng17, + including changes to pngvalid.c to ensure that the original, + distributed, version of contrib/visupng/cexcept.h can be used + (John Bowler). + pngvalid contains the correction to the use of SAVE/STORE_ + UNKNOWN_CHUNKS; a bug revealed by changes in libpng 1.7. More + tests contain the --strict option to detect warnings and the + pngvalid-standard test has been corrected so that it does not + turn on progressive-read. There is a separate test which does + that. (John Bowler) + Also made some signed/unsigned fixes. + Make pngstest error limits version specific. Splitting the machine + generated error structs out to a file allows the values to be updated + without changing pngstest.c itself. Since libpng 1.6 and 1.7 have + slightly different error limits this simplifies maintenance. The + makepngs.sh script has also been updated to more accurately reflect + current problems in libpng 1.7 (John Bowler). + Incorporated new test PNG files into make check. tests/pngstest-* + are changed so that the new test files are divided into 8 groups by + gamma and alpha channel. These tests have considerably better code + and pixel-value coverage than contrib/pngsuite; however,coverage is + still incomplete (John Bowler). + Removed the '--strict' in 1.6 because of the double-gamma-correction + warning, updated pngstest-errors.h for the errors detected with the + new contrib/testspngs PNG test files (John Bowler). + +Version 1.6.19beta04 [October 15, 2015] + Worked around rgb-to-gray issues in libpng 1.6. The previous + attempts to ignore the errors in the code aren't quite enough to + deal with the 'channel selection' encoding added to libpng 1.7; abort. + pngvalid.c is changed to drop this encoding in prior versions. + Fixed 'pow' macros in pngvalid.c. It is legal for 'pow' to be a + macro, therefore the argument list cannot contain preprocessing + directives. Make sure pow is a function where this happens. This is + a minimal safe fix, the issue only arises in non-performance-critical + code (bug report by Curtis Leach, fix by John Bowler). + Added sPLT support to pngtest.c + +Version 1.6.19rc01 [October 23, 2015] + No changes. + +Version 1.6.19rc02 [October 31, 2015] + Prevent setting or writing over-length PLTE chunk (Cosmin Truta). + Silently truncate over-length PLTE chunk while reading. + Libpng incorrectly calculated the output rowbytes when the application + decreased either the number of channels or the bit depth (or both) in + a user transform. This was safe; libpng overallocated buffer space + (potentially by quite a lot; up to 4 times the amount required) but, + from 1.5.4 on, resulted in a png_error (John Bowler). + +Version 1.6.19rc03 [November 3, 2015] + Fixed some inconsequential cut-and-paste typos in png_set_cHRM_XYZ_fixed(). + Clarified COPYRIGHT information to state explicitly that versions + are derived from previous versions. + Removed much of the long list of previous versions from png.h and + libpng.3. + +Version 1.6.19rc04 [November 5, 2015] + Fixed new bug with CRC error after reading an over-length palette + (bug report by Cosmin Truta) (CVE-2015-8126). + +Version 1.6.19 [November 12, 2015] + Cleaned up coding style in png_handle_PLTE(). + +Version 1.6.20beta01 [November 20, 2015] + Avoid potential pointer overflow/underflow in png_handle_sPLT() and + png_handle_pCAL() (Bug report by John Regehr). + +Version 1.6.20beta02 [November 23, 2015] + Fixed incorrect implementation of png_set_PLTE() that uses png_ptr + not info_ptr, that left png_set_PLTE() open to the CVE-2015-8126 + vulnerability. Fixes CVE-2015-8472. + +Version 1.6.20beta03 [November 24, 2015] + Backported tests from libpng-1.7.0beta69. + +Version 1.6.20rc01 [November 26, 2015] + Fixed an error in handling of bad zlib CMINFO field in pngfix, found by + American Fuzzy Lop, reported by Brian Carpenter. inflate() doesn't + immediately fault a bad CMINFO field; instead a 'too far back' error + happens later (at least some times). pngfix failed to limit CMINFO to + the allowed values but then assumed that window_bits was in range, + triggering an assert. The bug is mostly harmless; the PNG file cannot + be fixed. + +Version 1.6.20rc02 [November 29, 2015] + In libpng 1.6 zlib initialization was changed to use the window size + in the zlib stream, not a fixed value. This causes some invalid images, + where CINFO is too large, to display 'correctly' if the rest of the + data is valid. This provides a workaround for zlib versions where the + error arises (ones that support the API change to use the window size + in the stream). + +Version 1.6.20 [December 3, 2015] + No changes. + +Version 1.6.21beta01 [December 11, 2015] + Fixed syntax "$(command)" in tests/pngstest that some shells other than + bash could not parse (Bug report by Nelson Beebe). Use `command` instead. + +Version 1.6.21beta02 [December 14, 2015] + Moved png_check_keyword() from pngwutil.c to pngset.c + Removed LE/BE dependencies in pngvalid, to 'fix' the current problem + in the BigEndian tests by not testing it, making the BE code the same + as the LE version. + Fixes to pngvalid for various reduced build configurations (eliminate unused + statics) and a fix for the case in rgb_to_gray when the digitize option + reduces graylo to 0, producing a large error. + +Version 1.6.21beta03 [December 18, 2015] + Widened the 'limit' check on the internally calculated error limits in + the 'DIGITIZE' case (the code used prior to 1.7 for rgb_to_gray error + checks) and changed the check to only operate in non-release builds + (base build type not RC or RELEASE.) + Fixed undefined behavior in pngvalid.c, undefined because + (png_byte) << shift is undefined if it changes the signed bit + (because png_byte is promoted to int). The libpng exported functions + png_get_uint_32 and png_get_uint_16 handle this. (Bug reported by + David Drysdale as a result of reports from UBSAN in clang 3.8). + This changes pngvalid to use BE random numbers; this used to produce + errors but these should not be fixed as a result of the previous changes. + +Version 1.6.21rc01 [January 4, 2016] + In projects/vstudio, combined readme.txt and WARNING into README.txt + +Version 1.6.21rc02 [January 7, 2016] + Relocated assert() in contrib/tools/pngfix.c, bug found by American + Fuzzy Lop, reported by Brian Carpenter. + Marked 'limit' UNUSED in transform_range_check(). This only affects + release builds. + +Version 1.6.21 [January 15, 2016] + Worked around a false-positive Coverity issue in pngvalid.c. + +Version 1.6.22beta01 [January 23, 2016] + Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate + "tmpfile()" implementation in contrib/libtests/pngstest.c + Fixed NO_STDIO build of pngunknown.c to skip calling png_init_io() + if there is no stdio.h support. + Added a png_image_write_to_memory() API and a number of assist macros + to allow an application that uses the simplified API write to bypass + stdio and write directly to memory. + Added some warnings (png.h) and some check code to detect *possible* + overflow in the ROW_STRIDE and simplified image SIZE macros. This + disallows image width/height/format that *might* overflow. This is + a quiet API change that limits in-memory image size (uncompressed) to + less than 4GByte and image row size (stride) to less than 2GByte. + Revised workaround for false-positive Coverity issue in pngvalid.c. + +Version 1.6.22beta02 [February 8, 2016] + Only use exit(77) in configure builds. + Corrected error in PNG_IMAGE_PNG_SIZE_MAX. This new macro underreported + the palette size because it failed to take into account that the memory + palette has to be expanded to full RGB when it is written to PNG. + Updated CMakeLists.txt, added supporting scripts/gen*.cmake.in + and test.cmake.in (Roger Leigh). + Relaxed limit checks on gamma values in pngrtran.c. As suggested in + the comments gamma values outside the range currently permitted + by png_set_alpha_mode are useful for HDR data encoding. These values + are already permitted by png_set_gamma so it is reasonable caution to + extend the png_set_alpha_mode range as HDR imaging systems are starting + to emerge. + +Version 1.6.22beta03 [March 9, 2016] + Added a common-law trademark notice and export control information + to the LICENSE file, png.h, and the man page. + Restored "& 0xff" in png_save_uint_16() and png_save_uint_32() that + were accidentally removed from libpng-1.6.17. + Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in png.h + (Robert C. Seacord). + Removed dubious "#if INT_MAX" test from png.h that was added to + libpng-1.6.19beta02 (John Bowler). + Add ${INCLUDES} in scripts/genout.cmake.in (Bug report by Nixon Kwok). + Updated LICENSE to say files in the contrib directory are not + necessarily under the libpng license, and that some makefiles have + other copyright owners. + Added INTEL-SSE2 support (Mike Klein and Matt Sarett, Google, Inc.). + Made contrib/libtests/timepng more robust. The code no longer gives + up/fails on invalid PNG data, it just skips it (with error messages). + The code no longer fails on PNG files with data beyond IEND. Options + exist to use png_read_png (reading the whole image, not by row) and, in + that case, to apply any of the supported transforms. This makes for + more realistic testing; the decoded data actually gets used in a + meaningful fashion (John Bowler). + Fixed some misleading indentation (Krishnaraj Bhat). + +Version 1.6.22beta04 [April 5, 2016] + Force GCC compilation to C89 if needed (Dagobert Michelsen). + SSE filter speed improvements for bpp=3: + memcpy-free implementations of load3() / store3(). + call load3() only when needed at the end of a scanline. + +Version 1.6.22beta05 [April 27, 2016] + Added PNG_FAST_FILTERS macro (defined as + PNG_FILTER_NONE|PNG_FILTER_SUB|PNG_FILTER_UP). + Various fixes for contrib/libtests/timepng.c + Moved INTEL-SSE code from pngpriv.h into contrib/intel/intel_sse.patch. + Fixed typo (missing underscore) in #define PNG_READ_16_TO_8_SUPPORTED + (Bug report by Y.Ohashik). + +Version 1.6.22beta06 [May 5, 2016] + Rebased contrib/intel_sse.patch. + Quieted two Coverity issues in contrib/libtests/timepng.c. + Fixed issues with scripts/genout.cmake.in (David Capello, Nixon Kwok): + Added support to use multiple directories in ZLIBINCDIR variable, + Fixed CMAKE_C_FLAGS with multiple values when genout is compiled on MSVC, + Fixed pnglibconf.c compilation on OS X including the sysroot path. + +Version 1.6.22rc01 [May 14, 2016] + No changes. + +Version 1.6.22rc02 [May 16, 2016] + Removed contrib/timepng from default build; it does not build on platforms + that don't supply clock_gettime(). + +Version 1.6.22rc03 [May 17, 2016] + Restored contrib/timepng to default build but check for the presence + of clock_gettime() in configure.ac and Makefile.am. + +Version 1.6.22 [May 26, 2016] + No changes. + +Version 1.6.23beta01 [May 29, 2016] + Stop a potential memory leak in png_set_tRNS() (Bug report by Ted Ying). + Fixed the progressive reader to handle empty first IDAT chunk properly + (patch by Timothy Nikkel). This bug was introduced in libpng-1.6.0 and + only affected the libpng16 branch. + Added tests in pngvalid.c to check zero-length IDAT chunks in various + positions. Fixed the sequential reader to handle these more robustly + (John Bowler). + +Version 1.6.23rc01 [June 2, 2016] + Corrected progressive read input buffer in pngvalid.c. The previous version + the code invariably passed just one byte at a time to libpng. The intent + was to pass a random number of bytes in the range 0..511. + Moved sse2 prototype from pngpriv.h to contrib/intel/intel_sse.patch. + Added missing ")" in pngerror.c (Matt Sarrett). + +Version 1.6.23rc02 [June 4, 2016] + Fixed undefined behavior in png_push_save_buffer(). Do not call + memcpy() with a null source, even if count is zero (Leon Scroggins III). + +Version 1.6.23 [June 9, 2016] + Fixed bad link to RFC2083 in png.5 (Nikola Forro). + +Version 1.6.24beta01 [June 11, 2016] + Avoid potential overflow of the PNG_IMAGE_SIZE macro. This macro + is not used within libpng, but is used in some of the examples. + +Version 1.6.24beta02 [June 23, 2016] + Correct filter heuristic overflow handling. This was broken when the + write filter code was moved out-of-line; if there is a single filter and + the heuristic sum overflows the calculation of the filtered line is not + completed. In versions prior to 1.6 the code was duplicated in-line + and the check not performed, so the filter operation completed; however, + in the multi-filter case where the sum is performed the 'none' filter would + be selected if all the sums overflowed, even if it wasn't in the filter + list. The fix to the first problem is simply to provide PNG_SIZE_MAX as + the current lmins sum value; this means the sum can never exceed it and + overflows silently. A reasonable compiler that does choose to inline + the code will simply eliminate the sum check. + The fix to the second problem is to use high precision arithmetic (this is + implemented in 1.7), however a simple safe fix here is to chose the lowest + numbered filter in the list from png_set_filter (this only works if the + first problem is also fixed) (John Bowler). + Use a more efficient absolute value calculation on SSE2 (Matthieu Darbois). + Fixed the case where PNG_IMAGE_BUFFER_SIZE can overflow in the application + as a result of the application using an increased 'row_stride'; previously + png_image_finish_read only checked for overflow on the base calculation of + components. (I.e. it checked for overflow of a 32-bit number on the total + number of pixel components in the output format, not the possibly padded row + length and not the number of bytes, which for linear formats is twice the + number of components.) + MSVC does not like '-(unsigned)', so replaced it with 0U-(unsigned) + MSVC does not like (uInt) = -(unsigned) (i.e. as an initializer), unless + the conversion is explicitly invoked by a cast. + Put the SKIP definition in the correct place. It needs to come after the + png.h include (see all the other .c files in contrib/libtests) because it + depends on PNG_LIBPNG_VER. + Removed the three compile warning options from the individual project + files into the zlib.props globals. It increases the warning level from 4 + to All and adds a list of the warnings that need to be turned off. This is + semi-documentary; the intent is to tell libpng users which warnings have + been examined and judged non-fixable at present. The warning about + structure padding is fixable, but it would be a significant change (moving + structure members around). + +Version 1.6.24beta03 [July 4, 2016] + Optimized absolute value calculation in filter selection, similar to + code in the PAETH decoder in pngrutil.c. Build with PNG_USE_ABS to + use this. + Added pngcp to the build together with a pngcp.dfa configuration test. + Added high resolution timing to pngcp. + Added "Common linking failures" section to INSTALL. + Relocated misplaced #endif in png.c sRGB profile checking. + Fixed two Coverity issues in pngcp.c. + +Version 1.6.24beta04 [July 8, 2016] + Avoid filter-selection heuristic sum calculations in cases where only one + filter is a candidate for selection. This trades off code size (added + private png_setup_*_row_only() functions) for speed. + +Version 1.6.24beta05 [July 13, 2016] + Fixed some indentation to comply with our coding style. + Added contrib/tools/reindent. + +Version 1.6.24beta06 [July 18, 2016] + Fixed more indentation to comply with our coding style. + Eliminated unnecessary tests of boolean png_isaligned() vs 0. + +Version 1.6.24rc01 [July 25, 2016] + No changes. + +Version 1.6.24rc02 [August 1, 2016] + Conditionally compile SSE2 headers in contrib/intel/intel_sse.patch + Conditionally compile png_decompress_chunk(). + +Version 1.6.24rc03 [August 2, 2016] + Conditionally compile ARM_NEON headers in pngpriv.h + Updated contrib/intel/intel_sse.patch + +Version 1.6.24[August 4, 2016] + No changes. + +Version 1.6.25beta01 [August 12, 2016] + Reject oversized iCCP profile immediately. + Cleaned up PNG_DEBUG compile of pngtest.c. + Conditionally compile png_inflate(). + +Version 1.6.25beta02 [August 18, 2016] + Don't install pngcp; it conflicts with pngcp in the pngtools package. + Minor editing of INSTALL, (whitespace, added copyright line) + +Version 1.6.25rc01 [August 24, 2016] + No changes. + +Version 1.6.25rc02 [August 29, 2016] + Added MIPS support (Mandar Sahastrabuddhe ). + Only the UP filter is currently implemented. + +Version 1.6.25rc03 [August 29, 2016] + Rebased contrib/intel/intel_sse.patch after the MIPS implementation. + +Version 1.6.25rc04 [August 30, 2016] + Added MIPS support for SUB, AVG, and PAETH filters (Mandar Sahastrabuddhe). + +Version 1.6.25rc05 [August 30, 2016] + Rebased contrib/intel/intel_sse.patch after the MIPS implementation update.. + +Version 1.6.25 [September 1, 2016] + No changes. + +Version 1.6.26beta01 [September 26, 2016] + Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo, + bugfix by John Bowler). + Do not issue a png_error() on read in png_set_pCAL() because png_handle_pCAL + has allocated memory that libpng needs to free. + Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c + Issue a png_benign_error instead of a png_error on ADLER32 mismatch + while decoding compressed data chunks. + Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngpriv.h, pngstruct.h, and + pngrutil.c. + If CRC handling of critical chunks has been set to PNG_CRC_QUIET_USE, + ignore the ADLER32 checksum in the IDAT chunk as well as the chunk CRCs. + Issue png_benign_error() on ADLER32 checksum mismatch instead of png_error(). + Add tests/badcrc.png and tests/badadler.png to tests/pngtest. + Merged pngtest.c with libpng-1.7.0beta84/pngtest.c + +Version 1.6.26beta02 [October 1, 2016] + Updated the documentation about CRC and ADLER32 handling. + Quieted 117 warnings from clang-3.8 in pngtrans.c, pngread.c, + pngwrite.c, pngunknown.c, and pngvalid.c. + Quieted 58 (out of 144) -Wconversion compiler warnings by changing + flag definitions in pngpriv.h from 0xnnnn to 0xnnnnU and trivial changes + in png.c, pngread.c, and pngwutil.c. + +Version 1.6.26beta03 [October 2, 2016] + Removed contrib/libtests/*.orig and *.rej that slipped into the tarballs. + Quieted the 86 remaining -Wconversion compiler warnings by + revising the png_isaligned() macro and trivial changes in png.c, + pngerror.c, pngget.c, pngmem.c, pngset.c, pngrtran.c, pngrutil.c, + pngwtran.c, pngwrite.c, and pngwutil.c. + +Version 1.6.26beta04 [October 3, 2016] + Quieted (bogus?) clang warnings about "absolute value has no effect" + when PNG_USE_ABS is defined. + Fixed offsets in contrib/intel/intel_sse.patch + +Version 1.6.26beta05 [October 6, 2016] + Changed integer constant 4294967294 to unsigned 4294967294U in pngconf.h + to avoid a signed/unsigned compare in the preprocessor. + +Version 1.6.26beta06 [October 7, 2016] + Use zlib-1.2.8.1 inflateValidate() instead of inflateReset2() to + optionally avoid ADLER32 evaluation. + +Version 1.6.26rc01 [October 12, 2016] + No changes. + +Version 1.6.26 [October 20, 2016] + Cosmetic change, "ptr != 0" to "ptr != NULL" in png.c and pngrutil.c + Despammed email addresses (replaced "@" with " at "). + +Version 1.6.27beta01 [November 2, 2016] + Restrict the new ADLER32-skipping to IDAT chunks. It broke iCCP chunk + handling: an erroneous iCCP chunk would throw a png_error and reject the + entire PNG image instead of rejecting just the iCCP chunk with a warning, + if built with zlib-1.2.8.1. + +Version 1.6.27rc01 [December 27, 2016] + Control ADLER32 checking with new PNG_IGNORE_ADLER32 option. Fixes + an endless loop when handling erroneous ADLER32 checksums; bug + introduced in libpng-1.6.26. + Removed the use of a macro containing the pre-processor 'defined' + operator. It is unclear whether this is valid; a macro that + "generates" 'defined' is not permitted, but the use of the word + "generates" within the C90 standard seems to imply more than simple + substitution of an expression itself containing a well-formed defined + operation. + Added ARM support to CMakeLists.txt (Andreas Franek). + +Version 1.6.27 [December 29, 2016] + Fixed a potential null pointer dereference in png_set_text_2() (bug report + and patch by Patrick Keshishian, CVE-2016-10087). + +Version 1.6.28rc01 [January 3, 2017] + Fixed arm/aarch64 detection in CMakeLists.txt (Gianfranco Costamagna). + Added option to Cmake build allowing a custom location of zlib to be + specified in a scenario where libpng is being built as a subproject + alongside zlib by another project (Sam Serrels). + Changed png_ptr->options from a png_byte to png_uint_32, to accommodate + up to 16 options. + +Version 1.6.28rc02 [January 4, 2017] + Added "include(GNUInstallDirs)" to CMakeLists.txt (Gianfranco Costamagna). + Moved SSE2 optimization code into the main libpng source directory. + Configure libpng with "configure --enable-intel-sse" or compile + libpng with "-DPNG_INTEL_SSE" in CPPFLAGS to enable it. + +Version 1.6.28rc03 [January 4, 2017] + Backed out the SSE optimization and last CMakeLists.txt to allow time for QA. + +Version 1.6.28 [January 5, 2017] + No changes. + +Version 1.6.29beta01 [January 12, 2017] + Readded "include(GNUInstallDirs)" to CMakeLists.txt (Gianfranco Costamagna). + Moved SSE2 optimization code into the main libpng source directory. + Configure libpng with "configure --enable-intel-sse" or compile + libpng with "-DPNG_INTEL_SSE" in CPPFLAGS to enable it. + Simplified conditional compilation in pngvalid.c, for AIX (Michael Felt). + +Version 1.6.29beta02 [February 22, 2017] + Avoid conditional directives that break statements in pngrutil.c (Romero + Malaquias) + The contrib/examples/pngtopng.c recovery code was in the wrong "if" + branches; the comments were correct. + Added code for PowerPC VSX optimisation (Vadim Barkov). + +Version 1.6.29beta03 [March 1, 2017] + Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer). + Change test ZLIB_VERNUM >= 0x1281 to ZLIB_VERNUM >= 0x1290 in pngrutil.c + because Solaris 11 distributes zlib-1.2.8.f that is older than 1.2.8.1, + as suggested in zlib FAQ, item 24. + Suppress clang warnings about implicit sign changes in png.c + +Version 1.6.29 [March 16, 2017] + No changes. + +Version 1.6.30beta01 [April 1, 2017] + Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in + makefile.linux and makefile.solaris-x86 (Cosmin). + Revised documentation of png_get_error_ptr() in the libpng manual. + Silence clang -Wcomma and const drop warnings (Viktor Szakats). + Update Sourceforge URLs in documentation (https instead of http). + +Version 1.6.30beta02 [April 22, 2017] + Document need to check for integer overflow when allocating a pixel + buffer for multiple rows in contrib/gregbook, contrib/pngminus, + example.c, and in the manual (suggested by Jaeseung Choi). This + is similar to the bug reported against pngquant in CVE-2016-5735. + Removed reference to the obsolete PNG_SAFE_LIMITS macro in the documentation. + +Version 1.6.30beta03 [May 22, 2017] + Check for integer overflow in contrib/visupng and contrib/tools/genpng. + Do not double evaluate CMAKE_SYSTEM_PROCESSOR in CMakeLists.txt. + Test CMAKE_HOST_WIN32 instead of WIN32 in CMakeLists.txt. + Fix some URL in documentation. + +Version 1.6.30beta04 [June 7, 2017] + Avoid writing an empty IDAT when the last IDAT exactly fills the + compression buffer (bug report by Brian Baird). This bug was + introduced in libpng-1.6.0. + +Version 1.6.30rc01 [June 14, 2017] + No changes. + +Version 1.6.30rc02 [June 25, 2017] + Update copyright year in pnglibconf.h, make ltmain.sh executable. + Add a reference to the libpng.download site in README. + +Version 1.6.30 [June 28, 2017] + No changes. + +Version 1.6.31beta01 [July 5, 2017] + Guard the definition of _POSIX_SOURCE in pngpriv.h (AIX already defines it; + bug report by Michael Felt). + Revised pngpriv.h to work around failure to compile arm/filter_neon.S + ("typedef" directive is unrecognized by the assembler). The problem + was introduced in libpng-1.6.30beta01. + Added "Requires: zlib" to libpng.pc.in (Pieter Neerincx). + Added special case for FreeBSD in arm/filter_neon.S (Maya Rashish). + +Version 1.6.31beta02 [July 8, 2017] + Added instructions for disabling hardware optimizations in INSTALL. + Added "--enable-hardware-optimizations" configuration flag to enable + or disable all hardware optimizations with one flag. + +Version 1.6.31beta03 [July 9, 2017] + Updated CMakeLists.txt to add INTEL_SSE and MIPS_MSA platforms. + Changed "int" to "png_size_t" in intel/filter_sse2.c to prevent + possible integer overflow (Bug report by John Bowler). + Quieted "declaration after statement" warnings in intel/filter_sse2.c. + Added scripts/makefile-linux-opt, which has hardware optimizations enabled. + +Version 1.6.31beta04 [July 11, 2017] + Removed one of the GCC-7.1.0 'strict-overflow' warnings that result when + integers appear on both sides of a compare. Worked around the others by + forcing the strict-overflow setting in the relevant functions to a level + where they are not reported (John Bowler). + Changed "FALL THROUGH" comments to "FALLTHROUGH" because GCC doesn't like + the space. + Worked around some C-style casts from (void*) because g++ 5.4.0 objects + to them. + Increased the buffer size for 'sprint' to pass the gcc 7.1.0 'sprint + overflow' check that is on by default with -Wall -Wextra. + +Version 1.6.31beta05 [July 13, 2017] + Added eXIf chunk support. + +Version 1.6.31beta06 [July 17, 2017] + Added a minimal eXIf chunk (with Orientation and FocalLengthIn35mmFilm + tags) to pngtest.png. + +Version 1.6.31beta07 [July 18, 2017] + Revised the eXIf chunk in pngtest.png to fix "Bad IFD1 Directory" warning. + +Version 1.6.31rc01 [July 19, 2017] + No changes. + +Version 1.6.31rc02 [July 25, 2017] + Fixed typo in example.c (png_free_image should be png_image_free) (Bug + report by John Smith) + +Version 1.6.31 [July 27, 2017] + No changes. + +Version 1.6.32beta01 [July 31, 2017] + Avoid possible NULL dereference in png_handle_eXIf when benign_errors + are allowed. Avoid leaking the input buffer "eXIf_buf". + Eliminated png_ptr->num_exif member from pngstruct.h and added num_exif + to arguments for png_get_eXIf() and png_set_eXIf(). + Added calls to png_handle_eXIf(() in pngread.c and png_write_eXIf() in + pngwrite.c, and made various other fixes to png_write_eXIf(). + Changed name of png_get_eXIF and png_set_eXIf() to png_get_eXIf_1() and + png_set_eXIf_1(), respectively, to avoid breaking API compatibility + with libpng-1.6.31. + +Version 1.6.32beta02 [August 1, 2017] + Updated contrib/libtests/pngunknown.c with eXIf chunk. + +Version 1.6.32beta03 [August 2, 2017] + Initialized btoa[] in pngstest.c + Stop memory leak when returning from png_handle_eXIf() with an error + (Bug report from the OSS-fuzz project). + +Version 1.6.32beta04 [August 2, 2017] + Replaced local eXIf_buf with info_ptr-eXIf_buf in png_handle_eXIf(). + Update libpng.3 and libpng-manual.txt about eXIf functions. + +Version 1.6.32beta05 [August 2, 2017] + Restored png_get_eXIf() and png_set_eXIf() to maintain API compatibility. + +Version 1.6.32beta06 [August 2, 2017] + Removed png_get_eXIf_1() and png_set_eXIf_1(). + +Version 1.6.32beta07 [August 3, 2017] + Check length of all chunks except IDAT against user limit to fix an + OSS-fuzz issue (Fixes CVE-2017-12652). + +Version 1.6.32beta08 [August 3, 2017] + Check length of IDAT against maximum possible IDAT size, accounting + for height, rowbytes, interlacing and zlib/deflate overhead. + Restored png_get_eXIf_1() and png_set_eXIf_1(), because strlen(eXIf_buf) + does not work (the eXIf chunk data can contain zeroes). + +Version 1.6.32beta09 [August 3, 2017] + Require cmake-2.8.8 in CMakeLists.txt. Revised symlink creation, + no longer using deprecated cmake LOCATION feature (Clifford Yapp). + Fixed five-byte error in the calculation of IDAT maximum possible size. + +Version 1.6.32beta10 [August 5, 2017] + Moved chunk-length check into a png_check_chunk_length() private + function (Suggested by Max Stepin). + Moved bad pngs from tests to contrib/libtests/crashers + Moved testing of bad pngs into a separate tests/pngtest-badpngs script + Added the --xfail (expected FAIL) option to pngtest.c. It writes XFAIL + in the output but PASS for the libpng test. + Require cmake-3.0.2 in CMakeLists.txt (Clifford Yapp). + Fix "const" declaration info_ptr argument to png_get_eXIf_1() and the + num_exif argument to png_get_eXIf_1() (Github Issue 171). + +Version 1.6.32beta11 [August 7, 2017] + Added "eXIf" to "chunks_to_ignore[]" in png_set_keep_unknown_chunks(). + Added huge_IDAT.png and empty_ancillary_chunks.png to testpngs/crashers. + Make pngtest --strict, --relax, --xfail options imply -m (multiple). + Removed unused chunk_name parameter from png_check_chunk_length(). + Relocated setting free_me for eXIf data, to stop an OSS-fuzz leak. + Initialize profile_header[] in png_handle_iCCP() to fix OSS-fuzz issue. + Initialize png_ptr->row_buf[0] to 255 in png_read_row() to fix OSS-fuzz UMR. + Attempt to fix a UMR in png_set_text_2() to fix OSS-fuzz issue. + Increase minimum zlib stream from 9 to 14 in png_handle_iCCP(), to account + for the minimum 'deflate' stream, and relocate the test to a point + after the keyword has been read. + Check that the eXIf chunk has at least 2 bytes and begins with "II" or "MM". + +Version 1.6.32rc01 [August 18, 2017] + Added a set of "huge_xxxx_chunk.png" files to contrib/testpngs/crashers, + one for each known chunk type, with length = 2GB-1. + Check for 0 return from png_get_rowbytes() and added some (size_t) typecasts + in contrib/pngminus/*.c to stop some Coverity issues (162705, 162706, + and 162707). + Renamed chunks in contrib/testpngs/crashers to avoid having files whose + names differ only in case; this causes problems with some platforms + (github issue #172). + +Version 1.6.32rc02 [August 22, 2017] + Added contrib/oss-fuzz directory which contains files used by the oss-fuzz + project (https://github.com/google/oss-fuzz/tree/master/projects/libpng). + +Version 1.6.32 [August 24, 2017] + No changes. + +Version 1.6.33beta01 [August 28, 2017] + Added PNGMINUS_UNUSED macro to contrib/pngminus/p*.c and added missing + parenthesis in contrib/pngminus/pnm2png.c (bug report by Christian Hesse). + Fixed off-by-one error in png_do_check_palette_indexes() (Bug report + by Mick P., Source Forge Issue #269). + +Version 1.6.33beta02 [September 3, 2017] + Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc + to fix shortlived oss-fuzz issue 3234. + Compute a larger limit on IDAT because some applications write a deflate + buffer for each row (Bug report by Andrew Church). + Use current date (DATE) instead of release-date (RDATE) in last + changed date of contrib/oss-fuzz files. + Enabled ARM support in CMakeLists.txt (Bernd Kuhls). + +Version 1.6.33beta03 [September 14, 2017] + Fixed incorrect typecast of some arguments to png_malloc() and + png_calloc() that were png_uint_32 instead of png_alloc_size_t + (Bug report by "irwir" in Github libpng issue #175). + Use pnglibconf.h.prebuilt when building for ANDROID with cmake (Github + issue 162, by rcdailey). + +Version 1.6.33rc01 [September 20, 2017] + Initialize memory allocated by png_inflate to zero, using memset, to + stop an oss-fuzz "use of uninitialized value" detection in png_set_text_2() + due to truncated iTXt or zTXt chunk. + Initialize memory allocated by png_read_buffer to zero, using memset, to + stop an oss-fuzz "use of uninitialized value" detection in + png_icc_check_tag_table() due to truncated iCCP chunk. + Removed a redundant test (suggested by "irwir" in Github issue #180). + +Version 1.6.33rc02 [September 23, 2017] + Added an interlaced version of each file in contrib/pngsuite. + Relocate new memset() call in pngrutil.c. + Removed more redundant tests (suggested by "irwir" in Github issue #180). + Add support for loading images with associated alpha in the Simplified + API (Samuel Williams). + +Version 1.6.33 [September 28, 2017] + Revert contrib/oss-fuzz/libpng_read_fuzzer.cc to libpng-1.6.32 state. + Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc + Add end_info structure and png_read_end() to the libpng fuzzer. + +Version 1.6.34 [September 29, 2017] + Removed contrib/pngsuite/i*.png; some of them caused test failures. + +Version 1.6.35beta01 [March 6, 2018] + Restored 21 of the contrib/pngsuite/i*.png, which do not cause test + failures. Placed the remainder in contrib/pngsuite/interlaced/i*.png. + Added calls to png_set_*() transforms commonly used by browsers to + the fuzzer. + Removed some unnecessary brackets in pngrtran.c + Fixed miscellaneous typos (Patch by github user "luzpaz"). + Change "ASM C" to "C ASM" in CMakeLists.txt + Fixed incorrect handling of bKGD chunk in sub-8-bit files (Cosmin) + Added hardware optimization directories to zip and 7z distributions. + Fixed incorrect bitmask for options. + Fixed many spelling typos. + +Version 1.6.35beta02 [March 28, 2018] + Make png_get_iCCP consistent with man page (allow compression-type argument + to be NULL, bug report by Lenard Szolnoki). + +Version 1.6.35 [July 15, 2018] + Replaced the remaining uses of png_size_t with size_t (Cosmin) + Fixed the calculation of row_factor in png_check_chunk_length + (reported by Thuan Pham in SourceForge issue #278) + Added missing parentheses to a macro definition + (suggested by "irwir" in GitHub issue #216) + +Version 1.6.36 [December 1, 2018] + Optimized png_do_expand_palette for ARM processors. + Improved performance by around 10-22% on a recent ARM Chromebook. + (Contributed by Richard Townsend, ARM Holdings) + Fixed manipulation of machine-specific optimization options. + (Contributed by Vicki Pfau) + Used memcpy instead of manual pointer arithmetic on Intel SSE2. + (Contributed by Samuel Williams) + Fixed build errors with MSVC on ARM64. + (Contributed by Zhijie Liang) + Fixed detection of libm in CMakeLists. + (Contributed by Cameron Cawley) + Fixed incorrect creation of pkg-config file in CMakeLists. + (Contributed by Kyle Bentley) + Fixed the CMake build on Windows MSYS by avoiding symlinks. + Fixed a build warning on OpenBSD. + (Contributed by Theo Buehler) + Fixed various typos in comments. + (Contributed by "luz.paz") + Raised the minimum required CMake version from 3.0.2 to 3.1. + Removed yet more of the vestigial support for pre-ANSI C compilers. + Removed ancient makefiles for ancient systems that have been broken + across all previous libpng-1.6.x versions. + Removed the Y2K compliance statement and the export control + information. + Applied various code style and documentation fixes. + +Version 1.6.37 [April 14, 2019] + Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free. + Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette. + Fixed a memory leak in pngtest.c. + Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in + contrib/pngminus; refactor. + Changed the license of contrib/pngminus to MIT; refresh makefile and docs. + (Contributed by Willem van Schaik) + Fixed a typo in the libpng license v2. + (Contributed by Miguel Ojeda) + Added makefiles for AddressSanitizer-enabled builds. + Cleaned up various makefiles. + +Send comments/corrections/commendations to png-mng-implement at lists.sf.net. +Subscription is required; visit +https://lists.sourceforge.net/lists/listinfo/png-mng-implement +to subscribe. diff --git a/thirdparty/libpng-1.6.37/CMakeLists.txt b/thirdparty/libpng-1.6.37/CMakeLists.txt new file mode 100644 index 0000000..6451fcf --- /dev/null +++ b/thirdparty/libpng-1.6.37/CMakeLists.txt @@ -0,0 +1,931 @@ +# CMakeLists.txt + +# Copyright (C) 2018 Cosmin Truta +# Copyright (C) 2007,2009-2018 Glenn Randers-Pehrson +# Written by Christian Ehrlicher, 2007 +# Revised by Roger Lowman, 2009-2010 +# Revised by Clifford Yapp, 2011-2012,2017 +# Revised by Roger Leigh, 2016 +# Revised by Andreas Franek, 2016 +# Revised by Sam Serrels, 2017 +# Revised by Vadim Barkov, 2017 +# Revised by Vicky Pfau, 2018 +# Revised by Cameron Cawley, 2018 +# Revised by Cosmin Truta, 2018 +# Revised by Kyle Bentley, 2018 + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +cmake_minimum_required(VERSION 3.1) +cmake_policy(VERSION 3.1) + +project(libpng C ASM) +enable_testing() + +set(PNGLIB_MAJOR 1) +set(PNGLIB_MINOR 6) +set(PNGLIB_RELEASE 37) +set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) +set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) + +include(GNUInstallDirs) + +# needed packages + +# Allow users to specify location of Zlib. +# Useful if zlib is being built alongside this as a sub-project. +option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF) + +if(NOT PNG_BUILD_ZLIB) + find_package(ZLIB REQUIRED) + include_directories(${ZLIB_INCLUDE_DIR}) +endif() + +if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU) + find_library(M_LIBRARY m) +else() + # libm is not needed and/or not available + set(M_LIBRARY "") +endif() + +# COMMAND LINE OPTIONS +option(PNG_SHARED "Build shared lib" ON) +option(PNG_STATIC "Build static lib" ON) +option(PNG_TESTS "Build libpng tests" ON) + +# Many more configuration options could be added here +option(PNG_FRAMEWORK "Build OS X framework" OFF) +option(PNG_DEBUG "Build with debug output" OFF) +option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON) + +set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names") +set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings") + +if(PNG_HARDWARE_OPTIMIZATIONS) + +# set definitions and sources for arm +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") + set(PNG_ARM_NEON_POSSIBLE_VALUES check on off) + set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations: + check: (default) use internal checking code; + off: disable the optimizations; + on: turn on unconditionally.") + set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS + ${PNG_ARM_NEON_POSSIBLE_VALUES}) + list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index) + if(index EQUAL -1) + message(FATAL_ERROR + "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_ARM_NEON} STREQUAL "off") + set(libpng_arm_sources + arm/arm_init.c + arm/filter_neon.S + arm/filter_neon_intrinsics.c + arm/palette_neon_intrinsics.c) + + if(${PNG_ARM_NEON} STREQUAL "on") + add_definitions(-DPNG_ARM_NEON_OPT=2) + elseif(${PNG_ARM_NEON} STREQUAL "check") + add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED) + endif() + else() + add_definitions(-DPNG_ARM_NEON_OPT=0) + endif() +endif() + +# set definitions and sources for powerpc +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*") + set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off) + set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations: + off: disable the optimizations.") + set_property(CACHE PNG_POWERPC_VSX PROPERTY STRINGS + ${PNG_POWERPC_VSX_POSSIBLE_VALUES}) + list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index) + if(index EQUAL -1) + message(FATAL_ERROR + "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "off") + set(libpng_powerpc_sources + powerpc/powerpc_init.c + powerpc/filter_vsx_intrinsics.c) + if(${PNG_POWERPC_VSX} STREQUAL "on") + add_definitions(-DPNG_POWERPC_VSX_OPT=2) + endif() + else() + add_definitions(-DPNG_POWERPC_VSX_OPT=0) + endif() +endif() + +# set definitions and sources for intel +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*") + set(PNG_INTEL_SSE_POSSIBLE_VALUES on off) + set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations: + off: disable the optimizations") + set_property(CACHE PNG_INTEL_SSE PROPERTY STRINGS + ${PNG_INTEL_SSE_POSSIBLE_VALUES}) + list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index) + if(index EQUAL -1) + message(FATAL_ERROR + "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_INTEL_SSE} STREQUAL "off") + set(libpng_intel_sources + intel/intel_init.c + intel/filter_sse2_intrinsics.c) + if(${PNG_INTEL_SSE} STREQUAL "on") + add_definitions(-DPNG_INTEL_SSE_OPT=1) + endif() + else() + add_definitions(-DPNG_INTEL_SSE_OPT=0) + endif() +endif() + +# set definitions and sources for MIPS +if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*") + set(PNG_MIPS_MSA_POSSIBLE_VALUES on off) + set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations: + off: disable the optimizations") + set_property(CACHE PNG_MIPS_MSA PROPERTY STRINGS + ${PNG_MIPS_MSA_POSSIBLE_VALUES}) + list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index) + if(index EQUAL -1) + message(FATAL_ERROR + "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_MIPS_MSA} STREQUAL "off") + set(libpng_mips_sources + mips/mips_init.c + mips/filter_msa_intrinsics.c) + if(${PNG_MIPS_MSA} STREQUAL "on") + add_definitions(-DPNG_MIPS_MSA_OPT=2) + endif() + else() + add_definitions(-DPNG_MIPS_MSA_OPT=0) + endif() +endif() + +else(PNG_HARDWARE_OPTIMIZATIONS) + +# set definitions and sources for arm +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") + add_definitions(-DPNG_ARM_NEON_OPT=0) +endif() + +# set definitions and sources for powerpc +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*") + add_definitions(-DPNG_POWERPC_VSX_OPT=0) +endif() + +# set definitions and sources for intel +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*") + add_definitions(-DPNG_INTEL_SSE_OPT=0) +endif() + +# set definitions and sources for MIPS +if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*") + add_definitions(-DPNG_MIPS_MSA_OPT=0) +endif() + +endif(PNG_HARDWARE_OPTIMIZATIONS) + +# SET LIBNAME +set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) + +# to distinguish between debug and release lib +set(CMAKE_DEBUG_POSTFIX "d") + +include(CheckCSourceCompiles) +option(ld-version-script "Enable linker version script" ON) +if(ld-version-script AND NOT APPLE) + # Check if LD supports linker scripts. + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 { + global: sym; + local: *; +}; + +VERS_2 { + global: sym2; + main; +} VERS_1; +") + set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") + check_c_source_compiles("void sym(void) {} +void sym2(void) {} +int main(void) {return 0;} +" HAVE_LD_VERSION_SCRIPT) + if(NOT HAVE_LD_VERSION_SCRIPT) + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") + check_c_source_compiles("void sym(void) {} +void sym2(void) {} +int main(void) {return 0;} +" HAVE_SOLARIS_LD_VERSION_SCRIPT) + endif() + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) + file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") +endif() + +# Find symbol prefix. Likely obsolete and unnecessary with recent +# toolchains (it's not done in many other projects). +function(symbol_prefix) + set(SYMBOL_PREFIX) + + execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-" + INPUT_FILE /dev/null + OUTPUT_VARIABLE OUT + RESULT_VARIABLE STATUS) + + if(CPP_FAIL) + message(WARNING "Failed to run the C preprocessor") + endif() + + string(REPLACE "\n" ";" OUT "${OUT}") + foreach(line ${OUT}) + string(REGEX MATCH "^PREFIX=" found_match "${line}") + if(found_match) + string(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}") + string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}") + if(found_match) + string(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}") + endif() + set(SYMBOL_PREFIX "${prefix}") + endif() + endforeach() + + message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}") + set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE) +endfunction() + +if(UNIX) + symbol_prefix() +endif() + +find_program(AWK NAMES gawk awk) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +if(NOT AWK OR ANDROID) + # No awk available to generate sources; use pre-built pnglibconf.h + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt + ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) + add_custom_target(genfiles) # Dummy +else() + include(CMakeParseArguments) + # Generate .chk from .out with awk + # generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + function(generate_chk) + set(options) + set(oneValueArgs INPUT OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _GC_INPUT) + message(FATAL_ERROR "generate_chk: Missing INPUT argument") + endif() + if(NOT _GC_OUTPUT) + message(FATAL_ERROR "generate_chk: Missing OUTPUT argument") + endif() + + add_custom_command(OUTPUT "${_GC_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DINPUT=${_GC_INPUT}" + "-DOUTPUT=${_GC_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake" + DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endfunction() + + # Generate .out from .c with awk + # generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + function(generate_out) + set(options) + set(oneValueArgs INPUT OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _GO_INPUT) + message(FATAL_ERROR "generate_out: Missing INPUT argument") + endif() + if(NOT _GO_OUTPUT) + message(FATAL_ERROR "generate_out: Missing OUTPUT argument") + endif() + + add_custom_command(OUTPUT "${_GO_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DINPUT=${_GO_INPUT}" + "-DOUTPUT=${_GO_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake" + DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endfunction() + + # Generate specific source file with awk + # generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + function(generate_source) + set(options) + set(oneValueArgs OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _GSO_OUTPUT) + message(FATAL_ERROR "generate_source: Missing OUTPUT argument") + endif() + + add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DOUTPUT=${_GSO_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" + DEPENDS ${_GSO_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endfunction() + + # Copy file + function(generate_copy source destination) + add_custom_command(OUTPUT "${destination}" + COMMAND "${CMAKE_COMMAND}" -E remove "${destination}" + COMMAND "${CMAKE_COMMAND}" -E copy "${source}" + "${destination}" + DEPENDS "${source}") + endfunction() + + # Generate scripts/pnglibconf.h + generate_source(OUTPUT "scripts/pnglibconf.c" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") + + # Generate pnglibconf.c + generate_source(OUTPUT "pnglibconf.c" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") + + if(PNG_PREFIX) + set(PNGLIBCONF_H_EXTRA_DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst") + set(PNGPREFIX_H_EXTRA_DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") + endif() + + generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") + + # Generate pnglibconf.h + generate_source(OUTPUT "pnglibconf.h" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" + ${PNGLIBCONF_H_EXTRA_DEPENDS}) + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") + + # Generate pngprefix.h + generate_source(OUTPUT "pngprefix.h" + DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS}) + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt") + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") + + generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def") + + add_custom_target(symbol-check DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk") + + generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" + "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") + generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" + "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") + + add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") + add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") + + add_custom_target("genprebuilt" + COMMAND "${CMAKE_COMMAND}" + "-DOUTPUT=scripts/pnglibconf.h.prebuilt" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + + # A single target handles generation of all generated files. If + # they are depended upon separately by multiple targets, this + # confuses parallel make (it would require a separate top-level + # target for each file to track the dependencies properly). + add_custom_target(genfiles DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" + "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" + "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out") +endif(NOT AWK OR ANDROID) + +# OUR SOURCES +set(libpng_public_hdrs + png.h + pngconf.h + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" +) +set(libpng_private_hdrs + pngpriv.h + pngdebug.h + pnginfo.h + pngstruct.h +) +if(AWK AND NOT ANDROID) + list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h") +endif() +set(libpng_sources + ${libpng_public_hdrs} + ${libpng_private_hdrs} + png.c + pngerror.c + pngget.c + pngmem.c + pngpread.c + pngread.c + pngrio.c + pngrtran.c + pngrutil.c + pngset.c + pngtrans.c + pngwio.c + pngwrite.c + pngwtran.c + pngwutil.c + ${libpng_arm_sources} + ${libpng_intel_sources} + ${libpng_mips_sources} + ${libpng_powerpc_sources} +) +set(pngtest_sources + pngtest.c +) +set(pngvalid_sources + contrib/libtests/pngvalid.c +) +set(pngstest_sources + contrib/libtests/pngstest.c +) +set(pngunknown_sources + contrib/libtests/pngunknown.c +) +set(pngimage_sources + contrib/libtests/pngimage.c +) +set(pngfix_sources + contrib/tools/pngfix.c +) +set(png_fix_itxt_sources + contrib/tools/png-fix-itxt.c +) + +if(MSVC) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) +endif() + +if(PNG_DEBUG) + add_definitions(-DPNG_DEBUG) +endif() + +# NOW BUILD OUR TARGET +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) + +unset(PNG_LIB_TARGETS) + +if(PNG_SHARED) + add_library(png SHARED ${libpng_sources}) + set(PNG_LIB_TARGETS png) + set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME}) + add_dependencies(png genfiles) + if(MSVC) + # msvc does not append 'lib' - do it here to have consistent name + set_target_properties(png PROPERTIES PREFIX "lib") + set_target_properties(png PROPERTIES IMPORT_PREFIX "lib") + endif() + target_link_libraries(png ${ZLIB_LIBRARY} ${M_LIBRARY}) + + if(UNIX AND AWK) + if(HAVE_LD_VERSION_SCRIPT) + set_target_properties(png PROPERTIES LINK_FLAGS + "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") + elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT) + set_target_properties(png PROPERTIES LINK_FLAGS + "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") + endif() + endif() +endif() + +if(PNG_STATIC) + # does not work without changing name + set(PNG_LIB_NAME_STATIC png_static) + add_library(png_static STATIC ${libpng_sources}) + add_dependencies(png_static genfiles) + # MSVC doesn't use a different file extension for shared vs. static + # libs. We are able to change OUTPUT_NAME to remove the _static + # for all other platforms. + if(NOT MSVC) + set_target_properties(png_static PROPERTIES + OUTPUT_NAME "${PNG_LIB_NAME}" + CLEAN_DIRECT_OUTPUT 1) + else() + set_target_properties(png_static PROPERTIES + OUTPUT_NAME "${PNG_LIB_NAME}_static" + CLEAN_DIRECT_OUTPUT 1) + endif() + list(APPEND PNG_LIB_TARGETS png_static) + if(MSVC) + # msvc does not append 'lib' - do it here to have consistent name + set_target_properties(png_static PROPERTIES PREFIX "lib") + endif() + target_link_libraries(png_static ${ZLIB_LIBRARY} ${M_LIBRARY}) +endif() + +if(PNG_FRAMEWORK) + set(PNG_LIB_NAME_FRAMEWORK png_framework) + add_library(png_framework SHARED ${libpng_sources}) + add_dependencies(png_framework genfiles) + list(APPEND PNG_LIB_TARGETS png_framework) + set_target_properties(png_framework PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION ${PNGLIB_VERSION} + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR} + MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION} + MACOSX_FRAMEWORK_IDENTIFIER org.libpng.libpng + XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" + PUBLIC_HEADER "${libpng_public_hdrs}" + OUTPUT_NAME png) + target_link_libraries(png_framework ${ZLIB_LIBRARY} ${M_LIBRARY}) +endif() + +if(NOT PNG_LIB_TARGETS) + message(SEND_ERROR + "No library variant selected to build. " + "Please enable at least one of the following options: " + "PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK") +endif() + +if(PNG_SHARED AND WIN32) + set_target_properties(png PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) +endif() + +function(png_add_test) + set(options) + set(oneValueArgs NAME COMMAND) + set(multiValueArgs OPTIONS FILES) + cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT _PAT_NAME) + message(FATAL_ERROR "png_add_test: Missing NAME argument") + endif() + if(NOT _PAT_COMMAND) + message(FATAL_ERROR "png_add_test: Missing COMMAND argument") + endif() + + set(TEST_OPTIONS "${_PAT_OPTIONS}") + set(TEST_FILES "${_PAT_FILES}") + + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" @ONLY) + add_test(NAME "${_PAT_NAME}" + COMMAND "${CMAKE_COMMAND}" + "-DLIBPNG=$" + "-DTEST_COMMAND=$" + -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake") +endfunction() + +if(PNG_TESTS AND PNG_SHARED) + # Find test PNG files by globbing, but sort lists to ensure + # consistency between different filesystems. + file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png") + list(SORT PNGSUITE_PNGS) + file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png") + list(SORT TEST_PNGS) + + set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png") + + add_executable(pngtest ${pngtest_sources}) + target_link_libraries(pngtest png) + + png_add_test(NAME pngtest COMMAND pngtest FILES "${PNGTEST_PNG}") + + add_executable(pngvalid ${pngvalid_sources}) + target_link_libraries(pngvalid png) + + png_add_test(NAME pngvalid-gamma-16-to-8 + COMMAND pngvalid OPTIONS --gamma-16-to-8) + png_add_test(NAME pngvalid-gamma-alpha-mode + COMMAND pngvalid OPTIONS --gamma-alpha-mode) + png_add_test(NAME pngvalid-gamma-background + COMMAND pngvalid OPTIONS --gamma-background) + png_add_test(NAME pngvalid-gamma-expand16-alpha-mode + COMMAND pngvalid OPTIONS --gamma-alpha-mode --expand16) + png_add_test(NAME pngvalid-gamma-expand16-background + COMMAND pngvalid OPTIONS --gamma-background --expand16) + png_add_test(NAME pngvalid-gamma-expand16-transform + COMMAND pngvalid OPTIONS --gamma-transform --expand16) + png_add_test(NAME pngvalid-gamma-sbit + COMMAND pngvalid OPTIONS --gamma-sbit) + png_add_test(NAME pngvalid-gamma-threshold + COMMAND pngvalid OPTIONS --gamma-threshold) + png_add_test(NAME pngvalid-gamma-transform + COMMAND pngvalid OPTIONS --gamma-transform) + png_add_test(NAME pngvalid-progressive-interlace-standard + COMMAND pngvalid OPTIONS --standard --progressive-read --interlace) + png_add_test(NAME pngvalid-progressive-size + COMMAND pngvalid OPTIONS --size --progressive-read) + png_add_test(NAME pngvalid-progressive-standard + COMMAND pngvalid OPTIONS --standard --progressive-read) + png_add_test(NAME pngvalid-standard + COMMAND pngvalid OPTIONS --standard) + png_add_test(NAME pngvalid-transform + COMMAND pngvalid OPTIONS --transform) + + add_executable(pngstest ${pngstest_sources}) + target_link_libraries(pngstest png) + + foreach(gamma_type 1.8 linear none sRGB) + foreach(alpha_type none alpha) + set(PNGSTEST_FILES) + foreach(test_png ${TEST_PNGS}) + string(REGEX MATCH ".*-linear[-.].*" TEST_PNG_LINEAR "${test_png}") + string(REGEX MATCH ".*-sRGB[-.].*" TEST_PNG_SRGB "${test_png}") + string(REGEX MATCH ".*-1.8[-.].*" TEST_PNG_G18 "${test_png}") + string(REGEX MATCH ".*-alpha-.*" TEST_PNG_ALPHA "${test_png}") + + set(TEST_PNG_VALID TRUE) + + if(TEST_PNG_ALPHA) + if(NOT "${alpha_type}" STREQUAL "alpha") + set(TEST_PNG_VALID FALSE) + endif() + else() + if("${alpha_type}" STREQUAL "alpha") + set(TEST_PNG_VALID FALSE) + endif() + endif() + + if(TEST_PNG_LINEAR) + if(NOT "${gamma_type}" STREQUAL "linear") + set(TEST_PNG_VALID FALSE) + endif() + elseif(TEST_PNG_SRGB) + if(NOT "${gamma_type}" STREQUAL "sRGB") + set(TEST_PNG_VALID FALSE) + endif() + elseif(TEST_PNG_G18) + if(NOT "${gamma_type}" STREQUAL "1.8") + set(TEST_PNG_VALID FALSE) + endif() + else() + if(NOT "${gamma_type}" STREQUAL "none") + set(TEST_PNG_VALID FALSE) + endif() + endif() + + if(TEST_PNG_VALID) + list(APPEND PNGSTEST_FILES "${test_png}") + endif() + endforeach() + # Should already be sorted, but sort anyway to be certain. + list(SORT PNGSTEST_FILES) + png_add_test(NAME pngstest-${gamma_type}-${alpha_type} + COMMAND pngstest + OPTIONS --tmpfile "${gamma_type}-${alpha_type}-" --log + FILES ${PNGSTEST_FILES}) + endforeach() + endforeach() + + add_executable(pngunknown ${pngunknown_sources}) + target_link_libraries(pngunknown png) + + png_add_test(NAME pngunknown-discard COMMAND pngunknown OPTIONS --strict default=discard FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-IDAT COMMAND pngunknown OPTIONS --strict default=discard IDAT=save FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-if-safe COMMAND pngunknown OPTIONS --strict default=if-safe FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-sAPI COMMAND pngunknown OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-save COMMAND pngunknown OPTIONS --strict default=save FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-sTER COMMAND pngunknown OPTIONS --strict sTER=if-safe FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-vpAg COMMAND pngunknown OPTIONS --strict vpAg=if-safe FILES "${PNGTEST_PNG}") + + add_executable(pngimage ${pngimage_sources}) + target_link_libraries(pngimage png) + + png_add_test(NAME pngimage-quick COMMAND pngimage OPTIONS --list-combos --log FILES ${PNGSUITE_PNGS}) + png_add_test(NAME pngimage-full COMMAND pngimage OPTIONS --exhaustive --list-combos --log FILES ${PNGSUITE_PNGS}) +endif() + +if(PNG_SHARED) + add_executable(pngfix ${pngfix_sources}) + target_link_libraries(pngfix png) + set(PNG_BIN_TARGETS pngfix) + + add_executable(png-fix-itxt ${png_fix_itxt_sources}) + target_link_libraries(png-fix-itxt ${ZLIB_LIBRARY} ${M_LIBRARY}) + list(APPEND PNG_BIN_TARGETS png-fix-itxt) +endif() + +# Set a variable with CMake code which: +# Creates a symlink from src to dest (if possible) or alternatively +# copies if different. +include(CMakeParseArguments) + +function(create_symlink DEST_FILE) + + cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN}) + + if(NOT S_TARGET AND NOT S_FILE) + message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument") + endif() + + if(S_TARGET AND S_FILE) + message(FATAL_ERROR "create_symlink: Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; can only have one.") + endif() + + if(S_FILE) + # If we don't need to symlink something that's coming from a build target, + # we can go ahead and symlink/copy at configure time. + if(CMAKE_HOST_WIN32 AND NOT CYGWIN) + execute_process( + COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + else() + execute_process( + COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endif() + endif() + + if(S_TARGET) + # We need to use generator expressions, which can be a bit tricky, so for + # simplicity make the symlink a POST_BUILD step and use the TARGET + # signature of add_custom_command. + if(CMAKE_HOST_WIN32 AND NOT CYGWIN) + add_custom_command(TARGET ${S_TARGET} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_if_different $ $/${DEST_FILE}) + else() + add_custom_command(TARGET ${S_TARGET} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E create_symlink $ $/${DEST_FILE}) + endif() + endif() + +endfunction() + +# Create source generation scripts. +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY) + +# libpng is a library so default to 'lib' +if(NOT DEFINED CMAKE_INSTALL_LIBDIR) + set(CMAKE_INSTALL_LIBDIR lib) +endif() + +# CREATE PKGCONFIG FILES +# We use the same files like ./configure, so we have to set its vars. +# Only do this on Windows for Cygwin - the files don't make much sense outside +# of a UNIX look-alike. +if(NOT WIN32 OR CYGWIN OR MINGW) + set(prefix ${CMAKE_INSTALL_PREFIX}) + set(exec_prefix ${CMAKE_INSTALL_PREFIX}) + set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) + set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) + set(LIBS "-lz -lm") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY) + create_symlink(libpng.pc FILE ${PNGLIB_NAME}.pc) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in + ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY) + create_symlink(libpng-config FILE ${PNGLIB_NAME}-config) +endif() + +# SET UP LINKS +if(PNG_SHARED) + set_target_properties(png PROPERTIES +# VERSION 16.${PNGLIB_RELEASE}.1.6.37 + VERSION 16.${PNGLIB_RELEASE}.0 + SOVERSION 16 + CLEAN_DIRECT_OUTPUT 1) +endif() + +# INSTALL +if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) + install(TARGETS ${PNG_LIB_TARGETS} + EXPORT libpng + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + if(PNG_SHARED) + # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin + if(CYGWIN OR MINGW) + create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png) + install(FILES $/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() + + if(NOT WIN32) + create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png) + install(FILES $/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() + endif() + + if(PNG_STATIC) + if(NOT WIN32 OR CYGWIN OR MINGW) + create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static) + install(FILES $/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() + endif() +endif() + +if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) + install(FILES ${libpng_public_hdrs} DESTINATION include) + install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME}) +endif() +if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL) + if(NOT WIN32 OR CYGWIN OR MINGW) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin) + endif() +endif() + +if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL) + install(TARGETS ${PNG_BIN_TARGETS} + RUNTIME DESTINATION bin) +endif() + +if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL) + # Install man pages + if(NOT PNG_MAN_DIR) + set(PNG_MAN_DIR "share/man") + endif() + install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3) + install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5) + # Install pkg-config files + if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config + DESTINATION bin) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config + DESTINATION bin) + endif() +endif() + +# Create an export file that CMake users can include() to import our targets. +if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL) + install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake) +endif() + +# what's with libpng-manual.txt and all the extra files? + +# UNINSTALL +# do we need this? + +# DIST +# do we need this? + +# to create msvc import lib for mingw compiled shared lib +# pexports libpng.dll > libpng.def +# lib /def:libpng.def /machine:x86 diff --git a/thirdparty/libpng-1.6.37/INSTALL b/thirdparty/libpng-1.6.37/INSTALL new file mode 100644 index 0000000..4c17022 --- /dev/null +++ b/thirdparty/libpng-1.6.37/INSTALL @@ -0,0 +1,465 @@ + + Installing libpng + +Contents + + I. Simple installation + II. Rebuilding the configure scripts + III. Using scripts/makefile* + IV. Using cmake + V. Directory structure + VI. Building with project files + VII. Building with makefiles + VIII. Configuring libpng for 16-bit platforms + IX. Configuring for DOS + X. Configuring for Medium Model + XI. Prepending a prefix to exported symbols + XII. Configuring for compiler xxx: + XIII. Removing unwanted object code + XIV. Enabling or disabling hardware optimizations + XV. Changes to the build and configuration of libpng in libpng-1.5.x + XVI. Setjmp/longjmp issues + XVII. Common linking failures + XVIII. Other sources of information about libpng + +I. Simple installation + +On Unix/Linux and similar systems, you can simply type + + ./configure [--prefix=/path] + make check + make install + +and ignore the rest of this document. "/path" is the path to the directory +where you want to install the libpng "lib", "include", and "bin" +subdirectories. + +If you downloaded a GIT clone, you will need to run ./autogen.sh before +running ./configure, to create "configure" and "Makefile.in" which are +not included in the GIT repository. + +Note that "configure" is only included in the "*.tar" distributions and not +in the "*.zip" or "*.7z" distributions. If you downloaded one of those +distributions, see "Building with project files" or "Building with makefiles", +below. + +II. Rebuilding the configure scripts + +If configure does not work on your system, or if you have a need to +change configure.ac or Makefile.am, and you have a reasonably +up-to-date set of tools, running ./autogen.sh in a git clone before +running ./configure may fix the problem. To be really sure that you +aren't using any of the included pre-built scripts, especially if you +are building from a tar distribution instead of a git distribution, +do this: + + ./configure --enable-maintainer-mode + make maintainer-clean + ./autogen.sh --maintainer --clean + ./autogen.sh --maintainer + ./configure [--prefix=/path] [other options] + make + make install + make check + +III. Using scripts/makefile* + +Instead, you can use one of the custom-built makefiles in the +"scripts" directory + + cp scripts/pnglibconf.h.prebuilt pnglibconf.h + cp scripts/makefile.system makefile + make test + make install + +The files that are presently available in the scripts directory +are listed and described in scripts/README.txt. + +Or you can use one of the "projects" in the "projects" directory. + +Before installing libpng, you must first install zlib, if it +is not already on your system. zlib can usually be found +wherever you got libpng; otherwise go to https://zlib.net/. You can +place zlib in the same directory as libpng or in another directory. + +If your system already has a preinstalled zlib you will still need +to have access to the zlib.h and zconf.h include files that +correspond to the version of zlib that's installed. + +If you wish to test with a particular zlib that is not first in the +standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS, +and LD_LIBRARY_PATH in your environment before running "make test" +or "make distcheck": + + ZLIBLIB=/path/to/lib export ZLIBLIB + ZLIBINC=/path/to/include export ZLIBINC + CPPFLAGS="-I$ZLIBINC" export CPPFLAGS + LDFLAGS="-L$ZLIBLIB" export LDFLAGS + LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH + +If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC +in your environment and type + + make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test + +IV. Using cmake + +If you want to use "cmake" (see www.cmake.org), type + + cmake . -DCMAKE_INSTALL_PREFIX=/path + make + make install + +As when using the simple configure method described above, "/path" points to +the installation directory where you want to put the libpng "lib", "include", +and "bin" subdirectories. + +V. Directory structure + +You can rename the directories that you downloaded (they +might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8" +or "zlib128") so that you have directories called "zlib" and "libpng". + +Your directory structure should look like this: + + .. (the parent directory) + libpng (this directory) + INSTALL (this file) + README + *.h, *.c => libpng source files + CMakeLists.txt => "cmake" script + configuration files: + configure.ac, configure, Makefile.am, Makefile.in, + autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in, + libpng-config.in, aclocal.m4, config.h.in, config.sub, + depcomp, install-sh, mkinstalldirs, test-pngtest.sh + contrib + arm-neon, conftest, examples, gregbook, libtests, pngminim, + pngminus, pngsuite, tools, visupng + projects + cbuilder5, owatcom, visualc71, vstudio, xcode + scripts + makefile.* + *.def (module definition files) + etc. + pngtest.png + etc. + zlib + README, *.h, *.c contrib, etc. + +If the line endings in the files look funny, you may wish to get the other +distribution of libpng. It is available in both tar.gz (UNIX style line +endings) and zip (DOS style line endings) formats. + +VI. Building with project files + +If you are building libpng with MSVC, you can enter the +libpng projects\visualc71 or vstudio directory and follow the instructions +in README.txt. + +Otherwise enter the zlib directory and follow the instructions in zlib/README, +then come back here and run "configure" or choose the appropriate +makefile.sys in the scripts directory. + +VII. Building with makefiles + +Copy the file (or files) that you need from the +scripts directory into this directory, for example + +MSDOS example: + + copy scripts\makefile.msc makefile + copy scripts\pnglibconf.h.prebuilt pnglibconf.h + +UNIX example: + + cp scripts/makefile.std makefile + cp scripts/pnglibconf.h.prebuilt pnglibconf.h + +Read the makefile to see if you need to change any source or +target directories to match your preferences. + +Then read pnglibconf.dfa to see if you want to make any configuration +changes. + +Then just run "make" which will create the libpng library in +this directory and "make test" which will run a quick test that reads +the "pngtest.png" file and writes a "pngout.png" file that should be +identical to it. Look for "9782 zero samples" in the output of the +test. For more confidence, you can run another test by typing +"pngtest pngnow.png" and looking for "289 zero samples" in the output. +Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare +your output with the result shown in contrib/pngsuite/README. + +Most of the makefiles will allow you to run "make install" to +put the library in its final resting place (if you want to +do that, run "make install" in the zlib directory first if necessary). +Some also allow you to run "make test-installed" after you have +run "make install". + +VIII. Configuring libpng for 16-bit platforms + +You will want to look into zconf.h to tell zlib (and thus libpng) that +it cannot allocate more than 64K at a time. Even if you can, the memory +won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. + +IX. Configuring for DOS + +For DOS users who only have access to the lower 640K, you will +have to limit zlib's memory usage via a png_set_compression_mem_level() +call. See zlib.h or zconf.h in the zlib library for more information. + +X. Configuring for Medium Model + +Libpng's support for medium model has been tested on most of the popular +compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets +defined, and FAR gets defined to far in pngconf.h, and you should be +all set. Everything in the library (except for zlib's structure) is +expecting far data. You must use the typedefs with the p or pp on +the end for pointers (or at least look at them and be careful). Make +note that the rows of data are defined as png_bytepp, which is +an "unsigned char far * far *". + +XI. Prepending a prefix to exported symbols + +Starting with libpng-1.6.0, you can configure libpng (when using the +"configure" script) to prefix all exported symbols by means of the +configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any +string beginning with a letter and containing only uppercase +and lowercase letters, digits, and the underscore (i.e., a C language +identifier). This creates a set of macros in pnglibconf.h, so this is +transparent to applications; their function calls get transformed by +the macros to use the modified names. + +XII. Configuring for compiler xxx: + +All includes for libpng are in pngconf.h. If you need to add, change +or delete an include, this is the place to do it. +The includes that are not needed outside libpng are placed in pngpriv.h, +which is only used by the routines inside libpng itself. +The files in libpng proper only include pngpriv.h and png.h, which +in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h. +As of libpng-1.5.0, pngpriv.h also includes three other private header +files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material +that previously appeared in the public headers. + +XIII. Removing unwanted object code + +There are a bunch of #define's in pngconf.h that control what parts of +libpng are compiled. All the defines end in _SUPPORTED. If you are +never going to use a capability, you can change the #define to #undef +before recompiling libpng and save yourself code and data space, or +you can turn off individual capabilities with defines that begin with +"PNG_NO_". + +In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead. + +You can also turn all of the transforms and ancillary chunk capabilities +off en masse with compiler directives that define +PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, +or all four, along with directives to turn on any of the capabilities that +you do want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the +extra transformations but still leave the library fully capable of reading +and writing PNG files with all known public chunks. Use of the +PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library +that is incapable of reading or writing ancillary chunks. If you are +not using the progressive reading capability, you can turn that off +with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING +capability, which you'll still have). + +All the reading and writing specific code are in separate files, so the +linker should only grab the files it needs. However, if you want to +make sure, or if you are building a stand alone library, all the +reading files start with "pngr" and all the writing files start with "pngw". +The files that don't match either (like png.c, pngtrans.c, etc.) +are used for both reading and writing, and always need to be included. +The progressive reader is in pngpread.c + +If you are creating or distributing a dynamically linked library (a .so +or DLL file), you should not remove or disable any parts of the library, +as this will cause applications linked with different versions of the +library to fail if they call functions not available in your library. +The size of the library itself should not be an issue, because only +those sections that are actually used will be loaded into memory. + +XIV. Enabling or disabling hardware optimizations + +Certain hardware capabilities, such as the Intel SSE instructions, +are normally detected at run time. Enable them with configure options +such as one of + + --enable-arm-neon=yes + --enable-mips-msa=yes + --enable-intel-sse=yes + --enable-powerpc-vsx=yes + +or enable them all at once with + + --enable-hardware-optimizations=yes + +or, if you are not using "configure", you can use one +or more of + + CPPFLAGS += "-DPNG_ARM_NEON" + CPPFLAGS += "-DPNG_MIPS_MSA" + CPPFLAGS += "-DPNG_INTEL_SSE" + CPPFLAGS += "-DPNG_POWERPC_VSX" + +See for example scripts/makefile.linux-opt + +If you wish to avoid using them, +you can disable them via the configure option + + --disable-hardware-optimizations + +to disable them all, or + + --enable-intel-sse=no + +to disable a particular one, +or via compiler-command options such as + + CPPFLAGS += "-DPNG_ARM_NEON_OPT=0, -DPNG_MIPS_MSA_OPT=0, + -DPNG_INTEL_SSE_OPT=0, -DPNG_POWERPC_VSX_OPT=0" + +If you are using cmake, hardware optimizations are "on" +by default. To disable them, use + + cmake . -DPNG_ARM_NEON=no -DPNG_INTEL_SSE=no \ + -DPNG_MIPS_MSA=no -DPNG_POWERPC_VSX=no + +or disable them all at once with + + cmake . -DPNG_HARDWARE_OPTIMIZATIONS=no + +XV. Changes to the build and configuration of libpng in libpng-1.5.x + +Details of internal changes to the library code can be found in the CHANGES +file and in the GIT repository logs. These will be of no concern to the vast +majority of library users or builders; however, the few who configure libpng +to a non-default feature set may need to change how this is done. + +There should be no need for library builders to alter build scripts if +these use the distributed build support - configure or the makefiles - +however, users of the makefiles may care to update their build scripts +to build pnglibconf.h where the corresponding makefile does not do so. + +Building libpng with a non-default configuration has changed completely. +The old method using pngusr.h should still work correctly even though the +way pngusr.h is used in the build has been changed; however, library +builders will probably want to examine the changes to take advantage of +new capabilities and to simplify their build system. + +A. Specific changes to library configuration capabilities + +The exact mechanism used to control attributes of API functions has +changed. A single set of operating system independent macro definitions +is used and operating system specific directives are defined in +pnglibconf.h + +As part of this the mechanism used to choose procedure call standards on +those systems that allow a choice has been changed. At present this only +affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems +running on Intel processors. As before, PNGAPI is defined where required +to control the exported API functions; however, two new macros, PNGCBAPI +and PNGCAPI, are used instead for callback functions (PNGCBAPI) and +(PNGCAPI) for functions that must match a C library prototype (currently +only png_longjmp_ptr, which must match the C longjmp function.) The new +approach is documented in pngconf.h + +Despite these changes, libpng 1.5.0 only supports the native C function +calling standard on those platforms tested so far ("__cdecl" on Microsoft +Windows). This is because the support requirements for alternative +calling conventions seem to no longer exist. Developers who find it +necessary to set PNG_API_RULE to 1 should advise the mailing list +(png-mng-implement) of this and library builders who use Openwatcom and +therefore set PNG_API_RULE to 2 should also contact the mailing list. + +B. Changes to the configuration mechanism + +Prior to libpng-1.5.0 library builders who needed to configure libpng +had either to modify the exported pngconf.h header file to add system +specific configuration or had to write feature selection macros into +pngusr.h and cause this to be included into pngconf.h by defining +PNG_USER_CONFIG. The latter mechanism had the disadvantage that an +application built without PNG_USER_CONFIG defined would see the +unmodified, default, libpng API and thus would probably fail to link. + +These mechanisms still work in the configure build and in any makefile +build that builds pnglibconf.h, although the feature selection macros +have changed somewhat as described above. In 1.5.0, however, pngusr.h is +processed only once, at the time the exported header file pnglibconf.h is +built. pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored +after the build of pnglibconf.h and it is never included in an application +build. + +The formerly used alternative of adding a list of feature macros to the +CPPFLAGS setting in the build also still works; however, the macros will be +copied to pnglibconf.h and this may produce macro redefinition warnings +when the individual C files are compiled. + +All configuration now only works if pnglibconf.h is built from +scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan +(the original author of awk) maintains C source code of that awk and this +and all known later implementations (often called by subtly different +names - nawk and gawk for example) are adequate to build pnglibconf.h. +The Sun Microsystems (now Oracle) program 'awk' is an earlier version +and does not work; this may also apply to other systems that have a +functioning awk called 'nawk'. + +Configuration options are now documented in scripts/pnglibconf.dfa. This +file also includes dependency information that ensures a configuration is +consistent; that is, if a feature is switched off, dependent features are +also switched off. As a recommended alternative to using feature macros in +pngusr.h a system builder may also define equivalent options in pngusr.dfa +(or, indeed, any file) and add that to the configuration by setting +DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate +how to do this, and also illustrate a case where pngusr.h is still required. + +After you have built libpng, the definitions that were recorded in +pnglibconf.h are available to your application (pnglibconf.h is included +in png.h and gets installed alongside png.h and pngconf.h in your +$PREFIX/include directory). Do not edit pnglibconf.h after you have built +libpng, because than the settings would not accurately reflect the settings +that were used to build libpng. + +XVI. Setjmp/longjmp issues + +Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp() +is known to be not thread-safe on some platforms and we don't know of +any platform where it is guaranteed to be thread-safe. Therefore, if +your application is going to be using multiple threads, you should +configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with +-DPNG_NO_SETJMP on your compile line, or with + + #undef PNG_SETJMP_SUPPORTED + +in your pnglibconf.h or pngusr.h. + +Starting with libpng-1.6.0, the library included a "simplified API". +This requires setjmp/longjmp, so you must either build the library +with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED +and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined. + +XVII. Common linking failures + +If your application fails to find libpng or zlib entries while linking: + + Be sure "-lz" appears after "-lpng" on your linking command. + + Be sure you have built libpng, zlib, and your application for the + same platform (e.g., 32-bit or 64-bit). + + If you are using the vstudio project, observe the WARNING in + project/vstudio/README.txt. + +XVIII. Other sources of information about libpng: + +Further information can be found in the README and libpng-manual.txt +files, in the individual makefiles, in png.h, and the manual pages +libpng.3 and png.5. + +Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson +This document is released under the libpng license. +For conditions of distribution and use, see the disclaimer +and license in png.h. diff --git a/thirdparty/libpng-1.6.37/LICENSE b/thirdparty/libpng-1.6.37/LICENSE new file mode 100644 index 0000000..e0c5b53 --- /dev/null +++ b/thirdparty/libpng-1.6.37/LICENSE @@ -0,0 +1,134 @@ +COPYRIGHT NOTICE, DISCLAIMER, and LICENSE +========================================= + +PNG Reference Library License version 2 +--------------------------------------- + + * Copyright (c) 1995-2019 The PNG Reference Library Authors. + * Copyright (c) 2018-2019 Cosmin Truta. + * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. + * Copyright (c) 1996-1997 Andreas Dilger. + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. + +The software is supplied "as is", without warranty of any kind, +express or implied, including, without limitation, the warranties +of merchantability, fitness for a particular purpose, title, and +non-infringement. In no event shall the Copyright owners, or +anyone distributing the software, be liable for any damages or +other liability, whether in contract, tort or otherwise, arising +from, out of, or in connection with the software, or the use or +other dealings in the software, even if advised of the possibility +of such damage. + +Permission is hereby granted to use, copy, modify, and distribute +this software, or portions hereof, for any purpose, without fee, +subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you + use this software in a product, an acknowledgment in the product + documentation would be appreciated, but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. + + +PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35) +----------------------------------------------------------------------- + +libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are +Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are +derived from libpng-1.0.6, and are distributed according to the same +disclaimer and license as libpng-1.0.6 with the following individuals +added to the list of Contributing Authors: + + Simon-Pierre Cadieux + Eric S. Raymond + Mans Rullgard + Cosmin Truta + Gilles Vollant + James Yu + Mandar Sahastrabuddhe + Google Inc. + Vadim Barkov + +and with the following additions to the disclaimer: + + There is no warranty against interference with your enjoyment of + the library or against infringement. There is no warranty that our + efforts or the library will fulfill any of your particular purposes + or needs. This library is provided with all faults, and the entire + risk of satisfactory quality, performance, accuracy, and effort is + with the user. + +Some files in the "contrib" directory and some configure-generated +files that are distributed with libpng have other copyright owners, and +are released under other open source licenses. + +libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are +Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from +libpng-0.96, and are distributed according to the same disclaimer and +license as libpng-0.96, with the following individuals added to the +list of Contributing Authors: + + Tom Lane + Glenn Randers-Pehrson + Willem van Schaik + +libpng versions 0.89, June 1996, through 0.96, May 1997, are +Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, +and are distributed according to the same disclaimer and license as +libpng-0.88, with the following individuals added to the list of +Contributing Authors: + + John Bowler + Kevin Bracey + Sam Bushell + Magnus Holmgren + Greg Roelofs + Tom Tanner + +Some files in the "scripts" directory have other copyright owners, +but are released under this license. + +libpng versions 0.5, May 1995, through 0.88, January 1996, are +Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. + +For the purposes of this copyright and license, "Contributing Authors" +is defined as the following set of individuals: + + Andreas Dilger + Dave Martindale + Guy Eric Schalnat + Paul Schmidt + Tim Wegner + +The PNG Reference Library is supplied "AS IS". The Contributing +Authors and Group 42, Inc. disclaim all warranties, expressed or +implied, including, without limitation, the warranties of +merchantability and of fitness for any purpose. The Contributing +Authors and Group 42, Inc. assume no liability for direct, indirect, +incidental, special, exemplary, or consequential damages, which may +result from the use of the PNG Reference Library, even if advised of +the possibility of such damage. + +Permission is hereby granted to use, copy, modify, and distribute this +source code, or portions hereof, for any purpose, without fee, subject +to the following restrictions: + + 1. The origin of this source code must not be misrepresented. + + 2. Altered versions must be plainly marked as such and must not + be misrepresented as being the original source. + + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. + +The Contributing Authors and Group 42, Inc. specifically permit, +without fee, and encourage the use of this source code as a component +to supporting the PNG file format in commercial products. If you use +this source code in a product, acknowledgment is not required but would +be appreciated. diff --git a/thirdparty/libpng-1.6.37/Makefile b/thirdparty/libpng-1.6.37/Makefile new file mode 100644 index 0000000..0127ebd --- /dev/null +++ b/thirdparty/libpng-1.6.37/Makefile @@ -0,0 +1,2428 @@ +# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994-2018 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + +# Makefile.am, the source file for Makefile.in (and hence Makefile), is +# +# Copyright (c) 2018 Cosmin Truta +# Copyright (c) 2004-2016 Glenn Randers-Pehrson +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + + + + + + +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/libpng +pkglibdir = $(libdir)/libpng +pkglibexecdir = $(libexecdir)/libpng +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = x86_64-pc-linux-gnu +host_triplet = i586-pc-msdosdjgpp +check_PROGRAMS = pngtest$(EXEEXT) pngunknown$(EXEEXT) \ + pngstest$(EXEEXT) pngvalid$(EXEEXT) pngimage$(EXEEXT) \ + pngcp$(EXEEXT) $(am__EXEEXT_1) +#am__append_1 = timepng +bin_PROGRAMS = pngfix$(EXEEXT) png-fix-itxt$(EXEEXT) +#am__append_2 = arm/arm_init.c\ +# arm/filter_neon.S arm/filter_neon_intrinsics.c \ +# arm/palette_neon_intrinsics.c + +am__append_3 = mips/mips_init.c\ + mips/filter_msa_intrinsics.c + +am__append_4 = intel/intel_init.c\ + intel/filter_sse2_intrinsics.c + +am__append_5 = powerpc/powerpc_init.c\ + powerpc/filter_vsx_intrinsics.c + + +# Versioned symbols and restricted exports +#am__append_6 = -Wl,-M -Wl,libpng.vers +am__append_7 = -Wl,--version-script=libpng.vers +# Only restricted exports when possible +#am__append_8 = -export-symbols libpng.sym +#am__append_9 = -DPNG_PREFIX='' +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/scripts/libtool.m4 \ + $(top_srcdir)/scripts/ltoptions.m4 \ + $(top_srcdir)/scripts/ltsugar.m4 \ + $(top_srcdir)/scripts/ltversion.m4 \ + $(top_srcdir)/scripts/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(pkginclude_HEADERS) $(am__DIST_COMMON) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = libpng.pc libpng-config +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" \ + "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man3dir)" \ + "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(pkgconfigdir)" \ + "$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)" +#am__EXEEXT_1 = timepng$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +LTLIBRARIES = $(lib_LTLIBRARIES) +libpng16_la_LIBADD = +am__libpng16_la_SOURCES_DIST = png.c \ + pngerror.c pngget.c pngmem.c pngpread.c pngread.c pngrio.c \ + pngrtran.c pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c \ + pngwtran.c pngwutil.c png.h pngconf.h pngdebug.h pnginfo.h \ + pngpriv.h pngstruct.h pngusr.dfa arm/arm_init.c \ + arm/filter_neon.S arm/filter_neon_intrinsics.c \ + arm/palette_neon_intrinsics.c mips/mips_init.c \ + mips/filter_msa_intrinsics.c intel/intel_init.c \ + intel/filter_sse2_intrinsics.c powerpc/powerpc_init.c \ + powerpc/filter_vsx_intrinsics.c +am__dirstamp = $(am__leading_dot)dirstamp +#am__objects_1 = arm/arm_init.lo arm/filter_neon.lo \ +# arm/filter_neon_intrinsics.lo \ +# arm/palette_neon_intrinsics.lo +am__objects_2 = mips/mips_init.lo \ + mips/filter_msa_intrinsics.lo +am__objects_3 = intel/intel_init.lo \ + intel/filter_sse2_intrinsics.lo +am__objects_4 = powerpc/powerpc_init.lo \ + powerpc/filter_vsx_intrinsics.lo +am_libpng16_la_OBJECTS = png.lo pngerror.lo \ + pngget.lo pngmem.lo pngpread.lo pngread.lo pngrio.lo \ + pngrtran.lo pngrutil.lo pngset.lo pngtrans.lo pngwio.lo \ + pngwrite.lo pngwtran.lo pngwutil.lo $(am__objects_1) \ + $(am__objects_2) $(am__objects_3) $(am__objects_4) +nodist_libpng16_la_OBJECTS = +libpng16_la_OBJECTS = \ + $(am_libpng16_la_OBJECTS) \ + $(nodist_libpng16_la_OBJECTS) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +am__v_lt_1 = +libpng16_la_LINK = $(LIBTOOL) $(AM_V_lt) \ + --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ + $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libpng16_la_LDFLAGS) $(LDFLAGS) -o \ + $@ +am_png_fix_itxt_OBJECTS = contrib/tools/png-fix-itxt.$(OBJEXT) +png_fix_itxt_OBJECTS = $(am_png_fix_itxt_OBJECTS) +png_fix_itxt_LDADD = $(LDADD) +am_pngcp_OBJECTS = contrib/tools/pngcp.$(OBJEXT) +pngcp_OBJECTS = $(am_pngcp_OBJECTS) +pngcp_DEPENDENCIES = libpng16.la +am_pngfix_OBJECTS = contrib/tools/pngfix.$(OBJEXT) +pngfix_OBJECTS = $(am_pngfix_OBJECTS) +pngfix_DEPENDENCIES = libpng16.la +am_pngimage_OBJECTS = contrib/libtests/pngimage.$(OBJEXT) +pngimage_OBJECTS = $(am_pngimage_OBJECTS) +pngimage_DEPENDENCIES = libpng16.la +am_pngstest_OBJECTS = contrib/libtests/pngstest.$(OBJEXT) +pngstest_OBJECTS = $(am_pngstest_OBJECTS) +pngstest_DEPENDENCIES = libpng16.la +am_pngtest_OBJECTS = pngtest.$(OBJEXT) +pngtest_OBJECTS = $(am_pngtest_OBJECTS) +pngtest_DEPENDENCIES = libpng16.la +am_pngunknown_OBJECTS = contrib/libtests/pngunknown.$(OBJEXT) +pngunknown_OBJECTS = $(am_pngunknown_OBJECTS) +pngunknown_DEPENDENCIES = libpng16.la +am_pngvalid_OBJECTS = contrib/libtests/pngvalid.$(OBJEXT) +pngvalid_OBJECTS = $(am_pngvalid_OBJECTS) +pngvalid_DEPENDENCIES = libpng16.la +am_timepng_OBJECTS = contrib/libtests/timepng.$(OBJEXT) +timepng_OBJECTS = $(am_timepng_OBJECTS) +timepng_DEPENDENCIES = libpng16.la +SCRIPTS = $(bin_SCRIPTS) +AM_V_P = $(am__v_P_$(V)) +am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY)) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I. +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/png.Plo ./$(DEPDIR)/pngerror.Plo \ + ./$(DEPDIR)/pngget.Plo ./$(DEPDIR)/pngmem.Plo \ + ./$(DEPDIR)/pngpread.Plo ./$(DEPDIR)/pngread.Plo \ + ./$(DEPDIR)/pngrio.Plo ./$(DEPDIR)/pngrtran.Plo \ + ./$(DEPDIR)/pngrutil.Plo ./$(DEPDIR)/pngset.Plo \ + ./$(DEPDIR)/pngtest.Po ./$(DEPDIR)/pngtrans.Plo \ + ./$(DEPDIR)/pngwio.Plo ./$(DEPDIR)/pngwrite.Plo \ + ./$(DEPDIR)/pngwtran.Plo ./$(DEPDIR)/pngwutil.Plo \ + arm/$(DEPDIR)/arm_init.Plo arm/$(DEPDIR)/filter_neon.Plo \ + arm/$(DEPDIR)/filter_neon_intrinsics.Plo \ + arm/$(DEPDIR)/palette_neon_intrinsics.Plo \ + contrib/libtests/$(DEPDIR)/pngimage.Po \ + contrib/libtests/$(DEPDIR)/pngstest.Po \ + contrib/libtests/$(DEPDIR)/pngunknown.Po \ + contrib/libtests/$(DEPDIR)/pngvalid.Po \ + contrib/libtests/$(DEPDIR)/timepng.Po \ + contrib/tools/$(DEPDIR)/png-fix-itxt.Po \ + contrib/tools/$(DEPDIR)/pngcp.Po \ + contrib/tools/$(DEPDIR)/pngfix.Po \ + intel/$(DEPDIR)/filter_sse2_intrinsics.Plo \ + intel/$(DEPDIR)/intel_init.Plo \ + mips/$(DEPDIR)/filter_msa_intrinsics.Plo \ + mips/$(DEPDIR)/mips_init.Plo \ + powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo \ + powerpc/$(DEPDIR)/powerpc_init.Plo +am__mv = mv -f +CPPASCOMPILE = $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) +LTCPPASCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CCASFLAGS) $(CCASFLAGS) +AM_V_CPPAS = $(am__v_CPPAS_$(V)) +am__v_CPPAS_ = $(am__v_CPPAS_$(AM_DEFAULT_VERBOSITY)) +am__v_CPPAS_0 = @echo " CPPAS " $@; +am__v_CPPAS_1 = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libpng16_la_SOURCES) \ + $(nodist_libpng16_la_SOURCES) \ + $(png_fix_itxt_SOURCES) $(pngcp_SOURCES) $(pngfix_SOURCES) \ + $(pngimage_SOURCES) $(pngstest_SOURCES) $(pngtest_SOURCES) \ + $(pngunknown_SOURCES) $(pngvalid_SOURCES) $(timepng_SOURCES) +DIST_SOURCES = \ + $(am__libpng16_la_SOURCES_DIST) \ + $(png_fix_itxt_SOURCES) $(pngcp_SOURCES) $(pngfix_SOURCES) \ + $(pngimage_SOURCES) $(pngstest_SOURCES) $(pngtest_SOURCES) \ + $(pngunknown_SOURCES) $(pngvalid_SOURCES) $(timepng_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +man3dir = $(mandir)/man3 +man5dir = $(mandir)/man5 +NROFF = nroff +MANS = $(dist_man_MANS) +DATA = $(pkgconfig_DATA) +HEADERS = $(nodist_pkginclude_HEADERS) $(pkginclude_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ + $(LISP)config.h.in +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +CSCOPE = cscope +AM_RECURSIVE_TARGETS = cscope check recheck +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red=''; \ + grn=''; \ + lgn=''; \ + blu=''; \ + mgn=''; \ + brg=''; \ + std=''; \ + fi; \ +} +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = .exe .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:.exe.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in \ + $(srcdir)/config.h.in $(srcdir)/libpng-config.in \ + $(srcdir)/libpng.pc.in AUTHORS INSTALL README TODO compile \ + config.guess config.sub depcomp install-sh ltmain.sh missing \ + test-driver +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + if test -d "$(distdir)"; then \ + find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -rf "$(distdir)" \ + || { sleep 5 && rm -rf "$(distdir)"; }; \ + else :; fi +am__post_remove_distdir = $(am__remove_distdir) +DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.xz +GZIP_ENV = --best +DIST_TARGETS = dist-xz dist-gzip +distuninstallcheck_listfiles = find . -type f -print +am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ + | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' +distcleancheck_listfiles = find . -type f -print + +#distribute headers in /usr/include/libpng/* +pkgincludedir = $(includedir)/$(PNGLIB_BASENAME) +ACLOCAL = ${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing aclocal-1.16 +AMTAR = $${TAR-tar} +AM_DEFAULT_VERBOSITY = 1 +AR = i586-pc-msdosdjgpp-ar +AS = as +AUTOCONF = ${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing autoconf +AUTOHEADER = ${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing autoheader +AUTOMAKE = ${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing automake-1.16 +AWK = gawk +CC = i586-pc-msdosdjgpp-gcc +CCAS = i586-pc-msdosdjgpp-gcc +CCASDEPMODE = depmode=gcc3 +CCASFLAGS = -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib +CCDEPMODE = depmode=gcc3 +CFLAGS = -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib +CPP = i586-pc-msdosdjgpp-gcc -E +CPPFLAGS = +CYGPATH_W = echo +DEFS = -DHAVE_CONFIG_H +DEPDIR = .deps + +# DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe +# other operating systems (NeXT?) the C preprocessor selected by configure +# checks input tokens for validity - effectively it performs part of the ANSI-C +# parsing - and therefore fails with the .df files. configure.ac has special +# checks for this and sets DFNCPP appropriately. +DFNCPP = i586-pc-msdosdjgpp-gcc -E +DLLTOOL = false +DSYMUTIL = +DUMPBIN = +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /usr/bin/grep -E +EXEEXT = .exe +FGREP = /usr/bin/grep -F +GREP = /usr/bin/grep +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +LD = /opt/cross/djgpp/i586-pc-msdosdjgpp/bin/ld +LDFLAGS = +LIBOBJS = ${LIBOBJDIR}strtod$U.o +LIBS = -lz +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LIPO = +LN_S = ln -s +LTLIBOBJS = ${LIBOBJDIR}strtod$U.lo +LT_SYS_LIBRARY_PATH = +MAINT = # +MAKEINFO = ${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing makeinfo +MANIFEST_TOOL = : +MKDIR_P = /usr/bin/mkdir -p +NM = /opt/cross/djgpp/bin/i586-pc-msdosdjgpp-nm -B +NMEDIT = +OBJDUMP = i586-pc-msdosdjgpp-objdump +OBJEXT = o +OTOOL = +OTOOL64 = +PACKAGE = libpng +PACKAGE_BUGREPORT = png-mng-implement@lists.sourceforge.net +PACKAGE_NAME = libpng +PACKAGE_STRING = libpng 1.6.37 +PACKAGE_TARNAME = libpng +PACKAGE_URL = +PACKAGE_VERSION = 1.6.37 +PATH_SEPARATOR = : +PNGLIB_MAJOR = 1 +PNGLIB_MINOR = 6 +PNGLIB_RELEASE = 37 +PNGLIB_VERSION = 1.6.37 + +# PNG_COPTS give extra options for the C compiler to be used on all compilation +# steps (unless targe_CFLAGS is specified; that will take precedence over +# AM_CFLAGS) +PNG_COPTS = +PNG_PREFIX = +POW_LIB = +RANLIB = i586-pc-msdosdjgpp-ranlib +SED = /usr/bin/sed +SET_MAKE = +SHELL = /bin/bash +STRIP = i586-pc-msdosdjgpp-strip +SYMBOL_PREFIX = _ +VERSION = 1.6.37 +abs_builddir = /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37 +abs_srcdir = /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37 +abs_top_builddir = /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37 +abs_top_srcdir = /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37 +ac_ct_AR = +ac_ct_CC = +ac_ct_DUMPBIN = +am__include = include +am__leading_dot = . +am__quote = +am__tar = $${TAR-tar} chof - "$$tardir" +am__untar = $${TAR-tar} xf - + +# generate the -config scripts if required +binconfigs = libpng16-config +bindir = ${exec_prefix}/bin +build = x86_64-pc-linux-gnu +build_alias = x86_64-linux-gnu +build_cpu = x86_64 +build_os = linux-gnu +build_vendor = pc +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = i586-pc-msdosdjgpp +host_alias = i586-pc-msdosdjgpp +host_cpu = i586 +host_os = msdosdjgpp +host_vendor = pc +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = ${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = $(MKDIR_P) +oldincludedir = /usr/include +pdfdir = ${docdir} + +# pkg-config stuff, note that libpng.pc is always required in order +# to get the correct library +pkgconfigdir = ${libdir}/pkgconfig +prefix = /home/scott/code/FLTK_Nano-X_DOS/installed/dos +program_transform_name = s,x,x, +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target_alias = +top_build_prefix = +top_builddir = . +top_srcdir = . +PNGLIB_BASENAME = libpng16 +ACLOCAL_AMFLAGS = -I scripts + +# This ensures that pnglibconf.h gets built at the start of 'make all' or +# 'make check', but it does not add dependencies to the individual programs, +# this is done below. +# +# IMPORTANT: always add the object modules of new programs to the list below +# because otherwise the sequence 'configure; make new-program' will *sometimes* +# result in the installed (system) pnglibconf.h being used and the result is +# always wrong and always very confusing. +BUILT_SOURCES = pnglibconf.h +pngtest_SOURCES = pngtest.c +pngtest_LDADD = libpng16.la +pngvalid_SOURCES = contrib/libtests/pngvalid.c +pngvalid_LDADD = libpng16.la +pngstest_SOURCES = contrib/libtests/pngstest.c +pngstest_LDADD = libpng16.la +pngunknown_SOURCES = contrib/libtests/pngunknown.c +pngunknown_LDADD = libpng16.la +pngimage_SOURCES = contrib/libtests/pngimage.c +pngimage_LDADD = libpng16.la +timepng_SOURCES = contrib/libtests/timepng.c +timepng_LDADD = libpng16.la +pngfix_SOURCES = contrib/tools/pngfix.c +pngfix_LDADD = libpng16.la +png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c +pngcp_SOURCES = contrib/tools/pngcp.c +pngcp_LDADD = libpng16.la + +# Generally these are single line shell scripts to run a test with a particular +# set of parameters: +TESTS = \ + tests/pngtest\ + tests/pngtest-badpngs\ + tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\ + tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\ + tests/pngvalid-gamma-expand16-background\ + tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\ + tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\ + tests/pngvalid-progressive-size\ + tests/pngvalid-progressive-interlace-standard\ + tests/pngvalid-transform\ + tests/pngvalid-progressive-standard tests/pngvalid-standard\ + tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\ + tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\ + tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\ + tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\ + tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\ + tests/pngimage-quick tests/pngimage-full + + +# man pages +dist_man_MANS = libpng.3 libpngpf.3 png.5 +EXTRA_SCRIPTS = libpng-config libpng16-config +bin_SCRIPTS = ${binconfigs} + +# rules to build libpng, only build the old library on request +lib_LTLIBRARIES = libpng16.la +# EXTRA_LTLIBRARIES= libpng.la +libpng16_la_SOURCES = png.c pngerror.c \ + pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c \ + pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c \ + pngwutil.c png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h \ + pngstruct.h pngusr.dfa $(am__append_2) $(am__append_3) \ + $(am__append_4) $(am__append_5) +nodist_libpng16_la_SOURCES = pnglibconf.h +libpng16_la_LDFLAGS = -no-undefined \ + -export-dynamic -version-number \ + 16:37:0 \ + $(am__append_6) $(am__append_7) $(am__append_8) +#libpng16_la_DEPENDENCIES = libpng.sym +libpng16_la_DEPENDENCIES = libpng.vers +pkginclude_HEADERS = png.h pngconf.h +nodist_pkginclude_HEADERS = pnglibconf.h +pkgconfig_DATA = libpng16.pc + +# Extra source distribution files, '${srcdir}' is used below to stop build files +# from those directories being included. This only works if the configure is +# not done in the source directory! +EXTRA_DIST = \ + ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \ + pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \ + ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \ + $(TESTS) $(XFAIL_TESTS) tests/pngstest \ + CMakeLists.txt example.c libpng-manual.txt + +SCRIPT_CLEANFILES = scripts/*.out scripts/*.chk +CLEANFILES = *.tf? pngout.png libpng16.pc \ + libpng16-config libpng.vers libpng.sym \ + check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \ + pnglibconf.out pnglibconf.c pnglibconf.pre pnglibconf.dfn \ + $(SCRIPT_CLEANFILES) + +MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \ +config.sub configure depcomp install-sh ltmain.sh missing + +AM_CFLAGS = ${PNG_COPTS} +SUFFIXES = .chk .out + +# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually +# be built with PNG_USE_READ_MACROS; this prevents the read macros from +# interfering with the symbol file format. +SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG16_0' \ + -DPNGLIB_VERSION='1.6.37' \ + -DSYMBOL_PREFIX='$(SYMBOL_PREFIX)' -DPNG_NO_USE_READ_MACROS \ + -DPNG_BUILDING_SYMBOL_TABLE $(am__append_9) + +# EXT_LIST is a list of the possibly library directory extensions, this exists +# because we can't find a good way of discovering the file extensions that are +# actually installed on a given system, so instead we check for every extension +# we have seen. +EXT_LIST = a dll.a so so.16.37 la sl dylib +all: $(BUILT_SOURCES) config.h + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .chk .out .S .c .lo .log .o .obj .test .test$(EXEEXT) .trs +am--refresh: Makefile + @: +$(srcdir)/Makefile.in: # $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: # $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): # $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +config.h: stamp-h1 + @test -f $@ || rm -f stamp-h1 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: # $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +libpng.pc: $(top_builddir)/config.status $(srcdir)/libpng.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +libpng-config: $(top_builddir)/config.status $(srcdir)/libpng-config.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } +arm/$(am__dirstamp): + @$(MKDIR_P) arm + @: > arm/$(am__dirstamp) +arm/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) arm/$(DEPDIR) + @: > arm/$(DEPDIR)/$(am__dirstamp) +arm/arm_init.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp) +arm/filter_neon.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp) +arm/filter_neon_intrinsics.lo: arm/$(am__dirstamp) \ + arm/$(DEPDIR)/$(am__dirstamp) +arm/palette_neon_intrinsics.lo: arm/$(am__dirstamp) \ + arm/$(DEPDIR)/$(am__dirstamp) +mips/$(am__dirstamp): + @$(MKDIR_P) mips + @: > mips/$(am__dirstamp) +mips/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) mips/$(DEPDIR) + @: > mips/$(DEPDIR)/$(am__dirstamp) +mips/mips_init.lo: mips/$(am__dirstamp) mips/$(DEPDIR)/$(am__dirstamp) +mips/filter_msa_intrinsics.lo: mips/$(am__dirstamp) \ + mips/$(DEPDIR)/$(am__dirstamp) +intel/$(am__dirstamp): + @$(MKDIR_P) intel + @: > intel/$(am__dirstamp) +intel/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) intel/$(DEPDIR) + @: > intel/$(DEPDIR)/$(am__dirstamp) +intel/intel_init.lo: intel/$(am__dirstamp) \ + intel/$(DEPDIR)/$(am__dirstamp) +intel/filter_sse2_intrinsics.lo: intel/$(am__dirstamp) \ + intel/$(DEPDIR)/$(am__dirstamp) +powerpc/$(am__dirstamp): + @$(MKDIR_P) powerpc + @: > powerpc/$(am__dirstamp) +powerpc/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) powerpc/$(DEPDIR) + @: > powerpc/$(DEPDIR)/$(am__dirstamp) +powerpc/powerpc_init.lo: powerpc/$(am__dirstamp) \ + powerpc/$(DEPDIR)/$(am__dirstamp) +powerpc/filter_vsx_intrinsics.lo: powerpc/$(am__dirstamp) \ + powerpc/$(DEPDIR)/$(am__dirstamp) + +libpng16.la: $(libpng16_la_OBJECTS) $(libpng16_la_DEPENDENCIES) $(EXTRA_libpng16_la_DEPENDENCIES) + $(AM_V_CCLD)$(libpng16_la_LINK) -rpath $(libdir) $(libpng16_la_OBJECTS) $(libpng16_la_LIBADD) $(LIBS) +contrib/tools/$(am__dirstamp): + @$(MKDIR_P) contrib/tools + @: > contrib/tools/$(am__dirstamp) +contrib/tools/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) contrib/tools/$(DEPDIR) + @: > contrib/tools/$(DEPDIR)/$(am__dirstamp) +contrib/tools/png-fix-itxt.$(OBJEXT): contrib/tools/$(am__dirstamp) \ + contrib/tools/$(DEPDIR)/$(am__dirstamp) + +png-fix-itxt$(EXEEXT): $(png_fix_itxt_OBJECTS) $(png_fix_itxt_DEPENDENCIES) $(EXTRA_png_fix_itxt_DEPENDENCIES) + @rm -f png-fix-itxt$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(png_fix_itxt_OBJECTS) $(png_fix_itxt_LDADD) $(LIBS) +contrib/tools/pngcp.$(OBJEXT): contrib/tools/$(am__dirstamp) \ + contrib/tools/$(DEPDIR)/$(am__dirstamp) + +pngcp$(EXEEXT): $(pngcp_OBJECTS) $(pngcp_DEPENDENCIES) $(EXTRA_pngcp_DEPENDENCIES) + @rm -f pngcp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngcp_OBJECTS) $(pngcp_LDADD) $(LIBS) +contrib/tools/pngfix.$(OBJEXT): contrib/tools/$(am__dirstamp) \ + contrib/tools/$(DEPDIR)/$(am__dirstamp) + +pngfix$(EXEEXT): $(pngfix_OBJECTS) $(pngfix_DEPENDENCIES) $(EXTRA_pngfix_DEPENDENCIES) + @rm -f pngfix$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngfix_OBJECTS) $(pngfix_LDADD) $(LIBS) +contrib/libtests/$(am__dirstamp): + @$(MKDIR_P) contrib/libtests + @: > contrib/libtests/$(am__dirstamp) +contrib/libtests/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) contrib/libtests/$(DEPDIR) + @: > contrib/libtests/$(DEPDIR)/$(am__dirstamp) +contrib/libtests/pngimage.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngimage$(EXEEXT): $(pngimage_OBJECTS) $(pngimage_DEPENDENCIES) $(EXTRA_pngimage_DEPENDENCIES) + @rm -f pngimage$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngimage_OBJECTS) $(pngimage_LDADD) $(LIBS) +contrib/libtests/pngstest.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngstest$(EXEEXT): $(pngstest_OBJECTS) $(pngstest_DEPENDENCIES) $(EXTRA_pngstest_DEPENDENCIES) + @rm -f pngstest$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngstest_OBJECTS) $(pngstest_LDADD) $(LIBS) + +pngtest$(EXEEXT): $(pngtest_OBJECTS) $(pngtest_DEPENDENCIES) $(EXTRA_pngtest_DEPENDENCIES) + @rm -f pngtest$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngtest_OBJECTS) $(pngtest_LDADD) $(LIBS) +contrib/libtests/pngunknown.$(OBJEXT): \ + contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngunknown$(EXEEXT): $(pngunknown_OBJECTS) $(pngunknown_DEPENDENCIES) $(EXTRA_pngunknown_DEPENDENCIES) + @rm -f pngunknown$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngunknown_OBJECTS) $(pngunknown_LDADD) $(LIBS) +contrib/libtests/pngvalid.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngvalid$(EXEEXT): $(pngvalid_OBJECTS) $(pngvalid_DEPENDENCIES) $(EXTRA_pngvalid_DEPENDENCIES) + @rm -f pngvalid$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngvalid_OBJECTS) $(pngvalid_LDADD) $(LIBS) +contrib/libtests/timepng.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +timepng$(EXEEXT): $(timepng_OBJECTS) $(timepng_DEPENDENCIES) $(EXTRA_timepng_DEPENDENCIES) + @rm -f timepng$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(timepng_OBJECTS) $(timepng_LDADD) $(LIBS) +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + -rm -f arm/*.$(OBJEXT) + -rm -f arm/*.lo + -rm -f contrib/libtests/*.$(OBJEXT) + -rm -f contrib/tools/*.$(OBJEXT) + -rm -f intel/*.$(OBJEXT) + -rm -f intel/*.lo + -rm -f mips/*.$(OBJEXT) + -rm -f mips/*.lo + -rm -f powerpc/*.$(OBJEXT) + -rm -f powerpc/*.lo + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/png.Plo # am--include-marker +include ./$(DEPDIR)/pngerror.Plo # am--include-marker +include ./$(DEPDIR)/pngget.Plo # am--include-marker +include ./$(DEPDIR)/pngmem.Plo # am--include-marker +include ./$(DEPDIR)/pngpread.Plo # am--include-marker +include ./$(DEPDIR)/pngread.Plo # am--include-marker +include ./$(DEPDIR)/pngrio.Plo # am--include-marker +include ./$(DEPDIR)/pngrtran.Plo # am--include-marker +include ./$(DEPDIR)/pngrutil.Plo # am--include-marker +include ./$(DEPDIR)/pngset.Plo # am--include-marker +include ./$(DEPDIR)/pngtest.Po # am--include-marker +include ./$(DEPDIR)/pngtrans.Plo # am--include-marker +include ./$(DEPDIR)/pngwio.Plo # am--include-marker +include ./$(DEPDIR)/pngwrite.Plo # am--include-marker +include ./$(DEPDIR)/pngwtran.Plo # am--include-marker +include ./$(DEPDIR)/pngwutil.Plo # am--include-marker +include arm/$(DEPDIR)/arm_init.Plo # am--include-marker +include arm/$(DEPDIR)/filter_neon.Plo # am--include-marker +include arm/$(DEPDIR)/filter_neon_intrinsics.Plo # am--include-marker +include arm/$(DEPDIR)/palette_neon_intrinsics.Plo # am--include-marker +include contrib/libtests/$(DEPDIR)/pngimage.Po # am--include-marker +include contrib/libtests/$(DEPDIR)/pngstest.Po # am--include-marker +include contrib/libtests/$(DEPDIR)/pngunknown.Po # am--include-marker +include contrib/libtests/$(DEPDIR)/pngvalid.Po # am--include-marker +include contrib/libtests/$(DEPDIR)/timepng.Po # am--include-marker +include contrib/tools/$(DEPDIR)/png-fix-itxt.Po # am--include-marker +include contrib/tools/$(DEPDIR)/pngcp.Po # am--include-marker +include contrib/tools/$(DEPDIR)/pngfix.Po # am--include-marker +include intel/$(DEPDIR)/filter_sse2_intrinsics.Plo # am--include-marker +include intel/$(DEPDIR)/intel_init.Plo # am--include-marker +include mips/$(DEPDIR)/filter_msa_intrinsics.Plo # am--include-marker +include mips/$(DEPDIR)/mips_init.Plo # am--include-marker +include powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo # am--include-marker +include powerpc/$(DEPDIR)/powerpc_init.Plo # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.S.o: + $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ + $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ + $(am__mv) $$depbase.Tpo $$depbase.Po +# $(AM_V_CPPAS)source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) \ +# $(AM_V_CPPAS_no)$(CPPASCOMPILE) -c -o $@ $< + +.S.obj: + $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ + $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ + $(am__mv) $$depbase.Tpo $$depbase.Po +# $(AM_V_CPPAS)source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) \ +# $(AM_V_CPPAS_no)$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.S.lo: + $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ + $(LTCPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ + $(am__mv) $$depbase.Tpo $$depbase.Plo +# $(AM_V_CPPAS)source='$<' object='$@' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) \ +# $(AM_V_CPPAS_no)$(LTCPPASCOMPILE) -c -o $@ $< + +.c.o: + $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ + $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ + $(am__mv) $$depbase.Tpo $$depbase.Po +# $(AM_V_CC)source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(AM_V_CC_no)$(COMPILE) -c -o $@ $< + +.c.obj: + $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ + $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ + $(am__mv) $$depbase.Tpo $$depbase.Po +# $(AM_V_CC)source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(AM_V_CC_no)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: + $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ + $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ + $(am__mv) $$depbase.Tpo $$depbase.Plo +# $(AM_V_CC)source='$<' object='$@' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(AM_V_CC_no)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + -rm -rf arm/.libs arm/_libs + -rm -rf intel/.libs intel/_libs + -rm -rf mips/.libs mips/_libs + -rm -rf powerpc/.libs powerpc/_libs + +distclean-libtool: + -rm -f libtool config.lt +install-man3: $(dist_man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(dist_man_MANS)'; \ + test -n "$(man3dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.3[a-z]*$$/p'; \ + fi; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \ + done; } + +uninstall-man3: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man3dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.3[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir) +install-man5: $(dist_man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(dist_man_MANS)'; \ + test -n "$(man5dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.5[a-z]*$$/p'; \ + fi; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man5dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \ + done; } + +uninstall-man5: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man5dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.5[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir) +install-pkgconfigDATA: $(pkgconfig_DATA) + @$(NORMAL_INSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ + done + +uninstall-pkgconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) +install-nodist_pkgincludeHEADERS: $(nodist_pkginclude_HEADERS) + @$(NORMAL_INSTALL) + @list='$(nodist_pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ + done + +uninstall-nodist_pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(nodist_pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) +install-pkgincludeHEADERS: $(pkginclude_HEADERS) + @$(NORMAL_INSTALL) + @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ + done + +uninstall-pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscope: cscope.files + test ! -s cscope.files \ + || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) +clean-cscope: + -rm -f cscope.files +cscope.files: clean-cscope cscopelist +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + -rm -f cscope.out cscope.in.out cscope.po.out cscope.files + +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + elif test -n "$$redo_logs"; then \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: $(check_PROGRAMS) + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all $(check_PROGRAMS) + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +tests/pngtest.log: tests/pngtest + @p='tests/pngtest'; \ + b='tests/pngtest'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngtest-badpngs.log: tests/pngtest-badpngs + @p='tests/pngtest-badpngs'; \ + b='tests/pngtest-badpngs'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-16-to-8.log: tests/pngvalid-gamma-16-to-8 + @p='tests/pngvalid-gamma-16-to-8'; \ + b='tests/pngvalid-gamma-16-to-8'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-alpha-mode.log: tests/pngvalid-gamma-alpha-mode + @p='tests/pngvalid-gamma-alpha-mode'; \ + b='tests/pngvalid-gamma-alpha-mode'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-background.log: tests/pngvalid-gamma-background + @p='tests/pngvalid-gamma-background'; \ + b='tests/pngvalid-gamma-background'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-expand16-alpha-mode.log: tests/pngvalid-gamma-expand16-alpha-mode + @p='tests/pngvalid-gamma-expand16-alpha-mode'; \ + b='tests/pngvalid-gamma-expand16-alpha-mode'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-expand16-background.log: tests/pngvalid-gamma-expand16-background + @p='tests/pngvalid-gamma-expand16-background'; \ + b='tests/pngvalid-gamma-expand16-background'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-expand16-transform.log: tests/pngvalid-gamma-expand16-transform + @p='tests/pngvalid-gamma-expand16-transform'; \ + b='tests/pngvalid-gamma-expand16-transform'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-sbit.log: tests/pngvalid-gamma-sbit + @p='tests/pngvalid-gamma-sbit'; \ + b='tests/pngvalid-gamma-sbit'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-threshold.log: tests/pngvalid-gamma-threshold + @p='tests/pngvalid-gamma-threshold'; \ + b='tests/pngvalid-gamma-threshold'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-transform.log: tests/pngvalid-gamma-transform + @p='tests/pngvalid-gamma-transform'; \ + b='tests/pngvalid-gamma-transform'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-progressive-size.log: tests/pngvalid-progressive-size + @p='tests/pngvalid-progressive-size'; \ + b='tests/pngvalid-progressive-size'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-progressive-interlace-standard.log: tests/pngvalid-progressive-interlace-standard + @p='tests/pngvalid-progressive-interlace-standard'; \ + b='tests/pngvalid-progressive-interlace-standard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-transform.log: tests/pngvalid-transform + @p='tests/pngvalid-transform'; \ + b='tests/pngvalid-transform'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-progressive-standard.log: tests/pngvalid-progressive-standard + @p='tests/pngvalid-progressive-standard'; \ + b='tests/pngvalid-progressive-standard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-standard.log: tests/pngvalid-standard + @p='tests/pngvalid-standard'; \ + b='tests/pngvalid-standard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-1.8.log: tests/pngstest-1.8 + @p='tests/pngstest-1.8'; \ + b='tests/pngstest-1.8'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-1.8-alpha.log: tests/pngstest-1.8-alpha + @p='tests/pngstest-1.8-alpha'; \ + b='tests/pngstest-1.8-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-linear.log: tests/pngstest-linear + @p='tests/pngstest-linear'; \ + b='tests/pngstest-linear'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-linear-alpha.log: tests/pngstest-linear-alpha + @p='tests/pngstest-linear-alpha'; \ + b='tests/pngstest-linear-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-none.log: tests/pngstest-none + @p='tests/pngstest-none'; \ + b='tests/pngstest-none'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-none-alpha.log: tests/pngstest-none-alpha + @p='tests/pngstest-none-alpha'; \ + b='tests/pngstest-none-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-sRGB.log: tests/pngstest-sRGB + @p='tests/pngstest-sRGB'; \ + b='tests/pngstest-sRGB'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-sRGB-alpha.log: tests/pngstest-sRGB-alpha + @p='tests/pngstest-sRGB-alpha'; \ + b='tests/pngstest-sRGB-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-IDAT.log: tests/pngunknown-IDAT + @p='tests/pngunknown-IDAT'; \ + b='tests/pngunknown-IDAT'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-discard.log: tests/pngunknown-discard + @p='tests/pngunknown-discard'; \ + b='tests/pngunknown-discard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-if-safe.log: tests/pngunknown-if-safe + @p='tests/pngunknown-if-safe'; \ + b='tests/pngunknown-if-safe'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-sAPI.log: tests/pngunknown-sAPI + @p='tests/pngunknown-sAPI'; \ + b='tests/pngunknown-sAPI'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-sTER.log: tests/pngunknown-sTER + @p='tests/pngunknown-sTER'; \ + b='tests/pngunknown-sTER'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-save.log: tests/pngunknown-save + @p='tests/pngunknown-save'; \ + b='tests/pngunknown-save'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-vpAg.log: tests/pngunknown-vpAg + @p='tests/pngunknown-vpAg'; \ + b='tests/pngunknown-vpAg'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngimage-quick.log: tests/pngimage-quick + @p='tests/pngimage-quick'; \ + b='tests/pngimage-quick'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngimage-full.log: tests/pngimage-full + @p='tests/pngimage-full'; \ + b='tests/pngimage-full'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test$(EXEEXT).log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + $(am__remove_distdir) + test -d "$(distdir)" || mkdir "$(distdir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook + -test -n "$(am__skip_mode_fix)" \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r "$(distdir)" +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz + $(am__post_remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 + $(am__post_remove_distdir) + +dist-lzip: distdir + tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz + $(am__post_remove_distdir) +dist-xz: distdir + tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz + $(am__post_remove_distdir) + +dist-tarZ: distdir + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__post_remove_distdir) + +dist-shar: distdir + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 + shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz + $(am__post_remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__post_remove_distdir) + +dist dist-all: + $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' + $(am__post_remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lz*) \ + lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ + *.tar.xz*) \ + xz -dc $(distdir).tar.xz | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir) + chmod u+w $(distdir) + mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst + chmod a-w $(distdir) + test -d $(distdir)/_build || exit 0; \ + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && am__cwd=`pwd` \ + && $(am__cd) $(distdir)/_build/sub \ + && ../../configure \ + $(AM_DISTCHECK_CONFIGURE_FLAGS) \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + --srcdir=../.. --prefix="$$dc_install_base" \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ + && cd "$$am__cwd" \ + || exit 1 + $(am__post_remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @test -n '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: trying to run $@ with an empty' \ + '$$(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + $(am__cd) '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(SCRIPTS) $(MANS) $(DATA) \ + $(HEADERS) config.h +install-binPROGRAMS: install-libLTLIBRARIES + +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f arm/$(DEPDIR)/$(am__dirstamp) + -rm -f arm/$(am__dirstamp) + -rm -f contrib/libtests/$(DEPDIR)/$(am__dirstamp) + -rm -f contrib/libtests/$(am__dirstamp) + -rm -f contrib/tools/$(DEPDIR)/$(am__dirstamp) + -rm -f contrib/tools/$(am__dirstamp) + -rm -f intel/$(DEPDIR)/$(am__dirstamp) + -rm -f intel/$(am__dirstamp) + -rm -f mips/$(DEPDIR)/$(am__dirstamp) + -rm -f mips/$(am__dirstamp) + -rm -f powerpc/$(DEPDIR)/$(am__dirstamp) + -rm -f powerpc/$(am__dirstamp) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +##install-exec-hook: +##install-data-hook: +###uninstall-hook: +clean: clean-am + +clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ + clean-libLTLIBRARIES clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f ./$(DEPDIR)/png.Plo + -rm -f ./$(DEPDIR)/pngerror.Plo + -rm -f ./$(DEPDIR)/pngget.Plo + -rm -f ./$(DEPDIR)/pngmem.Plo + -rm -f ./$(DEPDIR)/pngpread.Plo + -rm -f ./$(DEPDIR)/pngread.Plo + -rm -f ./$(DEPDIR)/pngrio.Plo + -rm -f ./$(DEPDIR)/pngrtran.Plo + -rm -f ./$(DEPDIR)/pngrutil.Plo + -rm -f ./$(DEPDIR)/pngset.Plo + -rm -f ./$(DEPDIR)/pngtest.Po + -rm -f ./$(DEPDIR)/pngtrans.Plo + -rm -f ./$(DEPDIR)/pngwio.Plo + -rm -f ./$(DEPDIR)/pngwrite.Plo + -rm -f ./$(DEPDIR)/pngwtran.Plo + -rm -f ./$(DEPDIR)/pngwutil.Plo + -rm -f arm/$(DEPDIR)/arm_init.Plo + -rm -f arm/$(DEPDIR)/filter_neon.Plo + -rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo + -rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo + -rm -f contrib/libtests/$(DEPDIR)/pngimage.Po + -rm -f contrib/libtests/$(DEPDIR)/pngstest.Po + -rm -f contrib/libtests/$(DEPDIR)/pngunknown.Po + -rm -f contrib/libtests/$(DEPDIR)/pngvalid.Po + -rm -f contrib/libtests/$(DEPDIR)/timepng.Po + -rm -f contrib/tools/$(DEPDIR)/png-fix-itxt.Po + -rm -f contrib/tools/$(DEPDIR)/pngcp.Po + -rm -f contrib/tools/$(DEPDIR)/pngfix.Po + -rm -f intel/$(DEPDIR)/filter_sse2_intrinsics.Plo + -rm -f intel/$(DEPDIR)/intel_init.Plo + -rm -f mips/$(DEPDIR)/filter_msa_intrinsics.Plo + -rm -f mips/$(DEPDIR)/mips_init.Plo + -rm -f powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo + -rm -f powerpc/$(DEPDIR)/powerpc_init.Plo + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-man install-nodist_pkgincludeHEADERS \ + install-pkgconfigDATA install-pkgincludeHEADERS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-data-hook +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS install-binSCRIPTS \ + install-libLTLIBRARIES + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: install-man3 install-man5 + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f ./$(DEPDIR)/png.Plo + -rm -f ./$(DEPDIR)/pngerror.Plo + -rm -f ./$(DEPDIR)/pngget.Plo + -rm -f ./$(DEPDIR)/pngmem.Plo + -rm -f ./$(DEPDIR)/pngpread.Plo + -rm -f ./$(DEPDIR)/pngread.Plo + -rm -f ./$(DEPDIR)/pngrio.Plo + -rm -f ./$(DEPDIR)/pngrtran.Plo + -rm -f ./$(DEPDIR)/pngrutil.Plo + -rm -f ./$(DEPDIR)/pngset.Plo + -rm -f ./$(DEPDIR)/pngtest.Po + -rm -f ./$(DEPDIR)/pngtrans.Plo + -rm -f ./$(DEPDIR)/pngwio.Plo + -rm -f ./$(DEPDIR)/pngwrite.Plo + -rm -f ./$(DEPDIR)/pngwtran.Plo + -rm -f ./$(DEPDIR)/pngwutil.Plo + -rm -f arm/$(DEPDIR)/arm_init.Plo + -rm -f arm/$(DEPDIR)/filter_neon.Plo + -rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo + -rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo + -rm -f contrib/libtests/$(DEPDIR)/pngimage.Po + -rm -f contrib/libtests/$(DEPDIR)/pngstest.Po + -rm -f contrib/libtests/$(DEPDIR)/pngunknown.Po + -rm -f contrib/libtests/$(DEPDIR)/pngvalid.Po + -rm -f contrib/libtests/$(DEPDIR)/timepng.Po + -rm -f contrib/tools/$(DEPDIR)/png-fix-itxt.Po + -rm -f contrib/tools/$(DEPDIR)/pngcp.Po + -rm -f contrib/tools/$(DEPDIR)/pngfix.Po + -rm -f intel/$(DEPDIR)/filter_sse2_intrinsics.Plo + -rm -f intel/$(DEPDIR)/intel_init.Plo + -rm -f mips/$(DEPDIR)/filter_msa_intrinsics.Plo + -rm -f mips/$(DEPDIR)/mips_init.Plo + -rm -f powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo + -rm -f powerpc/$(DEPDIR)/powerpc_init.Plo + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \ + uninstall-libLTLIBRARIES uninstall-man \ + uninstall-nodist_pkgincludeHEADERS uninstall-pkgconfigDATA \ + uninstall-pkgincludeHEADERS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) uninstall-hook +uninstall-man: uninstall-man3 uninstall-man5 + +.MAKE: all check check-am install install-am install-data-am \ + install-exec-am install-strip uninstall-am + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles am--refresh check \ + check-TESTS check-am clean clean-binPROGRAMS \ + clean-checkPROGRAMS clean-cscope clean-generic \ + clean-libLTLIBRARIES clean-libtool cscope cscopelist-am ctags \ + ctags-am dist dist-all dist-bzip2 dist-gzip dist-hook \ + dist-lzip dist-shar dist-tarZ dist-xz dist-zip distcheck \ + distclean distclean-compile distclean-generic distclean-hdr \ + distclean-libtool distclean-tags distcleancheck distdir \ + distuninstallcheck dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-binSCRIPTS \ + install-data install-data-am install-data-hook install-dvi \ + install-dvi-am install-exec install-exec-am install-exec-hook \ + install-html install-html-am install-info install-info-am \ + install-libLTLIBRARIES install-man install-man3 install-man5 \ + install-nodist_pkgincludeHEADERS install-pdf install-pdf-am \ + install-pkgconfigDATA install-pkgincludeHEADERS install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \ + uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-binSCRIPTS uninstall-hook uninstall-libLTLIBRARIES \ + uninstall-man uninstall-man3 uninstall-man5 \ + uninstall-nodist_pkgincludeHEADERS uninstall-pkgconfigDATA \ + uninstall-pkgincludeHEADERS + +.PRECIOUS: Makefile + + +$(PNGLIB_BASENAME).pc: libpng.pc + cp libpng.pc $@ + +$(PNGLIB_BASENAME)-config: libpng-config + cp libpng-config $@ + +scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h +scripts/prefix.out: png.h pngconf.h pnglibconf.out +scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt +scripts/intprefix.out: pnglibconf.h + +libpng.sym: scripts/sym.out + rm -f $@ + cp $? $@ +libpng.vers: scripts/vers.out + rm -f $@ + cp $? $@ + +# Rename functions in scripts/prefix.out with a PNG_PREFIX prefix. +# Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual +# implementation of the macro). +#pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst +# rm -f $@ +# $(AWK) 's==0 && NR>1{print prev}\ +# s==0{prev=$$0}\ +# s==1{print "#define", $$1, "" $$1}\ +# s==2{print "#define png_" $$1, "PNG_" $$1}\ +# END{print prev}' s=0 pnglibconf.out s=1 scripts/prefix.out\ +# s=2 ${srcdir}/scripts/macro.lst >pnglibconf.tf8 +# mv pnglibconf.tf8 $@ + +#pngprefix.h: scripts/intprefix.out +# rm -f pngprefix.tf1 +# $(AWK) '{print "#define", $$1, "" $$1}' $? >pngprefix.tf1 +# mv pngprefix.tf1 $@ +pnglibconf.h: pnglibconf.out + rm -f $@ + cp $? $@ + +pngprefix.h: # is empty + :>$@ + +$(srcdir)/scripts/pnglibconf.h.prebuilt: + @echo "Attempting to build $@" >&2 + @echo "This is a machine generated file, but if you want to make" >&2 + @echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2 + @echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2 + @exit 1 + +# The following is necessary to ensure that the local pnglibconf.h is used, not +# an installed one (this can happen immediately after on a clean system if +# 'make test' is the first thing the user does.) Only files which include +# one of the png source files (typically png.h or pngpriv.h) need to be listed +# here: +pngtest.o: pnglibconf.h + +contrib/libtests/makepng.o: pnglibconf.h +contrib/libtests/pngstest.o: pnglibconf.h +contrib/libtests/pngunknown.o: pnglibconf.h +contrib/libtests/pngimage.o: pnglibconf.h +contrib/libtests/pngvalid.o: pnglibconf.h +contrib/libtests/readpng.o: pnglibconf.h +contrib/libtests/tarith.o: pnglibconf.h +contrib/libtests/timepng.o: pnglibconf.h + +contrib/tools/makesRGB.o: pnglibconf.h +contrib/tools/pngfix.o: pnglibconf.h +contrib/tools/pngcp.o: pnglibconf.h + +.c.out: + rm -f $@ $*.tf[12] + test -d scripts || mkdir scripts || test -d scripts + $(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\ + $(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1 + $(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2 + rm -f $*.tf1 + mv $*.tf2 $@ + +# The .c file for pnglibconf.h is machine generated +pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA) + rm -f $@ $*.tf[45] + $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\ + ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ + ${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2 + rm $*.tf4 + mv $*.tf5 $@ + +# Symbol checks (.def and .out files should match) +scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out + +.out.chk: + rm -f $@ $*.new + $(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\ + of="$*.new" $< >&2 + mv $*.new $@ + +# used on demand to regenerate the standard header, CPPFLAGS should +# be empty - no non-standard defines +scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h + rm -f $@ pnglibconf.tf[67] + test -z "$(CPPFLAGS)" + echo "com 1.6.37 STANDARD API DEFINITION" |\ + $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf6\ + logunsupported=1 version=search ${srcdir}/pngconf.h -\ + ${srcdir}/scripts/pnglibconf.dfa 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf7\ + pnglibconf.tf6 1>&2 + rm pnglibconf.tf6 + mv pnglibconf.tf7 $@ + +$(libpng16_la_OBJECTS): png.h pngconf.h \ + pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h pngprefix.h + +test: check-am + +# Extra checks +check: scripts/symbols.chk + +# Don't distribute the generated script files +dist-hook: + cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES) + +# Make links between installed files with release-specific names and the generic +# file names. If this install rule is run the generic names will be deleted and +# recreated - this has obvious issues for systems with multiple installations. + +install-header-links: + @set -ex; cd '$(DESTDIR)$(includedir)'; for f in $(HEADERS); do \ + rm -f "$$f"; $(LN_S) "$(PNGLIB_BASENAME)/$$f" "$$f"; done + +uninstall-header-links: + cd '$(DESTDIR)$(includedir)'; rm -f $(HEADERS) + +install-libpng-pc: + @set -ex; cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc; \ + $(LN_S) '$(PNGLIB_BASENAME).pc' libpng.pc + +uninstall-libpng-pc: + rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc' + +install-library-links: + @set -x; cd '$(DESTDIR)$(libdir)';\ + for ext in $(EXT_LIST); do\ + rm -f "libpng.$$ext";\ + if test -f "$(PNGLIB_BASENAME).$$ext"; then\ + $(LN_S) "$(PNGLIB_BASENAME).$$ext" "libpng.$$ext" || exit 1;\ + fi;\ + done + +uninstall-library-links: + @set -x; cd '$(DESTDIR)$(libdir)'; for ext in $(EXT_LIST); do\ + rm -f "libpng.$$ext"; done + +install-libpng-config: + @set -ex; cd '$(DESTDIR)$(bindir)'; rm -f libpng-config; \ + $(LN_S) '$(PNGLIB_BASENAME)-config' libpng-config + +uninstall-libpng-config: + rm -f '$(DESTDIR)$(bindir)/libpng-config' + +# If --enable-unversioned-links is specified the header and lib file links +# will be automatically made on a 'make install': + +install-data-hook: install-header-links +uninstall-hook: uninstall-header-links +install-exec-hook: install-library-links +uninstall-hook: uninstall-library-links + +# Likewise, --install-pc causes libpng.pc to be constructed: + +install-data-hook: install-libpng-pc +uninstall-hook: uninstall-libpng-pc + +# And --install-config: + +install-exec-hook: install-libpng-config +uninstall-hook: uninstall-libpng-config + +# The following addition ensures that 'make all' always builds the test programs +# too. It used to, but some change either in libpng or configure stopped this +# working. +all-am: $(check_PROGRAMS) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/thirdparty/libpng-1.6.37/Makefile.am b/thirdparty/libpng-1.6.37/Makefile.am new file mode 100644 index 0000000..4f621aa --- /dev/null +++ b/thirdparty/libpng-1.6.37/Makefile.am @@ -0,0 +1,393 @@ +# Makefile.am, the source file for Makefile.in (and hence Makefile), is +# +# Copyright (c) 2018 Cosmin Truta +# Copyright (c) 2004-2016 Glenn Randers-Pehrson +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ + +ACLOCAL_AMFLAGS = -I scripts + +# test programs - run on make check, make distcheck +check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage pngcp +if HAVE_CLOCK_GETTIME +check_PROGRAMS += timepng +endif + +# Utilities - installed +bin_PROGRAMS= pngfix png-fix-itxt + +# This ensures that pnglibconf.h gets built at the start of 'make all' or +# 'make check', but it does not add dependencies to the individual programs, +# this is done below. +# +# IMPORTANT: always add the object modules of new programs to the list below +# because otherwise the sequence 'configure; make new-program' will *sometimes* +# result in the installed (system) pnglibconf.h being used and the result is +# always wrong and always very confusing. +BUILT_SOURCES = pnglibconf.h + +pngtest_SOURCES = pngtest.c +pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngvalid_SOURCES = contrib/libtests/pngvalid.c +pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngstest_SOURCES = contrib/libtests/pngstest.c +pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngunknown_SOURCES = contrib/libtests/pngunknown.c +pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngimage_SOURCES = contrib/libtests/pngimage.c +pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +timepng_SOURCES = contrib/libtests/timepng.c +timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngfix_SOURCES = contrib/tools/pngfix.c +pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c + +pngcp_SOURCES = contrib/tools/pngcp.c +pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +# Generally these are single line shell scripts to run a test with a particular +# set of parameters: +TESTS =\ + tests/pngtest\ + tests/pngtest-badpngs\ + tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\ + tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\ + tests/pngvalid-gamma-expand16-background\ + tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\ + tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\ + tests/pngvalid-progressive-size\ + tests/pngvalid-progressive-interlace-standard\ + tests/pngvalid-transform\ + tests/pngvalid-progressive-standard tests/pngvalid-standard\ + tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\ + tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\ + tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\ + tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\ + tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\ + tests/pngimage-quick tests/pngimage-full + +# man pages +dist_man_MANS= libpng.3 libpngpf.3 png.5 + +# generate the -config scripts if required +binconfigs= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config +EXTRA_SCRIPTS= libpng-config libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config +bin_SCRIPTS= @binconfigs@ + +# rules to build libpng, only build the old library on request +lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +# EXTRA_LTLIBRARIES= libpng.la +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\ + pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c\ + pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\ + png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa + +if PNG_ARM_NEON +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\ + arm/filter_neon.S arm/filter_neon_intrinsics.c \ + arm/palette_neon_intrinsics.c +endif + +if PNG_MIPS_MSA +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c\ + mips/filter_msa_intrinsics.c +endif + +if PNG_INTEL_SSE +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += intel/intel_init.c\ + intel/filter_sse2_intrinsics.c +endif + +if PNG_POWERPC_VSX +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\ + powerpc/filter_vsx_intrinsics.c +endif + +nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h + +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \ + -version-number @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0 + +if HAVE_LD_VERSION_SCRIPT +# Versioned symbols and restricted exports +if HAVE_SOLARIS_LD + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,-M -Wl,libpng.vers +else + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,--version-script=libpng.vers +endif + + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.vers +else +# Only restricted exports when possible + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -export-symbols libpng.sym + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym +endif + +#distribute headers in /usr/include/libpng/* +pkgincludedir= $(includedir)/$(PNGLIB_BASENAME) +pkginclude_HEADERS= png.h pngconf.h +nodist_pkginclude_HEADERS= pnglibconf.h + +# pkg-config stuff, note that libpng.pc is always required in order +# to get the correct library +pkgconfigdir = @pkgconfigdir@ +pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc + +# Extra source distribution files, '${srcdir}' is used below to stop build files +# from those directories being included. This only works if the configure is +# not done in the source directory! +EXTRA_DIST= \ + ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \ + pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \ + ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \ + $(TESTS) $(XFAIL_TESTS) tests/pngstest \ + CMakeLists.txt example.c libpng-manual.txt + +SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk + +CLEANFILES= *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \ + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \ + check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \ + pnglibconf.out pnglibconf.c pnglibconf.pre pnglibconf.dfn \ + $(SCRIPT_CLEANFILES) + +MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \ +config.sub configure depcomp install-sh ltmain.sh missing + +# PNG_COPTS give extra options for the C compiler to be used on all compilation +# steps (unless targe_CFLAGS is specified; that will take precedence over +# AM_CFLAGS) +PNG_COPTS = @PNG_COPTS@ +AM_CFLAGS = ${PNG_COPTS} + +# DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe +# other operating systems (NeXT?) the C preprocessor selected by configure +# checks input tokens for validity - effectively it performs part of the ANSI-C +# parsing - and therefore fails with the .df files. configure.ac has special +# checks for this and sets DFNCPP appropriately. +DFNCPP = @DFNCPP@ + +SUFFIXES = .chk .out + +$(PNGLIB_BASENAME).pc: libpng.pc + cp libpng.pc $@ + +$(PNGLIB_BASENAME)-config: libpng-config + cp libpng-config $@ + +scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h +scripts/prefix.out: png.h pngconf.h pnglibconf.out +scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt +scripts/intprefix.out: pnglibconf.h + +libpng.sym: scripts/sym.out + rm -f $@ + cp $? $@ +libpng.vers: scripts/vers.out + rm -f $@ + cp $? $@ + +if DO_PNG_PREFIX +# Rename functions in scripts/prefix.out with a PNG_PREFIX prefix. +# Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual +# implementation of the macro). +pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst + rm -f $@ + $(AWK) 's==0 && NR>1{print prev}\ + s==0{prev=$$0}\ + s==1{print "#define", $$1, "@PNG_PREFIX@" $$1}\ + s==2{print "#define @PNG_PREFIX@png_" $$1, "PNG_" $$1}\ + END{print prev}' s=0 pnglibconf.out s=1 scripts/prefix.out\ + s=2 ${srcdir}/scripts/macro.lst >pnglibconf.tf8 + mv pnglibconf.tf8 $@ + +pngprefix.h: scripts/intprefix.out + rm -f pngprefix.tf1 + $(AWK) '{print "#define", $$1, "@PNG_PREFIX@" $$1}' $? >pngprefix.tf1 + mv pngprefix.tf1 $@ +else +pnglibconf.h: pnglibconf.out + rm -f $@ + cp $? $@ + +pngprefix.h: # is empty + :>$@ +endif + +$(srcdir)/scripts/pnglibconf.h.prebuilt: + @echo "Attempting to build $@" >&2 + @echo "This is a machine generated file, but if you want to make" >&2 + @echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2 + @echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2 + @exit 1 + +# The following is necessary to ensure that the local pnglibconf.h is used, not +# an installed one (this can happen immediately after on a clean system if +# 'make test' is the first thing the user does.) Only files which include +# one of the png source files (typically png.h or pngpriv.h) need to be listed +# here: +pngtest.o: pnglibconf.h + +contrib/libtests/makepng.o: pnglibconf.h +contrib/libtests/pngstest.o: pnglibconf.h +contrib/libtests/pngunknown.o: pnglibconf.h +contrib/libtests/pngimage.o: pnglibconf.h +contrib/libtests/pngvalid.o: pnglibconf.h +contrib/libtests/readpng.o: pnglibconf.h +contrib/libtests/tarith.o: pnglibconf.h +contrib/libtests/timepng.o: pnglibconf.h + +contrib/tools/makesRGB.o: pnglibconf.h +contrib/tools/pngfix.o: pnglibconf.h +contrib/tools/pngcp.o: pnglibconf.h + +# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually +# be built with PNG_USE_READ_MACROS; this prevents the read macros from +# interfering with the symbol file format. +SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\ + -DPNGLIB_VERSION='@PNGLIB_VERSION@'\ + -DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'\ + -DPNG_NO_USE_READ_MACROS -DPNG_BUILDING_SYMBOL_TABLE + +if DO_PNG_PREFIX +SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@' +endif + +.c.out: + rm -f $@ $*.tf[12] + test -d scripts || mkdir scripts || test -d scripts + $(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\ + $(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1 + $(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2 + rm -f $*.tf1 + mv $*.tf2 $@ + +# The .c file for pnglibconf.h is machine generated +pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA) + rm -f $@ $*.tf[45] + $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\ + ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ + ${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2 + rm $*.tf4 + mv $*.tf5 $@ + +# Symbol checks (.def and .out files should match) +scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out + +.out.chk: + rm -f $@ $*.new + $(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\ + of="$*.new" $< >&2 + mv $*.new $@ + +# used on demand to regenerate the standard header, CPPFLAGS should +# be empty - no non-standard defines +scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h + rm -f $@ pnglibconf.tf[67] + test -z "$(CPPFLAGS)" + echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\ + $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf6\ + logunsupported=1 version=search ${srcdir}/pngconf.h -\ + ${srcdir}/scripts/pnglibconf.dfa 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf7\ + pnglibconf.tf6 1>&2 + rm pnglibconf.tf6 + mv pnglibconf.tf7 $@ + +$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h \ + pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h pngprefix.h + +test: check-am + +# Extra checks +check: scripts/symbols.chk + +# Don't distribute the generated script files +dist-hook: + cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES) + +# Make links between installed files with release-specific names and the generic +# file names. If this install rule is run the generic names will be deleted and +# recreated - this has obvious issues for systems with multiple installations. + +install-header-links: + @set -ex; cd '$(DESTDIR)$(includedir)'; for f in $(HEADERS); do \ + rm -f "$$f"; $(LN_S) "$(PNGLIB_BASENAME)/$$f" "$$f"; done + +uninstall-header-links: + cd '$(DESTDIR)$(includedir)'; rm -f $(HEADERS) + +install-libpng-pc: + @set -ex; cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc; \ + $(LN_S) '$(PNGLIB_BASENAME).pc' libpng.pc + +uninstall-libpng-pc: + rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc' + +# EXT_LIST is a list of the possibly library directory extensions, this exists +# because we can't find a good way of discovering the file extensions that are +# actually installed on a given system, so instead we check for every extension +# we have seen. + +EXT_LIST = a dll.a so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ la sl dylib + +install-library-links: + @set -x; cd '$(DESTDIR)$(libdir)';\ + for ext in $(EXT_LIST); do\ + rm -f "libpng.$$ext";\ + if test -f "$(PNGLIB_BASENAME).$$ext"; then\ + $(LN_S) "$(PNGLIB_BASENAME).$$ext" "libpng.$$ext" || exit 1;\ + fi;\ + done + +uninstall-library-links: + @set -x; cd '$(DESTDIR)$(libdir)'; for ext in $(EXT_LIST); do\ + rm -f "libpng.$$ext"; done + +install-libpng-config: + @set -ex; cd '$(DESTDIR)$(bindir)'; rm -f libpng-config; \ + $(LN_S) '$(PNGLIB_BASENAME)-config' libpng-config + +uninstall-libpng-config: + rm -f '$(DESTDIR)$(bindir)/libpng-config' + +if DO_INSTALL_LINKS +# If --enable-unversioned-links is specified the header and lib file links +# will be automatically made on a 'make install': + +install-data-hook: install-header-links +uninstall-hook: uninstall-header-links +install-exec-hook: install-library-links +uninstall-hook: uninstall-library-links +endif + +if DO_INSTALL_LIBPNG_PC +# Likewise, --install-pc causes libpng.pc to be constructed: + +install-data-hook: install-libpng-pc +uninstall-hook: uninstall-libpng-pc +endif + +if DO_INSTALL_LIBPNG_CONFIG +# And --install-config: + +install-exec-hook: install-libpng-config +uninstall-hook: uninstall-libpng-config +endif + +# The following addition ensures that 'make all' always builds the test programs +# too. It used to, but some change either in libpng or configure stopped this +# working. +all-am: $(check_PROGRAMS) diff --git a/thirdparty/libpng-1.6.37/Makefile.in b/thirdparty/libpng-1.6.37/Makefile.in new file mode 100644 index 0000000..81ac1c8 --- /dev/null +++ b/thirdparty/libpng-1.6.37/Makefile.in @@ -0,0 +1,2428 @@ +# Makefile.in generated by automake 1.16.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2018 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Makefile.am, the source file for Makefile.in (and hence Makefile), is +# +# Copyright (c) 2018 Cosmin Truta +# Copyright (c) 2004-2016 Glenn Randers-Pehrson +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + + + + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = pngtest$(EXEEXT) pngunknown$(EXEEXT) \ + pngstest$(EXEEXT) pngvalid$(EXEEXT) pngimage$(EXEEXT) \ + pngcp$(EXEEXT) $(am__EXEEXT_1) +@HAVE_CLOCK_GETTIME_TRUE@am__append_1 = timepng +bin_PROGRAMS = pngfix$(EXEEXT) png-fix-itxt$(EXEEXT) +@PNG_ARM_NEON_TRUE@am__append_2 = arm/arm_init.c\ +@PNG_ARM_NEON_TRUE@ arm/filter_neon.S arm/filter_neon_intrinsics.c \ +@PNG_ARM_NEON_TRUE@ arm/palette_neon_intrinsics.c + +@PNG_MIPS_MSA_TRUE@am__append_3 = mips/mips_init.c\ +@PNG_MIPS_MSA_TRUE@ mips/filter_msa_intrinsics.c + +@PNG_INTEL_SSE_TRUE@am__append_4 = intel/intel_init.c\ +@PNG_INTEL_SSE_TRUE@ intel/filter_sse2_intrinsics.c + +@PNG_POWERPC_VSX_TRUE@am__append_5 = powerpc/powerpc_init.c\ +@PNG_POWERPC_VSX_TRUE@ powerpc/filter_vsx_intrinsics.c + + +# Versioned symbols and restricted exports +@HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_TRUE@am__append_6 = -Wl,-M -Wl,libpng.vers +@HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_FALSE@am__append_7 = -Wl,--version-script=libpng.vers +# Only restricted exports when possible +@HAVE_LD_VERSION_SCRIPT_FALSE@am__append_8 = -export-symbols libpng.sym +@DO_PNG_PREFIX_TRUE@am__append_9 = -DPNG_PREFIX='@PNG_PREFIX@' +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/scripts/libtool.m4 \ + $(top_srcdir)/scripts/ltoptions.m4 \ + $(top_srcdir)/scripts/ltsugar.m4 \ + $(top_srcdir)/scripts/ltversion.m4 \ + $(top_srcdir)/scripts/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(pkginclude_HEADERS) $(am__DIST_COMMON) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = libpng.pc libpng-config +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" \ + "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man3dir)" \ + "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(pkgconfigdir)" \ + "$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)" +@HAVE_CLOCK_GETTIME_TRUE@am__EXEEXT_1 = timepng$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +LTLIBRARIES = $(lib_LTLIBRARIES) +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = +am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES_DIST = png.c \ + pngerror.c pngget.c pngmem.c pngpread.c pngread.c pngrio.c \ + pngrtran.c pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c \ + pngwtran.c pngwutil.c png.h pngconf.h pngdebug.h pnginfo.h \ + pngpriv.h pngstruct.h pngusr.dfa arm/arm_init.c \ + arm/filter_neon.S arm/filter_neon_intrinsics.c \ + arm/palette_neon_intrinsics.c mips/mips_init.c \ + mips/filter_msa_intrinsics.c intel/intel_init.c \ + intel/filter_sse2_intrinsics.c powerpc/powerpc_init.c \ + powerpc/filter_vsx_intrinsics.c +am__dirstamp = $(am__leading_dot)dirstamp +@PNG_ARM_NEON_TRUE@am__objects_1 = arm/arm_init.lo arm/filter_neon.lo \ +@PNG_ARM_NEON_TRUE@ arm/filter_neon_intrinsics.lo \ +@PNG_ARM_NEON_TRUE@ arm/palette_neon_intrinsics.lo +@PNG_MIPS_MSA_TRUE@am__objects_2 = mips/mips_init.lo \ +@PNG_MIPS_MSA_TRUE@ mips/filter_msa_intrinsics.lo +@PNG_INTEL_SSE_TRUE@am__objects_3 = intel/intel_init.lo \ +@PNG_INTEL_SSE_TRUE@ intel/filter_sse2_intrinsics.lo +@PNG_POWERPC_VSX_TRUE@am__objects_4 = powerpc/powerpc_init.lo \ +@PNG_POWERPC_VSX_TRUE@ powerpc/filter_vsx_intrinsics.lo +am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS = png.lo pngerror.lo \ + pngget.lo pngmem.lo pngpread.lo pngread.lo pngrio.lo \ + pngrtran.lo pngrutil.lo pngset.lo pngtrans.lo pngwio.lo \ + pngwrite.lo pngwtran.lo pngwutil.lo $(am__objects_1) \ + $(am__objects_2) $(am__objects_3) $(am__objects_4) +nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS = +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS = \ + $(am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) \ + $(nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LINK = $(LIBTOOL) $(AM_V_lt) \ + --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ + $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS) $(LDFLAGS) -o \ + $@ +am_png_fix_itxt_OBJECTS = contrib/tools/png-fix-itxt.$(OBJEXT) +png_fix_itxt_OBJECTS = $(am_png_fix_itxt_OBJECTS) +png_fix_itxt_LDADD = $(LDADD) +am_pngcp_OBJECTS = contrib/tools/pngcp.$(OBJEXT) +pngcp_OBJECTS = $(am_pngcp_OBJECTS) +pngcp_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_pngfix_OBJECTS = contrib/tools/pngfix.$(OBJEXT) +pngfix_OBJECTS = $(am_pngfix_OBJECTS) +pngfix_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_pngimage_OBJECTS = contrib/libtests/pngimage.$(OBJEXT) +pngimage_OBJECTS = $(am_pngimage_OBJECTS) +pngimage_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_pngstest_OBJECTS = contrib/libtests/pngstest.$(OBJEXT) +pngstest_OBJECTS = $(am_pngstest_OBJECTS) +pngstest_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_pngtest_OBJECTS = pngtest.$(OBJEXT) +pngtest_OBJECTS = $(am_pngtest_OBJECTS) +pngtest_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_pngunknown_OBJECTS = contrib/libtests/pngunknown.$(OBJEXT) +pngunknown_OBJECTS = $(am_pngunknown_OBJECTS) +pngunknown_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_pngvalid_OBJECTS = contrib/libtests/pngvalid.$(OBJEXT) +pngvalid_OBJECTS = $(am_pngvalid_OBJECTS) +pngvalid_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_timepng_OBJECTS = contrib/libtests/timepng.$(OBJEXT) +timepng_OBJECTS = $(am_timepng_OBJECTS) +timepng_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +SCRIPTS = $(bin_SCRIPTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/png.Plo ./$(DEPDIR)/pngerror.Plo \ + ./$(DEPDIR)/pngget.Plo ./$(DEPDIR)/pngmem.Plo \ + ./$(DEPDIR)/pngpread.Plo ./$(DEPDIR)/pngread.Plo \ + ./$(DEPDIR)/pngrio.Plo ./$(DEPDIR)/pngrtran.Plo \ + ./$(DEPDIR)/pngrutil.Plo ./$(DEPDIR)/pngset.Plo \ + ./$(DEPDIR)/pngtest.Po ./$(DEPDIR)/pngtrans.Plo \ + ./$(DEPDIR)/pngwio.Plo ./$(DEPDIR)/pngwrite.Plo \ + ./$(DEPDIR)/pngwtran.Plo ./$(DEPDIR)/pngwutil.Plo \ + arm/$(DEPDIR)/arm_init.Plo arm/$(DEPDIR)/filter_neon.Plo \ + arm/$(DEPDIR)/filter_neon_intrinsics.Plo \ + arm/$(DEPDIR)/palette_neon_intrinsics.Plo \ + contrib/libtests/$(DEPDIR)/pngimage.Po \ + contrib/libtests/$(DEPDIR)/pngstest.Po \ + contrib/libtests/$(DEPDIR)/pngunknown.Po \ + contrib/libtests/$(DEPDIR)/pngvalid.Po \ + contrib/libtests/$(DEPDIR)/timepng.Po \ + contrib/tools/$(DEPDIR)/png-fix-itxt.Po \ + contrib/tools/$(DEPDIR)/pngcp.Po \ + contrib/tools/$(DEPDIR)/pngfix.Po \ + intel/$(DEPDIR)/filter_sse2_intrinsics.Plo \ + intel/$(DEPDIR)/intel_init.Plo \ + mips/$(DEPDIR)/filter_msa_intrinsics.Plo \ + mips/$(DEPDIR)/mips_init.Plo \ + powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo \ + powerpc/$(DEPDIR)/powerpc_init.Plo +am__mv = mv -f +CPPASCOMPILE = $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) +LTCPPASCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CCASFLAGS) $(CCASFLAGS) +AM_V_CPPAS = $(am__v_CPPAS_@AM_V@) +am__v_CPPAS_ = $(am__v_CPPAS_@AM_DEFAULT_V@) +am__v_CPPAS_0 = @echo " CPPAS " $@; +am__v_CPPAS_1 = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES) \ + $(nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES) \ + $(png_fix_itxt_SOURCES) $(pngcp_SOURCES) $(pngfix_SOURCES) \ + $(pngimage_SOURCES) $(pngstest_SOURCES) $(pngtest_SOURCES) \ + $(pngunknown_SOURCES) $(pngvalid_SOURCES) $(timepng_SOURCES) +DIST_SOURCES = \ + $(am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES_DIST) \ + $(png_fix_itxt_SOURCES) $(pngcp_SOURCES) $(pngfix_SOURCES) \ + $(pngimage_SOURCES) $(pngstest_SOURCES) $(pngtest_SOURCES) \ + $(pngunknown_SOURCES) $(pngvalid_SOURCES) $(timepng_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +man3dir = $(mandir)/man3 +man5dir = $(mandir)/man5 +NROFF = nroff +MANS = $(dist_man_MANS) +DATA = $(pkgconfig_DATA) +HEADERS = $(nodist_pkginclude_HEADERS) $(pkginclude_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ + $(LISP)config.h.in +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +CSCOPE = cscope +AM_RECURSIVE_TARGETS = cscope check recheck +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red=''; \ + grn=''; \ + lgn=''; \ + blu=''; \ + mgn=''; \ + brg=''; \ + std=''; \ + fi; \ +} +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in \ + $(srcdir)/config.h.in $(srcdir)/libpng-config.in \ + $(srcdir)/libpng.pc.in AUTHORS INSTALL README TODO compile \ + config.guess config.sub depcomp install-sh ltmain.sh missing \ + test-driver +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + if test -d "$(distdir)"; then \ + find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -rf "$(distdir)" \ + || { sleep 5 && rm -rf "$(distdir)"; }; \ + else :; fi +am__post_remove_distdir = $(am__remove_distdir) +DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.xz +GZIP_ENV = --best +DIST_TARGETS = dist-xz dist-gzip +distuninstallcheck_listfiles = find . -type f -print +am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ + | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' +distcleancheck_listfiles = find . -type f -print + +#distribute headers in /usr/include/libpng/* +pkgincludedir = $(includedir)/$(PNGLIB_BASENAME) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ + +# DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe +# other operating systems (NeXT?) the C preprocessor selected by configure +# checks input tokens for validity - effectively it performs part of the ANSI-C +# parsing - and therefore fails with the .df files. configure.ac has special +# checks for this and sets DFNCPP appropriately. +DFNCPP = @DFNCPP@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PNGLIB_MAJOR = @PNGLIB_MAJOR@ +PNGLIB_MINOR = @PNGLIB_MINOR@ +PNGLIB_RELEASE = @PNGLIB_RELEASE@ +PNGLIB_VERSION = @PNGLIB_VERSION@ + +# PNG_COPTS give extra options for the C compiler to be used on all compilation +# steps (unless targe_CFLAGS is specified; that will take precedence over +# AM_CFLAGS) +PNG_COPTS = @PNG_COPTS@ +PNG_PREFIX = @PNG_PREFIX@ +POW_LIB = @POW_LIB@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYMBOL_PREFIX = @SYMBOL_PREFIX@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ + +# generate the -config scripts if required +binconfigs = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ + +# pkg-config stuff, note that libpng.pc is always required in order +# to get the correct library +pkgconfigdir = @pkgconfigdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +PNGLIB_BASENAME = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ +ACLOCAL_AMFLAGS = -I scripts + +# This ensures that pnglibconf.h gets built at the start of 'make all' or +# 'make check', but it does not add dependencies to the individual programs, +# this is done below. +# +# IMPORTANT: always add the object modules of new programs to the list below +# because otherwise the sequence 'configure; make new-program' will *sometimes* +# result in the installed (system) pnglibconf.h being used and the result is +# always wrong and always very confusing. +BUILT_SOURCES = pnglibconf.h +pngtest_SOURCES = pngtest.c +pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +pngvalid_SOURCES = contrib/libtests/pngvalid.c +pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +pngstest_SOURCES = contrib/libtests/pngstest.c +pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +pngunknown_SOURCES = contrib/libtests/pngunknown.c +pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +pngimage_SOURCES = contrib/libtests/pngimage.c +pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +timepng_SOURCES = contrib/libtests/timepng.c +timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +pngfix_SOURCES = contrib/tools/pngfix.c +pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c +pngcp_SOURCES = contrib/tools/pngcp.c +pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +# Generally these are single line shell scripts to run a test with a particular +# set of parameters: +TESTS = \ + tests/pngtest\ + tests/pngtest-badpngs\ + tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\ + tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\ + tests/pngvalid-gamma-expand16-background\ + tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\ + tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\ + tests/pngvalid-progressive-size\ + tests/pngvalid-progressive-interlace-standard\ + tests/pngvalid-transform\ + tests/pngvalid-progressive-standard tests/pngvalid-standard\ + tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\ + tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\ + tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\ + tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\ + tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\ + tests/pngimage-quick tests/pngimage-full + + +# man pages +dist_man_MANS = libpng.3 libpngpf.3 png.5 +EXTRA_SCRIPTS = libpng-config libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config +bin_SCRIPTS = @binconfigs@ + +# rules to build libpng, only build the old library on request +lib_LTLIBRARIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +# EXTRA_LTLIBRARIES= libpng.la +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c \ + pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c \ + pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c \ + pngwutil.c png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h \ + pngstruct.h pngusr.dfa $(am__append_2) $(am__append_3) \ + $(am__append_4) $(am__append_5) +nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined \ + -export-dynamic -version-number \ + @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0 \ + $(am__append_6) $(am__append_7) $(am__append_8) +@HAVE_LD_VERSION_SCRIPT_FALSE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym +@HAVE_LD_VERSION_SCRIPT_TRUE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.vers +pkginclude_HEADERS = png.h pngconf.h +nodist_pkginclude_HEADERS = pnglibconf.h +pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc + +# Extra source distribution files, '${srcdir}' is used below to stop build files +# from those directories being included. This only works if the configure is +# not done in the source directory! +EXTRA_DIST = \ + ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \ + pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \ + ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \ + $(TESTS) $(XFAIL_TESTS) tests/pngstest \ + CMakeLists.txt example.c libpng-manual.txt + +SCRIPT_CLEANFILES = scripts/*.out scripts/*.chk +CLEANFILES = *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \ + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \ + check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \ + pnglibconf.out pnglibconf.c pnglibconf.pre pnglibconf.dfn \ + $(SCRIPT_CLEANFILES) + +MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \ +config.sub configure depcomp install-sh ltmain.sh missing + +AM_CFLAGS = ${PNG_COPTS} +SUFFIXES = .chk .out + +# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually +# be built with PNG_USE_READ_MACROS; this prevents the read macros from +# interfering with the symbol file format. +SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0' \ + -DPNGLIB_VERSION='@PNGLIB_VERSION@' \ + -DSYMBOL_PREFIX='$(SYMBOL_PREFIX)' -DPNG_NO_USE_READ_MACROS \ + -DPNG_BUILDING_SYMBOL_TABLE $(am__append_9) + +# EXT_LIST is a list of the possibly library directory extensions, this exists +# because we can't find a good way of discovering the file extensions that are +# actually installed on a given system, so instead we check for every extension +# we have seen. +EXT_LIST = a dll.a so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ la sl dylib +all: $(BUILT_SOURCES) config.h + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .chk .out .S .c .lo .log .o .obj .test .test$(EXEEXT) .trs +am--refresh: Makefile + @: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +config.h: stamp-h1 + @test -f $@ || rm -f stamp-h1 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +libpng.pc: $(top_builddir)/config.status $(srcdir)/libpng.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +libpng-config: $(top_builddir)/config.status $(srcdir)/libpng-config.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } +arm/$(am__dirstamp): + @$(MKDIR_P) arm + @: > arm/$(am__dirstamp) +arm/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) arm/$(DEPDIR) + @: > arm/$(DEPDIR)/$(am__dirstamp) +arm/arm_init.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp) +arm/filter_neon.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp) +arm/filter_neon_intrinsics.lo: arm/$(am__dirstamp) \ + arm/$(DEPDIR)/$(am__dirstamp) +arm/palette_neon_intrinsics.lo: arm/$(am__dirstamp) \ + arm/$(DEPDIR)/$(am__dirstamp) +mips/$(am__dirstamp): + @$(MKDIR_P) mips + @: > mips/$(am__dirstamp) +mips/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) mips/$(DEPDIR) + @: > mips/$(DEPDIR)/$(am__dirstamp) +mips/mips_init.lo: mips/$(am__dirstamp) mips/$(DEPDIR)/$(am__dirstamp) +mips/filter_msa_intrinsics.lo: mips/$(am__dirstamp) \ + mips/$(DEPDIR)/$(am__dirstamp) +intel/$(am__dirstamp): + @$(MKDIR_P) intel + @: > intel/$(am__dirstamp) +intel/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) intel/$(DEPDIR) + @: > intel/$(DEPDIR)/$(am__dirstamp) +intel/intel_init.lo: intel/$(am__dirstamp) \ + intel/$(DEPDIR)/$(am__dirstamp) +intel/filter_sse2_intrinsics.lo: intel/$(am__dirstamp) \ + intel/$(DEPDIR)/$(am__dirstamp) +powerpc/$(am__dirstamp): + @$(MKDIR_P) powerpc + @: > powerpc/$(am__dirstamp) +powerpc/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) powerpc/$(DEPDIR) + @: > powerpc/$(DEPDIR)/$(am__dirstamp) +powerpc/powerpc_init.lo: powerpc/$(am__dirstamp) \ + powerpc/$(DEPDIR)/$(am__dirstamp) +powerpc/filter_vsx_intrinsics.lo: powerpc/$(am__dirstamp) \ + powerpc/$(DEPDIR)/$(am__dirstamp) + +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la: $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES) $(EXTRA_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES) + $(AM_V_CCLD)$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LINK) -rpath $(libdir) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD) $(LIBS) +contrib/tools/$(am__dirstamp): + @$(MKDIR_P) contrib/tools + @: > contrib/tools/$(am__dirstamp) +contrib/tools/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) contrib/tools/$(DEPDIR) + @: > contrib/tools/$(DEPDIR)/$(am__dirstamp) +contrib/tools/png-fix-itxt.$(OBJEXT): contrib/tools/$(am__dirstamp) \ + contrib/tools/$(DEPDIR)/$(am__dirstamp) + +png-fix-itxt$(EXEEXT): $(png_fix_itxt_OBJECTS) $(png_fix_itxt_DEPENDENCIES) $(EXTRA_png_fix_itxt_DEPENDENCIES) + @rm -f png-fix-itxt$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(png_fix_itxt_OBJECTS) $(png_fix_itxt_LDADD) $(LIBS) +contrib/tools/pngcp.$(OBJEXT): contrib/tools/$(am__dirstamp) \ + contrib/tools/$(DEPDIR)/$(am__dirstamp) + +pngcp$(EXEEXT): $(pngcp_OBJECTS) $(pngcp_DEPENDENCIES) $(EXTRA_pngcp_DEPENDENCIES) + @rm -f pngcp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngcp_OBJECTS) $(pngcp_LDADD) $(LIBS) +contrib/tools/pngfix.$(OBJEXT): contrib/tools/$(am__dirstamp) \ + contrib/tools/$(DEPDIR)/$(am__dirstamp) + +pngfix$(EXEEXT): $(pngfix_OBJECTS) $(pngfix_DEPENDENCIES) $(EXTRA_pngfix_DEPENDENCIES) + @rm -f pngfix$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngfix_OBJECTS) $(pngfix_LDADD) $(LIBS) +contrib/libtests/$(am__dirstamp): + @$(MKDIR_P) contrib/libtests + @: > contrib/libtests/$(am__dirstamp) +contrib/libtests/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) contrib/libtests/$(DEPDIR) + @: > contrib/libtests/$(DEPDIR)/$(am__dirstamp) +contrib/libtests/pngimage.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngimage$(EXEEXT): $(pngimage_OBJECTS) $(pngimage_DEPENDENCIES) $(EXTRA_pngimage_DEPENDENCIES) + @rm -f pngimage$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngimage_OBJECTS) $(pngimage_LDADD) $(LIBS) +contrib/libtests/pngstest.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngstest$(EXEEXT): $(pngstest_OBJECTS) $(pngstest_DEPENDENCIES) $(EXTRA_pngstest_DEPENDENCIES) + @rm -f pngstest$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngstest_OBJECTS) $(pngstest_LDADD) $(LIBS) + +pngtest$(EXEEXT): $(pngtest_OBJECTS) $(pngtest_DEPENDENCIES) $(EXTRA_pngtest_DEPENDENCIES) + @rm -f pngtest$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngtest_OBJECTS) $(pngtest_LDADD) $(LIBS) +contrib/libtests/pngunknown.$(OBJEXT): \ + contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngunknown$(EXEEXT): $(pngunknown_OBJECTS) $(pngunknown_DEPENDENCIES) $(EXTRA_pngunknown_DEPENDENCIES) + @rm -f pngunknown$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngunknown_OBJECTS) $(pngunknown_LDADD) $(LIBS) +contrib/libtests/pngvalid.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngvalid$(EXEEXT): $(pngvalid_OBJECTS) $(pngvalid_DEPENDENCIES) $(EXTRA_pngvalid_DEPENDENCIES) + @rm -f pngvalid$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngvalid_OBJECTS) $(pngvalid_LDADD) $(LIBS) +contrib/libtests/timepng.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +timepng$(EXEEXT): $(timepng_OBJECTS) $(timepng_DEPENDENCIES) $(EXTRA_timepng_DEPENDENCIES) + @rm -f timepng$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(timepng_OBJECTS) $(timepng_LDADD) $(LIBS) +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + -rm -f arm/*.$(OBJEXT) + -rm -f arm/*.lo + -rm -f contrib/libtests/*.$(OBJEXT) + -rm -f contrib/tools/*.$(OBJEXT) + -rm -f intel/*.$(OBJEXT) + -rm -f intel/*.lo + -rm -f mips/*.$(OBJEXT) + -rm -f mips/*.lo + -rm -f powerpc/*.$(OBJEXT) + -rm -f powerpc/*.lo + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/png.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngerror.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngget.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngmem.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngpread.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngread.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngrio.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngrtran.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngrutil.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngset.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngtest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngtrans.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngwio.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngwrite.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngwtran.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngwutil.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/arm_init.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/filter_neon.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/filter_neon_intrinsics.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/palette_neon_intrinsics.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngimage.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngstest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngunknown.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngvalid.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/timepng.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/tools/$(DEPDIR)/png-fix-itxt.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/tools/$(DEPDIR)/pngcp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/tools/$(DEPDIR)/pngfix.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@intel/$(DEPDIR)/filter_sse2_intrinsics.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@intel/$(DEPDIR)/intel_init.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@mips/$(DEPDIR)/filter_msa_intrinsics.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@mips/$(DEPDIR)/mips_init.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@powerpc/$(DEPDIR)/powerpc_init.Plo@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.S.o: +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ $< + +.S.obj: +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.S.lo: +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCCAS_TRUE@ $(LTCPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LTCPPASCOMPILE) -c -o $@ $< + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + -rm -rf arm/.libs arm/_libs + -rm -rf intel/.libs intel/_libs + -rm -rf mips/.libs mips/_libs + -rm -rf powerpc/.libs powerpc/_libs + +distclean-libtool: + -rm -f libtool config.lt +install-man3: $(dist_man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(dist_man_MANS)'; \ + test -n "$(man3dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.3[a-z]*$$/p'; \ + fi; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \ + done; } + +uninstall-man3: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man3dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.3[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir) +install-man5: $(dist_man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(dist_man_MANS)'; \ + test -n "$(man5dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.5[a-z]*$$/p'; \ + fi; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man5dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \ + done; } + +uninstall-man5: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man5dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.5[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir) +install-pkgconfigDATA: $(pkgconfig_DATA) + @$(NORMAL_INSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ + done + +uninstall-pkgconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) +install-nodist_pkgincludeHEADERS: $(nodist_pkginclude_HEADERS) + @$(NORMAL_INSTALL) + @list='$(nodist_pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ + done + +uninstall-nodist_pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(nodist_pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) +install-pkgincludeHEADERS: $(pkginclude_HEADERS) + @$(NORMAL_INSTALL) + @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ + done + +uninstall-pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscope: cscope.files + test ! -s cscope.files \ + || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) +clean-cscope: + -rm -f cscope.files +cscope.files: clean-cscope cscopelist +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + -rm -f cscope.out cscope.in.out cscope.po.out cscope.files + +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + elif test -n "$$redo_logs"; then \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: $(check_PROGRAMS) + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all $(check_PROGRAMS) + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +tests/pngtest.log: tests/pngtest + @p='tests/pngtest'; \ + b='tests/pngtest'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngtest-badpngs.log: tests/pngtest-badpngs + @p='tests/pngtest-badpngs'; \ + b='tests/pngtest-badpngs'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-16-to-8.log: tests/pngvalid-gamma-16-to-8 + @p='tests/pngvalid-gamma-16-to-8'; \ + b='tests/pngvalid-gamma-16-to-8'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-alpha-mode.log: tests/pngvalid-gamma-alpha-mode + @p='tests/pngvalid-gamma-alpha-mode'; \ + b='tests/pngvalid-gamma-alpha-mode'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-background.log: tests/pngvalid-gamma-background + @p='tests/pngvalid-gamma-background'; \ + b='tests/pngvalid-gamma-background'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-expand16-alpha-mode.log: tests/pngvalid-gamma-expand16-alpha-mode + @p='tests/pngvalid-gamma-expand16-alpha-mode'; \ + b='tests/pngvalid-gamma-expand16-alpha-mode'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-expand16-background.log: tests/pngvalid-gamma-expand16-background + @p='tests/pngvalid-gamma-expand16-background'; \ + b='tests/pngvalid-gamma-expand16-background'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-expand16-transform.log: tests/pngvalid-gamma-expand16-transform + @p='tests/pngvalid-gamma-expand16-transform'; \ + b='tests/pngvalid-gamma-expand16-transform'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-sbit.log: tests/pngvalid-gamma-sbit + @p='tests/pngvalid-gamma-sbit'; \ + b='tests/pngvalid-gamma-sbit'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-threshold.log: tests/pngvalid-gamma-threshold + @p='tests/pngvalid-gamma-threshold'; \ + b='tests/pngvalid-gamma-threshold'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-transform.log: tests/pngvalid-gamma-transform + @p='tests/pngvalid-gamma-transform'; \ + b='tests/pngvalid-gamma-transform'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-progressive-size.log: tests/pngvalid-progressive-size + @p='tests/pngvalid-progressive-size'; \ + b='tests/pngvalid-progressive-size'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-progressive-interlace-standard.log: tests/pngvalid-progressive-interlace-standard + @p='tests/pngvalid-progressive-interlace-standard'; \ + b='tests/pngvalid-progressive-interlace-standard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-transform.log: tests/pngvalid-transform + @p='tests/pngvalid-transform'; \ + b='tests/pngvalid-transform'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-progressive-standard.log: tests/pngvalid-progressive-standard + @p='tests/pngvalid-progressive-standard'; \ + b='tests/pngvalid-progressive-standard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-standard.log: tests/pngvalid-standard + @p='tests/pngvalid-standard'; \ + b='tests/pngvalid-standard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-1.8.log: tests/pngstest-1.8 + @p='tests/pngstest-1.8'; \ + b='tests/pngstest-1.8'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-1.8-alpha.log: tests/pngstest-1.8-alpha + @p='tests/pngstest-1.8-alpha'; \ + b='tests/pngstest-1.8-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-linear.log: tests/pngstest-linear + @p='tests/pngstest-linear'; \ + b='tests/pngstest-linear'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-linear-alpha.log: tests/pngstest-linear-alpha + @p='tests/pngstest-linear-alpha'; \ + b='tests/pngstest-linear-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-none.log: tests/pngstest-none + @p='tests/pngstest-none'; \ + b='tests/pngstest-none'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-none-alpha.log: tests/pngstest-none-alpha + @p='tests/pngstest-none-alpha'; \ + b='tests/pngstest-none-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-sRGB.log: tests/pngstest-sRGB + @p='tests/pngstest-sRGB'; \ + b='tests/pngstest-sRGB'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-sRGB-alpha.log: tests/pngstest-sRGB-alpha + @p='tests/pngstest-sRGB-alpha'; \ + b='tests/pngstest-sRGB-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-IDAT.log: tests/pngunknown-IDAT + @p='tests/pngunknown-IDAT'; \ + b='tests/pngunknown-IDAT'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-discard.log: tests/pngunknown-discard + @p='tests/pngunknown-discard'; \ + b='tests/pngunknown-discard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-if-safe.log: tests/pngunknown-if-safe + @p='tests/pngunknown-if-safe'; \ + b='tests/pngunknown-if-safe'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-sAPI.log: tests/pngunknown-sAPI + @p='tests/pngunknown-sAPI'; \ + b='tests/pngunknown-sAPI'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-sTER.log: tests/pngunknown-sTER + @p='tests/pngunknown-sTER'; \ + b='tests/pngunknown-sTER'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-save.log: tests/pngunknown-save + @p='tests/pngunknown-save'; \ + b='tests/pngunknown-save'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-vpAg.log: tests/pngunknown-vpAg + @p='tests/pngunknown-vpAg'; \ + b='tests/pngunknown-vpAg'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngimage-quick.log: tests/pngimage-quick + @p='tests/pngimage-quick'; \ + b='tests/pngimage-quick'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngimage-full.log: tests/pngimage-full + @p='tests/pngimage-full'; \ + b='tests/pngimage-full'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + $(am__remove_distdir) + test -d "$(distdir)" || mkdir "$(distdir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook + -test -n "$(am__skip_mode_fix)" \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r "$(distdir)" +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz + $(am__post_remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 + $(am__post_remove_distdir) + +dist-lzip: distdir + tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz + $(am__post_remove_distdir) +dist-xz: distdir + tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz + $(am__post_remove_distdir) + +dist-tarZ: distdir + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__post_remove_distdir) + +dist-shar: distdir + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 + shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz + $(am__post_remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__post_remove_distdir) + +dist dist-all: + $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' + $(am__post_remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lz*) \ + lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ + *.tar.xz*) \ + xz -dc $(distdir).tar.xz | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir) + chmod u+w $(distdir) + mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst + chmod a-w $(distdir) + test -d $(distdir)/_build || exit 0; \ + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && am__cwd=`pwd` \ + && $(am__cd) $(distdir)/_build/sub \ + && ../../configure \ + $(AM_DISTCHECK_CONFIGURE_FLAGS) \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + --srcdir=../.. --prefix="$$dc_install_base" \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ + && cd "$$am__cwd" \ + || exit 1 + $(am__post_remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @test -n '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: trying to run $@ with an empty' \ + '$$(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + $(am__cd) '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(SCRIPTS) $(MANS) $(DATA) \ + $(HEADERS) config.h +install-binPROGRAMS: install-libLTLIBRARIES + +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f arm/$(DEPDIR)/$(am__dirstamp) + -rm -f arm/$(am__dirstamp) + -rm -f contrib/libtests/$(DEPDIR)/$(am__dirstamp) + -rm -f contrib/libtests/$(am__dirstamp) + -rm -f contrib/tools/$(DEPDIR)/$(am__dirstamp) + -rm -f contrib/tools/$(am__dirstamp) + -rm -f intel/$(DEPDIR)/$(am__dirstamp) + -rm -f intel/$(am__dirstamp) + -rm -f mips/$(DEPDIR)/$(am__dirstamp) + -rm -f mips/$(am__dirstamp) + -rm -f powerpc/$(DEPDIR)/$(am__dirstamp) + -rm -f powerpc/$(am__dirstamp) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +@DO_INSTALL_LIBPNG_CONFIG_FALSE@@DO_INSTALL_LINKS_FALSE@install-exec-hook: +@DO_INSTALL_LIBPNG_PC_FALSE@@DO_INSTALL_LINKS_FALSE@install-data-hook: +@DO_INSTALL_LIBPNG_CONFIG_FALSE@@DO_INSTALL_LIBPNG_PC_FALSE@@DO_INSTALL_LINKS_FALSE@uninstall-hook: +clean: clean-am + +clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ + clean-libLTLIBRARIES clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f ./$(DEPDIR)/png.Plo + -rm -f ./$(DEPDIR)/pngerror.Plo + -rm -f ./$(DEPDIR)/pngget.Plo + -rm -f ./$(DEPDIR)/pngmem.Plo + -rm -f ./$(DEPDIR)/pngpread.Plo + -rm -f ./$(DEPDIR)/pngread.Plo + -rm -f ./$(DEPDIR)/pngrio.Plo + -rm -f ./$(DEPDIR)/pngrtran.Plo + -rm -f ./$(DEPDIR)/pngrutil.Plo + -rm -f ./$(DEPDIR)/pngset.Plo + -rm -f ./$(DEPDIR)/pngtest.Po + -rm -f ./$(DEPDIR)/pngtrans.Plo + -rm -f ./$(DEPDIR)/pngwio.Plo + -rm -f ./$(DEPDIR)/pngwrite.Plo + -rm -f ./$(DEPDIR)/pngwtran.Plo + -rm -f ./$(DEPDIR)/pngwutil.Plo + -rm -f arm/$(DEPDIR)/arm_init.Plo + -rm -f arm/$(DEPDIR)/filter_neon.Plo + -rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo + -rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo + -rm -f contrib/libtests/$(DEPDIR)/pngimage.Po + -rm -f contrib/libtests/$(DEPDIR)/pngstest.Po + -rm -f contrib/libtests/$(DEPDIR)/pngunknown.Po + -rm -f contrib/libtests/$(DEPDIR)/pngvalid.Po + -rm -f contrib/libtests/$(DEPDIR)/timepng.Po + -rm -f contrib/tools/$(DEPDIR)/png-fix-itxt.Po + -rm -f contrib/tools/$(DEPDIR)/pngcp.Po + -rm -f contrib/tools/$(DEPDIR)/pngfix.Po + -rm -f intel/$(DEPDIR)/filter_sse2_intrinsics.Plo + -rm -f intel/$(DEPDIR)/intel_init.Plo + -rm -f mips/$(DEPDIR)/filter_msa_intrinsics.Plo + -rm -f mips/$(DEPDIR)/mips_init.Plo + -rm -f powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo + -rm -f powerpc/$(DEPDIR)/powerpc_init.Plo + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-man install-nodist_pkgincludeHEADERS \ + install-pkgconfigDATA install-pkgincludeHEADERS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-data-hook +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS install-binSCRIPTS \ + install-libLTLIBRARIES + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: install-man3 install-man5 + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f ./$(DEPDIR)/png.Plo + -rm -f ./$(DEPDIR)/pngerror.Plo + -rm -f ./$(DEPDIR)/pngget.Plo + -rm -f ./$(DEPDIR)/pngmem.Plo + -rm -f ./$(DEPDIR)/pngpread.Plo + -rm -f ./$(DEPDIR)/pngread.Plo + -rm -f ./$(DEPDIR)/pngrio.Plo + -rm -f ./$(DEPDIR)/pngrtran.Plo + -rm -f ./$(DEPDIR)/pngrutil.Plo + -rm -f ./$(DEPDIR)/pngset.Plo + -rm -f ./$(DEPDIR)/pngtest.Po + -rm -f ./$(DEPDIR)/pngtrans.Plo + -rm -f ./$(DEPDIR)/pngwio.Plo + -rm -f ./$(DEPDIR)/pngwrite.Plo + -rm -f ./$(DEPDIR)/pngwtran.Plo + -rm -f ./$(DEPDIR)/pngwutil.Plo + -rm -f arm/$(DEPDIR)/arm_init.Plo + -rm -f arm/$(DEPDIR)/filter_neon.Plo + -rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo + -rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo + -rm -f contrib/libtests/$(DEPDIR)/pngimage.Po + -rm -f contrib/libtests/$(DEPDIR)/pngstest.Po + -rm -f contrib/libtests/$(DEPDIR)/pngunknown.Po + -rm -f contrib/libtests/$(DEPDIR)/pngvalid.Po + -rm -f contrib/libtests/$(DEPDIR)/timepng.Po + -rm -f contrib/tools/$(DEPDIR)/png-fix-itxt.Po + -rm -f contrib/tools/$(DEPDIR)/pngcp.Po + -rm -f contrib/tools/$(DEPDIR)/pngfix.Po + -rm -f intel/$(DEPDIR)/filter_sse2_intrinsics.Plo + -rm -f intel/$(DEPDIR)/intel_init.Plo + -rm -f mips/$(DEPDIR)/filter_msa_intrinsics.Plo + -rm -f mips/$(DEPDIR)/mips_init.Plo + -rm -f powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo + -rm -f powerpc/$(DEPDIR)/powerpc_init.Plo + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \ + uninstall-libLTLIBRARIES uninstall-man \ + uninstall-nodist_pkgincludeHEADERS uninstall-pkgconfigDATA \ + uninstall-pkgincludeHEADERS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) uninstall-hook +uninstall-man: uninstall-man3 uninstall-man5 + +.MAKE: all check check-am install install-am install-data-am \ + install-exec-am install-strip uninstall-am + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles am--refresh check \ + check-TESTS check-am clean clean-binPROGRAMS \ + clean-checkPROGRAMS clean-cscope clean-generic \ + clean-libLTLIBRARIES clean-libtool cscope cscopelist-am ctags \ + ctags-am dist dist-all dist-bzip2 dist-gzip dist-hook \ + dist-lzip dist-shar dist-tarZ dist-xz dist-zip distcheck \ + distclean distclean-compile distclean-generic distclean-hdr \ + distclean-libtool distclean-tags distcleancheck distdir \ + distuninstallcheck dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-binSCRIPTS \ + install-data install-data-am install-data-hook install-dvi \ + install-dvi-am install-exec install-exec-am install-exec-hook \ + install-html install-html-am install-info install-info-am \ + install-libLTLIBRARIES install-man install-man3 install-man5 \ + install-nodist_pkgincludeHEADERS install-pdf install-pdf-am \ + install-pkgconfigDATA install-pkgincludeHEADERS install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \ + uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-binSCRIPTS uninstall-hook uninstall-libLTLIBRARIES \ + uninstall-man uninstall-man3 uninstall-man5 \ + uninstall-nodist_pkgincludeHEADERS uninstall-pkgconfigDATA \ + uninstall-pkgincludeHEADERS + +.PRECIOUS: Makefile + + +$(PNGLIB_BASENAME).pc: libpng.pc + cp libpng.pc $@ + +$(PNGLIB_BASENAME)-config: libpng-config + cp libpng-config $@ + +scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h +scripts/prefix.out: png.h pngconf.h pnglibconf.out +scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt +scripts/intprefix.out: pnglibconf.h + +libpng.sym: scripts/sym.out + rm -f $@ + cp $? $@ +libpng.vers: scripts/vers.out + rm -f $@ + cp $? $@ + +# Rename functions in scripts/prefix.out with a PNG_PREFIX prefix. +# Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual +# implementation of the macro). +@DO_PNG_PREFIX_TRUE@pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst +@DO_PNG_PREFIX_TRUE@ rm -f $@ +@DO_PNG_PREFIX_TRUE@ $(AWK) 's==0 && NR>1{print prev}\ +@DO_PNG_PREFIX_TRUE@ s==0{prev=$$0}\ +@DO_PNG_PREFIX_TRUE@ s==1{print "#define", $$1, "@PNG_PREFIX@" $$1}\ +@DO_PNG_PREFIX_TRUE@ s==2{print "#define @PNG_PREFIX@png_" $$1, "PNG_" $$1}\ +@DO_PNG_PREFIX_TRUE@ END{print prev}' s=0 pnglibconf.out s=1 scripts/prefix.out\ +@DO_PNG_PREFIX_TRUE@ s=2 ${srcdir}/scripts/macro.lst >pnglibconf.tf8 +@DO_PNG_PREFIX_TRUE@ mv pnglibconf.tf8 $@ + +@DO_PNG_PREFIX_TRUE@pngprefix.h: scripts/intprefix.out +@DO_PNG_PREFIX_TRUE@ rm -f pngprefix.tf1 +@DO_PNG_PREFIX_TRUE@ $(AWK) '{print "#define", $$1, "@PNG_PREFIX@" $$1}' $? >pngprefix.tf1 +@DO_PNG_PREFIX_TRUE@ mv pngprefix.tf1 $@ +@DO_PNG_PREFIX_FALSE@pnglibconf.h: pnglibconf.out +@DO_PNG_PREFIX_FALSE@ rm -f $@ +@DO_PNG_PREFIX_FALSE@ cp $? $@ + +@DO_PNG_PREFIX_FALSE@pngprefix.h: # is empty +@DO_PNG_PREFIX_FALSE@ :>$@ + +$(srcdir)/scripts/pnglibconf.h.prebuilt: + @echo "Attempting to build $@" >&2 + @echo "This is a machine generated file, but if you want to make" >&2 + @echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2 + @echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2 + @exit 1 + +# The following is necessary to ensure that the local pnglibconf.h is used, not +# an installed one (this can happen immediately after on a clean system if +# 'make test' is the first thing the user does.) Only files which include +# one of the png source files (typically png.h or pngpriv.h) need to be listed +# here: +pngtest.o: pnglibconf.h + +contrib/libtests/makepng.o: pnglibconf.h +contrib/libtests/pngstest.o: pnglibconf.h +contrib/libtests/pngunknown.o: pnglibconf.h +contrib/libtests/pngimage.o: pnglibconf.h +contrib/libtests/pngvalid.o: pnglibconf.h +contrib/libtests/readpng.o: pnglibconf.h +contrib/libtests/tarith.o: pnglibconf.h +contrib/libtests/timepng.o: pnglibconf.h + +contrib/tools/makesRGB.o: pnglibconf.h +contrib/tools/pngfix.o: pnglibconf.h +contrib/tools/pngcp.o: pnglibconf.h + +.c.out: + rm -f $@ $*.tf[12] + test -d scripts || mkdir scripts || test -d scripts + $(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\ + $(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1 + $(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2 + rm -f $*.tf1 + mv $*.tf2 $@ + +# The .c file for pnglibconf.h is machine generated +pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA) + rm -f $@ $*.tf[45] + $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\ + ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ + ${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2 + rm $*.tf4 + mv $*.tf5 $@ + +# Symbol checks (.def and .out files should match) +scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out + +.out.chk: + rm -f $@ $*.new + $(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\ + of="$*.new" $< >&2 + mv $*.new $@ + +# used on demand to regenerate the standard header, CPPFLAGS should +# be empty - no non-standard defines +scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h + rm -f $@ pnglibconf.tf[67] + test -z "$(CPPFLAGS)" + echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\ + $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf6\ + logunsupported=1 version=search ${srcdir}/pngconf.h -\ + ${srcdir}/scripts/pnglibconf.dfa 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf7\ + pnglibconf.tf6 1>&2 + rm pnglibconf.tf6 + mv pnglibconf.tf7 $@ + +$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h \ + pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h pngprefix.h + +test: check-am + +# Extra checks +check: scripts/symbols.chk + +# Don't distribute the generated script files +dist-hook: + cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES) + +# Make links between installed files with release-specific names and the generic +# file names. If this install rule is run the generic names will be deleted and +# recreated - this has obvious issues for systems with multiple installations. + +install-header-links: + @set -ex; cd '$(DESTDIR)$(includedir)'; for f in $(HEADERS); do \ + rm -f "$$f"; $(LN_S) "$(PNGLIB_BASENAME)/$$f" "$$f"; done + +uninstall-header-links: + cd '$(DESTDIR)$(includedir)'; rm -f $(HEADERS) + +install-libpng-pc: + @set -ex; cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc; \ + $(LN_S) '$(PNGLIB_BASENAME).pc' libpng.pc + +uninstall-libpng-pc: + rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc' + +install-library-links: + @set -x; cd '$(DESTDIR)$(libdir)';\ + for ext in $(EXT_LIST); do\ + rm -f "libpng.$$ext";\ + if test -f "$(PNGLIB_BASENAME).$$ext"; then\ + $(LN_S) "$(PNGLIB_BASENAME).$$ext" "libpng.$$ext" || exit 1;\ + fi;\ + done + +uninstall-library-links: + @set -x; cd '$(DESTDIR)$(libdir)'; for ext in $(EXT_LIST); do\ + rm -f "libpng.$$ext"; done + +install-libpng-config: + @set -ex; cd '$(DESTDIR)$(bindir)'; rm -f libpng-config; \ + $(LN_S) '$(PNGLIB_BASENAME)-config' libpng-config + +uninstall-libpng-config: + rm -f '$(DESTDIR)$(bindir)/libpng-config' + +# If --enable-unversioned-links is specified the header and lib file links +# will be automatically made on a 'make install': + +@DO_INSTALL_LINKS_TRUE@install-data-hook: install-header-links +@DO_INSTALL_LINKS_TRUE@uninstall-hook: uninstall-header-links +@DO_INSTALL_LINKS_TRUE@install-exec-hook: install-library-links +@DO_INSTALL_LINKS_TRUE@uninstall-hook: uninstall-library-links + +# Likewise, --install-pc causes libpng.pc to be constructed: + +@DO_INSTALL_LIBPNG_PC_TRUE@install-data-hook: install-libpng-pc +@DO_INSTALL_LIBPNG_PC_TRUE@uninstall-hook: uninstall-libpng-pc + +# And --install-config: + +@DO_INSTALL_LIBPNG_CONFIG_TRUE@install-exec-hook: install-libpng-config +@DO_INSTALL_LIBPNG_CONFIG_TRUE@uninstall-hook: uninstall-libpng-config + +# The following addition ensures that 'make all' always builds the test programs +# too. It used to, but some change either in libpng or configure stopped this +# working. +all-am: $(check_PROGRAMS) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/thirdparty/libpng-1.6.37/README b/thirdparty/libpng-1.6.37/README new file mode 100644 index 0000000..cfc1f0e --- /dev/null +++ b/thirdparty/libpng-1.6.37/README @@ -0,0 +1,183 @@ +README for libpng version 1.6.37 - April 14, 2019 +================================================= + +See the note about version numbers near the top of png.h. +See INSTALL for instructions on how to install libpng. + +Libpng comes in several distribution formats. Get libpng-*.tar.gz or +libpng-*.tar.xz or if you want UNIX-style line endings in the text +files, or lpng*.7z or lpng*.zip if you want DOS-style line endings. + +Version 0.89 was the first official release of libpng. Don't let the +fact that it's the first release fool you. The libpng library has been +in extensive use and testing since mid-1995. By late 1997 it had +finally gotten to the stage where there hadn't been significant +changes to the API in some time, and people have a bad feeling about +libraries with versions < 1.0. Version 1.0.0 was released in +March 1998. + +**** +Note that some of the changes to the png_info structure render this +version of the library binary incompatible with libpng-0.89 or +earlier versions if you are using a shared library. The type of the +"filler" parameter for png_set_filler() has changed from png_byte to +png_uint_32, which will affect shared-library applications that use +this function. + +To avoid problems with changes to the internals of the png info_struct, +new APIs have been made available in 0.95 to avoid direct application +access to info_ptr. These functions are the png_set_ and +png_get_ functions. These functions should be used when +accessing/storing the info_struct data, rather than manipulating it +directly, to avoid such problems in the future. + +It is important to note that the APIs did not make current programs +that access the info struct directly incompatible with the new +library, through libpng-1.2.x. In libpng-1.4.x, which was meant to +be a transitional release, members of the png_struct and the +info_struct can still be accessed, but the compiler will issue a +warning about deprecated usage. Since libpng-1.5.0, direct access +to these structs is not allowed, and the definitions of the structs +reside in private pngstruct.h and pnginfo.h header files that are not +accessible to applications. It is strongly suggested that new +programs use the new APIs (as shown in example.c and pngtest.c), and +older programs be converted to the new format, to facilitate upgrades +in the future. +**** + +Additions since 0.90 include the ability to compile libpng as a +Windows DLL, and new APIs for accessing data in the info struct. +Experimental functions include the ability to set weighting and cost +factors for row filter selection, direct reads of integers from buffers +on big-endian processors that support misaligned data access, faster +methods of doing alpha composition, and more accurate 16->8 bit color +conversion. + +The additions since 0.89 include the ability to read from a PNG stream +which has had some (or all) of the signature bytes read by the calling +application. This also allows the reading of embedded PNG streams that +do not have the PNG file signature. As well, it is now possible to set +the library action on the detection of chunk CRC errors. It is possible +to set different actions based on whether the CRC error occurred in a +critical or an ancillary chunk. + +For a detailed description on using libpng, read libpng-manual.txt. +For examples of libpng in a program, see example.c and pngtest.c. For +usage information and restrictions (what little they are) on libpng, +see png.h. For a description on using zlib (the compression library +used by libpng) and zlib's restrictions, see zlib.h + +I have included a general makefile, as well as several machine and +compiler specific ones, but you may have to modify one for your own +needs. + +You should use zlib 1.0.4 or later to run this, but it MAY work with +versions as old as zlib 0.95. Even so, there are bugs in older zlib +versions which can cause the output of invalid compression streams for +some images. + +You should also note that zlib is a compression library that is useful +for more things than just PNG files. You can use zlib as a drop-in +replacement for fread() and fwrite(), if you are so inclined. + +zlib should be available at the same place that libpng is, or at +https://zlib.net. + +You may also want a copy of the PNG specification. It is available +as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find +these at http://www.libpng.org/pub/png/pngdocs.html . + +This code is currently being archived at libpng.sourceforge.io in the +[DOWNLOAD] area, and at http://libpng.download/src . + +This release, based in a large way on Glenn's, Guy's and Andreas' +earlier work, was created and will be supported by myself and the PNG +development group. + +Send comments/corrections/commendations to png-mng-implement at +lists.sourceforge.net (subscription required; visit +https://lists.sourceforge.net/lists/listinfo/png-mng-implement +to subscribe). + +Send general questions about the PNG specification to png-mng-misc +at lists.sourceforge.net (subscription required; visit +https://lists.sourceforge.net/lists/listinfo/png-mng-misc to +subscribe). + +Files in this distribution: + + ANNOUNCE => Announcement of this version, with recent changes + AUTHORS => List of contributing authors + CHANGES => Description of changes between libpng versions + KNOWNBUG => List of known bugs and deficiencies + LICENSE => License to use and redistribute libpng + README => This file + TODO => Things not implemented in the current library + TRADEMARK => Trademark information + example.c => Example code for using libpng functions + libpng.3 => manual page for libpng (includes libpng-manual.txt) + libpng-manual.txt => Description of libpng and its functions + libpngpf.3 => manual page for libpng's private functions + png.5 => manual page for the PNG format + png.c => Basic interface functions common to library + png.h => Library function and interface declarations (public) + pngpriv.h => Library function and interface declarations (private) + pngconf.h => System specific library configuration (public) + pngstruct.h => png_struct declaration (private) + pnginfo.h => png_info struct declaration (private) + pngdebug.h => debugging macros (private) + pngerror.c => Error/warning message I/O functions + pngget.c => Functions for retrieving info from struct + pngmem.c => Memory handling functions + pngbar.png => PNG logo, 88x31 + pngnow.png => PNG logo, 98x31 + pngpread.c => Progressive reading functions + pngread.c => Read data/helper high-level functions + pngrio.c => Lowest-level data read I/O functions + pngrtran.c => Read data transformation functions + pngrutil.c => Read data utility functions + pngset.c => Functions for storing data into the info_struct + pngtest.c => Library test program + pngtest.png => Library test sample image + pngtrans.c => Common data transformation functions + pngwio.c => Lowest-level write I/O functions + pngwrite.c => High-level write functions + pngwtran.c => Write data transformations + pngwutil.c => Write utility functions + arm => Contains optimized code for the ARM platform + powerpc => Contains optimized code for the PowerPC platform + contrib => Contributions + arm-neon => Optimized code for ARM-NEON platform + powerpc-vsx => Optimized code for POWERPC-VSX platform + examples => Example programs + gregbook => source code for PNG reading and writing, from + Greg Roelofs' "PNG: The Definitive Guide", + O'Reilly, 1999 + libtests => Test programs + mips-msa => Optimized code for MIPS-MSA platform + pngminim => Minimal decoder, encoder, and progressive decoder + programs demonstrating use of pngusr.dfa + pngminus => Simple pnm2png and png2pnm programs + pngsuite => Test images + testpngs + tools => Various tools + visupng => Contains a MSVC workspace for VisualPng + intel => Optimized code for INTEL-SSE2 platform + mips => Optimized code for MIPS platform + projects => Contains project files and workspaces for + building a DLL + owatcom => Contains a WATCOM project for building libpng + visualc71 => Contains a Microsoft Visual C++ (MSVC) + workspace for building libpng and zlib + vstudio => Contains a Microsoft Visual C++ (MSVC) + workspace for building libpng and zlib + scripts => Directory containing scripts for building libpng: + (see scripts/README.txt for the list of scripts) + +Good luck, and happy coding! + + * Cosmin Truta (current maintainer, since 2018) + * Glenn Randers-Pehrson (former maintainer, 1998-2018) + * Andreas Eric Dilger (former maintainer, 1996-1997) + * Guy Eric Schalnat (original author and former maintainer, 1995-1996) + (formerly of Group 42, Inc.) diff --git a/thirdparty/libpng-1.6.37/TODO b/thirdparty/libpng-1.6.37/TODO new file mode 100644 index 0000000..562dab0 --- /dev/null +++ b/thirdparty/libpng-1.6.37/TODO @@ -0,0 +1,23 @@ +TODO - list of things to do for libpng: + +* Fix all defects (duh!) +* Better C++ wrapper / full C++ implementation (?) +* Fix the problems with C++ and 'extern "C"'. +* cHRM transformation. +* Palette creation. +* "grayscale->palette" transformation and "palette->grayscale" detection. +* Improved dithering. +* Multi-lingual error and warning message support. +* Complete sRGB transformation. (Currently it simply uses gamma=0.45455.) +* Man pages for function calls. +* Better documentation. +* Better filter selection + (e.g., counting huffman bits/precompression; filter inertia; filter costs). +* Histogram creation. +* Text conversion between different code pages (e.g., Latin-1 -> Mac). +* Avoid building gamma tables whenever possible. +* Greater precision in changing to linear gamma for compositing against + background, and in doing rgb-to-gray transformations. +* Investigate pre-incremented loop counters and other loop constructions. +* Interpolated method of handling interlacing. +* More validations for libpng transformations. diff --git a/thirdparty/libpng-1.6.37/TRADEMARK b/thirdparty/libpng-1.6.37/TRADEMARK new file mode 100644 index 0000000..ac66718 --- /dev/null +++ b/thirdparty/libpng-1.6.37/TRADEMARK @@ -0,0 +1,8 @@ +TRADEMARK +========= + +The name "libpng" has not been registered by the Copyright owners +as a trademark in any jurisdiction. However, because libpng has +been distributed and maintained world-wide, continually since 1995, +the Copyright owners claim "common-law trademark protection" in any +jurisdiction where common-law trademark is recognized. diff --git a/thirdparty/libpng-1.6.37/aclocal.m4 b/thirdparty/libpng-1.6.37/aclocal.m4 new file mode 100644 index 0000000..bc18c34 --- /dev/null +++ b/thirdparty/libpng-1.6.37/aclocal.m4 @@ -0,0 +1,1196 @@ +# generated automatically by aclocal 1.16.1 -*- Autoconf -*- + +# Copyright (C) 1996-2018 Free Software Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, +[m4_warning([this file was generated for autoconf 2.69. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically 'autoreconf'.])]) + +# Copyright (C) 2002-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.16' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.16.1], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.16.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) + +# Figure out how to run the assembler. -*- Autoconf -*- + +# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_AS +# ---------- +AC_DEFUN([AM_PROG_AS], +[# By default we simply use the C compiler to build assembly code. +AC_REQUIRE([AC_PROG_CC]) +test "${CCAS+set}" = set || CCAS=$CC +test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS +AC_ARG_VAR([CCAS], [assembler compiler command (defaults to CC)]) +AC_ARG_VAR([CCASFLAGS], [assembler compiler flags (defaults to CFLAGS)]) +_AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl +]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to +# '$srcdir', '$srcdir/..', or '$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is '.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ([2.52])dnl + m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + + +# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], + [$1], [CXX], [depcc="$CXX" am_compiler_list=], + [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], + [$1], [UPC], [depcc="$UPC" am_compiler_list=], + [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + am__universal=false + m4_case([$1], [CC], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac], + [CXX], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac]) + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES. +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE([dependency-tracking], [dnl +AS_HELP_STRING( + [--enable-dependency-tracking], + [do not reject slow dependency extractors]) +AS_HELP_STRING( + [--disable-dependency-tracking], + [speeds up one-time build])]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +AC_SUBST([am__nodep])dnl +_AM_SUBST_NOTMAKE([am__nodep])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[{ + # Older Autoconf quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + AS_CASE([$CONFIG_FILES], + [*\'*], [eval set x "$CONFIG_FILES"], + [*], [set x $CONFIG_FILES]) + shift + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf + do + # Strip MF so we end up with the name of the file. + am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`AS_DIRNAME(["$am_mf"])` + am_filepart=`AS_BASENAME(["$am_mf"])` + AM_RUN_LOG([cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles]) || am_rc=$? + done + if test $am_rc -ne 0; then + AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. Try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking).]) + fi + AS_UNSET([am_dirpart]) + AS_UNSET([am_filepart]) + AS_UNSET([am_mf]) + AS_UNSET([am_rc]) + rm -f conftest-deps.mk +} +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking is enabled. +# This creates each '.Po' and '.Plo' makefile fragment that we'll need in +# order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. +m4_define([AC_PROG_CC], +m4_defn([AC_PROG_CC]) +[_AM_PROG_CC_C_O +]) + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.65])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[AC_DIAGNOSE([obsolete], + [$0: two- and three-arguments forms are deprecated.]) +m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if( + m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), + [ok:ok],, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) + AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) +AM_MISSING_PROG([AUTOCONF], [autoconf]) +AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) +AM_MISSING_PROG([AUTOHEADER], [autoheader]) +AM_MISSING_PROG([MAKEINFO], [makeinfo]) +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +AC_SUBST([mkdir_p], ['$(MKDIR_P)']) +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES([CC])], + [m4_define([AC_PROG_CC], + m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES([CXX])], + [m4_define([AC_PROG_CXX], + m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES([OBJC])], + [m4_define([AC_PROG_OBJC], + m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], + [_AM_DEPENDENCIES([OBJCXX])], + [m4_define([AC_PROG_OBJCXX], + m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl +]) +AC_REQUIRE([AM_SILENT_RULES])dnl +dnl The testsuite driver may need to know about EXEEXT, so add the +dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This +dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_CONFIG_COMMANDS_PRE(dnl +[m4_provide_if([_AM_COMPILER_EXEEXT], + [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) + fi +fi +dnl The trailing newline in this macro's definition is deliberate, for +dnl backward compatibility and to allow trailing 'dnl'-style comments +dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. +]) + +dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further +dnl mangled by Autoconf and run in a shell conditional statement. +m4_define([_AC_COMPILER_EXEEXT], +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +if test x"${install_sh+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi +AC_SUBST([install_sh])]) + +# Copyright (C) 2003-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering + +# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_MAINTAINER_MODE([DEFAULT-MODE]) +# ---------------------------------- +# Control maintainer-specific portions of Makefiles. +# Default is to disable them, unless 'enable' is passed literally. +# For symmetry, 'disable' may be passed as well. Anyway, the user +# can override the default with the --enable/--disable switch. +AC_DEFUN([AM_MAINTAINER_MODE], +[m4_case(m4_default([$1], [disable]), + [enable], [m4_define([am_maintainer_other], [disable])], + [disable], [m4_define([am_maintainer_other], [enable])], + [m4_define([am_maintainer_other], [enable]) + m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) +AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + dnl maintainer-mode's default is 'disable' unless 'enable' is passed + AC_ARG_ENABLE([maintainer-mode], + [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], + am_maintainer_other[ make rules and dependencies not useful + (and sometimes confusing) to the casual installer])], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST([MAINT])dnl +] +) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_MAKE_INCLUDE() +# ----------------- +# Check whether make has an 'include' directive that can support all +# the idioms we need for our automatic dependency tracking code. +AC_DEFUN([AM_MAKE_INCLUDE], +[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) +cat > confinc.mk << 'END' +am__doit: + @echo this is the am__doit target >confinc.out +.PHONY: am__doit +END +am__include="#" +am__quote= +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) + AS_CASE([$?:`cat confinc.out 2>/dev/null`], + ['0:this is the am__doit target'], + [AS_CASE([$s], + [BSD], [am__include='.include' am__quote='"'], + [am__include='include' am__quote=''])]) + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +AC_MSG_RESULT([${_am_result}]) +AC_SUBST([am__include])]) +AC_SUBST([am__quote])]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it is modern enough. +# If it is, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " +else + am_missing_run= + AC_MSG_WARN(['missing' script is too old or missing]) +fi +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# -------------------- +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) + +# _AM_SET_OPTIONS(OPTIONS) +# ------------------------ +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_PROG_CC_C_O +# --------------- +# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC +# to automatically call this. +AC_DEFUN([_AM_PROG_CC_C_O], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([compile])dnl +AC_LANG_PUSH([C])dnl +AC_CACHE_CHECK( + [whether $CC understands -c and -o together], + [am_cv_prog_cc_c_o], + [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i]) +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +AC_LANG_POP([C])]) + +# For backward compatibility. +AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) + +# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_RUN_LOG(COMMAND) +# ------------------- +# Run COMMAND, save the exit status in ac_status, and log it. +# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) +AC_DEFUN([AM_RUN_LOG], +[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD + ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + (exit $ac_status); }]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[[\\\"\#\$\&\'\`$am_lf]]*) + AC_MSG_ERROR([unsafe absolute working directory name]);; +esac +case $srcdir in + *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) + AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; +esac + +# Do 'set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken + alias in your environment]) + fi + if test "$[2]" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT([yes]) +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi +AC_CONFIG_COMMANDS_PRE( + [AC_MSG_CHECKING([that generated files are newer than configure]) + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + AC_MSG_RESULT([done])]) +rm -f conftest.file +]) + +# Copyright (C) 2009-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_SILENT_RULES([DEFAULT]) +# -------------------------- +# Enable less verbose build rules; with the default set to DEFAULT +# ("yes" being less verbose, "no" or empty being verbose). +AC_DEFUN([AM_SILENT_RULES], +[AC_ARG_ENABLE([silent-rules], [dnl +AS_HELP_STRING( + [--enable-silent-rules], + [less verbose build output (undo: "make V=1")]) +AS_HELP_STRING( + [--disable-silent-rules], + [verbose build output (undo: "make V=0")])dnl +]) +case $enable_silent_rules in @%:@ ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; +esac +dnl +dnl A few 'make' implementations (e.g., NonStop OS and NextStep) +dnl do not support nested variable expansions. +dnl See automake bug#9928 and bug#10237. +am_make=${MAKE-make} +AC_CACHE_CHECK([whether $am_make supports nested variables], + [am_cv_make_support_nested_variables], + [if AS_ECHO([['TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi]) +if test $am_cv_make_support_nested_variables = yes; then + dnl Using '$V' instead of '$(V)' breaks IRIX make. + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AC_SUBST([AM_V])dnl +AM_SUBST_NOTMAKE([AM_V])dnl +AC_SUBST([AM_DEFAULT_V])dnl +AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl +AC_SUBST([AM_DEFAULT_VERBOSITY])dnl +AM_BACKSLASH='\' +AC_SUBST([AM_BACKSLASH])dnl +_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl +]) + +# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor 'install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in "make install-strip", and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the 'STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# -------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of 'v7', 'ustar', or 'pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +# +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) + +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' + +m4_if([$1], [v7], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], + + [m4_case([$1], + [ustar], + [# The POSIX 1988 'ustar' format is defined with fixed-size fields. + # There is notably a 21 bits limit for the UID and the GID. In fact, + # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 + # and bug#13588). + am_max_uid=2097151 # 2^21 - 1 + am_max_gid=$am_max_uid + # The $UID and $GID variables are not portable, so we need to resort + # to the POSIX-mandated id(1) utility. Errors in the 'id' calls + # below are definitely unexpected, so allow the users to see them + # (that is, avoid stderr redirection). + am_uid=`id -u || echo unknown` + am_gid=`id -g || echo unknown` + AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) + if test $am_uid -le $am_max_uid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi + AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) + if test $am_gid -le $am_max_gid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi], + + [pax], + [], + + [m4_fatal([Unknown tar format])]) + + AC_MSG_CHECKING([how to create a $1 tar archive]) + + # Go ahead even if we have the value already cached. We do so because we + # need to set the values for the 'am__tar' and 'am__untar' variables. + _am_tools=${am_cv_prog_tar_$1-$_am_tools} + + for _am_tool in $_am_tools; do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works. + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi + done + rm -rf conftest.dir + + AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) + AC_MSG_RESULT([$am_cv_prog_tar_$1])]) + +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + +m4_include([scripts/libtool.m4]) +m4_include([scripts/ltoptions.m4]) +m4_include([scripts/ltsugar.m4]) +m4_include([scripts/ltversion.m4]) +m4_include([scripts/lt~obsolete.m4]) diff --git a/thirdparty/libpng-1.6.37/arm/.deps/arm_init.Plo b/thirdparty/libpng-1.6.37/arm/.deps/arm_init.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/thirdparty/libpng-1.6.37/arm/.deps/arm_init.Plo @@ -0,0 +1 @@ +# dummy diff --git a/thirdparty/libpng-1.6.37/arm/.deps/filter_neon.Plo b/thirdparty/libpng-1.6.37/arm/.deps/filter_neon.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/thirdparty/libpng-1.6.37/arm/.deps/filter_neon.Plo @@ -0,0 +1 @@ +# dummy diff --git a/thirdparty/libpng-1.6.37/arm/.deps/filter_neon_intrinsics.Plo b/thirdparty/libpng-1.6.37/arm/.deps/filter_neon_intrinsics.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/thirdparty/libpng-1.6.37/arm/.deps/filter_neon_intrinsics.Plo @@ -0,0 +1 @@ +# dummy diff --git a/thirdparty/libpng-1.6.37/arm/.deps/palette_neon_intrinsics.Plo b/thirdparty/libpng-1.6.37/arm/.deps/palette_neon_intrinsics.Plo new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/thirdparty/libpng-1.6.37/arm/.deps/palette_neon_intrinsics.Plo @@ -0,0 +1 @@ +# dummy diff --git a/thirdparty/libpng-1.6.37/arm/arm_init.c b/thirdparty/libpng-1.6.37/arm/arm_init.c new file mode 100644 index 0000000..a34ecdb --- /dev/null +++ b/thirdparty/libpng-1.6.37/arm/arm_init.c @@ -0,0 +1,136 @@ + +/* arm_init.c - NEON optimised filter functions + * + * Copyright (c) 2018 Cosmin Truta + * Copyright (c) 2014,2016 Glenn Randers-Pehrson + * Written by Mans Rullgard, 2011. + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are + * called. + */ +#define _POSIX_SOURCE 1 + +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +#if PNG_ARM_NEON_OPT > 0 +#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */ +/* WARNING: it is strongly recommended that you do not build libpng with + * run-time checks for CPU features if at all possible. In the case of the ARM + * NEON instructions there is no processor-specific way of detecting the + * presence of the required support, therefore run-time detection is extremely + * OS specific. + * + * You may set the macro PNG_ARM_NEON_FILE to the file name of file containing + * a fragment of C source code which defines the png_have_neon function. There + * are a number of implementations in contrib/arm-neon, but the only one that + * has partial support is contrib/arm-neon/linux.c - a generic Linux + * implementation which reads /proc/cpufino. + */ +#ifndef PNG_ARM_NEON_FILE +# ifdef __linux__ +# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c" +# endif +#endif + +#ifdef PNG_ARM_NEON_FILE + +#include /* for sig_atomic_t */ +static int png_have_neon(png_structp png_ptr); +#include PNG_ARM_NEON_FILE + +#else /* PNG_ARM_NEON_FILE */ +# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks" +#endif /* PNG_ARM_NEON_FILE */ +#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ + +#ifndef PNG_ALIGNED_MEMORY_SUPPORTED +# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED" +#endif + +void +png_init_filter_functions_neon(png_structp pp, unsigned int bpp) +{ + /* The switch statement is compiled in for ARM_NEON_API, the call to + * png_have_neon is compiled in for ARM_NEON_CHECK. If both are defined + * the check is only performed if the API has not set the NEON option on + * or off explicitly. In this case the check controls what happens. + * + * If the CHECK is not compiled in and the option is UNSET the behavior prior + * to 1.6.7 was to use the NEON code - this was a bug caused by having the + * wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF, + * as documented in png.h + */ + png_debug(1, "in png_init_filter_functions_neon"); +#ifdef PNG_ARM_NEON_API_SUPPORTED + switch ((pp->options >> PNG_ARM_NEON) & 3) + { + case PNG_OPTION_UNSET: + /* Allow the run-time check to execute if it has been enabled - + * thus both API and CHECK can be turned on. If it isn't supported + * this case will fall through to the 'default' below, which just + * returns. + */ +#endif /* PNG_ARM_NEON_API_SUPPORTED */ +#ifdef PNG_ARM_NEON_CHECK_SUPPORTED + { + static volatile sig_atomic_t no_neon = -1; /* not checked */ + + if (no_neon < 0) + no_neon = !png_have_neon(pp); + + if (no_neon) + return; + } +#ifdef PNG_ARM_NEON_API_SUPPORTED + break; +#endif +#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ + +#ifdef PNG_ARM_NEON_API_SUPPORTED + default: /* OFF or INVALID */ + return; + + case PNG_OPTION_ON: + /* Option turned on */ + break; + } +#endif + + /* IMPORTANT: any new external functions used here must be declared using + * PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the + * 'prefix' option to configure works: + * + * ./configure --with-libpng-prefix=foobar_ + * + * Verify you have got this right by running the above command, doing a build + * and examining pngprefix.h; it must contain a #define for every external + * function you add. (Notice that this happens automatically for the + * initialization function.) + */ + pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon; + + if (bpp == 3) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth3_neon; + } + + else if (bpp == 4) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth4_neon; + } +} +#endif /* PNG_ARM_NEON_OPT > 0 */ +#endif /* READ */ diff --git a/thirdparty/libpng-1.6.37/arm/filter_neon.S b/thirdparty/libpng-1.6.37/arm/filter_neon.S new file mode 100644 index 0000000..2308aad --- /dev/null +++ b/thirdparty/libpng-1.6.37/arm/filter_neon.S @@ -0,0 +1,253 @@ + +/* filter_neon.S - NEON optimised filter functions + * + * Copyright (c) 2018 Cosmin Truta + * Copyright (c) 2014,2017 Glenn Randers-Pehrson + * Written by Mans Rullgard, 2011. + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* This is required to get the symbol renames, which are #defines, and the + * definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION. + */ +#define PNG_VERSION_INFO_ONLY +#include "../pngpriv.h" + +#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */ +#endif + +#ifdef PNG_READ_SUPPORTED + +/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for + * ARM64). The code in arm/filter_neon_intrinsics.c supports ARM64, however it + * only works if -mfpu=neon is specified on the GCC command line. See pngpriv.h + * for the logic which sets PNG_USE_ARM_NEON_ASM: + */ +#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */ + +#if PNG_ARM_NEON_OPT > 0 + +#ifdef __ELF__ +# define ELF +#else +# define ELF @ +#endif + + .arch armv7-a + .fpu neon + +.macro func name, export=0 + .macro endfunc +ELF .size \name, . - \name + .endfunc + .purgem endfunc + .endm + .text + + /* Explicitly specifying alignment here because some versions of + * GAS don't align code correctly. This is harmless in correctly + * written versions of GAS. + */ + .align 2 + + .if \export + .global \name + .endif +ELF .type \name, STT_FUNC + .func \name +\name: +.endm + +func png_read_filter_row_sub4_neon, export=1 + ldr r3, [r0, #4] @ rowbytes + vmov.i8 d3, #0 +1: + vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] + vadd.u8 d0, d3, d4 + vadd.u8 d1, d0, d5 + vadd.u8 d2, d1, d6 + vadd.u8 d3, d2, d7 + vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! + subs r3, r3, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_sub3_neon, export=1 + ldr r3, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + mov r0, r1 + mov r2, #3 + mov r12, #12 + vld1.8 {q11}, [r0], r12 +1: + vext.8 d5, d22, d23, #3 + vadd.u8 d0, d3, d22 + vext.8 d6, d22, d23, #6 + vadd.u8 d1, d0, d5 + vext.8 d7, d23, d23, #1 + vld1.8 {q11}, [r0], r12 + vst1.32 {d0[0]}, [r1,:32], r2 + vadd.u8 d2, d1, d6 + vst1.32 {d1[0]}, [r1], r2 + vadd.u8 d3, d2, d7 + vst1.32 {d2[0]}, [r1], r2 + vst1.32 {d3[0]}, [r1], r2 + subs r3, r3, #12 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_up_neon, export=1 + ldr r3, [r0, #4] @ rowbytes +1: + vld1.8 {q0}, [r1,:128] + vld1.8 {q1}, [r2,:128]! + vadd.u8 q0, q0, q1 + vst1.8 {q0}, [r1,:128]! + subs r3, r3, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_avg4_neon, export=1 + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 +1: + vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] + vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]! + vhadd.u8 d0, d3, d16 + vadd.u8 d0, d0, d4 + vhadd.u8 d1, d0, d17 + vadd.u8 d1, d1, d5 + vhadd.u8 d2, d1, d18 + vadd.u8 d2, d2, d6 + vhadd.u8 d3, d2, d19 + vadd.u8 d3, d3, d7 + vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! + subs r12, r12, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_avg3_neon, export=1 + push {r4,lr} + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + mov r0, r1 + mov r4, #3 + mov lr, #12 + vld1.8 {q11}, [r0], lr +1: + vld1.8 {q10}, [r2], lr + vext.8 d5, d22, d23, #3 + vhadd.u8 d0, d3, d20 + vext.8 d17, d20, d21, #3 + vadd.u8 d0, d0, d22 + vext.8 d6, d22, d23, #6 + vhadd.u8 d1, d0, d17 + vext.8 d18, d20, d21, #6 + vadd.u8 d1, d1, d5 + vext.8 d7, d23, d23, #1 + vld1.8 {q11}, [r0], lr + vst1.32 {d0[0]}, [r1,:32], r4 + vhadd.u8 d2, d1, d18 + vst1.32 {d1[0]}, [r1], r4 + vext.8 d19, d21, d21, #1 + vadd.u8 d2, d2, d6 + vhadd.u8 d3, d2, d19 + vst1.32 {d2[0]}, [r1], r4 + vadd.u8 d3, d3, d7 + vst1.32 {d3[0]}, [r1], r4 + subs r12, r12, #12 + bgt 1b + + pop {r4,pc} +endfunc + +.macro paeth rx, ra, rb, rc + vaddl.u8 q12, \ra, \rb @ a + b + vaddl.u8 q15, \rc, \rc @ 2*c + vabdl.u8 q13, \rb, \rc @ pa + vabdl.u8 q14, \ra, \rc @ pb + vabd.u16 q15, q12, q15 @ pc + vcle.u16 q12, q13, q14 @ pa <= pb + vcle.u16 q13, q13, q15 @ pa <= pc + vcle.u16 q14, q14, q15 @ pb <= pc + vand q12, q12, q13 @ pa <= pb && pa <= pc + vmovn.u16 d28, q14 + vmovn.u16 \rx, q12 + vbsl d28, \rb, \rc + vbsl \rx, \ra, d28 +.endm + +func png_read_filter_row_paeth4_neon, export=1 + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + vmov.i8 d20, #0 +1: + vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] + vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]! + paeth d0, d3, d16, d20 + vadd.u8 d0, d0, d4 + paeth d1, d0, d17, d16 + vadd.u8 d1, d1, d5 + paeth d2, d1, d18, d17 + vadd.u8 d2, d2, d6 + paeth d3, d2, d19, d18 + vmov d20, d19 + vadd.u8 d3, d3, d7 + vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! + subs r12, r12, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_paeth3_neon, export=1 + push {r4,lr} + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + vmov.i8 d4, #0 + mov r0, r1 + mov r4, #3 + mov lr, #12 + vld1.8 {q11}, [r0], lr +1: + vld1.8 {q10}, [r2], lr + paeth d0, d3, d20, d4 + vext.8 d5, d22, d23, #3 + vadd.u8 d0, d0, d22 + vext.8 d17, d20, d21, #3 + paeth d1, d0, d17, d20 + vst1.32 {d0[0]}, [r1,:32], r4 + vext.8 d6, d22, d23, #6 + vadd.u8 d1, d1, d5 + vext.8 d18, d20, d21, #6 + paeth d2, d1, d18, d17 + vext.8 d7, d23, d23, #1 + vld1.8 {q11}, [r0], lr + vst1.32 {d1[0]}, [r1], r4 + vadd.u8 d2, d2, d6 + vext.8 d19, d21, d21, #1 + paeth d3, d2, d19, d18 + vst1.32 {d2[0]}, [r1], r4 + vmov d4, d19 + vadd.u8 d3, d3, d7 + vst1.32 {d3[0]}, [r1], r4 + subs r12, r12, #12 + bgt 1b + + pop {r4,pc} +endfunc +#endif /* PNG_ARM_NEON_OPT > 0 */ +#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */ +#endif /* READ */ diff --git a/thirdparty/libpng-1.6.37/arm/filter_neon_intrinsics.c b/thirdparty/libpng-1.6.37/arm/filter_neon_intrinsics.c new file mode 100644 index 0000000..553c0be --- /dev/null +++ b/thirdparty/libpng-1.6.37/arm/filter_neon_intrinsics.c @@ -0,0 +1,402 @@ + +/* filter_neon_intrinsics.c - NEON optimised filter functions + * + * Copyright (c) 2018 Cosmin Truta + * Copyright (c) 2014,2016 Glenn Randers-Pehrson + * Written by James Yu , October 2013. + * Based on filter_neon.S, written by Mans Rullgard, 2011. + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +/* This code requires -mfpu=neon on the command line: */ +#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */ + +#if defined(_MSC_VER) && defined(_M_ARM64) +# include +#else +# include +#endif + +/* libpng row pointers are not necessarily aligned to any particular boundary, + * however this code will only work with appropriate alignment. arm/arm_init.c + * checks for this (and will not compile unless it is done). This code uses + * variants of png_aligncast to avoid compiler warnings. + */ +#define png_ptr(type,pointer) png_aligncast(type *,pointer) +#define png_ptrc(type,pointer) png_aligncastconst(const type *,pointer) + +/* The following relies on a variable 'temp_pointer' being declared with type + * 'type'. This is written this way just to hide the GCC strict aliasing + * warning; note that the code is safe because there never is an alias between + * the input and output pointers. + * + * When compiling with MSVC ARM64, the png_ldr macro can't be passed directly + * to vst4_lane_u32, because of an internal compiler error inside MSVC. + * To avoid this compiler bug, we use a temporary variable (vdest_val) to store + * the result of png_ldr. + */ +#define png_ldr(type,pointer)\ + (temp_pointer = png_ptr(type,pointer), *temp_pointer) + +#if PNG_ARM_NEON_OPT > 0 + +void +png_read_filter_row_up_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + png_const_bytep pp = prev_row; + + png_debug(1, "in png_read_filter_row_up_neon"); + + for (; rp < rp_stop; rp += 16, pp += 16) + { + uint8x16_t qrp, qpp; + + qrp = vld1q_u8(rp); + qpp = vld1q_u8(pp); + qrp = vaddq_u8(qrp, qpp); + vst1q_u8(rp, qrp); + } +} + +void +png_read_filter_row_sub3_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x16_t vtmp = vld1q_u8(rp); + uint8x8x2_t *vrpt = png_ptr(uint8x8x2_t, &vtmp); + uint8x8x2_t vrp = *vrpt; + + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_sub3_neon"); + + for (; rp < rp_stop;) + { + uint8x8_t vtmp1, vtmp2; + uint32x2_t *temp_pointer; + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3); + vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]); + vtmp2 = vext_u8(vrp.val[0], vrp.val[1], 6); + vdest.val[1] = vadd_u8(vdest.val[0], vtmp1); + + vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1); + vdest.val[2] = vadd_u8(vdest.val[1], vtmp2); + vdest.val[3] = vadd_u8(vdest.val[2], vtmp1); + + vtmp = vld1q_u8(rp + 12); + vrpt = png_ptr(uint8x8x2_t, &vtmp); + vrp = *vrpt; + + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0); + rp += 3; + } + + PNG_UNUSED(prev_row) +} + +void +png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_sub4_neon"); + + for (; rp < rp_stop; rp += 16) + { + uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp)); + uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp); + uint8x8x4_t vrp = *vrpt; + uint32x2x4_t *temp_pointer; + uint32x2x4_t vdest_val; + + vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]); + vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]); + vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]); + vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]); + + vdest_val = png_ldr(uint32x2x4_t, &vdest); + vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0); + } + + PNG_UNUSED(prev_row) +} + +void +png_read_filter_row_avg3_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_const_bytep pp = prev_row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x16_t vtmp; + uint8x8x2_t *vrpt; + uint8x8x2_t vrp; + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + vtmp = vld1q_u8(rp); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + png_debug(1, "in png_read_filter_row_avg3_neon"); + + for (; rp < rp_stop; pp += 12) + { + uint8x8_t vtmp1, vtmp2, vtmp3; + + uint8x8x2_t *vppt; + uint8x8x2_t vpp; + + uint32x2_t *temp_pointer; + + vtmp = vld1q_u8(pp); + vppt = png_ptr(uint8x8x2_t,&vtmp); + vpp = *vppt; + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3); + vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + + vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3); + vtmp3 = vext_u8(vrp.val[0], vrp.val[1], 6); + vdest.val[1] = vhadd_u8(vdest.val[0], vtmp2); + vdest.val[1] = vadd_u8(vdest.val[1], vtmp1); + + vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 6); + vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1); + + vtmp = vld1q_u8(rp + 12); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + vdest.val[2] = vhadd_u8(vdest.val[1], vtmp2); + vdest.val[2] = vadd_u8(vdest.val[2], vtmp3); + + vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1); + + vdest.val[3] = vhadd_u8(vdest.val[2], vtmp2); + vdest.val[3] = vadd_u8(vdest.val[3], vtmp1); + + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0); + rp += 3; + } +} + +void +png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + png_const_bytep pp = prev_row; + + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_avg4_neon"); + + for (; rp < rp_stop; rp += 16, pp += 16) + { + uint32x2x4_t vtmp; + uint8x8x4_t *vrpt, *vppt; + uint8x8x4_t vrp, vpp; + uint32x2x4_t *temp_pointer; + uint32x2x4_t vdest_val; + + vtmp = vld4_u32(png_ptr(uint32_t,rp)); + vrpt = png_ptr(uint8x8x4_t,&vtmp); + vrp = *vrpt; + vtmp = vld4_u32(png_ptrc(uint32_t,pp)); + vppt = png_ptr(uint8x8x4_t,&vtmp); + vpp = *vppt; + + vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + vdest.val[1] = vhadd_u8(vdest.val[0], vpp.val[1]); + vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]); + vdest.val[2] = vhadd_u8(vdest.val[1], vpp.val[2]); + vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]); + vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]); + vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]); + + vdest_val = png_ldr(uint32x2x4_t, &vdest); + vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0); + } +} + +static uint8x8_t +paeth(uint8x8_t a, uint8x8_t b, uint8x8_t c) +{ + uint8x8_t d, e; + uint16x8_t p1, pa, pb, pc; + + p1 = vaddl_u8(a, b); /* a + b */ + pc = vaddl_u8(c, c); /* c * 2 */ + pa = vabdl_u8(b, c); /* pa */ + pb = vabdl_u8(a, c); /* pb */ + pc = vabdq_u16(p1, pc); /* pc */ + + p1 = vcleq_u16(pa, pb); /* pa <= pb */ + pa = vcleq_u16(pa, pc); /* pa <= pc */ + pb = vcleq_u16(pb, pc); /* pb <= pc */ + + p1 = vandq_u16(p1, pa); /* pa <= pb && pa <= pc */ + + d = vmovn_u16(pb); + e = vmovn_u16(p1); + + d = vbsl_u8(d, b, c); + e = vbsl_u8(e, a, d); + + return e; +} + +void +png_read_filter_row_paeth3_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_const_bytep pp = prev_row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x16_t vtmp; + uint8x8x2_t *vrpt; + uint8x8x2_t vrp; + uint8x8_t vlast = vdup_n_u8(0); + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + vtmp = vld1q_u8(rp); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + png_debug(1, "in png_read_filter_row_paeth3_neon"); + + for (; rp < rp_stop; pp += 12) + { + uint8x8x2_t *vppt; + uint8x8x2_t vpp; + uint8x8_t vtmp1, vtmp2, vtmp3; + uint32x2_t *temp_pointer; + + vtmp = vld1q_u8(pp); + vppt = png_ptr(uint8x8x2_t,&vtmp); + vpp = *vppt; + + vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3); + vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3); + vdest.val[1] = paeth(vdest.val[0], vtmp2, vpp.val[0]); + vdest.val[1] = vadd_u8(vdest.val[1], vtmp1); + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 6); + vtmp3 = vext_u8(vpp.val[0], vpp.val[1], 6); + vdest.val[2] = paeth(vdest.val[1], vtmp3, vtmp2); + vdest.val[2] = vadd_u8(vdest.val[2], vtmp1); + + vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1); + vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1); + + vtmp = vld1q_u8(rp + 12); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + vdest.val[3] = paeth(vdest.val[2], vtmp2, vtmp3); + vdest.val[3] = vadd_u8(vdest.val[3], vtmp1); + + vlast = vtmp2; + + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0); + rp += 3; + } +} + +void +png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + png_const_bytep pp = prev_row; + + uint8x8_t vlast = vdup_n_u8(0); + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_paeth4_neon"); + + for (; rp < rp_stop; rp += 16, pp += 16) + { + uint32x2x4_t vtmp; + uint8x8x4_t *vrpt, *vppt; + uint8x8x4_t vrp, vpp; + uint32x2x4_t *temp_pointer; + uint32x2x4_t vdest_val; + + vtmp = vld4_u32(png_ptr(uint32_t,rp)); + vrpt = png_ptr(uint8x8x4_t,&vtmp); + vrp = *vrpt; + vtmp = vld4_u32(png_ptrc(uint32_t,pp)); + vppt = png_ptr(uint8x8x4_t,&vtmp); + vpp = *vppt; + + vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + vdest.val[1] = paeth(vdest.val[0], vpp.val[1], vpp.val[0]); + vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]); + vdest.val[2] = paeth(vdest.val[1], vpp.val[2], vpp.val[1]); + vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]); + vdest.val[3] = paeth(vdest.val[2], vpp.val[3], vpp.val[2]); + vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]); + + vlast = vpp.val[3]; + + vdest_val = png_ldr(uint32x2x4_t, &vdest); + vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0); + } +} + +#endif /* PNG_ARM_NEON_OPT > 0 */ +#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */ +#endif /* READ */ diff --git a/thirdparty/libpng-1.6.37/arm/palette_neon_intrinsics.c b/thirdparty/libpng-1.6.37/arm/palette_neon_intrinsics.c new file mode 100644 index 0000000..b4d1fd2 --- /dev/null +++ b/thirdparty/libpng-1.6.37/arm/palette_neon_intrinsics.c @@ -0,0 +1,149 @@ + +/* palette_neon_intrinsics.c - NEON optimised palette expansion functions + * + * Copyright (c) 2018-2019 Cosmin Truta + * Copyright (c) 2017-2018 Arm Holdings. All rights reserved. + * Written by Richard Townsend , February 2017. + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "../pngpriv.h" + +#if PNG_ARM_NEON_IMPLEMENTATION == 1 + +#if defined(_MSC_VER) && defined(_M_ARM64) +# include +#else +# include +#endif + +/* Build an RGBA8 palette from the separate RGB and alpha palettes. */ +void +png_riffle_palette_neon(png_structrp png_ptr) +{ + png_const_colorp palette = png_ptr->palette; + png_bytep riffled_palette = png_ptr->riffled_palette; + png_const_bytep trans_alpha = png_ptr->trans_alpha; + int num_trans = png_ptr->num_trans; + int i; + + png_debug(1, "in png_riffle_palette_neon"); + + /* Initially black, opaque. */ + uint8x16x4_t w = {{ + vdupq_n_u8(0x00), + vdupq_n_u8(0x00), + vdupq_n_u8(0x00), + vdupq_n_u8(0xff), + }}; + + /* First, riffle the RGB colours into an RGBA8 palette. + * The alpha component is set to opaque for now. + */ + for (i = 0; i < 256; i += 16) + { + uint8x16x3_t v = vld3q_u8((png_const_bytep)(palette + i)); + w.val[0] = v.val[0]; + w.val[1] = v.val[1]; + w.val[2] = v.val[2]; + vst4q_u8(riffled_palette + (i << 2), w); + } + + /* Fix up the missing transparency values. */ + for (i = 0; i < num_trans; i++) + riffled_palette[(i << 2) + 3] = trans_alpha[i]; +} + +/* Expands a palettized row into RGBA8. */ +int +png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info, + png_const_bytep row, png_bytepp ssp, png_bytepp ddp) +{ + png_uint_32 row_width = row_info->width; + const png_uint_32 *riffled_palette = + (const png_uint_32 *)png_ptr->riffled_palette; + const png_int_32 pixels_per_chunk = 4; + int i; + + png_debug(1, "in png_do_expand_palette_rgba8_neon"); + + if (row_width < pixels_per_chunk) + return 0; + + /* This function originally gets the last byte of the output row. + * The NEON part writes forward from a given position, so we have + * to seek this back by 4 pixels x 4 bytes. + */ + *ddp = *ddp - ((pixels_per_chunk * sizeof(png_uint_32)) - 1); + + for (i = 0; i < row_width; i += pixels_per_chunk) + { + uint32x4_t cur; + png_bytep sp = *ssp - i, dp = *ddp - (i << 2); + cur = vld1q_dup_u32 (riffled_palette + *(sp - 3)); + cur = vld1q_lane_u32(riffled_palette + *(sp - 2), cur, 1); + cur = vld1q_lane_u32(riffled_palette + *(sp - 1), cur, 2); + cur = vld1q_lane_u32(riffled_palette + *(sp - 0), cur, 3); + vst1q_u32((void *)dp, cur); + } + if (i != row_width) + { + /* Remove the amount that wasn't processed. */ + i -= pixels_per_chunk; + } + + /* Decrement output pointers. */ + *ssp = *ssp - i; + *ddp = *ddp - (i << 2); + return i; +} + +/* Expands a palettized row into RGB8. */ +int +png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info, + png_const_bytep row, png_bytepp ssp, png_bytepp ddp) +{ + png_uint_32 row_width = row_info->width; + png_const_bytep palette = (png_const_bytep)png_ptr->palette; + const png_uint_32 pixels_per_chunk = 8; + int i; + + png_debug(1, "in png_do_expand_palette_rgb8_neon"); + + if (row_width <= pixels_per_chunk) + return 0; + + /* Seeking this back by 8 pixels x 3 bytes. */ + *ddp = *ddp - ((pixels_per_chunk * sizeof(png_color)) - 1); + + for (i = 0; i < row_width; i += pixels_per_chunk) + { + uint8x8x3_t cur; + png_bytep sp = *ssp - i, dp = *ddp - ((i << 1) + i); + cur = vld3_dup_u8(palette + sizeof(png_color) * (*(sp - 7))); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 6)), cur, 1); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 5)), cur, 2); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 4)), cur, 3); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 3)), cur, 4); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 2)), cur, 5); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 1)), cur, 6); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 0)), cur, 7); + vst3_u8((void *)dp, cur); + } + + if (i != row_width) + { + /* Remove the amount that wasn't processed. */ + i -= pixels_per_chunk; + } + + /* Decrement output pointers. */ + *ssp = *ssp - i; + *ddp = *ddp - ((i << 1) + i); + return i; +} + +#endif /* PNG_ARM_NEON_IMPLEMENTATION */ diff --git a/thirdparty/libpng-1.6.37/autogen.sh b/thirdparty/libpng-1.6.37/autogen.sh new file mode 100755 index 0000000..a46daf6 --- /dev/null +++ b/thirdparty/libpng-1.6.37/autogen.sh @@ -0,0 +1,225 @@ +#! /bin/sh +# +# Run 'autoreconf' to build 'configure', 'Makefile.in' and other configure +# control files. +# +# The first time this is run on a GIT checkout the only files that exist are +# configure.ac and Makefile.am; all of the autotools support scripts are +# missing. They are instantiated with autoreconf --force --install. +# +# For regular ("tarball") distributions all the files should exist. We do not +# want them to be updated *under any circumstances*. It should never be +# necessary to run autogen.sh because ./configure --enable-maintainer-mode says +# what to do if Makefile.am or configure.ac are changed. +# +# It is *probably* OK to update the files on a GIT checkout, because they have +# come from the local tools, but leave that to the user who is assumed to know +# whether it is ok or required. +# +# This script is intended to work without arguments, there are, however, hidden +# arguments (a) for use while testing the script and (b) to fix up systems that +# have been broken. If (b) is required the script prompts for the correct +# options. For this reason the options are *NOT* documented in the help; this +# is deliberate; UTSL. +# +clean= +maintainer= +while test $# -gt 0 +do + case "$1" in + --maintainer) + maintainer=1;; + + --clean) + clean=1;; + + *) + exec >&2 + echo "$0: usage: ./autogen.sh" + if test -d .git + then + echo " ./autogen.sh generates the configure script and" + echo " Makefile.in, or refreshes them after changes to Makefile.am" + echo " or configure.ac. You may prefer to just run autoreconf." + elif test -z "$maintainer" + then + echo " DO NOT RUN THIS SCRIPT." + echo " If you need to change Makefile.am or configure.ac then you" + echo " also need to run ./configure --enable-maintainer-mode and" + echo " use the appropriate autotools, *NOT* this script, to update" + echo " everything, please check the documentation of autoreconf." + echo " WARNING: libpng is intentionally generated with a known," + echo " fixed, set of autotools. It is known *NOT* to work with" + echo " the collection of autotools distributed on highly reputable" + echo " operating systems." + echo " Remember: autotools is GNU software, you are expected to" + echo " pay for support." + else + echo " You have run autogen.sh with --maintainer enabled and you" + echo " are not using a GIT distribution, then you have given an" + echo " unrecognized argument. This is not good. --maintainer" + echo " switches off any assumptions that you might not know what" + echo " you are doing." + fi + exit 1;; + esac + + shift +done +# +# First check for a set of the autotools files; if absent then this is assumed +# to be a GIT version and the local autotools must be used. If present this +# is a tarball distribution and the script should not be used. If partially +# present bad things are happening. +# +# The autotools generated files: +libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in + config.sub configure depcomp install-sh ltmain.sh missing\ + test-driver" +# +# Files generated by versions of configue >2.68 or automake >1.13 (i.e. later +# versions than those required by configure.ac): +libpng_autotools_extra="compile config.h.in~" +# +# These are separate because 'maintainer-clean' does not remove them. +libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\ + scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4" + +libpng_autotools_dirs="autom4te.cache" # not required +# +# The configure generated files: +libpng_configure_files="Makefile config.h config.log config.status\ + libpng-config libpng.pc libtool stamp-h1" + +libpng_configure_dirs=".deps" +# +# We must remove the configure generated files as well as the autotools +# generated files if autotools are regenerated because otherwise if configure +# has been run without "--enable-maintainer-mode" make can do a partial update +# of Makefile. These functions do the two bits of cleaning. +clean_autotools(){ + rm -rf $libpng_autotools_files $libpng_libtool_files $libpng_autotools_dirs + rm -rf $libpng_autotools_extra +} + +clean_configure(){ + rm -rf $libpng_configure_files $libpng_configure_dirs +} +# +# Clean: remove everything (this is to help with testing) +if test -n "$clean" +then + clean_configure + if test -n "$maintainer" + then + clean_autotools + fi + + exit 0 +fi +# +# Validate the distribution. +libpng_autotools_file_found= +libpng_autotools_file_missing= +for file in $libpng_autotools_files +do + if test -f "$file" + then + libpng_autotools_file_found=1 + else + libpng_autotools_file_missing=1 + fi +done +# +# Presence of one of these does not *invalidate* missing, but absence +# invalidates found. +for file in $libpng_libtool_files +do + if test ! -f "$file" + then + libpng_autotools_file_missing=1 + fi +done +# +# The cache directory doesn't matter - it will be regenerated and does not exist +# anyway in a tarball. +# +# Either everything is missing or everything is there, the --maintainer option +# just changes this so that the mode is set to generate all the files. +mode= +if test -z "$libpng_autotools_file_found" -o -n "$maintainer" +then + mode="autoreconf" +else + if test -n "$libpng_autotools_file_missing" + then + mode="broken" + else + mode="configure" + fi +fi +# +# So: +case "$mode" in + autoreconf) + # Clean in case configure files exist + clean_configure + clean_autotools + # Everything must be initialized, so use --force + if autoreconf --warnings=all --force --install + then + missing= + for file in $libpng_autotools_files + do + test -f "$file" || missing=1 + done + # ignore the cache directory + test -z "$missing" || { + exec >&2 + echo "autoreconf was run, but did not produce all the expected" + echo "files. It is likely that your autotools installation is" + echo "not compatible with that expected by libpng." + exit 1 + } + else + exec >&2 + echo "autoreconf failed: your version of autotools is incompatible" + echo "with this libpng version. Please use a distributed archive" + echo "(which includes the autotools generated files) and run configure" + echo "instead." + exit 1 + fi;; + + configure) + if test -d .git + then + exec >&2 + echo "ERROR: running autoreconf on an initialized system" + echo " This is not necessary; it is only necessary to remake the" + echo " autotools generated files if Makefile.am or configure.ac" + echo " change and make does the right thing with:" + echo + echo " ./configure --enable-maintainer-mode." + echo + echo " You can run autoreconf yourself if you don't like maintainer" + echo " mode and you can also just run autoreconf -f -i to initialize" + echo " everything in the first place; this script is only for" + echo " compatibility with prior releases." + exit 1 + else + exec >&2 + echo "autogen.sh is intended only to generate 'configure' on systems" + echo "that do not have it. You have a complete 'configure', if you" + echo "need to change Makefile.am or configure.ac you also need to" + echo "run configure with the --enable-maintainer-mode option." + exit 1 + fi;; + + broken) + exec >&2 + echo "Your system has a partial set of autotools generated files." + echo "autogen.sh is unable to proceed. The full set of files is" + echo "contained in the libpng 'tar' distribution archive and you do" + echo "not need to run autogen.sh if you use it." + exit 1;; +esac diff --git a/thirdparty/libpng-1.6.37/compile b/thirdparty/libpng-1.6.37/compile new file mode 100755 index 0000000..99e5052 --- /dev/null +++ b/thirdparty/libpng-1.6.37/compile @@ -0,0 +1,348 @@ +#! /bin/sh +# Wrapper for compilers which do not understand '-c -o'. + +scriptversion=2018-03-07.03; # UTC + +# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + if test -f "$dir/lib$lib.a"; then + found=yes + lib=$dir/lib$lib.a + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file 'INSTALL'. + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; +esac + +ofile= +cfile= + +for arg +do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. + eat=1 + case $2 in + *.o | *.obj) + ofile=$2 + ;; + *) + set x "$@" -o "$2" + shift + ;; + esac + ;; + *.c) + cfile=$1 + set x "$@" "$1" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no '-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # '.c' file was seen then we are probably linking. That is also + # ok. + exec "$@" +fi + +# Name of file we expect compiler to create. +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` + +# Create the lock directory. +# Note: use '[/\\:.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d +while true; do + if mkdir "$lockdir" >/dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir '$lockdir'; exit 1" 1 2 15 + +# Run the compile. +"$@" +ret=$? + +if test -f "$cofile"; then + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" +elif test -f "${cofile}bj"; then + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" +fi + +rmdir "$lockdir" +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/thirdparty/libpng-1.6.37/config.guess b/thirdparty/libpng-1.6.37/config.guess new file mode 100755 index 0000000..256083a --- /dev/null +++ b/thirdparty/libpng-1.6.37/config.guess @@ -0,0 +1,1476 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2018 Free Software Foundation, Inc. + +timestamp='2018-03-08' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# +# Please send patches to . + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2018 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > "$dummy.c" ; + for c in cc gcc c89 c99 ; do + if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "$UNAME_SYSTEM" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval "$set_cc_for_build" + cat <<-EOF > "$dummy.c" + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl + then + LIBC=musl + fi + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ + echo unknown)` + case "$UNAME_MACHINE_ARCH" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown + ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently (or will in the future) and ABI. + case "$UNAME_MACHINE_ARCH" in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval "$set_cc_for_build" + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case "$UNAME_MACHINE_ARCH" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "$UNAME_VERSION" in + Debian*) + release='-gnu' + ;; + *) + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "$machine-${os}${release}${abi}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" + exit ;; + *:ekkoBSD:*:*) + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" + exit ;; + *:SolidBSD:*:*) + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" + exit ;; + *:MirBSD:*:*) + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" + exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE=alpha ;; + "EV4.5 (21064)") + UNAME_MACHINE=alpha ;; + "LCA4 (21066/21068)") + UNAME_MACHINE=alpha ;; + "EV5 (21164)") + UNAME_MACHINE=alphaev5 ;; + "EV5.6 (21164A)") + UNAME_MACHINE=alphaev56 ;; + "EV5.6 (21164PC)") + UNAME_MACHINE=alphapca56 ;; + "EV5.7 (21164PC)") + UNAME_MACHINE=alphapca57 ;; + "EV6 (21264)") + UNAME_MACHINE=alphaev6 ;; + "EV6.7 (21264A)") + UNAME_MACHINE=alphaev67 ;; + "EV6.8CB (21264C)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8AL (21264B)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8CX (21264D)") + UNAME_MACHINE=alphaev68 ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE=alphaev69 ;; + "EV7 (21364)") + UNAME_MACHINE=alphaev7 ;; + "EV7.9 (21364A)") + UNAME_MACHINE=alphaev79 ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo "$UNAME_MACHINE"-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo "$UNAME_MACHINE"-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix"$UNAME_RELEASE" + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux"$UNAME_RELEASE" + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval "$set_cc_for_build" + SUN_ARCH=i386 + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH=x86_64 + fi + fi + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos"$UNAME_RELEASE" + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos"$UNAME_RELEASE" + ;; + sun4) + echo sparc-sun-sunos"$UNAME_RELEASE" + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos"$UNAME_RELEASE" + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint"$UNAME_RELEASE" + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint"$UNAME_RELEASE" + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint"$UNAME_RELEASE" + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten"$UNAME_RELEASE" + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten"$UNAME_RELEASE" + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix"$UNAME_RELEASE" + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix"$UNAME_RELEASE" + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix"$UNAME_RELEASE" + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos"$UNAME_RELEASE" + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] + then + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] + then + echo m88k-dg-dgux"$UNAME_RELEASE" + else + echo m88k-dg-dguxbcs"$UNAME_RELEASE" + fi + else + echo i586-dg-dgux"$UNAME_RELEASE" + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + fi + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + fi + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "$sc_cpu_version" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "$sc_kernel_bits" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "$HP_ARCH" = "" ]; then + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ "$HP_ARCH" = hppa2.0w ] + then + eval "$set_cc_for_build" + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH=hppa2.0w + else + HP_ARCH=hppa64 + fi + fi + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" + exit ;; + 3050*:HI-UX:*:*) + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo "$UNAME_MACHINE"-unknown-osf1mk + else + echo "$UNAME_MACHINE"-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi"$UNAME_RELEASE" + exit ;; + *:BSD/OS:*:*) + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case "$UNAME_PROCESSOR" in + amd64) + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; + esac + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" + exit ;; + i*:CYGWIN*:*) + echo "$UNAME_MACHINE"-pc-cygwin + exit ;; + *:MINGW64*:*) + echo "$UNAME_MACHINE"-pc-mingw64 + exit ;; + *:MINGW*:*) + echo "$UNAME_MACHINE"-pc-mingw32 + exit ;; + *:MSYS*:*) + echo "$UNAME_MACHINE"-pc-msys + exit ;; + i*:PW*:*) + echo "$UNAME_MACHINE"-pc-pw32 + exit ;; + *:Interix*:*) + case "$UNAME_MACHINE" in + x86) + echo i586-pc-interix"$UNAME_RELEASE" + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix"$UNAME_RELEASE" + exit ;; + IA64) + echo ia64-unknown-interix"$UNAME_RELEASE" + exit ;; + esac ;; + i*:UWIN*:*) + echo "$UNAME_MACHINE"-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + *:GNU:*:*) + # the GNU system + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" + exit ;; + i*86:Minix:*:*) + echo "$UNAME_MACHINE"-pc-minix + exit ;; + aarch64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + arm*:Linux:*:*) + eval "$set_cc_for_build" + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi + else + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + cris:Linux:*:*) + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + crisv32:Linux:*:*) + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + e2k:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + frv:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + hexagon:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + i*86:Linux:*:*) + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + exit ;; + ia64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + m32r*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + m68*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" + test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } + ;; + mips64el:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-"$LIBC" + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-"$LIBC" + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-"$LIBC" + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-"$LIBC" + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-"$LIBC" + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-"$LIBC" + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-"$LIBC" + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" + exit ;; + sh64*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + sh*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + tile*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + vax:Linux:*:*) + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" + exit ;; + x86_64:Linux:*:*) + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + exit ;; + xtensa*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo "$UNAME_MACHINE"-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo "$UNAME_MACHINE"-unknown-stop + exit ;; + i*86:atheos:*:*) + echo "$UNAME_MACHINE"-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo "$UNAME_MACHINE"-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos"$UNAME_RELEASE" + exit ;; + i*86:*DOS:*:*) + echo "$UNAME_MACHINE"-pc-msdosdjgpp + exit ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" + else + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" + else + echo "$UNAME_MACHINE"-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configure will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos"$UNAME_RELEASE" + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos"$UNAME_RELEASE" + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos"$UNAME_RELEASE" + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos"$UNAME_RELEASE" + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv"$UNAME_RELEASE" + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo "$UNAME_MACHINE"-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo "$UNAME_MACHINE"-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux"$UNAME_RELEASE" + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv"$UNAME_RELEASE" + else + echo mips-unknown-sysv"$UNAME_RELEASE" + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux"$UNAME_RELEASE" + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux"$UNAME_RELEASE" + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux"$UNAME_RELEASE" + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux"$UNAME_RELEASE" + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux"$UNAME_RELEASE" + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux"$UNAME_RELEASE" + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux"$UNAME_RELEASE" + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody"$UNAME_RELEASE" + exit ;; + *:Rhapsody:*:*) + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval "$set_cc_for_build" + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = x86; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = 386; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo "$UNAME_MACHINE"-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux"$UNAME_RELEASE" + exit ;; + *:DragonFly:*:*) + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "$UNAME_MACHINE" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" + exit ;; + i*86:rdos:*:*) + echo "$UNAME_MACHINE"-pc-rdos + exit ;; + i*86:AROS:*:*) + echo "$UNAME_MACHINE"-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo "$UNAME_MACHINE"-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; +esac + +echo "$0: unable to guess system type" >&2 + +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 </dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/thirdparty/libpng-1.6.37/config.h b/thirdparty/libpng-1.6.37/config.h new file mode 100644 index 0000000..608cc24 --- /dev/null +++ b/thirdparty/libpng-1.6.37/config.h @@ -0,0 +1,127 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `feenableexcept' function. */ +/* #undef HAVE_FEENABLEEXCEPT */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `m' library (-lm). */ +/* #undef HAVE_LIBM */ + +/* Define to 1 if you have the `z' library (-lz). */ +#define HAVE_LIBZ 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `pow' function. */ +#define HAVE_POW 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "libpng" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libpng" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libpng 1.6.37" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libpng" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.6.37" + +/* Turn on ARM Neon optimizations at run-time */ +/* #undef PNG_ARM_NEON_API_SUPPORTED */ + +/* Check for ARM Neon support at run-time */ +/* #undef PNG_ARM_NEON_CHECK_SUPPORTED */ + +/* Enable ARM Neon optimizations */ +/* #undef PNG_ARM_NEON_OPT */ + +/* Enable Intel SSE optimizations */ +/* #undef PNG_INTEL_SSE_OPT */ + +/* Turn on MIPS MSA optimizations at run-time */ +/* #undef PNG_MIPS_MSA_API_SUPPORTED */ + +/* Check for MIPS MSA support at run-time */ +/* #undef PNG_MIPS_MSA_CHECK_SUPPORTED */ + +/* Enable MIPS MSA optimizations */ +/* #undef PNG_MIPS_MSA_OPT */ + +/* Turn on POWERPC VSX optimizations at run-time */ +/* #undef PNG_POWERPC_VSX_API_SUPPORTED */ + +/* Check for POWERPC VSX support at run-time */ +/* #undef PNG_POWERPC_VSX_CHECK_SUPPORTED */ + +/* Enable POWERPC VSX optimizations */ +/* #undef PNG_POWERPC_VSX_OPT */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Version number of package */ +#define VERSION "1.6.37" + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#define restrict __restrict +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ diff --git a/thirdparty/libpng-1.6.37/config.h.in b/thirdparty/libpng-1.6.37/config.h.in new file mode 100644 index 0000000..2931048 --- /dev/null +++ b/thirdparty/libpng-1.6.37/config.h.in @@ -0,0 +1,126 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the `feenableexcept' function. */ +#undef HAVE_FEENABLEEXCEPT + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `m' library (-lm). */ +#undef HAVE_LIBM + +/* Define to 1 if you have the `z' library (-lz). */ +#undef HAVE_LIBZ + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `pow' function. */ +#undef HAVE_POW + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#undef LT_OBJDIR + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Turn on ARM Neon optimizations at run-time */ +#undef PNG_ARM_NEON_API_SUPPORTED + +/* Check for ARM Neon support at run-time */ +#undef PNG_ARM_NEON_CHECK_SUPPORTED + +/* Enable ARM Neon optimizations */ +#undef PNG_ARM_NEON_OPT + +/* Enable Intel SSE optimizations */ +#undef PNG_INTEL_SSE_OPT + +/* Turn on MIPS MSA optimizations at run-time */ +#undef PNG_MIPS_MSA_API_SUPPORTED + +/* Check for MIPS MSA support at run-time */ +#undef PNG_MIPS_MSA_CHECK_SUPPORTED + +/* Enable MIPS MSA optimizations */ +#undef PNG_MIPS_MSA_OPT + +/* Turn on POWERPC VSX optimizations at run-time */ +#undef PNG_POWERPC_VSX_API_SUPPORTED + +/* Check for POWERPC VSX support at run-time */ +#undef PNG_POWERPC_VSX_CHECK_SUPPORTED + +/* Enable POWERPC VSX optimizations */ +#undef PNG_POWERPC_VSX_OPT + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* Version number of package */ +#undef VERSION + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#undef restrict +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif + +/* Define to `unsigned int' if does not define. */ +#undef size_t diff --git a/thirdparty/libpng-1.6.37/config.log b/thirdparty/libpng-1.6.37/config.log new file mode 100644 index 0000000..2b51363 --- /dev/null +++ b/thirdparty/libpng-1.6.37/config.log @@ -0,0 +1,998 @@ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by libpng configure 1.6.37, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ ./configure --with-zlib-prefix=/home/scott/code/FLTK_Nano-X_DOS/installed/dos --disable-shared --build=x86_64-linux-gnu --host=i586-pc-msdosdjgpp --prefix=/home/scott/code/FLTK_Nano-X_DOS/installed/dos + +## --------- ## +## Platform. ## +## --------- ## + +hostname = kpdev +uname -m = x86_64 +uname -r = 5.14.0-1032-oem +uname -s = Linux +uname -v = #35-Ubuntu SMP Thu Mar 31 12:49:29 UTC 2022 + +/usr/bin/uname -p = x86_64 +/bin/uname -X = unknown + +/bin/arch = x86_64 +/usr/bin/arch -k = unknown +/usr/convex/getsysinfo = unknown +/usr/bin/hostinfo = unknown +/bin/machine = unknown +/usr/bin/oslevel = unknown +/bin/universe = unknown + +PATH: /opt/cross/djgpp/bin +PATH: /home/scott/opt/bin +PATH: /home/scott/joey/sdks/IIgs +PATH: /home/scott/.local/bin +PATH: /home/scott/bin +PATH: /usr/local/sbin +PATH: /usr/local/bin +PATH: /usr/sbin +PATH: /usr/bin +PATH: /sbin +PATH: /bin +PATH: /usr/games +PATH: /usr/local/games +PATH: /snap/bin + + +## ----------- ## +## Core tests. ## +## ----------- ## + +configure:2354: checking for a BSD-compatible install +configure:2422: result: /usr/bin/install -c +configure:2433: checking whether build environment is sane +configure:2488: result: yes +configure:2545: checking for i586-pc-msdosdjgpp-strip +configure:2561: found /opt/cross/djgpp/bin/i586-pc-msdosdjgpp-strip +configure:2572: result: i586-pc-msdosdjgpp-strip +configure:2637: checking for a thread-safe mkdir -p +configure:2676: result: /usr/bin/mkdir -p +configure:2683: checking for gawk +configure:2699: found /usr/bin/gawk +configure:2710: result: gawk +configure:2721: checking whether make sets $(MAKE) +configure:2743: result: yes +configure:2772: checking whether make supports nested variables +configure:2789: result: yes +configure:2919: checking whether to enable maintainer-specific portions of Makefiles +configure:2928: result: no +configure:2968: checking for i586-pc-msdosdjgpp-gcc +configure:2984: found /opt/cross/djgpp/bin/i586-pc-msdosdjgpp-gcc +configure:2995: result: i586-pc-msdosdjgpp-gcc +configure:3264: checking for C compiler version +configure:3273: i586-pc-msdosdjgpp-gcc --version >&5 +i586-pc-msdosdjgpp-gcc (GCC) 10.2.0 +Copyright (C) 2020 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +configure:3284: $? = 0 +configure:3273: i586-pc-msdosdjgpp-gcc -v >&5 +Using built-in specs. +COLLECT_GCC=i586-pc-msdosdjgpp-gcc +COLLECT_LTO_WRAPPER=/opt/cross/djgpp/libexec/gcc/i586-pc-msdosdjgpp/10.2.0/lto-wrapper +Target: i586-pc-msdosdjgpp +Configured with: ../gnu/gcc-10.20/configure --target=i586-pc-msdosdjgpp --program-prefix=i586-pc-msdosdjgpp- --prefix=/opt/cross/djgpp --disable-nls --disable-plugin --disable-lto --enable-lto --enable-libstdcxx-filesystem-ts --enable-libquadmath-support --with-gmp=/home/scott/source/build-djgpp/build/djcross-gcc-10.2.0/tmpinst --with-mpfr=/home/scott/source/build-djgpp/build/djcross-gcc-10.2.0/tmpinst --with-mpc=/home/scott/source/build-djgpp/build/djcross-gcc-10.2.0/tmpinst --enable-version-specific-runtime-libs --enable-languages=c,c++ +Thread model: single +Supported LTO compression algorithms: zlib +gcc version 10.2.0 (GCC) +configure:3284: $? = 0 +configure:3273: i586-pc-msdosdjgpp-gcc -V >&5 +i586-pc-msdosdjgpp-gcc: error: unrecognized command-line option '-V' +i586-pc-msdosdjgpp-gcc: fatal error: no input files +compilation terminated. +configure:3284: $? = 1 +configure:3273: i586-pc-msdosdjgpp-gcc -qversion >&5 +i586-pc-msdosdjgpp-gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'? +i586-pc-msdosdjgpp-gcc: fatal error: no input files +compilation terminated. +configure:3284: $? = 1 +configure:3304: checking whether the C compiler works +configure:3326: i586-pc-msdosdjgpp-gcc -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:3330: $? = 0 +configure:3378: result: yes +configure:3381: checking for C compiler default output file name +configure:3383: result: a.out +configure:3389: checking for suffix of executables +configure:3396: i586-pc-msdosdjgpp-gcc -o conftest -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:3400: $? = 0 +configure:3422: result: .exe +configure:3444: checking whether we are cross compiling +configure:3482: result: yes +configure:3487: checking for suffix of object files +configure:3509: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:3513: $? = 0 +configure:3534: result: o +configure:3538: checking whether we are using the GNU C compiler +configure:3557: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:3557: $? = 0 +configure:3566: result: yes +configure:3575: checking whether i586-pc-msdosdjgpp-gcc accepts -g +configure:3595: i586-pc-msdosdjgpp-gcc -c -g conftest.c >&5 +configure:3595: $? = 0 +configure:3636: result: yes +configure:3653: checking for i586-pc-msdosdjgpp-gcc option to accept ISO C89 +configure:3716: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:3716: $? = 0 +configure:3729: result: none needed +configure:3754: checking whether i586-pc-msdosdjgpp-gcc understands -c and -o together +configure:3776: i586-pc-msdosdjgpp-gcc -c conftest.c -o conftest2.o +configure:3779: $? = 0 +configure:3776: i586-pc-msdosdjgpp-gcc -c conftest.c -o conftest2.o +configure:3779: $? = 0 +configure:3791: result: yes +configure:3811: checking whether make supports the include directive +configure:3826: make -f confmf.GNU && cat confinc.out +this is the am__doit target +configure:3829: $? = 0 +configure:3848: result: yes (GNU style) +configure:3873: checking dependency style of i586-pc-msdosdjgpp-gcc +configure:3984: result: gcc3 +configure:4008: checking dependency style of i586-pc-msdosdjgpp-gcc +configure:4117: result: gcc3 +configure:4136: checking build system type +configure:4150: result: x86_64-pc-linux-gnu +configure:4170: checking host system type +configure:4183: result: i586-pc-msdosdjgpp +configure:4203: checking for a sed that does not truncate output +configure:4267: result: /usr/bin/sed +configure:4285: checking for grep that handles long lines and -e +configure:4343: result: /usr/bin/grep +configure:4348: checking for egrep +configure:4410: result: /usr/bin/grep -E +configure:4415: checking for fgrep +configure:4477: result: /usr/bin/grep -F +configure:4504: checking how to print strings +configure:4531: result: printf +configure:4564: checking for ld used by i586-pc-msdosdjgpp-gcc +configure:4631: result: /opt/cross/djgpp/i586-pc-msdosdjgpp/bin/ld +configure:4638: checking if the linker (/opt/cross/djgpp/i586-pc-msdosdjgpp/bin/ld) is GNU ld +configure:4653: result: yes +configure:4670: checking how to run the C preprocessor +configure:4701: i586-pc-msdosdjgpp-gcc -E conftest.c +configure:4701: $? = 0 +configure:4715: i586-pc-msdosdjgpp-gcc -E conftest.c +conftest.c:11:10: fatal error: ac_nonexistent.h: No such file or directory + 11 | #include + | ^~~~~~~~~~~~~~~~~~ +compilation terminated. +configure:4715: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "libpng" +| #define PACKAGE_TARNAME "libpng" +| #define PACKAGE_VERSION "1.6.37" +| #define PACKAGE_STRING "libpng 1.6.37" +| #define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net" +| #define PACKAGE_URL "" +| #define PACKAGE "libpng" +| #define VERSION "1.6.37" +| /* end confdefs.h. */ +| #include +configure:4740: result: i586-pc-msdosdjgpp-gcc -E +configure:4760: i586-pc-msdosdjgpp-gcc -E conftest.c +configure:4760: $? = 0 +configure:4774: i586-pc-msdosdjgpp-gcc -E conftest.c +conftest.c:11:10: fatal error: ac_nonexistent.h: No such file or directory + 11 | #include + | ^~~~~~~~~~~~~~~~~~ +compilation terminated. +configure:4774: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "libpng" +| #define PACKAGE_TARNAME "libpng" +| #define PACKAGE_VERSION "1.6.37" +| #define PACKAGE_STRING "libpng 1.6.37" +| #define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net" +| #define PACKAGE_URL "" +| #define PACKAGE "libpng" +| #define VERSION "1.6.37" +| /* end confdefs.h. */ +| #include +configure:4806: checking for gawk +configure:4833: result: gawk +configure:4845: checking whether ln -s works +configure:4849: result: yes +configure:4856: checking whether make sets $(MAKE) +configure:4878: result: yes +configure:4930: checking for BSD- or MS-compatible name lister (nm) +configure:4984: result: /opt/cross/djgpp/bin/i586-pc-msdosdjgpp-nm -B +configure:5114: checking the name lister (/opt/cross/djgpp/bin/i586-pc-msdosdjgpp-nm -B) interface +configure:5121: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:5124: /opt/cross/djgpp/bin/i586-pc-msdosdjgpp-nm -B "conftest.o" +configure:5127: output +00000000 b .bss +00000000 N .comment +00000000 d .data +00000000 t .text +00000000 B _some_variable +configure:5128: result: BSD nm +configure:5132: checking the maximum length of command line arguments +configure:5263: result: 1572864 +configure:5311: checking how to convert x86_64-pc-linux-gnu file names to i586-pc-msdosdjgpp format +configure:5351: result: func_convert_file_noop +configure:5358: checking how to convert x86_64-pc-linux-gnu file names to toolchain format +configure:5378: result: func_convert_file_noop +configure:5385: checking for /opt/cross/djgpp/i586-pc-msdosdjgpp/bin/ld option to reload object files +configure:5392: result: -r +configure:5426: checking for i586-pc-msdosdjgpp-objdump +configure:5442: found /opt/cross/djgpp/bin/i586-pc-msdosdjgpp-objdump +configure:5453: result: i586-pc-msdosdjgpp-objdump +configure:5522: checking how to recognize dependent libraries +configure:5722: result: unknown +configure:5767: checking for i586-pc-msdosdjgpp-dlltool +configure:5797: result: no +configure:5807: checking for dlltool +configure:5837: result: no +configure:5864: checking how to associate runtime and link libraries +configure:5891: result: printf %s\n +configure:5908: checking for i586-pc-msdosdjgpp-ar +configure:5924: found /opt/cross/djgpp/bin/i586-pc-msdosdjgpp-ar +configure:5935: result: i586-pc-msdosdjgpp-ar +configure:6016: checking for archiver @FILE support +configure:6033: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:6033: $? = 0 +configure:6036: i586-pc-msdosdjgpp-ar cru libconftest.a @conftest.lst >&5 +configure:6039: $? = 0 +configure:6044: i586-pc-msdosdjgpp-ar cru libconftest.a @conftest.lst >&5 +i586-pc-msdosdjgpp-ar: conftest.o: No such file or directory +configure:6047: $? = 1 +configure:6046: result: @ +configure:6064: checking for i586-pc-msdosdjgpp-strip +configure:6091: result: i586-pc-msdosdjgpp-strip +configure:6163: checking for i586-pc-msdosdjgpp-ranlib +configure:6179: found /opt/cross/djgpp/bin/i586-pc-msdosdjgpp-ranlib +configure:6190: result: i586-pc-msdosdjgpp-ranlib +configure:6332: checking command to parse /opt/cross/djgpp/bin/i586-pc-msdosdjgpp-nm -B output from i586-pc-msdosdjgpp-gcc object +configure:6485: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:6488: $? = 0 +configure:6492: /opt/cross/djgpp/bin/i586-pc-msdosdjgpp-nm -B conftest.o \| sed -n -e 's/^.*[ ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | sed '/ __gnu_lto/d' \> conftest.nm +configure:6495: $? = 0 +cannot find nm_test_var in conftest.nm +configure:6485: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:6488: $? = 0 +configure:6492: /opt/cross/djgpp/bin/i586-pc-msdosdjgpp-nm -B conftest.o \| sed -n -e 's/^.*[ ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[ ][ ]*_\([_A-Za-z][_A-Za-z0-9]*\)$/\1 _\2 \2/p' | sed '/ __gnu_lto/d' \> conftest.nm +configure:6495: $? = 0 +configure:6561: i586-pc-msdosdjgpp-gcc -o conftest.exe -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c conftstm.o >&5 +configure:6564: $? = 0 +configure:6602: result: ok +configure:6649: checking for sysroot +configure:6679: result: no +configure:6686: checking for a working dd +configure:6724: result: /usr/bin/dd +configure:6728: checking how to truncate binary pipes +configure:6743: result: /usr/bin/dd bs=4096 count=1 +configure:7032: checking for i586-pc-msdosdjgpp-mt +configure:7062: result: no +configure:7072: checking for mt +configure:7088: found /usr/bin/mt +configure:7099: result: mt +configure:7111: WARNING: using cross tools not prefixed with host triplet +configure:7122: checking if mt is a manifest tool +configure:7128: mt '-?' +configure:7136: result: no +configure:7809: checking for ANSI C header files +configure:7829: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:7829: $? = 0 +configure:7913: result: yes +configure:7926: checking for sys/types.h +configure:7926: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:7926: $? = 0 +configure:7926: result: yes +configure:7926: checking for sys/stat.h +configure:7926: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:7926: $? = 0 +configure:7926: result: yes +configure:7926: checking for stdlib.h +configure:7926: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:7926: $? = 0 +configure:7926: result: yes +configure:7926: checking for string.h +configure:7926: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:7926: $? = 0 +configure:7926: result: yes +configure:7926: checking for memory.h +configure:7926: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:7926: $? = 0 +configure:7926: result: yes +configure:7926: checking for strings.h +configure:7926: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:7926: $? = 0 +configure:7926: result: yes +configure:7926: checking for inttypes.h +configure:7926: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:7926: $? = 0 +configure:7926: result: yes +configure:7926: checking for stdint.h +configure:7926: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:7926: $? = 0 +configure:7926: result: yes +configure:7926: checking for unistd.h +configure:7926: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:7926: $? = 0 +configure:7926: result: yes +configure:7940: checking for dlfcn.h +configure:7940: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:7940: $? = 0 +configure:7940: result: yes +configure:8494: checking for objdir +configure:8509: result: .libs +configure:8773: checking if i586-pc-msdosdjgpp-gcc supports -fno-rtti -fno-exceptions +configure:8791: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib -fno-rtti -fno-exceptions conftest.c >&5 +cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C +configure:8795: $? = 0 +configure:8808: result: no +configure:9166: checking for i586-pc-msdosdjgpp-gcc option to produce PIC +configure:9173: result: +configure:9245: checking if i586-pc-msdosdjgpp-gcc static flag -static works +configure:9273: result: yes +configure:9288: checking if i586-pc-msdosdjgpp-gcc supports -c -o file.o +configure:9309: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib -o out/conftest2.o conftest.c >&5 +configure:9313: $? = 0 +configure:9335: result: yes +configure:9343: checking if i586-pc-msdosdjgpp-gcc supports -c -o file.o +configure:9390: result: yes +configure:9423: checking whether the i586-pc-msdosdjgpp-gcc linker (/opt/cross/djgpp/i586-pc-msdosdjgpp/bin/ld) supports shared libraries +configure:10682: result: no +configure:10922: checking dynamic linker characteristics +configure:11740: result: no +configure:11862: checking how to hardcode library paths into programs +configure:11887: result: unsupported +configure:12435: checking whether stripping libraries is possible +configure:12440: result: yes +configure:12475: checking if libtool supports shared libraries +configure:12477: result: no +configure:12480: checking whether to build shared libraries +configure:12505: result: no +configure:12508: checking whether to build static libraries +configure:12512: result: yes +configure:9345: checking that AWK works +configure:9351: result: ok +configure:9402: checking if we need to force back C standard to C89 +configure:9418: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:9418: $? = 0 +configure:9419: result: no +configure:9434: checking for ANSI C header files +configure:9538: result: yes +configure:9548: checking for an ANSI C-conforming const +configure:9614: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:9614: $? = 0 +configure:9621: result: yes +configure:9629: checking for size_t +configure:9629: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:9629: $? = 0 +configure:9629: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +conftest.c: In function 'main': +conftest.c:60:21: error: expected expression before ')' token + 60 | if (sizeof ((size_t))) + | ^ +configure:9629: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "libpng" +| #define PACKAGE_TARNAME "libpng" +| #define PACKAGE_VERSION "1.6.37" +| #define PACKAGE_STRING "libpng 1.6.37" +| #define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net" +| #define PACKAGE_URL "" +| #define PACKAGE "libpng" +| #define VERSION "1.6.37" +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| #define HAVE_DLFCN_H 1 +| #define LT_OBJDIR ".libs/" +| #define STDC_HEADERS 1 +| /* end confdefs.h. */ +| #include +| #ifdef HAVE_SYS_TYPES_H +| # include +| #endif +| #ifdef HAVE_SYS_STAT_H +| # include +| #endif +| #ifdef STDC_HEADERS +| # include +| # include +| #else +| # ifdef HAVE_STDLIB_H +| # include +| # endif +| #endif +| #ifdef HAVE_STRING_H +| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H +| # include +| # endif +| # include +| #endif +| #ifdef HAVE_STRINGS_H +| # include +| #endif +| #ifdef HAVE_INTTYPES_H +| # include +| #endif +| #ifdef HAVE_STDINT_H +| # include +| #endif +| #ifdef HAVE_UNISTD_H +| # include +| #endif +| int +| main () +| { +| if (sizeof ((size_t))) +| return 0; +| ; +| return 0; +| } +configure:9629: result: yes +configure:9640: checking whether struct tm is in sys/time.h or time.h +configure:9660: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:9660: $? = 0 +configure:9667: result: time.h +configure:9675: checking for C/C++ restrict keyword +configure:9700: i586-pc-msdosdjgpp-gcc -c -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +configure:9700: $? = 0 +configure:9708: result: __restrict +configure:9723: checking for working strtod +configure:9774: result: no +configure:9783: checking for pow +configure:9783: i586-pc-msdosdjgpp-gcc -o conftest.exe -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +conftest.c:48:6: warning: conflicting types for built-in function 'pow'; expected 'double(double, double)' [-Wbuiltin-declaration-mismatch] + 48 | char pow (); + | ^~~ +conftest.c:36:1: note: 'pow' is declared in header '' + 35 | # include + 36 | #else +configure:9783: $? = 0 +configure:9783: result: yes +configure:9838: checking for pow +configure:9838: result: yes +configure:9898: checking for clock_gettime +configure:9898: i586-pc-msdosdjgpp-gcc -o conftest.exe -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c >&5 +/tmp/ccbZw3j7.o:conftest.c:(.text+0x7): undefined reference to `clock_gettime' +collect2: error: ld returned 1 exit status +configure:9898: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "libpng" +| #define PACKAGE_TARNAME "libpng" +| #define PACKAGE_VERSION "1.6.37" +| #define PACKAGE_STRING "libpng 1.6.37" +| #define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net" +| #define PACKAGE_URL "" +| #define PACKAGE "libpng" +| #define VERSION "1.6.37" +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| #define HAVE_DLFCN_H 1 +| #define LT_OBJDIR ".libs/" +| #define STDC_HEADERS 1 +| #define restrict __restrict +| #define HAVE_POW 1 +| /* end confdefs.h. */ +| /* Define clock_gettime to an innocuous variant, in case declares clock_gettime. +| For example, HP-UX 11i declares gettimeofday. */ +| #define clock_gettime innocuous_clock_gettime +| +| /* System header to define __stub macros and hopefully few prototypes, +| which can conflict with char clock_gettime (); below. +| Prefer to if __STDC__ is defined, since +| exists even on freestanding compilers. */ +| +| #ifdef __STDC__ +| # include +| #else +| # include +| #endif +| +| #undef clock_gettime +| +| /* Override any GCC internal prototype to avoid an error. +| Use char because int might match the return type of a GCC +| builtin and then its argument prototype would still apply. */ +| #ifdef __cplusplus +| extern "C" +| #endif +| char clock_gettime (); +| /* The GNU C library defines this for functions which it implements +| to always fail with ENOSYS. Some functions are actually named +| something starting with __ and the normal name is an alias. */ +| #if defined __stub_clock_gettime || defined __stub___clock_gettime +| choke me +| #endif +| +| int +| main () +| { +| return clock_gettime (); +| ; +| return 0; +| } +configure:9898: result: no +configure:9902: WARNING: not building timepng +configure:9923: checking for zlibVersion in -lz +configure:9948: i586-pc-msdosdjgpp-gcc -o conftest.exe -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c -lz >&5 +configure:9948: $? = 0 +configure:9957: result: yes +configure:10022: checking for feenableexcept in -lm +configure:10047: i586-pc-msdosdjgpp-gcc -o conftest.exe -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c -lm -lz >&5 +/tmp/ccxIHtq4.o:conftest.c:(.text+0x7): undefined reference to `feenableexcept' +collect2: error: ld returned 1 exit status +configure:10047: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "libpng" +| #define PACKAGE_TARNAME "libpng" +| #define PACKAGE_VERSION "1.6.37" +| #define PACKAGE_STRING "libpng 1.6.37" +| #define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net" +| #define PACKAGE_URL "" +| #define PACKAGE "libpng" +| #define VERSION "1.6.37" +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| #define HAVE_DLFCN_H 1 +| #define LT_OBJDIR ".libs/" +| #define STDC_HEADERS 1 +| #define restrict __restrict +| #define HAVE_POW 1 +| #define HAVE_LIBZ 1 +| /* end confdefs.h. */ +| +| /* Override any GCC internal prototype to avoid an error. +| Use char because int might match the return type of a GCC +| builtin and then its argument prototype would still apply. */ +| #ifdef __cplusplus +| extern "C" +| #endif +| char feenableexcept (); +| int +| main () +| { +| return feenableexcept (); +| ; +| return 0; +| } +configure:10056: result: no +configure:10069: checking for feenableexcept +configure:10069: i586-pc-msdosdjgpp-gcc -o conftest.exe -DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib conftest.c -lz >&5 +/tmp/ccRiWpJ9.o:conftest.c:(.text+0x7): undefined reference to `feenableexcept' +collect2: error: ld returned 1 exit status +configure:10069: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "libpng" +| #define PACKAGE_TARNAME "libpng" +| #define PACKAGE_VERSION "1.6.37" +| #define PACKAGE_STRING "libpng 1.6.37" +| #define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net" +| #define PACKAGE_URL "" +| #define PACKAGE "libpng" +| #define VERSION "1.6.37" +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| #define HAVE_DLFCN_H 1 +| #define LT_OBJDIR ".libs/" +| #define STDC_HEADERS 1 +| #define restrict __restrict +| #define HAVE_POW 1 +| #define HAVE_LIBZ 1 +| /* end confdefs.h. */ +| /* Define feenableexcept to an innocuous variant, in case declares feenableexcept. +| For example, HP-UX 11i declares gettimeofday. */ +| #define feenableexcept innocuous_feenableexcept +| +| /* System header to define __stub macros and hopefully few prototypes, +| which can conflict with char feenableexcept (); below. +| Prefer to if __STDC__ is defined, since +| exists even on freestanding compilers. */ +| +| #ifdef __STDC__ +| # include +| #else +| # include +| #endif +| +| #undef feenableexcept +| +| /* Override any GCC internal prototype to avoid an error. +| Use char because int might match the return type of a GCC +| builtin and then its argument prototype would still apply. */ +| #ifdef __cplusplus +| extern "C" +| #endif +| char feenableexcept (); +| /* The GNU C library defines this for functions which it implements +| to always fail with ENOSYS. Some functions are actually named +| something starting with __ and the normal name is an alias. */ +| #if defined __stub_feenableexcept || defined __stub___feenableexcept +| choke me +| #endif +| +| int +| main () +| { +| return feenableexcept (); +| ; +| return 0; +| } +configure:10069: result: no +configure:10079: checking if using Solaris linker +configure:10088: result: no +configure:10100: checking if libraries can be versioned +configure:10121: result: yes +configure:10143: checking for symbol prefix +configure:10150: result: _ +configure:10172: pkgconfig directory is ${libdir}/pkgconfig +configure:10533: Extra options for compiler: +configure:10643: checking that generated files are newer than configure +configure:10649: result: done +configure:10724: creating ./config.status + +## ---------------------- ## +## Running config.status. ## +## ---------------------- ## + +This file was extended by libpng config.status 1.6.37, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = + CONFIG_HEADERS = + CONFIG_LINKS = + CONFIG_COMMANDS = + $ ./config.status + +on kpdev + +config.status:1125: creating Makefile +config.status:1125: creating libpng.pc +config.status:1125: creating libpng-config +config.status:1125: creating config.h +config.status:1306: config.h is unchanged +config.status:1354: executing depfiles commands +config.status:1431: cd . && sed -e '/# am--include-marker/d' Makefile | make -f - am--depfiles +make: Nothing to be done for 'am--depfiles'. +config.status:1436: $? = 0 +config.status:1354: executing libtool commands + +## ---------------- ## +## Cache variables. ## +## ---------------- ## + +ac_cv_build=x86_64-pc-linux-gnu +ac_cv_c_compiler_gnu=yes +ac_cv_c_const=yes +ac_cv_c_restrict=__restrict +ac_cv_env_CCASFLAGS_set= +ac_cv_env_CCASFLAGS_value= +ac_cv_env_CCAS_set= +ac_cv_env_CCAS_value= +ac_cv_env_CC_set= +ac_cv_env_CC_value= +ac_cv_env_CFLAGS_set=set +ac_cv_env_CFLAGS_value='-DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib' +ac_cv_env_CPPFLAGS_set= +ac_cv_env_CPPFLAGS_value= +ac_cv_env_CPP_set= +ac_cv_env_CPP_value= +ac_cv_env_LDFLAGS_set= +ac_cv_env_LDFLAGS_value= +ac_cv_env_LIBS_set= +ac_cv_env_LIBS_value= +ac_cv_env_LT_SYS_LIBRARY_PATH_set= +ac_cv_env_LT_SYS_LIBRARY_PATH_value= +ac_cv_env_PNG_COPTS_set= +ac_cv_env_PNG_COPTS_value= +ac_cv_env_build_alias_set=set +ac_cv_env_build_alias_value=x86_64-linux-gnu +ac_cv_env_host_alias_set=set +ac_cv_env_host_alias_value=i586-pc-msdosdjgpp +ac_cv_env_target_alias_set= +ac_cv_env_target_alias_value= +ac_cv_exeext=.exe +ac_cv_func_clock_gettime=no +ac_cv_func_feenableexcept=no +ac_cv_func_pow=yes +ac_cv_func_strtod=no +ac_cv_header_dlfcn_h=yes +ac_cv_header_inttypes_h=yes +ac_cv_header_memory_h=yes +ac_cv_header_stdc=yes +ac_cv_header_stdint_h=yes +ac_cv_header_stdlib_h=yes +ac_cv_header_string_h=yes +ac_cv_header_strings_h=yes +ac_cv_header_sys_stat_h=yes +ac_cv_header_sys_types_h=yes +ac_cv_header_unistd_h=yes +ac_cv_host=i586-pc-msdosdjgpp +ac_cv_lib_m_feenableexcept=no +ac_cv_lib_z_zlibVersion=yes +ac_cv_objext=o +ac_cv_path_EGREP='/usr/bin/grep -E' +ac_cv_path_FGREP='/usr/bin/grep -F' +ac_cv_path_GREP=/usr/bin/grep +ac_cv_path_SED=/usr/bin/sed +ac_cv_path_install='/usr/bin/install -c' +ac_cv_path_lt_DD=/usr/bin/dd +ac_cv_path_mkdir=/usr/bin/mkdir +ac_cv_prog_AR=i586-pc-msdosdjgpp-ar +ac_cv_prog_AWK=gawk +ac_cv_prog_CC=i586-pc-msdosdjgpp-gcc +ac_cv_prog_CPP='i586-pc-msdosdjgpp-gcc -E' +ac_cv_prog_OBJDUMP=i586-pc-msdosdjgpp-objdump +ac_cv_prog_RANLIB=i586-pc-msdosdjgpp-ranlib +ac_cv_prog_STRIP=i586-pc-msdosdjgpp-strip +ac_cv_prog_ac_ct_MANIFEST_TOOL=mt +ac_cv_prog_cc_c89= +ac_cv_prog_cc_g=yes +ac_cv_prog_make_make_set=yes +ac_cv_struct_tm=time.h +ac_cv_type_size_t=yes +am_cv_CCAS_dependencies_compiler_type=gcc3 +am_cv_CC_dependencies_compiler_type=gcc3 +am_cv_make_support_nested_variables=yes +am_cv_prog_cc_c_o=yes +lt_cv_ar_at_file=@ +lt_cv_deplibs_check_method=unknown +lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_ld_reload_flag=-r +lt_cv_nm_interface='BSD nm' +lt_cv_objdir=.libs +lt_cv_path_LD=/opt/cross/djgpp/i586-pc-msdosdjgpp/bin/ld +lt_cv_path_NM='/opt/cross/djgpp/bin/i586-pc-msdosdjgpp-nm -B' +lt_cv_path_mainfest_tool=no +lt_cv_prog_compiler_c_o=yes +lt_cv_prog_compiler_pic= +lt_cv_prog_compiler_rtti_exceptions=no +lt_cv_prog_compiler_static_works=yes +lt_cv_prog_gnu_ld=yes +lt_cv_sharedlib_from_linklib_cmd='printf %s\n' +lt_cv_sys_global_symbol_pipe='sed -n -e '\''s/^.*[ ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[ ][ ]*_\([_A-Za-z][_A-Za-z0-9]*\)$/\1 _\2 \2/p'\'' | sed '\''/ __gnu_lto/d'\''' +lt_cv_sys_global_symbol_to_c_name_address='sed -n -e '\''s/^: \(.*\) .*$/ {"\1", (void *) 0},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/ {"\1", (void *) \&\1},/p'\''' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='sed -n -e '\''s/^: \(.*\) .*$/ {"\1", (void *) 0},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(lib.*\)$/ {"\1", (void *) \&\1},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/ {"lib\1", (void *) \&\1},/p'\''' +lt_cv_sys_global_symbol_to_cdecl='sed -n -e '\''s/^T .* \(.*\)$/extern int \1();/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/extern char \1;/p'\''' +lt_cv_sys_global_symbol_to_import= +lt_cv_sys_max_cmd_len=1572864 +lt_cv_to_host_file_cmd=func_convert_file_noop +lt_cv_to_tool_file_cmd=func_convert_file_noop +lt_cv_truncate_bin='/usr/bin/dd bs=4096 count=1' + +## ----------------- ## +## Output variables. ## +## ----------------- ## + +ACLOCAL='${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing aclocal-1.16' +AMDEPBACKSLASH='\' +AMDEP_FALSE='#' +AMDEP_TRUE='' +AMTAR='$${TAR-tar}' +AM_BACKSLASH='\' +AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +AM_DEFAULT_VERBOSITY='1' +AM_V='$(V)' +AR='i586-pc-msdosdjgpp-ar' +AS='as' +AUTOCONF='${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing autoconf' +AUTOHEADER='${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing autoheader' +AUTOMAKE='${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing automake-1.16' +AWK='gawk' +CC='i586-pc-msdosdjgpp-gcc' +CCAS='i586-pc-msdosdjgpp-gcc' +CCASDEPMODE='depmode=gcc3' +CCASFLAGS='-DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib' +CCDEPMODE='depmode=gcc3' +CFLAGS='-DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib' +CPP='i586-pc-msdosdjgpp-gcc -E' +CPPFLAGS='' +CYGPATH_W='echo' +DEFS='-DHAVE_CONFIG_H' +DEPDIR='.deps' +DFNCPP='i586-pc-msdosdjgpp-gcc -E' +DLLTOOL='false' +DO_INSTALL_LIBPNG_CONFIG_FALSE='#' +DO_INSTALL_LIBPNG_CONFIG_TRUE='' +DO_INSTALL_LIBPNG_PC_FALSE='#' +DO_INSTALL_LIBPNG_PC_TRUE='' +DO_INSTALL_LINKS_FALSE='#' +DO_INSTALL_LINKS_TRUE='' +DO_PNG_PREFIX_FALSE='' +DO_PNG_PREFIX_TRUE='#' +DSYMUTIL='' +DUMPBIN='' +ECHO_C='' +ECHO_N='-n' +ECHO_T='' +EGREP='/usr/bin/grep -E' +EXEEXT='.exe' +FGREP='/usr/bin/grep -F' +GREP='/usr/bin/grep' +HAVE_CLOCK_GETTIME_FALSE='' +HAVE_CLOCK_GETTIME_TRUE='#' +HAVE_LD_VERSION_SCRIPT_FALSE='#' +HAVE_LD_VERSION_SCRIPT_TRUE='' +HAVE_SOLARIS_LD_FALSE='' +HAVE_SOLARIS_LD_TRUE='#' +INSTALL_DATA='${INSTALL} -m 644' +INSTALL_PROGRAM='${INSTALL}' +INSTALL_SCRIPT='${INSTALL}' +INSTALL_STRIP_PROGRAM='$(install_sh) -c -s' +LD='/opt/cross/djgpp/i586-pc-msdosdjgpp/bin/ld' +LDFLAGS='' +LIBOBJS=' ${LIBOBJDIR}strtod$U.o' +LIBS='-lz ' +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +LIPO='' +LN_S='ln -s' +LTLIBOBJS=' ${LIBOBJDIR}strtod$U.lo' +LT_SYS_LIBRARY_PATH='' +MAINT='#' +MAINTAINER_MODE_FALSE='' +MAINTAINER_MODE_TRUE='#' +MAKEINFO='${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing makeinfo' +MANIFEST_TOOL=':' +MKDIR_P='/usr/bin/mkdir -p' +NM='/opt/cross/djgpp/bin/i586-pc-msdosdjgpp-nm -B' +NMEDIT='' +OBJDUMP='i586-pc-msdosdjgpp-objdump' +OBJEXT='o' +OTOOL64='' +OTOOL='' +PACKAGE='libpng' +PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net' +PACKAGE_NAME='libpng' +PACKAGE_STRING='libpng 1.6.37' +PACKAGE_TARNAME='libpng' +PACKAGE_URL='' +PACKAGE_VERSION='1.6.37' +PATH_SEPARATOR=':' +PNGLIB_MAJOR='1' +PNGLIB_MINOR='6' +PNGLIB_RELEASE='37' +PNGLIB_VERSION='1.6.37' +PNG_ARM_NEON_FALSE='' +PNG_ARM_NEON_TRUE='#' +PNG_COPTS='' +PNG_INTEL_SSE_FALSE='#' +PNG_INTEL_SSE_TRUE='' +PNG_MIPS_MSA_FALSE='#' +PNG_MIPS_MSA_TRUE='' +PNG_POWERPC_VSX_FALSE='#' +PNG_POWERPC_VSX_TRUE='' +PNG_PREFIX='' +POW_LIB='' +RANLIB='i586-pc-msdosdjgpp-ranlib' +SED='/usr/bin/sed' +SET_MAKE='' +SHELL='/bin/bash' +STRIP='i586-pc-msdosdjgpp-strip' +SYMBOL_PREFIX='_' +VERSION='1.6.37' +ac_ct_AR='' +ac_ct_CC='' +ac_ct_DUMPBIN='' +am__EXEEXT_FALSE='#' +am__EXEEXT_TRUE='' +am__fastdepCCAS_FALSE='#' +am__fastdepCCAS_TRUE='' +am__fastdepCC_FALSE='#' +am__fastdepCC_TRUE='' +am__include='include' +am__isrc='' +am__leading_dot='.' +am__nodep='_no' +am__quote='' +am__tar='$${TAR-tar} chof - "$$tardir"' +am__untar='$${TAR-tar} xf -' +binconfigs='${binconfigs}' +bindir='${exec_prefix}/bin' +build='x86_64-pc-linux-gnu' +build_alias='x86_64-linux-gnu' +build_cpu='x86_64' +build_os='linux-gnu' +build_vendor='pc' +datadir='${datarootdir}' +datarootdir='${prefix}/share' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +dvidir='${docdir}' +exec_prefix='${prefix}' +host='i586-pc-msdosdjgpp' +host_alias='i586-pc-msdosdjgpp' +host_cpu='i586' +host_os='msdosdjgpp' +host_vendor='pc' +htmldir='${docdir}' +includedir='${prefix}/include' +infodir='${datarootdir}/info' +install_sh='${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/install-sh' +libdir='${exec_prefix}/lib' +libexecdir='${exec_prefix}/libexec' +localedir='${datarootdir}/locale' +localstatedir='${prefix}/var' +mandir='${datarootdir}/man' +mkdir_p='$(MKDIR_P)' +oldincludedir='/usr/include' +pdfdir='${docdir}' +pkgconfigdir='${libdir}/pkgconfig' +prefix='/home/scott/code/FLTK_Nano-X_DOS/installed/dos' +program_transform_name='s,x,x,' +psdir='${docdir}' +sbindir='${exec_prefix}/sbin' +sharedstatedir='${prefix}/com' +sysconfdir='${prefix}/etc' +target_alias='' + +## ----------- ## +## confdefs.h. ## +## ----------- ## + +/* confdefs.h */ +#define PACKAGE_NAME "libpng" +#define PACKAGE_TARNAME "libpng" +#define PACKAGE_VERSION "1.6.37" +#define PACKAGE_STRING "libpng 1.6.37" +#define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net" +#define PACKAGE_URL "" +#define PACKAGE "libpng" +#define VERSION "1.6.37" +#define STDC_HEADERS 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_DLFCN_H 1 +#define LT_OBJDIR ".libs/" +#define STDC_HEADERS 1 +#define restrict __restrict +#define HAVE_POW 1 +#define HAVE_LIBZ 1 + +configure: exit 0 diff --git a/thirdparty/libpng-1.6.37/config.status b/thirdparty/libpng-1.6.37/config.status new file mode 100755 index 0000000..efdbdb6 --- /dev/null +++ b/thirdparty/libpng-1.6.37/config.status @@ -0,0 +1,2011 @@ +#! /bin/bash +# Generated by configure. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=${CONFIG_SHELL-/bin/bash} +export SHELL +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by libpng $as_me 1.6.37, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +# Files that config.status was made for. +config_files=" Makefile libpng.pc:libpng.pc.in libpng-config:libpng-config.in" +config_headers=" config.h" +config_commands=" depfiles libtool" + +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." + +ac_cs_config="'--with-zlib-prefix=/home/scott/code/FLTK_Nano-X_DOS/installed/dos' '--disable-shared' '--build=x86_64-linux-gnu' '--host=i586-pc-msdosdjgpp' '--prefix=/home/scott/code/FLTK_Nano-X_DOS/installed/dos' 'build_alias=x86_64-linux-gnu' 'host_alias=i586-pc-msdosdjgpp' 'CFLAGS=-DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib'" +ac_cs_version="\ +libpng config.status 1.6.37 +configured by ./configure, generated by GNU Autoconf 2.69, + with options \"$ac_cs_config\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='/home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37' +srcdir='.' +INSTALL='/usr/bin/install -c' +MKDIR_P='/usr/bin/mkdir -p' +AWK='gawk' +test -n "$AWK" || AWK=awk +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +if $ac_cs_recheck; then + set X /bin/bash './configure' '--with-zlib-prefix=/home/scott/code/FLTK_Nano-X_DOS/installed/dos' '--disable-shared' '--build=x86_64-linux-gnu' '--host=i586-pc-msdosdjgpp' '--prefix=/home/scott/code/FLTK_Nano-X_DOS/installed/dos' 'build_alias=x86_64-linux-gnu' 'host_alias=i586-pc-msdosdjgpp' 'CFLAGS=-DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib' $ac_configure_extra_args --no-create --no-recursion + shift + $as_echo "running CONFIG_SHELL=/bin/bash $*" >&6 + CONFIG_SHELL='/bin/bash' + export CONFIG_SHELL + exec "$@" +fi + +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +# +# INIT-COMMANDS +# +AMDEP_TRUE="" MAKE="make" + + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +double_quote_subst='s/\(["`\\]\)/\\\1/g' +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' +SED='/usr/bin/sed' +Xsed='/usr/bin/sed -e 1s/^X//' +GREP='/usr/bin/grep' +EGREP='/usr/bin/grep -E' +FGREP='/usr/bin/grep -F' +SHELL='/bin/bash' +ECHO='printf %s\n' +LD='/opt/cross/djgpp/i586-pc-msdosdjgpp/bin/ld' +macro_version='2.4.6' +macro_revision='2.4.6' +AS='as' +DLLTOOL='false' +OBJDUMP='i586-pc-msdosdjgpp-objdump' +enable_shared='no' +enable_static='yes' +pic_mode='default' +enable_fast_install='needless' +shared_archive_member_spec='' +PATH_SEPARATOR=':' +host_alias='i586-pc-msdosdjgpp' +host='i586-pc-msdosdjgpp' +host_os='msdosdjgpp' +build_alias='x86_64-linux-gnu' +build='x86_64-pc-linux-gnu' +build_os='linux-gnu' +NM='/opt/cross/djgpp/bin/i586-pc-msdosdjgpp-nm -B' +LN_S='ln -s' +max_cmd_len='1572864' +ac_objext='o' +exeext='' +lt_unset='unset' +lt_SP2NL='tr \040 \012' +lt_NL2SP='tr \015\012 \040\040' +lt_cv_to_host_file_cmd='func_convert_file_noop' +lt_cv_to_tool_file_cmd='func_convert_file_noop' +reload_flag=' -r' +reload_cmds='$LD$reload_flag -o $output$reload_objs' +deplibs_check_method='unknown' +file_magic_cmd='$MAGIC_CMD' +file_magic_glob='' +want_nocaseglob='no' +sharedlib_from_linklib_cmd='printf %s\n' +AR='i586-pc-msdosdjgpp-ar' +AR_FLAGS='cru' +archiver_list_spec='@' +STRIP='i586-pc-msdosdjgpp-strip' +RANLIB='i586-pc-msdosdjgpp-ranlib' +old_postinstall_cmds='chmod 644 $oldlib~$RANLIB $tool_oldlib' +old_postuninstall_cmds='' +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs~$RANLIB $tool_oldlib' +lock_old_archive_extraction='no' +CC='i586-pc-msdosdjgpp-gcc' +CFLAGS='-DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib' +compiler='i586-pc-msdosdjgpp-gcc' +GCC='yes' +lt_cv_sys_global_symbol_pipe='sed -n -e '\''s/^.*[ ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[ ][ ]*_\([_A-Za-z][_A-Za-z0-9]*\)$/\1 _\2 \2/p'\'' | sed '\''/ __gnu_lto/d'\''' +lt_cv_sys_global_symbol_to_cdecl='sed -n -e '\''s/^T .* \(.*\)$/extern int \1();/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/extern char \1;/p'\''' +lt_cv_sys_global_symbol_to_import='' +lt_cv_sys_global_symbol_to_c_name_address='sed -n -e '\''s/^: \(.*\) .*$/ {"\1", (void *) 0},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/ {"\1", (void *) \&\1},/p'\''' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='sed -n -e '\''s/^: \(.*\) .*$/ {"\1", (void *) 0},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(lib.*\)$/ {"\1", (void *) \&\1},/p'\'' -e '\''s/^[ABCDGIRSTW][ABCDGIRSTW]* .* \(.*\)$/ {"lib\1", (void *) \&\1},/p'\''' +lt_cv_nm_interface='BSD nm' +nm_file_list_spec='@' +lt_sysroot='' +lt_cv_truncate_bin='/usr/bin/dd bs=4096 count=1' +objdir='.libs' +MAGIC_CMD='file' +lt_prog_compiler_no_builtin_flag=' -fno-builtin' +lt_prog_compiler_pic='' +lt_prog_compiler_wl='-Wl,' +lt_prog_compiler_static='-static' +lt_cv_prog_compiler_c_o='yes' +need_locks='no' +MANIFEST_TOOL=':' +DSYMUTIL='' +NMEDIT='' +LIPO='' +OTOOL='' +OTOOL64='' +libext='a' +shrext_cmds='.so' +extract_expsyms_cmds='' +archive_cmds_need_lc='yes' +enable_shared_with_static_runtimes='no' +export_dynamic_flag_spec='' +whole_archive_flag_spec='' +compiler_needs_object='no' +old_archive_from_new_cmds='' +old_archive_from_expsyms_cmds='' +archive_cmds='' +archive_expsym_cmds='' +module_cmds='' +module_expsym_cmds='' +with_gnu_ld='yes' +allow_undefined_flag='' +no_undefined_flag='' +hardcode_libdir_flag_spec='' +hardcode_libdir_separator='' +hardcode_direct='no' +hardcode_direct_absolute='no' +hardcode_minus_L='no' +hardcode_shlibpath_var='unsupported' +hardcode_automatic='no' +inherit_rpath='no' +link_all_deplibs='unknown' +always_export_symbols='no' +export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' +exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' +include_expsyms='' +prelink_cmds='' +postlink_cmds='' +file_list_spec='' +variables_saved_for_relink='PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH' +need_lib_prefix='unknown' +need_version='unknown' +version_type='none' +runpath_var='' +shlibpath_var='' +shlibpath_overrides_runpath='unknown' +libname_spec='lib$name' +library_names_spec='' +soname_spec='' +install_override_mode='' +postinstall_cmds='' +postuninstall_cmds='' +finish_cmds='' +finish_eval='' +hardcode_into_libs='no' +sys_lib_search_path_spec='/opt/cross/djgpp/lib/gcc/i586-pc-msdosdjgpp/10.2.0 /opt/cross/djgpp/i586-pc-msdosdjgpp/lib ' +configure_time_dlsearch_path='/lib /usr/lib' +configure_time_lt_sys_library_path='' +hardcode_action='unsupported' +enable_dlopen='unknown' +enable_dlopen_self='unknown' +enable_dlopen_self_static='unknown' +old_striplib='i586-pc-msdosdjgpp-strip --strip-debug' +striplib='i586-pc-msdosdjgpp-strip --strip-unneeded' + +LTCC='i586-pc-msdosdjgpp-gcc' +LTCFLAGS='-DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib' +compiler='i586-pc-msdosdjgpp-gcc' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in SED GREP EGREP FGREP SHELL ECHO LD AS DLLTOOL OBJDUMP PATH_SEPARATOR NM LN_S lt_SP2NL lt_NL2SP reload_flag deplibs_check_method file_magic_cmd file_magic_glob want_nocaseglob sharedlib_from_linklib_cmd AR AR_FLAGS archiver_list_spec STRIP RANLIB CC CFLAGS compiler lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl lt_cv_sys_global_symbol_to_import lt_cv_sys_global_symbol_to_c_name_address lt_cv_sys_global_symbol_to_c_name_address_lib_prefix lt_cv_nm_interface nm_file_list_spec lt_cv_truncate_bin lt_prog_compiler_no_builtin_flag lt_prog_compiler_pic lt_prog_compiler_wl lt_prog_compiler_static lt_cv_prog_compiler_c_o need_locks MANIFEST_TOOL DSYMUTIL NMEDIT LIPO OTOOL OTOOL64 shrext_cmds export_dynamic_flag_spec whole_archive_flag_spec compiler_needs_object with_gnu_ld allow_undefined_flag no_undefined_flag hardcode_libdir_flag_spec hardcode_libdir_separator exclude_expsyms include_expsyms file_list_spec variables_saved_for_relink libname_spec library_names_spec soname_spec install_override_mode finish_eval old_striplib striplib; do + case `eval \\$ECHO \\""\\$$var"\\"` in + *[\\\`\"\$]*) + eval "lt_$var=\\\"\`\$ECHO \"\$$var\" | \$SED \"\$sed_quote_subst\"\`\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_$var=\\\"\$$var\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in reload_cmds old_postinstall_cmds old_postuninstall_cmds old_archive_cmds extract_expsyms_cmds old_archive_from_new_cmds old_archive_from_expsyms_cmds archive_cmds archive_expsym_cmds module_cmds module_expsym_cmds export_symbols_cmds prelink_cmds postlink_cmds postinstall_cmds postuninstall_cmds finish_cmds sys_lib_search_path_spec configure_time_dlsearch_path configure_time_lt_sys_library_path; do + case `eval \\$ECHO \\""\\$$var"\\"` in + *[\\\`\"\$]*) + eval "lt_$var=\\\"\`\$ECHO \"\$$var\" | \$SED -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_$var=\\\"\$$var\\\"" + ;; + esac +done + +ac_aux_dir='.' + +# See if we are running on zsh, and set the options that allow our +# commands through without removal of \ escapes INIT. +if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + + + PACKAGE='libpng' + VERSION='1.6.37' + RM='rm -f' + ofile='libtool' + + + + + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "libpng.pc") CONFIG_FILES="$CONFIG_FILES libpng.pc:libpng.pc.in" ;; + "libpng-config") CONFIG_FILES="$CONFIG_FILES libpng-config:libpng-config.in" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +cat >>"$ac_tmp/subs1.awk" <<\_ACAWK && +S["am__EXEEXT_FALSE"]="#" +S["am__EXEEXT_TRUE"]="" +S["LTLIBOBJS"]=" ${LIBOBJDIR}strtod$U.lo" +S["PNG_POWERPC_VSX_FALSE"]="#" +S["PNG_POWERPC_VSX_TRUE"]="" +S["PNG_INTEL_SSE_FALSE"]="#" +S["PNG_INTEL_SSE_TRUE"]="" +S["PNG_MIPS_MSA_FALSE"]="#" +S["PNG_MIPS_MSA_TRUE"]="" +S["PNG_ARM_NEON_FALSE"]="" +S["PNG_ARM_NEON_TRUE"]="#" +S["DO_INSTALL_LIBPNG_CONFIG_FALSE"]="#" +S["DO_INSTALL_LIBPNG_CONFIG_TRUE"]="" +S["DO_INSTALL_LIBPNG_PC_FALSE"]="#" +S["DO_INSTALL_LIBPNG_PC_TRUE"]="" +S["DO_INSTALL_LINKS_FALSE"]="#" +S["DO_INSTALL_LINKS_TRUE"]="" +S["DO_PNG_PREFIX_FALSE"]="" +S["DO_PNG_PREFIX_TRUE"]="#" +S["PNG_PREFIX"]="" +S["binconfigs"]="${binconfigs}" +S["pkgconfigdir"]="${libdir}/pkgconfig" +S["PNGLIB_RELEASE"]="37" +S["PNGLIB_MINOR"]="6" +S["PNGLIB_MAJOR"]="1" +S["PNGLIB_VERSION"]="1.6.37" +S["SYMBOL_PREFIX"]="_" +S["HAVE_LD_VERSION_SCRIPT_FALSE"]="#" +S["HAVE_LD_VERSION_SCRIPT_TRUE"]="" +S["HAVE_SOLARIS_LD_FALSE"]="" +S["HAVE_SOLARIS_LD_TRUE"]="#" +S["HAVE_CLOCK_GETTIME_FALSE"]="" +S["HAVE_CLOCK_GETTIME_TRUE"]="#" +S["LIBOBJS"]=" ${LIBOBJDIR}strtod$U.o" +S["POW_LIB"]="" +S["PNG_COPTS"]="" +S["DFNCPP"]="i586-pc-msdosdjgpp-gcc -E" +S["LT_SYS_LIBRARY_PATH"]="" +S["OTOOL64"]="" +S["OTOOL"]="" +S["LIPO"]="" +S["NMEDIT"]="" +S["DSYMUTIL"]="" +S["MANIFEST_TOOL"]=":" +S["RANLIB"]="i586-pc-msdosdjgpp-ranlib" +S["ac_ct_AR"]="" +S["AR"]="i586-pc-msdosdjgpp-ar" +S["NM"]="/opt/cross/djgpp/bin/i586-pc-msdosdjgpp-nm -B" +S["ac_ct_DUMPBIN"]="" +S["DUMPBIN"]="" +S["LIBTOOL"]="$(SHELL) $(top_builddir)/libtool" +S["OBJDUMP"]="i586-pc-msdosdjgpp-objdump" +S["DLLTOOL"]="false" +S["AS"]="as" +S["LN_S"]="ln -s" +S["CPP"]="i586-pc-msdosdjgpp-gcc -E" +S["LD"]="/opt/cross/djgpp/i586-pc-msdosdjgpp/bin/ld" +S["FGREP"]="/usr/bin/grep -F" +S["EGREP"]="/usr/bin/grep -E" +S["GREP"]="/usr/bin/grep" +S["SED"]="/usr/bin/sed" +S["host_os"]="msdosdjgpp" +S["host_vendor"]="pc" +S["host_cpu"]="i586" +S["host"]="i586-pc-msdosdjgpp" +S["build_os"]="linux-gnu" +S["build_vendor"]="pc" +S["build_cpu"]="x86_64" +S["build"]="x86_64-pc-linux-gnu" +S["am__fastdepCCAS_FALSE"]="#" +S["am__fastdepCCAS_TRUE"]="" +S["CCASDEPMODE"]="depmode=gcc3" +S["CCASFLAGS"]="-DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib" +S["CCAS"]="i586-pc-msdosdjgpp-gcc" +S["am__fastdepCC_FALSE"]="#" +S["am__fastdepCC_TRUE"]="" +S["CCDEPMODE"]="depmode=gcc3" +S["am__nodep"]="_no" +S["AMDEPBACKSLASH"]="\\" +S["AMDEP_FALSE"]="#" +S["AMDEP_TRUE"]="" +S["am__include"]="include" +S["DEPDIR"]=".deps" +S["OBJEXT"]="o" +S["EXEEXT"]=".exe" +S["ac_ct_CC"]="" +S["CPPFLAGS"]="" +S["LDFLAGS"]="" +S["CFLAGS"]="-DPNG_NO_CONSOLE_IO -I/home/scott/code/FLTK_Nano-X_DOS/installed/dos/include -L/home/scott/code/FLTK_Nano-X_DOS/installed/dos/lib" +S["CC"]="i586-pc-msdosdjgpp-gcc" +S["MAINT"]="#" +S["MAINTAINER_MODE_FALSE"]="" +S["MAINTAINER_MODE_TRUE"]="#" +S["AM_BACKSLASH"]="\\" +S["AM_DEFAULT_VERBOSITY"]="1" +S["AM_DEFAULT_V"]="$(AM_DEFAULT_VERBOSITY)" +S["AM_V"]="$(V)" +S["am__untar"]="$${TAR-tar} xf -" +S["am__tar"]="$${TAR-tar} chof - \"$$tardir\"" +S["AMTAR"]="$${TAR-tar}" +S["am__leading_dot"]="." +S["SET_MAKE"]="" +S["AWK"]="gawk" +S["mkdir_p"]="$(MKDIR_P)" +S["MKDIR_P"]="/usr/bin/mkdir -p" +S["INSTALL_STRIP_PROGRAM"]="$(install_sh) -c -s" +S["STRIP"]="i586-pc-msdosdjgpp-strip" +S["install_sh"]="${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/install-sh" +S["MAKEINFO"]="${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing makeinfo" +S["AUTOHEADER"]="${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing autoheader" +S["AUTOMAKE"]="${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing automake-1.16" +S["AUTOCONF"]="${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing autoconf" +S["ACLOCAL"]="${SHELL} /home/scott/code/FLTK_Nano-X_DOS/libpng-1.6.37/missing aclocal-1.16" +S["VERSION"]="1.6.37" +S["PACKAGE"]="libpng" +S["CYGPATH_W"]="echo" +S["am__isrc"]="" +S["INSTALL_DATA"]="${INSTALL} -m 644" +S["INSTALL_SCRIPT"]="${INSTALL}" +S["INSTALL_PROGRAM"]="${INSTALL}" +S["target_alias"]="" +S["host_alias"]="i586-pc-msdosdjgpp" +S["build_alias"]="x86_64-linux-gnu" +S["LIBS"]="-lz " +S["ECHO_T"]="" +S["ECHO_N"]="-n" +S["ECHO_C"]="" +S["DEFS"]="-DHAVE_CONFIG_H" +S["mandir"]="${datarootdir}/man" +S["localedir"]="${datarootdir}/locale" +S["libdir"]="${exec_prefix}/lib" +S["psdir"]="${docdir}" +S["pdfdir"]="${docdir}" +S["dvidir"]="${docdir}" +S["htmldir"]="${docdir}" +S["infodir"]="${datarootdir}/info" +S["docdir"]="${datarootdir}/doc/${PACKAGE_TARNAME}" +S["oldincludedir"]="/usr/include" +S["includedir"]="${prefix}/include" +S["localstatedir"]="${prefix}/var" +S["sharedstatedir"]="${prefix}/com" +S["sysconfdir"]="${prefix}/etc" +S["datadir"]="${datarootdir}" +S["datarootdir"]="${prefix}/share" +S["libexecdir"]="${exec_prefix}/libexec" +S["sbindir"]="${exec_prefix}/sbin" +S["bindir"]="${exec_prefix}/bin" +S["program_transform_name"]="s,x,x," +S["prefix"]="/home/scott/code/FLTK_Nano-X_DOS/installed/dos" +S["exec_prefix"]="${prefix}" +S["PACKAGE_URL"]="" +S["PACKAGE_BUGREPORT"]="png-mng-implement@lists.sourceforge.net" +S["PACKAGE_STRING"]="libpng 1.6.37" +S["PACKAGE_VERSION"]="1.6.37" +S["PACKAGE_TARNAME"]="libpng" +S["PACKAGE_NAME"]="libpng" +S["PATH_SEPARATOR"]=":" +S["SHELL"]="/bin/bash" +S["am__quote"]="" +_ACAWK +cat >>"$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +D["PACKAGE_NAME"]=" \"libpng\"" +D["PACKAGE_TARNAME"]=" \"libpng\"" +D["PACKAGE_VERSION"]=" \"1.6.37\"" +D["PACKAGE_STRING"]=" \"libpng 1.6.37\"" +D["PACKAGE_BUGREPORT"]=" \"png-mng-implement@lists.sourceforge.net\"" +D["PACKAGE_URL"]=" \"\"" +D["PACKAGE"]=" \"libpng\"" +D["VERSION"]=" \"1.6.37\"" +D["STDC_HEADERS"]=" 1" +D["HAVE_SYS_TYPES_H"]=" 1" +D["HAVE_SYS_STAT_H"]=" 1" +D["HAVE_STDLIB_H"]=" 1" +D["HAVE_STRING_H"]=" 1" +D["HAVE_MEMORY_H"]=" 1" +D["HAVE_STRINGS_H"]=" 1" +D["HAVE_INTTYPES_H"]=" 1" +D["HAVE_STDINT_H"]=" 1" +D["HAVE_UNISTD_H"]=" 1" +D["HAVE_DLFCN_H"]=" 1" +D["LT_OBJDIR"]=" \".libs/\"" +D["STDC_HEADERS"]=" 1" +D["restrict"]=" __restrict" +D["HAVE_POW"]=" 1" +D["HAVE_LIBZ"]=" 1" + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ { + line = $ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} + ac_datarootdir_hack=' + s&@datadir@&${datarootdir}&g + s&@docdir@&${datarootdir}/doc/${PACKAGE_TARNAME}&g + s&@infodir@&${datarootdir}/info&g + s&@localedir@&${datarootdir}/locale&g + s&@mandir@&${datarootdir}/man&g + s&\${datarootdir}&${prefix}/share&g' ;; +esac +ac_sed_extra="/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +} + +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Older Autoconf quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + case $CONFIG_FILES in #( + *\'*) : + eval set x "$CONFIG_FILES" ;; #( + *) : + set x $CONFIG_FILES ;; #( + *) : + ;; +esac + shift + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf + do + # Strip MF so we end up with the name of the file. + am_mf=`$as_echo "$am_mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`$as_dirname -- "$am_mf" || +$as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$am_mf" : 'X\(//\)[^/]' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$am_mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + am_filepart=`$as_basename -- "$am_mf" || +$as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$am_mf" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { echo "$as_me:$LINENO: cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles" >&5 + (cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } || am_rc=$? + done + if test $am_rc -ne 0; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. Try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking). +See \`config.log' for more details" "$LINENO" 5; } + fi + { am_dirpart=; unset am_dirpart;} + { am_filepart=; unset am_filepart;} + { am_mf=; unset am_mf;} + { am_rc=; unset am_rc;} + rm -f conftest-deps.mk +} + ;; + "libtool":C) + + # See if we are running on zsh, and set the options that allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST + fi + + cfgfile=${ofile}T + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL +# Generated automatically by $as_me ($PACKAGE) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# The names of the tagged configurations supported by this script. +available_tags='' + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} + +# ### BEGIN LIBTOOL CONFIG + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="\$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP=$lt_GREP + +# An ERE matcher. +EGREP=$lt_EGREP + +# A literal string matcher. +FGREP=$lt_FGREP + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# An echo program that protects backslashes. +ECHO=$lt_ECHO + +# Which release of libtool.m4 was used? +macro_version=$macro_version +macro_revision=$macro_revision + +# Assembler program. +AS=$lt_AS + +# DLL creation program. +DLLTOOL=$lt_DLLTOOL + +# Object dumper program. +OBJDUMP=$lt_OBJDUMP + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# What type of objects to build. +pic_mode=$pic_mode + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# Shared archive member basename,for filename based shared library versioning on AIX. +shared_archive_member_spec=$shared_archive_member_spec + +# The PATH separator for the build system. +PATH_SEPARATOR=$lt_PATH_SEPARATOR + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# A BSD- or MS-compatible name lister. +NM=$lt_NM + +# Whether we need soft or hard links. +LN_S=$lt_LN_S + +# What is the maximum length of a command? +max_cmd_len=$max_cmd_len + +# Object file suffix (normally "o"). +objext=$ac_objext + +# Executable file suffix (normally ""). +exeext=$exeext + +# whether the shell understands "unset". +lt_unset=$lt_unset + +# turn spaces into newlines. +SP2NL=$lt_lt_SP2NL + +# turn newlines into spaces. +NL2SP=$lt_lt_NL2SP + +# convert \$build file names to \$host format. +to_host_file_cmd=$lt_cv_to_host_file_cmd + +# convert \$build files to toolchain format. +to_tool_file_cmd=$lt_cv_to_tool_file_cmd + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method = "file_magic". +file_magic_cmd=$lt_file_magic_cmd + +# How to find potential files when deplibs_check_method = "file_magic". +file_magic_glob=$lt_file_magic_glob + +# Find potential files using nocaseglob when deplibs_check_method = "file_magic". +want_nocaseglob=$lt_want_nocaseglob + +# Command to associate shared and link libraries. +sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd + +# The archiver. +AR=$lt_AR + +# Flags to create an archive. +AR_FLAGS=$lt_AR_FLAGS + +# How to feed a file listing to the archiver. +archiver_list_spec=$lt_archiver_list_spec + +# A symbol stripping program. +STRIP=$lt_STRIP + +# Commands used to install an old-style archive. +RANLIB=$lt_RANLIB +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Whether to use a lock for old archive extraction. +lock_old_archive_extraction=$lock_old_archive_extraction + +# A C compiler. +LTCC=$lt_CC + +# LTCC compiler flags. +LTCFLAGS=$lt_CFLAGS + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm into a list of symbols to manually relocate. +global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix + +# The name lister interface. +nm_interface=$lt_lt_cv_nm_interface + +# Specify filename containing input files for \$NM. +nm_file_list_spec=$lt_nm_file_list_spec + +# The root where to search for dependent libraries,and where our libraries should be installed. +lt_sysroot=$lt_sysroot + +# Command to truncate a binary pipe. +lt_truncate_bin=$lt_lt_cv_truncate_bin + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=$MAGIC_CMD + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Manifest tool. +MANIFEST_TOOL=$lt_MANIFEST_TOOL + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL=$lt_DSYMUTIL + +# Tool to change global to local symbols on Mac OS X. +NMEDIT=$lt_NMEDIT + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO=$lt_LIPO + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL=$lt_OTOOL + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64=$lt_OTOOL64 + +# Old archive suffix (normally "a"). +libext=$libext + +# Shared library suffix (normally ".so"). +shrext_cmds=$lt_shrext_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink=$lt_variables_saved_for_relink + +# Do we need the "lib" prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Library versioning type. +version_type=$version_type + +# Shared library runtime path variable. +runpath_var=$runpath_var + +# Shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Permission mode override for installation of shared libraries. +install_override_mode=$lt_install_override_mode + +# Command to use after installation of a shared archive. +postinstall_cmds=$lt_postinstall_cmds + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval=$lt_finish_eval + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Compile-time system search path for libraries. +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Detected run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path + +# Explicit LT_SYS_LIBRARY_PATH set during ./configure time. +configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + + +# The linker used to build libraries. +LD=$lt_LD + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds + +# A language specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU compiler? +with_gcc=$GCC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \$shlibpath_var if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds + +# Commands necessary for finishing linking programs. +postlink_cmds=$lt_postlink_cmds + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# ### END LIBTOOL CONFIG + +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + + +# ### END FUNCTIONS SHARED WITH CONFIGURE + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + +ltmain=$ac_aux_dir/ltmain.sh + + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + + ;; + "libpng-config":F) chmod +x libpng-config ;; + + esac +done # for ac_tag + + +as_fn_exit 0 diff --git a/thirdparty/libpng-1.6.37/config.sub b/thirdparty/libpng-1.6.37/config.sub new file mode 100755 index 0000000..9ccf09a --- /dev/null +++ b/thirdparty/libpng-1.6.37/config.sub @@ -0,0 +1,1801 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2018 Free Software Foundation, Inc. + +timestamp='2018-03-08' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS + +Canonicalize a configuration name. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2018 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo "$1" + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo "$1" | sed 's/-[^-]*$//'` + if [ "$basic_machine" != "$1" ] + then os=`echo "$1" | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze*) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ + | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | wasm32 \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | ba-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | e2k-* | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ + | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ + | pyramid-* \ + | riscv32-* | riscv64-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | wasm32-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-pc + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + asmjs) + basic_machine=asmjs-unknown + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2*) + basic_machine=m68k-bull + os=-sysv3 + ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=$os"spe" + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=-linux + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + nsv-tandem) + basic_machine=nsv-tandem + ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + x64) + basic_machine=x86_64-pc + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases that might get confused + # with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # es1800 is here to avoid being matched by es* (a different OS) + -es1800*) + os=-ose + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* | -hcos* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ + | -midnightbsd*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -xray | -os68k* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo "$os" | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4*) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $basic_machine in + arm*) + os=-eabi + ;; + *) + os=-elf + ;; + esac + ;; + -nacl*) + ;; + -ios) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + pru-*) + os=-elf + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` + ;; +esac + +echo "$basic_machine$os" +exit + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/thirdparty/libpng-1.6.37/configure b/thirdparty/libpng-1.6.37/configure new file mode 100755 index 0000000..1b2c463 --- /dev/null +++ b/thirdparty/libpng-1.6.37/configure @@ -0,0 +1,16116 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for libpng 1.6.37. +# +# Report bugs to . +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1 + + test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( + ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + PATH=/empty FPATH=/empty; export PATH FPATH + test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ + || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and +$0: png-mng-implement@lists.sourceforge.net about your +$0: system, including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + +SHELL=${CONFIG_SHELL-/bin/sh} + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='libpng' +PACKAGE_TARNAME='libpng' +PACKAGE_VERSION='1.6.37' +PACKAGE_STRING='libpng 1.6.37' +PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net' +PACKAGE_URL='' + +ac_unique_file="pngget.c" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +PNG_POWERPC_VSX_FALSE +PNG_POWERPC_VSX_TRUE +PNG_INTEL_SSE_FALSE +PNG_INTEL_SSE_TRUE +PNG_MIPS_MSA_FALSE +PNG_MIPS_MSA_TRUE +PNG_ARM_NEON_FALSE +PNG_ARM_NEON_TRUE +DO_INSTALL_LIBPNG_CONFIG_FALSE +DO_INSTALL_LIBPNG_CONFIG_TRUE +DO_INSTALL_LIBPNG_PC_FALSE +DO_INSTALL_LIBPNG_PC_TRUE +DO_INSTALL_LINKS_FALSE +DO_INSTALL_LINKS_TRUE +DO_PNG_PREFIX_FALSE +DO_PNG_PREFIX_TRUE +PNG_PREFIX +binconfigs +pkgconfigdir +PNGLIB_RELEASE +PNGLIB_MINOR +PNGLIB_MAJOR +PNGLIB_VERSION +SYMBOL_PREFIX +HAVE_LD_VERSION_SCRIPT_FALSE +HAVE_LD_VERSION_SCRIPT_TRUE +HAVE_SOLARIS_LD_FALSE +HAVE_SOLARIS_LD_TRUE +HAVE_CLOCK_GETTIME_FALSE +HAVE_CLOCK_GETTIME_TRUE +LIBOBJS +POW_LIB +PNG_COPTS +DFNCPP +LT_SYS_LIBRARY_PATH +OTOOL64 +OTOOL +LIPO +NMEDIT +DSYMUTIL +MANIFEST_TOOL +RANLIB +ac_ct_AR +AR +NM +ac_ct_DUMPBIN +DUMPBIN +LIBTOOL +OBJDUMP +DLLTOOL +AS +LN_S +CPP +LD +FGREP +EGREP +GREP +SED +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +am__fastdepCCAS_FALSE +am__fastdepCCAS_TRUE +CCASDEPMODE +CCASFLAGS +CCAS +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +am__nodep +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +MAINT +MAINTAINER_MODE_FALSE +MAINTAINER_MODE_TRUE +AM_BACKSLASH +AM_DEFAULT_VERBOSITY +AM_DEFAULT_V +AM_V +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL +am__quote' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_silent_rules +enable_maintainer_mode +enable_dependency_tracking +with_gnu_ld +enable_shared +enable_static +with_pic +enable_fast_install +with_aix_soname +with_sysroot +enable_libtool_lock +enable_werror +with_zlib_prefix +with_pkgconfigdir +with_binconfigs +with_libpng_prefix +enable_unversioned_links +enable_unversioned_libpng_pc +enable_unversioned_libpng_config +enable_hardware_optimizations +enable_arm_neon +enable_mips_msa +enable_intel_sse +enable_powerpc_vsx +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CCAS +CCASFLAGS +CPP +LT_SYS_LIBRARY_PATH +PNG_COPTS' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures libpng 1.6.37 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/libpng] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of libpng 1.6.37:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-silent-rules less verbose build output (undo: "make V=1") + --disable-silent-rules verbose build output (undo: "make V=0") + --enable-maintainer-mode + enable make rules and dependencies not useful (and + sometimes confusing) to the casual installer + --enable-dependency-tracking + do not reject slow dependency extractors + --disable-dependency-tracking + speeds up one-time build + --enable-shared[=PKGS] build shared libraries [default=yes] + --enable-static[=PKGS] build static libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-libtool-lock avoid locking (might break parallel builds) + --enable-werror[=OPT] Pass -Werror or the given argument to the compiler + if it is supported + --enable-unversioned-links + Installed libpng header files are placed in a + versioned subdirectory and installed libpng library + (including DLL) files are versioned. If this option + is enabled unversioned links will be created + pointing to the corresponding installed files. If + you use libpng.pc or libpng-config for all builds + you do not need these links, but if you compile + programs directly they will typically #include + and link with -lpng; in that case you need + the links. The links can be installed manually using + 'make install-header-links' and 'make + install-library-links' and can be removed using the + corresponding uninstall- targets. If you do enable + this option every libpng 'make install' will + recreate the links to point to the just installed + version of libpng. The default is to create the + links; use --disable-unversioned-links to change + this + --enable-unversioned-libpng-pc + Install the configuration file 'libpng.pc' as a link + to the versioned version. This is done by default - + use --disable-unversioned-libpng-pc to change this. + --enable-unversioned-libpng-config + Install the configuration file 'libpng-config' as a + link to the versioned version. This is done by + default - use --disable-unversioned-libpng-config to + change this. + --enable-hardware-optimizations + Enable hardware optimizations: =no/off, yes/on: + --enable-arm-neon Enable ARM NEON optimizations: =no/off, check, api, + yes/on: no/off: disable the optimizations; check: + use internal checking code (deprecated and poorly + supported); api: disable by default, enable by a + call to png_set_option; yes/on: turn on + unconditionally. If not specified: determined by the + compiler. + --enable-mips-msa Enable MIPS MSA optimizations: =no/off, check, api, + yes/on: no/off: disable the optimizations; check: + use internal checking code (deprecated and poorly + supported); api: disable by default, enable by a + call to png_set_option; yes/on: turn on + unconditionally. If not specified: determined by the + compiler. + --enable-intel-sse Enable Intel SSE optimizations: =no/off, yes/on: + no/off: disable the optimizations; yes/on: enable + the optimizations. If not specified: determined by + the compiler. + --enable-powerpc-vsx Enable POWERPC VSX optimizations: =no/off, check, + api, yes/on: no/off: disable the optimizations; + check: use internal checking code api: disable by + default, enable by a call to png_set_option yes/on: + turn on unconditionally. If not specified: + determined by the compiler. + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use + both] + --with-aix-soname=aix|svr4|both + shared library versioning (aka "SONAME") variant to + provide on AIX, [default=aix]. + --with-sysroot[=DIR] Search for dependent libraries within DIR (or the + compiler's sysroot if not specified). + --with-zlib-prefix prefix that may have been used in installed zlib + --with-pkgconfigdir Use the specified pkgconfig dir (default is + libdir/pkgconfig) + --with-binconfigs Generate shell libpng-config scripts as well as + pkg-config data [default=yes] + --with-libpng-prefix prefix libpng exported function (API) names with the + given value + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CCAS assembler compiler command (defaults to CC) + CCASFLAGS assembler compiler flags (defaults to CFLAGS) + CPP C preprocessor + LT_SYS_LIBRARY_PATH + User-defined run-time library search path. + PNG_COPTS additional flags for the C compiler, use this for options that + would cause configure itself to fail + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +libpng configure 1.6.37 +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_type +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by libpng $as_me 1.6.37, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + +# libpng does not follow GNU file name conventions (hence 'foreign') +# color-tests requires automake 1.11 or later +# silent-rules requires automake 1.11 or later +# dist-xz requires automake 1.11 or later +# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1 +# 1.13 is required for parallel tests +am__api_version='1.16' + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; +esac +case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) + as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; +esac + +# Do 'set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken + alias in your environment" "$LINENO" 5 + fi + if test "$2" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done + test "$2" = conftest.file + ) +then + # Ok. + : +else + as_fn_error $? "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi + +rm -f conftest.file + +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` + +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " +else + am_missing_run= + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} +fi + +if test x"${install_sh+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the 'STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if ${ac_cv_path_mkdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + test -d ./--version && rmdir ./--version + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +# Check whether --enable-silent-rules was given. +if test "${enable_silent_rules+set}" = set; then : + enableval=$enable_silent_rules; +fi + +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=1;; +esac +am_make=${MAKE-make} +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +$as_echo_n "checking whether $am_make supports nested variables... " >&6; } +if ${am_cv_make_support_nested_variables+:} false; then : + $as_echo_n "(cached) " >&6 +else + if $as_echo 'TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +$as_echo "$am_cv_make_support_nested_variables" >&6; } +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AM_BACKSLASH='\' + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='libpng' + VERSION='1.6.37' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +mkdir_p='$(MKDIR_P)' + +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. +# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AMTAR='$${TAR-tar}' + + +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar pax cpio none' + +am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' + + + + + + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 + fi +fi + +# The following line causes --disable-maintainer-mode to be the default to +# configure. This is necessary because libpng distributions cannot rely on the +# time stamps of the autotools generated files being correct + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 +$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } + # Check whether --enable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then : + enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 +$as_echo "$USE_MAINTAINER_MODE" >&6; } + if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + + MAINT=$MAINTAINER_MODE_TRUE + + + + +PNGLIB_VERSION=1.6.37 +PNGLIB_MAJOR=1 +PNGLIB_MINOR=6 +PNGLIB_RELEASE=37 + + + +ac_config_headers="$ac_config_headers config.h" + + +# Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 +$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } +if ${am_cv_prog_cc_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 + ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +$as_echo "$am_cv_prog_cc_c_o" >&6; } +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 +$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } +cat > confinc.mk << 'END' +am__doit: + @echo this is the am__doit target >confinc.out +.PHONY: am__doit +END +am__include="#" +am__quote= +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 + (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + case $?:`cat confinc.out 2>/dev/null` in #( + '0:this is the am__doit target') : + case $s in #( + BSD) : + am__include='.include' am__quote='"' ;; #( + *) : + am__include='include' am__quote='' ;; +esac ;; #( + *) : + ;; +esac + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 +$as_echo "${_am_result}" >&6; } + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CC_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +# By default we simply use the C compiler to build assembly code. + +test "${CCAS+set}" = set || CCAS=$CC +test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS + + + +depcc="$CCAS" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CCAS_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CCAS_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CCAS_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CCAS_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CCAS_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CCAS_dependencies_compiler_type" >&6; } +CCASDEPMODE=depmode=$am_cv_CCAS_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CCAS_dependencies_compiler_type" = gcc3; then + am__fastdepCCAS_TRUE= + am__fastdepCCAS_FALSE='#' +else + am__fastdepCCAS_TRUE='#' + am__fastdepCCAS_FALSE= +fi + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if ${ac_cv_path_SED+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + { ac_script=; unset ac_script;} + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_SED" || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_SED_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi +else + ac_cv_path_SED=$SED +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +$as_echo "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed + +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 +$as_echo_n "checking for fgrep... " >&6; } +if ${ac_cv_path_FGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 + then ac_cv_path_FGREP="$GREP -F" + else + if test -z "$FGREP"; then + ac_path_FGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in fgrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_FGREP" || continue +# Check for GNU ac_path_FGREP and select it if it is found. + # Check for GNU $ac_path_FGREP +case `"$ac_path_FGREP" --version 2>&1` in +*GNU*) + ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'FGREP' >> "conftest.nl" + "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_FGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_FGREP="$ac_path_FGREP" + ac_path_FGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_FGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_FGREP"; then + as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_FGREP=$FGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 +$as_echo "$ac_cv_path_FGREP" >&6; } + FGREP="$ac_cv_path_FGREP" + + +test -z "$GREP" && GREP=grep + + + + + + + + + + + + + + + + + +ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 +$as_echo_n "checking how to print strings... " >&6; } +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "" +} + +case $ECHO in + printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 +$as_echo "printf" >&6; } ;; + print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 +$as_echo "print -r" >&6; } ;; + *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 +$as_echo "cat" >&6; } ;; +esac + + + + + + + + + + + + + + + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then : + withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test yes = "$GCC"; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +$as_echo_n "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return, which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD=$ac_prog + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test yes = "$with_gnu_ld"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if ${lt_cv_path_LD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD=$ac_dir/$ac_prog + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if ${lt_cv_prog_gnu_ld+:} false; then : + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +$as_echo "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + + +case `pwd` in + *\ * | *\ *) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 +$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; +esac + + + +macro_version='2.4.6' +macro_revision='2.4.6' + + + + + + + + + + + + + +ltmain=$ac_aux_dir/ltmain.sh + +# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 +$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } +if ${lt_cv_path_NM+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM=$NM +else + lt_nm_to_check=${ac_tool_prefix}nm + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + tmp_nm=$ac_dir/$lt_tmp_nm + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the 'sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + case $build_os in + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac + case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break 2 + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break 2 + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS=$lt_save_ifs + done + : ${lt_cv_path_NM=no} +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 +$as_echo "$lt_cv_path_NM" >&6; } +if test no != "$lt_cv_path_NM"; then + NM=$lt_cv_path_NM +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$DUMPBIN"; then : + # Let the user override the test. + else + if test -n "$ac_tool_prefix"; then + for ac_prog in dumpbin "link -dump" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DUMPBIN+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DUMPBIN"; then + ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DUMPBIN=$ac_cv_prog_DUMPBIN +if test -n "$DUMPBIN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 +$as_echo "$DUMPBIN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$DUMPBIN" && break + done +fi +if test -z "$DUMPBIN"; then + ac_ct_DUMPBIN=$DUMPBIN + for ac_prog in dumpbin "link -dump" +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DUMPBIN"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN +if test -n "$ac_ct_DUMPBIN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 +$as_echo "$ac_ct_DUMPBIN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_DUMPBIN" && break +done + + if test "x$ac_ct_DUMPBIN" = x; then + DUMPBIN=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DUMPBIN=$ac_ct_DUMPBIN + fi +fi + + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols -headers" + ;; + *) + DUMPBIN=: + ;; + esac + fi + + if test : != "$DUMPBIN"; then + NM=$DUMPBIN + fi +fi +test -z "$NM" && NM=nm + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 +$as_echo_n "checking the name lister ($NM) interface... " >&6; } +if ${lt_cv_nm_interface+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&5 + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&5 + (eval echo "\"\$as_me:$LINENO: output\"" >&5) + cat conftest.out >&5 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 +$as_echo "$lt_cv_nm_interface" >&6; } + +# find the maximum length of command line arguments +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 +$as_echo_n "checking the maximum length of command line arguments... " >&6; } +if ${lt_cv_sys_max_cmd_len+:} false; then : + $as_echo_n "(cached) " >&6 +else + i=0 + teststring=ABCD + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + mint*) + # On MiNT this can take a long time and run out of memory. + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test X`env echo "$teststring$teststring" 2>/dev/null` \ + = "X$teststring$teststring"; } >/dev/null 2>&1 && + test 17 != "$i" # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac + +fi + +if test -n "$lt_cv_sys_max_cmd_len"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 +$as_echo "$lt_cv_sys_max_cmd_len" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 +$as_echo "none" >&6; } +fi +max_cmd_len=$lt_cv_sys_max_cmd_len + + + + + + +: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi + + + + + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 +$as_echo_n "checking how to convert $build file names to $host format... " >&6; } +if ${lt_cv_to_host_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac + +fi + +to_host_file_cmd=$lt_cv_to_host_file_cmd +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 +$as_echo "$lt_cv_to_host_file_cmd" >&6; } + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 +$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } +if ${lt_cv_to_tool_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + #assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac + +fi + +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 +$as_echo "$lt_cv_to_tool_file_cmd" >&6; } + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 +$as_echo_n "checking for $LD option to reload object files... " >&6; } +if ${lt_cv_ld_reload_flag+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_reload_flag='-r' +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 +$as_echo "$lt_cv_ld_reload_flag" >&6; } +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + if test yes != "$GCC"; then + reload_cmds=false + fi + ;; + darwin*) + if test yes = "$GCC"; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +$as_echo "$OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +$as_echo "$ac_ct_OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + +test -z "$OBJDUMP" && OBJDUMP=objdump + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 +$as_echo_n "checking how to recognize dependent libraries... " >&6; } +if ${lt_cv_deplibs_check_method+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# 'unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# that responds to the $file_magic_cmd with a given extended regex. +# If you have 'file' or equivalent on your system and you're not sure +# whether 'pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[4-9]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + # Keep this pattern in sync with the one in func_win32_libid. + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc*) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +haiku*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[3-9]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd* | bitrig*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +os2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 +$as_echo "$lt_cv_deplibs_check_method" >&6; } + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` + fi + ;; + esac +fi + +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + + + + + + + + + + + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +$as_echo "$DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DLLTOOL="dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +$as_echo "$ac_ct_DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" +fi + +test -z "$DLLTOOL" && DLLTOOL=dlltool + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 +$as_echo_n "checking how to associate runtime and link libraries... " >&6; } +if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd=$ECHO + ;; +esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 +$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + + + + + + + + +if test -n "$ac_tool_prefix"; then + for ac_prog in ar + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AR" && break + done +fi +if test -z "$AR"; then + ac_ct_AR=$AR + for ac_prog in ar +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_AR" && break +done + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +fi + +: ${AR=ar} +: ${AR_FLAGS=cru} + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 +$as_echo_n "checking for archiver @FILE support... " >&6; } +if ${lt_cv_ar_at_file+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ar_at_file=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test 0 -eq "$ac_status"; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test 0 -ne "$ac_status"; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 +$as_echo "$lt_cv_ar_at_file" >&6; } + +if test no = "$lt_cv_ar_at_file"; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +test -z "$STRIP" && STRIP=: + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +test -z "$RANLIB" && RANLIB=: + + + + + + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + bitrig* | openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" +fi + +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 +$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } +if ${lt_cv_sys_global_symbol_pipe+:} false; then : + $as_echo_n "(cached) " >&6 +else + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[ABCDGISTW]' + ;; +hpux*) + if test ia64 = "$host_cpu"; then + symcode='[ABCDEGRST]' + fi + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris*) + symcode='[BDRT]' + ;; +sco3.2v5*) + symcode='[DT]' + ;; +sysv4.2uw2*) + symcode='[DT]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[ABDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. + lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" + lt_c_name_lib_hook="\ + -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ + -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" +else + # Disable hooks by default. + lt_cv_sys_global_symbol_to_import= + lt_cdecl_hook= + lt_c_name_hook= + lt_c_name_lib_hook= +fi + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +$lt_cdecl_hook\ +" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +$lt_c_name_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + +# Transform an extracted symbol line into symbol name with lib prefix and +# symbol address. +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +$lt_c_name_lib_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK '"\ +" {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ +" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ +" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ +" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ +" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 + (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +LT_DLSYM_CONST struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS + LIBS=conftstm.$ac_objext + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest$ac_exeext; then + pipe_works=yes + fi + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test yes = "$pipe_works"; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +$as_echo "failed" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } +fi + +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then + nm_file_list_spec='@' +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 +$as_echo_n "checking for sysroot... " >&6; } + +# Check whether --with-sysroot was given. +if test "${with_sysroot+set}" = set; then : + withval=$with_sysroot; +else + with_sysroot=no +fi + + +lt_sysroot= +case $with_sysroot in #( + yes) + if test yes = "$GCC"; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 +$as_echo "$with_sysroot" >&6; } + as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 + ;; +esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 +$as_echo "${lt_sysroot:-no}" >&6; } + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 +$as_echo_n "checking for a working dd... " >&6; } +if ${ac_cv_path_lt_DD+:} false; then : + $as_echo_n "(cached) " >&6 +else + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +: ${lt_DD:=$DD} +if test -z "$lt_DD"; then + ac_path_lt_DD_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in dd; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_lt_DD" || continue +if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: +fi + $ac_path_lt_DD_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_lt_DD"; then + : + fi +else + ac_cv_path_lt_DD=$lt_DD +fi + +rm -f conftest.i conftest2.i conftest.out +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 +$as_echo "$ac_cv_path_lt_DD" >&6; } + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 +$as_echo_n "checking how to truncate binary pipes... " >&6; } +if ${lt_cv_truncate_bin+:} false; then : + $as_echo_n "(cached) " >&6 +else + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +lt_cv_truncate_bin= +if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out +test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 +$as_echo "$lt_cv_truncate_bin" >&6; } + + + + + + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + +# Check whether --enable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then : + enableval=$enable_libtool_lock; +fi + +test no = "$enable_libtool_lock" || enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out what ABI is being produced by ac_compile, and set mode + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE=32 + ;; + *ELF-64*) + HPUX_IA64_MODE=64 + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + if test yes = "$lt_cv_prog_gnu_ld"; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +mips64*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + emul=elf + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; + *64-bit*) + emul="${emul}64" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; + *LSB*) + emul="${emul}ltsmip" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; + esac + LD="${LD-ld} -m $emul" + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. Note that the listed cases only cover the + # situations where additional linker options are needed (such as when + # doing 32-bit compilation for a host where ld defaults to 64-bit, or + # vice versa); the common cases where no linker options are needed do + # not appear in the list. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac + ;; + powerpc64le-*linux*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + powerpcle-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -belf" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 +$as_echo_n "checking whether the C compiler needs -belf... " >&6; } +if ${lt_cv_cc_needs_belf+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_cc_needs_belf=yes +else + lt_cv_cc_needs_belf=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 +$as_echo "$lt_cv_cc_needs_belf" >&6; } + if test yes != "$lt_cv_cc_needs_belf"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS=$SAVE_CFLAGS + fi + ;; +*-*solaris*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) + case $host in + i?86-*-solaris*|x86_64-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD=${LD-ld}_sol2 + fi + ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks=$enable_libtool_lock + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. +set dummy ${ac_tool_prefix}mt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$MANIFEST_TOOL"; then + ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL +if test -n "$MANIFEST_TOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 +$as_echo "$MANIFEST_TOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_MANIFEST_TOOL"; then + ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL + # Extract the first word of "mt", so it can be a program name with args. +set dummy mt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_MANIFEST_TOOL"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL +if test -n "$ac_ct_MANIFEST_TOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 +$as_echo "$ac_ct_MANIFEST_TOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_MANIFEST_TOOL" = x; then + MANIFEST_TOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL + fi +else + MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" +fi + +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 +$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } +if ${lt_cv_path_mainfest_tool+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&5 + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 +$as_echo "$lt_cv_path_mainfest_tool" >&6; } +if test yes != "$lt_cv_path_mainfest_tool"; then + MANIFEST_TOOL=: +fi + + + + + + + case $host_os in + rhapsody* | darwin*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. +set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DSYMUTIL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DSYMUTIL"; then + ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DSYMUTIL=$ac_cv_prog_DSYMUTIL +if test -n "$DSYMUTIL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 +$as_echo "$DSYMUTIL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DSYMUTIL"; then + ac_ct_DSYMUTIL=$DSYMUTIL + # Extract the first word of "dsymutil", so it can be a program name with args. +set dummy dsymutil; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DSYMUTIL"; then + ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL +if test -n "$ac_ct_DSYMUTIL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 +$as_echo "$ac_ct_DSYMUTIL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DSYMUTIL" = x; then + DSYMUTIL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DSYMUTIL=$ac_ct_DSYMUTIL + fi +else + DSYMUTIL="$ac_cv_prog_DSYMUTIL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. +set dummy ${ac_tool_prefix}nmedit; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_NMEDIT+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$NMEDIT"; then + ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +NMEDIT=$ac_cv_prog_NMEDIT +if test -n "$NMEDIT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 +$as_echo "$NMEDIT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_NMEDIT"; then + ac_ct_NMEDIT=$NMEDIT + # Extract the first word of "nmedit", so it can be a program name with args. +set dummy nmedit; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_NMEDIT"; then + ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_NMEDIT="nmedit" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT +if test -n "$ac_ct_NMEDIT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 +$as_echo "$ac_ct_NMEDIT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_NMEDIT" = x; then + NMEDIT=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + NMEDIT=$ac_ct_NMEDIT + fi +else + NMEDIT="$ac_cv_prog_NMEDIT" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. +set dummy ${ac_tool_prefix}lipo; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_LIPO+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$LIPO"; then + ac_cv_prog_LIPO="$LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_LIPO="${ac_tool_prefix}lipo" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +LIPO=$ac_cv_prog_LIPO +if test -n "$LIPO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 +$as_echo "$LIPO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_LIPO"; then + ac_ct_LIPO=$LIPO + # Extract the first word of "lipo", so it can be a program name with args. +set dummy lipo; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_LIPO+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_LIPO"; then + ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_LIPO="lipo" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO +if test -n "$ac_ct_LIPO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 +$as_echo "$ac_ct_LIPO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_LIPO" = x; then + LIPO=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + LIPO=$ac_ct_LIPO + fi +else + LIPO="$ac_cv_prog_LIPO" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OTOOL"; then + ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OTOOL="${ac_tool_prefix}otool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL=$ac_cv_prog_OTOOL +if test -n "$OTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 +$as_echo "$OTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL"; then + ac_ct_OTOOL=$OTOOL + # Extract the first word of "otool", so it can be a program name with args. +set dummy otool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OTOOL"; then + ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OTOOL="otool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL +if test -n "$ac_ct_OTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 +$as_echo "$ac_ct_OTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OTOOL" = x; then + OTOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL=$ac_ct_OTOOL + fi +else + OTOOL="$ac_cv_prog_OTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool64; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OTOOL64+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OTOOL64"; then + ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL64=$ac_cv_prog_OTOOL64 +if test -n "$OTOOL64"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 +$as_echo "$OTOOL64" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL64"; then + ac_ct_OTOOL64=$OTOOL64 + # Extract the first word of "otool64", so it can be a program name with args. +set dummy otool64; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OTOOL64"; then + ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OTOOL64="otool64" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 +if test -n "$ac_ct_OTOOL64"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 +$as_echo "$ac_ct_OTOOL64" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OTOOL64" = x; then + OTOOL64=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL64=$ac_ct_OTOOL64 + fi +else + OTOOL64="$ac_cv_prog_OTOOL64" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 +$as_echo_n "checking for -single_module linker flag... " >&6; } +if ${lt_cv_apple_cc_single_mod+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_apple_cc_single_mod=no + if test -z "$LT_MULTI_MODULE"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&5 + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test 0 = "$_lt_result"; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&5 + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 +$as_echo "$lt_cv_apple_cc_single_mod" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 +$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } +if ${lt_cv_ld_exported_symbols_list+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_ld_exported_symbols_list=yes +else + lt_cv_ld_exported_symbols_list=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 +$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 +$as_echo_n "checking for -force_load linker flag... " >&6; } +if ${lt_cv_ld_force_load+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_force_load=no + cat > conftest.c << _LT_EOF +int forced_loaded() { return 2;} +_LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 + echo "$AR cru libconftest.a conftest.o" >&5 + $AR cru libconftest.a conftest.o 2>&5 + echo "$RANLIB libconftest.a" >&5 + $RANLIB libconftest.a 2>&5 + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err + _lt_result=$? + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&5 + elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then + lt_cv_ld_force_load=yes + else + cat conftest.err >&5 + fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 +$as_echo "$lt_cv_ld_force_load" >&6; } + case $host_os in + rhapsody* | darwin1.[012]) + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[91]*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + 10.[012][,.]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test yes = "$lt_cv_apple_cc_single_mod"; then + _lt_dar_single_mod='$single_module' + fi + if test yes = "$lt_cv_ld_exported_symbols_list"; then + _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' + fi + if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in dlfcn.h +do : + ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default +" +if test "x$ac_cv_header_dlfcn_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DLFCN_H 1 +_ACEOF + +fi + +done + + + + + +# Set options +enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. +set dummy ${ac_tool_prefix}as; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AS+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AS="${ac_tool_prefix}as" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AS=$ac_cv_prog_AS +if test -n "$AS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 +$as_echo "$AS" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AS"; then + ac_ct_AS=$AS + # Extract the first word of "as", so it can be a program name with args. +set dummy as; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AS+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AS"; then + ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AS="as" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AS=$ac_cv_prog_ac_ct_AS +if test -n "$ac_ct_AS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 +$as_echo "$ac_ct_AS" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AS" = x; then + AS="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AS=$ac_ct_AS + fi +else + AS="$ac_cv_prog_AS" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +$as_echo "$DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DLLTOOL="dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +$as_echo "$ac_ct_DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +$as_echo "$OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +$as_echo "$ac_ct_OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + + ;; +esac + +test -z "$AS" && AS=as + + + + + +test -z "$DLLTOOL" && DLLTOOL=dlltool + + + + + +test -z "$OBJDUMP" && OBJDUMP=objdump + + + + + + + + enable_dlopen=no + + + + # Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then : + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else + enable_shared=yes +fi + + + + + + + + + + # Check whether --enable-static was given. +if test "${enable_static+set}" = set; then : + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else + enable_static=yes +fi + + + + + + + + + + +# Check whether --with-pic was given. +if test "${with_pic+set}" = set; then : + withval=$with_pic; lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $withval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else + pic_mode=default +fi + + + + + + + + + # Check whether --enable-fast-install was given. +if test "${enable_fast_install+set}" = set; then : + enableval=$enable_fast_install; p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else + enable_fast_install=yes +fi + + + + + + + + + shared_archive_member_spec= +case $host,$enable_shared in +power*-*-aix[5-9]*,yes) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 +$as_echo_n "checking which variant of shared library versioning to provide... " >&6; } + +# Check whether --with-aix-soname was given. +if test "${with_aix_soname+set}" = set; then : + withval=$with_aix_soname; case $withval in + aix|svr4|both) + ;; + *) + as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname +else + if ${lt_cv_with_aix_soname+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_with_aix_soname=aix +fi + + with_aix_soname=$lt_cv_with_aix_soname +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 +$as_echo "$with_aix_soname" >&6; } + if test aix != "$with_aix_soname"; then + # For the AIX way of multilib, we name the shared archive member + # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', + # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. + # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, + # the AIX toolchain works better with OBJECT_MODE set (default 32). + if test 64 = "${OBJECT_MODE-32}"; then + shared_archive_member_spec=shr_64 + else + shared_archive_member_spec=shr + fi + fi + ;; +*) + with_aix_soname=aix + ;; +esac + + + + + + + + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS=$ltmain + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +test -z "$LN_S" && LN_S="ln -s" + + + + + + + + + + + + + + +if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 +$as_echo_n "checking for objdir... " >&6; } +if ${lt_cv_objdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 +$as_echo "$lt_cv_objdir" >&6; } +objdir=$lt_cv_objdir + + + + + +cat >>confdefs.h <<_ACEOF +#define LT_OBJDIR "$lt_cv_objdir/" +_ACEOF + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld=$lt_cv_prog_gnu_ld + +old_CC=$CC +old_CFLAGS=$CFLAGS + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +func_cc_basename $compiler +cc_basename=$func_cc_basename_result + + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 +$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } +if ${lt_cv_path_MAGIC_CMD+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/${ac_tool_prefix}file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac +fi + +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 +$as_echo_n "checking for file... " >&6; } +if ${lt_cv_path_MAGIC_CMD+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac +fi + +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +# Use C for the default configuration in the libtool script + +lt_save_CC=$CC +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* + +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* + + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + +lt_prog_compiler_no_builtin_flag= + +if test yes = "$GCC"; then + case $cc_basename in + nvcc*) + lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; + *) + lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; + esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } +if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } + +if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + + + + + + + lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + + + if test yes = "$GCC"; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + lt_prog_compiler_pic='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + lt_prog_compiler_pic='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + lt_prog_compiler_static= + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + lt_prog_compiler_wl='-Xlinker ' + if test -n "$lt_prog_compiler_pic"; then + lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='$wl-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + # old Intel for x86_64, which still supported -KPIC. + ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='--shared' + lt_prog_compiler_static='--static' + ;; + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-qpic' + lt_prog_compiler_static='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' + ;; + *Sun\ F* | *Sun*Fortran*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Wl,' + ;; + *Intel*\ [CF]*Compiler*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + *Portland\ Group*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + rdos*) + lt_prog_compiler_static='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +case $host_os in + # For platforms that do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } +if ${lt_cv_prog_compiler_pic+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic=$lt_prog_compiler_pic +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 +$as_echo "$lt_cv_prog_compiler_pic" >&6; } +lt_prog_compiler_pic=$lt_cv_prog_compiler_pic + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if ${lt_cv_prog_compiler_pic_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 +$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } + +if test yes = "$lt_cv_prog_compiler_pic_works"; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi + + + + + + + + + + + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if ${lt_cv_prog_compiler_static_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_static_works=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works=yes + fi + else + lt_cv_prog_compiler_static_works=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 +$as_echo "$lt_cv_prog_compiler_static_works" >&6; } + +if test yes = "$lt_cv_prog_compiler_static_works"; then + : +else + lt_prog_compiler_static= +fi + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + +hard_links=nottested +if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then + # do not overwrite the value of need_locks provided by the user + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +$as_echo_n "checking if we can lock with hard links... " >&6; } + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +$as_echo "$hard_links" >&6; } + if test no = "$hard_links"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + runpath_var= + allow_undefined_flag= + always_export_symbols=no + archive_cmds= + archive_expsym_cmds= + compiler_needs_object=no + enable_shared_with_static_runtimes=no + export_dynamic_flag_spec= + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + hardcode_automatic=no + hardcode_direct=no + hardcode_direct_absolute=no + hardcode_libdir_flag_spec= + hardcode_libdir_separator= + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + inherit_rpath=no + link_all_deplibs=unknown + module_cmds= + module_expsym_cmds= + old_archive_from_new_cmds= + old_archive_from_expsyms_cmds= + thread_safe_flag_spec= + whole_archive_flag_spec= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ' (' and ')$', so one must not match beginning or + # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', + # as well as any symbol that contains 'd'. + exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test yes != "$GCC"; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd* | bitrig*) + with_gnu_ld=no + ;; + esac + + ld_shlibs=yes + + # On some targets, GNU ld is compatible enough with the native linker + # that we're better off using the native interface for both. + lt_use_gnu_ld_interface=no + if test yes = "$with_gnu_ld"; then + case $host_os in + aix*) + # The AIX port of GNU ld has always aspired to compatibility + # with the native linker. However, as the warning in the GNU ld + # block says, versions before 2.19.5* couldn't really create working + # shared libraries, regardless of the interface used. + case `$LD -v 2>&1` in + *\ \(GNU\ Binutils\)\ 2.19.5*) ;; + *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; + *\ \(GNU\ Binutils\)\ [3-9]*) ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + fi + + if test yes = "$lt_use_gnu_ld_interface"; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='$wl' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + export_dynamic_flag_spec='$wl--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + whole_archive_flag_spec= + fi + supports_anon_versioning=no + case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test ia64 != "$host_cpu"; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.19, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to install binutils +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. +*** You will then need to restart the configuration process. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + export_dynamic_flag_spec='$wl--export-all-symbols' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' + exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs=no + fi + ;; + + haiku*) + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + link_all_deplibs=yes + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes + ;; + + interix[3-9]*) + hardcode_direct=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + tmp_diet=no + if test linux-dietlibc = "$host_os"; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test no = "$tmp_diet" + then + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group f77 and f90 compilers + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + whole_archive_flag_spec= + tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 + tmp_sharedflag='-Wl,-shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + nvcc*) # Cuda Compiler Driver 2.2 + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + compiler_needs_object=yes + ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + compiler_needs_object=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + tcc*) + export_dynamic_flag_spec='-rdynamic' + ;; + xlf* | bgf* | bgxlf* | mpixlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test yes = "$supports_anon_versioning"; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test no = "$ld_shlibs"; then + runpath_var= + hardcode_libdir_flag_spec= + export_dynamic_flag_spec= + whole_archive_flag_spec= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix[4-9]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then + aix_use_runtimelinking=yes + break + fi + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_direct_absolute=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + file_list_spec='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # traditional, no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + hardcode_direct=no + hardcode_direct_absolute=no + ;; + esac + + if test yes = "$GCC"; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag="$shared_flag "'$wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + export_dynamic_flag_spec='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=/usr/lib:/lib + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=/usr/lib:/lib + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' $wl-bernotok' + allow_undefined_flag=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + fi + archive_cmds_need_lc=yes + archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in + cl*) + # Native MSVC + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + always_export_symbols=yes + file_list_spec='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, )='true' + enable_shared_with_static_runtimes=yes + exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + old_postinstall_cmds='chmod 644 $oldlib' + postlink_cmds='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + enable_shared_with_static_runtimes=yes + ;; + esac + ;; + + darwin* | rhapsody*) + + + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + if test yes = "$lt_cv_ld_force_load"; then + whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + + else + whole_archive_flag_spec='' + fi + link_all_deplibs=yes + allow_undefined_flag=$_lt_dar_allow_undefined + case $cc_basename in + ifort*|nagfor*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test yes = "$_lt_dar_can_shared"; then + output_verbose_link_cmd=func_echo_all + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + + else + ld_shlibs=no + fi + + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2.*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test yes = "$GCC"; then + archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='$wl-E' + ;; + + hpux10*) + if test yes,no = "$GCC,$with_gnu_ld"; then + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='$wl-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + + hpux11*) + if test yes,no = "$GCC,$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + + # Older versions of the 11.00 compiler do not understand -b yet + # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 +$as_echo_n "checking if $CC understands -b... " >&6; } +if ${lt_cv_prog_compiler__b+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler__b=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -b" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler__b=yes + fi + else + lt_cv_prog_compiler__b=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 +$as_echo "$lt_cv_prog_compiler__b" >&6; } + +if test yes = "$lt_cv_prog_compiler__b"; then + archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' +else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' +fi + + ;; + esac + fi + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' + hardcode_libdir_separator=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + *) + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='$wl-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test yes = "$GCC"; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + # This should be the same for all languages, so no per-tag cache variable. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 +$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } +if ${lt_cv_irix_exported_symbol+:} false; then : + $as_echo_n "(cached) " >&6 +else + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo (void) { return 0; } +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_irix_exported_symbol=yes +else + lt_cv_irix_exported_symbol=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 +$as_echo "$lt_cv_irix_exported_symbol" >&6; } + if test yes = "$lt_cv_irix_exported_symbol"; then + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' + fi + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + inherit_rpath=yes + link_all_deplibs=yes + ;; + + linux*) + case $cc_basename in + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + ld_shlibs=yes + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + *nto* | *qnx*) + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + hardcode_shlibpath_var=no + hardcode_direct_absolute=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' + else + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + fi + else + ld_shlibs=no + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes + ;; + + osf3*) + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + archive_cmds_need_lc='no' + hardcode_libdir_separator=: + ;; + + solaris*) + no_undefined_flag=' -z defs' + if test yes = "$GCC"; then + wlarc='$wl' + archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='$wl' + archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. GCC discards it without '$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test yes = "$GCC"; then + whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + else + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' + fi + ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test sequent = "$host_vendor"; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag='$wl-z,text' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag='$wl-z,text' + allow_undefined_flag='$wl-z,nodefs' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='$wl-R,$libdir' + hardcode_libdir_separator=':' + link_all_deplibs=yes + export_dynamic_flag_spec='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + + if test sni = "$host_vendor"; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + export_dynamic_flag_spec='$wl-Blargedynsym' + ;; + esac + fi + fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 +$as_echo "$ld_shlibs" >&6; } +test no = "$ld_shlibs" && can_build_shared=no + +with_gnu_ld=$with_gnu_ld + + + + + + + + + + + + + + + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test yes,yes = "$GCC,$enable_shared"; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } +if ${lt_cv_archive_cmds_need_lc+:} false; then : + $as_echo_n "(cached) " >&6 +else + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 + (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + then + lt_cv_archive_cmds_need_lc=no + else + lt_cv_archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 +$as_echo "$lt_cv_archive_cmds_need_lc" >&6; } + archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc + ;; + esac + fi + ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +$as_echo_n "checking dynamic linker characteristics... " >&6; } + +if test yes = "$GCC"; then + case $host_os in + darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; + *) lt_awk_arg='/^libraries:/' ;; + esac + case $host_os in + mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; + *) lt_sed_strip_eq='s|=/|/|g' ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` + case $lt_search_path_spec in + *\;*) + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary... + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + # ...but if some path component already ends with the multilib dir we assume + # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). + case "$lt_multi_os_dir; $lt_search_path_spec " in + "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) + lt_multi_os_dir= + ;; + esac + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" + elif test -n "$lt_multi_os_dir"; then + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' +BEGIN {RS = " "; FS = "/|\n";} { + lt_foo = ""; + lt_count = 0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo = "/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[lt_foo]++; } + if (lt_freq[lt_foo] == 1) { print lt_foo; } +}'` + # AWK program above erroneously prepends '/' to C:/dos/paths + # for these hosts. + case $host_os in + mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + $SED 's|/\([A-Za-z]:\)|\1|g'` ;; + esac + sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=.so +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + + + +case $host_os in +aix3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='$libname$release$shared_ext$major' + ;; + +aix[4-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test ia64 = "$host_cpu"; then + # AIX 5 supports IA64 + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a(lib.so.V)' + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='$libname$shared_ext' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + + case $GCC,$cc_basename in + yes,*) + # gcc + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec=$LIB + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' + ;; + + *) + # Assume MSVC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; + esac + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[23].*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2.*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + dynamic_linker="$host_os runtime_loader" + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=no + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 + fi + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 + ;; + +interix[3-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test yes = "$lt_cv_prog_gnu_ld"; then + version_type=linux # correct to gnu/linux during the next big refactor + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + hardcode_libdir_flag_spec='-L$libdir' + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + + # Some binutils ld are patched to set DT_RUNPATH + if ${lt_cv_shlibpath_overrides_runpath+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : + lt_cv_shlibpath_overrides_runpath=yes +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + +fi + + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd* | bitrig*) + version_type=sunos + sys_lib_dlsearch_path_spec=/usr/lib + need_lib_prefix=no + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +os2*) + libname_spec='$name' + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test yes = "$with_gnu_ld"; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec; then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=sco + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test yes = "$with_gnu_ld"; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +$as_echo "$dynamic_linker" >&6; } +test no = "$dynamic_linker" && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test yes = "$GCC"; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec +fi + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec +fi + +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; } +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || + test -n "$runpath_var" || + test yes = "$hardcode_automatic"; then + + # We can hardcode non-existent directories. + if test no != "$hardcode_direct" && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && + test no != "$hardcode_minus_L"; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 +$as_echo "$hardcode_action" >&6; } + +if test relink = "$hardcode_action" || + test yes = "$inherit_rpath"; then + # Fast installation is not supported + enable_fast_install=no +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + + + + + + if test yes != "$enable_dlopen"; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen=load_add_on + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen=LoadLibrary + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl +else + + lt_cv_dlopen=dyld + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + tpf*) + # Don't try to run any link tests for TPF. We know it's impossible + # because TPF is a cross-compiler, and we know how we open DSOs. + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + lt_cv_dlopen_self=no + ;; + + *) + ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" +if test "x$ac_cv_func_shl_load" = xyes; then : + lt_cv_dlopen=shl_load +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 +$as_echo_n "checking for shl_load in -ldld... " >&6; } +if ${ac_cv_lib_dld_shl_load+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_shl_load=yes +else + ac_cv_lib_dld_shl_load=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = xyes; then : + lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld +else + ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" +if test "x$ac_cv_func_dlopen" = xyes; then : + lt_cv_dlopen=dlopen +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 +$as_echo_n "checking for dlopen in -lsvld... " >&6; } +if ${ac_cv_lib_svld_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_svld_dlopen=yes +else + ac_cv_lib_svld_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 +$as_echo "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = xyes; then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 +$as_echo_n "checking for dld_link in -ldld... " >&6; } +if ${ac_cv_lib_dld_dld_link+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dld_link (); +int +main () +{ +return dld_link (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_dld_link=yes +else + ac_cv_lib_dld_dld_link=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 +$as_echo "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = xyes; then : + lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test no = "$lt_cv_dlopen"; then + enable_dlopen=no + else + enable_dlopen=yes + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS=$CPPFLAGS + test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS=$LDFLAGS + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS=$LIBS + LIBS="$lt_cv_dlopen_libs $LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 +$as_echo_n "checking whether a program can dlopen itself... " >&6; } +if ${lt_cv_dlopen_self+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test yes = "$cross_compiling"; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 +$as_echo "$lt_cv_dlopen_self" >&6; } + + if test yes = "$lt_cv_dlopen_self"; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 +$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } +if ${lt_cv_dlopen_self_static+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test yes = "$cross_compiling"; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 +$as_echo "$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + + + + + + + + + + + + + + + + +striplib= +old_striplib= +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 +$as_echo_n "checking whether stripping libraries is possible... " >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP"; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; + esac +fi + + + + + + + + + + + + + # Report what library types will actually be built + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 +$as_echo_n "checking if libtool supports shared libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 +$as_echo "$can_build_shared" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 +$as_echo_n "checking whether to build shared libraries... " >&6; } + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[4-9]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 +$as_echo "$enable_shared" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 +$as_echo_n "checking whether to build static libraries... " >&6; } + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 +$as_echo "$enable_static" >&6; } + + + + +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC=$lt_save_CC + + + + + + + + + + + + + + + + ac_config_commands="$ac_config_commands libtool" + + + + +# Only expand once: + + + + +# Some awks crash when confronted with pnglibconf.dfa, do a test run now +# to make sure this doesn't happen +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that AWK works" >&5 +$as_echo_n "checking that AWK works... " >&6; } +if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\ + ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ + ${srcdir}/pngusr.dfa 1>&2 +then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 1 "failed +See \`config.log' for more details" "$LINENO" 5; } +fi + +# This is a remnant of the old cc -E validation, where it may have been +# necessary to use a different preprocessor for .dfn files +DFNCPP="$CPP" + + +# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it +# checks the compiler with a program that generates a warning), add the +# following option to deal with this + +# Check whether --enable-werror was given. +if test "${enable_werror+set}" = set; then : + enableval=$enable_werror; test "$enable_werror" = "yes" && enable_werror="-Werror" + if test "$enable_werror" != "no"; then + sav_CFLAGS="$CFLAGS" + CFLAGS="$enable_werror $CFLAGS" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler allows $enable_werror" >&5 +$as_echo_n "checking if the compiler allows $enable_werror... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + int main(int argc, char **argv){ + return argv[argc-1][0]; + } +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + PNG_COPTS="$PNG_COPTS $enable_werror" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$sav_CFLAGS" + fi +fi + + +# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89 +# In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining _POSIX_SOURCE to 1 +# This is incompatible with the new default mode, so we test for that and force the +# "-std=c89" compiler option: +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need to force back C standard to C89" >&5 +$as_echo_n "checking if we need to force back C standard to C89... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define _POSIX_SOURCE 1 + #include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +else + + if test "x$GCC" != "xyes"; then + as_fn_error $? "Forcing back to C89 is required but the flags are only known for GCC" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + CFLAGS="$CFLAGS -std=c89" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +# Checks for header files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + + +# Checks for typedefs, structures, and compiler characteristics. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 +$as_echo_n "checking for an ANSI C-conforming const... " >&6; } +if ${ac_cv_c_const+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + +#ifndef __cplusplus + /* Ultrix mips cc rejects this sort of thing. */ + typedef int charset[2]; + const charset cs = { 0, 0 }; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_const=yes +else + ac_cv_c_const=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 +$as_echo "$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +$as_echo "#define const /**/" >>confdefs.h + +fi + +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 +$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } +if ${ac_cv_struct_tm+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +struct tm tm; + int *p = &tm.tm_sec; + return !p; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_struct_tm=time.h +else + ac_cv_struct_tm=sys/time.h +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 +$as_echo "$ac_cv_struct_tm" >&6; } +if test $ac_cv_struct_tm = sys/time.h; then + +$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5 +$as_echo_n "checking for C/C++ restrict keyword... " >&6; } +if ${ac_cv_c_restrict+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_restrict=no + # The order here caters to the fact that C++ does not require restrict. + for ac_kw in __restrict __restrict__ _Restrict restrict; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +typedef int * int_ptr; + int foo (int_ptr $ac_kw ip) { + return ip[0]; + } +int +main () +{ +int s[1]; + int * $ac_kw t = s; + t[0] = 0; + return foo(t) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_restrict=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_restrict" != no && break + done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5 +$as_echo "$ac_cv_c_restrict" >&6; } + + case $ac_cv_c_restrict in + restrict) ;; + no) $as_echo "#define restrict /**/" >>confdefs.h + ;; + *) cat >>confdefs.h <<_ACEOF +#define restrict $ac_cv_c_restrict +_ACEOF + ;; + esac + + +# Checks for library functions. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strtod" >&5 +$as_echo_n "checking for working strtod... " >&6; } +if ${ac_cv_func_strtod+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_strtod=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +$ac_includes_default +#ifndef strtod +double strtod (); +#endif +int +main() +{ + { + /* Some versions of Linux strtod mis-parse strings with leading '+'. */ + char *string = " +69"; + char *term; + double value; + value = strtod (string, &term); + if (value != 69 || term != (string + 4)) + return 1; + } + + { + /* Under Solaris 2.4, strtod returns the wrong value for the + terminating character under some conditions. */ + char *string = "NaN"; + char *term; + strtod (string, &term); + if (term != string && *(term - 1) == 0) + return 1; + } + return 0; +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_strtod=yes +else + ac_cv_func_strtod=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strtod" >&5 +$as_echo "$ac_cv_func_strtod" >&6; } +if test $ac_cv_func_strtod = no; then + case " $LIBOBJS " in + *" strtod.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtod.$ac_objext" + ;; +esac + +ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow" +if test "x$ac_cv_func_pow" = xyes; then : + +fi + +if test $ac_cv_func_pow = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 +$as_echo_n "checking for pow in -lm... " >&6; } +if ${ac_cv_lib_m_pow+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pow (); +int +main () +{ +return pow (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_pow=yes +else + ac_cv_lib_m_pow=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 +$as_echo "$ac_cv_lib_m_pow" >&6; } +if test "x$ac_cv_lib_m_pow" = xyes; then : + POW_LIB=-lm +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find library containing definition of pow" >&5 +$as_echo "$as_me: WARNING: cannot find library containing definition of pow" >&2;} +fi + +fi + +fi + +for ac_func in pow +do : + ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow" +if test "x$ac_cv_func_pow" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_POW 1 +_ACEOF + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 +$as_echo_n "checking for pow in -lm... " >&6; } +if ${ac_cv_lib_m_pow+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pow (); +int +main () +{ +return pow (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_pow=yes +else + ac_cv_lib_m_pow=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 +$as_echo "$ac_cv_lib_m_pow" >&6; } +if test "x$ac_cv_lib_m_pow" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBM 1 +_ACEOF + + LIBS="-lm $LIBS" + +else + as_fn_error $? "cannot find pow" "$LINENO" 5 +fi + +fi +done + + +# Some later POSIX 1003.1 functions are required for test programs, failure here +# is soft (the corresponding test program is not built). +ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime" +if test "x$ac_cv_func_clock_gettime" = xyes; then : + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: not building timepng" >&5 +$as_echo "$as_me: WARNING: not building timepng" >&2;} +fi + + if test "$ac_cv_func_clock_gettime" = "yes"; then + HAVE_CLOCK_GETTIME_TRUE= + HAVE_CLOCK_GETTIME_FALSE='#' +else + HAVE_CLOCK_GETTIME_TRUE='#' + HAVE_CLOCK_GETTIME_FALSE= +fi + + + +# Check whether --with-zlib-prefix was given. +if test "${with_zlib_prefix+set}" = set; then : + withval=$with_zlib_prefix; ZPREFIX=${withval} +else + ZPREFIX='z_' +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlibVersion in -lz" >&5 +$as_echo_n "checking for zlibVersion in -lz... " >&6; } +if ${ac_cv_lib_z_zlibVersion+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char zlibVersion (); +int +main () +{ +return zlibVersion (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_z_zlibVersion=yes +else + ac_cv_lib_z_zlibVersion=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_zlibVersion" >&5 +$as_echo "$ac_cv_lib_z_zlibVersion" >&6; } +if test "x$ac_cv_lib_z_zlibVersion" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBZ 1 +_ACEOF + + LIBS="-lz $LIBS" + +else + as_ac_Lib=`$as_echo "ac_cv_lib_z_${ZPREFIX}zlibVersion" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ZPREFIX}zlibVersion in -lz" >&5 +$as_echo_n "checking for ${ZPREFIX}zlibVersion in -lz... " >&6; } +if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ${ZPREFIX}zlibVersion (); +int +main () +{ +return ${ZPREFIX}zlibVersion (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$as_ac_Lib=yes" +else + eval "$as_ac_Lib=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBZ 1 +_ACEOF + + LIBS="-lz $LIBS" + +else + as_fn_error $? "zlib not installed" "$LINENO" 5 +fi + +fi + + +# The following is for pngvalid, to ensure it catches FP errors even on +# platforms that don't enable FP exceptions, the function appears in the math +# library (typically), it's not an error if it is not found. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for feenableexcept in -lm" >&5 +$as_echo_n "checking for feenableexcept in -lm... " >&6; } +if ${ac_cv_lib_m_feenableexcept+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char feenableexcept (); +int +main () +{ +return feenableexcept (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_feenableexcept=yes +else + ac_cv_lib_m_feenableexcept=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_feenableexcept" >&5 +$as_echo "$ac_cv_lib_m_feenableexcept" >&6; } +if test "x$ac_cv_lib_m_feenableexcept" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBM 1 +_ACEOF + + LIBS="-lm $LIBS" + +fi + +for ac_func in feenableexcept +do : + ac_fn_c_check_func "$LINENO" "feenableexcept" "ac_cv_func_feenableexcept" +if test "x$ac_cv_func_feenableexcept" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_FEENABLEEXCEPT 1 +_ACEOF + +fi +done + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if using Solaris linker" >&5 +$as_echo_n "checking if using Solaris linker... " >&6; } +SLD=`$LD --version 2>&1 | grep Solaris` +if test "$SLD"; then + have_solaris_ld=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + have_solaris_ld=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + if test "$have_solaris_ld" = "yes"; then + HAVE_SOLARIS_LD_TRUE= + HAVE_SOLARIS_LD_FALSE='#' +else + HAVE_SOLARIS_LD_TRUE='#' + HAVE_SOLARIS_LD_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if libraries can be versioned" >&5 +$as_echo_n "checking if libraries can be versioned... " >&6; } +# Special case for PE/COFF platforms: ld reports +# support for version-script, but doesn't actually +# DO anything with it. +case $host in +*cygwin* | *mingw32* | *interix* ) + have_ld_version_script=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +;; +* ) + +if test "$have_solaris_ld" = "yes"; then + GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'` +else + GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script` +fi + +if test "$GLD"; then + have_ld_version_script=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + have_ld_version_script=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** You have not enabled versioned symbols." >&5 +$as_echo "$as_me: WARNING: *** You have not enabled versioned symbols." >&2;} +fi +;; +esac + + if test "$have_ld_version_script" = "yes"; then + HAVE_LD_VERSION_SCRIPT_TRUE= + HAVE_LD_VERSION_SCRIPT_FALSE='#' +else + HAVE_LD_VERSION_SCRIPT_TRUE='#' + HAVE_LD_VERSION_SCRIPT_FALSE= +fi + + +if test "$have_ld_version_script" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for symbol prefix" >&5 +$as_echo_n "checking for symbol prefix... " >&6; } + SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \ + | ${CPP-${CC-gcc} -E} - 2>&1 \ + | ${EGREP-grep} "^PREFIX=" \ + | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"` + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SYMBOL_PREFIX" >&5 +$as_echo "$SYMBOL_PREFIX" >&6; } +fi + +# Substitutions for .in files + + + + + +# Additional arguments (and substitutions) +# Allow the pkg-config directory to be set + +# Check whether --with-pkgconfigdir was given. +if test "${with_pkgconfigdir+set}" = set; then : + withval=$with_pkgconfigdir; pkgconfigdir=${withval} +else + pkgconfigdir='${libdir}/pkgconfig' +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: pkgconfig directory is ${pkgconfigdir}" >&5 +$as_echo "$as_me: pkgconfig directory is ${pkgconfigdir}" >&6;} + +# Make the *-config binary config scripts optional + +# Check whether --with-binconfigs was given. +if test "${with_binconfigs+set}" = set; then : + withval=$with_binconfigs; if test "${withval}" = no; then + binconfigs= + { $as_echo "$as_me:${as_lineno-$LINENO}: libpng-config scripts will not be built" >&5 +$as_echo "$as_me: libpng-config scripts will not be built" >&6;} + else + binconfigs='${binconfigs}' + fi +else + binconfigs='${binconfigs}' +fi + + + +# Support for prefixes to the API function names; this will generate defines +# at the start of the build to rename exported library functions + +# Check whether --with-libpng-prefix was given. +if test "${with_libpng_prefix+set}" = set; then : + withval=$with_libpng_prefix; if test "${withval:-no}" != "no"; then + PNG_PREFIX=${withval} + + fi +fi + + if test "${with_libpng_prefix:-no}" != "no"; then + DO_PNG_PREFIX_TRUE= + DO_PNG_PREFIX_FALSE='#' +else + DO_PNG_PREFIX_TRUE='#' + DO_PNG_PREFIX_FALSE= +fi + + +# Control over what links are made for installed files. Versioned files are +# always installed, when the following options are turned on corresponding +# unversioned links are also created (normally as symbolic links): +# Check whether --enable-unversioned-links was given. +if test "${enable_unversioned_links+set}" = set; then : + enableval=$enable_unversioned_links; +fi + + +# The AM_CONDITIONAL test is written so that the default is enabled; +# --disable-unversioned-links must be given to turn the option off. + if test "$enable_unversioned_links" != "no"; then + DO_INSTALL_LINKS_TRUE= + DO_INSTALL_LINKS_FALSE='#' +else + DO_INSTALL_LINKS_TRUE='#' + DO_INSTALL_LINKS_FALSE= +fi + + +# Check whether --enable-unversioned-libpng-pc was given. +if test "${enable_unversioned_libpng_pc+set}" = set; then : + enableval=$enable_unversioned_libpng_pc; +fi + + if test "$enable_unversioned_libpng_pc" != "no"; then + DO_INSTALL_LIBPNG_PC_TRUE= + DO_INSTALL_LIBPNG_PC_FALSE='#' +else + DO_INSTALL_LIBPNG_PC_TRUE='#' + DO_INSTALL_LIBPNG_PC_FALSE= +fi + + +# Check whether --enable-unversioned-libpng-config was given. +if test "${enable_unversioned_libpng_config+set}" = set; then : + enableval=$enable_unversioned_libpng_config; +fi + + if test "$enable_unversioned_libpng_config" != "no"; then + DO_INSTALL_LIBPNG_CONFIG_TRUE= + DO_INSTALL_LIBPNG_CONFIG_FALSE='#' +else + DO_INSTALL_LIBPNG_CONFIG_TRUE='#' + DO_INSTALL_LIBPNG_CONFIG_FALSE= +fi + + +# HOST SPECIFIC OPTIONS +# ===================== +# +# DEFAULT +# ======= +# +# Check whether --enable-hardware-optimizations was given. +if test "${enable_hardware_optimizations+set}" = set; then : + enableval=$enable_hardware_optimizations; case "$enableval" in + no|off) + # disable hardware optimization on all systems: + enable_arm_neon=no + +$as_echo "#define PNG_ARM_NEON_OPT 0" >>confdefs.h + + enable_mips_msa=no + +$as_echo "#define PNG_MIPS_MSA_OPT 0" >>confdefs.h + + enable_powerpc_vsx=no + +$as_echo "#define PNG_POWERPC_VSX_OPT 0" >>confdefs.h + + enable_intel_sse=no + +$as_echo "#define PNG_INTEL_SSE_OPT 0" >>confdefs.h + + ;; + *) + # allow enabling hardware optimization on any system: + case "$host_cpu" in + arm*|aarch64*) + enable_arm_neon=yes + +$as_echo "#define PNG_ARM_NEON_OPT 0" >>confdefs.h + + ;; + mipsel*|mips64el*) + enable_mips_msa=yes + +$as_echo "#define PNG_MIPS_MSA_OPT 0" >>confdefs.h + + ;; + i?86|x86_64) + enable_intel_sse=yes + +$as_echo "#define PNG_INTEL_SSE_OPT 1" >>confdefs.h + + ;; + powerpc*|ppc64*) + enable_powerpc_vsx=yes + +$as_echo "#define PNG_POWERPC_VSX_OPT 2" >>confdefs.h + + ;; + esac + ;; + esac +fi + + +# ARM +# === +# +# ARM NEON (SIMD) support. + +# Check whether --enable-arm-neon was given. +if test "${enable_arm_neon+set}" = set; then : + enableval=$enable_arm_neon; case "$enableval" in + no|off) + # disable the default enabling on __ARM_NEON__ systems: + +$as_echo "#define PNG_ARM_NEON_OPT 0" >>confdefs.h + + # Prevent inclusion of the assembler files below: + enable_arm_neon=no;; + check) + +$as_echo "#define PNG_ARM_NEON_CHECK_SUPPORTED /**/" >>confdefs.h +;; + api) + +$as_echo "#define PNG_ARM_NEON_API_SUPPORTED /**/" >>confdefs.h +;; + yes|on) + +$as_echo "#define PNG_ARM_NEON_OPT 2" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-arm-neon: please specify 'check' or 'api', if + you want the optimizations unconditionally pass -mfpu=neon + to the compiler." >&5 +$as_echo "$as_me: WARNING: --enable-arm-neon: please specify 'check' or 'api', if + you want the optimizations unconditionally pass -mfpu=neon + to the compiler." >&2;};; + *) + as_fn_error $? "--enable-arm-neon=${enable_arm_neon}: invalid value" "$LINENO" 5 + esac +fi + + +# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or +# where ARM optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'arm*') + + if test "$enable_arm_neon" != 'no' && + case "$host_cpu" in + arm*|aarch64*) :;; + *) test "$enable_arm_neon" != '';; + esac; then + PNG_ARM_NEON_TRUE= + PNG_ARM_NEON_FALSE='#' +else + PNG_ARM_NEON_TRUE='#' + PNG_ARM_NEON_FALSE= +fi + + +# MIPS +# === +# +# MIPS MSA (SIMD) support. + +# Check whether --enable-mips-msa was given. +if test "${enable_mips_msa+set}" = set; then : + enableval=$enable_mips_msa; case "$enableval" in + no|off) + # disable the default enabling on __mips_msa systems: + +$as_echo "#define PNG_MIPS_MSA_OPT 0" >>confdefs.h + + # Prevent inclusion of the assembler files below: + enable_mips_msa=no;; + check) + +$as_echo "#define PNG_MIPS_MSA_CHECK_SUPPORTED /**/" >>confdefs.h +;; + api) + +$as_echo "#define PNG_MIPS_MSA_API_SUPPORTED /**/" >>confdefs.h +;; + yes|on) + +$as_echo "#define PNG_MIPS_MSA_OPT 2" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-mips-msa: please specify 'check' or 'api', if + you want the optimizations unconditionally pass '-mmsa -mfp64' + to the compiler." >&5 +$as_echo "$as_me: WARNING: --enable-mips-msa: please specify 'check' or 'api', if + you want the optimizations unconditionally pass '-mmsa -mfp64' + to the compiler." >&2;};; + *) + as_fn_error $? "--enable-mips-msa=${enable_mips_msa}: invalid value" "$LINENO" 5 + esac +fi + + +# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or +# where MIPS optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'mips*') + + if test "$enable_mips_msa" != 'no' && + case "$host_cpu" in + mipsel*|mips64el*) :;; + esac; then + PNG_MIPS_MSA_TRUE= + PNG_MIPS_MSA_FALSE='#' +else + PNG_MIPS_MSA_TRUE='#' + PNG_MIPS_MSA_FALSE= +fi + + +# INTEL +# ===== +# +# INTEL SSE (SIMD) support. + +# Check whether --enable-intel-sse was given. +if test "${enable_intel_sse+set}" = set; then : + enableval=$enable_intel_sse; case "$enableval" in + no|off) + # disable the default enabling: + +$as_echo "#define PNG_INTEL_SSE_OPT 0" >>confdefs.h + + # Prevent inclusion of the assembler files below: + enable_intel_sse=no;; + yes|on) + +$as_echo "#define PNG_INTEL_SSE_OPT 1" >>confdefs.h +;; + *) + as_fn_error $? "--enable-intel-sse=${enable_intel_sse}: invalid value" "$LINENO" 5 + esac +fi + + +# Add Intel specific files to all builds where the host_cpu is Intel ('x86*') +# or where Intel optimizations were explicitly requested (this allows a +# fallback if a future host CPU does not match 'x86*') + if test "$enable_intel_sse" != 'no' && + case "$host_cpu" in + i?86|x86_64) :;; + *) test "$enable_intel_sse" != '';; + esac; then + PNG_INTEL_SSE_TRUE= + PNG_INTEL_SSE_FALSE='#' +else + PNG_INTEL_SSE_TRUE='#' + PNG_INTEL_SSE_FALSE= +fi + + +# PowerPC +# === +# +# PowerPC VSX (SIMD) support. + +# Check whether --enable-powerpc-vsx was given. +if test "${enable_powerpc_vsx+set}" = set; then : + enableval=$enable_powerpc_vsx; case "$enableval" in + no|off) + # disable the default enabling on __ppc64__ systems: + +$as_echo "#define PNG_POWERPC_VSX_OPT 0" >>confdefs.h + + # Prevent inclusion of the platform specific files below: + enable_powerpc_vsx=no;; + check) + +$as_echo "#define PNG_POWERPC_VSX_CHECK_SUPPORTED /**/" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx Please check contrib/powerpc/README file + for the list of supported OSes." >&5 +$as_echo "$as_me: WARNING: --enable-powerpc-vsx Please check contrib/powerpc/README file + for the list of supported OSes." >&2;};; + api) + +$as_echo "#define PNG_POWERPC_VSX_API_SUPPORTED /**/" >>confdefs.h +;; + yes|on) + +$as_echo "#define PNG_POWERPC_VSX_OPT 2" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api', if + you want the optimizations unconditionally pass '-maltivec -mvsx' + or '-mcpu=power8'to the compiler." >&5 +$as_echo "$as_me: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api', if + you want the optimizations unconditionally pass '-maltivec -mvsx' + or '-mcpu=power8'to the compiler." >&2;};; + *) + as_fn_error $? "--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value" "$LINENO" 5 + esac +fi + + +# Add PowerPC specific files to all builds where the host_cpu is powerpc('powerpc*') or +# where POWERPC optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'powerpc*') + + if test "$enable_powerpc_vsx" != 'no' && + case "$host_cpu" in + powerpc*|ppc64*) :;; + esac; then + PNG_POWERPC_VSX_TRUE= + PNG_POWERPC_VSX_FALSE='#' +else + PNG_POWERPC_VSX_TRUE='#' + PNG_POWERPC_VSX_FALSE= +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: Extra options for compiler: $PNG_COPTS" >&5 +$as_echo "$as_me: Extra options for compiler: $PNG_COPTS" >&6;} + +# Config files, substituting as above +ac_config_files="$ac_config_files Makefile libpng.pc:libpng.pc.in" + +ac_config_files="$ac_config_files libpng-config:libpng-config.in" + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 +$as_echo_n "checking that generated files are newer than configure... " >&6; } + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 +$as_echo "done" >&6; } + if test -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= +fi + +if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then + as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + as_fn_error $? "conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_CLOCK_GETTIME_TRUE}" && test -z "${HAVE_CLOCK_GETTIME_FALSE}"; then + as_fn_error $? "conditional \"HAVE_CLOCK_GETTIME\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_SOLARIS_LD_TRUE}" && test -z "${HAVE_SOLARIS_LD_FALSE}"; then + as_fn_error $? "conditional \"HAVE_SOLARIS_LD\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_LD_VERSION_SCRIPT_TRUE}" && test -z "${HAVE_LD_VERSION_SCRIPT_FALSE}"; then + as_fn_error $? "conditional \"HAVE_LD_VERSION_SCRIPT\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${DO_PNG_PREFIX_TRUE}" && test -z "${DO_PNG_PREFIX_FALSE}"; then + as_fn_error $? "conditional \"DO_PNG_PREFIX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${DO_INSTALL_LINKS_TRUE}" && test -z "${DO_INSTALL_LINKS_FALSE}"; then + as_fn_error $? "conditional \"DO_INSTALL_LINKS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${DO_INSTALL_LIBPNG_PC_TRUE}" && test -z "${DO_INSTALL_LIBPNG_PC_FALSE}"; then + as_fn_error $? "conditional \"DO_INSTALL_LIBPNG_PC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${DO_INSTALL_LIBPNG_CONFIG_TRUE}" && test -z "${DO_INSTALL_LIBPNG_CONFIG_FALSE}"; then + as_fn_error $? "conditional \"DO_INSTALL_LIBPNG_CONFIG\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${PNG_ARM_NEON_TRUE}" && test -z "${PNG_ARM_NEON_FALSE}"; then + as_fn_error $? "conditional \"PNG_ARM_NEON\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${PNG_MIPS_MSA_TRUE}" && test -z "${PNG_MIPS_MSA_FALSE}"; then + as_fn_error $? "conditional \"PNG_MIPS_MSA\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${PNG_INTEL_SSE_TRUE}" && test -z "${PNG_INTEL_SSE_FALSE}"; then + as_fn_error $? "conditional \"PNG_INTEL_SSE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${PNG_POWERPC_VSX_TRUE}" && test -z "${PNG_POWERPC_VSX_FALSE}"; then + as_fn_error $? "conditional \"PNG_POWERPC_VSX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by libpng $as_me 1.6.37, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +libpng config.status 1.6.37 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" + + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' +Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' +GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' +EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' +FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' +SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' +ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' +LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' +macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' +macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' +AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`' +DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' +OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' +enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' +enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' +pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' +enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' +shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' +PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' +host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' +host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' +host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' +build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' +build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' +build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' +NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' +LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' +max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' +ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' +exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' +lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' +lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' +lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' +lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' +lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' +reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' +reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' +deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' +file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' +file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' +want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' +sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' +AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' +AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' +archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' +STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' +RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' +old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' +old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' +lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' +CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' +CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' +compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' +GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' +lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' +nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' +lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' +lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' +objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' +MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' +need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' +MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' +DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' +NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' +LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' +OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' +OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' +libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' +shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' +extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' +export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' +whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' +compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' +old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' +archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' +module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' +module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' +with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' +allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' +no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' +hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' +hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' +hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' +hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' +hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' +inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' +link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' +always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' +export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' +exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' +include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' +prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' +postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' +file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' +variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' +need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' +need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' +version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' +runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' +libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' +library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' +soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' +install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' +postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' +postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' +finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' +hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' +sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' +configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' +configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' +hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' +enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' +old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' +striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' + +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in SED \ +GREP \ +EGREP \ +FGREP \ +SHELL \ +ECHO \ +LD \ +AS \ +DLLTOOL \ +OBJDUMP \ +PATH_SEPARATOR \ +NM \ +LN_S \ +lt_SP2NL \ +lt_NL2SP \ +reload_flag \ +deplibs_check_method \ +file_magic_cmd \ +file_magic_glob \ +want_nocaseglob \ +sharedlib_from_linklib_cmd \ +AR \ +AR_FLAGS \ +archiver_list_spec \ +STRIP \ +RANLIB \ +CC \ +CFLAGS \ +compiler \ +lt_cv_sys_global_symbol_pipe \ +lt_cv_sys_global_symbol_to_cdecl \ +lt_cv_sys_global_symbol_to_import \ +lt_cv_sys_global_symbol_to_c_name_address \ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ +lt_cv_nm_interface \ +nm_file_list_spec \ +lt_cv_truncate_bin \ +lt_prog_compiler_no_builtin_flag \ +lt_prog_compiler_pic \ +lt_prog_compiler_wl \ +lt_prog_compiler_static \ +lt_cv_prog_compiler_c_o \ +need_locks \ +MANIFEST_TOOL \ +DSYMUTIL \ +NMEDIT \ +LIPO \ +OTOOL \ +OTOOL64 \ +shrext_cmds \ +export_dynamic_flag_spec \ +whole_archive_flag_spec \ +compiler_needs_object \ +with_gnu_ld \ +allow_undefined_flag \ +no_undefined_flag \ +hardcode_libdir_flag_spec \ +hardcode_libdir_separator \ +exclude_expsyms \ +include_expsyms \ +file_list_spec \ +variables_saved_for_relink \ +libname_spec \ +library_names_spec \ +soname_spec \ +install_override_mode \ +finish_eval \ +old_striplib \ +striplib; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in reload_cmds \ +old_postinstall_cmds \ +old_postuninstall_cmds \ +old_archive_cmds \ +extract_expsyms_cmds \ +old_archive_from_new_cmds \ +old_archive_from_expsyms_cmds \ +archive_cmds \ +archive_expsym_cmds \ +module_cmds \ +module_expsym_cmds \ +export_symbols_cmds \ +prelink_cmds \ +postlink_cmds \ +postinstall_cmds \ +postuninstall_cmds \ +finish_cmds \ +sys_lib_search_path_spec \ +configure_time_dlsearch_path \ +configure_time_lt_sys_library_path; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +ac_aux_dir='$ac_aux_dir' + +# See if we are running on zsh, and set the options that allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + + + PACKAGE='$PACKAGE' + VERSION='$VERSION' + RM='$RM' + ofile='$ofile' + + + + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "libpng.pc") CONFIG_FILES="$CONFIG_FILES libpng.pc:libpng.pc.in" ;; + "libpng-config") CONFIG_FILES="$CONFIG_FILES libpng-config:libpng-config.in" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Older Autoconf quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + case $CONFIG_FILES in #( + *\'*) : + eval set x "$CONFIG_FILES" ;; #( + *) : + set x $CONFIG_FILES ;; #( + *) : + ;; +esac + shift + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf + do + # Strip MF so we end up with the name of the file. + am_mf=`$as_echo "$am_mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`$as_dirname -- "$am_mf" || +$as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$am_mf" : 'X\(//\)[^/]' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$am_mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + am_filepart=`$as_basename -- "$am_mf" || +$as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$am_mf" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { echo "$as_me:$LINENO: cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles" >&5 + (cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } || am_rc=$? + done + if test $am_rc -ne 0; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. Try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking). +See \`config.log' for more details" "$LINENO" 5; } + fi + { am_dirpart=; unset am_dirpart;} + { am_filepart=; unset am_filepart;} + { am_mf=; unset am_mf;} + { am_rc=; unset am_rc;} + rm -f conftest-deps.mk +} + ;; + "libtool":C) + + # See if we are running on zsh, and set the options that allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST + fi + + cfgfile=${ofile}T + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL +# Generated automatically by $as_me ($PACKAGE) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# The names of the tagged configurations supported by this script. +available_tags='' + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} + +# ### BEGIN LIBTOOL CONFIG + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="\$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP=$lt_GREP + +# An ERE matcher. +EGREP=$lt_EGREP + +# A literal string matcher. +FGREP=$lt_FGREP + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# An echo program that protects backslashes. +ECHO=$lt_ECHO + +# Which release of libtool.m4 was used? +macro_version=$macro_version +macro_revision=$macro_revision + +# Assembler program. +AS=$lt_AS + +# DLL creation program. +DLLTOOL=$lt_DLLTOOL + +# Object dumper program. +OBJDUMP=$lt_OBJDUMP + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# What type of objects to build. +pic_mode=$pic_mode + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# Shared archive member basename,for filename based shared library versioning on AIX. +shared_archive_member_spec=$shared_archive_member_spec + +# The PATH separator for the build system. +PATH_SEPARATOR=$lt_PATH_SEPARATOR + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# A BSD- or MS-compatible name lister. +NM=$lt_NM + +# Whether we need soft or hard links. +LN_S=$lt_LN_S + +# What is the maximum length of a command? +max_cmd_len=$max_cmd_len + +# Object file suffix (normally "o"). +objext=$ac_objext + +# Executable file suffix (normally ""). +exeext=$exeext + +# whether the shell understands "unset". +lt_unset=$lt_unset + +# turn spaces into newlines. +SP2NL=$lt_lt_SP2NL + +# turn newlines into spaces. +NL2SP=$lt_lt_NL2SP + +# convert \$build file names to \$host format. +to_host_file_cmd=$lt_cv_to_host_file_cmd + +# convert \$build files to toolchain format. +to_tool_file_cmd=$lt_cv_to_tool_file_cmd + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method = "file_magic". +file_magic_cmd=$lt_file_magic_cmd + +# How to find potential files when deplibs_check_method = "file_magic". +file_magic_glob=$lt_file_magic_glob + +# Find potential files using nocaseglob when deplibs_check_method = "file_magic". +want_nocaseglob=$lt_want_nocaseglob + +# Command to associate shared and link libraries. +sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd + +# The archiver. +AR=$lt_AR + +# Flags to create an archive. +AR_FLAGS=$lt_AR_FLAGS + +# How to feed a file listing to the archiver. +archiver_list_spec=$lt_archiver_list_spec + +# A symbol stripping program. +STRIP=$lt_STRIP + +# Commands used to install an old-style archive. +RANLIB=$lt_RANLIB +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Whether to use a lock for old archive extraction. +lock_old_archive_extraction=$lock_old_archive_extraction + +# A C compiler. +LTCC=$lt_CC + +# LTCC compiler flags. +LTCFLAGS=$lt_CFLAGS + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm into a list of symbols to manually relocate. +global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix + +# The name lister interface. +nm_interface=$lt_lt_cv_nm_interface + +# Specify filename containing input files for \$NM. +nm_file_list_spec=$lt_nm_file_list_spec + +# The root where to search for dependent libraries,and where our libraries should be installed. +lt_sysroot=$lt_sysroot + +# Command to truncate a binary pipe. +lt_truncate_bin=$lt_lt_cv_truncate_bin + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=$MAGIC_CMD + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Manifest tool. +MANIFEST_TOOL=$lt_MANIFEST_TOOL + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL=$lt_DSYMUTIL + +# Tool to change global to local symbols on Mac OS X. +NMEDIT=$lt_NMEDIT + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO=$lt_LIPO + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL=$lt_OTOOL + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64=$lt_OTOOL64 + +# Old archive suffix (normally "a"). +libext=$libext + +# Shared library suffix (normally ".so"). +shrext_cmds=$lt_shrext_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink=$lt_variables_saved_for_relink + +# Do we need the "lib" prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Library versioning type. +version_type=$version_type + +# Shared library runtime path variable. +runpath_var=$runpath_var + +# Shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Permission mode override for installation of shared libraries. +install_override_mode=$lt_install_override_mode + +# Command to use after installation of a shared archive. +postinstall_cmds=$lt_postinstall_cmds + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval=$lt_finish_eval + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Compile-time system search path for libraries. +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Detected run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path + +# Explicit LT_SYS_LIBRARY_PATH set during ./configure time. +configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + + +# The linker used to build libraries. +LD=$lt_LD + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds + +# A language specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU compiler? +with_gcc=$GCC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct + +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \$shlibpath_var if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds + +# Commands necessary for finishing linking programs. +postlink_cmds=$lt_postlink_cmds + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# ### END LIBTOOL CONFIG + +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + + +# ### END FUNCTIONS SHARED WITH CONFIGURE + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + +ltmain=$ac_aux_dir/ltmain.sh + + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + + ;; + "libpng-config":F) chmod +x libpng-config ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/thirdparty/libpng-1.6.37/configure.ac b/thirdparty/libpng-1.6.37/configure.ac new file mode 100644 index 0000000..52dba94 --- /dev/null +++ b/thirdparty/libpng-1.6.37/configure.ac @@ -0,0 +1,532 @@ +# configure.ac + +# Copyright (c) 2018 Cosmin Truta +# Copyright (c) 2004-2016 Glenn Randers-Pehrson + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +dnl Process this file with autoconf to produce a configure script. +dnl +dnl Minor upgrades (compatible ABI): increment the package version +dnl (third field in two places below) and set the PNGLIB_RELEASE +dnl variable. +dnl +dnl Major upgrades (incompatible ABI): increment the package major +dnl version (second field, or first if desired), set the minor +dnl to 0, set PNGLIB_MAJOR below *and* follow the instructions in +dnl Makefile.am to upgrade the package name. + +dnl This is here to prevent earlier autoconf from being used, it +dnl should not be necessary to regenerate configure if the time +dnl stamps are correct +AC_PREREQ([2.68]) + +dnl Version number stuff here: + +AC_INIT([libpng],[1.6.37],[png-mng-implement@lists.sourceforge.net]) +AC_CONFIG_MACRO_DIR([scripts]) + +# libpng does not follow GNU file name conventions (hence 'foreign') +# color-tests requires automake 1.11 or later +# silent-rules requires automake 1.11 or later +# dist-xz requires automake 1.11 or later +# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1 +# 1.13 is required for parallel tests +AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects]) +# The following line causes --disable-maintainer-mode to be the default to +# configure. This is necessary because libpng distributions cannot rely on the +# time stamps of the autotools generated files being correct +AM_MAINTAINER_MODE + +dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later +dnl version; aclocal.m4 will generate a failure if you use a prior version of +dnl automake, so the following is not necessary (and is not defined anyway): +dnl AM_PREREQ([1.11.2]) +dnl stop configure from automagically running automake + +PNGLIB_VERSION=1.6.37 +PNGLIB_MAJOR=1 +PNGLIB_MINOR=6 +PNGLIB_RELEASE=37 + +dnl End of version number stuff + +AC_CONFIG_SRCDIR([pngget.c]) +AC_CONFIG_HEADERS([config.h]) + +# Checks for programs. +AC_LANG([C]) +AC_PROG_CC +AM_PROG_AS +LT_PATH_LD +AC_PROG_CPP +AC_PROG_AWK +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET + +dnl libtool/libtoolize; version 2.4.2 is the tested version. This or any +dnl compatible later version may be used +LT_INIT([win32-dll]) +LT_PREREQ([2.4.2]) + +# Some awks crash when confronted with pnglibconf.dfa, do a test run now +# to make sure this doesn't happen +AC_MSG_CHECKING([that AWK works]) +if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\ + ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ + ${srcdir}/pngusr.dfa 1>&2 +then + AC_MSG_RESULT([ok]) +else + AC_MSG_FAILURE([failed], 1) +fi + +# This is a remnant of the old cc -E validation, where it may have been +# necessary to use a different preprocessor for .dfn files +DFNCPP="$CPP" +AC_SUBST(DFNCPP) + +# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it +# checks the compiler with a program that generates a warning), add the +# following option to deal with this +AC_ARG_VAR(PNG_COPTS, + [additional flags for the C compiler, use this for options that would] + [cause configure itself to fail]) +AC_ARG_ENABLE(werror, + AS_HELP_STRING([[[--enable-werror[=OPT]]]], + [Pass -Werror or the given argument to the compiler if it is supported]), + [test "$enable_werror" = "yes" && enable_werror="-Werror" + if test "$enable_werror" != "no"; then + sav_CFLAGS="$CFLAGS" + CFLAGS="$enable_werror $CFLAGS" + AC_MSG_CHECKING([if the compiler allows $enable_werror]) + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([ + [int main(int argc, char **argv){] + [return argv[argc-1][0];] + [}]])], + AC_MSG_RESULT(yes) + PNG_COPTS="$PNG_COPTS $enable_werror", + AC_MSG_RESULT(no)) + CFLAGS="$sav_CFLAGS" + fi],) + +# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89 +# In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining _POSIX_SOURCE to 1 +# This is incompatible with the new default mode, so we test for that and force the +# "-std=c89" compiler option: +AC_MSG_CHECKING([if we need to force back C standard to C89]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ + [#define _POSIX_SOURCE 1] + [#include ] + ])], + AC_MSG_RESULT(no),[ + if test "x$GCC" != "xyes"; then + AC_MSG_ERROR( + [Forcing back to C89 is required but the flags are only known for GCC]) + fi + AC_MSG_RESULT(yes) + CFLAGS="$CFLAGS -std=c89" +]) + +# Checks for header files. +AC_HEADER_STDC + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_SIZE_T +AC_STRUCT_TM +AC_C_RESTRICT + +# Checks for library functions. +AC_FUNC_STRTOD +AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) ) + +# Some later POSIX 1003.1 functions are required for test programs, failure here +# is soft (the corresponding test program is not built). +AC_CHECK_FUNC([clock_gettime],,[AC_MSG_WARN([not building timepng])]) +AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "$ac_cv_func_clock_gettime" = "yes"]) + +AC_ARG_WITH(zlib-prefix, + AS_HELP_STRING([[[--with-zlib-prefix]]], + [prefix that may have been used in installed zlib]), + [ZPREFIX=${withval}], + [ZPREFIX='z_']) +AC_CHECK_LIB(z, zlibVersion, , + AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed))) + +# The following is for pngvalid, to ensure it catches FP errors even on +# platforms that don't enable FP exceptions, the function appears in the math +# library (typically), it's not an error if it is not found. +AC_CHECK_LIB([m], [feenableexcept]) +AC_CHECK_FUNCS([feenableexcept]) + +AC_MSG_CHECKING([if using Solaris linker]) +SLD=`$LD --version 2>&1 | grep Solaris` +if test "$SLD"; then + have_solaris_ld=yes + AC_MSG_RESULT(yes) +else + have_solaris_ld=no + AC_MSG_RESULT(no) +fi +AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes") + +AC_MSG_CHECKING([if libraries can be versioned]) +# Special case for PE/COFF platforms: ld reports +# support for version-script, but doesn't actually +# DO anything with it. +case $host in +*cygwin* | *mingw32* | *interix* ) + have_ld_version_script=no + AC_MSG_RESULT(no) +;; +* ) + +if test "$have_solaris_ld" = "yes"; then + GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'` +else + GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script` +fi + +if test "$GLD"; then + have_ld_version_script=yes + AC_MSG_RESULT(yes) +else + have_ld_version_script=no + AC_MSG_RESULT(no) + AC_MSG_WARN(*** You have not enabled versioned symbols.) +fi +;; +esac + +AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") + +if test "$have_ld_version_script" = "yes"; then + AC_MSG_CHECKING([for symbol prefix]) + SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \ + | ${CPP-${CC-gcc} -E} - 2>&1 \ + | ${EGREP-grep} "^PREFIX=" \ + | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"` + AC_SUBST(SYMBOL_PREFIX) + AC_MSG_RESULT($SYMBOL_PREFIX) +fi + +# Substitutions for .in files +AC_SUBST(PNGLIB_VERSION) +AC_SUBST(PNGLIB_MAJOR) +AC_SUBST(PNGLIB_MINOR) +AC_SUBST(PNGLIB_RELEASE) + +# Additional arguments (and substitutions) +# Allow the pkg-config directory to be set +AC_ARG_WITH(pkgconfigdir, + AS_HELP_STRING([[[--with-pkgconfigdir]]], + [Use the specified pkgconfig dir (default is libdir/pkgconfig)]), + [pkgconfigdir=${withval}], + [pkgconfigdir='${libdir}/pkgconfig']) + +AC_SUBST([pkgconfigdir]) +AC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]]) + +# Make the *-config binary config scripts optional +AC_ARG_WITH(binconfigs, + AS_HELP_STRING([[[--with-binconfigs]]], + [Generate shell libpng-config scripts as well as pkg-config data] + [@<:@default=yes@:>@]), + [if test "${withval}" = no; then + binconfigs= + AC_MSG_NOTICE([[libpng-config scripts will not be built]]) + else + binconfigs='${binconfigs}' + fi], + [binconfigs='${binconfigs}']) +AC_SUBST([binconfigs]) + +# Support for prefixes to the API function names; this will generate defines +# at the start of the build to rename exported library functions +AC_ARG_WITH(libpng-prefix, + AS_HELP_STRING([[[--with-libpng-prefix]]], + [prefix libpng exported function (API) names with the given value]), + [if test "${withval:-no}" != "no"; then + AC_SUBST([PNG_PREFIX], [${withval}]) + fi]) +AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"]) + +# Control over what links are made for installed files. Versioned files are +# always installed, when the following options are turned on corresponding +# unversioned links are also created (normally as symbolic links): +AC_ARG_ENABLE([unversioned-links], + AS_HELP_STRING([[[--enable-unversioned-links]]], + [Installed libpng header files are placed in a versioned subdirectory] + [and installed libpng library (including DLL) files are versioned.] + [If this option is enabled unversioned links will be created pointing to] + [the corresponding installed files. If you use libpng.pc or] + [libpng-config for all builds you do not need these links, but if you] + [compile programs directly they will typically #include and] + [link with -lpng; in that case you need the links.] + [The links can be installed manually using 'make install-header-links'] + [and 'make install-library-links' and can be removed using the] + [corresponding uninstall- targets. If you do enable this option every] + [libpng 'make install' will recreate the links to point to the just] + [installed version of libpng. The default is to create the links;] + [use --disable-unversioned-links to change this])) + +# The AM_CONDITIONAL test is written so that the default is enabled; +# --disable-unversioned-links must be given to turn the option off. +AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"]) + +AC_ARG_ENABLE([unversioned-libpng-pc], + AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]], + [Install the configuration file 'libpng.pc' as a link to the versioned] + [version. This is done by default - use --disable-unversioned-libpng-pc] + [to change this.])) +AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC], + [test "$enable_unversioned_libpng_pc" != "no"]) + +AC_ARG_ENABLE([unversioned-libpng-config], + AS_HELP_STRING([[[--enable-unversioned-libpng-config]]], + [Install the configuration file 'libpng-config' as a link to the] + [versioned version. This is done by default - use] + [--disable-unversioned-libpng-config to change this.])) +AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG], + [test "$enable_unversioned_libpng_config" != "no"]) + +# HOST SPECIFIC OPTIONS +# ===================== +# +# DEFAULT +# ======= +# +AC_ARG_ENABLE([hardware-optimizations], + AS_HELP_STRING([[[--enable-hardware-optimizations]]], + [Enable hardware optimizations: =no/off, yes/on:]), + [case "$enableval" in + no|off) + # disable hardware optimization on all systems: + enable_arm_neon=no + AC_DEFINE([PNG_ARM_NEON_OPT], [0], + [Disable ARM_NEON optimizations]) + enable_mips_msa=no + AC_DEFINE([PNG_MIPS_MSA_OPT], [0], + [Disable MIPS_MSA optimizations]) + enable_powerpc_vsx=no + AC_DEFINE([PNG_POWERPC_VSX_OPT], [0], + [Disable POWERPC VSX optimizations]) + enable_intel_sse=no + AC_DEFINE([PNG_INTEL_SSE_OPT], [0], + [Disable INTEL_SSE optimizations]) + ;; + *) + # allow enabling hardware optimization on any system: + case "$host_cpu" in + arm*|aarch64*) + enable_arm_neon=yes + AC_DEFINE([PNG_ARM_NEON_OPT], [0], + [Enable ARM_NEON optimizations]) + ;; + mipsel*|mips64el*) + enable_mips_msa=yes + AC_DEFINE([PNG_MIPS_MSA_OPT], [0], + [Enable MIPS_MSA optimizations]) + ;; + i?86|x86_64) + enable_intel_sse=yes + AC_DEFINE([PNG_INTEL_SSE_OPT], [1], + [Enable Intel SSE optimizations]) + ;; + powerpc*|ppc64*) + enable_powerpc_vsx=yes + AC_DEFINE([PNG_POWERPC_VSX_OPT], [2], + [Enable POWERPC VSX optimizations]) + ;; + esac + ;; + esac]) + +# ARM +# === +# +# ARM NEON (SIMD) support. + +AC_ARG_ENABLE([arm-neon], + AS_HELP_STRING([[[--enable-arm-neon]]], + [Enable ARM NEON optimizations: =no/off, check, api, yes/on:] + [no/off: disable the optimizations; check: use internal checking code] + [(deprecated and poorly supported); api: disable by default, enable by] + [a call to png_set_option; yes/on: turn on unconditionally.] + [If not specified: determined by the compiler.]), + [case "$enableval" in + no|off) + # disable the default enabling on __ARM_NEON__ systems: + AC_DEFINE([PNG_ARM_NEON_OPT], [0], + [Disable ARM Neon optimizations]) + # Prevent inclusion of the assembler files below: + enable_arm_neon=no;; + check) + AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [], + [Check for ARM Neon support at run-time]);; + api) + AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [], + [Turn on ARM Neon optimizations at run-time]);; + yes|on) + AC_DEFINE([PNG_ARM_NEON_OPT], [2], + [Enable ARM Neon optimizations]) + AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if] + [you want the optimizations unconditionally pass -mfpu=neon] + [to the compiler.]);; + *) + AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value]) + esac]) + +# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or +# where ARM optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'arm*') + +AM_CONDITIONAL([PNG_ARM_NEON], + [test "$enable_arm_neon" != 'no' && + case "$host_cpu" in + arm*|aarch64*) :;; + *) test "$enable_arm_neon" != '';; + esac]) + +# MIPS +# === +# +# MIPS MSA (SIMD) support. + +AC_ARG_ENABLE([mips-msa], + AS_HELP_STRING([[[--enable-mips-msa]]], + [Enable MIPS MSA optimizations: =no/off, check, api, yes/on:] + [no/off: disable the optimizations; check: use internal checking code] + [(deprecated and poorly supported); api: disable by default, enable by] + [a call to png_set_option; yes/on: turn on unconditionally.] + [If not specified: determined by the compiler.]), + [case "$enableval" in + no|off) + # disable the default enabling on __mips_msa systems: + AC_DEFINE([PNG_MIPS_MSA_OPT], [0], + [Disable MIPS MSA optimizations]) + # Prevent inclusion of the assembler files below: + enable_mips_msa=no;; + check) + AC_DEFINE([PNG_MIPS_MSA_CHECK_SUPPORTED], [], + [Check for MIPS MSA support at run-time]);; + api) + AC_DEFINE([PNG_MIPS_MSA_API_SUPPORTED], [], + [Turn on MIPS MSA optimizations at run-time]);; + yes|on) + AC_DEFINE([PNG_MIPS_MSA_OPT], [2], + [Enable MIPS MSA optimizations]) + AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api', if] + [you want the optimizations unconditionally pass '-mmsa -mfp64'] + [to the compiler.]);; + *) + AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}: invalid value]) + esac]) + +# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or +# where MIPS optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'mips*') + +AM_CONDITIONAL([PNG_MIPS_MSA], + [test "$enable_mips_msa" != 'no' && + case "$host_cpu" in + mipsel*|mips64el*) :;; + esac]) + +# INTEL +# ===== +# +# INTEL SSE (SIMD) support. + +AC_ARG_ENABLE([intel-sse], + AS_HELP_STRING([[[--enable-intel-sse]]], + [Enable Intel SSE optimizations: =no/off, yes/on:] + [no/off: disable the optimizations;] + [yes/on: enable the optimizations.] + [If not specified: determined by the compiler.]), + [case "$enableval" in + no|off) + # disable the default enabling: + AC_DEFINE([PNG_INTEL_SSE_OPT], [0], + [Disable Intel SSE optimizations]) + # Prevent inclusion of the assembler files below: + enable_intel_sse=no;; + yes|on) + AC_DEFINE([PNG_INTEL_SSE_OPT], [1], + [Enable Intel SSE optimizations]);; + *) + AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value]) + esac]) + +# Add Intel specific files to all builds where the host_cpu is Intel ('x86*') +# or where Intel optimizations were explicitly requested (this allows a +# fallback if a future host CPU does not match 'x86*') +AM_CONDITIONAL([PNG_INTEL_SSE], + [test "$enable_intel_sse" != 'no' && + case "$host_cpu" in + i?86|x86_64) :;; + *) test "$enable_intel_sse" != '';; + esac]) + +# PowerPC +# === +# +# PowerPC VSX (SIMD) support. + +AC_ARG_ENABLE([powerpc-vsx], +AS_HELP_STRING([[[--enable-powerpc-vsx]]], + [Enable POWERPC VSX optimizations: =no/off, check, api, yes/on:] + [no/off: disable the optimizations; check: use internal checking code] + [api: disable by default, enable by a call to png_set_option] + [yes/on: turn on unconditionally.] + [If not specified: determined by the compiler.]), + [case "$enableval" in + no|off) + # disable the default enabling on __ppc64__ systems: + AC_DEFINE([PNG_POWERPC_VSX_OPT], [0], + [Disable POWERPC VSX optimizations]) + # Prevent inclusion of the platform specific files below: + enable_powerpc_vsx=no;; + check) + AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [], + [Check for POWERPC VSX support at run-time]) + AC_MSG_WARN([--enable-powerpc-vsx Please check contrib/powerpc/README file] + [for the list of supported OSes.]);; + api) + AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [], + [Turn on POWERPC VSX optimizations at run-time]);; + yes|on) + AC_DEFINE([PNG_POWERPC_VSX_OPT], [2], + [Enable POWERPC VSX optimizations]) + AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api', if] + [you want the optimizations unconditionally pass '-maltivec -mvsx'] + [or '-mcpu=power8'to the compiler.]);; + *) + AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value]) + esac]) + +# Add PowerPC specific files to all builds where the host_cpu is powerpc('powerpc*') or +# where POWERPC optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'powerpc*') + +AM_CONDITIONAL([PNG_POWERPC_VSX], + [test "$enable_powerpc_vsx" != 'no' && + case "$host_cpu" in + powerpc*|ppc64*) :;; + esac]) + + +AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) + +# Config files, substituting as above +AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in]) +AC_CONFIG_FILES([libpng-config:libpng-config.in], + [chmod +x libpng-config]) + +AC_OUTPUT diff --git a/thirdparty/libpng-1.6.37/contrib/README.txt b/thirdparty/libpng-1.6.37/contrib/README.txt new file mode 100644 index 0000000..97963c6 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/README.txt @@ -0,0 +1,5 @@ + +This "contrib" directory contains contributions which are not necessarily under +the libpng license, although all are open source. They are not part of +libpng proper and are not used for building the library, although some are used +for testing the library via "make check". diff --git a/thirdparty/libpng-1.6.37/contrib/arm-neon/README b/thirdparty/libpng-1.6.37/contrib/arm-neon/README new file mode 100644 index 0000000..b4248cf --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/arm-neon/README @@ -0,0 +1,83 @@ +OPERATING SYSTEM SPECIFIC ARM NEON DETECTION +-------------------------------------------- + +Detection of the ability to execute ARM NEON on an ARM processor requires +operating system support. (The information is not available in user mode.) + +HOW TO USE THIS +--------------- + +This directory contains C code fragments that can be included in arm/arm_init.c +by setting the macro PNG_ARM_NEON_FILE to the file name in "" or <> at build +time. This setting is not recorded in pnglibconf.h and can be changed simply by +rebuilding arm/arm_init.o with the required macro definition. + +For any of this code to be used the ARM NEON code must be enabled and run time +checks must be supported. I.e.: + +#if PNG_ARM_NEON_OPT > 0 +#ifdef PNG_ARM_NEON_CHECK_SUPPORTED + +This is done in a 'configure' build by passing configure the argument: + + --enable-arm-neon=check + +Apart from the basic Linux implementation in contrib/arm-neon/linux.c this code +is unsupported. That means that it is not even compiled on a regular basis and +may be broken in any given minor release. + +FILE FORMAT +----------- + +Each file documents its testing status as of the last time it was tested (which +may have been a long time ago): + +STATUS: one of: + SUPPORTED: This indicates that the file is included in the regularly + performed test builds and bugs are fixed when discovered. + COMPILED: This indicates that the code did compile at least once. See the + more detailed description for the extent to which the result was + successful. + TESTED: This means the code was fully compiled into the libpng test programs + and these were run at least once. + +BUG REPORTS: an email address to which to send reports of problems + +The file is a fragment of C code. It should not define any 'extern' symbols; +everything should be static. It must define the function: + +static int png_have_neon(png_structp png_ptr); + +That function must return 1 if ARM NEON instructions are supported, 0 if not. +It must not execute png_error unless it detects a bug. A png_error will prevent +the reading of the PNG and in the future, writing too. + +BUG REPORTS +----------- + +If you mail a bug report for any file that is not SUPPORTED there may only be +limited response. Consider fixing it and sending a patch to fix the problem - +this is more likely to result in action. + +CONTRIBUTIONS +------------- + +You may send contributions of new implementations to +png-mng-implement@sourceforge.net. Please write code in strict C90 C where +possible. Obviously OS dependencies are to be expected. If you submit code you +must have the authors permission and it must have a license that is acceptable +to the current maintainer; in particular that license must permit modification +and redistribution. + +Please try to make the contribution a single file and give the file a clear and +unambiguous name that identifies the target OS. If multiple files really are +required put them all in a sub-directory. + +You must also be prepared to handle bug reports from users of the code, either +by joining the png-mng-implement mailing list or by providing an email for the +"BUG REPORTS" entry or both. Please make sure that the header of the file +contains the STATUS and BUG REPORTS fields as above. + +Please list the OS requirements as precisely as possible. Ideally you should +also list the environment in which the code has been tested and certainly list +any environments where you suspect it might not work. diff --git a/thirdparty/libpng-1.6.37/contrib/arm-neon/android-ndk.c b/thirdparty/libpng-1.6.37/contrib/arm-neon/android-ndk.c new file mode 100644 index 0000000..fb3a489 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/arm-neon/android-ndk.c @@ -0,0 +1,39 @@ +/* contrib/arm-neon/android-ndk.c + * + * Copyright (c) 2014 Glenn Randers-Pehrson + * Written by John Bowler, 2014. + * Last changed in libpng 1.6.10 [March 6, 2014] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * SEE contrib/arm-neon/README before reporting bugs + * + * STATUS: COMPILED, UNTESTED + * BUG REPORTS: png-mng-implement@sourceforge.net + * + * png_have_neon implemented for the Android NDK, see: + * + * Documentation: + * http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html + * https://code.google.com/p/android/issues/detail?id=49065 + * + * NOTE: this requires that libpng is built against the Android NDK and linked + * with an implementation of the Android ARM 'cpu-features' library. The code + * has been compiled only, not linked: no version of the library has been found, + * only the header files exist in the NDK. + */ +#include + +static int +png_have_neon(png_structp png_ptr) +{ + /* This is a whole lot easier than the linux code, however it is probably + * implemented as below, therefore it is better to cache the result (these + * function calls may be slow!) + */ + PNG_UNUSED(png_ptr) + return android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && + (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; +} diff --git a/thirdparty/libpng-1.6.37/contrib/arm-neon/linux-auxv.c b/thirdparty/libpng-1.6.37/contrib/arm-neon/linux-auxv.c new file mode 100644 index 0000000..4d26bd3 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/arm-neon/linux-auxv.c @@ -0,0 +1,120 @@ +/* contrib/arm-neon/linux-auxv.c + * + * Copyright (c) 2014 Glenn Randers-Pehrson + * Written by Mans Rullgard, 2011. + * Last changed in libpng 1.6.10 [March 6, 2014] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * SEE contrib/arm-neon/README before reporting bugs + * + * STATUS: COMPILED, TESTED + * BUG REPORTS: png-mng-implement@sourceforge.net + * + * png_have_neon implemented for Linux versions which allow access to + * /proc/self/auxv. This is probably faster, cleaner and safer than the code to + * read /proc/cpuinfo in contrib/arm-neon/linux, however it is yet another piece + * of potentially untested code and has more complex dependencies than the code + * to read cpuinfo. + * + * This generic __linux__ implementation requires reading /proc/self/auxv and + * looking at each element for one that records NEON capabilities. + */ +#include /* for POSIX 1003.1 */ +#include /* for EINTR */ + +#include +#include +#include +#include +#include + +/* A read call may be interrupted, in which case it returns -1 and sets errno to + * EINTR if nothing was done, otherwise (if something was done) a partial read + * may result. + */ +static size_t +safe_read(png_structp png_ptr, int fd, void *buffer_in, size_t nbytes) +{ + size_t ntotal = 0; + char *buffer = png_voidcast(char*, buffer_in); + + while (nbytes > 0) + { + unsigned int nread; + int iread; + + /* Passing nread > INT_MAX to read is implementation defined in POSIX + * 1003.1, therefore despite the unsigned argument portable code must + * limit the value to INT_MAX! + */ + if (nbytes > INT_MAX) + nread = INT_MAX; + + else + nread = (unsigned int)/*SAFE*/nbytes; + + iread = read(fd, buffer, nread); + + if (iread == -1) + { + /* This is the devil in the details, a read can terminate early with 0 + * bytes read because of EINTR, yet it still returns -1 otherwise end + * of file cannot be distinguished. + */ + if (errno != EINTR) + { + png_warning(png_ptr, "/proc read failed"); + return 0; /* I.e., a permanent failure */ + } + } + + else if (iread < 0) + { + /* Not a valid 'read' result: */ + png_warning(png_ptr, "OS /proc read bug"); + return 0; + } + + else if (iread > 0) + { + /* Continue reading until a permanent failure, or EOF */ + buffer += iread; + nbytes -= (unsigned int)/*SAFE*/iread; + ntotal += (unsigned int)/*SAFE*/iread; + } + + else + return ntotal; + } + + return ntotal; /* nbytes == 0 */ +} + +static int +png_have_neon(png_structp png_ptr) +{ + int fd = open("/proc/self/auxv", O_RDONLY); + Elf32_auxv_t aux; + + /* Failsafe: failure to open means no NEON */ + if (fd == -1) + { + png_warning(png_ptr, "/proc/self/auxv open failed"); + return 0; + } + + while (safe_read(png_ptr, fd, &aux, sizeof aux) == sizeof aux) + { + if (aux.a_type == AT_HWCAP && (aux.a_un.a_val & HWCAP_NEON) != 0) + { + close(fd); + return 1; + } + } + + close(fd); + return 0; +} diff --git a/thirdparty/libpng-1.6.37/contrib/arm-neon/linux.c b/thirdparty/libpng-1.6.37/contrib/arm-neon/linux.c new file mode 100644 index 0000000..a9bc360 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/arm-neon/linux.c @@ -0,0 +1,161 @@ +/* contrib/arm-neon/linux.c + * + * Last changed in libpng 1.6.31 [July 27, 2017] + * Copyright (c) 2014, 2017 Glenn Randers-Pehrson + * Written by John Bowler, 2014, 2017. + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * SEE contrib/arm-neon/README before reporting bugs + * + * STATUS: SUPPORTED + * BUG REPORTS: png-mng-implement@sourceforge.net + * + * png_have_neon implemented for Linux by reading the widely available + * pseudo-file /proc/cpuinfo. + * + * This code is strict ANSI-C and is probably moderately portable; it does + * however use and it assumes that /proc/cpuinfo is never localized. + */ +#include + +static int +png_have_neon(png_structp png_ptr) +{ + FILE *f = fopen("/proc/cpuinfo", "rb"); + + if (f != NULL) + { + /* This is a simple state machine which reads the input byte-by-byte until + * it gets a match on the 'neon' feature or reaches the end of the stream. + */ + static const char ch_feature[] = { 70, 69, 65, 84, 85, 82, 69, 83 }; + static const char ch_neon[] = { 78, 69, 79, 78 }; + + enum + { + StartLine, Feature, Colon, StartTag, Neon, HaveNeon, SkipTag, SkipLine + } state; + int counter; + + for (state=StartLine, counter=0;;) + { + int ch = fgetc(f); + + if (ch == EOF) + { + /* EOF means error or end-of-file, return false; neon at EOF is + * assumed to be a mistake. + */ + fclose(f); + return 0; + } + + switch (state) + { + case StartLine: + /* Match spaces at the start of line */ + if (ch <= 32) /* skip control characters and space */ + break; + + counter=0; + state = Feature; + /* FALLTHROUGH */ + + case Feature: + /* Match 'FEATURE', ASCII case insensitive. */ + if ((ch & ~0x20) == ch_feature[counter]) + { + if (++counter == (sizeof ch_feature)) + state = Colon; + break; + } + + /* did not match 'feature' */ + state = SkipLine; + /* FALLTHROUGH */ + + case SkipLine: + skipLine: + /* Skip everything until we see linefeed or carriage return */ + if (ch != 10 && ch != 13) + break; + + state = StartLine; + break; + + case Colon: + /* Match any number of space or tab followed by ':' */ + if (ch == 32 || ch == 9) + break; + + if (ch == 58) /* i.e. ':' */ + { + state = StartTag; + break; + } + + /* Either a bad line format or a 'feature' prefix followed by + * other characters. + */ + state = SkipLine; + goto skipLine; + + case StartTag: + /* Skip space characters before a tag */ + if (ch == 32 || ch == 9) + break; + + state = Neon; + counter = 0; + /* FALLTHROUGH */ + + case Neon: + /* Look for 'neon' tag */ + if ((ch & ~0x20) == ch_neon[counter]) + { + if (++counter == (sizeof ch_neon)) + state = HaveNeon; + break; + } + + state = SkipTag; + /* FALLTHROUGH */ + + case SkipTag: + /* Skip non-space characters */ + if (ch == 10 || ch == 13) + state = StartLine; + + else if (ch == 32 || ch == 9) + state = StartTag; + break; + + case HaveNeon: + /* Have seen a 'neon' prefix, but there must be a space or new + * line character to terminate it. + */ + if (ch == 10 || ch == 13 || ch == 32 || ch == 9) + { + fclose(f); + return 1; + } + + state = SkipTag; + break; + + default: + png_error(png_ptr, "png_have_neon: internal error (bug)"); + } + } + } + +#ifdef PNG_WARNINGS_SUPPORTED + else + png_warning(png_ptr, "/proc/cpuinfo open failed"); +#endif + + return 0; +} diff --git a/thirdparty/libpng-1.6.37/contrib/conftest/README b/thirdparty/libpng-1.6.37/contrib/conftest/README new file mode 100644 index 0000000..0f47279 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/conftest/README @@ -0,0 +1,49 @@ +This directory contains test configuration files, currently always '.dfa' files +intended to be used in the build by setting the make macro DFA_XTRA to the name +of the file. + +These files are used in release validation of the 'configure' builds of libpng +by building 'make check', or 'make all-am' for cross-builds, with each .dfa +file. + +The files in this directory may change between minor releases, however +contributions describing specific builds of libpng are welcomed. There is no +guarantee that libpng will continue to build with such configurations; support +for given configurations can be, and has been, dropped between successive minor +releases. However if a .dfa file describing a configuration is not in this +directory it is very unlikely that it will be tested before a minor release! + +You can use these .dfa files as the basis of new configurations. Files in this +directory should not have any use restrictions or restrictive licenses. + +This directory is not included in the .zip and .7z distributions, which do +not contain 'configure' scripts. + +DOCUMENTATION +============= + +Examples: + ${srcdir}/pngusr.dfa + ${srcdir}/contrib/pngminim/*/pngusr.dfa + +Documentation of the options: + ${srcdir}/scripts/pnglibconf.dfa + +Documentation of the file format: + ${srcdir}/scripts/options.awk + +FILE NAMING +=========== + +File names in this directory may NOT contain any of the five characters: + + - , + * ? + +Neither may they contain any space character. + +While other characters may be used it is strongly suggested that file names be +limited to lower case Latiin alphabetic characters (a-z), digits (0-9) and, if +necessary the underscore (_) character. File names should be about 8 characters +long (excluding the .dfa extension). Submitted .dfa files should have names +between 7 and 16 characters long, shorter names (6 characters or less) are +reserved for standard tests. diff --git a/thirdparty/libpng-1.6.37/contrib/conftest/pngcp.dfa b/thirdparty/libpng-1.6.37/contrib/conftest/pngcp.dfa new file mode 100644 index 0000000..31c411d --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/conftest/pngcp.dfa @@ -0,0 +1,57 @@ +# pngcp.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2016 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with support for pngcp. This means just png_read_png, +# png_write_png and small number of configuration settings. +# +everything = off + +# This option is specific to this configuration; it adds a #define to the +# generated pnglibconf.h which turns on the (not portable) timing option for +# pngcp. Note that any option is automatically preceded by PNG_; there is no +# way round this and this is deliberate. +option PNGCP_TIMING + +# Because of the everything off above the option must also be turned on. This +# may not be done in one step because it is safer and avoids mis-spelled options +# in user .dfa files to error out if an unrecognized option is turned on. +option PNGCP_TIMING on + +# Options to turn on png_read_png and png_write_png: +option INFO_IMAGE on +option SEQUENTIAL_READ on +option EASY_ACCESS on +option WRITE on +option WRITE_16BIT on +option WRITE_FILTER on + +# pngcp needs this to preserve unknown chunks, switching all these on means that +# pngcp can work without explicit known chunk reading support +option UNKNOWN_CHUNKS on +option SET_UNKNOWN_CHUNKS on +option HANDLE_AS_UNKNOWN on +option SAVE_UNKNOWN_CHUNKS on +option WRITE_UNKNOWN_CHUNKS on + +# pngcp needs this to handle palette files with invalid indices: +option CHECK_FOR_INVALID_INDEX on +option GET_PALETTE_MAX on + +# Pre-libpng 1.7 pngcp has to stash text chunks manually, post 1.7 without this +# text chunks should be handled as unknown ok. +option TEXT on + +# this is used to turn off limits: +option USER_LIMITS on +option SET_USER_LIMITS on + +# these are just required for specific customizations +option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on +option WRITE_CUSTOMIZE_COMPRESSION on diff --git a/thirdparty/libpng-1.6.37/contrib/conftest/read.dfa b/thirdparty/libpng-1.6.37/contrib/conftest/read.dfa new file mode 100644 index 0000000..21e88d0 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/conftest/read.dfa @@ -0,0 +1,58 @@ +# read.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2013 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with basic read support. This enables the lowest level libpng +# read API - the one where the calling code has to use a loop to read each row. +# At present this is the API used by most programs. +# +# Support is enabled only for those chunks and transformations that are +# typically required - others can be added easily. +# + +everything = off + +# The sequential read code is enabled here; the progressive code can be used +# instead but there is no point enabling both. + +option SEQUENTIAL_READ on + +# Likewise it is pointless enabling both fixed and floating point APIs. Choose +# one or the other for both the API and the internal math. + +#Fixed point: +#option FIXED_POINT on +#option FLOATING_ARITHMETIC off + +#Floating point: +option FLOATING_POINT on +option FLOATING_ARITHMETIC on + +# Basic error handling, IO and user memory support. The latter allows the +# application program to provide its own implementations of 'malloc' and 'free'. +option SETJMP on +option STDIO on +option USER_MEM on + +# To read the full set of PNG images correctly interlace, transparency and +# 16-bit support is required. The application can implement interlace itself, +# but very few do and it's no longer possible to disable it when READ is +# enabled. +option READ_tRNS on +option READ_16BIT on + +# Everything else is application dependent. This file assumes the app handles +# all the native PNG bit layouts, so it doesn't need any of layout change +# transforms, but needs libpng to perform gamma correction. It doesn't do any +# colorspace stuff and ignores the 'significant bit' information. +# +# If your app always expands the image to a limited set of bit layouts you +# probably want to consider using the simplified API instead of the low level +# one - see png.h and s_read.dfa. +option READ_GAMMA on diff --git a/thirdparty/libpng-1.6.37/contrib/conftest/s_read.dfa b/thirdparty/libpng-1.6.37/contrib/conftest/s_read.dfa new file mode 100644 index 0000000..cb1ce0b --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/conftest/s_read.dfa @@ -0,0 +1,35 @@ +# s_read.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2013 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with simplified read support (only). This builds a minimal +# libpng able to read all PNG formats and convert them into a small number of +# well understood memory formats. +# + +everything = off + +option SIMPLIFIED_READ on + +# It isn't necessary to chose fixed or floating point for the APIs because the +# simplified API doesn't need fixed or floating point numbers. It is necessary +# to chose an internal math implementation. The default (because of 'everything +# = off') is fixed point - turn the floating point implementation on if you have +# hardware floating point or prefer your software floating point implementation. +option FLOATING_ARITHMETIC on + +# This is not strictly necessary, but without it the message strings in the API +# will not be filled in +option ERROR_TEXT on + +# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't +# need this if you don't use them, they just allow the in-memory layout to be +# changed to match common hardware formats. +option SIMPLIFIED_READ_AFIRST on +option SIMPLIFIED_READ_BGR on diff --git a/thirdparty/libpng-1.6.37/contrib/conftest/s_write.dfa b/thirdparty/libpng-1.6.37/contrib/conftest/s_write.dfa new file mode 100644 index 0000000..e540a46 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/conftest/s_write.dfa @@ -0,0 +1,33 @@ +# s_write.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2013 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with (just) simplified write support +# + +everything = off + +option SIMPLIFIED_WRITE on + +# It isn't necessary to chose fixed or floating point for the APIs because the +# simplified API doesn't need fixed or floating point numbers. It is necessary +# to chose an internal math implementation. The default (because of 'everything +# = off') is fixed point - turn the floating point implementation on if you have +# hardware floating point or prefer your software floating point implementation. +option FLOATING_ARITHMETIC on + +# This is not strictly necessary, but without it the message strings in the API +# will not be filled in +option ERROR_TEXT on + +# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't +# need this if you don't use them, they just allow the in-memory layout to be +# changed to match common hardware formats. +option SIMPLIFIED_WRITE_AFIRST on +option SIMPLIFIED_WRITE_BGR on diff --git a/thirdparty/libpng-1.6.37/contrib/conftest/simple.dfa b/thirdparty/libpng-1.6.37/contrib/conftest/simple.dfa new file mode 100644 index 0000000..0419333 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/conftest/simple.dfa @@ -0,0 +1,36 @@ +# simple.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2013 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with just the simplified APIs (read and write). +# + +everything = off + +option SIMPLIFIED_WRITE on +option SIMPLIFIED_READ on + +# It isn't necessary to chose fixed or floating point for the APIs because the +# simplified API doesn't need fixed or floating point numbers. It is necessary +# to chose an internal math implementation. The default (because of 'everything +# = off') is fixed point - turn the floating point implementation on if you have +# hardware floating point or prefer your software floating point implementation. +option FLOATING_ARITHMETIC on + +# This is not strictly necessary, but without it the message strings in the API +# will not be filled in +option ERROR_TEXT on + +# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't +# need this if you don't use them, they just allow the in-memory layout to be +# changed to match common hardware formats. +option SIMPLIFIED_READ_AFIRST on +option SIMPLIFIED_READ_BGR on +option SIMPLIFIED_WRITE_AFIRST on +option SIMPLIFIED_WRITE_BGR on diff --git a/thirdparty/libpng-1.6.37/contrib/conftest/write.dfa b/thirdparty/libpng-1.6.37/contrib/conftest/write.dfa new file mode 100644 index 0000000..3319aab --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/conftest/write.dfa @@ -0,0 +1,45 @@ +# write.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2013 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with no read support and minimal write support. +# + +everything = off + +# Switch on the write code - this makes a minimalist encoder + +option WRITE on + +# Choose fixed or floating point APIs and arithmetic. The choices are +# independent but normally they will match. It is typically better to use the +# floating point if you have floating point hardware. If you don't know, or +# (perhaps) to make libpng smaller used fixed point throughout. + +#Fixed point: +#option FIXED_POINT on +#option FLOATING_ARITHMETIC off + +#Floating point: +option FLOATING_POINT on +option FLOATING_ARITHMETIC on + +# Basic error handling, IO and user memory support. The latter allows the +# application program to provide its own implementations of 'malloc' and 'free'. +option SETJMP on +option STDIO on +option USER_MEM on + +# Everything else is optional. Unlike the read code in libpng the write code +# does not need to deal with arbitrary formats, so only add support for things +# you really do write! For example you might only write sRGB images, sometimes +# with transparency and never write 16 bit images, so: +option WRITE_sRGB on +option WRITE_tRNS on +#option WRITE_16BIT off (this is the default with 'everything = off') diff --git a/thirdparty/libpng-1.6.37/contrib/examples/README.txt b/thirdparty/libpng-1.6.37/contrib/examples/README.txt new file mode 100644 index 0000000..48dab4f --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/examples/README.txt @@ -0,0 +1,24 @@ + +This directory (contrib/examples) contains examples of libpng usage. + +NO COPYRIGHT RIGHTS ARE CLAIMED TO ANY OF THE FILES IN THIS DIRECTORY. + +To the extent possible under law, the authors have waived all copyright and +related or neighboring rights to this work. This work is published from: +United States. + +The files may be used freely in any way. The intention is that appropriate +parts of the files be used in other libpng-using programs without any need for +the authors of the using code to seek copyright or license from the original +authors. + +The source code and comments in this directory are the original work of the +people named below. No other person or organization has made contributions to +the work in this directory. + +ORIGINAL AUTHORS + The following people have contributed to the code in this directory. None + of the people below claim any rights with regard to the contents of this + directory. + + John Bowler diff --git a/thirdparty/libpng-1.6.37/contrib/examples/iccfrompng.c b/thirdparty/libpng-1.6.37/contrib/examples/iccfrompng.c new file mode 100644 index 0000000..00056ab --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/examples/iccfrompng.c @@ -0,0 +1,185 @@ +/*- iccfrompng + * + * COPYRIGHT: Written by John Cunningham Bowler, 2011. + * To the extent possible under law, the author has waived all copyright and + * related or neighboring rights to this work. This work is published from: + * United States. + * + * Extract any icc profiles found in the given PNG files. This is a simple + * example of a program that extracts information from the header of a PNG file + * without processing the image. Notice that some header information may occur + * after the image data. Textual data and comments are an example; the approach + * in this file won't work reliably for such data because it only looks for the + * information in the section of the file that precedes the image data. + * + * Compile and link against libpng and zlib, plus anything else required on the + * system you use. + * + * To use supply a list of PNG files containing iCCP chunks, the chunks will be + * extracted to a similarly named file with the extension replaced by 'icc', + * which will be overwritten without warning. + */ +#include +#include +#include +#include + +#include + +#if defined(PNG_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) && \ + defined (PNG_iCCP_SUPPORTED) + + +static int verbose = 1; +static png_byte no_profile[] = "no profile"; + +static png_bytep +extract(FILE *fp, png_uint_32 *proflen) +{ + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0); + png_infop info_ptr = NULL; + png_bytep result = NULL; + + /* Initialize for error or no profile: */ + *proflen = 0; + + if (png_ptr == NULL) + { + fprintf(stderr, "iccfrompng: version library mismatch?\n"); + return 0; + } + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return 0; + } + + png_init_io(png_ptr, fp); + + info_ptr = png_create_info_struct(png_ptr); + if (info_ptr == NULL) + png_error(png_ptr, "OOM allocating info structure"); + + png_read_info(png_ptr, info_ptr); + + { + png_charp name; + int compression_type; + png_bytep profile; + + if (png_get_iCCP(png_ptr, info_ptr, &name, &compression_type, &profile, + proflen) & PNG_INFO_iCCP) + { + result = malloc(*proflen); + if (result != NULL) + memcpy(result, profile, *proflen); + + else + png_error(png_ptr, "OOM allocating profile buffer"); + } + + else + result = no_profile; + } + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return result; +} + +static int +extract_one_file(const char *filename) +{ + int result = 0; + FILE *fp = fopen(filename, "rb"); + + if (fp != NULL) + { + png_uint_32 proflen = 0; + png_bytep profile = extract(fp, &proflen); + + if (profile != NULL && profile != no_profile) + { + size_t len; + char *output; + + { + const char *ep = strrchr(filename, '.'); + + if (ep != NULL) + len = ep-filename; + + else + len = strlen(filename); + } + + output = malloc(len + 5); + if (output != NULL) + { + FILE *of; + + memcpy(output, filename, len); + strcpy(output+len, ".icc"); + + of = fopen(output, "wb"); + if (of != NULL) + { + if (fwrite(profile, proflen, 1, of) == 1 && + fflush(of) == 0 && + fclose(of) == 0) + { + if (verbose) + printf("%s -> %s\n", filename, output); + /* Success return */ + result = 1; + } + + else + { + fprintf(stderr, "%s: error writing profile\n", output); + if (remove(output)) + fprintf(stderr, "%s: could not remove file\n", output); + } + } + + else + fprintf(stderr, "%s: failed to open output file\n", output); + + free(output); + } + + else + fprintf(stderr, "%s: OOM allocating string!\n", filename); + + free(profile); + } + + else if (verbose && profile == no_profile) + printf("%s has no profile\n", filename); + } + + else + fprintf(stderr, "%s: could not open file\n", filename); + + return result; +} + +int +main(int argc, char **argv) +{ + int i; + int extracted = 0; + + for (i=1; i +#include +#include /* required for error handling */ + +/* Normally use here to get the installed libpng, but this is done to + * ensure the code picks up the local libpng implementation: + */ +#include "../../png.h" + +#if defined(PNG_READ_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED) + +/* Return component 'c' of pixel 'x' from the given row. */ +static unsigned int +component(png_const_bytep row, png_uint_32 x, unsigned int c, + unsigned int bit_depth, unsigned int channels) +{ + /* PNG images can be up to 2^31 pixels wide, but this means they can be up to + * 2^37 bits wide (for a 64-bit pixel - the largest possible) and hence 2^34 + * bytes wide. Since the row fitted into memory, however, the following must + * work: + */ + png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels); + png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c); + + row = (png_const_bytep)(((const png_byte (*)[8])row) + bit_offset_hi); + row += bit_offset_lo >> 3; + bit_offset_lo &= 0x07; + + /* PNG pixels are packed into bytes to put the first pixel in the highest + * bits of the byte and into two bytes for 16-bit values with the high 8 bits + * first, so: + */ + switch (bit_depth) + { + case 1: return (row[0] >> (7-bit_offset_lo)) & 0x01; + case 2: return (row[0] >> (6-bit_offset_lo)) & 0x03; + case 4: return (row[0] >> (4-bit_offset_lo)) & 0x0f; + case 8: return row[0]; + case 16: return (row[0] << 8) + row[1]; + default: + /* This should never happen; it indicates a bug in this program or in + * libpng itself: + */ + fprintf(stderr, "pngpixel: invalid bit depth %u\n", bit_depth); + exit(1); + } +} + +/* Print a pixel from a row returned by libpng; determine the row format, find + * the pixel, and print the relevant information to stdout. + */ +static void +print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row, + png_uint_32 x) +{ + unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr); + + switch (png_get_color_type(png_ptr, info_ptr)) + { + case PNG_COLOR_TYPE_GRAY: + printf("GRAY %u\n", component(row, x, 0, bit_depth, 1)); + return; + + /* The palette case is slightly more difficult - the palette and, if + * present, the tRNS ('transparency', though the values are really + * opacity) data must be read to give the full picture: + */ + case PNG_COLOR_TYPE_PALETTE: + { + int index = component(row, x, 0, bit_depth, 1); + png_colorp palette = NULL; + int num_palette = 0; + + if ((png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) & + PNG_INFO_PLTE) && num_palette > 0 && palette != NULL) + { + png_bytep trans_alpha = NULL; + int num_trans = 0; + if ((png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, + NULL) & PNG_INFO_tRNS) && num_trans > 0 && + trans_alpha != NULL) + printf("INDEXED %u = %d %d %d %d\n", index, + palette[index].red, palette[index].green, + palette[index].blue, + index < num_trans ? trans_alpha[index] : 255); + + else /* no transparency */ + printf("INDEXED %u = %d %d %d\n", index, + palette[index].red, palette[index].green, + palette[index].blue); + } + + else + printf("INDEXED %u = invalid index\n", index); + } + return; + + case PNG_COLOR_TYPE_RGB: + printf("RGB %u %u %u\n", component(row, x, 0, bit_depth, 3), + component(row, x, 1, bit_depth, 3), + component(row, x, 2, bit_depth, 3)); + return; + + case PNG_COLOR_TYPE_GRAY_ALPHA: + printf("GRAY+ALPHA %u %u\n", component(row, x, 0, bit_depth, 2), + component(row, x, 1, bit_depth, 2)); + return; + + case PNG_COLOR_TYPE_RGB_ALPHA: + printf("RGBA %u %u %u %u\n", component(row, x, 0, bit_depth, 4), + component(row, x, 1, bit_depth, 4), + component(row, x, 2, bit_depth, 4), + component(row, x, 3, bit_depth, 4)); + return; + + default: + png_error(png_ptr, "pngpixel: invalid color type"); + } +} + +int main(int argc, const char **argv) +{ + /* This program uses the default, based, libpng error handling + * mechanism, therefore any local variable that exists before the call to + * setjmp and is changed after the call to setjmp returns successfully must + * be declared with 'volatile' to ensure that their values don't get + * destroyed by longjmp: + */ + volatile int result = 1/*fail*/; + + if (argc == 4) + { + long x = atol(argv[1]); + long y = atol(argv[2]); + FILE *f = fopen(argv[3], "rb"); + volatile png_bytep row = NULL; + + if (f != NULL) + { + /* libpng requires a callback function for handling errors; this + * callback must not return. The default callback function uses a + * stored style jmp_buf which is held in a png_struct and + * writes error messages to stderr. Creating the png_struct is a + * little tricky; just copy the following code. + */ + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + NULL, NULL, NULL); + + if (png_ptr != NULL) + { + png_infop info_ptr = png_create_info_struct(png_ptr); + + if (info_ptr != NULL) + { + /* Declare stack variables to hold pointers to locally allocated + * data. + */ + + /* Initialize the error control buffer: */ + if (setjmp(png_jmpbuf(png_ptr)) == 0) + { + png_uint_32 width, height; + int bit_depth, color_type, interlace_method, + compression_method, filter_method; + png_bytep row_tmp; + + /* Now associate the recently opened (FILE*) with the default + * libpng initialization functions. Sometimes libpng is + * compiled without stdio support (it can be difficult to do + * in some environments); in that case you will have to write + * your own read callback to read data from the (FILE*). + */ + png_init_io(png_ptr, f); + + /* And read the first part of the PNG file - the header and + * all the information up to the first pixel. + */ + png_read_info(png_ptr, info_ptr); + + /* This fills in enough information to tell us the width of + * each row in bytes, allocate the appropriate amount of + * space. In this case png_malloc is used - it will not + * return if memory isn't available. + */ + row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, + info_ptr)); + + /* To avoid the overhead of using a volatile auto copy row_tmp + * to a local here - just use row for the png_free below. + */ + row_tmp = row; + + /* All the information we need is in the header is returned by + * png_get_IHDR, if this fails we can now use 'png_error' to + * signal the error and return control to the setjmp above. + */ + if (png_get_IHDR(png_ptr, info_ptr, &width, &height, + &bit_depth, &color_type, &interlace_method, + &compression_method, &filter_method)) + { + int passes, pass; + + /* png_set_interlace_handling returns the number of + * passes required as well as turning on libpng's + * handling, but since we do it ourselves this is + * necessary: + */ + switch (interlace_method) + { + case PNG_INTERLACE_NONE: + passes = 1; + break; + + case PNG_INTERLACE_ADAM7: + passes = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + png_error(png_ptr, "pngpixel: unknown interlace"); + } + + /* Now read the pixels, pass-by-pass, row-by-row: */ + png_start_read_image(png_ptr); + + for (pass=0; pass +#include +#include +#include + +/* Normally use here to get the installed libpng, but this is done to + * ensure the code picks up the local libpng implementation: + */ +#include "../../png.h" +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && \ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) + +int main(int argc, const char **argv) +{ + int result = 1; + + if (argc == 3) + { + png_image image; + + /* Only the image structure version number needs to be set. */ + memset(&image, 0, sizeof image); + image.version = PNG_IMAGE_VERSION; + + if (png_image_begin_read_from_file(&image, argv[1])) + { + png_bytep buffer; + + /* Change this to try different formats! If you set a colormap format + * then you must also supply a colormap below. + */ + image.format = PNG_FORMAT_RGBA; + + buffer = malloc(PNG_IMAGE_SIZE(image)); + + if (buffer != NULL) + { + if (png_image_finish_read(&image, NULL/*background*/, buffer, + 0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */)) + { + if (png_image_write_to_file(&image, argv[2], + 0/*convert_to_8bit*/, buffer, 0/*row_stride*/, + NULL/*colormap*/)) + result = 0; + + else + fprintf(stderr, "pngtopng: write %s: %s\n", argv[2], + image.message); + } + + else + fprintf(stderr, "pngtopng: read %s: %s\n", argv[1], + image.message); + + free(buffer); + } + + else + { + fprintf(stderr, "pngtopng: out of memory: %lu bytes\n", + (unsigned long)PNG_IMAGE_SIZE(image)); + + /* This is the only place where a 'free' is required; libpng does + * the cleanup on error and success, but in this case we couldn't + * complete the read because of running out of memory and so libpng + * has not got to the point where it can do cleanup. + */ + png_image_free(&image); + } + } + + else + /* Failed to read the first argument: */ + fprintf(stderr, "pngtopng: %s: %s\n", argv[1], image.message); + } + + else + /* Wrong number of arguments */ + fprintf(stderr, "pngtopng: usage: pngtopng input-file output-file\n"); + + return result; +} +#endif /* READ && WRITE */ diff --git a/thirdparty/libpng-1.6.37/contrib/examples/simpleover.c b/thirdparty/libpng-1.6.37/contrib/examples/simpleover.c new file mode 100644 index 0000000..59dd313 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/examples/simpleover.c @@ -0,0 +1,648 @@ +/*- simpleover + * + * COPYRIGHT: Written by John Cunningham Bowler, 2015. + * To the extent possible under law, the author has waived all copyright and + * related or neighboring rights to this work. This work is published from: + * United States. + * + * Read several PNG files, which should have an alpha channel or transparency + * information, and composite them together to produce one or more 16-bit linear + * RGBA intermediates. This involves doing the correct 'over' composition to + * combine the alpha channels and corresponding data. + * + * Finally read an output (background) PNG using the 24-bit RGB format (the + * PNG will be composited on green (#00ff00) by default if it has an alpha + * channel), and apply the intermediate image generated above to specified + * locations in the image. + * + * The command line has the general format: + * + * simpleover [output.png] + * {--sprite=width,height,name {[--at=x,y] {sprite.png}}} + * {--add=name {x,y}} + * + * The --sprite and --add options may occur multiple times. They are executed + * in order. --add may refer to any sprite already read. + * + * This code is intended to show how to composite multiple images together + * correctly. Apart from the libpng Simplified API the only work done in here + * is to combine multiple input PNG images into a single sprite; this involves + * a Porter-Duff 'over' operation and the input PNG images may, as a result, + * be regarded as being layered one on top of the other with the first (leftmost + * on the command line) being at the bottom and the last on the top. + */ +#include +#include +#include +#include +#include + +/* Normally use here to get the installed libpng, but this is done to + * ensure the code picks up the local libpng implementation, so long as this + * file is linked against a sufficiently recent libpng (1.6+) it is ok to + * change this to : + */ +#include "../../png.h" + +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED + +#define sprite_name_chars 15 +struct sprite { + FILE *file; + png_uint_16p buffer; + unsigned int width; + unsigned int height; + char name[sprite_name_chars+1]; +}; + +#if 0 /* div by 65535 test program */ +#include +#include + +int main(void) { + double err = 0; + unsigned int xerr = 0; + unsigned int r = 32769; + { + unsigned int x = 0; + + do { + unsigned int t = x + (x >> 16) /*+ (x >> 31)*/ + r; + double v = x, errtest; + + if (t < x) { + fprintf(stderr, "overflow: %u+%u -> %u\n", x, r, t); + return 1; + } + + v /= 65535; + errtest = v; + t >>= 16; + errtest -= t; + + if (errtest > err) { + err = errtest; + xerr = x; + + if (errtest >= .5) { + fprintf(stderr, "error: %u/65535 = %f, not %u, error %f\n", + x, v, t, errtest); + return 0; + } + } + } while (++x <= 65535U*65535U); + } + + printf("error %f @ %u\n", err, xerr); + + return 0; +} +#endif /* div by 65535 test program */ + +static void +sprite_op(const struct sprite *sprite, int x_offset, int y_offset, + png_imagep image, const png_uint_16 *buffer) +{ + /* This is where the Porter-Duff 'Over' operator is evaluated; change this + * code to change the operator (this could be parameterized). Any other + * image processing operation could be used here. + */ + + + /* Check for an x or y offset that pushes any part of the image beyond the + * right or bottom of the sprite: + */ + if ((y_offset < 0 || (unsigned)/*SAFE*/y_offset < sprite->height) && + (x_offset < 0 || (unsigned)/*SAFE*/x_offset < sprite->width)) + { + unsigned int y = 0; + + if (y_offset < 0) + y = -y_offset; /* Skip to first visible row */ + + do + { + unsigned int x = 0; + + if (x_offset < 0) + x = -x_offset; + + do + { + /* In and out are RGBA values, so: */ + const png_uint_16 *in_pixel = buffer + (y * image->width + x)*4; + png_uint_32 in_alpha = in_pixel[3]; + + /* This is the optimized Porter-Duff 'Over' operation, when the + * input alpha is 0 the output is not changed. + */ + if (in_alpha > 0) + { + png_uint_16 *out_pixel = sprite->buffer + + ((y+y_offset) * sprite->width + (x+x_offset))*4; + + /* This is the weight to apply to the output: */ + in_alpha = 65535-in_alpha; + + if (in_alpha > 0) + { + /* The input must be composed onto the output. This means + * multiplying the current output pixel value by the inverse + * of the input alpha (1-alpha). A division is required but + * it is by the constant 65535. Approximate this as: + * + * (x + (x >> 16) + 32769) >> 16; + * + * This is exact (and does not overflow) for all values of + * x in the range 0..65535*65535. (Note that the calculation + * produces the closest integer; the maximum error is <0.5). + */ + png_uint_32 tmp; + +# define compose(c)\ + tmp = out_pixel[c] * in_alpha;\ + tmp = (tmp + (tmp >> 16) + 32769) >> 16;\ + out_pixel[c] = tmp + in_pixel[c] + + /* The following is very vectorizable... */ + compose(0); + compose(1); + compose(2); + compose(3); + } + + else + out_pixel[0] = in_pixel[0], + out_pixel[1] = in_pixel[1], + out_pixel[2] = in_pixel[2], + out_pixel[3] = in_pixel[3]; + } + } + while (++x < image->width); + } + while (++y < image->height); + } +} + +static int +create_sprite(struct sprite *sprite, int *argc, const char ***argv) +{ + /* Read the arguments and create this sprite. The sprite buffer has already + * been allocated. This reads the input PNGs one by one in linear format, + * composes them onto the sprite buffer (the code in the function above) + * then saves the result, converting it on the fly to PNG RGBA 8-bit format. + */ + while (*argc > 0) + { + char tombstone; + int x = 0, y = 0; + + if ((*argv)[0][0] == '-' && (*argv)[0][1] == '-') + { + /* The only supported option is --at. */ + if (sscanf((*argv)[0], "--at=%d,%d%c", &x, &y, &tombstone) != 2) + break; /* success; caller will parse this option */ + + ++*argv, --*argc; + } + + else + { + /* The argument has to be a file name */ + png_image image; + + image.version = PNG_IMAGE_VERSION; + image.opaque = NULL; + + if (png_image_begin_read_from_file(&image, (*argv)[0])) + { + png_uint_16p buffer; + + image.format = PNG_FORMAT_LINEAR_RGB_ALPHA; + + buffer = malloc(PNG_IMAGE_SIZE(image)); + + if (buffer != NULL) + { + if (png_image_finish_read(&image, NULL/*background*/, buffer, + 0/*row_stride*/, + NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/)) + { + /* This is the place where the Porter-Duff 'Over' operator + * needs to be done by this code. In fact, any image + * processing required can be done here; the data is in + * the correct format (linear, 16-bit) and source and + * destination are in memory. + */ + sprite_op(sprite, x, y, &image, buffer); + free(buffer); + ++*argv, --*argc; + /* And continue to the next argument */ + continue; + } + + else + { + free(buffer); + fprintf(stderr, "simpleover: read %s: %s\n", (*argv)[0], + image.message); + } + } + + else + { + fprintf(stderr, "simpleover: out of memory: %lu bytes\n", + (unsigned long)PNG_IMAGE_SIZE(image)); + + /* png_image_free must be called if we abort the Simplified API + * read because of a problem detected in this code. If problems + * are detected in the Simplified API it cleans up itself. + */ + png_image_free(&image); + } + } + + else + { + /* Failed to read the first argument: */ + fprintf(stderr, "simpleover: %s: %s\n", (*argv)[0], image.message); + } + + return 0; /* failure */ + } + } + + /* All the sprite operations have completed successfully. Save the RGBA + * buffer as a PNG using the simplified write API. + */ + sprite->file = tmpfile(); + + if (sprite->file != NULL) + { + png_image save; + + memset(&save, 0, sizeof save); + save.version = PNG_IMAGE_VERSION; + save.opaque = NULL; + save.width = sprite->width; + save.height = sprite->height; + save.format = PNG_FORMAT_LINEAR_RGB_ALPHA; + save.flags = PNG_IMAGE_FLAG_FAST; + save.colormap_entries = 0; + + if (png_image_write_to_stdio(&save, sprite->file, 1/*convert_to_8_bit*/, + sprite->buffer, 0/*row_stride*/, NULL/*colormap*/)) + { + /* Success; the buffer is no longer needed: */ + free(sprite->buffer); + sprite->buffer = NULL; + return 1; /* ok */ + } + + else + fprintf(stderr, "simpleover: write sprite %s: %s\n", sprite->name, + save.message); + } + + else + fprintf(stderr, "simpleover: sprite %s: could not allocate tmpfile: %s\n", + sprite->name, strerror(errno)); + + return 0; /* fail */ +} + +static int +add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite, + int *argc, const char ***argv) +{ + /* Given a --add argument naming this sprite, perform the operations listed + * in the following arguments. The arguments are expected to have the form + * (x,y), which is just an offset at which to add the sprite to the + * output. + */ + while (*argc > 0) + { + char tombstone; + int x, y; + + if ((*argv)[0][0] == '-' && (*argv)[0][1] == '-') + return 1; /* success */ + + if (sscanf((*argv)[0], "%d,%d%c", &x, &y, &tombstone) == 2) + { + /* Now add the new image into the sprite data, but only if it + * will fit. + */ + if (x < 0 || y < 0 || + (unsigned)/*SAFE*/x >= output->width || + (unsigned)/*SAFE*/y >= output->height || + sprite->width > output->width-x || + sprite->height > output->height-y) + { + fprintf(stderr, "simpleover: sprite %s @ (%d,%d) outside image\n", + sprite->name, x, y); + /* Could just skip this, but for the moment it is an error */ + return 0; /* error */ + } + + else + { + /* Since we know the sprite fits we can just read it into the + * output using the simplified API. + */ + png_image in; + + in.version = PNG_IMAGE_VERSION; + rewind(sprite->file); + + if (png_image_begin_read_from_stdio(&in, sprite->file)) + { + in.format = PNG_FORMAT_RGB; /* force compose */ + + if (png_image_finish_read(&in, NULL/*background*/, + out_buf + (y*output->width + x)*3/*RGB*/, + output->width*3/*row_stride*/, + NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/)) + { + ++*argv, --*argc; + continue; + } + } + + /* The read failed: */ + fprintf(stderr, "simpleover: add sprite %s: %s\n", sprite->name, + in.message); + return 0; /* error */ + } + } + + else + { + fprintf(stderr, "simpleover: --add='%s': invalid position %s\n", + sprite->name, (*argv)[0]); + return 0; /* error */ + } + } + + return 1; /* ok */ +} + +static int +simpleover_process(png_imagep output, png_bytep out_buf, int argc, + const char **argv) +{ + int result = 1; /* success */ +# define csprites 10/*limit*/ +# define str(a) #a + int nsprites = 0; + struct sprite sprites[csprites]; + + while (argc > 0) + { + result = 0; /* fail */ + + if (strncmp(argv[0], "--sprite=", 9) == 0) + { + char tombstone; + + if (nsprites < csprites) + { + int n; + + sprites[nsprites].width = sprites[nsprites].height = 0; + sprites[nsprites].name[0] = 0; + + n = sscanf(argv[0], "--sprite=%u,%u,%" str(sprite_name_chars) "s%c", + &sprites[nsprites].width, &sprites[nsprites].height, + sprites[nsprites].name, &tombstone); + + if ((n == 2 || n == 3) && + sprites[nsprites].width > 0 && sprites[nsprites].height > 0) + { + size_t buf_size, tmp; + + /* Default a name if not given. */ + if (sprites[nsprites].name[0] == 0) + sprintf(sprites[nsprites].name, "sprite-%d", nsprites+1); + + /* Allocate a buffer for the sprite and calculate the buffer + * size: + */ + buf_size = sizeof (png_uint_16 [4]); + buf_size *= sprites[nsprites].width; + buf_size *= sprites[nsprites].height; + + /* This can overflow a (size_t); check for this: */ + tmp = buf_size; + tmp /= sprites[nsprites].width; + tmp /= sprites[nsprites].height; + + if (tmp == sizeof (png_uint_16 [4])) + { + sprites[nsprites].buffer = malloc(buf_size); + /* This buffer must be initialized to transparent: */ + memset(sprites[nsprites].buffer, 0, buf_size); + + if (sprites[nsprites].buffer != NULL) + { + sprites[nsprites].file = NULL; + ++argv, --argc; + + if (create_sprite(sprites+nsprites++, &argc, &argv)) + { + result = 1; /* still ok */ + continue; + } + + break; /* error */ + } + } + + /* Overflow, or OOM */ + fprintf(stderr, "simpleover: %s: sprite too large\n", argv[0]); + break; + } + + else + { + fprintf(stderr, "simpleover: %s: invalid sprite (%u,%u)\n", + argv[0], sprites[nsprites].width, sprites[nsprites].height); + break; + } + } + + else + { + fprintf(stderr, "simpleover: %s: too many sprites\n", argv[0]); + break; + } + } + + else if (strncmp(argv[0], "--add=", 6) == 0) + { + const char *name = argv[0]+6; + int isprite = nsprites; + + ++argv, --argc; + + while (--isprite >= 0) + { + if (strcmp(sprites[isprite].name, name) == 0) + { + if (!add_sprite(output, out_buf, sprites+isprite, &argc, &argv)) + goto out; /* error in add_sprite */ + + break; + } + } + + if (isprite < 0) /* sprite not found */ + { + fprintf(stderr, "simpleover: --add='%s': sprite not found\n", name); + break; + } + } + + else + { + fprintf(stderr, "simpleover: %s: unrecognized operation\n", argv[0]); + break; + } + + result = 1; /* ok */ + } + + /* Clean up the cache of sprites: */ +out: + while (--nsprites >= 0) + { + if (sprites[nsprites].buffer != NULL) + free(sprites[nsprites].buffer); + + if (sprites[nsprites].file != NULL) + (void)fclose(sprites[nsprites].file); + } + + return result; +} + +int main(int argc, const char **argv) +{ + int result = 1; /* default to fail */ + + if (argc >= 2) + { + int argi = 2; + const char *output = NULL; + png_image image; + + if (argc > 2 && argv[2][0] != '-'/*an operation*/) + { + output = argv[2]; + argi = 3; + } + + image.version = PNG_IMAGE_VERSION; + image.opaque = NULL; + + if (png_image_begin_read_from_file(&image, argv[1])) + { + png_bytep buffer; + + image.format = PNG_FORMAT_RGB; /* 24-bit RGB */ + + buffer = malloc(PNG_IMAGE_SIZE(image)); + + if (buffer != NULL) + { + png_color background = {0, 0xff, 0}; /* fully saturated green */ + + if (png_image_finish_read(&image, &background, buffer, + 0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */)) + { + /* At this point png_image_finish_read has cleaned up the + * allocated data in png_image, and only the buffer needs to be + * freed. + * + * Perform the remaining operations: + */ + if (simpleover_process(&image, buffer, argc-argi, argv+argi)) + { + /* Write the output: */ + if ((output != NULL && + png_image_write_to_file(&image, output, + 0/*convert_to_8bit*/, buffer, 0/*row_stride*/, + NULL/*colormap*/)) || + (output == NULL && + png_image_write_to_stdio(&image, stdout, + 0/*convert_to_8bit*/, buffer, 0/*row_stride*/, + NULL/*colormap*/))) + result = 0; + + else + fprintf(stderr, "simpleover: write %s: %s\n", + output == NULL ? "stdout" : output, image.message); + } + + /* else simpleover_process writes an error message */ + } + + else + fprintf(stderr, "simpleover: read %s: %s\n", argv[1], + image.message); + + free(buffer); + } + + else + { + fprintf(stderr, "simpleover: out of memory: %lu bytes\n", + (unsigned long)PNG_IMAGE_SIZE(image)); + + /* This is the only place where a 'free' is required; libpng does + * the cleanup on error and success, but in this case we couldn't + * complete the read because of running out of memory. + */ + png_image_free(&image); + } + } + + else + { + /* Failed to read the first argument: */ + fprintf(stderr, "simpleover: %s: %s\n", argv[1], image.message); + } + } + + else + { + /* Usage message */ + fprintf(stderr, + "simpleover: usage: simpleover background.png [output.png]\n" + " Output 'background.png' as a 24-bit RGB PNG file in 'output.png'\n" + " or, if not given, stdout. 'background.png' will be composited\n" + " on fully saturated green.\n" + "\n" + " Optionally, before output, process additional PNG files:\n" + "\n" + " --sprite=width,height,name {[--at=x,y] {sprite.png}}\n" + " Produce a transparent sprite of size (width,height) and with\n" + " name 'name'.\n" + " For each sprite.png composite it using a Porter-Duff 'Over'\n" + " operation at offset (x,y) in the sprite (defaulting to (0,0)).\n" + " Input PNGs will be truncated to the area of the sprite.\n" + "\n" + " --add='name' {x,y}\n" + " Optionally, before output, composite a sprite, 'name', which\n" + " must have been previously produced using --sprite, at each\n" + " offset (x,y) in the output image. Each sprite must fit\n" + " completely within the output image.\n" + "\n" + " PNG files are processed in the order they occur on the command\n" + " line and thus the first PNG processed appears as the bottommost\n" + " in the output image.\n"); + } + + return result; +} +#endif /* SIMPLIFIED_READ */ diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/COPYING b/thirdparty/libpng-1.6.37/contrib/gregbook/COPYING new file mode 100644 index 0000000..a3e9774 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/LICENSE b/thirdparty/libpng-1.6.37/contrib/gregbook/LICENSE new file mode 100644 index 0000000..d956717 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/LICENSE @@ -0,0 +1,50 @@ + --------------------------------------------------------------------------- + + Copyright (c) 1998-2008 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + --------------------------------------------------------------------------- diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.mingw32 b/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.mingw32 new file mode 100644 index 0000000..3a3ff60 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.mingw32 @@ -0,0 +1,131 @@ +# Sample makefile for rpng-win / rpng2-win / wpng using mingw32-gcc and make. +# Greg Roelofs +# Last modified: 2 June 2007 +# +# The programs built by this makefile are described in the book, +# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and +# Associates, 1999). Go buy a copy, eh? Well, OK, it's not +# generally for sale anymore, but it's the thought that counts, +# right? (Hint: http://www.libpng.org/pub/png/book/ ) +# +# Invoke this makefile from a DOS-prompt window via: +# +# make -f Makefile.mingw32 +# +# This makefile assumes libpng and zlib have already been built or downloaded +# and are in subdirectories at the same level as the current subdirectory +# (as indicated by the PNGDIR and ZDIR macros below). It makes no assumptions +# at all about the mingw32 installation tree (W32DIR). Edit as appropriate. +# +# Note that the names of the dynamic and static libpng and zlib libraries +# used below may change in later releases of the libraries. This makefile +# builds both statically and dynamically linked executables by default. +# (You need only one set, but for testing it can be handy to have both.) + + +# macros -------------------------------------------------------------------- + +#PNGDIR = ../..# for libpng-x.y.z/contrib/gregbook builds +PNGDIR = ../libpng-win32 +PNGINC = -I$(PNGDIR) +PNGLIBd = $(PNGDIR)/libpng.dll.a # dynamically linked +PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng + +#ZDIR = ../../../zlib-win32# for libpng-x.y.z/contrib/gregbook builds +ZDIR = ../zlib-win32 +ZINC = -I$(ZDIR) +ZLIBd = $(ZDIR)/libzdll.a +ZLIBs = $(ZDIR)/libz.a + +# change this to be the path where mingw32 installs its stuff: +W32DIR = +#W32DIR = /usr/local/cross-tools/i386-mingw32msvc +W32INC = -I$(W32DIR)/include +W32LIB = $(W32DIR)/lib/libuser32.a $(W32DIR)/lib/libgdi32.a + +CC = gcc +#CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation +LD = $(CC) +RM = rm -f +CPPFLAGS = $(INCS) +CFLAGS = -O -Wall $(MINGW_CCFLAGS) +# [note that -Wall is a gcc-specific compilation flag ("most warnings on")] +# [-ansi, -pedantic and -W can also be used] +LDFLAGS = $(MINGW_LDFLAGS) +O = .o +E = .exe + +INCS = $(PNGINC) $(ZINC) $(W32INC) +RLIBSd = $(PNGLIBd) $(ZLIBd) $(W32LIB) -lm +RLIBSs = $(PNGLIBs) $(ZLIBs) $(W32LIB) -lm +WLIBSd = $(PNGLIBd) $(ZLIBd) +WLIBSs = $(PNGLIBs) $(ZLIBs) + +RPNG = rpng-win +RPNG2 = rpng2-win +WPNG = wpng + +ROBJSd = $(RPNG)$(O) readpng.pic$(O) +ROBJS2d = $(RPNG2)$(O) readpng2.pic$(O) +WOBJSd = $(WPNG)$(O) writepng.pic$(O) + +RPNGs = $(RPNG)-static +RPNG2s = $(RPNG2)-static +WPNGs = $(WPNG)-static + +ROBJSs = $(RPNG)$(O) readpng$(O) +ROBJS2s = $(RPNG2)$(O) readpng2$(O) +WOBJSs = $(WPNG)$(O) writepng$(O) + +STATIC_EXES = $(RPNGs)$(E) $(RPNG2s)$(E) $(WPNGs)$(E) +DYNAMIC_EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) + +EXES = $(STATIC_EXES) $(DYNAMIC_EXES) + + +# implicit make rules ------------------------------------------------------- + +.c$(O): + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< + +%.pic$(O): %.c + $(CC) -c $(CPPFLAGS) $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< + + +# dependencies -------------------------------------------------------------- + +all: $(EXES) + +$(RPNGs)$(E): $(ROBJSs) + $(LD) $(LDFLAGS) -o $@ $(ROBJSs) $(RLIBSs) + +$(RPNG)$(E): $(ROBJSd) + $(LD) $(LDFLAGS) -o $@ $(ROBJSd) $(RLIBSd) + +$(RPNG2s)$(E): $(ROBJS2s) + $(LD) $(LDFLAGS) -o $@ $(ROBJS2s) $(RLIBSs) + +$(RPNG2)$(E): $(ROBJS2d) + $(LD) $(LDFLAGS) -o $@ $(ROBJS2d) $(RLIBSd) + +$(WPNGs)$(E): $(WOBJSs) + $(LD) $(LDFLAGS) -o $@ $(WOBJSs) $(WLIBSs) + +$(WPNG)$(E): $(WOBJSd) + $(LD) $(LDFLAGS) -o $@ $(WOBJSd) $(WLIBSd) + +$(RPNG)$(O): $(RPNG).c readpng.h +$(RPNG2)$(O): $(RPNG2).c readpng2.h +$(WPNG)$(O): $(WPNG).c writepng.h + +readpng$(O) readpng.pic$(O): readpng.c readpng.h +readpng2$(O) readpng2.pic$(O): readpng2.c readpng2.h +writepng$(O) writepng.pic$(O): writepng.c writepng.h + + +# maintenance --------------------------------------------------------------- + +clean: + $(RM) $(EXES) + $(RM) $(ROBJSs) $(ROBJS2s) $(WOBJSs) + $(RM) $(ROBJSd) $(ROBJS2d) $(WOBJSd) diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.sgi b/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.sgi new file mode 100644 index 0000000..94d61b4 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.sgi @@ -0,0 +1,105 @@ +# Sample makefile for rpng-x / rpng2-x / wpng for SGI using cc and make. +# Greg Roelofs +# Last modified: 7 March 2002 +# +# The programs built by this makefile are described in the book, +# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and +# Associates, 1999). Go buy a copy, eh? Buy some for friends +# and family, too. (Not that this is a blatant plug or anything.) +# +# Invoke this makefile from a shell prompt in the usual way; for example: +# +# make -f Makefile.sgi +# +# This makefile assumes libpng and zlib have already been built or downloaded +# and are both installed in /usr/local/{include,lib} (as indicated by the +# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of +# the PNGINC, PNGLIB, ZINC and ZLIB lines. +# +# This makefile builds dynamically linked executables (against libpng and zlib, +# that is), but that can be changed by uncommenting the appropriate PNGLIB and +# ZLIB lines. + + +# macros -------------------------------------------------------------------- + +PNGINC = -I/usr/local/include/libpng16 +PNGLIB = -L/usr/local/lib -lpng16 # dynamically linked against libpng +#PNGLIB = /usr/local/lib/libpng16.a # statically linked against libpng +# or: +#PNGINC = -I../.. +#PNGLIB = -L../.. -lpng +#PNGLIB = ../../libpng.a + +ZINC = -I/usr/local/include +ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib +#ZLIB = /usr/local/lib/libz.a # statically linked against zlib +#ZINC = -I../zlib +#ZLIB = -L../zlib -lz +#ZLIB = ../../../zlib/libz.a + +XINC = -I/usr/include/X11 # old-style, stock X distributions +XLIB = -L/usr/lib/X11 -lX11 +#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows) +#XLIB = -L/usr/openwin/lib -lX11 +#XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.) +#XLIB = -L/usr/X11R6/lib -lX11 + +INCS = $(PNGINC) $(ZINC) $(XINC) +RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm +WLIBS = $(PNGLIB) $(ZLIB) + +CC = cc +LD = cc +RM = rm -f +# ABI must be the same as that used to build libpng. +ABI = +CPPFLAGS = +CFLAGS = $(ABI) -O -fullwarn $(INCS) +LDFLAGS = $(ABI) +O = .o +E = + +RPNG = rpng-x +RPNG2 = rpng2-x +WPNG = wpng + +ROBJS = $(RPNG)$(O) readpng$(O) +ROBJS2 = $(RPNG2)$(O) readpng2$(O) +WOBJS = $(WPNG)$(O) writepng$(O) + +EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) + + +# implicit make rules ------------------------------------------------------- + +.c$(O): + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< + + +# dependencies -------------------------------------------------------------- + +all: $(EXES) + +$(RPNG)$(E): $(ROBJS) + $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS) + +$(RPNG2)$(E): $(ROBJS2) + $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS) + +$(WPNG)$(E): $(WOBJS) + $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS) + +$(RPNG)$(O): $(RPNG).c readpng.h +$(RPNG2)$(O): $(RPNG2).c readpng2.h +$(WPNG)$(O): $(WPNG).c writepng.h + +readpng$(O): readpng.c readpng.h +readpng2$(O): readpng2.c readpng2.h +writepng$(O): writepng.c writepng.h + + +# maintenance --------------------------------------------------------------- + +clean: + $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.unx b/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.unx new file mode 100644 index 0000000..1a73e03 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.unx @@ -0,0 +1,134 @@ +# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make. +# Greg Roelofs +# Last modified: 2 June 2007 +# +# The programs built by this makefile are described in the book, +# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and +# Associates, 1999). Go buy a copy, eh? Well, OK, it's not +# generally for sale anymore, but it's the thought that counts, +# right? (Hint: http://www.libpng.org/pub/png/book/ ) +# +# Invoke this makefile from a shell prompt in the usual way; for example: +# +# make -f Makefile.unx +# +# This makefile assumes libpng and zlib have already been built or downloaded +# and are installed in /usr/local/{include,lib} or as otherwise indicated by +# the PNG* and Z* macros below. Edit as appropriate--choose only ONE each of +# the PNGINC, PNGLIBd, PNGLIBs, ZINC, ZLIBd and ZLIBs lines. +# +# This makefile builds both dynamically and statically linked executables +# (against libpng and zlib, that is), but that can be changed by modifying +# the "EXES =" line. (You need only one set, but for testing it can be handy +# to have both.) + + +# macros -------------------------------------------------------------------- + +#PNGDIR = /usr/local/lib +#PNGINC = -I/usr/local/include/libpng16 +#PNGLIBd = -L$(PNGDIR) -lpng16 # dynamically linked, installed libpng +#PNGLIBs = $(PNGDIR)/libpng16.a # statically linked, installed libpng +# or: +PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds +#PNGDIR = ../libpng +PNGINC = -I$(PNGDIR) +PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng16 # dynamically linked +PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng + +ZDIR = /usr/local/lib +#ZDIR = /usr/lib64 +ZINC = -I/usr/local/include +ZLIBd = -L$(ZDIR) -lz # dynamically linked against zlib +ZLIBs = $(ZDIR)/libz.a # statically linked against zlib +# or: +#ZDIR = ../zlib +#ZINC = -I$(ZDIR) +#ZLIBd = -Wl,-rpath,$(ZDIR) -L$(ZDIR) -lz # -rpath allows in-place testing +#ZLIBs = $(ZDIR)/libz.a + +#XINC = -I/usr/include # old-style, stock X distributions +#XLIB = -L/usr/lib/X11 -lX11 # (including SGI IRIX) +#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows) +#XLIB = -L/usr/openwin/lib -lX11 +XINC = -I/usr/X11R6/include # new X distributions (X.org, etc.) +XLIB = -L/usr/X11R6/lib -lX11 +#XLIB = -L/usr/X11R6/lib64 -lX11 # e.g., Red Hat on AMD64 + +INCS = $(PNGINC) $(ZINC) $(XINC) +RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm +RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm +WLIBSd = $(PNGLIBd) $(ZLIBd) -lm +WLIBSs = $(PNGLIBs) $(ZLIBs) -lm + +CC = gcc +LD = gcc +RM = rm -f +CPPFLAGS = $(INCS) -DFEATURE_LOOP +CFLAGS = -O -Wall +#CFLAGS = -O -W -Wall -Wextra -pedantic -ansi +# [note that -Wall is a gcc-specific compilation flag ("most warnings on")] +# [-ansi, -pedantic, -Wextra, and -W can also be used] +LDFLAGS = +O = .o +E = + +RPNG = rpng-x +RPNG2 = rpng2-x +WPNG = wpng + +RPNGs = $(RPNG)-static +RPNG2s = $(RPNG2)-static +WPNGs = $(WPNG)-static + +ROBJS = $(RPNG)$(O) readpng$(O) +ROBJS2 = $(RPNG2)$(O) readpng2$(O) +WOBJS = $(WPNG)$(O) writepng$(O) + +STATIC_EXES = $(RPNGs)$(E) $(RPNG2s)$(E) $(WPNGs)$(E) +DYNAMIC_EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) + +EXES = $(STATIC_EXES) $(DYNAMIC_EXES) + + +# implicit make rules ------------------------------------------------------- + +.c$(O): + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< + + +# dependencies -------------------------------------------------------------- + +all: $(EXES) + +$(RPNGs)$(E): $(ROBJS) + $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBSs) + +$(RPNG)$(E): $(ROBJS) + $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBSd) + +$(RPNG2s)$(E): $(ROBJS2) + $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBSs) + +$(RPNG2)$(E): $(ROBJS2) + $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBSd) + +$(WPNGs)$(E): $(WOBJS) + $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBSs) + +$(WPNG)$(E): $(WOBJS) + $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBSd) + +$(RPNG)$(O): $(RPNG).c readpng.h +$(RPNG2)$(O): $(RPNG2).c readpng2.h +$(WPNG)$(O): $(WPNG).c writepng.h + +readpng$(O): readpng.c readpng.h +readpng2$(O): readpng2.c readpng2.h +writepng$(O): writepng.c writepng.h + + +# maintenance --------------------------------------------------------------- + +clean: + $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.w32 b/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.w32 new file mode 100644 index 0000000..ab7dcf7 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/Makefile.w32 @@ -0,0 +1,114 @@ +# Sample makefile for rpng-win / rpng2-win / wpng using MSVC and NMAKE. +# Greg Roelofs +# Last modified: 2 June 2007 +# +# The programs built by this makefile are described in the book, +# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and +# Associates, 1999). Go buy a copy, eh? Well, OK, it's not +# generally for sale anymore, but it's the thought that counts, +# right? (Hint: http://www.libpng.org/pub/png/book/ ) +# +# Invoke this makefile from a DOS prompt window via: +# +# %devstudio%\vc\bin\vcvars32.bat +# nmake -nologo -f Makefile.w32 +# +# where %devstudio% is the installation directory for MSVC / DevStudio. If +# you get "environment out of space" errors, create a desktop shortcut with +# "c:\windows\command.com /e:4096" as the program command line and set the +# working directory to this directory. Then double-click to open the new +# DOS-prompt window with a bigger environment and retry the commands above. +# +# This makefile assumes libpng and zlib have already been built or downloaded +# and are in subdirectories at the same level as the current subdirectory +# (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate. +# +# Note that the names of the dynamic and static libpng and zlib libraries +# used below may change in later releases of the libraries. This makefile +# builds statically linked executables, but that can be changed by uncom- +# menting the appropriate PNGLIB and ZLIB lines. + +!include + + +# macros -------------------------------------------------------------------- + +PNGPATH = ../libpng +PNGINC = -I$(PNGPATH) +#PNGLIB = $(PNGPATH)/pngdll.lib +PNGLIB = $(PNGPATH)/libpng.lib + +ZPATH = ../zlib +ZINC = -I$(ZPATH) +#ZLIB = $(ZPATH)/zlibdll.lib +ZLIB = $(ZPATH)/zlibstat.lib + +WINLIBS = -defaultlib:user32.lib gdi32.lib +# ["real" apps may also need comctl32.lib, comdlg32.lib, winmm.lib, etc.] + +INCS = $(PNGINC) $(ZINC) +RLIBS = $(PNGLIB) $(ZLIB) $(WINLIBS) +WLIBS = $(PNGLIB) $(ZLIB) + +CC = cl +LD = link +RM = del +CPPFLAGS = $(INCS) +CFLAGS = -nologo -O -W3 $(cvars) +# [note that -W3 is an MSVC-specific compilation flag ("all warnings on")] +# [see %devstudio%\vc\include\win32.mak for cvars macro definition] +O = .obj +E = .exe + +RLDFLAGS = -nologo -subsystem:windows +WLDFLAGS = -nologo + +RPNG = rpng-win +RPNG2 = rpng2-win +WPNG = wpng + +ROBJS = $(RPNG)$(O) readpng$(O) +ROBJS2 = $(RPNG2)$(O) readpng2$(O) +WOBJS = $(WPNG)$(O) writepng$(O) + +EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) + + +# implicit make rules ------------------------------------------------------- + +.c$(O): + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< + + +# dependencies -------------------------------------------------------------- + +all: $(EXES) + +$(RPNG)$(E): $(ROBJS) + $(LD) $(RLDFLAGS) -out:$@ $(ROBJS) $(RLIBS) + +$(RPNG2)$(E): $(ROBJS2) + $(LD) $(RLDFLAGS) -out:$@ $(ROBJS2) $(RLIBS) + +$(WPNG)$(E): $(WOBJS) + $(LD) $(WLDFLAGS) -out:$@ $(WOBJS) $(WLIBS) + +$(RPNG)$(O): $(RPNG).c readpng.h +$(RPNG2)$(O): $(RPNG2).c readpng2.h +$(WPNG)$(O): $(WPNG).c writepng.h + +readpng$(O): readpng.c readpng.h +readpng2$(O): readpng2.c readpng2.h +writepng$(O): writepng.c writepng.h + + +# maintenance --------------------------------------------------------------- + +clean: +# ideally we could just do this: +# $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) +# ...but the Windows "DEL" command is none too bright, so: + $(RM) r*$(E) + $(RM) w*$(E) + $(RM) r*$(O) + $(RM) w*$(O) diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/README b/thirdparty/libpng-1.6.37/contrib/gregbook/README new file mode 100644 index 0000000..90e28f7 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/README @@ -0,0 +1,186 @@ + =========================== + PNG: The Definitive Guide + =========================== + + Source Code + +Chapters 13, 14 and 15 of "PNG: The Definitive Guide" discuss three free, +cross-platform demo programs that show how to use the libpng reference +library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is +a very simple example that that shows how a standard file-viewer might use +libpng, while the second is designed to process streaming data and shows +how a web browser might be written. wpng is a simple command-line program +that reads binary PGM and PPM files (the ``raw'' grayscale and RGB subsets +of PBMPLUS/NetPBM) and converts them to PNG. + +The source code for all three demo programs currently compiles under +Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser, +zinser at decus.de, for making the necessary changes for OpenVMS and for +providing an appropriate build script.) Build instructions can be found +below. + +Files: + + README this file + LICENSE terms of distribution and reuse (BSD-like or GNU GPL) + COPYING GNU General Public License (GPL) + + Makefile.unx Unix makefile + Makefile.w32 Windows (MSVC) makefile + makevms.com OpenVMS build script + + rpng-win.c Windows front end for the basic viewer + rpng-x.c X Window System (Unix, OpenVMS) front end + readpng.c generic back end for the basic viewer + readpng.h header file for the basic viewer + + rpng2-win.c Windows front end for the progressive viewer + rpng2-x.c X front end for the progressive viewer + readpng2.c generic back end for the progressive viewer + readpng2.h header file for the progressive viewer + + wpng.c generic (text) front end for the converter + writepng.c generic back end for the converter + writepng.h header file for the converter + + toucan.png transparent PNG for testing (by Stefan Schneider) + +Note that, although the programs are designed to be functional, their +primary purpose is to illustrate how to use libpng to add PNG support to +other programs. As such, their user interfaces are crude and definitely +are not intended for everyday use. + +Please see http://www.libpng.org/pub/png/pngbook.html for further infor- +mation and links to the latest version of the source code, and Chapters +13-15 of the book for detailed discussion of the three programs. + +Greg Roelofs +https://pobox.com/~newt/greg_contact.html +16 March 2008 + + +BUILD INSTRUCTIONS + + - Prerequisites (in order of compilation): + + - zlib https://zlib.net/ + - libpng http://www.libpng.org/pub/png/libpng.html + - pngbook http://www.libpng.org/pub/png/book/sources.html + + The pngbook demo programs are explicitly designed to demonstrate proper + coding techniques for using the libpng reference library. As a result, + you need to download and build both zlib (on which libpng depends) and + libpng. A common build setup is to place the zlib, libpng and pngbook + subdirectory trees ("folders") in the same parent directory. Then the + libpng build can refer to files in ../zlib (or ..\zlib or [-.zlib]), + and similarly for the pngbook build. + + Note that all three packages are designed to be built from a command + line by default; those who wish to use a graphical or other integrated + development environments are on their own. + + + - Unix: + + Unpack the latest pngbook sources (which should correspond to this + README file) into a directory and change into that directory. + + Copy Makefile.unx to Makefile and edit the PNG* and Z* variables + appropriately (possibly also the X* variables if necessary). + + make + + There is no "install" target, so copy the three executables somewhere + in your path or run them from the current directory. All three will + print a basic usage screen when run without any command-line arguments; + see the book for more details. + + + - Windows: + + Unpack the latest pngbook sources (which should correspond to this + README file) into a folder, open a "DOS shell" or "command prompt" + or equivalent command-line window, and cd into the folder where you + unpacked the source code. + + For MSVC, set up the necessary environment variables by invoking + + %devstudio%\vc\bin\vcvars32.bat + + where where %devstudio% is the installation directory for MSVC / + DevStudio. If you get "environment out of space" errors under 95/98, + create a desktop shortcut with "c:\windows\command.com /e:4096" as + the program command line and set the working directory to the pngbook + directory. Then double-click to open the new DOS-prompt window with + a bigger environment and retry the commands above. + + Copy Makefile.w32 to Makefile and edit the PNGPATH and ZPATH variables + appropriately (possibly also the "INC" and "LIB" variables if needed). + Note that the names of the dynamic and static libpng and zlib libraries + used in the makefile may change in later releases of the libraries. + Also note that, as of libpng version 1.0.5, MSVC DLL builds do not work. + This makefile therefore builds statically linked executables, but if + the DLL problems ever get fixed, uncommenting the appropriate PNGLIB + and ZLIB lines will build dynamically linked executables instead. + + Do the build by typing + + nmake + + The result should be three executables: rpng-win.exe, rpng2-win.exe, + and wpng.exe. Copy them somewhere in your PATH or run them from the + current folder. Like the Unix versions, the two windowed programs + (rpng and rpng2) now display a usage screen in a console window when + invoked without command-line arguments; this is new behavior as of + the June 2001 release. Note that the programs use the Unix-style "-" + character to specify options, instead of the more common DOS/Windows + "/" character. (For example: "rpng2-win -bgpat 4 foo.png", not + "rpng2-win /bgpat 4 foo.png") + + + - OpenVMS: + + Unpack the pngbook sources into a subdirectory and change into that + subdirectory. + + Edit makevms.com appropriately, specifically the zpath and pngpath + variables. + + @makevms + + To run the programs, they probably first need to be set up as "foreign + symbols," with "disk" and "dir" set appropriately: + + $ rpng == "$disk:[dir]rpng-x.exe" + $ rpng2 == "$disk:[dir]rpng2-x.exe" + $ wpng == "$disk:[dir]wpng.exe" + + All three will print a basic usage screen when run without any command- + line arguments; see the book for more details. Note that the options + style is Unix-like, i.e., preceded by "-" rather than "/". + + +RUNNING THE PROGRAMS: (VERY) BRIEF INTRO + + rpng is a simple PNG viewer that can display transparent PNGs with a + specified background color; for example, + + rpng -bgcolor \#ff0000 toucan.png + + would display the image with a red background. rpng2 is a progressive + viewer that simulates a web browser in some respects; it can display + images against either a background color or a dynamically generated + background image. For example: + + rpng2 -bgpat 16 toucan.png + + wpng is a purely command-line image converter from binary PBMPLUS/NetPBM + format (.pgm or .ppm) to PNG; for example, + + wpng -time < toucan-notrans.ppm > toucan-notrans.png + + would convert the specified PPM file (using redirection) to PNG, auto- + matically setting the PNG modification-time chunk. + + All options can be abbreviated to the shortest unique value; for example, + "-bgc" for -bgcolor (versus "-bgp" for -bgpat), or "-g" for -gamma. diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/makevms.com b/thirdparty/libpng-1.6.37/contrib/gregbook/makevms.com new file mode 100644 index 0000000..f32bcab --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/makevms.com @@ -0,0 +1,132 @@ +$!------------------------------------------------------------------------------ +$! make "PNG: The Definitive Guide" demo programs (for X) under OpenVMS +$! +$! Script created by Martin Zinser for libpng; modified by Greg Roelofs +$! for standalone pngbook source distribution. +$! +$! +$! Set locations where zlib and libpng sources live. +$! +$ zpath = "" +$ pngpath = "" +$! +$ if f$search("[---.zlib]zlib.h").nes."" then zpath = "[---.zlib]" +$ if f$search("[--]png.h").nes."" then pngpath = "[--]" +$! +$ if f$search("[-.zlib]zlib.h").nes."" then zpath = "[-.zlib]" +$ if f$search("[-.libpng]png.h").nes."" then pngpath = "[-.libpng]" +$! +$ if zpath .eqs. "" +$ then +$ write sys$output "zlib include not found. Exiting..." +$ exit 2 +$ endif +$! +$ if pngpath .eqs. "" +$ then +$ write sys$output "libpng include not found. Exiting..." +$ exit 2 +$ endif +$! +$! Look for the compiler used. +$! +$ ccopt="/include=(''zpath',''pngpath')" +$ if f$getsyi("HW_MODEL").ge.1024 +$ then +$ ccopt = "/prefix=all"+ccopt +$ comp = "__decc__=1" +$ if f$trnlnm("SYS").eqs."" then define sys sys$library: +$ else +$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" +$ then +$ if f$trnlnm("SYS").eqs."" then define sys sys$library: +$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" +$ then +$ comp = "__gcc__=1" +$ CC :== GCC +$ else +$ comp = "__vaxc__=1" +$ endif +$ else +$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: +$ ccopt = "/decc/prefix=all"+ccopt +$ comp = "__decc__=1" +$ endif +$ endif +$ open/write lopt lib.opt +$ write lopt "''pngpath'libpng.olb/lib" +$ write lopt "''zpath'libz.olb/lib" +$ close lopt +$ open/write xopt x11.opt +$ write xopt "sys$library:decw$xlibshr.exe/share" +$ close xopt +$! +$! Build 'em. +$! +$ write sys$output "Compiling PNG book programs ..." +$ CALL MAKE readpng.OBJ "cc ''CCOPT' readpng" - + readpng.c readpng.h +$ CALL MAKE readpng2.OBJ "cc ''CCOPT' readpng2" - + readpng2.c readpng2.h +$ CALL MAKE writepng.OBJ "cc ''CCOPT' writepng" - + writepng.c writepng.h +$ write sys$output "Building rpng-x..." +$ CALL MAKE rpng-x.OBJ "cc ''CCOPT' rpng-x" - + rpng-x.c readpng.h +$ call make rpng-x.exe - + "LINK rpng-x,readpng,lib.opt/opt,x11.opt/opt" - + rpng-x.obj readpng.obj +$ write sys$output "Building rpng2-x..." +$ CALL MAKE rpng2-x.OBJ "cc ''CCOPT' rpng2-x" - + rpng2-x.c readpng2.h +$ call make rpng2-x.exe - + "LINK rpng2-x,readpng2,lib.opt/opt,x11.opt/opt" - + rpng2-x.obj readpng2.obj +$ write sys$output "Building wpng..." +$ CALL MAKE wpng.OBJ "cc ''CCOPT' wpng" - + wpng.c writepng.h +$ call make wpng.exe - + "LINK wpng,writepng,lib.opt/opt" - + wpng.obj writepng.obj +$ exit +$! +$! +$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES +$ V = 'F$Verify(0) +$! P1 = What we are trying to make +$! P2 = Command to make it +$! P3 - P8 What it depends on +$ +$ If F$Search(P1) .Eqs. "" Then Goto Makeit +$ Time = F$CvTime(F$File(P1,"RDT")) +$arg=3 +$Loop: +$ Argument = P'arg +$ If Argument .Eqs. "" Then Goto Exit +$ El=0 +$Loop2: +$ File = F$Element(El," ",Argument) +$ If File .Eqs. " " Then Goto Endl +$ AFile = "" +$Loop3: +$ OFile = AFile +$ AFile = F$Search(File) +$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl +$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit +$ Goto Loop3 +$NextEL: +$ El = El + 1 +$ Goto Loop2 +$EndL: +$ arg=arg+1 +$ If arg .Le. 8 Then Goto Loop +$ Goto Exit +$ +$Makeit: +$ VV=F$VERIFY(0) +$ write sys$output P2 +$ 'P2 +$ VV='F$Verify(VV) +$Exit: +$ If V Then Set Verify +$ENDSUBROUTINE diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/readpng.c b/thirdparty/libpng-1.6.37/contrib/gregbook/readpng.c new file mode 100644 index 0000000..fad9b53 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/readpng.c @@ -0,0 +1,323 @@ +/*--------------------------------------------------------------------------- + + rpng - simple PNG display program readpng.c + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2007,2017 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ---------------------------------------------------------------------------*/ + +#include +#include +#include + +#include "png.h" /* libpng header */ +#include "readpng.h" /* typedefs, common macros, public prototypes */ + +/* future versions of libpng will provide this macro: */ +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#endif + + +static png_structp png_ptr = NULL; +static png_infop info_ptr = NULL; + +png_uint_32 width, height; +int bit_depth, color_type; +uch *image_data = NULL; + + +void readpng_version_info(void) +{ + fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", + PNG_LIBPNG_VER_STRING, png_libpng_ver); + fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", + ZLIB_VERSION, zlib_version); +} + + +/* return value = 0 for success, 1 for bad sig, 2 for bad IHDR, 4 for no mem */ + +int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight) +{ + uch sig[8]; + + + /* first do a quick check that the file really is a PNG image; could + * have used slightly more general png_sig_cmp() function instead */ + + fread(sig, 1, 8, infile); + if (png_sig_cmp(sig, 0, 8)) + return 1; /* bad signature */ + + + /* could pass pointers to user-defined error handlers instead of NULLs: */ + + png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), NULL, NULL, + NULL); + if (!png_ptr) + return 4; /* out of memory */ + + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + png_destroy_read_struct(&png_ptr, NULL, NULL); + return 4; /* out of memory */ + } + + + /* we could create a second info struct here (end_info), but it's only + * useful if we want to keep pre- and post-IDAT chunk info separated + * (mainly for PNG-aware image editors and converters) */ + + + /* setjmp() must be called in every function that calls a PNG-reading + * libpng function */ + + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return 2; + } + + + png_init_io(png_ptr, infile); + png_set_sig_bytes(png_ptr, 8); /* we already read the 8 signature bytes */ + + png_read_info(png_ptr, info_ptr); /* read all PNG info up to image data */ + + + /* alternatively, could make separate calls to png_get_image_width(), + * etc., but want bit_depth and color_type for later [don't care about + * compression_type and filter_type => NULLs] */ + + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, + NULL, NULL, NULL); + *pWidth = width; + *pHeight = height; + + + /* OK, that's all we need for now; return happy */ + + return 0; +} + + + + +/* returns 0 if succeeds, 1 if fails due to no bKGD chunk, 2 if libpng error; + * scales values to 8-bit if necessary */ + +int readpng_get_bgcolor(uch *red, uch *green, uch *blue) +{ + png_color_16p pBackground; + + + /* setjmp() must be called in every function that calls a PNG-reading + * libpng function */ + + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return 2; + } + + + if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) + return 1; + + /* it is not obvious from the libpng documentation, but this function + * takes a pointer to a pointer, and it always returns valid red, green + * and blue values, regardless of color_type: */ + + png_get_bKGD(png_ptr, info_ptr, &pBackground); + + + /* however, it always returns the raw bKGD data, regardless of any + * bit-depth transformations, so check depth and adjust if necessary */ + + if (bit_depth == 16) { + *red = pBackground->red >> 8; + *green = pBackground->green >> 8; + *blue = pBackground->blue >> 8; + } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { + if (bit_depth == 1) + *red = *green = *blue = pBackground->gray? 255 : 0; + else if (bit_depth == 2) + *red = *green = *blue = (255/3) * pBackground->gray; + else /* bit_depth == 4 */ + *red = *green = *blue = (255/15) * pBackground->gray; + } else { + *red = (uch)pBackground->red; + *green = (uch)pBackground->green; + *blue = (uch)pBackground->blue; + } + + return 0; +} + + + + +/* display_exponent == LUT_exponent * CRT_exponent */ + +uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes) +{ + double gamma; + png_uint_32 i, rowbytes; + png_bytepp row_pointers = NULL; + + + /* setjmp() must be called in every function that calls a PNG-reading + * libpng function */ + + if (setjmp(png_jmpbuf(png_ptr))) { + free(image_data); + image_data = NULL; + free(row_pointers); + row_pointers = NULL; + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return NULL; + } + + + /* expand palette images to RGB, low-bit-depth grayscale images to 8 bits, + * transparency chunks to full alpha channel; strip 16-bit-per-sample + * images to 8 bits per sample; and convert grayscale to RGB[A] */ + + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_expand(png_ptr); + if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) + png_set_expand(png_ptr); + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + png_set_expand(png_ptr); +#ifdef PNG_READ_16_TO_8_SUPPORTED + if (bit_depth == 16) +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + png_set_scale_16(png_ptr); +# else + png_set_strip_16(png_ptr); +# endif +#endif + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + + + /* unlike the example in the libpng documentation, we have *no* idea where + * this file may have come from--so if it doesn't have a file gamma, don't + * do any correction ("do no harm") */ + + if (png_get_gAMA(png_ptr, info_ptr, &gamma)) + png_set_gamma(png_ptr, display_exponent, gamma); + + + /* all transformations have been registered; now update info_ptr data, + * get rowbytes and channels, and allocate image memory */ + + png_read_update_info(png_ptr, info_ptr); + + *pRowbytes = rowbytes = png_get_rowbytes(png_ptr, info_ptr); + *pChannels = (int)png_get_channels(png_ptr, info_ptr); + + /* Guard against integer overflow */ + if (height > ((size_t)(-1))/rowbytes) { + fprintf(stderr, "readpng: image_data buffer would be too large\n", + return NULL; + } + + if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return NULL; + } + if ((row_pointers = (png_bytepp)malloc(height*sizeof(png_bytep))) == NULL) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + free(image_data); + image_data = NULL; + return NULL; + } + + Trace((stderr, "readpng_get_image: channels = %d, rowbytes = %ld, height = %ld\n", + *pChannels, rowbytes, height)); + + + /* set the individual row_pointers to point at the correct offsets */ + + for (i = 0; i < height; ++i) + row_pointers[i] = image_data + i*rowbytes; + + + /* now we can go ahead and just read the whole image */ + + png_read_image(png_ptr, row_pointers); + + + /* and we're done! (png_read_end() can be omitted if no processing of + * post-IDAT text/time/etc. is desired) */ + + free(row_pointers); + row_pointers = NULL; + + png_read_end(png_ptr, NULL); + + return image_data; +} + + +void readpng_cleanup(int free_image_data) +{ + if (free_image_data && image_data) { + free(image_data); + image_data = NULL; + } + + if (png_ptr && info_ptr) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + png_ptr = NULL; + info_ptr = NULL; + } +} diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/readpng.h b/thirdparty/libpng-1.6.37/contrib/gregbook/readpng.h new file mode 100644 index 0000000..fad9fe3 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/readpng.h @@ -0,0 +1,88 @@ +/*--------------------------------------------------------------------------- + + rpng - simple PNG display program readpng.h + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ---------------------------------------------------------------------------*/ + +#ifndef TRUE +# define TRUE 1 +# define FALSE 0 +#endif + +#ifndef MAX +# define MAX(a,b) ((a) > (b)? (a) : (b)) +# define MIN(a,b) ((a) < (b)? (a) : (b)) +#endif + +#ifdef DEBUG +# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} +#else +# define Trace(x) ; +#endif + +typedef unsigned char uch; +typedef unsigned short ush; +typedef unsigned long ulg; + + +/* prototypes for public functions in readpng.c */ + +void readpng_version_info(void); + +int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight); + +int readpng_get_bgcolor(uch *bg_red, uch *bg_green, uch *bg_blue); + +uch *readpng_get_image(double display_exponent, int *pChannels, + ulg *pRowbytes); + +void readpng_cleanup(int free_image_data); diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/readpng2.c b/thirdparty/libpng-1.6.37/contrib/gregbook/readpng2.c new file mode 100644 index 0000000..610b3cd --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/readpng2.c @@ -0,0 +1,521 @@ +/*--------------------------------------------------------------------------- + + rpng2 - progressive-model PNG display program readpng2.c + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2015 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + --------------------------------------------------------------------------- + + Changelog: + 2015-11-12 - Check return value of png_get_bKGD() (Glenn R-P) + 2017-04-22 - Guard against integer overflow (Glenn R-P) + + ---------------------------------------------------------------------------*/ + + +#include /* for exit() prototype */ +#include + +#include +#include "png.h" /* libpng header from the local directory */ +#include "readpng2.h" /* typedefs, common macros, public prototypes */ + + +/* local prototypes */ + +static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr); +static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row, + png_uint_32 row_num, int pass); +static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr); +static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg); +static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg); + + + + +void readpng2_version_info(void) +{ + fprintf(stderr, " Compiled with libpng %s; using libpng %s\n", + PNG_LIBPNG_VER_STRING, png_libpng_ver); + + fprintf(stderr, " and with zlib %s; using zlib %s.\n", + ZLIB_VERSION, zlib_version); +} + + + + +int readpng2_check_sig(uch *sig, int num) +{ + return !png_sig_cmp(sig, 0, num); +} + + + + +/* returns 0 for success, 2 for libpng problem, 4 for out of memory */ + +int readpng2_init(mainprog_info *mainprog_ptr) +{ + png_structp png_ptr; /* note: temporary variables! */ + png_infop info_ptr; + + + /* could also replace libpng warning-handler (final NULL), but no need: */ + + png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), mainprog_ptr, + readpng2_error_handler, readpng2_warning_handler); + if (!png_ptr) + return 4; /* out of memory */ + + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + png_destroy_read_struct(&png_ptr, NULL, NULL); + return 4; /* out of memory */ + } + + + /* we could create a second info struct here (end_info), but it's only + * useful if we want to keep pre- and post-IDAT chunk info separated + * (mainly for PNG-aware image editors and converters) */ + + + /* setjmp() must be called in every function that calls a PNG-reading + * libpng function, unless an alternate error handler was installed-- + * but compatible error handlers must either use longjmp() themselves + * (as in this program) or exit immediately, so here we are: */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return 2; + } + + +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + /* prepare the reader to ignore all recognized chunks whose data won't be + * used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT, + * IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */ + { + /* These byte strings were copied from png.h. If a future version + * of readpng2.c recognizes more chunks, add them to this list. + */ + static const png_byte chunks_to_process[] = { + 98, 75, 71, 68, '\0', /* bKGD */ + 103, 65, 77, 65, '\0', /* gAMA */ + 115, 82, 71, 66, '\0', /* sRGB */ + }; + + /* Ignore all chunks except for IHDR, PLTE, tRNS, IDAT, and IEND */ + png_set_keep_unknown_chunks(png_ptr, -1 /* PNG_HANDLE_CHUNK_NEVER */, + NULL, -1); + + /* But do not ignore chunks in the "chunks_to_process" list */ + png_set_keep_unknown_chunks(png_ptr, + 0 /* PNG_HANDLE_CHUNK_AS_DEFAULT */, chunks_to_process, + sizeof(chunks_to_process)/5); + } +#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */ + + + /* instead of doing png_init_io() here, now we set up our callback + * functions for progressive decoding */ + + png_set_progressive_read_fn(png_ptr, mainprog_ptr, + readpng2_info_callback, readpng2_row_callback, readpng2_end_callback); + + + /* make sure we save our pointers for use in readpng2_decode_data() */ + + mainprog_ptr->png_ptr = png_ptr; + mainprog_ptr->info_ptr = info_ptr; + + + /* and that's all there is to initialization */ + + return 0; +} + + + + +/* returns 0 for success, 2 for libpng (longjmp) problem */ + +int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length) +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + + /* setjmp() must be called in every function that calls a PNG-reading + * libpng function */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + mainprog_ptr->png_ptr = NULL; + mainprog_ptr->info_ptr = NULL; + return 2; + } + + + /* hand off the next chunk of input data to libpng for decoding */ + + png_process_data(png_ptr, info_ptr, rawbuf, length); + + return 0; +} + + + + +static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr) +{ + mainprog_info *mainprog_ptr; + int color_type, bit_depth; + png_uint_32 width, height; +#ifdef PNG_FLOATING_POINT_SUPPORTED + double gamma; +#else + png_fixed_point gamma; +#endif + + + /* setjmp() doesn't make sense here, because we'd either have to exit(), + * longjmp() ourselves, or return control to libpng, which doesn't want + * to see us again. By not doing anything here, libpng will instead jump + * to readpng2_decode_data(), which can return an error value to the main + * program. */ + + + /* retrieve the pointer to our special-purpose struct, using the png_ptr + * that libpng passed back to us (i.e., not a global this time--there's + * no real difference for a single image, but for a multithreaded browser + * decoding several PNG images at the same time, one needs to avoid mixing + * up different images' structs) */ + + mainprog_ptr = png_get_progressive_ptr(png_ptr); + + if (mainprog_ptr == NULL) { /* we be hosed */ + fprintf(stderr, + "readpng2 error: main struct not recoverable in info_callback.\n"); + fflush(stderr); + return; + /* + * Alternatively, we could call our error-handler just like libpng + * does, which would effectively terminate the program. Since this + * can only happen if png_ptr gets redirected somewhere odd or the + * main PNG struct gets wiped, we're probably toast anyway. (If + * png_ptr itself is NULL, we would not have been called.) + */ + } + + + /* this is just like in the non-progressive case */ + + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, + NULL, NULL, NULL); + mainprog_ptr->width = (ulg)width; + mainprog_ptr->height = (ulg)height; + + + /* since we know we've read all of the PNG file's "header" (i.e., up + * to IDAT), we can check for a background color here */ + + if (mainprog_ptr->need_bgcolor) + { + png_color_16p pBackground; + + /* it is not obvious from the libpng documentation, but this function + * takes a pointer to a pointer, and it always returns valid red, + * green and blue values, regardless of color_type: */ + if (png_get_bKGD(png_ptr, info_ptr, &pBackground)) + { + + /* however, it always returns the raw bKGD data, regardless of any + * bit-depth transformations, so check depth and adjust if necessary + */ + if (bit_depth == 16) { + mainprog_ptr->bg_red = pBackground->red >> 8; + mainprog_ptr->bg_green = pBackground->green >> 8; + mainprog_ptr->bg_blue = pBackground->blue >> 8; + } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { + if (bit_depth == 1) + mainprog_ptr->bg_red = mainprog_ptr->bg_green = + mainprog_ptr->bg_blue = pBackground->gray? 255 : 0; + else if (bit_depth == 2) + mainprog_ptr->bg_red = mainprog_ptr->bg_green = + mainprog_ptr->bg_blue = (255/3) * pBackground->gray; + else /* bit_depth == 4 */ + mainprog_ptr->bg_red = mainprog_ptr->bg_green = + mainprog_ptr->bg_blue = (255/15) * pBackground->gray; + } else { + mainprog_ptr->bg_red = (uch)pBackground->red; + mainprog_ptr->bg_green = (uch)pBackground->green; + mainprog_ptr->bg_blue = (uch)pBackground->blue; + } + } + } + + + /* as before, let libpng expand palette images to RGB, low-bit-depth + * grayscale images to 8 bits, transparency chunks to full alpha channel; + * strip 16-bit-per-sample images to 8 bits per sample; and convert + * grayscale to RGB[A] */ + + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_expand(png_ptr); + if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) + png_set_expand(png_ptr); + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + png_set_expand(png_ptr); +#ifdef PNG_READ_16_TO_8_SUPPORTED + if (bit_depth == 16) +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + png_set_scale_16(png_ptr); +# else + png_set_strip_16(png_ptr); +# endif +#endif + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + + + /* Unlike the basic viewer, which was designed to operate on local files, + * this program is intended to simulate a web browser--even though we + * actually read from a local file, too. But because we are pretending + * that most of the images originate on the Internet, we follow the recom- + * mendation of the sRGB proposal and treat unlabelled images (no gAMA + * chunk) as existing in the sRGB color space. That is, we assume that + * such images have a file gamma of 0.45455, which corresponds to a PC-like + * display system. This change in assumptions will have no effect on a + * PC-like system, but on a Mac, SGI, NeXT or other system with a non- + * identity lookup table, it will darken unlabelled images, which effec- + * tively favors images from PC-like systems over those originating on + * the local platform. Note that mainprog_ptr->display_exponent is the + * "gamma" value for the entire display system, i.e., the product of + * LUT_exponent and CRT_exponent. */ + +#ifdef PNG_FLOATING_POINT_SUPPORTED + if (png_get_gAMA(png_ptr, info_ptr, &gamma)) + png_set_gamma(png_ptr, mainprog_ptr->display_exponent, gamma); + else + png_set_gamma(png_ptr, mainprog_ptr->display_exponent, 0.45455); +#else + if (png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) + png_set_gamma_fixed(png_ptr, + (png_fixed_point)(100000*mainprog_ptr->display_exponent+.5), gamma); + else + png_set_gamma_fixed(png_ptr, + (png_fixed_point)(100000*mainprog_ptr->display_exponent+.5), 45455); +#endif + + /* we'll let libpng expand interlaced images, too */ + + mainprog_ptr->passes = png_set_interlace_handling(png_ptr); + + + /* all transformations have been registered; now update info_ptr data and + * then get rowbytes and channels */ + + png_read_update_info(png_ptr, info_ptr); + + mainprog_ptr->rowbytes = (int)png_get_rowbytes(png_ptr, info_ptr); + mainprog_ptr->channels = png_get_channels(png_ptr, info_ptr); + + + /* Call the main program to allocate memory for the image buffer and + * initialize windows and whatnot. (The old-style function-pointer + * invocation is used for compatibility with a few supposedly ANSI + * compilers that nevertheless barf on "fn_ptr()"-style syntax.) */ + + (*mainprog_ptr->mainprog_init)(); + + + /* and that takes care of initialization */ + + return; +} + + + + + +static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row, + png_uint_32 row_num, int pass) +{ + mainprog_info *mainprog_ptr; + + + /* first check whether the row differs from the previous pass; if not, + * nothing to combine or display */ + + if (!new_row) + return; + + + /* retrieve the pointer to our special-purpose struct so we can access + * the old rows and image-display callback function */ + + mainprog_ptr = png_get_progressive_ptr(png_ptr); + + + /* save the pass number for optional use by the front end */ + + mainprog_ptr->pass = pass; + + + /* have libpng either combine the new row data with the existing row data + * from previous passes (if interlaced) or else just copy the new row + * into the main program's image buffer */ + + png_progressive_combine_row(png_ptr, mainprog_ptr->row_pointers[row_num], + new_row); + + + /* finally, call the display routine in the main program with the number + * of the row we just updated */ + + (*mainprog_ptr->mainprog_display_row)(row_num); + + + /* and we're ready for more */ + + return; +} + + + + + +static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr) +{ + mainprog_info *mainprog_ptr; + + + /* retrieve the pointer to our special-purpose struct */ + + mainprog_ptr = png_get_progressive_ptr(png_ptr); + + + /* let the main program know that it should flush any buffered image + * data to the display now and set a "done" flag or whatever, but note + * that it SHOULD NOT DESTROY THE PNG STRUCTS YET--in other words, do + * NOT call readpng2_cleanup() either here or in the finish_display() + * routine; wait until control returns to the main program via + * readpng2_decode_data() */ + + (*mainprog_ptr->mainprog_finish_display)(); + + + /* all done */ + + (void)info_ptr; /* Unused */ + + return; +} + + + + + +void readpng2_cleanup(mainprog_info *mainprog_ptr) +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + if (png_ptr && info_ptr) + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + + mainprog_ptr->png_ptr = NULL; + mainprog_ptr->info_ptr = NULL; +} + + +static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg) +{ + fprintf(stderr, "readpng2 libpng warning: %s\n", msg); + fflush(stderr); + (void)png_ptr; /* Unused */ +} + + +static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg) +{ + mainprog_info *mainprog_ptr; + + /* This function, aside from the extra step of retrieving the "error + * pointer" (below) and the fact that it exists within the application + * rather than within libpng, is essentially identical to libpng's + * default error handler. The second point is critical: since both + * setjmp() and longjmp() are called from the same code, they are + * guaranteed to have compatible notions of how big a jmp_buf is, + * regardless of whether _BSD_SOURCE or anything else has (or has not) + * been defined. */ + + fprintf(stderr, "readpng2 libpng error: %s\n", msg); + fflush(stderr); + + mainprog_ptr = png_get_error_ptr(png_ptr); + if (mainprog_ptr == NULL) { /* we are completely hosed now */ + fprintf(stderr, + "readpng2 severe error: jmpbuf not recoverable; terminating.\n"); + fflush(stderr); + exit(99); + } + + /* Now we have our data structure we can use the information in it + * to return control to our own higher level code (all the points + * where 'setjmp' is called in this file.) This will work with other + * error handling mechanisms as well - libpng always calls png_error + * when it can proceed no further, thus, so long as the error handler + * is intercepted, application code can do its own error recovery. + */ + longjmp(mainprog_ptr->jmpbuf, 1); +} diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/readpng2.h b/thirdparty/libpng-1.6.37/contrib/gregbook/readpng2.h new file mode 100644 index 0000000..6b3660d --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/readpng2.h @@ -0,0 +1,116 @@ +/*--------------------------------------------------------------------------- + + rpng2 - progressive-model PNG display program readpng2.h + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2008 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ---------------------------------------------------------------------------*/ + +#ifndef TRUE +# define TRUE 1 +# define FALSE 0 +#endif + +#ifndef MAX +# define MAX(a,b) ((a) > (b)? (a) : (b)) +# define MIN(a,b) ((a) < (b)? (a) : (b)) +#endif + +#ifdef DEBUG +# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} +#else +# define Trace(x) ; +#endif + +enum rpng2_states { + kPreInit = 0, + kWindowInit, + kDone +}; + +typedef unsigned char uch; +typedef unsigned short ush; +typedef unsigned long ulg; + +typedef struct _mainprog_info { + double display_exponent; + ulg width; + ulg height; + void *png_ptr; + void *info_ptr; + void (*mainprog_init)(void); + void (*mainprog_display_row)(ulg row_num); + void (*mainprog_finish_display)(void); + uch *image_data; + uch **row_pointers; + jmp_buf jmpbuf; + int passes; /* not used */ + int pass; + int rowbytes; + int channels; + int need_bgcolor; + int state; + uch bg_red; + uch bg_green; + uch bg_blue; +} mainprog_info; + + +/* prototypes for public functions in readpng2.c */ + +void readpng2_version_info(void); + +int readpng2_check_sig(uch *sig, int num); + +int readpng2_init(mainprog_info *mainprog_ptr); + +int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length); + +void readpng2_cleanup(mainprog_info *mainprog_ptr); diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/readppm.c b/thirdparty/libpng-1.6.37/contrib/gregbook/readppm.c new file mode 100644 index 0000000..52e7027 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/readppm.c @@ -0,0 +1,188 @@ +/*--------------------------------------------------------------------------- + + rpng - simple PNG display program readppm.c + + --------------------------------------------------------------------------- + + This is a special-purpose replacement for readpng.c that allows binary + PPM files to be used in place of PNG images. + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2007,2017 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ---------------------------------------------------------------------------*/ + +#include +#include + +#include "readpng.h" /* typedefs, common macros, public prototypes */ + + +ulg width, height; +int bit_depth, color_type, channels; +uch *image_data = NULL; +FILE *saved_infile; + + +void readpng_version_info() +{ + fprintf(stderr, " Compiled without libpng, zlib or PBMPLUS/NetPBM.\n"); +} + + +/* return value = 0 for success, 1 for bad sig, 2 for bad IHDR, 4 for no mem */ + +int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight) +{ + static uch ppmline[256]; + int maxval; + + + saved_infile = infile; + + fgets(ppmline, 256, infile); + if (ppmline[0] != 'P' || ppmline[1] != '6') { + fprintf(stderr, "ERROR: not a PPM file\n"); + return 1; + } + /* possible color types: P5 = grayscale (0), P6 = RGB (2), P8 = RGBA (6) */ + if (ppmline[1] == '6') { + color_type = 2; + channels = 3; + } else if (ppmline[1] == '8') { + color_type = 6; + channels = 4; + } else /* if (ppmline[1] == '5') */ { + color_type = 0; + channels = 1; + } + + do { + fgets(ppmline, 256, infile); + } while (ppmline[0] == '#'); + sscanf(ppmline, "%lu %lu", &width, &height); + + do { + fgets(ppmline, 256, infile); + } while (ppmline[0] == '#'); + sscanf(ppmline, "%d", &maxval); + if (maxval != 255) { + fprintf(stderr, "ERROR: maxval = %d\n", maxval); + return 2; + } + bit_depth = 8; + + *pWidth = width; + *pHeight = height; + + return 0; +} + + + + +/* returns 0 if succeeds, 1 if fails due to no bKGD chunk, 2 if libpng error; + * scales values to 8-bit if necessary */ + +int readpng_get_bgcolor(uch *red, uch *green, uch *blue) +{ + return 1; +} + + + + +/* display_exponent == LUT_exponent * CRT_exponent */ + +uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes) +{ + ulg rowbytes; + + + /* expand palette images to RGB, low-bit-depth grayscale images to 8 bits, + * transparency chunks to full alpha channel; strip 16-bit-per-sample + * images to 8 bits per sample; and convert grayscale to RGB[A] */ + + /* GRR WARNING: grayscale needs to be expanded and channels reset! */ + + *pRowbytes = rowbytes = channels*width; + *pChannels = channels; + + Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height)); + + /* Guard against integer overflow */ + if (height > ((size_t)(-1))/rowbytes) { + fprintf(stderr, PROGNAME ": image_data buffer would be too large\n", + return NULL; + } + + if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) { + return NULL; + } + + /* now we can go ahead and just read the whole image */ + + if (fread(image_data, 1L, rowbytes*height, saved_infile) < + rowbytes*height) { + free (image_data); + image_data = NULL; + return NULL; + } + + return image_data; +} + + +void readpng_cleanup(int free_image_data) +{ + if (free_image_data && image_data) { + free(image_data); + image_data = NULL; + } +} diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/rpng-win.c b/thirdparty/libpng-1.6.37/contrib/gregbook/rpng-win.c new file mode 100644 index 0000000..1a6f876 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/rpng-win.c @@ -0,0 +1,735 @@ +/*--------------------------------------------------------------------------- + + rpng - simple PNG display program rpng-win.c + + This program decodes and displays PNG images, with gamma correction and + optionally with a user-specified background color (in case the image has + transparency). It is very nearly the most basic PNG viewer possible. + This version is for 32-bit Windows; it may compile under 16-bit Windows + with a little tweaking (or maybe not). + + to do: + - handle quoted command-line args (especially filenames with spaces) + - have minimum window width: oh well + - use %.1023s to simplify truncation of title-bar string? + + --------------------------------------------------------------------------- + + Changelog: + - 1.00: initial public release + - 1.01: modified to allow abbreviated options; fixed long/ulong mis- + match; switched to png_jmpbuf() macro + - 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed + command-line parsing bug + - 1.10: enabled "message window"/console (thanks to David Geldreich) + - 2.00: dual-licensed (added GNU GPL) + - 2.01: fixed improper display of usage screen on PNG error(s) + - 2.02: check for integer overflow (Glenn R-P) + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ---------------------------------------------------------------------------*/ + +#define PROGNAME "rpng-win" +#define LONGNAME "Simple PNG Viewer for Windows" +#define VERSION "2.01 of 16 March 2008" + +#include +#include +#include +#include +#include +#ifdef __CYGWIN__ +/* getch replacement. Turns out, we don't really need this, + * but leave it here if we ever enable any of the uses of + * _getch in the main code + */ +#include +#include +#include +int repl_getch( void ) +{ + char ch; + int fd = fileno(stdin); + struct termio old_tty, new_tty; + + ioctl(fd, TCGETA, &old_tty); + new_tty = old_tty; + new_tty.c_lflag &= ~(ICANON | ECHO | ISIG); + ioctl(fd, TCSETA, &new_tty); + fread(&ch, 1, sizeof(ch), stdin); + ioctl(fd, TCSETA, &old_tty); + + return ch; +} +#define _getch repl_getch +#else +#include /* only for _getch() */ +#endif + +/* #define DEBUG : this enables the Trace() macros */ + +#include "readpng.h" /* typedefs, common macros, readpng prototypes */ + + +/* could just include png.h, but this macro is the only thing we need + * (name and typedefs changed to local versions); note that side effects + * only happen with alpha (which could easily be avoided with + * "ush acopy = (alpha);") */ + +#define alpha_composite(composite, fg, alpha, bg) { \ + ush temp = ((ush)(fg)*(ush)(alpha) + \ + (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \ + (composite) = (uch)((temp + (temp >> 8)) >> 8); \ +} + + +/* local prototypes */ +static int rpng_win_create_window(HINSTANCE hInst, int showmode); +static int rpng_win_display_image(void); +static void rpng_win_cleanup(void); +LRESULT CALLBACK rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM); + + +static char titlebar[1024]; +static char *progname = PROGNAME; +static char *appname = LONGNAME; +static char *filename; +static FILE *infile; + +static char *bgstr; +static uch bg_red=0, bg_green=0, bg_blue=0; + +static double display_exponent; + +static ulg image_width, image_height, image_rowbytes; +static int image_channels; +static uch *image_data; + +/* Windows-specific variables */ +static ulg wimage_rowbytes; +static uch *dib; +static uch *wimage_data; +static BITMAPINFOHEADER *bmih; + +static HWND global_hwnd; + + + + +int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) +{ + char *args[1024]; /* arbitrary limit, but should suffice */ + char *p, *q, **argv = args; + int argc = 0; + int rc, alen, flen; + int error = 0; + int have_bg = FALSE; + double LUT_exponent; /* just the lookup table */ + double CRT_exponent = 2.2; /* just the monitor */ + double default_display_exponent; /* whole display system */ + MSG msg; + + + filename = (char *)NULL; + +#ifndef __CYGWIN__ + /* First reenable console output, which normally goes to the bit bucket + * for windowed apps. Closing the console window will terminate the + * app. Thanks to David.Geldreich at realviz.com for supplying the magical + * incantation. */ + + AllocConsole(); + freopen("CONOUT$", "a", stderr); + freopen("CONOUT$", "a", stdout); +#endif + + + /* Next set the default value for our display-system exponent, i.e., + * the product of the CRT exponent and the exponent corresponding to + * the frame-buffer's lookup table (LUT), if any. This is not an + * exhaustive list of LUT values (e.g., OpenStep has a lot of weird + * ones), but it should cover 99% of the current possibilities. And + * yes, these ifdefs are completely wasted in a Windows program... */ + +#if defined(NeXT) + LUT_exponent = 1.0 / 2.2; + /* + if (some_next_function_that_returns_gamma(&next_gamma)) + LUT_exponent = 1.0 / next_gamma; + */ +#elif defined(sgi) + LUT_exponent = 1.0 / 1.7; + /* there doesn't seem to be any documented function to get the + * "gamma" value, so we do it the hard way */ + infile = fopen("/etc/config/system.glGammaVal", "r"); + if (infile) { + double sgi_gamma; + + fgets(tmpline, 80, infile); + fclose(infile); + sgi_gamma = atof(tmpline); + if (sgi_gamma > 0.0) + LUT_exponent = 1.0 / sgi_gamma; + } +#elif defined(Macintosh) + LUT_exponent = 1.8 / 2.61; + /* + if (some_mac_function_that_returns_gamma(&mac_gamma)) + LUT_exponent = mac_gamma / 2.61; + */ +#else + LUT_exponent = 1.0; /* assume no LUT: most PCs */ +#endif + + /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ + default_display_exponent = LUT_exponent * CRT_exponent; + + + /* If the user has set the SCREEN_GAMMA environment variable as suggested + * (somewhat imprecisely) in the libpng documentation, use that; otherwise + * use the default value we just calculated. Either way, the user may + * override this via a command-line option. */ + + if ((p = getenv("SCREEN_GAMMA")) != NULL) + display_exponent = atof(p); + else + display_exponent = default_display_exponent; + + + /* Windows really hates command lines, so we have to set up our own argv. + * Note that we do NOT bother with quoted arguments here, so don't use + * filenames with spaces in 'em! */ + + argv[argc++] = PROGNAME; + p = cmd; + for (;;) { + if (*p == ' ') + while (*++p == ' ') + ; + /* now p points at the first non-space after some spaces */ + if (*p == '\0') + break; /* nothing after the spaces: done */ + argv[argc++] = q = p; + while (*q && *q != ' ') + ++q; + /* now q points at a space or the end of the string */ + if (*q == '\0') + break; /* last argv already terminated; quit */ + *q = '\0'; /* change space to terminator */ + p = q + 1; + } + argv[argc] = NULL; /* terminate the argv array itself */ + + + /* Now parse the command line for options and the PNG filename. */ + + while (*++argv && !error) { + if (!strncmp(*argv, "-gamma", 2)) { + if (!*++argv) + ++error; + else { + display_exponent = atof(*argv); + if (display_exponent <= 0.0) + ++error; + } + } else if (!strncmp(*argv, "-bgcolor", 2)) { + if (!*++argv) + ++error; + else { + bgstr = *argv; + if (strlen(bgstr) != 7 || bgstr[0] != '#') + ++error; + else + have_bg = TRUE; + } + } else { + if (**argv != '-') { + filename = *argv; + if (argv[1]) /* shouldn't be any more args after filename */ + ++error; + } else + ++error; /* not expecting any other options */ + } + } + + if (!filename) + ++error; + + + /* print usage screen if any errors up to this point */ + + if (error) { +#ifndef __CYGWIN__ + int ch; +#endif + + fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); + readpng_version_info(); + fprintf(stderr, "\n" + "Usage: %s [-gamma exp] [-bgcolor bg] file.png\n" + " exp \ttransfer-function exponent (``gamma'') of the display\n" + "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" + "\t\t to the product of the lookup-table exponent (varies)\n" + "\t\t and the CRT exponent (usually 2.2); must be positive\n" + " bg \tdesired background color in 7-character hex RGB format\n" + "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" + "\t\t used with transparent images\n" + "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" +#ifndef __CYGWIN__ + "Press Q or Esc to quit this usage screen.\n" +#endif + "\n", PROGNAME, default_display_exponent); +#ifndef __CYGWIN__ + do + ch = _getch(); + while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif + exit(1); + } + + + if (!(infile = fopen(filename, "rb"))) { + fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); + ++error; + } else { + if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) { + switch (rc) { + case 1: + fprintf(stderr, PROGNAME + ": [%s] is not a PNG file: incorrect signature\n", + filename); + break; + case 2: + fprintf(stderr, PROGNAME + ": [%s] has bad IHDR (libpng longjmp)\n", filename); + break; + case 4: + fprintf(stderr, PROGNAME ": insufficient memory\n"); + break; + default: + fprintf(stderr, PROGNAME + ": unknown readpng_init() error\n"); + break; + } + ++error; + } + if (error) + fclose(infile); + } + + + if (error) { +#ifndef __CYGWIN__ + int ch; +#endif + + fprintf(stderr, PROGNAME ": aborting.\n"); +#ifndef __CYGWIN__ + do + ch = _getch(); + while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif + exit(2); + } else { + fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); +#ifndef __CYGWIN__ + fprintf(stderr, + "\n [console window: closing this window will terminate %s]\n\n", + PROGNAME); +#endif + } + + + /* set the title-bar string, but make sure buffer doesn't overflow */ + + alen = strlen(appname); + flen = strlen(filename); + if (alen + flen + 3 > 1023) + sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); + else + sprintf(titlebar, "%s: %s", appname, filename); + + + /* if the user didn't specify a background color on the command line, + * check for one in the PNG file--if not, the initialized values of 0 + * (black) will be used */ + + if (have_bg) { + unsigned r, g, b; /* this approach quiets compiler warnings */ + + sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); + bg_red = (uch)r; + bg_green = (uch)g; + bg_blue = (uch)b; + } else if (readpng_get_bgcolor(&bg_red, &bg_green, &bg_blue) > 1) { + readpng_cleanup(TRUE); + fprintf(stderr, PROGNAME + ": libpng error while checking for background color\n"); + exit(2); + } + + + /* do the basic Windows initialization stuff, make the window and fill it + * with the background color */ + + if (rpng_win_create_window(hInst, showmode)) + exit(2); + + + /* decode the image, all at once */ + + Trace((stderr, "calling readpng_get_image()\n")) + image_data = readpng_get_image(display_exponent, &image_channels, + &image_rowbytes); + Trace((stderr, "done with readpng_get_image()\n")) + + + /* done with PNG file, so clean up to minimize memory usage (but do NOT + * nuke image_data!) */ + + readpng_cleanup(FALSE); + fclose(infile); + + if (!image_data) { + fprintf(stderr, PROGNAME ": unable to decode PNG image\n"); + exit(3); + } + + + /* display image (composite with background if requested) */ + + Trace((stderr, "calling rpng_win_display_image()\n")) + if (rpng_win_display_image()) { + free(image_data); + exit(4); + } + Trace((stderr, "done with rpng_win_display_image()\n")) + + + /* wait for the user to tell us when to quit */ + + printf( +#ifndef __CYGWIN__ + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n" +#else + "Done. Press mouse button 1 (within image window) to quit.\n" +#endif + ); + fflush(stdout); + + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + + /* OK, we're done: clean up all image and Windows resources and go away */ + + rpng_win_cleanup(); + + return msg.wParam; +} + + + + + +static int rpng_win_create_window(HINSTANCE hInst, int showmode) +{ + uch *dest; + int extra_width, extra_height; + ulg i, j; + WNDCLASSEX wndclass; + + +/*--------------------------------------------------------------------------- + Allocate memory for the display-specific version of the image (round up + to multiple of 4 for Windows DIB). + ---------------------------------------------------------------------------*/ + + wimage_rowbytes = ((3*image_width + 3L) >> 2) << 2; + + /* Guard against integer overflow */ + if (image_height > ((size_t)(-1))/wimage_rowbytes) { + fprintf(stderr, PROGNAME ": image_data buffer would be too large\n"); + return 4; /* fail */ + } + + if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) + + wimage_rowbytes*image_height))) + { + return 4; /* fail */ + } + +/*--------------------------------------------------------------------------- + Initialize the DIB. Negative height means to use top-down BMP ordering + (must be uncompressed, but that's what we want). Bit count of 1, 4 or 8 + implies a colormap of RGBX quads, but 24-bit BMPs just use B,G,R values + directly => wimage_data begins immediately after BMP header. + ---------------------------------------------------------------------------*/ + + memset(dib, 0, sizeof(BITMAPINFOHEADER)); + bmih = (BITMAPINFOHEADER *)dib; + bmih->biSize = sizeof(BITMAPINFOHEADER); + bmih->biWidth = image_width; + bmih->biHeight = -((long)image_height); + bmih->biPlanes = 1; + bmih->biBitCount = 24; + bmih->biCompression = 0; + wimage_data = dib + sizeof(BITMAPINFOHEADER); + +/*--------------------------------------------------------------------------- + Fill in background color (black by default); data are in BGR order. + ---------------------------------------------------------------------------*/ + + for (j = 0; j < image_height; ++j) { + dest = wimage_data + j*wimage_rowbytes; + for (i = image_width; i > 0; --i) { + *dest++ = bg_blue; + *dest++ = bg_green; + *dest++ = bg_red; + } + } + +/*--------------------------------------------------------------------------- + Set the window parameters. + ---------------------------------------------------------------------------*/ + + memset(&wndclass, 0, sizeof(wndclass)); + + wndclass.cbSize = sizeof(wndclass); + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = rpng_win_wndproc; + wndclass.hInstance = hInst; + wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = progname; + wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + + RegisterClassEx(&wndclass); + +/*--------------------------------------------------------------------------- + Finally, create the window. + ---------------------------------------------------------------------------*/ + + extra_width = 2*(GetSystemMetrics(SM_CXBORDER) + + GetSystemMetrics(SM_CXDLGFRAME)); + extra_height = 2*(GetSystemMetrics(SM_CYBORDER) + + GetSystemMetrics(SM_CYDLGFRAME)) + + GetSystemMetrics(SM_CYCAPTION); + + global_hwnd = CreateWindow(progname, titlebar, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, image_width+extra_width, + image_height+extra_height, NULL, NULL, hInst, NULL); + + ShowWindow(global_hwnd, showmode); + UpdateWindow(global_hwnd); + + return 0; + +} /* end function rpng_win_create_window() */ + + + + + +static int rpng_win_display_image() +{ + uch *src, *dest; + uch r, g, b, a; + ulg i, row, lastrow; + RECT rect; + + + Trace((stderr, "beginning display loop (image_channels == %d)\n", + image_channels)) + Trace((stderr, "(width = %ld, rowbytes = %ld, wimage_rowbytes = %d)\n", + image_width, image_rowbytes, wimage_rowbytes)) + + +/*--------------------------------------------------------------------------- + Blast image data to buffer. This whole routine takes place before the + message loop begins, so there's no real point in any pseudo-progressive + display... + ---------------------------------------------------------------------------*/ + + for (lastrow = row = 0; row < image_height; ++row) { + src = image_data + row*image_rowbytes; + dest = wimage_data + row*wimage_rowbytes; + if (image_channels == 3) { + for (i = image_width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + *dest++ = b; + *dest++ = g; /* note reverse order */ + *dest++ = r; + } + } else /* if (image_channels == 4) */ { + for (i = image_width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (a == 255) { + *dest++ = b; + *dest++ = g; + *dest++ = r; + } else if (a == 0) { + *dest++ = bg_blue; + *dest++ = bg_green; + *dest++ = bg_red; + } else { + /* this macro (copied from png.h) composites the + * foreground and background values and puts the + * result into the first argument; there are no + * side effects with the first argument */ + alpha_composite(*dest++, b, a, bg_blue); + alpha_composite(*dest++, g, a, bg_green); + alpha_composite(*dest++, r, a, bg_red); + } + } + } + /* display after every 16 lines */ + if (((row+1) & 0xf) == 0) { + rect.left = 0L; + rect.top = (LONG)lastrow; + rect.right = (LONG)image_width; /* possibly off by one? */ + rect.bottom = (LONG)lastrow + 16L; /* possibly off by one? */ + InvalidateRect(global_hwnd, &rect, FALSE); + UpdateWindow(global_hwnd); /* similar to XFlush() */ + lastrow = row + 1; + } + } + + Trace((stderr, "calling final image-flush routine\n")) + if (lastrow < image_height) { + rect.left = 0L; + rect.top = (LONG)lastrow; + rect.right = (LONG)image_width; /* possibly off by one? */ + rect.bottom = (LONG)image_height; /* possibly off by one? */ + InvalidateRect(global_hwnd, &rect, FALSE); + UpdateWindow(global_hwnd); /* similar to XFlush() */ + } + +/* + last param determines whether or not background is wiped before paint + InvalidateRect(global_hwnd, NULL, TRUE); + UpdateWindow(global_hwnd); + */ + + return 0; +} + + + + + +static void rpng_win_cleanup() +{ + if (image_data) { + free(image_data); + image_data = NULL; + } + + if (dib) { + free(dib); + dib = NULL; + } +} + + + + + +LRESULT CALLBACK rpng_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP) +{ + HDC hdc; + PAINTSTRUCT ps; + int rc; + + switch (iMsg) { + case WM_CREATE: + /* one-time processing here, if any */ + return 0; + + case WM_PAINT: + hdc = BeginPaint(hwnd, &ps); + /* dest */ + rc = StretchDIBits(hdc, 0, 0, image_width, image_height, + /* source */ + 0, 0, image_width, image_height, + wimage_data, (BITMAPINFO *)bmih, + /* iUsage: no clue */ + 0, SRCCOPY); + EndPaint(hwnd, &ps); + return 0; + + /* wait for the user to tell us when to quit */ + case WM_CHAR: + switch (wP) { /* only need one, so ignore repeat count */ + case 'q': + case 'Q': + case 0x1B: /* Esc key */ + PostQuitMessage(0); + } + return 0; + + case WM_LBUTTONDOWN: /* another way of quitting */ + case WM_DESTROY: + PostQuitMessage(0); + return 0; + } + + return DefWindowProc(hwnd, iMsg, wP, lP); +} diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/rpng-x.c b/thirdparty/libpng-1.6.37/contrib/gregbook/rpng-x.c new file mode 100644 index 0000000..92effaa --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/rpng-x.c @@ -0,0 +1,911 @@ +/*--------------------------------------------------------------------------- + + rpng - simple PNG display program rpng-x.c + + This program decodes and displays PNG images, with gamma correction and + optionally with a user-specified background color (in case the image has + transparency). It is very nearly the most basic PNG viewer possible. + This version is for the X Window System (tested by author under Unix and + by Martin Zinser under OpenVMS; may work under OS/2 with some tweaking). + + to do: + - 8-bit (colormapped) X support + - use %.1023s to simplify truncation of title-bar string? + + --------------------------------------------------------------------------- + + Changelog: + - 1.01: initial public release + - 1.02: modified to allow abbreviated options; fixed long/ulong mis- + match; switched to png_jmpbuf() macro + - 1.10: added support for non-default visuals; fixed X pixel-conversion + - 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed + command-line parsing bug + - 1.12: fixed some small X memory leaks (thanks to François Petitjean) + - 1.13: fixed XFreeGC() crash bug (thanks to Patrick Welche) + - 1.14: added support for X resources (thanks to Gerhard Niklasch) + - 2.00: dual-licensed (added GNU GPL) + - 2.01: fixed improper display of usage screen on PNG error(s) + - 2.02: Added "void(argc);" statement to quiet pedantic compiler warnings + about unused variable (GR-P) + - 2.03: check for integer overflow (Glenn R-P) + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ---------------------------------------------------------------------------*/ + +#define PROGNAME "rpng-x" +#define LONGNAME "Simple PNG Viewer for X" +#define VERSION "2.02 of 15 June 2014" +#define RESNAME "rpng" /* our X resource application name */ +#define RESCLASS "Rpng" /* our X resource class name */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* #define DEBUG : this enables the Trace() macros */ + +#include "readpng.h" /* typedefs, common macros, readpng prototypes */ + + +/* could just include png.h, but this macro is the only thing we need + * (name and typedefs changed to local versions); note that side effects + * only happen with alpha (which could easily be avoided with + * "ush acopy = (alpha);") */ + +#define alpha_composite(composite, fg, alpha, bg) { \ + ush temp = ((ush)(fg)*(ush)(alpha) + \ + (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \ + (composite) = (uch)((temp + (temp >> 8)) >> 8); \ +} + + +/* local prototypes */ +static int rpng_x_create_window(void); +static int rpng_x_display_image(void); +static void rpng_x_cleanup(void); +static int rpng_x_msb(ulg u32val); + + +static char titlebar[1024], *window_name = titlebar; +static char *appname = LONGNAME; +static char *icon_name = PROGNAME; +static char *res_name = RESNAME; +static char *res_class = RESCLASS; +static char *filename; +static FILE *infile; + +static char *bgstr; +static uch bg_red=0, bg_green=0, bg_blue=0; + +static double display_exponent; + +static ulg image_width, image_height, image_rowbytes; +static int image_channels; +static uch *image_data; + +/* X-specific variables */ +static char *displayname; +static XImage *ximage; +static Display *display; +static int depth; +static Visual *visual; +static XVisualInfo *visual_list; +static int RShift, GShift, BShift; +static ulg RMask, GMask, BMask; +static Window window; +static GC gc; +static Colormap colormap; + +static int have_nondefault_visual = FALSE; +static int have_colormap = FALSE; +static int have_window = FALSE; +static int have_gc = FALSE; +/* +ulg numcolors=0, pixels[256]; +ush reds[256], greens[256], blues[256]; + */ + + + + +int main(int argc, char **argv) +{ +#ifdef sgi + char tmpline[80]; +#endif + char *p; + int rc, alen, flen; + int error = 0; + int have_bg = FALSE; + double LUT_exponent; /* just the lookup table */ + double CRT_exponent = 2.2; /* just the monitor */ + double default_display_exponent; /* whole display system */ + XEvent e; + KeySym k; + + + displayname = (char *)NULL; + filename = (char *)NULL; + + + /* First set the default value for our display-system exponent, i.e., + * the product of the CRT exponent and the exponent corresponding to + * the frame-buffer's lookup table (LUT), if any. This is not an + * exhaustive list of LUT values (e.g., OpenStep has a lot of weird + * ones), but it should cover 99% of the current possibilities. */ + +#if defined(NeXT) + LUT_exponent = 1.0 / 2.2; + /* + if (some_next_function_that_returns_gamma(&next_gamma)) + LUT_exponent = 1.0 / next_gamma; + */ +#elif defined(sgi) + LUT_exponent = 1.0 / 1.7; + /* there doesn't seem to be any documented function to get the + * "gamma" value, so we do it the hard way */ + infile = fopen("/etc/config/system.glGammaVal", "r"); + if (infile) { + double sgi_gamma; + + fgets(tmpline, 80, infile); + fclose(infile); + sgi_gamma = atof(tmpline); + if (sgi_gamma > 0.0) + LUT_exponent = 1.0 / sgi_gamma; + } +#elif defined(Macintosh) + LUT_exponent = 1.8 / 2.61; + /* + if (some_mac_function_that_returns_gamma(&mac_gamma)) + LUT_exponent = mac_gamma / 2.61; + */ +#else + LUT_exponent = 1.0; /* assume no LUT: most PCs */ +#endif + + /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ + default_display_exponent = LUT_exponent * CRT_exponent; + + + /* If the user has set the SCREEN_GAMMA environment variable as suggested + * (somewhat imprecisely) in the libpng documentation, use that; otherwise + * use the default value we just calculated. Either way, the user may + * override this via a command-line option. */ + + if ((p = getenv("SCREEN_GAMMA")) != NULL) + display_exponent = atof(p); + else + display_exponent = default_display_exponent; + + + /* Now parse the command line for options and the PNG filename. */ + + while (*++argv && !error) { + if (!strncmp(*argv, "-display", 2)) { + if (!*++argv) + ++error; + else + displayname = *argv; + } else if (!strncmp(*argv, "-gamma", 2)) { + if (!*++argv) + ++error; + else { + display_exponent = atof(*argv); + if (display_exponent <= 0.0) + ++error; + } + } else if (!strncmp(*argv, "-bgcolor", 2)) { + if (!*++argv) + ++error; + else { + bgstr = *argv; + if (strlen(bgstr) != 7 || bgstr[0] != '#') + ++error; + else + have_bg = TRUE; + } + } else { + if (**argv != '-') { + filename = *argv; + if (argv[1]) /* shouldn't be any more args after filename */ + ++error; + } else + ++error; /* not expecting any other options */ + } + } + + if (!filename) + ++error; + + + /* print usage screen if any errors up to this point */ + + if (error) { + fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); + readpng_version_info(); + fprintf(stderr, "\n" + "Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n" + " xdpy\tname of the target X display (e.g., ``hostname:0'')\n" + " exp \ttransfer-function exponent (``gamma'') of the display\n" + "\t\t system in floating-point format (e.g., ``%.1f''); equal\n", + PROGNAME, default_display_exponent); + + fprintf(stderr, "\n" + "\t\t to the product of the lookup-table exponent (varies)\n" + "\t\t and the CRT exponent (usually 2.2); must be positive\n" + " bg \tdesired background color in 7-character hex RGB format\n" + "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" + "\t\t used with transparent images\n" + "\nPress Q, Esc or mouse button 1 (within image window, after image\n" + "is displayed) to quit.\n"); + exit(1); + } + + + if (!(infile = fopen(filename, "rb"))) { + fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); + ++error; + } else { + if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) { + switch (rc) { + case 1: + fprintf(stderr, PROGNAME + ": [%s] is not a PNG file: incorrect signature\n", + filename); + break; + case 2: + fprintf(stderr, PROGNAME + ": [%s] has bad IHDR (libpng longjmp)\n", filename); + break; + case 4: + fprintf(stderr, PROGNAME ": insufficient memory\n"); + break; + default: + fprintf(stderr, PROGNAME + ": unknown readpng_init() error\n"); + break; + } + ++error; + } else { + display = XOpenDisplay(displayname); + if (!display) { + readpng_cleanup(TRUE); + fprintf(stderr, PROGNAME ": can't open X display [%s]\n", + displayname? displayname : "default"); + ++error; + } + } + if (error) + fclose(infile); + } + + + if (error) { + fprintf(stderr, PROGNAME ": aborting.\n"); + exit(2); + } + + + /* set the title-bar string, but make sure buffer doesn't overflow */ + + alen = strlen(appname); + flen = strlen(filename); + if (alen + flen + 3 > 1023) + sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); + else + sprintf(titlebar, "%s: %s", appname, filename); + + + /* if the user didn't specify a background color on the command line, + * check for one in the PNG file--if not, the initialized values of 0 + * (black) will be used */ + + if (have_bg) { + unsigned r, g, b; /* this approach quiets compiler warnings */ + + sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); + bg_red = (uch)r; + bg_green = (uch)g; + bg_blue = (uch)b; + } else if (readpng_get_bgcolor(&bg_red, &bg_green, &bg_blue) > 1) { + readpng_cleanup(TRUE); + fprintf(stderr, PROGNAME + ": libpng error while checking for background color\n"); + exit(2); + } + + + /* do the basic X initialization stuff, make the window and fill it + * with the background color */ + + if (rpng_x_create_window()) + exit(2); + + + /* decode the image, all at once */ + + Trace((stderr, "calling readpng_get_image()\n")) + image_data = readpng_get_image(display_exponent, &image_channels, + &image_rowbytes); + Trace((stderr, "done with readpng_get_image()\n")) + + + /* done with PNG file, so clean up to minimize memory usage (but do NOT + * nuke image_data!) */ + + readpng_cleanup(FALSE); + fclose(infile); + + if (!image_data) { + fprintf(stderr, PROGNAME ": unable to decode PNG image\n"); + exit(3); + } + + + /* display image (composite with background if requested) */ + + Trace((stderr, "calling rpng_x_display_image()\n")) + if (rpng_x_display_image()) { + free(image_data); + exit(4); + } + Trace((stderr, "done with rpng_x_display_image()\n")) + + + /* wait for the user to tell us when to quit */ + + printf( + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); + fflush(stdout); + + do + XNextEvent(display, &e); + while (!(e.type == ButtonPress && e.xbutton.button == Button1) && + !(e.type == KeyPress && /* v--- or 1 for shifted keys */ + ((k = XLookupKeysym(&e.xkey, 0)) == XK_q || k == XK_Escape) )); + + + /* OK, we're done: clean up all image and X resources and go away */ + + rpng_x_cleanup(); + + (void)argc; /* Unused */ + + return 0; +} + + + + + +static int rpng_x_create_window(void) +{ + uch *xdata; + int need_colormap = FALSE; + int screen, pad; + ulg bg_pixel = 0L; + ulg attrmask; + Window root; + XEvent e; + XGCValues gcvalues; + XSetWindowAttributes attr; + XTextProperty windowName, *pWindowName = &windowName; + XTextProperty iconName, *pIconName = &iconName; + XVisualInfo visual_info; + XSizeHints *size_hints; + XWMHints *wm_hints; + XClassHint *class_hints; + + + screen = DefaultScreen(display); + depth = DisplayPlanes(display, screen); + root = RootWindow(display, screen); + +#ifdef DEBUG + XSynchronize(display, True); +#endif + +#if 0 +/* GRR: add 8-bit support */ + if (/* depth != 8 && */ depth != 16 && depth != 24 && depth != 32) { + fprintf(stderr, + "screen depth %d not supported (only 16-, 24- or 32-bit TrueColor)\n", + depth); + return 2; + } + + XMatchVisualInfo(display, screen, depth, + (depth == 8)? PseudoColor : TrueColor, &visual_info); + visual = visual_info.visual; +#else + if (depth != 16 && depth != 24 && depth != 32) { + int visuals_matched = 0; + + Trace((stderr, "default depth is %d: checking other visuals\n", + depth)) + + /* 24-bit first */ + visual_info.screen = screen; + visual_info.depth = 24; + visual_list = XGetVisualInfo(display, + VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched); + if (visuals_matched == 0) { +/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */ + fprintf(stderr, "default screen depth %d not supported, and no" + " 24-bit visuals found\n", depth); + return 2; + } + Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n", + visuals_matched)) + visual = visual_list[0].visual; + depth = visual_list[0].depth; +/* + colormap_size = visual_list[0].colormap_size; + visual_class = visual->class; + visualID = XVisualIDFromVisual(visual); + */ + have_nondefault_visual = TRUE; + need_colormap = TRUE; + } else { + XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info); + visual = visual_info.visual; + } +#endif + + RMask = visual->red_mask; + GMask = visual->green_mask; + BMask = visual->blue_mask; + +/* GRR: add/check 8-bit support */ + if (depth == 8 || need_colormap) { + colormap = XCreateColormap(display, root, visual, AllocNone); + if (!colormap) { + fprintf(stderr, "XCreateColormap() failed\n"); + return 2; + } + have_colormap = TRUE; + } + if (depth == 15 || depth == 16) { + RShift = 15 - rpng_x_msb(RMask); /* these are right-shifts */ + GShift = 15 - rpng_x_msb(GMask); + BShift = 15 - rpng_x_msb(BMask); + } else if (depth > 16) { +#define NO_24BIT_MASKS +#ifdef NO_24BIT_MASKS + RShift = rpng_x_msb(RMask) - 7; /* these are left-shifts */ + GShift = rpng_x_msb(GMask) - 7; + BShift = rpng_x_msb(BMask) - 7; +#else + RShift = 7 - rpng_x_msb(RMask); /* these are right-shifts, too */ + GShift = 7 - rpng_x_msb(GMask); + BShift = 7 - rpng_x_msb(BMask); +#endif + } + if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) { + fprintf(stderr, "rpng internal logic error: negative X shift(s)!\n"); + return 2; + } + +/*--------------------------------------------------------------------------- + Finally, create the window. + ---------------------------------------------------------------------------*/ + + attr.backing_store = Always; + attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask; + attrmask = CWBackingStore | CWEventMask; + if (have_nondefault_visual) { + attr.colormap = colormap; + attr.background_pixel = 0; + attr.border_pixel = 1; + attrmask |= CWColormap | CWBackPixel | CWBorderPixel; + } + + window = XCreateWindow(display, root, 0, 0, image_width, image_height, 0, + depth, InputOutput, visual, attrmask, &attr); + + if (window == None) { + fprintf(stderr, "XCreateWindow() failed\n"); + return 2; + } else + have_window = TRUE; + + if (depth == 8) + XSetWindowColormap(display, window, colormap); + + if (!XStringListToTextProperty(&window_name, 1, pWindowName)) + pWindowName = NULL; + if (!XStringListToTextProperty(&icon_name, 1, pIconName)) + pIconName = NULL; + + /* OK if any hints allocation fails; XSetWMProperties() allows NULLs */ + + if ((size_hints = XAllocSizeHints()) != NULL) { + /* window will not be resizable */ + size_hints->flags = PMinSize | PMaxSize; + size_hints->min_width = size_hints->max_width = (int)image_width; + size_hints->min_height = size_hints->max_height = (int)image_height; + } + + if ((wm_hints = XAllocWMHints()) != NULL) { + wm_hints->initial_state = NormalState; + wm_hints->input = True; + /* wm_hints->icon_pixmap = icon_pixmap; */ + wm_hints->flags = StateHint | InputHint /* | IconPixmapHint */ ; + } + + if ((class_hints = XAllocClassHint()) != NULL) { + class_hints->res_name = res_name; + class_hints->res_class = res_class; + } + + XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0, + size_hints, wm_hints, class_hints); + + /* various properties and hints no longer needed; free memory */ + if (pWindowName) + XFree(pWindowName->value); + if (pIconName) + XFree(pIconName->value); + if (size_hints) + XFree(size_hints); + if (wm_hints) + XFree(wm_hints); + if (class_hints) + XFree(class_hints); + + XMapWindow(display, window); + + gc = XCreateGC(display, window, 0, &gcvalues); + have_gc = TRUE; + +/*--------------------------------------------------------------------------- + Fill window with the specified background color. + ---------------------------------------------------------------------------*/ + + if (depth == 24 || depth == 32) { + bg_pixel = ((ulg)bg_red << RShift) | + ((ulg)bg_green << GShift) | + ((ulg)bg_blue << BShift); + } else if (depth == 16) { + bg_pixel = ((((ulg)bg_red << 8) >> RShift) & RMask) | + ((((ulg)bg_green << 8) >> GShift) & GMask) | + ((((ulg)bg_blue << 8) >> BShift) & BMask); + } else /* depth == 8 */ { + + /* GRR: add 8-bit support */ + + } + + XSetForeground(display, gc, bg_pixel); + XFillRectangle(display, window, gc, 0, 0, image_width, image_height); + +/*--------------------------------------------------------------------------- + Wait for first Expose event to do any drawing, then flush. + ---------------------------------------------------------------------------*/ + + do + XNextEvent(display, &e); + while (e.type != Expose || e.xexpose.count); + + XFlush(display); + +/*--------------------------------------------------------------------------- + Allocate memory for the X- and display-specific version of the image. + ---------------------------------------------------------------------------*/ + + if (depth == 24 || depth == 32) { + xdata = (uch *)malloc(4*image_width*image_height); + pad = 32; + } else if (depth == 16) { + xdata = (uch *)malloc(2*image_width*image_height); + pad = 16; + } else /* depth == 8 */ { + xdata = (uch *)malloc(image_width*image_height); + pad = 8; + } + + if (!xdata) { + fprintf(stderr, PROGNAME ": unable to allocate image memory\n"); + return 4; + } + + ximage = XCreateImage(display, visual, depth, ZPixmap, 0, + (char *)xdata, image_width, image_height, pad, 0); + + if (!ximage) { + fprintf(stderr, PROGNAME ": XCreateImage() failed\n"); + free(xdata); + return 3; + } + + /* to avoid testing the byte order every pixel (or doubling the size of + * the drawing routine with a giant if-test), we arbitrarily set the byte + * order to MSBFirst and let Xlib worry about inverting things on little- + * endian machines (like Linux/x86, old VAXen, etc.)--this is not the most + * efficient approach (the giant if-test would be better), but in the + * interest of clarity, we take the easy way out... */ + + ximage->byte_order = MSBFirst; + + return 0; + +} /* end function rpng_x_create_window() */ + + + + + +static int rpng_x_display_image(void) +{ + uch *src; + char *dest; + uch r, g, b, a; + ulg i, row, lastrow = 0; + ulg pixel; + int ximage_rowbytes = ximage->bytes_per_line; +/* int bpp = ximage->bits_per_pixel; */ + + + Trace((stderr, "beginning display loop (image_channels == %d)\n", + image_channels)) + Trace((stderr, " (width = %ld, rowbytes = %ld, ximage_rowbytes = %d)\n", + image_width, image_rowbytes, ximage_rowbytes)) + Trace((stderr, " (bpp = %d)\n", ximage->bits_per_pixel)) + Trace((stderr, " (byte_order = %s)\n", ximage->byte_order == MSBFirst? + "MSBFirst" : (ximage->byte_order == LSBFirst? "LSBFirst" : "unknown"))) + + if (depth == 24 || depth == 32) { + ulg red, green, blue; + + for (lastrow = row = 0; row < image_height; ++row) { + src = image_data + row*image_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + if (image_channels == 3) { + for (i = image_width; i > 0; --i) { + red = *src++; + green = *src++; + blue = *src++; +#ifdef NO_24BIT_MASKS + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + /* GRR BUG: this assumes bpp == 32, but may be 24: */ + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); +#else + red = (RShift < 0)? red << (-RShift) : red >> RShift; + green = (GShift < 0)? green << (-GShift) : green >> GShift; + blue = (BShift < 0)? blue << (-BShift) : blue >> BShift; + pixel = (red & RMask) | (green & GMask) | (blue & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); +#endif + } + } else /* if (image_channels == 4) */ { + for (i = image_width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (a == 255) { + red = r; + green = g; + blue = b; + } else if (a == 0) { + red = bg_red; + green = bg_green; + blue = bg_blue; + } else { + /* this macro (from png.h) composites the foreground + * and background values and puts the result into the + * first argument */ + alpha_composite(red, r, a, bg_red); + alpha_composite(green, g, a, bg_green); + alpha_composite(blue, b, a, bg_blue); + } + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + /* display after every 16 lines */ + if (((row+1) & 0xf) == 0) { + XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, + (int)lastrow, image_width, 16); + XFlush(display); + lastrow = row + 1; + } + } + + } else if (depth == 16) { + ush red, green, blue; + + for (lastrow = row = 0; row < image_height; ++row) { + src = image_data + row*image_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + if (image_channels == 3) { + for (i = image_width; i > 0; --i) { + red = ((ush)(*src) << 8); + ++src; + green = ((ush)(*src) << 8); + ++src; + blue = ((ush)(*src) << 8); + ++src; + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } else /* if (image_channels == 4) */ { + for (i = image_width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (a == 255) { + red = ((ush)r << 8); + green = ((ush)g << 8); + blue = ((ush)b << 8); + } else if (a == 0) { + red = ((ush)bg_red << 8); + green = ((ush)bg_green << 8); + blue = ((ush)bg_blue << 8); + } else { + /* this macro (from png.h) composites the foreground + * and background values and puts the result back into + * the first argument (== fg byte here: safe) */ + alpha_composite(r, r, a, bg_red); + alpha_composite(g, g, a, bg_green); + alpha_composite(b, b, a, bg_blue); + red = ((ush)r << 8); + green = ((ush)g << 8); + blue = ((ush)b << 8); + } + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + /* display after every 16 lines */ + if (((row+1) & 0xf) == 0) { + XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, + (int)lastrow, image_width, 16); + XFlush(display); + lastrow = row + 1; + } + } + + } else /* depth == 8 */ { + + /* GRR: add 8-bit support */ + + } + + Trace((stderr, "calling final XPutImage()\n")) + if (lastrow < image_height) { + XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, + (int)lastrow, image_width, image_height-lastrow); + XFlush(display); + } + + return 0; +} + + + + +static void rpng_x_cleanup(void) +{ + if (image_data) { + free(image_data); + image_data = NULL; + } + + if (ximage) { + if (ximage->data) { + free(ximage->data); /* we allocated it, so we free it */ + ximage->data = (char *)NULL; /* instead of XDestroyImage() */ + } + XDestroyImage(ximage); + ximage = NULL; + } + + if (have_gc) + XFreeGC(display, gc); + + if (have_window) + XDestroyWindow(display, window); + + if (have_colormap) + XFreeColormap(display, colormap); + + if (have_nondefault_visual) + XFree(visual_list); +} + + + + + +static int rpng_x_msb(ulg u32val) +{ + int i; + + for (i = 31; i >= 0; --i) { + if (u32val & 0x80000000L) + break; + u32val <<= 1; + } + return i; +} diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/rpng2-win.c b/thirdparty/libpng-1.6.37/contrib/gregbook/rpng2-win.c new file mode 100644 index 0000000..ed6b526 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/rpng2-win.c @@ -0,0 +1,1261 @@ +/*--------------------------------------------------------------------------- + + rpng2 - progressive-model PNG display program rpng2-win.c + + This program decodes and displays PNG files progressively, as if it were + a web browser (though the front end is only set up to read from files). + It supports gamma correction, user-specified background colors, and user- + specified background patterns (for transparent images). This version is + for 32-bit Windows; it may compile under 16-bit Windows with a little + tweaking (or maybe not). Thanks to Adam Costello and Pieter S. van der + Meulen for the "diamond" and "radial waves" patterns, respectively. + + to do (someday, maybe): + - handle quoted command-line args (especially filenames with spaces) + - finish resizable checkerboard-gradient (sizes 4-128?) + - use %.1023s to simplify truncation of title-bar string? + - have minimum window width: oh well + + --------------------------------------------------------------------------- + + Changelog: + - 1.01: initial public release + - 1.02: fixed cut-and-paste error in usage screen (oops...) + - 1.03: modified to allow abbreviated options + - 1.04: removed bogus extra argument from usage fprintf() [Glenn R-P?]; + fixed command-line parsing bug + - 1.10: enabled "message window"/console (thanks to David Geldreich) + - 1.20: added runtime MMX-enabling/disabling and new -mmx* options + - 1.21: made minor tweak to usage screen to fit within 25-line console + - 1.22: added AMD64/EM64T support (__x86_64__) + - 2.00: dual-licensed (added GNU GPL) + - 2.01: fixed 64-bit typo in readpng2.c + - 2.02: fixed improper display of usage screen on PNG error(s); fixed + unexpected-EOF and file-read-error cases + - 2.03: removed runtime MMX-enabling/disabling and obsolete -mmx* options + - 2.04: check for integer overflow (Glenn R-P) + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ---------------------------------------------------------------------------*/ + +#define PROGNAME "rpng2-win" +#define LONGNAME "Progressive PNG Viewer for Windows" +#define VERSION "2.02 of 16 March 2008" + +#include +#include +#include +#include /* for jmpbuf declaration in readpng2.h */ +#include +#include /* only for PvdM background code */ +#include +#ifdef __CYGWIN__ +/* getch replacement. Turns out, we don't really need this, + * but leave it here if we ever enable any of the uses of + * _getch in the main code + */ +#include +#include +#include +int repl_getch( void ) +{ + char ch; + int fd = fileno(stdin); + struct termio old_tty, new_tty; + + ioctl(fd, TCGETA, &old_tty); + new_tty = old_tty; + new_tty.c_lflag &= ~(ICANON | ECHO | ISIG); + ioctl(fd, TCSETA, &new_tty); + fread(&ch, 1, sizeof(ch), stdin); + ioctl(fd, TCSETA, &old_tty); + + return ch; +} +#define _getch repl_getch +#else +#include /* only for _getch() */ +#endif + +/* all for PvdM background code: */ +#ifndef PI +# define PI 3.141592653589793238 +#endif +#define PI_2 (PI*0.5) +#define INV_PI_360 (360.0 / PI) +#define MAX(a,b) (a>b?a:b) +#define MIN(a,b) (a> 8)) >> 8); \ +} + + +#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this + * block size corresponds roughly to a download + * speed 10% faster than theoretical 33.6K maximum + * (assuming 8 data bits, 1 stop bit and no other + * overhead) */ + +/* local prototypes */ +static void rpng2_win_init(void); +static int rpng2_win_create_window(void); +static int rpng2_win_load_bg_image(void); +static void rpng2_win_display_row(ulg row); +static void rpng2_win_finish_display(void); +static void rpng2_win_cleanup(void); +LRESULT CALLBACK rpng2_win_wndproc(HWND, UINT, WPARAM, LPARAM); + + +static char titlebar[1024]; +static char *progname = PROGNAME; +static char *appname = LONGNAME; +static char *filename; +static FILE *infile; + +static mainprog_info rpng2_info; + +static uch inbuf[INBUFSIZE]; +static int incount; + +static int pat = 6; /* must be less than num_bgpat */ +static int bg_image = 0; +static int bgscale = 16; +static ulg bg_rowbytes; +static uch *bg_data; + +static struct rgb_color { + uch r, g, b; +} rgb[] = { + { 0, 0, 0}, /* 0: black */ + {255, 255, 255}, /* 1: white */ + {173, 132, 57}, /* 2: tan */ + { 64, 132, 0}, /* 3: medium green */ + {189, 117, 1}, /* 4: gold */ + {253, 249, 1}, /* 5: yellow */ + { 0, 0, 255}, /* 6: blue */ + { 0, 0, 120}, /* 7: medium blue */ + {255, 0, 255}, /* 8: magenta */ + { 64, 0, 64}, /* 9: dark magenta */ + {255, 0, 0}, /* 10: red */ + { 64, 0, 0}, /* 11: dark red */ + {255, 127, 0}, /* 12: orange */ + {192, 96, 0}, /* 13: darker orange */ + { 24, 60, 0}, /* 14: dark green-yellow */ + { 85, 125, 200} /* 15: ice blue */ +}; +/* not used for now, but should be for error-checking: +static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color); + */ + +/* + This whole struct is a fairly cheesy way to keep the number of + command-line options to a minimum. The radial-waves background + type is a particularly poor fit to the integer elements of the + struct...but a few macros and a little fixed-point math will do + wonders for ya. + + type bits: + F E D C B A 9 8 7 6 5 4 3 2 1 0 + | | | | | + | | +-+-+-- 0 = sharp-edged checkerboard + | | 1 = soft diamonds + | | 2 = radial waves + | | 3-7 = undefined + | +-- gradient #2 inverted? + +-- alternating columns inverted? + */ +static struct background_pattern { + ush type; + int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */ + int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/ +} bg[] = { + {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */ + {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */ + {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */ + {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */ + {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */ + {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */ + {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */ + {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */ + {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */ + {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */ + {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */ + {1, 3,0, 0,0}, /* diamonds: medium green vs. black */ + {2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */ + {2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */ + {2, 16, 256, 100, 250}, /* radial: very tight spiral */ + {2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */ +}; +static int num_bgpat = sizeof(bg) / sizeof(struct background_pattern); + + +/* Windows-specific global variables (could go in struct, but messy...) */ +static ulg wimage_rowbytes; +static uch *dib; +static uch *wimage_data; +static BITMAPINFOHEADER *bmih; + +static HWND global_hwnd; +static HINSTANCE global_hInst; +static int global_showmode; + + + + +int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) +{ + char *args[1024]; /* arbitrary limit, but should suffice */ + char **argv = args; + char *p, *q, *bgstr = NULL; + int argc = 0; + int rc, alen, flen; + int error = 0; + int timing = FALSE; + int have_bg = FALSE; + double LUT_exponent; /* just the lookup table */ + double CRT_exponent = 2.2; /* just the monitor */ + double default_display_exponent; /* whole display system */ + MSG msg; + + + /* First initialize a few things, just to be sure--memset takes care of + * default background color (black), booleans (FALSE), pointers (NULL), + * etc. */ + + global_hInst = hInst; + global_showmode = showmode; + filename = (char *)NULL; + memset(&rpng2_info, 0, sizeof(mainprog_info)); + +#ifndef __CYGWIN__ + /* Next reenable console output, which normally goes to the bit bucket + * for windowed apps. Closing the console window will terminate the + * app. Thanks to David.Geldreich at realviz.com for supplying the magical + * incantation. */ + + AllocConsole(); + freopen("CONOUT$", "a", stderr); + freopen("CONOUT$", "a", stdout); +#endif + + /* Set the default value for our display-system exponent, i.e., the + * product of the CRT exponent and the exponent corresponding to + * the frame-buffer's lookup table (LUT), if any. This is not an + * exhaustive list of LUT values (e.g., OpenStep has a lot of weird + * ones), but it should cover 99% of the current possibilities. And + * yes, these ifdefs are completely wasted in a Windows program... */ + +#if defined(NeXT) + /* third-party utilities can modify the default LUT exponent */ + LUT_exponent = 1.0 / 2.2; + /* + if (some_next_function_that_returns_gamma(&next_gamma)) + LUT_exponent = 1.0 / next_gamma; + */ +#elif defined(sgi) + LUT_exponent = 1.0 / 1.7; + /* there doesn't seem to be any documented function to + * get the "gamma" value, so we do it the hard way */ + infile = fopen("/etc/config/system.glGammaVal", "r"); + if (infile) { + double sgi_gamma; + + fgets(tmpline, 80, infile); + fclose(infile); + sgi_gamma = atof(tmpline); + if (sgi_gamma > 0.0) + LUT_exponent = 1.0 / sgi_gamma; + } +#elif defined(Macintosh) + LUT_exponent = 1.8 / 2.61; + /* + if (some_mac_function_that_returns_gamma(&mac_gamma)) + LUT_exponent = mac_gamma / 2.61; + */ +#else + LUT_exponent = 1.0; /* assume no LUT: most PCs */ +#endif + + /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ + default_display_exponent = LUT_exponent * CRT_exponent; + + + /* If the user has set the SCREEN_GAMMA environment variable as suggested + * (somewhat imprecisely) in the libpng documentation, use that; otherwise + * use the default value we just calculated. Either way, the user may + * override this via a command-line option. */ + + if ((p = getenv("SCREEN_GAMMA")) != NULL) + rpng2_info.display_exponent = atof(p); + else + rpng2_info.display_exponent = default_display_exponent; + + + /* Windows really hates command lines, so we have to set up our own argv. + * Note that we do NOT bother with quoted arguments here, so don't use + * filenames with spaces in 'em! */ + + argv[argc++] = PROGNAME; + p = cmd; + for (;;) { + if (*p == ' ') + while (*++p == ' ') + ; + /* now p points at the first non-space after some spaces */ + if (*p == '\0') + break; /* nothing after the spaces: done */ + argv[argc++] = q = p; + while (*q && *q != ' ') + ++q; + /* now q points at a space or the end of the string */ + if (*q == '\0') + break; /* last argv already terminated; quit */ + *q = '\0'; /* change space to terminator */ + p = q + 1; + } + argv[argc] = NULL; /* terminate the argv array itself */ + + + /* Now parse the command line for options and the PNG filename. */ + + while (*++argv && !error) { + if (!strncmp(*argv, "-gamma", 2)) { + if (!*++argv) + ++error; + else { + rpng2_info.display_exponent = atof(*argv); + if (rpng2_info.display_exponent <= 0.0) + ++error; + } + } else if (!strncmp(*argv, "-bgcolor", 4)) { + if (!*++argv) + ++error; + else { + bgstr = *argv; + if (strlen(bgstr) != 7 || bgstr[0] != '#') + ++error; + else { + have_bg = TRUE; + bg_image = FALSE; + } + } + } else if (!strncmp(*argv, "-bgpat", 4)) { + if (!*++argv) + ++error; + else { + pat = atoi(*argv) - 1; + if (pat < 0 || pat >= num_bgpat) + ++error; + else { + bg_image = TRUE; + have_bg = FALSE; + } + } + } else if (!strncmp(*argv, "-timing", 2)) { + timing = TRUE; + } else { + if (**argv != '-') { + filename = *argv; + if (argv[1]) /* shouldn't be any more args after filename */ + ++error; + } else + ++error; /* not expecting any other options */ + } + } + + if (!filename) + ++error; + + + /* print usage screen if any errors up to this point */ + + if (error) { +#ifndef __CYGWIN__ + int ch; +#endif + + fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); + readpng2_version_info(); + fprintf(stderr, "\n" + "Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]\n" + " %*s file.png\n\n" + " exp \ttransfer-function exponent (``gamma'') of the display\n" + "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" + "\t\t to the product of the lookup-table exponent (varies)\n" + "\t\t and the CRT exponent (usually 2.2); must be positive\n" + " bg \tdesired background color in 7-character hex RGB format\n" + "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" + "\t\t used with transparent images; overrides -bgpat option\n" + " pat \tdesired background pattern number (1-%d); used with\n" + "\t\t transparent images; overrides -bgcolor option\n" + " -timing\tenables delay for every block read, to simulate modem\n" + "\t\t download of image (~36 Kbps)\n" + "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" +#ifndef __CYGWIN__ + "Press Q or Esc to quit this usage screen. ", +#else + , +#endif + PROGNAME, +#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) && \ + !(defined(__CYGWIN__) || defined(__MINGW32__)) + (int)strlen(PROGNAME), " ", +#endif + (int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat); + fflush(stderr); +#ifndef __CYGWIN__ + do + ch = _getch(); + while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif + exit(1); + } + + + if (!(infile = fopen(filename, "rb"))) { + fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); + ++error; + } else { + incount = fread(inbuf, 1, INBUFSIZE, infile); + if (incount < 8 || !readpng2_check_sig(inbuf, 8)) { + fprintf(stderr, PROGNAME + ": [%s] is not a PNG file: incorrect signature\n", + filename); + ++error; + } else if ((rc = readpng2_init(&rpng2_info)) != 0) { + switch (rc) { + case 2: + fprintf(stderr, PROGNAME + ": [%s] has bad IHDR (libpng longjmp)\n", filename); + break; + case 4: + fprintf(stderr, PROGNAME ": insufficient memory\n"); + break; + default: + fprintf(stderr, PROGNAME + ": unknown readpng2_init() error\n"); + break; + } + ++error; + } + if (error) + fclose(infile); + } + + + if (error) { +#ifndef __CYGWIN__ + int ch; +#endif + + fprintf(stderr, PROGNAME ": aborting.\n"); +#ifndef __CYGWIN__ + do + ch = _getch(); + while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif + exit(2); + } else { + fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); +#ifndef __CYGWIN__ + fprintf(stderr, + "\n [console window: closing this window will terminate %s]\n\n", + PROGNAME); +#endif + fflush(stderr); + } + + + /* set the title-bar string, but make sure buffer doesn't overflow */ + + alen = strlen(appname); + flen = strlen(filename); + if (alen + flen + 3 > 1023) + sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); + else + sprintf(titlebar, "%s: %s", appname, filename); + + + /* set some final rpng2_info variables before entering main data loop */ + + if (have_bg) { + unsigned r, g, b; /* this approach quiets compiler warnings */ + + sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); + rpng2_info.bg_red = (uch)r; + rpng2_info.bg_green = (uch)g; + rpng2_info.bg_blue = (uch)b; + } else + rpng2_info.need_bgcolor = TRUE; + + rpng2_info.state = kPreInit; + rpng2_info.mainprog_init = rpng2_win_init; + rpng2_info.mainprog_display_row = rpng2_win_display_row; + rpng2_info.mainprog_finish_display = rpng2_win_finish_display; + + + /* OK, this is the fun part: call readpng2_decode_data() at the start of + * the loop to deal with our first buffer of data (read in above to verify + * that the file is a PNG image), then loop through the file and continue + * calling the same routine to handle each chunk of data. It in turn + * passes the data to libpng, which will invoke one or more of our call- + * backs as decoded data become available. We optionally call Sleep() for + * one second per iteration to simulate downloading the image via an analog + * modem. */ + + for (;;) { + Trace((stderr, "about to call readpng2_decode_data()\n")) + if (readpng2_decode_data(&rpng2_info, inbuf, incount)) + ++error; + Trace((stderr, "done with readpng2_decode_data()\n")) + + if (error || incount != INBUFSIZE || rpng2_info.state == kDone) { + if (rpng2_info.state == kDone) { + Trace((stderr, "done decoding PNG image\n")) + } else if (ferror(infile)) { + fprintf(stderr, PROGNAME + ": error while reading PNG image file\n"); + exit(3); + } else if (feof(infile)) { + fprintf(stderr, PROGNAME ": end of file reached " + "(unexpectedly) while reading PNG image file\n"); + exit(3); + } else /* if (error) */ { + /* will print error message below */ + } + break; + } + + if (timing) + Sleep(1000L); + + incount = fread(inbuf, 1, INBUFSIZE, infile); + } + + + /* clean up PNG stuff and report any decoding errors */ + + fclose(infile); + Trace((stderr, "about to call readpng2_cleanup()\n")) + readpng2_cleanup(&rpng2_info); + + if (error) { + fprintf(stderr, PROGNAME ": libpng error while decoding PNG image\n"); + exit(3); + } + + + /* wait for the user to tell us when to quit */ + + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + + /* we're done: clean up all image and Windows resources and go away */ + + Trace((stderr, "about to call rpng2_win_cleanup()\n")) + rpng2_win_cleanup(); + + return msg.wParam; +} + + + + + +/* this function is called by readpng2_info_callback() in readpng2.c, which + * in turn is called by libpng after all of the pre-IDAT chunks have been + * read and processed--i.e., we now have enough info to finish initializing */ + +static void rpng2_win_init() +{ + ulg i; + ulg rowbytes = rpng2_info.rowbytes; + + Trace((stderr, "beginning rpng2_win_init()\n")) + Trace((stderr, " rowbytes = %d\n", rpng2_info.rowbytes)) + Trace((stderr, " width = %ld\n", rpng2_info.width)) + Trace((stderr, " height = %ld\n", rpng2_info.height)) + + /* Guard against integer overflow */ + if (rpng2_info.height > ((size_t)(-1))/rowbytes) { + fprintf(stderr, PROGNAME ": image_data buffer would be too large\n", + readpng2_cleanup(&rpng2_info); + return; + } + + rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); + if (!rpng2_info.image_data) { + readpng2_cleanup(&rpng2_info); + return; + } + + rpng2_info.row_pointers = (uch **)malloc(rpng2_info.height * sizeof(uch *)); + if (!rpng2_info.row_pointers) { + free(rpng2_info.image_data); + rpng2_info.image_data = NULL; + readpng2_cleanup(&rpng2_info); + return; + } + + for (i = 0; i < rpng2_info.height; ++i) + rpng2_info.row_pointers[i] = rpng2_info.image_data + i*rowbytes; + +/*--------------------------------------------------------------------------- + Do the basic Windows initialization stuff, make the window, and fill it + with the user-specified, file-specified or default background color. + ---------------------------------------------------------------------------*/ + + if (rpng2_win_create_window()) { + readpng2_cleanup(&rpng2_info); + return; + } + + rpng2_info.state = kWindowInit; +} + + + + + +static int rpng2_win_create_window() +{ + uch bg_red = rpng2_info.bg_red; + uch bg_green = rpng2_info.bg_green; + uch bg_blue = rpng2_info.bg_blue; + uch *dest; + int extra_width, extra_height; + ulg i, j; + WNDCLASSEX wndclass; + RECT rect; + + +/*--------------------------------------------------------------------------- + Allocate memory for the display-specific version of the image (round up + to multiple of 4 for Windows DIB). + ---------------------------------------------------------------------------*/ + + wimage_rowbytes = ((3*rpng2_info.width + 3L) >> 2) << 2; + + if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) + + wimage_rowbytes*rpng2_info.height))) + { + return 4; /* fail */ + } + +/*--------------------------------------------------------------------------- + Initialize the DIB. Negative height means to use top-down BMP ordering + (must be uncompressed, but that's what we want). Bit count of 1, 4 or 8 + implies a colormap of RGBX quads, but 24-bit BMPs just use B,G,R values + directly => wimage_data begins immediately after BMP header. + ---------------------------------------------------------------------------*/ + + memset(dib, 0, sizeof(BITMAPINFOHEADER)); + bmih = (BITMAPINFOHEADER *)dib; + bmih->biSize = sizeof(BITMAPINFOHEADER); + bmih->biWidth = rpng2_info.width; + bmih->biHeight = -((long)rpng2_info.height); + bmih->biPlanes = 1; + bmih->biBitCount = 24; + bmih->biCompression = 0; + wimage_data = dib + sizeof(BITMAPINFOHEADER); + +/*--------------------------------------------------------------------------- + Fill window with the specified background color (default is black), but + defer loading faked "background image" until window is displayed (may be + slow to compute). Data are in BGR order. + ---------------------------------------------------------------------------*/ + + if (bg_image) { /* just fill with black for now */ + memset(wimage_data, 0, wimage_rowbytes*rpng2_info.height); + } else { + for (j = 0; j < rpng2_info.height; ++j) { + dest = wimage_data + j*wimage_rowbytes; + for (i = rpng2_info.width; i > 0; --i) { + *dest++ = bg_blue; + *dest++ = bg_green; + *dest++ = bg_red; + } + } + } + +/*--------------------------------------------------------------------------- + Set the window parameters. + ---------------------------------------------------------------------------*/ + + memset(&wndclass, 0, sizeof(wndclass)); + + wndclass.cbSize = sizeof(wndclass); + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = rpng2_win_wndproc; + wndclass.hInstance = global_hInst; + wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = progname; + wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + + RegisterClassEx(&wndclass); + +/*--------------------------------------------------------------------------- + Finally, create the window. + ---------------------------------------------------------------------------*/ + + extra_width = 2*(GetSystemMetrics(SM_CXBORDER) + + GetSystemMetrics(SM_CXDLGFRAME)); + extra_height = 2*(GetSystemMetrics(SM_CYBORDER) + + GetSystemMetrics(SM_CYDLGFRAME)) + + GetSystemMetrics(SM_CYCAPTION); + + global_hwnd = CreateWindow(progname, titlebar, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, rpng2_info.width+extra_width, + rpng2_info.height+extra_height, NULL, NULL, global_hInst, NULL); + + ShowWindow(global_hwnd, global_showmode); + UpdateWindow(global_hwnd); + +/*--------------------------------------------------------------------------- + Now compute the background image and display it. If it fails (memory + allocation), revert to a plain background color. + ---------------------------------------------------------------------------*/ + + if (bg_image) { + static const char *msg = "Computing background image..."; + int x, y, len = strlen(msg); + HDC hdc = GetDC(global_hwnd); + TEXTMETRIC tm; + + GetTextMetrics(hdc, &tm); + x = (rpng2_info.width - len*tm.tmAveCharWidth)/2; + y = (rpng2_info.height - tm.tmHeight)/2; + SetBkMode(hdc, TRANSPARENT); + SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); + /* this can still begin out of bounds even if x is positive (???): */ + TextOut(hdc, ((x < 0)? 0 : x), ((y < 0)? 0 : y), msg, len); + ReleaseDC(global_hwnd, hdc); + + rpng2_win_load_bg_image(); /* resets bg_image if fails */ + } + + if (!bg_image) { + for (j = 0; j < rpng2_info.height; ++j) { + dest = wimage_data + j*wimage_rowbytes; + for (i = rpng2_info.width; i > 0; --i) { + *dest++ = bg_blue; + *dest++ = bg_green; + *dest++ = bg_red; + } + } + } + + rect.left = 0L; + rect.top = 0L; + rect.right = (LONG)rpng2_info.width; /* possibly off by one? */ + rect.bottom = (LONG)rpng2_info.height; /* possibly off by one? */ + InvalidateRect(global_hwnd, &rect, FALSE); + UpdateWindow(global_hwnd); /* similar to XFlush() */ + + return 0; + +} /* end function rpng2_win_create_window() */ + + + + + +static int rpng2_win_load_bg_image() +{ + uch *src, *dest; + uch r1, r2, g1, g2, b1, b2; + uch r1_inv, r2_inv, g1_inv, g2_inv, b1_inv, b2_inv; + int k, hmax, max; + int xidx, yidx, yidx_max = (bgscale-1); + int even_odd_vert, even_odd_horiz, even_odd; + int invert_gradient2 = (bg[pat].type & 0x08); + int invert_column; + ulg i, row; + +/*--------------------------------------------------------------------------- + Allocate buffer for fake background image to be used with transparent + images; if this fails, revert to plain background color. + ---------------------------------------------------------------------------*/ + + bg_rowbytes = 3 * rpng2_info.width; + bg_data = (uch *)malloc(bg_rowbytes * rpng2_info.height); + if (!bg_data) { + fprintf(stderr, PROGNAME + ": unable to allocate memory for background image\n"); + bg_image = 0; + return 1; + } + +/*--------------------------------------------------------------------------- + Vertical gradients (ramps) in NxN squares, alternating direction and + colors (N == bgscale). + ---------------------------------------------------------------------------*/ + + if ((bg[pat].type & 0x07) == 0) { + uch r1_min = rgb[bg[pat].rgb1_min].r; + uch g1_min = rgb[bg[pat].rgb1_min].g; + uch b1_min = rgb[bg[pat].rgb1_min].b; + uch r2_min = rgb[bg[pat].rgb2_min].r; + uch g2_min = rgb[bg[pat].rgb2_min].g; + uch b2_min = rgb[bg[pat].rgb2_min].b; + int r1_diff = rgb[bg[pat].rgb1_max].r - r1_min; + int g1_diff = rgb[bg[pat].rgb1_max].g - g1_min; + int b1_diff = rgb[bg[pat].rgb1_max].b - b1_min; + int r2_diff = rgb[bg[pat].rgb2_max].r - r2_min; + int g2_diff = rgb[bg[pat].rgb2_max].g - g2_min; + int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min; + + for (row = 0; row < rpng2_info.height; ++row) { + yidx = row % bgscale; + even_odd_vert = (row / bgscale) & 1; + + r1 = r1_min + (r1_diff * yidx) / yidx_max; + g1 = g1_min + (g1_diff * yidx) / yidx_max; + b1 = b1_min + (b1_diff * yidx) / yidx_max; + r1_inv = r1_min + (r1_diff * (yidx_max-yidx)) / yidx_max; + g1_inv = g1_min + (g1_diff * (yidx_max-yidx)) / yidx_max; + b1_inv = b1_min + (b1_diff * (yidx_max-yidx)) / yidx_max; + + r2 = r2_min + (r2_diff * yidx) / yidx_max; + g2 = g2_min + (g2_diff * yidx) / yidx_max; + b2 = b2_min + (b2_diff * yidx) / yidx_max; + r2_inv = r2_min + (r2_diff * (yidx_max-yidx)) / yidx_max; + g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max; + b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max; + + dest = bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + even_odd_horiz = (i / bgscale) & 1; + even_odd = even_odd_vert ^ even_odd_horiz; + invert_column = + (even_odd_horiz && (bg[pat].type & 0x10)); + if (even_odd == 0) { /* gradient #1 */ + if (invert_column) { + *dest++ = r1_inv; + *dest++ = g1_inv; + *dest++ = b1_inv; + } else { + *dest++ = r1; + *dest++ = g1; + *dest++ = b1; + } + } else { /* gradient #2 */ + if ((invert_column && invert_gradient2) || + (!invert_column && !invert_gradient2)) + { + *dest++ = r2; /* not inverted or */ + *dest++ = g2; /* doubly inverted */ + *dest++ = b2; + } else { + *dest++ = r2_inv; + *dest++ = g2_inv; /* singly inverted */ + *dest++ = b2_inv; + } + } + } + } + +/*--------------------------------------------------------------------------- + Soft gradient-diamonds with scale = bgscale. Code contributed by Adam + M. Costello. + ---------------------------------------------------------------------------*/ + + } else if ((bg[pat].type & 0x07) == 1) { + + hmax = (bgscale-1)/2; /* half the max weight of a color */ + max = 2*hmax; /* the max weight of a color */ + + r1 = rgb[bg[pat].rgb1_max].r; + g1 = rgb[bg[pat].rgb1_max].g; + b1 = rgb[bg[pat].rgb1_max].b; + r2 = rgb[bg[pat].rgb2_max].r; + g2 = rgb[bg[pat].rgb2_max].g; + b2 = rgb[bg[pat].rgb2_max].b; + + for (row = 0; row < rpng2_info.height; ++row) { + yidx = row % bgscale; + if (yidx > hmax) + yidx = bgscale-1 - yidx; + dest = bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + xidx = i % bgscale; + if (xidx > hmax) + xidx = bgscale-1 - xidx; + k = xidx + yidx; + *dest++ = (k*r1 + (max-k)*r2) / max; + *dest++ = (k*g1 + (max-k)*g2) / max; + *dest++ = (k*b1 + (max-k)*b2) / max; + } + } + +/*--------------------------------------------------------------------------- + Radial "starburst" with azimuthal sinusoids; [eventually number of sinu- + soids will equal bgscale?]. This one is slow but very cool. Code con- + tributed by Pieter S. van der Meulen (originally in Smalltalk). + ---------------------------------------------------------------------------*/ + + } else if ((bg[pat].type & 0x07) == 2) { + uch ch; + int ii, x, y, hw, hh, grayspot; + double freq, rotate, saturate, gray, intensity; + double angle=0.0, aoffset=0.0, maxDist, dist; + double red=0.0, green=0.0, blue=0.0, hue, s, v, f, p, q, t; + + fprintf(stderr, "%s: computing radial background...", + PROGNAME); + fflush(stderr); + + hh = rpng2_info.height / 2; + hw = rpng2_info.width / 2; + + /* variables for radial waves: + * aoffset: number of degrees to rotate hue [CURRENTLY NOT USED] + * freq: number of color beams originating from the center + * grayspot: size of the graying center area (anti-alias) + * rotate: rotation of the beams as a function of radius + * saturate: saturation of beams' shape azimuthally + */ + angle = CLIP(angle, 0.0, 360.0); + grayspot = CLIP(bg[pat].bg_gray, 1, (hh + hw)); + freq = MAX((double)bg[pat].bg_freq, 0.0); + saturate = (double)bg[pat].bg_bsat * 0.1; + rotate = (double)bg[pat].bg_brot * 0.1; + gray = 0.0; + intensity = 0.0; + maxDist = (double)((hw*hw) + (hh*hh)); + + for (row = 0; row < rpng2_info.height; ++row) { + y = row - hh; + dest = bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + x = i - hw; + angle = (x == 0)? PI_2 : atan((double)y / (double)x); + gray = (double)MAX(ABS(y), ABS(x)) / grayspot; + gray = MIN(1.0, gray); + dist = (double)((x*x) + (y*y)) / maxDist; + intensity = cos((angle+(rotate*dist*PI)) * freq) * + gray * saturate; + intensity = (MAX(MIN(intensity,1.0),-1.0) + 1.0) * 0.5; + hue = (angle + PI) * INV_PI_360 + aoffset; + s = gray * ((double)(ABS(x)+ABS(y)) / (double)(hw + hh)); + s = MIN(MAX(s,0.0), 1.0); + v = MIN(MAX(intensity,0.0), 1.0); + + if (s == 0.0) { + ch = (uch)(v * 255.0); + *dest++ = ch; + *dest++ = ch; + *dest++ = ch; + } else { + if ((hue < 0.0) || (hue >= 360.0)) + hue -= (((int)(hue / 360.0)) * 360.0); + hue /= 60.0; + ii = (int)hue; + f = hue - (double)ii; + p = (1.0 - s) * v; + q = (1.0 - (s * f)) * v; + t = (1.0 - (s * (1.0 - f))) * v; + if (ii == 0) { red = v; green = t; blue = p; } + else if (ii == 1) { red = q; green = v; blue = p; } + else if (ii == 2) { red = p; green = v; blue = t; } + else if (ii == 3) { red = p; green = q; blue = v; } + else if (ii == 4) { red = t; green = p; blue = v; } + else if (ii == 5) { red = v; green = p; blue = q; } + *dest++ = (uch)(red * 255.0); + *dest++ = (uch)(green * 255.0); + *dest++ = (uch)(blue * 255.0); + } + } + } + fprintf(stderr, "done.\n"); + fflush(stderr); + } + +/*--------------------------------------------------------------------------- + Blast background image to display buffer before beginning PNG decode; + calling function will handle invalidation and UpdateWindow() call. + ---------------------------------------------------------------------------*/ + + for (row = 0; row < rpng2_info.height; ++row) { + src = bg_data + row*bg_rowbytes; + dest = wimage_data + row*wimage_rowbytes; + for (i = rpng2_info.width; i > 0; --i) { + r1 = *src++; + g1 = *src++; + b1 = *src++; + *dest++ = b1; + *dest++ = g1; /* note reverse order */ + *dest++ = r1; + } + } + + return 0; + +} /* end function rpng2_win_load_bg_image() */ + + + + + +static void rpng2_win_display_row(ulg row) +{ + uch bg_red = rpng2_info.bg_red; + uch bg_green = rpng2_info.bg_green; + uch bg_blue = rpng2_info.bg_blue; + uch *src, *src2=NULL, *dest; + uch r, g, b, a; + ulg i; + static int rows=0; + static ulg firstrow; + +/*--------------------------------------------------------------------------- + rows and firstrow simply track how many rows (and which ones) have not + yet been displayed; alternatively, we could call InvalidateRect() for + every row and not bother with the records-keeping. + ---------------------------------------------------------------------------*/ + + Trace((stderr, "beginning rpng2_win_display_row()\n")) + + if (rows == 0) + firstrow = row; /* first row not yet displayed */ + + ++rows; /* count of rows received but not yet displayed */ + +/*--------------------------------------------------------------------------- + Aside from the use of the rpng2_info struct and the lack of an outer + loop (over rows), this routine is identical to rpng_win_display_image() + in the non-progressive version of the program. + ---------------------------------------------------------------------------*/ + + src = rpng2_info.image_data + row*rpng2_info.rowbytes; + if (bg_image) + src2 = bg_data + row*bg_rowbytes; + dest = wimage_data + row*wimage_rowbytes; + + if (rpng2_info.channels == 3) { + for (i = rpng2_info.width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + *dest++ = b; + *dest++ = g; /* note reverse order */ + *dest++ = r; + } + } else /* if (rpng2_info.channels == 4) */ { + for (i = rpng2_info.width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (bg_image) { + bg_red = *src2++; + bg_green = *src2++; + bg_blue = *src2++; + } + if (a == 255) { + *dest++ = b; + *dest++ = g; + *dest++ = r; + } else if (a == 0) { + *dest++ = bg_blue; + *dest++ = bg_green; + *dest++ = bg_red; + } else { + /* this macro (copied from png.h) composites the + * foreground and background values and puts the + * result into the first argument; there are no + * side effects with the first argument */ + alpha_composite(*dest++, b, a, bg_blue); + alpha_composite(*dest++, g, a, bg_green); + alpha_composite(*dest++, r, a, bg_red); + } + } + } + +/*--------------------------------------------------------------------------- + Display after every 16 rows or when on last row. (Region may include + previously displayed lines due to interlacing--i.e., not contiguous.) + ---------------------------------------------------------------------------*/ + + if ((rows & 0xf) == 0 || row == rpng2_info.height-1) { + RECT rect; + + rect.left = 0L; + rect.top = (LONG)firstrow; + rect.right = (LONG)rpng2_info.width; /* possibly off by one? */ + rect.bottom = (LONG)row + 1L; /* possibly off by one? */ + InvalidateRect(global_hwnd, &rect, FALSE); + UpdateWindow(global_hwnd); /* similar to XFlush() */ + rows = 0; + } + +} /* end function rpng2_win_display_row() */ + + + + + +static void rpng2_win_finish_display() +{ + Trace((stderr, "beginning rpng2_win_finish_display()\n")) + + /* last row has already been displayed by rpng2_win_display_row(), so + * we have nothing to do here except set a flag and let the user know + * that the image is done */ + + rpng2_info.state = kDone; + printf( +#ifndef __CYGWIN__ + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n" +#else + "Done. Press mouse button 1 (within image window) to quit.\n" +#endif + ); + fflush(stdout); +} + + + + + +static void rpng2_win_cleanup() +{ + if (bg_image && bg_data) { + free(bg_data); + bg_data = NULL; + } + + if (rpng2_info.image_data) { + free(rpng2_info.image_data); + rpng2_info.image_data = NULL; + } + + if (rpng2_info.row_pointers) { + free(rpng2_info.row_pointers); + rpng2_info.row_pointers = NULL; + } + + if (dib) { + free(dib); + dib = NULL; + } +} + + + + + +LRESULT CALLBACK rpng2_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP) +{ + HDC hdc; + PAINTSTRUCT ps; + int rc; + + switch (iMsg) { + case WM_CREATE: + /* one-time processing here, if any */ + return 0; + + case WM_PAINT: + hdc = BeginPaint(hwnd, &ps); + rc = StretchDIBits(hdc, 0, 0, rpng2_info.width, rpng2_info.height, + 0, 0, rpng2_info.width, rpng2_info.height, + wimage_data, (BITMAPINFO *)bmih, + 0, SRCCOPY); + EndPaint(hwnd, &ps); + return 0; + + /* wait for the user to tell us when to quit */ + case WM_CHAR: + switch (wP) { /* only need one, so ignore repeat count */ + case 'q': + case 'Q': + case 0x1B: /* Esc key */ + PostQuitMessage(0); + } + return 0; + + case WM_LBUTTONDOWN: /* another way of quitting */ + case WM_DESTROY: + PostQuitMessage(0); + return 0; + } + + return DefWindowProc(hwnd, iMsg, wP, lP); +} diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/rpng2-x.c b/thirdparty/libpng-1.6.37/contrib/gregbook/rpng2-x.c new file mode 100644 index 0000000..af944c0 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/rpng2-x.c @@ -0,0 +1,2143 @@ +/*--------------------------------------------------------------------------- + + rpng2 - progressive-model PNG display program rpng2-x.c + + This program decodes and displays PNG files progressively, as if it were + a web browser (though the front end is only set up to read from files). + It supports gamma correction, user-specified background colors, and user- + specified background patterns (for transparent images). This version is + for the X Window System (tested by the author under Unix and by Martin + Zinser under OpenVMS; may work under OS/2 with a little tweaking). + + Thanks to Adam Costello and Pieter S. van der Meulen for the "diamond" + and "radial waves" patterns, respectively. + + to do (someday, maybe): + - fix expose/redraw code: don't draw entire row if only part exposed + - 8-bit (colormapped) X support + - finish resizable checkerboard-gradient (sizes 4-128?) + - use %.1023s to simplify truncation of title-bar string? + + --------------------------------------------------------------------------- + + Changelog: + - 1.01: initial public release + - 1.02: modified to allow abbreviated options; fixed char/uchar mismatch + - 1.10: added support for non-default visuals; fixed X pixel-conversion + - 1.11: added -usleep option for demos; fixed command-line parsing bug + - 1.12: added -pause option for demos and testing + - 1.20: added runtime MMX-enabling/disabling and new -mmx* options + - 1.21: fixed some small X memory leaks (thanks to François Petitjean) + - 1.22: fixed XFreeGC() crash bug (thanks to Patrick Welche) + - 1.23: added -bgpat 0 mode (std white/gray checkerboard, 8x8 squares) + - 1.30: added -loop option for -bgpat (ifdef FEATURE_LOOP); fixed bpp = + 24; added support for X resources (thanks to Gerhard Niklasch) + - 1.31: added code to skip unused chunks (thanks to Glenn Randers-Pehrson) + - 1.32: added AMD64/EM64T support (__x86_64__); added basic expose/redraw + handling + - 2.00: dual-licensed (added GNU GPL) + - 2.01: fixed 64-bit typo in readpng2.c; fixed -pause usage description + - 2.02: fixed improper display of usage screen on PNG error(s); fixed + unexpected-EOF and file-read-error cases; fixed Trace() cut-and- + paste bugs + - 2.03: deleted runtime MMX-enabling/disabling and obsolete -mmx* options + - 2.04: Added "void(foo);" statements to quiet pedantic compiler warnings + about unused variables (GR-P) + - 2.05: Use nanosleep() instead of usleep(), which is deprecated (GR-P). + - 2.06: check for integer overflow (Glenn R-P) + --------------------------------------------------------------------------- + + Copyright (c) 1998-2010, 2014-2015, 2017 Greg Roelofs. All rights + reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ---------------------------------------------------------------------------*/ + +#define PROGNAME "rpng2-x" +#define LONGNAME "Progressive PNG Viewer for X" +#define VERSION "2.04 of 15 June 2014" +#define RESNAME "rpng2" /* our X resource application name */ +#define RESCLASS "Rpng" /* our X resource class name */ + +#include +#include +#include +#include +#include /* for jmpbuf declaration in readpng2.h */ +#include +#include /* only for PvdM background code */ +#include +#include +#include +#include /* defines XK_* macros */ + +#if _POSIX_C_SOURCE >= 199309L /* have nanosleep() */ +# undef usleep +# define usleep(usec) { \ + struct timespec ts; \ + ts.tv_sec = 0; \ + ts.tv_nsec = (usec) * 1000; \ + nanosleep(&ts, NULL); } +# endif + +#ifndef usleep /* have neither nanosleep() nor usleep() */ +# define usleep(x) sleep(((x)+499999)/1000000) +#endif + +#ifdef VMS +# include +#endif + +/* all for PvdM background code: */ +#ifndef PI +# define PI 3.141592653589793238 +#endif +#define PI_2 (PI*0.5) +#define INV_PI_360 (360.0 / PI) +#define MAX(a,b) (a>b?a:b) +#define MIN(a,b) (a> 8)) >> 8); \ +} + + +#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this + * block size corresponds roughly to a download + * speed 10% faster than theoretical 33.6K maximum + * (assuming 8 data bits, 1 stop bit and no other + * overhead) */ + +/* local prototypes */ +static void rpng2_x_init (void); +static int rpng2_x_create_window (void); +static int rpng2_x_load_bg_image (void); +static void rpng2_x_display_row (ulg row); +static void rpng2_x_finish_display (void); +static void rpng2_x_redisplay_image (ulg startcol, ulg startrow, + ulg width, ulg height); +#ifdef FEATURE_LOOP +static void rpng2_x_reload_bg_image (void); +static int is_number (char *p); +#endif +static void rpng2_x_cleanup (void); +static int rpng2_x_msb (ulg u32val); + + +static char titlebar[1024], *window_name = titlebar; +static char *appname = LONGNAME; +static char *icon_name = PROGNAME; +static char *res_name = RESNAME; +static char *res_class = RESCLASS; +static char *filename; +static FILE *infile; + +static mainprog_info rpng2_info; + +static uch inbuf[INBUFSIZE]; +static int incount; + +static int pat = 6; /* must be less than num_bgpat */ +static int bg_image = 0; +static int bgscale, bgscale_default = 16; +static ulg bg_rowbytes; +static uch *bg_data; + +int pause_after_pass = FALSE; +int demo_timing = FALSE; +ulg usleep_duration = 0L; + +static struct rgb_color { + uch r, g, b; +} rgb[] = { + { 0, 0, 0}, /* 0: black */ + {255, 255, 255}, /* 1: white */ + {173, 132, 57}, /* 2: tan */ + { 64, 132, 0}, /* 3: medium green */ + {189, 117, 1}, /* 4: gold */ + {253, 249, 1}, /* 5: yellow */ + { 0, 0, 255}, /* 6: blue */ + { 0, 0, 120}, /* 7: medium blue */ + {255, 0, 255}, /* 8: magenta */ + { 64, 0, 64}, /* 9: dark magenta */ + {255, 0, 0}, /* 10: red */ + { 64, 0, 0}, /* 11: dark red */ + {255, 127, 0}, /* 12: orange */ + {192, 96, 0}, /* 13: darker orange */ + { 24, 60, 0}, /* 14: dark green-yellow */ + { 85, 125, 200}, /* 15: ice blue */ + {192, 192, 192} /* 16: Netscape/Mosaic gray */ +}; +/* not used for now, but should be for error-checking: +static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color); + */ + +/* + This whole struct is a fairly cheesy way to keep the number of + command-line options to a minimum. The radial-waves background + type is a particularly poor fit to the integer elements of the + struct...but a few macros and a little fixed-point math will do + wonders for ya. + + type bits: + F E D C B A 9 8 7 6 5 4 3 2 1 0 + | | | | | + | | +-+-+-- 0 = sharp-edged checkerboard + | | 1 = soft diamonds + | | 2 = radial waves + | | 3-7 = undefined + | +-- gradient #2 inverted? + +-- alternating columns inverted? + */ +static struct background_pattern { + ush type; + int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */ + int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/ +} bg[] = { + {0, 1,1, 16,16}, /* checkered: white vs. light gray (basic) */ + {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */ + {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */ + {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */ + {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */ + {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */ + {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */ + {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */ + {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */ + {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */ + {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */ + {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */ + {1, 3,0, 0,0}, /* diamonds: medium green vs. black */ + {2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */ + {2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */ + {2, 16, 256, 100, 250}, /* radial: very tight spiral */ + {2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */ +}; +static int num_bgpat = sizeof(bg) / sizeof(struct background_pattern); + + +/* X-specific variables */ +static char *displayname; +static XImage *ximage; +static Display *display; +static int depth; +static Visual *visual; +static XVisualInfo *visual_list; +static int RShift, GShift, BShift; +static ulg RMask, GMask, BMask; +static Window window; +static GC gc; +static Colormap colormap; + +static int have_nondefault_visual = FALSE; +static int have_colormap = FALSE; +static int have_window = FALSE; +static int have_gc = FALSE; + + + + +int main(int argc, char **argv) +{ +#ifdef sgi + char tmpline[80]; +#endif + char *p, *bgstr = NULL; + int rc, alen, flen; + int error = 0; + int timing = FALSE; + int have_bg = FALSE; +#ifdef FEATURE_LOOP + int loop = FALSE; + long loop_interval = -1; /* seconds (100,000 max) */ +#endif + double LUT_exponent; /* just the lookup table */ + double CRT_exponent = 2.2; /* just the monitor */ + double default_display_exponent; /* whole display system */ + XEvent e; + KeySym k; + + + /* First initialize a few things, just to be sure--memset takes care of + * default background color (black), booleans (FALSE), pointers (NULL), + * etc. */ + + displayname = (char *)NULL; + filename = (char *)NULL; + memset(&rpng2_info, 0, sizeof(mainprog_info)); + + + /* Set the default value for our display-system exponent, i.e., the + * product of the CRT exponent and the exponent corresponding to + * the frame-buffer's lookup table (LUT), if any. This is not an + * exhaustive list of LUT values (e.g., OpenStep has a lot of weird + * ones), but it should cover 99% of the current possibilities. */ + +#if defined(NeXT) + /* third-party utilities can modify the default LUT exponent */ + LUT_exponent = 1.0 / 2.2; + /* + if (some_next_function_that_returns_gamma(&next_gamma)) + LUT_exponent = 1.0 / next_gamma; + */ +#elif defined(sgi) + LUT_exponent = 1.0 / 1.7; + /* there doesn't seem to be any documented function to + * get the "gamma" value, so we do it the hard way */ + infile = fopen("/etc/config/system.glGammaVal", "r"); + if (infile) { + double sgi_gamma; + + fgets(tmpline, 80, infile); + fclose(infile); + sgi_gamma = atof(tmpline); + if (sgi_gamma > 0.0) + LUT_exponent = 1.0 / sgi_gamma; + } +#elif defined(Macintosh) + LUT_exponent = 1.8 / 2.61; + /* + if (some_mac_function_that_returns_gamma(&mac_gamma)) + LUT_exponent = mac_gamma / 2.61; + */ +#else + LUT_exponent = 1.0; /* assume no LUT: most PCs */ +#endif + + /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ + default_display_exponent = LUT_exponent * CRT_exponent; + + + /* If the user has set the SCREEN_GAMMA environment variable as suggested + * (somewhat imprecisely) in the libpng documentation, use that; otherwise + * use the default value we just calculated. Either way, the user may + * override this via a command-line option. */ + + if ((p = getenv("SCREEN_GAMMA")) != NULL) + rpng2_info.display_exponent = atof(p); + else + rpng2_info.display_exponent = default_display_exponent; + + + /* Now parse the command line for options and the PNG filename. */ + + while (*++argv && !error) { + if (!strncmp(*argv, "-display", 2)) { + if (!*++argv) + ++error; + else + displayname = *argv; + } else if (!strncmp(*argv, "-gamma", 2)) { + if (!*++argv) + ++error; + else { + rpng2_info.display_exponent = atof(*argv); + if (rpng2_info.display_exponent <= 0.0) + ++error; + } + } else if (!strncmp(*argv, "-bgcolor", 4)) { + if (!*++argv) + ++error; + else { + bgstr = *argv; + if (strlen(bgstr) != 7 || bgstr[0] != '#') + ++error; + else { + have_bg = TRUE; + bg_image = FALSE; + } + } + } else if (!strncmp(*argv, "-bgpat", 4)) { + if (!*++argv) + ++error; + else { + pat = atoi(*argv); + if (pat >= 0 && pat < num_bgpat) { + bg_image = TRUE; + have_bg = FALSE; + } else + ++error; + } + } else if (!strncmp(*argv, "-usleep", 2)) { + if (!*++argv) + ++error; + else { + usleep_duration = (ulg)atol(*argv); + demo_timing = TRUE; + } + } else if (!strncmp(*argv, "-pause", 2)) { + pause_after_pass = TRUE; + } else if (!strncmp(*argv, "-timing", 2)) { + timing = TRUE; +#ifdef FEATURE_LOOP + } else if (!strncmp(*argv, "-loop", 2)) { + loop = TRUE; + if (!argv[1] || !is_number(argv[1])) + loop_interval = 2; + else { + ++argv; + loop_interval = atol(*argv); + if (loop_interval < 0) + loop_interval = 2; + else if (loop_interval > 100000) /* bit more than one day */ + loop_interval = 100000; + } +#endif + } else { + if (**argv != '-') { + filename = *argv; + if (argv[1]) /* shouldn't be any more args after filename */ + ++error; + } else + ++error; /* not expecting any other options */ + } + } + + if (!filename) + ++error; + + + /* print usage screen if any errors up to this point */ + + if (error) { + fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); + readpng2_version_info(); + fprintf(stderr, "\n" + "Usage: "); + fprintf(stderr, + "%s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n" + " %*s [-usleep dur | -timing] [-pause]\n", + PROGNAME, (int)strlen(PROGNAME), " "); + fprintf(stderr, +#ifdef FEATURE_LOOP + " [-loop [sec]]" +#endif + " file.png\n\n"); + fprintf(stderr, + " xdpy\tname of the target X display (e.g., ``hostname:0'')\n" + " exp \ttransfer-function exponent (``gamma'') of the display\n" + "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" + "\t\t to the product of the lookup-table exponent (varies)\n", + default_display_exponent); + fprintf(stderr, + "\t\t and the CRT exponent (usually 2.2); must be positive\n" + " bg \tdesired background color in 7-character hex RGB format\n" + "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" + "\t\t used with transparent images; overrides -bgpat\n" + " pat \tdesired background pattern number (0-%d); used with\n" + "\t\t transparent images; overrides -bgcolor\n", + num_bgpat-1); +#ifdef FEATURE_LOOP + fprintf(stderr, + " -loop\tloops through background images after initial display\n" + "\t\t is complete (depends on -bgpat)\n" + " sec \tseconds to display each background image (default = 2)\n"); +#endif + fprintf(stderr, + " dur \tduration in microseconds to wait after displaying each\n" + "\t\t row (for demo purposes)\n" + " -timing\tenables delay for every block read, to simulate modem\n" + "\t\t download of image (~36 Kbps)\n" + " -pause\tpauses after displaying each pass until mouse clicked\n" + "\nPress Q, Esc or mouse button 1 (within image window, after image\n" + "is displayed) to quit.\n"); + exit(1); + } + + if (!(infile = fopen(filename, "rb"))) { + fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); + ++error; + } else { + incount = fread(inbuf, 1, INBUFSIZE, infile); + if (incount < 8 || !readpng2_check_sig(inbuf, 8)) { + fprintf(stderr, PROGNAME + ": [%s] is not a PNG file: incorrect signature\n", + filename); + ++error; + } else if ((rc = readpng2_init(&rpng2_info)) != 0) { + switch (rc) { + case 2: + fprintf(stderr, PROGNAME + ": [%s] has bad IHDR (libpng longjmp)\n", filename); + break; + case 4: + fprintf(stderr, PROGNAME ": insufficient memory\n"); + break; + default: + fprintf(stderr, PROGNAME + ": unknown readpng2_init() error\n"); + break; + } + ++error; + } else { + Trace((stderr, "about to call XOpenDisplay()\n")) + display = XOpenDisplay(displayname); + if (!display) { + readpng2_cleanup(&rpng2_info); + fprintf(stderr, PROGNAME ": can't open X display [%s]\n", + displayname? displayname : "default"); + ++error; + } + } + if (error) + fclose(infile); + } + + + if (error) { + fprintf(stderr, PROGNAME ": aborting.\n"); + exit(2); + } + + + /* set the title-bar string, but make sure buffer doesn't overflow */ + + alen = strlen(appname); + flen = strlen(filename); + if (alen + flen + 3 > 1023) + sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); + else + sprintf(titlebar, "%s: %s", appname, filename); + + + /* set some final rpng2_info variables before entering main data loop */ + + if (have_bg) { + unsigned r, g, b; /* this approach quiets compiler warnings */ + + sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); + rpng2_info.bg_red = (uch)r; + rpng2_info.bg_green = (uch)g; + rpng2_info.bg_blue = (uch)b; + } else + rpng2_info.need_bgcolor = TRUE; + + rpng2_info.state = kPreInit; + rpng2_info.mainprog_init = rpng2_x_init; + rpng2_info.mainprog_display_row = rpng2_x_display_row; + rpng2_info.mainprog_finish_display = rpng2_x_finish_display; + + + /* OK, this is the fun part: call readpng2_decode_data() at the start of + * the loop to deal with our first buffer of data (read in above to verify + * that the file is a PNG image), then loop through the file and continue + * calling the same routine to handle each chunk of data. It in turn + * passes the data to libpng, which will invoke one or more of our call- + * backs as decoded data become available. We optionally call sleep() for + * one second per iteration to simulate downloading the image via an analog + * modem. */ + + for (;;) { + Trace((stderr, "about to call readpng2_decode_data()\n")) + if (readpng2_decode_data(&rpng2_info, inbuf, incount)) + ++error; + Trace((stderr, "done with readpng2_decode_data()\n")) + + if (error || incount != INBUFSIZE || rpng2_info.state == kDone) { + if (rpng2_info.state == kDone) { + Trace((stderr, "done decoding PNG image\n")) + } else if (ferror(infile)) { + fprintf(stderr, PROGNAME + ": error while reading PNG image file\n"); + exit(3); + } else if (feof(infile)) { + fprintf(stderr, PROGNAME ": end of file reached " + "(unexpectedly) while reading PNG image file\n"); + exit(3); + } else /* if (error) */ { + /* will print error message below */ + } + break; + } + + if (timing) + sleep(1); + + incount = fread(inbuf, 1, INBUFSIZE, infile); + } + + + /* clean up PNG stuff and report any decoding errors */ + + fclose(infile); + Trace((stderr, "about to call readpng2_cleanup()\n")) + readpng2_cleanup(&rpng2_info); + + if (error) { + fprintf(stderr, PROGNAME ": libpng error while decoding PNG image\n"); + exit(3); + } + + +#ifdef FEATURE_LOOP + + if (loop && bg_image) { + Trace((stderr, "entering -loop loop (FEATURE_LOOP)\n")) + for (;;) { + int i, use_sleep; + struct timeval now, then; + + /* get current time and add loop_interval to get target time */ + if (gettimeofday(&then, NULL) == 0) { + then.tv_sec += loop_interval; + use_sleep = FALSE; + } else + use_sleep = TRUE; + + /* do quick check for a quit event but don't wait for it */ + /* GRR BUG: should also check for Expose events and redraw... */ + if (XCheckMaskEvent(display, KeyPressMask | ButtonPressMask, &e)) + if (QUIT(e,k)) + break; + + /* generate next background image */ + if (++pat >= num_bgpat) + pat = 0; + rpng2_x_reload_bg_image(); + + /* wait for timeout, using whatever means are available */ + if (use_sleep || gettimeofday(&now, NULL) != 0) { + for (i = loop_interval; i > 0; --i) { + sleep(1); + /* GRR BUG: also need to check for Expose (and redraw!) */ + if (XCheckMaskEvent(display, KeyPressMask | ButtonPressMask, + &e) && QUIT(e,k)) + break; + } + } else { + /* Y2038 BUG! */ + if (now.tv_sec < then.tv_sec || + (now.tv_sec == then.tv_sec && now.tv_usec < then.tv_usec)) + { + int quit = FALSE; + long seconds_to_go = then.tv_sec - now.tv_sec; + long usleep_usec; + + /* basically chew up most of remaining loop-interval with + * calls to sleep(1) interleaved with checks for quit + * events, but also recalc time-to-go periodically; when + * done, clean up any remaining time with usleep() call + * (could also use SIGALRM, but signals are a pain...) */ + while (seconds_to_go-- > 1) { + int seconds_done = 0; + + for (i = seconds_to_go; i > 0 && !quit; --i) { + sleep(1); + /* GRR BUG: need to check for Expose and redraw */ + if (XCheckMaskEvent(display, KeyPressMask | + ButtonPressMask, &e) && QUIT(e,k)) + quit = TRUE; + if (++seconds_done > 1000) + break; /* time to redo seconds_to_go meas. */ + } + if (quit) + break; + + /* OK, more than 1000 seconds since last check: + * correct the time-to-go measurement for drift */ + if (gettimeofday(&now, NULL) == 0) { + if (now.tv_sec >= then.tv_sec) + break; + seconds_to_go = then.tv_sec - now.tv_sec; + } else + ++seconds_to_go; /* restore what we subtracted */ + } + if (quit) + break; /* breaks outer do-loop, skips redisplay */ + + /* since difference between "now" and "then" is already + * eaten up to within a couple of seconds, don't need to + * worry about overflow--but might have overshot (neg.) */ + if (gettimeofday(&now, NULL) == 0) { + usleep_usec = 1000000L*(then.tv_sec - now.tv_sec) + + then.tv_usec - now.tv_usec; + if (usleep_usec > 0) + usleep((ulg)usleep_usec); + } + } + } + + /* composite image against new background and display (note that + * we do not take into account the time spent doing this...) */ + rpng2_x_redisplay_image (0, 0, rpng2_info.width, rpng2_info.height); + } + + } else /* FALL THROUGH and do the normal thing */ + +#endif /* FEATURE_LOOP */ + + /* wait for the user to tell us when to quit */ + + if (rpng2_info.state >= kWindowInit) { + Trace((stderr, "entering final wait-for-quit-event loop\n")) + do { + XNextEvent(display, &e); + if (e.type == Expose) { + XExposeEvent *ex = (XExposeEvent *)&e; + rpng2_x_redisplay_image (ex->x, ex->y, ex->width, ex->height); + } + } while (!QUIT(e,k)); + } else { + fprintf(stderr, PROGNAME ": init callback never called: probable " + "libpng error while decoding PNG metadata\n"); + exit(4); + } + + + /* we're done: clean up all image and X resources and go away */ + + Trace((stderr, "about to call rpng2_x_cleanup()\n")) + rpng2_x_cleanup(); + + (void)argc; /* Unused */ + + return 0; +} + + + + + +/* this function is called by readpng2_info_callback() in readpng2.c, which + * in turn is called by libpng after all of the pre-IDAT chunks have been + * read and processed--i.e., we now have enough info to finish initializing */ + +static void rpng2_x_init(void) +{ + ulg i; + ulg rowbytes = rpng2_info.rowbytes; + + Trace((stderr, "beginning rpng2_x_init()\n")) + Trace((stderr, " rowbytes = %d\n", rpng2_info.rowbytes)) + Trace((stderr, " width = %ld\n", rpng2_info.width)) + Trace((stderr, " height = %ld\n", rpng2_info.height)) + + /* Guard against integer overflow */ + if (rpng2_info.height > ((size_t)(-1))/rpng2_info.rowbytes) { + fprintf(stderr, PROGNAME ": image_data buffer would be too large\n"); + readpng2_cleanup(&rpng2_info); + return; + } + + rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); + if (!rpng2_info.image_data) { + readpng2_cleanup(&rpng2_info); + return; + } + + rpng2_info.row_pointers = (uch **)malloc(rpng2_info.height * sizeof(uch *)); + if (!rpng2_info.row_pointers) { + free(rpng2_info.image_data); + rpng2_info.image_data = NULL; + readpng2_cleanup(&rpng2_info); + return; + } + + for (i = 0; i < rpng2_info.height; ++i) + rpng2_info.row_pointers[i] = rpng2_info.image_data + i*rowbytes; + + + /* do the basic X initialization stuff, make the window, and fill it with + * the user-specified, file-specified or default background color or + * pattern */ + + if (rpng2_x_create_window()) { + + /* GRR TEMPORARY HACK: this is fundamentally no different from cases + * above; libpng should call our error handler to longjmp() back to us + * when png_ptr goes away. If we/it segfault instead, seems like a + * libpng bug... */ + + /* we're here via libpng callback, so if window fails, clean and bail */ + readpng2_cleanup(&rpng2_info); + rpng2_x_cleanup(); + exit(2); + } + + rpng2_info.state = kWindowInit; +} + + + + + +static int rpng2_x_create_window(void) +{ + ulg bg_red = rpng2_info.bg_red; + ulg bg_green = rpng2_info.bg_green; + ulg bg_blue = rpng2_info.bg_blue; + ulg bg_pixel = 0L; + ulg attrmask; + int need_colormap = FALSE; + int screen, pad; + uch *xdata; + Window root; + XEvent e; + XGCValues gcvalues; + XSetWindowAttributes attr; + XTextProperty windowName, *pWindowName = &windowName; + XTextProperty iconName, *pIconName = &iconName; + XVisualInfo visual_info; + XSizeHints *size_hints; + XWMHints *wm_hints; + XClassHint *class_hints; + + + Trace((stderr, "beginning rpng2_x_create_window()\n")) + + screen = DefaultScreen(display); + depth = DisplayPlanes(display, screen); + root = RootWindow(display, screen); + +#ifdef DEBUG + XSynchronize(display, True); +#endif + + if (depth != 16 && depth != 24 && depth != 32) { + int visuals_matched = 0; + + Trace((stderr, "default depth is %d: checking other visuals\n", + depth)) + + /* 24-bit first */ + visual_info.screen = screen; + visual_info.depth = 24; + visual_list = XGetVisualInfo(display, + VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched); + if (visuals_matched == 0) { +/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */ + fprintf(stderr, "default screen depth %d not supported, and no" + " 24-bit visuals found\n", depth); + return 2; + } + Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n", + visuals_matched)) + visual = visual_list[0].visual; + depth = visual_list[0].depth; +/* + colormap_size = visual_list[0].colormap_size; + visual_class = visual->class; + visualID = XVisualIDFromVisual(visual); + */ + have_nondefault_visual = TRUE; + need_colormap = TRUE; + } else { + XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info); + visual = visual_info.visual; + } + + RMask = visual->red_mask; + GMask = visual->green_mask; + BMask = visual->blue_mask; + +/* GRR: add/check 8-bit support */ + if (depth == 8 || need_colormap) { + colormap = XCreateColormap(display, root, visual, AllocNone); + if (!colormap) { + fprintf(stderr, "XCreateColormap() failed\n"); + return 2; + } + have_colormap = TRUE; + if (depth == 8) + bg_image = FALSE; /* gradient just wastes palette entries */ + } + if (depth == 15 || depth == 16) { + RShift = 15 - rpng2_x_msb(RMask); /* these are right-shifts */ + GShift = 15 - rpng2_x_msb(GMask); + BShift = 15 - rpng2_x_msb(BMask); + } else if (depth > 16) { + RShift = rpng2_x_msb(RMask) - 7; /* these are left-shifts */ + GShift = rpng2_x_msb(GMask) - 7; + BShift = rpng2_x_msb(BMask) - 7; + } + if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) { + fprintf(stderr, "rpng2 internal logic error: negative X shift(s)!\n"); + return 2; + } + +/*--------------------------------------------------------------------------- + Finally, create the window. + ---------------------------------------------------------------------------*/ + + attr.backing_store = Always; + attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask; + attrmask = CWBackingStore | CWEventMask; + if (have_nondefault_visual) { + attr.colormap = colormap; + attr.background_pixel = 0; + attr.border_pixel = 1; + attrmask |= CWColormap | CWBackPixel | CWBorderPixel; + } + + window = XCreateWindow(display, root, 0, 0, rpng2_info.width, + rpng2_info.height, 0, depth, InputOutput, visual, attrmask, &attr); + + if (window == None) { + fprintf(stderr, "XCreateWindow() failed\n"); + return 2; + } else + have_window = TRUE; + + if (depth == 8) + XSetWindowColormap(display, window, colormap); + + if (!XStringListToTextProperty(&window_name, 1, pWindowName)) + pWindowName = NULL; + if (!XStringListToTextProperty(&icon_name, 1, pIconName)) + pIconName = NULL; + + /* OK if either hints allocation fails; XSetWMProperties() allows NULLs */ + + if ((size_hints = XAllocSizeHints()) != NULL) { + /* window will not be resizable */ + size_hints->flags = PMinSize | PMaxSize; + size_hints->min_width = size_hints->max_width = (int)rpng2_info.width; + size_hints->min_height = size_hints->max_height = + (int)rpng2_info.height; + } + + if ((wm_hints = XAllocWMHints()) != NULL) { + wm_hints->initial_state = NormalState; + wm_hints->input = True; + /* wm_hints->icon_pixmap = icon_pixmap; */ + wm_hints->flags = StateHint | InputHint /* | IconPixmapHint */ ; + } + + if ((class_hints = XAllocClassHint()) != NULL) { + class_hints->res_name = res_name; + class_hints->res_class = res_class; + } + + XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0, + size_hints, wm_hints, class_hints); + + /* various properties and hints no longer needed; free memory */ + if (pWindowName) + XFree(pWindowName->value); + if (pIconName) + XFree(pIconName->value); + if (size_hints) + XFree(size_hints); + if (wm_hints) + XFree(wm_hints); + if (class_hints) + XFree(class_hints); + + XMapWindow(display, window); + + gc = XCreateGC(display, window, 0, &gcvalues); + have_gc = TRUE; + +/*--------------------------------------------------------------------------- + Allocate memory for the X- and display-specific version of the image. + ---------------------------------------------------------------------------*/ + + if (depth == 24 || depth == 32) { + xdata = (uch *)malloc(4*rpng2_info.width*rpng2_info.height); + pad = 32; + } else if (depth == 16) { + xdata = (uch *)malloc(2*rpng2_info.width*rpng2_info.height); + pad = 16; + } else /* depth == 8 */ { + xdata = (uch *)malloc(rpng2_info.width*rpng2_info.height); + pad = 8; + } + + if (!xdata) { + fprintf(stderr, PROGNAME ": unable to allocate image memory\n"); + return 4; + } + + ximage = XCreateImage(display, visual, depth, ZPixmap, 0, + (char *)xdata, rpng2_info.width, rpng2_info.height, pad, 0); + + if (!ximage) { + fprintf(stderr, PROGNAME ": XCreateImage() failed\n"); + free(xdata); + return 3; + } + + /* to avoid testing the byte order every pixel (or doubling the size of + * the drawing routine with a giant if-test), we arbitrarily set the byte + * order to MSBFirst and let Xlib worry about inverting things on little- + * endian machines (e.g., Linux/x86, old VAXen, etc.)--this is not the + * most efficient approach (the giant if-test would be better), but in + * the interest of clarity, we'll take the easy way out... */ + + ximage->byte_order = MSBFirst; + +/*--------------------------------------------------------------------------- + Fill window with the specified background color (default is black) or + faked "background image" (but latter is disabled if 8-bit; gradients + just waste palette entries). + ---------------------------------------------------------------------------*/ + + if (bg_image) + rpng2_x_load_bg_image(); /* resets bg_image if fails */ + + if (!bg_image) { + if (depth == 24 || depth == 32) { + bg_pixel = (bg_red << RShift) | + (bg_green << GShift) | + (bg_blue << BShift); + } else if (depth == 16) { + bg_pixel = (((bg_red << 8) >> RShift) & RMask) | + (((bg_green << 8) >> GShift) & GMask) | + (((bg_blue << 8) >> BShift) & BMask); + } else /* depth == 8 */ { + + /* GRR: add 8-bit support */ + + } + XSetForeground(display, gc, bg_pixel); + XFillRectangle(display, window, gc, 0, 0, rpng2_info.width, + rpng2_info.height); + } + +/*--------------------------------------------------------------------------- + Wait for first Expose event to do any drawing, then flush and return. + ---------------------------------------------------------------------------*/ + + do + XNextEvent(display, &e); + while (e.type != Expose || e.xexpose.count); + + XFlush(display); + + return 0; + +} /* end function rpng2_x_create_window() */ + + + + + +static int rpng2_x_load_bg_image(void) +{ + uch *src; + char *dest; + uch r1, r2, g1, g2, b1, b2; + uch r1_inv, r2_inv, g1_inv, g2_inv, b1_inv, b2_inv; + int k, hmax, max; + int xidx, yidx, yidx_max; + int even_odd_vert, even_odd_horiz, even_odd; + int invert_gradient2 = (bg[pat].type & 0x08); + int invert_column; + int ximage_rowbytes = ximage->bytes_per_line; + ulg i, row; + ulg pixel; + +/*--------------------------------------------------------------------------- + Allocate buffer for fake background image to be used with transparent + images; if this fails, revert to plain background color. + ---------------------------------------------------------------------------*/ + + bg_rowbytes = 3 * rpng2_info.width; + bg_data = (uch *)malloc(bg_rowbytes * rpng2_info.height); + if (!bg_data) { + fprintf(stderr, PROGNAME + ": unable to allocate memory for background image\n"); + bg_image = 0; + return 1; + } + + bgscale = (pat == 0)? 8 : bgscale_default; + yidx_max = bgscale - 1; + +/*--------------------------------------------------------------------------- + Vertical gradients (ramps) in NxN squares, alternating direction and + colors (N == bgscale). + ---------------------------------------------------------------------------*/ + + if ((bg[pat].type & 0x07) == 0) { + uch r1_min = rgb[bg[pat].rgb1_min].r; + uch g1_min = rgb[bg[pat].rgb1_min].g; + uch b1_min = rgb[bg[pat].rgb1_min].b; + uch r2_min = rgb[bg[pat].rgb2_min].r; + uch g2_min = rgb[bg[pat].rgb2_min].g; + uch b2_min = rgb[bg[pat].rgb2_min].b; + int r1_diff = rgb[bg[pat].rgb1_max].r - r1_min; + int g1_diff = rgb[bg[pat].rgb1_max].g - g1_min; + int b1_diff = rgb[bg[pat].rgb1_max].b - b1_min; + int r2_diff = rgb[bg[pat].rgb2_max].r - r2_min; + int g2_diff = rgb[bg[pat].rgb2_max].g - g2_min; + int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min; + + for (row = 0; row < rpng2_info.height; ++row) { + yidx = (int)(row % bgscale); + even_odd_vert = (int)((row / bgscale) & 1); + + r1 = r1_min + (r1_diff * yidx) / yidx_max; + g1 = g1_min + (g1_diff * yidx) / yidx_max; + b1 = b1_min + (b1_diff * yidx) / yidx_max; + r1_inv = r1_min + (r1_diff * (yidx_max-yidx)) / yidx_max; + g1_inv = g1_min + (g1_diff * (yidx_max-yidx)) / yidx_max; + b1_inv = b1_min + (b1_diff * (yidx_max-yidx)) / yidx_max; + + r2 = r2_min + (r2_diff * yidx) / yidx_max; + g2 = g2_min + (g2_diff * yidx) / yidx_max; + b2 = b2_min + (b2_diff * yidx) / yidx_max; + r2_inv = r2_min + (r2_diff * (yidx_max-yidx)) / yidx_max; + g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max; + b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max; + + dest = (char *)bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + even_odd_horiz = (int)((i / bgscale) & 1); + even_odd = even_odd_vert ^ even_odd_horiz; + invert_column = + (even_odd_horiz && (bg[pat].type & 0x10)); + if (even_odd == 0) { /* gradient #1 */ + if (invert_column) { + *dest++ = r1_inv; + *dest++ = g1_inv; + *dest++ = b1_inv; + } else { + *dest++ = r1; + *dest++ = g1; + *dest++ = b1; + } + } else { /* gradient #2 */ + if ((invert_column && invert_gradient2) || + (!invert_column && !invert_gradient2)) + { + *dest++ = r2; /* not inverted or */ + *dest++ = g2; /* doubly inverted */ + *dest++ = b2; + } else { + *dest++ = r2_inv; + *dest++ = g2_inv; /* singly inverted */ + *dest++ = b2_inv; + } + } + } + } + +/*--------------------------------------------------------------------------- + Soft gradient-diamonds with scale = bgscale. Code contributed by Adam + M. Costello. + ---------------------------------------------------------------------------*/ + + } else if ((bg[pat].type & 0x07) == 1) { + + hmax = (bgscale-1)/2; /* half the max weight of a color */ + max = 2*hmax; /* the max weight of a color */ + + r1 = rgb[bg[pat].rgb1_max].r; + g1 = rgb[bg[pat].rgb1_max].g; + b1 = rgb[bg[pat].rgb1_max].b; + r2 = rgb[bg[pat].rgb2_max].r; + g2 = rgb[bg[pat].rgb2_max].g; + b2 = rgb[bg[pat].rgb2_max].b; + + for (row = 0; row < rpng2_info.height; ++row) { + yidx = (int)(row % bgscale); + if (yidx > hmax) + yidx = bgscale-1 - yidx; + dest = (char *)bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + xidx = (int)(i % bgscale); + if (xidx > hmax) + xidx = bgscale-1 - xidx; + k = xidx + yidx; + *dest++ = (k*r1 + (max-k)*r2) / max; + *dest++ = (k*g1 + (max-k)*g2) / max; + *dest++ = (k*b1 + (max-k)*b2) / max; + } + } + +/*--------------------------------------------------------------------------- + Radial "starburst" with azimuthal sinusoids; [eventually number of sinu- + soids will equal bgscale?]. This one is slow but very cool. Code con- + tributed by Pieter S. van der Meulen (originally in Smalltalk). + ---------------------------------------------------------------------------*/ + + } else if ((bg[pat].type & 0x07) == 2) { + uch ch; + int ii, x, y, hw, hh, grayspot; + double freq, rotate, saturate, gray, intensity; + double angle=0.0, aoffset=0.0, maxDist, dist; + double red=0.0, green=0.0, blue=0.0, hue, s, v, f, p, q, t; + + fprintf(stderr, "%s: computing radial background...", + PROGNAME); + fflush(stderr); + + hh = (int)(rpng2_info.height / 2); + hw = (int)(rpng2_info.width / 2); + + /* variables for radial waves: + * aoffset: number of degrees to rotate hue [CURRENTLY NOT USED] + * freq: number of color beams originating from the center + * grayspot: size of the graying center area (anti-alias) + * rotate: rotation of the beams as a function of radius + * saturate: saturation of beams' shape azimuthally + */ + angle = CLIP(angle, 0.0, 360.0); + grayspot = CLIP(bg[pat].bg_gray, 1, (hh + hw)); + freq = MAX((double)bg[pat].bg_freq, 0.0); + saturate = (double)bg[pat].bg_bsat * 0.1; + rotate = (double)bg[pat].bg_brot * 0.1; + gray = 0.0; + intensity = 0.0; + maxDist = (double)((hw*hw) + (hh*hh)); + + for (row = 0; row < rpng2_info.height; ++row) { + y = (int)(row - hh); + dest = (char *)bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + x = (int)(i - hw); + angle = (x == 0)? PI_2 : atan((double)y / (double)x); + gray = (double)MAX(ABS(y), ABS(x)) / grayspot; + gray = MIN(1.0, gray); + dist = (double)((x*x) + (y*y)) / maxDist; + intensity = cos((angle+(rotate*dist*PI)) * freq) * + gray * saturate; + intensity = (MAX(MIN(intensity,1.0),-1.0) + 1.0) * 0.5; + hue = (angle + PI) * INV_PI_360 + aoffset; + s = gray * ((double)(ABS(x)+ABS(y)) / (double)(hw + hh)); + s = MIN(MAX(s,0.0), 1.0); + v = MIN(MAX(intensity,0.0), 1.0); + + if (s == 0.0) { + ch = (uch)(v * 255.0); + *dest++ = ch; + *dest++ = ch; + *dest++ = ch; + } else { + if ((hue < 0.0) || (hue >= 360.0)) + hue -= (((int)(hue / 360.0)) * 360.0); + hue /= 60.0; + ii = (int)hue; + f = hue - (double)ii; + p = (1.0 - s) * v; + q = (1.0 - (s * f)) * v; + t = (1.0 - (s * (1.0 - f))) * v; + if (ii == 0) { red = v; green = t; blue = p; } + else if (ii == 1) { red = q; green = v; blue = p; } + else if (ii == 2) { red = p; green = v; blue = t; } + else if (ii == 3) { red = p; green = q; blue = v; } + else if (ii == 4) { red = t; green = p; blue = v; } + else if (ii == 5) { red = v; green = p; blue = q; } + *dest++ = (uch)(red * 255.0); + *dest++ = (uch)(green * 255.0); + *dest++ = (uch)(blue * 255.0); + } + } + } + fprintf(stderr, "done.\n"); + fflush(stderr); + } + +/*--------------------------------------------------------------------------- + Blast background image to display buffer before beginning PNG decode. + ---------------------------------------------------------------------------*/ + + if (depth == 24 || depth == 32) { + ulg red, green, blue; + int bpp = ximage->bits_per_pixel; + + for (row = 0; row < rpng2_info.height; ++row) { + src = bg_data + row*bg_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + if (bpp == 32) { /* slightly optimized version */ + for (i = rpng2_info.width; i > 0; --i) { + red = *src++; + green = *src++; + blue = *src++; + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } else { + for (i = rpng2_info.width; i > 0; --i) { + red = *src++; + green = *src++; + blue = *src++; + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + /* GRR BUG? this assumes bpp == 24 & bits are packed low */ + /* (probably need to use RShift, RMask, etc.) */ + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + } + + } else if (depth == 16) { + ush red, green, blue; + + for (row = 0; row < rpng2_info.height; ++row) { + src = bg_data + row*bg_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + for (i = rpng2_info.width; i > 0; --i) { + red = ((ush)(*src) << 8); ++src; + green = ((ush)(*src) << 8); ++src; + blue = ((ush)(*src) << 8); ++src; + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + + } else /* depth == 8 */ { + + /* GRR: add 8-bit support */ + + } + + XPutImage(display, window, gc, ximage, 0, 0, 0, 0, rpng2_info.width, + rpng2_info.height); + + return 0; + +} /* end function rpng2_x_load_bg_image() */ + + + + + +static void rpng2_x_display_row(ulg row) +{ + uch bg_red = rpng2_info.bg_red; + uch bg_green = rpng2_info.bg_green; + uch bg_blue = rpng2_info.bg_blue; + uch *src, *src2=NULL; + char *dest; + uch r, g, b, a; + int ximage_rowbytes = ximage->bytes_per_line; + ulg i, pixel; + static int rows=0, prevpass=(-1); + static ulg firstrow; + +/*--------------------------------------------------------------------------- + rows and firstrow simply track how many rows (and which ones) have not + yet been displayed; alternatively, we could call XPutImage() for every + row and not bother with the records-keeping. + ---------------------------------------------------------------------------*/ + + Trace((stderr, "beginning rpng2_x_display_row()\n")) + + if (rpng2_info.pass != prevpass) { + if (pause_after_pass && rpng2_info.pass > 0) { + XEvent e; + KeySym k; + + fprintf(stderr, + "%s: end of pass %d of 7; click in image window to continue\n", + PROGNAME, prevpass + 1); + do + XNextEvent(display, &e); + while (!QUIT(e,k)); + } + fprintf(stderr, "%s: pass %d of 7\r", PROGNAME, rpng2_info.pass + 1); + fflush(stderr); + prevpass = rpng2_info.pass; + } + + if (rows == 0) + firstrow = row; /* first row that is not yet displayed */ + + ++rows; /* count of rows received but not yet displayed */ + +/*--------------------------------------------------------------------------- + Aside from the use of the rpng2_info struct, the lack of an outer loop + (over rows) and moving the XPutImage() call outside the "if (depth)" + tests, this routine is identical to rpng_x_display_image() in the non- + progressive version of the program. + ---------------------------------------------------------------------------*/ + + if (depth == 24 || depth == 32) { + ulg red, green, blue; + int bpp = ximage->bits_per_pixel; + + src = rpng2_info.image_data + row*rpng2_info.rowbytes; + if (bg_image) + src2 = bg_data + row*bg_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + if (rpng2_info.channels == 3) { + for (i = rpng2_info.width; i > 0; --i) { + red = *src++; + green = *src++; + blue = *src++; + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + if (bpp == 32) { + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } else { + /* GRR BUG? this assumes bpp == 24 & bits are packed low */ + /* (probably need to use RShift, RMask, etc.) */ + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + } else /* if (rpng2_info.channels == 4) */ { + for (i = rpng2_info.width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (bg_image) { + bg_red = *src2++; + bg_green = *src2++; + bg_blue = *src2++; + } + if (a == 255) { + red = r; + green = g; + blue = b; + } else if (a == 0) { + red = bg_red; + green = bg_green; + blue = bg_blue; + } else { + /* this macro (from png.h) composites the foreground + * and background values and puts the result into the + * first argument */ + alpha_composite(red, r, a, bg_red); + alpha_composite(green, g, a, bg_green); + alpha_composite(blue, b, a, bg_blue); + } + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + if (bpp == 32) { + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } else { + /* GRR BUG? this assumes bpp == 24 & bits are packed low */ + /* (probably need to use RShift, RMask, etc.) */ + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + } + + } else if (depth == 16) { + ush red, green, blue; + + src = rpng2_info.row_pointers[row]; + if (bg_image) + src2 = bg_data + row*bg_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + if (rpng2_info.channels == 3) { + for (i = rpng2_info.width; i > 0; --i) { + red = ((ush)(*src) << 8); + ++src; + green = ((ush)(*src) << 8); + ++src; + blue = ((ush)(*src) << 8); + ++src; + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } else /* if (rpng2_info.channels == 4) */ { + for (i = rpng2_info.width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (bg_image) { + bg_red = *src2++; + bg_green = *src2++; + bg_blue = *src2++; + } + if (a == 255) { + red = ((ush)r << 8); + green = ((ush)g << 8); + blue = ((ush)b << 8); + } else if (a == 0) { + red = ((ush)bg_red << 8); + green = ((ush)bg_green << 8); + blue = ((ush)bg_blue << 8); + } else { + /* this macro (from png.h) composites the foreground + * and background values and puts the result back into + * the first argument (== fg byte here: safe) */ + alpha_composite(r, r, a, bg_red); + alpha_composite(g, g, a, bg_green); + alpha_composite(b, b, a, bg_blue); + red = ((ush)r << 8); + green = ((ush)g << 8); + blue = ((ush)b << 8); + } + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + + } else /* depth == 8 */ { + + /* GRR: add 8-bit support */ + + } + + +/*--------------------------------------------------------------------------- + Display after every 16 rows or when on one of last two rows. (Region + may include previously displayed lines due to interlacing--i.e., not + contiguous. Also, second-to-last row is final one in interlaced images + with odd number of rows.) For demos, flush (and delay) after every 16th + row so "sparse" passes don't go twice as fast. + ---------------------------------------------------------------------------*/ + + if (demo_timing && (row - firstrow >= 16 || row >= rpng2_info.height-2)) { + XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0, + (int)firstrow, rpng2_info.width, row - firstrow + 1); + XFlush(display); + rows = 0; + usleep(usleep_duration); + } else + if (!demo_timing && ((rows & 0xf) == 0 || row >= rpng2_info.height-2)) { + XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0, + (int)firstrow, rpng2_info.width, row - firstrow + 1); + XFlush(display); + rows = 0; + } + +} + + + + + +static void rpng2_x_finish_display(void) +{ + Trace((stderr, "beginning rpng2_x_finish_display()\n")) + + /* last row has already been displayed by rpng2_x_display_row(), so we + * have nothing to do here except set a flag and let the user know that + * the image is done */ + + rpng2_info.state = kDone; + printf( + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); + fflush(stdout); +} + + + + + +static void rpng2_x_redisplay_image(ulg startcol, ulg startrow, + ulg width, ulg height) +{ + uch bg_red = rpng2_info.bg_red; + uch bg_green = rpng2_info.bg_green; + uch bg_blue = rpng2_info.bg_blue; + uch *src, *src2=NULL; + char *dest; + uch r, g, b, a; + ulg i, row, lastrow = 0; + ulg pixel; + int ximage_rowbytes = ximage->bytes_per_line; + + + Trace((stderr, "beginning display loop (image_channels == %d)\n", + rpng2_info.channels)) + Trace((stderr, " (width = %ld, rowbytes = %d, ximage_rowbytes = %d)\n", + rpng2_info.width, rpng2_info.rowbytes, ximage_rowbytes)) + Trace((stderr, " (bpp = %d)\n", ximage->bits_per_pixel)) + Trace((stderr, " (byte_order = %s)\n", ximage->byte_order == MSBFirst? + "MSBFirst" : (ximage->byte_order == LSBFirst? "LSBFirst" : "unknown"))) + +/*--------------------------------------------------------------------------- + Aside from the use of the rpng2_info struct and of src2 (for background + image), this routine is identical to rpng_x_display_image() in the non- + progressive version of the program--for the simple reason that redisplay + of the image against a new background happens after the image is fully + decoded and therefore is, by definition, non-progressive. + ---------------------------------------------------------------------------*/ + + if (depth == 24 || depth == 32) { + ulg red, green, blue; + int bpp = ximage->bits_per_pixel; + + for (lastrow = row = startrow; row < startrow+height; ++row) { + src = rpng2_info.image_data + row*rpng2_info.rowbytes; + if (bg_image) + src2 = bg_data + row*bg_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + if (rpng2_info.channels == 3) { + for (i = rpng2_info.width; i > 0; --i) { + red = *src++; + green = *src++; + blue = *src++; +#ifdef NO_24BIT_MASKS + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + if (bpp == 32) { + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } else { + /* this assumes bpp == 24 & bits are packed low */ + /* (probably need to use RShift, RMask, etc.) */ + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } +#else + red = (RShift < 0)? red << (-RShift) : red >> RShift; + green = (GShift < 0)? green << (-GShift) : green >> GShift; + blue = (BShift < 0)? blue << (-BShift) : blue >> BShift; + pixel = (red & RMask) | (green & GMask) | (blue & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + if (bpp == 32) { + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } else { + /* GRR BUG */ + /* this assumes bpp == 24 & bits are packed low */ + /* (probably need to use RShift/RMask/etc. here, too) */ + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } +#endif + } + + } else /* if (rpng2_info.channels == 4) */ { + for (i = rpng2_info.width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (bg_image) { + bg_red = *src2++; + bg_green = *src2++; + bg_blue = *src2++; + } + if (a == 255) { + red = r; + green = g; + blue = b; + } else if (a == 0) { + red = bg_red; + green = bg_green; + blue = bg_blue; + } else { + /* this macro (from png.h) composites the foreground + * and background values and puts the result into the + * first argument */ + alpha_composite(red, r, a, bg_red); + alpha_composite(green, g, a, bg_green); + alpha_composite(blue, b, a, bg_blue); + } +#ifdef NO_24BIT_MASKS + pixel = (red << RShift) | + (green << GShift) | + (blue << BShift); + /* recall that we set ximage->byte_order = MSBFirst above */ + if (bpp == 32) { + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } else { + /* this assumes bpp == 24 & bits are packed low */ + /* (probably need to use RShift, RMask, etc.) */ + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } +#else + red = (RShift < 0)? red << (-RShift) : red >> RShift; + green = (GShift < 0)? green << (-GShift) : green >> GShift; + blue = (BShift < 0)? blue << (-BShift) : blue >> BShift; + pixel = (red & RMask) | (green & GMask) | (blue & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + if (bpp == 32) { + *dest++ = (char)((pixel >> 24) & 0xff); + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } else { + /* GRR BUG */ + /* this assumes bpp == 24 & bits are packed low */ + /* (probably need to use RShift/RMask/etc. here, too) */ + *dest++ = (char)((pixel >> 16) & 0xff); + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } +#endif + } + } + /* display after every 16 lines */ + if (((row+1) & 0xf) == 0) { + XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, + (int)lastrow, rpng2_info.width, 16); + XFlush(display); + lastrow = row + 1; + } + } + + } else if (depth == 16) { + ush red, green, blue; + + for (lastrow = row = startrow; row < startrow+height; ++row) { + src = rpng2_info.row_pointers[row]; + if (bg_image) + src2 = bg_data + row*bg_rowbytes; + dest = ximage->data + row*ximage_rowbytes; + if (rpng2_info.channels == 3) { + for (i = rpng2_info.width; i > 0; --i) { + red = ((ush)(*src) << 8); + ++src; + green = ((ush)(*src) << 8); + ++src; + blue = ((ush)(*src) << 8); + ++src; + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } else /* if (rpng2_info.channels == 4) */ { + for (i = rpng2_info.width; i > 0; --i) { + r = *src++; + g = *src++; + b = *src++; + a = *src++; + if (bg_image) { + bg_red = *src2++; + bg_green = *src2++; + bg_blue = *src2++; + } + if (a == 255) { + red = ((ush)r << 8); + green = ((ush)g << 8); + blue = ((ush)b << 8); + } else if (a == 0) { + red = ((ush)bg_red << 8); + green = ((ush)bg_green << 8); + blue = ((ush)bg_blue << 8); + } else { + /* this macro (from png.h) composites the foreground + * and background values and puts the result back into + * the first argument (== fg byte here: safe) */ + alpha_composite(r, r, a, bg_red); + alpha_composite(g, g, a, bg_green); + alpha_composite(b, b, a, bg_blue); + red = ((ush)r << 8); + green = ((ush)g << 8); + blue = ((ush)b << 8); + } + pixel = ((red >> RShift) & RMask) | + ((green >> GShift) & GMask) | + ((blue >> BShift) & BMask); + /* recall that we set ximage->byte_order = MSBFirst above */ + *dest++ = (char)((pixel >> 8) & 0xff); + *dest++ = (char)( pixel & 0xff); + } + } + /* display after every 16 lines */ + if (((row+1) & 0xf) == 0) { + XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, + (int)lastrow, rpng2_info.width, 16); + XFlush(display); + lastrow = row + 1; + } + } + + } else /* depth == 8 */ { + + /* GRR: add 8-bit support */ + + } + + Trace((stderr, "calling final XPutImage()\n")) + if (lastrow < startrow+height) { + XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, + (int)lastrow, rpng2_info.width, rpng2_info.height-lastrow); + XFlush(display); + } + + (void)startcol; + (void)width; + +} /* end function rpng2_x_redisplay_image() */ + + + + + +#ifdef FEATURE_LOOP + +static void rpng2_x_reload_bg_image(void) +{ + char *dest; + uch r1, r2, g1, g2, b1, b2; + uch r1_inv, r2_inv, g1_inv, g2_inv, b1_inv, b2_inv; + int k, hmax, max; + int xidx, yidx, yidx_max; + int even_odd_vert, even_odd_horiz, even_odd; + int invert_gradient2 = (bg[pat].type & 0x08); + int invert_column; + ulg i, row; + + + bgscale = (pat == 0)? 8 : bgscale_default; + yidx_max = bgscale - 1; + +/*--------------------------------------------------------------------------- + Vertical gradients (ramps) in NxN squares, alternating direction and + colors (N == bgscale). + ---------------------------------------------------------------------------*/ + + if ((bg[pat].type & 0x07) == 0) { + uch r1_min = rgb[bg[pat].rgb1_min].r; + uch g1_min = rgb[bg[pat].rgb1_min].g; + uch b1_min = rgb[bg[pat].rgb1_min].b; + uch r2_min = rgb[bg[pat].rgb2_min].r; + uch g2_min = rgb[bg[pat].rgb2_min].g; + uch b2_min = rgb[bg[pat].rgb2_min].b; + int r1_diff = rgb[bg[pat].rgb1_max].r - r1_min; + int g1_diff = rgb[bg[pat].rgb1_max].g - g1_min; + int b1_diff = rgb[bg[pat].rgb1_max].b - b1_min; + int r2_diff = rgb[bg[pat].rgb2_max].r - r2_min; + int g2_diff = rgb[bg[pat].rgb2_max].g - g2_min; + int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min; + + for (row = 0; row < rpng2_info.height; ++row) { + yidx = (int)(row % bgscale); + even_odd_vert = (int)((row / bgscale) & 1); + + r1 = r1_min + (r1_diff * yidx) / yidx_max; + g1 = g1_min + (g1_diff * yidx) / yidx_max; + b1 = b1_min + (b1_diff * yidx) / yidx_max; + r1_inv = r1_min + (r1_diff * (yidx_max-yidx)) / yidx_max; + g1_inv = g1_min + (g1_diff * (yidx_max-yidx)) / yidx_max; + b1_inv = b1_min + (b1_diff * (yidx_max-yidx)) / yidx_max; + + r2 = r2_min + (r2_diff * yidx) / yidx_max; + g2 = g2_min + (g2_diff * yidx) / yidx_max; + b2 = b2_min + (b2_diff * yidx) / yidx_max; + r2_inv = r2_min + (r2_diff * (yidx_max-yidx)) / yidx_max; + g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max; + b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max; + + dest = (char *)bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + even_odd_horiz = (int)((i / bgscale) & 1); + even_odd = even_odd_vert ^ even_odd_horiz; + invert_column = + (even_odd_horiz && (bg[pat].type & 0x10)); + if (even_odd == 0) { /* gradient #1 */ + if (invert_column) { + *dest++ = r1_inv; + *dest++ = g1_inv; + *dest++ = b1_inv; + } else { + *dest++ = r1; + *dest++ = g1; + *dest++ = b1; + } + } else { /* gradient #2 */ + if ((invert_column && invert_gradient2) || + (!invert_column && !invert_gradient2)) + { + *dest++ = r2; /* not inverted or */ + *dest++ = g2; /* doubly inverted */ + *dest++ = b2; + } else { + *dest++ = r2_inv; + *dest++ = g2_inv; /* singly inverted */ + *dest++ = b2_inv; + } + } + } + } + +/*--------------------------------------------------------------------------- + Soft gradient-diamonds with scale = bgscale. Code contributed by Adam + M. Costello. + ---------------------------------------------------------------------------*/ + + } else if ((bg[pat].type & 0x07) == 1) { + + hmax = (bgscale-1)/2; /* half the max weight of a color */ + max = 2*hmax; /* the max weight of a color */ + + r1 = rgb[bg[pat].rgb1_max].r; + g1 = rgb[bg[pat].rgb1_max].g; + b1 = rgb[bg[pat].rgb1_max].b; + r2 = rgb[bg[pat].rgb2_max].r; + g2 = rgb[bg[pat].rgb2_max].g; + b2 = rgb[bg[pat].rgb2_max].b; + + for (row = 0; row < rpng2_info.height; ++row) { + yidx = (int)(row % bgscale); + if (yidx > hmax) + yidx = bgscale-1 - yidx; + dest = (char *)bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + xidx = (int)(i % bgscale); + if (xidx > hmax) + xidx = bgscale-1 - xidx; + k = xidx + yidx; + *dest++ = (k*r1 + (max-k)*r2) / max; + *dest++ = (k*g1 + (max-k)*g2) / max; + *dest++ = (k*b1 + (max-k)*b2) / max; + } + } + +/*--------------------------------------------------------------------------- + Radial "starburst" with azimuthal sinusoids; [eventually number of sinu- + soids will equal bgscale?]. This one is slow but very cool. Code con- + tributed by Pieter S. van der Meulen (originally in Smalltalk). + ---------------------------------------------------------------------------*/ + + } else if ((bg[pat].type & 0x07) == 2) { + uch ch; + int ii, x, y, hw, hh, grayspot; + double freq, rotate, saturate, gray, intensity; + double angle=0.0, aoffset=0.0, maxDist, dist; + double red=0.0, green=0.0, blue=0.0, hue, s, v, f, p, q, t; + + hh = (int)(rpng2_info.height / 2); + hw = (int)(rpng2_info.width / 2); + + /* variables for radial waves: + * aoffset: number of degrees to rotate hue [CURRENTLY NOT USED] + * freq: number of color beams originating from the center + * grayspot: size of the graying center area (anti-alias) + * rotate: rotation of the beams as a function of radius + * saturate: saturation of beams' shape azimuthally + */ + angle = CLIP(angle, 0.0, 360.0); + grayspot = CLIP(bg[pat].bg_gray, 1, (hh + hw)); + freq = MAX((double)bg[pat].bg_freq, 0.0); + saturate = (double)bg[pat].bg_bsat * 0.1; + rotate = (double)bg[pat].bg_brot * 0.1; + gray = 0.0; + intensity = 0.0; + maxDist = (double)((hw*hw) + (hh*hh)); + + for (row = 0; row < rpng2_info.height; ++row) { + y = (int)(row - hh); + dest = (char *)bg_data + row*bg_rowbytes; + for (i = 0; i < rpng2_info.width; ++i) { + x = (int)(i - hw); + angle = (x == 0)? PI_2 : atan((double)y / (double)x); + gray = (double)MAX(ABS(y), ABS(x)) / grayspot; + gray = MIN(1.0, gray); + dist = (double)((x*x) + (y*y)) / maxDist; + intensity = cos((angle+(rotate*dist*PI)) * freq) * + gray * saturate; + intensity = (MAX(MIN(intensity,1.0),-1.0) + 1.0) * 0.5; + hue = (angle + PI) * INV_PI_360 + aoffset; + s = gray * ((double)(ABS(x)+ABS(y)) / (double)(hw + hh)); + s = MIN(MAX(s,0.0), 1.0); + v = MIN(MAX(intensity,0.0), 1.0); + + if (s == 0.0) { + ch = (uch)(v * 255.0); + *dest++ = ch; + *dest++ = ch; + *dest++ = ch; + } else { + if ((hue < 0.0) || (hue >= 360.0)) + hue -= (((int)(hue / 360.0)) * 360.0); + hue /= 60.0; + ii = (int)hue; + f = hue - (double)ii; + p = (1.0 - s) * v; + q = (1.0 - (s * f)) * v; + t = (1.0 - (s * (1.0 - f))) * v; + if (ii == 0) { red = v; green = t; blue = p; } + else if (ii == 1) { red = q; green = v; blue = p; } + else if (ii == 2) { red = p; green = v; blue = t; } + else if (ii == 3) { red = p; green = q; blue = v; } + else if (ii == 4) { red = t; green = p; blue = v; } + else if (ii == 5) { red = v; green = p; blue = q; } + *dest++ = (uch)(red * 255.0); + *dest++ = (uch)(green * 255.0); + *dest++ = (uch)(blue * 255.0); + } + } + } + } + +} /* end function rpng2_x_reload_bg_image() */ + + + + + +static int is_number(char *p) +{ + while (*p) { + if (!isdigit(*p)) + return FALSE; + ++p; + } + return TRUE; +} + +#endif /* FEATURE_LOOP */ + + + + + +static void rpng2_x_cleanup(void) +{ + if (bg_image && bg_data) { + free(bg_data); + bg_data = NULL; + } + + if (rpng2_info.image_data) { + free(rpng2_info.image_data); + rpng2_info.image_data = NULL; + } + + if (rpng2_info.row_pointers) { + free(rpng2_info.row_pointers); + rpng2_info.row_pointers = NULL; + } + + if (ximage) { + if (ximage->data) { + free(ximage->data); /* we allocated it, so we free it */ + ximage->data = (char *)NULL; /* instead of XDestroyImage() */ + } + XDestroyImage(ximage); + ximage = NULL; + } + + if (have_gc) + XFreeGC(display, gc); + + if (have_window) + XDestroyWindow(display, window); + + if (have_colormap) + XFreeColormap(display, colormap); + + if (have_nondefault_visual) + XFree(visual_list); +} + + + + + +static int rpng2_x_msb(ulg u32val) +{ + int i; + + for (i = 31; i >= 0; --i) { + if (u32val & 0x80000000L) + break; + u32val <<= 1; + } + return i; +} diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/toucan.png b/thirdparty/libpng-1.6.37/contrib/gregbook/toucan.png new file mode 100644 index 0000000..72b472e --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/toucan.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9813e3a499eb5145c88dec52327de8493362155f43ced42737caad513db94de7 +size 12901 diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/wpng.c b/thirdparty/libpng-1.6.37/contrib/gregbook/wpng.c new file mode 100644 index 0000000..a8f367f --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/wpng.c @@ -0,0 +1,865 @@ +/*--------------------------------------------------------------------------- + + wpng - simple PNG-writing program wpng.c + + This program converts certain NetPBM binary files (grayscale and RGB, + maxval = 255) to PNG. Non-interlaced PNGs are written progressively; + interlaced PNGs are read and written in one memory-intensive blast. + + Thanks to Jean-loup Gailly for providing the necessary trick to read + interactive text from the keyboard while stdin is redirected. Thanks + to Cosmin Truta for Cygwin fixes. + + NOTE: includes provisional support for PNM type "8" (portable alphamap) + images, presumed to be a 32-bit interleaved RGBA format; no pro- + vision for possible interleaved grayscale+alpha (16-bit) format. + THIS IS UNLIKELY TO BECOME AN OFFICIAL NETPBM ALPHA FORMAT! + + to do: + - delete output file if quit before calling any writepng routines + - process backspace with -text option under DOS/Win? (currently get ^H) + + --------------------------------------------------------------------------- + + Changelog: + - 1.01: initial public release + - 1.02: modified to allow abbreviated options + - 1.03: removed extraneous character from usage screen; fixed bug in + command-line parsing + - 1.04: fixed DOS/OS2/Win32 detection, including partial Cygwin fix + (see http://home.att.net/~perlspinr/diffs/GregBook_cygwin.diff) + - 2.00: dual-licensed (added GNU GPL) + - 2.01: check for integer overflow (Glenn R-P) + + [REPORTED BUG (win32 only): "contrib/gregbook/wpng.c - cmd line + dose not work! In order to do something useful I needed to redirect + both input and output, with cygwin and with bcc32 as well. Under + Linux, the same wpng appears to work fine. I don't know what is + the problem."] + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2007, 2017 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ---------------------------------------------------------------------------*/ + +#define PROGNAME "wpng" +#define VERSION "2.00 of 2 June 2007" +#define APPNAME "Simple PGM/PPM/PAM to PNG Converter" + +#if defined(__MSDOS__) || defined(__OS2__) +# define DOS_OS2_W32 +#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) +# ifndef __GNUC__ /* treat Win32 native ports of gcc as Unix environments */ +# define DOS_OS2_W32 +# endif +#endif + +#include +#include +#include +#include /* for jmpbuf declaration in writepng.h */ +#include + +#ifdef DOS_OS2_W32 +# include /* for isatty(), setmode() prototypes */ +# include /* O_BINARY for fdopen() without text translation */ +# ifdef __EMX__ +# ifndef getch +# define getch() _read_kbd(0, 1, 0) /* need getche() */ +# endif +# else /* !__EMX__ */ +# ifdef __GO32__ +# include +# define getch() getkey() /* GRR: need getche() */ +# else +# include /* for getche() console input */ +# endif +# endif /* ?__EMX__ */ +# define FGETS(buf,len,stream) dos_kbd_gets(buf,len) +#else +# include /* for isatty() prototype */ +# define FGETS fgets +#endif + +/* #define DEBUG : this enables the Trace() macros */ + +/* #define FORBID_LATIN1_CTRL : this requires the user to re-enter any + text that includes control characters discouraged by the PNG spec; text + that includes an escape character (27) must be re-entered regardless */ + +#include "writepng.h" /* typedefs, common macros, writepng prototypes */ + + + +/* local prototypes */ + +static int wpng_isvalid_latin1(uch *p, int len); +static void wpng_cleanup(void); + +#ifdef DOS_OS2_W32 + static char *dos_kbd_gets(char *buf, int len); +#endif + + + +static mainprog_info wpng_info; /* lone global */ + + + +int main(int argc, char **argv) +{ +#ifndef DOS_OS2_W32 + FILE *keybd; +#endif +#ifdef sgi + FILE *tmpfile; /* or we could just use keybd, since no overlap */ + char tmpline[80]; +#endif + char *inname = NULL, outname[256]; + char *p, pnmchar, pnmline[256]; + char *bgstr, *textbuf = NULL; + ulg rowbytes; + int rc, len = 0; + int error = 0; + int text = FALSE; + int maxval; + double LUT_exponent; /* just the lookup table */ + double CRT_exponent = 2.2; /* just the monitor */ + double default_display_exponent; /* whole display system */ + double default_gamma = 0.0; + + + wpng_info.infile = NULL; + wpng_info.outfile = NULL; + wpng_info.image_data = NULL; + wpng_info.row_pointers = NULL; + wpng_info.filter = FALSE; + wpng_info.interlaced = FALSE; + wpng_info.have_bg = FALSE; + wpng_info.have_time = FALSE; + wpng_info.have_text = 0; + wpng_info.gamma = 0.0; + + + /* First get the default value for our display-system exponent, i.e., + * the product of the CRT exponent and the exponent corresponding to + * the frame-buffer's lookup table (LUT), if any. If the PNM image + * looks correct on the user's display system, its file gamma is the + * inverse of this value. (Note that this is not an exhaustive list + * of LUT values--e.g., OpenStep has a lot of weird ones--but it should + * cover 99% of the current possibilities. This section must ensure + * that default_display_exponent is positive.) */ + +#if defined(NeXT) + /* third-party utilities can modify the default LUT exponent */ + LUT_exponent = 1.0 / 2.2; + /* + if (some_next_function_that_returns_gamma(&next_gamma)) + LUT_exponent = 1.0 / next_gamma; + */ +#elif defined(sgi) + LUT_exponent = 1.0 / 1.7; + /* there doesn't seem to be any documented function to + * get the "gamma" value, so we do it the hard way */ + tmpfile = fopen("/etc/config/system.glGammaVal", "r"); + if (tmpfile) { + double sgi_gamma; + + fgets(tmpline, 80, tmpfile); + fclose(tmpfile); + sgi_gamma = atof(tmpline); + if (sgi_gamma > 0.0) + LUT_exponent = 1.0 / sgi_gamma; + } +#elif defined(Macintosh) + LUT_exponent = 1.8 / 2.61; + /* + if (some_mac_function_that_returns_gamma(&mac_gamma)) + LUT_exponent = mac_gamma / 2.61; + */ +#else + LUT_exponent = 1.0; /* assume no LUT: most PCs */ +#endif + + /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ + default_display_exponent = LUT_exponent * CRT_exponent; + + + /* If the user has set the SCREEN_GAMMA environment variable as suggested + * (somewhat imprecisely) in the libpng documentation, use that; otherwise + * use the default value we just calculated. Either way, the user may + * override this via a command-line option. */ + + if ((p = getenv("SCREEN_GAMMA")) != NULL) { + double exponent = atof(p); + + if (exponent > 0.0) + default_gamma = 1.0 / exponent; + } + + if (default_gamma == 0.0) + default_gamma = 1.0 / default_display_exponent; + + + /* Now parse the command line for options and the PNM filename. */ + + while (*++argv && !error) { + if (!strncmp(*argv, "-i", 2)) { + wpng_info.interlaced = TRUE; + } else if (!strncmp(*argv, "-time", 3)) { + wpng_info.modtime = time(NULL); + wpng_info.have_time = TRUE; + } else if (!strncmp(*argv, "-text", 3)) { + text = TRUE; + } else if (!strncmp(*argv, "-gamma", 2)) { + if (!*++argv) + ++error; + else { + wpng_info.gamma = atof(*argv); + if (wpng_info.gamma <= 0.0) + ++error; + else if (wpng_info.gamma > 1.01) + fprintf(stderr, PROGNAME + " warning: file gammas are usually less than 1.0\n"); + } + } else if (!strncmp(*argv, "-bgcolor", 4)) { + if (!*++argv) + ++error; + else { + bgstr = *argv; + if (strlen(bgstr) != 7 || bgstr[0] != '#') + ++error; + else { + unsigned r, g, b; /* this way quiets compiler warnings */ + + sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); + wpng_info.bg_red = (uch)r; + wpng_info.bg_green = (uch)g; + wpng_info.bg_blue = (uch)b; + wpng_info.have_bg = TRUE; + } + } + } else { + if (**argv != '-') { + inname = *argv; + if (argv[1]) /* shouldn't be any more args after filename */ + ++error; + } else + ++error; /* not expecting any other options */ + } + } + + + /* open the input and output files, or register an error and abort */ + + if (!inname) { + if (isatty(0)) { + fprintf(stderr, PROGNAME + ": must give input filename or provide image data via stdin\n"); + ++error; + } else { +#ifdef DOS_OS2_W32 + /* some buggy C libraries require BOTH setmode() and fdopen(bin) */ + setmode(fileno(stdin), O_BINARY); + setmode(fileno(stdout), O_BINARY); +#endif + if ((wpng_info.infile = fdopen(fileno(stdin), "rb")) == NULL) { + fprintf(stderr, PROGNAME + ": unable to reopen stdin in binary mode\n"); + ++error; + } else + if ((wpng_info.outfile = fdopen(fileno(stdout), "wb")) == NULL) { + fprintf(stderr, PROGNAME + ": unable to reopen stdout in binary mode\n"); + fclose(wpng_info.infile); + ++error; + } else + wpng_info.filter = TRUE; + } + } else if ((len = strlen(inname)) > 250) { + fprintf(stderr, PROGNAME ": input filename is too long [%d chars]\n", + len); + ++error; + } else if (!(wpng_info.infile = fopen(inname, "rb"))) { + fprintf(stderr, PROGNAME ": can't open input file [%s]\n", inname); + ++error; + } + + if (!error) { + fgets(pnmline, 256, wpng_info.infile); + if (pnmline[0] != 'P' || ((pnmchar = pnmline[1]) != '5' && + pnmchar != '6' && pnmchar != '8')) + { + fprintf(stderr, PROGNAME + ": input file [%s] is not a binary PGM, PPM or PAM file\n", + inname); + ++error; + } else { + wpng_info.pnmtype = (int)(pnmchar - '0'); + if (wpng_info.pnmtype != 8) + wpng_info.have_bg = FALSE; /* no need for bg if opaque */ + do { + fgets(pnmline, 256, wpng_info.infile); /* lose any comments */ + } while (pnmline[0] == '#'); + sscanf(pnmline, "%ld %ld", &wpng_info.width, &wpng_info.height); + do { + fgets(pnmline, 256, wpng_info.infile); /* more comment lines */ + } while (pnmline[0] == '#'); + sscanf(pnmline, "%d", &maxval); + if (wpng_info.width <= 0L || wpng_info.height <= 0L || + maxval != 255) + { + fprintf(stderr, PROGNAME + ": only positive width/height, maxval == 255 allowed \n"); + ++error; + } + wpng_info.sample_depth = 8; /* <==> maxval 255 */ + + if (!wpng_info.filter) { + /* make outname from inname */ + if ((p = strrchr(inname, '.')) == NULL || + (p - inname) != (len - 4)) + { + strcpy(outname, inname); + strcpy(outname+len, ".png"); + } else { + len -= 4; + strncpy(outname, inname, len); + strcpy(outname+len, ".png"); + } + /* check if outname already exists; if not, open */ + if ((wpng_info.outfile = fopen(outname, "rb")) != NULL) { + fprintf(stderr, PROGNAME ": output file exists [%s]\n", + outname); + fclose(wpng_info.outfile); + ++error; + } else if (!(wpng_info.outfile = fopen(outname, "wb"))) { + fprintf(stderr, PROGNAME ": can't open output file [%s]\n", + outname); + ++error; + } + } + } + if (error) { + fclose(wpng_info.infile); + wpng_info.infile = NULL; + if (wpng_info.filter) { + fclose(wpng_info.outfile); + wpng_info.outfile = NULL; + } + } + } + + + /* if we had any errors, print usage and die horrible death...arrr! */ + + if (error) { + fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, APPNAME); + writepng_version_info(); + fprintf(stderr, "\n" +"Usage: %s [-gamma exp] [-bgcolor bg] [-text] [-time] [-interlace] pnmfile\n" +"or: ... | %s [-gamma exp] [-bgcolor bg] [-text] [-time] [-interlace] | ...\n" + " exp \ttransfer-function exponent (``gamma'') of the image in\n" + "\t\t floating-point format (e.g., ``%.5f''); if image looks\n" + "\t\t correct on given display system, image gamma is equal to\n" + "\t\t inverse of display-system exponent, i.e., 1 / (LUT * CRT)\n" + "\t\t (where LUT = lookup-table exponent and CRT = CRT exponent;\n" + "\t\t first varies, second is usually 2.2, all are positive)\n" + " bg \tdesired background color for alpha-channel images, in\n" + "\t\t 7-character hex RGB format (e.g., ``#ff7700'' for orange:\n" + "\t\t same as HTML colors)\n" + " -text\tprompt interactively for text info (tEXt chunks)\n" + " -time\tinclude a tIME chunk (last modification time)\n" + " -interlace\twrite interlaced PNG image\n" + "\n" +"pnmfile or stdin must be a binary PGM (`P5'), PPM (`P6') or (extremely\n" +"unofficial and unsupported!) PAM (`P8') file. Currently it is required\n" +"to have maxval == 255 (i.e., no scaling). If pnmfile is specified, it\n" +"is converted to the corresponding PNG file with the same base name but a\n" +"``.png'' extension; files read from stdin are converted and sent to stdout.\n" +"The conversion is progressive (low memory usage) unless interlacing is\n" +"requested; in that case the whole image will be buffered in memory and\n" +"written in one call.\n" + "\n", PROGNAME, PROGNAME, default_gamma); + exit(1); + } + + + /* prepare the text buffers for libpng's use; note that even though + * PNG's png_text struct includes a length field, we don't have to fill + * it out */ + + if (text && +#ifndef DOS_OS2_W32 + (keybd = fdopen(fileno(stderr), "r")) != NULL && +#endif + (textbuf = (char *)malloc((5 + 9)*75)) != NULL) + { + int i, valid, result; + + fprintf(stderr, + "Enter text info (no more than 72 characters per line);\n"); + fprintf(stderr, "to skip a field, hit the key.\n"); + /* note: just leaves len == 1 */ + + do { + valid = TRUE; + p = textbuf + TEXT_TITLE_OFFSET; + fprintf(stderr, " Title: "); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { + if (p[len-1] == '\n') + p[--len] = '\0'; + wpng_info.title = p; + wpng_info.have_text |= TEXT_TITLE; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_TITLE; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_TITLE; + valid = FALSE; + } +#endif + } + } + } while (!valid); + + do { + valid = TRUE; + p = textbuf + TEXT_AUTHOR_OFFSET; + fprintf(stderr, " Author: "); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { + if (p[len-1] == '\n') + p[--len] = '\0'; + wpng_info.author = p; + wpng_info.have_text |= TEXT_AUTHOR; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_AUTHOR; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_AUTHOR; + valid = FALSE; + } +#endif + } + } + } while (!valid); + + do { + valid = TRUE; + p = textbuf + TEXT_DESC_OFFSET; + fprintf(stderr, " Description (up to 9 lines):\n"); + for (i = 1; i < 10; ++i) { + fprintf(stderr, " [%d] ", i); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) + p += len; /* now points at NULL; char before is newline */ + else + break; + } + if ((len = p - (textbuf + TEXT_DESC_OFFSET)) > 1) { + if (p[-1] == '\n') { + p[-1] = '\0'; + --len; + } + wpng_info.desc = textbuf + TEXT_DESC_OFFSET; + wpng_info.have_text |= TEXT_DESC; + p = textbuf + TEXT_DESC_OFFSET; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_DESC; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_DESC; + valid = FALSE; + } +#endif + } + } + } while (!valid); + + do { + valid = TRUE; + p = textbuf + TEXT_COPY_OFFSET; + fprintf(stderr, " Copyright: "); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { + if (p[len-1] == '\n') + p[--len] = '\0'; + wpng_info.copyright = p; + wpng_info.have_text |= TEXT_COPY; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_COPY; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_COPY; + valid = FALSE; + } +#endif + } + } + } while (!valid); + + do { + valid = TRUE; + p = textbuf + TEXT_EMAIL_OFFSET; + fprintf(stderr, " E-mail: "); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { + if (p[len-1] == '\n') + p[--len] = '\0'; + wpng_info.email = p; + wpng_info.have_text |= TEXT_EMAIL; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_EMAIL; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_EMAIL; + valid = FALSE; + } +#endif + } + } + } while (!valid); + + do { + valid = TRUE; + p = textbuf + TEXT_URL_OFFSET; + fprintf(stderr, " URL: "); + fflush(stderr); + if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { + if (p[len-1] == '\n') + p[--len] = '\0'; + wpng_info.url = p; + wpng_info.have_text |= TEXT_URL; + if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { + fprintf(stderr, " " PROGNAME " warning: character code" + " %u is %sdiscouraged by the PNG\n specification " + "[first occurrence was at character position #%d]\n", + (unsigned)p[result], (p[result] == 27)? "strongly " : "", + result+1); + fflush(stderr); +#ifdef FORBID_LATIN1_CTRL + wpng_info.have_text &= ~TEXT_URL; + valid = FALSE; +#else + if (p[result] == 27) { /* escape character */ + wpng_info.have_text &= ~TEXT_URL; + valid = FALSE; + } +#endif + } + } + } while (!valid); + +#ifndef DOS_OS2_W32 + fclose(keybd); +#endif + + } else if (text) { + fprintf(stderr, PROGNAME ": unable to allocate memory for text\n"); + text = FALSE; + wpng_info.have_text = 0; + } + + + /* allocate libpng stuff, initialize transformations, write pre-IDAT data */ + + if ((rc = writepng_init(&wpng_info)) != 0) { + switch (rc) { + case 2: + fprintf(stderr, PROGNAME + ": libpng initialization problem (longjmp)\n"); + break; + case 4: + fprintf(stderr, PROGNAME ": insufficient memory\n"); + break; + case 11: + fprintf(stderr, PROGNAME + ": internal logic error (unexpected PNM type)\n"); + break; + default: + fprintf(stderr, PROGNAME + ": unknown writepng_init() error\n"); + break; + } + exit(rc); + } + + + /* free textbuf, since it's a completely local variable and all text info + * has just been written to the PNG file */ + + if (text && textbuf) { + free(textbuf); + textbuf = NULL; + } + + + /* calculate rowbytes on basis of image type; note that this becomes much + * more complicated if we choose to support PBM type, ASCII PNM types, or + * 16-bit-per-sample binary data [currently not an official NetPBM type] */ + + if (wpng_info.pnmtype == 5) + rowbytes = wpng_info.width; + else if (wpng_info.pnmtype == 6) + rowbytes = wpng_info.width * 3; + else /* if (wpng_info.pnmtype == 8) */ + rowbytes = wpng_info.width * 4; + + + /* read and write the image, either in its entirety (if writing interlaced + * PNG) or row by row (if non-interlaced) */ + + fprintf(stderr, "Encoding image data...\n"); + fflush(stderr); + + if (wpng_info.interlaced) { + long i; + ulg bytes; + ulg image_bytes; + + /* Guard against integer overflow */ + if (wpng_info_height > ((size_t)(-1)/rowbytes || + wpng_info_height > ((ulg)(-1)/rowbytes) { + fprintf(stderr, PROGNAME ": image_data buffer too large\n"); + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(5); + } + + image_bytes = rowbytes * wpng_info.height; + + wpng_info.image_data = (uch *)malloc(image_bytes); + wpng_info.row_pointers = (uch **)malloc(wpng_info.height*sizeof(uch *)); + if (wpng_info.image_data == NULL || wpng_info.row_pointers == NULL) { + fprintf(stderr, PROGNAME ": insufficient memory for image data\n"); + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(5); + } + for (i = 0; i < wpng_info.height; ++i) + wpng_info.row_pointers[i] = wpng_info.image_data + i*rowbytes; + bytes = fread(wpng_info.image_data, 1, image_bytes, wpng_info.infile); + if (bytes != image_bytes) { + fprintf(stderr, PROGNAME ": expected %lu bytes, got %lu bytes\n", + image_bytes, bytes); + fprintf(stderr, " (continuing anyway)\n"); + } + if (writepng_encode_image(&wpng_info) != 0) { + fprintf(stderr, PROGNAME + ": libpng problem (longjmp) while writing image data\n"); + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(2); + } + + } else /* not interlaced: write progressively (row by row) */ { + long j; + ulg bytes; + + wpng_info.image_data = (uch *)malloc(rowbytes); + if (wpng_info.image_data == NULL) { + fprintf(stderr, PROGNAME ": insufficient memory for row data\n"); + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(5); + } + error = 0; + for (j = wpng_info.height; j > 0L; --j) { + bytes = fread(wpng_info.image_data, 1, rowbytes, wpng_info.infile); + if (bytes != rowbytes) { + fprintf(stderr, PROGNAME + ": expected %lu bytes, got %lu bytes (row %ld)\n", rowbytes, + bytes, wpng_info.height-j); + ++error; + break; + } + if (writepng_encode_row(&wpng_info) != 0) { + fprintf(stderr, PROGNAME + ": libpng problem (longjmp) while writing row %ld\n", + wpng_info.height-j); + ++error; + break; + } + } + if (error) { + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(2); + } + if (writepng_encode_finish(&wpng_info) != 0) { + fprintf(stderr, PROGNAME ": error on final libpng call\n"); + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(2); + } + } + + + /* OK, we're done (successfully): clean up all resources and quit */ + + fprintf(stderr, "Done.\n"); + fflush(stderr); + + writepng_cleanup(&wpng_info); + wpng_cleanup(); + + return 0; +} + + + + + +static int wpng_isvalid_latin1(uch *p, int len) +{ + int i, result = -1; + + for (i = 0; i < len; ++i) { + if (p[i] == 10 || (p[i] > 31 && p[i] < 127) || p[i] > 160) + continue; /* character is completely OK */ + if (result < 0 || (p[result] != 27 && p[i] == 27)) + result = i; /* mark location of first questionable one */ + } /* or of first escape character (bad) */ + + return result; +} + + + + + +static void wpng_cleanup(void) +{ + if (wpng_info.outfile) { + fclose(wpng_info.outfile); + wpng_info.outfile = NULL; + } + + if (wpng_info.infile) { + fclose(wpng_info.infile); + wpng_info.infile = NULL; + } + + if (wpng_info.image_data) { + free(wpng_info.image_data); + wpng_info.image_data = NULL; + } + + if (wpng_info.row_pointers) { + free(wpng_info.row_pointers); + wpng_info.row_pointers = NULL; + } +} + + + + +#ifdef DOS_OS2_W32 + +static char *dos_kbd_gets(char *buf, int len) +{ + int ch, count=0; + + do { + buf[count++] = ch = getche(); + } while (ch != '\r' && count < len-1); + + buf[count--] = '\0'; /* terminate string */ + if (buf[count] == '\r') /* Enter key makes CR, so change to newline */ + buf[count] = '\n'; + + fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */ + fflush(stderr); + + return buf; +} + +#endif /* DOS_OS2_W32 */ diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/writepng.c b/thirdparty/libpng-1.6.37/contrib/gregbook/writepng.c new file mode 100644 index 0000000..055c743 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/writepng.c @@ -0,0 +1,401 @@ +/*--------------------------------------------------------------------------- + + wpng - simple PNG-writing program writepng.c + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2007, 2017 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ---------------------------------------------------------------------------*/ + + +#include /* for exit() prototype */ +#include + +#include "png.h" /* libpng header, includes setjmp.h */ +#include "writepng.h" /* typedefs, common macros, public prototypes */ + + +/* local prototype */ + +static void writepng_error_handler(png_structp png_ptr, png_const_charp msg); + + + +void writepng_version_info(void) +{ + fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", + PNG_LIBPNG_VER_STRING, png_libpng_ver); + fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", + ZLIB_VERSION, zlib_version); +} + + + + +/* returns 0 for success, 2 for libpng problem, 4 for out of memory, 11 for + * unexpected pnmtype; note that outfile might be stdout */ + +int writepng_init(mainprog_info *mainprog_ptr) +{ + png_structp png_ptr; /* note: temporary variables! */ + png_infop info_ptr; + int color_type, interlace_type; + + + /* could also replace libpng warning-handler (final NULL), but no need: */ + + png_ptr = png_create_write_struct(png_get_libpng_ver(NULL), mainprog_ptr, + writepng_error_handler, NULL); + if (!png_ptr) + return 4; /* out of memory */ + + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + png_destroy_write_struct(&png_ptr, NULL); + return 4; /* out of memory */ + } + + + /* setjmp() must be called in every function that calls a PNG-writing + * libpng function, unless an alternate error handler was installed-- + * but compatible error handlers must either use longjmp() themselves + * (as in this program) or some other method to return control to + * application code, so here we go: */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr, &info_ptr); + return 2; + } + + + /* make sure outfile is (re)opened in BINARY mode */ + + png_init_io(png_ptr, mainprog_ptr->outfile); + + + /* set the compression levels--in general, always want to leave filtering + * turned on (except for palette images) and allow all of the filters, + * which is the default; want 32K zlib window, unless entire image buffer + * is 16K or smaller (unknown here)--also the default; usually want max + * compression (NOT the default); and remaining compression flags should + * be left alone */ + + png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); +/* + >> this is default for no filtering; Z_FILTERED is default otherwise: + png_set_compression_strategy(png_ptr, Z_DEFAULT_STRATEGY); + >> these are all defaults: + png_set_compression_mem_level(png_ptr, 8); + png_set_compression_window_bits(png_ptr, 15); + png_set_compression_method(png_ptr, 8); + */ + + + /* set the image parameters appropriately */ + + if (mainprog_ptr->pnmtype == 5) + color_type = PNG_COLOR_TYPE_GRAY; + else if (mainprog_ptr->pnmtype == 6) + color_type = PNG_COLOR_TYPE_RGB; + else if (mainprog_ptr->pnmtype == 8) + color_type = PNG_COLOR_TYPE_RGB_ALPHA; + else { + png_destroy_write_struct(&png_ptr, &info_ptr); + return 11; + } + + interlace_type = mainprog_ptr->interlaced? PNG_INTERLACE_ADAM7 : + PNG_INTERLACE_NONE; + + png_set_IHDR(png_ptr, info_ptr, mainprog_ptr->width, mainprog_ptr->height, + mainprog_ptr->sample_depth, color_type, interlace_type, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + if (mainprog_ptr->gamma > 0.0) + png_set_gAMA(png_ptr, info_ptr, mainprog_ptr->gamma); + + if (mainprog_ptr->have_bg) { /* we know it's RGBA, not gray+alpha */ + png_color_16 background; + + background.red = mainprog_ptr->bg_red; + background.green = mainprog_ptr->bg_green; + background.blue = mainprog_ptr->bg_blue; + png_set_bKGD(png_ptr, info_ptr, &background); + } + + if (mainprog_ptr->have_time) { + png_time modtime; + + png_convert_from_time_t(&modtime, mainprog_ptr->modtime); + png_set_tIME(png_ptr, info_ptr, &modtime); + } + + if (mainprog_ptr->have_text) { + png_text text[6]; + int num_text = 0; + + if (mainprog_ptr->have_text & TEXT_TITLE) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "Title"; + text[num_text].text = mainprog_ptr->title; + ++num_text; + } + if (mainprog_ptr->have_text & TEXT_AUTHOR) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "Author"; + text[num_text].text = mainprog_ptr->author; + ++num_text; + } + if (mainprog_ptr->have_text & TEXT_DESC) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "Description"; + text[num_text].text = mainprog_ptr->desc; + ++num_text; + } + if (mainprog_ptr->have_text & TEXT_COPY) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "Copyright"; + text[num_text].text = mainprog_ptr->copyright; + ++num_text; + } + if (mainprog_ptr->have_text & TEXT_EMAIL) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "E-mail"; + text[num_text].text = mainprog_ptr->email; + ++num_text; + } + if (mainprog_ptr->have_text & TEXT_URL) { + text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + text[num_text].key = "URL"; + text[num_text].text = mainprog_ptr->url; + ++num_text; + } + png_set_text(png_ptr, info_ptr, text, num_text); + } + + + /* write all chunks up to (but not including) first IDAT */ + + png_write_info(png_ptr, info_ptr); + + + /* if we wanted to write any more text info *after* the image data, we + * would set up text struct(s) here and call png_set_text() again, with + * just the new data; png_set_tIME() could also go here, but it would + * have no effect since we already called it above (only one tIME chunk + * allowed) */ + + + /* set up the transformations: for now, just pack low-bit-depth pixels + * into bytes (one, two or four pixels per byte) */ + + png_set_packing(png_ptr); +/* png_set_shift(png_ptr, &sig_bit); to scale low-bit-depth values */ + + + /* make sure we save our pointers for use in writepng_encode_image() */ + + mainprog_ptr->png_ptr = png_ptr; + mainprog_ptr->info_ptr = info_ptr; + + + /* OK, that's all we need to do for now; return happy */ + + return 0; +} + + + + + +/* returns 0 for success, 2 for libpng (longjmp) problem */ + +int writepng_encode_image(mainprog_info *mainprog_ptr) +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + + /* as always, setjmp() must be called in every function that calls a + * PNG-writing libpng function */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr, &info_ptr); + mainprog_ptr->png_ptr = NULL; + mainprog_ptr->info_ptr = NULL; + return 2; + } + + + /* and now we just write the whole image; libpng takes care of interlacing + * for us */ + + png_write_image(png_ptr, mainprog_ptr->row_pointers); + + + /* since that's it, we also close out the end of the PNG file now--if we + * had any text or time info to write after the IDATs, second argument + * would be info_ptr, but we optimize slightly by sending NULL pointer: */ + + png_write_end(png_ptr, NULL); + + return 0; +} + + + + + +/* returns 0 if succeeds, 2 if libpng problem */ + +int writepng_encode_row(mainprog_info *mainprog_ptr) /* NON-interlaced only! */ +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + + /* as always, setjmp() must be called in every function that calls a + * PNG-writing libpng function */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr, &info_ptr); + mainprog_ptr->png_ptr = NULL; + mainprog_ptr->info_ptr = NULL; + return 2; + } + + + /* image_data points at our one row of image data */ + + png_write_row(png_ptr, mainprog_ptr->image_data); + + return 0; +} + + + + + +/* returns 0 if succeeds, 2 if libpng problem */ + +int writepng_encode_finish(mainprog_info *mainprog_ptr) /* NON-interlaced! */ +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + + /* as always, setjmp() must be called in every function that calls a + * PNG-writing libpng function */ + + if (setjmp(mainprog_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr, &info_ptr); + mainprog_ptr->png_ptr = NULL; + mainprog_ptr->info_ptr = NULL; + return 2; + } + + + /* close out PNG file; if we had any text or time info to write after + * the IDATs, second argument would be info_ptr: */ + + png_write_end(png_ptr, NULL); + + return 0; +} + + + + + +void writepng_cleanup(mainprog_info *mainprog_ptr) +{ + png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; + png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; + + if (png_ptr && info_ptr) + png_destroy_write_struct(&png_ptr, &info_ptr); +} + + + + + +static void writepng_error_handler(png_structp png_ptr, png_const_charp msg) +{ + mainprog_info *mainprog_ptr; + + /* This function, aside from the extra step of retrieving the "error + * pointer" (below) and the fact that it exists within the application + * rather than within libpng, is essentially identical to libpng's + * default error handler. The second point is critical: since both + * setjmp() and longjmp() are called from the same code, they are + * guaranteed to have compatible notions of how big a jmp_buf is, + * regardless of whether _BSD_SOURCE or anything else has (or has not) + * been defined. */ + + fprintf(stderr, "writepng libpng error: %s\n", msg); + fflush(stderr); + + mainprog_ptr = png_get_error_ptr(png_ptr); + if (mainprog_ptr == NULL) { /* we are completely hosed now */ + fprintf(stderr, + "writepng severe error: jmpbuf not recoverable; terminating.\n"); + fflush(stderr); + exit(99); + } + + /* Now we have our data structure we can use the information in it + * to return control to our own higher level code (all the points + * where 'setjmp' is called in this file.) This will work with other + * error handling mechanisms as well - libpng always calls png_error + * when it can proceed no further, thus, so long as the error handler + * is intercepted, application code can do its own error recovery. + */ + longjmp(mainprog_ptr->jmpbuf, 1); +} diff --git a/thirdparty/libpng-1.6.37/contrib/gregbook/writepng.h b/thirdparty/libpng-1.6.37/contrib/gregbook/writepng.h new file mode 100644 index 0000000..78b966b --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/gregbook/writepng.h @@ -0,0 +1,133 @@ +/*--------------------------------------------------------------------------- + + wpng - simple PNG-writing program writepng.h + + --------------------------------------------------------------------------- + + Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. + + This software is provided "as is," without warranty of any kind, + express or implied. In no event shall the author or contributors + be held liable for any damages arising in any way from the use of + this software. + + The contents of this file are DUAL-LICENSED. You may modify and/or + redistribute this software according to the terms of one of the + following two licenses (at your option): + + + LICENSE 1 ("BSD-like with advertising clause"): + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright + notice, disclaimer, and this list of conditions. + 2. Redistributions in binary form must reproduce the above copyright + notice, disclaimer, and this list of conditions in the documenta- + tion and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + + This product includes software developed by Greg Roelofs + and contributors for the book, "PNG: The Definitive Guide," + published by O'Reilly and Associates. + + + LICENSE 2 (GNU GPL v2 or later): + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ---------------------------------------------------------------------------*/ + +#ifndef TRUE +# define TRUE 1 +# define FALSE 0 +#endif + +#ifndef MAX +# define MAX(a,b) ((a) > (b)? (a) : (b)) +# define MIN(a,b) ((a) < (b)? (a) : (b)) +#endif + +#ifdef DEBUG +# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} +#else +# define Trace(x) ; +#endif + +#define TEXT_TITLE 0x01 +#define TEXT_AUTHOR 0x02 +#define TEXT_DESC 0x04 +#define TEXT_COPY 0x08 +#define TEXT_EMAIL 0x10 +#define TEXT_URL 0x20 + +#define TEXT_TITLE_OFFSET 0 +#define TEXT_AUTHOR_OFFSET 72 +#define TEXT_COPY_OFFSET (2*72) +#define TEXT_EMAIL_OFFSET (3*72) +#define TEXT_URL_OFFSET (4*72) +#define TEXT_DESC_OFFSET (5*72) + +typedef unsigned char uch; +typedef unsigned short ush; +typedef unsigned long ulg; + +typedef struct _mainprog_info { + double gamma; + long width; + long height; + time_t modtime; + FILE *infile; + FILE *outfile; + void *png_ptr; + void *info_ptr; + uch *image_data; + uch **row_pointers; + char *title; + char *author; + char *desc; + char *copyright; + char *email; + char *url; + int filter; /* command-line-filter flag, not PNG row filter! */ + int pnmtype; + int sample_depth; + int interlaced; + int have_bg; + int have_time; + int have_text; + jmp_buf jmpbuf; + uch bg_red; + uch bg_green; + uch bg_blue; +} mainprog_info; + + +/* prototypes for public functions in writepng.c */ + +void writepng_version_info(void); + +int writepng_init(mainprog_info *mainprog_ptr); + +int writepng_encode_image(mainprog_info *mainprog_ptr); + +int writepng_encode_row(mainprog_info *mainprog_ptr); + +int writepng_encode_finish(mainprog_info *mainprog_ptr); + +void writepng_cleanup(mainprog_info *mainprog_ptr); diff --git a/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngimage.Po b/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngimage.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngimage.Po @@ -0,0 +1 @@ +# dummy diff --git a/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngstest.Po b/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngstest.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngstest.Po @@ -0,0 +1 @@ +# dummy diff --git a/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngunknown.Po b/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngunknown.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngunknown.Po @@ -0,0 +1 @@ +# dummy diff --git a/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngvalid.Po b/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngvalid.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/libtests/.deps/pngvalid.Po @@ -0,0 +1 @@ +# dummy diff --git a/thirdparty/libpng-1.6.37/contrib/libtests/.deps/timepng.Po b/thirdparty/libpng-1.6.37/contrib/libtests/.deps/timepng.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/libtests/.deps/timepng.Po @@ -0,0 +1 @@ +# dummy diff --git a/thirdparty/libpng-1.6.37/contrib/libtests/fakepng.c b/thirdparty/libpng-1.6.37/contrib/libtests/fakepng.c new file mode 100644 index 0000000..6512c14 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/libtests/fakepng.c @@ -0,0 +1,65 @@ +/* Fake a PNG - just write it out directly. + * + * COPYRIGHT: Written by John Cunningham Bowler, 2014. + * To the extent possible under law, the author has waived all copyright and + * related or neighboring rights to this work. This work is published from: + * United States. + * + */ + +#include +#include /* for crc32 */ + +void +put_uLong(uLong val) +{ + putchar(val >> 24); + putchar(val >> 16); + putchar(val >> 8); + putchar(val >> 0); +} + +void +put_chunk(const unsigned char *chunk, uInt length) +{ + uLong crc; + + put_uLong(length-4); /* Exclude the tag */ + + fwrite(chunk, length, 1, stdout); + + crc = crc32(0, Z_NULL, 0); + put_uLong(crc32(crc, chunk, length)); +} + +const unsigned char signature[] = +{ + 137, 80, 78, 71, 13, 10, 26, 10 +}; + +const unsigned char IHDR[] = +{ + 73, 72, 68, 82, /* IHDR */ + 0, 0, 0, 1, /* width */ + 0, 0, 0, 1, /* height */ + 1, /* bit depth */ + 0, /* color type: greyscale */ + 0, /* compression method */ + 0, /* filter method */ + 0 /* interlace method: none */ +}; + +const unsigned char unknown[] = +{ + 'u', 'n', 'K', 'n' /* "unKn" - private safe to copy */ +}; + +int +main(void) +{ + fwrite(signature, sizeof signature, 1, stdout); + put_chunk(IHDR, sizeof IHDR); + + for (;;) + put_chunk(unknown, sizeof unknown); +} diff --git a/thirdparty/libpng-1.6.37/contrib/libtests/gentests.sh b/thirdparty/libpng-1.6.37/contrib/libtests/gentests.sh new file mode 100755 index 0000000..f0f8d23 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/libtests/gentests.sh @@ -0,0 +1,102 @@ +#!/bin/sh +# +# Copyright (c) 2013 John Cunningham Bowler +# +# Last changed in libpng 1.6.0 [February 14, 2013] +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h +# +# Generate a set of PNG test images. The images are generated in a +# sub-directory called 'tests' by default, however a command line argument will +# change that name. The generation requires a built version of makepng in the +# current directory. +# +usage(){ + exec >&2 + echo "$0 []" + echo ' Generate a set of PNG test files in "directory" ("tests" by default)' + exit 1 +} + +mp="$PWD/makepng" +test -x "$mp" || { + exec >&2 + echo "$0: the 'makepng' program must exist" + echo " in the directory within which this program:" + echo " $mp" + echo " is executed" + usage +} + +# Just one argument: the directory +testdir="tests" +test $# -gt 1 && { + testdir="$1" + shift +} +test $# -eq 0 || usage + +# Take care not to clobber something +if test -e "$testdir" +then + test -d "$testdir" || usage +else + # mkdir -p isn't portable, so do the following + mkdir "$testdir" 2>/dev/null || mkdir -p "$testdir" || usage +fi + +# This fails in a very satisfactory way if it's not accessible +cd "$testdir" +:>"test$$.png" || { + exec >&2 + echo "$testdir: directory not writable" + usage +} +rm "test$$.png" || { + exec >&2 + echo "$testdir: you have create but not write privileges here." + echo " This is unexpected. You have a spurion; "'"'"test$$.png"'"'"." + echo " You need to remove this yourself. Try a different directory." + exit 1 +} + +# Now call makepng ($mp) to create every file we can think of with a +# reasonable name +doit(){ + for gamma in "" --sRGB --linear --1.8 + do + case "$gamma" in + "") + gname=;; + --sRGB) + gname="-srgb";; + --linear) + gname="-lin";; + --1.8) + gname="-18";; + *) + gname="-$gamma";; + esac + "$mp" $gamma "$1" "$2" "test-$1-$2$gname.png" + done +} +# +for ct in gray palette +do + for bd in 1 2 4 8 + do + doit "$ct" "$bd" + done +done +# +doit "gray" "16" +# +for ct in gray-alpha rgb rgb-alpha +do + for bd in 8 16 + do + doit "$ct" "$bd" + done +done diff --git a/thirdparty/libpng-1.6.37/contrib/libtests/makepng.c b/thirdparty/libpng-1.6.37/contrib/libtests/makepng.c new file mode 100644 index 0000000..312062b --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/libtests/makepng.c @@ -0,0 +1,1941 @@ +/* makepng.c */ +#define _ISOC99_SOURCE +/* Copyright: */ +#define COPYRIGHT "\251 2013,2015 John Cunningham Bowler" +/* + * Last changed in libpng 1.6.20 [November 24, 2015] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * Make a test PNG image. The arguments are as follows: + * + * makepng [--sRGB|--linear|--1.8] [--tRNS] [--nofilters] \ + * color-type bit-depth [file-name] + * + * The color-type may be numeric (and must match the numbers used by the PNG + * specification) or one of the format names listed below. The bit-depth is the + * component bit depth, or the pixel bit-depth for a color-mapped image. + * + * Without any options no color-space information is written, with the options + * an sRGB or the appropriate gAMA chunk is written. "1.8" refers to the + * display system used on older Apple computers to correct for high ambient + * light levels in the viewing environment; it applies a transform of + * approximately value^(1/1.45) to the color values and so a gAMA chunk of 65909 + * is written (1.45/2.2). + * + * The image data is generated internally. Unless --color is given the images + * used are as follows: + * + * 1 channel: a square image with a diamond, the least luminous colors are on + * the edge of the image, the most luminous in the center. + * + * 2 channels: the color channel increases in luminosity from top to bottom, the + * alpha channel increases in opacity from left to right. + * + * 3 channels: linear combinations of, from the top-left corner clockwise, + * black, green, white, red. + * + * 4 channels: linear combinations of, from the top-left corner clockwise, + * transparent, red, green, blue. + * + * For color-mapped images a four channel color-map is used and if --tRNS is + * given the PNG file has a tRNS chunk, as follows: + * + * 1-bit: entry 0 is transparent-red, entry 1 is opaque-white + * 2-bit: entry 0: transparent-green + * entry 1: 40%-red + * entry 2: 80%-blue + * entry 3: opaque-white + * 4-bit: the 16 combinations of the 2-bit case + * 8-bit: the 256 combinations of the 4-bit case + * + * The palette always has 2^bit-depth entries and the tRNS chunk one fewer. The + * image is the 1-channel diamond, but using palette index, not luminosity. + * + * For formats other than color-mapped ones if --tRNS is specified a tRNS chunk + * is generated with all channels equal to the low bits of 0x0101. + * + * Image size is determined by the final pixel depth in bits, i.e. channels x + * bit-depth, as follows: + * + * 8 bits or less: 64x64 + * 16 bits: 256x256 + * More than 16 bits: 1024x1024 + * + * Row filtering is the libpng default but may be turned off (the 'none' filter + * is used on every row) with the --nofilters option. + * + * The images are not interlaced. + * + * If file-name is given then the PNG is written to that file, else it is + * written to stdout. Notice that stdout is not supported on systems where, by + * default, it assumes text output; this program makes no attempt to change the + * text mode of stdout! + * + * makepng --color= ... + * + * If --color is given then the whole image has that color, color-mapped images + * will have exactly one palette entry and all image files with be 16x16 in + * size. The color value is 1 to 4 decimal numbers as appropriate for the color + * type. + * + * makepng --small ... + * + * If --small is given the images are no larger than required to include every + * possible pixel value for the format. + * + * For formats with pixels 8 bits or fewer in size the images consist of a + * single row with 2^pixel-depth pixels, one of every possible value. + * + * For formats with 16-bit pixels a 256x256 image is generated containing every + * possible pixel value. + * + * For larger pixel sizes a 256x256 image is generated where the first row + * consists of each pixel that has identical byte values throughout the pixel + * followed by rows where the byte values differ within the pixel. + * + * In all cases the pixel values are arranged in such a way that the SUB and UP + * filters give byte sequences for maximal zlib compression. By default (if + * --nofilters is not given) the SUB filter is used on the first row and the UP + * filter on all following rows. + * + * The --small option is meant to provide good test-case coverage, however the + * images are not easy to examine visually. Without the --small option the + * images contain identical color values; the pixel values are adjusted + * according to the gamma encoding with no gamma encoding being interpreted as + * sRGB. + * + * LICENSING + * ========= + * + * This code is copyright of the authors, see the COPYRIGHT define above. The + * code is licensed as above, using the libpng license. The code generates + * images which are solely the product of the code; the options choose which of + * the many possibilities to generate. The images that result (but not the code + * which generates them) are licensed as defined here: + * + * IMPORTANT: the COPYRIGHT #define must contain ISO-Latin-1 characters, the + * IMAGE_LICENSING #define must contain UTF-8 characters. The 'copyright' + * symbol 0xA9U (\251) in ISO-Latin-1 encoding and 0xC20xA9 (\302\251) in UTF-8. + */ +#define IMAGE_LICENSING "Dedicated to the public domain per Creative Commons "\ + "license \"CC0 1.0\"; https://creativecommons.org/publicdomain/zero/1.0/" + +#include /* for offsetof */ +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) +# include +#endif + +/* Define the following to use this test against your installed libpng, rather + * than the one being built here: + */ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../../png.h" +#endif + +#include + +/* Work round for GCC complaints about casting a (double) function result to + * an unsigned: + */ +static unsigned int +flooru(double d) +{ + d = floor(d); + return (unsigned int)d; +} + +static png_byte +floorb(double d) +{ + d = floor(d); + return (png_byte)d; +} + +/* This structure is used for inserting extra chunks (the --insert argument, not + * documented above.) + */ +typedef struct chunk_insert +{ + struct chunk_insert *next; + void (*insert)(png_structp, png_infop, int, png_charpp); + int nparams; + png_charp parameters[1]; +} chunk_insert; + +static unsigned int +channels_of_type(int color_type) +{ + if (color_type & PNG_COLOR_MASK_PALETTE) + return 1; + + else + { + int channels = 1; + + if (color_type & PNG_COLOR_MASK_COLOR) + channels = 3; + + if (color_type & PNG_COLOR_MASK_ALPHA) + return channels + 1; + + else + return channels; + } +} + +static unsigned int +pixel_depth_of_type(int color_type, int bit_depth) +{ + return channels_of_type(color_type) * bit_depth; +} + +static unsigned int +image_size_of_type(int color_type, int bit_depth, unsigned int *colors, + int small) +{ + if (*colors) + return 16; + + else + { + int pixel_depth = pixel_depth_of_type(color_type, bit_depth); + + if (small) + { + if (pixel_depth <= 8) /* there will be one row */ + return 1 << pixel_depth; + + else + return 256; + } + + else if (pixel_depth < 8) + return 64; + + else if (pixel_depth > 16) + return 1024; + + else + return 256; + } +} + +static void +set_color(png_colorp color, png_bytep trans, unsigned int red, + unsigned int green, unsigned int blue, unsigned int alpha, + png_const_bytep gamma_table) +{ + color->red = gamma_table[red]; + color->green = gamma_table[green]; + color->blue = gamma_table[blue]; + *trans = (png_byte)alpha; +} + +static int +generate_palette(png_colorp palette, png_bytep trans, int bit_depth, + png_const_bytep gamma_table, unsigned int *colors) +{ + /* + * 1-bit: entry 0 is transparent-red, entry 1 is opaque-white + * 2-bit: entry 0: transparent-green + * entry 1: 40%-red + * entry 2: 80%-blue + * entry 3: opaque-white + * 4-bit: the 16 combinations of the 2-bit case + * 8-bit: the 256 combinations of the 4-bit case + */ + switch (colors[0]) + { + default: + fprintf(stderr, "makepng: --colors=...: invalid count %u\n", + colors[0]); + exit(1); + + case 1: + set_color(palette+0, trans+0, colors[1], colors[1], colors[1], 255, + gamma_table); + return 1; + + case 2: + set_color(palette+0, trans+0, colors[1], colors[1], colors[1], + colors[2], gamma_table); + return 1; + + case 3: + set_color(palette+0, trans+0, colors[1], colors[2], colors[3], 255, + gamma_table); + return 1; + + case 4: + set_color(palette+0, trans+0, colors[1], colors[2], colors[3], + colors[4], gamma_table); + return 1; + + case 0: + if (bit_depth == 1) + { + set_color(palette+0, trans+0, 255, 0, 0, 0, gamma_table); + set_color(palette+1, trans+1, 255, 255, 255, 255, gamma_table); + return 2; + } + + else + { + unsigned int size = 1U << (bit_depth/2); /* 2, 4 or 16 */ + unsigned int x, y; + volatile unsigned int ip = 0; + + for (x=0; x> 3; + + if (offset < rowbytes && (bit_depth < 16 || offset+1 < rowbytes)) + { + row += offset; + + switch (bit_depth) + { + case 1: + case 2: + case 4: + /* Don't gamma correct - values get smashed */ + { + unsigned int shift = (8 - bit_depth) - (x & 0x7U); + + mask <<= shift; + value = (value << shift) & mask; + *row = (png_byte)((*row & ~mask) | value); + } + return; + + default: + fprintf(stderr, "makepng: bad bit depth (internal error)\n"); + exit(1); + + case 16: + value = flooru(65535*pow(value/65535.,conv)+.5); + *row++ = (png_byte)(value >> 8); + *row = (png_byte)value; + return; + + case 8: + *row = gamma_table[value]; + return; + } + } + + else + { + fprintf(stderr, "makepng: row buffer overflow (internal error)\n"); + exit(1); + } + } + + else + { + fprintf(stderr, "makepng: component overflow (internal error)\n"); + exit(1); + } +} + +static int /* filter mask for row */ +generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type, + int bit_depth, png_const_bytep gamma_table, double conv, + unsigned int *colors, int small) +{ + int filters = 0; /* file *MASK*, 0 means the default, not NONE */ + png_uint_32 size_max = + image_size_of_type(color_type, bit_depth, colors, small)-1; + png_uint_32 depth_max = (1U << bit_depth)-1; /* up to 65536 */ + + if (colors[0] == 0) if (small) + { + unsigned int pixel_depth = pixel_depth_of_type(color_type, bit_depth); + + /* For pixel depths less than 16 generate a single row containing all the + * possible pixel values. For 16 generate all 65536 byte pair + * combinations in a 256x256 pixel array. + */ + switch (pixel_depth) + { + case 1: + assert(y == 0 && rowbytes == 1 && size_max == 1); + row[0] = 0x6CU; /* binary: 01101100, only top 2 bits used */ + filters = PNG_FILTER_NONE; + break; + + case 2: + assert(y == 0 && rowbytes == 1 && size_max == 3); + row[0] = 0x1BU; /* binary 00011011, all bits used */ + filters = PNG_FILTER_NONE; + break; + + case 4: + assert(y == 0 && rowbytes == 8 && size_max == 15); + row[0] = 0x01U; + row[1] = 0x23U; /* SUB gives 0x22U for all following bytes */ + row[2] = 0x45U; + row[3] = 0x67U; + row[4] = 0x89U; + row[5] = 0xABU; + row[6] = 0xCDU; + row[7] = 0xEFU; + filters = PNG_FILTER_SUB; + break; + + case 8: + /* The row will have all the pixel values in order starting with + * '1', the SUB filter will change every byte into '1' (including + * the last, which generates pixel value '0'). Since the SUB filter + * has value 1 this should result in maximum compression. + */ + assert(y == 0 && rowbytes == 256 && size_max == 255); + for (;;) + { + row[size_max] = 0xFFU & (size_max+1); + if (size_max == 0) + break; + --size_max; + } + filters = PNG_FILTER_SUB; + break; + + case 16: + /* Rows are generated such that each row has a constant difference + * between the first and second byte of each pixel and so that the + * difference increases by 1 at each row. The rows start with the + * first byte value of 0 and the value increases to 255 across the + * row. + * + * The difference starts at 1, so the first row is: + * + * 0 1 1 2 2 3 3 4 ... 254 255 255 0 + * + * This means that running the SUB filter on the first row produces: + * + * [SUB==1] 0 1 0 1 0 1... + * + * Then the difference is 2 on the next row, giving: + * + * 0 2 1 3 2 4 3 5 ... 254 0 255 1 + * + * When the UP filter is run on this libpng produces: + * + * [UP ==2] 0 1 0 1 0 1... + * + * And so on for all the remain rows to the final two * rows: + * + * row 254: 0 255 1 0 2 1 3 2 4 3 ... 254 253 255 254 + * row 255: 0 0 1 1 2 2 3 3 4 4 ... 254 254 255 255 + */ + assert(rowbytes == 512 && size_max == 255); + for (;;) + { + row[2*size_max ] = 0xFFU & size_max; + row[2*size_max+1] = 0xFFU & (size_max+y+1); + if (size_max == 0) + break; + --size_max; + } + /* The first row must include PNG_FILTER_UP so that libpng knows we + * need to keep it for the following row: + */ + filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP); + break; + + case 24: + case 32: + case 48: + case 64: + /* The rows are filled by an alogorithm similar to the above, in the + * first row pixel bytes are all equal, increasing from 0 by 1 for + * each pixel. In the second row the bytes within a pixel are + * incremented 1,3,5,7,... from the previous row byte. Using an odd + * number ensures all the possible byte values are used. + */ + assert(size_max == 255 && rowbytes == 256*(pixel_depth>>3)); + pixel_depth >>= 3; /* now in bytes */ + while (rowbytes > 0) + { + const size_t pixel_index = --rowbytes/pixel_depth; + + if (y == 0) + row[rowbytes] = 0xFFU & pixel_index; + + else + { + const size_t byte_offset = + rowbytes - pixel_index * pixel_depth; + + row[rowbytes] = + 0xFFU & (pixel_index + (byte_offset * 2*y) + 1); + } + } + filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP); + break; + + default: + assert(0/*NOT REACHED*/); + } + } + + else switch (channels_of_type(color_type)) + { + /* 1 channel: a square image with a diamond, the least luminous colors are on + * the edge of the image, the most luminous in the center. + */ + case 1: + { + png_uint_32 x; + png_uint_32 base = 2*size_max - abs(2*y-size_max); + + for (x=0; x<=size_max; ++x) + { + png_uint_32 luma = base - abs(2*x-size_max); + + /* 'luma' is now in the range 0..2*size_max, we need + * 0..depth_max + */ + luma = (luma*depth_max + size_max) / (2*size_max); + set_value(row, rowbytes, x, bit_depth, luma, gamma_table, conv); + } + } + break; + + /* 2 channels: the color channel increases in luminosity from top to bottom, + * the alpha channel increases in opacity from left to right. + */ + case 2: + { + png_uint_32 alpha = (depth_max * y * 2 + size_max) / (2 * size_max); + png_uint_32 x; + + for (x=0; x<=size_max; ++x) + { + set_value(row, rowbytes, 2*x, bit_depth, + (depth_max * x * 2 + size_max) / (2 * size_max), gamma_table, + conv); + set_value(row, rowbytes, 2*x+1, bit_depth, alpha, gamma_table, + conv); + } + } + break; + + /* 3 channels: linear combinations of, from the top-left corner clockwise, + * black, green, white, red. + */ + case 3: + { + /* x0: the black->red scale (the value of the red component) at the + * start of the row (blue and green are 0). + * x1: the green->white scale (the value of the red and blue + * components at the end of the row; green is depth_max). + */ + png_uint_32 Y = (depth_max * y * 2 + size_max) / (2 * size_max); + png_uint_32 x; + + /* Interpolate x/depth_max from start to end: + * + * start end difference + * red: Y Y 0 + * green: 0 depth_max depth_max + * blue: 0 Y Y + */ + for (x=0; x<=size_max; ++x) + { + set_value(row, rowbytes, 3*x+0, bit_depth, /* red */ Y, + gamma_table, conv); + set_value(row, rowbytes, 3*x+1, bit_depth, /* green */ + (depth_max * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + set_value(row, rowbytes, 3*x+2, bit_depth, /* blue */ + (Y * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + } + } + break; + + /* 4 channels: linear combinations of, from the top-left corner clockwise, + * transparent, red, green, blue. + */ + case 4: + { + /* x0: the transparent->blue scale (the value of the blue and alpha + * components) at the start of the row (red and green are 0). + * x1: the red->green scale (the value of the red and green + * components at the end of the row; blue is 0 and alpha is + * depth_max). + */ + png_uint_32 Y = (depth_max * y * 2 + size_max) / (2 * size_max); + png_uint_32 x; + + /* Interpolate x/depth_max from start to end: + * + * start end difference + * red: 0 depth_max-Y depth_max-Y + * green: 0 Y Y + * blue: Y 0 -Y + * alpha: Y depth_max depth_max-Y + */ + for (x=0; x<=size_max; ++x) + { + set_value(row, rowbytes, 4*x+0, bit_depth, /* red */ + ((depth_max-Y) * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + set_value(row, rowbytes, 4*x+1, bit_depth, /* green */ + (Y * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + set_value(row, rowbytes, 4*x+2, bit_depth, /* blue */ + Y - (Y * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + set_value(row, rowbytes, 4*x+3, bit_depth, /* alpha */ + Y + ((depth_max-Y) * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + } + } + break; + + default: + fprintf(stderr, "makepng: internal bad channel count\n"); + exit(2); + } + + else if (color_type & PNG_COLOR_MASK_PALETTE) + { + /* Palette with fixed color: the image rows are all 0 and the image width + * is 16. + */ + memset(row, 0, rowbytes); + } + + else if (colors[0] == channels_of_type(color_type)) + switch (channels_of_type(color_type)) + { + case 1: + { + png_uint_32 luma = colors[1]; + png_uint_32 x; + + for (x=0; x<=size_max; ++x) + set_value(row, rowbytes, x, bit_depth, luma, gamma_table, + conv); + } + break; + + case 2: + { + png_uint_32 luma = colors[1]; + png_uint_32 alpha = colors[2]; + png_uint_32 x; + + for (x=0; x 0 && gamma < 1000) + gamma = PNG_FP_1; + + if (gamma > 0) + real_gamma = gamma; + + { + unsigned int i; + + if (real_gamma == 45455) for (i=0; i<256; ++i) + { + gamma_table[i] = (png_byte)i; + conv = 1.; + } + + else + { + /* Convert 'i' from sRGB (45455) to real_gamma, this makes + * the images look the same regardless of the gAMA chunk. + */ + conv = real_gamma; + conv /= 45455; + + gamma_table[0] = 0; + + for (i=1; i<255; ++i) + gamma_table[i] = floorb(pow(i/255.,conv) * 255 + .5); + + gamma_table[255] = 255; + } + } + + png_set_IHDR(png_ptr, info_ptr, size, ysize, bit_depth, color_type, + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + if (color_type & PNG_COLOR_MASK_PALETTE) + { + int npalette; + png_color palette[256]; + png_byte trans[256]; + + npalette = generate_palette(palette, trans, bit_depth, gamma_table, + colors); + png_set_PLTE(png_ptr, info_ptr, palette, npalette); + + if (tRNS) + png_set_tRNS(png_ptr, info_ptr, trans, npalette-1, + NULL/*transparent color*/); + + /* Reset gamma_table to prevent the image rows being changed */ + for (npalette=0; npalette<256; ++npalette) + gamma_table[npalette] = (png_byte)npalette; + } + + else if (tRNS) + { + png_color_16 col; + + col.red = col.green = col.blue = col.gray = + 0x0101U & ((1U< 0) /* Else don't set color space information */ + { + png_set_gAMA_fixed(png_ptr, info_ptr, real_gamma); + + /* Just use the sRGB values here. */ + png_set_cHRM_fixed(png_ptr, info_ptr, + /* color x y */ + /* white */ 31270, 32900, + /* red */ 64000, 33000, + /* green */ 30000, 60000, + /* blue */ 15000, 6000 + ); + } + + /* Insert extra information. */ + while (insert != NULL) + { + insert->insert(png_ptr, info_ptr, insert->nparams, insert->parameters); + insert = insert->next; + } + + /* Write the file header. */ + png_write_info(png_ptr, info_ptr); + + /* Restrict the filters */ + png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, filters); + + { +# ifdef PNG_WRITE_INTERLACING_SUPPORTED + int passes = png_set_interlace_handling(png_ptr); +# else /* !WRITE_INTERLACING */ + int passes = 1; +# endif /* !WRITE_INTERLACING */ + int pass; + size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr); + + row = malloc(rowbytes); + + if (row == NULL) + png_error(png_ptr, "OOM allocating row buffer"); + + for (pass = 0; pass < passes; ++pass) + { + unsigned int y; + + for (y=0; y 0) + { + /* Round up to a multiple of 4 here to allow an iCCP profile + * to be padded to a 4x boundary. + */ + png_bytep data = malloc((total+3)&~3); + + if (data != NULL) + { + size_t new_size = 0; + + for (;;) + { + ch = getc(fp); + if (ch == EOF) break; + data[new_size++] = (png_byte)ch; + } + + if (ferror(fp) || new_size != total) + { + perror("temporary file"); + fprintf(stderr, "temporary file read error\n"); + free(data); + } + + else + { + (void)fclose(fp); + *result = data; + return total; + } + } + + else + fprintf(stderr, "%s: out of memory loading file\n", name); + } + + else + fprintf(stderr, "%s: empty file\n", name); + } + } + } + + else + { + perror(name); + fprintf(stderr, "%s: open failed\n", name); + } + + fclose(fp); + } + + else + fprintf(stderr, "makepng: %s: could not open temporary file\n", name); + + exit(1); + return 0; +} + +static size_t +load_fake(png_charp param, png_bytepp profile) +{ + char *endptr = NULL; + uint64_t size = strtoull(param, &endptr, 0/*base*/); + + /* The 'fake' format is *[string] */ + if (endptr != NULL && *endptr == '*') + { + size_t len = strlen(++endptr); + size_t result = (size_t)size; + + if (len == 0) len = 1; /* capture the terminating '\0' */ + + /* Now repeat that string to fill 'size' bytes. */ + if (result == size && (*profile = malloc(result)) != NULL) + { + png_bytep out = *profile; + + if (len == 1) + memset(out, *endptr, result); + + else + { + while (size >= len) + { + memcpy(out, endptr, len); + out += len; + size -= len; + } + memcpy(out, endptr, size); + } + + return result; + } + + else + { + fprintf(stderr, "%s: size exceeds system limits\n", param); + exit(1); + } + } + + return 0; +} + +static void +check_param_count(int nparams, int expect) +{ + if (nparams != expect) + { + fprintf(stderr, "bad parameter count (internal error)\n"); + exit(1); + } +} + +static void +insert_iCCP(png_structp png_ptr, png_infop info_ptr, int nparams, + png_charpp params) +{ + png_bytep profile = NULL; + png_uint_32 proflen = 0; + int result; + + check_param_count(nparams, 2); + + switch (params[1][0]) + { + case '<': + { + size_t filelen = load_file(params[1]+1, &profile); + if (filelen > 0xfffffffc) /* Maximum profile length */ + { + fprintf(stderr, "%s: file too long (%lu) for an ICC profile\n", + params[1]+1, (unsigned long)filelen); + exit(1); + } + + proflen = (png_uint_32)filelen; + } + break; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + { + size_t fake_len = load_fake(params[1], &profile); + + if (fake_len > 0) /* else a simple parameter */ + { + if (fake_len > 0xffffffff) /* Maximum profile length */ + { + fprintf(stderr, + "%s: fake data too long (%lu) for an ICC profile\n", + params[1], (unsigned long)fake_len); + exit(1); + } + proflen = (png_uint_32)(fake_len & ~3U); + /* Always fix up the profile length. */ + png_save_uint_32(profile, proflen); + break; + } + } + + default: + fprintf(stderr, "--insert iCCP \"%s\": unrecognized\n", params[1]); + fprintf(stderr, " use '<' to read a file: \" 3) + { + png_uint_32 prof_header = png_get_uint_32(profile); + + if (prof_header != proflen) + { + fprintf(stderr, "--insert iCCP %s: profile length field wrong:\n", + params[1]); + fprintf(stderr, " actual %lu, recorded value %lu (corrected)\n", + (unsigned long)proflen, (unsigned long)prof_header); + png_save_uint_32(profile, proflen); + } + } + + if (result && profile != NULL && proflen >=4) + png_set_iCCP(png_ptr, info_ptr, params[0], PNG_COMPRESSION_TYPE_BASE, + profile, proflen); + + if (profile) + free(profile); + + if (!result) + exit(1); +} + +static void +clear_text(png_text *text, png_charp keyword) +{ + text->compression = -1; /* none */ + text->key = keyword; + text->text = NULL; + text->text_length = 0; /* libpng calculates this */ + text->itxt_length = 0; /* libpng calculates this */ + text->lang = NULL; + text->lang_key = NULL; +} + +static void +set_text(png_structp png_ptr, png_infop info_ptr, png_textp text, + png_charp param) +{ + switch (param[0]) + { + case '<': + { + png_bytep file = NULL; + + text->text_length = load_file(param+1, &file); + text->text = (png_charp)file; + } + break; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + { + png_bytep data = NULL; + size_t fake_len = load_fake(param, &data); + + if (fake_len > 0) /* else a simple parameter */ + { + text->text_length = fake_len; + text->text = (png_charp)data; + break; + } + } + + default: + text->text = param; + break; + } + + png_set_text(png_ptr, info_ptr, text, 1); + + if (text->text != param) + free(text->text); +} + +static void +insert_tEXt(png_structp png_ptr, png_infop info_ptr, int nparams, + png_charpp params) +{ + png_text text; + + check_param_count(nparams, 2); + clear_text(&text, params[0]); + set_text(png_ptr, info_ptr, &text, params[1]); +} + +static void +insert_zTXt(png_structp png_ptr, png_infop info_ptr, int nparams, + png_charpp params) +{ + png_text text; + + check_param_count(nparams, 2); + clear_text(&text, params[0]); + text.compression = 0; /* deflate */ + set_text(png_ptr, info_ptr, &text, params[1]); +} + +static void +insert_iTXt(png_structp png_ptr, png_infop info_ptr, int nparams, + png_charpp params) +{ + png_text text; + + check_param_count(nparams, 4); + clear_text(&text, params[0]); + text.compression = 2; /* iTXt + deflate */ + text.lang = params[1];/* language tag */ + text.lang_key = params[2]; /* translated keyword */ + set_text(png_ptr, info_ptr, &text, params[3]); +} + +static void +insert_hIST(png_structp png_ptr, png_infop info_ptr, int nparams, + png_charpp params) +{ + int i; + png_uint_16 freq[256]; + + /* libpng takes the count from the PLTE count; we don't check it here but we + * do set the array to 0 for unspecified entries. + */ + memset(freq, 0, sizeof freq); + for (i=0; inext = NULL; + cip->insert = insert; + cip->nparams = nparams; + for (i=0; iparameters[i] = list[i]; + + return cip; +} + +static chunk_insert * +find_insert(png_const_charp what, png_charp param) +{ + png_uint_32 chunk = 0; + png_charp parameter_list[1024]; + int i, nparams; + + /* Assemble the chunk name */ + for (i=0; i<4; ++i) + { + char ch = what[i]; + + if ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122)) + chunk = (chunk << 8) + what[i]; + + else + break; + } + + if (i < 4 || what[4] != 0) + { + fprintf(stderr, "makepng --insert \"%s\": invalid chunk name\n", what); + exit(1); + } + + /* Assemble the parameter list. */ + nparams = find_parameters(what, param, parameter_list, 1024); + +# define CHUNK(a,b,c,d) (((a)<<24)+((b)<<16)+((c)<<8)+(d)) + + switch (chunk) + { + case CHUNK(105,67,67,80): /* iCCP */ + if (nparams == 2) + return make_insert(what, insert_iCCP, nparams, parameter_list); + break; + + case CHUNK(116,69,88,116): /* tEXt */ + if (nparams == 2) + return make_insert(what, insert_tEXt, nparams, parameter_list); + break; + + case CHUNK(122,84,88,116): /* zTXt */ + if (nparams == 2) + return make_insert(what, insert_zTXt, nparams, parameter_list); + break; + + case CHUNK(105,84,88,116): /* iTXt */ + if (nparams == 4) + return make_insert(what, insert_iTXt, nparams, parameter_list); + break; + + case CHUNK(104,73,83,84): /* hIST */ + if (nparams <= 256) + return make_insert(what, insert_hIST, nparams, parameter_list); + break; + + case CHUNK(115,66,73,84): /* sBIT */ + if (nparams <= 4) + return make_insert(what, insert_sBIT, nparams, parameter_list); + break; + +#if 0 + case CHUNK(115,80,76,84): /* sPLT */ + return make_insert(what, insert_sPLT, nparams, parameter_list); +#endif + + default: + fprintf(stderr, "makepng --insert \"%s\": unrecognized chunk name\n", + what); + exit(1); + } + + bad_parameter_count(what, nparams); + return NULL; +} + +/* This is necessary because libpng expects writeable strings for things like + * text chunks (maybe this should be fixed...) + */ +static png_charp +strstash(png_const_charp foo) +{ + /* The program indicates a memory allocation error by crashing, this is by + * design. + */ + if (foo != NULL) + { + png_charp bar = malloc(strlen(foo)+1); + return strcpy(bar, foo); + } + + return NULL; +} + +static png_charp +strstash_list(const png_const_charp *text) +{ + size_t foo = 0; + png_charp result, bar; + const png_const_charp *line = text; + + while (*line != NULL) + foo += strlen(*line++); + + result = bar = malloc(foo+1); + + line = text; + while (*line != NULL) + { + foo = strlen(*line); + memcpy(bar, *line++, foo); + bar += foo; + } + + *bar = 0; + return result; +} + +/* These are used to insert Copyright and Licence fields, they allow the text to + * have \n unlike the --insert option. + */ +static chunk_insert * +add_tEXt(const char *key, const png_const_charp *text) +{ + static char what[5] = { 116, 69, 88, 116, 0 }; + png_charp parameter_list[3]; + + parameter_list[0] = strstash(key); + parameter_list[1] = strstash_list(text); + parameter_list[2] = NULL; + + return make_insert(what, insert_tEXt, 2, parameter_list); +} + +static chunk_insert * +add_iTXt(const char *key, const char *language, const char *language_key, + const png_const_charp *text) +{ + static char what[5] = { 105, 84, 88, 116, 0 }; + png_charp parameter_list[5]; + + parameter_list[0] = strstash(key); + parameter_list[1] = strstash(language); + parameter_list[2] = strstash(language_key); + parameter_list[3] = strstash_list(text); + parameter_list[4] = NULL; + + return make_insert(what, insert_iTXt, 4, parameter_list); +} + +/* This is a not-very-good parser for a sequence of numbers (including 0). It + * doesn't accept some apparently valid things, but it accepts all the sensible + * combinations. + */ +static void +parse_color(char *arg, unsigned int *colors) +{ + unsigned int ncolors = 0; + + while (*arg && ncolors < 4) + { + char *ep = arg; + + unsigned long ul = strtoul(arg, &ep, 0); + + if (ul > 65535) + { + fprintf(stderr, "makepng --color=...'%s': too big\n", arg); + exit(1); + } + + if (ep == arg) + { + fprintf(stderr, "makepng --color=...'%s': not a valid color\n", arg); + exit(1); + } + + if (*ep) ++ep; /* skip a separator */ + arg = ep; + + colors[++ncolors] = (unsigned int)ul; /* checked above */ + } + + if (*arg) + { + fprintf(stderr, "makepng --color=...'%s': too many values\n", arg); + exit(1); + } + + *colors = ncolors; +} + +int +main(int argc, char **argv) +{ + FILE *fp = stdout; + const char *file_name = NULL; + int color_type = 8; /* invalid */ + int bit_depth = 32; /* invalid */ + int small = 0; /* make full size images */ + int tRNS = 0; /* don't output a tRNS chunk */ + unsigned int colors[5]; + unsigned int filters = PNG_ALL_FILTERS; + png_fixed_point gamma = 0; /* not set */ + chunk_insert *head_insert = NULL; + chunk_insert **insert_ptr = &head_insert; + + memset(colors, 0, sizeof colors); + + while (--argc > 0) + { + char *arg = *++argv; + + if (strcmp(arg, "--small") == 0) + { + small = 1; + continue; + } + + if (strcmp(arg, "--tRNS") == 0) + { + tRNS = 1; + continue; + } + + if (strcmp(arg, "--sRGB") == 0) + { + gamma = PNG_DEFAULT_sRGB; + continue; + } + + if (strcmp(arg, "--linear") == 0) + { + gamma = PNG_FP_1; + continue; + } + + if (strcmp(arg, "--1.8") == 0) + { + gamma = PNG_GAMMA_MAC_18; + continue; + } + + if (strcmp(arg, "--nofilters") == 0) + { + filters = PNG_FILTER_NONE; + continue; + } + + if (strncmp(arg, "--color=", 8) == 0) + { + parse_color(arg+8, colors); + continue; + } + + if (argc >= 3 && strcmp(arg, "--insert") == 0) + { + png_const_charp what = *++argv; + png_charp param = *++argv; + chunk_insert *new_insert; + + argc -= 2; + + new_insert = find_insert(what, param); + + if (new_insert != NULL) + { + *insert_ptr = new_insert; + insert_ptr = &new_insert->next; + } + + continue; + } + + if (arg[0] == '-') + { + fprintf(stderr, "makepng: %s: invalid option\n", arg); + exit(1); + } + + if (strcmp(arg, "palette") == 0) + { + color_type = PNG_COLOR_TYPE_PALETTE; + continue; + } + + if (strncmp(arg, "gray", 4) == 0) + { + if (arg[4] == 0) + { + color_type = PNG_COLOR_TYPE_GRAY; + continue; + } + + else if (strcmp(arg+4, "a") == 0 || + strcmp(arg+4, "alpha") == 0 || + strcmp(arg+4, "-alpha") == 0) + { + color_type = PNG_COLOR_TYPE_GRAY_ALPHA; + continue; + } + } + + if (strncmp(arg, "rgb", 3) == 0) + { + if (arg[3] == 0) + { + color_type = PNG_COLOR_TYPE_RGB; + continue; + } + + else if (strcmp(arg+3, "a") == 0 || + strcmp(arg+3, "alpha") == 0 || + strcmp(arg+3, "-alpha") == 0) + { + color_type = PNG_COLOR_TYPE_RGB_ALPHA; + continue; + } + } + + if (color_type == 8 && isdigit(arg[0])) + { + color_type = atoi(arg); + if (color_type < 0 || color_type > 6 || color_type == 1 || + color_type == 5) + { + fprintf(stderr, "makepng: %s: not a valid color type\n", arg); + exit(1); + } + + continue; + } + + if (bit_depth == 32 && isdigit(arg[0])) + { + bit_depth = atoi(arg); + if (bit_depth <= 0 || bit_depth > 16 || + (bit_depth & -bit_depth) != bit_depth) + { + fprintf(stderr, "makepng: %s: not a valid bit depth\n", arg); + exit(1); + } + + continue; + } + + if (argc == 1) /* It's the file name */ + { + fp = fopen(arg, "wb"); + if (fp == NULL) + { + fprintf(stderr, "%s: %s: could not open\n", arg, strerror(errno)); + exit(1); + } + + file_name = arg; + continue; + } + + fprintf(stderr, "makepng: %s: unknown argument\n", arg); + exit(1); + } /* argument while loop */ + + if (color_type == 8 || bit_depth == 32) + { + fprintf(stderr, "usage: makepng [--small] [--sRGB|--linear|--1.8] " + "[--color=...] color-type bit-depth [file-name]\n" + " Make a test PNG file, by default writes to stdout.\n" + " Other options are available, UTSL.\n"); + exit(1); + } + + /* Check the colors */ + { + unsigned int lim = (color_type == PNG_COLOR_TYPE_PALETTE ? 255U : + (1U< lim) + { + fprintf(stderr, "makepng: --color=...: %u out of range [0..%u]\n", + colors[i], lim); + exit(1); + } + } + + /* small and colors are incomparible (will probably crash if both are used at + * the same time!) + */ + if (small && colors[0] != 0) + { + fprintf(stderr, "makepng: --color --small: only one at a time!\n"); + exit(1); + } + + /* Restrict the filters for more speed to those we know are used for the + * generated images. + */ + if (filters == PNG_ALL_FILTERS && !small/*small provides defaults*/) + { + if ((color_type & PNG_COLOR_MASK_PALETTE) != 0 || bit_depth < 8) + filters = PNG_FILTER_NONE; + + else if (color_type & PNG_COLOR_MASK_COLOR) /* rgb */ + { + if (bit_depth == 8) + filters &= ~(PNG_FILTER_NONE | PNG_FILTER_AVG); + + else + filters = PNG_FILTER_SUB | PNG_FILTER_PAETH; + } + + else /* gray 8 or 16-bit */ + filters &= ~PNG_FILTER_NONE; + } + + /* Insert standard copyright and licence text. */ + { + static png_const_charp copyright[] = + { + COPYRIGHT, /* ISO-Latin-1 */ + NULL + }; + static png_const_charp licensing[] = + { + IMAGE_LICENSING, /* UTF-8 */ + NULL + }; + + chunk_insert *new_insert; + + new_insert = add_tEXt("Copyright", copyright); + if (new_insert != NULL) + { + *insert_ptr = new_insert; + insert_ptr = &new_insert->next; + } + + new_insert = add_iTXt("Licensing", "en", NULL, licensing); + if (new_insert != NULL) + { + *insert_ptr = new_insert; + insert_ptr = &new_insert->next; + } + } + + { + int ret = write_png(&file_name, fp, color_type, bit_depth, gamma, + head_insert, filters, colors, small, tRNS); + + if (ret != 0 && file_name != NULL) + remove(file_name); + + return ret; + } +} diff --git a/thirdparty/libpng-1.6.37/contrib/libtests/pngimage.c b/thirdparty/libpng-1.6.37/contrib/libtests/pngimage.c new file mode 100644 index 0000000..f130c04 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/libtests/pngimage.c @@ -0,0 +1,1712 @@ +/* pngimage.c + * + * Copyright (c) 2015,2016 John Cunningham Bowler + * + * Last changed in libpng 1.6.24 [August 4, 2016] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * Test the png_read_png and png_write_png interfaces. Given a PNG file load it + * using png_read_png and then write with png_write_png. Test all possible + * transforms. + */ +#include +#include +#include +#include +#include +#include + +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) +# include +#endif + +/* Define the following to use this test against your installed libpng, rather + * than the one being built here: + */ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../../png.h" +#endif + +#ifndef PNG_SETJMP_SUPPORTED +# include /* because png.h did *not* include this */ +#endif + +/* 1.6.1 added support for the configure test harness, which uses 77 to indicate + * a skipped test, in earlier versions we need to succeed on a skipped test, so: + */ +#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H) +# define SKIP 77 +#else +# define SKIP 0 +#endif + +#if PNG_LIBPNG_VER < 10700 + /* READ_PNG and WRITE_PNG were not defined, so: */ +# ifdef PNG_INFO_IMAGE_SUPPORTED +# ifdef PNG_SEQUENTIAL_READ_SUPPORTED +# define PNG_READ_PNG_SUPPORTED +# endif /* SEQUENTIAL_READ */ +# ifdef PNG_WRITE_SUPPORTED +# define PNG_WRITE_PNG_SUPPORTED +# endif /* WRITE */ +# endif /* INFO_IMAGE */ +#endif /* pre 1.7.0 */ + +#ifdef PNG_READ_PNG_SUPPORTED +/* If a transform is valid on both read and write this implies that if the + * transform is applied to read it must also be applied on write to produce + * meaningful data. This is because these transforms when performed on read + * produce data with a memory format that does not correspond to a PNG format. + * + * Most of these transforms are invertible; after applying the transform on + * write the result is the original PNG data that would have would have been + * read if no transform were applied. + * + * The exception is _SHIFT, which destroys the low order bits marked as not + * significant in a PNG with the sBIT chunk. + * + * The following table lists, for each transform, the conditions under which it + * is expected to do anything. Conditions are defined as follows: + * + * 1) Color mask bits required - simply a mask to AND with color_type; one of + * these must be present for the transform to fire, except that 0 means + * 'always'. + * 2) Color mask bits which must be absent - another mask - none of these must + * be present. + * 3) Bit depths - a mask of component bit depths for the transform to fire. + * 4) 'read' - the transform works in png_read_png. + * 5) 'write' - the transform works in png_write_png. + * 6) PNG_INFO_chunk; a mask of the chunks that must be present for the + * transform to fire. All must be present - the requirement is that + * png_get_valid() & mask == mask, so if mask is 0 there is no requirement. + * + * The condition refers to the original image state - if multiple transforms are + * used together it is possible to cause a transform that wouldn't fire on the + * original image to fire. + */ +static struct transform_info +{ + const char *name; + int transform; + png_uint_32 valid_chunks; +# define CHUNK_NONE 0 +# define CHUNK_sBIT PNG_INFO_sBIT +# define CHUNK_tRNS PNG_INFO_tRNS + png_byte color_mask_required; + png_byte color_mask_absent; +# define COLOR_MASK_X 0 +# define COLOR_MASK_P PNG_COLOR_MASK_PALETTE +# define COLOR_MASK_C PNG_COLOR_MASK_COLOR +# define COLOR_MASK_A PNG_COLOR_MASK_ALPHA +# define COLOR_MASK_ALL (PALETTE+COLOR+ALPHA) /* absent = gray, no alpha */ + png_byte bit_depths; +# define BD_ALL (1 + 2 + 4 + 8 + 16) +# define BD_PAL (1 + 2 + 4 + 8) +# define BD_LOW (1 + 2 + 4) +# define BD_16 16 +# define BD_TRUE (8+16) /* i.e. true-color depths */ + png_byte when; +# define TRANSFORM_R 1 +# define TRANSFORM_W 2 +# define TRANSFORM_RW 3 + png_byte tested; /* the transform was tested somewhere */ +} transform_info[] = +{ + /* List ALL the PNG_TRANSFORM_ macros here. Check for support using the READ + * macros; even if the transform is supported on write it cannot be tested + * without the read support. + */ +# define T(name,chunk,cm_required,cm_absent,bd,when)\ + { #name, PNG_TRANSFORM_ ## name, CHUNK_ ## chunk,\ + COLOR_MASK_ ## cm_required, COLOR_MASK_ ## cm_absent, BD_ ## bd,\ + TRANSFORM_ ## when, 0/*!tested*/ } + +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED + T(STRIP_16, NONE, X, X, 16, R), + /* drops the bottom 8 bits when bit depth is 16 */ +#endif +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + T(STRIP_ALPHA, NONE, A, X, ALL, R), + /* removes the alpha channel if present */ +#endif +#ifdef PNG_WRITE_PACK_SUPPORTED +# define TRANSFORM_RW_PACK TRANSFORM_RW +#else +# define TRANSFORM_RW_PACK TRANSFORM_R +#endif +#ifdef PNG_READ_PACK_SUPPORTED + T(PACKING, NONE, X, X, LOW, RW_PACK), + /* unpacks low-bit-depth components into 1 byte per component on read, + * reverses this on write. + */ +#endif +#ifdef PNG_WRITE_PACKSWAP_SUPPORTED +# define TRANSFORM_RW_PACKSWAP TRANSFORM_RW +#else +# define TRANSFORM_RW_PACKSWAP TRANSFORM_R +#endif +#ifdef PNG_READ_PACKSWAP_SUPPORTED + T(PACKSWAP, NONE, X, X, LOW, RW_PACKSWAP), + /* reverses the order of low-bit-depth components packed into a byte */ +#endif +#ifdef PNG_READ_EXPAND_SUPPORTED + T(EXPAND, NONE, P, X, ALL, R), + /* expands PLTE PNG files to RGB (no tRNS) or RGBA (tRNS) * + * Note that the 'EXPAND' transform does lots of different things: */ + T(EXPAND, NONE, X, C, ALL, R), + /* expands grayscale PNG files to RGB, or RGBA */ + T(EXPAND, tRNS, X, A, ALL, R), + /* expands the tRNS chunk in files without alpha */ +#endif +#ifdef PNG_WRITE_INVERT_SUPPORTED +# define TRANSFORM_RW_INVERT TRANSFORM_RW +#else +# define TRANSFORM_RW_INVERT TRANSFORM_R +#endif +#ifdef PNG_READ_INVERT_SUPPORTED + T(INVERT_MONO, NONE, X, C, ALL, RW_INVERT), + /* converts gray-scale components to 1..0 from 0..1 */ +#endif +#ifdef PNG_WRITE_SHIFT_SUPPORTED +# define TRANSFORM_RW_SHIFT TRANSFORM_RW +#else +# define TRANSFORM_RW_SHIFT TRANSFORM_R +#endif +#ifdef PNG_READ_SHIFT_SUPPORTED + T(SHIFT, sBIT, X, X, ALL, RW_SHIFT), + /* reduces component values to the original range based on the sBIT chunk, + * this is only partially reversible - the low bits are lost and cannot be + * recovered on write. In fact write code replicates the bits to generate + * new low-order bits. + */ +#endif +#ifdef PNG_WRITE_BGR_SUPPORTED +# define TRANSFORM_RW_BGR TRANSFORM_RW +#else +# define TRANSFORM_RW_BGR TRANSFORM_R +#endif +#ifdef PNG_READ_BGR_SUPPORTED + T(BGR, NONE, C, P, TRUE, RW_BGR), + /* reverses the rgb component values of true-color pixels */ +#endif +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED +# define TRANSFORM_RW_SWAP_ALPHA TRANSFORM_RW +#else +# define TRANSFORM_RW_SWAP_ALPHA TRANSFORM_R +#endif +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED + T(SWAP_ALPHA, NONE, A, X, TRUE, RW_SWAP_ALPHA), + /* swaps the alpha channel of RGBA or GA pixels to the front - ARGB or + * AG, on write reverses the process. + */ +#endif +#ifdef PNG_WRITE_SWAP_SUPPORTED +# define TRANSFORM_RW_SWAP TRANSFORM_RW +#else +# define TRANSFORM_RW_SWAP TRANSFORM_R +#endif +#ifdef PNG_READ_SWAP_SUPPORTED + T(SWAP_ENDIAN, NONE, X, P, 16, RW_SWAP), + /* byte-swaps 16-bit component values */ +#endif +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED +# define TRANSFORM_RW_INVERT_ALPHA TRANSFORM_RW +#else +# define TRANSFORM_RW_INVERT_ALPHA TRANSFORM_R +#endif +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED + T(INVERT_ALPHA, NONE, A, X, TRUE, RW_INVERT_ALPHA), + /* converts an alpha channel from 0..1 to 1..0 */ +#endif +#ifdef PNG_WRITE_FILLER_SUPPORTED + T(STRIP_FILLER_BEFORE, NONE, A, P, TRUE, W), /* 'A' for a filler! */ + /* on write skips a leading filler channel; testing requires data with a + * filler channel so this is produced from RGBA or GA images by removing + * the 'alpha' flag from the color type in place. + */ + T(STRIP_FILLER_AFTER, NONE, A, P, TRUE, W), + /* on write strips a trailing filler channel */ +#endif +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED + T(GRAY_TO_RGB, NONE, X, C, ALL, R), + /* expands grayscale images to RGB, also causes the palette part of + * 'EXPAND' to happen. Low bit depth grayscale images are expanded to + * 8-bits per component and no attempt is made to convert the image to a + * palette image. While this transform is partially reversible + * png_write_png does not currently support this. + */ + T(GRAY_TO_RGB, NONE, P, X, ALL, R), + /* The 'palette' side effect mentioned above; a bit bogus but this is the + * way the libpng code works. + */ +#endif +#ifdef PNG_READ_EXPAND_16_SUPPORTED + T(EXPAND_16, NONE, X, X, PAL, R), + /* expands images to 16-bits per component, as a side effect expands + * palette images to RGB and expands the tRNS chunk if present, so it can + * modify 16-bit per component images as well: + */ + T(EXPAND_16, tRNS, X, A, 16, R), + /* side effect of EXPAND_16 - expands the tRNS chunk in an RGB or G 16-bit + * image. + */ +#endif +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + T(SCALE_16, NONE, X, X, 16, R), + /* scales 16-bit components to 8-bits. */ +#endif + + { NULL /*name*/, 0, 0, 0, 0, 0, 0, 0/*!tested*/ } + +#undef T +}; + +#define ARRAY_SIZE(a) ((sizeof a)/(sizeof a[0])) +#define TTABLE_SIZE ARRAY_SIZE(transform_info) + +/* Some combinations of options that should be reversible are not; these cases + * are bugs. + */ +static int known_bad_combos[][2] = +{ + /* problem, antidote */ + { PNG_TRANSFORM_SHIFT | PNG_TRANSFORM_INVERT_ALPHA, 0/*antidote*/ } +}; + +static int +is_combo(int transforms) +{ + return transforms & (transforms-1); /* non-zero if more than one set bit */ +} + +static int +first_transform(int transforms) +{ + return transforms & -transforms; /* lowest set bit */ +} + +static int +is_bad_combo(int transforms) +{ + unsigned int i; + + for (i=0; ifirst.next = NULL; + buffer->last = NULL; + buffer->current = NULL; +} + +static void +buffer_destroy_list(struct buffer_list *list) +{ + if (list != NULL) + { + struct buffer_list *next = list->next; + DELETE(list); + buffer_destroy_list(next); + } +} + +static void +buffer_destroy(struct buffer *buffer) +{ + struct buffer_list *list = buffer->first.next; + buffer_init(buffer); + buffer_destroy_list(list); +} + +#ifdef PNG_WRITE_PNG_SUPPORTED +static void +buffer_start_write(struct buffer *buffer) +{ + buffer->last = &buffer->first; + buffer->end_count = 0; + buffer->current = NULL; +} +#endif + +static void +buffer_start_read(struct buffer *buffer) +{ + buffer->current = &buffer->first; + buffer->read_count = 0; +} + +#ifdef ENOMEM /* required by POSIX 1003.1 */ +# define MEMORY ENOMEM +#else +# define MEMORY ERANGE /* required by ANSI-C */ +#endif +static struct buffer * +get_buffer(png_structp pp) + /* Used from libpng callbacks to get the current buffer */ +{ + return (struct buffer*)png_get_io_ptr(pp); +} + +static struct buffer_list * +buffer_extend(struct buffer_list *current) +{ + struct buffer_list *add; + + assert(current->next == NULL); + + add = NEW(struct buffer_list); + if (add == NULL) + return NULL; + + add->next = NULL; + current->next = add; + + return add; +} + +/* Load a buffer from a file; does the equivalent of buffer_start_write. On a + * read error returns an errno value, else returns 0. + */ +static int +buffer_from_file(struct buffer *buffer, FILE *fp) +{ + struct buffer_list *last = &buffer->first; + size_t count = 0; + + for (;;) + { + size_t r = fread(last->buffer+count, 1/*size*/, + (sizeof last->buffer)-count, fp); + + if (r > 0) + { + count += r; + + if (count >= sizeof last->buffer) + { + assert(count == sizeof last->buffer); + count = 0; + + if (last->next == NULL) + { + last = buffer_extend(last); + if (last == NULL) + return MEMORY; + } + + else + last = last->next; + } + } + + else /* fread failed - probably end of file */ + { + if (feof(fp)) + { + buffer->last = last; + buffer->end_count = count; + return 0; /* no error */ + } + + /* Some kind of funky error; errno should be non-zero */ + return errno == 0 ? ERANGE : errno; + } + } +} + +/* This structure is used to control the test of a single file. */ +typedef enum +{ + VERBOSE, /* switches on all messages */ + INFORMATION, + WARNINGS, /* switches on warnings */ + LIBPNG_WARNING, + APP_WARNING, + ERRORS, /* just errors */ + APP_FAIL, /* continuable error - no need to longjmp */ + LIBPNG_ERROR, /* this and higher cause a longjmp */ + LIBPNG_BUG, /* erroneous behavior in libpng */ + APP_ERROR, /* such as out-of-memory in a callback */ + QUIET, /* no normal messages */ + USER_ERROR, /* such as file-not-found */ + INTERNAL_ERROR +} error_level; +#define LEVEL_MASK 0xf /* where the level is in 'options' */ + +#define EXHAUSTIVE 0x010 /* Test all combinations of active options */ +#define STRICT 0x020 /* Fail on warnings as well as errors */ +#define LOG 0x040 /* Log pass/fail to stdout */ +#define CONTINUE 0x080 /* Continue on APP_FAIL errors */ +#define SKIP_BUGS 0x100 /* Skip over known bugs */ +#define LOG_SKIPPED 0x200 /* Log skipped bugs */ +#define FIND_BAD_COMBOS 0x400 /* Attempt to deduce bad combos */ +#define LIST_COMBOS 0x800 /* List combos by name */ + +/* Result masks apply to the result bits in the 'results' field below; these + * bits are simple 1U<options = WARNINGS; /* default to !verbose, !quiet */ + dp->filename = NULL; + dp->operation = NULL; + dp->original_pp = NULL; + dp->original_ip = NULL; + dp->original_rows = NULL; + dp->read_pp = NULL; + dp->read_ip = NULL; + buffer_init(&dp->original_file); + +# ifdef PNG_WRITE_PNG_SUPPORTED + dp->write_pp = NULL; + buffer_init(&dp->written_file); +# endif +} + +static void +display_clean_read(struct display *dp) +{ + if (dp->read_pp != NULL) + png_destroy_read_struct(&dp->read_pp, &dp->read_ip, NULL); +} + +#ifdef PNG_WRITE_PNG_SUPPORTED +static void +display_clean_write(struct display *dp) +{ + if (dp->write_pp != NULL) + png_destroy_write_struct(&dp->write_pp, NULL); +} +#endif + +static void +display_clean(struct display *dp) +{ +# ifdef PNG_WRITE_PNG_SUPPORTED + display_clean_write(dp); +# endif + display_clean_read(dp); + + dp->original_rowbytes = 0; + dp->original_rows = NULL; + dp->chunks = 0; + + png_destroy_read_struct(&dp->original_pp, &dp->original_ip, NULL); + /* leave the filename for error detection */ + dp->results = 0; /* reset for next time */ +} + +static void +display_destroy(struct display *dp) +{ + /* Release any memory held in the display. */ +# ifdef PNG_WRITE_PNG_SUPPORTED + buffer_destroy(&dp->written_file); +# endif + + buffer_destroy(&dp->original_file); +} + +static struct display * +get_dp(png_structp pp) + /* The display pointer is always stored in the png_struct error pointer */ +{ + struct display *dp = (struct display*)png_get_error_ptr(pp); + + if (dp == NULL) + { + fprintf(stderr, "pngimage: internal error (no display)\n"); + exit(99); /* prevents a crash */ + } + + return dp; +} + +/* error handling */ +#ifdef __GNUC__ +# define VGATTR __attribute__((__format__ (__printf__,3,4))) + /* Required to quiet GNUC warnings when the compiler sees a stdarg function + * that calls one of the stdio v APIs. + */ +#else +# define VGATTR +#endif +static void VGATTR +display_log(struct display *dp, error_level level, const char *fmt, ...) + /* 'level' is as above, fmt is a stdio style format string. This routine + * does not return if level is above LIBPNG_WARNING + */ +{ + dp->results |= 1U << level; + + if (level > (error_level)(dp->options & LEVEL_MASK)) + { + const char *lp; + va_list ap; + + switch (level) + { + case INFORMATION: lp = "information"; break; + case LIBPNG_WARNING: lp = "warning(libpng)"; break; + case APP_WARNING: lp = "warning(pngimage)"; break; + case APP_FAIL: lp = "error(continuable)"; break; + case LIBPNG_ERROR: lp = "error(libpng)"; break; + case LIBPNG_BUG: lp = "bug(libpng)"; break; + case APP_ERROR: lp = "error(pngimage)"; break; + case USER_ERROR: lp = "error(user)"; break; + + case INTERNAL_ERROR: /* anything unexpected is an internal error: */ + case VERBOSE: case WARNINGS: case ERRORS: case QUIET: + default: lp = "bug(pngimage)"; break; + } + + fprintf(stderr, "%s: %s: %s", + dp->filename != NULL ? dp->filename : "", lp, dp->operation); + + if (dp->transforms != 0) + { + int tr = dp->transforms; + + if (is_combo(tr)) + { + if (dp->options & LIST_COMBOS) + { + int trx = tr; + + fprintf(stderr, "("); + if (trx) + { + int start = 0; + + while (trx) + { + int trz = trx & -trx; + + if (start) fprintf(stderr, "+"); + fprintf(stderr, "%s", transform_name(trz)); + start = 1; + trx &= ~trz; + } + } + + else + fprintf(stderr, "-"); + fprintf(stderr, ")"); + } + + else + fprintf(stderr, "(0x%x)", tr); + } + + else + fprintf(stderr, "(%s)", transform_name(tr)); + } + + fprintf(stderr, ": "); + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + fputc('\n', stderr); + } + /* else do not output any message */ + + /* Errors cause this routine to exit to the fail code */ + if (level > APP_FAIL || (level > ERRORS && !(dp->options & CONTINUE))) + longjmp(dp->error_return, level); +} + +/* error handler callbacks for libpng */ +static void PNGCBAPI +display_warning(png_structp pp, png_const_charp warning) +{ + display_log(get_dp(pp), LIBPNG_WARNING, "%s", warning); +} + +static void PNGCBAPI +display_error(png_structp pp, png_const_charp error) +{ + struct display *dp = get_dp(pp); + + display_log(dp, LIBPNG_ERROR, "%s", error); +} + +static void +display_cache_file(struct display *dp, const char *filename) + /* Does the initial cache of the file. */ +{ + FILE *fp; + int ret; + + dp->filename = filename; + + if (filename != NULL) + { + fp = fopen(filename, "rb"); + if (fp == NULL) + display_log(dp, USER_ERROR, "open failed: %s", strerror(errno)); + } + + else + fp = stdin; + + ret = buffer_from_file(&dp->original_file, fp); + + fclose(fp); + + if (ret != 0) + display_log(dp, APP_ERROR, "read failed: %s", strerror(ret)); +} + +static void +buffer_read(struct display *dp, struct buffer *bp, png_bytep data, + size_t size) +{ + struct buffer_list *last = bp->current; + size_t read_count = bp->read_count; + + while (size > 0) + { + size_t avail; + + if (last == NULL || + (last == bp->last && read_count >= bp->end_count)) + { + display_log(dp, USER_ERROR, "file truncated (%lu bytes)", + (unsigned long)size); + /*NOTREACHED*/ + break; + } + + else if (read_count >= sizeof last->buffer) + { + /* Move to the next buffer: */ + last = last->next; + read_count = 0; + bp->current = last; /* Avoid update outside the loop */ + + /* And do a sanity check (the EOF case is caught above) */ + if (last == NULL) + { + display_log(dp, INTERNAL_ERROR, "damaged buffer list"); + /*NOTREACHED*/ + break; + } + } + + avail = (sizeof last->buffer) - read_count; + if (avail > size) + avail = size; + + memcpy(data, last->buffer + read_count, avail); + read_count += avail; + size -= avail; + data += avail; + } + + bp->read_count = read_count; +} + +static void PNGCBAPI +read_function(png_structp pp, png_bytep data, size_t size) +{ + buffer_read(get_dp(pp), get_buffer(pp), data, size); +} + +static void +read_png(struct display *dp, struct buffer *bp, const char *operation, + int transforms) +{ + png_structp pp; + png_infop ip; + + /* This cleans out any previous read and sets operation and transforms to + * empty. + */ + display_clean_read(dp); + + if (operation != NULL) /* else this is a verify and do not overwrite info */ + { + dp->operation = operation; + dp->transforms = transforms; + } + + dp->read_pp = pp = png_create_read_struct(PNG_LIBPNG_VER_STRING, dp, + display_error, display_warning); + if (pp == NULL) + display_log(dp, LIBPNG_ERROR, "failed to create read struct"); + + /* The png_read_png API requires us to make the info struct, but it does the + * call to png_read_info. + */ + dp->read_ip = ip = png_create_info_struct(pp); + if (ip == NULL) + display_log(dp, LIBPNG_ERROR, "failed to create info struct"); + +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + /* Remove the user limits, if any */ + png_set_user_limits(pp, 0x7fffffff, 0x7fffffff); +# endif + + /* Set the IO handling */ + buffer_start_read(bp); + png_set_read_fn(pp, bp, read_function); + + png_read_png(pp, ip, transforms, NULL/*params*/); + +#if 0 /* crazy debugging */ + { + png_bytep pr = png_get_rows(pp, ip)[0]; + size_t rb = png_get_rowbytes(pp, ip); + size_t cb; + char c = ' '; + + fprintf(stderr, "%.4x %2d (%3lu bytes):", transforms, png_get_bit_depth(pp,ip), (unsigned long)rb); + + for (cb=0; cboriginal_file, "original read", 0/*no transform*/); + + /* Move the result to the 'original' fields */ + dp->original_pp = pp = dp->read_pp, dp->read_pp = NULL; + dp->original_ip = ip = dp->read_ip, dp->read_ip = NULL; + + dp->original_rowbytes = png_get_rowbytes(pp, ip); + if (dp->original_rowbytes == 0) + display_log(dp, LIBPNG_BUG, "png_get_rowbytes returned 0"); + + dp->chunks = png_get_valid(pp, ip, 0xffffffff); + if ((dp->chunks & PNG_INFO_IDAT) == 0) /* set by png_read_png */ + display_log(dp, LIBPNG_BUG, "png_read_png did not set IDAT flag"); + + dp->original_rows = png_get_rows(pp, ip); + if (dp->original_rows == NULL) + display_log(dp, LIBPNG_BUG, "png_read_png did not create row buffers"); + + if (!png_get_IHDR(pp, ip, + &dp->width, &dp->height, &dp->bit_depth, &dp->color_type, + &dp->interlace_method, &dp->compression_method, &dp->filter_method)) + display_log(dp, LIBPNG_BUG, "png_get_IHDR failed"); + + /* 'active' transforms are discovered based on the original image format; + * running one active transform can activate others. At present the code + * does not attempt to determine the closure. + */ + { + png_uint_32 chunks = dp->chunks; + int active = 0, inactive = 0; + int ct = dp->color_type; + int bd = dp->bit_depth; + unsigned int i; + + for (i=0; iactive_transforms = active; + dp->ignored_transforms = inactive; /* excluding write-only transforms */ + } +} + +static int +compare_read(struct display *dp, int applied_transforms) +{ + /* Compare the png_info from read_ip with original_info */ + size_t rowbytes; + png_uint_32 width, height; + int bit_depth, color_type; + int interlace_method, compression_method, filter_method; + const char *e = NULL; + + png_get_IHDR(dp->read_pp, dp->read_ip, &width, &height, &bit_depth, + &color_type, &interlace_method, &compression_method, &filter_method); + +# define C(item) if (item != dp->item) \ + display_log(dp, APP_WARNING, "IHDR " #item "(%lu) changed to %lu",\ + (unsigned long)dp->item, (unsigned long)item), e = #item + + /* The IHDR should be identical: */ + C(width); + C(height); + C(bit_depth); + C(color_type); + C(interlace_method); + C(compression_method); + C(filter_method); + + /* 'e' remains set to the name of the last thing changed: */ + if (e) + display_log(dp, APP_ERROR, "IHDR changed (%s)", e); + + /* All the chunks from the original PNG should be preserved in the output PNG + * because the PNG format has not been changed. + */ + { + unsigned long chunks = + png_get_valid(dp->read_pp, dp->read_ip, 0xffffffff); + + if (chunks != dp->chunks) + display_log(dp, APP_FAIL, "PNG chunks changed from 0x%lx to 0x%lx", + (unsigned long)dp->chunks, chunks); + } + + /* rowbytes should be the same */ + rowbytes = png_get_rowbytes(dp->read_pp, dp->read_ip); + + /* NOTE: on 64-bit systems this may trash the top bits of rowbytes, + * which could lead to weird error messages. + */ + if (rowbytes != dp->original_rowbytes) + display_log(dp, APP_ERROR, "PNG rowbytes changed from %lu to %lu", + (unsigned long)dp->original_rowbytes, (unsigned long)rowbytes); + + /* The rows should be the same too, unless the applied transforms includes + * the shift transform, in which case low bits may have been lost. + */ + { + png_bytepp rows = png_get_rows(dp->read_pp, dp->read_ip); + unsigned int mask; /* mask (if not zero) for the final byte */ + + if (bit_depth < 8) + { + /* Need the stray bits at the end, this depends only on the low bits + * of the image width; overflow does not matter. If the width is an + * exact multiple of 8 bits this gives a mask of 0, not 0xff. + */ + mask = 0xff & (0xff00 >> ((bit_depth * width) & 7)); + } + + else + mask = 0; + + if (rows == NULL) + display_log(dp, LIBPNG_BUG, "png_get_rows returned NULL"); + + if ((applied_transforms & PNG_TRANSFORM_SHIFT) == 0 || + (dp->active_transforms & PNG_TRANSFORM_SHIFT) == 0 || + color_type == PNG_COLOR_TYPE_PALETTE) + { + unsigned long y; + + for (y=0; yoriginal_rows[y]; + + if (memcmp(row, orig, rowbytes-(mask != 0)) != 0 || (mask != 0 && + ((row[rowbytes-1] & mask) != (orig[rowbytes-1] & mask)))) + { + size_t x; + + /* Find the first error */ + for (x=0; x 0x%.2x", + (unsigned long)x, (unsigned long)y, orig[x], row[x]); + return 0; /* don't keep reporting failed rows on 'continue' */ + } + } + } + + else +# ifdef PNG_sBIT_SUPPORTED + { + unsigned long y; + int bpp; /* bits-per-pixel then bytes-per-pixel */ + /* components are up to 8 bytes in size */ + png_byte sig_bits[8]; + png_color_8p sBIT; + + if (png_get_sBIT(dp->read_pp, dp->read_ip, &sBIT) != PNG_INFO_sBIT) + display_log(dp, INTERNAL_ERROR, + "active shift transform but no sBIT in file"); + + switch (color_type) + { + case PNG_COLOR_TYPE_GRAY: + sig_bits[0] = sBIT->gray; + bpp = bit_depth; + break; + + case PNG_COLOR_TYPE_GA: + sig_bits[0] = sBIT->gray; + sig_bits[1] = sBIT->alpha; + bpp = 2 * bit_depth; + break; + + case PNG_COLOR_TYPE_RGB: + sig_bits[0] = sBIT->red; + sig_bits[1] = sBIT->green; + sig_bits[2] = sBIT->blue; + bpp = 3 * bit_depth; + break; + + case PNG_COLOR_TYPE_RGBA: + sig_bits[0] = sBIT->red; + sig_bits[1] = sBIT->green; + sig_bits[2] = sBIT->blue; + sig_bits[3] = sBIT->alpha; + bpp = 4 * bit_depth; + break; + + default: + display_log(dp, LIBPNG_ERROR, "invalid colour type %d", + color_type); + /*NOTREACHED*/ + bpp = 0; + break; + } + + { + int b; + + for (b=0; 8*b bit_depth/*!palette*/) + display_log(dp, LIBPNG_BUG, + "invalid sBIT[%u] value %d returned for PNG bit depth %d", + b, sig_bits[b], bit_depth); + } + } + + if (bpp < 8 && bpp != bit_depth) + { + /* sanity check; this is a grayscale PNG; something is wrong in the + * code above. + */ + display_log(dp, INTERNAL_ERROR, "invalid bpp %u for bit_depth %u", + bpp, bit_depth); + } + + switch (bit_depth) + { + int b; + + case 16: /* Two bytes per component, big-endian */ + for (b = (bpp >> 4); b > 0; --b) + { + unsigned int sig = (unsigned int)(0xffff0000 >> sig_bits[b]); + + sig_bits[2*b+1] = (png_byte)sig; + sig_bits[2*b+0] = (png_byte)(sig >> 8); /* big-endian */ + } + break; + + case 8: /* One byte per component */ + for (b=0; b*8 < bpp; ++b) + sig_bits[b] = (png_byte)(0xff00 >> sig_bits[b]); + break; + + case 1: /* allowed, but dumb */ + /* Value is 1 */ + sig_bits[0] = 0xff; + break; + + case 2: /* Replicate 4 times */ + /* Value is 1 or 2 */ + b = 0x3 & ((0x3<<2) >> sig_bits[0]); + b |= b << 2; + b |= b << 4; + sig_bits[0] = (png_byte)b; + break; + + case 4: /* Relicate twice */ + /* Value is 1, 2, 3 or 4 */ + b = 0xf & ((0xf << 4) >> sig_bits[0]); + b |= b << 4; + sig_bits[0] = (png_byte)b; + break; + + default: + display_log(dp, LIBPNG_BUG, "invalid bit depth %d", bit_depth); + break; + } + + /* Convert bpp to bytes; this gives '1' for low-bit depth grayscale, + * where there are multiple pixels per byte. + */ + bpp = (bpp+7) >> 3; + + /* The mask can be combined with sig_bits[0] */ + if (mask != 0) + { + mask &= sig_bits[0]; + + if (bpp != 1 || mask == 0) + display_log(dp, INTERNAL_ERROR, "mask calculation error %u, %u", + bpp, mask); + } + + for (y=0; yoriginal_rows[y]; + unsigned long x; + + for (x=0; x<(width-(mask!=0)); ++x) + { + int b; + + for (b=0; b%.2x", + x, b, y, orig[-1], row[-1]); + return 0; + } + } + } + + if (mask != 0 && (*row & mask) != (*orig & mask)) + { + display_log(dp, APP_FAIL, + "significant bits at (%lu[end],%lu) changed", x, y); + return 0; + } + } /* for y */ + } +# else /* !sBIT */ + display_log(dp, INTERNAL_ERROR, + "active shift transform but no sBIT support"); +# endif /* !sBIT */ + } + + return 1; /* compare succeeded */ +} + +#ifdef PNG_WRITE_PNG_SUPPORTED +static void +buffer_write(struct display *dp, struct buffer *buffer, png_bytep data, + size_t size) + /* Generic write function used both from the write callback provided to + * libpng and from the generic read code. + */ +{ + /* Write the data into the buffer, adding buffers as required */ + struct buffer_list *last = buffer->last; + size_t end_count = buffer->end_count; + + while (size > 0) + { + size_t avail; + + if (end_count >= sizeof last->buffer) + { + if (last->next == NULL) + { + last = buffer_extend(last); + + if (last == NULL) + display_log(dp, APP_ERROR, "out of memory saving file"); + } + + else + last = last->next; + + buffer->last = last; /* avoid the need to rewrite every time */ + end_count = 0; + } + + avail = (sizeof last->buffer) - end_count; + if (avail > size) + avail = size; + + memcpy(last->buffer + end_count, data, avail); + end_count += avail; + size -= avail; + data += avail; + } + + buffer->end_count = end_count; +} + +static void PNGCBAPI +write_function(png_structp pp, png_bytep data, size_t size) +{ + buffer_write(get_dp(pp), get_buffer(pp), data, size); +} + +static void +write_png(struct display *dp, png_infop ip, int transforms) +{ + display_clean_write(dp); /* safety */ + + buffer_start_write(&dp->written_file); + dp->operation = "write"; + dp->transforms = transforms; + + dp->write_pp = png_create_write_struct(PNG_LIBPNG_VER_STRING, dp, + display_error, display_warning); + + if (dp->write_pp == NULL) + display_log(dp, APP_ERROR, "failed to create write png_struct"); + + png_set_write_fn(dp->write_pp, &dp->written_file, write_function, + NULL/*flush*/); + +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + /* Remove the user limits, if any */ + png_set_user_limits(dp->write_pp, 0x7fffffff, 0x7fffffff); +# endif + + /* Certain transforms require the png_info to be zapped to allow the + * transform to work correctly. + */ + if (transforms & (PNG_TRANSFORM_PACKING| + PNG_TRANSFORM_STRIP_FILLER| + PNG_TRANSFORM_STRIP_FILLER_BEFORE)) + { + int ct = dp->color_type; + + if (transforms & (PNG_TRANSFORM_STRIP_FILLER| + PNG_TRANSFORM_STRIP_FILLER_BEFORE)) + ct &= ~PNG_COLOR_MASK_ALPHA; + + png_set_IHDR(dp->write_pp, ip, dp->width, dp->height, dp->bit_depth, ct, + dp->interlace_method, dp->compression_method, dp->filter_method); + } + + png_write_png(dp->write_pp, ip, transforms, NULL/*params*/); + + /* Clean it on the way out - if control returns to the caller then the + * written_file contains the required data. + */ + display_clean_write(dp); +} +#endif /* WRITE_PNG */ + +static int +skip_transform(struct display *dp, int tr) + /* Helper to test for a bad combo and log it if it is skipped */ +{ + if ((dp->options & SKIP_BUGS) != 0 && is_bad_combo(tr)) + { + /* Log this to stdout if logging is on, otherwise just do an information + * display_log. + */ + if ((dp->options & LOG_SKIPPED) != 0) + { + printf("SKIP: %s transforms ", dp->filename); + + while (tr != 0) + { + int next = first_transform(tr); + tr &= ~next; + + printf("%s", transform_name(next)); + if (tr != 0) + putchar('+'); + } + + putchar('\n'); + } + + else + display_log(dp, INFORMATION, "%s: skipped known bad combo 0x%x", + dp->filename, tr); + + return 1; /* skip */ + } + + return 0; /* don't skip */ +} + +static void +test_one_file(struct display *dp, const char *filename) +{ + /* First cache the file and update the display original file + * information for the new file. + */ + dp->operation = "cache file"; + dp->transforms = 0; + display_cache_file(dp, filename); + update_display(dp); + + /* First test: if there are options that should be ignored for this file + * verify that they really are ignored. + */ + if (dp->ignored_transforms != 0) + { + read_png(dp, &dp->original_file, "ignored transforms", + dp->ignored_transforms); + + /* The result should be identical to the original_rows */ + if (!compare_read(dp, 0/*transforms applied*/)) + return; /* no point testing more */ + } + +#ifdef PNG_WRITE_PNG_SUPPORTED + /* Second test: write the original PNG data out to a new file (to test the + * write side) then read the result back in and make sure that it hasn't + * changed. + */ + dp->operation = "write"; + write_png(dp, dp->original_ip, 0/*transforms*/); + read_png(dp, &dp->written_file, NULL, 0/*transforms*/); + if (!compare_read(dp, 0/*transforms applied*/)) + return; +#endif + + /* Third test: the active options. Test each in turn, or, with the + * EXHAUSTIVE option, test all possible combinations. + */ + { + /* Use unsigned int here because the code below to increment through all + * the possibilities exhaustively has to use a compare and that must be + * unsigned, because some transforms are negative on a 16-bit system. + */ + unsigned int active = dp->active_transforms; + int exhaustive = (dp->options & EXHAUSTIVE) != 0; + unsigned int current = first_transform(active); + unsigned int bad_transforms = 0; + unsigned int bad_combo = ~0U; /* bitwise AND of failing transforms */ + unsigned int bad_combo_list = 0; /* bitwise OR of failures */ + + for (;;) + { + read_png(dp, &dp->original_file, "active transforms", current); + + /* If this involved any irreversible transformations then if we write + * it out with just the reversible transformations and read it in again + * with the same transforms we should get the same thing. At present + * this isn't done - it just seems like a waste of time and it would + * require two sets of read png_struct/png_info. + * + * If there were no irreversible transformations then if we write it + * out and read it back in again (without the reversible transforms) + * we should get back to the place where we started. + */ +#ifdef PNG_WRITE_PNG_SUPPORTED + if ((current & write_transforms) == current) + { + /* All transforms reversible: write the PNG with the transformations + * reversed, then read it back in with no transformations. The + * result should be the same as the original apart from the loss of + * low order bits because of the SHIFT/sBIT transform. + */ + dp->operation = "reversible transforms"; + write_png(dp, dp->read_ip, current); + + /* And if this is read back in, because all the transformations were + * reversible, the result should be the same. + */ + read_png(dp, &dp->written_file, NULL, 0); + if (!compare_read(dp, current/*for the SHIFT/sBIT transform*/)) + { + /* This set of transforms failed. If a single bit is set - if + * there is just one transform - don't include this in further + * 'exhaustive' tests. Notice that each transform is tested on + * its own before testing combos in the exhaustive case. + */ + if (is_combo(current)) + { + bad_combo &= current; + bad_combo_list |= current; + } + + else + bad_transforms |= current; + } + } +#endif + + /* Now move to the next transform */ + if (exhaustive) /* all combinations */ + { + unsigned int next = current; + + do + { + if (next == read_transforms) /* Everything tested */ + goto combo; + + ++next; + } /* skip known bad combos if the relevant option is set; skip + * combos involving known bad single transforms in all cases. + */ + while ( (next & read_transforms) <= current + || (next & active) == 0 /* skip cases that do nothing */ + || (next & bad_transforms) != 0 + || skip_transform(dp, next)); + + assert((next & read_transforms) == next); + current = next; + } + + else /* one at a time */ + { + active &= ~current; + + if (active == 0) + goto combo; + + current = first_transform(active); + } + } + +combo: + if (dp->options & FIND_BAD_COMBOS) + { + /* bad_combos identifies the combos that occur in all failing cases; + * bad_combo_list identifies transforms that do not prevent the + * failure. + */ + if (bad_combo != ~0U) + printf("%s[0x%x]: PROBLEM: 0x%x[0x%x] ANTIDOTE: 0x%x\n", + dp->filename, active, bad_combo, bad_combo_list, + rw_transforms & ~bad_combo_list); + + else + printf("%s: no %sbad combos found\n", dp->filename, + (dp->options & SKIP_BUGS) ? "additional " : ""); + } + } +} + +static int +do_test(struct display *dp, const char *file) + /* Exists solely to isolate the setjmp clobbers */ +{ + int ret = setjmp(dp->error_return); + + if (ret == 0) + { + test_one_file(dp, file); + return 0; + } + + else if (ret < ERRORS) /* shouldn't longjmp on warnings */ + display_log(dp, INTERNAL_ERROR, "unexpected return code %d", ret); + + return ret; +} + +int +main(int argc, char **argv) +{ + /* For each file on the command line test it with a range of transforms */ + int option_end, ilog = 0; + struct display d; + + validate_T(); + display_init(&d); + + for (option_end=1; option_end QUIET) /* abort on user or internal error */ + return 99; + } + + /* Here on any return, including failures, except user/internal issues + */ + { + int pass = (d.options & STRICT) ? + RESULT_STRICT(d.results) : RESULT_RELAXED(d.results); + + if (!pass) + ++errors; + + if (d.options & LOG) + { + int j; + + printf("%s: pngimage ", pass ? "PASS" : "FAIL"); + + for (j=1; j +#include +#include +#include +#include +#include +#include + +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) +# include +#endif + +/* Define the following to use this test against your installed libpng, rather + * than the one being built here: + */ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../../png.h" +#endif + +/* 1.6.1 added support for the configure test harness, which uses 77 to indicate + * a skipped test, in earlier versions we need to succeed on a skipped test, so: + */ +#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H) +# define SKIP 77 +#else +# define SKIP 0 +#endif + +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED /* Else nothing can be done */ +#include "../tools/sRGB.h" + +/* KNOWN ISSUES + * + * These defines switch on alternate algorithms for format conversions to match + * the current libpng implementation; they are set to allow pngstest to pass + * even though libpng is producing answers that are not as correct as they + * should be. + */ +#define ALLOW_UNUSED_GPC 0 + /* If true include unused static GPC functions and declare an external array + * of them to hide the fact that they are unused. This is for development + * use while testing the correct function to use to take into account libpng + * misbehavior, such as using a simple power law to correct sRGB to linear. + */ + +/* The following is to support direct compilation of this file as C++ */ +#ifdef __cplusplus +# define voidcast(type, value) static_cast(value) +# define aligncastconst(type, value) \ + static_cast(static_cast(value)) +#else +# define voidcast(type, value) (value) +# define aligncastconst(type, value) ((const void*)(value)) +#endif /* __cplusplus */ + +/* During parallel runs of pngstest each temporary file needs a unique name, + * this is used to permit uniqueness using a command line argument which can be + * up to 22 characters long. + */ +static char tmpf[23] = "TMP"; + +/* Generate random bytes. This uses a boring repeatable algorithm and it + * is implemented here so that it gives the same set of numbers on every + * architecture. It's a linear congruential generator (Knuth or Sedgewick + * "Algorithms") but it comes from the 'feedback taps' table in Horowitz and + * Hill, "The Art of Electronics". + */ +static void +make_random_bytes(png_uint_32* seed, void* pv, size_t size) +{ + png_uint_32 u0 = seed[0], u1 = seed[1]; + png_bytep bytes = voidcast(png_bytep, pv); + + /* There are thirty three bits, the next bit in the sequence is bit-33 XOR + * bit-20. The top 1 bit is in u1, the bottom 32 are in u0. + */ + size_t i; + for (i=0; i> (20-8)) ^ ((u1 << 7) | (u0 >> (32-7)))) & 0xff; + u1 <<= 8; + u1 |= u0 >> 24; + u0 <<= 8; + u0 |= u; + *bytes++ = (png_byte)u; + } + + seed[0] = u0; + seed[1] = u1; +} + +static png_uint_32 color_seed[2]; + +static void +reseed(void) +{ + color_seed[0] = 0x12345678U; + color_seed[1] = 0x9abcdefU; +} + +static void +random_color(png_colorp color) +{ + make_random_bytes(color_seed, color, sizeof *color); +} + +/* Math support - neither Cygwin nor Visual Studio have C99 support and we need + * a predictable rounding function, so make one here: + */ +static double +closestinteger(double x) +{ + return floor(x + .5); +} + +/* Cast support: remove GCC whines. */ +static png_byte +u8d(double d) +{ + d = closestinteger(d); + return (png_byte)d; +} + +static png_uint_16 +u16d(double d) +{ + d = closestinteger(d); + return (png_uint_16)d; +} + +/* sRGB support: use exact calculations rounded to the nearest int, see the + * fesetround() call in main(). sRGB_to_d optimizes the 8 to 16-bit conversion. + */ +static double sRGB_to_d[256]; +static double g22_to_d[256]; + +static void +init_sRGB_to_d(void) +{ + int i; + + sRGB_to_d[0] = 0; + for (i=1; i<255; ++i) + sRGB_to_d[i] = linear_from_sRGB(i/255.); + sRGB_to_d[255] = 1; + + g22_to_d[0] = 0; + for (i=1; i<255; ++i) + g22_to_d[i] = pow(i/255., 1/.45455); + g22_to_d[255] = 1; +} + +static png_byte +sRGB(double linear /*range 0.0 .. 1.0*/) +{ + return u8d(255 * sRGB_from_linear(linear)); +} + +static png_byte +isRGB(int fixed_linear) +{ + return sRGB(fixed_linear / 65535.); +} + +#if 0 /* not used */ +static png_byte +unpremultiply(int component, int alpha) +{ + if (alpha <= component) + return 255; /* Arbitrary, but consistent with the libpng code */ + + else if (alpha >= 65535) + return isRGB(component); + + else + return sRGB((double)component / alpha); +} +#endif + +static png_uint_16 +ilinear(int fixed_srgb) +{ + return u16d(65535 * sRGB_to_d[fixed_srgb]); +} + +static png_uint_16 +ilineara(int fixed_srgb, int alpha) +{ + return u16d((257 * alpha) * sRGB_to_d[fixed_srgb]); +} + +static png_uint_16 +ilinear_g22(int fixed_srgb) +{ + return u16d(65535 * g22_to_d[fixed_srgb]); +} + +#if ALLOW_UNUSED_GPC +static png_uint_16 +ilineara_g22(int fixed_srgb, int alpha) +{ + return u16d((257 * alpha) * g22_to_d[fixed_srgb]); +} +#endif + +static double +YfromRGBint(int ir, int ig, int ib) +{ + double r = ir; + double g = ig; + double b = ib; + return YfromRGB(r, g, b); +} + +#if 0 /* unused */ +/* The error that results from using a 2.2 power law in place of the correct + * sRGB transform, given an 8-bit value which might be either sRGB or power-law. + */ +static int +power_law_error8(int value) +{ + if (value > 0 && value < 255) + { + double vd = value / 255.; + double e = fabs( + pow(sRGB_to_d[value], 1/2.2) - sRGB_from_linear(pow(vd, 2.2))); + + /* Always allow an extra 1 here for rounding errors */ + e = 1+floor(255 * e); + return (int)e; + } + + return 0; +} + +static int error_in_sRGB_roundtrip = 56; /* by experiment */ +static int +power_law_error16(int value) +{ + if (value > 0 && value < 65535) + { + /* Round trip the value through an 8-bit representation but using + * non-matching to/from conversions. + */ + double vd = value / 65535.; + double e = fabs( + pow(sRGB_from_linear(vd), 2.2) - linear_from_sRGB(pow(vd, 1/2.2))); + + /* Always allow an extra 1 here for rounding errors */ + e = error_in_sRGB_roundtrip+floor(65535 * e); + return (int)e; + } + + return 0; +} + +static int +compare_8bit(int v1, int v2, int error_limit, int multiple_algorithms) +{ + int e = abs(v1-v2); + int ev1, ev2; + + if (e <= error_limit) + return 1; + + if (!multiple_algorithms) + return 0; + + ev1 = power_law_error8(v1); + if (e <= ev1) + return 1; + + ev2 = power_law_error8(v2); + if (e <= ev2) + return 1; + + return 0; +} + +static int +compare_16bit(int v1, int v2, int error_limit, int multiple_algorithms) +{ + int e = abs(v1-v2); + int ev1, ev2; + + if (e <= error_limit) + return 1; + + /* "multiple_algorithms" in this case means that a color-map has been + * involved somewhere, so we can deduce that the values were forced to 8-bit + * (like the via_linear case for 8-bit.) + */ + if (!multiple_algorithms) + return 0; + + ev1 = power_law_error16(v1); + if (e <= ev1) + return 1; + + ev2 = power_law_error16(v2); + if (e <= ev2) + return 1; + + return 0; +} +#endif /* unused */ + +#define USE_FILE 1 /* else memory */ +#define USE_STDIO 2 /* else use file name */ +#define STRICT 4 /* fail on warnings too */ +#define VERBOSE 8 +#define KEEP_TMPFILES 16 /* else delete temporary files */ +#define KEEP_GOING 32 +#define ACCUMULATE 64 +#define FAST_WRITE 128 +#define sRGB_16BIT 256 +#define NO_RESEED 512 /* do not reseed on each new file */ +#define GBG_ERROR 1024 /* do not ignore the gamma+background_rgb_to_gray + * libpng warning. */ + +static void +print_opts(png_uint_32 opts) +{ + if (opts & USE_FILE) + printf(" --file"); + if (opts & USE_STDIO) + printf(" --stdio"); + if (!(opts & STRICT)) + printf(" --nostrict"); + if (opts & VERBOSE) + printf(" --verbose"); + if (opts & KEEP_TMPFILES) + printf(" --preserve"); + if (opts & KEEP_GOING) + printf(" --keep-going"); + if (opts & ACCUMULATE) + printf(" --accumulate"); + if (!(opts & FAST_WRITE)) /* --fast is currently the default */ + printf(" --slow"); + if (opts & sRGB_16BIT) + printf(" --sRGB-16bit"); + if (opts & NO_RESEED) + printf(" --noreseed"); +#if PNG_LIBPNG_VER < 10700 /* else on by default */ + if (opts & GBG_ERROR) + printf(" --fault-gbg-warning"); +#endif +} + +#define FORMAT_NO_CHANGE 0x80000000 /* additional flag */ + +/* A name table for all the formats - defines the format of the '+' arguments to + * pngstest. + */ +#define FORMAT_COUNT 64 +#define FORMAT_MASK 0x3f +static const char * const format_names[FORMAT_COUNT] = +{ + "sRGB-gray", + "sRGB-gray+alpha", + "sRGB-rgb", + "sRGB-rgb+alpha", + "linear-gray", + "linear-gray+alpha", + "linear-rgb", + "linear-rgb+alpha", + + "color-mapped-sRGB-gray", + "color-mapped-sRGB-gray+alpha", + "color-mapped-sRGB-rgb", + "color-mapped-sRGB-rgb+alpha", + "color-mapped-linear-gray", + "color-mapped-linear-gray+alpha", + "color-mapped-linear-rgb", + "color-mapped-linear-rgb+alpha", + + "sRGB-gray", + "sRGB-gray+alpha", + "sRGB-bgr", + "sRGB-bgr+alpha", + "linear-gray", + "linear-gray+alpha", + "linear-bgr", + "linear-bgr+alpha", + + "color-mapped-sRGB-gray", + "color-mapped-sRGB-gray+alpha", + "color-mapped-sRGB-bgr", + "color-mapped-sRGB-bgr+alpha", + "color-mapped-linear-gray", + "color-mapped-linear-gray+alpha", + "color-mapped-linear-bgr", + "color-mapped-linear-bgr+alpha", + + "sRGB-gray", + "alpha+sRGB-gray", + "sRGB-rgb", + "alpha+sRGB-rgb", + "linear-gray", + "alpha+linear-gray", + "linear-rgb", + "alpha+linear-rgb", + + "color-mapped-sRGB-gray", + "color-mapped-alpha+sRGB-gray", + "color-mapped-sRGB-rgb", + "color-mapped-alpha+sRGB-rgb", + "color-mapped-linear-gray", + "color-mapped-alpha+linear-gray", + "color-mapped-linear-rgb", + "color-mapped-alpha+linear-rgb", + + "sRGB-gray", + "alpha+sRGB-gray", + "sRGB-bgr", + "alpha+sRGB-bgr", + "linear-gray", + "alpha+linear-gray", + "linear-bgr", + "alpha+linear-bgr", + + "color-mapped-sRGB-gray", + "color-mapped-alpha+sRGB-gray", + "color-mapped-sRGB-bgr", + "color-mapped-alpha+sRGB-bgr", + "color-mapped-linear-gray", + "color-mapped-alpha+linear-gray", + "color-mapped-linear-bgr", + "color-mapped-alpha+linear-bgr", +}; + +/* Decode an argument to a format number. */ +static png_uint_32 +formatof(const char *arg) +{ + char *ep; + unsigned long format = strtoul(arg, &ep, 0); + + if (ep > arg && *ep == 0 && format < FORMAT_COUNT) + return (png_uint_32)format; + + else for (format=0; format < FORMAT_COUNT; ++format) + { + if (strcmp(format_names[format], arg) == 0) + return (png_uint_32)format; + } + + fprintf(stderr, "pngstest: format name '%s' invalid\n", arg); + return FORMAT_COUNT; +} + +/* Bitset/test functions for formats */ +#define FORMAT_SET_COUNT (FORMAT_COUNT / 32) +typedef struct +{ + png_uint_32 bits[FORMAT_SET_COUNT]; +} +format_list; + +static void format_init(format_list *pf) +{ + int i; + for (i=0; ibits[i] = 0; /* All off */ +} + +#if 0 /* currently unused */ +static void format_clear(format_list *pf) +{ + int i; + for (i=0; ibits[i] = 0; +} +#endif + +static int format_is_initial(format_list *pf) +{ + int i; + for (i=0; ibits[i] != 0) + return 0; + + return 1; +} + +static int format_set(format_list *pf, png_uint_32 format) +{ + if (format < FORMAT_COUNT) + return pf->bits[format >> 5] |= ((png_uint_32)1) << (format & 31); + + return 0; +} + +#if 0 /* currently unused */ +static int format_unset(format_list *pf, png_uint_32 format) +{ + if (format < FORMAT_COUNT) + return pf->bits[format >> 5] &= ~((png_uint_32)1) << (format & 31); + + return 0; +} +#endif + +static int format_isset(format_list *pf, png_uint_32 format) +{ + return format < FORMAT_COUNT && + (pf->bits[format >> 5] & (((png_uint_32)1) << (format & 31))) != 0; +} + +static void format_default(format_list *pf, int redundant) +{ + if (redundant) + { + int i; + + /* set everything, including flags that are pointless */ + for (i=0; ibits[i] = ~(png_uint_32)0; + } + + else + { + png_uint_32 f; + + for (f=0; finput_file != NULL) + rewind(image->input_file); +} + +/* Free the image buffer; the buffer is re-used on a re-read, this is just for + * cleanup. + */ +static void +freebuffer(Image *image) +{ + if (image->buffer) free(image->buffer); + image->buffer = NULL; + image->bufsize = 0; + image->allocsize = 0; +} + +/* Delete function; cleans out all the allocated data and the temporary file in + * the image. + */ +static void +freeimage(Image *image) +{ + freebuffer(image); + png_image_free(&image->image); + + if (image->input_file != NULL) + { + fclose(image->input_file); + image->input_file = NULL; + } + + if (image->input_memory != NULL) + { + free(image->input_memory); + image->input_memory = NULL; + image->input_memory_size = 0; + } + + if (image->tmpfile_name[0] != 0 && (image->opts & KEEP_TMPFILES) == 0) + { + (void)remove(image->tmpfile_name); + image->tmpfile_name[0] = 0; + } +} + +/* This is actually a re-initializer; allows an image structure to be re-used by + * freeing everything that relates to an old image. + */ +static void initimage(Image *image, png_uint_32 opts, const char *file_name, + int stride_extra) +{ + freeimage(image); + memset(&image->image, 0, sizeof image->image); + image->opts = opts; + image->file_name = file_name; + image->stride_extra = stride_extra; +} + +/* Make sure the image buffer is big enough; allows re-use of the buffer if the + * image is re-read. + */ +#define BUFFER_INIT8 73 +static void +allocbuffer(Image *image) +{ + size_t size = PNG_IMAGE_BUFFER_SIZE(image->image, image->stride); + + if (size+32 > image->bufsize) + { + freebuffer(image); + image->buffer = voidcast(png_bytep, malloc(size+32)); + if (image->buffer == NULL) + { + fflush(stdout); + fprintf(stderr, + "simpletest: out of memory allocating %lu(+32) byte buffer\n", + (unsigned long)size); + exit(1); + } + image->bufsize = size+32; + } + + memset(image->buffer, 95, image->bufsize); + memset(image->buffer+16, BUFFER_INIT8, size); + image->allocsize = size; +} + +/* Make sure 16 bytes match the given byte. */ +static int +check16(png_const_bytep bp, int b) +{ + int i = 16; + + do + if (*bp != b) return 1; + while (--i); + + return 0; +} + +/* Check for overwrite in the image buffer. */ +static void +checkbuffer(Image *image, const char *arg) +{ + if (check16(image->buffer, 95)) + { + fflush(stdout); + fprintf(stderr, "%s: overwrite at start of image buffer\n", arg); + exit(1); + } + + if (check16(image->buffer+16+image->allocsize, 95)) + { + fflush(stdout); + fprintf(stderr, "%s: overwrite at end of image buffer\n", arg); + exit(1); + } +} + +/* ERROR HANDLING */ +/* Log a terminal error, also frees the libpng part of the image if necessary. + */ +static int +logerror(Image *image, const char *a1, const char *a2, const char *a3) +{ + fflush(stdout); + if (image->image.warning_or_error) + fprintf(stderr, "%s%s%s: %s\n", a1, a2, a3, image->image.message); + + else + fprintf(stderr, "%s%s%s\n", a1, a2, a3); + + if (image->image.opaque != NULL) + { + fprintf(stderr, "%s: image opaque pointer non-NULL on error\n", + image->file_name); + png_image_free(&image->image); + } + + return 0; +} + +/* Log an error and close a file (just a utility to do both things in one + * function call.) + */ +static int +logclose(Image *image, FILE *f, const char *name, const char *operation) +{ + int e = errno; + + fclose(f); + return logerror(image, name, operation, strerror(e)); +} + +/* Make sure the png_image has been freed - validates that libpng is doing what + * the spec says and freeing the image. + */ +static int +checkopaque(Image *image) +{ + if (image->image.opaque != NULL) + { + png_image_free(&image->image); + return logerror(image, image->file_name, ": opaque not NULL", ""); + } + + /* Separate out the gamma+background_rgb_to_gray warning because it may + * produce opaque component errors: + */ + else if (image->image.warning_or_error != 0 && + (strcmp(image->image.message, + "libpng does not support gamma+background+rgb_to_gray") == 0 ? + (image->opts & GBG_ERROR) != 0 : (image->opts & STRICT) != 0)) + return logerror(image, image->file_name, (image->opts & GBG_ERROR) != 0 ? + " --fault-gbg-warning" : " --strict", ""); + + else + return 1; +} + +/* IMAGE COMPARISON/CHECKING */ +/* Compare the pixels of two images, which should be the same but aren't. The + * images must have been checked for a size match. + */ +typedef struct +{ + /* The components, for grayscale images the gray value is in 'g' and if alpha + * is not present 'a' is set to 255 or 65535 according to format. + */ + int r, g, b, a; +} Pixel; + +typedef struct +{ + /* The background as the original sRGB 8-bit value converted to the final + * integer format and as a double precision linear value in the range 0..1 + * for with partially transparent pixels. + */ + int ir, ig, ib; + double dr, dg, db; /* linear r,g,b scaled to 0..1 */ +} Background; + +/* Basic image formats; control the data but not the layout thereof. */ +#define BASE_FORMATS\ + (PNG_FORMAT_FLAG_ALPHA|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_LINEAR) + +/* Read a Pixel from a buffer. The code below stores the correct routine for + * the format in a function pointer, these are the routines: + */ +static void +gp_g8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = p->g = p->b = pp[0]; + p->a = 255; +} + +static void +gp_ga8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = p->g = p->b = pp[0]; + p->a = pp[1]; +} + +#ifdef PNG_FORMAT_AFIRST_SUPPORTED +static void +gp_ag8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = p->g = p->b = pp[1]; + p->a = pp[0]; +} +#endif + +static void +gp_rgb8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[0]; + p->g = pp[1]; + p->b = pp[2]; + p->a = 255; +} + +#ifdef PNG_FORMAT_BGR_SUPPORTED +static void +gp_bgr8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[2]; + p->g = pp[1]; + p->b = pp[0]; + p->a = 255; +} +#endif + +static void +gp_rgba8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[0]; + p->g = pp[1]; + p->b = pp[2]; + p->a = pp[3]; +} + +#ifdef PNG_FORMAT_BGR_SUPPORTED +static void +gp_bgra8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[2]; + p->g = pp[1]; + p->b = pp[0]; + p->a = pp[3]; +} +#endif + +#ifdef PNG_FORMAT_AFIRST_SUPPORTED +static void +gp_argb8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[1]; + p->g = pp[2]; + p->b = pp[3]; + p->a = pp[0]; +} +#endif + +#if defined(PNG_FORMAT_AFIRST_SUPPORTED) && defined(PNG_FORMAT_BGR_SUPPORTED) +static void +gp_abgr8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[3]; + p->g = pp[2]; + p->b = pp[1]; + p->a = pp[0]; +} +#endif + +static void +gp_g16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = p->g = p->b = pp[0]; + p->a = 65535; +} + +static void +gp_ga16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = p->g = p->b = pp[0]; + p->a = pp[1]; +} + +#ifdef PNG_FORMAT_AFIRST_SUPPORTED +static void +gp_ag16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = p->g = p->b = pp[1]; + p->a = pp[0]; +} +#endif + +static void +gp_rgb16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[0]; + p->g = pp[1]; + p->b = pp[2]; + p->a = 65535; +} + +#ifdef PNG_FORMAT_BGR_SUPPORTED +static void +gp_bgr16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[2]; + p->g = pp[1]; + p->b = pp[0]; + p->a = 65535; +} +#endif + +static void +gp_rgba16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[0]; + p->g = pp[1]; + p->b = pp[2]; + p->a = pp[3]; +} + +#ifdef PNG_FORMAT_BGR_SUPPORTED +static void +gp_bgra16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[2]; + p->g = pp[1]; + p->b = pp[0]; + p->a = pp[3]; +} +#endif + +#ifdef PNG_FORMAT_AFIRST_SUPPORTED +static void +gp_argb16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[1]; + p->g = pp[2]; + p->b = pp[3]; + p->a = pp[0]; +} +#endif + +#if defined(PNG_FORMAT_AFIRST_SUPPORTED) && defined(PNG_FORMAT_BGR_SUPPORTED) +static void +gp_abgr16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[3]; + p->g = pp[2]; + p->b = pp[1]; + p->a = pp[0]; +} +#endif + +/* Given a format, return the correct one of the above functions. */ +static void (* +get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb) +{ + /* The color-map flag is irrelevant here - the caller of the function + * returned must either pass the buffer or, for a color-mapped image, the + * correct entry in the color-map. + */ + if (format & PNG_FORMAT_FLAG_LINEAR) + { + if (format & PNG_FORMAT_FLAG_COLOR) + { +# ifdef PNG_FORMAT_BGR_SUPPORTED + if (format & PNG_FORMAT_FLAG_BGR) + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_abgr16; + + else +# endif + return gp_bgra16; + } + + else + return gp_bgr16; + } + + else +# endif + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_argb16; + + else +# endif + return gp_rgba16; + } + + else + return gp_rgb16; + } + } + + else + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_ag16; + + else +# endif + return gp_ga16; + } + + else + return gp_g16; + } + } + + else + { + if (format & PNG_FORMAT_FLAG_COLOR) + { +# ifdef PNG_FORMAT_BGR_SUPPORTED + if (format & PNG_FORMAT_FLAG_BGR) + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_abgr8; + + else +# endif + return gp_bgra8; + } + + else + return gp_bgr8; + } + + else +# endif + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_argb8; + + else +# endif + return gp_rgba8; + } + + else + return gp_rgb8; + } + } + + else + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_ag8; + + else +# endif + return gp_ga8; + } + + else + return gp_g8; + } + } +} + +/* Conversion between pixel formats. The code above effectively eliminates the + * component ordering changes leaving three basic changes: + * + * 1) Remove an alpha channel by pre-multiplication or compositing on a + * background color. (Adding an alpha channel is a no-op.) + * + * 2) Remove color by mapping to grayscale. (Grayscale to color is a no-op.) + * + * 3) Convert between 8-bit and 16-bit components. (Both directtions are + * relevant.) + * + * This gives the following base format conversion matrix: + * + * OUT: ----- 8-bit ----- ----- 16-bit ----- + * IN G GA RGB RGBA G GA RGB RGBA + * 8 G . . . . lin lin lin lin + * 8 GA bckg . bckc . pre' pre pre' pre + * 8 RGB g8 g8 . . glin glin lin lin + * 8 RGBA g8b g8 bckc . gpr' gpre pre' pre + * 16 G sRGB sRGB sRGB sRGB . . . . + * 16 GA b16g unpg b16c unpc A . A . + * 16 RGB sG sG sRGB sRGB g16 g16 . . + * 16 RGBA gb16 sGp cb16 sCp g16 g16' A . + * + * 8-bit to 8-bit: + * bckg: composite on gray background + * bckc: composite on color background + * g8: convert sRGB components to sRGB grayscale + * g8b: convert sRGB components to grayscale and composite on gray background + * + * 8-bit to 16-bit: + * lin: make sRGB components linear, alpha := 65535 + * pre: make sRGB components linear and premultiply by alpha (scale alpha) + * pre': as 'pre' but alpha := 65535 + * glin: make sRGB components linear, convert to grayscale, alpha := 65535 + * gpre: make sRGB components grayscale and linear and premultiply by alpha + * gpr': as 'gpre' but alpha := 65535 + * + * 16-bit to 8-bit: + * sRGB: convert linear components to sRGB, alpha := 255 + * unpg: unpremultiply gray component and convert to sRGB (scale alpha) + * unpc: unpremultiply color components and convert to sRGB (scale alpha) + * b16g: composite linear onto gray background and convert the result to sRGB + * b16c: composite linear onto color background and convert the result to sRGB + * sG: convert linear RGB to sRGB grayscale + * sGp: unpremultiply RGB then convert to sRGB grayscale + * sCp: unpremultiply RGB then convert to sRGB + * gb16: composite linear onto background and convert to sRGB grayscale + * (order doesn't matter, the composite and grayscale operations permute) + * cb16: composite linear onto background and convert to sRGB + * + * 16-bit to 16-bit: + * A: set alpha to 65535 + * g16: convert linear RGB to linear grayscale (alpha := 65535) + * g16': as 'g16' but alpha is unchanged + */ +/* Simple copy: */ +static void +gpc_noop(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + out->r = in->r; + out->g = in->g; + out->b = in->b; + out->a = in->a; +} + +#if ALLOW_UNUSED_GPC +static void +gpc_nop8(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + if (in->a == 0) + out->r = out->g = out->b = 255; + + else + { + out->r = in->r; + out->g = in->g; + out->b = in->b; + } + + out->a = in->a; +} +#endif + +#if ALLOW_UNUSED_GPC +static void +gpc_nop6(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + if (in->a == 0) + out->r = out->g = out->b = 65535; + + else + { + out->r = in->r; + out->g = in->g; + out->b = in->b; + } + + out->a = in->a; +} +#endif + +/* 8-bit to 8-bit conversions */ +/* bckg: composite on gray background */ +static void +gpc_bckg(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + out->r = out->g = out->b = back->ig; + + else if (in->a >= 255) + out->r = out->g = out->b = in->g; + + else + { + double a = in->a / 255.; + + out->r = out->g = out->b = sRGB(sRGB_to_d[in->g] * a + back->dg * (1-a)); + } + + out->a = 255; +} + +/* bckc: composite on color background */ +static void +gpc_bckc(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + { + out->r = back->ir; + out->g = back->ig; + out->b = back->ib; + } + + else if (in->a >= 255) + { + out->r = in->r; + out->g = in->g; + out->b = in->b; + } + + else + { + double a = in->a / 255.; + + out->r = sRGB(sRGB_to_d[in->r] * a + back->dr * (1-a)); + out->g = sRGB(sRGB_to_d[in->g] * a + back->dg * (1-a)); + out->b = sRGB(sRGB_to_d[in->b] * a + back->db * (1-a)); + } + + out->a = 255; +} + +/* g8: convert sRGB components to sRGB grayscale */ +static void +gpc_g8(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = in->g; + + else + out->r = out->g = out->b = + sRGB(YfromRGB(sRGB_to_d[in->r], sRGB_to_d[in->g], sRGB_to_d[in->b])); + + out->a = in->a; +} + +/* g8b: convert sRGB components to grayscale and composite on gray background */ +static void +gpc_g8b(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + out->r = out->g = out->b = back->ig; + + else if (in->a >= 255) + { + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = in->g; + + else + out->r = out->g = out->b = sRGB(YfromRGB( + sRGB_to_d[in->r], sRGB_to_d[in->g], sRGB_to_d[in->b])); + } + + else + { + double a = in->a/255.; + + out->r = out->g = out->b = sRGB(a * YfromRGB(sRGB_to_d[in->r], + sRGB_to_d[in->g], sRGB_to_d[in->b]) + back->dg * (1-a)); + } + + out->a = 255; +} + +/* 8-bit to 16-bit conversions */ +/* lin: make sRGB components linear, alpha := 65535 */ +static void +gpc_lin(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilinear(in->r); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilinear(in->b); + } + + else + { + out->g = ilinear(in->g); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilinear(in->b); + } + + out->a = 65535; +} + +/* pre: make sRGB components linear and premultiply by alpha (scale alpha) */ +static void +gpc_pre(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilineara(in->r, in->a); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilineara(in->b, in->a); + } + + else + { + out->g = ilineara(in->g, in->a); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilineara(in->b, in->a); + } + + out->a = in->a * 257; +} + +/* pre': as 'pre' but alpha := 65535 */ +static void +gpc_preq(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilineara(in->r, in->a); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilineara(in->b, in->a); + } + + else + { + out->g = ilineara(in->g, in->a); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilineara(in->b, in->a); + } + + out->a = 65535; +} + +/* glin: make sRGB components linear, convert to grayscale, alpha := 65535 */ +static void +gpc_glin(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilinear(in->g); + + else + out->r = out->g = out->b = u16d(65535 * + YfromRGB(sRGB_to_d[in->r], sRGB_to_d[in->g], sRGB_to_d[in->b])); + + out->a = 65535; +} + +/* gpre: make sRGB components grayscale and linear and premultiply by alpha */ +static void +gpc_gpre(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilineara(in->g, in->a); + + else + out->r = out->g = out->b = u16d(in->a * 257 * + YfromRGB(sRGB_to_d[in->r], sRGB_to_d[in->g], sRGB_to_d[in->b])); + + out->a = 257 * in->a; +} + +/* gpr': as 'gpre' but alpha := 65535 */ +static void +gpc_gprq(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilineara(in->g, in->a); + + else + out->r = out->g = out->b = u16d(in->a * 257 * + YfromRGB(sRGB_to_d[in->r], sRGB_to_d[in->g], sRGB_to_d[in->b])); + + out->a = 65535; +} + +/* 8-bit to 16-bit conversions for gAMA 45455 encoded values */ +/* Lin: make gAMA 45455 components linear, alpha := 65535 */ +static void +gpc_Lin(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilinear_g22(in->r); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilinear_g22(in->b); + } + + else + { + out->g = ilinear_g22(in->g); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilinear_g22(in->b); + } + + out->a = 65535; +} + +#if ALLOW_UNUSED_GPC +/* Pre: make gAMA 45455 components linear and premultiply by alpha (scale alpha) + */ +static void +gpc_Pre(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilineara_g22(in->r, in->a); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilineara_g22(in->b, in->a); + } + + else + { + out->g = ilineara_g22(in->g, in->a); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilineara_g22(in->b, in->a); + } + + out->a = in->a * 257; +} +#endif + +#if ALLOW_UNUSED_GPC +/* Pre': as 'Pre' but alpha := 65535 */ +static void +gpc_Preq(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilineara_g22(in->r, in->a); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilineara_g22(in->b, in->a); + } + + else + { + out->g = ilineara_g22(in->g, in->a); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilineara_g22(in->b, in->a); + } + + out->a = 65535; +} +#endif + +#if ALLOW_UNUSED_GPC +/* Glin: make gAMA 45455 components linear, convert to grayscale, alpha := 65535 + */ +static void +gpc_Glin(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilinear_g22(in->g); + + else + out->r = out->g = out->b = u16d(65535 * + YfromRGB(g22_to_d[in->r], g22_to_d[in->g], g22_to_d[in->b])); + + out->a = 65535; +} +#endif + +#if ALLOW_UNUSED_GPC +/* Gpre: make gAMA 45455 components grayscale and linear and premultiply by + * alpha. + */ +static void +gpc_Gpre(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilineara_g22(in->g, in->a); + + else + out->r = out->g = out->b = u16d(in->a * 257 * + YfromRGB(g22_to_d[in->r], g22_to_d[in->g], g22_to_d[in->b])); + + out->a = 257 * in->a; +} +#endif + +#if ALLOW_UNUSED_GPC +/* Gpr': as 'Gpre' but alpha := 65535 */ +static void +gpc_Gprq(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilineara_g22(in->g, in->a); + + else + out->r = out->g = out->b = u16d(in->a * 257 * + YfromRGB(g22_to_d[in->r], g22_to_d[in->g], g22_to_d[in->b])); + + out->a = 65535; +} +#endif + +/* 16-bit to 8-bit conversions */ +/* sRGB: convert linear components to sRGB, alpha := 255 */ +static void +gpc_sRGB(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = isRGB(in->r); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = isRGB(in->b); + } + + else + { + out->g = isRGB(in->g); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = isRGB(in->b); + } + + out->a = 255; +} + +/* unpg: unpremultiply gray component and convert to sRGB (scale alpha) */ +static void +gpc_unpg(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->a <= 128) + { + out->r = out->g = out->b = 255; + out->a = 0; + } + + else + { + out->r = out->g = out->b = sRGB((double)in->g / in->a); + out->a = u8d(in->a / 257.); + } +} + +/* unpc: unpremultiply color components and convert to sRGB (scale alpha) */ +static void +gpc_unpc(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->a <= 128) + { + out->r = out->g = out->b = 255; + out->a = 0; + } + + else + { + out->r = sRGB((double)in->r / in->a); + out->g = sRGB((double)in->g / in->a); + out->b = sRGB((double)in->b / in->a); + out->a = u8d(in->a / 257.); + } +} + +/* b16g: composite linear onto gray background and convert the result to sRGB */ +static void +gpc_b16g(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + out->r = out->g = out->b = back->ig; + + else + { + double a = in->a/65535.; + double a1 = 1-a; + + a /= 65535; + out->r = out->g = out->b = sRGB(in->g * a + back->dg * a1); + } + + out->a = 255; +} + +/* b16c: composite linear onto color background and convert the result to sRGB*/ +static void +gpc_b16c(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + { + out->r = back->ir; + out->g = back->ig; + out->b = back->ib; + } + + else + { + double a = in->a/65535.; + double a1 = 1-a; + + a /= 65535; + out->r = sRGB(in->r * a + back->dr * a1); + out->g = sRGB(in->g * a + back->dg * a1); + out->b = sRGB(in->b * a + back->db * a1); + } + + out->a = 255; +} + +/* sG: convert linear RGB to sRGB grayscale */ +static void +gpc_sG(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = out->g = out->b = sRGB(YfromRGBint(in->r, in->g, in->b)/65535); + out->a = 255; +} + +/* sGp: unpremultiply RGB then convert to sRGB grayscale */ +static void +gpc_sGp(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->a <= 128) + { + out->r = out->g = out->b = 255; + out->a = 0; + } + + else + { + out->r = out->g = out->b = sRGB(YfromRGBint(in->r, in->g, in->b)/in->a); + out->a = u8d(in->a / 257.); + } +} + +/* sCp: unpremultiply RGB then convert to sRGB */ +static void +gpc_sCp(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->a <= 128) + { + out->r = out->g = out->b = 255; + out->a = 0; + } + + else + { + out->r = sRGB((double)in->r / in->a); + out->g = sRGB((double)in->g / in->a); + out->b = sRGB((double)in->b / in->a); + out->a = u8d(in->a / 257.); + } +} + +/* gb16: composite linear onto background and convert to sRGB grayscale */ +/* (order doesn't matter, the composite and grayscale operations permute) */ +static void +gpc_gb16(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + out->r = out->g = out->b = back->ig; + + else if (in->a >= 65535) + out->r = out->g = out->b = isRGB(in->g); + + else + { + double a = in->a / 65535.; + double a1 = 1-a; + + a /= 65535; + out->r = out->g = out->b = sRGB(in->g * a + back->dg * a1); + } + + out->a = 255; +} + +/* cb16: composite linear onto background and convert to sRGB */ +static void +gpc_cb16(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + { + out->r = back->ir; + out->g = back->ig; + out->b = back->ib; + } + + else if (in->a >= 65535) + { + out->r = isRGB(in->r); + out->g = isRGB(in->g); + out->b = isRGB(in->b); + } + + else + { + double a = in->a / 65535.; + double a1 = 1-a; + + a /= 65535; + out->r = sRGB(in->r * a + back->dr * a1); + out->g = sRGB(in->g * a + back->dg * a1); + out->b = sRGB(in->b * a + back->db * a1); + } + + out->a = 255; +} + +/* 16-bit to 16-bit conversions */ +/* A: set alpha to 65535 */ +static void +gpc_A(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + out->r = in->r; + out->g = in->g; + out->b = in->b; + out->a = 65535; +} + +/* g16: convert linear RGB to linear grayscale (alpha := 65535) */ +static void +gpc_g16(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + out->r = out->g = out->b = u16d(YfromRGBint(in->r, in->g, in->b)); + out->a = 65535; +} + +/* g16': as 'g16' but alpha is unchanged */ +static void +gpc_g16q(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + out->r = out->g = out->b = u16d(YfromRGBint(in->r, in->g, in->b)); + out->a = in->a; +} + +#if ALLOW_UNUSED_GPC +/* Unused functions (to hide them from GCC unused function warnings) */ +void (* const gpc_unused[]) + (Pixel *out, const Pixel *in, const Background *back) = +{ + gpc_Pre, gpc_Preq, gpc_Glin, gpc_Gpre, gpc_Gprq, gpc_nop8, gpc_nop6 +}; +#endif + +/* OUT: ----- 8-bit ----- ----- 16-bit ----- + * IN G GA RGB RGBA G GA RGB RGBA + * 8 G . . . . lin lin lin lin + * 8 GA bckg . bckc . pre' pre pre' pre + * 8 RGB g8 g8 . . glin glin lin lin + * 8 RGBA g8b g8 bckc . gpr' gpre pre' pre + * 16 G sRGB sRGB sRGB sRGB . . . . + * 16 GA b16g unpg b16c unpc A . A . + * 16 RGB sG sG sRGB sRGB g16 g16 . . + * 16 RGBA gb16 sGp cb16 sCp g16 g16' A . + * + * The matrix is held in an array indexed thus: + * + * gpc_fn[out_format & BASE_FORMATS][in_format & BASE_FORMATS]; + */ +/* This will produce a compile time error if the FORMAT_FLAG values don't + * match the above matrix! + */ +#if PNG_FORMAT_FLAG_ALPHA == 1 && PNG_FORMAT_FLAG_COLOR == 2 &&\ + PNG_FORMAT_FLAG_LINEAR == 4 +static void (* const gpc_fn[8/*in*/][8/*out*/]) + (Pixel *out, const Pixel *in, const Background *back) = +{ +/*out: G-8 GA-8 RGB-8 RGBA-8 G-16 GA-16 RGB-16 RGBA-16 */ + {gpc_noop,gpc_noop,gpc_noop,gpc_noop, gpc_Lin, gpc_Lin, gpc_Lin, gpc_Lin }, + {gpc_bckg,gpc_noop,gpc_bckc,gpc_noop, gpc_preq,gpc_pre, gpc_preq,gpc_pre }, + {gpc_g8, gpc_g8, gpc_noop,gpc_noop, gpc_glin,gpc_glin,gpc_lin, gpc_lin }, + {gpc_g8b, gpc_g8, gpc_bckc,gpc_noop, gpc_gprq,gpc_gpre,gpc_preq,gpc_pre }, + {gpc_sRGB,gpc_sRGB,gpc_sRGB,gpc_sRGB, gpc_noop,gpc_noop,gpc_noop,gpc_noop}, + {gpc_b16g,gpc_unpg,gpc_b16c,gpc_unpc, gpc_A, gpc_noop,gpc_A, gpc_noop}, + {gpc_sG, gpc_sG, gpc_sRGB,gpc_sRGB, gpc_g16, gpc_g16, gpc_noop,gpc_noop}, + {gpc_gb16,gpc_sGp, gpc_cb16,gpc_sCp, gpc_g16, gpc_g16q,gpc_A, gpc_noop} +}; + +/* The array is repeated for the cases where both the input and output are color + * mapped because then different algorithms are used. + */ +static void (* const gpc_fn_colormapped[8/*in*/][8/*out*/]) + (Pixel *out, const Pixel *in, const Background *back) = +{ +/*out: G-8 GA-8 RGB-8 RGBA-8 G-16 GA-16 RGB-16 RGBA-16 */ + {gpc_noop,gpc_noop,gpc_noop,gpc_noop, gpc_lin, gpc_lin, gpc_lin, gpc_lin }, + {gpc_bckg,gpc_noop,gpc_bckc,gpc_noop, gpc_preq,gpc_pre, gpc_preq,gpc_pre }, + {gpc_g8, gpc_g8, gpc_noop,gpc_noop, gpc_glin,gpc_glin,gpc_lin, gpc_lin }, + {gpc_g8b, gpc_g8, gpc_bckc,gpc_noop, gpc_gprq,gpc_gpre,gpc_preq,gpc_pre }, + {gpc_sRGB,gpc_sRGB,gpc_sRGB,gpc_sRGB, gpc_noop,gpc_noop,gpc_noop,gpc_noop}, + {gpc_b16g,gpc_unpg,gpc_b16c,gpc_unpc, gpc_A, gpc_noop,gpc_A, gpc_noop}, + {gpc_sG, gpc_sG, gpc_sRGB,gpc_sRGB, gpc_g16, gpc_g16, gpc_noop,gpc_noop}, + {gpc_gb16,gpc_sGp, gpc_cb16,gpc_sCp, gpc_g16, gpc_g16q,gpc_A, gpc_noop} +}; + +/* The error arrays record the error in the same matrix; 64 entries, however + * the different algorithms used in libpng for colormap and direct conversions + * mean that four separate matrices are used (for each combination of + * colormapped and direct.) + * + * In some cases the conversion between sRGB formats goes via a linear + * intermediate; an sRGB to linear conversion (as above) is followed by a simple + * linear to sRGB step with no other conversions. This is done by a separate + * error array from an arbitrary 'in' format to one of the four basic outputs + * (since final output is always sRGB not colormapped). + * + * These arrays may be modified if the --accumulate flag is set during the run; + * then instead of logging errors they are simply added in. + * + * The three entries are currently for transparent, partially transparent and + * opaque input pixel values. Notice that alpha should be exact in each case. + * + * Errors in alpha should only occur when converting from a direct format + * to a colormapped format, when alpha is effectively smashed (so large + * errors can occur.) There should be no error in the '0' and 'opaque' + * values. The fourth entry in the array is used for the alpha error (and it + * should always be zero for the 'via linear' case since this is never color + * mapped.) + * + * Mapping to a colormap smashes the colors, it is necessary to have separate + * values for these cases because they are much larger; it is very much + * impossible to obtain a reasonable result, these are held in + * gpc_error_to_colormap. + */ +#if PNG_FORMAT_FLAG_COLORMAP == 8 /* extra check also required */ +# include "pngstest-errors.h" /* machine generated */ +#endif /* COLORMAP flag check */ +#endif /* flag checks */ + +typedef struct +{ + /* Basic pixel information: */ + Image* in_image; /* Input image */ + const Image* out_image; /* Output image */ + + /* 'background' is the value passed to the gpc_ routines, it may be NULL if + * it should not be used (*this* program has an error if it crashes as a + * result!) + */ + Background background_color; + const Background* background; + + /* Precalculated values: */ + int in_opaque; /* Value of input alpha that is opaque */ + int is_palette; /* Sample values come from the palette */ + int accumulate; /* Accumulate component errors (don't log) */ + int output_8bit; /* Output is 8-bit (else 16-bit) */ + + void (*in_gp)(Pixel*, png_const_voidp); + void (*out_gp)(Pixel*, png_const_voidp); + + void (*transform)(Pixel *out, const Pixel *in, const Background *back); + /* A function to perform the required transform */ + + void (*from_linear)(Pixel *out, const Pixel *in, const Background *back); + /* For 'via_linear' transforms the final, from linear, step, else NULL */ + + png_uint_16 error[4]; + /* Three error values for transparent, partially transparent and opaque + * input pixels (in turn). + */ + + png_uint_16 *error_ptr; + /* Where these are stored in the static array (for 'accumulate') */ +} +Transform; + +/* Return a 'transform' as above for the given format conversion. */ +static void +transform_from_formats(Transform *result, Image *in_image, + const Image *out_image, png_const_colorp background, int via_linear) +{ + png_uint_32 in_format, out_format; + png_uint_32 in_base, out_base; + + memset(result, 0, sizeof *result); + + /* Store the original images for error messages */ + result->in_image = in_image; + result->out_image = out_image; + + in_format = in_image->image.format; + out_format = out_image->image.format; + + if (in_format & PNG_FORMAT_FLAG_LINEAR) + result->in_opaque = 65535; + else + result->in_opaque = 255; + + result->output_8bit = (out_format & PNG_FORMAT_FLAG_LINEAR) == 0; + + result->is_palette = 0; /* set by caller if required */ + result->accumulate = (in_image->opts & ACCUMULATE) != 0; + + /* The loaders (which need the ordering information) */ + result->in_gp = get_pixel(in_format); + result->out_gp = get_pixel(out_format); + + /* Remove the ordering information: */ + in_format &= BASE_FORMATS | PNG_FORMAT_FLAG_COLORMAP; + in_base = in_format & BASE_FORMATS; + out_format &= BASE_FORMATS | PNG_FORMAT_FLAG_COLORMAP; + out_base = out_format & BASE_FORMATS; + + if (via_linear) + { + /* Check for an error in this program: */ + if (out_format & (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLORMAP)) + { + fprintf(stderr, "internal transform via linear error 0x%x->0x%x\n", + in_format, out_format); + exit(1); + } + + result->transform = gpc_fn[in_base][out_base | PNG_FORMAT_FLAG_LINEAR]; + result->from_linear = gpc_fn[out_base | PNG_FORMAT_FLAG_LINEAR][out_base]; + result->error_ptr = gpc_error_via_linear[in_format][out_format]; + } + + else if (~in_format & out_format & PNG_FORMAT_FLAG_COLORMAP) + { + /* The input is not colormapped but the output is, the errors will + * typically be large (only the grayscale-no-alpha case permits preserving + * even 8-bit values.) + */ + result->transform = gpc_fn[in_base][out_base]; + result->from_linear = NULL; + result->error_ptr = gpc_error_to_colormap[in_base][out_base]; + } + + else + { + /* The caller handles the colormap->pixel value conversion, so the + * transform function just gets a pixel value, however because libpng + * currently contains a different implementation for mapping a colormap if + * both input and output are colormapped we need different conversion + * functions to deal with errors in the libpng implementation. + */ + if (in_format & out_format & PNG_FORMAT_FLAG_COLORMAP) + result->transform = gpc_fn_colormapped[in_base][out_base]; + else + result->transform = gpc_fn[in_base][out_base]; + result->from_linear = NULL; + result->error_ptr = gpc_error[in_format][out_format]; + } + + /* Follow the libpng simplified API rules to work out what to pass to the gpc + * routines as a background value, if one is not required pass NULL so that + * this program crashes in the even of a programming error. + */ + result->background = NULL; /* default: not required */ + + /* Rule 1: background only need be supplied if alpha is to be removed */ + if (in_format & ~out_format & PNG_FORMAT_FLAG_ALPHA) + { + /* The input value is 'NULL' to use the background and (otherwise) an sRGB + * background color (to use a solid color). The code above uses a fixed + * byte value, BUFFER_INIT8, for buffer even for 16-bit output. For + * linear (16-bit) output the sRGB background color is ignored; the + * composition is always on the background (so BUFFER_INIT8 * 257), except + * that for the colormap (i.e. linear colormapped output) black is used. + */ + result->background = &result->background_color; + + if (out_format & PNG_FORMAT_FLAG_LINEAR || via_linear) + { + if (out_format & PNG_FORMAT_FLAG_COLORMAP) + { + result->background_color.ir = + result->background_color.ig = + result->background_color.ib = 0; + result->background_color.dr = + result->background_color.dg = + result->background_color.db = 0; + } + + else + { + result->background_color.ir = + result->background_color.ig = + result->background_color.ib = BUFFER_INIT8 * 257; + result->background_color.dr = + result->background_color.dg = + result->background_color.db = 0; + } + } + + else /* sRGB output */ + { + if (background != NULL) + { + if (out_format & PNG_FORMAT_FLAG_COLOR) + { + result->background_color.ir = background->red; + result->background_color.ig = background->green; + result->background_color.ib = background->blue; + /* TODO: sometimes libpng uses the power law conversion here, how + * to handle this? + */ + result->background_color.dr = sRGB_to_d[background->red]; + result->background_color.dg = sRGB_to_d[background->green]; + result->background_color.db = sRGB_to_d[background->blue]; + } + + else /* grayscale: libpng only looks at 'g' */ + { + result->background_color.ir = + result->background_color.ig = + result->background_color.ib = background->green; + /* TODO: sometimes libpng uses the power law conversion here, how + * to handle this? + */ + result->background_color.dr = + result->background_color.dg = + result->background_color.db = sRGB_to_d[background->green]; + } + } + + else if ((out_format & PNG_FORMAT_FLAG_COLORMAP) == 0) + { + result->background_color.ir = + result->background_color.ig = + result->background_color.ib = BUFFER_INIT8; + /* TODO: sometimes libpng uses the power law conversion here, how + * to handle this? + */ + result->background_color.dr = + result->background_color.dg = + result->background_color.db = sRGB_to_d[BUFFER_INIT8]; + } + + /* Else the output is colormapped and a background color must be + * provided; if pngstest crashes then that is a bug in this program + * (though libpng should png_error as well.) + */ + else + result->background = NULL; + } + } + + if (result->background == NULL) + { + result->background_color.ir = + result->background_color.ig = + result->background_color.ib = -1; /* not used */ + result->background_color.dr = + result->background_color.dg = + result->background_color.db = 1E30; /* not used */ + } + + + /* Copy the error values into the Transform: */ + result->error[0] = result->error_ptr[0]; + result->error[1] = result->error_ptr[1]; + result->error[2] = result->error_ptr[2]; + result->error[3] = result->error_ptr[3]; +} + + +/* Compare two pixels. + * + * OLD error values: +static int error_to_linear = 811; * by experiment * +static int error_to_linear_grayscale = 424; * by experiment * +static int error_to_sRGB = 6; * by experiment * +static int error_to_sRGB_grayscale = 17; * libpng error by calculation + + 2 by experiment * +static int error_in_compose = 2; * by experiment * +static int error_in_premultiply = 1; + * + * The following is *just* the result of a round trip from 8-bit sRGB to linear + * then back to 8-bit sRGB when it is done by libpng. There are two problems: + * + * 1) libpng currently uses a 2.2 power law with no linear segment, this results + * in instability in the low values and even with 16-bit precision sRGB(1) ends + * up mapping to sRGB(0) as a result of rounding in the 16-bit representation. + * This gives an error of 1 in the handling of value 1 only. + * + * 2) libpng currently uses an intermediate 8-bit linear value in gamma + * correction of 8-bit values. This results in many more errors, the worse of + * which is mapping sRGB(14) to sRGB(0). + * + * The general 'error_via_linear' is more complex because of pre-multiplication, + * this compounds the 8-bit errors according to the alpha value of the pixel. + * As a result 256 values are pre-calculated for error_via_linear. + */ +#if 0 +static int error_in_libpng_gamma; +static int error_via_linear[256]; /* Indexed by 8-bit alpha */ + +static void +init_error_via_linear(void) +{ + int alpha; + + error_via_linear[0] = 255; /* transparent pixel */ + + for (alpha=1; alpha<=255; ++alpha) + { + /* 16-bit values less than 128.5 get rounded to 8-bit 0 and so the worst + * case error arises with 16-bit 128.5, work out what sRGB + * (non-associated) value generates 128.5; any value less than this is + * going to map to 0, so the worst error is floor(value). + * + * Note that errors are considerably higher (more than a factor of 2) + * because libpng uses a simple power law for sRGB data at present. + * + * Add .1 for arithmetic errors inside libpng. + */ + double v = floor(255*pow(.5/*(128.5 * 255 / 65535)*/ / alpha, 1/2.2)+.1); + + error_via_linear[alpha] = (int)v; + } + + /* This is actually 14.99, but, despite the closeness to 15, 14 seems to work + * ok in this case. + */ + error_in_libpng_gamma = 14; +} +#endif + +static void +print_pixel(char string[64], const Pixel *pixel, png_uint_32 format) +{ + switch (format & (PNG_FORMAT_FLAG_ALPHA|PNG_FORMAT_FLAG_COLOR)) + { + case 0: + sprintf(string, "%s(%d)", format_names[format], pixel->g); + break; + + case PNG_FORMAT_FLAG_ALPHA: + sprintf(string, "%s(%d,%d)", format_names[format], pixel->g, + pixel->a); + break; + + case PNG_FORMAT_FLAG_COLOR: + sprintf(string, "%s(%d,%d,%d)", format_names[format], + pixel->r, pixel->g, pixel->b); + break; + + case PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA: + sprintf(string, "%s(%d,%d,%d,%d)", format_names[format], + pixel->r, pixel->g, pixel->b, pixel->a); + break; + + default: + sprintf(string, "invalid-format"); + break; + } +} + +static int +logpixel(const Transform *transform, png_uint_32 x, png_uint_32 y, + const Pixel *in, const Pixel *calc, const Pixel *out, const char *reason) +{ + png_uint_32 in_format = transform->in_image->image.format; + png_uint_32 out_format = transform->out_image->image.format; + + png_uint_32 back_format = out_format & ~PNG_FORMAT_FLAG_ALPHA; + const char *via_linear = ""; + + char pixel_in[64], pixel_calc[64], pixel_out[64], pixel_loc[64]; + char background_info[100]; + + print_pixel(pixel_in, in, in_format); + print_pixel(pixel_calc, calc, out_format); + print_pixel(pixel_out, out, out_format); + + if (transform->is_palette) + sprintf(pixel_loc, "palette: %lu", (unsigned long)y); + else + sprintf(pixel_loc, "%lu,%lu", (unsigned long)x, (unsigned long)y); + + if (transform->from_linear != NULL) + { + via_linear = " (via linear)"; + /* And as a result the *read* format which did any background processing + * was itself linear, so the background color information is also + * linear. + */ + back_format |= PNG_FORMAT_FLAG_LINEAR; + } + + if (transform->background != NULL) + { + Pixel back; + char pixel_back[64]; + + back.r = transform->background->ir; + back.g = transform->background->ig; + back.b = transform->background->ib; + back.a = -1; /* not used */ + + print_pixel(pixel_back, &back, back_format); + sprintf(background_info, " on background %s", pixel_back); + } + + else + background_info[0] = 0; + + if (transform->in_image->file_name != transform->out_image->file_name) + { + char error_buffer[512]; + sprintf(error_buffer, + "(%s) %s error%s:\n %s%s ->\n %s\n not: %s.\n" + "Use --preserve and examine: ", pixel_loc, reason, via_linear, + pixel_in, background_info, pixel_out, pixel_calc); + return logerror(transform->in_image, transform->in_image->file_name, + error_buffer, transform->out_image->file_name); + } + + else + { + char error_buffer[512]; + sprintf(error_buffer, + "(%s) %s error%s:\n %s%s ->\n %s\n not: %s.\n" + " The error happened when reading the original file with this format.", + pixel_loc, reason, via_linear, pixel_in, background_info, pixel_out, + pixel_calc); + return logerror(transform->in_image, transform->in_image->file_name, + error_buffer, ""); + } +} + +static int +cmppixel(Transform *transform, png_const_voidp in, png_const_voidp out, + png_uint_32 x, png_uint_32 y/*or palette index*/) +{ + int maxerr; + png_const_charp errmsg; + Pixel pixel_in, pixel_calc, pixel_out; + + transform->in_gp(&pixel_in, in); + + if (transform->from_linear == NULL) + transform->transform(&pixel_calc, &pixel_in, transform->background); + + else + { + transform->transform(&pixel_out, &pixel_in, transform->background); + transform->from_linear(&pixel_calc, &pixel_out, NULL); + } + + transform->out_gp(&pixel_out, out); + + /* Eliminate the case where the input and output values match exactly. */ + if (pixel_calc.a == pixel_out.a && pixel_calc.r == pixel_out.r && + pixel_calc.g == pixel_out.g && pixel_calc.b == pixel_out.b) + return 1; + + /* Eliminate the case where the output pixel is transparent and the output + * is 8-bit - any component values are valid. Don't check the input alpha + * here to also skip the 16-bit small alpha cases. + */ + if (transform->output_8bit && pixel_calc.a == 0 && pixel_out.a == 0) + return 1; + + /* Check for alpha errors first; an alpha error can damage the components too + * so avoid spurious checks on components if one is found. + */ + errmsg = NULL; + { + int err_a = abs(pixel_calc.a-pixel_out.a); + + if (err_a > transform->error[3]) + { + /* If accumulating check the components too */ + if (transform->accumulate) + transform->error[3] = (png_uint_16)err_a; + + else + errmsg = "alpha"; + } + } + + /* Now if *either* of the output alphas are 0 but alpha is within tolerance + * eliminate the 8-bit component comparison. + */ + if (errmsg == NULL && transform->output_8bit && + (pixel_calc.a == 0 || pixel_out.a == 0)) + return 1; + + if (errmsg == NULL) /* else just signal an alpha error */ + { + int err_r = abs(pixel_calc.r - pixel_out.r); + int err_g = abs(pixel_calc.g - pixel_out.g); + int err_b = abs(pixel_calc.b - pixel_out.b); + int limit; + + if ((err_r | err_g | err_b) == 0) + return 1; /* exact match */ + + /* Mismatch on a component, check the input alpha */ + if (pixel_in.a >= transform->in_opaque) + { + errmsg = "opaque component"; + limit = 2; /* opaque */ + } + + else if (pixel_in.a > 0) + { + errmsg = "alpha component"; + limit = 1; /* partially transparent */ + } + + else + { + errmsg = "transparent component (background)"; + limit = 0; /* transparent */ + } + + maxerr = err_r; + if (maxerr < err_g) maxerr = err_g; + if (maxerr < err_b) maxerr = err_b; + + if (maxerr <= transform->error[limit]) + return 1; /* within the error limits */ + + /* Handle a component mis-match; log it, just return an error code, or + * accumulate it. + */ + if (transform->accumulate) + { + transform->error[limit] = (png_uint_16)maxerr; + return 1; /* to cause the caller to keep going */ + } + } + + /* Failure to match and not accumulating, so the error must be logged. */ + return logpixel(transform, x, y, &pixel_in, &pixel_calc, &pixel_out, errmsg); +} + +static png_byte +component_loc(png_byte loc[4], png_uint_32 format) +{ + /* Given a format return the number of channels and the location of + * each channel. + * + * The mask 'loc' contains the component offset of the channels in the + * following order. Note that if 'format' is grayscale the entries 1-3 must + * all contain the location of the gray channel. + * + * 0: alpha + * 1: red or gray + * 2: green or gray + * 3: blue or gray + */ + png_byte channels; + + if (format & PNG_FORMAT_FLAG_COLOR) + { + channels = 3; + + loc[2] = 1; + +# ifdef PNG_FORMAT_BGR_SUPPORTED + if (format & PNG_FORMAT_FLAG_BGR) + { + loc[1] = 2; + loc[3] = 0; + } + + else +# endif + { + loc[1] = 0; + loc[3] = 2; + } + } + + else + { + channels = 1; + loc[1] = loc[2] = loc[3] = 0; + } + + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + { + loc[0] = 0; + ++loc[1]; + ++loc[2]; + ++loc[3]; + } + + else +# endif + loc[0] = channels; + + ++channels; + } + + else + loc[0] = 4; /* not present */ + + return channels; +} + +/* Compare two images, the original 'a', which was written out then read back in + * to * give image 'b'. The formats may have been changed. + */ +static int +compare_two_images(Image *a, Image *b, int via_linear, + png_const_colorp background) +{ + ptrdiff_t stridea = a->stride; + ptrdiff_t strideb = b->stride; + png_const_bytep rowa = a->buffer+16; + png_const_bytep rowb = b->buffer+16; + png_uint_32 width = a->image.width; + png_uint_32 height = a->image.height; + png_uint_32 formata = a->image.format; + png_uint_32 formatb = b->image.format; + unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata); + unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb); + int alpha_added, alpha_removed; + int bchannels; + png_uint_32 y; + Transform tr; + int btoa[4]={0,0,0,0}; + + /* This should never happen: */ + if (width != b->image.width || height != b->image.height) + return logerror(a, a->file_name, ": width x height changed: ", + b->file_name); + + /* Set up the background and the transform */ + transform_from_formats(&tr, a, b, background, via_linear); + + /* Find the first row and inter-row space. */ + if (!(formata & PNG_FORMAT_FLAG_COLORMAP) && + (formata & PNG_FORMAT_FLAG_LINEAR)) + stridea *= 2; + + if (!(formatb & PNG_FORMAT_FLAG_COLORMAP) && + (formatb & PNG_FORMAT_FLAG_LINEAR)) + strideb *= 2; + + if (stridea < 0) rowa += (height-1) * (-stridea); + if (strideb < 0) rowb += (height-1) * (-strideb); + + /* First shortcut the two colormap case by comparing the image data; if it + * matches then we expect the colormaps to match, although this is not + * absolutely necessary for an image match. If the colormaps fail to match + * then there is a problem in libpng. + */ + if (formata & formatb & PNG_FORMAT_FLAG_COLORMAP) + { + /* Only check colormap entries that actually exist; */ + png_const_bytep ppa, ppb; + int match; + png_byte in_use[256], amax = 0, bmax = 0; + + memset(in_use, 0, sizeof in_use); + + ppa = rowa; + ppb = rowb; + + /* Do this the slow way to accumulate the 'in_use' flags, don't break out + * of the loop until the end; this validates the color-mapped data to + * ensure all pixels are valid color-map indexes. + */ + for (y=0, match=1; y bmax) + bmax = bval; + + if (bval != aval) + match = 0; + + in_use[aval] = 1; + if (aval > amax) + amax = aval; + } + } + + /* If the buffers match then the colormaps must too. */ + if (match) + { + /* Do the color-maps match, entry by entry? Only check the 'in_use' + * entries. An error here should be logged as a color-map error. + */ + png_const_bytep a_cmap = (png_const_bytep)a->colormap; + png_const_bytep b_cmap = (png_const_bytep)b->colormap; + int result = 1; /* match by default */ + + /* This is used in logpixel to get the error message correct. */ + tr.is_palette = 1; + + for (y=0; y<256; ++y, a_cmap += a_sample, b_cmap += b_sample) + if (in_use[y]) + { + /* The colormap entries should be valid, but because libpng doesn't + * do any checking at present the original image may contain invalid + * pixel values. These cause an error here (at present) unless + * accumulating errors in which case the program just ignores them. + */ + if (y >= a->image.colormap_entries) + { + if ((a->opts & ACCUMULATE) == 0) + { + char pindex[9]; + sprintf(pindex, "%lu[%lu]", (unsigned long)y, + (unsigned long)a->image.colormap_entries); + logerror(a, a->file_name, ": bad pixel index: ", pindex); + } + result = 0; + } + + else if (y >= b->image.colormap_entries) + { + if ((b->opts & ACCUMULATE) == 0) + { + char pindex[9]; + sprintf(pindex, "%lu[%lu]", (unsigned long)y, + (unsigned long)b->image.colormap_entries); + logerror(b, b->file_name, ": bad pixel index: ", pindex); + } + result = 0; + } + + /* All the mismatches are logged here; there can only be 256! */ + else if (!cmppixel(&tr, a_cmap, b_cmap, 0, y)) + result = 0; + } + + /* If requested, copy the error values back from the Transform. */ + if (a->opts & ACCUMULATE) + { + tr.error_ptr[0] = tr.error[0]; + tr.error_ptr[1] = tr.error[1]; + tr.error_ptr[2] = tr.error[2]; + tr.error_ptr[3] = tr.error[3]; + result = 1; /* force a continue */ + } + + return result; + } + + /* else the image buffers don't match pixel-wise so compare sample values + * instead, but first validate that the pixel indexes are in range (but + * only if not accumulating, when the error is ignored.) + */ + else if ((a->opts & ACCUMULATE) == 0) + { +# ifdef __GNUC__ +# define BYTE_CHARS 20 /* 2^32: GCC sprintf warning */ +# else +# define BYTE_CHARS 3 /* 2^8: real maximum value */ +# endif + /* Check the original image first, + * TODO: deal with input images with bad pixel values? + */ + if (amax >= a->image.colormap_entries) + { + char pindex[3+2*BYTE_CHARS]; + sprintf(pindex, "%d[%u]", amax, + (png_byte)/*SAFE*/a->image.colormap_entries); + return logerror(a, a->file_name, ": bad pixel index: ", pindex); + } + + else if (bmax >= b->image.colormap_entries) + { + char pindex[3+2*BYTE_CHARS]; + sprintf(pindex, "%d[%u]", bmax, + (png_byte)/*SAFE*/b->image.colormap_entries); + return logerror(b, b->file_name, ": bad pixel index: ", pindex); + } + } + } + + /* We can directly compare pixel values without the need to use the read + * or transform support (i.e. a memory compare) if: + * + * 1) The bit depth has not changed. + * 2) RGB to grayscale has not been done (the reverse is ok; we just compare + * the three RGB values to the original grayscale.) + * 3) An alpha channel has not been removed from an 8-bit format, or the + * 8-bit alpha value of the pixel was 255 (opaque). + * + * If an alpha channel has been *added* then it must have the relevant opaque + * value (255 or 65535). + * + * The fist two the tests (in the order given above) (using the boolean + * equivalence !a && !b == !(a || b)) + */ + if (!(((formata ^ formatb) & PNG_FORMAT_FLAG_LINEAR) | + (formata & (formatb ^ PNG_FORMAT_FLAG_COLOR) & PNG_FORMAT_FLAG_COLOR))) + { + /* Was an alpha channel changed? */ + png_uint_32 alpha_changed = (formata ^ formatb) & PNG_FORMAT_FLAG_ALPHA; + + /* Was an alpha channel removed? (The third test.) If so the direct + * comparison is only possible if the input alpha is opaque. + */ + alpha_removed = (formata & alpha_changed) != 0; + + /* Was an alpha channel added? */ + alpha_added = (formatb & alpha_changed) != 0; + + /* The channels may have been moved between input and output, this finds + * out how, recording the result in the btoa array, which says where in + * 'a' to find each channel of 'b'. If alpha was added then btoa[alpha] + * ends up as 4 (and is not used.) + */ + { + int i; + png_byte aloc[4]; + png_byte bloc[4]; + + /* The following are used only if the formats match, except that + * 'bchannels' is a flag for matching formats. btoa[x] says, for each + * channel in b, where to find the corresponding value in a, for the + * bchannels. achannels may be different for a gray to rgb transform + * (a will be 1 or 2, b will be 3 or 4 channels.) + */ + (void)component_loc(aloc, formata); + bchannels = component_loc(bloc, formatb); + + /* Hence the btoa array. */ + for (i=0; i<4; ++i) if (bloc[i] < 4) + btoa[bloc[i]] = aloc[i]; /* may be '4' for alpha */ + + if (alpha_added) + alpha_added = bloc[0]; /* location of alpha channel in image b */ + + else + alpha_added = 4; /* Won't match an image b channel */ + + if (alpha_removed) + alpha_removed = aloc[0]; /* location of alpha channel in image a */ + + else + alpha_removed = 4; + } + } + + else + { + /* Direct compare is not possible, cancel out all the corresponding local + * variables. + */ + bchannels = 0; + alpha_removed = alpha_added = 4; + btoa[3] = btoa[2] = btoa[1] = btoa[0] = 4; /* 4 == not present */ + } + + for (y=0; ycolormap + a_sample * *ppa++; + else + psa = ppa, ppa += a_sample; + + if (formatb & PNG_FORMAT_FLAG_COLORMAP) + psb = (png_const_bytep)b->colormap + b_sample * *ppb++; + else + psb = ppb, ppb += b_sample; + + /* Do the fast test if possible. */ + if (bchannels) + { + /* Check each 'b' channel against either the corresponding 'a' + * channel or the opaque alpha value, as appropriate. If + * alpha_removed value is set (not 4) then also do this only if the + * 'a' alpha channel (alpha_removed) is opaque; only relevant for + * the 8-bit case. + */ + if (formatb & PNG_FORMAT_FLAG_LINEAR) /* 16-bit checks */ + { + png_const_uint_16p pua = aligncastconst(png_const_uint_16p, psa); + png_const_uint_16p pub = aligncastconst(png_const_uint_16p, psb); + + switch (bchannels) + { + case 4: + if (pua[btoa[3]] != pub[3]) break; + /* FALLTHROUGH */ + case 3: + if (pua[btoa[2]] != pub[2]) break; + /* FALLTHROUGH */ + case 2: + if (pua[btoa[1]] != pub[1]) break; + /* FALLTHROUGH */ + case 1: + if (pua[btoa[0]] != pub[0]) break; + if (alpha_added != 4 && pub[alpha_added] != 65535) break; + continue; /* x loop */ + default: + break; /* impossible */ + } + } + + else if (alpha_removed == 4 || psa[alpha_removed] == 255) + { + switch (bchannels) + { + case 4: + if (psa[btoa[3]] != psb[3]) break; + /* FALLTHROUGH */ + case 3: + if (psa[btoa[2]] != psb[2]) break; + /* FALLTHROUGH */ + case 2: + if (psa[btoa[1]] != psb[1]) break; + /* FALLTHROUGH */ + case 1: + if (psa[btoa[0]] != psb[0]) break; + if (alpha_added != 4 && psb[alpha_added] != 255) break; + continue; /* x loop */ + default: + break; /* impossible */ + } + } + } + + /* If we get to here the fast match failed; do the slow match for this + * pixel. + */ + if (!cmppixel(&tr, psa, psb, x, y) && (a->opts & KEEP_GOING) == 0) + return 0; /* error case */ + } + } + + /* If requested, copy the error values back from the Transform. */ + if (a->opts & ACCUMULATE) + { + tr.error_ptr[0] = tr.error[0]; + tr.error_ptr[1] = tr.error[1]; + tr.error_ptr[2] = tr.error[2]; + tr.error_ptr[3] = tr.error[3]; + } + + return 1; +} + +/* Read the file; how the read gets done depends on which of input_file and + * input_memory have been set. + */ +static int +read_file(Image *image, png_uint_32 format, png_const_colorp background) +{ + memset(&image->image, 0, sizeof image->image); + image->image.version = PNG_IMAGE_VERSION; + + if (image->input_memory != NULL) + { + if (!png_image_begin_read_from_memory(&image->image, image->input_memory, + image->input_memory_size)) + return logerror(image, "memory init: ", image->file_name, ""); + } + +# ifdef PNG_STDIO_SUPPORTED + else if (image->input_file != NULL) + { + if (!png_image_begin_read_from_stdio(&image->image, image->input_file)) + return logerror(image, "stdio init: ", image->file_name, ""); + } + + else + { + if (!png_image_begin_read_from_file(&image->image, image->file_name)) + return logerror(image, "file init: ", image->file_name, ""); + } +# else + else + { + return logerror(image, "unsupported file/stdio init: ", + image->file_name, ""); + } +# endif + + /* This must be set after the begin_read call: */ + if (image->opts & sRGB_16BIT) + image->image.flags |= PNG_IMAGE_FLAG_16BIT_sRGB; + + /* Have an initialized image with all the data we need plus, maybe, an + * allocated file (myfile) or buffer (mybuffer) that need to be freed. + */ + { + int result; + png_uint_32 image_format; + + /* Print both original and output formats. */ + image_format = image->image.format; + + if (image->opts & VERBOSE) + { + printf("%s %lu x %lu %s -> %s", image->file_name, + (unsigned long)image->image.width, + (unsigned long)image->image.height, + format_names[image_format & FORMAT_MASK], + (format & FORMAT_NO_CHANGE) != 0 || image->image.format == format + ? "no change" : format_names[format & FORMAT_MASK]); + + if (background != NULL) + printf(" background(%d,%d,%d)\n", background->red, + background->green, background->blue); + else + printf("\n"); + + fflush(stdout); + } + + /* 'NO_CHANGE' combined with the color-map flag forces the base format + * flags to be set on read to ensure that the original representation is + * not lost in the pass through a colormap format. + */ + if ((format & FORMAT_NO_CHANGE) != 0) + { + if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0 && + (image_format & PNG_FORMAT_FLAG_COLORMAP) != 0) + format = (image_format & ~BASE_FORMATS) | (format & BASE_FORMATS); + + else + format = image_format; + } + + image->image.format = format; + + image->stride = PNG_IMAGE_ROW_STRIDE(image->image) + image->stride_extra; + allocbuffer(image); + + result = png_image_finish_read(&image->image, background, + image->buffer+16, (png_int_32)image->stride, image->colormap); + + checkbuffer(image, image->file_name); + + if (result) + return checkopaque(image); + + else + return logerror(image, image->file_name, ": image read failed", ""); + } +} + +/* Reads from a filename, which must be in image->file_name, but uses + * image->opts to choose the method. The file is always read in its native + * format (the one the simplified API suggests). + */ +static int +read_one_file(Image *image) +{ + if (!(image->opts & USE_FILE) || (image->opts & USE_STDIO)) + { + /* memory or stdio. */ + FILE *f = fopen(image->file_name, "rb"); + + if (f != NULL) + { + if (image->opts & USE_FILE) + image->input_file = f; + + else /* memory */ + { + if (fseek(f, 0, SEEK_END) == 0) + { + long int cb = ftell(f); + + if (cb > 0) + { +#ifndef __COVERITY__ + if ((unsigned long int)cb <= (size_t)~(size_t)0) +#endif + { + png_bytep b = voidcast(png_bytep, malloc((size_t)cb)); + + if (b != NULL) + { + rewind(f); + + if (fread(b, (size_t)cb, 1, f) == 1) + { + fclose(f); + image->input_memory_size = cb; + image->input_memory = b; + } + + else + { + free(b); + return logclose(image, f, image->file_name, + ": read failed: "); + } + } + + else + return logclose(image, f, image->file_name, + ": out of memory: "); + } + + else + return logclose(image, f, image->file_name, + ": file too big for this architecture: "); + /* cb is the length of the file as a (long) and + * this is greater than the maximum amount of + * memory that can be requested from malloc. + */ + } + + else if (cb == 0) + return logclose(image, f, image->file_name, + ": zero length: "); + + else + return logclose(image, f, image->file_name, + ": tell failed: "); + } + + else + return logclose(image, f, image->file_name, ": seek failed: "); + } + } + + else + return logerror(image, image->file_name, ": open failed: ", + strerror(errno)); + } + + return read_file(image, FORMAT_NO_CHANGE, NULL); +} + +#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED +static int +write_one_file(Image *output, Image *image, int convert_to_8bit) +{ + if (image->opts & FAST_WRITE) + image->image.flags |= PNG_IMAGE_FLAG_FAST; + + if (image->opts & USE_STDIO) + { +#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED +#ifndef __COVERITY__ + FILE *f = tmpfile(); +#else + /* Experimental. Coverity says tmpfile() is insecure because it + * generates predictable names. + * + * It is possible to satisfy Coverity by using mkstemp(); however, + * any platform supporting mkstemp() undoubtedly has a secure tmpfile() + * implementation as well, and doesn't need the fix. Note that + * the fix won't work on platforms that don't support mkstemp(). + * + * https://www.securecoding.cert.org/confluence/display/c/ + * FIO21-C.+Do+not+create+temporary+files+in+shared+directories + * says that most historic implementations of tmpfile() provide + * only a limited number of possible temporary file names + * (usually 26) before file names are recycled. That article also + * provides a secure solution that unfortunately depends upon mkstemp(). + */ + char tmpfile[] = "pngstest-XXXXXX"; + int filedes; + FILE *f; + umask(0177); + filedes = mkstemp(tmpfile); + if (filedes < 0) + f = NULL; + else + { + f = fdopen(filedes,"w+"); + /* Hide the filename immediately and ensure that the file does + * not exist after the program ends + */ + (void) unlink(tmpfile); + } +#endif + + if (f != NULL) + { + if (png_image_write_to_stdio(&image->image, f, convert_to_8bit, + image->buffer+16, (png_int_32)image->stride, image->colormap)) + { + if (fflush(f) == 0) + { + rewind(f); + initimage(output, image->opts, "tmpfile", image->stride_extra); + output->input_file = f; + if (!checkopaque(image)) + return 0; + } + + else + return logclose(image, f, "tmpfile", ": flush: "); + } + + else + { + fclose(f); + return logerror(image, "tmpfile", ": write failed", ""); + } + } + + else + return logerror(image, "tmpfile", ": open: ", strerror(errno)); +#else /* SIMPLIFIED_WRITE_STDIO */ + return logerror(image, "tmpfile", ": open: unsupported", ""); +#endif /* SIMPLIFIED_WRITE_STDIO */ + } + + else if (image->opts & USE_FILE) + { +#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED + static int counter = 0; + char name[32]; + + sprintf(name, "%s%d.png", tmpf, ++counter); + + if (png_image_write_to_file(&image->image, name, convert_to_8bit, + image->buffer+16, (png_int_32)image->stride, image->colormap)) + { + initimage(output, image->opts, output->tmpfile_name, + image->stride_extra); + /* Afterwards, or freeimage will delete it! */ + strcpy(output->tmpfile_name, name); + + if (!checkopaque(image)) + return 0; + } + + else + return logerror(image, name, ": write failed", ""); +#else /* SIMPLIFIED_WRITE_STDIO */ + return logerror(image, "stdio", ": open: unsupported", ""); +#endif /* SIMPLIFIED_WRITE_STDIO */ + } + + else /* use memory */ + { + png_alloc_size_t size; + + if (png_image_write_get_memory_size(image->image, size, convert_to_8bit, + image->buffer+16, (png_int_32)image->stride, image->colormap)) + { + /* This is non-fatal but ignoring it was causing serious problems in + * the macro to be ignored: + */ + if (size > PNG_IMAGE_PNG_SIZE_MAX(image->image)) + return logerror(image, "memory", ": PNG_IMAGE_SIZE_MAX wrong", ""); + + initimage(output, image->opts, "memory", image->stride_extra); + output->input_memory = malloc(size); + + if (output->input_memory != NULL) + { + output->input_memory_size = size; + + if (png_image_write_to_memory(&image->image, output->input_memory, + &output->input_memory_size, convert_to_8bit, image->buffer+16, + (png_int_32)image->stride, image->colormap)) + { + /* This is also non-fatal but it safes safer to error out anyway: + */ + if (size != output->input_memory_size) + return logerror(image, "memory", ": memory size wrong", ""); + } + + else + return logerror(image, "memory", ": write failed", ""); + } + + else + return logerror(image, "memory", ": out of memory", ""); + } + + else + return logerror(image, "memory", ": get size:", ""); + } + + /* 'output' has an initialized temporary image, read this back in and compare + * this against the original: there should be no change since the original + * format was written unmodified unless 'convert_to_8bit' was specified. + * However, if the original image was color-mapped, a simple read will zap + * the linear, color and maybe alpha flags, this will cause spurious failures + * under some circumstances. + */ + if (read_file(output, image->image.format | FORMAT_NO_CHANGE, NULL)) + { + png_uint_32 original_format = image->image.format; + + if (convert_to_8bit) + original_format &= ~PNG_FORMAT_FLAG_LINEAR; + + if ((output->image.format & BASE_FORMATS) != + (original_format & BASE_FORMATS)) + return logerror(image, image->file_name, ": format changed on read: ", + output->file_name); + + return compare_two_images(image, output, 0/*via linear*/, NULL); + } + + else + return logerror(output, output->tmpfile_name, + ": read of new file failed", ""); +} +#endif + +static int +testimage(Image *image, png_uint_32 opts, format_list *pf) +{ + int result; + Image copy; + + /* Copy the original data, stealing it from 'image' */ + checkopaque(image); + copy = *image; + + copy.opts = opts; + copy.buffer = NULL; + copy.bufsize = 0; + copy.allocsize = 0; + + image->input_file = NULL; + image->input_memory = NULL; + image->input_memory_size = 0; + image->tmpfile_name[0] = 0; + + { + png_uint_32 counter; + Image output; + + newimage(&output); + + result = 1; + + /* Use the low bit of 'counter' to indicate whether or not to do alpha + * removal with a background color or by composting onto the image; this + * step gets skipped if it isn't relevant + */ + for (counter=0; counter<2*FORMAT_COUNT; ++counter) + if (format_isset(pf, counter >> 1)) + { + png_uint_32 format = counter >> 1; + + png_color background_color; + png_colorp background = NULL; + + /* If there is a format change that removes the alpha channel then + * the background is relevant. If the output is 8-bit color-mapped + * then a background color *must* be provided, otherwise there are + * two tests to do - one with a color, the other with NULL. The + * NULL test happens second. + */ + if ((counter & 1) == 0) + { + if ((format & PNG_FORMAT_FLAG_ALPHA) == 0 && + (image->image.format & PNG_FORMAT_FLAG_ALPHA) != 0) + { + /* Alpha/transparency will be removed, the background is + * relevant: make it a color the first time + */ + random_color(&background_color); + background = &background_color; + + /* BUT if the output is to a color-mapped 8-bit format then + * the background must always be a color, so increment 'counter' + * to skip the NULL test. + */ + if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0 && + (format & PNG_FORMAT_FLAG_LINEAR) == 0) + ++counter; + } + + /* Otherwise an alpha channel is not being eliminated, just leave + * background NULL and skip the (counter & 1) NULL test. + */ + else + ++counter; + } + /* else just use NULL for background */ + + resetimage(©); + copy.opts = opts; /* in case read_file needs to change it */ + + result = read_file(©, format, background); + if (!result) + break; + + /* Make sure the file just read matches the original file. */ + result = compare_two_images(image, ©, 0/*via linear*/, background); + if (!result) + break; + +# ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED + /* Write the *copy* just made to a new file to make sure the write + * side works ok. Check the conversion to sRGB if the copy is + * linear. + */ + output.opts = opts; + result = write_one_file(&output, ©, 0/*convert to 8bit*/); + if (!result) + break; + + /* Validate against the original too; the background is needed here + * as well so that compare_two_images knows what color was used. + */ + result = compare_two_images(image, &output, 0, background); + if (!result) + break; + + if ((format & PNG_FORMAT_FLAG_LINEAR) != 0 && + (format & PNG_FORMAT_FLAG_COLORMAP) == 0) + { + /* 'output' is linear, convert to the corresponding sRGB format. + */ + output.opts = opts; + result = write_one_file(&output, ©, 1/*convert to 8bit*/); + if (!result) + break; + + /* This may involve a conversion via linear; in the ideal world + * this would round-trip correctly, but libpng 1.5.7 is not the + * ideal world so allow a drift (error_via_linear). + * + * 'image' has an alpha channel but 'output' does not then there + * will a strip-alpha-channel operation (because 'output' is + * linear), handle this by composing on black when doing the + * comparison. + */ + result = compare_two_images(image, &output, 1/*via_linear*/, + background); + if (!result) + break; + } +# endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */ + } + + freeimage(&output); + } + + freeimage(©); + + return result; +} + +static int +test_one_file(const char *file_name, format_list *formats, png_uint_32 opts, + int stride_extra, int log_pass) +{ + int result; + Image image; + + if (!(opts & NO_RESEED)) + reseed(); /* ensure that the random numbers don't depend on file order */ + newimage(&image); + initimage(&image, opts, file_name, stride_extra); + result = read_one_file(&image); + if (result) + result = testimage(&image, opts, formats); + freeimage(&image); + + /* Ensure that stderr is flushed into any log file */ + fflush(stderr); + + if (log_pass) + { + if (result) + printf("PASS:"); + + else + printf("FAIL:"); + +# ifndef PNG_SIMPLIFIED_WRITE_SUPPORTED + printf(" (no write)"); +# endif + + print_opts(opts); + printf(" %s\n", file_name); + /* stdout may not be line-buffered if it is piped to a file, so: */ + fflush(stdout); + } + + else if (!result) + exit(1); + + return result; +} + +int +main(int argc, char **argv) +{ + png_uint_32 opts = FAST_WRITE | STRICT; + format_list formats; + const char *touch = NULL; + int log_pass = 0; + int redundant = 0; + int stride_extra = 0; + int retval = 0; + int c; + +#if PNG_LIBPNG_VER >= 10700 + /* This error should not exist in 1.7 or later: */ + opts |= GBG_ERROR; +#endif + + init_sRGB_to_d(); +#if 0 + init_error_via_linear(); +#endif + format_init(&formats); + reseed(); /* initialize random number seeds */ + + for (c=1; c= sizeof tmpf) + { + fflush(stdout); + fprintf(stderr, "%s: %s is too long for a temp file prefix\n", + argv[0], argv[c]); + exit(99); + } + + /* Safe: checked above */ + strncpy(tmpf, argv[c], sizeof (tmpf)-1); + } + + else + { + fflush(stdout); + fprintf(stderr, "%s: %s requires a temporary file prefix\n", + argv[0], arg); + exit(99); + } + } + else if (strcmp(arg, "--touch") == 0) + { + if (c+1 < argc) + touch = argv[++c]; + + else + { + fflush(stdout); + fprintf(stderr, "%s: %s requires a file name argument\n", + argv[0], arg); + exit(99); + } + } + else if (arg[0] == '+') + { + png_uint_32 format = formatof(arg+1); + + if (format > FORMAT_COUNT) + exit(99); + + format_set(&formats, format); + } + else if (arg[0] == '-' && arg[1] != 0 && (arg[1] != '0' || arg[2] != 0)) + { + fflush(stdout); + fprintf(stderr, "%s: unknown option: %s\n", argv[0], arg); + exit(99); + } + else + { + if (format_is_initial(&formats)) + format_default(&formats, redundant); + + if (arg[0] == '-') + { + int term = (arg[1] == '0' ? 0 : '\n'); + unsigned int ich = 0; + + /* Loop reading files, use a static buffer to simplify this and just + * stop if the name gets to long. + */ + static char buffer[4096]; + + do + { + int ch = getchar(); + + /* Don't allow '\0' in file names, and terminate with '\n' or, + * for -0, just '\0' (use -print0 to find to make this work!) + */ + if (ch == EOF || ch == term || ch == 0) + { + buffer[ich] = 0; + + if (ich > 0 && !test_one_file(buffer, &formats, opts, + stride_extra, log_pass)) + retval = 1; + + if (ch == EOF) + break; + + ich = 0; + --ich; /* so that the increment below sets it to 0 again */ + } + + else + buffer[ich] = (char)ch; + } while (++ich < sizeof buffer); + + if (ich) + { + buffer[32] = 0; + buffer[4095] = 0; + fprintf(stderr, "%s...%s: file name too long\n", buffer, + buffer+(4096-32)); + exit(99); + } + } + + else if (!test_one_file(arg, &formats, opts, stride_extra, log_pass)) + retval = 1; + } + } + + if (opts & ACCUMULATE) + { + unsigned int in; + + printf("/* contrib/libtests/pngstest-errors.h\n"); + printf(" *\n"); + printf(" * BUILT USING:" PNG_HEADER_VERSION_STRING); + printf(" *\n"); + printf(" * This code is released under the libpng license.\n"); + printf(" * For conditions of distribution and use, see the disclaimer\n"); + printf(" * and license in png.h\n"); + printf(" *\n"); + printf(" * THIS IS A MACHINE GENERATED FILE: do not edit it directly!\n"); + printf(" * Instead run:\n"); + printf(" *\n"); + printf(" * pngstest --accumulate\n"); + printf(" *\n"); + printf(" * on as many PNG files as possible; at least PNGSuite and\n"); + printf(" * contrib/libtests/testpngs.\n"); + printf(" */\n"); + + printf("static png_uint_16 gpc_error[16/*in*/][16/*out*/][4/*a*/] =\n"); + printf("{\n"); + for (in=0; in<16; ++in) + { + unsigned int out; + printf(" { /* input: %s */\n ", format_names[in]); + for (out=0; out<16; ++out) + { + unsigned int alpha; + printf(" {"); + for (alpha=0; alpha<4; ++alpha) + { + printf(" %d", gpc_error[in][out][alpha]); + if (alpha < 3) putchar(','); + } + printf(" }"); + if (out < 15) + { + putchar(','); + if (out % 4 == 3) printf("\n "); + } + } + printf("\n }"); + + if (in < 15) + putchar(','); + else + putchar('\n'); + } + printf("};\n"); + + printf("static png_uint_16 gpc_error_via_linear[16][4/*out*/][4] =\n"); + printf("{\n"); + for (in=0; in<16; ++in) + { + unsigned int out; + printf(" { /* input: %s */\n ", format_names[in]); + for (out=0; out<4; ++out) + { + unsigned int alpha; + printf(" {"); + for (alpha=0; alpha<4; ++alpha) + { + printf(" %d", gpc_error_via_linear[in][out][alpha]); + if (alpha < 3) putchar(','); + } + printf(" }"); + if (out < 3) + putchar(','); + } + printf("\n }"); + + if (in < 15) + putchar(','); + else + putchar('\n'); + } + printf("};\n"); + + printf("static png_uint_16 gpc_error_to_colormap[8/*i*/][8/*o*/][4] =\n"); + printf("{\n"); + for (in=0; in<8; ++in) + { + unsigned int out; + printf(" { /* input: %s */\n ", format_names[in]); + for (out=0; out<8; ++out) + { + unsigned int alpha; + printf(" {"); + for (alpha=0; alpha<4; ++alpha) + { + printf(" %d", gpc_error_to_colormap[in][out][alpha]); + if (alpha < 3) putchar(','); + } + printf(" }"); + if (out < 7) + { + putchar(','); + if (out % 4 == 3) printf("\n "); + } + } + printf("\n }"); + + if (in < 7) + putchar(','); + else + putchar('\n'); + } + printf("};\n"); + printf("/* END MACHINE GENERATED */\n"); + } + + if (retval == 0 && touch != NULL) + { + FILE *fsuccess = fopen(touch, "wt"); + + if (fsuccess != NULL) + { + int error = 0; + fprintf(fsuccess, "PNG simple API tests succeeded\n"); + fflush(fsuccess); + error = ferror(fsuccess); + + if (fclose(fsuccess) || error) + { + fflush(stdout); + fprintf(stderr, "%s: write failed\n", touch); + exit(99); + } + } + + else + { + fflush(stdout); + fprintf(stderr, "%s: open failed\n", touch); + exit(99); + } + } + + return retval; +} + +#else /* !PNG_SIMPLIFIED_READ_SUPPORTED */ +int main(void) +{ + fprintf(stderr, "pngstest: no read support in libpng, test skipped\n"); + /* So the test is skipped: */ + return SKIP; +} +#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */ diff --git a/thirdparty/libpng-1.6.37/contrib/libtests/pngunknown.c b/thirdparty/libpng-1.6.37/contrib/libtests/pngunknown.c new file mode 100644 index 0000000..05bdd83 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/libtests/pngunknown.c @@ -0,0 +1,1294 @@ + +/* pngunknown.c - test the read side unknown chunk handling + * + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 2015,2017 Glenn Randers-Pehrson + * Written by John Cunningham Bowler + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * NOTES: + * This is a C program that is intended to be linked against libpng. It + * allows the libpng unknown handling code to be tested by interpreting + * arguments to save or discard combinations of chunks. The program is + * currently just a minimal validation for the built-in libpng facilities. + */ + +#include +#include +#include +#include + +/* Define the following to use this test against your installed libpng, rather + * than the one being built here: + */ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../../png.h" +#endif + +/* 1.6.1 added support for the configure test harness, which uses 77 to indicate + * a skipped test, in earlier versions we need to succeed on a skipped test, so: + */ +#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H) +# define SKIP 77 +#else +# define SKIP 0 +#endif + + +/* Since this program tests the ability to change the unknown chunk handling + * these must be defined: + */ +#if defined(PNG_SET_UNKNOWN_CHUNKS_SUPPORTED) &&\ + defined(PNG_STDIO_SUPPORTED) &&\ + defined(PNG_READ_SUPPORTED) + +/* One of these must be defined to allow us to find out what happened. It is + * still useful to set unknown chunk handling without either of these in order + * to cause *known* chunks to be discarded. This can be a significant + * efficiency gain, but it can't really be tested here. + */ +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) ||\ + defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED) + +#if PNG_LIBPNG_VER < 10500 +/* This deliberately lacks the const. */ +typedef png_byte *png_const_bytep; + +/* This is copied from 1.5.1 png.h: */ +#define PNG_INTERLACE_ADAM7_PASSES 7 +#define PNG_PASS_START_ROW(pass) (((1U&~(pass))<<(3-((pass)>>1)))&7) +#define PNG_PASS_START_COL(pass) (((1U& (pass))<<(3-(((pass)+1)>>1)))&7) +#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) +#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) +#define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) +#define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) +#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \ + (((yIn)<>(((7-(off))-(pass))<<2)) & 0xFU) | \ + ((0x01145AF0U>>(((7-(off))-(pass))<<2)) & 0xF0U)) +#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ + ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) +#define PNG_COL_IN_INTERLACE_PASS(x, pass) \ + ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) + +/* These are needed too for the default build: */ +#define PNG_WRITE_16BIT_SUPPORTED +#define PNG_READ_16BIT_SUPPORTED + +/* This comes from pnglibconf.h after 1.5: */ +#define PNG_FP_1 100000 +#define PNG_GAMMA_THRESHOLD_FIXED\ + ((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1)) +#endif + +#if PNG_LIBPNG_VER < 10600 + /* 1.6.0 constifies many APIs. The following exists to allow pngvalid to be + * compiled against earlier versions. + */ +# define png_const_structp png_structp +#endif + +#if PNG_LIBPNG_VER < 10700 + /* Copied from libpng 1.7.0 png.h */ +#define PNG_u2(b1, b2) (((unsigned int)(b1) << 8) + (b2)) + +#define PNG_U16(b1, b2) ((png_uint_16)PNG_u2(b1, b2)) +#define PNG_U32(b1, b2, b3, b4)\ + (((png_uint_32)PNG_u2(b1, b2) << 16) + PNG_u2(b3, b4)) + +/* Constants for known chunk types. + */ +#define png_IDAT PNG_U32( 73, 68, 65, 84) +#define png_IEND PNG_U32( 73, 69, 78, 68) +#define png_IHDR PNG_U32( 73, 72, 68, 82) +#define png_PLTE PNG_U32( 80, 76, 84, 69) +#define png_bKGD PNG_U32( 98, 75, 71, 68) +#define png_cHRM PNG_U32( 99, 72, 82, 77) +#define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */ +#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */ +#define png_gAMA PNG_U32(103, 65, 77, 65) +#define png_gIFg PNG_U32(103, 73, 70, 103) +#define png_gIFt PNG_U32(103, 73, 70, 116) /* deprecated */ +#define png_gIFx PNG_U32(103, 73, 70, 120) +#define png_hIST PNG_U32(104, 73, 83, 84) +#define png_iCCP PNG_U32(105, 67, 67, 80) +#define png_iTXt PNG_U32(105, 84, 88, 116) +#define png_oFFs PNG_U32(111, 70, 70, 115) +#define png_pCAL PNG_U32(112, 67, 65, 76) +#define png_pHYs PNG_U32(112, 72, 89, 115) +#define png_sBIT PNG_U32(115, 66, 73, 84) +#define png_sCAL PNG_U32(115, 67, 65, 76) +#define png_sPLT PNG_U32(115, 80, 76, 84) +#define png_sRGB PNG_U32(115, 82, 71, 66) +#define png_sTER PNG_U32(115, 84, 69, 82) +#define png_tEXt PNG_U32(116, 69, 88, 116) +#define png_tIME PNG_U32(116, 73, 77, 69) +#define png_tRNS PNG_U32(116, 82, 78, 83) +#define png_zTXt PNG_U32(122, 84, 88, 116) + +/* Test on flag values as defined in the spec (section 5.4): */ +#define PNG_CHUNK_ANCILLARY(c) (1 & ((c) >> 29)) +#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c)) +#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21)) +#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13)) +#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5)) + +#endif /* PNG_LIBPNG_VER < 10700 */ + +#ifdef __cplusplus +# define this not_the_cpp_this +# define new not_the_cpp_new +# define voidcast(type, value) static_cast(value) +#else +# define voidcast(type, value) (value) +#endif /* __cplusplus */ + +/* Unused formal parameter errors are removed using the following macro which is + * expected to have no bad effects on performance. + */ +#ifndef UNUSED +# if defined(__GNUC__) || defined(_MSC_VER) +# define UNUSED(param) (void)param; +# else +# define UNUSED(param) +# endif +#endif + +/* Types of chunks not known to libpng */ +#define png_vpAg PNG_U32(118, 112, 65, 103) + +/* Chunk information */ +#define PNG_INFO_tEXt 0x10000000U +#define PNG_INFO_iTXt 0x20000000U +#define PNG_INFO_zTXt 0x40000000U + +#define PNG_INFO_sTER 0x01000000U +#define PNG_INFO_vpAg 0x02000000U + +#define ABSENT 0 +#define START 1 +#define END 2 + +static struct +{ + char name[5]; + png_uint_32 flag; + png_uint_32 tag; + int unknown; /* Chunk not known to libpng */ + int all; /* Chunk set by the '-1' option */ + int position; /* position in pngtest.png */ + int keep; /* unknown handling setting */ +} chunk_info[] = { + /* Critical chunks */ + { "IDAT", PNG_INFO_IDAT, png_IDAT, 0, 0, START, 0 }, /* must be [0] */ + { "PLTE", PNG_INFO_PLTE, png_PLTE, 0, 0, ABSENT, 0 }, + + /* Non-critical chunks that libpng handles */ + /* This is a mess but it seems to be the only way to do it - there is no way + * to check for a definition outside a #if. + */ + { "bKGD", PNG_INFO_bKGD, png_bKGD, +# ifdef PNG_READ_bKGD_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "cHRM", PNG_INFO_cHRM, png_cHRM, +# ifdef PNG_READ_cHRM_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "eXIf", PNG_INFO_eXIf, png_eXIf, +# ifdef PNG_READ_eXIf_SUPPORTED + 0, +# else + 1, +# endif + 1, END, 0 }, + { "gAMA", PNG_INFO_gAMA, png_gAMA, +# ifdef PNG_READ_gAMA_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "hIST", PNG_INFO_hIST, png_hIST, +# ifdef PNG_READ_hIST_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "iCCP", PNG_INFO_iCCP, png_iCCP, +# ifdef PNG_READ_iCCP_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "iTXt", PNG_INFO_iTXt, png_iTXt, +# ifdef PNG_READ_iTXt_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "oFFs", PNG_INFO_oFFs, png_oFFs, +# ifdef PNG_READ_oFFs_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "pCAL", PNG_INFO_pCAL, png_pCAL, +# ifdef PNG_READ_pCAL_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "pHYs", PNG_INFO_pHYs, png_pHYs, +# ifdef PNG_READ_pHYs_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "sBIT", PNG_INFO_sBIT, png_sBIT, +# ifdef PNG_READ_sBIT_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "sCAL", PNG_INFO_sCAL, png_sCAL, +# ifdef PNG_READ_sCAL_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "sPLT", PNG_INFO_sPLT, png_sPLT, +# ifdef PNG_READ_sPLT_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "sRGB", PNG_INFO_sRGB, png_sRGB, +# ifdef PNG_READ_sRGB_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "tEXt", PNG_INFO_tEXt, png_tEXt, +# ifdef PNG_READ_tEXt_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "tIME", PNG_INFO_tIME, png_tIME, +# ifdef PNG_READ_tIME_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "tRNS", PNG_INFO_tRNS, png_tRNS, +# ifdef PNG_READ_tRNS_SUPPORTED + 0, +# else + 1, +# endif + 0, ABSENT, 0 }, + { "zTXt", PNG_INFO_zTXt, png_zTXt, +# ifdef PNG_READ_zTXt_SUPPORTED + 0, +# else + 1, +# endif + 1, END, 0 }, + + /* No libpng handling */ + { "sTER", PNG_INFO_sTER, png_sTER, 1, 1, START, 0 }, + { "vpAg", PNG_INFO_vpAg, png_vpAg, 1, 0, START, 0 }, +}; + +#define NINFO ((int)((sizeof chunk_info)/(sizeof chunk_info[0]))) + +static void +clear_keep(void) +{ + int i = NINFO; + while (--i >= 0) + chunk_info[i].keep = 0; +} + +static int +find(const char *name) +{ + int i = NINFO; + while (--i >= 0) + { + if (memcmp(chunk_info[i].name, name, 4) == 0) + break; + } + + return i; +} + +static int +findb(const png_byte *name) +{ + int i = NINFO; + while (--i >= 0) + { + if (memcmp(chunk_info[i].name, name, 4) == 0) + break; + } + + return i; +} + +static int +find_by_flag(png_uint_32 flag) +{ + int i = NINFO; + + while (--i >= 0) if (chunk_info[i].flag == flag) return i; + + fprintf(stderr, "pngunknown: internal error\n"); + exit(4); +} + +static int +ancillary(const char *name) +{ + return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3])); +} + +#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED +static int +ancillaryb(const png_byte *name) +{ + return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3])); +} +#endif + +/* Type of an error_ptr */ +typedef struct +{ + jmp_buf error_return; + png_structp png_ptr; + png_infop info_ptr, end_ptr; + png_uint_32 before_IDAT; + png_uint_32 after_IDAT; + int error_count; + int warning_count; + int keep; /* the default value */ + const char *program; + const char *file; + const char *test; +} display; + +static const char init[] = "initialization"; +static const char cmd[] = "command line"; + +static void +init_display(display *d, const char *program) +{ + memset(d, 0, sizeof *d); + d->png_ptr = NULL; + d->info_ptr = d->end_ptr = NULL; + d->error_count = d->warning_count = 0; + d->program = program; + d->file = program; + d->test = init; +} + +static void +clean_display(display *d) +{ + png_destroy_read_struct(&d->png_ptr, &d->info_ptr, &d->end_ptr); + + /* This must not happen - it might cause an app crash */ + if (d->png_ptr != NULL || d->info_ptr != NULL || d->end_ptr != NULL) + { + fprintf(stderr, "%s(%s): png_destroy_read_struct error\n", d->file, + d->test); + exit(1); + } +} + +PNG_FUNCTION(void, display_exit, (display *d), static PNG_NORETURN) +{ + ++(d->error_count); + + if (d->png_ptr != NULL) + clean_display(d); + + /* During initialization and if this is a single command line argument set + * exit now - there is only one test, otherwise longjmp to do the next test. + */ + if (d->test == init || d->test == cmd) + exit(1); + + longjmp(d->error_return, 1); +} + +static int +display_rc(const display *d, int strict) +{ + return d->error_count + (strict ? d->warning_count : 0); +} + +/* libpng error and warning callbacks */ +PNG_FUNCTION(void, (PNGCBAPI error), (png_structp png_ptr, const char *message), + static PNG_NORETURN) +{ + display *d = (display*)png_get_error_ptr(png_ptr); + + fprintf(stderr, "%s(%s): libpng error: %s\n", d->file, d->test, message); + display_exit(d); +} + +static void PNGCBAPI +warning(png_structp png_ptr, const char *message) +{ + display *d = (display*)png_get_error_ptr(png_ptr); + + fprintf(stderr, "%s(%s): libpng warning: %s\n", d->file, d->test, message); + ++(d->warning_count); +} + +static png_uint_32 +get_valid(display *d, png_infop info_ptr) +{ + png_uint_32 flags = png_get_valid(d->png_ptr, info_ptr, (png_uint_32)~0); + + /* Map the text chunks back into the flags */ + { + png_textp text; + png_uint_32 ntext = png_get_text(d->png_ptr, info_ptr, &text, NULL); + + while (ntext > 0) switch (text[--ntext].compression) + { + case -1: + flags |= PNG_INFO_tEXt; + break; + case 0: + flags |= PNG_INFO_zTXt; + break; + case 1: + case 2: + flags |= PNG_INFO_iTXt; + break; + default: + fprintf(stderr, "%s(%s): unknown text compression %d\n", d->file, + d->test, text[ntext].compression); + display_exit(d); + } + } + + return flags; +} + +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED +static int PNGCBAPI +read_callback(png_structp pp, png_unknown_chunkp pc) +{ + /* This function mimics the behavior of png_set_keep_unknown_chunks by + * returning '0' to keep the chunk and '1' to discard it. + */ + display *d = voidcast(display*, png_get_user_chunk_ptr(pp)); + int chunk = findb(pc->name); + int keep, discard; + + if (chunk < 0) /* not one in our list, so not a known chunk */ + keep = d->keep; + + else + { + keep = chunk_info[chunk].keep; + if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT) + { + /* See the comments in png.h - use the default for unknown chunks, + * do not keep known chunks. + */ + if (chunk_info[chunk].unknown) + keep = d->keep; + + else + keep = PNG_HANDLE_CHUNK_NEVER; + } + } + + switch (keep) + { + default: + fprintf(stderr, "%s(%s): %d: unrecognized chunk option\n", d->file, + d->test, chunk_info[chunk].keep); + display_exit(d); + + case PNG_HANDLE_CHUNK_AS_DEFAULT: + case PNG_HANDLE_CHUNK_NEVER: + discard = 1/*handled; discard*/; + break; + + case PNG_HANDLE_CHUNK_IF_SAFE: + case PNG_HANDLE_CHUNK_ALWAYS: + discard = 0/*not handled; keep*/; + break; + } + + /* Also store information about this chunk in the display, the relevant flag + * is set if the chunk is to be kept ('not handled'.) + */ + if (chunk >= 0) if (!discard) /* stupidity to stop a GCC warning */ + { + png_uint_32 flag = chunk_info[chunk].flag; + + if (pc->location & PNG_AFTER_IDAT) + d->after_IDAT |= flag; + + else + d->before_IDAT |= flag; + } + + /* However if there is no support to store unknown chunks don't ask libpng to + * do it; there will be an png_error. + */ +# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + return discard; +# else + return 1; /*handled; discard*/ +# endif +} +#endif /* READ_USER_CHUNKS_SUPPORTED */ + +#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED +static png_uint_32 +get_unknown(display *d, png_infop info_ptr, int after_IDAT) +{ + /* Create corresponding 'unknown' flags */ + png_uint_32 flags = 0; + + UNUSED(after_IDAT) + + { + png_unknown_chunkp unknown; + int num_unknown = png_get_unknown_chunks(d->png_ptr, info_ptr, &unknown); + + while (--num_unknown >= 0) + { + int chunk = findb(unknown[num_unknown].name); + + /* Chunks not known to pngunknown must be validated here; since they + * must also be unknown to libpng the 'display->keep' behavior should + * have been used. + */ + if (chunk < 0) switch (d->keep) + { + default: /* impossible */ + case PNG_HANDLE_CHUNK_AS_DEFAULT: + case PNG_HANDLE_CHUNK_NEVER: + fprintf(stderr, "%s(%s): %s: %s: unknown chunk saved\n", + d->file, d->test, d->keep ? "discard" : "default", + unknown[num_unknown].name); + ++(d->error_count); + break; + + case PNG_HANDLE_CHUNK_IF_SAFE: + if (!ancillaryb(unknown[num_unknown].name)) + { + fprintf(stderr, + "%s(%s): if-safe: %s: unknown critical chunk saved\n", + d->file, d->test, unknown[num_unknown].name); + ++(d->error_count); + break; + } + /* FALLTHROUGH */ /* (safe) */ + case PNG_HANDLE_CHUNK_ALWAYS: + break; + } + + else + flags |= chunk_info[chunk].flag; + } + } + + return flags; +} +#else /* SAVE_UNKNOWN_CHUNKS */ +static png_uint_32 +get_unknown(display *d, png_infop info_ptr, int after_IDAT) + /* Otherwise this will return the cached values set by any user callback */ +{ + UNUSED(info_ptr); + + if (after_IDAT) + return d->after_IDAT; + + else + return d->before_IDAT; +} + +# ifndef PNG_READ_USER_CHUNKS_SUPPORTED + /* The #defines above should mean this is never reached, it's just here as + * a check to ensure the logic is correct. + */ +# error No store support and no user chunk support, this will not work +# endif /* READ_USER_CHUNKS */ +#endif /* SAVE_UNKNOWN_CHUNKS */ + +static int +check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/, + display *d, int set_callback) +{ + int i, npasses, ipass; + png_uint_32 height; + + d->keep = PNG_HANDLE_CHUNK_AS_DEFAULT; + d->before_IDAT = 0; + d->after_IDAT = 0; + + /* Some of these errors are permanently fatal and cause an exit here, others + * are per-test and cause an error return. + */ + d->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, d, error, + warning); + if (d->png_ptr == NULL) + { + fprintf(stderr, "%s(%s): could not allocate png struct\n", d->file, + d->test); + /* Terminate here, this error is not test specific. */ + exit(1); + } + + d->info_ptr = png_create_info_struct(d->png_ptr); + d->end_ptr = png_create_info_struct(d->png_ptr); + if (d->info_ptr == NULL || d->end_ptr == NULL) + { + fprintf(stderr, "%s(%s): could not allocate png info\n", d->file, + d->test); + clean_display(d); + exit(1); + } + + png_init_io(d->png_ptr, fp); + +# ifdef PNG_READ_USER_CHUNKS_SUPPORTED + /* This is only done if requested by the caller; it interferes with the + * standard store/save mechanism. + */ + if (set_callback) + png_set_read_user_chunk_fn(d->png_ptr, d, read_callback); +# else + UNUSED(set_callback) +# endif + + /* Handle each argument in turn; multiple settings are possible for the same + * chunk and multiple calls will occur (the last one should override all + * preceding ones). + */ + for (i=0; i= 10700 &&\ + !defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED) + if (option < PNG_HANDLE_CHUNK_IF_SAFE) +# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */ + { + png_byte name[5]; + + memcpy(name, chunk_info[chunk].name, 5); + png_set_keep_unknown_chunks(d->png_ptr, option, name, 1); + chunk_info[chunk].keep = option; + } + continue; + } + + break; + + case 7: /* default */ + if (memcmp(argv[i], "default", 7) == 0) + { +# if PNG_LIBPNG_VER >= 10700 &&\ + !defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED) + if (option < PNG_HANDLE_CHUNK_IF_SAFE) +# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */ + png_set_keep_unknown_chunks(d->png_ptr, option, NULL, 0); + + d->keep = option; + continue; + } + + break; + + case 3: /* all */ + if (memcmp(argv[i], "all", 3) == 0) + { +# if PNG_LIBPNG_VER >= 10700 &&\ + !defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED) + if (option < PNG_HANDLE_CHUNK_IF_SAFE) +# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */ + png_set_keep_unknown_chunks(d->png_ptr, option, NULL, -1); + + d->keep = option; + + for (chunk = 0; chunk < NINFO; ++chunk) + if (chunk_info[chunk].all) + chunk_info[chunk].keep = option; + continue; + } + + break; + + default: /* some misplaced = */ + + break; + } + } + + fprintf(stderr, "%s(%s): %s: unrecognized chunk argument\n", d->file, + d->test, argv[i]); + display_exit(d); + } + + png_read_info(d->png_ptr, d->info_ptr); + + switch (png_get_interlace_type(d->png_ptr, d->info_ptr)) + { + case PNG_INTERLACE_NONE: + npasses = 1; + break; + + case PNG_INTERLACE_ADAM7: + npasses = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + /* Hard error because it is not test specific */ + fprintf(stderr, "%s(%s): invalid interlace type\n", d->file, d->test); + clean_display(d); + exit(1); + } + + /* Skip the image data, if IDAT is not being handled then don't do this + * because it will cause a CRC error. + */ + if (chunk_info[0/*IDAT*/].keep == PNG_HANDLE_CHUNK_AS_DEFAULT) + { + png_start_read_image(d->png_ptr); + height = png_get_image_height(d->png_ptr, d->info_ptr); + + if (npasses > 1) + { + png_uint_32 width = png_get_image_width(d->png_ptr, d->info_ptr); + + for (ipass=0; ipass 0) + { + png_uint_32 y; + + for (y=0; ypng_ptr, NULL, NULL); + } + } + } /* interlaced */ + + else /* not interlaced */ + { + png_uint_32 y; + + for (y=0; ypng_ptr, NULL, NULL); + } + } + + png_read_end(d->png_ptr, d->end_ptr); + + flags[0] = get_valid(d, d->info_ptr); + flags[1] = get_unknown(d, d->info_ptr, 0/*before IDAT*/); + + /* Only png_read_png sets PNG_INFO_IDAT! */ + flags[chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT] |= + PNG_INFO_IDAT; + + flags[2] = get_valid(d, d->end_ptr); + flags[3] = get_unknown(d, d->end_ptr, 1/*after IDAT*/); + + clean_display(d); + + return d->keep; +} + +static void +check_error(display *d, png_uint_32 flags, const char *message) +{ + while (flags) + { + png_uint_32 flag = flags & -(png_int_32)flags; + int i = find_by_flag(flag); + + fprintf(stderr, "%s(%s): chunk %s: %s\n", d->file, d->test, + chunk_info[i].name, message); + ++(d->error_count); + + flags &= ~flag; + } +} + +static void +check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known, + png_uint_32 unknown, const char *position, int set_callback) +{ + while (chunks) + { + png_uint_32 flag = chunks & -(png_int_32)chunks; + int i = find_by_flag(flag); + int keep = chunk_info[i].keep; + const char *type; + const char *errorx = NULL; + + if (chunk_info[i].unknown) + { + if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT) + { + type = "UNKNOWN (default)"; + keep = def; + } + + else + type = "UNKNOWN (specified)"; + + if (flag & known) + errorx = "chunk processed"; + + else switch (keep) + { + case PNG_HANDLE_CHUNK_AS_DEFAULT: + if (flag & unknown) + errorx = "DEFAULT: unknown chunk saved"; + break; + + case PNG_HANDLE_CHUNK_NEVER: + if (flag & unknown) + errorx = "DISCARD: unknown chunk saved"; + break; + + case PNG_HANDLE_CHUNK_IF_SAFE: + if (ancillary(chunk_info[i].name)) + { + if (!(flag & unknown)) + errorx = "IF-SAFE: unknown ancillary chunk lost"; + } + + else if (flag & unknown) + errorx = "IF-SAFE: unknown critical chunk saved"; + break; + + case PNG_HANDLE_CHUNK_ALWAYS: + if (!(flag & unknown)) + errorx = "SAVE: unknown chunk lost"; + break; + + default: + errorx = "internal error: bad keep"; + break; + } + } /* unknown chunk */ + + else /* known chunk */ + { + type = "KNOWN"; + + if (flag & known) + { + /* chunk was processed, it won't have been saved because that is + * caught below when checking for inconsistent processing. + */ + if (keep != PNG_HANDLE_CHUNK_AS_DEFAULT) + errorx = "!DEFAULT: known chunk processed"; + } + + else /* not processed */ switch (keep) + { + case PNG_HANDLE_CHUNK_AS_DEFAULT: + errorx = "DEFAULT: known chunk not processed"; + break; + + case PNG_HANDLE_CHUNK_NEVER: + if (flag & unknown) + errorx = "DISCARD: known chunk saved"; + break; + + case PNG_HANDLE_CHUNK_IF_SAFE: + if (ancillary(chunk_info[i].name)) + { + if (!(flag & unknown)) + errorx = "IF-SAFE: known ancillary chunk lost"; + } + + else if (flag & unknown) + errorx = "IF-SAFE: known critical chunk saved"; + break; + + case PNG_HANDLE_CHUNK_ALWAYS: + if (!(flag & unknown)) + errorx = "SAVE: known chunk lost"; + break; + + default: + errorx = "internal error: bad keep (2)"; + break; + } + } + + if (errorx != NULL) + { + ++(d->error_count); + fprintf(stderr, "%s(%s%s): %s %s %s: %s\n", d->file, d->test, + set_callback ? ",callback" : "", + type, chunk_info[i].name, position, errorx); + } + + chunks &= ~flag; + } +} + +static void +perform_one_test(FILE *fp, int argc, const char **argv, + png_uint_32 *default_flags, display *d, int set_callback) +{ + int def; + png_uint_32 flags[2][4]; + + rewind(fp); + clear_keep(); + memcpy(flags[0], default_flags, sizeof flags[0]); + + def = check(fp, argc, argv, flags[1], d, set_callback); + + /* If IDAT is being handled as unknown the image read is skipped and all the + * IDATs after the first end up in the end info struct, so in this case add + * IDAT to the list of unknowns. (Do this after 'check' above sets the + * chunk_info 'keep' fields.) + * + * Note that the flag setting has to be in the 'known' field to avoid + * triggering the consistency check below and the flag must only be set if + * there are multiple IDATs, so if the check above did find an unknown IDAT + * after IDAT. + */ + if (chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT && + (flags[1][3] & PNG_INFO_IDAT) != 0) + flags[0][2] |= PNG_INFO_IDAT; + + /* Chunks should either be known or unknown, never both and this should apply + * whether the chunk is before or after the IDAT (actually, the app can + * probably change this by swapping the handling after the image, but this + * test does not do that.) + */ + check_error(d, (flags[0][0]|flags[0][2]) & (flags[0][1]|flags[0][3]), + "chunk handled inconsistently in count tests"); + check_error(d, (flags[1][0]|flags[1][2]) & (flags[1][1]|flags[1][3]), + "chunk handled inconsistently in option tests"); + + /* Now find out what happened to each chunk before and after the IDAT and + * determine if the behavior was correct. First some basic sanity checks, + * any known chunk should be known in the original count, any unknown chunk + * should be either known or unknown in the original. + */ + { + png_uint_32 test; + + test = flags[1][0] & ~flags[0][0]; + check_error(d, test, "new known chunk before IDAT"); + test = flags[1][1] & ~(flags[0][0] | flags[0][1]); + check_error(d, test, "new unknown chunk before IDAT"); + test = flags[1][2] & ~flags[0][2]; + check_error(d, test, "new known chunk after IDAT"); + test = flags[1][3] & ~(flags[0][2] | flags[0][3]); + check_error(d, test, "new unknown chunk after IDAT"); + } + + /* Now each chunk in the original list should have been handled according to + * the options set for that chunk, regardless of whether libpng knows about + * it or not. + */ + check_handling(d, def, flags[0][0] | flags[0][1], flags[1][0], flags[1][1], + "before IDAT", set_callback); + check_handling(d, def, flags[0][2] | flags[0][3], flags[1][2], flags[1][3], + "after IDAT", set_callback); +} + +static void +perform_one_test_safe(FILE *fp, int argc, const char **argv, + png_uint_32 *default_flags, display *d, const char *test) +{ + if (setjmp(d->error_return) == 0) + { + d->test = test; /* allow use of d->error_return */ +# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + perform_one_test(fp, argc, argv, default_flags, d, 0); +# endif +# ifdef PNG_READ_USER_CHUNKS_SUPPORTED + perform_one_test(fp, argc, argv, default_flags, d, 1); +# endif + d->test = init; /* prevent use of d->error_return */ + } +} + +static const char *standard_tests[] = +{ + "discard", "default=discard", 0, + "save", "default=save", 0, + "if-safe", "default=if-safe", 0, + "vpAg", "vpAg=if-safe", 0, + "sTER", "sTER=if-safe", 0, + "IDAT", "default=discard", "IDAT=save", 0, + "sAPI", "bKGD=save", "cHRM=save", "gAMA=save", "all=discard", "iCCP=save", + "sBIT=save", "sRGB=save", "eXIf=save", 0, + 0/*end*/ +}; + +static PNG_NORETURN void +usage(const char *program, const char *reason) +{ + fprintf(stderr, "pngunknown: %s: usage:\n %s [--strict] " + "--default|{(CHNK|default|all)=(default|discard|if-safe|save)} " + "testfile.png\n", reason, program); + exit(99); +} + +int +main(int argc, const char **argv) +{ + FILE *fp; + png_uint_32 default_flags[4/*valid,unknown{before,after}*/]; + int strict = 0, default_tests = 0; + const char *count_argv = "default=save"; + const char *touch_file = NULL; + display d; + + init_display(&d, argv[0]); + + while (++argv, --argc > 0) + { + if (strcmp(*argv, "--strict") == 0) + strict = 1; + + else if (strcmp(*argv, "--default") == 0) + default_tests = 1; + + else if (strcmp(*argv, "--touch") == 0) + { + if (argc > 1) + touch_file = *++argv, --argc; + + else + usage(d.program, "--touch: missing file name"); + } + + else + break; + } + + /* A file name is required, but there should be no other arguments if + * --default was specified. + */ + if (argc <= 0) + usage(d.program, "missing test file"); + + /* GCC BUG: if (default_tests && argc != 1) triggers some weird GCC argc + * optimization which causes warnings with -Wstrict-overflow! + */ + else if (default_tests) if (argc != 1) + usage(d.program, "extra arguments"); + + /* The name of the test file is the last argument; remove it. */ + d.file = argv[--argc]; + + fp = fopen(d.file, "rb"); + if (fp == NULL) + { + perror(d.file); + exit(99); + } + + /* First find all the chunks, known and unknown, in the test file, a failure + * here aborts the whole test. + * + * If 'save' is supported then the normal saving method should happen, + * otherwise if 'read' is supported then the read callback will do the + * same thing. If both are supported the 'read' callback won't be + * instantiated by default. If 'save' is *not* supported then a user + * callback is required even though we can call png_get_unknown_chunks. + */ + if (check(fp, 1, &count_argv, default_flags, &d, +# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + 0 +# else + 1 +# endif + ) != PNG_HANDLE_CHUNK_ALWAYS) + { + fprintf(stderr, "%s: %s: internal error\n", d.program, d.file); + exit(99); + } + + /* Now find what the various supplied options cause to change: */ + if (!default_tests) + { + d.test = cmd; /* acts as a flag to say exit, do not longjmp */ +# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + perform_one_test(fp, argc, argv, default_flags, &d, 0); +# endif +# ifdef PNG_READ_USER_CHUNKS_SUPPORTED + perform_one_test(fp, argc, argv, default_flags, &d, 1); +# endif + d.test = init; + } + + else + { + const char **test = standard_tests; + + /* Set the exit_test pointer here so we can continue after a libpng error. + * NOTE: this leaks memory because the png_struct data from the failing + * test is never freed. + */ + while (*test) + { + const char *this_test = *test++; + const char **next = test; + int count = display_rc(&d, strict), new_count; + const char *result; + int arg_count = 0; + + while (*next) ++next, ++arg_count; + + perform_one_test_safe(fp, arg_count, test, default_flags, &d, + this_test); + + new_count = display_rc(&d, strict); + + if (new_count == count) + result = "PASS"; + + else + result = "FAIL"; + + printf("%s: %s %s\n", result, d.program, this_test); + + test = next+1; + } + } + + fclose(fp); + + if (display_rc(&d, strict) == 0) + { + /* Success, touch the success file if appropriate */ + if (touch_file != NULL) + { + FILE *fsuccess = fopen(touch_file, "wt"); + + if (fsuccess != NULL) + { + int err = 0; + fprintf(fsuccess, "PNG unknown tests succeeded\n"); + fflush(fsuccess); + err = ferror(fsuccess); + + if (fclose(fsuccess) || err) + { + fprintf(stderr, "%s: write failed\n", touch_file); + exit(99); + } + } + + else + { + fprintf(stderr, "%s: open failed\n", touch_file); + exit(99); + } + } + + return 0; + } + + return 1; +} + +#else /* !(READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS) */ +int +main(void) +{ + fprintf(stderr, + " test ignored: no support to find out about unknown chunks\n"); + /* So the test is skipped: */ + return SKIP; +} +#endif /* READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS */ + +#else /* !(SET_UNKNOWN_CHUNKS && READ) */ +int +main(void) +{ + fprintf(stderr, + " test ignored: no support to modify unknown chunk handling\n"); + /* So the test is skipped: */ + return SKIP; +} +#endif /* SET_UNKNOWN_CHUNKS && READ*/ diff --git a/thirdparty/libpng-1.6.37/contrib/libtests/pngvalid.c b/thirdparty/libpng-1.6.37/contrib/libtests/pngvalid.c new file mode 100644 index 0000000..d800110 --- /dev/null +++ b/thirdparty/libpng-1.6.37/contrib/libtests/pngvalid.c @@ -0,0 +1,12230 @@ + +/* pngvalid.c - validate libpng by constructing then reading png files. + * + * Last changed in libpng 1.6.31 [July 27, 2017] + * Copyright (c) 2014-2017 John Cunningham Bowler + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * NOTES: + * This is a C program that is intended to be linked against libpng. It + * generates bitmaps internally, stores them as PNG files (using the + * sequential write code) then reads them back (using the sequential + * read code) and validates that the result has the correct data. + * + * The program can be modified and extended to test the correctness of + * transformations performed by libpng. + */ + +#define _POSIX_SOURCE 1 +#define _ISOC99_SOURCE 1 /* For floating point */ +#define _GNU_SOURCE 1 /* For the floating point exception extension */ +#define _BSD_SOURCE 1 /* For the floating point exception extension */ + +#include +#include + +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) +# include +#endif + +#ifdef HAVE_FEENABLEEXCEPT /* from config.h, if included */ +# include +#endif + +#ifndef FE_DIVBYZERO +# define FE_DIVBYZERO 0 +#endif +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif +#ifndef FE_OVERFLOW +# define FE_OVERFLOW 0 +#endif + +/* Define the following to use this test against your installed libpng, rather + * than the one being built here: + */ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../../png.h" +#endif + +#ifdef PNG_ZLIB_HEADER +# include PNG_ZLIB_HEADER +#else +# include /* For crc32 */ +#endif + +/* 1.6.1 added support for the configure test harness, which uses 77 to indicate + * a skipped test, in earlier versions we need to succeed on a skipped test, so: + */ +#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H) +# define SKIP 77 +#else +# define SKIP 0 +#endif + +/* pngvalid requires write support and one of the fixed or floating point APIs. + */ +#if defined(PNG_WRITE_SUPPORTED) &&\ + (defined(PNG_FIXED_POINT_SUPPORTED) || defined(PNG_FLOATING_POINT_SUPPORTED)) + +#if PNG_LIBPNG_VER < 10500 +/* This deliberately lacks the const. */ +typedef png_byte *png_const_bytep; + +/* This is copied from 1.5.1 png.h: */ +#define PNG_INTERLACE_ADAM7_PASSES 7 +#define PNG_PASS_START_ROW(pass) (((1U&~(pass))<<(3-((pass)>>1)))&7) +#define PNG_PASS_START_COL(pass) (((1U& (pass))<<(3-(((pass)+1)>>1)))&7) +#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) +#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) +#define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) +#define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) +#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \ + (((yIn)<>(((7-(off))-(pass))<<2)) & 0xFU) | \ + ((0x01145AF0U>>(((7-(off))-(pass))<<2)) & 0xF0U)) +#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ + ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) +#define PNG_COL_IN_INTERLACE_PASS(x, pass) \ + ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) + +/* These are needed too for the default build: */ +#define PNG_WRITE_16BIT_SUPPORTED +#define PNG_READ_16BIT_SUPPORTED + +/* This comes from pnglibconf.h after 1.5: */ +#define PNG_FP_1 100000 +#define PNG_GAMMA_THRESHOLD_FIXED\ + ((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1)) +#endif + +#if PNG_LIBPNG_VER < 10600 + /* 1.6.0 constifies many APIs, the following exists to allow pngvalid to be + * compiled against earlier versions. + */ +# define png_const_structp png_structp +#endif + +#ifndef RELEASE_BUILD + /* RELEASE_BUILD is true for releases and release candidates: */ +# define RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC) +#endif +#if RELEASE_BUILD +# define debugonly(something) +#else /* !RELEASE_BUILD */ +# define debugonly(something) something +#endif /* !RELEASE_BUILD */ + +#include /* For floating point constants */ +#include /* For malloc */ +#include /* For memcpy, memset */ +#include /* For floor */ + +/* Convenience macros. */ +#define CHUNK(a,b,c,d) (((a)<<24)+((b)<<16)+((c)<<8)+(d)) +#define CHUNK_IHDR CHUNK(73,72,68,82) +#define CHUNK_PLTE CHUNK(80,76,84,69) +#define CHUNK_IDAT CHUNK(73,68,65,84) +#define CHUNK_IEND CHUNK(73,69,78,68) +#define CHUNK_cHRM CHUNK(99,72,82,77) +#define CHUNK_gAMA CHUNK(103,65,77,65) +#define CHUNK_sBIT CHUNK(115,66,73,84) +#define CHUNK_sRGB CHUNK(115,82,71,66) + +/* Unused formal parameter errors are removed using the following macro which is + * expected to have no bad effects on performance. + */ +#ifndef UNUSED +# if defined(__GNUC__) || defined(_MSC_VER) +# define UNUSED(param) (void)param; +# else +# define UNUSED(param) +# endif +#endif + +/***************************** EXCEPTION HANDLING *****************************/ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../visupng/cexcept.h" +#endif + +#ifdef __cplusplus +# define this not_the_cpp_this +# define new not_the_cpp_new +# define voidcast(type, value) static_cast(value) +#else +# define voidcast(type, value) (value) +#endif /* __cplusplus */ + +struct png_store; +define_exception_type(struct png_store*); + +/* The following are macros to reduce typing everywhere where the well known + * name 'the_exception_context' must be defined. + */ +#define anon_context(ps) struct exception_context *the_exception_context = \ + &(ps)->exception_context +#define context(ps,fault) anon_context(ps); png_store *fault + +/* This macro returns the number of elements in an array as an (unsigned int), + * it is necessary to avoid the inability of certain versions of GCC to use + * the value of a compile-time constant when performing range checks. It must + * be passed an array name. + */ +#define ARRAY_SIZE(a) ((unsigned int)((sizeof (a))/(sizeof (a)[0]))) + +/* GCC BUG 66447 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66447) requires + * some broken GCC versions to be fixed up to avoid invalid whining about auto + * variables that are *not* changed within the scope of a setjmp being changed. + * + * Feel free to extend the list of broken versions. + */ +#define is_gnu(major,minor)\ + (defined __GNUC__) && __GNUC__ == (major) && __GNUC_MINOR__ == (minor) +#define is_gnu_patch(major,minor,patch)\ + is_gnu(major,minor) && __GNUC_PATCHLEVEL__ == 0 +/* For the moment just do it always; all versions of GCC seem to be broken: */ +#ifdef __GNUC__ + const void * volatile make_volatile_for_gnu; +# define gnu_volatile(x) make_volatile_for_gnu = &x; +#else /* !GNUC broken versions */ +# define gnu_volatile(x) +#endif /* !GNUC broken versions */ + +/******************************* UTILITIES ************************************/ +/* Error handling is particularly problematic in production code - error + * handlers often themselves have bugs which lead to programs that detect + * minor errors crashing. The following functions deal with one very + * common class of errors in error handlers - attempting to format error or + * warning messages into buffers that are too small. + */ +static size_t safecat(char *buffer, size_t bufsize, size_t pos, + const char *cat) +{ + while (pos < bufsize && cat != NULL && *cat != 0) + buffer[pos++] = *cat++; + + if (pos >= bufsize) + pos = bufsize-1; + + buffer[pos] = 0; + return pos; +} + +static size_t safecatn(char *buffer, size_t bufsize, size_t pos, int n) +{ + char number[64]; + sprintf(number, "%d", n); + return safecat(buffer, bufsize, pos, number); +} + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +static size_t safecatd(char *buffer, size_t bufsize, size_t pos, double d, + int precision) +{ + char number[64]; + sprintf(number, "%.*f", precision, d); + return safecat(buffer, bufsize, pos, number); +} +#endif + +static const char invalid[] = "invalid"; +static const char sep[] = ": "; + +static const char *colour_types[8] = +{ + "grayscale", invalid, "truecolour", "indexed-colour", + "grayscale with alpha", invalid, "truecolour with alpha", invalid +}; + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +/* Convert a double precision value to fixed point. */ +static png_fixed_point +fix(double d) +{ + d = floor(d * PNG_FP_1 + .5); + return (png_fixed_point)d; +} +#endif /* PNG_READ_SUPPORTED */ + +/* Generate random bytes. This uses a boring repeatable algorithm and it + * is implemented here so that it gives the same set of numbers on every + * architecture. It's a linear congruential generator (Knuth or Sedgewick + * "Algorithms") but it comes from the 'feedback taps' table in Horowitz and + * Hill, "The Art of Electronics" (Pseudo-Random Bit Sequences and Noise + * Generation.) + */ +static void +make_random_bytes(png_uint_32* seed, void* pv, size_t size) +{ + png_uint_32 u0 = seed[0], u1 = seed[1]; + png_bytep bytes = voidcast(png_bytep, pv); + + /* There are thirty three bits, the next bit in the sequence is bit-33 XOR + * bit-20. The top 1 bit is in u1, the bottom 32 are in u0. + */ + size_t i; + for (i=0; i> (20-8)) ^ ((u1 << 7) | (u0 >> (32-7)))) & 0xff; + u1 <<= 8; + u1 |= u0 >> 24; + u0 <<= 8; + u0 |= u; + *bytes++ = (png_byte)u; + } + + seed[0] = u0; + seed[1] = u1; +} + +static void +make_four_random_bytes(png_uint_32* seed, png_bytep bytes) +{ + make_random_bytes(seed, bytes, 4); +} + +#if defined PNG_READ_SUPPORTED || defined PNG_WRITE_tRNS_SUPPORTED ||\ + defined PNG_WRITE_FILTER_SUPPORTED +static void +randomize(void *pv, size_t size) +{ + static png_uint_32 random_seed[2] = {0x56789abc, 0xd}; + make_random_bytes(random_seed, pv, size); +} + +#define R8(this) randomize(&(this), sizeof (this)) + +#ifdef PNG_READ_SUPPORTED +static png_byte +random_byte(void) +{ + unsigned char b1[1]; + randomize(b1, sizeof b1); + return b1[0]; +} +#endif /* READ */ + +static png_uint_16 +random_u16(void) +{ + unsigned char b2[2]; + randomize(b2, sizeof b2); + return png_get_uint_16(b2); +} + +#if defined PNG_READ_RGB_TO_GRAY_SUPPORTED ||\ + defined PNG_READ_FILLER_SUPPORTED +static png_uint_32 +random_u32(void) +{ + unsigned char b4[4]; + randomize(b4, sizeof b4); + return png_get_uint_32(b4); +} +#endif /* READ_FILLER || READ_RGB_TO_GRAY */ + +#endif /* READ || WRITE_tRNS || WRITE_FILTER */ + +#if defined PNG_READ_TRANSFORMS_SUPPORTED ||\ + defined PNG_WRITE_FILTER_SUPPORTED +static unsigned int +random_mod(unsigned int max) +{ + return random_u16() % max; /* 0 .. max-1 */ +} +#endif /* READ_TRANSFORMS || WRITE_FILTER */ + +#if (defined PNG_READ_RGB_TO_GRAY_SUPPORTED) ||\ + (defined PNG_READ_FILLER_SUPPORTED) +static int +random_choice(void) +{ + return random_byte() & 1; +} +#endif /* READ_RGB_TO_GRAY || READ_FILLER */ + +/* A numeric ID based on PNG file characteristics. The 'do_interlace' field + * simply records whether pngvalid did the interlace itself or whether it + * was done by libpng. Width and height must be less than 256. 'palette' is an + * index of the palette to use for formats with a palette otherwise a boolean + * indicating if a tRNS chunk was generated. + */ +#define FILEID(col, depth, palette, interlace, width, height, do_interlace) \ + ((png_uint_32)((col) + ((depth)<<3) + ((palette)<<8) + ((interlace)<<13) + \ + (((do_interlace)!=0)<<15) + ((width)<<16) + ((height)<<24))) + +#define COL_FROM_ID(id) ((png_byte)((id)& 0x7U)) +#define DEPTH_FROM_ID(id) ((png_byte)(((id) >> 3) & 0x1fU)) +#define PALETTE_FROM_ID(id) (((id) >> 8) & 0x1f) +#define INTERLACE_FROM_ID(id) ((png_byte)(((id) >> 13) & 0x3)) +#define DO_INTERLACE_FROM_ID(id) ((int)(((id)>>15) & 1)) +#define WIDTH_FROM_ID(id) (((id)>>16) & 0xff) +#define HEIGHT_FROM_ID(id) (((id)>>24) & 0xff) + +/* Utility to construct a standard name for a standard image. */ +static size_t +standard_name(char *buffer, size_t bufsize, size_t pos, png_byte colour_type, + int bit_depth, unsigned int npalette, int interlace_type, + png_uint_32 w, png_uint_32 h, int do_interlace) +{ + pos = safecat(buffer, bufsize, pos, colour_types[colour_type]); + if (colour_type == 3) /* must have a palette */ + { + pos = safecat(buffer, bufsize, pos, "["); + pos = safecatn(buffer, bufsize, pos, npalette); + pos = safecat(buffer, bufsize, pos, "]"); + } + + else if (npalette != 0) + pos = safecat(buffer, bufsize, pos, "+tRNS"); + + pos = safecat(buffer, bufsize, pos, " "); + pos = safecatn(buffer, bufsize, pos, bit_depth); + pos = safecat(buffer, bufsize, pos, " bit"); + + if (interlace_type != PNG_INTERLACE_NONE) + { + pos = safecat(buffer, bufsize, pos, " interlaced"); + if (do_interlace) + pos = safecat(buffer, bufsize, pos, "(pngvalid)"); + else + pos = safecat(buffer, bufsize, pos, "(libpng)"); + } + + if (w > 0 || h > 0) + { + pos = safecat(buffer, bufsize, pos, " "); + pos = safecatn(buffer, bufsize, pos, w); + pos = safecat(buffer, bufsize, pos, "x"); + pos = safecatn(buffer, bufsize, pos, h); + } + + return pos; +} + +static size_t +standard_name_from_id(char *buffer, size_t bufsize, size_t pos, png_uint_32 id) +{ + return standard_name(buffer, bufsize, pos, COL_FROM_ID(id), + DEPTH_FROM_ID(id), PALETTE_FROM_ID(id), INTERLACE_FROM_ID(id), + WIDTH_FROM_ID(id), HEIGHT_FROM_ID(id), DO_INTERLACE_FROM_ID(id)); +} + +/* Convenience API and defines to list valid formats. Note that 16 bit read and + * write support is required to do 16 bit read tests (we must be able to make a + * 16 bit image to test!) + */ +#ifdef PNG_WRITE_16BIT_SUPPORTED +# define WRITE_BDHI 4 +# ifdef PNG_READ_16BIT_SUPPORTED +# define READ_BDHI 4 +# define DO_16BIT +# endif +#else +# define WRITE_BDHI 3 +#endif +#ifndef DO_16BIT +# define READ_BDHI 3 +#endif + +/* The following defines the number of different palettes to generate for + * each log bit depth of a colour type 3 standard image. + */ +#define PALETTE_COUNT(bit_depth) ((bit_depth) > 4 ? 1U : 16U) + +static int +next_format(png_bytep colour_type, png_bytep bit_depth, + unsigned int* palette_number, int low_depth_gray, int tRNS) +{ + if (*bit_depth == 0) + { + *colour_type = 0; + if (low_depth_gray) + *bit_depth = 1; + else + *bit_depth = 8; + *palette_number = 0; + return 1; + } + + if (*colour_type < 4/*no alpha channel*/) + { + /* Add multiple palettes for colour type 3, one image with tRNS + * and one without for other non-alpha formats: + */ + unsigned int pn = ++*palette_number; + png_byte ct = *colour_type; + + if (((ct == 0/*GRAY*/ || ct/*RGB*/ == 2) && tRNS && pn < 2) || + (ct == 3/*PALETTE*/ && pn < PALETTE_COUNT(*bit_depth))) + return 1; + + /* No: next bit depth */ + *palette_number = 0; + } + + *bit_depth = (png_byte)(*bit_depth << 1); + + /* Palette images are restricted to 8 bit depth */ + if (*bit_depth <= 8 +#ifdef DO_16BIT + || (*colour_type != 3 && *bit_depth <= 16) +#endif + ) + return 1; + + /* Move to the next color type, or return 0 at the end. */ + switch (*colour_type) + { + case 0: + *colour_type = 2; + *bit_depth = 8; + return 1; + + case 2: + *colour_type = 3; + *bit_depth = 1; + return 1; + + case 3: + *colour_type = 4; + *bit_depth = 8; + return 1; + + case 4: + *colour_type = 6; + *bit_depth = 8; + return 1; + + default: + return 0; + } +} + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +static unsigned int +sample(png_const_bytep row, png_byte colour_type, png_byte bit_depth, + png_uint_32 x, unsigned int sample_index, int swap16, int littleendian) +{ + png_uint_32 bit_index, result; + + /* Find a sample index for the desired sample: */ + x *= bit_depth; + bit_index = x; + + if ((colour_type & 1) == 0) /* !palette */ + { + if (colour_type & 2) + bit_index *= 3; + + if (colour_type & 4) + bit_index += x; /* Alpha channel */ + + /* Multiple channels; select one: */ + if (colour_type & (2+4)) + bit_index += sample_index * bit_depth; + } + + /* Return the sample from the row as an integer. */ + row += bit_index >> 3; + result = *row; + + if (bit_depth == 8) + return result; + + else if (bit_depth > 8) + { + if (swap16) + return (*++row << 8) + result; + else + return (result << 8) + *++row; + } + + /* Less than 8 bits per sample. By default PNG has the big end of + * the egg on the left of the screen, but if littleendian is set + * then the big end is on the right. + */ + bit_index &= 7; + + if (!littleendian) + bit_index = 8-bit_index-bit_depth; + + return (result >> bit_index) & ((1U<> 3] & ~destMask; + unsigned int sourceByte = fromBuffer[fromIndex >> 3]; + + /* Don't rely on << or >> supporting '0' here, just in case: */ + fromIndex &= 7; + if (littleendian) + { + if (fromIndex > 0) sourceByte >>= fromIndex; + if ((toIndex & 7) > 0) sourceByte <<= toIndex & 7; + } + + else + { + if (fromIndex > 0) sourceByte <<= fromIndex; + if ((toIndex & 7) > 0) sourceByte >>= toIndex & 7; + } + + toBuffer[toIndex >> 3] = (png_byte)(destByte | (sourceByte & destMask)); + } + else /* One or more bytes */ + memmove(toBuffer+(toIndex>>3), fromBuffer+(fromIndex>>3), pixelSize>>3); +} + +#ifdef PNG_READ_SUPPORTED +/* Copy a complete row of pixels, taking into account potential partial + * bytes at the end. + */ +static void +row_copy(png_bytep toBuffer, png_const_bytep fromBuffer, unsigned int bitWidth, + int littleendian) +{ + memcpy(toBuffer, fromBuffer, bitWidth >> 3); + + if ((bitWidth & 7) != 0) + { + unsigned int mask; + + toBuffer += bitWidth >> 3; + fromBuffer += bitWidth >> 3; + if (littleendian) + mask = 0xff << (bitWidth & 7); + else + mask = 0xff >> (bitWidth & 7); + *toBuffer = (png_byte)((*toBuffer & mask) | (*fromBuffer & ~mask)); + } +} + +/* Compare pixels - they are assumed to start at the first byte in the + * given buffers. + */ +static int +pixel_cmp(png_const_bytep pa, png_const_bytep pb, png_uint_32 bit_width) +{ +#if PNG_LIBPNG_VER < 10506 + if (memcmp(pa, pb, bit_width>>3) == 0) + { + png_uint_32 p; + + if ((bit_width & 7) == 0) return 0; + + /* Ok, any differences? */ + p = pa[bit_width >> 3]; + p ^= pb[bit_width >> 3]; + + if (p == 0) return 0; + + /* There are, but they may not be significant, remove the bits + * after the end (the low order bits in PNG.) + */ + bit_width &= 7; + p >>= 8-bit_width; + + if (p == 0) return 0; + } +#else + /* From libpng-1.5.6 the overwrite should be fixed, so compare the trailing + * bits too: + */ + if (memcmp(pa, pb, (bit_width+7)>>3) == 0) + return 0; +#endif + + /* Return the index of the changed byte. */ + { + png_uint_32 where = 0; + + while (pa[where] == pb[where]) ++where; + return 1+where; + } +} +#endif /* PNG_READ_SUPPORTED */ + +/*************************** BASIC PNG FILE WRITING ***************************/ +/* A png_store takes data from the sequential writer or provides data + * to the sequential reader. It can also store the result of a PNG + * write for later retrieval. + */ +#define STORE_BUFFER_SIZE 500 /* arbitrary */ +typedef struct png_store_buffer +{ + struct png_store_buffer* prev; /* NOTE: stored in reverse order */ + png_byte buffer[STORE_BUFFER_SIZE]; +} png_store_buffer; + +#define FILE_NAME_SIZE 64 + +typedef struct store_palette_entry /* record of a single palette entry */ +{ + png_byte red; + png_byte green; + png_byte blue; + png_byte alpha; +} store_palette_entry, store_palette[256]; + +typedef struct png_store_file +{ + struct png_store_file* next; /* as many as you like... */ + char name[FILE_NAME_SIZE]; + unsigned int IDAT_bits; /* Number of bits in IDAT size */ + png_uint_32 IDAT_size; /* Total size of IDAT data */ + png_uint_32 id; /* must be correct (see FILEID) */ + size_t datacount; /* In this (the last) buffer */ + png_store_buffer data; /* Last buffer in file */ + int npalette; /* Number of entries in palette */ + store_palette_entry* palette; /* May be NULL */ +} png_store_file; + +/* The following is a pool of memory allocated by a single libpng read or write + * operation. + */ +typedef struct store_pool +{ + struct png_store *store; /* Back pointer */ + struct store_memory *list; /* List of allocated memory */ + png_byte mark[4]; /* Before and after data */ + + /* Statistics for this run. */ + png_alloc_size_t max; /* Maximum single allocation */ + png_alloc_size_t current; /* Current allocation */ + png_alloc_size_t limit; /* Highest current allocation */ + png_alloc_size_t total; /* Total allocation */ + + /* Overall statistics (retained across successive runs). */ + png_alloc_size_t max_max; + png_alloc_size_t max_limit; + png_alloc_size_t max_total; +} store_pool; + +typedef struct png_store +{ + /* For cexcept.h exception handling - simply store one of these; + * the context is a self pointer but it may point to a different + * png_store (in fact it never does in this program.) + */ + struct exception_context + exception_context; + + unsigned int verbose :1; + unsigned int treat_warnings_as_errors :1; + unsigned int expect_error :1; + unsigned int expect_warning :1; + unsigned int saw_warning :1; + unsigned int speed :1; + unsigned int progressive :1; /* use progressive read */ + unsigned int validated :1; /* used as a temporary flag */ + int nerrors; + int nwarnings; + int noptions; /* number of options below: */ + struct { + unsigned char option; /* option number, 0..30 */ + unsigned char setting; /* setting (unset,invalid,on,off) */ + } options[16]; + char test[128]; /* Name of test */ + char error[256]; + + /* Share fields */ + png_uint_32 chunklen; /* Length of chunk+overhead (chunkpos >= 8) */ + png_uint_32 chunktype;/* Type of chunk (valid if chunkpos >= 4) */ + png_uint_32 chunkpos; /* Position in chunk */ + png_uint_32 IDAT_size;/* Accumulated IDAT size in .new */ + unsigned int IDAT_bits;/* Cache of the file store value */ + + /* Read fields */ + png_structp pread; /* Used to read a saved file */ + png_infop piread; + png_store_file* current; /* Set when reading */ + png_store_buffer* next; /* Set when reading */ + size_t readpos; /* Position in *next */ + png_byte* image; /* Buffer for reading interlaced images */ + size_t cb_image; /* Size of this buffer */ + size_t cb_row; /* Row size of the image(s) */ + uLong IDAT_crc; + png_uint_32 IDAT_len; /* Used when re-chunking IDAT chunks */ + png_uint_32 IDAT_pos; /* Used when re-chunking IDAT chunks */ + png_uint_32 image_h; /* Number of rows in a single image */ + store_pool read_memory_pool; + + /* Write fields */ + png_store_file* saved; + png_structp pwrite; /* Used when writing a new file */ + png_infop piwrite; + size_t writepos; /* Position in .new */ + char wname[FILE_NAME_SIZE]; + png_store_buffer new; /* The end of the new PNG file being written. */ + store_pool write_memory_pool; + store_palette_entry* palette; + int npalette; +} png_store; + +/* Initialization and cleanup */ +static void +store_pool_mark(png_bytep mark) +{ + static png_uint_32 store_seed[2] = { 0x12345678, 1}; + + make_four_random_bytes(store_seed, mark); +} + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +/* Use this for random 32 bit values; this function makes sure the result is + * non-zero. + */ +static png_uint_32 +random_32(void) +{ + + for (;;) + { + png_byte mark[4]; + png_uint_32 result; + + store_pool_mark(mark); + result = png_get_uint_32(mark); + + if (result != 0) + return result; + } +} +#endif /* PNG_READ_SUPPORTED */ + +static void +store_pool_init(png_store *ps, store_pool *pool) +{ + memset(pool, 0, sizeof *pool); + + pool->store = ps; + pool->list = NULL; + pool->max = pool->current = pool->limit = pool->total = 0; + pool->max_max = pool->max_limit = pool->max_total = 0; + store_pool_mark(pool->mark); +} + +static void +store_init(png_store* ps) +{ + memset(ps, 0, sizeof *ps); + init_exception_context(&ps->exception_context); + store_pool_init(ps, &ps->read_memory_pool); + store_pool_init(ps, &ps->write_memory_pool); + ps->verbose = 0; + ps->treat_warnings_as_errors = 0; + ps->expect_error = 0; + ps->expect_warning = 0; + ps->saw_warning = 0; + ps->speed = 0; + ps->progressive = 0; + ps->validated = 0; + ps->nerrors = ps->nwarnings = 0; + ps->pread = NULL; + ps->piread = NULL; + ps->saved = ps->current = NULL; + ps->next = NULL; + ps->readpos = 0; + ps->image = NULL; + ps->cb_image = 0; + ps->cb_row = 0; + ps->image_h = 0; + ps->pwrite = NULL; + ps->piwrite = NULL; + ps->writepos = 0; + ps->chunkpos = 8; + ps->chunktype = 0; + ps->chunklen = 16; + ps->IDAT_size = 0; + ps->IDAT_bits = 0; + ps->new.prev = NULL; + ps->palette = NULL; + ps->npalette = 0; + ps->noptions = 0; +} + +static void +store_freebuffer(png_store_buffer* psb) +{ + if (psb->prev) + { + store_freebuffer(psb->prev); + free(psb->prev); + psb->prev = NULL; + } +} + +static void +store_freenew(png_store *ps) +{ + store_freebuffer(&ps->new); + ps->writepos = 0; + ps->chunkpos = 8; + ps->chunktype = 0; + ps->chunklen = 16; + ps->IDAT_size = 0; + ps->IDAT_bits = 0; + if (ps->palette != NULL) + { + free(ps->palette); + ps->palette = NULL; + ps->npalette = 0; + } +} + +static void +store_storenew(png_store *ps) +{ + png_store_buffer *pb; + + pb = voidcast(png_store_buffer*, malloc(sizeof *pb)); + + if (pb == NULL) + png_error(ps->pwrite, "store new: OOM"); + + *pb = ps->new; + ps->new.prev = pb; + ps->writepos = 0; +} + +static void +store_freefile(png_store_file **ppf) +{ + if (*ppf != NULL) + { + store_freefile(&(*ppf)->next); + + store_freebuffer(&(*ppf)->data); + (*ppf)->datacount = 0; + if ((*ppf)->palette != NULL) + { + free((*ppf)->palette); + (*ppf)->palette = NULL; + (*ppf)->npalette = 0; + } + free(*ppf); + *ppf = NULL; + } +} + +static unsigned int +bits_of(png_uint_32 num) +{ + /* Return the number of bits in 'num' */ + unsigned int b = 0; + + if (num & 0xffff0000U) b += 16U, num >>= 16; + if (num & 0xff00U) b += 8U, num >>= 8; + if (num & 0xf0U) b += 4U, num >>= 4; + if (num & 0xcU) b += 2U, num >>= 2; + if (num & 0x2U) ++b, num >>= 1; + if (num) ++b; + + return b; /* 0..32 */ +} + +/* Main interface to file storage, after writing a new PNG file (see the API + * below) call store_storefile to store the result with the given name and id. + */ +static void +store_storefile(png_store *ps, png_uint_32 id) +{ + png_store_file *pf; + + if (ps->chunkpos != 0U || ps->chunktype != 0U || ps->chunklen != 0U || + ps->IDAT_size == 0) + png_error(ps->pwrite, "storefile: incomplete write"); + + pf = voidcast(png_store_file*, malloc(sizeof *pf)); + if (pf == NULL) + png_error(ps->pwrite, "storefile: OOM"); + safecat(pf->name, sizeof pf->name, 0, ps->wname); + pf->id = id; + pf->data = ps->new; + pf->datacount = ps->writepos; + pf->IDAT_size = ps->IDAT_size; + pf->IDAT_bits = bits_of(ps->IDAT_size); + /* Because the IDAT always has zlib header stuff this must be true: */ + if (pf->IDAT_bits == 0U) + png_error(ps->pwrite, "storefile: 0 sized IDAT"); + ps->new.prev = NULL; + ps->writepos = 0; + ps->chunkpos = 8; + ps->chunktype = 0; + ps->chunklen = 16; + ps->IDAT_size = 0; + pf->palette = ps->palette; + pf->npalette = ps->npalette; + ps->palette = 0; + ps->npalette = 0; + + /* And save it. */ + pf->next = ps->saved; + ps->saved = pf; +} + +/* Generate an error message (in the given buffer) */ +static size_t +store_message(png_store *ps, png_const_structp pp, char *buffer, size_t bufsize, + size_t pos, const char *msg) +{ + if (pp != NULL && pp == ps->pread) + { + /* Reading a file */ + pos = safecat(buffer, bufsize, pos, "read: "); + + if (ps->current != NULL) + { + pos = safecat(buffer, bufsize, pos, ps->current->name); + pos = safecat(buffer, bufsize, pos, sep); + } + } + + else if (pp != NULL && pp == ps->pwrite) + { + /* Writing a file */ + pos = safecat(buffer, bufsize, pos, "write: "); + pos = safecat(buffer, bufsize, pos, ps->wname); + pos = safecat(buffer, bufsize, pos, sep); + } + + else + { + /* Neither reading nor writing (or a memory error in struct delete) */ + pos = safecat(buffer, bufsize, pos, "pngvalid: "); + } + + if (ps->test[0] != 0) + { + pos = safecat(buffer, bufsize, pos, ps->test); + pos = safecat(buffer, bufsize, pos, sep); + } + pos = safecat(buffer, bufsize, pos, msg); + return pos; +} + +/* Verbose output to the error stream: */ +static void +store_verbose(png_store *ps, png_const_structp pp, png_const_charp prefix, + png_const_charp message) +{ + char buffer[512]; + + if (prefix) + fputs(prefix, stderr); + + (void)store_message(ps, pp, buffer, sizeof buffer, 0, message); + fputs(buffer, stderr); + fputc('\n', stderr); +} + +/* Log an error or warning - the relevant count is always incremented. */ +static void +store_log(png_store* ps, png_const_structp pp, png_const_charp message, + int is_error) +{ + /* The warning is copied to the error buffer if there are no errors and it is + * the first warning. The error is copied to the error buffer if it is the + * first error (overwriting any prior warnings). + */ + if (is_error ? (ps->nerrors)++ == 0 : + (ps->nwarnings)++ == 0 && ps->nerrors == 0) + store_message(ps, pp, ps->error, sizeof ps->error, 0, message); + + if (ps->verbose) + store_verbose(ps, pp, is_error ? "error: " : "warning: ", message); +} + +#ifdef PNG_READ_SUPPORTED +/* Internal error function, called with a png_store but no libpng stuff. */ +static void +internal_error(png_store *ps, png_const_charp message) +{ + store_log(ps, NULL, message, 1 /* error */); + + /* And finally throw an exception. */ + { + struct exception_context *the_exception_context = &ps->exception_context; + Throw ps; + } +} +#endif /* PNG_READ_SUPPORTED */ + +/* Functions to use as PNG callbacks. */ +static void PNGCBAPI +store_error(png_structp ppIn, png_const_charp message) /* PNG_NORETURN */ +{ + png_const_structp pp = ppIn; + png_store *ps = voidcast(png_store*, png_get_error_ptr(pp)); + + if (!ps->expect_error) + store_log(ps, pp, message, 1 /* error */); + + /* And finally throw an exception. */ + { + struct exception_context *the_exception_context = &ps->exception_context; + Throw ps; + } +} + +static void PNGCBAPI +store_warning(png_structp ppIn, png_const_charp message) +{ + png_const_structp pp = ppIn; + png_store *ps = voidcast(png_store*, png_get_error_ptr(pp)); + + if (!ps->expect_warning) + store_log(ps, pp, message, 0 /* warning */); + else + ps->saw_warning = 1; +} + +/* These somewhat odd functions are used when reading an image to ensure that + * the buffer is big enough, the png_structp is for errors. + */ +/* Return a single row from the correct image. */ +static png_bytep +store_image_row(const png_store* ps, png_const_structp pp, int nImage, + png_uint_32 y) +{ + size_t coffset = (nImage * ps->image_h + y) * (ps->cb_row + 5) + 2; + + if (ps->image == NULL) + png_error(pp, "no allocated image"); + + if (coffset + ps->cb_row + 3 > ps->cb_image) + png_error(pp, "image too small"); + + return ps->image + coffset; +} + +static void +store_image_free(png_store *ps, png_const_structp pp) +{ + if (ps->image != NULL) + { + png_bytep image = ps->image; + + if (image[-1] != 0xed || image[ps->cb_image] != 0xfe) + { + if (pp != NULL) + png_error(pp, "png_store image overwrite (1)"); + else + store_log(ps, NULL, "png_store image overwrite (2)", 1); + } + + ps->image = NULL; + ps->cb_image = 0; + --image; + free(image); + } +} + +static void +store_ensure_image(png_store *ps, png_const_structp pp, int nImages, + size_t cbRow, png_uint_32 cRows) +{ + size_t cb = nImages * cRows * (cbRow + 5); + + if (ps->cb_image < cb) + { + png_bytep image; + + store_image_free(ps, pp); + + /* The buffer is deliberately mis-aligned. */ + image = voidcast(png_bytep, malloc(cb+2)); + if (image == NULL) + { + /* Called from the startup - ignore the error for the moment. */ + if (pp == NULL) + return; + + png_error(pp, "OOM allocating image buffer"); + } + + /* These magic tags are used to detect overwrites above. */ + ++image; + image[-1] = 0xed; + image[cb] = 0xfe; + + ps->image = image; + ps->cb_image = cb; + } + + /* We have an adequate sized image; lay out the rows. There are 2 bytes at + * the start and three at the end of each (this ensures that the row + * alignment starts out odd - 2+1 and changes for larger images on each row.) + */ + ps->cb_row = cbRow; + ps->image_h = cRows; + + /* For error checking, the whole buffer is set to 10110010 (0xb2 - 178). + * This deliberately doesn't match the bits in the size test image which are + * outside the image; these are set to 0xff (all 1). To make the row + * comparison work in the 'size' test case the size rows are pre-initialized + * to the same value prior to calling 'standard_row'. + */ + memset(ps->image, 178, cb); + + /* Then put in the marks. */ + while (--nImages >= 0) + { + png_uint_32 y; + + for (y=0; yimage; + + if (image[-1] != 0xed || image[ps->cb_image] != 0xfe) + png_error(pp, "image overwrite"); + else + { + size_t cbRow = ps->cb_row; + png_uint_32 rows = ps->image_h; + + image += iImage * (cbRow+5) * ps->image_h; + + image += 2; /* skip image first row markers */ + + for (; rows > 0; --rows) + { + if (image[-2] != 190 || image[-1] != 239) + png_error(pp, "row start overwritten"); + + if (image[cbRow] != 222 || image[cbRow+1] != 173 || + image[cbRow+2] != 17) + png_error(pp, "row end overwritten"); + + image += cbRow+5; + } + } +} +#endif /* PNG_READ_SUPPORTED */ + +static int +valid_chunktype(png_uint_32 chunktype) +{ + /* Each byte in the chunk type must be in one of the ranges 65..90, 97..122 + * (both inclusive), so: + */ + unsigned int i; + + for (i=0; i<4; ++i) + { + unsigned int c = chunktype & 0xffU; + + if (!((c >= 65U && c <= 90U) || (c >= 97U && c <= 122U))) + return 0; + + chunktype >>= 8; + } + + return 1; /* It's valid */ +} + +static void PNGCBAPI +store_write(png_structp ppIn, png_bytep pb, size_t st) +{ + png_const_structp pp = ppIn; + png_store *ps = voidcast(png_store*, png_get_io_ptr(pp)); + size_t writepos = ps->writepos; + png_uint_32 chunkpos = ps->chunkpos; + png_uint_32 chunktype = ps->chunktype; + png_uint_32 chunklen = ps->chunklen; + + if (ps->pwrite != pp) + png_error(pp, "store state damaged"); + + /* Technically this is legal, but in practice libpng never writes more than + * the maximum chunk size at once so if it happens something weird has + * changed inside libpng (probably). + */ + if (st > 0x7fffffffU) + png_error(pp, "unexpected write size"); + + /* Now process the bytes to be written. Do this in units of the space in the + * output (write) buffer or, at the start 4 bytes for the chunk type and + * length limited in any case by the amount of data. + */ + while (st > 0) + { + if (writepos >= STORE_BUFFER_SIZE) + store_storenew(ps), writepos = 0; + + if (chunkpos < 4) + { + png_byte b = *pb++; + --st; + chunklen = (chunklen << 8) + b; + ps->new.buffer[writepos++] = b; + ++chunkpos; + } + + else if (chunkpos < 8) + { + png_byte b = *pb++; + --st; + chunktype = (chunktype << 8) + b; + ps->new.buffer[writepos++] = b; + + if (++chunkpos == 8) + { + chunklen &= 0xffffffffU; + if (chunklen > 0x7fffffffU) + png_error(pp, "chunk length too great"); + + chunktype &= 0xffffffffU; + if (chunktype == CHUNK_IDAT) + { + if (chunklen > ~ps->IDAT_size) + png_error(pp, "pngvalid internal image too large"); + + ps->IDAT_size += chunklen; + } + + else if (!valid_chunktype(chunktype)) + png_error(pp, "invalid chunk type"); + + chunklen += 12; /* for header and CRC */ + } + } + + else /* chunkpos >= 8 */ + { + size_t cb = st; + + if (cb > STORE_BUFFER_SIZE - writepos) + cb = STORE_BUFFER_SIZE - writepos; + + if (cb > chunklen - chunkpos/* bytes left in chunk*/) + cb = (size_t)/*SAFE*/(chunklen - chunkpos); + + memcpy(ps->new.buffer + writepos, pb, cb); + chunkpos += (png_uint_32)/*SAFE*/cb; + pb += cb; + writepos += cb; + st -= cb; + + if (chunkpos >= chunklen) /* must be equal */ + chunkpos = chunktype = chunklen = 0; + } + } /* while (st > 0) */ + + ps->writepos = writepos; + ps->chunkpos = chunkpos; + ps->chunktype = chunktype; + ps->chunklen = chunklen; +} + +static void PNGCBAPI +store_flush(png_structp ppIn) +{ + UNUSED(ppIn) /*DOES NOTHING*/ +} + +#ifdef PNG_READ_SUPPORTED +static size_t +store_read_buffer_size(png_store *ps) +{ + /* Return the bytes available for read in the current buffer. */ + if (ps->next != &ps->current->data) + return STORE_BUFFER_SIZE; + + return ps->current->datacount; +} + +/* Return total bytes available for read. */ +static size_t +store_read_buffer_avail(png_store *ps) +{ + if (ps->current != NULL && ps->next != NULL) + { + png_store_buffer *next = &ps->current->data; + size_t cbAvail = ps->current->datacount; + + while (next != ps->next && next != NULL) + { + next = next->prev; + cbAvail += STORE_BUFFER_SIZE; + } + + if (next != ps->next) + png_error(ps->pread, "buffer read error"); + + if (cbAvail > ps->readpos) + return cbAvail - ps->readpos; + } + + return 0; +} + +static int +store_read_buffer_next(png_store *ps) +{ + png_store_buffer *pbOld = ps->next; + png_store_buffer *pbNew = &ps->current->data; + if (pbOld != pbNew) + { + while (pbNew != NULL && pbNew->prev != pbOld) + pbNew = pbNew->prev; + + if (pbNew != NULL) + { + ps->next = pbNew; + ps->readpos = 0; + return 1; + } + + png_error(ps->pread, "buffer lost"); + } + + return 0; /* EOF or error */ +} + +/* Need separate implementation and callback to allow use of the same code + * during progressive read, where the io_ptr is set internally by libpng. + */ +static void +store_read_imp(png_store *ps, png_bytep pb, size_t st) +{ + if (ps->current == NULL || ps->next == NULL) + png_error(ps->pread, "store state damaged"); + + while (st > 0) + { + size_t cbAvail = store_read_buffer_size(ps) - ps->readpos; + + if (cbAvail > 0) + { + if (cbAvail > st) cbAvail = st; + memcpy(pb, ps->next->buffer + ps->readpos, cbAvail); + st -= cbAvail; + pb += cbAvail; + ps->readpos += cbAvail; + } + + else if (!store_read_buffer_next(ps)) + png_error(ps->pread, "read beyond end of file"); + } +} + +static size_t +store_read_chunk(png_store *ps, png_bytep pb, size_t max, size_t min) +{ + png_uint_32 chunklen = ps->chunklen; + png_uint_32 chunktype = ps->chunktype; + png_uint_32 chunkpos = ps->chunkpos; + size_t st = max; + + if (st > 0) do + { + if (chunkpos >= chunklen) /* end of last chunk */ + { + png_byte buffer[8]; + + /* Read the header of the next chunk: */ + store_read_imp(ps, buffer, 8U); + chunklen = png_get_uint_32(buffer) + 12U; + chunktype = png_get_uint_32(buffer+4U); + chunkpos = 0U; /* Position read so far */ + } + + if (chunktype == CHUNK_IDAT) + { + png_uint_32 IDAT_pos = ps->IDAT_pos; + png_uint_32 IDAT_len = ps->IDAT_len; + png_uint_32 IDAT_size = ps->IDAT_size; + + /* The IDAT headers are constructed here; skip the input header. */ + if (chunkpos < 8U) + chunkpos = 8U; + + if (IDAT_pos == IDAT_len) + { + png_byte random = random_byte(); + + /* Make a new IDAT chunk, if IDAT_len is 0 this is the first IDAT, + * if IDAT_size is 0 this is the end. At present this is set up + * using a random number so that there is a 25% chance before + * the start of the first IDAT chunk being 0 length. + */ + if (IDAT_len == 0U) /* First IDAT */ + { + switch (random & 3U) + { + case 0U: IDAT_len = 12U; break; /* 0 bytes */ + case 1U: IDAT_len = 13U; break; /* 1 byte */ + default: IDAT_len = random_u32(); + IDAT_len %= IDAT_size; + IDAT_len += 13U; /* 1..IDAT_size bytes */ + break; + } + } + + else if (IDAT_size == 0U) /* all IDAT data read */ + { + /* The last (IDAT) chunk should be positioned at the CRC now: */ + if (chunkpos != chunklen-4U) + png_error(ps->pread, "internal: IDAT size mismatch"); + + /* The only option here is to add a zero length IDAT, this + * happens 25% of the time. Because of the check above + * chunklen-4U-chunkpos must be zero, we just need to skip the + * CRC now. + */ + if ((random & 3U) == 0U) + IDAT_len = 12U; /* Output another 0 length IDAT */ + + else + { + /* End of IDATs, skip the CRC to make the code above load the + * next chunk header next time round. + */ + png_byte buffer[4]; + + store_read_imp(ps, buffer, 4U); + chunkpos += 4U; + ps->IDAT_pos = IDAT_pos; + ps->IDAT_len = IDAT_len; + ps->IDAT_size = 0U; + continue; /* Read the next chunk */ + } + } + + else + { + /* Middle of IDATs, use 'random' to determine the number of bits + * to use in the IDAT length. + */ + IDAT_len = random_u32(); + IDAT_len &= (1U << (1U + random % ps->IDAT_bits)) - 1U; + if (IDAT_len > IDAT_size) + IDAT_len = IDAT_size; + IDAT_len += 12U; /* zero bytes may occur */ + } + + IDAT_pos = 0U; + ps->IDAT_crc = 0x35af061e; /* Ie: crc32(0UL, "IDAT", 4) */ + } /* IDAT_pos == IDAT_len */ + + if (IDAT_pos < 8U) /* Return the header */ do + { + png_uint_32 b; + unsigned int shift; + + if (IDAT_pos < 4U) + b = IDAT_len - 12U; + + else + b = CHUNK_IDAT; + + shift = 3U & IDAT_pos; + ++IDAT_pos; + + if (shift < 3U) + b >>= 8U*(3U-shift); + + *pb++ = 0xffU & b; + } + while (--st > 0 && IDAT_pos < 8); + + else if (IDAT_pos < IDAT_len - 4U) /* I.e not the CRC */ + { + if (chunkpos < chunklen-4U) + { + uInt avail = (uInt)-1; + + if (avail > (IDAT_len-4U) - IDAT_pos) + avail = (uInt)/*SAFE*/((IDAT_len-4U) - IDAT_pos); + + if (avail > st) + avail = (uInt)/*SAFE*/st; + + if (avail > (chunklen-4U) - chunkpos) + avail = (uInt)/*SAFE*/((chunklen-4U) - chunkpos); + + store_read_imp(ps, pb, avail); + ps->IDAT_crc = crc32(ps->IDAT_crc, pb, avail); + pb += (size_t)/*SAFE*/avail; + st -= (size_t)/*SAFE*/avail; + chunkpos += (png_uint_32)/*SAFE*/avail; + IDAT_size -= (png_uint_32)/*SAFE*/avail; + IDAT_pos += (png_uint_32)/*SAFE*/avail; + } + + else /* skip the input CRC */ + { + png_byte buffer[4]; + + store_read_imp(ps, buffer, 4U); + chunkpos += 4U; + } + } + + else /* IDAT crc */ do + { + uLong b = ps->IDAT_crc; + unsigned int shift = (IDAT_len - IDAT_pos); /* 4..1 */ + ++IDAT_pos; + + if (shift > 1U) + b >>= 8U*(shift-1U); + + *pb++ = 0xffU & b; + } + while (--st > 0 && IDAT_pos < IDAT_len); + + ps->IDAT_pos = IDAT_pos; + ps->IDAT_len = IDAT_len; + ps->IDAT_size = IDAT_size; + } + + else /* !IDAT */ + { + /* If there is still some pending IDAT data after the IDAT chunks have + * been processed there is a problem: + */ + if (ps->IDAT_len > 0 && ps->IDAT_size > 0) + png_error(ps->pread, "internal: missing IDAT data"); + + if (chunktype == CHUNK_IEND && ps->IDAT_len == 0U) + png_error(ps->pread, "internal: missing IDAT"); + + if (chunkpos < 8U) /* Return the header */ do + { + png_uint_32 b; + unsigned int shift; + + if (chunkpos < 4U) + b = chunklen - 12U; + + else + b = chunktype; + + shift = 3U & chunkpos; + ++chunkpos; + + if (shift < 3U) + b >>= 8U*(3U-shift); + + *pb++ = 0xffU & b; + } + while (--st > 0 && chunkpos < 8); + + else /* Return chunk bytes, including the CRC */ + { + size_t avail = st; + + if (avail > chunklen - chunkpos) + avail = (size_t)/*SAFE*/(chunklen - chunkpos); + + store_read_imp(ps, pb, avail); + pb += avail; + st -= avail; + chunkpos += (png_uint_32)/*SAFE*/avail; + + /* Check for end of chunk and end-of-file; don't try to read a new + * chunk header at this point unless instructed to do so by 'min'. + */ + if (chunkpos >= chunklen && max-st >= min && + store_read_buffer_avail(ps) == 0) + break; + } + } /* !IDAT */ + } + while (st > 0); + + ps->chunklen = chunklen; + ps->chunktype = chunktype; + ps->chunkpos = chunkpos; + + return st; /* space left */ +} + +static void PNGCBAPI +store_read(png_structp ppIn, png_bytep pb, size_t st) +{ + png_const_structp pp = ppIn; + png_store *ps = voidcast(png_store*, png_get_io_ptr(pp)); + + if (ps == NULL || ps->pread != pp) + png_error(pp, "bad store read call"); + + store_read_chunk(ps, pb, st, st); +} + +static void +store_progressive_read(png_store *ps, png_structp pp, png_infop pi) +{ + if (ps->pread != pp || ps->current == NULL || ps->next == NULL) + png_error(pp, "store state damaged (progressive)"); + + /* This is another Horowitz and Hill random noise generator. In this case + * the aim is to stress the progressive reader with truly horrible variable + * buffer sizes in the range 1..500, so a sequence of 9 bit random numbers + * is generated. We could probably just count from 1 to 32767 and get as + * good a result. + */ + while (store_read_buffer_avail(ps) > 0) + { + static png_uint_32 noise = 2; + size_t cb; + png_byte buffer[512]; + + /* Generate 15 more bits of stuff: */ + noise = (noise << 9) | ((noise ^ (noise >> (9-5))) & 0x1ff); + cb = noise & 0x1ff; + cb -= store_read_chunk(ps, buffer, cb, 1); + png_process_data(pp, pi, buffer, cb); + } +} +#endif /* PNG_READ_SUPPORTED */ + +/* The caller must fill this in: */ +static store_palette_entry * +store_write_palette(png_store *ps, int npalette) +{ + if (ps->pwrite == NULL) + store_log(ps, NULL, "attempt to write palette without write stream", 1); + + if (ps->palette != NULL) + png_error(ps->pwrite, "multiple store_write_palette calls"); + + /* This function can only return NULL if called with '0'! */ + if (npalette > 0) + { + ps->palette = voidcast(store_palette_entry*, malloc(npalette * + sizeof *ps->palette)); + + if (ps->palette == NULL) + png_error(ps->pwrite, "store new palette: OOM"); + + ps->npalette = npalette; + } + + return ps->palette; +} + +#ifdef PNG_READ_SUPPORTED +static store_palette_entry * +store_current_palette(png_store *ps, int *npalette) +{ + /* This is an internal error (the call has been made outside a read + * operation.) + */ + if (ps->current == NULL) + { + store_log(ps, ps->pread, "no current stream for palette", 1); + return NULL; + } + + /* The result may be null if there is no palette. */ + *npalette = ps->current->npalette; + return ps->current->palette; +} +#endif /* PNG_READ_SUPPORTED */ + +/***************************** MEMORY MANAGEMENT*** ***************************/ +#ifdef PNG_USER_MEM_SUPPORTED +/* A store_memory is simply the header for an allocated block of memory. The + * pointer returned to libpng is just after the end of the header block, the + * allocated memory is followed by a second copy of the 'mark'. + */ +typedef struct store_memory +{ + store_pool *pool; /* Originating pool */ + struct store_memory *next; /* Singly linked list */ + png_alloc_size_t size; /* Size of memory allocated */ + png_byte mark[4]; /* ID marker */ +} store_memory; + +/* Handle a fatal error in memory allocation. This calls png_error if the + * libpng struct is non-NULL, else it outputs a message and returns. This means + * that a memory problem while libpng is running will abort (png_error) the + * handling of particular file while one in cleanup (after the destroy of the + * struct has returned) will simply keep going and free (or attempt to free) + * all the memory. + */ +static void +store_pool_error(png_store *ps, png_const_structp pp, const char *msg) +{ + if (pp != NULL) + png_error(pp, msg); + + /* Else we have to do it ourselves. png_error eventually calls store_log, + * above. store_log accepts a NULL png_structp - it just changes what gets + * output by store_message. + */ + store_log(ps, pp, msg, 1 /* error */); +} + +static void +store_memory_free(png_const_structp pp, store_pool *pool, store_memory *memory) +{ + /* Note that pp may be NULL (see store_pool_delete below), the caller has + * found 'memory' in pool->list *and* unlinked this entry, so this is a valid + * pointer (for sure), but the contents may have been trashed. + */ + if (memory->pool != pool) + store_pool_error(pool->store, pp, "memory corrupted (pool)"); + + else if (memcmp(memory->mark, pool->mark, sizeof memory->mark) != 0) + store_pool_error(pool->store, pp, "memory corrupted (start)"); + + /* It should be safe to read the size field now. */ + else + { + png_alloc_size_t cb = memory->size; + + if (cb > pool->max) + store_pool_error(pool->store, pp, "memory corrupted (size)"); + + else if (memcmp((png_bytep)(memory+1)+cb, pool->mark, sizeof pool->mark) + != 0) + store_pool_error(pool->store, pp, "memory corrupted (end)"); + + /* Finally give the library a chance to find problems too: */ + else + { + pool->current -= cb; + free(memory); + } + } +} + +static void +store_pool_delete(png_store *ps, store_pool *pool) +{ + if (pool->list != NULL) + { + fprintf(stderr, "%s: %s %s: memory lost (list follows):\n", ps->test, + pool == &ps->read_memory_pool ? "read" : "write", + pool == &ps->read_memory_pool ? (ps->current != NULL ? + ps->current->name : "unknown file") : ps->wname); + ++ps->nerrors; + + do + { + store_memory *next = pool->list; + pool->list = next->next; + next->next = NULL; + + fprintf(stderr, "\t%lu bytes @ %p\n", + (unsigned long)next->size, (const void*)(next+1)); + /* The NULL means this will always return, even if the memory is + * corrupted. + */ + store_memory_free(NULL, pool, next); + } + while (pool->list != NULL); + } + + /* And reset the other fields too for the next time. */ + if (pool->max > pool->max_max) pool->max_max = pool->max; + pool->max = 0; + if (pool->current != 0) /* unexpected internal error */ + fprintf(stderr, "%s: %s %s: memory counter mismatch (internal error)\n", + ps->test, pool == &ps->read_memory_pool ? "read" : "write", + pool == &ps->read_memory_pool ? (ps->current != NULL ? + ps->current->name : "unknown file") : ps->wname); + pool->current = 0; + + if (pool->limit > pool->max_limit) + pool->max_limit = pool->limit; + + pool->limit = 0; + + if (pool->total > pool->max_total) + pool->max_total = pool->total; + + pool->total = 0; + + /* Get a new mark too. */ + store_pool_mark(pool->mark); +} + +/* The memory callbacks: */ +static png_voidp PNGCBAPI +store_malloc(png_structp ppIn, png_alloc_size_t cb) +{ + png_const_structp pp = ppIn; + store_pool *pool = voidcast(store_pool*, png_get_mem_ptr(pp)); + store_memory *new = voidcast(store_memory*, malloc(cb + (sizeof *new) + + (sizeof pool->mark))); + + if (new != NULL) + { + if (cb > pool->max) + pool->max = cb; + + pool->current += cb; + + if (pool->current > pool->limit) + pool->limit = pool->current; + + pool->total += cb; + + new->size = cb; + memcpy(new->mark, pool->mark, sizeof new->mark); + memcpy((png_byte*)(new+1) + cb, pool->mark, sizeof pool->mark); + new->pool = pool; + new->next = pool->list; + pool->list = new; + ++new; + } + + else + { + /* NOTE: the PNG user malloc function cannot use the png_ptr it is passed + * other than to retrieve the allocation pointer! libpng calls the + * store_malloc callback in two basic cases: + * + * 1) From png_malloc; png_malloc will do a png_error itself if NULL is + * returned. + * 2) From png_struct or png_info structure creation; png_malloc is + * to return so cleanup can be performed. + * + * To handle this store_malloc can log a message, but can't do anything + * else. + */ + store_log(pool->store, pp, "out of memory", 1 /* is_error */); + } + + return new; +} + +static void PNGCBAPI +store_free(png_structp ppIn, png_voidp memory) +{ + png_const_structp pp = ppIn; + store_pool *pool = voidcast(store_pool*, png_get_mem_ptr(pp)); + store_memory *this = voidcast(store_memory*, memory), **test; + + /* Because libpng calls store_free with a dummy png_struct when deleting + * png_struct or png_info via png_destroy_struct_2 it is necessary to check + * the passed in png_structp to ensure it is valid, and not pass it to + * png_error if it is not. + */ + if (pp != pool->store->pread && pp != pool->store->pwrite) + pp = NULL; + + /* First check that this 'memory' really is valid memory - it must be in the + * pool list. If it is, use the shared memory_free function to free it. + */ + --this; + for (test = &pool->list; *test != this; test = &(*test)->next) + { + if (*test == NULL) + { + store_pool_error(pool->store, pp, "bad pointer to free"); + return; + } + } + + /* Unlink this entry, *test == this. */ + *test = this->next; + this->next = NULL; + store_memory_free(pp, pool, this); +} +#endif /* PNG_USER_MEM_SUPPORTED */ + +/* Setup functions. */ +/* Cleanup when aborting a write or after storing the new file. */ +static void +store_write_reset(png_store *ps) +{ + if (ps->pwrite != NULL) + { + anon_context(ps); + + Try + png_destroy_write_struct(&ps->pwrite, &ps->piwrite); + + Catch_anonymous + { + /* memory corruption: continue. */ + } + + ps->pwrite = NULL; + ps->piwrite = NULL; + } + + /* And make sure that all the memory has been freed - this will output + * spurious errors in the case of memory corruption above, but this is safe. + */ +# ifdef PNG_USER_MEM_SUPPORTED + store_pool_delete(ps, &ps->write_memory_pool); +# endif + + store_freenew(ps); +} + +/* The following is the main write function, it returns a png_struct and, + * optionally, a png_info suitable for writiing a new PNG file. Use + * store_storefile above to record this file after it has been written. The + * returned libpng structures as destroyed by store_write_reset above. + */ +static png_structp +set_store_for_write(png_store *ps, png_infopp ppi, const char *name) +{ + anon_context(ps); + + Try + { + if (ps->pwrite != NULL) + png_error(ps->pwrite, "write store already in use"); + + store_write_reset(ps); + safecat(ps->wname, sizeof ps->wname, 0, name); + + /* Don't do the slow memory checks if doing a speed test, also if user + * memory is not supported we can't do it anyway. + */ +# ifdef PNG_USER_MEM_SUPPORTED + if (!ps->speed) + ps->pwrite = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, + ps, store_error, store_warning, &ps->write_memory_pool, + store_malloc, store_free); + + else +# endif + ps->pwrite = png_create_write_struct(PNG_LIBPNG_VER_STRING, + ps, store_error, store_warning); + + png_set_write_fn(ps->pwrite, ps, store_write, store_flush); + +# ifdef PNG_SET_OPTION_SUPPORTED + { + int opt; + for (opt=0; optnoptions; ++opt) + if (png_set_option(ps->pwrite, ps->options[opt].option, + ps->options[opt].setting) == PNG_OPTION_INVALID) + png_error(ps->pwrite, "png option invalid"); + } +# endif + + if (ppi != NULL) + *ppi = ps->piwrite = png_create_info_struct(ps->pwrite); + } + + Catch_anonymous + return NULL; + + return ps->pwrite; +} + +/* Cleanup when finished reading (either due to error or in the success case). + * This routine exists even when there is no read support to make the code + * tidier (avoid a mass of ifdefs) and so easier to maintain. + */ +static void +store_read_reset(png_store *ps) +{ +# ifdef PNG_READ_SUPPORTED + if (ps->pread != NULL) + { + anon_context(ps); + + Try + png_destroy_read_struct(&ps->pread, &ps->piread, NULL); + + Catch_anonymous + { + /* error already output: continue */ + } + + ps->pread = NULL; + ps->piread = NULL; + } +# endif + +# ifdef PNG_USER_MEM_SUPPORTED + /* Always do this to be safe. */ + store_pool_delete(ps, &ps->read_memory_pool); +# endif + + ps->current = NULL; + ps->next = NULL; + ps->readpos = 0; + ps->validated = 0; + + ps->chunkpos = 8; + ps->chunktype = 0; + ps->chunklen = 16; + ps->IDAT_size = 0; +} + +#ifdef PNG_READ_SUPPORTED +static void +store_read_set(png_store *ps, png_uint_32 id) +{ + png_store_file *pf = ps->saved; + + while (pf != NULL) + { + if (pf->id == id) + { + ps->current = pf; + ps->next = NULL; + ps->IDAT_size = pf->IDAT_size; + ps->IDAT_bits = pf->IDAT_bits; /* just a cache */ + ps->IDAT_len = 0; + ps->IDAT_pos = 0; + ps->IDAT_crc = 0UL; + store_read_buffer_next(ps); + return; + } + + pf = pf->next; + } + + { + size_t pos; + char msg[FILE_NAME_SIZE+64]; + + pos = standard_name_from_id(msg, sizeof msg, 0, id); + pos = safecat(msg, sizeof msg, pos, ": file not found"); + png_error(ps->pread, msg); + } +} + +/* The main interface for reading a saved file - pass the id number of the file + * to retrieve. Ids must be unique or the earlier file will be hidden. The API + * returns a png_struct and, optionally, a png_info. Both of these will be + * destroyed by store_read_reset above. + */ +static png_structp +set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id, + const char *name) +{ + /* Set the name for png_error */ + safecat(ps->test, sizeof ps->test, 0, name); + + if (ps->pread != NULL) + png_error(ps->pread, "read store already in use"); + + store_read_reset(ps); + + /* Both the create APIs can return NULL if used in their default mode + * (because there is no other way of handling an error because the jmp_buf + * by default is stored in png_struct and that has not been allocated!) + * However, given that store_error works correctly in these circumstances + * we don't ever expect NULL in this program. + */ +# ifdef PNG_USER_MEM_SUPPORTED + if (!ps->speed) + ps->pread = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, ps, + store_error, store_warning, &ps->read_memory_pool, store_malloc, + store_free); + + else +# endif + ps->pread = png_create_read_struct(PNG_LIBPNG_VER_STRING, ps, store_error, + store_warning); + + if (ps->pread == NULL) + { + struct exception_context *the_exception_context = &ps->exception_context; + + store_log(ps, NULL, "png_create_read_struct returned NULL (unexpected)", + 1 /*error*/); + + Throw ps; + } + +# ifdef PNG_SET_OPTION_SUPPORTED + { + int opt; + for (opt=0; optnoptions; ++opt) + if (png_set_option(ps->pread, ps->options[opt].option, + ps->options[opt].setting) == PNG_OPTION_INVALID) + png_error(ps->pread, "png option invalid"); + } +# endif + + store_read_set(ps, id); + + if (ppi != NULL) + *ppi = ps->piread = png_create_info_struct(ps->pread); + + return ps->pread; +} +#endif /* PNG_READ_SUPPORTED */ + +/* The overall cleanup of a store simply calls the above then removes all the + * saved files. This does not delete the store itself. + */ +static void +store_delete(png_store *ps) +{ + store_write_reset(ps); + store_read_reset(ps); + store_freefile(&ps->saved); + store_image_free(ps, NULL); +} + +/*********************** PNG FILE MODIFICATION ON READ ************************/ +/* Files may be modified on read. The following structure contains a complete + * png_store together with extra members to handle modification and a special + * read callback for libpng. To use this the 'modifications' field must be set + * to a list of png_modification structures that actually perform the + * modification, otherwise a png_modifier is functionally equivalent to a + * png_store. There is a special read function, set_modifier_for_read, which + * replaces set_store_for_read. + */ +typedef enum modifier_state +{ + modifier_start, /* Initial value */ + modifier_signature, /* Have a signature */ + modifier_IHDR /* Have an IHDR */ +} modifier_state; + +typedef struct CIE_color +{ + /* A single CIE tristimulus value, representing the unique response of a + * standard observer to a variety of light spectra. The observer recognizes + * all spectra that produce this response as the same color, therefore this + * is effectively a description of a color. + */ + double X, Y, Z; +} CIE_color; + +typedef struct color_encoding +{ + /* A description of an (R,G,B) encoding of color (as defined above); this + * includes the actual colors of the (R,G,B) triples (1,0,0), (0,1,0) and + * (0,0,1) plus an encoding value that is used to encode the linear + * components R, G and B to give the actual values R^gamma, G^gamma and + * B^gamma that are stored. + */ + double gamma; /* Encoding (file) gamma of space */ + CIE_color red, green, blue; /* End points */ +} color_encoding; + +#ifdef PNG_READ_SUPPORTED +#if defined PNG_READ_TRANSFORMS_SUPPORTED && defined PNG_READ_cHRM_SUPPORTED +static double +chromaticity_x(CIE_color c) +{ + return c.X / (c.X + c.Y + c.Z); +} + +static double +chromaticity_y(CIE_color c) +{ + return c.Y / (c.X + c.Y + c.Z); +} + +static CIE_color +white_point(const color_encoding *encoding) +{ + CIE_color white; + + white.X = encoding->red.X + encoding->green.X + encoding->blue.X; + white.Y = encoding->red.Y + encoding->green.Y + encoding->blue.Y; + white.Z = encoding->red.Z + encoding->green.Z + encoding->blue.Z; + + return white; +} +#endif /* READ_TRANSFORMS && READ_cHRM */ + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +static void +normalize_color_encoding(color_encoding *encoding) +{ + const double whiteY = encoding->red.Y + encoding->green.Y + + encoding->blue.Y; + + if (whiteY != 1) + { + encoding->red.X /= whiteY; + encoding->red.Y /= whiteY; + encoding->red.Z /= whiteY; + encoding->green.X /= whiteY; + encoding->green.Y /= whiteY; + encoding->green.Z /= whiteY; + encoding->blue.X /= whiteY; + encoding->blue.Y /= whiteY; + encoding->blue.Z /= whiteY; + } +} +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +static size_t +safecat_color_encoding(char *buffer, size_t bufsize, size_t pos, + const color_encoding *e, double encoding_gamma) +{ + if (e != 0) + { + if (encoding_gamma != 0) + pos = safecat(buffer, bufsize, pos, "("); + pos = safecat(buffer, bufsize, pos, "R("); + pos = safecatd(buffer, bufsize, pos, e->red.X, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->red.Y, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->red.Z, 4); + pos = safecat(buffer, bufsize, pos, "),G("); + pos = safecatd(buffer, bufsize, pos, e->green.X, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->green.Y, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->green.Z, 4); + pos = safecat(buffer, bufsize, pos, "),B("); + pos = safecatd(buffer, bufsize, pos, e->blue.X, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->blue.Y, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->blue.Z, 4); + pos = safecat(buffer, bufsize, pos, ")"); + if (encoding_gamma != 0) + pos = safecat(buffer, bufsize, pos, ")"); + } + + if (encoding_gamma != 0) + { + pos = safecat(buffer, bufsize, pos, "^"); + pos = safecatd(buffer, bufsize, pos, encoding_gamma, 5); + } + + return pos; +} +#endif /* READ_TRANSFORMS */ +#endif /* PNG_READ_SUPPORTED */ + +typedef struct png_modifier +{ + png_store this; /* I am a png_store */ + struct png_modification *modifications; /* Changes to make */ + + modifier_state state; /* My state */ + + /* Information from IHDR: */ + png_byte bit_depth; /* From IHDR */ + png_byte colour_type; /* From IHDR */ + + /* While handling PLTE, IDAT and IEND these chunks may be pended to allow + * other chunks to be inserted. + */ + png_uint_32 pending_len; + png_uint_32 pending_chunk; + + /* Test values */ + double *gammas; + unsigned int ngammas; + unsigned int ngamma_tests; /* Number of gamma tests to run*/ + double current_gamma; /* 0 if not set */ + const color_encoding *encodings; + unsigned int nencodings; + const color_encoding *current_encoding; /* If an encoding has been set */ + unsigned int encoding_counter; /* For iteration */ + int encoding_ignored; /* Something overwrote it */ + + /* Control variables used to iterate through possible encodings, the + * following must be set to 0 and tested by the function that uses the + * png_modifier because the modifier only sets it to 1 (true.) + */ + unsigned int repeat :1; /* Repeat this transform test. */ + unsigned int test_uses_encoding :1; + + /* Lowest sbit to test (pre-1.7 libpng fails for sbit < 8) */ + png_byte sbitlow; + + /* Error control - these are the limits on errors accepted by the gamma tests + * below. + */ + double maxout8; /* Maximum output value error */ + double maxabs8; /* Absolute sample error 0..1 */ + double maxcalc8; /* Absolute sample error 0..1 */ + double maxpc8; /* Percentage sample error 0..100% */ + double maxout16; /* Maximum output value error */ + double maxabs16; /* Absolute sample error 0..1 */ + double maxcalc16;/* Absolute sample error 0..1 */ + double maxcalcG; /* Absolute sample error 0..1 */ + double maxpc16; /* Percentage sample error 0..100% */ + + /* This is set by transforms that need to allow a higher limit, it is an + * internal check on pngvalid to ensure that the calculated error limits are + * not ridiculous; without this it is too easy to make a mistake in pngvalid + * that allows any value through. + * + * NOTE: this is not checked in release builds. + */ + double limit; /* limit on error values, normally 4E-3 */ + + /* Log limits - values above this are logged, but not necessarily + * warned. + */ + double log8; /* Absolute error in 8 bits to log */ + double log16; /* Absolute error in 16 bits to log */ + + /* Logged 8 and 16 bit errors ('output' values): */ + double error_gray_2; + double error_gray_4; + double error_gray_8; + double error_gray_16; + double error_color_8; + double error_color_16; + double error_indexed; + + /* Flags: */ + /* Whether to call png_read_update_info, not png_read_start_image, and how + * many times to call it. + */ + int use_update_info; + + /* Whether or not to interlace. */ + int interlace_type :9; /* int, but must store '1' */ + + /* Run the standard tests? */ + unsigned int test_standard :1; + + /* Run the odd-sized image and interlace read/write tests? */ + unsigned int test_size :1; + + /* Run tests on reading with a combination of transforms, */ + unsigned int test_transform :1; + unsigned int test_tRNS :1; /* Includes tRNS images */ + + /* When to use the use_input_precision option, this controls the gamma + * validation code checks. If set any value that is within the transformed + * range input-.5 to input+.5 will be accepted, otherwise the value must be + * within the normal limits. It should not be necessary to set this; the + * result should always be exact within the permitted error limits. + */ + unsigned int use_input_precision :1; + unsigned int use_input_precision_sbit :1; + unsigned int use_input_precision_16to8 :1; + + /* If set assume that the calculation bit depth is set by the input + * precision, not the output precision. + */ + unsigned int calculations_use_input_precision :1; + + /* If set assume that the calculations are done in 16 bits even if the sample + * depth is 8 bits. + */ + unsigned int assume_16_bit_calculations :1; + + /* Which gamma tests to run: */ + unsigned int test_gamma_threshold :1; + unsigned int test_gamma_transform :1; /* main tests */ + unsigned int test_gamma_sbit :1; + unsigned int test_gamma_scale16 :1; + unsigned int test_gamma_background :1; + unsigned int test_gamma_alpha_mode :1; + unsigned int test_gamma_expand16 :1; + unsigned int test_exhaustive :1; + + /* Whether or not to run the low-bit-depth grayscale tests. This fails on + * gamma images in some cases because of gross inaccuracies in the grayscale + * gamma handling for low bit depth. + */ + unsigned int test_lbg :1; + unsigned int test_lbg_gamma_threshold :1; + unsigned int test_lbg_gamma_transform :1; + unsigned int test_lbg_gamma_sbit :1; + unsigned int test_lbg_gamma_composition :1; + + unsigned int log :1; /* Log max error */ + + /* Buffer information, the buffer size limits the size of the chunks that can + * be modified - they must fit (including header and CRC) into the buffer! + */ + size_t flush; /* Count of bytes to flush */ + size_t buffer_count; /* Bytes in buffer */ + size_t buffer_position; /* Position in buffer */ + png_byte buffer[1024]; +} png_modifier; + +/* This returns true if the test should be stopped now because it has already + * failed and it is running silently. + */ +static int fail(png_modifier *pm) +{ + return !pm->log && !pm->this.verbose && (pm->this.nerrors > 0 || + (pm->this.treat_warnings_as_errors && pm->this.nwarnings > 0)); +} + +static void +modifier_init(png_modifier *pm) +{ + memset(pm, 0, sizeof *pm); + store_init(&pm->this); + pm->modifications = NULL; + pm->state = modifier_start; + pm->sbitlow = 1U; + pm->ngammas = 0; + pm->ngamma_tests = 0; + pm->gammas = 0; + pm->current_gamma = 0; + pm->encodings = 0; + pm->nencodings = 0; + pm->current_encoding = 0; + pm->encoding_counter = 0; + pm->encoding_ignored = 0; + pm->repeat = 0; + pm->test_uses_encoding = 0; + pm->maxout8 = pm->maxpc8 = pm->maxabs8 = pm->maxcalc8 = 0; + pm->maxout16 = pm->maxpc16 = pm->maxabs16 = pm->maxcalc16 = 0; + pm->maxcalcG = 0; + pm->limit = 4E-3; + pm->log8 = pm->log16 = 0; /* Means 'off' */ + pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = 0; + pm->error_gray_16 = pm->error_color_8 = pm->error_color_16 = 0; + pm->error_indexed = 0; + pm->use_update_info = 0; + pm->interlace_type = PNG_INTERLACE_NONE; + pm->test_standard = 0; + pm->test_size = 0; + pm->test_transform = 0; +# ifdef PNG_WRITE_tRNS_SUPPORTED + pm->test_tRNS = 1; +# else + pm->test_tRNS = 0; +# endif + pm->use_input_precision = 0; + pm->use_input_precision_sbit = 0; + pm->use_input_precision_16to8 = 0; + pm->calculations_use_input_precision = 0; + pm->assume_16_bit_calculations = 0; + pm->test_gamma_threshold = 0; + pm->test_gamma_transform = 0; + pm->test_gamma_sbit = 0; + pm->test_gamma_scale16 = 0; + pm->test_gamma_background = 0; + pm->test_gamma_alpha_mode = 0; + pm->test_gamma_expand16 = 0; + pm->test_lbg = 1; + pm->test_lbg_gamma_threshold = 1; + pm->test_lbg_gamma_transform = 1; + pm->test_lbg_gamma_sbit = 1; + pm->test_lbg_gamma_composition = 1; + pm->test_exhaustive = 0; + pm->log = 0; + + /* Rely on the memset for all the other fields - there are no pointers */ +} + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED + +/* This controls use of checks that explicitly know how libpng digitizes the + * samples in calculations; setting this circumvents simple error limit checking + * in the rgb_to_gray check, replacing it with an exact copy of the libpng 1.5 + * algorithm. + */ +#define DIGITIZE PNG_LIBPNG_VER < 10700 + +/* If pm->calculations_use_input_precision is set then operations will happen + * with the precision of the input, not the precision of the output depth. + * + * If pm->assume_16_bit_calculations is set then even 8 bit calculations use 16 + * bit precision. This only affects those of the following limits that pertain + * to a calculation - not a digitization operation - unless the following API is + * called directly. + */ +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +#if DIGITIZE +static double digitize(double value, int depth, int do_round) +{ + /* 'value' is in the range 0 to 1, the result is the same value rounded to a + * multiple of the digitization factor - 8 or 16 bits depending on both the + * sample depth and the 'assume' setting. Digitization is normally by + * rounding and 'do_round' should be 1, if it is 0 the digitized value will + * be truncated. + */ + unsigned int digitization_factor = (1U << depth) - 1; + + /* Limiting the range is done as a convenience to the caller - it's easier to + * do it once here than every time at the call site. + */ + if (value <= 0) + value = 0; + + else if (value >= 1) + value = 1; + + value *= digitization_factor; + if (do_round) value += .5; + return floor(value)/digitization_factor; +} +#endif +#endif /* RGB_TO_GRAY */ + +#ifdef PNG_READ_GAMMA_SUPPORTED +static double abserr(const png_modifier *pm, int in_depth, int out_depth) +{ + /* Absolute error permitted in linear values - affected by the bit depth of + * the calculations. + */ + if (pm->assume_16_bit_calculations || + (pm->calculations_use_input_precision ? in_depth : out_depth) == 16) + return pm->maxabs16; + else + return pm->maxabs8; +} + +static double calcerr(const png_modifier *pm, int in_depth, int out_depth) +{ + /* Error in the linear composition arithmetic - only relevant when + * composition actually happens (0 < alpha < 1). + */ + if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16) + return pm->maxcalc16; + else if (pm->assume_16_bit_calculations) + return pm->maxcalcG; + else + return pm->maxcalc8; +} + +static double pcerr(const png_modifier *pm, int in_depth, int out_depth) +{ + /* Percentage error permitted in the linear values. Note that the specified + * value is a percentage but this routine returns a simple number. + */ + if (pm->assume_16_bit_calculations || + (pm->calculations_use_input_precision ? in_depth : out_depth) == 16) + return pm->maxpc16 * .01; + else + return pm->maxpc8 * .01; +} + +/* Output error - the error in the encoded value. This is determined by the + * digitization of the output so can be +/-0.5 in the actual output value. In + * the expand_16 case with the current code in libpng the expand happens after + * all the calculations are done in 8 bit arithmetic, so even though the output + * depth is 16 the output error is determined by the 8 bit calculation. + * + * This limit is not determined by the bit depth of internal calculations. + * + * The specified parameter does *not* include the base .5 digitization error but + * it is added here. + */ +static double outerr(const png_modifier *pm, int in_depth, int out_depth) +{ + /* There is a serious error in the 2 and 4 bit grayscale transform because + * the gamma table value (8 bits) is simply shifted, not rounded, so the + * error in 4 bit grayscale gamma is up to the value below. This is a hack + * to allow pngvalid to succeed: + * + * TODO: fix this in libpng + */ + if (out_depth == 2) + return .73182-.5; + + if (out_depth == 4) + return .90644-.5; + + if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16) + return pm->maxout16; + + /* This is the case where the value was calculated at 8-bit precision then + * scaled to 16 bits. + */ + else if (out_depth == 16) + return pm->maxout8 * 257; + + else + return pm->maxout8; +} + +/* This does the same thing as the above however it returns the value to log, + * rather than raising a warning. This is useful for debugging to track down + * exactly what set of parameters cause high error values. + */ +static double outlog(const png_modifier *pm, int in_depth, int out_depth) +{ + /* The command line parameters are either 8 bit (0..255) or 16 bit (0..65535) + * and so must be adjusted for low bit depth grayscale: + */ + if (out_depth <= 8) + { + if (pm->log8 == 0) /* switched off */ + return 256; + + if (out_depth < 8) + return pm->log8 / 255 * ((1<log8; + } + + if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16) + { + if (pm->log16 == 0) + return 65536; + + return pm->log16; + } + + /* This is the case where the value was calculated at 8-bit precision then + * scaled to 16 bits. + */ + if (pm->log8 == 0) + return 65536; + + return pm->log8 * 257; +} + +/* This complements the above by providing the appropriate quantization for the + * final value. Normally this would just be quantization to an integral value, + * but in the 8 bit calculation case it's actually quantization to a multiple of + * 257! + */ +static int output_quantization_factor(const png_modifier *pm, int in_depth, + int out_depth) +{ + if (out_depth == 16 && in_depth != 16 && + pm->calculations_use_input_precision) + return 257; + else + return 1; +} +#endif /* PNG_READ_GAMMA_SUPPORTED */ + +/* One modification structure must be provided for each chunk to be modified (in + * fact more than one can be provided if multiple separate changes are desired + * for a single chunk.) Modifications include adding a new chunk when a + * suitable chunk does not exist. + * + * The caller of modify_fn will reset the CRC of the chunk and record 'modified' + * or 'added' as appropriate if the modify_fn returns 1 (true). If the + * modify_fn is NULL the chunk is simply removed. + */ +typedef struct png_modification +{ + struct png_modification *next; + png_uint_32 chunk; + + /* If the following is NULL all matching chunks will be removed: */ + int (*modify_fn)(struct png_modifier *pm, + struct png_modification *me, int add); + + /* If the following is set to PLTE, IDAT or IEND and the chunk has not been + * found and modified (and there is a modify_fn) the modify_fn will be called + * to add the chunk before the relevant chunk. + */ + png_uint_32 add; + unsigned int modified :1; /* Chunk was modified */ + unsigned int added :1; /* Chunk was added */ + unsigned int removed :1; /* Chunk was removed */ +} png_modification; + +static void +modification_reset(png_modification *pmm) +{ + if (pmm != NULL) + { + pmm->modified = 0; + pmm->added = 0; + pmm->removed = 0; + modification_reset(pmm->next); + } +} + +static void +modification_init(png_modification *pmm) +{ + memset(pmm, 0, sizeof *pmm); + pmm->next = NULL; + pmm->chunk = 0; + pmm->modify_fn = NULL; + pmm->add = 0; + modification_reset(pmm); +} + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +static void +modifier_current_encoding(const png_modifier *pm, color_encoding *ce) +{ + if (pm->current_encoding != 0) + *ce = *pm->current_encoding; + + else + memset(ce, 0, sizeof *ce); + + ce->gamma = pm->current_gamma; +} +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +static size_t +safecat_current_encoding(char *buffer, size_t bufsize, size_t pos, + const png_modifier *pm) +{ + pos = safecat_color_encoding(buffer, bufsize, pos, pm->current_encoding, + pm->current_gamma); + + if (pm->encoding_ignored) + pos = safecat(buffer, bufsize, pos, "[overridden]"); + + return pos; +} +#endif + +/* Iterate through the usefully testable color encodings. An encoding is one + * of: + * + * 1) Nothing (no color space, no gamma). + * 2) Just a gamma value from the gamma array (including 1.0) + * 3) A color space from the encodings array with the corresponding gamma. + * 4) The same, but with gamma 1.0 (only really useful with 16 bit calculations) + * + * The iterator selects these in turn, the randomizer selects one at random, + * which is used depends on the setting of the 'test_exhaustive' flag. Notice + * that this function changes the colour space encoding so it must only be + * called on completion of the previous test. This is what 'modifier_reset' + * does, below. + * + * After the function has been called the 'repeat' flag will still be set; the + * caller of modifier_reset must reset it at the start of each run of the test! + */ +static unsigned int +modifier_total_encodings(const png_modifier *pm) +{ + return 1 + /* (1) nothing */ + pm->ngammas + /* (2) gamma values to test */ + pm->nencodings + /* (3) total number of encodings */ + /* The following test only works after the first time through the + * png_modifier code because 'bit_depth' is set when the IHDR is read. + * modifier_reset, below, preserves the setting until after it has called + * the iterate function (also below.) + * + * For this reason do not rely on this function outside a call to + * modifier_reset. + */ + ((pm->bit_depth == 16 || pm->assume_16_bit_calculations) ? + pm->nencodings : 0); /* (4) encodings with gamma == 1.0 */ +} + +static void +modifier_encoding_iterate(png_modifier *pm) +{ + if (!pm->repeat && /* Else something needs the current encoding again. */ + pm->test_uses_encoding) /* Some transform is encoding dependent */ + { + if (pm->test_exhaustive) + { + if (++pm->encoding_counter >= modifier_total_encodings(pm)) + pm->encoding_counter = 0; /* This will stop the repeat */ + } + + else + { + /* Not exhaustive - choose an encoding at random; generate a number in + * the range 1..(max-1), so the result is always non-zero: + */ + if (pm->encoding_counter == 0) + pm->encoding_counter = random_mod(modifier_total_encodings(pm)-1)+1; + else + pm->encoding_counter = 0; + } + + if (pm->encoding_counter > 0) + pm->repeat = 1; + } + + else if (!pm->repeat) + pm->encoding_counter = 0; +} + +static void +modifier_reset(png_modifier *pm) +{ + store_read_reset(&pm->this); + pm->limit = 4E-3; + pm->pending_len = pm->pending_chunk = 0; + pm->flush = pm->buffer_count = pm->buffer_position = 0; + pm->modifications = NULL; + pm->state = modifier_start; + modifier_encoding_iterate(pm); + /* The following must be set in the next run. In particular + * test_uses_encodings must be set in the _ini function of each transform + * that looks at the encodings. (Not the 'add' function!) + */ + pm->test_uses_encoding = 0; + pm->current_gamma = 0; + pm->current_encoding = 0; + pm->encoding_ignored = 0; + /* These only become value after IHDR is read: */ + pm->bit_depth = pm->colour_type = 0; +} + +/* The following must be called before anything else to get the encoding set up + * on the modifier. In particular it must be called before the transform init + * functions are called. + */ +static void +modifier_set_encoding(png_modifier *pm) +{ + /* Set the encoding to the one specified by the current encoding counter, + * first clear out all the settings - this corresponds to an encoding_counter + * of 0. + */ + pm->current_gamma = 0; + pm->current_encoding = 0; + pm->encoding_ignored = 0; /* not ignored yet - happens in _ini functions. */ + + /* Now, if required, set the gamma and encoding fields. */ + if (pm->encoding_counter > 0) + { + /* The gammas[] array is an array of screen gammas, not encoding gammas, + * so we need the inverse: + */ + if (pm->encoding_counter <= pm->ngammas) + pm->current_gamma = 1/pm->gammas[pm->encoding_counter-1]; + + else + { + unsigned int i = pm->encoding_counter - pm->ngammas; + + if (i >= pm->nencodings) + { + i %= pm->nencodings; + pm->current_gamma = 1; /* Linear, only in the 16 bit case */ + } + + else + pm->current_gamma = pm->encodings[i].gamma; + + pm->current_encoding = pm->encodings + i; + } + } +} + +/* Enquiry functions to find out what is set. Notice that there is an implicit + * assumption below that the first encoding in the list is the one for sRGB. + */ +static int +modifier_color_encoding_is_sRGB(const png_modifier *pm) +{ + return pm->current_encoding != 0 && pm->current_encoding == pm->encodings && + pm->current_encoding->gamma == pm->current_gamma; +} + +static int +modifier_color_encoding_is_set(const png_modifier *pm) +{ + return pm->current_gamma != 0; +} + +/* The guts of modification are performed during a read. */ +static void +modifier_crc(png_bytep buffer) +{ + /* Recalculate the chunk CRC - a complete chunk must be in + * the buffer, at the start. + */ + uInt datalen = png_get_uint_32(buffer); + uLong crc = crc32(0, buffer+4, datalen+4); + /* The cast to png_uint_32 is safe because a crc32 is always a 32 bit value. + */ + png_save_uint_32(buffer+datalen+8, (png_uint_32)crc); +} + +static void +modifier_setbuffer(png_modifier *pm) +{ + modifier_crc(pm->buffer); + pm->buffer_count = png_get_uint_32(pm->buffer)+12; + pm->buffer_position = 0; +} + +/* Separate the callback into the actual implementation (which is passed the + * png_modifier explicitly) and the callback, which gets the modifier from the + * png_struct. + */ +static void +modifier_read_imp(png_modifier *pm, png_bytep pb, size_t st) +{ + while (st > 0) + { + size_t cb; + png_uint_32 len, chunk; + png_modification *mod; + + if (pm->buffer_position >= pm->buffer_count) switch (pm->state) + { + static png_byte sign[8] = { 137, 80, 78, 71, 13, 10, 26, 10 }; + case modifier_start: + store_read_chunk(&pm->this, pm->buffer, 8, 8); /* signature. */ + pm->buffer_count = 8; + pm->buffer_position = 0; + + if (memcmp(pm->buffer, sign, 8) != 0) + png_error(pm->this.pread, "invalid PNG file signature"); + pm->state = modifier_signature; + break; + + case modifier_signature: + store_read_chunk(&pm->this, pm->buffer, 13+12, 13+12); /* IHDR */ + pm->buffer_count = 13+12; + pm->buffer_position = 0; + + if (png_get_uint_32(pm->buffer) != 13 || + png_get_uint_32(pm->buffer+4) != CHUNK_IHDR) + png_error(pm->this.pread, "invalid IHDR"); + + /* Check the list of modifiers for modifications to the IHDR. */ + mod = pm->modifications; + while (mod != NULL) + { + if (mod->chunk == CHUNK_IHDR && mod->modify_fn && + (*mod->modify_fn)(pm, mod, 0)) + { + mod->modified = 1; + modifier_setbuffer(pm); + } + + /* Ignore removal or add if IHDR! */ + mod = mod->next; + } + + /* Cache information from the IHDR (the modified one.) */ + pm->bit_depth = pm->buffer[8+8]; + pm->colour_type = pm->buffer[8+8+1]; + + pm->state = modifier_IHDR; + pm->flush = 0; + break; + + case modifier_IHDR: + default: + /* Read a new chunk and process it until we see PLTE, IDAT or + * IEND. 'flush' indicates that there is still some data to + * output from the preceding chunk. + */ + if ((cb = pm->flush) > 0) + { + if (cb > st) cb = st; + pm->flush -= cb; + store_read_chunk(&pm->this, pb, cb, cb); + pb += cb; + st -= cb; + if (st == 0) return; + } + + /* No more bytes to flush, read a header, or handle a pending + * chunk. + */ + if (pm->pending_chunk != 0) + { + png_save_uint_32(pm->buffer, pm->pending_len); + png_save_uint_32(pm->buffer+4, pm->pending_chunk); + pm->pending_len = 0; + pm->pending_chunk = 0; + } + else + store_read_chunk(&pm->this, pm->buffer, 8, 8); + + pm->buffer_count = 8; + pm->buffer_position = 0; + + /* Check for something to modify or a terminator chunk. */ + len = png_get_uint_32(pm->buffer); + chunk = png_get_uint_32(pm->buffer+4); + + /* Terminators first, they may have to be delayed for added + * chunks + */ + if (chunk == CHUNK_PLTE || chunk == CHUNK_IDAT || + chunk == CHUNK_IEND) + { + mod = pm->modifications; + + while (mod != NULL) + { + if ((mod->add == chunk || + (mod->add == CHUNK_PLTE && chunk == CHUNK_IDAT)) && + mod->modify_fn != NULL && !mod->modified && !mod->added) + { + /* Regardless of what the modify function does do not run + * this again. + */ + mod->added = 1; + + if ((*mod->modify_fn)(pm, mod, 1 /*add*/)) + { + /* Reset the CRC on a new chunk */ + if (pm->buffer_count > 0) + modifier_setbuffer(pm); + + else + { + pm->buffer_position = 0; + mod->removed = 1; + } + + /* The buffer has been filled with something (we assume) + * so output this. Pend the current chunk. + */ + pm->pending_len = len; + pm->pending_chunk = chunk; + break; /* out of while */ + } + } + + mod = mod->next; + } + + /* Don't do any further processing if the buffer was modified - + * otherwise the code will end up modifying a chunk that was + * just added. + */ + if (mod != NULL) + break; /* out of switch */ + } + + /* If we get to here then this chunk may need to be modified. To + * do this it must be less than 1024 bytes in total size, otherwise + * it just gets flushed. + */ + if (len+12 <= sizeof pm->buffer) + { + size_t s = len+12-pm->buffer_count; + store_read_chunk(&pm->this, pm->buffer+pm->buffer_count, s, s); + pm->buffer_count = len+12; + + /* Check for a modification, else leave it be. */ + mod = pm->modifications; + while (mod != NULL) + { + if (mod->chunk == chunk) + { + if (mod->modify_fn == NULL) + { + /* Remove this chunk */ + pm->buffer_count = pm->buffer_position = 0; + mod->removed = 1; + break; /* Terminate the while loop */ + } + + else if ((*mod->modify_fn)(pm, mod, 0)) + { + mod->modified = 1; + /* The chunk may have been removed: */ + if (pm->buffer_count == 0) + { + pm->buffer_position = 0; + break; + } + modifier_setbuffer(pm); + } + } + + mod = mod->next; + } + } + + else + pm->flush = len+12 - pm->buffer_count; /* data + crc */ + + /* Take the data from the buffer (if there is any). */ + break; + } + + /* Here to read from the modifier buffer (not directly from + * the store, as in the flush case above.) + */ + cb = pm->buffer_count - pm->buffer_position; + + if (cb > st) + cb = st; + + memcpy(pb, pm->buffer + pm->buffer_position, cb); + st -= cb; + pb += cb; + pm->buffer_position += cb; + } +} + +/* The callback: */ +static void PNGCBAPI +modifier_read(png_structp ppIn, png_bytep pb, size_t st) +{ + png_const_structp pp = ppIn; + png_modifier *pm = voidcast(png_modifier*, png_get_io_ptr(pp)); + + if (pm == NULL || pm->this.pread != pp) + png_error(pp, "bad modifier_read call"); + + modifier_read_imp(pm, pb, st); +} + +/* Like store_progressive_read but the data is getting changed as we go so we + * need a local buffer. + */ +static void +modifier_progressive_read(png_modifier *pm, png_structp pp, png_infop pi) +{ + if (pm->this.pread != pp || pm->this.current == NULL || + pm->this.next == NULL) + png_error(pp, "store state damaged (progressive)"); + + /* This is another Horowitz and Hill random noise generator. In this case + * the aim is to stress the progressive reader with truly horrible variable + * buffer sizes in the range 1..500, so a sequence of 9 bit random numbers + * is generated. We could probably just count from 1 to 32767 and get as + * good a result. + */ + for (;;) + { + static png_uint_32 noise = 1; + size_t cb, cbAvail; + png_byte buffer[512]; + + /* Generate 15 more bits of stuff: */ + noise = (noise << 9) | ((noise ^ (noise >> (9-5))) & 0x1ff); + cb = noise & 0x1ff; + + /* Check that this number of bytes are available (in the current buffer.) + * (This doesn't quite work - the modifier might delete a chunk; unlikely + * but possible, it doesn't happen at present because the modifier only + * adds chunks to standard images.) + */ + cbAvail = store_read_buffer_avail(&pm->this); + if (pm->buffer_count > pm->buffer_position) + cbAvail += pm->buffer_count - pm->buffer_position; + + if (cb > cbAvail) + { + /* Check for EOF: */ + if (cbAvail == 0) + break; + + cb = cbAvail; + } + + modifier_read_imp(pm, buffer, cb); + png_process_data(pp, pi, buffer, cb); + } + + /* Check the invariants at the end (if this fails it's a problem in this + * file!) + */ + if (pm->buffer_count > pm->buffer_position || + pm->this.next != &pm->this.current->data || + pm->this.readpos < pm->this.current->datacount) + png_error(pp, "progressive read implementation error"); +} + +/* Set up a modifier. */ +static png_structp +set_modifier_for_read(png_modifier *pm, png_infopp ppi, png_uint_32 id, + const char *name) +{ + /* Do this first so that the modifier fields are cleared even if an error + * happens allocating the png_struct. No allocation is done here so no + * cleanup is required. + */ + pm->state = modifier_start; + pm->bit_depth = 0; + pm->colour_type = 255; + + pm->pending_len = 0; + pm->pending_chunk = 0; + pm->flush = 0; + pm->buffer_count = 0; + pm->buffer_position = 0; + + return set_store_for_read(&pm->this, ppi, id, name); +} + + +/******************************** MODIFICATIONS *******************************/ +/* Standard modifications to add chunks. These do not require the _SUPPORTED + * macros because the chunks can be there regardless of whether this specific + * libpng supports them. + */ +typedef struct gama_modification +{ + png_modification this; + png_fixed_point gamma; +} gama_modification; + +static int +gama_modify(png_modifier *pm, png_modification *me, int add) +{ + UNUSED(add) + /* This simply dumps the given gamma value into the buffer. */ + png_save_uint_32(pm->buffer, 4); + png_save_uint_32(pm->buffer+4, CHUNK_gAMA); + png_save_uint_32(pm->buffer+8, ((gama_modification*)me)->gamma); + return 1; +} + +static void +gama_modification_init(gama_modification *me, png_modifier *pm, double gammad) +{ + double g; + + modification_init(&me->this); + me->this.chunk = CHUNK_gAMA; + me->this.modify_fn = gama_modify; + me->this.add = CHUNK_PLTE; + g = fix(gammad); + me->gamma = (png_fixed_point)g; + me->this.next = pm->modifications; + pm->modifications = &me->this; +} + +typedef struct chrm_modification +{ + png_modification this; + const color_encoding *encoding; + png_fixed_point wx, wy, rx, ry, gx, gy, bx, by; +} chrm_modification; + +static int +chrm_modify(png_modifier *pm, png_modification *me, int add) +{ + UNUSED(add) + /* As with gAMA this just adds the required cHRM chunk to the buffer. */ + png_save_uint_32(pm->buffer , 32); + png_save_uint_32(pm->buffer+ 4, CHUNK_cHRM); + png_save_uint_32(pm->buffer+ 8, ((chrm_modification*)me)->wx); + png_save_uint_32(pm->buffer+12, ((chrm_modification*)me)->wy); + png_save_uint_32(pm->buffer+16, ((chrm_modification*)me)->rx); + png_save_uint_32(pm->buffer+20, ((chrm_modification*)me)->ry); + png_save_uint_32(pm->buffer+24, ((chrm_modification*)me)->gx); + png_save_uint_32(pm->buffer+28, ((chrm_modification*)me)->gy); + png_save_uint_32(pm->buffer+32, ((chrm_modification*)me)->bx); + png_save_uint_32(pm->buffer+36, ((chrm_modification*)me)->by); + return 1; +} + +static void +chrm_modification_init(chrm_modification *me, png_modifier *pm, + const color_encoding *encoding) +{ + CIE_color white = white_point(encoding); + + /* Original end points: */ + me->encoding = encoding; + + /* Chromaticities (in fixed point): */ + me->wx = fix(chromaticity_x(white)); + me->wy = fix(chromaticity_y(white)); + + me->rx = fix(chromaticity_x(encoding->red)); + me->ry = fix(chromaticity_y(encoding->red)); + me->gx = fix(chromaticity_x(encoding->green)); + me->gy = fix(chromaticity_y(encoding->green)); + me->bx = fix(chromaticity_x(encoding->blue)); + me->by = fix(chromaticity_y(encoding->blue)); + + modification_init(&me->this); + me->this.chunk = CHUNK_cHRM; + me->this.modify_fn = chrm_modify; + me->this.add = CHUNK_PLTE; + me->this.next = pm->modifications; + pm->modifications = &me->this; +} + +typedef struct srgb_modification +{ + png_modification this; + png_byte intent; +} srgb_modification; + +static int +srgb_modify(png_modifier *pm, png_modification *me, int add) +{ + UNUSED(add) + /* As above, ignore add and just make a new chunk */ + png_save_uint_32(pm->buffer, 1); + png_save_uint_32(pm->buffer+4, CHUNK_sRGB); + pm->buffer[8] = ((srgb_modification*)me)->intent; + return 1; +} + +static void +srgb_modification_init(srgb_modification *me, png_modifier *pm, png_byte intent) +{ + modification_init(&me->this); + me->this.chunk = CHUNK_sBIT; + + if (intent <= 3) /* if valid, else *delete* sRGB chunks */ + { + me->this.modify_fn = srgb_modify; + me->this.add = CHUNK_PLTE; + me->intent = intent; + } + + else + { + me->this.modify_fn = 0; + me->this.add = 0; + me->intent = 0; + } + + me->this.next = pm->modifications; + pm->modifications = &me->this; +} + +#ifdef PNG_READ_GAMMA_SUPPORTED +typedef struct sbit_modification +{ + png_modification this; + png_byte sbit; +} sbit_modification; + +static int +sbit_modify(png_modifier *pm, png_modification *me, int add) +{ + png_byte sbit = ((sbit_modification*)me)->sbit; + if (pm->bit_depth > sbit) + { + int cb = 0; + switch (pm->colour_type) + { + case 0: + cb = 1; + break; + + case 2: + case 3: + cb = 3; + break; + + case 4: + cb = 2; + break; + + case 6: + cb = 4; + break; + + default: + png_error(pm->this.pread, + "unexpected colour type in sBIT modification"); + } + + png_save_uint_32(pm->buffer, cb); + png_save_uint_32(pm->buffer+4, CHUNK_sBIT); + + while (cb > 0) + (pm->buffer+8)[--cb] = sbit; + + return 1; + } + else if (!add) + { + /* Remove the sBIT chunk */ + pm->buffer_count = pm->buffer_position = 0; + return 1; + } + else + return 0; /* do nothing */ +} + +static void +sbit_modification_init(sbit_modification *me, png_modifier *pm, png_byte sbit) +{ + modification_init(&me->this); + me->this.chunk = CHUNK_sBIT; + me->this.modify_fn = sbit_modify; + me->this.add = CHUNK_PLTE; + me->sbit = sbit; + me->this.next = pm->modifications; + pm->modifications = &me->this; +} +#endif /* PNG_READ_GAMMA_SUPPORTED */ +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + +/***************************** STANDARD PNG FILES *****************************/ +/* Standard files - write and save standard files. */ +/* There are two basic forms of standard images. Those which attempt to have + * all the possible pixel values (not possible for 16bpp images, but a range of + * values are produced) and those which have a range of image sizes. The former + * are used for testing transforms, in particular gamma correction and bit + * reduction and increase. The latter are reserved for testing the behavior of + * libpng with respect to 'odd' image sizes - particularly small images where + * rows become 1 byte and interlace passes disappear. + * + * The first, most useful, set are the 'transform' images, the second set of + * small images are the 'size' images. + * + * The transform files are constructed with rows which fit into a 1024 byte row + * buffer. This makes allocation easier below. Further regardless of the file + * format every row has 128 pixels (giving 1024 bytes for 64bpp formats). + * + * Files are stored with no gAMA or sBIT chunks, with a PLTE only when needed + * and with an ID derived from the colour type, bit depth and interlace type + * as above (FILEID). The width (128) and height (variable) are not stored in + * the FILEID - instead the fields are set to 0, indicating a transform file. + * + * The size files ar constructed with rows a maximum of 128 bytes wide, allowing + * a maximum width of 16 pixels (for the 64bpp case.) They also have a maximum + * height of 16 rows. The width and height are stored in the FILEID and, being + * non-zero, indicate a size file. + * + * Because the PNG filter code is typically the largest CPU consumer within + * libpng itself there is a tendency to attempt to optimize it. This results in + * special case code which needs to be validated. To cause this to happen the + * 'size' images are made to use each possible filter, in so far as this is + * possible for smaller images. + * + * For palette image (colour type 3) multiple transform images are stored with + * the same bit depth to allow testing of more colour combinations - + * particularly important for testing the gamma code because libpng uses a + * different code path for palette images. For size images a single palette is + * used. + */ + +/* Make a 'standard' palette. Because there are only 256 entries in a palette + * (maximum) this actually makes a random palette in the hope that enough tests + * will catch enough errors. (Note that the same palette isn't produced every + * time for the same test - it depends on what previous tests have been run - + * but a given set of arguments to pngvalid will always produce the same palette + * at the same test! This is why pseudo-random number generators are useful for + * testing.) + * + * The store must be open for write when this is called, otherwise an internal + * error will occur. This routine contains its own magic number seed, so the + * palettes generated don't change if there are intervening errors (changing the + * calls to the store_mark seed.) + */ +static store_palette_entry * +make_standard_palette(png_store* ps, int npalette, int do_tRNS) +{ + static png_uint_32 palette_seed[2] = { 0x87654321, 9 }; + + int i = 0; + png_byte values[256][4]; + + /* Always put in black and white plus the six primary and secondary colors. + */ + for (; i<8; ++i) + { + values[i][1] = (png_byte)((i&1) ? 255U : 0U); + values[i][2] = (png_byte)((i&2) ? 255U : 0U); + values[i][3] = (png_byte)((i&4) ? 255U : 0U); + } + + /* Then add 62 grays (one quarter of the remaining 256 slots). */ + { + int j = 0; + png_byte random_bytes[4]; + png_byte need[256]; + + need[0] = 0; /*got black*/ + memset(need+1, 1, (sizeof need)-2); /*need these*/ + need[255] = 0; /*but not white*/ + + while (i<70) + { + png_byte b; + + if (j==0) + { + make_four_random_bytes(palette_seed, random_bytes); + j = 4; + } + + b = random_bytes[--j]; + if (need[b]) + { + values[i][1] = b; + values[i][2] = b; + values[i++][3] = b; + } + } + } + + /* Finally add 192 colors at random - don't worry about matches to things we + * already have, chance is less than 1/65536. Don't worry about grays, + * chance is the same, so we get a duplicate or extra gray less than 1 time + * in 170. + */ + for (; i<256; ++i) + make_four_random_bytes(palette_seed, values[i]); + + /* Fill in the alpha values in the first byte. Just use all possible values + * (0..255) in an apparently random order: + */ + { + store_palette_entry *palette; + png_byte selector[4]; + + make_four_random_bytes(palette_seed, selector); + + if (do_tRNS) + for (i=0; i<256; ++i) + values[i][0] = (png_byte)(i ^ selector[0]); + + else + for (i=0; i<256; ++i) + values[i][0] = 255; /* no transparency/tRNS chunk */ + + /* 'values' contains 256 ARGB values, but we only need 'npalette'. + * 'npalette' will always be a power of 2: 2, 4, 16 or 256. In the low + * bit depth cases select colors at random, else it is difficult to have + * a set of low bit depth palette test with any chance of a reasonable + * range of colors. Do this by randomly permuting values into the low + * 'npalette' entries using an XOR mask generated here. This also + * permutes the npalette == 256 case in a potentially useful way (there is + * no relationship between palette index and the color value therein!) + */ + palette = store_write_palette(ps, npalette); + + for (i=0; i 0) + png_set_tRNS(pp, pi, tRNS, j, 0/*color*/); +#endif + } +} + +#ifdef PNG_WRITE_tRNS_SUPPORTED +static void +set_random_tRNS(png_structp pp, png_infop pi, png_byte colour_type, + int bit_depth) +{ + /* To make this useful the tRNS color needs to match at least one pixel. + * Random values are fine for gray, including the 16-bit case where we know + * that the test image contains all the gray values. For RGB we need more + * method as only 65536 different RGB values are generated. + */ + png_color_16 tRNS; + png_uint_16 mask = (png_uint_16)((1U << bit_depth)-1); + + R8(tRNS); /* makes unset fields random */ + + if (colour_type & 2/*RGB*/) + { + if (bit_depth == 8) + { + tRNS.red = random_u16(); + tRNS.green = random_u16(); + tRNS.blue = tRNS.red ^ tRNS.green; + tRNS.red &= mask; + tRNS.green &= mask; + tRNS.blue &= mask; + } + + else /* bit_depth == 16 */ + { + tRNS.red = random_u16(); + tRNS.green = (png_uint_16)(tRNS.red * 257); + tRNS.blue = (png_uint_16)(tRNS.green * 17); + } + } + + else + { + tRNS.gray = random_u16(); + tRNS.gray &= mask; + } + + png_set_tRNS(pp, pi, NULL, 0, &tRNS); +} +#endif + +/* The number of passes is related to the interlace type. There was no libpng + * API to determine this prior to 1.5, so we need an inquiry function: + */ +static int +npasses_from_interlace_type(png_const_structp pp, int interlace_type) +{ + switch (interlace_type) + { + default: + png_error(pp, "invalid interlace type"); + + case PNG_INTERLACE_NONE: + return 1; + + case PNG_INTERLACE_ADAM7: + return PNG_INTERLACE_ADAM7_PASSES; + } +} + +static unsigned int +bit_size(png_const_structp pp, png_byte colour_type, png_byte bit_depth) +{ + switch (colour_type) + { + default: png_error(pp, "invalid color type"); + + case 0: return bit_depth; + + case 2: return 3*bit_depth; + + case 3: return bit_depth; + + case 4: return 2*bit_depth; + + case 6: return 4*bit_depth; + } +} + +#define TRANSFORM_WIDTH 128U +#define TRANSFORM_ROWMAX (TRANSFORM_WIDTH*8U) +#define SIZE_ROWMAX (16*8U) /* 16 pixels, max 8 bytes each - 128 bytes */ +#define STANDARD_ROWMAX TRANSFORM_ROWMAX /* The larger of the two */ +#define SIZE_HEIGHTMAX 16 /* Maximum range of size images */ + +static size_t +transform_rowsize(png_const_structp pp, png_byte colour_type, + png_byte bit_depth) +{ + return (TRANSFORM_WIDTH * bit_size(pp, colour_type, bit_depth)) / 8; +} + +/* transform_width(pp, colour_type, bit_depth) current returns the same number + * every time, so just use a macro: + */ +#define transform_width(pp, colour_type, bit_depth) TRANSFORM_WIDTH + +static png_uint_32 +transform_height(png_const_structp pp, png_byte colour_type, png_byte bit_depth) +{ + switch (bit_size(pp, colour_type, bit_depth)) + { + case 1: + case 2: + case 4: + return 1; /* Total of 128 pixels */ + + case 8: + return 2; /* Total of 256 pixels/bytes */ + + case 16: + return 512; /* Total of 65536 pixels */ + + case 24: + case 32: + return 512; /* 65536 pixels */ + + case 48: + case 64: + return 2048;/* 4 x 65536 pixels. */ +# define TRANSFORM_HEIGHTMAX 2048 + + default: + return 0; /* Error, will be caught later */ + } +} + +#ifdef PNG_READ_SUPPORTED +/* The following can only be defined here, now we have the definitions + * of the transform image sizes. + */ +static png_uint_32 +standard_width(png_const_structp pp, png_uint_32 id) +{ + png_uint_32 width = WIDTH_FROM_ID(id); + UNUSED(pp) + + if (width == 0) + width = transform_width(pp, COL_FROM_ID(id), DEPTH_FROM_ID(id)); + + return width; +} + +static png_uint_32 +standard_height(png_const_structp pp, png_uint_32 id) +{ + png_uint_32 height = HEIGHT_FROM_ID(id); + + if (height == 0) + height = transform_height(pp, COL_FROM_ID(id), DEPTH_FROM_ID(id)); + + return height; +} + +static png_uint_32 +standard_rowsize(png_const_structp pp, png_uint_32 id) +{ + png_uint_32 width = standard_width(pp, id); + + /* This won't overflow: */ + width *= bit_size(pp, COL_FROM_ID(id), DEPTH_FROM_ID(id)); + return (width + 7) / 8; +} +#endif /* PNG_READ_SUPPORTED */ + +static void +transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX], + png_byte colour_type, png_byte bit_depth, png_uint_32 y) +{ + png_uint_32 v = y << 7; + png_uint_32 i = 0; + + switch (bit_size(pp, colour_type, bit_depth)) + { + case 1: + while (i<128/8) buffer[i] = (png_byte)(v & 0xff), v += 17, ++i; + return; + + case 2: + while (i<128/4) buffer[i] = (png_byte)(v & 0xff), v += 33, ++i; + return; + + case 4: + while (i<128/2) buffer[i] = (png_byte)(v & 0xff), v += 65, ++i; + return; + + case 8: + /* 256 bytes total, 128 bytes in each row set as follows: */ + while (i<128) buffer[i] = (png_byte)(v & 0xff), ++v, ++i; + return; + + case 16: + /* Generate all 65536 pixel values in order, which includes the 8 bit + * GA case as well as the 16 bit G case. + */ + while (i<128) + { + buffer[2*i] = (png_byte)((v>>8) & 0xff); + buffer[2*i+1] = (png_byte)(v & 0xff); + ++v; + ++i; + } + + return; + + case 24: + /* 65535 pixels, but rotate the values. */ + while (i<128) + { + /* Three bytes per pixel, r, g, b, make b by r^g */ + buffer[3*i+0] = (png_byte)((v >> 8) & 0xff); + buffer[3*i+1] = (png_byte)(v & 0xff); + buffer[3*i+2] = (png_byte)(((v >> 8) ^ v) & 0xff); + ++v; + ++i; + } + + return; + + case 32: + /* 65535 pixels, r, g, b, a; just replicate */ + while (i<128) + { + buffer[4*i+0] = (png_byte)((v >> 8) & 0xff); + buffer[4*i+1] = (png_byte)(v & 0xff); + buffer[4*i+2] = (png_byte)((v >> 8) & 0xff); + buffer[4*i+3] = (png_byte)(v & 0xff); + ++v; + ++i; + } + + return; + + case 48: + /* y is maximum 2047, giving 4x65536 pixels, make 'r' increase by 1 at + * each pixel, g increase by 257 (0x101) and 'b' by 0x1111: + */ + while (i<128) + { + png_uint_32 t = v++; + buffer[6*i+0] = (png_byte)((t >> 8) & 0xff); + buffer[6*i+1] = (png_byte)(t & 0xff); + t *= 257; + buffer[6*i+2] = (png_byte)((t >> 8) & 0xff); + buffer[6*i+3] = (png_byte)(t & 0xff); + t *= 17; + buffer[6*i+4] = (png_byte)((t >> 8) & 0xff); + buffer[6*i+5] = (png_byte)(t & 0xff); + ++i; + } + + return; + + case 64: + /* As above in the 32 bit case. */ + while (i<128) + { + png_uint_32 t = v++; + buffer[8*i+0] = (png_byte)((t >> 8) & 0xff); + buffer[8*i+1] = (png_byte)(t & 0xff); + buffer[8*i+4] = (png_byte)((t >> 8) & 0xff); + buffer[8*i+5] = (png_byte)(t & 0xff); + t *= 257; + buffer[8*i+2] = (png_byte)((t >> 8) & 0xff); + buffer[8*i+3] = (png_byte)(t & 0xff); + buffer[8*i+6] = (png_byte)((t >> 8) & 0xff); + buffer[8*i+7] = (png_byte)(t & 0xff); + ++i; + } + return; + + default: + break; + } + + png_error(pp, "internal error"); +} + +/* This is just to do the right cast - could be changed to a function to check + * 'bd' but there isn't much point. + */ +#define DEPTH(bd) ((png_byte)(1U << (bd))) + +/* This is just a helper for compiling on minimal systems with no write + * interlacing support. If there is no write interlacing we can't generate test + * cases with interlace: + */ +#ifdef PNG_WRITE_INTERLACING_SUPPORTED +# define INTERLACE_LAST PNG_INTERLACE_LAST +# define check_interlace_type(type) ((void)(type)) +# define set_write_interlace_handling(pp,type) png_set_interlace_handling(pp) +# define do_own_interlace 0 +#elif PNG_LIBPNG_VER < 10700 +# define set_write_interlace_handling(pp,type) (1) +static void +check_interlace_type(int const interlace_type) +{ + /* Prior to 1.7.0 libpng does not support the write of an interlaced image + * unless PNG_WRITE_INTERLACING_SUPPORTED, even with do_interlace so the + * code here does the pixel interlace itself, so: + */ + if (interlace_type != PNG_INTERLACE_NONE) + { + /* This is an internal error - --interlace tests should be skipped, not + * attempted. + */ + fprintf(stderr, "pngvalid: no interlace support\n"); + exit(99); + } +} +# define INTERLACE_LAST (PNG_INTERLACE_NONE+1) +# define do_own_interlace 0 +#else /* libpng 1.7+ */ +# define set_write_interlace_handling(pp,type)\ + npasses_from_interlace_type(pp,type) +# define check_interlace_type(type) ((void)(type)) +# define INTERLACE_LAST PNG_INTERLACE_LAST +# define do_own_interlace 1 +#endif /* WRITE_INTERLACING tests */ + +#if PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED +# define CAN_WRITE_INTERLACE 1 +#else +# define CAN_WRITE_INTERLACE 0 +#endif + +/* Do the same thing for read interlacing; this controls whether read tests do + * their own de-interlace or use libpng. + */ +#ifdef PNG_READ_INTERLACING_SUPPORTED +# define do_read_interlace 0 +#else /* no libpng read interlace support */ +# define do_read_interlace 1 +#endif +/* The following two routines use the PNG interlace support macros from + * png.h to interlace or deinterlace rows. + */ +static void +interlace_row(png_bytep buffer, png_const_bytep imageRow, + unsigned int pixel_size, png_uint_32 w, int pass, int littleendian) +{ + png_uint_32 xin, xout, xstep; + + /* Note that this can, trivially, be optimized to a memcpy on pass 7, the + * code is presented this way to make it easier to understand. In practice + * consult the code in the libpng source to see other ways of doing this. + * + * It is OK for buffer and imageRow to be identical, because 'xin' moves + * faster than 'xout' and we copy up. + */ + xin = PNG_PASS_START_COL(pass); + xstep = 1U<wname); + text.text = copy; + text.text_length = pos; + text.itxt_length = 0; + text.lang = 0; + text.lang_key = 0; + + png_set_text(pp, pi, &text, 1); + } +#endif + + if (colour_type == 3) /* palette */ + init_standard_palette(ps, pp, pi, 1U << bit_depth, 1/*do tRNS*/); + +# ifdef PNG_WRITE_tRNS_SUPPORTED + else if (palette_number) + set_random_tRNS(pp, pi, colour_type, bit_depth); +# endif + + png_write_info(pp, pi); + + if (png_get_rowbytes(pp, pi) != + transform_rowsize(pp, colour_type, bit_depth)) + png_error(pp, "transform row size incorrect"); + + else + { + /* Somewhat confusingly this must be called *after* png_write_info + * because if it is called before, the information in *pp has not been + * updated to reflect the interlaced image. + */ + int npasses = set_write_interlace_handling(pp, interlace_type); + int pass; + + if (npasses != npasses_from_interlace_type(pp, interlace_type)) + png_error(pp, "write: png_set_interlace_handling failed"); + + for (pass=0; pass 0) + interlace_row(buffer, buffer, + bit_size(pp, colour_type, bit_depth), w, pass, + 0/*data always bigendian*/); + else + continue; + } +# endif /* do_own_interlace */ + + choose_random_filter(pp, pass == 0 && y == 0); + png_write_row(pp, buffer); + } + } + } + +#ifdef PNG_TEXT_SUPPORTED + { + static char key[] = "end marker"; + static char comment[] = "end"; + png_text text; + + /* Use a compressed text string to test the correct interaction of text + * compression and IDAT compression. + */ + text.compression = TEXT_COMPRESSION; + text.key = key; + text.text = comment; + text.text_length = (sizeof comment)-1; + text.itxt_length = 0; + text.lang = 0; + text.lang_key = 0; + + png_set_text(pp, pi, &text, 1); + } +#endif + + png_write_end(pp, pi); + + /* And store this under the appropriate id, then clean up. */ + store_storefile(ps, FILEID(colour_type, bit_depth, palette_number, + interlace_type, 0, 0, 0)); + + store_write_reset(ps); + } + + Catch(fault) + { + /* Use the png_store returned by the exception. This may help the compiler + * because 'ps' is not used in this branch of the setjmp. Note that fault + * and ps will always be the same value. + */ + store_write_reset(fault); + } +} + +static void +make_transform_images(png_modifier *pm) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + unsigned int palette_number = 0; + + /* This is in case of errors. */ + safecat(pm->this.test, sizeof pm->this.test, 0, "make standard images"); + + /* Use next_format to enumerate all the combinations we test, including + * generating multiple low bit depth palette images. Non-A images (palette + * and direct) are created with and without tRNS chunks. + */ + while (next_format(&colour_type, &bit_depth, &palette_number, 1, 1)) + { + int interlace_type; + + for (interlace_type = PNG_INTERLACE_NONE; + interlace_type < INTERLACE_LAST; ++interlace_type) + { + char name[FILE_NAME_SIZE]; + + standard_name(name, sizeof name, 0, colour_type, bit_depth, + palette_number, interlace_type, 0, 0, do_own_interlace); + make_transform_image(&pm->this, colour_type, bit_depth, palette_number, + interlace_type, name); + } + } +} + +/* Build a single row for the 'size' test images; this fills in only the + * first bit_width bits of the sample row. + */ +static void +size_row(png_byte buffer[SIZE_ROWMAX], png_uint_32 bit_width, png_uint_32 y) +{ + /* height is in the range 1 to 16, so: */ + y = ((y & 1) << 7) + ((y & 2) << 6) + ((y & 4) << 5) + ((y & 8) << 4); + /* the following ensures bits are set in small images: */ + y ^= 0xA5; + + while (bit_width >= 8) + *buffer++ = (png_byte)y++, bit_width -= 8; + + /* There may be up to 7 remaining bits, these go in the most significant + * bits of the byte. + */ + if (bit_width > 0) + { + png_uint_32 mask = (1U<<(8-bit_width))-1; + *buffer = (png_byte)((*buffer & mask) | (y & ~mask)); + } +} + +static void +make_size_image(png_store* const ps, png_byte const colour_type, + png_byte const bit_depth, int const interlace_type, + png_uint_32 const w, png_uint_32 const h, + int const do_interlace) +{ + context(ps, fault); + + check_interlace_type(interlace_type); + + Try + { + png_infop pi; + png_structp pp; + unsigned int pixel_size; + + /* Make a name and get an appropriate id for the store: */ + char name[FILE_NAME_SIZE]; + png_uint_32 id = FILEID(colour_type, bit_depth, 0/*palette*/, + interlace_type, w, h, do_interlace); + + standard_name_from_id(name, sizeof name, 0, id); + pp = set_store_for_write(ps, &pi, name); + + /* In the event of a problem return control to the Catch statement below + * to do the clean up - it is not possible to 'return' directly from a Try + * block. + */ + if (pp == NULL) + Throw ps; + + png_set_IHDR(pp, pi, w, h, bit_depth, colour_type, interlace_type, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + +#ifdef PNG_TEXT_SUPPORTED + { + static char key[] = "image name"; /* must be writeable */ + size_t pos; + png_text text; + char copy[FILE_NAME_SIZE]; + + /* Use a compressed text string to test the correct interaction of text + * compression and IDAT compression. + */ + text.compression = TEXT_COMPRESSION; + text.key = key; + /* Yuck: the text must be writable! */ + pos = safecat(copy, sizeof copy, 0, ps->wname); + text.text = copy; + text.text_length = pos; + text.itxt_length = 0; + text.lang = 0; + text.lang_key = 0; + + png_set_text(pp, pi, &text, 1); + } +#endif + + if (colour_type == 3) /* palette */ + init_standard_palette(ps, pp, pi, 1U << bit_depth, 0/*do tRNS*/); + + png_write_info(pp, pi); + + /* Calculate the bit size, divide by 8 to get the byte size - this won't + * overflow because we know the w values are all small enough even for + * a system where 'unsigned int' is only 16 bits. + */ + pixel_size = bit_size(pp, colour_type, bit_depth); + if (png_get_rowbytes(pp, pi) != ((w * pixel_size) + 7) / 8) + png_error(pp, "size row size incorrect"); + + else + { + int npasses = npasses_from_interlace_type(pp, interlace_type); + png_uint_32 y; + int pass; + png_byte image[16][SIZE_ROWMAX]; + + /* To help consistent error detection make the parts of this buffer + * that aren't set below all '1': + */ + memset(image, 0xff, sizeof image); + + if (!do_interlace && + npasses != set_write_interlace_handling(pp, interlace_type)) + png_error(pp, "write: png_set_interlace_handling failed"); + + /* Prepare the whole image first to avoid making it 7 times: */ + for (y=0; y 0) + { + /* Set to all 1's for error detection (libpng tends to + * set unset things to 0). + */ + memset(tempRow, 0xff, sizeof tempRow); + interlace_row(tempRow, row, pixel_size, w, pass, + 0/*data always bigendian*/); + row = tempRow; + } + else + continue; + } + +# ifdef PNG_WRITE_FILTER_SUPPORTED + /* Only get to here if the row has some pixels in it, set the + * filters to 'all' for the very first row and thereafter to a + * single filter. It isn't well documented, but png_set_filter + * does accept a filter number (per the spec) as well as a bit + * mask. + * + * The code now uses filters at random, except that on the first + * row of an image it ensures that a previous row filter is in + * the set so that libpng allocates the row buffer. + */ + { + int filters = 8 << random_mod(PNG_FILTER_VALUE_LAST); + + if (pass == 0 && y == 0 && + (filters < PNG_FILTER_UP || w == 1U)) + filters |= PNG_FILTER_UP; + + png_set_filter(pp, 0/*method*/, filters); + } +# endif + + png_write_row(pp, row); + } + } + } + +#ifdef PNG_TEXT_SUPPORTED + { + static char key[] = "end marker"; + static char comment[] = "end"; + png_text text; + + /* Use a compressed text string to test the correct interaction of text + * compression and IDAT compression. + */ + text.compression = TEXT_COMPRESSION; + text.key = key; + text.text = comment; + text.text_length = (sizeof comment)-1; + text.itxt_length = 0; + text.lang = 0; + text.lang_key = 0; + + png_set_text(pp, pi, &text, 1); + } +#endif + + png_write_end(pp, pi); + + /* And store this under the appropriate id, then clean up. */ + store_storefile(ps, id); + + store_write_reset(ps); + } + + Catch(fault) + { + /* Use the png_store returned by the exception. This may help the compiler + * because 'ps' is not used in this branch of the setjmp. Note that fault + * and ps will always be the same value. + */ + store_write_reset(fault); + } +} + +static void +make_size(png_store* const ps, png_byte const colour_type, int bdlo, + int const bdhi) +{ + for (; bdlo <= bdhi; ++bdlo) + { + png_uint_32 width; + + for (width = 1; width <= 16; ++width) + { + png_uint_32 height; + + for (height = 1; height <= 16; ++height) + { + /* The four combinations of DIY interlace and interlace or not - + * no interlace + DIY should be identical to no interlace with + * libpng doing it. + */ + make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_NONE, + width, height, 0); + make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_NONE, + width, height, 1); +# ifdef PNG_WRITE_INTERLACING_SUPPORTED + make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7, + width, height, 0); +# endif +# if CAN_WRITE_INTERLACE + /* 1.7.0 removes the hack that prevented app write of an interlaced + * image if WRITE_INTERLACE was not supported + */ + make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7, + width, height, 1); +# endif + } + } + } +} + +static void +make_size_images(png_store *ps) +{ + /* This is in case of errors. */ + safecat(ps->test, sizeof ps->test, 0, "make size images"); + + /* Arguments are colour_type, low bit depth, high bit depth + */ + make_size(ps, 0, 0, WRITE_BDHI); + make_size(ps, 2, 3, WRITE_BDHI); + make_size(ps, 3, 0, 3 /*palette: max 8 bits*/); + make_size(ps, 4, 3, WRITE_BDHI); + make_size(ps, 6, 3, WRITE_BDHI); +} + +#ifdef PNG_READ_SUPPORTED +/* Return a row based on image id and 'y' for checking: */ +static void +standard_row(png_const_structp pp, png_byte std[STANDARD_ROWMAX], + png_uint_32 id, png_uint_32 y) +{ + if (WIDTH_FROM_ID(id) == 0) + transform_row(pp, std, COL_FROM_ID(id), DEPTH_FROM_ID(id), y); + else + size_row(std, WIDTH_FROM_ID(id) * bit_size(pp, COL_FROM_ID(id), + DEPTH_FROM_ID(id)), y); +} +#endif /* PNG_READ_SUPPORTED */ + +/* Tests - individual test cases */ +/* Like 'make_standard' but errors are deliberately introduced into the calls + * to ensure that they get detected - it should not be possible to write an + * invalid image with libpng! + */ +/* TODO: the 'set' functions can probably all be made to take a + * png_const_structp rather than a modifiable one. + */ +#ifdef PNG_WARNINGS_SUPPORTED +static void +sBIT0_error_fn(png_structp pp, png_infop pi) +{ + /* 0 is invalid... */ + png_color_8 bad; + bad.red = bad.green = bad.blue = bad.gray = bad.alpha = 0; + png_set_sBIT(pp, pi, &bad); +} + +static void +sBIT_error_fn(png_structp pp, png_infop pi) +{ + png_byte bit_depth; + png_color_8 bad; + + if (png_get_color_type(pp, pi) == PNG_COLOR_TYPE_PALETTE) + bit_depth = 8; + + else + bit_depth = png_get_bit_depth(pp, pi); + + /* Now we know the bit depth we can easily generate an invalid sBIT entry */ + bad.red = bad.green = bad.blue = bad.gray = bad.alpha = + (png_byte)(bit_depth+1); + png_set_sBIT(pp, pi, &bad); +} + +static const struct +{ + void (*fn)(png_structp, png_infop); + const char *msg; + unsigned int warning :1; /* the error is a warning... */ +} error_test[] = + { + /* no warnings makes these errors undetectable prior to 1.7.0 */ + { sBIT0_error_fn, "sBIT(0): failed to detect error", + PNG_LIBPNG_VER < 10700 }, + + { sBIT_error_fn, "sBIT(too big): failed to detect error", + PNG_LIBPNG_VER < 10700 }, + }; + +static void +make_error(png_store* const ps, png_byte const colour_type, + png_byte bit_depth, int interlace_type, int test, png_const_charp name) +{ + context(ps, fault); + + check_interlace_type(interlace_type); + + Try + { + png_infop pi; + png_structp pp = set_store_for_write(ps, &pi, name); + png_uint_32 w, h; + gnu_volatile(pp) + + if (pp == NULL) + Throw ps; + + w = transform_width(pp, colour_type, bit_depth); + gnu_volatile(w) + h = transform_height(pp, colour_type, bit_depth); + gnu_volatile(h) + png_set_IHDR(pp, pi, w, h, bit_depth, colour_type, interlace_type, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + if (colour_type == 3) /* palette */ + init_standard_palette(ps, pp, pi, 1U << bit_depth, 0/*do tRNS*/); + + /* Time for a few errors; these are in various optional chunks, the + * standard tests test the standard chunks pretty well. + */ +# define exception__prev exception_prev_1 +# define exception__env exception_env_1 + Try + { + gnu_volatile(exception__prev) + + /* Expect this to throw: */ + ps->expect_error = !error_test[test].warning; + ps->expect_warning = error_test[test].warning; + ps->saw_warning = 0; + error_test[test].fn(pp, pi); + + /* Normally the error is only detected here: */ + png_write_info(pp, pi); + + /* And handle the case where it was only a warning: */ + if (ps->expect_warning && ps->saw_warning) + Throw ps; + + /* If we get here there is a problem, we have success - no error or + * no warning - when we shouldn't have success. Log an error. + */ + store_log(ps, pp, error_test[test].msg, 1 /*error*/); + } + + Catch (fault) + { /* expected exit */ + } +#undef exception__prev +#undef exception__env + + /* And clear these flags */ + ps->expect_warning = 0; + + if (ps->expect_error) + ps->expect_error = 0; + + else + { + /* Now write the whole image, just to make sure that the detected, or + * undetected, error has not created problems inside libpng. This + * doesn't work if there was a png_error in png_write_info because that + * can abort before PLTE was written. + */ + if (png_get_rowbytes(pp, pi) != + transform_rowsize(pp, colour_type, bit_depth)) + png_error(pp, "row size incorrect"); + + else + { + int npasses = set_write_interlace_handling(pp, interlace_type); + int pass; + + if (npasses != npasses_from_interlace_type(pp, interlace_type)) + png_error(pp, "write: png_set_interlace_handling failed"); + + for (pass=0; pass 0) + interlace_row(buffer, buffer, + bit_size(pp, colour_type, bit_depth), w, pass, + 0/*data always bigendian*/); + else + continue; + } +# endif /* do_own_interlace */ + + png_write_row(pp, buffer); + } + } + } /* image writing */ + + png_write_end(pp, pi); + } + + /* The following deletes the file that was just written. */ + store_write_reset(ps); + } + + Catch(fault) + { + store_write_reset(fault); + } +} + +static int +make_errors(png_modifier* const pm, png_byte const colour_type, + int bdlo, int const bdhi) +{ + for (; bdlo <= bdhi; ++bdlo) + { + int interlace_type; + + for (interlace_type = PNG_INTERLACE_NONE; + interlace_type < INTERLACE_LAST; ++interlace_type) + { + unsigned int test; + char name[FILE_NAME_SIZE]; + + standard_name(name, sizeof name, 0, colour_type, 1<this, colour_type, DEPTH(bdlo), interlace_type, + test, name); + + if (fail(pm)) + return 0; + } + } + } + + return 1; /* keep going */ +} +#endif /* PNG_WARNINGS_SUPPORTED */ + +static void +perform_error_test(png_modifier *pm) +{ +#ifdef PNG_WARNINGS_SUPPORTED /* else there are no cases that work! */ + /* Need to do this here because we just write in this test. */ + safecat(pm->this.test, sizeof pm->this.test, 0, "error test"); + + if (!make_errors(pm, 0, 0, WRITE_BDHI)) + return; + + if (!make_errors(pm, 2, 3, WRITE_BDHI)) + return; + + if (!make_errors(pm, 3, 0, 3)) + return; + + if (!make_errors(pm, 4, 3, WRITE_BDHI)) + return; + + if (!make_errors(pm, 6, 3, WRITE_BDHI)) + return; +#else + UNUSED(pm) +#endif +} + +/* This is just to validate the internal PNG formatting code - if this fails + * then the warning messages the library outputs will probably be garbage. + */ +static void +perform_formatting_test(png_store *ps) +{ +#ifdef PNG_TIME_RFC1123_SUPPORTED + /* The handle into the formatting code is the RFC1123 support; this test does + * nothing if that is compiled out. + */ + context(ps, fault); + + Try + { + png_const_charp correct = "29 Aug 2079 13:53:60 +0000"; + png_const_charp result; +# if PNG_LIBPNG_VER >= 10600 + char timestring[29]; +# endif + png_structp pp; + png_time pt; + + pp = set_store_for_write(ps, NULL, "libpng formatting test"); + + if (pp == NULL) + Throw ps; + + + /* Arbitrary settings: */ + pt.year = 2079; + pt.month = 8; + pt.day = 29; + pt.hour = 13; + pt.minute = 53; + pt.second = 60; /* a leap second */ + +# if PNG_LIBPNG_VER < 10600 + result = png_convert_to_rfc1123(pp, &pt); +# else + if (png_convert_to_rfc1123_buffer(timestring, &pt)) + result = timestring; + + else + result = NULL; +# endif + + if (result == NULL) + png_error(pp, "png_convert_to_rfc1123 failed"); + + if (strcmp(result, correct) != 0) + { + size_t pos = 0; + char msg[128]; + + pos = safecat(msg, sizeof msg, pos, "png_convert_to_rfc1123("); + pos = safecat(msg, sizeof msg, pos, correct); + pos = safecat(msg, sizeof msg, pos, ") returned: '"); + pos = safecat(msg, sizeof msg, pos, result); + pos = safecat(msg, sizeof msg, pos, "'"); + + png_error(pp, msg); + } + + store_write_reset(ps); + } + + Catch(fault) + { + store_write_reset(fault); + } +#else + UNUSED(ps) +#endif +} + +#ifdef PNG_READ_SUPPORTED +/* Because we want to use the same code in both the progressive reader and the + * sequential reader it is necessary to deal with the fact that the progressive + * reader callbacks only have one parameter (png_get_progressive_ptr()), so this + * must contain all the test parameters and all the local variables directly + * accessible to the sequential reader implementation. + * + * The technique adopted is to reinvent part of what Dijkstra termed a + * 'display'; an array of pointers to the stack frames of enclosing functions so + * that a nested function definition can access the local (C auto) variables of + * the functions that contain its definition. In fact C provides the first + * pointer (the local variables - the stack frame pointer) and the last (the + * global variables - the BCPL global vector typically implemented as global + * addresses), this code requires one more pointer to make the display - the + * local variables (and function call parameters) of the function that actually + * invokes either the progressive or sequential reader. + * + * Perhaps confusingly this technique is confounded with classes - the + * 'standard_display' defined here is sub-classed as the 'gamma_display' below. + * A gamma_display is a standard_display, taking advantage of the ANSI-C + * requirement that the pointer to the first member of a structure must be the + * same as the pointer to the structure. This allows us to reuse standard_ + * functions in the gamma test code; something that could not be done with + * nested functions! + */ +typedef struct standard_display +{ + png_store* ps; /* Test parameters (passed to the function) */ + png_byte colour_type; + png_byte bit_depth; + png_byte red_sBIT; /* Input data sBIT values. */ + png_byte green_sBIT; + png_byte blue_sBIT; + png_byte alpha_sBIT; + png_byte interlace_type; + png_byte filler; /* Output has a filler */ + png_uint_32 id; /* Calculated file ID */ + png_uint_32 w; /* Width of image */ + png_uint_32 h; /* Height of image */ + int npasses; /* Number of interlaced passes */ + png_uint_32 pixel_size; /* Width of one pixel in bits */ + png_uint_32 bit_width; /* Width of output row in bits */ + size_t cbRow; /* Bytes in a row of the output image */ + int do_interlace; /* Do interlacing internally */ + int littleendian; /* App (row) data is little endian */ + int is_transparent; /* Transparency information was present. */ + int has_tRNS; /* color type GRAY or RGB with a tRNS chunk. */ + int speed; /* Doing a speed test */ + int use_update_info;/* Call update_info, not start_image */ + struct + { + png_uint_16 red; + png_uint_16 green; + png_uint_16 blue; + } transparent; /* The transparent color, if set. */ + int npalette; /* Number of entries in the palette. */ + store_palette + palette; +} standard_display; + +static void +standard_display_init(standard_display *dp, png_store* ps, png_uint_32 id, + int do_interlace, int use_update_info) +{ + memset(dp, 0, sizeof *dp); + + dp->ps = ps; + dp->colour_type = COL_FROM_ID(id); + dp->bit_depth = DEPTH_FROM_ID(id); + if (dp->bit_depth < 1 || dp->bit_depth > 16) + internal_error(ps, "internal: bad bit depth"); + if (dp->colour_type == 3) + dp->red_sBIT = dp->blue_sBIT = dp->green_sBIT = dp->alpha_sBIT = 8; + else + dp->red_sBIT = dp->blue_sBIT = dp->green_sBIT = dp->alpha_sBIT = + dp->bit_depth; + dp->interlace_type = INTERLACE_FROM_ID(id); + check_interlace_type(dp->interlace_type); + dp->id = id; + /* All the rest are filled in after the read_info: */ + dp->w = 0; + dp->h = 0; + dp->npasses = 0; + dp->pixel_size = 0; + dp->bit_width = 0; + dp->cbRow = 0; + dp->do_interlace = do_interlace; + dp->littleendian = 0; + dp->is_transparent = 0; + dp->speed = ps->speed; + dp->use_update_info = use_update_info; + dp->npalette = 0; + /* Preset the transparent color to black: */ + memset(&dp->transparent, 0, sizeof dp->transparent); + /* Preset the palette to full intensity/opaque throughout: */ + memset(dp->palette, 0xff, sizeof dp->palette); +} + +/* Initialize the palette fields - this must be done later because the palette + * comes from the particular png_store_file that is selected. + */ +static void +standard_palette_init(standard_display *dp) +{ + store_palette_entry *palette = store_current_palette(dp->ps, &dp->npalette); + + /* The remaining entries remain white/opaque. */ + if (dp->npalette > 0) + { + int i = dp->npalette; + memcpy(dp->palette, palette, i * sizeof *palette); + + /* Check for a non-opaque palette entry: */ + while (--i >= 0) + if (palette[i].alpha < 255) + break; + +# ifdef __GNUC__ + /* GCC can't handle the more obviously optimizable version. */ + if (i >= 0) + dp->is_transparent = 1; + else + dp->is_transparent = 0; +# else + dp->is_transparent = (i >= 0); +# endif + } +} + +/* Utility to read the palette from the PNG file and convert it into + * store_palette format. This returns 1 if there is any transparency in the + * palette (it does not check for a transparent colour in the non-palette case.) + */ +static int +read_palette(store_palette palette, int *npalette, png_const_structp pp, + png_infop pi) +{ + png_colorp pal; + png_bytep trans_alpha; + int num; + + pal = 0; + *npalette = -1; + + if (png_get_PLTE(pp, pi, &pal, npalette) & PNG_INFO_PLTE) + { + int i = *npalette; + + if (i <= 0 || i > 256) + png_error(pp, "validate: invalid PLTE count"); + + while (--i >= 0) + { + palette[i].red = pal[i].red; + palette[i].green = pal[i].green; + palette[i].blue = pal[i].blue; + } + + /* Mark the remainder of the entries with a flag value (other than + * white/opaque which is the flag value stored above.) + */ + memset(palette + *npalette, 126, (256-*npalette) * sizeof *palette); + } + + else /* !png_get_PLTE */ + { + if (*npalette != (-1)) + png_error(pp, "validate: invalid PLTE result"); + /* But there is no palette, so record this: */ + *npalette = 0; + memset(palette, 113, sizeof (store_palette)); + } + + trans_alpha = 0; + num = 2; /* force error below */ + if ((png_get_tRNS(pp, pi, &trans_alpha, &num, 0) & PNG_INFO_tRNS) != 0 && + (trans_alpha != NULL || num != 1/*returns 1 for a transparent color*/) && + /* Oops, if a palette tRNS gets expanded png_read_update_info (at least so + * far as 1.5.4) does not remove the trans_alpha pointer, only num_trans, + * so in the above call we get a success, we get a pointer (who knows what + * to) and we get num_trans == 0: + */ + !(trans_alpha != NULL && num == 0)) /* TODO: fix this in libpng. */ + { + int i; + + /* Any of these are crash-worthy - given the implementation of + * png_get_tRNS up to 1.5 an app won't crash if it just checks the + * result above and fails to check that the variables it passed have + * actually been filled in! Note that if the app were to pass the + * last, png_color_16p, variable too it couldn't rely on this. + */ + if (trans_alpha == NULL || num <= 0 || num > 256 || num > *npalette) + png_error(pp, "validate: unexpected png_get_tRNS (palette) result"); + + for (i=0; iis_transparent) + png_error(pp, "validate: palette transparency changed"); + + if (npalette != dp->npalette) + { + size_t pos = 0; + char msg[64]; + + pos = safecat(msg, sizeof msg, pos, "validate: palette size changed: "); + pos = safecatn(msg, sizeof msg, pos, dp->npalette); + pos = safecat(msg, sizeof msg, pos, " -> "); + pos = safecatn(msg, sizeof msg, pos, npalette); + png_error(pp, msg); + } + + { + int i = npalette; /* npalette is aliased */ + + while (--i >= 0) + if (palette[i].red != dp->palette[i].red || + palette[i].green != dp->palette[i].green || + palette[i].blue != dp->palette[i].blue || + palette[i].alpha != dp->palette[i].alpha) + png_error(pp, "validate: PLTE or tRNS chunk changed"); + } +} + +/* By passing a 'standard_display' the progressive callbacks can be used + * directly by the sequential code, the functions suffixed "_imp" are the + * implementations, the functions without the suffix are the callbacks. + * + * The code for the info callback is split into two because this callback calls + * png_read_update_info or png_start_read_image and what gets called depends on + * whether the info needs updating (we want to test both calls in pngvalid.) + */ +static void +standard_info_part1(standard_display *dp, png_structp pp, png_infop pi) +{ + if (png_get_bit_depth(pp, pi) != dp->bit_depth) + png_error(pp, "validate: bit depth changed"); + + if (png_get_color_type(pp, pi) != dp->colour_type) + png_error(pp, "validate: color type changed"); + + if (png_get_filter_type(pp, pi) != PNG_FILTER_TYPE_BASE) + png_error(pp, "validate: filter type changed"); + + if (png_get_interlace_type(pp, pi) != dp->interlace_type) + png_error(pp, "validate: interlacing changed"); + + if (png_get_compression_type(pp, pi) != PNG_COMPRESSION_TYPE_BASE) + png_error(pp, "validate: compression type changed"); + + dp->w = png_get_image_width(pp, pi); + + if (dp->w != standard_width(pp, dp->id)) + png_error(pp, "validate: image width changed"); + + dp->h = png_get_image_height(pp, pi); + + if (dp->h != standard_height(pp, dp->id)) + png_error(pp, "validate: image height changed"); + + /* Record (but don't check at present) the input sBIT according to the colour + * type information. + */ + { + png_color_8p sBIT = 0; + + if (png_get_sBIT(pp, pi, &sBIT) & PNG_INFO_sBIT) + { + int sBIT_invalid = 0; + + if (sBIT == 0) + png_error(pp, "validate: unexpected png_get_sBIT result"); + + if (dp->colour_type & PNG_COLOR_MASK_COLOR) + { + if (sBIT->red == 0 || sBIT->red > dp->bit_depth) + sBIT_invalid = 1; + else + dp->red_sBIT = sBIT->red; + + if (sBIT->green == 0 || sBIT->green > dp->bit_depth) + sBIT_invalid = 1; + else + dp->green_sBIT = sBIT->green; + + if (sBIT->blue == 0 || sBIT->blue > dp->bit_depth) + sBIT_invalid = 1; + else + dp->blue_sBIT = sBIT->blue; + } + + else /* !COLOR */ + { + if (sBIT->gray == 0 || sBIT->gray > dp->bit_depth) + sBIT_invalid = 1; + else + dp->blue_sBIT = dp->green_sBIT = dp->red_sBIT = sBIT->gray; + } + + /* All 8 bits in tRNS for a palette image are significant - see the + * spec. + */ + if (dp->colour_type & PNG_COLOR_MASK_ALPHA) + { + if (sBIT->alpha == 0 || sBIT->alpha > dp->bit_depth) + sBIT_invalid = 1; + else + dp->alpha_sBIT = sBIT->alpha; + } + + if (sBIT_invalid) + png_error(pp, "validate: sBIT value out of range"); + } + } + + /* Important: this is validating the value *before* any transforms have been + * put in place. It doesn't matter for the standard tests, where there are + * no transforms, but it does for other tests where rowbytes may change after + * png_read_update_info. + */ + if (png_get_rowbytes(pp, pi) != standard_rowsize(pp, dp->id)) + png_error(pp, "validate: row size changed"); + + /* Validate the colour type 3 palette (this can be present on other color + * types.) + */ + standard_palette_validate(dp, pp, pi); + + /* In any case always check for a transparent color (notice that the + * colour type 3 case must not give a successful return on the get_tRNS call + * with these arguments!) + */ + { + png_color_16p trans_color = 0; + + if (png_get_tRNS(pp, pi, 0, 0, &trans_color) & PNG_INFO_tRNS) + { + if (trans_color == 0) + png_error(pp, "validate: unexpected png_get_tRNS (color) result"); + + switch (dp->colour_type) + { + case 0: + dp->transparent.red = dp->transparent.green = dp->transparent.blue = + trans_color->gray; + dp->has_tRNS = 1; + break; + + case 2: + dp->transparent.red = trans_color->red; + dp->transparent.green = trans_color->green; + dp->transparent.blue = trans_color->blue; + dp->has_tRNS = 1; + break; + + case 3: + /* Not expected because it should result in the array case + * above. + */ + png_error(pp, "validate: unexpected png_get_tRNS result"); + break; + + default: + png_error(pp, "validate: invalid tRNS chunk with alpha image"); + } + } + } + + /* Read the number of passes - expected to match the value used when + * creating the image (interlaced or not). This has the side effect of + * turning on interlace handling (if do_interlace is not set.) + */ + dp->npasses = npasses_from_interlace_type(pp, dp->interlace_type); + if (!dp->do_interlace) + { +# ifdef PNG_READ_INTERLACING_SUPPORTED + if (dp->npasses != png_set_interlace_handling(pp)) + png_error(pp, "validate: file changed interlace type"); +# else /* !READ_INTERLACING */ + /* This should never happen: the relevant tests (!do_interlace) should + * not be run. + */ + if (dp->npasses > 1) + png_error(pp, "validate: no libpng interlace support"); +# endif /* !READ_INTERLACING */ + } + + /* Caller calls png_read_update_info or png_start_read_image now, then calls + * part2. + */ +} + +/* This must be called *after* the png_read_update_info call to get the correct + * 'rowbytes' value, otherwise png_get_rowbytes will refer to the untransformed + * image. + */ +static void +standard_info_part2(standard_display *dp, png_const_structp pp, + png_const_infop pi, int nImages) +{ + /* Record cbRow now that it can be found. */ + { + png_byte ct = png_get_color_type(pp, pi); + png_byte bd = png_get_bit_depth(pp, pi); + + if (bd >= 8 && (ct == PNG_COLOR_TYPE_RGB || ct == PNG_COLOR_TYPE_GRAY) && + dp->filler) + ct |= 4; /* handle filler as faked alpha channel */ + + dp->pixel_size = bit_size(pp, ct, bd); + } + dp->bit_width = png_get_image_width(pp, pi) * dp->pixel_size; + dp->cbRow = png_get_rowbytes(pp, pi); + + /* Validate the rowbytes here again. */ + if (dp->cbRow != (dp->bit_width+7)/8) + png_error(pp, "bad png_get_rowbytes calculation"); + + /* Then ensure there is enough space for the output image(s). */ + store_ensure_image(dp->ps, pp, nImages, dp->cbRow, dp->h); +} + +static void +standard_info_imp(standard_display *dp, png_structp pp, png_infop pi, + int nImages) +{ + /* Note that the validation routine has the side effect of turning on + * interlace handling in the subsequent code. + */ + standard_info_part1(dp, pp, pi); + + /* And the info callback has to call this (or png_read_update_info - see + * below in the png_modifier code for that variant. + */ + if (dp->use_update_info) + { + /* For debugging the effect of multiple calls: */ + int i = dp->use_update_info; + while (i-- > 0) + png_read_update_info(pp, pi); + } + + else + png_start_read_image(pp); + + /* Validate the height, width and rowbytes plus ensure that sufficient buffer + * exists for decoding the image. + */ + standard_info_part2(dp, pp, pi, nImages); +} + +static void PNGCBAPI +standard_info(png_structp pp, png_infop pi) +{ + standard_display *dp = voidcast(standard_display*, + png_get_progressive_ptr(pp)); + + /* Call with nImages==1 because the progressive reader can only produce one + * image. + */ + standard_info_imp(dp, pp, pi, 1 /*only one image*/); +} + +static void PNGCBAPI +progressive_row(png_structp ppIn, png_bytep new_row, png_uint_32 y, int pass) +{ + png_const_structp pp = ppIn; + const standard_display *dp = voidcast(standard_display*, + png_get_progressive_ptr(pp)); + + /* When handling interlacing some rows will be absent in each pass, the + * callback still gets called, but with a NULL pointer. This is checked + * in the 'else' clause below. We need our own 'cbRow', but we can't call + * png_get_rowbytes because we got no info structure. + */ + if (new_row != NULL) + { + png_bytep row; + + /* In the case where the reader doesn't do the interlace it gives + * us the y in the sub-image: + */ + if (dp->do_interlace && dp->interlace_type == PNG_INTERLACE_ADAM7) + { +#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED + /* Use this opportunity to validate the png 'current' APIs: */ + if (y != png_get_current_row_number(pp)) + png_error(pp, "png_get_current_row_number is broken"); + + if (pass != png_get_current_pass_number(pp)) + png_error(pp, "png_get_current_pass_number is broken"); +#endif /* USER_TRANSFORM_INFO */ + + y = PNG_ROW_FROM_PASS_ROW(y, pass); + } + + /* Validate this just in case. */ + if (y >= dp->h) + png_error(pp, "invalid y to progressive row callback"); + + row = store_image_row(dp->ps, pp, 0, y); + + /* Combine the new row into the old: */ +#ifdef PNG_READ_INTERLACING_SUPPORTED + if (dp->do_interlace) +#endif /* READ_INTERLACING */ + { + if (dp->interlace_type == PNG_INTERLACE_ADAM7) + deinterlace_row(row, new_row, dp->pixel_size, dp->w, pass, + dp->littleendian); + else + row_copy(row, new_row, dp->pixel_size * dp->w, dp->littleendian); + } +#ifdef PNG_READ_INTERLACING_SUPPORTED + else + png_progressive_combine_row(pp, row, new_row); +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + } + + else if (dp->interlace_type == PNG_INTERLACE_ADAM7 && + PNG_ROW_IN_INTERLACE_PASS(y, pass) && + PNG_PASS_COLS(dp->w, pass) > 0) + png_error(pp, "missing row in progressive de-interlacing"); +} + +static void +sequential_row(standard_display *dp, png_structp pp, png_infop pi, + int iImage, int iDisplay) +{ + int npasses = dp->npasses; + int do_interlace = dp->do_interlace && + dp->interlace_type == PNG_INTERLACE_ADAM7; + png_uint_32 height = standard_height(pp, dp->id); + png_uint_32 width = standard_width(pp, dp->id); + const png_store* ps = dp->ps; + int pass; + + for (pass=0; pass 0 && PNG_ROW_IN_INTERLACE_PASS(y, pass)) + { + /* Read the row into a pair of temporary buffers, then do the + * merge here into the output rows. + */ + png_byte row[STANDARD_ROWMAX], display[STANDARD_ROWMAX]; + + /* The following aids (to some extent) error detection - we can + * see where png_read_row wrote. Use opposite values in row and + * display to make this easier. Don't use 0xff (which is used in + * the image write code to fill unused bits) or 0 (which is a + * likely value to overwrite unused bits with). + */ + memset(row, 0xc5, sizeof row); + memset(display, 0x5c, sizeof display); + + png_read_row(pp, row, display); + + if (iImage >= 0) + deinterlace_row(store_image_row(ps, pp, iImage, y), row, + dp->pixel_size, dp->w, pass, dp->littleendian); + + if (iDisplay >= 0) + deinterlace_row(store_image_row(ps, pp, iDisplay, y), display, + dp->pixel_size, dp->w, pass, dp->littleendian); + } + } + else + png_read_row(pp, + iImage >= 0 ? store_image_row(ps, pp, iImage, y) : NULL, + iDisplay >= 0 ? store_image_row(ps, pp, iDisplay, y) : NULL); + } + } + + /* And finish the read operation (only really necessary if the caller wants + * to find additional data in png_info from chunks after the last IDAT.) + */ + png_read_end(pp, pi); +} + +#ifdef PNG_TEXT_SUPPORTED +static void +standard_check_text(png_const_structp pp, png_const_textp tp, + png_const_charp keyword, png_const_charp text) +{ + char msg[1024]; + size_t pos = safecat(msg, sizeof msg, 0, "text: "); + size_t ok; + + pos = safecat(msg, sizeof msg, pos, keyword); + pos = safecat(msg, sizeof msg, pos, ": "); + ok = pos; + + if (tp->compression != TEXT_COMPRESSION) + { + char buf[64]; + + sprintf(buf, "compression [%d->%d], ", TEXT_COMPRESSION, + tp->compression); + pos = safecat(msg, sizeof msg, pos, buf); + } + + if (tp->key == NULL || strcmp(tp->key, keyword) != 0) + { + pos = safecat(msg, sizeof msg, pos, "keyword \""); + if (tp->key != NULL) + { + pos = safecat(msg, sizeof msg, pos, tp->key); + pos = safecat(msg, sizeof msg, pos, "\", "); + } + + else + pos = safecat(msg, sizeof msg, pos, "null, "); + } + + if (tp->text == NULL) + pos = safecat(msg, sizeof msg, pos, "text lost, "); + + else + { + if (tp->text_length != strlen(text)) + { + char buf[64]; + sprintf(buf, "text length changed[%lu->%lu], ", + (unsigned long)strlen(text), (unsigned long)tp->text_length); + pos = safecat(msg, sizeof msg, pos, buf); + } + + if (strcmp(tp->text, text) != 0) + { + pos = safecat(msg, sizeof msg, pos, "text becomes \""); + pos = safecat(msg, sizeof msg, pos, tp->text); + pos = safecat(msg, sizeof msg, pos, "\" (was \""); + pos = safecat(msg, sizeof msg, pos, text); + pos = safecat(msg, sizeof msg, pos, "\"), "); + } + } + + if (tp->itxt_length != 0) + pos = safecat(msg, sizeof msg, pos, "iTXt length set, "); + + if (tp->lang != NULL) + { + pos = safecat(msg, sizeof msg, pos, "iTXt language \""); + pos = safecat(msg, sizeof msg, pos, tp->lang); + pos = safecat(msg, sizeof msg, pos, "\", "); + } + + if (tp->lang_key != NULL) + { + pos = safecat(msg, sizeof msg, pos, "iTXt keyword \""); + pos = safecat(msg, sizeof msg, pos, tp->lang_key); + pos = safecat(msg, sizeof msg, pos, "\", "); + } + + if (pos > ok) + { + msg[pos-2] = '\0'; /* Remove the ", " at the end */ + png_error(pp, msg); + } +} + +static void +standard_text_validate(standard_display *dp, png_const_structp pp, + png_infop pi, int check_end) +{ + png_textp tp = NULL; + png_uint_32 num_text = png_get_text(pp, pi, &tp, NULL); + + if (num_text == 2 && tp != NULL) + { + standard_check_text(pp, tp, "image name", dp->ps->current->name); + + /* This exists because prior to 1.5.18 the progressive reader left the + * png_struct z_stream unreset at the end of the image, so subsequent + * attempts to use it simply returns Z_STREAM_END. + */ + if (check_end) + standard_check_text(pp, tp+1, "end marker", "end"); + } + + else + { + char msg[64]; + + sprintf(msg, "expected two text items, got %lu", + (unsigned long)num_text); + png_error(pp, msg); + } +} +#else +# define standard_text_validate(dp,pp,pi,check_end) ((void)0) +#endif + +static void +standard_row_validate(standard_display *dp, png_const_structp pp, + int iImage, int iDisplay, png_uint_32 y) +{ + int where; + png_byte std[STANDARD_ROWMAX]; + + /* The row must be pre-initialized to the magic number here for the size + * tests to pass: + */ + memset(std, 178, sizeof std); + standard_row(pp, std, dp->id, y); + + /* At the end both the 'row' and 'display' arrays should end up identical. + * In earlier passes 'row' will be partially filled in, with only the pixels + * that have been read so far, but 'display' will have those pixels + * replicated to fill the unread pixels while reading an interlaced image. + */ + if (iImage >= 0 && + (where = pixel_cmp(std, store_image_row(dp->ps, pp, iImage, y), + dp->bit_width)) != 0) + { + char msg[64]; + sprintf(msg, "PNG image row[%lu][%d] changed from %.2x to %.2x", + (unsigned long)y, where-1, std[where-1], + store_image_row(dp->ps, pp, iImage, y)[where-1]); + png_error(pp, msg); + } + + if (iDisplay >= 0 && + (where = pixel_cmp(std, store_image_row(dp->ps, pp, iDisplay, y), + dp->bit_width)) != 0) + { + char msg[64]; + sprintf(msg, "display row[%lu][%d] changed from %.2x to %.2x", + (unsigned long)y, where-1, std[where-1], + store_image_row(dp->ps, pp, iDisplay, y)[where-1]); + png_error(pp, msg); + } +} + +static void +standard_image_validate(standard_display *dp, png_const_structp pp, int iImage, + int iDisplay) +{ + png_uint_32 y; + + if (iImage >= 0) + store_image_check(dp->ps, pp, iImage); + + if (iDisplay >= 0) + store_image_check(dp->ps, pp, iDisplay); + + for (y=0; yh; ++y) + standard_row_validate(dp, pp, iImage, iDisplay, y); + + /* This avoids false positives if the validation code is never called! */ + dp->ps->validated = 1; +} + +static void PNGCBAPI +standard_end(png_structp ppIn, png_infop pi) +{ + png_const_structp pp = ppIn; + standard_display *dp = voidcast(standard_display*, + png_get_progressive_ptr(pp)); + + UNUSED(pi) + + /* Validate the image - progressive reading only produces one variant for + * interlaced images. + */ + standard_text_validate(dp, pp, pi, + PNG_LIBPNG_VER >= 10518/*check_end: see comments above*/); + standard_image_validate(dp, pp, 0, -1); +} + +/* A single test run checking the standard image to ensure it is not damaged. */ +static void +standard_test(png_store* const psIn, png_uint_32 const id, + int do_interlace, int use_update_info) +{ + standard_display d; + context(psIn, fault); + + /* Set up the display (stack frame) variables from the arguments to the + * function and initialize the locals that are filled in later. + */ + standard_display_init(&d, psIn, id, do_interlace, use_update_info); + + /* Everything is protected by a Try/Catch. The functions called also + * typically have local Try/Catch blocks. + */ + Try + { + png_structp pp; + png_infop pi; + + /* Get a png_struct for reading the image. This will throw an error if it + * fails, so we don't need to check the result. + */ + pp = set_store_for_read(d.ps, &pi, d.id, + d.do_interlace ? (d.ps->progressive ? + "pngvalid progressive deinterlacer" : + "pngvalid sequential deinterlacer") : (d.ps->progressive ? + "progressive reader" : "sequential reader")); + + /* Initialize the palette correctly from the png_store_file. */ + standard_palette_init(&d); + + /* Introduce the correct read function. */ + if (d.ps->progressive) + { + png_set_progressive_read_fn(pp, &d, standard_info, progressive_row, + standard_end); + + /* Now feed data into the reader until we reach the end: */ + store_progressive_read(d.ps, pp, pi); + } + else + { + /* Note that this takes the store, not the display. */ + png_set_read_fn(pp, d.ps, store_read); + + /* Check the header values: */ + png_read_info(pp, pi); + + /* The code tests both versions of the images that the sequential + * reader can produce. + */ + standard_info_imp(&d, pp, pi, 2 /*images*/); + + /* Need the total bytes in the image below; we can't get to this point + * unless the PNG file values have been checked against the expected + * values. + */ + { + sequential_row(&d, pp, pi, 0, 1); + + /* After the last pass loop over the rows again to check that the + * image is correct. + */ + if (!d.speed) + { + standard_text_validate(&d, pp, pi, 1/*check_end*/); + standard_image_validate(&d, pp, 0, 1); + } + else + d.ps->validated = 1; + } + } + + /* Check for validation. */ + if (!d.ps->validated) + png_error(pp, "image read failed silently"); + + /* Successful completion. */ + } + + Catch(fault) + d.ps = fault; /* make sure this hasn't been clobbered. */ + + /* In either case clean up the store. */ + store_read_reset(d.ps); +} + +static int +test_standard(png_modifier* const pm, png_byte const colour_type, + int bdlo, int const bdhi) +{ + for (; bdlo <= bdhi; ++bdlo) + { + int interlace_type; + + for (interlace_type = PNG_INTERLACE_NONE; + interlace_type < INTERLACE_LAST; ++interlace_type) + { + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + interlace_type, 0, 0, 0), do_read_interlace, pm->use_update_info); + + if (fail(pm)) + return 0; + } + } + + return 1; /* keep going */ +} + +static void +perform_standard_test(png_modifier *pm) +{ + /* Test each colour type over the valid range of bit depths (expressed as + * log2(bit_depth) in turn, stop as soon as any error is detected. + */ + if (!test_standard(pm, 0, 0, READ_BDHI)) + return; + + if (!test_standard(pm, 2, 3, READ_BDHI)) + return; + + if (!test_standard(pm, 3, 0, 3)) + return; + + if (!test_standard(pm, 4, 3, READ_BDHI)) + return; + + if (!test_standard(pm, 6, 3, READ_BDHI)) + return; +} + + +/********************************** SIZE TESTS ********************************/ +static int +test_size(png_modifier* const pm, png_byte const colour_type, + int bdlo, int const bdhi) +{ + /* Run the tests on each combination. + * + * NOTE: on my 32 bit x86 each of the following blocks takes + * a total of 3.5 seconds if done across every combo of bit depth + * width and height. This is a waste of time in practice, hence the + * hinc and winc stuff: + */ + static const png_byte hinc[] = {1, 3, 11, 1, 5}; + static const png_byte winc[] = {1, 9, 5, 7, 1}; + int save_bdlo = bdlo; + + for (; bdlo <= bdhi; ++bdlo) + { + png_uint_32 h, w; + + for (h=1; h<=16; h+=hinc[bdlo]) for (w=1; w<=16; w+=winc[bdlo]) + { + /* First test all the 'size' images against the sequential + * reader using libpng to deinterlace (where required.) This + * validates the write side of libpng. There are four possibilities + * to validate. + */ + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_NONE, w, h, 0), 0/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; + + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_NONE, w, h, 1), 0/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; + + /* Now validate the interlaced read side - do_interlace true, + * in the progressive case this does actually make a difference + * to the code used in the non-interlaced case too. + */ + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_NONE, w, h, 0), 1/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; + +# if CAN_WRITE_INTERLACE + /* Validate the pngvalid code itself: */ + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_ADAM7, w, h, 1), 1/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; +# endif + } + } + + /* Now do the tests of libpng interlace handling, after we have made sure + * that the pngvalid version works: + */ + for (bdlo = save_bdlo; bdlo <= bdhi; ++bdlo) + { + png_uint_32 h, w; + + for (h=1; h<=16; h+=hinc[bdlo]) for (w=1; w<=16; w+=winc[bdlo]) + { +# ifdef PNG_READ_INTERLACING_SUPPORTED + /* Test with pngvalid generated interlaced images first; we have + * already verify these are ok (unless pngvalid has self-consistent + * read/write errors, which is unlikely), so this detects errors in the + * read side first: + */ +# if CAN_WRITE_INTERLACE + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_ADAM7, w, h, 1), 0/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; +# endif +# endif /* READ_INTERLACING */ + +# ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* Test the libpng write side against the pngvalid read side: */ + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_ADAM7, w, h, 0), 1/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; +# endif + +# ifdef PNG_READ_INTERLACING_SUPPORTED +# ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* Test both together: */ + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_ADAM7, w, h, 0), 0/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; +# endif +# endif /* READ_INTERLACING */ + } + } + + return 1; /* keep going */ +} + +static void +perform_size_test(png_modifier *pm) +{ + /* Test each colour type over the valid range of bit depths (expressed as + * log2(bit_depth) in turn, stop as soon as any error is detected. + */ + if (!test_size(pm, 0, 0, READ_BDHI)) + return; + + if (!test_size(pm, 2, 3, READ_BDHI)) + return; + + /* For the moment don't do the palette test - it's a waste of time when + * compared to the grayscale test. + */ +#if 0 + if (!test_size(pm, 3, 0, 3)) + return; +#endif + + if (!test_size(pm, 4, 3, READ_BDHI)) + return; + + if (!test_size(pm, 6, 3, READ_BDHI)) + return; +} + + +/******************************* TRANSFORM TESTS ******************************/ +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +/* A set of tests to validate libpng image transforms. The possibilities here + * are legion because the transforms can be combined in a combinatorial + * fashion. To deal with this some measure of restraint is required, otherwise + * the tests would take forever. + */ +typedef struct image_pixel +{ + /* A local (pngvalid) representation of a PNG pixel, in all its + * various forms. + */ + unsigned int red, green, blue, alpha; /* For non-palette images. */ + unsigned int palette_index; /* For a palette image. */ + png_byte colour_type; /* As in the spec. */ + png_byte bit_depth; /* Defines bit size in row */ + png_byte sample_depth; /* Scale of samples */ + unsigned int have_tRNS :1; /* tRNS chunk may need processing */ + unsigned int swap_rgb :1; /* RGB swapped to BGR */ + unsigned int alpha_first :1; /* Alpha at start, not end */ + unsigned int alpha_inverted :1; /* Alpha channel inverted */ + unsigned int mono_inverted :1; /* Gray channel inverted */ + unsigned int swap16 :1; /* Byte swap 16-bit components */ + unsigned int littleendian :1; /* High bits on right */ + unsigned int sig_bits :1; /* Pixel shifted (sig bits only) */ + + /* For checking the code calculates double precision floating point values + * along with an error value, accumulated from the transforms. Because an + * sBIT setting allows larger error bounds (indeed, by the spec, apparently + * up to just less than +/-1 in the scaled value) the *lowest* sBIT for each + * channel is stored. This sBIT value is folded in to the stored error value + * at the end of the application of the transforms to the pixel. + * + * If sig_bits is set above the red, green, blue and alpha values have been + * scaled so they only contain the significant bits of the component values. + */ + double redf, greenf, bluef, alphaf; + double rede, greene, bluee, alphae; + png_byte red_sBIT, green_sBIT, blue_sBIT, alpha_sBIT; +} image_pixel; + +/* Shared utility function, see below. */ +static void +image_pixel_setf(image_pixel *this, unsigned int rMax, unsigned int gMax, + unsigned int bMax, unsigned int aMax) +{ + this->redf = this->red / (double)rMax; + this->greenf = this->green / (double)gMax; + this->bluef = this->blue / (double)bMax; + this->alphaf = this->alpha / (double)aMax; + + if (this->red < rMax) + this->rede = this->redf * DBL_EPSILON; + else + this->rede = 0; + if (this->green < gMax) + this->greene = this->greenf * DBL_EPSILON; + else + this->greene = 0; + if (this->blue < bMax) + this->bluee = this->bluef * DBL_EPSILON; + else + this->bluee = 0; + if (this->alpha < aMax) + this->alphae = this->alphaf * DBL_EPSILON; + else + this->alphae = 0; +} + +/* Initialize the structure for the next pixel - call this before doing any + * transforms and call it for each pixel since all the fields may need to be + * reset. + */ +static void +image_pixel_init(image_pixel *this, png_const_bytep row, png_byte colour_type, + png_byte bit_depth, png_uint_32 x, store_palette palette, + const image_pixel *format /*from pngvalid transform of input*/) +{ + png_byte sample_depth = + (png_byte)(colour_type == PNG_COLOR_TYPE_PALETTE ? 8 : bit_depth); + unsigned int max = (1U<swap16); + int littleendian = (format != 0 && format->littleendian); + int sig_bits = (format != 0 && format->sig_bits); + + /* Initially just set everything to the same number and the alpha to opaque. + * Note that this currently assumes a simple palette where entry x has colour + * rgb(x,x,x)! + */ + this->palette_index = this->red = this->green = this->blue = + sample(row, colour_type, bit_depth, x, 0, swap16, littleendian); + this->alpha = max; + this->red_sBIT = this->green_sBIT = this->blue_sBIT = this->alpha_sBIT = + sample_depth; + + /* Then override as appropriate: */ + if (colour_type == 3) /* palette */ + { + /* This permits the caller to default to the sample value. */ + if (palette != 0) + { + unsigned int i = this->palette_index; + + this->red = palette[i].red; + this->green = palette[i].green; + this->blue = palette[i].blue; + this->alpha = palette[i].alpha; + } + } + + else /* not palette */ + { + unsigned int i = 0; + + if ((colour_type & 4) != 0 && format != 0 && format->alpha_first) + { + this->alpha = this->red; + /* This handles the gray case for 'AG' pixels */ + this->palette_index = this->red = this->green = this->blue = + sample(row, colour_type, bit_depth, x, 1, swap16, littleendian); + i = 1; + } + + if (colour_type & 2) + { + /* Green is second for both BGR and RGB: */ + this->green = sample(row, colour_type, bit_depth, x, ++i, swap16, + littleendian); + + if (format != 0 && format->swap_rgb) /* BGR */ + this->red = sample(row, colour_type, bit_depth, x, ++i, swap16, + littleendian); + else + this->blue = sample(row, colour_type, bit_depth, x, ++i, swap16, + littleendian); + } + + else /* grayscale */ if (format != 0 && format->mono_inverted) + this->red = this->green = this->blue = this->red ^ max; + + if ((colour_type & 4) != 0) /* alpha */ + { + if (format == 0 || !format->alpha_first) + this->alpha = sample(row, colour_type, bit_depth, x, ++i, swap16, + littleendian); + + if (format != 0 && format->alpha_inverted) + this->alpha ^= max; + } + } + + /* Calculate the scaled values, these are simply the values divided by + * 'max' and the error is initialized to the double precision epsilon value + * from the header file. + */ + image_pixel_setf(this, + sig_bits ? (1U << format->red_sBIT)-1 : max, + sig_bits ? (1U << format->green_sBIT)-1 : max, + sig_bits ? (1U << format->blue_sBIT)-1 : max, + sig_bits ? (1U << format->alpha_sBIT)-1 : max); + + /* Store the input information for use in the transforms - these will + * modify the information. + */ + this->colour_type = colour_type; + this->bit_depth = bit_depth; + this->sample_depth = sample_depth; + this->have_tRNS = 0; + this->swap_rgb = 0; + this->alpha_first = 0; + this->alpha_inverted = 0; + this->mono_inverted = 0; + this->swap16 = 0; + this->littleendian = 0; + this->sig_bits = 0; +} + +#if defined PNG_READ_EXPAND_SUPPORTED || defined PNG_READ_GRAY_TO_RGB_SUPPORTED\ + || defined PNG_READ_EXPAND_SUPPORTED || defined PNG_READ_EXPAND_16_SUPPORTED\ + || defined PNG_READ_BACKGROUND_SUPPORTED +/* Convert a palette image to an rgb image. This necessarily converts the tRNS + * chunk at the same time, because the tRNS will be in palette form. The way + * palette validation works means that the original palette is never updated, + * instead the image_pixel value from the row contains the RGB of the + * corresponding palette entry and *this* is updated. Consequently this routine + * only needs to change the colour type information. + */ +static void +image_pixel_convert_PLTE(image_pixel *this) +{ + if (this->colour_type == PNG_COLOR_TYPE_PALETTE) + { + if (this->have_tRNS) + { + this->colour_type = PNG_COLOR_TYPE_RGB_ALPHA; + this->have_tRNS = 0; + } + else + this->colour_type = PNG_COLOR_TYPE_RGB; + + /* The bit depth of the row changes at this point too (notice that this is + * the row format, not the sample depth, which is separate.) + */ + this->bit_depth = 8; + } +} + +/* Add an alpha channel; this will import the tRNS information because tRNS is + * not valid in an alpha image. The bit depth will invariably be set to at + * least 8 prior to 1.7.0. Palette images will be converted to alpha (using + * the above API). With png_set_background the alpha channel is never expanded + * but this routine is used by pngvalid to simplify code; 'for_background' + * records this. + */ +static void +image_pixel_add_alpha(image_pixel *this, const standard_display *display, + int for_background) +{ + if (this->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(this); + + if ((this->colour_type & PNG_COLOR_MASK_ALPHA) == 0) + { + if (this->colour_type == PNG_COLOR_TYPE_GRAY) + { +# if PNG_LIBPNG_VER < 10700 + if (!for_background && this->bit_depth < 8) + this->bit_depth = this->sample_depth = 8; +# endif + + if (this->have_tRNS) + { + /* After 1.7 the expansion of bit depth only happens if there is a + * tRNS chunk to expand at this point. + */ +# if PNG_LIBPNG_VER >= 10700 + if (!for_background && this->bit_depth < 8) + this->bit_depth = this->sample_depth = 8; +# endif + + this->have_tRNS = 0; + + /* Check the input, original, channel value here against the + * original tRNS gray chunk valie. + */ + if (this->red == display->transparent.red) + this->alphaf = 0; + else + this->alphaf = 1; + } + else + this->alphaf = 1; + + this->colour_type = PNG_COLOR_TYPE_GRAY_ALPHA; + } + + else if (this->colour_type == PNG_COLOR_TYPE_RGB) + { + if (this->have_tRNS) + { + this->have_tRNS = 0; + + /* Again, check the exact input values, not the current transformed + * value! + */ + if (this->red == display->transparent.red && + this->green == display->transparent.green && + this->blue == display->transparent.blue) + this->alphaf = 0; + else + this->alphaf = 1; + } + else + this->alphaf = 1; + + this->colour_type = PNG_COLOR_TYPE_RGB_ALPHA; + } + + /* The error in the alpha is zero and the sBIT value comes from the + * original sBIT data (actually it will always be the original bit depth). + */ + this->alphae = 0; + this->alpha_sBIT = display->alpha_sBIT; + } +} +#endif /* transforms that need image_pixel_add_alpha */ + +struct transform_display; +typedef struct image_transform +{ + /* The name of this transform: a string. */ + const char *name; + + /* Each transform can be disabled from the command line: */ + int enable; + + /* The global list of transforms; read only. */ + struct image_transform *const list; + + /* The global count of the number of times this transform has been set on an + * image. + */ + unsigned int global_use; + + /* The local count of the number of times this transform has been set. */ + unsigned int local_use; + + /* The next transform in the list, each transform must call its own next + * transform after it has processed the pixel successfully. + */ + const struct image_transform *next; + + /* A single transform for the image, expressed as a series of function + * callbacks and some space for values. + * + * First a callback to add any required modifications to the png_modifier; + * this gets called just before the modifier is set up for read. + */ + void (*ini)(const struct image_transform *this, + struct transform_display *that); + + /* And a callback to set the transform on the current png_read_struct: + */ + void (*set)(const struct image_transform *this, + struct transform_display *that, png_structp pp, png_infop pi); + + /* Then a transform that takes an input pixel in one PNG format or another + * and modifies it by a pngvalid implementation of the transform (thus + * duplicating the libpng intent without, we hope, duplicating the bugs + * in the libpng implementation!) The png_structp is solely to allow error + * reporting via png_error and png_warning. + */ + void (*mod)(const struct image_transform *this, image_pixel *that, + png_const_structp pp, const struct transform_display *display); + + /* Add this transform to the list and return true if the transform is + * meaningful for this colour type and bit depth - if false then the + * transform should have no effect on the image so there's not a lot of + * point running it. + */ + int (*add)(struct image_transform *this, + const struct image_transform **that, png_byte colour_type, + png_byte bit_depth); +} image_transform; + +typedef struct transform_display +{ + standard_display this; + + /* Parameters */ + png_modifier* pm; + const image_transform* transform_list; + unsigned int max_gamma_8; + + /* Local variables */ + png_byte output_colour_type; + png_byte output_bit_depth; + png_byte unpacked; + + /* Modifications (not necessarily used.) */ + gama_modification gama_mod; + chrm_modification chrm_mod; + srgb_modification srgb_mod; +} transform_display; + +/* Set sRGB, cHRM and gAMA transforms as required by the current encoding. */ +static void +transform_set_encoding(transform_display *this) +{ + /* Set up the png_modifier '_current' fields then use these to determine how + * to add appropriate chunks. + */ + png_modifier *pm = this->pm; + + modifier_set_encoding(pm); + + if (modifier_color_encoding_is_set(pm)) + { + if (modifier_color_encoding_is_sRGB(pm)) + srgb_modification_init(&this->srgb_mod, pm, PNG_sRGB_INTENT_ABSOLUTE); + + else + { + /* Set gAMA and cHRM separately. */ + gama_modification_init(&this->gama_mod, pm, pm->current_gamma); + + if (pm->current_encoding != 0) + chrm_modification_init(&this->chrm_mod, pm, pm->current_encoding); + } + } +} + +/* Three functions to end the list: */ +static void +image_transform_ini_end(const image_transform *this, + transform_display *that) +{ + UNUSED(this) + UNUSED(that) +} + +static void +image_transform_set_end(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + UNUSED(this) + UNUSED(that) + UNUSED(pp) + UNUSED(pi) +} + +/* At the end of the list recalculate the output image pixel value from the + * double precision values set up by the preceding 'mod' calls: + */ +static unsigned int +sample_scale(double sample_value, unsigned int scale) +{ + sample_value = floor(sample_value * scale + .5); + + /* Return NaN as 0: */ + if (!(sample_value > 0)) + sample_value = 0; + else if (sample_value > scale) + sample_value = scale; + + return (unsigned int)sample_value; +} + +static void +image_transform_mod_end(const image_transform *this, image_pixel *that, + png_const_structp pp, const transform_display *display) +{ + unsigned int scale = (1U<sample_depth)-1; + int sig_bits = that->sig_bits; + + UNUSED(this) + UNUSED(pp) + UNUSED(display) + + /* At the end recalculate the digitized red green and blue values according + * to the current sample_depth of the pixel. + * + * The sample value is simply scaled to the maximum, checking for over + * and underflow (which can both happen for some image transforms, + * including simple size scaling, though libpng doesn't do that at present. + */ + that->red = sample_scale(that->redf, scale); + + /* This is a bit bogus; really the above calculation should use the red_sBIT + * value, not sample_depth, but because libpng does png_set_shift by just + * shifting the bits we get errors if we don't do it the same way. + */ + if (sig_bits && that->red_sBIT < that->sample_depth) + that->red >>= that->sample_depth - that->red_sBIT; + + /* The error value is increased, at the end, according to the lowest sBIT + * value seen. Common sense tells us that the intermediate integer + * representations are no more accurate than +/- 0.5 in the integral values, + * the sBIT allows the implementation to be worse than this. In addition the + * PNG specification actually permits any error within the range (-1..+1), + * but that is ignored here. Instead the final digitized value is compared, + * below to the digitized value of the error limits - this has the net effect + * of allowing (almost) +/-1 in the output value. It's difficult to see how + * any algorithm that digitizes intermediate results can be more accurate. + */ + that->rede += 1./(2*((1U<red_sBIT)-1)); + + if (that->colour_type & PNG_COLOR_MASK_COLOR) + { + that->green = sample_scale(that->greenf, scale); + if (sig_bits && that->green_sBIT < that->sample_depth) + that->green >>= that->sample_depth - that->green_sBIT; + + that->blue = sample_scale(that->bluef, scale); + if (sig_bits && that->blue_sBIT < that->sample_depth) + that->blue >>= that->sample_depth - that->blue_sBIT; + + that->greene += 1./(2*((1U<green_sBIT)-1)); + that->bluee += 1./(2*((1U<blue_sBIT)-1)); + } + else + { + that->blue = that->green = that->red; + that->bluef = that->greenf = that->redf; + that->bluee = that->greene = that->rede; + } + + if ((that->colour_type & PNG_COLOR_MASK_ALPHA) || + that->colour_type == PNG_COLOR_TYPE_PALETTE) + { + that->alpha = sample_scale(that->alphaf, scale); + that->alphae += 1./(2*((1U<alpha_sBIT)-1)); + } + else + { + that->alpha = scale; /* opaque */ + that->alphaf = 1; /* Override this. */ + that->alphae = 0; /* It's exact ;-) */ + } + + if (sig_bits && that->alpha_sBIT < that->sample_depth) + that->alpha >>= that->sample_depth - that->alpha_sBIT; +} + +/* Static 'end' structure: */ +static image_transform image_transform_end = +{ + "(end)", /* name */ + 1, /* enable */ + 0, /* list */ + 0, /* global_use */ + 0, /* local_use */ + 0, /* next */ + image_transform_ini_end, + image_transform_set_end, + image_transform_mod_end, + 0 /* never called, I want it to crash if it is! */ +}; + +/* Reader callbacks and implementations, where they differ from the standard + * ones. + */ +static void +transform_display_init(transform_display *dp, png_modifier *pm, png_uint_32 id, + const image_transform *transform_list) +{ + memset(dp, 0, sizeof *dp); + + /* Standard fields */ + standard_display_init(&dp->this, &pm->this, id, do_read_interlace, + pm->use_update_info); + + /* Parameter fields */ + dp->pm = pm; + dp->transform_list = transform_list; + dp->max_gamma_8 = 16; + + /* Local variable fields */ + dp->output_colour_type = 255; /* invalid */ + dp->output_bit_depth = 255; /* invalid */ + dp->unpacked = 0; /* not unpacked */ +} + +static void +transform_info_imp(transform_display *dp, png_structp pp, png_infop pi) +{ + /* Reuse the standard stuff as appropriate. */ + standard_info_part1(&dp->this, pp, pi); + + /* Now set the list of transforms. */ + dp->transform_list->set(dp->transform_list, dp, pp, pi); + + /* Update the info structure for these transforms: */ + { + int i = dp->this.use_update_info; + /* Always do one call, even if use_update_info is 0. */ + do + png_read_update_info(pp, pi); + while (--i > 0); + } + + /* And get the output information into the standard_display */ + standard_info_part2(&dp->this, pp, pi, 1/*images*/); + + /* Plus the extra stuff we need for the transform tests: */ + dp->output_colour_type = png_get_color_type(pp, pi); + dp->output_bit_depth = png_get_bit_depth(pp, pi); + + /* If png_set_filler is in action then fake the output color type to include + * an alpha channel where appropriate. + */ + if (dp->output_bit_depth >= 8 && + (dp->output_colour_type == PNG_COLOR_TYPE_RGB || + dp->output_colour_type == PNG_COLOR_TYPE_GRAY) && dp->this.filler) + dp->output_colour_type |= 4; + + /* Validate the combination of colour type and bit depth that we are getting + * out of libpng; the semantics of something not in the PNG spec are, at + * best, unclear. + */ + switch (dp->output_colour_type) + { + case PNG_COLOR_TYPE_PALETTE: + if (dp->output_bit_depth > 8) goto error; + /* FALLTHROUGH */ + case PNG_COLOR_TYPE_GRAY: + if (dp->output_bit_depth == 1 || dp->output_bit_depth == 2 || + dp->output_bit_depth == 4) + break; + /* FALLTHROUGH */ + default: + if (dp->output_bit_depth == 8 || dp->output_bit_depth == 16) + break; + /* FALLTHROUGH */ + error: + { + char message[128]; + size_t pos; + + pos = safecat(message, sizeof message, 0, + "invalid final bit depth: colour type("); + pos = safecatn(message, sizeof message, pos, dp->output_colour_type); + pos = safecat(message, sizeof message, pos, ") with bit depth: "); + pos = safecatn(message, sizeof message, pos, dp->output_bit_depth); + + png_error(pp, message); + } + } + + /* Use a test pixel to check that the output agrees with what we expect - + * this avoids running the whole test if the output is unexpected. This also + * checks for internal errors. + */ + { + image_pixel test_pixel; + + memset(&test_pixel, 0, sizeof test_pixel); + test_pixel.colour_type = dp->this.colour_type; /* input */ + test_pixel.bit_depth = dp->this.bit_depth; + if (test_pixel.colour_type == PNG_COLOR_TYPE_PALETTE) + test_pixel.sample_depth = 8; + else + test_pixel.sample_depth = test_pixel.bit_depth; + /* Don't need sBIT here, but it must be set to non-zero to avoid + * arithmetic overflows. + */ + test_pixel.have_tRNS = dp->this.is_transparent != 0; + test_pixel.red_sBIT = test_pixel.green_sBIT = test_pixel.blue_sBIT = + test_pixel.alpha_sBIT = test_pixel.sample_depth; + + dp->transform_list->mod(dp->transform_list, &test_pixel, pp, dp); + + if (test_pixel.colour_type != dp->output_colour_type) + { + char message[128]; + size_t pos = safecat(message, sizeof message, 0, "colour type "); + + pos = safecatn(message, sizeof message, pos, dp->output_colour_type); + pos = safecat(message, sizeof message, pos, " expected "); + pos = safecatn(message, sizeof message, pos, test_pixel.colour_type); + + png_error(pp, message); + } + + if (test_pixel.bit_depth != dp->output_bit_depth) + { + char message[128]; + size_t pos = safecat(message, sizeof message, 0, "bit depth "); + + pos = safecatn(message, sizeof message, pos, dp->output_bit_depth); + pos = safecat(message, sizeof message, pos, " expected "); + pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth); + + png_error(pp, message); + } + + /* If both bit depth and colour type are correct check the sample depth. + */ + if (test_pixel.colour_type == PNG_COLOR_TYPE_PALETTE && + test_pixel.sample_depth != 8) /* oops - internal error! */ + png_error(pp, "pngvalid: internal: palette sample depth not 8"); + else if (dp->unpacked && test_pixel.bit_depth != 8) + png_error(pp, "pngvalid: internal: bad unpacked pixel depth"); + else if (!dp->unpacked && test_pixel.colour_type != PNG_COLOR_TYPE_PALETTE + && test_pixel.bit_depth != test_pixel.sample_depth) + { + char message[128]; + size_t pos = safecat(message, sizeof message, 0, + "internal: sample depth "); + + /* Because unless something has set 'unpacked' or the image is palette + * mapped we expect the transform to keep sample depth and bit depth + * the same. + */ + pos = safecatn(message, sizeof message, pos, test_pixel.sample_depth); + pos = safecat(message, sizeof message, pos, " expected "); + pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth); + + png_error(pp, message); + } + else if (test_pixel.bit_depth != dp->output_bit_depth) + { + /* This could be a libpng error too; libpng has not produced what we + * expect for the output bit depth. + */ + char message[128]; + size_t pos = safecat(message, sizeof message, 0, + "internal: bit depth "); + + pos = safecatn(message, sizeof message, pos, dp->output_bit_depth); + pos = safecat(message, sizeof message, pos, " expected "); + pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth); + + png_error(pp, message); + } + } +} + +static void PNGCBAPI +transform_info(png_structp pp, png_infop pi) +{ + transform_info_imp(voidcast(transform_display*, png_get_progressive_ptr(pp)), + pp, pi); +} + +static void +transform_range_check(png_const_structp pp, unsigned int r, unsigned int g, + unsigned int b, unsigned int a, unsigned int in_digitized, double in, + unsigned int out, png_byte sample_depth, double err, double limit, + const char *name, double digitization_error) +{ + /* Compare the scaled, digitzed, values of our local calculation (in+-err) + * with the digitized values libpng produced; 'sample_depth' is the actual + * digitization depth of the libpng output colors (the bit depth except for + * palette images where it is always 8.) The check on 'err' is to detect + * internal errors in pngvalid itself. + */ + unsigned int max = (1U< limit ||) !(out >= in_min && out <= in_max)) + { + char message[256]; + size_t pos; + + pos = safecat(message, sizeof message, 0, name); + pos = safecat(message, sizeof message, pos, " output value error: rgba("); + pos = safecatn(message, sizeof message, pos, r); + pos = safecat(message, sizeof message, pos, ","); + pos = safecatn(message, sizeof message, pos, g); + pos = safecat(message, sizeof message, pos, ","); + pos = safecatn(message, sizeof message, pos, b); + pos = safecat(message, sizeof message, pos, ","); + pos = safecatn(message, sizeof message, pos, a); + pos = safecat(message, sizeof message, pos, "): "); + pos = safecatn(message, sizeof message, pos, out); + pos = safecat(message, sizeof message, pos, " expected: "); + pos = safecatn(message, sizeof message, pos, in_digitized); + pos = safecat(message, sizeof message, pos, " ("); + pos = safecatd(message, sizeof message, pos, (in-err)*max, 3); + pos = safecat(message, sizeof message, pos, ".."); + pos = safecatd(message, sizeof message, pos, (in+err)*max, 3); + pos = safecat(message, sizeof message, pos, ")"); + + png_error(pp, message); + } + + UNUSED(limit) +} + +static void +transform_image_validate(transform_display *dp, png_const_structp pp, + png_infop pi) +{ + /* Constants for the loop below: */ + const png_store* const ps = dp->this.ps; + png_byte in_ct = dp->this.colour_type; + png_byte in_bd = dp->this.bit_depth; + png_uint_32 w = dp->this.w; + png_uint_32 h = dp->this.h; + png_byte out_ct = dp->output_colour_type; + png_byte out_bd = dp->output_bit_depth; + png_byte sample_depth = + (png_byte)(out_ct == PNG_COLOR_TYPE_PALETTE ? 8 : out_bd); + png_byte red_sBIT = dp->this.red_sBIT; + png_byte green_sBIT = dp->this.green_sBIT; + png_byte blue_sBIT = dp->this.blue_sBIT; + png_byte alpha_sBIT = dp->this.alpha_sBIT; + int have_tRNS = dp->this.is_transparent; + double digitization_error; + + store_palette out_palette; + png_uint_32 y; + + UNUSED(pi) + + /* Check for row overwrite errors */ + store_image_check(dp->this.ps, pp, 0); + + /* Read the palette corresponding to the output if the output colour type + * indicates a palette, otherwise set out_palette to garbage. + */ + if (out_ct == PNG_COLOR_TYPE_PALETTE) + { + /* Validate that the palette count itself has not changed - this is not + * expected. + */ + int npalette = (-1); + + (void)read_palette(out_palette, &npalette, pp, pi); + if (npalette != dp->this.npalette) + png_error(pp, "unexpected change in palette size"); + + digitization_error = .5; + } + else + { + png_byte in_sample_depth; + + memset(out_palette, 0x5e, sizeof out_palette); + + /* use-input-precision means assume that if the input has 8 bit (or less) + * samples and the output has 16 bit samples the calculations will be done + * with 8 bit precision, not 16. + */ + if (in_ct == PNG_COLOR_TYPE_PALETTE || in_bd < 16) + in_sample_depth = 8; + else + in_sample_depth = in_bd; + + if (sample_depth != 16 || in_sample_depth > 8 || + !dp->pm->calculations_use_input_precision) + digitization_error = .5; + + /* Else calculations are at 8 bit precision, and the output actually + * consists of scaled 8-bit values, so scale .5 in 8 bits to the 16 bits: + */ + else + digitization_error = .5 * 257; + } + + for (y=0; ythis.palette, + NULL); + + in_pixel.red_sBIT = red_sBIT; + in_pixel.green_sBIT = green_sBIT; + in_pixel.blue_sBIT = blue_sBIT; + in_pixel.alpha_sBIT = alpha_sBIT; + in_pixel.have_tRNS = have_tRNS != 0; + + /* For error detection, below. */ + r = in_pixel.red; + g = in_pixel.green; + b = in_pixel.blue; + a = in_pixel.alpha; + + /* This applies the transforms to the input data, including output + * format operations which must be used when reading the output + * pixel that libpng produces. + */ + dp->transform_list->mod(dp->transform_list, &in_pixel, pp, dp); + + /* Read the output pixel and compare it to what we got, we don't + * use the error field here, so no need to update sBIT. in_pixel + * says whether we expect libpng to change the output format. + */ + image_pixel_init(&out_pixel, pRow, out_ct, out_bd, x, out_palette, + &in_pixel); + + /* We don't expect changes to the index here even if the bit depth is + * changed. + */ + if (in_ct == PNG_COLOR_TYPE_PALETTE && + out_ct == PNG_COLOR_TYPE_PALETTE) + { + if (in_pixel.palette_index != out_pixel.palette_index) + png_error(pp, "unexpected transformed palette index"); + } + + /* Check the colours for palette images too - in fact the palette could + * be separately verified itself in most cases. + */ + if (in_pixel.red != out_pixel.red) + transform_range_check(pp, r, g, b, a, in_pixel.red, in_pixel.redf, + out_pixel.red, sample_depth, in_pixel.rede, + dp->pm->limit + 1./(2*((1U<pm->limit + 1./(2*((1U<pm->limit + 1./(2*((1U<pm->limit + 1./(2*((1U<this.ps->validated = 1; +} + +static void PNGCBAPI +transform_end(png_structp ppIn, png_infop pi) +{ + png_const_structp pp = ppIn; + transform_display *dp = voidcast(transform_display*, + png_get_progressive_ptr(pp)); + + if (!dp->this.speed) + transform_image_validate(dp, pp, pi); + else + dp->this.ps->validated = 1; +} + +/* A single test run. */ +static void +transform_test(png_modifier *pmIn, png_uint_32 idIn, + const image_transform* transform_listIn, const char * const name) +{ + transform_display d; + context(&pmIn->this, fault); + + transform_display_init(&d, pmIn, idIn, transform_listIn); + + Try + { + size_t pos = 0; + png_structp pp; + png_infop pi; + char full_name[256]; + + /* Make sure the encoding fields are correct and enter the required + * modifications. + */ + transform_set_encoding(&d); + + /* Add any modifications required by the transform list. */ + d.transform_list->ini(d.transform_list, &d); + + /* Add the color space information, if any, to the name. */ + pos = safecat(full_name, sizeof full_name, pos, name); + pos = safecat_current_encoding(full_name, sizeof full_name, pos, d.pm); + + /* Get a png_struct for reading the image. */ + pp = set_modifier_for_read(d.pm, &pi, d.this.id, full_name); + standard_palette_init(&d.this); + +# if 0 + /* Logging (debugging only) */ + { + char buffer[256]; + + (void)store_message(&d.pm->this, pp, buffer, sizeof buffer, 0, + "running test"); + + fprintf(stderr, "%s\n", buffer); + } +# endif + + /* Introduce the correct read function. */ + if (d.pm->this.progressive) + { + /* Share the row function with the standard implementation. */ + png_set_progressive_read_fn(pp, &d, transform_info, progressive_row, + transform_end); + + /* Now feed data into the reader until we reach the end: */ + modifier_progressive_read(d.pm, pp, pi); + } + else + { + /* modifier_read expects a png_modifier* */ + png_set_read_fn(pp, d.pm, modifier_read); + + /* Check the header values: */ + png_read_info(pp, pi); + + /* Process the 'info' requirements. Only one image is generated */ + transform_info_imp(&d, pp, pi); + + sequential_row(&d.this, pp, pi, -1, 0); + + if (!d.this.speed) + transform_image_validate(&d, pp, pi); + else + d.this.ps->validated = 1; + } + + modifier_reset(d.pm); + } + + Catch(fault) + { + modifier_reset(voidcast(png_modifier*,(void*)fault)); + } +} + +/* The transforms: */ +#define ITSTRUCT(name) image_transform_##name +#define ITDATA(name) image_transform_data_##name +#define image_transform_ini image_transform_default_ini +#define IT(name)\ +static image_transform ITSTRUCT(name) =\ +{\ + #name,\ + 1, /*enable*/\ + &PT, /*list*/\ + 0, /*global_use*/\ + 0, /*local_use*/\ + 0, /*next*/\ + image_transform_ini,\ + image_transform_png_set_##name##_set,\ + image_transform_png_set_##name##_mod,\ + image_transform_png_set_##name##_add\ +} +#define PT ITSTRUCT(end) /* stores the previous transform */ + +/* To save code: */ +extern void image_transform_default_ini(const image_transform *this, + transform_display *that); /* silence GCC warnings */ + +void /* private, but almost always needed */ +image_transform_default_ini(const image_transform *this, + transform_display *that) +{ + this->next->ini(this->next, that); +} + +#ifdef PNG_READ_BACKGROUND_SUPPORTED +static int +image_transform_default_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return 1; +} +#endif + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* png_set_palette_to_rgb */ +static void +image_transform_png_set_palette_to_rgb_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_palette_to_rgb(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_palette_to_rgb_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_palette_to_rgb_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return colour_type == PNG_COLOR_TYPE_PALETTE; +} + +IT(palette_to_rgb); +#undef PT +#define PT ITSTRUCT(palette_to_rgb) +#endif /* PNG_READ_EXPAND_SUPPORTED */ + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* png_set_tRNS_to_alpha */ +static void +image_transform_png_set_tRNS_to_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_tRNS_to_alpha(pp); + + /* If there was a tRNS chunk that would get expanded and add an alpha + * channel is_transparent must be updated: + */ + if (that->this.has_tRNS) + that->this.is_transparent = 1; + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_tRNS_to_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ +#if PNG_LIBPNG_VER < 10700 + /* LIBPNG BUG: this always forces palette images to RGB. */ + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); +#endif + + /* This effectively does an 'expand' only if there is some transparency to + * convert to an alpha channel. + */ + if (that->have_tRNS) +# if PNG_LIBPNG_VER >= 10700 + if (that->colour_type != PNG_COLOR_TYPE_PALETTE && + (that->colour_type & PNG_COLOR_MASK_ALPHA) == 0) +# endif + image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + +#if PNG_LIBPNG_VER < 10700 + /* LIBPNG BUG: otherwise libpng still expands to 8 bits! */ + else + { + if (that->bit_depth < 8) + that->bit_depth =8; + if (that->sample_depth < 8) + that->sample_depth = 8; + } +#endif + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_tRNS_to_alpha_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + /* We don't know yet whether there will be a tRNS chunk, but we know that + * this transformation should do nothing if there already is an alpha + * channel. In addition, after the bug fix in 1.7.0, there is no longer + * any action on a palette image. + */ + return +# if PNG_LIBPNG_VER >= 10700 + colour_type != PNG_COLOR_TYPE_PALETTE && +# endif + (colour_type & PNG_COLOR_MASK_ALPHA) == 0; +} + +IT(tRNS_to_alpha); +#undef PT +#define PT ITSTRUCT(tRNS_to_alpha) +#endif /* PNG_READ_EXPAND_SUPPORTED */ + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +/* png_set_gray_to_rgb */ +static void +image_transform_png_set_gray_to_rgb_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_gray_to_rgb(pp); + /* NOTE: this doesn't result in tRNS expansion. */ + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_gray_to_rgb_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* NOTE: we can actually pend the tRNS processing at this point because we + * can correctly recognize the original pixel value even though we have + * mapped the one gray channel to the three RGB ones, but in fact libpng + * doesn't do this, so we don't either. + */ + if ((that->colour_type & PNG_COLOR_MASK_COLOR) == 0 && that->have_tRNS) + image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + + /* Simply expand the bit depth and alter the colour type as required. */ + if (that->colour_type == PNG_COLOR_TYPE_GRAY) + { + /* RGB images have a bit depth at least equal to '8' */ + if (that->bit_depth < 8) + that->sample_depth = that->bit_depth = 8; + + /* And just changing the colour type works here because the green and blue + * channels are being maintained in lock-step with the red/gray: + */ + that->colour_type = PNG_COLOR_TYPE_RGB; + } + + else if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA) + that->colour_type = PNG_COLOR_TYPE_RGB_ALPHA; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_gray_to_rgb_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return (colour_type & PNG_COLOR_MASK_COLOR) == 0; +} + +IT(gray_to_rgb); +#undef PT +#define PT ITSTRUCT(gray_to_rgb) +#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */ + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* png_set_expand */ +static void +image_transform_png_set_expand_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_expand(pp); + + if (that->this.has_tRNS) + that->this.is_transparent = 1; + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_expand_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* The general expand case depends on what the colour type is: */ + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); + else if (that->bit_depth < 8) /* grayscale */ + that->sample_depth = that->bit_depth = 8; + + if (that->have_tRNS) + image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_expand_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + /* 'expand' should do nothing for RGBA or GA input - no tRNS and the bit + * depth is at least 8 already. + */ + return (colour_type & PNG_COLOR_MASK_ALPHA) == 0; +} + +IT(expand); +#undef PT +#define PT ITSTRUCT(expand) +#endif /* PNG_READ_EXPAND_SUPPORTED */ + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* png_set_expand_gray_1_2_4_to_8 + * Pre 1.7.0 LIBPNG BUG: this just does an 'expand' + */ +static void +image_transform_png_set_expand_gray_1_2_4_to_8_set( + const image_transform *this, transform_display *that, png_structp pp, + png_infop pi) +{ + png_set_expand_gray_1_2_4_to_8(pp); + /* NOTE: don't expect this to expand tRNS */ + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_expand_gray_1_2_4_to_8_mod( + const image_transform *this, image_pixel *that, png_const_structp pp, + const transform_display *display) +{ +#if PNG_LIBPNG_VER < 10700 + image_transform_png_set_expand_mod(this, that, pp, display); +#else + /* Only expand grayscale of bit depth less than 8: */ + if (that->colour_type == PNG_COLOR_TYPE_GRAY && + that->bit_depth < 8) + that->sample_depth = that->bit_depth = 8; + + this->next->mod(this->next, that, pp, display); +#endif /* 1.7 or later */ +} + +static int +image_transform_png_set_expand_gray_1_2_4_to_8_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ +#if PNG_LIBPNG_VER < 10700 + return image_transform_png_set_expand_add(this, that, colour_type, + bit_depth); +#else + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + /* This should do nothing unless the color type is gray and the bit depth is + * less than 8: + */ + return colour_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8; +#endif /* 1.7 or later */ +} + +IT(expand_gray_1_2_4_to_8); +#undef PT +#define PT ITSTRUCT(expand_gray_1_2_4_to_8) +#endif /* PNG_READ_EXPAND_SUPPORTED */ + +#ifdef PNG_READ_EXPAND_16_SUPPORTED +/* png_set_expand_16 */ +static void +image_transform_png_set_expand_16_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_expand_16(pp); + + /* NOTE: prior to 1.7 libpng does SET_EXPAND as well, so tRNS is expanded. */ +# if PNG_LIBPNG_VER < 10700 + if (that->this.has_tRNS) + that->this.is_transparent = 1; +# endif + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_expand_16_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* Expect expand_16 to expand everything to 16 bits as a result of also + * causing 'expand' to happen. + */ + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); + + if (that->have_tRNS) + image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + + if (that->bit_depth < 16) + that->sample_depth = that->bit_depth = 16; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_expand_16_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + /* expand_16 does something unless the bit depth is already 16. */ + return bit_depth < 16; +} + +IT(expand_16); +#undef PT +#define PT ITSTRUCT(expand_16) +#endif /* PNG_READ_EXPAND_16_SUPPORTED */ + +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED /* API added in 1.5.4 */ +/* png_set_scale_16 */ +static void +image_transform_png_set_scale_16_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_scale_16(pp); +# if PNG_LIBPNG_VER < 10700 + /* libpng will limit the gamma table size: */ + that->max_gamma_8 = PNG_MAX_GAMMA_8; +# endif + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_scale_16_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth == 16) + { + that->sample_depth = that->bit_depth = 8; + if (that->red_sBIT > 8) that->red_sBIT = 8; + if (that->green_sBIT > 8) that->green_sBIT = 8; + if (that->blue_sBIT > 8) that->blue_sBIT = 8; + if (that->alpha_sBIT > 8) that->alpha_sBIT = 8; + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_scale_16_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + return bit_depth > 8; +} + +IT(scale_16); +#undef PT +#define PT ITSTRUCT(scale_16) +#endif /* PNG_READ_SCALE_16_TO_8_SUPPORTED (1.5.4 on) */ + +#ifdef PNG_READ_16_TO_8_SUPPORTED /* the default before 1.5.4 */ +/* png_set_strip_16 */ +static void +image_transform_png_set_strip_16_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_strip_16(pp); +# if PNG_LIBPNG_VER < 10700 + /* libpng will limit the gamma table size: */ + that->max_gamma_8 = PNG_MAX_GAMMA_8; +# endif + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_strip_16_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth == 16) + { + that->sample_depth = that->bit_depth = 8; + if (that->red_sBIT > 8) that->red_sBIT = 8; + if (that->green_sBIT > 8) that->green_sBIT = 8; + if (that->blue_sBIT > 8) that->blue_sBIT = 8; + if (that->alpha_sBIT > 8) that->alpha_sBIT = 8; + + /* Prior to 1.5.4 png_set_strip_16 would use an 'accurate' method if this + * configuration option is set. From 1.5.4 the flag is never set and the + * 'scale' API (above) must be used. + */ +# ifdef PNG_READ_ACCURATE_SCALE_SUPPORTED +# if PNG_LIBPNG_VER >= 10504 +# error PNG_READ_ACCURATE_SCALE should not be set +# endif + + /* The strip 16 algorithm drops the low 8 bits rather than calculating + * 1/257, so we need to adjust the permitted errors appropriately: + * Notice that this is only relevant prior to the addition of the + * png_set_scale_16 API in 1.5.4 (but 1.5.4+ always defines the above!) + */ + { + const double d = (255-128.5)/65535; + that->rede += d; + that->greene += d; + that->bluee += d; + that->alphae += d; + } +# endif + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_strip_16_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + return bit_depth > 8; +} + +IT(strip_16); +#undef PT +#define PT ITSTRUCT(strip_16) +#endif /* PNG_READ_16_TO_8_SUPPORTED */ + +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED +/* png_set_strip_alpha */ +static void +image_transform_png_set_strip_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_strip_alpha(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_strip_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA) + that->colour_type = PNG_COLOR_TYPE_GRAY; + else if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA) + that->colour_type = PNG_COLOR_TYPE_RGB; + + that->have_tRNS = 0; + that->alphaf = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_strip_alpha_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return (colour_type & PNG_COLOR_MASK_ALPHA) != 0; +} + +IT(strip_alpha); +#undef PT +#define PT ITSTRUCT(strip_alpha) +#endif /* PNG_READ_STRIP_ALPHA_SUPPORTED */ + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +/* png_set_rgb_to_gray(png_structp, int err_action, double red, double green) + * png_set_rgb_to_gray_fixed(png_structp, int err_action, png_fixed_point red, + * png_fixed_point green) + * png_get_rgb_to_gray_status + * + * The 'default' test here uses values known to be used inside libpng prior to + * 1.7.0: + * + * red: 6968 + * green: 23434 + * blue: 2366 + * + * These values are being retained for compatibility, along with the somewhat + * broken truncation calculation in the fast-and-inaccurate code path. Older + * versions of libpng will fail the accuracy tests below because they use the + * truncation algorithm everywhere. + */ +#define data ITDATA(rgb_to_gray) +static struct +{ + double gamma; /* File gamma to use in processing */ + + /* The following are the parameters for png_set_rgb_to_gray: */ +# ifdef PNG_FLOATING_POINT_SUPPORTED + double red_to_set; + double green_to_set; +# else + png_fixed_point red_to_set; + png_fixed_point green_to_set; +# endif + + /* The actual coefficients: */ + double red_coefficient; + double green_coefficient; + double blue_coefficient; + + /* Set if the coeefficients have been overridden. */ + int coefficients_overridden; +} data; + +#undef image_transform_ini +#define image_transform_ini image_transform_png_set_rgb_to_gray_ini +static void +image_transform_png_set_rgb_to_gray_ini(const image_transform *this, + transform_display *that) +{ + png_modifier *pm = that->pm; + const color_encoding *e = pm->current_encoding; + + UNUSED(this) + + /* Since we check the encoding this flag must be set: */ + pm->test_uses_encoding = 1; + + /* If 'e' is not NULL chromaticity information is present and either a cHRM + * or an sRGB chunk will be inserted. + */ + if (e != 0) + { + /* Coefficients come from the encoding, but may need to be normalized to a + * white point Y of 1.0 + */ + const double whiteY = e->red.Y + e->green.Y + e->blue.Y; + + data.red_coefficient = e->red.Y; + data.green_coefficient = e->green.Y; + data.blue_coefficient = e->blue.Y; + + if (whiteY != 1) + { + data.red_coefficient /= whiteY; + data.green_coefficient /= whiteY; + data.blue_coefficient /= whiteY; + } + } + + else + { + /* The default (built in) coeffcients, as above: */ +# if PNG_LIBPNG_VER < 10700 + data.red_coefficient = 6968 / 32768.; + data.green_coefficient = 23434 / 32768.; + data.blue_coefficient = 2366 / 32768.; +# else + data.red_coefficient = .2126; + data.green_coefficient = .7152; + data.blue_coefficient = .0722; +# endif + } + + data.gamma = pm->current_gamma; + + /* If not set then the calculations assume linear encoding (implicitly): */ + if (data.gamma == 0) + data.gamma = 1; + + /* The arguments to png_set_rgb_to_gray can override the coefficients implied + * by the color space encoding. If doing exhaustive checks do the override + * in each case, otherwise do it randomly. + */ + if (pm->test_exhaustive) + { + /* First time in coefficients_overridden is 0, the following sets it to 1, + * so repeat if it is set. If a test fails this may mean we subsequently + * skip a non-override test, ignore that. + */ + data.coefficients_overridden = !data.coefficients_overridden; + pm->repeat = data.coefficients_overridden != 0; + } + + else + data.coefficients_overridden = random_choice(); + + if (data.coefficients_overridden) + { + /* These values override the color encoding defaults, simply use random + * numbers. + */ + png_uint_32 ru; + double total; + + ru = random_u32(); + data.green_coefficient = total = (ru & 0xffff) / 65535.; + ru >>= 16; + data.red_coefficient = (1 - total) * (ru & 0xffff) / 65535.; + total += data.red_coefficient; + data.blue_coefficient = 1 - total; + +# ifdef PNG_FLOATING_POINT_SUPPORTED + data.red_to_set = data.red_coefficient; + data.green_to_set = data.green_coefficient; +# else + data.red_to_set = fix(data.red_coefficient); + data.green_to_set = fix(data.green_coefficient); +# endif + + /* The following just changes the error messages: */ + pm->encoding_ignored = 1; + } + + else + { + data.red_to_set = -1; + data.green_to_set = -1; + } + + /* Adjust the error limit in the png_modifier because of the larger errors + * produced in the digitization during the gamma handling. + */ + if (data.gamma != 1) /* Use gamma tables */ + { + if (that->this.bit_depth == 16 || pm->assume_16_bit_calculations) + { + /* The computations have the form: + * + * r * rc + g * gc + b * bc + * + * Each component of which is +/-1/65535 from the gamma_to_1 table + * lookup, resulting in a base error of +/-6. The gamma_from_1 + * conversion adds another +/-2 in the 16-bit case and + * +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case. + */ +# if PNG_LIBPNG_VER < 10700 + if (that->this.bit_depth < 16) + that->max_gamma_8 = PNG_MAX_GAMMA_8; +# endif + that->pm->limit += pow( + (that->this.bit_depth == 16 || that->max_gamma_8 > 14 ? + 8. : + 6. + (1<<(15-that->max_gamma_8)) + )/65535, data.gamma); + } + + else + { + /* Rounding to 8 bits in the linear space causes massive errors which + * will trigger the error check in transform_range_check. Fix that + * here by taking the gamma encoding into account. + * + * When DIGITIZE is set because a pre-1.7 version of libpng is being + * tested allow a bigger slack. + * + * NOTE: this number only affects the internal limit check in pngvalid, + * it has no effect on the limits applied to the libpng values. + */ +#if DIGITIZE + that->pm->limit += pow( 2.0/255, data.gamma); +#else + that->pm->limit += pow( 1.0/255, data.gamma); +#endif + } + } + + else + { + /* With no gamma correction a large error comes from the truncation of the + * calculation in the 8 bit case, allow for that here. + */ + if (that->this.bit_depth != 16 && !pm->assume_16_bit_calculations) + that->pm->limit += 4E-3; + } +} + +static void +image_transform_png_set_rgb_to_gray_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + int error_action = 1; /* no error, no defines in png.h */ + +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_rgb_to_gray(pp, error_action, data.red_to_set, data.green_to_set); +# else + png_set_rgb_to_gray_fixed(pp, error_action, data.red_to_set, + data.green_to_set); +# endif + +# ifdef PNG_READ_cHRM_SUPPORTED + if (that->pm->current_encoding != 0) + { + /* We have an encoding so a cHRM chunk may have been set; if so then + * check that the libpng APIs give the correct (X,Y,Z) values within + * some margin of error for the round trip through the chromaticity + * form. + */ +# ifdef PNG_FLOATING_POINT_SUPPORTED +# define API_function png_get_cHRM_XYZ +# define API_form "FP" +# define API_type double +# define API_cvt(x) (x) +# else +# define API_function png_get_cHRM_XYZ_fixed +# define API_form "fixed" +# define API_type png_fixed_point +# define API_cvt(x) ((double)(x)/PNG_FP_1) +# endif + + API_type rX, gX, bX; + API_type rY, gY, bY; + API_type rZ, gZ, bZ; + + if ((API_function(pp, pi, &rX, &rY, &rZ, &gX, &gY, &gZ, &bX, &bY, &bZ) + & PNG_INFO_cHRM) != 0) + { + double maxe; + const char *el; + color_encoding e, o; + + /* Expect libpng to return a normalized result, but the original + * color space encoding may not be normalized. + */ + modifier_current_encoding(that->pm, &o); + normalize_color_encoding(&o); + + /* Sanity check the pngvalid code - the coefficients should match + * the normalized Y values of the encoding unless they were + * overridden. + */ + if (data.red_to_set == -1 && data.green_to_set == -1 && + (fabs(o.red.Y - data.red_coefficient) > DBL_EPSILON || + fabs(o.green.Y - data.green_coefficient) > DBL_EPSILON || + fabs(o.blue.Y - data.blue_coefficient) > DBL_EPSILON)) + png_error(pp, "internal pngvalid cHRM coefficient error"); + + /* Generate a colour space encoding. */ + e.gamma = o.gamma; /* not used */ + e.red.X = API_cvt(rX); + e.red.Y = API_cvt(rY); + e.red.Z = API_cvt(rZ); + e.green.X = API_cvt(gX); + e.green.Y = API_cvt(gY); + e.green.Z = API_cvt(gZ); + e.blue.X = API_cvt(bX); + e.blue.Y = API_cvt(bY); + e.blue.Z = API_cvt(bZ); + + /* This should match the original one from the png_modifier, within + * the range permitted by the libpng fixed point representation. + */ + maxe = 0; + el = "-"; /* Set to element name with error */ + +# define CHECK(col,x)\ + {\ + double err = fabs(o.col.x - e.col.x);\ + if (err > maxe)\ + {\ + maxe = err;\ + el = #col "(" #x ")";\ + }\ + } + + CHECK(red,X) + CHECK(red,Y) + CHECK(red,Z) + CHECK(green,X) + CHECK(green,Y) + CHECK(green,Z) + CHECK(blue,X) + CHECK(blue,Y) + CHECK(blue,Z) + + /* Here in both fixed and floating cases to check the values read + * from the cHRm chunk. PNG uses fixed point in the cHRM chunk, so + * we can't expect better than +/-.5E-5 on the result, allow 1E-5. + */ + if (maxe >= 1E-5) + { + size_t pos = 0; + char buffer[256]; + + pos = safecat(buffer, sizeof buffer, pos, API_form); + pos = safecat(buffer, sizeof buffer, pos, " cHRM "); + pos = safecat(buffer, sizeof buffer, pos, el); + pos = safecat(buffer, sizeof buffer, pos, " error: "); + pos = safecatd(buffer, sizeof buffer, pos, maxe, 7); + pos = safecat(buffer, sizeof buffer, pos, " "); + /* Print the color space without the gamma value: */ + pos = safecat_color_encoding(buffer, sizeof buffer, pos, &o, 0); + pos = safecat(buffer, sizeof buffer, pos, " -> "); + pos = safecat_color_encoding(buffer, sizeof buffer, pos, &e, 0); + + png_error(pp, buffer); + } + } + } +# endif /* READ_cHRM */ + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_rgb_to_gray_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if ((that->colour_type & PNG_COLOR_MASK_COLOR) != 0) + { + double gray, err; + +# if PNG_LIBPNG_VER < 10700 + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); +# endif + + /* Image now has RGB channels... */ +# if DIGITIZE + { + png_modifier *pm = display->pm; + unsigned int sample_depth = that->sample_depth; + unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 : + sample_depth); + unsigned int gamma_depth = + (sample_depth == 16 ? + display->max_gamma_8 : + (pm->assume_16_bit_calculations ? + display->max_gamma_8 : + sample_depth)); + int isgray; + double r, g, b; + double rlo, rhi, glo, ghi, blo, bhi, graylo, grayhi; + + /* Do this using interval arithmetic, otherwise it is too difficult to + * handle the errors correctly. + * + * To handle the gamma correction work out the upper and lower bounds + * of the digitized value. Assume rounding here - normally the values + * will be identical after this operation if there is only one + * transform, feel free to delete the png_error checks on this below in + * the future (this is just me trying to ensure it works!) + * + * Interval arithmetic is exact, but to implement it it must be + * possible to control the floating point implementation rounding mode. + * This cannot be done in ANSI-C, so instead I reduce the 'lo' values + * by DBL_EPSILON and increase the 'hi' values by the same. + */ +# define DD(v,d,r) (digitize(v*(1-DBL_EPSILON), d, r) * (1-DBL_EPSILON)) +# define DU(v,d,r) (digitize(v*(1+DBL_EPSILON), d, r) * (1+DBL_EPSILON)) + + r = rlo = rhi = that->redf; + rlo -= that->rede; + rlo = DD(rlo, calc_depth, 1/*round*/); + rhi += that->rede; + rhi = DU(rhi, calc_depth, 1/*round*/); + + g = glo = ghi = that->greenf; + glo -= that->greene; + glo = DD(glo, calc_depth, 1/*round*/); + ghi += that->greene; + ghi = DU(ghi, calc_depth, 1/*round*/); + + b = blo = bhi = that->bluef; + blo -= that->bluee; + blo = DD(blo, calc_depth, 1/*round*/); + bhi += that->bluee; + bhi = DU(bhi, calc_depth, 1/*round*/); + + isgray = r==g && g==b; + + if (data.gamma != 1) + { + const double power = 1/data.gamma; + const double abse = .5/(sample_depth == 16 ? 65535 : 255); + + /* If a gamma calculation is done it is done using lookup tables of + * precision gamma_depth, so the already digitized value above may + * need to be further digitized here. + */ + if (gamma_depth != calc_depth) + { + rlo = DD(rlo, gamma_depth, 0/*truncate*/); + rhi = DU(rhi, gamma_depth, 0/*truncate*/); + glo = DD(glo, gamma_depth, 0/*truncate*/); + ghi = DU(ghi, gamma_depth, 0/*truncate*/); + blo = DD(blo, gamma_depth, 0/*truncate*/); + bhi = DU(bhi, gamma_depth, 0/*truncate*/); + } + + /* 'abse' is the error in the gamma table calculation itself. */ + r = pow(r, power); + rlo = DD(pow(rlo, power)-abse, calc_depth, 1); + rhi = DU(pow(rhi, power)+abse, calc_depth, 1); + + g = pow(g, power); + glo = DD(pow(glo, power)-abse, calc_depth, 1); + ghi = DU(pow(ghi, power)+abse, calc_depth, 1); + + b = pow(b, power); + blo = DD(pow(blo, power)-abse, calc_depth, 1); + bhi = DU(pow(bhi, power)+abse, calc_depth, 1); + } + + /* Now calculate the actual gray values. Although the error in the + * coefficients depends on whether they were specified on the command + * line (in which case truncation to 15 bits happened) or not (rounding + * was used) the maximum error in an individual coefficient is always + * 2/32768, because even in the rounding case the requirement that + * coefficients add up to 32768 can cause a larger rounding error. + * + * The only time when rounding doesn't occur in 1.5.5 and later is when + * the non-gamma code path is used for less than 16 bit data. + */ + gray = r * data.red_coefficient + g * data.green_coefficient + + b * data.blue_coefficient; + + { + int do_round = data.gamma != 1 || calc_depth == 16; + const double ce = 2. / 32768; + + graylo = DD(rlo * (data.red_coefficient-ce) + + glo * (data.green_coefficient-ce) + + blo * (data.blue_coefficient-ce), calc_depth, do_round); + if (graylo > gray) /* always accept the right answer */ + graylo = gray; + + grayhi = DU(rhi * (data.red_coefficient+ce) + + ghi * (data.green_coefficient+ce) + + bhi * (data.blue_coefficient+ce), calc_depth, do_round); + if (grayhi < gray) + grayhi = gray; + } + + /* And invert the gamma. */ + if (data.gamma != 1) + { + const double power = data.gamma; + + /* And this happens yet again, shifting the values once more. */ + if (gamma_depth != sample_depth) + { + rlo = DD(rlo, gamma_depth, 0/*truncate*/); + rhi = DU(rhi, gamma_depth, 0/*truncate*/); + glo = DD(glo, gamma_depth, 0/*truncate*/); + ghi = DU(ghi, gamma_depth, 0/*truncate*/); + blo = DD(blo, gamma_depth, 0/*truncate*/); + bhi = DU(bhi, gamma_depth, 0/*truncate*/); + } + + gray = pow(gray, power); + graylo = DD(pow(graylo, power), sample_depth, 1); + grayhi = DU(pow(grayhi, power), sample_depth, 1); + } + +# undef DD +# undef DU + + /* Now the error can be calculated. + * + * If r==g==b because there is no overall gamma correction libpng + * currently preserves the original value. + */ + if (isgray) + err = (that->rede + that->greene + that->bluee)/3; + + else + { + err = fabs(grayhi-gray); + + if (fabs(gray - graylo) > err) + err = fabs(graylo-gray); + +#if !RELEASE_BUILD + /* Check that this worked: */ + if (err > pm->limit) + { + size_t pos = 0; + char buffer[128]; + + pos = safecat(buffer, sizeof buffer, pos, "rgb_to_gray error "); + pos = safecatd(buffer, sizeof buffer, pos, err, 6); + pos = safecat(buffer, sizeof buffer, pos, " exceeds limit "); + pos = safecatd(buffer, sizeof buffer, pos, pm->limit, 6); + png_warning(pp, buffer); + pm->limit = err; + } +#endif /* !RELEASE_BUILD */ + } + } +# else /* !DIGITIZE */ + { + double r = that->redf; + double re = that->rede; + double g = that->greenf; + double ge = that->greene; + double b = that->bluef; + double be = that->bluee; + +# if PNG_LIBPNG_VER < 10700 + /* The true gray case involves no math in earlier versions (not + * true, there was some if gamma correction was happening too.) + */ + if (r == g && r == b) + { + gray = r; + err = re; + if (err < ge) err = ge; + if (err < be) err = be; + } + + else +# endif /* before 1.7 */ + if (data.gamma == 1) + { + /* There is no need to do the conversions to and from linear space, + * so the calculation should be a lot more accurate. There is a + * built in error in the coefficients because they only have 15 bits + * and are adjusted to make sure they add up to 32768. This + * involves a integer calculation with truncation of the form: + * + * ((int)(coefficient * 100000) * 32768)/100000 + * + * This is done to the red and green coefficients (the ones + * provided to the API) then blue is calculated from them so the + * result adds up to 32768. In the worst case this can result in + * a -1 error in red and green and a +2 error in blue. Consequently + * the worst case in the calculation below is 2/32768 error. + * + * TODO: consider fixing this in libpng by rounding the calculation + * limiting the error to 1/32768. + * + * Handling this by adding 2/32768 here avoids needing to increase + * the global error limits to take this into account.) + */ + gray = r * data.red_coefficient + g * data.green_coefficient + + b * data.blue_coefficient; + err = re * data.red_coefficient + ge * data.green_coefficient + + be * data.blue_coefficient + 2./32768 + gray * 5 * DBL_EPSILON; + } + + else + { + /* The calculation happens in linear space, and this produces much + * wider errors in the encoded space. These are handled here by + * factoring the errors in to the calculation. There are two table + * lookups in the calculation and each introduces a quantization + * error defined by the table size. + */ + png_modifier *pm = display->pm; + double in_qe = (that->sample_depth > 8 ? .5/65535 : .5/255); + double out_qe = (that->sample_depth > 8 ? .5/65535 : + (pm->assume_16_bit_calculations ? .5/(1<max_gamma_8) : + .5/255)); + double rhi, ghi, bhi, grayhi; + double g1 = 1/data.gamma; + + rhi = r + re + in_qe; if (rhi > 1) rhi = 1; + r -= re + in_qe; if (r < 0) r = 0; + ghi = g + ge + in_qe; if (ghi > 1) ghi = 1; + g -= ge + in_qe; if (g < 0) g = 0; + bhi = b + be + in_qe; if (bhi > 1) bhi = 1; + b -= be + in_qe; if (b < 0) b = 0; + + r = pow(r, g1)*(1-DBL_EPSILON); rhi = pow(rhi, g1)*(1+DBL_EPSILON); + g = pow(g, g1)*(1-DBL_EPSILON); ghi = pow(ghi, g1)*(1+DBL_EPSILON); + b = pow(b, g1)*(1-DBL_EPSILON); bhi = pow(bhi, g1)*(1+DBL_EPSILON); + + /* Work out the lower and upper bounds for the gray value in the + * encoded space, then work out an average and error. Remove the + * previously added input quantization error at this point. + */ + gray = r * data.red_coefficient + g * data.green_coefficient + + b * data.blue_coefficient - 2./32768 - out_qe; + if (gray <= 0) + gray = 0; + else + { + gray *= (1 - 6 * DBL_EPSILON); + gray = pow(gray, data.gamma) * (1-DBL_EPSILON); + } + + grayhi = rhi * data.red_coefficient + ghi * data.green_coefficient + + bhi * data.blue_coefficient + 2./32768 + out_qe; + grayhi *= (1 + 6 * DBL_EPSILON); + if (grayhi >= 1) + grayhi = 1; + else + grayhi = pow(grayhi, data.gamma) * (1+DBL_EPSILON); + + err = (grayhi - gray) / 2; + gray = (grayhi + gray) / 2; + + if (err <= in_qe) + err = gray * DBL_EPSILON; + + else + err -= in_qe; + +#if !RELEASE_BUILD + /* Validate that the error is within limits (this has caused + * problems before, it's much easier to detect them here.) + */ + if (err > pm->limit) + { + size_t pos = 0; + char buffer[128]; + + pos = safecat(buffer, sizeof buffer, pos, "rgb_to_gray error "); + pos = safecatd(buffer, sizeof buffer, pos, err, 6); + pos = safecat(buffer, sizeof buffer, pos, " exceeds limit "); + pos = safecatd(buffer, sizeof buffer, pos, pm->limit, 6); + png_warning(pp, buffer); + pm->limit = err; + } +#endif /* !RELEASE_BUILD */ + } + } +# endif /* !DIGITIZE */ + + that->bluef = that->greenf = that->redf = gray; + that->bluee = that->greene = that->rede = err; + + /* The sBIT is the minimum of the three colour channel sBITs. */ + if (that->red_sBIT > that->green_sBIT) + that->red_sBIT = that->green_sBIT; + if (that->red_sBIT > that->blue_sBIT) + that->red_sBIT = that->blue_sBIT; + that->blue_sBIT = that->green_sBIT = that->red_sBIT; + + /* And remove the colour bit in the type: */ + if (that->colour_type == PNG_COLOR_TYPE_RGB) + that->colour_type = PNG_COLOR_TYPE_GRAY; + else if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA) + that->colour_type = PNG_COLOR_TYPE_GRAY_ALPHA; + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_rgb_to_gray_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return (colour_type & PNG_COLOR_MASK_COLOR) != 0; +} + +#undef data +IT(rgb_to_gray); +#undef PT +#define PT ITSTRUCT(rgb_to_gray) +#undef image_transform_ini +#define image_transform_ini image_transform_default_ini +#endif /* PNG_READ_RGB_TO_GRAY_SUPPORTED */ + +#ifdef PNG_READ_BACKGROUND_SUPPORTED +/* png_set_background(png_structp, png_const_color_16p background_color, + * int background_gamma_code, int need_expand, double background_gamma) + * png_set_background_fixed(png_structp, png_const_color_16p background_color, + * int background_gamma_code, int need_expand, + * png_fixed_point background_gamma) + * + * This ignores the gamma (at present.) +*/ +#define data ITDATA(background) +static image_pixel data; + +static void +image_transform_png_set_background_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_byte colour_type, bit_depth; + png_byte random_bytes[8]; /* 8 bytes - 64 bits - the biggest pixel */ + int expand; + png_color_16 back; + + /* We need a background colour, because we don't know exactly what transforms + * have been set we have to supply the colour in the original file format and + * so we need to know what that is! The background colour is stored in the + * transform_display. + */ + R8(random_bytes); + + /* Read the random value, for colour type 3 the background colour is actually + * expressed as a 24bit rgb, not an index. + */ + colour_type = that->this.colour_type; + if (colour_type == 3) + { + colour_type = PNG_COLOR_TYPE_RGB; + bit_depth = 8; + expand = 0; /* passing in an RGB not a pixel index */ + } + + else + { + if (that->this.has_tRNS) + that->this.is_transparent = 1; + + bit_depth = that->this.bit_depth; + expand = 1; + } + + image_pixel_init(&data, random_bytes, colour_type, + bit_depth, 0/*x*/, 0/*unused: palette*/, NULL/*format*/); + + /* Extract the background colour from this image_pixel, but make sure the + * unused fields of 'back' are garbage. + */ + R8(back); + + if (colour_type & PNG_COLOR_MASK_COLOR) + { + back.red = (png_uint_16)data.red; + back.green = (png_uint_16)data.green; + back.blue = (png_uint_16)data.blue; + } + + else + back.gray = (png_uint_16)data.red; + +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_background(pp, &back, PNG_BACKGROUND_GAMMA_FILE, expand, 0); +#else + png_set_background_fixed(pp, &back, PNG_BACKGROUND_GAMMA_FILE, expand, 0); +#endif + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_background_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* Check for tRNS first: */ + if (that->have_tRNS && that->colour_type != PNG_COLOR_TYPE_PALETTE) + image_pixel_add_alpha(that, &display->this, 1/*for background*/); + + /* This is only necessary if the alpha value is less than 1. */ + if (that->alphaf < 1) + { + /* Now we do the background calculation without any gamma correction. */ + if (that->alphaf <= 0) + { + that->redf = data.redf; + that->greenf = data.greenf; + that->bluef = data.bluef; + + that->rede = data.rede; + that->greene = data.greene; + that->bluee = data.bluee; + + that->red_sBIT= data.red_sBIT; + that->green_sBIT= data.green_sBIT; + that->blue_sBIT= data.blue_sBIT; + } + + else /* 0 < alpha < 1 */ + { + double alf = 1 - that->alphaf; + + that->redf = that->redf * that->alphaf + data.redf * alf; + that->rede = that->rede * that->alphaf + data.rede * alf + + DBL_EPSILON; + that->greenf = that->greenf * that->alphaf + data.greenf * alf; + that->greene = that->greene * that->alphaf + data.greene * alf + + DBL_EPSILON; + that->bluef = that->bluef * that->alphaf + data.bluef * alf; + that->bluee = that->bluee * that->alphaf + data.bluee * alf + + DBL_EPSILON; + } + + /* Remove the alpha type and set the alpha (not in that order.) */ + that->alphaf = 1; + that->alphae = 0; + } + + if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA) + that->colour_type = PNG_COLOR_TYPE_RGB; + else if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA) + that->colour_type = PNG_COLOR_TYPE_GRAY; + /* PNG_COLOR_TYPE_PALETTE is not changed */ + + this->next->mod(this->next, that, pp, display); +} + +#define image_transform_png_set_background_add image_transform_default_add + +#undef data +IT(background); +#undef PT +#define PT ITSTRUCT(background) +#endif /* PNG_READ_BACKGROUND_SUPPORTED */ + +/* png_set_quantize(png_structp, png_colorp palette, int num_palette, + * int maximum_colors, png_const_uint_16p histogram, int full_quantize) + * + * Very difficult to validate this! + */ +/*NOTE: TBD NYI */ + +/* The data layout transforms are handled by swapping our own channel data, + * necessarily these need to happen at the end of the transform list because the + * semantic of the channels changes after these are executed. Some of these, + * like set_shift and set_packing, can't be done at present because they change + * the layout of the data at the sub-sample level so sample() won't get the + * right answer. + */ +/* png_set_invert_alpha */ +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED +/* Invert the alpha channel + * + * png_set_invert_alpha(png_structrp png_ptr) + */ +static void +image_transform_png_set_invert_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_invert_alpha(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_invert_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type & 4) + that->alpha_inverted = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_invert_alpha_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + /* Only has an effect on pixels with alpha: */ + return (colour_type & 4) != 0; +} + +IT(invert_alpha); +#undef PT +#define PT ITSTRUCT(invert_alpha) + +#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */ + +/* png_set_bgr */ +#ifdef PNG_READ_BGR_SUPPORTED +/* Swap R,G,B channels to order B,G,R. + * + * png_set_bgr(png_structrp png_ptr) + * + * This only has an effect on RGB and RGBA pixels. + */ +static void +image_transform_png_set_bgr_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_bgr(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_bgr_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type == PNG_COLOR_TYPE_RGB || + that->colour_type == PNG_COLOR_TYPE_RGBA) + that->swap_rgb = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_bgr_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return colour_type == PNG_COLOR_TYPE_RGB || + colour_type == PNG_COLOR_TYPE_RGBA; +} + +IT(bgr); +#undef PT +#define PT ITSTRUCT(bgr) + +#endif /* PNG_READ_BGR_SUPPORTED */ + +/* png_set_swap_alpha */ +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED +/* Put the alpha channel first. + * + * png_set_swap_alpha(png_structrp png_ptr) + * + * This only has an effect on GA and RGBA pixels. + */ +static void +image_transform_png_set_swap_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_swap_alpha(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_swap_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type == PNG_COLOR_TYPE_GA || + that->colour_type == PNG_COLOR_TYPE_RGBA) + that->alpha_first = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_swap_alpha_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return colour_type == PNG_COLOR_TYPE_GA || + colour_type == PNG_COLOR_TYPE_RGBA; +} + +IT(swap_alpha); +#undef PT +#define PT ITSTRUCT(swap_alpha) + +#endif /* PNG_READ_SWAP_ALPHA_SUPPORTED */ + +/* png_set_swap */ +#ifdef PNG_READ_SWAP_SUPPORTED +/* Byte swap 16-bit components. + * + * png_set_swap(png_structrp png_ptr) + */ +static void +image_transform_png_set_swap_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_swap(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_swap_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth == 16) + that->swap16 = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_swap_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + return bit_depth == 16; +} + +IT(swap); +#undef PT +#define PT ITSTRUCT(swap) + +#endif /* PNG_READ_SWAP_SUPPORTED */ + +#ifdef PNG_READ_FILLER_SUPPORTED +/* Add a filler byte to 8-bit Gray or 24-bit RGB images. + * + * png_set_filler, (png_structp png_ptr, png_uint_32 filler, int flags)); + * + * Flags: + * + * PNG_FILLER_BEFORE + * PNG_FILLER_AFTER + */ +#define data ITDATA(filler) +static struct +{ + png_uint_32 filler; + int flags; +} data; + +static void +image_transform_png_set_filler_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + /* Need a random choice for 'before' and 'after' as well as for the + * filler. The 'filler' value has all 32 bits set, but only bit_depth + * will be used. At this point we don't know bit_depth. + */ + data.filler = random_u32(); + data.flags = random_choice(); + + png_set_filler(pp, data.filler, data.flags); + + /* The standard display handling stuff also needs to know that + * there is a filler, so set that here. + */ + that->this.filler = 1; + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_filler_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth >= 8 && + (that->colour_type == PNG_COLOR_TYPE_RGB || + that->colour_type == PNG_COLOR_TYPE_GRAY)) + { + unsigned int max = (1U << that->bit_depth)-1; + that->alpha = data.filler & max; + that->alphaf = ((double)that->alpha) / max; + that->alphae = 0; + + /* The filler has been stored in the alpha channel, we must record + * that this has been done for the checking later on, the color + * type is faked to have an alpha channel, but libpng won't report + * this; the app has to know the extra channel is there and this + * was recording in standard_display::filler above. + */ + that->colour_type |= 4; /* alpha added */ + that->alpha_first = data.flags == PNG_FILLER_BEFORE; + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_filler_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + this->next = *that; + *that = this; + + return bit_depth >= 8 && (colour_type == PNG_COLOR_TYPE_RGB || + colour_type == PNG_COLOR_TYPE_GRAY); +} + +#undef data +IT(filler); +#undef PT +#define PT ITSTRUCT(filler) + +/* png_set_add_alpha, (png_structp png_ptr, png_uint_32 filler, int flags)); */ +/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ +#define data ITDATA(add_alpha) +static struct +{ + png_uint_32 filler; + int flags; +} data; + +static void +image_transform_png_set_add_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + /* Need a random choice for 'before' and 'after' as well as for the + * filler. The 'filler' value has all 32 bits set, but only bit_depth + * will be used. At this point we don't know bit_depth. + */ + data.filler = random_u32(); + data.flags = random_choice(); + + png_set_add_alpha(pp, data.filler, data.flags); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_add_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth >= 8 && + (that->colour_type == PNG_COLOR_TYPE_RGB || + that->colour_type == PNG_COLOR_TYPE_GRAY)) + { + unsigned int max = (1U << that->bit_depth)-1; + that->alpha = data.filler & max; + that->alphaf = ((double)that->alpha) / max; + that->alphae = 0; + + that->colour_type |= 4; /* alpha added */ + that->alpha_first = data.flags == PNG_FILLER_BEFORE; + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_add_alpha_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + this->next = *that; + *that = this; + + return bit_depth >= 8 && (colour_type == PNG_COLOR_TYPE_RGB || + colour_type == PNG_COLOR_TYPE_GRAY); +} + +#undef data +IT(add_alpha); +#undef PT +#define PT ITSTRUCT(add_alpha) + +#endif /* PNG_READ_FILLER_SUPPORTED */ + +/* png_set_packing */ +#ifdef PNG_READ_PACK_SUPPORTED +/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. + * + * png_set_packing(png_structrp png_ptr) + * + * This should only affect grayscale and palette images with less than 8 bits + * per pixel. + */ +static void +image_transform_png_set_packing_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_packing(pp); + that->unpacked = 1; + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_packing_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* The general expand case depends on what the colour type is, + * low bit-depth pixel values are unpacked into bytes without + * scaling, so sample_depth is not changed. + */ + if (that->bit_depth < 8) /* grayscale or palette */ + that->bit_depth = 8; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_packing_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + /* Nothing should happen unless the bit depth is less than 8: */ + return bit_depth < 8; +} + +IT(packing); +#undef PT +#define PT ITSTRUCT(packing) + +#endif /* PNG_READ_PACK_SUPPORTED */ + +/* png_set_packswap */ +#ifdef PNG_READ_PACKSWAP_SUPPORTED +/* Swap pixels packed into bytes; reverses the order on screen so that + * the high order bits correspond to the rightmost pixels. + * + * png_set_packswap(png_structrp png_ptr) + */ +static void +image_transform_png_set_packswap_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_packswap(pp); + that->this.littleendian = 1; + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_packswap_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth < 8) + that->littleendian = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_packswap_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + return bit_depth < 8; +} + +IT(packswap); +#undef PT +#define PT ITSTRUCT(packswap) + +#endif /* PNG_READ_PACKSWAP_SUPPORTED */ + + +/* png_set_invert_mono */ +#ifdef PNG_READ_INVERT_MONO_SUPPORTED +/* Invert the gray channel + * + * png_set_invert_mono(png_structrp png_ptr) + */ +static void +image_transform_png_set_invert_mono_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_invert_mono(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_invert_mono_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type & 4) + that->mono_inverted = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_invert_mono_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + /* Only has an effect on pixels with no colour: */ + return (colour_type & 2) == 0; +} + +IT(invert_mono); +#undef PT +#define PT ITSTRUCT(invert_mono) + +#endif /* PNG_READ_INVERT_MONO_SUPPORTED */ + +#ifdef PNG_READ_SHIFT_SUPPORTED +/* png_set_shift(png_structp, png_const_color_8p true_bits) + * + * The output pixels will be shifted by the given true_bits + * values. + */ +#define data ITDATA(shift) +static png_color_8 data; + +static void +image_transform_png_set_shift_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + /* Get a random set of shifts. The shifts need to do something + * to test the transform, so they are limited to the bit depth + * of the input image. Notice that in the following the 'gray' + * field is randomized independently. This acts as a check that + * libpng does use the correct field. + */ + unsigned int depth = that->this.bit_depth; + + data.red = (png_byte)/*SAFE*/(random_mod(depth)+1); + data.green = (png_byte)/*SAFE*/(random_mod(depth)+1); + data.blue = (png_byte)/*SAFE*/(random_mod(depth)+1); + data.gray = (png_byte)/*SAFE*/(random_mod(depth)+1); + data.alpha = (png_byte)/*SAFE*/(random_mod(depth)+1); + + png_set_shift(pp, &data); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_shift_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* Copy the correct values into the sBIT fields, libpng does not do + * anything to palette data: + */ + if (that->colour_type != PNG_COLOR_TYPE_PALETTE) + { + that->sig_bits = 1; + + /* The sBIT fields are reset to the values previously sent to + * png_set_shift according to the colour type. + * does. + */ + if (that->colour_type & 2) /* RGB channels */ + { + that->red_sBIT = data.red; + that->green_sBIT = data.green; + that->blue_sBIT = data.blue; + } + + else /* One grey channel */ + that->red_sBIT = that->green_sBIT = that->blue_sBIT = data.gray; + + that->alpha_sBIT = data.alpha; + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_shift_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return colour_type != PNG_COLOR_TYPE_PALETTE; +} + +IT(shift); +#undef PT +#define PT ITSTRUCT(shift) + +#endif /* PNG_READ_SHIFT_SUPPORTED */ + +#ifdef THIS_IS_THE_PROFORMA +static void +image_transform_png_set_@_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_@(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_@_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_@_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + this->next = *that; + *that = this; + + return 1; +} + +IT(@); +#endif + + +/* This may just be 'end' if all the transforms are disabled! */ +static image_transform *const image_transform_first = &PT; + +static void +transform_enable(const char *name) +{ + /* Everything starts out enabled, so if we see an 'enable' disabled + * everything else the first time round. + */ + static int all_disabled = 0; + int found_it = 0; + image_transform *list = image_transform_first; + + while (list != &image_transform_end) + { + if (strcmp(list->name, name) == 0) + { + list->enable = 1; + found_it = 1; + } + else if (!all_disabled) + list->enable = 0; + + list = list->list; + } + + all_disabled = 1; + + if (!found_it) + { + fprintf(stderr, "pngvalid: --transform-enable=%s: unknown transform\n", + name); + exit(99); + } +} + +static void +transform_disable(const char *name) +{ + image_transform *list = image_transform_first; + + while (list != &image_transform_end) + { + if (strcmp(list->name, name) == 0) + { + list->enable = 0; + return; + } + + list = list->list; + } + + fprintf(stderr, "pngvalid: --transform-disable=%s: unknown transform\n", + name); + exit(99); +} + +static void +image_transform_reset_count(void) +{ + image_transform *next = image_transform_first; + int count = 0; + + while (next != &image_transform_end) + { + next->local_use = 0; + next->next = 0; + next = next->list; + ++count; + } + + /* This can only happen if we every have more than 32 transforms (excluding + * the end) in the list. + */ + if (count > 32) abort(); +} + +static int +image_transform_test_counter(png_uint_32 counter, unsigned int max) +{ + /* Test the list to see if there is any point contining, given a current + * counter and a 'max' value. + */ + image_transform *next = image_transform_first; + + while (next != &image_transform_end) + { + /* For max 0 or 1 continue until the counter overflows: */ + counter >>= 1; + + /* Continue if any entry hasn't reacked the max. */ + if (max > 1 && next->local_use < max) + return 1; + next = next->list; + } + + return max <= 1 && counter == 0; +} + +static png_uint_32 +image_transform_add(const image_transform **this, unsigned int max, + png_uint_32 counter, char *name, size_t sizeof_name, size_t *pos, + png_byte colour_type, png_byte bit_depth) +{ + for (;;) /* until we manage to add something */ + { + png_uint_32 mask; + image_transform *list; + + /* Find the next counter value, if the counter is zero this is the start + * of the list. This routine always returns the current counter (not the + * next) so it returns 0 at the end and expects 0 at the beginning. + */ + if (counter == 0) /* first time */ + { + image_transform_reset_count(); + if (max <= 1) + counter = 1; + else + counter = random_32(); + } + else /* advance the counter */ + { + switch (max) + { + case 0: ++counter; break; + case 1: counter <<= 1; break; + default: counter = random_32(); break; + } + } + + /* Now add all these items, if possible */ + *this = &image_transform_end; + list = image_transform_first; + mask = 1; + + /* Go through the whole list adding anything that the counter selects: */ + while (list != &image_transform_end) + { + if ((counter & mask) != 0 && list->enable && + (max == 0 || list->local_use < max)) + { + /* Candidate to add: */ + if (list->add(list, this, colour_type, bit_depth) || max == 0) + { + /* Added, so add to the name too. */ + *pos = safecat(name, sizeof_name, *pos, " +"); + *pos = safecat(name, sizeof_name, *pos, list->name); + } + + else + { + /* Not useful and max>0, so remove it from *this: */ + *this = list->next; + list->next = 0; + + /* And, since we know it isn't useful, stop it being added again + * in this run: + */ + list->local_use = max; + } + } + + mask <<= 1; + list = list->list; + } + + /* Now if anything was added we have something to do. */ + if (*this != &image_transform_end) + return counter; + + /* Nothing added, but was there anything in there to add? */ + if (!image_transform_test_counter(counter, max)) + return 0; + } +} + +static void +perform_transform_test(png_modifier *pm) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + unsigned int palette_number = 0; + + while (next_format(&colour_type, &bit_depth, &palette_number, pm->test_lbg, + pm->test_tRNS)) + { + png_uint_32 counter = 0; + size_t base_pos; + char name[64]; + + base_pos = safecat(name, sizeof name, 0, "transform:"); + + for (;;) + { + size_t pos = base_pos; + const image_transform *list = 0; + + /* 'max' is currently hardwired to '1'; this should be settable on the + * command line. + */ + counter = image_transform_add(&list, 1/*max*/, counter, + name, sizeof name, &pos, colour_type, bit_depth); + + if (counter == 0) + break; + + /* The command line can change this to checking interlaced images. */ + do + { + pm->repeat = 0; + transform_test(pm, FILEID(colour_type, bit_depth, palette_number, + pm->interlace_type, 0, 0, 0), list, name); + + if (fail(pm)) + return; + } + while (pm->repeat); + } + } +} +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + +/********************************* GAMMA TESTS ********************************/ +#ifdef PNG_READ_GAMMA_SUPPORTED +/* Reader callbacks and implementations, where they differ from the standard + * ones. + */ +typedef struct gamma_display +{ + standard_display this; + + /* Parameters */ + png_modifier* pm; + double file_gamma; + double screen_gamma; + double background_gamma; + png_byte sbit; + int threshold_test; + int use_input_precision; + int scale16; + int expand16; + int do_background; + png_color_16 background_color; + + /* Local variables */ + double maxerrout; + double maxerrpc; + double maxerrabs; +} gamma_display; + +#define ALPHA_MODE_OFFSET 4 + +static void +gamma_display_init(gamma_display *dp, png_modifier *pm, png_uint_32 id, + double file_gamma, double screen_gamma, png_byte sbit, int threshold_test, + int use_input_precision, int scale16, int expand16, + int do_background, const png_color_16 *pointer_to_the_background_color, + double background_gamma) +{ + /* Standard fields */ + standard_display_init(&dp->this, &pm->this, id, do_read_interlace, + pm->use_update_info); + + /* Parameter fields */ + dp->pm = pm; + dp->file_gamma = file_gamma; + dp->screen_gamma = screen_gamma; + dp->background_gamma = background_gamma; + dp->sbit = sbit; + dp->threshold_test = threshold_test; + dp->use_input_precision = use_input_precision; + dp->scale16 = scale16; + dp->expand16 = expand16; + dp->do_background = do_background; + if (do_background && pointer_to_the_background_color != 0) + dp->background_color = *pointer_to_the_background_color; + else + memset(&dp->background_color, 0, sizeof dp->background_color); + + /* Local variable fields */ + dp->maxerrout = dp->maxerrpc = dp->maxerrabs = 0; +} + +static void +gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi) +{ + /* Reuse the standard stuff as appropriate. */ + standard_info_part1(&dp->this, pp, pi); + + /* If requested strip 16 to 8 bits - this is handled automagically below + * because the output bit depth is read from the library. Note that there + * are interactions with sBIT but, internally, libpng makes sbit at most + * PNG_MAX_GAMMA_8 prior to 1.7 when doing the following. + */ + if (dp->scale16) +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + png_set_scale_16(pp); +# else + /* The following works both in 1.5.4 and earlier versions: */ +# ifdef PNG_READ_16_TO_8_SUPPORTED + png_set_strip_16(pp); +# else + png_error(pp, "scale16 (16 to 8 bit conversion) not supported"); +# endif +# endif + + if (dp->expand16) +# ifdef PNG_READ_EXPAND_16_SUPPORTED + png_set_expand_16(pp); +# else + png_error(pp, "expand16 (8 to 16 bit conversion) not supported"); +# endif + + if (dp->do_background >= ALPHA_MODE_OFFSET) + { +# ifdef PNG_READ_ALPHA_MODE_SUPPORTED + { + /* This tests the alpha mode handling, if supported. */ + int mode = dp->do_background - ALPHA_MODE_OFFSET; + + /* The gamma value is the output gamma, and is in the standard, + * non-inverted, representation. It provides a default for the PNG file + * gamma, but since the file has a gAMA chunk this does not matter. + */ + const double sg = dp->screen_gamma; +# ifndef PNG_FLOATING_POINT_SUPPORTED + png_fixed_point g = fix(sg); +# endif + +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_alpha_mode(pp, mode, sg); +# else + png_set_alpha_mode_fixed(pp, mode, g); +# endif + + /* However, for the standard Porter-Duff algorithm the output defaults + * to be linear, so if the test requires non-linear output it must be + * corrected here. + */ + if (mode == PNG_ALPHA_STANDARD && sg != 1) + { +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_gamma(pp, sg, dp->file_gamma); +# else + png_fixed_point f = fix(dp->file_gamma); + png_set_gamma_fixed(pp, g, f); +# endif + } + } +# else + png_error(pp, "alpha mode handling not supported"); +# endif + } + + else + { + /* Set up gamma processing. */ +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_gamma(pp, dp->screen_gamma, dp->file_gamma); +# else + { + png_fixed_point s = fix(dp->screen_gamma); + png_fixed_point f = fix(dp->file_gamma); + png_set_gamma_fixed(pp, s, f); + } +# endif + + if (dp->do_background) + { +# ifdef PNG_READ_BACKGROUND_SUPPORTED + /* NOTE: this assumes the caller provided the correct background gamma! + */ + const double bg = dp->background_gamma; +# ifndef PNG_FLOATING_POINT_SUPPORTED + png_fixed_point g = fix(bg); +# endif + +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_background(pp, &dp->background_color, dp->do_background, + 0/*need_expand*/, bg); +# else + png_set_background_fixed(pp, &dp->background_color, + dp->do_background, 0/*need_expand*/, g); +# endif +# else + png_error(pp, "png_set_background not supported"); +# endif + } + } + + { + int i = dp->this.use_update_info; + /* Always do one call, even if use_update_info is 0. */ + do + png_read_update_info(pp, pi); + while (--i > 0); + } + + /* Now we may get a different cbRow: */ + standard_info_part2(&dp->this, pp, pi, 1 /*images*/); +} + +static void PNGCBAPI +gamma_info(png_structp pp, png_infop pi) +{ + gamma_info_imp(voidcast(gamma_display*, png_get_progressive_ptr(pp)), pp, + pi); +} + +/* Validate a single component value - the routine gets the input and output + * sample values as unscaled PNG component values along with a cache of all the + * information required to validate the values. + */ +typedef struct validate_info +{ + png_const_structp pp; + gamma_display *dp; + png_byte sbit; + int use_input_precision; + int do_background; + int scale16; + unsigned int sbit_max; + unsigned int isbit_shift; + unsigned int outmax; + + double gamma_correction; /* Overall correction required. */ + double file_inverse; /* Inverse of file gamma. */ + double screen_gamma; + double screen_inverse; /* Inverse of screen gamma. */ + + double background_red; /* Linear background value, red or gray. */ + double background_green; + double background_blue; + + double maxabs; + double maxpc; + double maxcalc; + double maxout; + double maxout_total; /* Total including quantization error */ + double outlog; + int outquant; +} +validate_info; + +static void +init_validate_info(validate_info *vi, gamma_display *dp, png_const_structp pp, + int in_depth, int out_depth) +{ + unsigned int outmax = (1U<pp = pp; + vi->dp = dp; + + if (dp->sbit > 0 && dp->sbit < in_depth) + { + vi->sbit = dp->sbit; + vi->isbit_shift = in_depth - dp->sbit; + } + + else + { + vi->sbit = (png_byte)in_depth; + vi->isbit_shift = 0; + } + + vi->sbit_max = (1U << vi->sbit)-1; + + /* This mimics the libpng threshold test, '0' is used to prevent gamma + * correction in the validation test. + */ + vi->screen_gamma = dp->screen_gamma; + if (fabs(vi->screen_gamma-1) < PNG_GAMMA_THRESHOLD) + vi->screen_gamma = vi->screen_inverse = 0; + else + vi->screen_inverse = 1/vi->screen_gamma; + + vi->use_input_precision = dp->use_input_precision; + vi->outmax = outmax; + vi->maxabs = abserr(dp->pm, in_depth, out_depth); + vi->maxpc = pcerr(dp->pm, in_depth, out_depth); + vi->maxcalc = calcerr(dp->pm, in_depth, out_depth); + vi->maxout = outerr(dp->pm, in_depth, out_depth); + vi->outquant = output_quantization_factor(dp->pm, in_depth, out_depth); + vi->maxout_total = vi->maxout + vi->outquant * .5; + vi->outlog = outlog(dp->pm, in_depth, out_depth); + + if ((dp->this.colour_type & PNG_COLOR_MASK_ALPHA) != 0 || + (dp->this.colour_type == 3 && dp->this.is_transparent) || + ((dp->this.colour_type == 0 || dp->this.colour_type == 2) && + dp->this.has_tRNS)) + { + vi->do_background = dp->do_background; + + if (vi->do_background != 0) + { + const double bg_inverse = 1/dp->background_gamma; + double r, g, b; + + /* Caller must at least put the gray value into the red channel */ + r = dp->background_color.red; r /= outmax; + g = dp->background_color.green; g /= outmax; + b = dp->background_color.blue; b /= outmax; + +# if 0 + /* libpng doesn't do this optimization, if we do pngvalid will fail. + */ + if (fabs(bg_inverse-1) >= PNG_GAMMA_THRESHOLD) +# endif + { + r = pow(r, bg_inverse); + g = pow(g, bg_inverse); + b = pow(b, bg_inverse); + } + + vi->background_red = r; + vi->background_green = g; + vi->background_blue = b; + } + } + else /* Do not expect any background processing */ + vi->do_background = 0; + + if (vi->do_background == 0) + vi->background_red = vi->background_green = vi->background_blue = 0; + + vi->gamma_correction = 1/(dp->file_gamma*dp->screen_gamma); + if (fabs(vi->gamma_correction-1) < PNG_GAMMA_THRESHOLD) + vi->gamma_correction = 0; + + vi->file_inverse = 1/dp->file_gamma; + if (fabs(vi->file_inverse-1) < PNG_GAMMA_THRESHOLD) + vi->file_inverse = 0; + + vi->scale16 = dp->scale16; +} + +/* This function handles composition of a single non-alpha component. The + * argument is the input sample value, in the range 0..1, and the alpha value. + * The result is the composed, linear, input sample. If alpha is less than zero + * this is the alpha component and the function should not be called! + */ +static double +gamma_component_compose(int do_background, double input_sample, double alpha, + double background, int *compose) +{ + switch (do_background) + { +#ifdef PNG_READ_BACKGROUND_SUPPORTED + case PNG_BACKGROUND_GAMMA_SCREEN: + case PNG_BACKGROUND_GAMMA_FILE: + case PNG_BACKGROUND_GAMMA_UNIQUE: + /* Standard PNG background processing. */ + if (alpha < 1) + { + if (alpha > 0) + { + input_sample = input_sample * alpha + background * (1-alpha); + if (compose != NULL) + *compose = 1; + } + + else + input_sample = background; + } + break; +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + case ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD: + case ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN: + /* The components are premultiplied in either case and the output is + * gamma encoded (to get standard Porter-Duff we expect the output + * gamma to be set to 1.0!) + */ + case ALPHA_MODE_OFFSET + PNG_ALPHA_OPTIMIZED: + /* The optimization is that the partial-alpha entries are linear + * while the opaque pixels are gamma encoded, but this only affects the + * output encoding. + */ + if (alpha < 1) + { + if (alpha > 0) + { + input_sample *= alpha; + if (compose != NULL) + *compose = 1; + } + + else + input_sample = 0; + } + break; +#endif + + default: + /* Standard cases where no compositing is done (so the component + * value is already correct.) + */ + UNUSED(alpha) + UNUSED(background) + UNUSED(compose) + break; + } + + return input_sample; +} + +/* This API returns the encoded *input* component, in the range 0..1 */ +static double +gamma_component_validate(const char *name, const validate_info *vi, + unsigned int id, unsigned int od, + const double alpha /* <0 for the alpha channel itself */, + const double background /* component background value */) +{ + unsigned int isbit = id >> vi->isbit_shift; + unsigned int sbit_max = vi->sbit_max; + unsigned int outmax = vi->outmax; + int do_background = vi->do_background; + + double i; + + /* First check on the 'perfect' result obtained from the digitized input + * value, id, and compare this against the actual digitized result, 'od'. + * 'i' is the input result in the range 0..1: + */ + i = isbit; i /= sbit_max; + + /* Check for the fast route: if we don't do any background composition or if + * this is the alpha channel ('alpha' < 0) or if the pixel is opaque then + * just use the gamma_correction field to correct to the final output gamma. + */ + if (alpha == 1 /* opaque pixel component */ || !do_background +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + || do_background == ALPHA_MODE_OFFSET + PNG_ALPHA_PNG +#endif + || (alpha < 0 /* alpha channel */ +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + && do_background != ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN +#endif + )) + { + /* Then get the gamma corrected version of 'i' and compare to 'od', any + * error less than .5 is insignificant - just quantization of the output + * value to the nearest digital value (nevertheless the error is still + * recorded - it's interesting ;-) + */ + double encoded_sample = i; + double encoded_error; + + /* alpha less than 0 indicates the alpha channel, which is always linear + */ + if (alpha >= 0 && vi->gamma_correction > 0) + encoded_sample = pow(encoded_sample, vi->gamma_correction); + encoded_sample *= outmax; + + encoded_error = fabs(od-encoded_sample); + + if (encoded_error > vi->dp->maxerrout) + vi->dp->maxerrout = encoded_error; + + if (encoded_error < vi->maxout_total && encoded_error < vi->outlog) + return i; + } + + /* The slow route - attempt to do linear calculations. */ + /* There may be an error, or background processing is required, so calculate + * the actual sample values - unencoded light intensity values. Note that in + * practice these are not completely unencoded because they include a + * 'viewing correction' to decrease or (normally) increase the perceptual + * contrast of the image. There's nothing we can do about this - we don't + * know what it is - so assume the unencoded value is perceptually linear. + */ + { + double input_sample = i; /* In range 0..1 */ + double output, error, encoded_sample, encoded_error; + double es_lo, es_hi; + int compose = 0; /* Set to one if composition done */ + int output_is_encoded; /* Set if encoded to screen gamma */ + int log_max_error = 1; /* Check maximum error values */ + png_const_charp pass = 0; /* Reason test passes (or 0 for fail) */ + + /* Convert to linear light (with the above caveat.) The alpha channel is + * already linear. + */ + if (alpha >= 0) + { + int tcompose; + + if (vi->file_inverse > 0) + input_sample = pow(input_sample, vi->file_inverse); + + /* Handle the compose processing: */ + tcompose = 0; + input_sample = gamma_component_compose(do_background, input_sample, + alpha, background, &tcompose); + + if (tcompose) + compose = 1; + } + + /* And similarly for the output value, but we need to check the background + * handling to linearize it correctly. + */ + output = od; + output /= outmax; + + output_is_encoded = vi->screen_gamma > 0; + + if (alpha < 0) /* The alpha channel */ + { +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + if (do_background != ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN) +#endif + { + /* In all other cases the output alpha channel is linear already, + * don't log errors here, they are much larger in linear data. + */ + output_is_encoded = 0; + log_max_error = 0; + } + } + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + else /* A component */ + { + if (do_background == ALPHA_MODE_OFFSET + PNG_ALPHA_OPTIMIZED && + alpha < 1) /* the optimized case - linear output */ + { + if (alpha > 0) log_max_error = 0; + output_is_encoded = 0; + } + } +#endif + + if (output_is_encoded) + output = pow(output, vi->screen_gamma); + + /* Calculate (or recalculate) the encoded_sample value and repeat the + * check above (unnecessary if we took the fast route, but harmless.) + */ + encoded_sample = input_sample; + if (output_is_encoded) + encoded_sample = pow(encoded_sample, vi->screen_inverse); + encoded_sample *= outmax; + + encoded_error = fabs(od-encoded_sample); + + /* Don't log errors in the alpha channel, or the 'optimized' case, + * neither are significant to the overall perception. + */ + if (log_max_error && encoded_error > vi->dp->maxerrout) + vi->dp->maxerrout = encoded_error; + + if (encoded_error < vi->maxout_total) + { + if (encoded_error < vi->outlog) + return i; + + /* Test passed but error is bigger than the log limit, record why the + * test passed: + */ + pass = "less than maxout:\n"; + } + + /* i: the original input value in the range 0..1 + * + * pngvalid calculations: + * input_sample: linear result; i linearized and composed, range 0..1 + * encoded_sample: encoded result; input_sample scaled to output bit depth + * + * libpng calculations: + * output: linear result; od scaled to 0..1 and linearized + * od: encoded result from libpng + */ + + /* Now we have the numbers for real errors, both absolute values as as a + * percentage of the correct value (output): + */ + error = fabs(input_sample-output); + + if (log_max_error && error > vi->dp->maxerrabs) + vi->dp->maxerrabs = error; + + /* The following is an attempt to ignore the tendency of quantization to + * dominate the percentage errors for lower result values: + */ + if (log_max_error && input_sample > .5) + { + double percentage_error = error/input_sample; + if (percentage_error > vi->dp->maxerrpc) + vi->dp->maxerrpc = percentage_error; + } + + /* Now calculate the digitization limits for 'encoded_sample' using the + * 'max' values. Note that maxout is in the encoded space but maxpc and + * maxabs are in linear light space. + * + * First find the maximum error in linear light space, range 0..1: + */ + { + double tmp = input_sample * vi->maxpc; + if (tmp < vi->maxabs) tmp = vi->maxabs; + /* If 'compose' is true the composition was done in linear space using + * integer arithmetic. This introduces an extra error of +/- 0.5 (at + * least) in the integer space used. 'maxcalc' records this, taking + * into account the possibility that even for 16 bit output 8 bit space + * may have been used. + */ + if (compose && tmp < vi->maxcalc) tmp = vi->maxcalc; + + /* The 'maxout' value refers to the encoded result, to compare with + * this encode input_sample adjusted by the maximum error (tmp) above. + */ + es_lo = encoded_sample - vi->maxout; + + if (es_lo > 0 && input_sample-tmp > 0) + { + double low_value = input_sample-tmp; + if (output_is_encoded) + low_value = pow(low_value, vi->screen_inverse); + low_value *= outmax; + if (low_value < es_lo) es_lo = low_value; + + /* Quantize this appropriately: */ + es_lo = ceil(es_lo / vi->outquant - .5) * vi->outquant; + } + + else + es_lo = 0; + + es_hi = encoded_sample + vi->maxout; + + if (es_hi < outmax && input_sample+tmp < 1) + { + double high_value = input_sample+tmp; + if (output_is_encoded) + high_value = pow(high_value, vi->screen_inverse); + high_value *= outmax; + if (high_value > es_hi) es_hi = high_value; + + es_hi = floor(es_hi / vi->outquant + .5) * vi->outquant; + } + + else + es_hi = outmax; + } + + /* The primary test is that the final encoded value returned by the + * library should be between the two limits (inclusive) that were + * calculated above. + */ + if (od >= es_lo && od <= es_hi) + { + /* The value passes, but we may need to log the information anyway. */ + if (encoded_error < vi->outlog) + return i; + + if (pass == 0) + pass = "within digitization limits:\n"; + } + + { + /* There has been an error in processing, or we need to log this + * value. + */ + double is_lo, is_hi; + + /* pass is set at this point if either of the tests above would have + * passed. Don't do these additional tests here - just log the + * original [es_lo..es_hi] values. + */ + if (pass == 0 && vi->use_input_precision && vi->dp->sbit) + { + /* Ok, something is wrong - this actually happens in current libpng + * 16-to-8 processing. Assume that the input value (id, adjusted + * for sbit) can be anywhere between value-.5 and value+.5 - quite a + * large range if sbit is low. + * + * NOTE: at present because the libpng gamma table stuff has been + * changed to use a rounding algorithm to correct errors in 8-bit + * calculations the precise sbit calculation (a shift) has been + * lost. This can result in up to a +/-1 error in the presence of + * an sbit less than the bit depth. + */ +# if PNG_LIBPNG_VER < 10700 +# define SBIT_ERROR .5 +# else +# define SBIT_ERROR 1. +# endif + double tmp = (isbit - SBIT_ERROR)/sbit_max; + + if (tmp <= 0) + tmp = 0; + + else if (alpha >= 0 && vi->file_inverse > 0 && tmp < 1) + tmp = pow(tmp, vi->file_inverse); + + tmp = gamma_component_compose(do_background, tmp, alpha, background, + NULL); + + if (output_is_encoded && tmp > 0 && tmp < 1) + tmp = pow(tmp, vi->screen_inverse); + + is_lo = ceil(outmax * tmp - vi->maxout_total); + + if (is_lo < 0) + is_lo = 0; + + tmp = (isbit + SBIT_ERROR)/sbit_max; + + if (tmp >= 1) + tmp = 1; + + else if (alpha >= 0 && vi->file_inverse > 0 && tmp < 1) + tmp = pow(tmp, vi->file_inverse); + + tmp = gamma_component_compose(do_background, tmp, alpha, background, + NULL); + + if (output_is_encoded && tmp > 0 && tmp < 1) + tmp = pow(tmp, vi->screen_inverse); + + is_hi = floor(outmax * tmp + vi->maxout_total); + + if (is_hi > outmax) + is_hi = outmax; + + if (!(od < is_lo || od > is_hi)) + { + if (encoded_error < vi->outlog) + return i; + + pass = "within input precision limits:\n"; + } + + /* One last chance. If this is an alpha channel and the 16to8 + * option has been used and 'inaccurate' scaling is used then the + * bit reduction is obtained by simply using the top 8 bits of the + * value. + * + * This is only done for older libpng versions when the 'inaccurate' + * (chop) method of scaling was used. + */ +# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# if PNG_LIBPNG_VER < 10504 + /* This may be required for other components in the future, + * but at present the presence of gamma correction effectively + * prevents the errors in the component scaling (I don't quite + * understand why, but since it's better this way I care not + * to ask, JB 20110419.) + */ + if (pass == 0 && alpha < 0 && vi->scale16 && vi->sbit > 8 && + vi->sbit + vi->isbit_shift == 16) + { + tmp = ((id >> 8) - .5)/255; + + if (tmp > 0) + { + is_lo = ceil(outmax * tmp - vi->maxout_total); + if (is_lo < 0) is_lo = 0; + } + + else + is_lo = 0; + + tmp = ((id >> 8) + .5)/255; + + if (tmp < 1) + { + is_hi = floor(outmax * tmp + vi->maxout_total); + if (is_hi > outmax) is_hi = outmax; + } + + else + is_hi = outmax; + + if (!(od < is_lo || od > is_hi)) + { + if (encoded_error < vi->outlog) + return i; + + pass = "within 8 bit limits:\n"; + } + } +# endif +# endif + } + else /* !use_input_precision */ + is_lo = es_lo, is_hi = es_hi; + + /* Attempt to output a meaningful error/warning message: the message + * output depends on the background/composite operation being performed + * because this changes what parameters were actually used above. + */ + { + size_t pos = 0; + /* Need either 1/255 or 1/65535 precision here; 3 or 6 decimal + * places. Just use outmax to work out which. + */ + int precision = (outmax >= 1000 ? 6 : 3); + int use_input=1, use_background=0, do_compose=0; + char msg[256]; + + if (pass != 0) + pos = safecat(msg, sizeof msg, pos, "\n\t"); + + /* Set up the various flags, the output_is_encoded flag above + * is also used below. do_compose is just a double check. + */ + switch (do_background) + { +# ifdef PNG_READ_BACKGROUND_SUPPORTED + case PNG_BACKGROUND_GAMMA_SCREEN: + case PNG_BACKGROUND_GAMMA_FILE: + case PNG_BACKGROUND_GAMMA_UNIQUE: + use_background = (alpha >= 0 && alpha < 1); +# endif +# ifdef PNG_READ_ALPHA_MODE_SUPPORTED + /* FALLTHROUGH */ + case ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD: + case ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN: + case ALPHA_MODE_OFFSET + PNG_ALPHA_OPTIMIZED: +# endif /* ALPHA_MODE_SUPPORTED */ + do_compose = (alpha > 0 && alpha < 1); + use_input = (alpha != 0); + break; + + default: + break; + } + + /* Check the 'compose' flag */ + if (compose != do_compose) + png_error(vi->pp, "internal error (compose)"); + + /* 'name' is the component name */ + pos = safecat(msg, sizeof msg, pos, name); + pos = safecat(msg, sizeof msg, pos, "("); + pos = safecatn(msg, sizeof msg, pos, id); + if (use_input || pass != 0/*logging*/) + { + if (isbit != id) + { + /* sBIT has reduced the precision of the input: */ + pos = safecat(msg, sizeof msg, pos, ", sbit("); + pos = safecatn(msg, sizeof msg, pos, vi->sbit); + pos = safecat(msg, sizeof msg, pos, "): "); + pos = safecatn(msg, sizeof msg, pos, isbit); + } + pos = safecat(msg, sizeof msg, pos, "/"); + /* The output is either "id/max" or "id sbit(sbit): isbit/max" */ + pos = safecatn(msg, sizeof msg, pos, vi->sbit_max); + } + pos = safecat(msg, sizeof msg, pos, ")"); + + /* A component may have been multiplied (in linear space) by the + * alpha value, 'compose' says whether this is relevant. + */ + if (compose || pass != 0) + { + /* If any form of composition is being done report our + * calculated linear value here (the code above doesn't record + * the input value before composition is performed, so what + * gets reported is the value after composition.) + */ + if (use_input || pass != 0) + { + if (vi->file_inverse > 0) + { + pos = safecat(msg, sizeof msg, pos, "^"); + pos = safecatd(msg, sizeof msg, pos, vi->file_inverse, 2); + } + + else + pos = safecat(msg, sizeof msg, pos, "[linear]"); + + pos = safecat(msg, sizeof msg, pos, "*(alpha)"); + pos = safecatd(msg, sizeof msg, pos, alpha, precision); + } + + /* Now record the *linear* background value if it was used + * (this function is not passed the original, non-linear, + * value but it is contained in the test name.) + */ + if (use_background) + { + pos = safecat(msg, sizeof msg, pos, use_input ? "+" : " "); + pos = safecat(msg, sizeof msg, pos, "(background)"); + pos = safecatd(msg, sizeof msg, pos, background, precision); + pos = safecat(msg, sizeof msg, pos, "*"); + pos = safecatd(msg, sizeof msg, pos, 1-alpha, precision); + } + } + + /* Report the calculated value (input_sample) and the linearized + * libpng value (output) unless this is just a component gamma + * correction. + */ + if (compose || alpha < 0 || pass != 0) + { + pos = safecat(msg, sizeof msg, pos, + pass != 0 ? " =\n\t" : " = "); + pos = safecatd(msg, sizeof msg, pos, input_sample, precision); + pos = safecat(msg, sizeof msg, pos, " (libpng: "); + pos = safecatd(msg, sizeof msg, pos, output, precision); + pos = safecat(msg, sizeof msg, pos, ")"); + + /* Finally report the output gamma encoding, if any. */ + if (output_is_encoded) + { + pos = safecat(msg, sizeof msg, pos, " ^"); + pos = safecatd(msg, sizeof msg, pos, vi->screen_inverse, 2); + pos = safecat(msg, sizeof msg, pos, "(to screen) ="); + } + + else + pos = safecat(msg, sizeof msg, pos, " [screen is linear] ="); + } + + if ((!compose && alpha >= 0) || pass != 0) + { + if (pass != 0) /* logging */ + pos = safecat(msg, sizeof msg, pos, "\n\t[overall:"); + + /* This is the non-composition case, the internal linear + * values are irrelevant (though the log below will reveal + * them.) Output a much shorter warning/error message and report + * the overall gamma correction. + */ + if (vi->gamma_correction > 0) + { + pos = safecat(msg, sizeof msg, pos, " ^"); + pos = safecatd(msg, sizeof msg, pos, vi->gamma_correction, 2); + pos = safecat(msg, sizeof msg, pos, "(gamma correction) ="); + } + + else + pos = safecat(msg, sizeof msg, pos, + " [no gamma correction] ="); + + if (pass != 0) + pos = safecat(msg, sizeof msg, pos, "]"); + } + + /* This is our calculated encoded_sample which should (but does + * not) match od: + */ + pos = safecat(msg, sizeof msg, pos, pass != 0 ? "\n\t" : " "); + pos = safecatd(msg, sizeof msg, pos, is_lo, 1); + pos = safecat(msg, sizeof msg, pos, " < "); + pos = safecatd(msg, sizeof msg, pos, encoded_sample, 1); + pos = safecat(msg, sizeof msg, pos, " (libpng: "); + pos = safecatn(msg, sizeof msg, pos, od); + pos = safecat(msg, sizeof msg, pos, ")"); + pos = safecat(msg, sizeof msg, pos, "/"); + pos = safecatn(msg, sizeof msg, pos, outmax); + pos = safecat(msg, sizeof msg, pos, " < "); + pos = safecatd(msg, sizeof msg, pos, is_hi, 1); + + if (pass == 0) /* The error condition */ + { +# ifdef PNG_WARNINGS_SUPPORTED + png_warning(vi->pp, msg); +# else + store_warning(vi->pp, msg); +# endif + } + + else /* logging this value */ + store_verbose(&vi->dp->pm->this, vi->pp, pass, msg); + } + } + } + + return i; +} + +static void +gamma_image_validate(gamma_display *dp, png_const_structp pp, + png_infop pi) +{ + /* Get some constants derived from the input and output file formats: */ + const png_store* const ps = dp->this.ps; + png_byte in_ct = dp->this.colour_type; + png_byte in_bd = dp->this.bit_depth; + png_uint_32 w = dp->this.w; + png_uint_32 h = dp->this.h; + const size_t cbRow = dp->this.cbRow; + png_byte out_ct = png_get_color_type(pp, pi); + png_byte out_bd = png_get_bit_depth(pp, pi); + + /* There are three sources of error, firstly the quantization in the + * file encoding, determined by sbit and/or the file depth, secondly + * the output (screen) gamma and thirdly the output file encoding. + * + * Since this API receives the screen and file gamma in double + * precision it is possible to calculate an exact answer given an input + * pixel value. Therefore we assume that the *input* value is exact - + * sample/maxsample - calculate the corresponding gamma corrected + * output to the limits of double precision arithmetic and compare with + * what libpng returns. + * + * Since the library must quantize the output to 8 or 16 bits there is + * a fundamental limit on the accuracy of the output of +/-.5 - this + * quantization limit is included in addition to the other limits + * specified by the parameters to the API. (Effectively, add .5 + * everywhere.) + * + * The behavior of the 'sbit' parameter is defined by section 12.5 + * (sample depth scaling) of the PNG spec. That section forces the + * decoder to assume that the PNG values have been scaled if sBIT is + * present: + * + * png-sample = floor( input-sample * (max-out/max-in) + .5); + * + * This means that only a subset of the possible PNG values should + * appear in the input. However, the spec allows the encoder to use a + * variety of approximations to the above and doesn't require any + * restriction of the values produced. + * + * Nevertheless the spec requires that the upper 'sBIT' bits of the + * value stored in a PNG file be the original sample bits. + * Consequently the code below simply scales the top sbit bits by + * (1<this.palette; + int in_is_transparent = dp->this.is_transparent; + int process_tRNS; + int out_npalette = -1; + int out_is_transparent = 0; /* Just refers to the palette case */ + store_palette out_palette; + validate_info vi; + + /* Check for row overwrite errors */ + store_image_check(dp->this.ps, pp, 0); + + /* Supply the input and output sample depths here - 8 for an indexed image, + * otherwise the bit depth. + */ + init_validate_info(&vi, dp, pp, in_ct==3?8:in_bd, out_ct==3?8:out_bd); + + processing = (vi.gamma_correction > 0 && !dp->threshold_test) + || in_bd != out_bd || in_ct != out_ct || vi.do_background; + process_tRNS = dp->this.has_tRNS && vi.do_background; + + /* TODO: FIX THIS: MAJOR BUG! If the transformations all happen inside + * the palette there is no way of finding out, because libpng fails to + * update the palette on png_read_update_info. Indeed, libpng doesn't + * even do the required work until much later, when it doesn't have any + * info pointer. Oops. For the moment 'processing' is turned off if + * out_ct is palette. + */ + if (in_ct == 3 && out_ct == 3) + processing = 0; + + if (processing && out_ct == 3) + out_is_transparent = read_palette(out_palette, &out_npalette, pp, pi); + + for (y=0; ythis.palette[in_index].alpha : + sample(std, in_ct, in_bd, x, samples_per_pixel, 0, 0); + + unsigned int output_alpha = 65536 /* as a flag value */; + + if (out_ct == 3) + { + if (out_is_transparent) + output_alpha = out_palette[out_index].alpha; + } + + else if ((out_ct & PNG_COLOR_MASK_ALPHA) != 0) + output_alpha = sample(pRow, out_ct, out_bd, x, + samples_per_pixel, 0, 0); + + if (output_alpha != 65536) + alpha = gamma_component_validate("alpha", &vi, input_alpha, + output_alpha, -1/*alpha*/, 0/*background*/); + + else /* no alpha in output */ + { + /* This is a copy of the calculation of 'i' above in order to + * have the alpha value to use in the background calculation. + */ + alpha = input_alpha >> vi.isbit_shift; + alpha /= vi.sbit_max; + } + } + + else if (process_tRNS) + { + /* alpha needs to be set appropriately for this pixel, it is + * currently 1 and needs to be 0 for an input pixel which matches + * the values in tRNS. + */ + switch (in_ct) + { + case 0: /* gray */ + if (sample(std, in_ct, in_bd, x, 0, 0, 0) == + dp->this.transparent.red) + alpha = 0; + break; + + case 2: /* RGB */ + if (sample(std, in_ct, in_bd, x, 0, 0, 0) == + dp->this.transparent.red && + sample(std, in_ct, in_bd, x, 1, 0, 0) == + dp->this.transparent.green && + sample(std, in_ct, in_bd, x, 2, 0, 0) == + dp->this.transparent.blue) + alpha = 0; + break; + + default: + break; + } + } + + /* Handle grayscale or RGB components. */ + if ((in_ct & PNG_COLOR_MASK_COLOR) == 0) /* grayscale */ + (void)gamma_component_validate("gray", &vi, + sample(std, in_ct, in_bd, x, 0, 0, 0), + sample(pRow, out_ct, out_bd, x, 0, 0, 0), + alpha/*component*/, vi.background_red); + else /* RGB or palette */ + { + (void)gamma_component_validate("red", &vi, + in_ct == 3 ? in_palette[in_index].red : + sample(std, in_ct, in_bd, x, 0, 0, 0), + out_ct == 3 ? out_palette[out_index].red : + sample(pRow, out_ct, out_bd, x, 0, 0, 0), + alpha/*component*/, vi.background_red); + + (void)gamma_component_validate("green", &vi, + in_ct == 3 ? in_palette[in_index].green : + sample(std, in_ct, in_bd, x, 1, 0, 0), + out_ct == 3 ? out_palette[out_index].green : + sample(pRow, out_ct, out_bd, x, 1, 0, 0), + alpha/*component*/, vi.background_green); + + (void)gamma_component_validate("blue", &vi, + in_ct == 3 ? in_palette[in_index].blue : + sample(std, in_ct, in_bd, x, 2, 0, 0), + out_ct == 3 ? out_palette[out_index].blue : + sample(pRow, out_ct, out_bd, x, 2, 0, 0), + alpha/*component*/, vi.background_blue); + } + } + } + + else if (memcmp(std, pRow, cbRow) != 0) + { + char msg[64]; + + /* No transform is expected on the threshold tests. */ + sprintf(msg, "gamma: below threshold row %lu changed", + (unsigned long)y); + + png_error(pp, msg); + } + } /* row (y) loop */ + + dp->this.ps->validated = 1; +} + +static void PNGCBAPI +gamma_end(png_structp ppIn, png_infop pi) +{ + png_const_structp pp = ppIn; + gamma_display *dp = voidcast(gamma_display*, png_get_progressive_ptr(pp)); + + if (!dp->this.speed) + gamma_image_validate(dp, pp, pi); + else + dp->this.ps->validated = 1; +} + +/* A single test run checking a gamma transformation. + * + * maxabs: maximum absolute error as a fraction + * maxout: maximum output error in the output units + * maxpc: maximum percentage error (as a percentage) + */ +static void +gamma_test(png_modifier *pmIn, png_byte colour_typeIn, + png_byte bit_depthIn, int palette_numberIn, + int interlace_typeIn, + const double file_gammaIn, const double screen_gammaIn, + png_byte sbitIn, int threshold_testIn, + const char *name, + int use_input_precisionIn, int scale16In, + int expand16In, int do_backgroundIn, + const png_color_16 *bkgd_colorIn, double bkgd_gammaIn) +{ + gamma_display d; + context(&pmIn->this, fault); + + gamma_display_init(&d, pmIn, FILEID(colour_typeIn, bit_depthIn, + palette_numberIn, interlace_typeIn, 0, 0, 0), + file_gammaIn, screen_gammaIn, sbitIn, + threshold_testIn, use_input_precisionIn, scale16In, + expand16In, do_backgroundIn, bkgd_colorIn, bkgd_gammaIn); + + Try + { + png_structp pp; + png_infop pi; + gama_modification gama_mod; + srgb_modification srgb_mod; + sbit_modification sbit_mod; + + /* For the moment don't use the png_modifier support here. */ + d.pm->encoding_counter = 0; + modifier_set_encoding(d.pm); /* Just resets everything */ + d.pm->current_gamma = d.file_gamma; + + /* Make an appropriate modifier to set the PNG file gamma to the + * given gamma value and the sBIT chunk to the given precision. + */ + d.pm->modifications = NULL; + gama_modification_init(&gama_mod, d.pm, d.file_gamma); + srgb_modification_init(&srgb_mod, d.pm, 127 /*delete*/); + if (d.sbit > 0) + sbit_modification_init(&sbit_mod, d.pm, d.sbit); + + modification_reset(d.pm->modifications); + + /* Get a png_struct for reading the image. */ + pp = set_modifier_for_read(d.pm, &pi, d.this.id, name); + standard_palette_init(&d.this); + + /* Introduce the correct read function. */ + if (d.pm->this.progressive) + { + /* Share the row function with the standard implementation. */ + png_set_progressive_read_fn(pp, &d, gamma_info, progressive_row, + gamma_end); + + /* Now feed data into the reader until we reach the end: */ + modifier_progressive_read(d.pm, pp, pi); + } + else + { + /* modifier_read expects a png_modifier* */ + png_set_read_fn(pp, d.pm, modifier_read); + + /* Check the header values: */ + png_read_info(pp, pi); + + /* Process the 'info' requirements. Only one image is generated */ + gamma_info_imp(&d, pp, pi); + + sequential_row(&d.this, pp, pi, -1, 0); + + if (!d.this.speed) + gamma_image_validate(&d, pp, pi); + else + d.this.ps->validated = 1; + } + + modifier_reset(d.pm); + + if (d.pm->log && !d.threshold_test && !d.this.speed) + fprintf(stderr, "%d bit %s %s: max error %f (%.2g, %2g%%)\n", + d.this.bit_depth, colour_types[d.this.colour_type], name, + d.maxerrout, d.maxerrabs, 100*d.maxerrpc); + + /* Log the summary values too. */ + if (d.this.colour_type == 0 || d.this.colour_type == 4) + { + switch (d.this.bit_depth) + { + case 1: + break; + + case 2: + if (d.maxerrout > d.pm->error_gray_2) + d.pm->error_gray_2 = d.maxerrout; + + break; + + case 4: + if (d.maxerrout > d.pm->error_gray_4) + d.pm->error_gray_4 = d.maxerrout; + + break; + + case 8: + if (d.maxerrout > d.pm->error_gray_8) + d.pm->error_gray_8 = d.maxerrout; + + break; + + case 16: + if (d.maxerrout > d.pm->error_gray_16) + d.pm->error_gray_16 = d.maxerrout; + + break; + + default: + png_error(pp, "bad bit depth (internal: 1)"); + } + } + + else if (d.this.colour_type == 2 || d.this.colour_type == 6) + { + switch (d.this.bit_depth) + { + case 8: + + if (d.maxerrout > d.pm->error_color_8) + d.pm->error_color_8 = d.maxerrout; + + break; + + case 16: + + if (d.maxerrout > d.pm->error_color_16) + d.pm->error_color_16 = d.maxerrout; + + break; + + default: + png_error(pp, "bad bit depth (internal: 2)"); + } + } + + else if (d.this.colour_type == 3) + { + if (d.maxerrout > d.pm->error_indexed) + d.pm->error_indexed = d.maxerrout; + } + } + + Catch(fault) + modifier_reset(voidcast(png_modifier*,(void*)fault)); +} + +static void gamma_threshold_test(png_modifier *pm, png_byte colour_type, + png_byte bit_depth, int interlace_type, double file_gamma, + double screen_gamma) +{ + size_t pos = 0; + char name[64]; + pos = safecat(name, sizeof name, pos, "threshold "); + pos = safecatd(name, sizeof name, pos, file_gamma, 3); + pos = safecat(name, sizeof name, pos, "/"); + pos = safecatd(name, sizeof name, pos, screen_gamma, 3); + + (void)gamma_test(pm, colour_type, bit_depth, 0/*palette*/, interlace_type, + file_gamma, screen_gamma, 0/*sBIT*/, 1/*threshold test*/, name, + 0 /*no input precision*/, + 0 /*no scale16*/, 0 /*no expand16*/, 0 /*no background*/, 0 /*hence*/, + 0 /*no background gamma*/); +} + +static void +perform_gamma_threshold_tests(png_modifier *pm) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + unsigned int palette_number = 0; + + /* Don't test more than one instance of each palette - it's pointless, in + * fact this test is somewhat excessive since libpng doesn't make this + * decision based on colour type or bit depth! + * + * CHANGED: now test two palettes and, as a side effect, images with and + * without tRNS. + */ + while (next_format(&colour_type, &bit_depth, &palette_number, + pm->test_lbg_gamma_threshold, pm->test_tRNS)) + if (palette_number < 2) + { + double test_gamma = 1.0; + while (test_gamma >= .4) + { + /* There's little point testing the interlacing vs non-interlacing, + * but this can be set from the command line. + */ + gamma_threshold_test(pm, colour_type, bit_depth, pm->interlace_type, + test_gamma, 1/test_gamma); + test_gamma *= .95; + } + + /* And a special test for sRGB */ + gamma_threshold_test(pm, colour_type, bit_depth, pm->interlace_type, + .45455, 2.2); + + if (fail(pm)) + return; + } +} + +static void gamma_transform_test(png_modifier *pm, + png_byte colour_type, png_byte bit_depth, + int palette_number, + int interlace_type, const double file_gamma, + const double screen_gamma, png_byte sbit, + int use_input_precision, int scale16) +{ + size_t pos = 0; + char name[64]; + + if (sbit != bit_depth && sbit != 0) + { + pos = safecat(name, sizeof name, pos, "sbit("); + pos = safecatn(name, sizeof name, pos, sbit); + pos = safecat(name, sizeof name, pos, ") "); + } + + else + pos = safecat(name, sizeof name, pos, "gamma "); + + if (scale16) + pos = safecat(name, sizeof name, pos, "16to8 "); + + pos = safecatd(name, sizeof name, pos, file_gamma, 3); + pos = safecat(name, sizeof name, pos, "->"); + pos = safecatd(name, sizeof name, pos, screen_gamma, 3); + + gamma_test(pm, colour_type, bit_depth, palette_number, interlace_type, + file_gamma, screen_gamma, sbit, 0, name, use_input_precision, + scale16, pm->test_gamma_expand16, 0 , 0, 0); +} + +static void perform_gamma_transform_tests(png_modifier *pm) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + unsigned int palette_number = 0; + + while (next_format(&colour_type, &bit_depth, &palette_number, + pm->test_lbg_gamma_transform, pm->test_tRNS)) + { + unsigned int i, j; + + for (i=0; ingamma_tests; ++i) for (j=0; jngamma_tests; ++j) + if (i != j) + { + gamma_transform_test(pm, colour_type, bit_depth, palette_number, + pm->interlace_type, 1/pm->gammas[i], pm->gammas[j], 0/*sBIT*/, + pm->use_input_precision, 0 /*do not scale16*/); + + if (fail(pm)) + return; + } + } +} + +static void perform_gamma_sbit_tests(png_modifier *pm) +{ + png_byte sbit; + + /* The only interesting cases are colour and grayscale, alpha is ignored here + * for overall speed. Only bit depths where sbit is less than the bit depth + * are tested. + */ + for (sbit=pm->sbitlow; sbit<(1<test_lbg_gamma_sbit, pm->test_tRNS)) + if ((colour_type & PNG_COLOR_MASK_ALPHA) == 0 && + ((colour_type == 3 && sbit < 8) || + (colour_type != 3 && sbit < bit_depth))) + { + unsigned int i; + + for (i=0; ingamma_tests; ++i) + { + unsigned int j; + + for (j=0; jngamma_tests; ++j) if (i != j) + { + gamma_transform_test(pm, colour_type, bit_depth, npalette, + pm->interlace_type, 1/pm->gammas[i], pm->gammas[j], + sbit, pm->use_input_precision_sbit, 0 /*scale16*/); + + if (fail(pm)) + return; + } + } + } + } +} + +/* Note that this requires a 16 bit source image but produces 8 bit output, so + * we only need the 16bit write support, but the 16 bit images are only + * generated if DO_16BIT is defined. + */ +#ifdef DO_16BIT +static void perform_gamma_scale16_tests(png_modifier *pm) +{ +# ifndef PNG_MAX_GAMMA_8 +# define PNG_MAX_GAMMA_8 11 +# endif +# if defined PNG_MAX_GAMMA_8 || PNG_LIBPNG_VER < 10700 +# define SBIT_16_TO_8 PNG_MAX_GAMMA_8 +# else +# define SBIT_16_TO_8 16 +# endif + /* Include the alpha cases here. Note that sbit matches the internal value + * used by the library - otherwise we will get spurious errors from the + * internal sbit style approximation. + * + * The threshold test is here because otherwise the 16 to 8 conversion will + * proceed *without* gamma correction, and the tests above will fail (but not + * by much) - this could be fixed, it only appears with the -g option. + */ + unsigned int i, j; + for (i=0; ingamma_tests; ++i) + { + for (j=0; jngamma_tests; ++j) + { + if (i != j && + fabs(pm->gammas[j]/pm->gammas[i]-1) >= PNG_GAMMA_THRESHOLD) + { + gamma_transform_test(pm, 0, 16, 0, pm->interlace_type, + 1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8, + pm->use_input_precision_16to8, 1 /*scale16*/); + + if (fail(pm)) + return; + + gamma_transform_test(pm, 2, 16, 0, pm->interlace_type, + 1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8, + pm->use_input_precision_16to8, 1 /*scale16*/); + + if (fail(pm)) + return; + + gamma_transform_test(pm, 4, 16, 0, pm->interlace_type, + 1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8, + pm->use_input_precision_16to8, 1 /*scale16*/); + + if (fail(pm)) + return; + + gamma_transform_test(pm, 6, 16, 0, pm->interlace_type, + 1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8, + pm->use_input_precision_16to8, 1 /*scale16*/); + + if (fail(pm)) + return; + } + } + } +} +#endif /* 16 to 8 bit conversion */ + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) +static void gamma_composition_test(png_modifier *pm, + png_byte colour_type, png_byte bit_depth, + int palette_number, + int interlace_type, const double file_gamma, + const double screen_gamma, + int use_input_precision, int do_background, + int expand_16) +{ + size_t pos = 0; + png_const_charp base; + double bg; + char name[128]; + png_color_16 background; + + /* Make up a name and get an appropriate background gamma value. */ + switch (do_background) + { + default: + base = ""; + bg = 4; /* should not be used */ + break; + case PNG_BACKGROUND_GAMMA_SCREEN: + base = " bckg(Screen):"; + bg = 1/screen_gamma; + break; + case PNG_BACKGROUND_GAMMA_FILE: + base = " bckg(File):"; + bg = file_gamma; + break; + case PNG_BACKGROUND_GAMMA_UNIQUE: + base = " bckg(Unique):"; + /* This tests the handling of a unique value, the math is such that the + * value tends to be <1, but is neither screen nor file (even if they + * match!) + */ + bg = (file_gamma + screen_gamma) / 3; + break; +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + case ALPHA_MODE_OFFSET + PNG_ALPHA_PNG: + base = " alpha(PNG)"; + bg = 4; /* should not be used */ + break; + case ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD: + base = " alpha(Porter-Duff)"; + bg = 4; /* should not be used */ + break; + case ALPHA_MODE_OFFSET + PNG_ALPHA_OPTIMIZED: + base = " alpha(Optimized)"; + bg = 4; /* should not be used */ + break; + case ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN: + base = " alpha(Broken)"; + bg = 4; /* should not be used */ + break; +#endif + } + + /* Use random background values - the background is always presented in the + * output space (8 or 16 bit components). + */ + if (expand_16 || bit_depth == 16) + { + png_uint_32 r = random_32(); + + background.red = (png_uint_16)r; + background.green = (png_uint_16)(r >> 16); + r = random_32(); + background.blue = (png_uint_16)r; + background.gray = (png_uint_16)(r >> 16); + + /* In earlier libpng versions, those where DIGITIZE is set, any background + * gamma correction in the expand16 case was done using 8-bit gamma + * correction tables, resulting in larger errors. To cope with those + * cases use a 16-bit background value which will handle this gamma + * correction. + */ +# if DIGITIZE + if (expand_16 && (do_background == PNG_BACKGROUND_GAMMA_UNIQUE || + do_background == PNG_BACKGROUND_GAMMA_FILE) && + fabs(bg*screen_gamma-1) > PNG_GAMMA_THRESHOLD) + { + /* The background values will be looked up in an 8-bit table to do + * the gamma correction, so only select values which are an exact + * match for the 8-bit table entries: + */ + background.red = (png_uint_16)((background.red >> 8) * 257); + background.green = (png_uint_16)((background.green >> 8) * 257); + background.blue = (png_uint_16)((background.blue >> 8) * 257); + background.gray = (png_uint_16)((background.gray >> 8) * 257); + } +# endif + } + + else /* 8 bit colors */ + { + png_uint_32 r = random_32(); + + background.red = (png_byte)r; + background.green = (png_byte)(r >> 8); + background.blue = (png_byte)(r >> 16); + background.gray = (png_byte)(r >> 24); + } + + background.index = 193; /* rgb(193,193,193) to detect errors */ + + if (!(colour_type & PNG_COLOR_MASK_COLOR)) + { + /* Because, currently, png_set_background is always called with + * 'need_expand' false in this case and because the gamma test itself + * doesn't cause an expand to 8-bit for lower bit depths the colour must + * be reduced to the correct range. + */ + if (bit_depth < 8) + background.gray &= (png_uint_16)((1U << bit_depth)-1); + + /* Grayscale input, we do not convert to RGB (TBD), so we must set the + * background to gray - else libpng seems to fail. + */ + background.red = background.green = background.blue = background.gray; + } + + pos = safecat(name, sizeof name, pos, "gamma "); + pos = safecatd(name, sizeof name, pos, file_gamma, 3); + pos = safecat(name, sizeof name, pos, "->"); + pos = safecatd(name, sizeof name, pos, screen_gamma, 3); + + pos = safecat(name, sizeof name, pos, base); + if (do_background < ALPHA_MODE_OFFSET) + { + /* Include the background color and gamma in the name: */ + pos = safecat(name, sizeof name, pos, "("); + /* This assumes no expand gray->rgb - the current code won't handle that! + */ + if (colour_type & PNG_COLOR_MASK_COLOR) + { + pos = safecatn(name, sizeof name, pos, background.red); + pos = safecat(name, sizeof name, pos, ","); + pos = safecatn(name, sizeof name, pos, background.green); + pos = safecat(name, sizeof name, pos, ","); + pos = safecatn(name, sizeof name, pos, background.blue); + } + else + pos = safecatn(name, sizeof name, pos, background.gray); + pos = safecat(name, sizeof name, pos, ")^"); + pos = safecatd(name, sizeof name, pos, bg, 3); + } + + gamma_test(pm, colour_type, bit_depth, palette_number, interlace_type, + file_gamma, screen_gamma, 0/*sBIT*/, 0, name, use_input_precision, + 0/*strip 16*/, expand_16, do_background, &background, bg); +} + + +static void +perform_gamma_composition_tests(png_modifier *pm, int do_background, + int expand_16) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + unsigned int palette_number = 0; + + /* Skip the non-alpha cases - there is no setting of a transparency colour at + * present. + * + * TODO: incorrect; the palette case sets tRNS and, now RGB and gray do, + * however the palette case fails miserably so is commented out below. + */ + while (next_format(&colour_type, &bit_depth, &palette_number, + pm->test_lbg_gamma_composition, pm->test_tRNS)) + if ((colour_type & PNG_COLOR_MASK_ALPHA) != 0 +#if 0 /* TODO: FIXME */ + /*TODO: FIXME: this should work */ + || colour_type == 3 +#endif + || (colour_type != 3 && palette_number != 0)) + { + unsigned int i, j; + + /* Don't skip the i==j case here - it's relevant. */ + for (i=0; ingamma_tests; ++i) for (j=0; jngamma_tests; ++j) + { + gamma_composition_test(pm, colour_type, bit_depth, palette_number, + pm->interlace_type, 1/pm->gammas[i], pm->gammas[j], + pm->use_input_precision, do_background, expand_16); + + if (fail(pm)) + return; + } + } +} +#endif /* READ_BACKGROUND || READ_ALPHA_MODE */ + +static void +init_gamma_errors(png_modifier *pm) +{ + /* Use -1 to catch tests that were not actually run */ + pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = -1.; + pm->error_color_8 = -1.; + pm->error_indexed = -1.; + pm->error_gray_16 = pm->error_color_16 = -1.; +} + +static void +print_one(const char *leader, double err) +{ + if (err != -1.) + printf(" %s %.5f\n", leader, err); +} + +static void +summarize_gamma_errors(png_modifier *pm, png_const_charp who, int low_bit_depth, + int indexed) +{ + fflush(stderr); + + if (who) + printf("\nGamma correction with %s:\n", who); + + else + printf("\nBasic gamma correction:\n"); + + if (low_bit_depth) + { + print_one(" 2 bit gray: ", pm->error_gray_2); + print_one(" 4 bit gray: ", pm->error_gray_4); + print_one(" 8 bit gray: ", pm->error_gray_8); + print_one(" 8 bit color:", pm->error_color_8); + if (indexed) + print_one(" indexed: ", pm->error_indexed); + } + + print_one("16 bit gray: ", pm->error_gray_16); + print_one("16 bit color:", pm->error_color_16); + + fflush(stdout); +} + +static void +perform_gamma_test(png_modifier *pm, int summary) +{ + /*TODO: remove this*/ + /* Save certain values for the temporary overrides below. */ + unsigned int calculations_use_input_precision = + pm->calculations_use_input_precision; +# ifdef PNG_READ_BACKGROUND_SUPPORTED + double maxout8 = pm->maxout8; +# endif + + /* First some arbitrary no-transform tests: */ + if (!pm->this.speed && pm->test_gamma_threshold) + { + perform_gamma_threshold_tests(pm); + + if (fail(pm)) + return; + } + + /* Now some real transforms. */ + if (pm->test_gamma_transform) + { + if (summary) + { + fflush(stderr); + printf("Gamma correction error summary\n\n"); + printf("The printed value is the maximum error in the pixel values\n"); + printf("calculated by the libpng gamma correction code. The error\n"); + printf("is calculated as the difference between the output pixel\n"); + printf("value (always an integer) and the ideal value from the\n"); + printf("libpng specification (typically not an integer).\n\n"); + + printf("Expect this value to be less than .5 for 8 bit formats,\n"); + printf("less than 1 for formats with fewer than 8 bits and a small\n"); + printf("number (typically less than 5) for the 16 bit formats.\n"); + printf("For performance reasons the value for 16 bit formats\n"); + printf("increases when the image file includes an sBIT chunk.\n"); + fflush(stdout); + } + + init_gamma_errors(pm); + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + pm->calculations_use_input_precision = 1; + perform_gamma_transform_tests(pm); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + + if (summary) + summarize_gamma_errors(pm, 0/*who*/, 1/*low bit depth*/, 1/*indexed*/); + + if (fail(pm)) + return; + } + + /* The sbit tests produce much larger errors: */ + if (pm->test_gamma_sbit) + { + init_gamma_errors(pm); + perform_gamma_sbit_tests(pm); + + if (summary) + summarize_gamma_errors(pm, "sBIT", pm->sbitlow < 8U, 1/*indexed*/); + + if (fail(pm)) + return; + } + +#ifdef DO_16BIT /* Should be READ_16BIT_SUPPORTED */ + if (pm->test_gamma_scale16) + { + /* The 16 to 8 bit strip operations: */ + init_gamma_errors(pm); + perform_gamma_scale16_tests(pm); + + if (summary) + { + fflush(stderr); + printf("\nGamma correction with 16 to 8 bit reduction:\n"); + printf(" 16 bit gray: %.5f\n", pm->error_gray_16); + printf(" 16 bit color: %.5f\n", pm->error_color_16); + fflush(stdout); + } + + if (fail(pm)) + return; + } +#endif + +#ifdef PNG_READ_BACKGROUND_SUPPORTED + if (pm->test_gamma_background) + { + init_gamma_errors(pm); + + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + { + pm->calculations_use_input_precision = 1; + pm->maxout8 = .499; /* because the 16 bit background is smashed */ + } + perform_gamma_composition_tests(pm, PNG_BACKGROUND_GAMMA_UNIQUE, + pm->test_gamma_expand16); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + pm->maxout8 = maxout8; + + if (summary) + summarize_gamma_errors(pm, "background", 1, 0/*indexed*/); + + if (fail(pm)) + return; + } +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + if (pm->test_gamma_alpha_mode) + { + int do_background; + + init_gamma_errors(pm); + + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + pm->calculations_use_input_precision = 1; + for (do_background = ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD; + do_background <= ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN && !fail(pm); + ++do_background) + perform_gamma_composition_tests(pm, do_background, + pm->test_gamma_expand16); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + + if (summary) + summarize_gamma_errors(pm, "alpha mode", 1, 0/*indexed*/); + + if (fail(pm)) + return; + } +#endif +} +#endif /* PNG_READ_GAMMA_SUPPORTED */ +#endif /* PNG_READ_SUPPORTED */ + +/* INTERLACE MACRO VALIDATION */ +/* This is copied verbatim from the specification, it is simply the pass + * number in which each pixel in each 8x8 tile appears. The array must + * be indexed adam7[y][x] and notice that the pass numbers are based at + * 1, not 0 - the base libpng uses. + */ +static const +png_byte adam7[8][8] = +{ + { 1,6,4,6,2,6,4,6 }, + { 7,7,7,7,7,7,7,7 }, + { 5,6,5,6,5,6,5,6 }, + { 7,7,7,7,7,7,7,7 }, + { 3,6,4,6,3,6,4,6 }, + { 7,7,7,7,7,7,7,7 }, + { 5,6,5,6,5,6,5,6 }, + { 7,7,7,7,7,7,7,7 } +}; + +/* This routine validates all the interlace support macros in png.h for + * a variety of valid PNG widths and heights. It uses a number of similarly + * named internal routines that feed off the above array. + */ +static png_uint_32 +png_pass_start_row(int pass) +{ + int x, y; + ++pass; + for (y=0; y<8; ++y) for (x=0; x<8; ++x) if (adam7[y][x] == pass) + return y; + return 0xf; +} + +static png_uint_32 +png_pass_start_col(int pass) +{ + int x, y; + ++pass; + for (x=0; x<8; ++x) for (y=0; y<8; ++y) if (adam7[y][x] == pass) + return x; + return 0xf; +} + +static int +png_pass_row_shift(int pass) +{ + int x, y, base=(-1), inc=8; + ++pass; + for (y=0; y<8; ++y) for (x=0; x<8; ++x) if (adam7[y][x] == pass) + { + if (base == (-1)) + base = y; + else if (base == y) + {} + else if (inc == y-base) + base=y; + else if (inc == 8) + inc = y-base, base=y; + else if (inc != y-base) + return 0xff; /* error - more than one 'inc' value! */ + } + + if (base == (-1)) return 0xfe; /* error - no row in pass! */ + + /* The shift is always 1, 2 or 3 - no pass has all the rows! */ + switch (inc) + { +case 2: return 1; +case 4: return 2; +case 8: return 3; +default: break; + } + + /* error - unrecognized 'inc' */ + return (inc << 8) + 0xfd; +} + +static int +png_pass_col_shift(int pass) +{ + int x, y, base=(-1), inc=8; + ++pass; + for (x=0; x<8; ++x) for (y=0; y<8; ++y) if (adam7[y][x] == pass) + { + if (base == (-1)) + base = x; + else if (base == x) + {} + else if (inc == x-base) + base=x; + else if (inc == 8) + inc = x-base, base=x; + else if (inc != x-base) + return 0xff; /* error - more than one 'inc' value! */ + } + + if (base == (-1)) return 0xfe; /* error - no row in pass! */ + + /* The shift is always 1, 2 or 3 - no pass has all the rows! */ + switch (inc) + { +case 1: return 0; /* pass 7 has all the columns */ +case 2: return 1; +case 4: return 2; +case 8: return 3; +default: break; + } + + /* error - unrecognized 'inc' */ + return (inc << 8) + 0xfd; +} + +static png_uint_32 +png_row_from_pass_row(png_uint_32 yIn, int pass) +{ + /* By examination of the array: */ + switch (pass) + { +case 0: return yIn * 8; +case 1: return yIn * 8; +case 2: return yIn * 8 + 4; +case 3: return yIn * 4; +case 4: return yIn * 4 + 2; +case 5: return yIn * 2; +case 6: return yIn * 2 + 1; +default: break; + } + + return 0xff; /* bad pass number */ +} + +static png_uint_32 +png_col_from_pass_col(png_uint_32 xIn, int pass) +{ + /* By examination of the array: */ + switch (pass) + { +case 0: return xIn * 8; +case 1: return xIn * 8 + 4; +case 2: return xIn * 4; +case 3: return xIn * 4 + 2; +case 4: return xIn * 2; +case 5: return xIn * 2 + 1; +case 6: return xIn; +default: break; + } + + return 0xff; /* bad pass number */ +} + +static int +png_row_in_interlace_pass(png_uint_32 y, int pass) +{ + /* Is row 'y' in pass 'pass'? */ + int x; + y &= 7; + ++pass; + for (x=0; x<8; ++x) if (adam7[y][x] == pass) + return 1; + + return 0; +} + +static int +png_col_in_interlace_pass(png_uint_32 x, int pass) +{ + /* Is column 'x' in pass 'pass'? */ + int y; + x &= 7; + ++pass; + for (y=0; y<8; ++y) if (adam7[y][x] == pass) + return 1; + + return 0; +} + +static png_uint_32 +png_pass_rows(png_uint_32 height, int pass) +{ + png_uint_32 tiles = height>>3; + png_uint_32 rows = 0; + unsigned int x, y; + + height &= 7; + ++pass; + for (y=0; y<8; ++y) for (x=0; x<8; ++x) if (adam7[y][x] == pass) + { + rows += tiles; + if (y < height) ++rows; + break; /* i.e. break the 'x', column, loop. */ + } + + return rows; +} + +static png_uint_32 +png_pass_cols(png_uint_32 width, int pass) +{ + png_uint_32 tiles = width>>3; + png_uint_32 cols = 0; + unsigned int x, y; + + width &= 7; + ++pass; + for (x=0; x<8; ++x) for (y=0; y<8; ++y) if (adam7[y][x] == pass) + { + cols += tiles; + if (x < width) ++cols; + break; /* i.e. break the 'y', row, loop. */ + } + + return cols; +} + +static void +perform_interlace_macro_validation(void) +{ + /* The macros to validate, first those that depend only on pass: + * + * PNG_PASS_START_ROW(pass) + * PNG_PASS_START_COL(pass) + * PNG_PASS_ROW_SHIFT(pass) + * PNG_PASS_COL_SHIFT(pass) + */ + int pass; + + for (pass=0; pass<7; ++pass) + { + png_uint_32 m, f, v; + + m = PNG_PASS_START_ROW(pass); + f = png_pass_start_row(pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_START_ROW(%d) = %u != %x\n", pass, m, f); + exit(99); + } + + m = PNG_PASS_START_COL(pass); + f = png_pass_start_col(pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_START_COL(%d) = %u != %x\n", pass, m, f); + exit(99); + } + + m = PNG_PASS_ROW_SHIFT(pass); + f = png_pass_row_shift(pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_ROW_SHIFT(%d) = %u != %x\n", pass, m, f); + exit(99); + } + + m = PNG_PASS_COL_SHIFT(pass); + f = png_pass_col_shift(pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_COL_SHIFT(%d) = %u != %x\n", pass, m, f); + exit(99); + } + + /* Macros that depend on the image or sub-image height too: + * + * PNG_PASS_ROWS(height, pass) + * PNG_PASS_COLS(width, pass) + * PNG_ROW_FROM_PASS_ROW(yIn, pass) + * PNG_COL_FROM_PASS_COL(xIn, pass) + * PNG_ROW_IN_INTERLACE_PASS(y, pass) + * PNG_COL_IN_INTERLACE_PASS(x, pass) + */ + for (v=0;;) + { + /* The first two tests overflow if the pass row or column is outside + * the possible range for a 32-bit result. In fact the values should + * never be outside the range for a 31-bit result, but checking for 32 + * bits here ensures that if an app uses a bogus pass row or column + * (just so long as it fits in a 32 bit integer) it won't get a + * possibly dangerous overflow. + */ + /* First the base 0 stuff: */ + if (v < png_pass_rows(0xFFFFFFFFU, pass)) + { + m = PNG_ROW_FROM_PASS_ROW(v, pass); + f = png_row_from_pass_row(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + } + + if (v < png_pass_cols(0xFFFFFFFFU, pass)) + { + m = PNG_COL_FROM_PASS_COL(v, pass); + f = png_col_from_pass_col(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_COL_FROM_PASS_COL(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + } + + m = PNG_ROW_IN_INTERLACE_PASS(v, pass); + f = png_row_in_interlace_pass(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_ROW_IN_INTERLACE_PASS(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + + m = PNG_COL_IN_INTERLACE_PASS(v, pass); + f = png_col_in_interlace_pass(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_COL_IN_INTERLACE_PASS(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + + /* Then the base 1 stuff: */ + ++v; + m = PNG_PASS_ROWS(v, pass); + f = png_pass_rows(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_ROWS(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + + m = PNG_PASS_COLS(v, pass); + f = png_pass_cols(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_COLS(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + + /* Move to the next v - the stepping algorithm starts skipping + * values above 1024. + */ + if (v > 1024) + { + if (v == PNG_UINT_31_MAX) + break; + + v = (v << 1) ^ v; + if (v >= PNG_UINT_31_MAX) + v = PNG_UINT_31_MAX-1; + } + } + } +} + +/* Test color encodings. These values are back-calculated from the published + * chromaticities. The values are accurate to about 14 decimal places; 15 are + * given. These values are much more accurate than the ones given in the spec, + * which typically don't exceed 4 decimal places. This allows testing of the + * libpng code to its theoretical accuracy of 4 decimal places. (If pngvalid + * used the published errors the 'slack' permitted would have to be +/-.5E-4 or + * more.) + * + * The png_modifier code assumes that encodings[0] is sRGB and treats it + * specially: do not change the first entry in this list! + */ +static const color_encoding test_encodings[] = +{ +/* sRGB: must be first in this list! */ +/*gamma:*/ { 1/2.2, +/*red: */ { 0.412390799265959, 0.212639005871510, 0.019330818715592 }, +/*green:*/ { 0.357584339383878, 0.715168678767756, 0.119194779794626 }, +/*blue: */ { 0.180480788401834, 0.072192315360734, 0.950532152249660} }, +/* Kodak ProPhoto (wide gamut) */ +/*gamma:*/ { 1/1.6 /*approximate: uses 1.8 power law compared to sRGB 2.4*/, +/*red: */ { 0.797760489672303, 0.288071128229293, 0.000000000000000 }, +/*green:*/ { 0.135185837175740, 0.711843217810102, 0.000000000000000 }, +/*blue: */ { 0.031349349581525, 0.000085653960605, 0.825104602510460} }, +/* Adobe RGB (1998) */ +/*gamma:*/ { 1/(2+51./256), +/*red: */ { 0.576669042910131, 0.297344975250536, 0.027031361386412 }, +/*green:*/ { 0.185558237906546, 0.627363566255466, 0.070688852535827 }, +/*blue: */ { 0.188228646234995, 0.075291458493998, 0.991337536837639} }, +/* Adobe Wide Gamut RGB */ +/*gamma:*/ { 1/(2+51./256), +/*red: */ { 0.716500716779386, 0.258728243040113, 0.000000000000000 }, +/*green:*/ { 0.101020574397477, 0.724682314948566, 0.051211818965388 }, +/*blue: */ { 0.146774385252705, 0.016589442011321, 0.773892783545073} }, +/* Fake encoding which selects just the green channel */ +/*gamma:*/ { 1.45/2.2, /* the 'Mac' gamma */ +/*red: */ { 0.716500716779386, 0.000000000000000, 0.000000000000000 }, +/*green:*/ { 0.101020574397477, 1.000000000000000, 0.051211818965388 }, +/*blue: */ { 0.146774385252705, 0.000000000000000, 0.773892783545073} }, +}; + +/* signal handler + * + * This attempts to trap signals and escape without crashing. It needs a + * context pointer so that it can throw an exception (call longjmp) to recover + * from the condition; this is handled by making the png_modifier used by 'main' + * into a global variable. + */ +static png_modifier pm; + +static void signal_handler(int signum) +{ + + size_t pos = 0; + char msg[64]; + + pos = safecat(msg, sizeof msg, pos, "caught signal: "); + + switch (signum) + { + case SIGABRT: + pos = safecat(msg, sizeof msg, pos, "abort"); + break; + + case SIGFPE: + pos = safecat(msg, sizeof msg, pos, "floating point exception"); + break; + + case SIGILL: + pos = safecat(msg, sizeof msg, pos, "illegal instruction"); + break; + + case SIGINT: + pos = safecat(msg, sizeof msg, pos, "interrupt"); + break; + + case SIGSEGV: + pos = safecat(msg, sizeof msg, pos, "invalid memory access"); + break; + + case SIGTERM: + pos = safecat(msg, sizeof msg, pos, "termination request"); + break; + + default: + pos = safecat(msg, sizeof msg, pos, "unknown "); + pos = safecatn(msg, sizeof msg, pos, signum); + break; + } + + store_log(&pm.this, NULL/*png_structp*/, msg, 1/*error*/); + + /* And finally throw an exception so we can keep going, unless this is + * SIGTERM in which case stop now. + */ + if (signum != SIGTERM) + { + struct exception_context *the_exception_context = + &pm.this.exception_context; + + Throw &pm.this; + } + + else + exit(1); +} + +/* main program */ +int main(int argc, char **argv) +{ + int summary = 1; /* Print the error summary at the end */ + int memstats = 0; /* Print memory statistics at the end */ + + /* Create the given output file on success: */ + const char *touch = NULL; + + /* This is an array of standard gamma values (believe it or not I've seen + * every one of these mentioned somewhere.) + * + * In the following list the most useful values are first! + */ + static double + gammas[]={2.2, 1.0, 2.2/1.45, 1.8, 1.5, 2.4, 2.5, 2.62, 2.9}; + + /* This records the command and arguments: */ + size_t cp = 0; + char command[1024]; + + anon_context(&pm.this); + + gnu_volatile(summary) + gnu_volatile(memstats) + gnu_volatile(touch) + + /* Add appropriate signal handlers, just the ANSI specified ones: */ + signal(SIGABRT, signal_handler); + signal(SIGFPE, signal_handler); + signal(SIGILL, signal_handler); + signal(SIGINT, signal_handler); + signal(SIGSEGV, signal_handler); + signal(SIGTERM, signal_handler); + +#ifdef HAVE_FEENABLEEXCEPT + /* Only required to enable FP exceptions on platforms where they start off + * disabled; this is not necessary but if it is not done pngvalid will likely + * end up ignoring FP conditions that other platforms fault. + */ + feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); +#endif + + modifier_init(&pm); + + /* Preallocate the image buffer, because we know how big it needs to be, + * note that, for testing purposes, it is deliberately mis-aligned by tag + * bytes either side. All rows have an additional five bytes of padding for + * overwrite checking. + */ + store_ensure_image(&pm.this, NULL, 2, TRANSFORM_ROWMAX, TRANSFORM_HEIGHTMAX); + + /* Don't give argv[0], it's normally some horrible libtool string: */ + cp = safecat(command, sizeof command, cp, "pngvalid"); + + /* Default to error on warning: */ + pm.this.treat_warnings_as_errors = 1; + + /* Default assume_16_bit_calculations appropriately; this tells the checking + * code that 16-bit arithmetic is used for 8-bit samples when it would make a + * difference. + */ + pm.assume_16_bit_calculations = PNG_LIBPNG_VER >= 10700; + + /* Currently 16 bit expansion happens at the end of the pipeline, so the + * calculations are done in the input bit depth not the output. + * + * TODO: fix this + */ + pm.calculations_use_input_precision = 1U; + + /* Store the test gammas */ + pm.gammas = gammas; + pm.ngammas = ARRAY_SIZE(gammas); + pm.ngamma_tests = 0; /* default to off */ + + /* Low bit depth gray images don't do well in the gamma tests, until + * this is fixed turn them off for some gamma cases: + */ +# ifdef PNG_WRITE_tRNS_SUPPORTED + pm.test_tRNS = 1; +# endif + pm.test_lbg = PNG_LIBPNG_VER >= 10600; + pm.test_lbg_gamma_threshold = 1; + pm.test_lbg_gamma_transform = PNG_LIBPNG_VER >= 10600; + pm.test_lbg_gamma_sbit = 1; + pm.test_lbg_gamma_composition = PNG_LIBPNG_VER >= 10700; + + /* And the test encodings */ + pm.encodings = test_encodings; + pm.nencodings = ARRAY_SIZE(test_encodings); + +# if PNG_LIBPNG_VER < 10700 + pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */ +# else + pm.sbitlow = 1U; +# endif + + /* The following allows results to pass if they correspond to anything in the + * transformed range [input-.5,input+.5]; this is is required because of the + * way libpng treates the 16_TO_8 flag when building the gamma tables in + * releases up to 1.6.0. + * + * TODO: review this + */ + pm.use_input_precision_16to8 = 1U; + pm.use_input_precision_sbit = 1U; /* because libpng now rounds sBIT */ + + /* Some default values (set the behavior for 'make check' here). + * These values simply control the maximum error permitted in the gamma + * transformations. The practical limits for human perception are described + * below (the setting for maxpc16), however for 8 bit encodings it isn't + * possible to meet the accepted capabilities of human vision - i.e. 8 bit + * images can never be good enough, regardless of encoding. + */ + pm.maxout8 = .1; /* Arithmetic error in *encoded* value */ + pm.maxabs8 = .00005; /* 1/20000 */ + pm.maxcalc8 = 1./255; /* +/-1 in 8 bits for compose errors */ + pm.maxpc8 = .499; /* I.e., .499% fractional error */ + pm.maxout16 = .499; /* Error in *encoded* value */ + pm.maxabs16 = .00005;/* 1/20000 */ + pm.maxcalc16 =1./65535;/* +/-1 in 16 bits for compose errors */ +# if PNG_LIBPNG_VER < 10700 + pm.maxcalcG = 1./((1<38149 by the following: + */ + pm.maxpc16 = .005; /* I.e., 1/200% - 1/20000 */ + + /* Now parse the command line options. */ + while (--argc >= 1) + { + int catmore = 0; /* Set if the argument has an argument. */ + + /* Record each argument for posterity: */ + cp = safecat(command, sizeof command, cp, " "); + cp = safecat(command, sizeof command, cp, *++argv); + + if (strcmp(*argv, "-v") == 0) + pm.this.verbose = 1; + + else if (strcmp(*argv, "-l") == 0) + pm.log = 1; + + else if (strcmp(*argv, "-q") == 0) + summary = pm.this.verbose = pm.log = 0; + + else if (strcmp(*argv, "-w") == 0 || + strcmp(*argv, "--strict") == 0) + pm.this.treat_warnings_as_errors = 1; /* NOTE: this is the default! */ + + else if (strcmp(*argv, "--nostrict") == 0) + pm.this.treat_warnings_as_errors = 0; + + else if (strcmp(*argv, "--speed") == 0) + pm.this.speed = 1, pm.ngamma_tests = pm.ngammas, pm.test_standard = 0, + summary = 0; + + else if (strcmp(*argv, "--memory") == 0) + memstats = 1; + + else if (strcmp(*argv, "--size") == 0) + pm.test_size = 1; + + else if (strcmp(*argv, "--nosize") == 0) + pm.test_size = 0; + + else if (strcmp(*argv, "--standard") == 0) + pm.test_standard = 1; + + else if (strcmp(*argv, "--nostandard") == 0) + pm.test_standard = 0; + + else if (strcmp(*argv, "--transform") == 0) + pm.test_transform = 1; + + else if (strcmp(*argv, "--notransform") == 0) + pm.test_transform = 0; + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED + else if (strncmp(*argv, "--transform-disable=", + sizeof "--transform-disable") == 0) + { + pm.test_transform = 1; + transform_disable(*argv + sizeof "--transform-disable"); + } + + else if (strncmp(*argv, "--transform-enable=", + sizeof "--transform-enable") == 0) + { + pm.test_transform = 1; + transform_enable(*argv + sizeof "--transform-enable"); + } +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + + else if (strcmp(*argv, "--gamma") == 0) + { + /* Just do two gamma tests here (2.2 and linear) for speed: */ + pm.ngamma_tests = 2U; + pm.test_gamma_threshold = 1; + pm.test_gamma_transform = 1; + pm.test_gamma_sbit = 1; + pm.test_gamma_scale16 = 1; + pm.test_gamma_background = 1; /* composition */ + pm.test_gamma_alpha_mode = 1; + } + + else if (strcmp(*argv, "--nogamma") == 0) + pm.ngamma_tests = 0; + + else if (strcmp(*argv, "--gamma-threshold") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_threshold = 1; + + else if (strcmp(*argv, "--nogamma-threshold") == 0) + pm.test_gamma_threshold = 0; + + else if (strcmp(*argv, "--gamma-transform") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_transform = 1; + + else if (strcmp(*argv, "--nogamma-transform") == 0) + pm.test_gamma_transform = 0; + + else if (strcmp(*argv, "--gamma-sbit") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_sbit = 1; + + else if (strcmp(*argv, "--nogamma-sbit") == 0) + pm.test_gamma_sbit = 0; + + else if (strcmp(*argv, "--gamma-16-to-8") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_scale16 = 1; + + else if (strcmp(*argv, "--nogamma-16-to-8") == 0) + pm.test_gamma_scale16 = 0; + + else if (strcmp(*argv, "--gamma-background") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_background = 1; + + else if (strcmp(*argv, "--nogamma-background") == 0) + pm.test_gamma_background = 0; + + else if (strcmp(*argv, "--gamma-alpha-mode") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_alpha_mode = 1; + + else if (strcmp(*argv, "--nogamma-alpha-mode") == 0) + pm.test_gamma_alpha_mode = 0; + + else if (strcmp(*argv, "--expand16") == 0) + pm.test_gamma_expand16 = 1; + + else if (strcmp(*argv, "--noexpand16") == 0) + pm.test_gamma_expand16 = 0; + + else if (strcmp(*argv, "--low-depth-gray") == 0) + pm.test_lbg = pm.test_lbg_gamma_threshold = + pm.test_lbg_gamma_transform = pm.test_lbg_gamma_sbit = + pm.test_lbg_gamma_composition = 1; + + else if (strcmp(*argv, "--nolow-depth-gray") == 0) + pm.test_lbg = pm.test_lbg_gamma_threshold = + pm.test_lbg_gamma_transform = pm.test_lbg_gamma_sbit = + pm.test_lbg_gamma_composition = 0; + +# ifdef PNG_WRITE_tRNS_SUPPORTED + else if (strcmp(*argv, "--tRNS") == 0) + pm.test_tRNS = 1; +# endif + + else if (strcmp(*argv, "--notRNS") == 0) + pm.test_tRNS = 0; + + else if (strcmp(*argv, "--more-gammas") == 0) + pm.ngamma_tests = 3U; + + else if (strcmp(*argv, "--all-gammas") == 0) + pm.ngamma_tests = pm.ngammas; + + else if (strcmp(*argv, "--progressive-read") == 0) + pm.this.progressive = 1; + + else if (strcmp(*argv, "--use-update-info") == 0) + ++pm.use_update_info; /* Can call multiple times */ + + else if (strcmp(*argv, "--interlace") == 0) + { +# if CAN_WRITE_INTERLACE + pm.interlace_type = PNG_INTERLACE_ADAM7; +# else /* !CAN_WRITE_INTERLACE */ + fprintf(stderr, "pngvalid: no write interlace support\n"); + return SKIP; +# endif /* !CAN_WRITE_INTERLACE */ + } + + else if (strcmp(*argv, "--use-input-precision") == 0) + pm.use_input_precision = 1U; + + else if (strcmp(*argv, "--use-calculation-precision") == 0) + pm.use_input_precision = 0; + + else if (strcmp(*argv, "--calculations-use-input-precision") == 0) + pm.calculations_use_input_precision = 1U; + + else if (strcmp(*argv, "--assume-16-bit-calculations") == 0) + pm.assume_16_bit_calculations = 1U; + + else if (strcmp(*argv, "--calculations-follow-bit-depth") == 0) + pm.calculations_use_input_precision = + pm.assume_16_bit_calculations = 0; + + else if (strcmp(*argv, "--exhaustive") == 0) + pm.test_exhaustive = 1; + + else if (argc > 1 && strcmp(*argv, "--sbitlow") == 0) + --argc, pm.sbitlow = (png_byte)atoi(*++argv), catmore = 1; + + else if (argc > 1 && strcmp(*argv, "--touch") == 0) + --argc, touch = *++argv, catmore = 1; + + else if (argc > 1 && strncmp(*argv, "--max", 5) == 0) + { + --argc; + + if (strcmp(5+*argv, "abs8") == 0) + pm.maxabs8 = atof(*++argv); + + else if (strcmp(5+*argv, "abs16") == 0) + pm.maxabs16 = atof(*++argv); + + else if (strcmp(5+*argv, "calc8") == 0) + pm.maxcalc8 = atof(*++argv); + + else if (strcmp(5+*argv, "calc16") == 0) + pm.maxcalc16 = atof(*++argv); + + else if (strcmp(5+*argv, "out8") == 0) + pm.maxout8 = atof(*++argv); + + else if (strcmp(5+*argv, "out16") == 0) + pm.maxout16 = atof(*++argv); + + else if (strcmp(5+*argv, "pc8") == 0) + pm.maxpc8 = atof(*++argv); + + else if (strcmp(5+*argv, "pc16") == 0) + pm.maxpc16 = atof(*++argv); + + else + { + fprintf(stderr, "pngvalid: %s: unknown 'max' option\n", *argv); + exit(99); + } + + catmore = 1; + } + + else if (strcmp(*argv, "--log8") == 0) + --argc, pm.log8 = atof(*++argv), catmore = 1; + + else if (strcmp(*argv, "--log16") == 0) + --argc, pm.log16 = atof(*++argv), catmore = 1; + +#ifdef PNG_SET_OPTION_SUPPORTED + else if (strncmp(*argv, "--option=", 9) == 0) + { + /* Syntax of the argument is